summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-10-15 12:48:01 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-10-15 12:48:01 (GMT)
commit8dbf629bbd678da2e818bf404657fadba6dfa23f (patch)
treebc801f48a8332633528fab31fdc2bae6464c5e14
parentf3170ccef8809e4a3f82fe9f82dc7a4a486c28c1 (diff)
downloadcpython-8dbf629bbd678da2e818bf404657fadba6dfa23f.zip
cpython-8dbf629bbd678da2e818bf404657fadba6dfa23f.tar.gz
cpython-8dbf629bbd678da2e818bf404657fadba6dfa23f.tar.bz2
imp.load_dynamic() uses PyUnicode_FSConverter() to support surrogates
in the library path.
-rw-r--r--Python/import.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Python/import.c b/Python/import.c
index 48fd205..b8bcabd 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -3326,24 +3326,24 @@ static PyObject *
imp_load_dynamic(PyObject *self, PyObject *args)
{
char *name;
+ PyObject *pathbytes;
char *pathname;
PyObject *fob = NULL;
PyObject *m;
FILE *fp = NULL;
- if (!PyArg_ParseTuple(args, "ses|O:load_dynamic",
- &name,
- Py_FileSystemDefaultEncoding, &pathname,
- &fob))
+ if (!PyArg_ParseTuple(args, "sO&|O:load_dynamic",
+ &name, PyUnicode_FSConverter, &pathbytes, &fob))
return NULL;
+ pathname = PyBytes_AS_STRING(pathbytes);
if (fob) {
fp = get_file(pathname, fob, "r");
if (fp == NULL) {
- PyMem_Free(pathname);
+ Py_DECREF(pathbytes);
return NULL;
}
}
m = _PyImport_LoadDynamicModule(name, pathname, fp);
- PyMem_Free(pathname);
+ Py_DECREF(pathbytes);
if (fp)
fclose(fp);
return m;