We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2c383e7 commit 18411f4Copy full SHA for 18411f4
src/object/class.cpp
@@ -301,12 +301,11 @@ namespace objects
301
PyObject* d = type_->tp_dict;
302
PyObject* instance_size_obj = PyObject_GetAttrString(d, "__instance_size__");
303
304
- long instance_size = 0;
305
- if (instance_size != 0)
306
- instance_size = PyInt_AsLong(instance_size_obj);
+ long instance_size = instance_size_obj ? PyInt_AsLong(instance_size_obj) : 0;
307
308
if (instance_size < 0)
309
instance_size = 0;
+
310
PyErr_Clear(); // Clear any errors that may have occurred.
311
312
instance<>* result = (instance<>*)type_->tp_alloc(type_, instance_size);
0 commit comments