| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1? | |||
| 10 | 10 | Core and Builtins | |
| 11 | 11 | ----------------- | |
| 12 | 12 | ||
| 13 | + - Issue #11619: _PyImport_LoadDynamicModule() doesn't encode the path to bytes | ||
| 14 | + on Windows. | ||
| 15 | + | ||
| 13 | 16 | - Issue #10998: Remove mentions of -Q, sys.flags.division_warning and | |
| 14 | 17 | Py_DivisionWarningFlag left over from Python 2. | |
| 15 | 18 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -171,8 +171,8 @@ static char *GetPythonImport (HINSTANCE hModule) | |||
| 171 | 171 | return NULL; | |
| 172 | 172 | } | |
| 173 | 173 | ||
| 174 | - dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, | ||
| 175 | - const char *pathname, FILE *fp) | ||
| 174 | + dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname, | ||
| 175 | + PyObject *pathname, FILE *fp) | ||
| 176 | 176 | { | |
| 177 | 177 | dl_funcptr p; | |
| 178 | 178 | char funcname[258], *import_python; | |
@@ -185,8 +185,7 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, | |||
| 185 | 185 | ||
| 186 | 186 | { | |
| 187 | 187 | HINSTANCE hDLL = NULL; | |
| 188 | - char pathbuf[260]; | ||
| 189 | - LPTSTR dummy; | ||
| 188 | + wchar_t pathbuf[260]; | ||
| 190 | 189 | unsigned int old_mode; | |
| 191 | 190 | ULONG_PTR cookie = 0; | |
| 192 | 191 | /* We use LoadLibraryEx so Windows looks for dependent DLLs | |
@@ -198,14 +197,14 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, | |||
| 198 | 197 | /* Don't display a message box when Python can't load a DLL */ | |
| 199 | 198 | old_mode = SetErrorMode(SEM_FAILCRITICALERRORS); | |
| 200 | 199 | ||
| 201 | - if (GetFullPathName(pathname, | ||
| 202 | - sizeof(pathbuf), | ||
| 203 | - pathbuf, | ||
| 204 | - &dummy)) { | ||
| 200 | + if (GetFullPathNameW(PyUnicode_AS_UNICODE(pathname), | ||
| 201 | + sizeof(pathbuf) / sizeof(pathbuf[0]), | ||
| 202 | + pathbuf, | ||
| 203 | + NULL)) { | ||
| 205 | 204 | ULONG_PTR cookie = _Py_ActivateActCtx(); | |
| 206 | 205 | /* XXX This call doesn't exist in Windows CE */ | |
| 207 | - hDLL = LoadLibraryEx(pathname, NULL, | ||
| 208 | - LOAD_WITH_ALTERED_SEARCH_PATH); | ||
| 206 | + hDLL = LoadLibraryExW(PyUnicode_AS_UNICODE(pathname), NULL, | ||
| 207 | + LOAD_WITH_ALTERED_SEARCH_PATH); | ||
| 209 | 208 | _Py_DeactivateActCtx(cookie); | |
| 210 | 209 | } | |
| 211 | 210 | ||
@@ -264,21 +263,21 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, | |||
| 264 | 263 | } else { | |
| 265 | 264 | char buffer[256]; | |
| 266 | 265 | ||
| 266 | + PyOS_snprintf(buffer, sizeof(buffer), | ||
| 267 | 267 | #ifdef _DEBUG | |
| 268 | - PyOS_snprintf(buffer, sizeof(buffer), "python%d%d_d.dll", | ||
| 268 | + "python%d%d_d.dll", | ||
| 269 | 269 | #else | |
| 270 | - PyOS_snprintf(buffer, sizeof(buffer), "python%d%d.dll", | ||
| 270 | + "python%d%d.dll", | ||
| 271 | 271 | #endif | |
| 272 | 272 | PY_MAJOR_VERSION,PY_MINOR_VERSION); | |
| 273 | 273 | import_python = GetPythonImport(hDLL); | |
| 274 | 274 | ||
| 275 | 275 | if (import_python && | |
| 276 | 276 | strcasecmp(buffer,import_python)) { | |
| 277 | - PyOS_snprintf(buffer, sizeof(buffer), | ||
| 278 | - "Module use of %.150s conflicts " | ||
| 279 | - "with this version of Python.", | ||
| 280 | - import_python); | ||
| 281 | - PyErr_SetString(PyExc_ImportError,buffer); | ||
| 277 | + PyErr_Format(PyExc_ImportError, | ||
| 278 | + "Module use of %.150s conflicts " | ||
| 279 | + "with this version of Python.", | ||
| 280 | + import_python); | ||
| 282 | 281 | FreeLibrary(hDLL); | |
| 283 | 282 | return NULL; | |
| 284 | 283 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,8 +12,13 @@ | |||
| 12 | 12 | ||
| 13 | 13 | #include "importdl.h" | |
| 14 | 14 | ||
| 15 | + #ifdef MS_WINDOWS | ||
| 16 | + extern dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname, | ||
| 17 | + PyObject *pathname, FILE *fp); | ||
| 18 | + #else | ||
| 15 | 19 | extern dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, | |
| 16 | 20 | const char *pathname, FILE *fp); | |
| 21 | + #endif | ||
| 17 | 22 | ||
| 18 | 23 | /* name should be ASCII only because the C language doesn't accept non-ASCII | |
| 19 | 24 | identifiers, and dynamic modules are written in C. */ | |
@@ -22,7 +27,9 @@ PyObject * | |||
| 22 | 27 | _PyImport_LoadDynamicModule(PyObject *name, PyObject *path, FILE *fp) | |
| 23 | 28 | { | |
| 24 | 29 | PyObject *m; | |
| 30 | + #ifndef MS_WINDOWS | ||
| 25 | 31 | PyObject *pathbytes; | |
| 32 | + #endif | ||
| 26 | 33 | char *namestr, *lastdot, *shortname, *packagecontext, *oldcontext; | |
| 27 | 34 | dl_funcptr p0; | |
| 28 | 35 | PyObject* (*p)(void); | |
@@ -48,12 +55,16 @@ _PyImport_LoadDynamicModule(PyObject *name, PyObject *path, FILE *fp) | |||
| 48 | 55 | shortname = lastdot+1; | |
| 49 | 56 | } | |
| 50 | 57 | ||
| 58 | + #ifdef MS_WINDOWS | ||
| 59 | + p0 = _PyImport_GetDynLoadWindows(shortname, path, fp); | ||
| 60 | + #else | ||
| 51 | 61 | pathbytes = PyUnicode_EncodeFSDefault(path); | |
| 52 | 62 | if (pathbytes == NULL) | |
| 53 | 63 | return NULL; | |
| 54 | 64 | p0 = _PyImport_GetDynLoadFunc(shortname, | |
| 55 | 65 | PyBytes_AS_STRING(pathbytes), fp); | |
| 56 | 66 | Py_DECREF(pathbytes); | |
| 67 | + #endif | ||
| 57 | 68 | p = (PyObject*(*)(void))p0; | |
| 58 | 69 | if (PyErr_Occurred()) | |
| 59 | 70 | return NULL; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments