This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author cubinator
Recipients cubinator
Date 2017-03-07.21:27:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1488922068.27.0.463542328186.issue29751@psf.upfronthosting.co.za>
In-reply-to
Content
Calling PyLong_FromString(str, NULL, 0) fails, if str is a string containing a decimal number with leading zeros, even though such strings should be parsed as decimal numbers according to the documentation:

"If base is 0, the radix will be determined based on the leading characters of str: if str starts with '0x' or '0X', radix 16 will be used; if str starts with '0o' or '0O', radix 8 will be used; if str starts with '0b' or '0B', radix 2 will be used; otherwise radix 10 will be used"

Examples:
PyLong_FromString("15", NULL, 0); // Returns int(15) (Correct)
PyLong_FromString("0xF", NULL, 0); // Returns int(15) (Correct)
PyLong_FromString("015", NULL, 0); // Should return int(15), but raises ValueError: invalid literal for int() with base 0: '015'

Version information:
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32
History
Date User Action Args
2017-03-07 21:27:48cubinatorsetrecipients: + cubinator
2017-03-07 21:27:48cubinatorsetmessageid: <1488922068.27.0.463542328186.issue29751@psf.upfronthosting.co.za>
2017-03-07 21:27:48cubinatorlinkissue29751 messages
2017-03-07 21:27:48cubinatorcreate