]> granicus.if.org Git - python/commitdiff
Issue #8949: "z" format of PyArg_Parse*() functions doesn't accept bytes
authorVictor Stinner <victor.stinner@haypocalc.com>
Thu, 24 Jun 2010 22:08:25 +0000 (22:08 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Thu, 24 Jun 2010 22:08:25 +0000 (22:08 +0000)
objects, as described in the documentation.

Lib/test/test_getargs2.py
Misc/NEWS
Python/getargs.c

index 7186f55ed0bb73b0dcf248a604e271947b57a01f..5ade2b43e6c1ea933c3b623b324f27bba1c666cf 100644 (file)
@@ -325,7 +325,7 @@ class Bytes_TestCase(unittest.TestCase):
         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))
index 2c6083d31c394cc9586f5d4154815842154208d8..46583e999a1ad452b38680763349f6c3f4363200 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 3.2 Alpha 1?
 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.
index 20f4814e8b88b1eaae3fa882c00046cb650f302f..bce99ae798eeb277e37ae0dee0e71d6843e248c8 100644 (file)
@@ -1005,11 +1005,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
 
             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)