-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: Move ctypes ImportError catching to appropriate place #8898
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e273fb5
Move ctypes ImportError catching to appropriate place
davidjn 69143e7
Add dummy_ctype to _internal.py and refactor some ctypes methods
davidjn c9fe3ba
BUG: Updating dummy_ctype's behavior.
davidjn b29ae31
Adding numpy/core/tests/test_internal.py.
davidjn bb56070
Add numpy import to _internal.py.
davidjn 3af4fe5
BUG: move numpy import into _getintp_ctype
davidjn 4e2ab70
BUG: Removing sys mangling from test_ctypes_is_not_available
davidjn bd3011e
Adding GetIntPCtypeTest and minor clean up
9b19671
Fixing GetIntPCtypeTest for x-platform
0e4942a
BUG: Use cache in _getintp_ctype, move tests.
82bebd2
_cyptes._arr.shape -> _ctypes.shape
davidjn 647a75e
BUG: Fixing tests and actually udating _getintp_ctype to use cache.
e75a486
BUG: Fixing tests and actually udating _getintp_ctype to use cache.
06b3a82
BUG: Updates to TestCTypes test class.
2652a1e
BUG: list casting -> typle casting.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Debatable whether testing implementation details like this (and the one above) makes any sense
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.
If you feel strongly, I'll remove it. I think its a good check to keep. For instance, if someone decides to add an "import ctypes" statement into one of these methods in the future, this assertion will catch that. Otherwise, the test will continue to pass.
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.
Yeah, my concernt is that that's somewhat artificial, and doesn't really catch us doing
import ctypes
anywhere else - these tests wouldn't catch the bug that caused you to patch this in the first place, for instance.I don't feel strongly about it, but would appreciate input from someone else on a better way to test this.
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.
Fair enough. Will wait for additional input.
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'm almost tempted to spin off a new python interpreter without ctypes to run the test, to ensure it can't break anything else
You might also be able to get your
sys.modules
hackery to work if you try to put everything back together again, but also a little risky.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.
Hey Eric,
I tried again with the sys.modules hackery, and trying to put things back together again with the try/finally block. Unfortunately, other tests continue to fail. I guess this is because tests are run in parallel. With the current setup (setting ctypes = None), we will have similar cross-test side effects, but I guess we are getting lucky in that it isn't causing any errant failures.
By "spin off a new python interpreter", are you suggesting to execute the test with python's subprocess?
Eg (?):
def some_test(self):
self.assertEqual(0, subprocess.call(sys.executable, "-c", test_code)
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, that is what I mean. I'm not actually sure that's a good idea though, and I don't think you should risk wasting time trying it until someone else weighs in.