summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/marshal.c5
-rw-r--r--Python/pylifecycle.c38
-rw-r--r--Python/pystate.c2
3 files changed, 23 insertions, 22 deletions
diff --git a/Python/marshal.c b/Python/marshal.c
index cb11c8c74e..ec6b3dadc0 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -1829,6 +1829,9 @@ PyMarshal_Init(void)
PyObject *mod = PyModule_Create(&marshalmodule);
if (mod == NULL)
return NULL;
- PyModule_AddIntConstant(mod, "version", Py_MARSHAL_VERSION);
+ if (PyModule_AddIntConstant(mod, "version", Py_MARSHAL_VERSION) < 0) {
+ Py_DECREF(mod);
+ return NULL;
+ }
return mod;
}
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index add7519ed0..9739bb1541 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -558,26 +558,29 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
static PyStatus
-pycore_init_types(void)
+pycore_init_types(_PyRuntimeState *runtime)
{
- PyStatus status = _PyTypes_Init();
+ PyStatus status;
+
+ status = _PyGC_Init(runtime);
if (_PyStatus_EXCEPTION(status)) {
return status;
}
- status = _PyUnicode_Init();
+ status = _PyTypes_Init();
if (_PyStatus_EXCEPTION(status)) {
return status;
}
- if (_PyStructSequence_Init() < 0) {
- return _PyStatus_ERR("can't initialize structseq");
- }
-
if (!_PyLong_Init()) {
return _PyStatus_ERR("can't init longs");
}
+ status = _PyUnicode_Init();
+ if (_PyStatus_EXCEPTION(status)) {
+ return status;
+ }
+
status = _PyExc_Init();
if (_PyStatus_EXCEPTION(status)) {
return status;
@@ -587,8 +590,8 @@ pycore_init_types(void)
return _PyStatus_ERR("can't init float");
}
- if (!_PyContext_Init()) {
- return _PyStatus_ERR("can't init context");
+ if (_PyStructSequence_Init() < 0) {
+ return _PyStatus_ERR("can't initialize structseq");
}
status = _PyErr_Init();
@@ -596,6 +599,10 @@ pycore_init_types(void)
return status;
}
+ if (!_PyContext_Init()) {
+ return _PyStatus_ERR("can't init context");
+ }
+
return _PyStatus_OK();
}
@@ -683,7 +690,7 @@ pyinit_config(_PyRuntimeState *runtime,
config = &tstate->interp->config;
*tstate_p = tstate;
- status = pycore_init_types();
+ status = pycore_init_types(runtime);
if (_PyStatus_EXCEPTION(status)) {
return status;
}
@@ -1447,16 +1454,7 @@ new_interpreter(PyThreadState **tstate_p)
}
config = &interp->config;
- status = _PyExc_Init();
- if (_PyStatus_EXCEPTION(status)) {
- return status;
- }
-
- status = _PyErr_Init();
- if (_PyStatus_EXCEPTION(status)) {
- return status;
- }
-
+ status = pycore_init_types(runtime);
/* XXX The following is lax in error checking */
PyObject *modules = PyDict_New();
diff --git a/Python/pystate.c b/Python/pystate.c
index b4b1247228..06cc9a8fb4 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -58,7 +58,7 @@ _PyRuntimeState_Init_impl(_PyRuntimeState *runtime)
runtime->open_code_userdata = open_code_userdata;
runtime->audit_hook_head = audit_hook_head;
- _PyGC_Initialize(&runtime->gc);
+ _PyGC_InitializeRuntime(&runtime->gc);
_PyEval_Initialize(&runtime->ceval);
PyPreConfig_InitPythonConfig(&runtime->preconfig);