]> granicus.if.org Git - python/commitdiff
Fix a potential 'SystemError: NULL result without error'.
authorThomas Heller <theller@ctypes.org>
Fri, 11 Jan 2008 20:29:19 +0000 (20:29 +0000)
committerThomas Heller <theller@ctypes.org>
Fri, 11 Jan 2008 20:29:19 +0000 (20:29 +0000)
NULL may be a valid return value from PyLong_AsVoidPtr.

Will backport to release25-maint.

Modules/_ctypes/_ctypes.c

index 4c4720e4a5f918682c1ce62a7183366cd9671f1e..1e0f9632f55755a98d77fe69fa1bd5f6384a7abb 100644 (file)
@@ -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)