diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2023-04-27 22:19:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-27 22:19:43 (GMT) |
commit | d2e2e53f733f8c8098035bbbc452bd1892796cb3 (patch) | |
tree | 4f01c11ff1f6ad9ebbcd4786bca991878226a4c6 /Modules | |
parent | 56c7176d1de3a0770085cad3865c1de42ba86f42 (diff) | |
download | cpython-d2e2e53f733f8c8098035bbbc452bd1892796cb3.zip cpython-d2e2e53f733f8c8098035bbbc452bd1892796cb3.tar.gz cpython-d2e2e53f733f8c8098035bbbc452bd1892796cb3.tar.bz2 |
gh-94673: Ensure Builtin Static Types are Readied Properly (gh-103940)
There were cases where we do unnecessary work for builtin static types. This also simplifies some work necessary for a per-interpreter GIL.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_io/_iomodule.c | 10 | ||||
-rw-r--r-- | Modules/mathmodule.c | 2 | ||||
-rw-r--r-- | Modules/symtablemodule.c | 7 |
3 files changed, 5 insertions, 14 deletions
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index 7f4f1d9..a3bfbc9 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -671,13 +671,11 @@ static PyTypeObject* static_types[] = { PyStatus _PyIO_InitTypes(PyInterpreterState *interp) { - if (!_Py_IsMainInterpreter(interp)) { - return _PyStatus_OK(); - } - - // Set type base classes #ifdef HAVE_WINDOWS_CONSOLE_IO - PyWindowsConsoleIO_Type.tp_base = &PyRawIOBase_Type; + if (_Py_IsMainInterpreter(interp)) { + // Set type base classes + PyWindowsConsoleIO_Type.tp_base = &PyRawIOBase_Type; + } #endif for (size_t i=0; i < Py_ARRAY_LENGTH(static_types); i++) { diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index eddc1a3..a5e82d5 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -2096,7 +2096,7 @@ math_trunc(PyObject *module, PyObject *x) return PyFloat_Type.tp_as_number->nb_int(x); } - if (Py_TYPE(x)->tp_dict == NULL) { + if (_PyType_IsReady(Py_TYPE(x))) { if (PyType_Ready(Py_TYPE(x)) < 0) return NULL; } diff --git a/Modules/symtablemodule.c b/Modules/symtablemodule.c index 4ef1d8c..91538b4 100644 --- a/Modules/symtablemodule.c +++ b/Modules/symtablemodule.c @@ -67,12 +67,6 @@ static PyMethodDef symtable_methods[] = { }; static int -symtable_init_stentry_type(PyObject *m) -{ - return PyType_Ready(&PySTEntry_Type); -} - -static int symtable_init_constants(PyObject *m) { if (PyModule_AddIntMacro(m, USE) < 0) return -1; @@ -105,7 +99,6 @@ symtable_init_constants(PyObject *m) } static PyModuleDef_Slot symtable_slots[] = { - {Py_mod_exec, symtable_init_stentry_type}, {Py_mod_exec, symtable_init_constants}, {0, NULL} }; |