-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Pypy fixes #15080
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 #15080
Conversation
Current coverage is 84.77% (diff: 100%)@@ master #15080 diff @@
==========================================
Files 145 145
Lines 51212 51220 +8
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 43413 43421 +8
Misses 7799 7799
Partials 0 0
|
commit 2e3c256 fixes a bug where substitution of |
@@ -26,9 +26,9 @@ from cpython cimport (PyDict_New, PyDict_GetItem, PyDict_SetItem, | |||
PyBytes_GET_SIZE, | |||
PyUnicode_GET_SIZE) | |||
|
|||
try: | |||
IF PY_MAJOR_VERSION == 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this more typical? (and already defined)
#if PY_VERSION_HEX >= 0x03000000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is more typical for C
code, but converting a pyx
file to C
happens during a cython compiliation, and the only variables available are the ones appearing in cython_compile_time_env AFAICT, which is why I needed to define the variable in setup.py.
It is not surprising that this is not well known, the only reference I could find on it was a stack overflow question. I tried all different ways to rewrite this code to keep the PyString_GET_SIZE
on python2 and make it PyUnicode_GET_SIZE
on python3, this was the least intrusive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly can use these constants?
https://github.com/cython/cython/blob/master/Cython/Includes/cpython/version.pxd
from
http://stackoverflow.com/a/28316509/3657742
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chris-b1 that did the trick, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chris-b1 I could not get that to work since this is needed at compile time, so I needed the upper-case IF <env_var>
, not a runtime if <value>
:( I reverted to the original fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this still seems very odd, the why can't you do
#if PY_VERSION_HEX >= 0x03000000
from cpython cimport PyUnicode_GET_SIZE as PyString_GET_SIZE
#else
from cpython cimport PyString_GET_SIZE
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that. It does not work for me. Running python3 setup.py cython
results in a lib.c
with PyString_GET_SIZE in the translated max_len_string_array
, where if it worked that would become PyUnicode_GET_SIZE
@@ -149,6 +149,11 @@ def build_extensions(self): | |||
|
|||
with open(outfile, "w") as f: | |||
f.write(pyxcontent) | |||
# XXX used only in lib.pyx, assumes old_build_ext | |||
if not self.cython_compile_time_env: | |||
self.cython_compile_time_env = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
@@ -427,7 +427,11 @@ int Object_npyObjectAddKey(void *prv, JSOBJ obj, JSOBJ name, JSOBJ value) { | |||
|
|||
// only fill label array once, assumes all column labels are the same | |||
// for 2-dimensional arrays. | |||
#ifdef PYPY_VERSION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you are defining this on external compile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is defined when compiling c-extensions with the PyPy headers
updated pull request as per reviews and suggestions |
BUG: bring implementation into compliance with cython documentation BUG: fix improper use of conditional compilation closes pandas-dev#15080
An alternative to the |
Sorry for the noise |
benign changes visa-vis CPython needed to build pandas for PyPy 2.7