Merge lp:~vila/bzr/712474-module-available into lp:bzr
Proposed by
Vincent Ladeuil
Status: | Merged |
---|---|
Approved by: | John A Meinel |
Approved revision: | no longer in the source branch. |
Merged at revision: | 6076 |
Proposed branch: | lp:~vila/bzr/712474-module-available |
Merge into: | lp:bzr |
Diff against target: |
40 lines (+14/-4) 2 files modified
bzrlib/tests/features.py (+10/-4) doc/en/release-notes/bzr-2.5.txt (+4/-0) |
To merge this branch: | bzr merge lp:~vila/bzr/712474-module-available |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John A Meinel | Approve | ||
bzr-core | Pending | ||
Review via email:
|
Commit message
ModuleAvailable
Description of the change
__import__ doesn't check that a module has already been imported, don't use it.
See the bug report for a real life use case (bzr-svn plugin).
To post a comment you must log in.
I think checking sys.modules should do instead, something like:
sentinel = object() get(self. module_ name) _(self. module_ name, {}, {}, [''])
module = sys.modules.
if module is None:
return False
if module is sentinel:
try:
module = __import_
except ImportError: # import can raise other things, but that's a bug
return False
return True
That should save me worrying needlessly about exec on an interpolated string.