'long int too large to convert to int' in 'garbage collection' ignored

Peter Kwan pkwan at advsofteng.com
Fri Aug 1 10:44:55 EDT 2003


Hi, 

I believe I have discovered a bug in Python 2.3. Could anyone suggest a get around?

When I tested my existing Python code with the newly released Python 2.3, I get the following warning:

FutureWarning: hex/oct constants > sys.maxint will return positive values in Python 2.4 and up

It is because I used some constants such as 0x80ff3366, so I change it to 0x80ff3366L, hoping to get rid of the warning.

But then I get the following fatal error:

Exception exceptions.OverflowError: 'long int too large to convert to int' in 'garbage collection' ignored
Fatal Python error: unexpected exception during garbage collection

abnormal program termination

I have tried testing the same code in Python 1.5.2 to Python 2.2. In all these versions, there is no error, no matter I use 0x80ff3366 or 0x80ff3366L. But in Python 2.3, I get warning or fatal error in these cases.

The details are as follows:

The code is running on Windows 2000. Python 2.3.

The Python code calls a C library and pass 0x80ff3366 or 0x80ff3366L to the C library. In the C library, it calls

//convert the given argument to Long in case it is not already Long
 PyObject *longObj = PyNumber_Long(argObj);

//get the value of the Python Long variable
long ret = PyLong_AsLong(longObj);

I have done some testing and confirm that the error does not happen if the second line "PyLong_AsLong" is commented out. Also, the erorr does not happen immediately when executing the above statement. It occurs slightly afterwards (during garbage collection?).

Could someone suggest a word around without touching the C library, and without making the Python code too ugly?

Regards
Peter Kwan



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20030801/8aff0938/attachment.html>


More information about the Python-list mailing list