New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
int() lies about base parameter #47093
Comments
>>> int('42', 42)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: int() base must be >= 2 and <= 36
>>> int('42', -909)
42 |
Some quick digging in the code on trunk has revealed that by the time |
In int_new in intobject.c the base -909 is used to indicate that no base |
The same issue is present in long_new: >>> long('42', -909)
42L I don't see why any magic value is needed, 10 would do the trick. |
10 would *not* do the trick: >>> int(42)
42
>>> int(42, 10)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: int() can't convert non-string with explicit base |
You are right. I guess something like bpo-2844-1.diff will be |
I'm -1 on complicating these simple functions. Raymond? |
I don't see the problem at all. The -909 value is an implementation Closing as "won't fix". |
Agreed. Totally a non-issue. |
For py3k, this was fixed in r81557. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: