Re: music2xml script, musicexp.py, self.short_indent/char_per_cm, and a division by zero
Jean Abou Samra <[email protected]>
| Newsgroups | gmane.comp.gnu.lilypond.bugs |
|---|---|
| Message-ID | <[email protected]> |
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
OpenPGP_signature
(application/pgp-signature, 236 B) - not displayed