Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 65382:90052889ce3d
imp_load_module() uses PyUnicode_FSConverter() to support surrogates in module
path
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Fri, 15 Oct 2010 22:43:10 +0000 |
| parents | 844ed6dddc03 |
| children | 292b1df01bad |
line wrap: on
line diff
--- a/Python/import.c Fri Oct 15 21:56:35 2010 +0000 +++ b/Python/import.c Fri Oct 15 22:43:10 2010 +0000 @@ -3380,16 +3380,16 @@ { 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 @@ 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 @@ 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;
