Message177863
| Author |
gangesmaster |
| Recipients |
gangesmaster |
| Date |
2012年12月20日.23:37:21 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1356046641.74.0.314140910069.issue16741@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| 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 |
|