472,956 Members | 2,218 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,956 software developers and data experts.

ctypes 0.9.1 released

ctypes 0.9.1 released - Sept 14, 2004


ctypes is a 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 runs on Windows, MacOS X, Linux, Solaris, FreeBSD. It may
also run on other systems, provided that libffi supports this

On windows, ctypes contains a ctypes.com package which allows to
call and implement custom COM interfaces.
Changes in 0.9.1

ctypes 0.9.1 should be fully compatible again with Gary Bishop's
readline module which is also used by IPython.

ctypes changes

The internal conversions that ctypes does between unicode and
strings can now use a specified encoding and error handling. A
set_conversion_mode() function allows to set them, it returns the
previous values. The inital values are ('mbcs', 'ignore') on
Windows, and ('ascii', 'strict') on other systems.

When internal processing of an argument for a function call fails,
the new ctypes.ArgumentError is raised.

CDLL and its subclasses now accept an optional second handle
parameter. If this is supplied, it is used instead of calling
LoadLibrary() or dlopen() to get one.

Sometimes objects have been freed too early when calling functions
where argtypes have been set.

Fixed the create_unicode_buffer function - it was returning c_char
arrays instead of c_wchar arrays.

Both create_string_buffer and create_unicode_buffer can now be
called with string and unicode instances, they will do the needed
conversions themselves.

ctypes now allows calling Python C api functions. The 'pythonapi'
symbol should be used to access these functions, this will
automatically use the correct calling convention and exception
handling. The 'py_object' type is the ctypes variant of 'PyObject *'.
This feature should also work if you are using a static python

It is now possible to call cdecl functions with more arguments
than the length of the argtypes sequence specifies - this allows
to provide functions like sprintf() with a proper prototype.

It is now possible to create strings or unicode strings if you
have the integer address by calling c_char_p(address) or
c_wchar_p(address). Integers can also be assigned to structure
fields of type c_char_p and c_wchar_p.

c_char_p and c_wchar_p both accept strings and unicode strings -
if needed they are encoded or decoded using 'strict' error

The _ctypes.call_function function, although private and
deprecated, has been put back in - it is used by Gary Bishop's
readline module.

Array and pointer instances now support slicing, for pointers only
getslice is implemented (setslice is too dangerous, probably).
Slices are represented as lists of the elements, except
for character and unicode character pointer and arrays, where
strings resp. unicode strings are used instead.

On windows, the include files were missing from the source

The alignment function was not exported by the ctypes module. It
returns the alignment requirements in bytes of a type or instance.
ctypes.com changes

Applied a patch from Bruce Dodson which fixes an infinite loop in
readtlb.py if a typelib references types defined in another
typelib. readtlb still generates bad code for such cases, but the
results could be edited by hand if the dependencies can be sorted

ctypes now caches the types that WINFUNCTYPE and CFUNCTYPE
creates, to avoid unneeeded creation of classes. This
makes importing files containing a lot of COM interfaces (like the
ones that the readtlb tool generates) a lot (10 x) faster.

COM servers now print a short usage message when they are run
without the /regserver or /unregserver flag.

VARIANT does now handle the COM DATE type (VT_DATE) as Python

VARIANT now handles integers and longs correctly - if longs are
too large they are stored as doubles (VT_R8). Integers are now
stored as VT_I4 instead of VT_INT.

Detailed changelogs are in CVS:


Future plans

The ultimate purpose of the 0.9 release series is to shake out the
remaining bugs, especially on platforms I have no access to, and
to target a rock stable ctypes 1.0 release.

When ctypes 1.0 is released, the com framework will be split off
into a separate framework named 'comtypes'.

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.




Jul 18 '05 #1
1 2525
Thomas Heller wrote:
ctypes 0.9.1 released - Sept 14, 2004
===================================== [...] The _ctypes.call_function function, although private and
deprecated, has been put back in - it is used by Gary Bishop's
readline module.

IPython uses heavily Gary's readline and had been bitten by this. Windows
users of ipython have already confirmed that ctypes 0.9.1 fixes the problem.
I'd just like to send you a quick thank you note for accomodating us :)


Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Thomas Heller | last post by:
It's release day ;-) ctypes 0.6.3 released ===================== Overview 'ctypes' is a Python package to create and manipulate C data types in Python, and to call functions in dynamic...
by: Thomas Heller | last post by:
ctypes 0.9.2 released - Oct 28, 2004 ==================================== Overview ctypes is a ffi (Foreign Function Interface) package for Python 2.3 and higher. ctypes allows to call...
by: geskerrett | last post by:
I was wondering if a ctypes expert could point me in the right direction. I am using the wrapper for the "freeimage" library to create multipage TIFF files from a group of png images. The...
by: sjdevnull | last post by:
Hey, I'm trying to wrap GNU readline with ctypes (the Python readline library doesn't support the callback interface), but I can't figure out how to set values to a variable inside the library. ...
by: Daniel | last post by:
I'm trying to implement a routine that converts a PDF document to image files using ctypes and the Apple CoreGraphics library as per the 'Splitting a PDF File' example on Apple's web site ....
by: mmacrobert | last post by:
Hi Everyone, I've created a 'C' dll that is accessed via ctypes library containing a bunch of functions. I've successfully been able to use the functions. However, I would like to throw python...
by: Jack | last post by:
I'm not able to build IP2Location's Python interface so I'm trying to use ctypes to call its C interface. The functions return a pointer to the struct below. I haven't been able to figure out how...
by: Egor Zindy | last post by:
Egor Zindy wrote: #!/usr/bin/env python """ A generic chipid library based on ctypes This module handles most of the functions in FTChipID.dll
by: waldek | last post by:
Hi, I'm trying to handle data passed to Py Callback which is called from C dll. Callback passes data to another thread using Queue module and there the data are printed out. If data is...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.