mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
gh-111972: Make Unicode name C APIcapsule initialization thread-safe (#112249)
This commit is contained in:
parent
81261fa67f
commit
0785c68559
3 changed files with 26 additions and 20 deletions
|
@ -931,8 +931,6 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc)
|
|||
return Py_BuildValue("(Nn)", res, end);
|
||||
}
|
||||
|
||||
static _PyUnicode_Name_CAPI *ucnhash_capi = NULL;
|
||||
|
||||
PyObject *PyCodec_NameReplaceErrors(PyObject *exc)
|
||||
{
|
||||
if (PyObject_TypeCheck(exc, (PyTypeObject *)PyExc_UnicodeEncodeError)) {
|
||||
|
@ -953,13 +951,9 @@ PyObject *PyCodec_NameReplaceErrors(PyObject *exc)
|
|||
return NULL;
|
||||
if (!(object = PyUnicodeEncodeError_GetObject(exc)))
|
||||
return NULL;
|
||||
if (!ucnhash_capi) {
|
||||
/* load the unicode data module */
|
||||
ucnhash_capi = (_PyUnicode_Name_CAPI *)PyCapsule_Import(
|
||||
PyUnicodeData_CAPSULE_NAME, 1);
|
||||
if (!ucnhash_capi) {
|
||||
return NULL;
|
||||
}
|
||||
_PyUnicode_Name_CAPI *ucnhash_capi = _PyUnicode_GetNameCAPI();
|
||||
if (ucnhash_capi == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (i = start, ressize = 0; i < end; ++i) {
|
||||
/* object is guaranteed to be "ready" */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue