ctypes 0.9.9.3 released
theller at python.net
Wed Feb 15 20:47:38 CET 2006
ctypes 0.9.9.3 released - Feb 15, 2006
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 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, Windows CE, MacOS X, Linux, Solaris,
FreeBSD, OpenBSD. It may also run on other systems, provided that
libffi supports this platform.
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.9.3
(These are the most important changes, see the ChangeLog for
The ctypes.com package is no longer included and supported.
It is replaced by the comtypes package which will be released
ctypes has been ported to Windows CE by Luke Dunstan.
Hye-Shik Chang has written a new build system for libffi
which should remove possible licensing issues.
The library loading code has been rewritten by Andreas Degert,
there are now sophisticated methods to find shared libraries.
On OS X, this uses files from Bob Ippolito's macholib.
See the manual for details.
Finally I started to write the manual, it is available online:
New 'errcheck' protocol to check the return values of foreign
functions, suggested by Mike Fletcher.
Lots of bug fixes, especially for 64-bit platforms. Improved
performance when creating ctypes instances.
Subclasses of simple types (c_int, c_void_p, and so on) now
behave as expected - they are not automatically converted into
native Python types any longer.
Support for explicit byte ordering in structures has been
added (BigEndianStructure, LittleEndianStructure base
call byref() automatically, if needed, for POINTER types in
Lots of improvements to the code generator.
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 changelog is 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 and Windows CE, 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