[Python-checkins] r82714 - python/branches/import_unicode/Python/importdl.c
victor.stinner
python-checkins at python.org
Fri Jul 9 01:33:25 CEST 2010
Author: victor.stinner
Date: Fri Jul 9 01:33:25 2010
New Revision: 82714
Log:
importdl: use PyUnicode_EncodeFSDefault()
Instead of the evil _PyUnicode_AsString()
Modified:
python/branches/import_unicode/Python/importdl.c
Modified: python/branches/import_unicode/Python/importdl.c
==============================================================================
--- python/branches/import_unicode/Python/importdl.c (original)
+++ python/branches/import_unicode/Python/importdl.c Fri Jul 9 01:33:25 2010
@@ -22,15 +22,12 @@
_PyImport_LoadDynamicModule(char *name, PyObject *path, FILE *fp)
{
PyObject *m;
- char *pathname;
+ PyObject *pathbytes;
char *lastdot, *shortname, *packagecontext, *oldcontext;
dl_funcptr p0;
PyObject* (*p)(void);
struct PyModuleDef *def;
- /* FIXME: don't use _PyUnicode_AsString */
- pathname = _PyUnicode_AsString(path);
-
if ((m = _PyImport_FindExtensionUnicode(name, path)) != NULL) {
Py_INCREF(m);
return m;
@@ -45,7 +42,12 @@
shortname = lastdot+1;
}
- p0 = _PyImport_GetDynLoadFunc(name, shortname, pathname, fp);
+ /* FIXME: pass path, not pathname, at least to the Windows implementation */
+ pathbytes = PyUnicode_EncodeFSDefault(path);
+ if (pathbytes == NULL)
+ return NULL;
+ p0 = _PyImport_GetDynLoadFunc(name, shortname, PyBytes_AsString(pathbytes), fp);
+ Py_DECREF(pathbytes);
p = (PyObject*(*)(void))p0;
if (PyErr_Occurred())
return NULL;
@@ -84,9 +86,9 @@
if (_PyImport_FixupExtensionUnicode(m, name, path) < 0)
return NULL;
if (Py_VerboseFlag)
- PySys_WriteStderr(
- "import %s # dynamically loaded from %s\n",
- name, pathname);
+ PySys_FormatStderr(
+ "import %s # dynamically loaded from %U\n",
+ name, path);
return m;
}
More information about the Python-checkins
mailing list