diff Objects/floatobject.c @ 84793:fc718c177ee6

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
author Victor Stinner <victor.stinner@gmail.com>
date Mon, 22 Jul 2013 22:24:54 +0200
parents 41a2cbe23349
children e7f6cef7a4cc
line wrap: on
line diff
--- a/Objects/floatobject.c	Mon Jul 22 13:08:21 2013 -0500
+++ b/Objects/floatobject.c	Mon Jul 22 22:24:54 2013 +0200
@@ -1853,7 +1853,7 @@
     float_new,                                  /* tp_new */
 };
 
-void
+int
 _PyFloat_Init(void)
 {
     /* We attempt to determine if this machine is using IEEE
@@ -1903,8 +1903,11 @@
     float_format = detected_float_format;
 
     /* Init float info */
-    if (FloatInfoType.tp_name == 0)
-        PyStructSequence_InitType(&FloatInfoType, &floatinfo_desc);
+    if (FloatInfoType.tp_name == NULL) {
+        if (PyStructSequence_InitType2(&FloatInfoType, &floatinfo_desc) < 0)
+            return 0;
+    }
+    return 1;
 }
 
 int