[PATCH 0 of 6] Port of hg's C modules to py3k
Michael Tharp
gxti at partiallystapled.com
Tue Jun 8 14:24:07 CDT 2010
On 06/08/2010 01:57 PM, Renato Cunha wrote:
> Main sources of incompatibility were:
>
> 1. The PyString* functions, which are gone for good;
> 2. The PyInt_* functions, which are also gone for good;
> 3. The module initialization functions& conventions, which have changed.
I wrote some macros to ease the transition without having nearly as many
#ifdef/#else/#endif blocks, maybe you can borrow some ideas:
http://hg.rpath.com/rmake-2.0/file/fe7aaf43bc5e/rmake/lib/pycompat.h
The most useful bits are probably the PYBYTES_Foo macros which switch
between PyString and PyBytes as appropriate. There's also
PYMODULE_DECLARE which takes care of much of the (varying) boilerplate
in creating a module, and the less ambitious PYMODULE_INIT/CREATE/RETURN
which PYMODULE_DECLARE is built from.
You can see examples of the PYMODULE_ macros (and others) here:
http://hg.rpath.com/conary/file/8b23b6c97774/conary/lib/misc.c
http://hg.rpath.com/rmake-2.0/file/fe7aaf43bc5e/rmake/lib/osutil.c
-- m. tharp
More information about the Mercurial-devel
mailing list