ctypes 0.9.6 released
theller at python.net
Fri Mar 18 20:33:57 CET 2005
ctypes 0.9.6 released - Mar 18, 2005
ctypes is an advanced ffi (Foreign Function Interface) package for
Python 2.3 and higher.
ctypes allows to call functions exposed from dlls/shared libraries
and has extensive facilities to create, access and manipulate
simple and complicated C data types in Python - in other words:
wrap libraries in pure Python. It is even possible to implement C
callback functions in pure Python.
ctypes now includes a code generator toolchain which allows
automatic creation of library wrappers from C header files.
This feature is still experimental and beta quality.
ctypes runs on Windows, MacOS X, Linux, Solaris, FreeBSD, OpenBSD.
It may also run on other systems, provided that libffi supports
For windows, ctypes contains a ctypes.com package which allows to
call and implement custom COM interfaces.
If you download the source distribution, please choose the ZIP
file for Windows, and the .tar.gz file for other machines.
These archive have different contents!
There have been lots of changes - if you are the author or user of
a package that uses ctypes, please test it with this release
and report problems on the ctypes-users mailing list.
Changes in 0.9.6
Thanks to all of you who reported bugs so quickly, and those who
tried out the codegenerator toolchain.
- keyword arguments in Structure/Union initializers had no effect.
- it was impossible to override the from_parm class method
in subclasses of c_void_p, c_char_p, and c_wchar_p.
- removed the __del__ method of _CDLL. It caused uncollectable
garbage in Python's gc.
- ctypes.com.register: enclose the Python script to run a com
server in quotes, otherwise it won't run correctly when the
directory name contains spaces.
- Several changes have been made to the h2xml script from the
codegenerator toolchain. See the documentation (linked below) for
Additions in 0.9.5
New package ctypes.wrap. This contains decorators usable for
easier creation of wrapper functions.
This package also contains a toolchain for (semi)automatic
creation of wrappers for external libraries - it can parse
C header files and generate ctypes code for the declarations in
them. It can even handle preprocessor definitions! For details,
Changes in 0.9.5
On systems where sizeof(int) == sizeof(long), c_int/c_long and
c_uint/c_ulong are now aliases. Similar for c_long/c_longlong and
c_ulong/c_ulonglong. This prevents unneeded type errors.
If an exception occurs in a callback function, a full traceback is
now printed. Raising SystemExit in a callback function now
correctly exists Python.
HRESULT is now a proper ctype - no longer a function. This allows
to use it in the argtypes sequence for function prototypes.
An easier way to define structures and unions that reference
themselves, or have dependencies to other data types. The
_fields_ attribute can now be set *after* the Structure/Union
class has been created. This makes the SetPointerType function
The semantics of the _fields_ attribute in sub-subclasses of
Structure and Union has been fixed. The baseclasses _fields_ list
is extended, not replaced, in subclasses. Assigning _fields_ when
it is no longer possible raises an error now.
Structures and unions now work as restype and in the argtypes list
An important bug has been fixed with pointers.
Detailed changelogs are in CVS:
Downloads are available in the sourceforge files section
Separate source distributions are available for windows and non-windows systems.
Please use the .zip file for Windows (it contains the ctypes.com framework),
and use the .tar.gz file for non-Windows systems (it contains the
complete cross-platform libffi sources).
Binary windows installers, which contain compiled extension
modules, are also available, be sure to download the correct one
for the Python version you are using.
More information about the Python-announce-list