Commit 920df332 authored by Brett Cannon's avatar Brett Cannon

Issue #20884: Don't assume in importlib.__init__ that __file__ is

defined.
parent 7791cb27
...@@ -22,7 +22,12 @@ else: ...@@ -22,7 +22,12 @@ else:
# a second copy of the module. # a second copy of the module.
_bootstrap.__name__ = 'importlib._bootstrap' _bootstrap.__name__ = 'importlib._bootstrap'
_bootstrap.__package__ = 'importlib' _bootstrap.__package__ = 'importlib'
try:
_bootstrap.__file__ = __file__.replace('__init__.py', '_bootstrap.py') _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 sys.modules['importlib._bootstrap'] = _bootstrap
# To simplify imports in test code # To simplify imports in test code
......
...@@ -21,6 +21,8 @@ Core and Builtins ...@@ -21,6 +21,8 @@ Core and Builtins
Library Library
------- -------
- Issue #20884: Don't assume that __file__ is defined on importlib.__init__.
- Issue #20879: Delay the initialization of encoding and decoding tables for - Issue #20879: Delay the initialization of encoding and decoding tables for
base32, ascii85 and base85 codecs in the base64 module, and delay the base32, ascii85 and base85 codecs in the base64 module, and delay the
initialization of the unquote_to_bytes() table of the urllib.parse module, to initialization of the unquote_to_bytes() table of the urllib.parse module, to
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment