This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author smunday
Recipients smunday
Date 2021-02-02.17:03:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
If I attempt to import an extension module via something like this:

from pkg import extmodule

and it happens that "pkg" is found in a folder that is given in sys.path as a relative path, then the import fails, with 

ImportError: DLL load failed while importing extmodule: The parameter is incorrect.

This only happens with 3.8 and later.  

AFAICS the reason is that if the module resolution is done via a relative path, it results in dynload_win.c:_PyImport_FindSharedFuncptrWindows attempting to feed LoadLibraryExW a relative path for the .pyd file.   But LoadLibraryExW treats relative paths completely differently from absolute ones, in that it searches for the given path relative to the library search path entries rather than simply loading the DLL at that path.  But as of 3.8 the current directory is removed from the search path, so the .pyd is never found.  Since Python knows the specific file it wants LoadLibraryExW to load, having just resolved it via the import mechanism, I guess it ought to ensure it only ever calls LoadLibraryExW with an absolute path.  

(I'm assuming use of relative paths in sys.path is officially supported, since nothing I've found in the docs says otherwise.)
Date User Action Args
2021-02-02 17:03:00smundaysetrecipients: + smunday
2021-02-02 17:03:00smundaysetmessageid: <>
2021-02-02 17:03:00smundaylinkissue43105 messages
2021-02-02 17:03:00smundaycreate