summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2009-09-18 20:05:44 (GMT)
committerThomas Heller <theller@ctypes.org>2009-09-18 20:05:44 (GMT)
commit6be522bfc268a3a49c7a605667a760dd4a09e43f (patch)
tree71c82690ef32e8cf6cb535ec6070071098cb7138 /Modules
parent7a352c0ed8a12d868d9b682f4adf33f558d19855 (diff)
downloadcpython-6be522bfc268a3a49c7a605667a760dd4a09e43f.zip
cpython-6be522bfc268a3a49c7a605667a760dd4a09e43f.tar.gz
cpython-6be522bfc268a3a49c7a605667a760dd4a09e43f.tar.bz2
Issue #4606: Passing 'None' if ctypes argtype is set to POINTER(...)
does now always result in NULL.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c7
-rw-r--r--Modules/_ctypes/callproc.c1
2 files changed, 6 insertions, 2 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index a5c00cd..25cf956 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -972,8 +972,11 @@ PyCPointerType_from_param(PyObject *type, PyObject *value)
{
StgDictObject *typedict;
- if (value == Py_None)
- return PyInt_FromLong(0); /* NULL pointer */
+ if (value == Py_None) {
+ /* ConvParam will convert to a NULL pointer later */
+ Py_INCREF(value);
+ return value;
+ }
typedict = PyType_stgdict(type);
assert(typedict); /* Cannot be NULL for pointer types */
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index ec6d05b..cf17e3a 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -542,6 +542,7 @@ PyTypeObject PyCArg_Type = {
* C function call.
*
* 1. Python integers are converted to C int and passed by value.
+ * Py_None is converted to a C NULL pointer.
*
* 2. 3-tuples are expected to have a format character in the first
* item, which must be 'i', 'f', 'd', 'q', or 'P'.