Skip to content

MusicXML export fails on "check_simultan self.sections.pop()" #76

Closed

Description

@ExecutorElassus

I have the following file
transkription kayser 6. messe d-moll - flattened.ly.zip

Export to MusicXML fails with the following error:

Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/frescobaldi_app/file_export/__init__.py", line 65, in exportMusicXML
    writer.parse_text(doc.toPlainText())
  File "/usr/lib64/python2.7/site-packages/ly/musicxml/lymus2musxml.py", line 102, in parse_text
    self.parse_document(doc)
  File "/usr/lib64/python2.7/site-packages/ly/musicxml/lymus2musxml.py", line 119, in parse_document
    self.parse_tree(mustree)
  File "/usr/lib64/python2.7/site-packages/ly/musicxml/lymus2musxml.py", line 133, in parse_tree
    self.parse_nodes(mus_nodes)
  File "/usr/lib64/python2.7/site-packages/ly/musicxml/lymus2musxml.py", line 145, in parse_nodes
    func_call(m)
  File "/usr/lib64/python2.7/site-packages/ly/musicxml/lymus2musxml.py", line 624, in End
    self.mediator.check_simultan()
  File "/usr/lib64/python2.7/site-packages/ly/musicxml/ly2xml_mediator.py", line 293, in check_simultan
    self.sections.pop()
IndexError: pop from empty list

(the \includes in that file are all layout/font options. The entire file tree can be found here).

What is going wrong here? Is there some issue of formatting that isn't being correctly interpreted?

Thanks for the help

Activity

  1. uliska commented on Oct 23, 2016

    @uliska
    Collaborator

    Note that this file can only be compiled in the original context as otherwise the includes cannot be resolved.

    I suspected this failed include could be the reason but when placing the flattened file in the original context a) it became compilable and b) the MusicXML export fails with the same message. So this is not the issue.

    The other thing is that I tried that with python-ly from Git (where the OP obviously has the packaged version), and the error is the same. So that isn't a reason either.

  2. mtarenskeen commented on Nov 6, 2019

    @mtarenskeen

    I bumped into this bug when trying a very simple test:

    1. create a very simple minimal.ly test with for example only { c' d' e' f' }
    2. ly musicxml minimal.ly -o minimal.musicxml
    3. musicxml2ly minimal.musicxml -o minimal2.ly
    4. ly musicxml minimal2.ly -o minimal2.musicxml

    Unknown command: \mergeDifferentlyDottedOn
    Unknown command: \mergeDifferentlyHeadedOn
    Warning: End not implemented!
    'NoneType' object has no attribute 'merge_voice'
    Traceback (most recent call last):
    File "/usr/bin/ly", line 4, in
    sys.exit(main())
    File "/usr/lib/python3.7/site-packages/ly/cli/main.py", line 288, in main
    c.run(options, cursor, output)
    File "/usr/lib/python3.7/site-packages/ly/cli/command.py", line 221, in run
    writer.parse_document(cursor.document, absolute)
    File "/usr/lib/python3.7/site-packages/ly/musicxml/lymus2musxml.py", line 119, in parse_document
    self.parse_tree(mustree)
    File "/usr/lib/python3.7/site-packages/ly/musicxml/lymus2musxml.py", line 133, in parse_tree
    self.parse_nodes(mus_nodes)
    File "/usr/lib/python3.7/site-packages/ly/musicxml/lymus2musxml.py", line 145, in parse_nodes
    func_call(m)
    File "/usr/lib/python3.7/site-packages/ly/musicxml/lymus2musxml.py", line 624, in End
    self.mediator.check_simultan()
    File "/usr/lib/python3.7/site-packages/ly/musicxml/ly2xml_mediator.py", line 293, in check_simultan
    self.sections.pop()
    IndexError: pop from empty list

  3. mtarenskeen commented on Nov 6, 2019

    @mtarenskeen

    As a workaround I changed line 293 in ly2xml_mediator.py. I am not enough of a Python programmer to judge if this makes any sense, but it worked for me now.

            # self.sections.pop()
            if self.sections:
                self.sections.pop()
    
    
  4. shoorick commented on Apr 23, 2022

    @shoorick

    The same situation in 2022. As written in previous comment it's possible to patch /usr/lib/python3/dist-packages/ly/musicxml/ly2xml_mediator.py — different lines but the same code

    301c301,302
    <         self.sections.pop()
    ---
    >         if self.sections:
    >             self.sections.pop()
  5. fedelibre commented on Feb 6, 2026

    @fedelibre
    Member

    It's probably a workaround to avoid the error, but not the best solution to fix the underlying bug. I'm not able to help.

  6. bmjcode commented on Feb 7, 2026

    @bmjcode
    Member

    @fedelibre Testing that self.sections isn't empty before pop()-ing it is basic defensive programming. It should be in there regardless of whether there's another underlying bug. I just merged #184 which should hopefully fix this.

  7. fedelibre commented on Apr 1, 2026

    @fedelibre
    Member

    Fixed by #184

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions