From 31de3540e46c7b587a79b8684665bffa509367e8 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Wed, 10 Oct 2007 15:00:03 +0200 Subject: [PATCH] MusicXML: Add sanity check before setting a duration --- scripts/musicxml2ly.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index b31511a291..e07584eae2 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -156,7 +156,14 @@ def rational_to_lily_duration (rational_len): d = musicexp.Duration () d.duration_log = {1: 0, 2: 1, 4:2, 8:3, 16:4, 32:5, 64:6, 128:7, 256:8, 512:9}.get (rational_len.denominator (), -1) d.factor = Rational (rational_len.numerator ()) - return d + if d.duration_log < 0: + error_message ("Encountered rational duration with denominator %s, " + "unable to convert to lilypond duration" % + rational_len.denominator ()) + # TODO: Test the above error message + return None + else: + return d def musicxml_partial_to_lily (partial_len): if partial_len > 0: -- 2.39.5