diff Python/import.c @ 3557:cee4a6d8415e legacy-trunk

Remember source filename as <module>.__file__.
author Guido van Rossum <guido@python.org>
date Thu, 16 May 1996 20:43:40 +0000
parents 08130f00c18d
children 73664ea2030e
line wrap: on
line diff
--- a/Python/import.c	Thu May 16 17:53:48 1996 +0000
+++ b/Python/import.c	Thu May 16 20:43:40 1996 +0000
@@ -161,6 +161,9 @@
 		if (dictinsert(d, "__builtins__", getbuiltins()) != 0)
 			return NULL;
 	}
+	/* Remember the filename as the __file__ attribute */
+	if (dictinsert(d, "__file__", ((codeobject *)co)->co_filename) != 0)
+		err_clear(); /* Not important enough to report */
 	v = eval_code((codeobject *)co, d, d); /* XXX owner? */
 	if (v == NULL)
 		return NULL;