Closed hellantos closed 3 years ago
Sounds good, but I have some comments:
except
part, which would result in an error again. You should replace the 0
base with something else.int
literals with leading zeroes are octal literals, not decimal. So maybe the correct base should be 8
, and not 10
.
- It seems this is only a problem in Python 3, not in Python 2.7.
I did run into this problem with Python 3. I did not check Python 2.7. With Python 2.7 being EOL, it is probably good to fix this, also it has backwards compatibility.
- Your commit adds exactly the same line in the
except
part, which would result in an error again. You should replace the0
base with something else.- In C++,
int
literals with leading zeroes are octal literals, not decimal. So maybe the correct base should be8
, and not10
.
You're absolutely correct, changed it in the commit.
Looks good now! Thanks for the contribution :+1:
When parsing CPP-Integers with a leading zero, the current code throws a ValueError. It seams Python cannot derive the base from such a literal.
Python proof:
int("0666", 0)
results in:CPP example where this error occurs:
const int get_flags = 0666;
The pull request will catch the error and assume that its a base 10 integer. Then interpreting works.