Issue 653542: PyLong_AsVoidPtr()/PyLong_FromVoidPtr() - Python tracker (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/37611

classification

Title: PyLong_AsVoidPtr()/PyLong_FromVoidPtr()
Type: Stage:
Components: Documentation Versions:

process

Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: david_abrahams, fdrake, georg.brandl, loewis, tim.peters
Priority: normal Keywords:

Created on 2002-12-14 01:02 by david_abrahams, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (7)
msg13609 - (view) Author: David Abrahams (david_abrahams) Date: 2002-12-14 01:02
These two functions have mutually-recursive definitions in the docs (which is to say, none).
msg13610 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-12-14 14:15
Logged In: YES user_id=21627 Would you like to provide a patch?
msg13611 - (view) Author: David Abrahams (david_abrahams) Date: 2002-12-14 14:37
Logged In: YES user_id=52572 Thanks for asking but the problem is that I don't know what they do!
msg13612 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-12-14 16:15
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 */ }
msg13613 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2003-09-23 22:00
Logged In: YES user_id=3066 Tim, aren't these your babies?
msg13614 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2003-09-24 01:25
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.
msg13615 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-12-26 22:59
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.
History
Date User Action Args
2022-04-10 16:06:02 admin set github: 37611
2002-12-14 01:02:41 david_abrahams create