This repository was archived by the owner on Jul 5, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -3500,6 +3500,7 @@ parsenumber(struct compiling *c, const char *s)
3500
3500
const char * end ;
3501
3501
long x ;
3502
3502
double dx ;
3503
+ int old_style_octal ;
3503
3504
#ifndef WITHOUT_COMPLEX
3504
3505
Py_complex complex ;
3505
3506
int imflag ;
@@ -3519,14 +3520,17 @@ parsenumber(struct compiling *c, const char *s)
3519
3520
return PyErr_NoMemory ();
3520
3521
memcpy (copy , s , len );
3521
3522
copy [len - 1 ] = '\0' ;
3522
- PyObject * result = PyLong_FromString (copy , (char * * )0 , 0 );
3523
+ old_style_octal = len > 2 && copy [0 ] == '0' && copy [1 ] >= '0' && copy [1 ] <= '9' ;
3524
+ PyObject * result = PyLong_FromString (copy , (char * * )0 , old_style_octal ? 8 : 0 );
3523
3525
free (copy );
3524
3526
return result ;
3525
3527
}
3526
3528
x = Ta27OS_strtol ((char * )s , (char * * )& end , 0 );
3527
3529
if (* end == '\0' ) {
3528
- if (errno != 0 )
3529
- return PyLong_FromString ((char * )s , (char * * )0 , 0 );
3530
+ if (errno != 0 ) {
3531
+ old_style_octal = end - s > 1 && s [0 ] == '0' && s [1 ] >= '0' && s [1 ] <= '9' ;
3532
+ return PyLong_FromString ((char * )s , (char * * )0 , old_style_octal ? 8 : 0 );
3533
+ }
3530
3534
return PyLong_FromLong (x );
3531
3535
}
3532
3536
/* XXX Huge floats may silently fail */
You can’t perform that action at this time.
0 commit comments