diff options
author | Victor Stinner <vstinner@python.org> | 2019-11-19 23:38:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-19 23:38:03 (GMT) |
commit | ef5aa9af7c7e493402ac62009e4400aed7c3d54e (patch) | |
tree | 94e31084abcedc65e8d930469d61af807f40fe8a /Python | |
parent | ac2235432c607ce2c0faf6dff5d9b2534d2f6652 (diff) | |
download | cpython-ef5aa9af7c7e493402ac62009e4400aed7c3d54e.zip cpython-ef5aa9af7c7e493402ac62009e4400aed7c3d54e.tar.gz cpython-ef5aa9af7c7e493402ac62009e4400aed7c3d54e.tar.bz2 |
bpo-38858: Reorganize pycore_init_types() (GH-17265)
* Call _PyLong_Init() and _PyExc_Init() earlier
* new_interpreter() reuses pycore_init_types()
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pylifecycle.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index add7519..1bfc7c1 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -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(); |