diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-16 23:22:45 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-16 23:22:45 (GMT) |
commit | 26f91999b453563839466322164e566781f10ccd (patch) | |
tree | 4ea36e05182ee4b76d630f423f3bb83cbd68e86e /Python | |
parent | b8f602a60aea73497126b83fc4cad24e5c639641 (diff) | |
download | cpython-26f91999b453563839466322164e566781f10ccd.zip cpython-26f91999b453563839466322164e566781f10ccd.tar.gz cpython-26f91999b453563839466322164e566781f10ccd.tar.bz2 |
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.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pythonrun.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index d95a09d..814220b 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -86,6 +86,7 @@ static void call_py_exitfuncs(void); 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 @@ _Py_InitializeEx_Private(int install_sigs, int install_importlib) /* 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) |