diff -r f2c257820a73 Lib/importlib/__init__.py --- a/Lib/importlib/__init__.py Thu Mar 13 22:17:28 2014 -0400 +++ b/Lib/importlib/__init__.py Fri Mar 14 09:35:02 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