-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Ensure that a module within a namespace package can be found by --pyargs #1597
Conversation
return x | ||
try: | ||
path = loader.get_filename() | ||
except: |
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.
It is usually better to avoid bare except
clauses like this... could this be replaced by except ImportError
?
Appveyor caught a little problem with a test setup using PyPy on Windows: I'll fix that. @nicoddemus I'll incorporate your feedback. The reason why that try-except clause is needed is that sometimes I'll catch explicitly that exception and add a comment to explain why that is necessary. |
Fixed problem caused in a test on Windows by file left open by PyPy and not immediately garbage collected.
I incorporated the feedback from @nicoddemus and also fixed a problem caused in a test on Windows by a file left open by PyPy and not immediately garbage collected. |
Thanks! 😁 LGTM. Could someone else take a look as well? Also, we need a |
Shall I add the entries in |
Please do. We usually ask for PR submitters to do it, but this has gone back and forth a few times already and I didn't want to ask for one more, hehehe. 😅 |
It seems this is now in conflict. Would you please merge/rebase to fix it? Thanks! |
Fixed problem caused in a test on Windows by file left open by PyPy and not immediately garbage collected.
Rebased the PR. |
Thanks! 😁 I will merge this later unless someone says otherwise. |
Thanks, sorry for the delay! 😁 |
This PR supersedes #1568 and addresses the problem highlighted in #1567 and in part #478.
See #1568 for the description of the test setup.
Unlike #1568, this PR does not attempt to emulate the import machinery to determine the filename of a package or directory, delegating instead most of the work to the
pkgutil
module of the standard library.NB In case of a non-top-level module or package,
pkgutil.find_loader
will import the parent package or packages.