diff Python/import.c @ 9050:f3ebdb2274e4 legacy-trunk

__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.
author Guido van Rossum <guido@python.org>
date Tue, 25 Aug 1998 18:44:34 +0000
parents 20b83ca06ce8
children 2088f80253db
line wrap: on
line diff
--- a/Python/import.c	Tue Aug 25 18:22:17 1998 +0000
+++ b/Python/import.c	Tue Aug 25 18:44:34 1998 +0000
@@ -706,6 +706,7 @@
 		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 @@
 				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;