summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-10-15 20:34:32 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-10-15 20:34:32 (GMT)
commit3ea23ddabffe85a0d69bf0fc67c962b5174df345 (patch)
tree5bfff0b951f34653406c01e3471653b224ddf1db
parent392c92a0c67b1423f75181579c708d04a2190878 (diff)
downloadcpython-3ea23ddabffe85a0d69bf0fc67c962b5174df345.zip
cpython-3ea23ddabffe85a0d69bf0fc67c962b5174df345.tar.gz
cpython-3ea23ddabffe85a0d69bf0fc67c962b5174df345.tar.bz2
imp.cache_from_source() uses PyUnicode_FSConverter() to support surrogates in
module path
-rw-r--r--Python/import.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Python/import.c b/Python/import.c
index b8bcabd..6a41439 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -3460,21 +3460,24 @@ imp_cache_from_source(PyObject *self, PyObject *args, PyObject *kws)
static char *kwlist[] = {"path", "debug_override", NULL};
char buf[MAXPATHLEN+1];
- char *pathname, *cpathname;
+ PyObject *pathbytes;
+ char *cpathname;
PyObject *debug_override = Py_None;
int debug = !Py_OptimizeFlag;
if (!PyArg_ParseTupleAndKeywords(
- args, kws, "es|O", kwlist,
- Py_FileSystemDefaultEncoding, &pathname, &debug_override))
+ args, kws, "O&|O", kwlist,
+ PyUnicode_FSConverter, &pathbytes, &debug_override))
return NULL;
if (debug_override != Py_None)
if ((debug = PyObject_IsTrue(debug_override)) < 0)
return NULL;
- cpathname = make_compiled_pathname(pathname, buf, MAXPATHLEN+1, debug);
- PyMem_Free(pathname);
+ cpathname = make_compiled_pathname(
+ PyBytes_AS_STRING(pathbytes),
+ buf, MAXPATHLEN+1, debug);
+ Py_DECREF(pathbytes);
if (cpathname == NULL) {
PyErr_Format(PyExc_SystemError, "path buffer too short");