cpython/Python
Brett Cannon 442c9b92d8 Make importlib compatible with __import__ by "fixing" code.co_filename
paths.

__import__ does a little trick when importing from bytecode by
back-patching the co_filename paths to point to the file location
where the code object was loaded from, *not* where the code object was
originally created. This allows co_filename to point to a valid path.
Problem is that co_filename is immutable from Python, so a private
function -- imp._fix_co_filename() -- had to be introduced in order to
get things working properly. Originally the plan was to add a file
argument to marshal.loads(), but that failed as the algorithm used by
__import__ is not fully recursive as one might expect, so to be fully
backwards-compatible the code used by __import__ needed to be exposed.

This closes issue #6811 by taking a different approach than outlined
in the issue.
2011-03-23 16:14:42 -07:00
..
_warnings.c #11515: Merge with 3.1. 2011-03-15 05:59:46 +02:00
asdl.c Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
ast.c Issue #8914: fix various warnings from the Clang static analyzer v254. 2011-02-22 20:15:44 +00:00
bltinmodule.c Issue #3080: Add PyImport_ImportModuleLevelObject() function 2011-03-14 15:54:52 -04:00
ceval_gil.h Fix the GIL with subinterpreters. Hopefully this will allow mod_wsgi to work with 3.2. 2011-01-15 11:37:11 +00:00
ceval.c Issue #7330, #10833: Replace %100s by %.100s and %200s by %.200s 2011-03-22 01:09:21 +01:00
codecs.c Merged revisions 84655 via svnmerge from 2010-09-09 20:33:43 +00:00
compile.c Remove useless argument of _PyUnicode_AsDefaultEncodedString() 2011-03-02 01:03:11 +00:00
dtoa.c Issue #8914: fix various warnings from the Clang static analyzer v254. 2011-02-22 20:15:44 +00:00
dup2.c Merged revisions 85236 via svnmerge from 2010-10-05 22:18:29 +00:00
dynamic_annotations.c Make (most of) Python's tests pass under Thread Sanitizer. 2010-05-03 19:29:34 +00:00
dynload_aix.c Merged revisions 88430 via svnmerge from 2011-02-25 10:22:44 +00:00
dynload_dl.c dynload_dl.c: replace tabs by spaces 2011-02-23 11:29:28 +00:00
dynload_hpux.c Issue #3080: Remove unused argument of _PyImport_GetDynLoadFunc() 2011-02-22 23:16:19 +00:00
dynload_next.c Issue #3080: Remove unused argument of _PyImport_GetDynLoadFunc() 2011-02-22 23:16:19 +00:00
dynload_os2.c Issue #3080: Remove unused argument of _PyImport_GetDynLoadFunc() 2011-02-22 23:16:19 +00:00
dynload_shlib.c Issue #3080: Remove unused argument of _PyImport_GetDynLoadFunc() 2011-02-22 23:16:19 +00:00
dynload_stub.c REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
dynload_win.c Issue #3080: Remove unused argument of _PyImport_GetDynLoadFunc() 2011-02-22 23:16:19 +00:00
errors.c Issue #10780: PyErr_SetFromWindowsErrWithFilename() and 2010-12-28 00:28:21 +00:00
fileutils.c _Py_char2wchar() frees the memory on conversion error 2010-11-08 23:30:46 +00:00
formatter_unicode.c Merged revisions 75441 via svnmerge from 2009-10-27 17:31:26 +00:00
frozen.c Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
frozenmain.c Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
future.c Remove redundant includes of headers that are already included by Python.h. 2010-11-30 09:41:01 +00:00
getargs.c Issue #10833: Use PyErr_Format() and PyUnicode_FromFormat() instead of 2011-03-21 18:15:42 +01:00
getcompiler.c The GCC version is loooooooooong; put it on a new line. 2000-09-05 04:40:39 +00:00
getcopyright.c Merged revisions 87607 via svnmerge from 2011-01-01 15:32:26 +00:00
getcwd.c Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
getopt.c Issue #10089: Add support for arbitrary -X options on the command-line. 2010-10-21 13:42:28 +00:00
getplatform.c REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
getversion.c Merged revisions 83352,83355-83358,83362,83366,83368-83369 via svnmerge from 2010-08-01 19:17:57 +00:00
graminit.c Regenerate Python/graminit.c. 2010-07-12 14:18:21 +00:00
import.c Make importlib compatible with __import__ by "fixing" code.co_filename 2011-03-23 16:14:42 -07:00
importdl.c Issue #3080: _PyImport_LoadDynamicModule() uses Unicode for name and path 2011-03-14 15:54:07 -04:00
importdl.h Issue #3080: _PyImport_LoadDynamicModule() uses Unicode for name and path 2011-03-14 15:54:07 -04:00
makeopcodetargets.py Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
marshal.c Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
modsupport.c Issue #2443: Added a new macro, Py_VA_COPY, which is equivalent to C99 2010-08-11 17:31:17 +00:00
mysnprintf.c Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
mystrtoul.c Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
opcode_targets.h #4617: Previously it was illegal to delete a name from the local 2010-09-10 21:39:53 +00:00
peephole.c Issue #11244: Remove outdated peepholer check that was preventing the peepholer from folding -0 and -0.0. Thanks Eugene Toder for the patch. 2011-03-23 17:59:37 +00:00
pyarena.c Remove redundant includes of headers that are already included by Python.h. 2010-11-30 09:41:01 +00:00
pyctype.c Include files missed in r72044. 2009-04-27 20:54:42 +00:00
pyfpe.c Patch #411138: Rename config.h to pyconfig.h. Closes bug #231774. 2001-07-26 13:41:06 +00:00
pymath.c Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
pystate.c #11565: Merge with 3.1. 2011-03-16 11:35:38 +02:00
pystrcmp.c Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
pystrtod.c Issue #8914: fix various warnings from the Clang static analyzer v254. 2011-02-22 20:15:44 +00:00
Python-ast.c use only the hex version, since the revno is unreliable across repos 2011-03-13 16:36:08 -05:00
pythonrun.c Fix #11586: typo in initfsencoding() 2011-03-20 23:09:03 +01:00
pytime.c Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API 2010-08-05 17:34:27 +00:00
sigcheck.c REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
strdup.c Mass ANSIfication of function definitions. Doesn't cover all 'extern' 2000-07-22 18:47:25 +00:00
structmember.c Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
symtable.c Merged revisions 85757 via svnmerge from 2010-10-20 21:35:05 +00:00
sysmodule.c #11515: Merge with 3.2. 2011-03-15 06:03:08 +02:00
thread_cthread.h Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
thread_foobar.h Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
thread_lwp.h Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
thread_nt.h Issue #8844: Regular and recursive lock acquisitions can now be interrupted 2010-12-15 22:59:16 +00:00
thread_os2.h Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
thread_pth.h Issue #11495: OSF support is eliminated. It was deprecated in Python 3.2 2011-03-14 17:36:54 +01:00
thread_pthread.h Issue #11495: OSF support is eliminated. It was deprecated in Python 3.2 2011-03-14 17:36:54 +01:00
thread_sgi.h Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
thread_solaris.h Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
thread_wince.h Recorded merge of revisions 81032 via svnmerge from 2010-05-09 16:14:21 +00:00
thread.c #11565: Merge with 3.1. 2011-03-16 11:35:38 +02:00
traceback.c Remove redundant includes of headers that are already included by Python.h. 2010-11-30 09:41:01 +00:00