On Sat, Mar 21, 2009 at 12:13 PM, Arfrever Frehtes Taifersar Arahesis
> 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
As for supporting Python 2.4 and 2.5 without using 2to3, here are a few ideas:
> 'except exception, variable:' => 'except exception as variable:'
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
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 |
Received on 2009-03-21 21:10:29 CET