diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-04-04 21:05:53 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-04-04 21:05:53 (GMT) |
commit | 2d3222740bd119df048b955facd30eb48953b05f (patch) | |
tree | 440e417c56ae42fac26a81f4a38828b0a92168b3 /Python/importdl.c | |
parent | 54e7135fe81369a06e4c0dc496d423ed69dffc83 (diff) | |
download | cpython-2d3222740bd119df048b955facd30eb48953b05f.zip cpython-2d3222740bd119df048b955facd30eb48953b05f.tar.gz cpython-2d3222740bd119df048b955facd30eb48953b05f.tar.bz2 |
Issue #11619: _PyImport_LoadDynamicModule() doesn't encode the path to bytes
on Windows.
Diffstat (limited to 'Python/importdl.c')
-rw-r--r-- | Python/importdl.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Python/importdl.c b/Python/importdl.c index 629f3e2..69bb711 100644 --- a/Python/importdl.c +++ b/Python/importdl.c @@ -12,8 +12,13 @@ #include "importdl.h" +#ifdef MS_WINDOWS +extern dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname, + PyObject *pathname, FILE *fp); +#else extern dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, const char *pathname, FILE *fp); +#endif /* name should be ASCII only because the C language doesn't accept non-ASCII identifiers, and dynamic modules are written in C. */ @@ -22,7 +27,9 @@ PyObject * _PyImport_LoadDynamicModule(PyObject *name, PyObject *path, FILE *fp) { PyObject *m; +#ifndef MS_WINDOWS PyObject *pathbytes; +#endif char *namestr, *lastdot, *shortname, *packagecontext, *oldcontext; dl_funcptr p0; PyObject* (*p)(void); @@ -48,12 +55,16 @@ _PyImport_LoadDynamicModule(PyObject *name, PyObject *path, FILE *fp) shortname = lastdot+1; } +#ifdef MS_WINDOWS + p0 = _PyImport_GetDynLoadWindows(shortname, path, fp); +#else pathbytes = PyUnicode_EncodeFSDefault(path); if (pathbytes == NULL) return NULL; p0 = _PyImport_GetDynLoadFunc(shortname, PyBytes_AS_STRING(pathbytes), fp); Py_DECREF(pathbytes); +#endif p = (PyObject*(*)(void))p0; if (PyErr_Occurred()) return NULL; |