bpo-38858: Reorganize pycore_init_types() (GH-17265)

* Call _PyLong_Init() and _PyExc_Init() earlier
* new_interpreter() reuses pycore_init_types()
This commit is contained in:
Victor Stinner 2019-11-20 00:38:03 +01:00 committed by GitHub
parent ac2235432c
commit ef5aa9af7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 20 deletions

View File

@ -565,19 +565,15 @@ pycore_init_types(void)
return status;
}
if (!_PyLong_Init()) {
return _PyStatus_ERR("can't init longs");
}
status = _PyUnicode_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 = _PyExc_Init();
if (_PyStatus_EXCEPTION(status)) {
return status;
@ -587,8 +583,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 +592,10 @@ pycore_init_types(void)
return status;
}
if (!_PyContext_Init()) {
return _PyStatus_ERR("can't init context");
}
return _PyStatus_OK();
}
@ -1447,16 +1447,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();
/* XXX The following is lax in error checking */
PyObject *modules = PyDict_New();