[Python-checkins] r74923 - in python/branches/release31-maint: Lib/ctypes/test/test_parameters.py Misc/NEWS Modules/_ctypes/_ctypes.c Modules/_ctypes/callproc.c

thomas.heller python-checkins at python.org
Fri Sep 18 22:09:57 CEST 2009


Author: thomas.heller
Date: Fri Sep 18 22:09:57 2009
New Revision: 74923
Log:
Merged revisions 74922 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
 r74922 | thomas.heller | 2009年09月18日 22:08:39 +0200 (Fr, 18 Sep 2009) | 10 lines
 
 Merged revisions 74921 via svnmerge from 
 svn+ssh://pythondev@svn.python.org/python/trunk
 
 ........
 r74921 | thomas.heller | 2009年09月18日 22:05:44 +0200 (Fr, 18 Sep 2009) | 3 lines
 
 Issue #4606: Passing 'None' if ctypes argtype is set to POINTER(...)
 does now always result in NULL.
 ........
................
Modified:
 python/branches/release31-maint/ (props changed)
 python/branches/release31-maint/Lib/ctypes/test/test_parameters.py
 python/branches/release31-maint/Misc/NEWS
 python/branches/release31-maint/Modules/_ctypes/_ctypes.c
 python/branches/release31-maint/Modules/_ctypes/callproc.c
Modified: python/branches/release31-maint/Lib/ctypes/test/test_parameters.py
==============================================================================
--- python/branches/release31-maint/Lib/ctypes/test/test_parameters.py	(original)
+++ python/branches/release31-maint/Lib/ctypes/test/test_parameters.py	Fri Sep 18 22:09:57 2009
@@ -97,7 +97,7 @@
 self.assertEqual(x.contents.value, 42)
 self.assertEqual(LPINT(c_int(42)).contents.value, 42)
 
- self.assertEqual(LPINT.from_param(None), 0)
+ self.assertEqual(LPINT.from_param(None), None)
 
 if c_int != c_long:
 self.assertRaises(TypeError, LPINT.from_param, pointer(c_long(42)))
Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS	(original)
+++ python/branches/release31-maint/Misc/NEWS	Fri Sep 18 22:09:57 2009
@@ -21,6 +21,9 @@
 Library
 -------
 
+- Issue #4606: Passing 'None' if ctypes argtype is set to POINTER(...)
+ does now always result in NULL.
+
 - Issue #5042: Structure sub-subclass does now initialize correctly
 with base class positional arguments.
 
Modified: python/branches/release31-maint/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/branches/release31-maint/Modules/_ctypes/_ctypes.c	(original)
+++ python/branches/release31-maint/Modules/_ctypes/_ctypes.c	Fri Sep 18 22:09:57 2009
@@ -936,8 +936,11 @@
 {
 	StgDictObject *typedict;
 
-	if (value == Py_None)
-		return PyLong_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 */
Modified: python/branches/release31-maint/Modules/_ctypes/callproc.c
==============================================================================
--- python/branches/release31-maint/Modules/_ctypes/callproc.c	(original)
+++ python/branches/release31-maint/Modules/_ctypes/callproc.c	Fri Sep 18 22:09:57 2009
@@ -547,6 +547,7 @@
 * 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'.


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /