Hi,
I managed to compile lxml against Py3, although I couldn't test it so far as
the PyFile_* functions are gone due to the new I/O system. Also, Cython's test
runner didn't work right away, as it (obviously) tries to compile the tests
using Cython, and Cython itself does not yet run under Py3. So I added a work
around. If you run
python2.5 runtests.py --no-cleanup
python3.0 runtests.py --no-cython
it will run Cython from Python 2.5 to compile and run the tests, but not
delete the generated .c files, and then run Python3 to C-compile and run the
tests without importing Cython at all. This allows testing the generated
sources with different Python versions in general.
However, for Py3 in particular, all tests go straight red (as expected ;) The
problem is (again) identifiers, which are unicode strings in Py3. So we will
have to find a way to make every one of them a unicode string, from class
names to keyword arguments, but only on Py3. A good idea might be to actually
remove the string interning Option and *always* intern identifiers, so that we
have more control over how they enter the runtime environment. I'll look into
that when I find the time...
Regarding Cython's source itself, I tried running the 2to3 tool on Cython like
this:
python3.0 -m lib2to3.refactor Cython
which generates a 3000 lines patch, but being only a static analysis tool, it
breaks the ".next()" method on the scanner, thinking that what we actually
meant was calling the new built-in "next()" function on an iterator. We might
even work around that by actually making it an iterator, not sure if that will
work.
Other than I thought, the 2to3 tool does not touch string literals, so if you
use a byte string literal in Py2 code, it will become a unicode literal after
running 2to3. I think this is good for Cython where most byte string literals
are really meant to be unicode literals. We might still want to take a bit of
caution here, as there might be places where this is not the case.
You can find the current Py3 branch of Cython here:
http://hg.cython.org/cython-devel-py3
It will (or at least should) compile things nicely on Py2 without a noticeable
difference, but it will not yet compile any code correctly for Py3. I'll keep
working on it, any help is appreciated.
Have fun,
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev