From: Guido van Rossum Date: Thu, 16 May 1996 20:43:40 +0000 (+0000) Subject: Remember source filename as .__file__. X-Git-Tag: v1.4b1~185 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c9a07c9c9a7532e1b89c80ab765cb3aade27d1b;p=python Remember source filename as .__file__. --- diff --git a/Python/import.c b/Python/import.c index 18968d0a0f..afaaab7eef 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;