gh-111972: unicode: Make `ucnhash_capi`capsule initialization thread-safe by Eclips4 · Pull Request #112249 · python/cpython

@Eclips4

@Eclips4

colesbury

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.

@Eclips4

@Eclips4

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

@Eclips4

@Eclips4

colesbury

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.

@Eclips4

@Eclips4

colesbury

@colesbury

erlend-aasland

@erlend-aasland

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

vstinner

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