Kaydet (Commit) 8dbf629b authored tarafından Victor Stinner's avatar Victor Stinner

imp.load_dynamic() uses PyUnicode_FSConverter() to support surrogates

in the library path.
üst f3170cce
...@@ -3326,24 +3326,24 @@ static PyObject * ...@@ -3326,24 +3326,24 @@ static PyObject *
imp_load_dynamic(PyObject *self, PyObject *args) imp_load_dynamic(PyObject *self, PyObject *args)
{ {
char *name; char *name;
PyObject *pathbytes;
char *pathname; char *pathname;
PyObject *fob = NULL; PyObject *fob = NULL;
PyObject *m; PyObject *m;
FILE *fp = NULL; FILE *fp = NULL;
if (!PyArg_ParseTuple(args, "ses|O:load_dynamic", if (!PyArg_ParseTuple(args, "sO&|O:load_dynamic",
&name, &name, PyUnicode_FSConverter, &pathbytes, &fob))
Py_FileSystemDefaultEncoding, &pathname,
&fob))
return NULL; return NULL;
pathname = PyBytes_AS_STRING(pathbytes);
if (fob) { if (fob) {
fp = get_file(pathname, fob, "r"); fp = get_file(pathname, fob, "r");
if (fp == NULL) { if (fp == NULL) {
PyMem_Free(pathname); Py_DECREF(pathbytes);
return NULL; return NULL;
} }
} }
m = _PyImport_LoadDynamicModule(name, pathname, fp); m = _PyImport_LoadDynamicModule(name, pathname, fp);
PyMem_Free(pathname); Py_DECREF(pathbytes);
if (fp) if (fp)
fclose(fp); fclose(fp);
return m; return m;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment