Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundLocalError: local variable 'val' referenced before assignment #80

Open
wbsoft opened this issue Feb 14, 2017 · 2 comments
Open

Comments

@wbsoft
Copy link
Collaborator

wbsoft commented Feb 14, 2017

Reported by a Frescobaldi user:

Exporting the following file to MusicXML

\version "2.19.49"
\language "english"

origBreak = { \break }

ThirdTune =
\relative {
   \repeat volta 2 {
     \time 4/4
     \key g \major
     | e''4 e g8 e d b
     | e8 d b a d4 b
     | e4 e g8 e g4
     | a2 g
     \origBreak
     | e4 e g8 e d b
     | e8 d b a d4 b
     | e4 d8 b d b a g
     | b8 a g4 e2
     \origBreak
   }
   \repeat volta 2 {
     | b'4 a8 g e4 b'
     | a8 g e g a4 b
     | d2 cs2
     | c2 a
     | b4 a8 g e4 b'
     \origBreak
     | a8 g e d g4 e
   }
   \alternative {
     {
       | b4 d8 d b4 d
       | ds4 b ds8 fs a4
     }
     {
       | g8 c c c b4 g
       | a8 fs d4 e2
     }
   }
}

ThirdTuneChords = \chordmode {
   \repeat volta 2 {
     | e1:m s s a2 g
     | e1:m s e2:m d b:7 e:m
     | e1:m s d2 a c b:7 e1:m
     | s1
   }
   \alternative {
     { d1 b1:7 }
     { c2 g d e:m }
   }
}

\score {
   <<
     \new ChordNames \ThirdTuneChords
     \new Staff { \clef treble \ThirdTune }
   >>  
   \layout {
     indent = 0 \in
     \override Score.BarNumber.break-visibility = #'#(#f #f #f)
   }
}

results in:

File "/usr/lib/python3/dist-packages/ly/musicxml/lymus2musxml.py", line 
96, in parse_text
self.parse_document(doc)
File "/usr/lib/python3/dist-packages/ly/musicxml/lymus2musxml.py", line 
109, in parse_document
self.parse_tree(mustree)
File "/usr/lib/python3/dist-packages/ly/musicxml/lymus2musxml.py", line 
123, in parse_tree
self.parse_nodes(mus_nodes)
File "/usr/lib/python3/dist-packages/ly/musicxml/lymus2musxml.py", line 
135, in parse_nodes
func_call(m)
File "/usr/lib/python3/dist-packages/ly/musicxml/lymus2musxml.py", line 
173, in Assignment
self.mediator.new_header_assignment(a.name(), val)
UnboundLocalError: local variable 'val' referenced before assignment
@prabhanshuguptagit
Copy link

I attempted solving the issue and found this happening because of the indent command in the layout block.

indent = 0 \in

It leads to this node <Assignment 'indent'> being generated in the tree. There is no case in the ParseSource.Assignment method for handling this node. The code works well without the indent statement.

I think this can be handled by adding a condition in the Assignment method. What could the indent command be translated to in MusicXML?

@uliska
Copy link
Collaborator

uliska commented Mar 7, 2017

Looking at ParseSource.Assignment() I have the impression that this indent shouldn't reach this in the first place. But that's just a guess.
@PeterBjuhr could you have a look please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants