]> granicus.if.org Git - python/commitdiff
Remember source filename as <module>.__file__.
authorGuido van Rossum <guido@python.org>
Thu, 16 May 1996 20:43:40 +0000 (20:43 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 16 May 1996 20:43:40 +0000 (20:43 +0000)
Python/import.c

index 18968d0a0fc812a639c3178ea6e533a65fcbb0f1..afaaab7eef7f9ca7c63d98845bcfa5ec403fdd3c 100644 (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;