[ python-Bugs-653542 ] PyLong_AsVoidPtr()/PyLong_FromVoidPtr()

SourceForge.net noreply at sourceforge.net
Mon Dec 26 23:59:37 CET 2005


Bugs item #653542, was opened at 2002-12-14 02:02
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=653542&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: Documentation
Group: None
>Status: Closed
>Resolution: Works For Me
Priority: 5
Submitted By: David Abrahams (david_abrahams)
Assigned to: Nobody/Anonymous (nobody)
Summary: PyLong_AsVoidPtr()/PyLong_FromVoidPtr()

Initial Comment:
These two functions have mutually-recursive definitions 
in the docs (which is to say, none).

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

>Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-12-26 23:59

Message:
Logged In: YES 
user_id=1188172

I think the definitions are pretty clear to understand.
PyLong_FromVoidPtr makes a long from a pointer,
PyLong_AsVoidPtr makes a pointer from a long... closing as
Works for Me.

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

Comment By: Tim Peters (tim_one)
Date: 2003-09-24 03:25

Message:
Logged In: YES 
user_id=31435

Nope.  Guido checked them in 5 years ago, in rev 1.48.  To 
judge from the checkin comment, the code may actually have 
come from Greg Stein.  I don't have time for it, so unassigning.

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

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2003-09-24 00:00

Message:
Logged In: YES 
user_id=3066

Tim, aren't these your babies?

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

Comment By: Martin v. Löwis (loewis)
Date: 2002-12-14 17:15

Message:
Logged In: YES 
user_id=21627

Something very simple:

PyObject *
PyLong_FromVoidPtr(void *p)
{
#if SIZEOF_VOID_P <= SIZEOF_LONG
	return PyInt_FromLong((long)p);
#else

#ifndef HAVE_LONG_LONG
#   error "PyLong_FromVoidPtr: sizeof(void*) > sizeof(long), 
but no long long"
#endif
#if SIZEOF_LONG_LONG < SIZEOF_VOID_P
#   error "PyLong_FromVoidPtr: sizeof(LONG_LONG) < sizeof
(void*)"
#endif
	/* optimize null pointers */
	if (p == NULL)
		return PyInt_FromLong(0);
	return PyLong_FromLongLong((LONG_LONG)p);

#endif /* SIZEOF_VOID_P <= SIZEOF_LONG */
}


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

Comment By: David Abrahams (david_abrahams)
Date: 2002-12-14 15:37

Message:
Logged In: YES 
user_id=52572

Thanks for asking but the problem is that I don't know what 
they do!

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

Comment By: Martin v. Löwis (loewis)
Date: 2002-12-14 15:15

Message:
Logged In: YES 
user_id=21627

Would you like to provide a patch?

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

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


More information about the Python-bugs-list mailing list