From 3046647478f584b665a33c3a1c3d1d6117979d64 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 22 Feb 2011 23:16:19 +0000 Subject: Issue #3080: Remove unused argument of _PyImport_GetDynLoadFunc() The first argument, fqname, was not used. --- Python/dynload_win.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/dynload_win.c') diff --git a/Python/dynload_win.c b/Python/dynload_win.c index 73a1dcf897..9c04250f33 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -171,7 +171,7 @@ static char *GetPythonImport (HINSTANCE hModule) return NULL; } -dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, +dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, const char *pathname, FILE *fp) { dl_funcptr p; -- cgit v1.2.1 From d206f91d5300b6ee4d99d9d45f9a4160fa384366 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 4 Apr 2011 23:05:53 +0200 Subject: Issue #11619: _PyImport_LoadDynamicModule() doesn't encode the path to bytes on Windows. --- Python/dynload_win.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'Python/dynload_win.c') diff --git a/Python/dynload_win.c b/Python/dynload_win.c index 9c04250f33..9869f6ae8b 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -171,8 +171,8 @@ static char *GetPythonImport (HINSTANCE hModule) return NULL; } -dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, - const char *pathname, FILE *fp) +dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname, + PyObject *pathname, FILE *fp) { dl_funcptr p; char funcname[258], *import_python; @@ -185,8 +185,7 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, { HINSTANCE hDLL = NULL; - char pathbuf[260]; - LPTSTR dummy; + wchar_t pathbuf[260]; unsigned int old_mode; ULONG_PTR cookie = 0; /* We use LoadLibraryEx so Windows looks for dependent DLLs @@ -198,14 +197,14 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, /* Don't display a message box when Python can't load a DLL */ old_mode = SetErrorMode(SEM_FAILCRITICALERRORS); - if (GetFullPathName(pathname, - sizeof(pathbuf), - pathbuf, - &dummy)) { + if (GetFullPathNameW(PyUnicode_AS_UNICODE(pathname), + sizeof(pathbuf) / sizeof(pathbuf[0]), + pathbuf, + NULL)) { ULONG_PTR cookie = _Py_ActivateActCtx(); /* XXX This call doesn't exist in Windows CE */ - hDLL = LoadLibraryEx(pathname, NULL, - LOAD_WITH_ALTERED_SEARCH_PATH); + hDLL = LoadLibraryExW(PyUnicode_AS_UNICODE(pathname), NULL, + LOAD_WITH_ALTERED_SEARCH_PATH); _Py_DeactivateActCtx(cookie); } @@ -264,21 +263,21 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, } else { char buffer[256]; + PyOS_snprintf(buffer, sizeof(buffer), #ifdef _DEBUG - PyOS_snprintf(buffer, sizeof(buffer), "python%d%d_d.dll", + "python%d%d_d.dll", #else - PyOS_snprintf(buffer, sizeof(buffer), "python%d%d.dll", + "python%d%d.dll", #endif PY_MAJOR_VERSION,PY_MINOR_VERSION); import_python = GetPythonImport(hDLL); if (import_python && strcasecmp(buffer,import_python)) { - PyOS_snprintf(buffer, sizeof(buffer), - "Module use of %.150s conflicts " - "with this version of Python.", - import_python); - PyErr_SetString(PyExc_ImportError,buffer); + PyErr_Format(PyExc_ImportError, + "Module use of %.150s conflicts " + "with this version of Python.", + import_python); FreeLibrary(hDLL); return NULL; } -- cgit v1.2.1 From faf7f967781894e0af45064e95fdb6bc0b31f22c Mon Sep 17 00:00:00 2001 From: Brian Curtin Date: Thu, 9 Jun 2011 17:55:54 -0500 Subject: Removed a Windows 9x trick used before LoadLibraryExW. Windows 9x has long been unsupported and the result of GetFullPathName was not even being used in the first place. --- Python/dynload_win.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'Python/dynload_win.c') diff --git a/Python/dynload_win.c b/Python/dynload_win.c index 9869f6ae8b..932a637680 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -185,28 +185,19 @@ dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname, { HINSTANCE hDLL = NULL; - wchar_t pathbuf[260]; unsigned int old_mode; ULONG_PTR cookie = 0; - /* We use LoadLibraryEx so Windows looks for dependent DLLs - in directory of pathname first. However, Windows95 - can sometimes not work correctly unless the absolute - path is used. If GetFullPathName() fails, the LoadLibrary - will certainly fail too, so use its error code */ - + /* Don't display a message box when Python can't load a DLL */ old_mode = SetErrorMode(SEM_FAILCRITICALERRORS); - if (GetFullPathNameW(PyUnicode_AS_UNICODE(pathname), - sizeof(pathbuf) / sizeof(pathbuf[0]), - pathbuf, - NULL)) { - ULONG_PTR cookie = _Py_ActivateActCtx(); - /* XXX This call doesn't exist in Windows CE */ - hDLL = LoadLibraryExW(PyUnicode_AS_UNICODE(pathname), NULL, - LOAD_WITH_ALTERED_SEARCH_PATH); - _Py_DeactivateActCtx(cookie); - } + cookie = _Py_ActivateActCtx(); + /* We use LoadLibraryEx so Windows looks for dependent DLLs + in directory of pathname first. */ + /* XXX This call doesn't exist in Windows CE */ + hDLL = LoadLibraryExW(PyUnicode_AS_UNICODE(pathname), NULL, + LOAD_WITH_ALTERED_SEARCH_PATH); + _Py_DeactivateActCtx(cookie); /* restore old error mode settings */ SetErrorMode(old_mode); -- cgit v1.2.1 From 0c2e8df558514b8e0d85d011857f3c2984e39f6e Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sun, 2 Oct 2011 20:35:10 +0200 Subject: Check error when calling PyUnicode_AppendAndDel() --- Python/dynload_win.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Python/dynload_win.c') diff --git a/Python/dynload_win.c b/Python/dynload_win.c index 932a637680..c620e58948 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -187,7 +187,7 @@ dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname, HINSTANCE hDLL = NULL; unsigned int old_mode; ULONG_PTR cookie = 0; - + /* Don't display a message box when Python can't load a DLL */ old_mode = SetErrorMode(SEM_FAILCRITICALERRORS); @@ -248,8 +248,10 @@ dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname, theInfo, theLength)); } - PyErr_SetObject(PyExc_ImportError, message); - Py_XDECREF(message); + if (message != NULL) { + PyErr_SetObject(PyExc_ImportError, message); + Py_DECREF(message); + } return NULL; } else { char buffer[256]; -- cgit v1.2.1 From b2d40d2728272d56781ac9164279d9a3ec900a7c Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 21 Nov 2011 02:01:41 +0100 Subject: Check for PyUnicode_AS_UNICODE() failure --- Python/dynload_win.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Python/dynload_win.c') diff --git a/Python/dynload_win.c b/Python/dynload_win.c index c620e58948..e511098d1d 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -176,11 +176,16 @@ dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname, { dl_funcptr p; char funcname[258], *import_python; + wchar_t *wpathname; #ifndef _DEBUG _Py_CheckPython3(); #endif + wpathname = PyUnicode_AsUnicode(pathname); + if (wpathname == NULL) + return NULL; + PyOS_snprintf(funcname, sizeof(funcname), "PyInit_%.200s", shortname); { @@ -195,7 +200,7 @@ dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname, /* We use LoadLibraryEx so Windows looks for dependent DLLs in directory of pathname first. */ /* XXX This call doesn't exist in Windows CE */ - hDLL = LoadLibraryExW(PyUnicode_AS_UNICODE(pathname), NULL, + hDLL = LoadLibraryExW(wpathname, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); _Py_DeactivateActCtx(cookie); -- cgit v1.2.1 From 05407577effc3f36d9b63c12b8e754eb86e8e3f6 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 22 Nov 2011 02:27:30 +0100 Subject: Use the new Unicode API * Replace PyUnicode_FromUnicode(NULL, 0) by PyUnicode_New(0, 0) * Replce PyUnicode_FromUnicode(str, len) by PyUnicode_FromWideChar(str, len) * Replace Py_UNICODE by wchar_t * posix_putenv() uses PyUnicode_FromFormat() to create the string, instead of PyUnicode_FromUnicode() + _snwprintf() --- Python/dynload_win.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/dynload_win.c') diff --git a/Python/dynload_win.c b/Python/dynload_win.c index e511098d1d..2cbfe9f30d 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -249,7 +249,7 @@ dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname, "DLL load failed: "); PyUnicode_AppendAndDel(&message, - PyUnicode_FromUnicode( + PyUnicode_FromWideChar( theInfo, theLength)); } -- cgit v1.2.1 From 11c40722cbce41aff4d80d99d677ee2b5cabf0cd Mon Sep 17 00:00:00 2001 From: Brian Curtin Date: Mon, 16 Apr 2012 00:10:17 -0500 Subject: Fix #10854. Make use of the new path and name attributes on ImportError for extension modules on Windows. --- Python/dynload_win.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Python/dynload_win.c') diff --git a/Python/dynload_win.c b/Python/dynload_win.c index 2cbfe9f30d..ef3e2c5958 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -254,8 +254,9 @@ dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname, theLength)); } if (message != NULL) { - PyErr_SetObject(PyExc_ImportError, message); - Py_DECREF(message); + PyErr_SetFromImportErrorWithNameAndPath(message, + PyUnicode_FromString(shortname), + pathname); } return NULL; } else { -- cgit v1.2.1 From 5d8520121e1ea38bcfe37258449a946ee328cac1 Mon Sep 17 00:00:00 2001 From: Brian Curtin Date: Tue, 17 Apr 2012 16:57:09 -0500 Subject: Fix #14600. Correct reference handling and naming of ImportError convenience function --- Python/dynload_win.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Python/dynload_win.c') diff --git a/Python/dynload_win.c b/Python/dynload_win.c index ef3e2c5958..7bf3dfc811 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -254,9 +254,9 @@ dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname, theLength)); } if (message != NULL) { - PyErr_SetFromImportErrorWithNameAndPath(message, - PyUnicode_FromString(shortname), - pathname); + PyErr_SetImportError(message, PyUnicode_FromString(shortname), + pathname); + Py_DECREF(message); } return NULL; } else { -- cgit v1.2.1 From f9e12fdf7205afea929ddb2b8f6e950721c831bf Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 4 May 2012 15:20:40 -0400 Subject: Issue #13959: Re-implement imp.get_suffixes() in Lib/imp.py. This introduces a new function, imp.extension_suffixes(), which is currently undocumented. That is forthcoming once issue #14657 is resolved and how to expose file suffixes is decided. --- Python/dynload_win.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Python/dynload_win.c') diff --git a/Python/dynload_win.c b/Python/dynload_win.c index 7bf3dfc811..9c48a2de4f 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -15,13 +15,13 @@ extern ULONG_PTR _Py_ActivateActCtx(); void _Py_DeactivateActCtx(ULONG_PTR cookie); -const struct filedescr _PyImport_DynLoadFiletab[] = { +const char *_PyImport_DynLoadFiletab[] = { #ifdef _DEBUG - {"_d.pyd", "rb", C_EXTENSION}, + "_d.pyd", #else - {".pyd", "rb", C_EXTENSION}, + ".pyd", #endif - {0, 0} + NULL }; -- cgit v1.2.1 From 24c2b4159481ae98df26a6dc727e4405d3d95b1d Mon Sep 17 00:00:00 2001 From: Brian Curtin Date: Sun, 13 May 2012 11:19:23 -0500 Subject: Fix #13210. Port the Windows build from VS2008 to VS2010. --- Python/dynload_win.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Python/dynload_win.c') diff --git a/Python/dynload_win.c b/Python/dynload_win.c index 9c48a2de4f..25b6680b3b 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -12,8 +12,10 @@ #include // "activation context" magic - see dl_nt.c... +#if HAVE_SXS extern ULONG_PTR _Py_ActivateActCtx(); void _Py_DeactivateActCtx(ULONG_PTR cookie); +#endif const char *_PyImport_DynLoadFiletab[] = { #ifdef _DEBUG @@ -191,18 +193,24 @@ dl_funcptr _PyImport_GetDynLoadWindows(const char *shortname, { HINSTANCE hDLL = NULL; unsigned int old_mode; +#if HAVE_SXS ULONG_PTR cookie = 0; +#endif /* Don't display a message box when Python can't load a DLL */ old_mode = SetErrorMode(SEM_FAILCRITICALERRORS); +#if HAVE_SXS cookie = _Py_ActivateActCtx(); +#endif /* We use LoadLibraryEx so Windows looks for dependent DLLs in directory of pathname first. */ /* XXX This call doesn't exist in Windows CE */ hDLL = LoadLibraryExW(wpathname, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); +#if HAVE_SXS _Py_DeactivateActCtx(cookie); +#endif /* restore old error mode settings */ SetErrorMode(old_mode); -- cgit v1.2.1