[Python-Dev] cffi in stdlib

Armin Rigo arigo at tunes.org
Wed Feb 27 20:08:40 CET 2013


Hi Paul,

On Wed, Feb 27, 2013 at 7:24 PM, Paul Moore <p.f.moore at gmail.com> wrote:
> On 27 February 2013 11:53, Maciej Fijalkowski <fijall at gmail.com> wrote:
>> I think it means you can't use the ABI version and specify the calling
>> convention. It's a reasonable bug report (the calling convention on
>> API version works though)
>
> That would be a deal-breaker for my use case of quick scripts working
> with the Windows API on a machine with no C compiler. I'd have to use
> ctypes in that case until cffi had this feature.

That's not correct: you can't indeed give the calling convention, but
it is not needed for the common case.  What is not supported is only
Python-defined callbacks using the Windows-specific convention --- as
documented, there is a workaround for that case.

And, in case you wonder, this automatic detection comes from ctypes.
I copied the hacked-up version of libffi for Windows from ctypes to
cffi, and the logic to detect the actual calling convention and
support both is there.  The difference is only that in ctypes, after
it did the call (always successfully), it checks the convention that
was found to be used by the C function, and if it differs from the one
specified by the user, then it complains.  I basically just removed
the "complaining" part.


A bientôt,

Armin.


More information about the Python-Dev mailing list