[issue16741] `int()`, `float()`, etc think python strings are null-terminated

Matthew Barnett report at bugs.python.org
Sun Dec 30 03:52:19 CET 2012


Matthew Barnett added the comment:

I've attached a patch.

It now reports an invalid literal as-is:

>>> int("#\N{ARABIC-INDIC DIGIT ONE}")
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    int("#\N{ARABIC-INDIC DIGIT ONE}")
ValueError: invalid literal for int() with base 10: '#١'
>>> int("foo\x00bar")
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    int("foo\x00bar")
ValueError: invalid literal for int() with base 10: 'foo\x00bar'

There's a slight difference in that it truncates to 200 codepoints, not 200 UTF-8 bytes.

----------
keywords: +patch
Added file: http://bugs.python.org/file28487/issue16741.patch

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


More information about the Python-bugs-list mailing list