cpython: b5b81a3eb6e6 (original) (raw)
Mercurial > cpython
changeset 89900:b5b81a3eb6e6 3.4
Issue #20884: Don't assume in importlib.__init__ that __file__ is defined. [#20884]
Brett Cannon brett@python.org | |
---|---|
date | Fri, 21 Mar 2014 10:58:33 -0400 |
parents | bdad874195d6 |
children | 42ae7b2524a2 09fd93f7ce02 |
files | Lib/importlib/__init__.py Misc/NEWS |
diffstat | 2 files changed, 8 insertions(+), 1 deletions(-)[+] [-] Lib/importlib/__init__.py 7 Misc/NEWS 2 |
line wrap: on
line diff
--- a/Lib/importlib/init.py +++ b/Lib/importlib/init.py @@ -22,7 +22,12 @@ else: # a second copy of the module. _bootstrap.name = 'importlib._bootstrap' _bootstrap.package = 'importlib'
- try:
_bootstrap.__file__ = __file__.replace('__init__.py', '_bootstrap.py')[](#l1.9)
- except NameError:
# __file__ is not guaranteed to be defined, e.g. if this code gets[](#l1.11)
# frozen by a tool like cx_Freeze.[](#l1.12)
sys.modules['importlib._bootstrap'] = _bootstrappass[](#l1.13)
To simplify imports in test code
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -21,6 +21,8 @@ Core and Builtins Library ------- +- Issue #20884: Don't assume that file is defined on importlib.init. +