mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
imp_load_module() uses PyUnicode_FSConverter() to support surrogates in module
path
This commit is contained in:
parent
42311734ab
commit
1a5630326f
1 changed files with 7 additions and 7 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue