Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 84684:af18829a7754
Close #18469: Replace PyDict_GetItemString() with _PyDict_GetItemId() in structseq.c
_PyDict_GetItemId() is more efficient: it only builds the Unicode string once.
Identifiers (dictionary keys) are now created at Python initialization, and if
the creation failed, Python does exit with a fatal error.
Before, PyDict_GetItemString() failure was not handled: structseq_new() could
call PyObject_GC_NewVar() with a negative size, and structseq_dealloc() could
also crash.
| author | Victor Stinner <victor.stinner@gmail.com> |
|---|---|
| date | Wed, 17 Jul 2013 01:22:45 +0200 |
| parents | 65f2c92ed079 |
| children | 276477d5a548 |
line wrap: on
line diff
--- a/Python/pythonrun.c Wed Jul 17 01:10:04 2013 +0200 +++ b/Python/pythonrun.c Wed Jul 17 01:22:45 2013 +0200 @@ -86,6 +86,7 @@ static void wait_for_thread_shutdown(void); static void call_ll_exitfuncs(void); extern int _PyUnicode_Init(void); +extern int _PyStructSequence_Init(void); extern void _PyUnicode_Fini(void); extern int _PyLong_Init(void); extern void PyLong_Fini(void); @@ -336,6 +337,8 @@ /* Init Unicode implementation; relies on the codec registry */ if (_PyUnicode_Init() < 0) Py_FatalError("Py_Initialize: can't initialize unicode"); + if (_PyStructSequence_Init() < 0) + Py_FatalError("Py_Initialize: can't initialize structseq"); bimod = _PyBuiltin_Init(); if (bimod == NULL)
