[Python-checkins] r82200 - in python/branches/py3k: Lib/test/test_getargs2.py Misc/NEWS Python/getargs.c

victor.stinner python-checkins at python.org
Fri Jun 25 00:08:25 CEST 2010


Author: victor.stinner
Date: Fri Jun 25 00:08:25 2010
New Revision: 82200

Log:
Issue #8949: "z" format of PyArg_Parse*() functions doesn't accept bytes
objects, as described in the documentation.


Modified:
   python/branches/py3k/Lib/test/test_getargs2.py
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Python/getargs.c

Modified: python/branches/py3k/Lib/test/test_getargs2.py
==============================================================================
--- python/branches/py3k/Lib/test/test_getargs2.py	(original)
+++ python/branches/py3k/Lib/test/test_getargs2.py	Fri Jun 25 00:08:25 2010
@@ -325,7 +325,7 @@
         from _testcapi import getargs_z
         self.assertEqual(getargs_z('abc\xe9'), b'abc\xc3\xa9')
         self.assertRaises(TypeError, getargs_z, 'nul:\0')
-        self.assertEqual(getargs_z(b'bytes'), b'bytes')
+        self.assertRaises(TypeError, getargs_z, b'bytes')
         self.assertRaises(TypeError, getargs_z, bytearray(b'bytearray'))
         self.assertRaises(TypeError, getargs_z, memoryview(b'memoryview'))
         self.assertIsNone(getargs_z(None))

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Fri Jun 25 00:08:25 2010
@@ -12,6 +12,9 @@
 Core and Builtins
 -----------------
 
+- Issue #8949: "z" format of PyArg_Parse*() functions doesn't accept bytes
+  objects, as described in the documentation.
+
 - Issue #6543: Write the traceback in the terminal encoding instead of utf-8.
   Fix the encoding of the modules filename. Patch written by Amaury Forgeot
   d'Arc.

Modified: python/branches/py3k/Python/getargs.c
==============================================================================
--- python/branches/py3k/Python/getargs.c	(original)
+++ python/branches/py3k/Python/getargs.c	Fri Jun 25 00:08:25 2010
@@ -1005,11 +1005,6 @@
 
             if (arg == Py_None)
                 *p = 0;
-            else if (PyBytes_Check(arg)) {
-                /* Enable null byte check below */
-                uarg = arg;
-                *p = PyBytes_AS_STRING(arg);
-            }
             else if (PyUnicode_Check(arg)) {
                 uarg = UNICODE_DEFAULT_ENCODING(arg);
                 if (uarg == NULL)


More information about the Python-checkins mailing list