[Python-checkins] r85552 - python/branches/py3k/Python/import.c
victor.stinner
python-checkins at python.org
Sat Oct 16 00:43:10 CEST 2010
Author: victor.stinner
Date: Sat Oct 16 00:43:10 2010
New Revision: 85552
Log:
imp_load_module() uses PyUnicode_FSConverter() to support surrogates in module
path
Modified:
python/branches/py3k/Python/import.c
Modified: python/branches/py3k/Python/import.c
==============================================================================
--- python/branches/py3k/Python/import.c (original)
+++ python/branches/py3k/Python/import.c Sat Oct 16 00:43:10 2010
@@ -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;
More information about the Python-checkins
mailing list