Skip to content

Commit 1ca28c7

Browse files
committed
Restore the exception only if present
1 parent 6d8d1ce commit 1ca28c7

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

Modules/_ctypes/_ctypes.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,12 +2247,16 @@ PyCSimpleType_from_param(PyObject *type, PyObject *value)
22472247
value = PyCSimpleType_from_param(type, as_parameter);
22482248
_Py_LeaveRecursiveCall();
22492249
Py_DECREF(as_parameter);
2250-
Py_DECREF(exc);
2251-
Py_DECREF(val);
2252-
Py_DECREF(tb);
2250+
Py_XDECREF(exc);
2251+
Py_XDECREF(val);
2252+
Py_XDECREF(tb);
22532253
return value;
22542254
}
2255-
PyErr_Restore(exc, val, tb);
2255+
if (exc)
2256+
PyErr_Restore(exc, val, tb);
2257+
else
2258+
PyErr_SetString(PyExc_TypeError,
2259+
"wrong type");
22562260
return NULL;
22572261
}
22582262

0 commit comments

Comments
 (0)