diff options
author | Guido van Rossum <guido@python.org> | 1998-08-25 18:44:34 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-08-25 18:44:34 (GMT) |
commit | afd3daedded4f77f9803a3a486ca00f9fe363859 (patch) | |
tree | 4997a5c81f61dc84698609deacb11812dcc7a3d8 /Python/import.c | |
parent | 90f827c67e27b98804d74e8e579a9bd98bc01702 (diff) | |
download | cpython-afd3daedded4f77f9803a3a486ca00f9fe363859.zip cpython-afd3daedded4f77f9803a3a486ca00f9fe363859.tar.gz cpython-afd3daedded4f77f9803a3a486ca00f9fe363859.tar.bz2 |
__file__ used to be always set to the .pyc (or .pyo) file, even if
that file in fact did not exist or at least was not used. Change this
so that __file__ is *only* set to the .pyc/.pyo file when it actually
read the code object from it; otherwise __file__ is set to the .py
file.
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/import.c b/Python/import.c index 33d266a..7099d1b 100644 --- a/Python/import.c +++ b/Python/import.c @@ -706,6 +706,7 @@ load_source_module(name, pathname, fp) if (Py_VerboseFlag) fprintf(stderr, "import %s # precompiled from %s\n", name, cpathname); + pathname = cpathname; } else { co = parse_source_module(pathname, fp); @@ -716,7 +717,7 @@ load_source_module(name, pathname, fp) name, pathname); write_compiled_module(co, cpathname, mtime); } - m = PyImport_ExecCodeModuleEx(name, (PyObject *)co, cpathname); + m = PyImport_ExecCodeModuleEx(name, (PyObject *)co, pathname); Py_DECREF(co); return m; |