Skip to content

gh-155292: Skip updating unicodedata with mismatched interpreter - #157066

Open
encukou wants to merge 4 commits into
python:mainfrom
encukou:fix-makeunicode-update
Open

gh-155292: Skip updating unicodedata with mismatched interpreter#157066
encukou wants to merge 4 commits into
python:mainfrom
encukou:fix-makeunicode-update

Conversation

@encukou

@encukou encukou commented Sep 7, 2026

Copy link
Copy Markdown
Member

mkstringprep uses things like str.lower(), so it generates the wrong
result if run in an interpreter with a different Unicode data version
than the target.

This means that updating the Unicode version is a two-step process:
run makeunicodedata.py, then compile, then run mkstringprep.py.

The two steps can (and should) be combined when re-running
regen-unicodedata to verify that the data is up to date.
The #155292 fix only considered that case.

Change makeunicodedata.py to only run mkstringprep.py when the
current interpreter is up to it. Otherwise, show a reminder.

For an extra complication, download the input (rcf3454.txt) in
the "first step", since an out-of-date stringprep.py's freshness
assertion may break URL encoding in urllib.

mkstringprep uses things like str.lower(), so it generates the wrong
result if run in an interpreter with a different Unicode data version
than the target.

This means that updating the Unicode version is a two-step process:
run makeunicodedata.py, then compile, then run mkstringprep.py.

The two steps can (and should) be combined when re-running
regen-unicodedata to verify that the data is up to date.
The pythonGH-155292 fix only considered that case.

Change makeunicodedata.py to only run mkstringprep.py when the
current interpreter is up to it. Otherwise, show a reminder.

As an extra complication, download the input (RFC 3454) in
the "first step", since an out-of-date stringprep.py's freshness
assertion may prevent downloads.
data_file = open(FILENAME, encoding='utf-8')

with data_file:
with open("Tools/unicode/data/rfc3454.txt", encoding='utf-8') as data_file:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured we don't need the urllib call here: you shouldn't hit this in the usual case, and if you do, the FileNotFoundError makes it clear that you need rfc3454.txt and where to put it.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant