bug-lilypond
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: music2xml script, musicexp.py, self.short_indent/char_per_cm, and a


From: Jean Abou Samra
Subject: Re: music2xml script, musicexp.py, self.short_indent/char_per_cm, and a division by zero
Date: Sat, 14 Jan 2023 00:01:00 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0



Le 30/12/2022 à 15:09, James Wilkinson a écrit :
Hello everyone,

Firstly, thank you for all your work on Lilypond, and a very Happy New
Year!

I hope this is the right place to report bugs with musicxml2ly (version
2.23.82, from Fedora).

In musicexp.py, in class Paper, def print_ly(self, printer), there is
this snippet:

         char_per_cm = (len(self.get_longest_instrument_name())
                        * 13) / self.page_width
         if self.indent != 0:
             self.print_length_field(printer, "indent", self.indent/char_per_cm)
         if self.short_indent != 0:
             self.print_length_field(
                 printer, "short-indent", self.short_indent/char_per_cm)

It’s possible for there not to be a longest instrument name, char_per_cm
to be zero, self.short_indent not to be zero, and the final division to
raise a divide-by-zero error. A very minimal “fix” of
         if self.short_indent != 0 and char_per_cm != 0:
enabled me to run the conversion.

The error message from the original version was this:

$ musicxml2ly Good_Christian_Men.mxl
musicxml2ly: Reading MusicXML from Good_Christian_Men.mxl ...
musicxml2ly: Input file Good_Christian_Men.mxl is compressed, extracting raw 
MusicXML data
musicxml2ly: Converting to LilyPond expressions...
musicxml2ly: Converting to LilyPond expressions...
musicxml2ly: Converting to LilyPond expressions...
musicxml2ly: Converting to LilyPond expressions...
musicxml2ly: Output to `Good_Christian_Men.ly'
Traceback (most recent call last):
   File "/usr/bin/musicxml2ly", line 3482, in <module>
     main()
   File "/usr/bin/musicxml2ly", line 3475, in main
     voices = convert(filename, options)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/bin/musicxml2ly", line 3372, in convert
     paper_information.print_ly(printer)
   File "/usr/share/lilypond/2.23.82/python/musicexp.py", line 1026, in print_ly
     printer, "short-indent", self.short_indent/char_per_cm)
                              ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
ZeroDivisionError: float division by zero

The file is available at
https://www.cpdl.org/wiki/images/f/f9/Good_Christian_Men.mxl .

Thanks for your time, and hope this helps,





Thanks, this is now https://gitlab.com/lilypond/lilypond/-/issues/6518

Since the fix looks quite simple, would you be willing to submit the corresponding patch yourself?

Best,
Jean

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]