STINNER Victor added the comment:
I tested Python 2.7 on Windows, downloaded from python.org:
* 32-bit:
- 'x'*(2**31+5) fails with OverflowError as expected
- len('x' * (sys.maxsize // 2)) returns 2**30-1 as a Python int
- for length larger with 'x' * (sys.maxsize // 2), I get a MemoryError,
probably because of a integer overflow in the C code, or maybe because malloc()
failed, I don't know
* 64-bit:
- len('x' * (2**32 + 5)) returns 2**32 + 5 (a positive number) as a Pyhon long
- len('x' * (2**31 + 5)) returns 2**31 + 5 (a positive number) as a Pyhon long
- len('x' * (2**31 - 5)) returns 2**31 - 5 (a positive number) as a Pyhon int
Limits :
* 32-bit: sys.maxint == 2**31-1, sys.maxsize == 2**31-1 == sys.maxint
* 64-bit: sys.maxint == 2**31-1, sys.maxsize == 2**63-1
It looks like the issue is specific to Python compiled by Continuum ("Anaconda"
flavor)?
----------
nosy: +pitrou
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue26423>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com