Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-111972: unicode: Make ucnhash_capicapsule initialization thread-safe #112249

Merged
merged 6 commits into from
Nov 30, 2023

Conversation

Eclips4
Copy link
Member

@Eclips4 Eclips4 commented Nov 18, 2023

Copy link
Contributor

@colesbury colesbury left a comment

Choose a reason for hiding this comment

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

I think we also need to handle the case 'N' in _PyUnicode_DecodeUnicodeEscapeInternal.

Python/codecs.c Outdated Show resolved Hide resolved
@Eclips4
Copy link
Member Author

Eclips4 commented Nov 19, 2023

Should we do something with _PyUnicode_Fini?

cpython/Objects/unicodeobject.c

Lines 15445 to 15460 in 14fd86a

void
_PyUnicode_Fini(PyInterpreterState *interp)
{
struct _Py_unicode_state *state = &interp->unicode;
// _PyUnicode_ClearInterned() must be called before _PyUnicode_Fini()
assert(get_interned_dict(interp) == NULL);
_PyUnicode_FiniEncodings(&state->fs_codec);
// bpo-47182: force a unicodedata CAPI capsule re-import on
// subsequent initialization of interpreter.
interp->unicode.ucnhash_capi = NULL;
unicode_clear_identifiers(state);
}

Copy link
Contributor

@colesbury colesbury left a comment

Choose a reason for hiding this comment

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

_PyUnicode_Fini looks fine. I don't think it needs any special handling.

Lib/test/test_unicodedata.py Outdated Show resolved Hide resolved
@colesbury
Copy link
Contributor

@erlend-aasland, would you please review this when you get a chance?

@erlend-aasland erlend-aasland merged commit 0785c68 into python:main Nov 30, 2023
34 checks passed
@erlend-aasland
Copy link
Contributor

Thanks for the PR, Kirill, and thanks for the review, Sam!

@Eclips4 Eclips4 deleted the issue-111972 branch November 30, 2023 10:15
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
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.

unicode: make ucnhash_capi initialization thread-safe in --disable-gil builds
4 participants