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

Inconsistency with PyLong_FromVoidPtr() and PyLong_AsVoidPtr() #60484

Closed
serhiy-storchaka opened this issue Oct 18, 2012 · 3 comments
Closed
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 16280
Nosy @mdickinson, @serhiy-storchaka

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 = 'https://github.com/mdickinson'
closed_at = <Date 2012-10-18.21:31:56.992>
created_at = <Date 2012-10-18.20:36:45.724>
labels = ['interpreter-core', 'type-bug']
title = 'Inconsistency with PyLong_FromVoidPtr() and PyLong_AsVoidPtr()'
updated_at = <Date 2012-10-18.21:31:56.991>
user = 'https://github.com/serhiy-storchaka'

bugs.python.org fields:

activity = <Date 2012-10-18.21:31:56.991>
actor = 'mark.dickinson'
assignee = 'mark.dickinson'
closed = True
closed_date = <Date 2012-10-18.21:31:56.992>
closer = 'mark.dickinson'
components = ['Interpreter Core']
creation = <Date 2012-10-18.20:36:45.724>
creator = 'serhiy.storchaka'
dependencies = []
files = []
hgrepos = []
issue_num = 16280
keywords = []
message_count = 3.0
messages = ['173295', '173297', '173298']
nosy_count = 3.0
nosy_names = ['mark.dickinson', 'python-dev', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue16280'
versions = ['Python 2.7', 'Python 3.2', 'Python 3.3', 'Python 3.4']

@serhiy-storchaka
Copy link
Member Author

This issue is taken out of the discussion of bpo-16277.

PyLong_FromVoidPtr() has special case which maps null pointer to zero integer.

On platforms where (uintptr_t)(void *)0 is 0, this code has no effect and is redundant. But on hypothetic platforms where (uintptr_t)(void *)0 is not 0, PyLong_FromVoidPtr() maps NULL to 0 and then PyLong_AsVoidPtr() maps 0 to non-NULL. Also PyLong_FromVoidPtr() is multivalued, it maps to 0 NULL and may be some other pointer.

PyLong_FromVoidPtr() in 2.7 has special case only on platform where sizeof(void*) > sizeof(long). It commented as "optimize null pointers". In 3.x branch such optimization non needed because PyLong_FromUnsignedLongLong() already has special case for short integers.

The solution of this issue is getting rid of a special case, or adding a special case in PyLong_FromVoidPtr(). It is desirable to make it avoiding multivaluedity.

@serhiy-storchaka serhiy-storchaka added performance Performance or resource usage interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Oct 18, 2012
@python-dev
Copy link
Mannequin

python-dev mannequin commented Oct 18, 2012

New changeset 5ae4ff03b35f by Mark Dickinson in branch 'default':
bpo-16280: Drop questionable special-casing of null pointer in PyLong_FromVoidPtr.
http://hg.python.org/cpython/rev/5ae4ff03b35f

@mdickinson
Copy link
Member

Dropped the special case for 3.4. I'm leaving the code as-is for the maintenance branches, as discussed in bpo-16277.

@mdickinson mdickinson self-assigned this Oct 18, 2012
@mdickinson mdickinson added type-bug An unexpected behavior, bug, or error and removed performance Performance or resource usage labels Oct 18, 2012
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants