Skip to content

Conversation

rudi-c
Copy link
Contributor

@rudi-c rudi-c commented Jul 28, 2015

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.

@rudi-c rudi-c force-pushed the ctypes branch 2 times, most recently from 1ed9b71 to 6730b88 Compare July 29, 2015 00:44
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

@kmod
Copy link
Collaborator

kmod commented Jul 29, 2015

could we get a test that just imports ctypes?

@rudi-c rudi-c force-pushed the ctypes branch 2 times, most recently from 096f88d to 59e4e06 Compare July 29, 2015 22:13
rudi-c added 6 commits July 30, 2015 16:10
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.
@rudi-c rudi-c force-pushed the ctypes branch 3 times, most recently from 9300acd to fb15223 Compare July 31, 2015 00:00
@rudi-c
Copy link
Contributor Author

rudi-c commented Jul 31, 2015

Alright, all changes made, tests pass again.

Copy link
Collaborator

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 :)

kmod added a commit that referenced this pull request Aug 1, 2015
Import the ctypes module.
@kmod kmod merged commit b04977a into pyston:master Aug 1, 2015
@kmod
Copy link
Collaborator

kmod commented Aug 1, 2015

Nice, this now supports the small usage we have in the dropbox codebase :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants