8000 gh-94673: Properly Initialize and Finalize Static Builtin Types for Each Interpreter by ericsnowcurrently · Pull Request #104072 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Finalize static builtin types for each interpreter.
  • Loading branch information
ericsnowcurrently committed May 1, 2023
commit f41a74d551571bffe8fb39772b63dfab1198f77c
2 changes: 1 addition & 1 deletion Include/internal/pycore_pylifecycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern PyStatus _PySys_Create(
extern PyStatus _PySys_ReadPreinitWarnOptions(PyWideStringList *options);
extern PyStatus _PySys_ReadPreinitXOptions(PyConfig *config);
extern int _PySys_UpdateConfig(PyThreadState *tstate);
extern void _PySys_Fini(PyInterpreterState *interp);
extern void _PySys_FiniTypes(PyInterpreterState *interp);
extern int _PyBuiltins_AddExceptions(PyObject * bltinmod);
extern PyStatus _Py_HashRandomization_Init(const PyConfig *);

Expand Down
4 changes: 0 additions & 4 deletions Modules/_io/_iomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,6 @@ _PyIO_InitTypes(PyInterpreterState *interp)
void
_PyIO_FiniTypes(PyInterpreterState *interp)
{
if (!_Py_IsMainInterpreter(interp)) {
return;
}

// Deallocate types in the reverse order to deallocate subclasses before
// their base classes.
for (Py_ssize_t i=Py_ARRAY_LENGTH(static_types) - 1; i >= 0; i--) {
Expand Down
4 changes: 0 additions & 4 deletions Objects/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -3609,10 +3609,6 @@ _PyExc_InitTypes(PyInterpreterState *interp)
static void
_PyExc_FiniTypes(PyInterpreterState *interp)
{
if (!_Py_IsMainInterpreter(interp)) {
return;
}

for (Py_ssize_t i=Py_ARRAY_LENGTH(static_exceptions) - 1; i >= 0; i--) {
PyTypeObject *exc = static_exceptions[i].exc;
_PyStaticType_Dealloc(interp, exc);
Expand Down
3 changes: 0 additions & 3 deletions Objects/floatobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2029,9 +2029,6 @@ _PyFloat_Fini(PyInterpreterState *interp)
void
_PyFloat_FiniType(PyInterpreterState *interp)
{
if (!_Py_IsMainInterpreter(interp)) {
return;
}
_PyStructSequence_FiniBuiltin(interp, &FloatInfoType);
}

Expand Down
5 changes: 0 additions & 5 deletions Objects/longobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "pycore_initconfig.h" // _PyStatus_OK()
#include "pycore_long.h" // _Py_SmallInts
#include "pycore_object.h" // _PyObject_Init()
#include "pycore_pystate.h" // _Py_IsMainInterpreter()
#include "pycore_runtime.h" // _PY_NSMALLPOSINTS
#include "pycore_structseq.h" // _PyStructSequence_FiniBuiltin()

Expand Down Expand Up @@ -6365,9 +6364,5 @@ _PyLong_InitTypes(PyInterpreterState *interp)
void
_PyLong_FiniTypes(PyInterpreterState *interp)
{
if (!_Py_IsMainInterpreter(interp)) {
return;
}

_PyStructSequence_FiniBuiltin(interp, &Int_InfoType);
}
4 changes: 0 additions & 4 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -2128,10 +2128,6 @@ _PyTypes_InitTypes(PyInterpreterState *interp)
void
_PyTypes_FiniTypes(PyInterpreterState *interp)
{
if (!_Py_IsMainInterpreter(interp)) {
return;
}

// Deallocate types in the reverse order to deallocate subclasses before
// their base classes.
for (Py_ssize_t i=Py_ARRAY_LENGTH(static_types)-1; i>=0; i--) {
Expand Down
4 changes: 0 additions & 4 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -15158,10 +15158,6 @@ unicode_is_finalizing(void)
void
_PyUnicode_FiniTypes(PyInterpreterState *interp)
{
if (!_Py_IsMainInterpreter(interp)) {
return;
}

_PyStaticType_Dealloc(interp, &EncodingMapType);
_PyStaticType_Dealloc(interp, &PyFieldNameIter_Type);
_PyStaticType_Dealloc(interp, &PyFormatterIter_Type);
Expand Down
4 changes: 0 additions & 4 deletions Python/errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -1354,10 +1354,6 @@ _PyErr_InitTypes(PyInterpreterState *interp)
void
_PyErr_FiniTypes(PyInterpreterState *interp)
{
if (!_Py_IsMainInterpreter(interp)) {
return;
}

_PyStructSequence_FiniBuiltin(interp, &UnraisableHookArgsType);
}

Expand Down
2 changes: 1 addition & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ finalize_interp_types(PyInterpreterState *interp)
_PyIO_FiniTypes(interp);

_PyUnicode_FiniTypes(interp);
_PySys_Fini(interp);
_PySys_FiniTypes(interp);
_PyExc_Fini(interp);
_PyAsyncGen_Fini(interp);
_PyContext_Fini(interp);
Expand Down
10 changes: 4 additions & 6 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3493,12 +3493,8 @@ _PySys_Create(PyThreadState *tstate, PyObject **sysmod_p)


void
_PySys_Fini(PyInterpreterState *interp)
_PySys_FiniTypes(PyInterpreterState *interp)
{
if (!_Py_IsMainInterpreter(interp)) {
return;
}

_PyStructSequence_FiniBuiltin(interp, &VersionInfoType);
_PyStructSequence_FiniBuiltin(interp, &FlagsType);
#if defined(MS_WINDOWS)
Expand All @@ -3507,7 +3503,9 @@ _PySys_Fini(PyInterpreterState *interp)
_PyStructSequence_FiniBuiltin(interp, &Hash_InfoType);
_PyStructSequence_FiniBuiltin(interp, &AsyncGenHooksType);
#ifdef __EMSCRIPTEN__
Py_CLEAR(EmscriptenInfoType);
if (_Py_IsMainInterpreter(interp)) {
Py_CLEAR(EmscriptenInfoType);
}
#endif
}

Expand Down
4 changes: 0 additions & 4 deletions Python/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,5 @@ PyThread_GetInfo(void)
void
_PyThread_FiniType(PyInterpreterState *interp)
{
if (!_Py_IsMainInterpreter(interp)) {
return;
}

_PyStructSequence_FiniBuiltin(interp, &ThreadInfoType);
}
0