Author: thomas.heller
Date: Wed Oct 24 21:37:27 2007
New Revision: 58642

Modified:
   python/branches/py3k/Lib/ctypes/test/test_prototypes.py
   python/branches/py3k/Modules/_ctypes/_ctypes.c
Log:
A 'PyObject *' parameter in PyErr_Format must use %S parameter, not %s.

Added unittest for calling a function with paramflags.

Modified: python/branches/py3k/Lib/ctypes/test/test_prototypes.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_prototypes.py     (original)
+++ python/branches/py3k/Lib/ctypes/test/test_prototypes.py     Wed Oct 24 
21:37:27 2007
@@ -48,6 +48,24 @@
         func.restype = c_long
         func.argtypes = None
 
+    def test_paramflags(self):
+        # function returns c_void_p result,
+        # and has a required parameter named 'input'
+        prototype = CFUNCTYPE(c_void_p, c_void_p)
+        func = prototype(("_testfunc_p_p", testdll),
+                         ((1, "input"),))
+
+        try:
+            func()
+        except TypeError as details:
+            self.failUnlessEqual(str(details), "required argument 'input' 
missing")
+        else:
+            self.fail("TypeError not raised")
+
+        self.failUnlessEqual(func(None), None)
+        self.failUnlessEqual(func(input=None), None)
+
+
     def test_int_pointer_arg(self):
         func = testdll._testfunc_p_p
         func.restype = c_long

Modified: python/branches/py3k/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/branches/py3k/Modules/_ctypes/_ctypes.c      (original)
+++ python/branches/py3k/Modules/_ctypes/_ctypes.c      Wed Oct 24 21:37:27 2007
@@ -2992,7 +2992,7 @@
        /* we can't currently emit a better error message */
        if (name)
                PyErr_Format(PyExc_TypeError,
-                            "required argument '%s' missing", name);
+                            "required argument '%S' missing", name);
        else
                PyErr_Format(PyExc_TypeError,
                             "not enough arguments");
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to