diff options
author | Brett Cannon <brett@python.org> | 2014-03-21 15:01:02 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2014-03-21 15:01:02 (GMT) |
commit | 5d8a2444bf4787dacd48517f19ac28c6ff304380 (patch) | |
tree | 5110f0d2f2b8742cc8c1843b5077e5c623c9ee52 | |
parent | a77d0c36e561c3f56dee1c4b0fdd9451d6f8a894 (diff) | |
parent | a00c2407caed1fe61bdd92788f7a8eb27fcff969 (diff) | |
download | cpython-5d8a2444bf4787dacd48517f19ac28c6ff304380.zip cpython-5d8a2444bf4787dacd48517f19ac28c6ff304380.tar.gz cpython-5d8a2444bf4787dacd48517f19ac28c6ff304380.tar.bz2 |
Merge for issue #20884
-rw-r--r-- | Lib/importlib/__init__.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/importlib/__init__.py b/Lib/importlib/__init__.py index f6adc5c..1bc9947 100644 --- 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' - _bootstrap.__file__ = __file__.replace('__init__.py', '_bootstrap.py') + try: + _bootstrap.__file__ = __file__.replace('__init__.py', '_bootstrap.py') + except NameError: + # __file__ is not guaranteed to be defined, e.g. if this code gets + # frozen by a tool like cx_Freeze. + pass sys.modules['importlib._bootstrap'] = _bootstrap # To simplify imports in test code |