summaryrefslogtreecommitdiff
path: root/Python/importdl.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-10-15 02:52:41 +0000
committerGuido van Rossum <guido@python.org>2007-10-15 02:52:41 +0000
commit00bc0e0a2d0b6c403a3c6ab96fa7d3398b5c751e (patch)
tree34fda27260f18f813912d83a2cf060264a736190 /Python/importdl.c
parentcdadf242ba32f1b3ef55e74d2eeb021e62da8041 (diff)
downloadcpython-git-00bc0e0a2d0b6c403a3c6ab96fa7d3398b5c751e.tar.gz
Patch #1272, by Christian Heimes and Alexandre Vassalotti.
Changes to make __file__ a proper Unicode object, using the default filesystem encoding. This is a bit tricky because the default filesystem encoding isn't set by the time we import the first modules; at that point we fudge things a bit. This is okay since __file__ isn't really used much except for error reporting. Tested on OSX and Linux only so far.
Diffstat (limited to 'Python/importdl.c')
-rw-r--r--Python/importdl.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Python/importdl.c b/Python/importdl.c
index 9c325e447d..7978c48b3d 100644
--- a/Python/importdl.c
+++ b/Python/importdl.c
@@ -62,7 +62,9 @@ _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp)
return NULL;
}
/* Remember the filename as the __file__ attribute */
- if (PyModule_AddStringConstant(m, "__file__", pathname) < 0)
+ PyObject *path;
+ path = PyUnicode_DecodeFSDefault(pathname);
+ if (PyModule_AddObject(m, "__file__", path) < 0)
PyErr_Clear(); /* Not important enough to report */
if (_PyImport_FixupExtension(name, pathname) == NULL)