Python 3

Barry Warsaw barry at canonical.com
Tue Jun 22 23:20:31 BST 2010


On Jun 23, 2010, at 09:47 AM, Robert Collins wrote:

>I've done a couple of trivial patches moving in the direction of being
>able to play with Python 3 and bzr.

\o/

(quoting out of order...)

>If the consensus from this thread is that this is ok, I'll update
>HACKING docs appropriately.

HACKING.txt doesn't describe the minimum Python version for which
compatibility must be maintained.  Perhaps it should?  Maybe it's described in
a different document?  It does *imply* in a few places that Python 2.4 is the
minimum version.  Understandable of course, but darn.

>which on 2 is a no-op, and on 3 reencodes using latin-1 (so everything
>works). Or we could split out separate files to import on 2 and 3, but
>I think the extra seek would make it a wash perf wise.

Or split it out for Python 2.4/2.6+ compatibility?  At least you can write
idioms for the latter that 2to3 can more easily transform.  E.g...

>The no brainers (simple, not terribly ugly, not used a lot in our code):
>octal 0666 ->0o666
>print foo, bar -> print("%s %s" % (foo, bar))

from __future__ import print_function
print(foo, bar)

>exec foo, locals() -> exec(foo, locals())
>
>Somewhat ugly - we're going to see a lot of these:
>except Foo, e:

except Foo as e:

>->
>except Foo:
>    e = sys.exc_info()[1]
>
>bytestrings:
>This has the potential to slow load times slightly: in 3 to get a
>bytestring one says b'foo', but you can't do that in 2, so for
>single-source compatibility it gets written as:
> _b('foo')

b'foo' FTW. :)

>
>really ugly, but very few occurences:
>    raise type, val, tb
>->
>    bzrlib.util.py._builtin._reraise(type, val, tb)

raise

-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20100622/ed005c2b/attachment.pgp 


More information about the bazaar mailing list