My reading of the Python 2.6.1 version of dynload_win.c tells me that:

1. It uses LoadLibraryEx() to attempt to load the pyd given its full
pathname

2. If that fails, it gets the Windows error code using GetLastError()

3. It gets the Windows message text using FormatMessage()

4. It assembles the message as "DLL load failed: " plus the Windows
message text (less any trailing "\r\n").

Note that if the pyd load succeeds, it rummages in memory to find the
pythonxx.dll used by the pyd so that it can be checked for
consistency. Then and only then it uses GetProcAddress() to get the
address of the initFOO function.

Do you know a way of getting more info out of Windows than GetLastError
()?

Thank you for your help, it is much appreciated:

In summary:

Q) How can one get Python to tell you which symbol is causing a problem when it loads an extension with a bad reference to a symbol in a DLL it uses?

A) There is no such way: you *must* use external tools: When a symbol is missing form a DLL that a Python extension depends on, the failure will be picked up in Python immediately on attempting to load the extension: the extension code is never reached and there is no specific attempt made in Python to resolve the problem symbol. further, The normal platform APIs lack the ability to determine the cause of the load failure.

> Do you know a way of getting more info out of Windows than GetLastError
> ()?

No, but presumably the ability to determine in code that a DLL has a bad reference and which symbol is bad exists because the depends program is able to do it. Of course it's a separate question as to whether Python wants to load itself down with complex platform specific code for a small corner case.

Best Regards,
Chris.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to