[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Requiring Python 2.6 (was: Re: svn commit: r35458 - in branches/python-3-compatibility: . build subversion/bindings/swig subversion/tests/cmdline subversion/tests/cmdline/svntest tools/hook-scripts)

From: David James <james82_at_gmail.com>
Date: Sat, 21 Mar 2009 13:10:11 -0700

On Sat, Mar 21, 2009 at 12:13 PM, Arfrever Frehtes Taifersar Arahesis
<arfrever.fta_at_gmail.com> wrote:
> 2009-03-21 18:04:36 David James napisaƂ(a):
>> On Sun, Jan 25, 2009 at 11:25 AM, Arfrever Frehtes Taifersar Arahesis
>> <Arfrever.FTA_at_gmail.com> wrote:
>> > On the 'python-3-compatibility' branch:
>> > Require Python >=2.6.
>> > (Actually Python <2.6 wasn't supported earlier.)
>>
>> Hi Arfrever,
>>
>> Is it possible to support Python 3.0 without breaking compatibility
>> with Python 2.4?
>
> It is rather hard, because Python 2.5 doesn't support some syntax changes
> which were made in Python 3.

You're right -- it is hard. I think that converting Subversion to work
with Python 3 is a really hard task, because there are so many changes
in Python 3.0.

Reading up on the topic, I see that most people use one of two approaches:
  1. Leave your code as-is, but convert your code at build time to
work in Python 3.0 using 2to3
  2. Convert their source code to use syntax that works in all
versions of Python

Folks who use the 2to3 tool have reported that it doesn't work very
well -- a lot of files can't be parsed by the tool. I tried it on
ctypesgen and had little success. But maybe we should file bugs
against 2to3 and fix the bugs? Once 2to3 works well, we can actually
just teach autogen.sh to run 2to3 on our source files if you are using
Python 3.0

As for supporting Python 2.4 and 2.5 without using 2to3, here are a few ideas:

> 'except exception, variable:' => 'except exception as variable:'
> https://svn.collab.net/viewvc/svn?view=revision&revision=35001

According to < http://pythonology.blogspot.com/2009/02/making-code-run-on-python-20-through-30.html
>, you can support all versions by just doing "except exception:" and
then checking sys.exc_info(). Messy, but it works.

> 0123 => 0o123 or 0O123
> https://svn.collab.net/viewvc/svn?view=revision&revision=35608

It looks like most of the uses of octal numbers are for os.chmod. If
you want to write code that works in both Python 2 and 3, you can use
the constants in the stat module. E.g. "stat.S_IRWXU | stat.S_IRWXG |
stat.S_IRWXO"

Cheers,

David

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1374838
Received on 2009-03-21 21:10:29 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.