Current py3k stage and next steps

Renato Cunha renatoc at gmail.com
Thu Jun 24 23:08:15 CDT 2010


Hi all,

As some of you might know, I've managed to build hg with python3. It is far
from being usable, since the only command that actually works is hg version.
To get to this, I had to run 2to3 and do some manual edits. Some of those
edits can be easily implemented as 2to3 fixers, while others will need a
compatibility layer to work. I've already noticed that, for some strange
reason, my current py3k "port" is trying to read .hg/00changelog.i instead of
.hg/store/00changelog.i, as exemplified in the command below:

$ ./hg tip
abort: index 00changelog.i unknown format 2!

(the dummy 00changelog.i in the .hg directory actually has that '2' embedded
in it)

It might probably have to do with osutil's functions returning bytes objects
and some incompatibilities with implicit assumptions in other parts of the
code (hints, anyone?). Whatever action I take now, I believe standardizing the
bytes vs.  strings issue is crucial to making the py3k version work. I believe
getting 'hg tip' to run would be a reasonable next milestone.

To do that, I'd have to define a compatibility layer for str/bytes...  Martin
Geisler commented on IRC that I could use Uche Mennel's ustr[1] to separate
strings and unicode objects. Another approach would be to use Martin v. Löwis'
py3 module[2]. Maybe integrating both approaches would be a nice way of doing
it, defining u to be ustr in 2.x and str in py3k...

I'd like to hear from you regarding the string approaches and would like to
have you raising some points I might be ignoring. I would also like to know if
debugging localrepo/revlog/store and friends would be a reasonable approach
for now. Long story short: if you have some ideas for my next steps, I'd love
to hear your opinions. Also, if you need some clarifications, feel free to
ask.

[1] http://bitbucket.org/mg/ustr/changeset/fb3e0ff02579
[2] http://bitbucket.org/loewis/django-3k/src/tip/django/utils/py3.py

List of issues not handled by 2to3 so far:
 * Modules of the email package that had capitalized names were changed to
 lowercase;
 * ugettext doesn't exist anymore (gettext now returns a bytes/str according
 to the input passed to it);
 * Encoding gettext's output breaks the ui;
 * Inheriting from file won't work (I suppose io.RawIOBase is what we want in
 py3k).

Regards,
-- 
Renato Cunha <http://renatocunha.com>


More information about the Mercurial-devel mailing list