[Python-checkins] r85518 - python/branches/py3k/Python/import.c

victor.stinner python-checkins at python.org
Fri Oct 15 14:48:01 CEST 2010


Author: victor.stinner
Date: Fri Oct 15 14:48:01 2010
New Revision: 85518
Log:
imp.load_dynamic() uses PyUnicode_FSConverter() to support surrogates
in the library 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	Fri Oct 15 14:48:01 2010
@@ -3326,24 +3326,24 @@
 imp_load_dynamic(PyObject *self, PyObject *args)
 {
 char *name;
+ PyObject *pathbytes;
 char *pathname;
 PyObject *fob = NULL;
 PyObject *m;
 FILE *fp = NULL;
- if (!PyArg_ParseTuple(args, "ses|O:load_dynamic",
- &name,
- Py_FileSystemDefaultEncoding, &pathname,
- &fob))
+ if (!PyArg_ParseTuple(args, "sO&|O:load_dynamic",
+ &name, PyUnicode_FSConverter, &pathbytes, &fob))
 return NULL;
+ pathname = PyBytes_AS_STRING(pathbytes);
 if (fob) {
 fp = get_file(pathname, fob, "r");
 if (fp == NULL) {
- PyMem_Free(pathname);
+ Py_DECREF(pathbytes);
 return NULL;
 }
 }
 m = _PyImport_LoadDynamicModule(name, pathname, fp);
- PyMem_Free(pathname);
+ Py_DECREF(pathbytes);
 if (fp)
 fclose(fp);
 return m;


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /