Opened 4 years ago

Last modified 3 years ago

#140 new task

python: Implement ctypes module

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

Description

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 4 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 4 years ago by dmik

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

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

+elif _os.name == "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 3 years ago by dmik

  • Type changed from task to defect

JFYI, more details about the failure that raised this ticket are here: https://github.com/bitwiseworks/mozilla-os2/issues/100#issuecomment-95366689. In the meantime, I committed the above hack in r602.

comment:4 Changed 3 years ago by dmik

  • Type changed from defect to task
Note: See TracTickets for help on using tickets.