-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Removed PyString refs from extension modules #28322
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -4,11 +4,7 @@ from cpython cimport PyTypeObject | |||
cdef extern from *: | ||||
""" | ||||
PyObject* char_to_string(const char* data) { | ||||
#if PY_VERSION_HEX >= 0x03000000 | ||||
return PyUnicode_FromString(data); | ||||
#else | ||||
return PyString_FromString(data); | ||||
#endif | ||||
} | ||||
""" | ||||
object char_to_string(const char* data) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldnt L14 be removed too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's actually used here: pandas/pandas/_libs/tslibs/period.pyx Line 1267 in 2d65e38
So maybe but would require a more comprehensive refactor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that just becomes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool - I'll give it a look. Seems like this caused a somewhat surprising failure so that might solve There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm so didn't realize the cdef of the tripled quoted string was actually using that as a macro. Was thinking of cimporting PyUnicode_FromString directly but looks like that isn't available until Cython 3.0.0 For now going to revert to macro |
||||
|
@@ -18,7 +14,6 @@ cdef extern from "Python.h": | |||
# Note: importing extern-style allows us to declare these as nogil | ||||
# functions, whereas `from cpython cimport` does not. | ||||
bint PyUnicode_Check(object obj) nogil | ||||
bint PyString_Check(object obj) nogil | ||||
bint PyBool_Check(object obj) nogil | ||||
bint PyFloat_Check(object obj) nogil | ||||
bint PyComplex_Check(object obj) nogil | ||||
|
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 think there's one more PY_VERSION_HEX check in compat_helper that could go
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.
Yea I was looking at that but I'm planning on the compat stuff in a separate PR