Mercurial > cpython-lru_cache-weakref
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 84683:1872555a2f4e | 84684:af18829a7754 |
|---|---|
| 84 static void initsigs(void); | 84 static void initsigs(void); |
| 85 static void call_py_exitfuncs(void); | 85 static void call_py_exitfuncs(void); |
| 86 static void wait_for_thread_shutdown(void); | 86 static void wait_for_thread_shutdown(void); |
| 87 static void call_ll_exitfuncs(void); | 87 static void call_ll_exitfuncs(void); |
| 88 extern int _PyUnicode_Init(void); | 88 extern int _PyUnicode_Init(void); |
| 89 extern int _PyStructSequence_Init(void); | |
| 89 extern void _PyUnicode_Fini(void); | 90 extern void _PyUnicode_Fini(void); |
| 90 extern int _PyLong_Init(void); | 91 extern int _PyLong_Init(void); |
| 91 extern void PyLong_Fini(void); | 92 extern void PyLong_Fini(void); |
| 92 extern int _PyFaulthandler_Init(void); | 93 extern int _PyFaulthandler_Init(void); |
| 93 extern void _PyFaulthandler_Fini(void); | 94 extern void _PyFaulthandler_Fini(void); |
| 334 Py_FatalError("Py_Initialize: can't make modules dictionary"); | 335 Py_FatalError("Py_Initialize: can't make modules dictionary"); |
| 335 | 336 |
| 336 /* Init Unicode implementation; relies on the codec registry */ | 337 /* Init Unicode implementation; relies on the codec registry */ |
| 337 if (_PyUnicode_Init() < 0) | 338 if (_PyUnicode_Init() < 0) |
| 338 Py_FatalError("Py_Initialize: can't initialize unicode"); | 339 Py_FatalError("Py_Initialize: can't initialize unicode"); |
| 340 if (_PyStructSequence_Init() < 0) | |
| 341 Py_FatalError("Py_Initialize: can't initialize structseq"); | |
| 339 | 342 |
| 340 bimod = _PyBuiltin_Init(); | 343 bimod = _PyBuiltin_Init(); |
| 341 if (bimod == NULL) | 344 if (bimod == NULL) |
| 342 Py_FatalError("Py_Initialize: can't initialize builtins modules"); | 345 Py_FatalError("Py_Initialize: can't initialize builtins modules"); |
| 343 _PyImport_FixupBuiltin(bimod, "builtins"); | 346 _PyImport_FixupBuiltin(bimod, "builtins"); |
