Skip to content

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

Merged
erlend-aasland merged 6 commits into
python:mainfrom
Eclips4:issue-111972
Nov 30, 2023
Merged

gh-111972: unicode: Make ucnhash_capicapsule initialization thread-safe#112249
erlend-aasland merged 6 commits into
python:mainfrom
Eclips4:issue-111972

Conversation

@Eclips4

@Eclips4Eclips4 commented Nov 18, 2023

Copy link
Copy Markdown
Member

@colesburycolesbury left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadPython/codecs.c Outdated
@Eclips4

Copy link
Copy Markdown
MemberAuthor

Should we do something with _PyUnicode_Fini?

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);
}

@colesburycolesbury left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadLib/test/test_unicodedata.py Outdated
@colesbury

Copy link
Copy Markdown
Contributor

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

@erlend-aasland

Copy link
Copy Markdown
Contributor

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

@Eclips4
Eclips4 deleted the issue-111972 branch November 30, 2023 10:15
Comment threadObjects/unicodeobject.c
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 freeto 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

@Eclips4@colesbury@erlend-aasland@vstinner