-
Notifications
You must be signed in to change notification settings - Fork 288
Import the ctypes module. #767
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
Conversation
1ed9b71
to
6730b88
Compare
@@ -719,6 +719,9 @@ vBOOL_get(void *ptr, Py_ssize_t size) | |||
} | |||
#endif | |||
|
|||
// Pyston change: We don't run CPython's ./configure so we didn't have this defined. | |||
#define SIZEOF__BOOL 1 |
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.
Could we just put this in our pyconfig.h?
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.
True, that is a better place.
could we get a test that just imports ctypes? |
096f88d
to
59e4e06
Compare
If both a metaclass and an instance of it are defined in C extensions, the metaclass doesn't have attrs_offset != 0 or tp_dictoffset != 0 which causes the call to PyType_Ready on the instance to fail.
- Temporarily disable code for ctypes that requires class descriptors. - Skip the attribute lookup for __new__ for the base type class and directly call a special function assigned to tp_new. - Add a #define from CPython's ./configure - Add test.
The test was passing before by using the fallback behavior, but importing ctypes successfully makes it try to use it and fails.
9300acd
to
fb15223
Compare
Alright, all changes made, tests pass again. |
@@ -2044,13 +2044,21 @@ PyCSimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) | |||
break; | |||
} | |||
|
|||
if (ml) { | |||
// TODO: Pyston change: |
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 it's best if we can avoid these kinds of "soft" failures, since it'll potentially be much harder to debug why we get a no attribute "from_param"
than a "hard" error like "Py_FatalError: unimplemented". I tried, though, to think of some other way to get around this, and I couldn't think of anything better so let's just go with this and hope we remember that this is here :)
Nice, this now supports the small usage we have in the dropbox codebase :) |
This PR allows us to compile the ctypes module and run
import ctypes
. Functionality has not been tested. This is part of WIP to run NumPy.