[PATCH 0 of 6] Port of hg's C modules to py3k

Renato Cunha renatoc at gmail.com
Tue Jun 8 17:57:26 UTC 2010


Hi,

the following patches implement a preliminary port of mercurial's C modules to
Python 3.

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.

To separate the python 2.x from the python 3.x implementations, I decided to
check PY_MAJOR_VERSION and define a IS_PY3K "symbol" for later checking if the
modules were being built by python 2.x or python 3.x, as suggested by the
python documentation [1].

To substitute the PyString* calls I decided to go with PyBytes, as, I suppose,
hg operates on bytes, anyway.

As int and long were unified in python 3, the logical decision here was to
substitute the PyInt* calls to PyLong.

As for the module initialization conventions, I am not really sure if I took
the best path, but I followed the tutorial, and, hopefully, there's nothing
wrong with the new versions.

I have already tested the new modules using the interpreter, and agree that
more testing is needed. For the basic testing, I'll write some python modules
to compare the output given by both interpreters and will be happy if the
output given by py3k agrees to the one given by python 2.x. At least for now,
since I cannot stress test the thing.

[1] http://docs.python.org/py3k/howto/cporting.html



More information about the Mercurial-devel mailing list