Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4aae1eb

Browse files
author
Victor Stinner
committed
Issue #8949: "z" format of PyArg_Parse*() functions doesn't accept bytes
objects, as described in the documentation.
1 parent 2f7105d commit 4aae1eb

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

Lib/test/test_getargs2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def test_z(self):
325325
from _testcapi import getargs_z
326326
self.assertEqual(getargs_z('abc\xe9'), b'abc\xc3\xa9')
327327
self.assertRaises(TypeError, getargs_z, 'nul:\0')
328-
self.assertEqual(getargs_z(b'bytes'), b'bytes')
328+
self.assertRaises(TypeError, getargs_z, b'bytes')
329329
self.assertRaises(TypeError, getargs_z, bytearray(b'bytearray'))
330330
self.assertRaises(TypeError, getargs_z, memoryview(b'memoryview'))
331331
self.assertIsNone(getargs_z(None))

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ What's New in Python 3.2 Alpha 1?
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #8949: "z" format of PyArg_Parse*() functions doesn't accept bytes
16+
objects, as described in the documentation.
17+
1518
- Issue #6543: Write the traceback in the terminal encoding instead of utf-8.
1619
Fix the encoding of the modules filename. Patch written by Amaury Forgeot
1720
d'Arc.

Python/getargs.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,11 +1005,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
10051005

10061006
if (arg == Py_None)
10071007
*p = 0;
1008-
else if (PyBytes_Check(arg)) {
1009-
/* Enable null byte check below */
1010-
uarg = arg;
1011-
*p = PyBytes_AS_STRING(arg);
1012-
}
10131008
else if (PyUnicode_Check(arg)) {
10141009
uarg = UNICODE_DEFAULT_ENCODING(arg);
10151010
if (uarg == NULL)

0 commit comments

Comments
 (0)