[New-bugs-announce] [issue6624] PyArg_ParseTuple with "s" format and NUL: Bogus TypeError detail string.

Sean Reifschneider report at bugs.python.org
Sun Aug 2 01:53:44 CEST 2009


New submission from Sean Reifschneider <jafo at tummy.com>:

As detailed in the python-dev post:

   http://mail.python.org/pipermail/python-dev/2009-July/090791.html

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

   syslog.syslog('hello\0there')
   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
argument.

I have made this change and "make test" for both python and py3k trunks
is clean.

----------
assignee: jafo
components: Interpreter Core
messages: 91177
nosy: jafo
priority: normal
severity: normal
stage: committed/rejected
status: open
title: PyArg_ParseTuple with "s" format and NUL: Bogus TypeError detail string.
type: behavior
versions: Python 2.7, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6624>
_______________________________________


More information about the New-bugs-announce mailing list