Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9c9a07c

Browse files
committed
Remember source filename as <module>.__file__.
1 parent 63e39ae commit 9c9a07c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Python/import.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ exec_code_module(name, co)
161161
if (dictinsert(d, "__builtins__", getbuiltins()) != 0)
162162
return NULL;
163163
}
164+
/* Remember the filename as the __file__ attribute */
165+
if (dictinsert(d, "__file__", ((codeobject *)co)->co_filename) != 0)
166+
err_clear(); /* Not important enough to report */
164167
v = eval_code((codeobject *)co, d, d); /* XXX owner? */
165168
if (v == NULL)
166169
return NULL;

0 commit comments

Comments
 (0)