Title: PyArg_ParseTuple with "s" format and NUL: Bogus TypeError detail string.
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.2, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jafo Nosy List: jafo
Priority: normal Keywords:

Created on 2009-08-01 23:53 by jafo, last changed 2009-08-01 23:55 by jafo. This issue is now closed.

Messages (2)
msg91177 - (view) Author: Sean Reifschneider (jafo) * (Python committer) Date: 2009-08-01 23:53
As detailed in the python-dev post:

I have found a bug in the handling of PyArg_ParseTuple where a NUL in an
argument causes a message like this:

   TypeError: [priority,] message string

Instead of:

   TypeError: must be string without null bytes, not str

This seems to be a thinko in Python/getargs.c at line 331:

   msg = convertitem(PyTuple_GET_ITEM(args, i), &format, p_va,
        flags, levels, msgbuf,
        sizeof(msgbuf), &freelist);
   if (msg) {
      seterror(i+1, msg, levels, fname, message);   <<< Line 331
      return cleanreturn(0, freelist);

This also applies to Python 3 trunk in line 390.

I think that's supposed to be "msg" instead of "message" in the last

I have made this change and "make test" for both python and py3k trunks
is clean.
msg91178 - (view) Author: Sean Reifschneider (jafo) * (Python committer) Date: 2009-08-01 23:55
Fixed in python trunk commit 74277.
Fixed in py3k trunk commit 74278.
Date User Action Args
2009-08-01 23:55:53jafosetstatus: open -> closed
resolution: fixed
messages: + msg91178
2009-08-01 23:53:35jafocreate