mirror of
https://github.com/python/cpython.git
synced 2025-07-12 05:45:15 +00:00
gh-81057: Move More Globals to _PyRuntimeState (gh-100092)
https://github.com/python/cpython/issues/81057
This commit is contained in:
parent
d47ffeb9e3
commit
91a8e002c2
14 changed files with 66 additions and 56 deletions
|
@ -5697,8 +5697,6 @@ PyUnicode_AsUTF16String(PyObject *unicode)
|
|||
|
||||
/* --- Unicode Escape Codec ----------------------------------------------- */
|
||||
|
||||
static _PyUnicode_Name_CAPI *ucnhash_capi = NULL;
|
||||
|
||||
PyObject *
|
||||
_PyUnicode_DecodeUnicodeEscapeInternal(const char *s,
|
||||
Py_ssize_t size,
|
||||
|
@ -5711,6 +5709,8 @@ _PyUnicode_DecodeUnicodeEscapeInternal(const char *s,
|
|||
const char *end;
|
||||
PyObject *errorHandler = NULL;
|
||||
PyObject *exc = NULL;
|
||||
_PyUnicode_Name_CAPI *ucnhash_capi;
|
||||
PyInterpreterState *interp = _PyInterpreterState_Get();
|
||||
|
||||
// so we can remember if we've seen an invalid escape char or not
|
||||
*first_invalid_escape = NULL;
|
||||
|
@ -5858,6 +5858,7 @@ _PyUnicode_DecodeUnicodeEscapeInternal(const char *s,
|
|||
|
||||
/* \N{name} */
|
||||
case 'N':
|
||||
ucnhash_capi = interp->unicode.ucnhash_capi;
|
||||
if (ucnhash_capi == NULL) {
|
||||
/* load the unicode data module */
|
||||
ucnhash_capi = (_PyUnicode_Name_CAPI *)PyCapsule_Import(
|
||||
|
@ -5869,6 +5870,7 @@ _PyUnicode_DecodeUnicodeEscapeInternal(const char *s,
|
|||
);
|
||||
goto onError;
|
||||
}
|
||||
interp->unicode.ucnhash_capi = ucnhash_capi;
|
||||
}
|
||||
|
||||
message = "malformed \\N character escape";
|
||||
|
@ -15128,10 +15130,10 @@ _PyUnicode_Fini(PyInterpreterState *interp)
|
|||
assert(get_interned_dict() == NULL);
|
||||
// bpo-47182: force a unicodedata CAPI capsule re-import on
|
||||
// subsequent initialization of main interpreter.
|
||||
ucnhash_capi = NULL;
|
||||
}
|
||||
|
||||
_PyUnicode_FiniEncodings(&state->fs_codec);
|
||||
interp->unicode.ucnhash_capi = NULL;
|
||||
|
||||
unicode_clear_identifiers(state);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue