@@ -655,6 +655,11 @@ def mark_diffs(
655655 if t .TYPE_CHECKING :
656656 assert noteOrChord2 is not None
657657 if len (op ) >= 5 and op [4 ] is not None :
658+ if not isinstance (noteOrChord2 , m21 .chord .ChordBase ):
659+ # Can happen if imported xml has repeated xml:id values,
660+ # so getElementById returns an unexpected GeneralNote.
661+ # Don't crash, but we won't color the note either.
662+ continue
658663 note2 = noteOrChord2 .notes [op [4 ]]
659664 else :
660665 note2 = noteOrChord2
@@ -676,6 +681,11 @@ def mark_diffs(
676681 if t .TYPE_CHECKING :
677682 assert noteOrChord1 is not None
678683 if len (op ) >= 5 and op [4 ] is not None :
684+ if not isinstance (noteOrChord1 , m21 .chord .ChordBase ):
685+ # Can happen if imported xml has repeated xml:id values,
686+ # so getElementById returns an unexpected GeneralNote.
687+ # Don't crash, but we won't color the note either.
688+ continue
679689 note1 = noteOrChord1 .notes [op [4 ]]
680690 else :
681691 note1 = noteOrChord1
@@ -2365,6 +2375,11 @@ def get_text_output(
23652375 if t .TYPE_CHECKING :
23662376 assert noteOrChord2 is not None
23672377 if len (op ) >= 5 and op [4 ] is not None :
2378+ if not isinstance (noteOrChord2 , m21 .chord .ChordBase ):
2379+ # Can happen if imported xml has repeated xml:id values,
2380+ # so getElementById returns an unexpected GeneralNote.
2381+ # Don't crash, but we won't color the note either.
2382+ continue
23682383 note2 = noteOrChord2 .notes [op [4 ]]
23692384 else :
23702385 note2 = noteOrChord2
@@ -2384,6 +2399,11 @@ def get_text_output(
23842399 if t .TYPE_CHECKING :
23852400 assert noteOrChord1 is not None
23862401 if len (op ) >= 5 and op [4 ] is not None :
2402+ if not isinstance (noteOrChord1 , m21 .chord .ChordBase ):
2403+ # Can happen if imported xml has repeated xml:id values,
2404+ # so getElementById returns an unexpected GeneralNote.
2405+ # Don't crash, but we won't color the note either.
2406+ continue
23872407 note1 = noteOrChord1 .notes [op [4 ]]
23882408 else :
23892409 note1 = noteOrChord1
0 commit comments