-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
BUG: gh-10882 may have broken ctypes compatibility in older versions of python #11150
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
Comments
If the nightly wheels build cleanly we can close this. |
That assumes that this was tested... |
I am confused as to what the user-experienced problem is. From the cpython link, the following fails:
on an older python, whether I use Edit: The error changed from a |
@eric-wieser could you clarify if the problem is a different exception type or something deeper? |
@mattip: I think the case that matters is |
Turns out my WSL has python 2.7.12, so I'm all set to test this: >>> sys.version_info
'2.7.12 (default, Dec 4 2017, 14:50:18) \n[GCC 5.4.0 20160609]'
>>> bad = ctypes.c_long(42)
>>> ctypes.sizeof(bad) # this failure requires 64-bit long (ie, not windows native)
8
# 1.14
>>> np.asarray(bad)
RuntimeWarning: Item size computed from the PEP 3118 buffer format string does not match the actual item size.
array(42)
# master
>>> np.asarray(bad)
RuntimeError: Item size computed from the PEP 3118 buffer format string does not match the actual item size. |
@eric-wieser We can close this now? |
Not unless things have changed since I ran my test above (which shows it failing) |
Hmm. I vote that we document the required versions, with a strong suggest that folks keep current. Given that the problems are fixed upstream that seems reasonable. What about python 3.5? EDIT: I'm going to propose dropping 3.4 in the 1.16 release. |
In case it changes your mind, ubuntu 16.04 ships with python 2.7.12, which exhibits the ctypes bug |
I could try tweaking #10882 to have a special case for ctypes objects, |
Sure, give it a shot, but don't spend a lot of time on it. |
…ype(ctype_obj)) Fixes numpygh-10528 Fixes numpygh-10978 Fixes numpygh-11150 A warning is thrown when ctypes misbehaves, in order to not hide issues that need fixing upstream
Reopening - this is a real issue for
After this change, we now reject the PEP3118 interface, and never check This causes toinsson/pyrealsense#82, which unfortunately they never raised upstream. #12380 has made the error message even more cryptic, so we really ought to fix this for 1.16. |
The follow-on issue #12421 was left open but tentatively declared "won't fix", does that mean this issue is also "won't fix", or at least can be removed from the 1.16 milestone? |
Yeah, this can be removed from the milestone |
I also stumbled on this: I have unrelated buffer interface (inherited from ctypes impl) and my custom array_interface that I'd like to be used |
@eric-wieser we have dropped support for python<3.8, I think we can close this? |
Agreed with Matti, seems like we can close it with old Python versions long EOL and unsupported. |
#10882 changed the behavior of
np.array
from.__array_interface__
insteadabort()
due to bad error silencing (ctypeslib.as_array aborts #6741)__array_interface__
insteadTo
__array_interface__
insteadThis means that objects which incorrectly implement the buffer interface now fail loudly, rather than silently-or-with-abort().
Unfortunately, prior to python/cpython#31, (before 2.7.14 / 3.6.3 / 3.7.0) ctypes did not implement the buffer interface correctly for integer types (the format and itemsize didn't match)
Do we have a minimum supported patch version of python? If so, should we enable tests for it so that this doesn't happen again?
The text was updated successfully, but these errors were encountered: