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:21gangesmastersetrecipients: + gangesmaster
2012-12-20 23:37:21gangesmastersetmessageid: <1356046641.74.0.314140910069.issue16741@psf.upfronthosting.co.za>
2012-12-20 23:37:21gangesmasterlinkissue16741 messages
2012-12-20 23:37:21gangesmastercreate