Re: GNOME goal for 3.8: Python 3 -- impact for pygobject itself



Olav Vitters [2012-11-05 13:19 +0100]:
> There is also a script to change v2 to v3. Then I assume run it and
> done.

More precisely there is the tool "2to3" which is shipped with py3. It
gets the syntactic changes out of the way, and also copes with renamed
imports and some straightforward behavioural changes (lists turned
into iterators, etc.) By default it shows a diff, with -i it applies
the changes.

I haven't seen its output to be actively wrong, it's generally quite a
good one. In some cases it's overcautious and overcomplicates the
syntax unnecessarily, and in some cases when you want to make your
code work with both py2 and 3 you have to be more creative, but it's a
general first step for a port.

However, what the tool can't sort out for you is to properly sort out
byte arrays vs. strings in your code; python2 has mixed those all over
the place, resulting in the ever-enjoyable UnicodeDecodeErrors that
happen in only some circumstances/locales. py3 is strict with that,
which takes some effort in porting, but results in much more stable
code.

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]