mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
imp.cache_from_source() uses PyUnicode_FSConverter() to support surrogates in
module path
This commit is contained in:
parent
392c92a0c6
commit
3ea23ddabf
1 changed files with 8 additions and 5 deletions
|
@ -3460,21 +3460,24 @@ imp_cache_from_source(PyObject *self, PyObject *args, PyObject *kws)
|
||||||
static char *kwlist[] = {"path", "debug_override", NULL};
|
static char *kwlist[] = {"path", "debug_override", NULL};
|
||||||
|
|
||||||
char buf[MAXPATHLEN+1];
|
char buf[MAXPATHLEN+1];
|
||||||
char *pathname, *cpathname;
|
PyObject *pathbytes;
|
||||||
|
char *cpathname;
|
||||||
PyObject *debug_override = Py_None;
|
PyObject *debug_override = Py_None;
|
||||||
int debug = !Py_OptimizeFlag;
|
int debug = !Py_OptimizeFlag;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(
|
if (!PyArg_ParseTupleAndKeywords(
|
||||||
args, kws, "es|O", kwlist,
|
args, kws, "O&|O", kwlist,
|
||||||
Py_FileSystemDefaultEncoding, &pathname, &debug_override))
|
PyUnicode_FSConverter, &pathbytes, &debug_override))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (debug_override != Py_None)
|
if (debug_override != Py_None)
|
||||||
if ((debug = PyObject_IsTrue(debug_override)) < 0)
|
if ((debug = PyObject_IsTrue(debug_override)) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
cpathname = make_compiled_pathname(pathname, buf, MAXPATHLEN+1, debug);
|
cpathname = make_compiled_pathname(
|
||||||
PyMem_Free(pathname);
|
PyBytes_AS_STRING(pathbytes),
|
||||||
|
buf, MAXPATHLEN+1, debug);
|
||||||
|
Py_DECREF(pathbytes);
|
||||||
|
|
||||||
if (cpathname == NULL) {
|
if (cpathname == NULL) {
|
||||||
PyErr_Format(PyExc_SystemError, "path buffer too short");
|
PyErr_Format(PyExc_SystemError, "path buffer too short");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue