Skip to content

Fix panics with int() #1290

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

Merged
merged 4 commits into from
Aug 23, 2019
Merged

Fix panics with int() #1290

merged 4 commits into from
Aug 23, 2019

Conversation

mpajkowski
Copy link
Contributor

Resolves #1228 issue

@mpajkowski mpajkowski changed the title Fix panics with int Fix panics with int() Aug 16, 2019
@@ -97,14 +97,40 @@
assert -10 // -4 == 2

assert int() == 0
assert int("101", 2) == 5
assert int("101", base=2) == 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its good to keep this check with an explicit base given.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I'll fix it in a moment

@windelbouwman
Copy link
Contributor

@mpajkowski nice job!

+ add automatic radix detection based on given literal
  if optional arg base is set to 0 (CPython behavior)
+ tolerate underscore separators
+ Add tests covering those changes
@windelbouwman windelbouwman merged commit 89a97b6 into RustPython:master Aug 23, 2019
@mpajkowski mpajkowski deleted the int_fix branch August 23, 2019 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

int('0b100', base=0) panic!
3 participants