From 43617bc610a92d0025a9c9473fdbe0d81c51fd4d Mon Sep 17 00:00:00 2001 From: Thomas Heller Date: Fri, 11 Jan 2008 20:29:19 +0000 Subject: [PATCH] Fix a potential 'SystemError: NULL result without error'. NULL may be a valid return value from PyLong_AsVoidPtr. Will backport to release25-maint. --- Modules/_ctypes/_ctypes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 4c4720e4a5f..1e0f9632f55 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)