Repository navigation
bool of large range raises OverflowError #73062
Description
Activity
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_tThis 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.
- added3.7 (EOL)end of lifeend of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Dec 5, 2016 +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
versionchanged:: 3.6I'm not sure how it should be documented.
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
nb_boolin therange_as_numberstruct (per C99 6.7.8p21), but it's fine as it is.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
[2] https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.htmlThis 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?
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: