changeset: 89900:b5b81a3eb6e6 branch: 3.4 parent: 89871:bdad874195d6 user: Brett Cannon date: Fri Mar 21 10:58:33 2014 -0400 files: Lib/importlib/__init__.py Misc/NEWS description: Issue #20884: Don't assume in importlib.__init__ that __file__ is defined. diff -r bdad874195d6 -r b5b81a3eb6e6 Lib/importlib/__init__.py --- a/Lib/importlib/__init__.py Thu Mar 20 09:26:55 2014 +0100 +++ b/Lib/importlib/__init__.py Fri Mar 21 10:58:33 2014 -0400 @@ -22,7 +22,12 @@ # 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 diff -r bdad874195d6 -r b5b81a3eb6e6 Misc/NEWS --- a/Misc/NEWS Thu Mar 20 09:26:55 2014 +0100 +++ b/Misc/NEWS Fri Mar 21 10:58:33 2014 -0400 @@ -21,6 +21,8 @@ Library ------- +- Issue #20884: Don't assume that __file__ is defined on importlib.__init__. + - Issue #20879: Delay the initialization of encoding and decoding tables for 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