summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/errors.c4
-rw-r--r--Python/sysmodule.c41
-rw-r--r--Python/thread.c3
3 files changed, 22 insertions, 26 deletions
diff --git a/Python/errors.c b/Python/errors.c
index b6b5d9b..2aa748c 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -1229,8 +1229,8 @@ _PyErr_InitTypes(PyInterpreterState *interp)
}
if (UnraisableHookArgsType.tp_name == NULL) {
- if (PyStructSequence_InitType2(&UnraisableHookArgsType,
- &UnraisableHookArgs_desc) < 0) {
+ if (_PyStructSequence_InitBuiltin(&UnraisableHookArgsType,
+ &UnraisableHookArgs_desc) < 0) {
return _PyStatus_ERR("failed to initialize UnraisableHookArgs type");
}
}
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index a5fa551..e861d9c 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -28,7 +28,7 @@ Data members:
#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR
#include "pycore_pymem.h" // _PyMem_SetDefaultAllocator()
#include "pycore_pystate.h" // _PyThreadState_GET()
-#include "pycore_structseq.h" // _PyStructSequence_InitType()
+#include "pycore_structseq.h" // _PyStructSequence_InitBuiltinWithFlags()
#include "pycore_tuple.h" // _PyTuple_FromArray()
#include "frameobject.h" // PyFrame_FastToLocalsWithError()
@@ -2921,7 +2921,7 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
SET_SYS("int_info", PyLong_GetInfo());
/* initialize hash_info */
if (Hash_InfoType.tp_name == NULL) {
- if (PyStructSequence_InitType2(&Hash_InfoType, &hash_info_desc) < 0) {
+ if (_PyStructSequence_InitBuiltin(&Hash_InfoType, &hash_info_desc) < 0) {
goto type_init_failed;
}
}
@@ -2943,14 +2943,18 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
SET_SYS_FROM_STRING("abiflags", ABIFLAGS);
#endif
+#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; \
+ } \
+ } \
+ } while (0)
+
/* version_info */
- if (VersionInfoType.tp_name == NULL) {
- if (_PyStructSequence_InitType(&VersionInfoType,
- &version_info_desc,
- Py_TPFLAGS_DISALLOW_INSTANTIATION) < 0) {
- goto type_init_failed;
- }
- }
+ ENSURE_INFO_TYPE(VersionInfoType, version_info_desc);
version_info = make_version_info(tstate);
SET_SYS("version_info", version_info);
@@ -2958,27 +2962,18 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
SET_SYS("implementation", make_impl_info(version_info));
// sys.flags: updated in-place later by _PySys_UpdateConfig()
- if (FlagsType.tp_name == 0) {
- if (_PyStructSequence_InitType(&FlagsType, &flags_desc,
- Py_TPFLAGS_DISALLOW_INSTANTIATION) < 0) {
- goto type_init_failed;
- }
- }
+ ENSURE_INFO_TYPE(FlagsType, flags_desc);
SET_SYS("flags", make_flags(tstate->interp));
#if defined(MS_WINDOWS)
/* getwindowsversion */
- if (WindowsVersionType.tp_name == 0) {
- if (_PyStructSequence_InitType(&WindowsVersionType,
- &windows_version_desc,
- Py_TPFLAGS_DISALLOW_INSTANTIATION) < 0) {
- goto type_init_failed;
- }
- }
+ ENSURE_INFO_TYPE(WindowsVersionType, windows_version_desc);
SET_SYS_FROM_STRING("_vpath", VPATH);
#endif
+#undef ENSURE_INFO_TYPE
+
/* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */
#if _PY_SHORT_FLOAT_REPR == 1
SET_SYS_FROM_STRING("float_repr_style", "short");
@@ -2990,7 +2985,7 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
/* initialize asyncgen_hooks */
if (AsyncGenHooksType.tp_name == NULL) {
- if (PyStructSequence_InitType2(
+ if (_PyStructSequence_InitBuiltin(
&AsyncGenHooksType, &asyncgen_hooks_desc) < 0) {
goto type_init_failed;
}
diff --git a/Python/thread.c b/Python/thread.c
index 846f025..d321121 100644
--- a/Python/thread.c
+++ b/Python/thread.c
@@ -155,7 +155,8 @@ PyThread_GetInfo(void)
#endif
if (ThreadInfoType.tp_name == 0) {
- if (PyStructSequence_InitType2(&ThreadInfoType, &threadinfo_desc) < 0)
+ if (_PyStructSequence_InitBuiltin(&ThreadInfoType,
+ &threadinfo_desc) < 0)
return NULL;
}