A critical bug with pointer instances was fixed, this makes the
incomplete types sample code in the tutorial actually work.
All ctypes objects are now correctly garbarge collected. This may lead to crashes in your program (especially with callback functions, or pointers handed out to longer running C code). You must keep a reference in Python to any object as long as it is used in foreign C code.
All known bugs have been fixed.
Again, a lot of changes to the COM package, but all this is still work in progress and unstable, and it has to be properly documented.
Fixed a bug which prevented callback functions to return data types other than integers. They can now also return pointers, floats, and doubles.
It is now possible to pass structures and unions to function calls by value. Currently this works only on Windows.
A lot of changes to the COM package, but all this is still work in progress and unstable, and it has to be properly documented.
ctypes types now have a
in_dll(dll, symbolname) class method.
It allows to access and/or change values exported by dlls.
Several bugs have been fixed.
ctypes has been converted into a package, it is no longer a
couple of modules.
This requires that you remove any previous version of
ctypes you may have installed, either (on Windows, if you have
installed from the exe-file) by running the uninstaller from
Control Panel->Add/Remove Programs, or by deleting the files
ctypes - the basic stuff mentioned in the tutorial
ctypes.wintypes - defines several common windows datatypes
ctypes.com - the beginning of a com framework, client code
as well as localserver code. This is only proof-of-concept
code, the interface is not stable at all.
ctypes.com.tools - an utility
readtlb.py which generates
Python wrapper code from type libraries.
ctypes.com.samples - this is not really a package, currently
it contains a sample which controls Internet Explorer, and
The com framework is currently undocumented, but I believe it contains quite some code which should be quite easy to read, at least for experienced com/C programmers. The basic goal of this framework is to allow easy collaboration with ATL servers and clients, it is centered around typelibraries.
The source distribution contains additional code in a samples directory tree and full documentation.
It is now safe to do
from ctypes import *, only symbols actually
needed are exposed.
Format characters like
"H" are no longer supported
anywhere. They must be replaced by the corresponding type like
c_ushort. String formats in Structures or Unions
"6c" which describe an array of 6 characters must be
c_char * 6.
Again, format characters are no longer allowed as function's
restype attribute. Replace them by the appropriate ctypes' type
like c_char_p instead of
"z" if the function returns a
string pointer, for example.
The type for callback functions can no longer be defined by
CFunction, actually this type no longer exists. The
recommended way to define the type of a callback function is to
WINFUNCTYPE() if you need a C-callable function pointer using
the __stdcall calling convention, or
CFUNCTYPE() if you need a
function pointer using the standard cdecl calling convention.
You have to supply the result type and the expected argument types.
Instances of these types are callable from C, but they are now also callable from Python directly.
These types can also be used in the
argtypes sequence, or as the
restype attribute if you have a dll function expecting or returning
a function pointer.
Pointer types are created by calling
POINTER function maintains a cache of created
types, so calling it with the same argument always returns the
same identical type.
pointer instances are usually created by
pointer() internally calls
POINTER() to get the type.
In previous versions the
c_wstring types could be
used to allocate mutable buffers and fill them from or convert
them to Python strings or unicode objects. These do no longer exist.
ctypes now exports a
c_buffer() function as a replacement.
c_buffer returns a character array (an instance of
c_char * size).