8000 BUG: core: fix NPY_TITLE_KEY macro on pypy by pv · Pull Request #10860 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: core: fix NPY_TITLE_KEY macro on pypy #10860

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

Merged
merged 1 commit into from
Apr 9, 2018

Conversation

pv
Copy link
Member
@pv pv commented Apr 7, 2018

On Pypy, dictionary keys do not necessarily preserve object identity.

This however was assumed by the NPY_TITLE_KEY macro, which relies on
descriptor.c:568 using the same 'title' object both as a dictionary key
as an entry in the tuple inserted.

Since the items in the field dict are unique, value identity is however
sufficient for the NPY_TITLE_KEY macro. On PyPy, fix the macro by
comparing values instead.

cf. https://bitbucket.org/pypy/pypy/issues/2789

cc: @mattip

@pv pv force-pushed the pypyfix-npy-title-key branch from b76ad0c to adb3997 Compare April 7, 2018 21:57
#endif
return 0;
}
#define NPY_TITLE_KEY(key, value) (NPY_TITLE_KEY_check(key, value))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the macro wrapping? Should both paths maybe be replaced with the inline function, which would narrow the scope of the PYPY check?

Copy link
Member Author
@pv pv Apr 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because there's code that does
if NPY_TITLE_KEY(key, value) { ... and omits the parentheses, and I wanted to keep this PR minimal and obviously correct for non-pypy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with comments explaining why.

On Pypy, dictionary keys do not necessarily preserve object identity.

This however was assumed by the NPY_TITLE_KEY macro, which relies on
descriptor.c:568 using the same 'title' object both as a dictionary key
as an entry in the tuple inserted.

Since the items in the field dict are unique, value identity is however
sufficient for the NPY_TITLE_KEY macro. On PyPy, fix the macro by
comparing values instead.
@mattip
Copy link
Member
mattip commented Apr 9, 2018

LGTM

@mattip
Copy link
Member
mattip commented Apr 9, 2018

IMO this should be in 1.15, does it justify an entry in the release notes?

@charris
Copy link
Member
charris commented Apr 9, 2018

We mostly use the release notes for enhancements/deprecations/signature_changes -- basically things that change intended behavior or add options. Bug fixes for old/minor problems don't count in that regard. Newly introduced bugs that everyone notices are a different matter.

@charris charris merged commit 105bdfd into numpy:master Apr 9, 2018
@charris
Copy link
Member
charris commented Apr 9, 2018

Thanks @pv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0