Message177863
I'm not sure if it's a bug or just an inconvenience, but when a string containing \x00 is passed to int/float/etc, they return a misleading exception:
>>> int("abc")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: 'abc'
>>> int("\x00abc")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: ''
>>> float("\x00abc")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: could not convert string to float:
I noticed the code does actually try to handle it:
http://hg.python.org/cpython/file/39803c20c9bf/Objects/intobject.c#l1066
but still, the reported error is very misleading. |
|
Date |
User |
Action |
Args |
2012-12-20 23:37:21 | gangesmaster | set | recipients:
+ gangesmaster |
2012-12-20 23:37:21 | gangesmaster | set | messageid: <1356046641.74.0.314140910069.issue16741@psf.upfronthosting.co.za> |
2012-12-20 23:37:21 | gangesmaster | link | issue16741 messages |
2012-12-20 23:37:21 | gangesmaster | create | |
|