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
The range for xrange() is too narrow on Windows 64-bit #70615
Comments
The xrange() object works with integers in the range of C long, not Py_ssize_t. Thus the idiomatic expression xrange(len(seq)) can fail for real sequences if sys.maxint < sys.maxsize (e.g on 64-bit Windows). Proposed patch changes the xrange() implementation to use Py_ssize_t instead of C long. |
Platforms with sizeof(long) < sizeof(size_t), I only know one platform: Windows 64-bit. Since this change only impacts Windows 64-bit, we must compile (to check for compilation warnings) and run tests with this patch on Windows 64-bit. Many other similar issues has been fixed in Python 3. I'm not sure that it's worth to spend too much time on supporting the full 64-bit range on Python 2, it's almost a new feature no? Examples:
|
I hate to say it, but I think this would count as an enhancement rather than a bugfix: there's nothing documented about the range of |
I agree that it's a new feature since xrange() still functions if you give it a value larger than |
What do you mean? Did you mean to write range() instead of xrange()? Both range and xrange in Python 2 use a C long for the start, stop, step, and length values. With how they get used this generally isn't a problem, which is why no one previously created an issue for this. |
No, I meant to write xrange(). My point is there is no crasher if this change didn't occur. |
Oh, by 'still functions' you meant that it doesn't cause an access violation that crashes the process, as opposed to raising an OverflowError that can be handled. |
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: