summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-10-15 22:43:10 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-10-15 22:43:10 (GMT)
commit1a5630326f0992db78949a378a32b4979517e200 (patch)
tree9b74603b033034e0a340e01533a834b4e7d1cd67 /Python
parent42311734ab3ee5f04dcaa7c0772f7d27de46065d (diff)
downloadcpython-1a5630326f0992db78949a378a32b4979517e200.zip
cpython-1a5630326f0992db78949a378a32b4979517e200.tar.gz
cpython-1a5630326f0992db78949a378a32b4979517e200.tar.bz2
imp_load_module() uses PyUnicode_FSConverter() to support surrogates in module
path
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/Python/import.c b/Python/import.c
index 6a41439..8575293 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -3380,16 +3380,16 @@ imp_load_module(PyObject *self, PyObject *args)
{
char *name;
PyObject *fob;
- char *pathname;
+ PyObject *pathname;
PyObject * ret;
char *suffix; /* Unused */
char *mode;
int type;
FILE *fp;
- if (!PyArg_ParseTuple(args, "sOes(ssi):load_module",
+ if (!PyArg_ParseTuple(args, "sOO&(ssi):load_module",
&name, &fob,
- Py_FileSystemDefaultEncoding, &pathname,
+ PyUnicode_FSConverter, &pathname,
&suffix, &mode, &type))
return NULL;
if (*mode) {
@@ -3400,7 +3400,7 @@ imp_load_module(PyObject *self, PyObject *args)
if (!(*mode == 'r' || *mode == 'U') || strchr(mode, '+')) {
PyErr_Format(PyExc_ValueError,
"invalid file open mode %.200s", mode);
- PyMem_Free(pathname);
+ Py_DECREF(pathname);
return NULL;
}
}
@@ -3409,12 +3409,12 @@ imp_load_module(PyObject *self, PyObject *args)
else {
fp = get_file(NULL, fob, mode);
if (fp == NULL) {
- PyMem_Free(pathname);
+ Py_DECREF(pathname);
return NULL;
}
}
- ret = load_module(name, fp, pathname, type, NULL);
- PyMem_Free(pathname);
+ ret = load_module(name, fp, PyBytes_AS_STRING(pathname), type, NULL);
+ Py_DECREF(pathname);
if (fp)
fclose(fp);
return ret;