From 1c8f059019d79f1891f42a2656a96919a1187967 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 22 Jul 2013 22:24:54 +0200 Subject: 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 --- Modules/_lsprof.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Modules/_lsprof.c') diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index fef255fdf5..894788916d 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -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); -- cgit v1.2.1