diff --git a/ast27/Python/ast.c b/ast27/Python/ast.c index 9ae7d2b1..5340d332 100644 --- a/ast27/Python/ast.c +++ b/ast27/Python/ast.c @@ -3500,6 +3500,7 @@ parsenumber(struct compiling *c, const char *s) const char *end; long x; double dx; + int old_style_octal; #ifndef WITHOUT_COMPLEX Py_complex complex; int imflag; @@ -3519,14 +3520,17 @@ parsenumber(struct compiling *c, const char *s) return PyErr_NoMemory(); memcpy(copy, s, len); copy[len - 1] = '\0'; - PyObject *result = PyLong_FromString(copy, (char **)0, 0); + old_style_octal = len > 2 && copy[0] == '0' && copy[1] >= '0' && copy[1] <= '9'; + PyObject *result = PyLong_FromString(copy, (char **)0, old_style_octal ? 8 : 0); free(copy); return result; } x = Ta27OS_strtol((char *)s, (char **)&end, 0); if (*end == '\0') { - if (errno != 0) - return PyLong_FromString((char *)s, (char **)0, 0); + if (errno != 0) { + old_style_octal = end - s > 1 && s[0] == '0' && s[1] >= '0' && s[1] <= '9'; + return PyLong_FromString((char *)s, (char **)0, old_style_octal ? 8 : 0); + } return PyLong_FromLong(x); } /* XXX Huge floats may silently fail */