From 9c9a07c9c9a7532e1b89c80ab765cb3aade27d1b Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 16 May 1996 20:43:40 +0000 Subject: Remember source filename as .__file__. --- Python/import.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Python/import.c b/Python/import.c index 18968d0..afaaab7 100644 --- a/Python/import.c +++ b/Python/import.c @@ -161,6 +161,9 @@ exec_code_module(name, co) 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; -- cgit v0.12