summaryrefslogtreecommitdiff
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2023-04-27 16:19:43 -0600
committerGitHub <noreply@github.com>2023-04-27 16:19:43 -0600
commitd2e2e53f733f8c8098035bbbc452bd1892796cb3 (patch)
tree4f01c11ff1f6ad9ebbcd4786bca991878226a4c6 /Python/sysmodule.c
parent56c7176d1de3a0770085cad3865c1de42ba86f42 (diff)
downloadcpython-git-d2e2e53f733f8c8098035bbbc452bd1892796cb3.tar.gz
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 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 58ed48859b..d673e40af5 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -3166,10 +3166,8 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
SET_SYS("float_info", PyFloat_GetInfo());
SET_SYS("int_info", PyLong_GetInfo());
/* initialize hash_info */
- if (Hash_InfoType.tp_name == NULL) {
- if (_PyStructSequence_InitBuiltin(&Hash_InfoType, &hash_info_desc) < 0) {
- goto type_init_failed;
- }
+ if (_PyStructSequence_InitBuiltin(&Hash_InfoType, &hash_info_desc) < 0) {
+ goto type_init_failed;
}
SET_SYS("hash_info", get_hash_info(tstate));
SET_SYS("maxunicode", PyLong_FromLong(0x10FFFF));
@@ -3191,11 +3189,9 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
#define ENSURE_INFO_TYPE(TYPE, DESC) \
do { \
- if (TYPE.tp_name == NULL) { \
- if (_PyStructSequence_InitBuiltinWithFlags( \
- &TYPE, &DESC, Py_TPFLAGS_DISALLOW_INSTANTIATION) < 0) { \
- goto type_init_failed; \
- } \
+ if (_PyStructSequence_InitBuiltinWithFlags( \
+ &TYPE, &DESC, Py_TPFLAGS_DISALLOW_INSTANTIATION) < 0) { \
+ goto type_init_failed; \
} \
} while (0)
@@ -3230,11 +3226,9 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
SET_SYS("thread_info", PyThread_GetInfo());
/* initialize asyncgen_hooks */
- if (AsyncGenHooksType.tp_name == NULL) {
- if (_PyStructSequence_InitBuiltin(
- &AsyncGenHooksType, &asyncgen_hooks_desc) < 0) {
- goto type_init_failed;
- }
+ if (_PyStructSequence_InitBuiltin(
+ &AsyncGenHooksType, &asyncgen_hooks_desc) < 0) {
+ goto type_init_failed;
}
#ifdef __EMSCRIPTEN__