Opened 5 years ago

Last modified 5 years ago

#140 new task

python: Implement ctypes module

Reported by: dmik Owned by:
Priority: major Milestone:
Component: python Version:
Severity: medium Keywords:


It seems that the ctypes module that allows calling functions in native DLLs right from python doesn't support OS/2 at the moment. There is Win32 support though so adding OS/2 should be easy.

One should start from looking at source:/python/trunk/Modules/_ctypes/callproc.c and source:/python/trunk/Lib/ctypes/.

Change History (4)

comment:1 Changed 5 years ago by dmik

This functionality is for example used by the coolorama module which is part of the pip python library version 1.5.4 used by Mozilla esr31.

comment:2 Changed 5 years ago by dmik

Note that I currently use the following hack to /usr/lib/python2.7/ctypes/ to silently fail instead of throw an exception:

---   2015-02-26 21:23:20.000000000 +0400
+++ 2015-04-23 21:55:04.000000000 +0400
@@ -140,6 +140,10 @@
 elif == "posix":
     from _ctypes import dlopen as _dlopen

+elif == "os2":
+    def _dlopen(name, mode):
+        return
 from _ctypes import sizeof, byref, addressof, alignment, resize
 from _ctypes import get_errno, set_errno
 from _ctypes import _SimpleCData

I don't think it's OK to distribute this hack widely by including it into the package — it's too loose and there is a big probability to create unexpected behavior in many cases.

comment:3 Changed 5 years ago by dmik

Type: taskdefect

JFYI, more details about the failure that raised this ticket are here: In the meantime, I committed the above hack in r602.

comment:4 Changed 5 years ago by dmik

Type: defecttask
Note: See TracTickets for help on using tickets.