You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Keyboard braille: extractHeading passes a KeySignature where a TimeSignature is expected (isinstance tested on the container) #1986
Summary:BrailleGrandSegment.extractHeading (braille/segment.py, the SIGNATURE branch) tests isinstance on the grouping container instead of the element:
try:
keySignature, timeSignature=useElement[0], useElement[1]
exceptIndexError:
ifisinstance(useElement, key.KeySignature): # container, never truekeySignature=useElement[0]
else:
timeSignature=useElement[0] # a lone KeySignature lands here
useElement is a grouping (list-like), never a KeySignature, so a mid-piece key change with no simultaneous meter change (a SIGNATURE grouping holding only a KeySignature) falls into the else, is passed to transcribeSignatures, which reads m21TimeSignature.symbol (braille/basic.py) → AttributeError: 'KeySignature' object has no attribute 'symbol', aborting the transcription.
Fix sketch: test the element rather than the container: isinstance(useElement[0], key.KeySignature).
Reproduction sketch: a two-part keyboard score with a key change (no meter change) at an interior measure, transcribed via braille.translate.keyboardPartsToBraille.
Related, found while tracing: the warning path of handleArticulations (braille/basic.py) references music21Note.editorial.fingering, which does not exist — the except branch itself raises AttributeError when a fingering fails to transcribe.
useElement is always a BrailleElementGrouping according to current typing, so this makes sense -- clearly this is code that originally expected a single element (hence the name useElement and not useGrouping) and was designed for a bit to work with either an Element or a Grouping. It seems very brittle. I think best would be to replace all that code with something that gets the first keySignature object from the grouping and gets the first timeSignature object from the grouping, without making any assumptions about ordering etc.
Activity
mscuthbert commentedon Jul 22, 2026
useElement is always a BrailleElementGrouping according to current typing, so this makes sense -- clearly this is code that originally expected a single element (hence the name useElement and not useGrouping) and was designed for a bit to work with either an Element or a Grouping. It seems very brittle. I think best would be to replace all that code with something that gets the first keySignature object from the grouping and gets the first timeSignature object from the grouping, without making any assumptions about ordering etc.