You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
01L is a perfectly valid Python 2 long literal, but for some reason ast27 refuses to parse it and instead gives ValueError: invalid literal for int() with base 0: '01'. 01 and 1L both work fine.
The text was updated successfully, but these errors were encountered:
Here's why: Numbers are parsed in the parsenumber function in ast27/Python/ast.c. In two different circumstances, parsenumber calls PyLong_FromString to do the parsing:
If the number ends with an 'l' or an 'L', we strip the final character (as Python 3 doesn't allow it) and pass it to PyLong_FromString.
If the number is too large to be parsed by strtol (or there's some other error when we try parsing it with strtol), we pass it to PyLong_FromString.
Unfortunately, Python 3 doesn't support the 01 octal syntax; it has to be 0o1 instead. Hence the error.
01L
is a perfectly valid Python 2 long literal, but for some reason ast27 refuses to parse it and instead givesValueError: invalid literal for int() with base 0: '01'
.01
and1L
both work fine.The text was updated successfully, but these errors were encountered: