Mercurial > cpython-lru_cache-weakref
diff Python/importdl.c @ 8569:450076068b22 legacy-trunk
Windows-specific hack to make sure that when LoadLibrary() is called,
the filename contains at least a rudimentary pathname.
(The bad part is that we need to call getcwd() because only a prefix
of ".\\" is not enough -- we prefix the drive letter.)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Sat, 27 Jun 1998 21:53:17 +0000 |
| parents | e80d4c3dbb78 |
| children | 3be906467740 |
line wrap: on
line diff
--- a/Python/importdl.c Sat Jun 27 20:38:36 1998 +0000 +++ b/Python/importdl.c Sat Jun 27 21:53:17 1998 +0000 @@ -104,6 +104,7 @@ #ifdef MS_WINDOWS /* i.e. MS_WIN32 or MS_WIN16 */ #define DYNAMIC_LINK #include <windows.h> +#include <direct.h> typedef FARPROC dl_funcptr; #define _DL_FUNCPTR_DEFINED #ifdef _DEBUG @@ -419,6 +420,19 @@ #ifdef MS_WIN32 { HINSTANCE hDLL; + char pathbuf[260]; + if (strchr(pathname, SEP) == NULL && + strchr(pathname, ALTSEP) == NULL) + { + /* Prefix bare filename with ".\" */ + char *p = pathbuf; + *p = '\0'; + _getcwd(pathbuf, sizeof pathbuf); + if (*p != '\0' && p[1] == ':') + p += 2; + sprintf(p, ".\\%-.255s", pathname); + pathname = pathbuf; + } hDLL = LoadLibrary(pathname); if (hDLL==NULL){ char errBuf[256]; @@ -471,6 +485,14 @@ #ifdef MS_WIN16 { HINSTANCE hDLL; + char pathbuf[16]; + if (strchr(pathname, SEP) == NULL && + strchr(pathname, ALTSEP) == NULL) + { + /* Prefix bare filename with ".\" */ + sprintf(pathbuf, ".\\%-.13s", pathname); + pathname = pathbuf; + } hDLL = LoadLibrary(pathname); if (hDLL < HINSTANCE_ERROR){ char errBuf[256];
