STINNER Victor victor.stin...@haypocalc.com added the comment:
I commited a bigger patch: r81973 not only fixes y format, but also u and
Z. It does also add a lot of tests in test_getargs2.py for many string
formats (not all, eg. es is not tested).
Even if I consider this as a bugfix, I don't
STINNER Victor victor.stin...@haypocalc.com added the comment:
Attached patch fixes the initial problem: raise an error if the byte strings
embeds a NUL-byte.
--
keywords: +patch
Added file: http://bugs.python.org/file17636/y_format.patch
___
Python
STINNER Victor victor.stin...@haypocalc.com added the comment:
See also #8850: Remove w format of PyParse_ParseTuple().
--
About y: the parser HAVE TO check for embedded NUL bytes, because the caller
doesn't know the size of the buffer (and strlen() would give the wrong size).
--
STINNER Victor victor.stin...@haypocalc.com added the comment:
Same issue for y#:
y# (...) This variant on s# doesn’t accept Unicode objects, only bytes-like
objects.
s# (...) The string may contain embedded null bytes.
--
y* might mention that it accepts embedded null bytes.
--
grep
STINNER Victor victor.stin...@haypocalc.com added the comment:
See also #8215.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8592
___
___
New submission from Antoine Pitrou pit...@free.fr:
The documentation for the 'y' format (PyArg_ParseTuple and friends) states that:
« The bytes object must not contain embedded NUL bytes; if it does, a TypeError
exception is raised. »
But, reading Python/getargs.c, the strlen() check is