-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
bool of large range raises OverflowError #73062
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
Comments
The bool of a large range raises OverflowError: >>> bool(range(2**63))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C ssize_t This is a side-effect of len raising OverflowError, which is a general problem that's nontrivial to fix (the sq_length slot is constrained to return a ssize_t). In theory, though, it would be possible to implement nb_bool for range objects to do the right thing. In practice, this may well not be worth fixing, though I think it's at least worth reporting. |
+1 for implementing nb_bool for range objects. |
Here's a patch with range_bool() implementation, tests and the docs update. I'm not sure how it should be documented. I've specified it as |
I think a change at this level probably isn't worth documenting in the official docs; it's enough that there's a Misc/NEWS entry for it. |
I've removed the documentation changes from the patch. |
Patch LGTM. You could safely drop the initialisers beyond |
Following the python-dev discussion [1] I've added a variant of the patch that uses c99 designated initializers [2] [1] https://mail.python.org/pipermail/python-dev/2017-January/147175.html |
This patch looks ready to go. I'll wait a bit to see it there are any other comments. If not, I'll apply it shortly. |
LGTM, except 2-space indent. |
Latest patch LGTM too. |
Akira, could you open a pull request on GitHub? |
Done. PR 699 |
Thank you Akira for your patch. |
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: