@@ -2497,22 +2497,30 @@ PyCSimpleType_init(PyObject *self, PyObject *args, PyObject *kwds)
24972497 }
24982498 assert (sw_info );
24992499#ifdef WORDS_BIGENDIAN
2500- PyObject_SetAttrString (self , "__ctype_le__" , swapped );
2501- PyObject_SetAttrString (self , "__ctype_be__" , self );
2502- PyObject_SetAttrString (swapped , "__ctype_be__" , self );
2503- PyObject_SetAttrString (swapped , "__ctype_le__" , swapped );
2500+ if (PyObject_SetAttrString (self , "__ctype_le__" , swapped ) < 0 ||
2501+ PyObject_SetAttrString (self , "__ctype_be__" , self ) < 0 ||
2502+ PyObject_SetAttrString (swapped , "__ctype_be__" , self ) < 0 ||
2503+ PyObject_SetAttrString (swapped , "__ctype_le__" , swapped ) < 0 )
2504+ {
2505+ Py_DECREF (swapped );
2506+ return -1 ;
2507+ }
25042508 /* We are creating the type for the OTHER endian */
25052509 sw_info -> format = _ctypes_alloc_format_string ("<" , stginfo -> format + 1 );
25062510#else
2507- PyObject_SetAttrString (self , "__ctype_be__" , swapped );
2508- PyObject_SetAttrString (self , "__ctype_le__" , self );
2509- PyObject_SetAttrString (swapped , "__ctype_le__" , self );
2510- PyObject_SetAttrString (swapped , "__ctype_be__" , swapped );
2511+ if (PyObject_SetAttrString (self , "__ctype_be__" , swapped ) < 0 ||
2512+ PyObject_SetAttrString (self , "__ctype_le__" , self ) < 0 ||
2513+ PyObject_SetAttrString (swapped , "__ctype_le__" , self ) < 0 ||
2514+ PyObject_SetAttrString (swapped , "__ctype_be__" , swapped ) < 0 )
2515+ {
2516+ Py_DECREF (swapped );
2517+ return -1 ;
2518+ }
25112519 /* We are creating the type for the OTHER endian */
25122520 sw_info -> format = _ctypes_alloc_format_string (">" , stginfo -> format + 1 );
25132521#endif
25142522 Py_DECREF (swapped );
2515- if (PyErr_Occurred () ) {
2523+ if (sw_info -> format == NULL ) {
25162524 return -1 ;
25172525 }
25182526 };
0 commit comments