This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PyArg_ParseTuple(args, "i") and sys.maxint
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, lemburg
Priority: normal Keywords:

Created on 2006-06-08 08:42 by lemburg, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (8)
msg28737 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2006-06-08 08:42
The argument parser seems to have trouble with
sys.maxint on 64-bit platforms:

>>> import sys
>>> sys.maxint
9223372036854775807
>>> sys.setcheckinterval(sys.maxint)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: signed integer is greater than maximum

>>> sys.setcheckinterval(2**31-1)
>>> sys.setcheckinterval(2**31)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: signed integer is greater than maximum

Looks like INT_MAX isn't the right value to test against.

This is on AMD64, Linux2.6, gcc 3.3.
msg28738 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-06-08 12:47
Logged In: YES 
user_id=849994

No, INT_MAX is definitely not the right value. Changed to
LONG_MAX and LONG_MIN in rev. 46741, 46742 (2.4).
msg28739 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-06-08 13:32
Logged In: YES 
user_id=849994

The bug isn't in getargs. Format code "i" wants a C integer.

Question is whether sys.setcheckinterval and perhaps dozens
of other functions should be changed to accept "l".

Changing to Invalid. Reverted checkin.
msg28740 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2006-06-08 13:39
Logged In: YES 
user_id=38388

Reopened: the bug is still there.

Note that a C integer does have 64-bits on a 64-bit Linux
system :-) (unlike on a Win64 system).
msg28741 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2006-06-08 13:45
Logged In: YES 
user_id=38388

Strike that last comment about ints haveing 64-bit. I got
carried away by Python using C longs for ints.
msg28742 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-06-08 13:52
Logged In: YES 
user_id=849994

To be sure: ints are 32-bit and longs 64-bit?
msg28743 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2006-06-08 14:00
Logged In: YES 
user_id=38388

Yes. Sorry for the confusion.

ints are 32 bit and longs 64 bit on 64bit Linux (and other
64bit Unix systems).

Since Python uses C longs for storing integers, sys.maxint
correctly gives LONG_MAX.
msg28744 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-06-08 14:11
Logged In: YES 
user_id=849994

Okay, closing.
History
Date User Action Args
2022-04-11 14:56:17adminsetgithub: 43472
2006-06-08 08:42:09lemburgcreate