Remember source filename as <module>.__file__.

This commit is contained in:
Guido van Rossum 1996-05-16 20:43:40 +00:00
parent 63e39ae933
commit 9c9a07c9c9
1 changed files with 3 additions and 0 deletions

View File

@ -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;