diff -ur -x importlib.h /home/lemburg/egenix/projects/PyRun/Python-3.4.1/Lib/importlib/_bootstrap.py ./Lib/importlib/_bootstrap.py --- /home/lemburg/egenix/projects/PyRun/Python-3.4.1/Lib/importlib/_bootstrap.py 2014-05-19 07:19:38.000000000 +0200 +++ ./Lib/importlib/_bootstrap.py 2014-06-12 17:45:06.192649090 +0200 @@ -1356,6 +1364,7 @@ raise ImportError('{!r} is not a frozen module'.format(name), name=name) code = _call_with_frames_removed(_imp.get_frozen_object, name) + module.__file__ = code.co_filename exec(code, module.__dict__) @classmethod diff -ur -x importlib.h /home/lemburg/egenix/projects/PyRun/Python-3.4.1/Python/import.c ./Python/import.c --- /home/lemburg/egenix/projects/PyRun/Python-3.4.1/Python/import.c 2014-05-19 07:19:40.000000000 +0200 +++ ./Python/import.c 2014-06-12 02:12:33.739715917 +0200 @@ -1268,6 +1268,23 @@ if (d == NULL) { goto err_return; } + + /* Remember the filename as the __file__ attribute, for all frozen modules + except the special _frozen_importlib one (doing this breaks + bootstrapping for some reason) + + Note: this function is only called during startup of the interpreter + and by C extensions. All other imports of frozen modules are handled by + the importlib. See importlib._bootstrap.FrozenImporter for details. + + */ + if (PyUnicode_CompareWithASCIIString(name, "_frozen_importlib") != 0) { + if (PyDict_SetItemString(d, + "__file__", + ((PyCodeObject *)co)->co_filename)) + PyErr_Clear(); /* Not important enough to report */ + } + m = exec_code_in_module(name, d, co); if (m == NULL) goto err_return;