From: Thomas Heller Date: Fri, 11 Jan 2008 20:29:19 +0000 (+0000) Subject: Fix a potential 'SystemError: NULL result without error'. X-Git-Tag: v2.6a1~635 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=43617bc610a92d0025a9c9473fdbe0d81c51fd4d;p=python Fix a potential 'SystemError: NULL result without error'. NULL may be a valid return value from PyLong_AsVoidPtr. Will backport to release25-maint. --- diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 4c4720e4a5..1e0f9632f5 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -2899,7 +2899,7 @@ CFuncPtr_new(PyTypeObject *type, PyObject *args, PyObject *kwds) || PyLong_Check(PyTuple_GET_ITEM(args, 0)))) { CDataObject *ob; void *ptr = PyLong_AsVoidPtr(PyTuple_GET_ITEM(args, 0)); - if (ptr == NULL) + if (ptr == NULL && PyErr_Occurred()) return NULL; ob = (CDataObject *)GenericCData_new(type, args, kwds); if (ob == NULL)