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

Pypy fixes #7839

Merged
merged 2 commits into from
Jul 19, 2016
Merged

Pypy fixes #7839

merged 2 commits into from
Jul 19, 2016

Conversation

mattip
Copy link
Member

@mattip mattip commented Jul 15, 2016

two simple fixes for PyPy:

  1. When PyType_Ready is called, function slots like tp_as_number.nb_add are wrapped into a Python function and put into the Python type object. Any that are NULL are ignored. Later, when umath is imported, these are overloaded for scalars. Before this patch the functions were NULL when PyType_Ready was called, so PyPy was ignoring the overload.
  2. PyPy has no Makefile

@@ -126,8 +126,10 @@ def get_flags_linker_so(self):
# from it.
import distutils.sysconfig as sc
g = {}
filename = sc.get_makefile_filename()
sc.parse_makefile(filename, g)
if '__pypy__' not in sys.builtin_module.names:
Copy link
Member

Choose a reason for hiding this comment

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

I feel like a try/except might be more appropriate than an explicit pypy check? That way we're robust against pypy adding a makefile, or being used with some other python implementation that also doesn't have a makefile.

@charris
Copy link
Member

charris commented Jul 16, 2016

Please squash the commits and follow the commit message template in doc/source//dev/gitwash/development_workflow.rst.

filename = sc.get_makefile_filename()
sc.parse_makefile(filename, g)
except AttributeError as e:
if 'get_makefile_filename' in e.message:
Copy link
Member

Choose a reason for hiding this comment

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

Instead of checking the error message, would using an else block work? e.g.,

try:
    get_filename = sc.get_makefile_filename
except AttributeError:
    pass  # no Makefile
else:
    sc.parsefile(get_filename(), g)

It's generally a good idea to contain no more than the single line at which the exception can occur in the try block.

@mattip
Copy link
Member Author

mattip commented Jul 18, 2016

Updated as per shoyer's comment

@njsmith
Copy link
Member

njsmith commented Jul 19, 2016

LGTM, thanks @mattip

@njsmith njsmith merged commit e825e76 into numpy:master Jul 19, 2016
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.

None yet

4 participants