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.

classification
Title: cannot import extension module with Purify
Type: Stage:
Components: Extension Modules Versions:
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: loewis Nosy List: amaury.forgeotdarc, loewis
Priority: normal Keywords:

Created on 2006-01-11 16:02 by amaury.forgeotdarc, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg27272 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2006-01-11 16:02
When run with Purify, Python cannot load any extension
module.

Here is a typical output:

Starting Purify'd application...
Python 2.4.2 (#46, Jan  3 2006, 16:05:11) [MSC v.1200
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for
more information.
>>> import socket
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "c:\python\lib\socket.py", line 45, in ?
    import _socket
ImportError: Module use of
python24__d$Purify_c_python.dll conflicts with this
version of Python.

It reproduces with python 2.4.2 and 2.5a0.
It works with python 2.3.3.
msg27273 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2006-01-11 16:22
Logged In: YES 
user_id=389140

The pb seems to be in dynload_win.c, line 136:
while (*pch && pch[0] != '_' && pch[1] != 'd' && pch[2] !=
'.') {

This means that if a .pyd has "python_something.dll" in its
import table, it will be taken as THE python DLL.
I think the line should be:

while (*pch && (pch[0] != '_' || pch[1] != 'd' || pch[2] !=
'.')) {


msg27274 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2006-01-11 16:35
Logged In: YES 
user_id=389140

The root cause it that Purify renames all DLLs with names like
"python24__d$Purify_c_python.dll".
With python 2.3, this name was not taken as the python DLL,
and no check was performed.
The broken logic in my previous comment changed this for 2.4.

A more correct fix is to get the python DLL name from the
current process, using GetModuleName(PyWin_DLLhModule).
msg79682 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-01-12 15:39
Newer versions of Purify seem to convert the file name to uppercase
letters (PYTHON27__D$Purify...), so the error is does not occur anymore.
The current code is fragile though...
History
Date User Action Args
2022-04-11 14:56:14adminsetgithub: 42786
2009-01-12 15:39:23amaury.forgeotdarcsetstatus: open -> closed
resolution: works for me
messages: + msg79682
2006-01-11 16:02:25amaury.forgeotdarccreate