Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8dbf629

Browse files
author
Victor Stinner
committed
imp.load_dynamic() uses PyUnicode_FSConverter() to support surrogates
in the library path.
1 parent f3170cc commit 8dbf629

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Python/import.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3326,24 +3326,24 @@ static PyObject *
33263326
imp_load_dynamic(PyObject *self, PyObject *args)
33273327
{
33283328
char *name;
3329+
PyObject *pathbytes;
33293330
char *pathname;
33303331
PyObject *fob = NULL;
33313332
PyObject *m;
33323333
FILE *fp = NULL;
3333-
if (!PyArg_ParseTuple(args, "ses|O:load_dynamic",
3334-
&name,
3335-
Py_FileSystemDefaultEncoding, &pathname,
3336-
&fob))
3334+
if (!PyArg_ParseTuple(args, "sO&|O:load_dynamic",
3335+
&name, PyUnicode_FSConverter, &pathbytes, &fob))
33373336
return NULL;
3337+
pathname = PyBytes_AS_STRING(pathbytes);
33383338
if (fob) {
33393339
fp = get_file(pathname, fob, "r");
33403340
if (fp == NULL) {
3341-
PyMem_Free(pathname);
3341+
Py_DECREF(pathbytes);
33423342
return NULL;
33433343
}
33443344
}
33453345
m = _PyImport_LoadDynamicModule(name, pathname, fp);
3346-
PyMem_Free(pathname);
3346+
Py_DECREF(pathbytes);
33473347
if (fp)
33483348
fclose(fp);
33493349
return m;

0 commit comments

Comments
 (0)