[ python-Bugs-1518190 ] c_void_pointer should accept a long pointer > 0x7fffffff

SourceForge.net noreply at sourceforge.net
Thu Jul 6 19:03:51 CEST 2006


Bugs item #1518190, was opened at 2006-07-06 16:46
Message generated for change (Comment added) made by theller
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1518190&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Thomas Heller (theller)
>Assigned to: Neal Norwitz (nnorwitz)
Summary: c_void_pointer should accept a long pointer > 0x7fffffff

Initial Comment:
Mike Fletcher reported this problem:

http://tinyurl.com/esneq

Currently, the c_void_p constructor calls
PyLong_AsVoidPtr(value), in Modules/_ctypes/cfield.c,
near line 1491.

This call should be changed to use either
PyLong_AsUnsignedLongMask() or
PyLong_AsUnsignedLongLongMask() depending on
sizeof(void *), and cast the result to (void *).

This change would also make the c_void_p behaviour more
consistent with the other c_int, c_long and so on
constructors since all of them mask the value to the
number of bits they can accept.

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

>Comment By: Thomas Heller (theller)
Date: 2006-07-06 19:03

Message:
Logged In: YES 
user_id=11105

Assigning to Neal for review (please).  The #if block is not
really needed imo, but I used it for clarity - it is copied
verbatim from Objects/longobject.c, which would throw
compile errors if the conditions are not fulfilled.

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

Comment By: Thomas Heller (theller)
Date: 2006-07-06 18:56

Message:
Logged In: YES 
user_id=11105

Attached a patch, with tests, that fixes this bug.
PyInt_AsUnsignedLongMask() and
PyInt_AsUnsignedLongLongMask() is what we need to use.

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

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


More information about the Python-bugs-list mailing list