Skip to content

Keyboard braille: extractHeading passes a KeySignature where a TimeSignature is expected (isinstance tested on the container) #1986

Open

Description

@jpsmith8488

Environment: music21 10.5.0, Python 3.14, macOS.

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]
except IndexError:
    if isinstance(useElement, key.KeySignature):   # container, never true
        keySignature = 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.

Activity

  1. mscuthbert commented on Jul 22, 2026

    @mscuthbert
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions