[Python-bugs-list] [ python-Bugs-432552 ] PyLong_AsLongLong() problems

noreply@sourceforge.net noreply@sourceforge.net
Tue, 12 Jun 2001 14:50:01 -0700


Bugs item #432552, was updated on 2001-06-12 14:50
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=432552&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Tim Peters (tim_one)
Assigned to: Tim Peters (tim_one)
Summary: PyLong_AsLongLong() problems

Initial Comment:
The C API function PyLong_AsLongLong() botches some 
overflow endcases.  Most obviously, if the Python long 
contains the most-negative C long long (-(2**63) when 
sizeof(long long) == 8), on most boxes signed right 
shifts sign-extend (C doesn't define this), and then 
the

if ((x >> SHIFT) != prev)

overflow test triggers by mistake (because the leading 
1-bit gets misinterpreted as "a sign bit", and the 
signed right shift then duplicates it 15 times).

Bumped into this while writing a LONG_LONG API test 
for _testcapimodule.c.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=432552&group_id=5470