Converting Orca to Python 3.0

Something we've got to be thinking about soon is seeing what needs to be done to get Orca to run with Python 3.0, which is planned to be available in Auguest 2008.

So I thought I'd give it a try now with the current Python 3.0a3 download.

Building it was trivial:

  $ cd /home/richb/Python-3.0a3
  $ ./configure --prefix=/usr
  $ make
  $ sudo make install

Guido and team have even made the conversion trivial. There is a tool called 2to3 in the Tools directory that will do the refactor for you.

I checked out a clean copy of the Orca sources from SVN and converted it with:

  $ cd /home/richb/Python-3.0a3/Tools/2to3
  $ python refactor.py /home/richb/gnome/orca/trunk/src >/tmp/diffs

This generated about 115KB of patch diffs on standard out which I then applied to the Orca source code:

  $ cd /home/richb/gnome/orca/trunk
  $ patch -p0 </tmp/diffs

I then configured, built and installed Orca with:

  $ cd /home/richb/gnome/orca/trunk
  $ ./autogen.sh --prefix=/usr
  $ make
  $ sudo make install

As it was byte-compiling all the Orca Python modules it bitched about the following two problems:

orca.py", line 1306
    + Q_("option|main-window") + "]", end=' ')
                                         \^
SyntaxError: invalid syntax

orca_prefs.py", line 636
    os.close(os.open(initFile, os.O_CREAT, 0o700))
                                               \^
SyntaxError: invalid syntax

For the second one, it looks like "0o700" should be "o0700" but I couldn't work out what was wrong with the first one. The original code was:

    print "-e, --enable=[" \\
        + Q_("option|speech") + "|" \\
        + Q_("option|braille") + "|" \\
        + Q_("option|braille-monitor") + "|" \\
        + Q_("option|magnifier") + "|" \\
        + Q_("option|main-window") + "]",

and it refactored it to:

    print("-e, --enable=[" \\
        + Q_("option|speech") + "|" \\
        + Q_("option|braille") + "|" \\
        + Q_("option|braille-monitor") + "|" \\
        + Q_("option|magnifier") + "|" \\
        + Q_("option|main-window") + "]", end=' ')

According to the What's New in Python 3.0 web page, that seems okay. For now I've just removed the "end=' '" part and I have a successful install (with a minor run-time formatting error when you print out the usage message).

When I run Orca, everything seems to work fine. No tracebacks and Orca is happy brailling and speaking away.

What worries me is that when I check the version number of /usr/bin/python (which is the same binary as /usr/bin/python3.0) I get:

  $ /usr/bin/python3.0 --version
  Python 2.5.2

So I'm not convinced I've done everything correctly.

Still it was nice to know that the conversion should hopefully be fairly trouble free when we do it for real. I guess that comes from pylinting the code to within an inch of its life.

[]

[]

Comments:

Post a Comment:
Comments are closed for this entry.
About

user12607856

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today