gh-94673: Properly Initialize and Finalize Static Builtin Types for Each Interpreter (gh-104072)

Until now, we haven't been initializing nor finalizing the per-interpreter state properly.
This commit is contained in:
Eric Snow 2023-05-01 19:36:00 -06:00 committed by GitHub
parent b1ca34d4d5
commit fdd878650d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 146 additions and 135 deletions

View file

@ -14573,13 +14573,13 @@ _PyUnicode_InitGlobalObjects(PyInterpreterState *interp)
PyStatus
_PyUnicode_InitTypes(PyInterpreterState *interp)
{
if (_PyStaticType_InitBuiltin(&EncodingMapType) < 0) {
if (_PyStaticType_InitBuiltin(interp, &EncodingMapType) < 0) {
goto error;
}
if (_PyStaticType_InitBuiltin(&PyFieldNameIter_Type) < 0) {
if (_PyStaticType_InitBuiltin(interp, &PyFieldNameIter_Type) < 0) {
goto error;
}
if (_PyStaticType_InitBuiltin(&PyFormatterIter_Type) < 0) {
if (_PyStaticType_InitBuiltin(interp, &PyFormatterIter_Type) < 0) {
goto error;
}
return _PyStatus_OK();
@ -15158,13 +15158,9 @@ unicode_is_finalizing(void)
void
_PyUnicode_FiniTypes(PyInterpreterState *interp)
{
if (!_Py_IsMainInterpreter(interp)) {
return;
}
_PyStaticType_Dealloc(&EncodingMapType);
_PyStaticType_Dealloc(&PyFieldNameIter_Type);
_PyStaticType_Dealloc(&PyFormatterIter_Type);
_PyStaticType_Dealloc(interp, &EncodingMapType);
_PyStaticType_Dealloc(interp, &PyFieldNameIter_Type);
_PyStaticType_Dealloc(interp, &PyFormatterIter_Type);
}