changeset: 90046:001a6dc996e7 branch: 3.4 parent: 90044:ed81acc970d9 user: Martin v. Löwis date: Sun Mar 30 21:07:25 2014 +0200 files: Lib/site.py Misc/NEWS Tools/freeze/freeze.py Tools/freeze/makeconfig.py description: Issue #16047: Fix module exception list and __file__ handling in freeze. Patch by Meador Inge. diff -r ed81acc970d9 -r 001a6dc996e7 Lib/site.py --- a/Lib/site.py Sun Mar 30 15:07:09 2014 -0400 +++ b/Lib/site.py Sun Mar 30 21:07:25 2014 +0200 @@ -364,12 +364,17 @@ builtins.credits = _sitebuiltins._Printer("credits", """\ Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands for supporting Python development. See www.python.org for more information.""") - here = os.path.dirname(os.__file__) + files, dirs = [], [] + # Not all modules are required to have a __file__ attribute. See + # PEP 420 for more details. + if hasattr(os, '__file__'): + here = os.path.dirname(os.__file__) + files.extend(["LICENSE.txt", "LICENSE"]) + dirs.extend([os.path.join(here, os.pardir), here, os.curdir]) builtins.license = _sitebuiltins._Printer( "license", "See http://www.python.org/download/releases/%.5s/license" % sys.version, - ["LICENSE.txt", "LICENSE"], - [os.path.join(here, os.pardir), here, os.curdir]) + files, dirs) def sethelper(): diff -r ed81acc970d9 -r 001a6dc996e7 Misc/NEWS --- a/Misc/NEWS Sun Mar 30 15:07:09 2014 -0400 +++ b/Misc/NEWS Sun Mar 30 21:07:25 2014 +0200 @@ -137,6 +137,9 @@ Tools/Demos ----------- +- Issue #16047: Fix module exception list and __file__ handling in freeze. + Patch by Meador Inge. + - Issue #11824: Consider ABI tags in freeze. Patch by Meador Inge. - Issue #20535: PYTHONWARNING no longer affects the run_tests.py script. diff -r ed81acc970d9 -r 001a6dc996e7 Tools/freeze/freeze.py --- a/Tools/freeze/freeze.py Sun Mar 30 15:07:09 2014 -0400 +++ b/Tools/freeze/freeze.py Sun Mar 30 21:07:25 2014 +0200 @@ -365,6 +365,10 @@ else: mf.load_file(mod) + # Alias "importlib._bootstrap" to "_frozen_importlib" so that the + # import machinery can bootstrap. + mf.modules["_frozen_importlib"] = mf.modules["importlib._bootstrap"] + # Add the main script as either __main__, or the actual module name. if python_entry_is_main: mf.run_script(scriptfile) diff -r ed81acc970d9 -r 001a6dc996e7 Tools/freeze/makeconfig.py --- a/Tools/freeze/makeconfig.py Sun Mar 30 15:07:09 2014 -0400 +++ b/Tools/freeze/makeconfig.py Sun Mar 30 21:07:25 2014 +0200 @@ -3,7 +3,7 @@ # Write the config.c file -never = ['marshal', 'imp', '_ast', '__main__', 'builtins', +never = ['marshal', '_imp', '_ast', '__main__', 'builtins', 'sys', 'gc', '_warnings'] def makeconfig(infp, outfp, modules, with_ifdef=0):