Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyLong_AsVoidPtr()/PyLong_FromVoidPtr() #37611

Closed
davidabrahams mannequin opened this issue Dec 14, 2002 · 7 comments
Closed

PyLong_AsVoidPtr()/PyLong_FromVoidPtr() #37611

davidabrahams mannequin opened this issue Dec 14, 2002 · 7 comments
Labels
docs Documentation in the Doc dir

Comments

@davidabrahams
Copy link
Mannequin

davidabrahams mannequin commented Dec 14, 2002

BPO 653542
Nosy @tim-one, @loewis, @freddrake, @birkenfeld

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2005-12-26.22:59:37.000>
created_at = <Date 2002-12-14.01:02:41.000>
labels = ['docs']
title = 'PyLong_AsVoidPtr()/PyLong_FromVoidPtr()'
updated_at = <Date 2005-12-26.22:59:37.000>
user = 'https://bugs.python.org/davidabrahams'

bugs.python.org fields:

activity = <Date 2005-12-26.22:59:37.000>
actor = 'georg.brandl'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2002-12-14.01:02:41.000>
creator = 'david_abrahams'
dependencies = []
files = []
hgrepos = []
issue_num = 653542
keywords = []
message_count = 7.0
messages = ['13609', '13610', '13611', '13612', '13613', '13614', '13615']
nosy_count = 5.0
nosy_names = ['tim.peters', 'loewis', 'fdrake', 'georg.brandl', 'david_abrahams']
pr_nums = []
priority = 'normal'
resolution = 'works for me'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue653542'
versions = []

@davidabrahams
Copy link
Mannequin Author

davidabrahams mannequin commented Dec 14, 2002

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

@davidabrahams davidabrahams mannequin closed this as completed Dec 14, 2002
@davidabrahams davidabrahams mannequin added the docs Documentation in the Doc dir label Dec 14, 2002
@davidabrahams davidabrahams mannequin closed this as completed Dec 14, 2002
@davidabrahams davidabrahams mannequin added the docs Documentation in the Doc dir label Dec 14, 2002
@loewis
Copy link
Mannequin

loewis mannequin commented Dec 14, 2002

Logged In: YES
user_id=21627

Would you like to provide a patch?

@davidabrahams
Copy link
Mannequin Author

davidabrahams mannequin commented Dec 14, 2002

Logged In: YES
user_id=52572

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

@loewis
Copy link
Mannequin

loewis mannequin commented Dec 14, 2002

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 */
}

@freddrake
Copy link
Member

Logged In: YES
user_id=3066

Tim, aren't these your babies?

@tim-one
Copy link
Member

tim-one commented Sep 24, 2003

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.

@birkenfeld
Copy link
Member

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

3 participants