Skip to content

Fix panics with int()#1290

Merged
windelbouwman merged 4 commits into
RustPython:masterfrom
mpajkowski:int_fix
Aug 23, 2019
Merged

Fix panics with int()#1290
windelbouwman merged 4 commits into
RustPython:masterfrom
mpajkowski:int_fix

Conversation

@mpajkowski
Copy link
Copy Markdown
Contributor

Resolves #1228 issue

@mpajkowski mpajkowski changed the title Fix panics with int Fix panics with int() Aug 16, 2019
Comment thread tests/snippets/ints.py

assert int() == 0
assert int("101", 2) == 5
assert int("101", base=2) == 5
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread vm/src/obj/objint.rs Outdated
@windelbouwman
Copy link
Copy Markdown
Contributor

@mpajkowski nice job!

Comment thread vm/src/obj/objint.rs Outdated
Comment thread vm/src/obj/objint.rs
+ 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