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: PyLong_AsLongLong() problems
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: tim.peters Nosy List: tim.peters
Priority: normal Keywords:

Created on 2001-06-12 21:50 by tim.peters, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (2)
msg5029 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-06-12 21:50
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.
msg5030 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-06-13 00:36
Logged In: YES 
user_id=31435

Repaired, in

Modules/_testcapimodule.c, rev 1.5
Objects/longobject.c, rev 1.75
History
Date User Action Args
2022-04-10 16:04:07adminsetgithub: 34619
2001-06-12 21:50:01tim.peterscreate