Issue #18520: Add a new PyStructSequence_InitType2() function, same than

PyStructSequence_InitType() except that it has a return value (0 on success,
-1 on error).

 * PyStructSequence_InitType2() now raises MemoryError on memory allocation failure
 * Fix also some calls to PyDict_SetItemString(): handle error
This commit is contained in:
Victor Stinner 2013-07-22 22:24:54 +02:00
parent 2a545099f7
commit 1c8f059019
17 changed files with 117 additions and 54 deletions

View file

@ -884,10 +884,12 @@ PyInit__lsprof(void)
PyDict_SetItemString(d, "Profiler", (PyObject *)&PyProfiler_Type);
if (!initialized) {
PyStructSequence_InitType(&StatsEntryType,
&profiler_entry_desc);
PyStructSequence_InitType(&StatsSubEntryType,
&profiler_subentry_desc);
if (PyStructSequence_InitType2(&StatsEntryType,
&profiler_entry_desc) < 0)
return NULL;
if (PyStructSequence_InitType2(&StatsSubEntryType,
&profiler_subentry_desc) < 0)
return NULL;
}
Py_INCREF((PyObject*) &StatsEntryType);
Py_INCREF((PyObject*) &StatsSubEntryType);