mirror of
https://github.com/python/cpython.git
synced 2025-08-25 11:15:02 +00:00
bpo-46417: Clear Unicode static types at exit (GH-30806)
Add _PyUnicode_FiniTypes() function, called by finalize_interp_types(). It clears these static types: * EncodingMapType * PyFieldNameIter_Type * PyFormatterIter_Type _PyStaticType_Dealloc() now does nothing if tp_subclasses is not NULL.
This commit is contained in:
parent
621a45ccac
commit
1626bf4ac7
6 changed files with 25 additions and 22 deletions
|
@ -15567,23 +15567,19 @@ _PyUnicode_InitTypes(PyInterpreterState *interp)
|
|||
return _PyStatus_OK();
|
||||
}
|
||||
|
||||
if (PyType_Ready(&PyUnicode_Type) < 0) {
|
||||
return _PyStatus_ERR("Can't initialize unicode type");
|
||||
}
|
||||
if (PyType_Ready(&PyUnicodeIter_Type) < 0) {
|
||||
return _PyStatus_ERR("Can't initialize unicode iterator type");
|
||||
}
|
||||
|
||||
if (PyType_Ready(&EncodingMapType) < 0) {
|
||||
return _PyStatus_ERR("Can't initialize encoding map type");
|
||||
goto error;
|
||||
}
|
||||
if (PyType_Ready(&PyFieldNameIter_Type) < 0) {
|
||||
return _PyStatus_ERR("Can't initialize field name iterator type");
|
||||
goto error;
|
||||
}
|
||||
if (PyType_Ready(&PyFormatterIter_Type) < 0) {
|
||||
return _PyStatus_ERR("Can't initialize formatter iter type");
|
||||
goto error;
|
||||
}
|
||||
return _PyStatus_OK();
|
||||
|
||||
error:
|
||||
return _PyStatus_ERR("Can't initialize unicode types");
|
||||
}
|
||||
|
||||
|
||||
|
@ -16111,6 +16107,19 @@ unicode_is_finalizing(void)
|
|||
#endif
|
||||
|
||||
|
||||
void
|
||||
_PyUnicode_FiniTypes(PyInterpreterState *interp)
|
||||
{
|
||||
if (!_Py_IsMainInterpreter(interp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_PyStaticType_Dealloc(&EncodingMapType);
|
||||
_PyStaticType_Dealloc(&PyFieldNameIter_Type);
|
||||
_PyStaticType_Dealloc(&PyFormatterIter_Type);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_PyUnicode_Fini(PyInterpreterState *interp)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue