Skip to content

RomanNumerals reject x/y/z in figures; use ⑪⑬⑮ as internal placeholders - #1998

Merged
mscuthbert merged 1 commit into
masterfrom
rn-xy
Aug 10, 2026
Merged

RomanNumerals reject x/y/z in figures; use ⑪⑬⑮ as internal placeholders#1998
mscuthbert merged 1 commit into
masterfrom
rn-xy

Conversation

@mscuthbert

Copy link
Copy Markdown
Member

A user on another site noticed that things like "IIIx" get interpreted as E-G#-B-D-F-A -- a III13 chord.

Why? RomanNumeral.expandShortHand() collapsed the two-digit figures 11, 13, and 15 to the single characters x, y, and z so that SHORTHAND_RE would find each as one group. That leaked: RomanNumeral('Ix') parsed as I11, 'Iy' as I13 (and Iz as C4 C4!). Since x/y/z passed the isalnum() figure validation.

The placeholders are now ⑪ ⑬ ⑮, which read in the code as the numbers they stand for, but they are turned back at the end. Creating a figure containing x, y, or z raises RomanNumeralException an construction (No real figure uses those letters: clercqTemperley rewrites its 'x' to 'o' before constructing a RomanNumeral, and no corpus RomanText file has one.)

Misc: Also strengthens the AGENTS.md / writing-docs rule that regression cases belong in unittests, not docstrings. -- my agent keeps wanting to document bugs and things not to do for all time! nope!

AI-assisted (Claude)

expandShortHand() collapsed the two-digit figures 11, 13, and 15 to the
single characters x, y, and z so that SHORTHAND_RE would find each as one
group. That leaked: RomanNumeral('Ix') parsed as I11, 'Iy' as I13, and
'Iz' as a nonsensical two-note C4 C4 chord, since x/y/z pass the
isalnum() figure validation.

The placeholders are now ⑪ ⑬ ⑮, which read as the numbers they stand for,
and a figure containing x, y, or z raises RomanNumeralException. No real
figure uses those letters: clercqTemperley rewrites its 'x' to 'o' before
constructing a RomanNumeral, and no corpus RomanText file has one.

Also strengthens the AGENTS.md / writing-docs rule that regression cases
belong in unittests, not docstrings.

AI-assisted (Claude)
@mscuthbert mscuthbert added the bug label Aug 10, 2026
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 93.326%. remained the same — rn-xy into master

@mscuthbert
mscuthbert merged commit 7c09bdd into master Aug 10, 2026
7 checks passed
@mscuthbert
mscuthbert deleted the rn-xy branch August 11, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants