-
Notifications
You must be signed in to change notification settings - Fork 262
BF: be resilient to optional module non-ImportError exceptions upon import #618
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
…mport ATM h5py is giving a grief while trying to work on a filesystem without utf-8 encoding support in filenames.
Codecov Report
@@ Coverage Diff @@
## master #618 +/- ##
=========================================
- Coverage 90.31% 90.3% -0.01%
=========================================
Files 87 87
Lines 10810 10813 +3
Branches 1793 1793
=========================================
+ Hits 9763 9765 +2
- Misses 718 719 +1
Partials 329 329
Continue to review full report at Codecov.
|
raise Exception( | ||
"non ImportError could be thrown by some malfunctioning module " | ||
"upon import, and optional_package should catch it too") | ||
with mock.patch.object(builtins, '__import__', side_effect=raise_Exception): |
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.
In Python 3, builtins is __builtin__
, and in Python 2 you're setting builtins = __builtin__
. Could you just import __builtin__
and patch that here? I'm not sure what we're getting by adding this to py3k
.
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.
In Python 3, builtins is __builtin__
. I am confused with what you mean ;):
$> python3 -c 'import builtins'
$> python3 -c 'import __builtin__'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named '__builtin__'
py3k
is a module to establish the compatibility layer and feels intended to do so that code using it stays "python3" like. With this change then any code which needs to usebuiltins
module in either of pythons would do so with python3 naming. I didn't want to breed python 2-vs-3 code right here in the test
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.
Ah, perhaps this is an IPython thing.
In [1]: __builtin__
Out[1]: <module 'builtins' (built-in)>
But:
$ python -c 'import builtins; print(builtins is __builtin__)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name '__builtin__' is not defined
ok - merging since no disagreement ;-) |
ATM h5py is giving a grief while trying to work on a filesystem without
utf-8 encoding support in filenames.