@@ -2479,22 +2479,30 @@ PyCSimpleType_init(PyObject *self, PyObject *args, PyObject *kwds)
24792479 }
24802480 assert (sw_info );
24812481#ifdef WORDS_BIGENDIAN
2482- PyObject_SetAttrString (self , "__ctype_le__" , swapped );
2483- PyObject_SetAttrString (self , "__ctype_be__" , self );
2484- PyObject_SetAttrString (swapped , "__ctype_be__" , self );
2485- PyObject_SetAttrString (swapped , "__ctype_le__" , swapped );
2482+ if (PyObject_SetAttrString (self , "__ctype_le__" , swapped ) < 0 ||
2483+ PyObject_SetAttrString (self , "__ctype_be__" , self ) < 0 ||
2484+ PyObject_SetAttrString (swapped , "__ctype_be__" , self ) < 0 ||
2485+ PyObject_SetAttrString (swapped , "__ctype_le__" , swapped ) < 0 )
2486+ {
2487+ Py_DECREF (swapped );
2488+ return -1 ;
2489+ }
24862490 /* We are creating the type for the OTHER endian */
24872491 sw_info -> format = _ctypes_alloc_format_string ("<" , stginfo -> format + 1 );
24882492#else
2489- PyObject_SetAttrString (self , "__ctype_be__" , swapped );
2490- PyObject_SetAttrString (self , "__ctype_le__" , self );
2491- PyObject_SetAttrString (swapped , "__ctype_le__" , self );
2492- PyObject_SetAttrString (swapped , "__ctype_be__" , swapped );
2493+ if (PyObject_SetAttrString (self , "__ctype_be__" , swapped ) < 0 ||
2494+ PyObject_SetAttrString (self , "__ctype_le__" , self ) < 0 ||
2495+ PyObject_SetAttrString (swapped , "__ctype_le__" , self ) < 0 ||
2496+ PyObject_SetAttrString (swapped , "__ctype_be__" , swapped ) < 0 )
2497+ {
2498+ Py_DECREF (swapped );
2499+ return -1 ;
2500+ }
24932501 /* We are creating the type for the OTHER endian */
24942502 sw_info -> format = _ctypes_alloc_format_string (">" , stginfo -> format + 1 );
24952503#endif
24962504 Py_DECREF (swapped );
2497- if (PyErr_Occurred () ) {
2505+ if (sw_info -> format == NULL ) {
24982506 return -1 ;
24992507 }
25002508 };
0 commit comments