classification
Title: Patch for "string without null bytes" check in getargs.c
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.0
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Clean up getargs.c and its formatting possibilities
View: 2322
Assigned To: Nosy List: alexandre.vassalotti, belopolsky, dgreiman, georg.brandl
Priority: normal Keywords: patch

Created on 2008-03-16 06:00 by dgreiman, last changed 2008-03-21 20:47 by georg.brandl. This issue is now closed.

Files
File name Uploaded Description Edit
py3k-getargs-null-bytes-20080315.diff dgreiman, 2008-03-16 06:00
unnamed belopolsky, 2008-03-17 15:29
Messages (6)
msg63571 - (view) Author: Douglas Greiman (dgreiman) * Date: 2008-03-16 06:00
Code in getargs.c:convertsimple incorrectly uses PyUnicode_GetSize
instead of PyString_GET_SIZE when checking whether a bytes object
(encoded string) contains a null byte.

To reproduce: __import__('\u0080')
Incorrect behavior:
  TypeError: __import__() argument 1 must be string without null bytes,
not str
Correct behavior: 
  ImportError

Note the lack of null bytes:
  >>> '\u0080'.encode('utf-8')
  b'\xc2\x80'
msg63582 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2008-03-16 16:10
Note that this patch will expose a bug fixed in issue1950. (See msg63363.)  I suggest that the import.c part of issue1950 and this go 
together.  Alexandre?
msg63643 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2008-03-17 13:51
Yes, that sounds like a good idea. Although I haven't reviewed this
patch yet, I find the naming of the `ustr` variable confusing -- e.g. is
it a bytes object or a unicode object? (It seems to be bytes). Anyway, I
will check this out later today, when I will get the time.
msg63652 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2008-03-17 15:29
On Mon, Mar 17, 2008 at 9:51 AM, Alexandre Vassalotti <
report@bugs.python.org> wrote:

>
> Alexandre Vassalotti <alexandre@peadrop.com> added the comment:
>
> .. Although I haven't reviewed this
> patch yet, I find the naming of the `ustr` variable confusing -- e.g. is
> it a bytes object or a unicode object?

There is no `ustr` variable , you  probably mean  `uarg`.   If so, it  is
not introduced by the patch.   To me the patch looks straightforward and
correct, but a unit test should be added.  Some additional refactoring is
due for getargs.c (does py3k support builds without Py_USING_UNICODE?), but
the bug fix should not wait for that.
msg63684 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2008-03-17 17:27
There is now issue2322 (Clean up getargs.c and its formatting 
possibilities) related to this.
msg64278 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-03-21 20:47
I've added XXX comments to the code, so this is now tracked by #2322.
History
Date User Action Args
2008-03-21 20:47:15georg.brandlsetstatus: open -> closed
resolution: duplicate
superseder: Clean up getargs.c and its formatting possibilities
messages: + msg64278
nosy: + georg.brandl
2008-03-17 17:27:05belopolskysetmessages: + msg63684
2008-03-17 15:29:53belopolskysetfiles: + unnamed
messages: + msg63652
2008-03-17 13:51:24alexandre.vassalottisetmessages: + msg63643
2008-03-16 16:10:26belopolskysetnosy: + alexandre.vassalotti, belopolsky
messages: + msg63582
2008-03-16 06:00:38dgreimancreate