[Bug 460389] Re: SyntaxError in package

TJ ubuntu at tjworld.net
Sat Jan 23 19:04:03 GMT 2010


This is caused because the package relies upon using the Python "with"
keyword. For Python 2.6 "with" is available by default but for Python
2.5 any script that uses "with" needs to do a future import as the first
line of the script:

from __future__ import with_statement

Compiling the package manually shows the same error:

--- Python 2.5 ---
cd /usr/lib/python2.5/site-packages/Onboard/
sudo rm *.pyc
sudo python2.5
Python 2.5.4 (r254:67916, Jan 20 2010, 21:43:02) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import compileall
>>> compileall.compile_dir('./')
Listing ./ ...
Compiling ./Config.py ...
Compiling ./Exceptions.py ...
Compiling ./IconPalette.py ...
Compiling ./KbdWindow.py ...
Compiling ./KeyCommon.py ...
Compiling ./KeyGtk.py ...
Compiling ./Keyboard.py ...
Compiling ./KeyboardGTK.py ...
Compiling ./KeyboardSVG.py ...
./KeyboardSVG.py:105: Warning: 'with' will become a reserved keyword in Python 2.6
  File "./KeyboardSVG.py", line 105
    with open(pane_svg_filename) as svg_file:
            ^
SyntaxError: invalid syntax

Compiling ./OnboardGtk.py ...
Compiling ./Pane.py ...
Compiling ./SnippetList.py ...
Compiling ./__init__.py ...
Compiling ./settings.py ...
Compiling ./utils.py ...
0
>>> exit()
------

The attached patch adds the required line to KeyboardSVG.py. It is
tested with python2.5 and python2.6 on Karmic and works for both:

--- Python 2.5 ---
cd /usr/lib/python2.5/site-packages/Onboard/
sudo rm *.pyc
sudo python2.5
Python 2.5.4 (r254:67916, Jan 20 2010, 21:43:02) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import compileall
>>> compileall.compile_dir('./')
Listing ./ ...
Compiling ./Config.py ...
Compiling ./Exceptions.py ...
Compiling ./IconPalette.py ...
Compiling ./KbdWindow.py ...
Compiling ./KeyCommon.py ...
Compiling ./KeyGtk.py ...
Compiling ./Keyboard.py ...
Compiling ./KeyboardGTK.py ...
Compiling ./KeyboardSVG.py ...
Compiling ./OnboardGtk.py ...
Compiling ./Pane.py ...
Compiling ./SnippetList.py ...
Compiling ./__init__.py ...
Compiling ./settings.py ...
Compiling ./utils.py ...
1
>>> exit()
------

--- Python 2.6 ---
cd /usr/lib/python2.6/dist-packages/Onboard/
sudo rm *.pyc
sudo python2.6
Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import compileall
>>> compileall.compile_dir('./')
Listing ./ ...
Compiling ./Config.py ...
Compiling ./Exceptions.py ...
Compiling ./IconPalette.py ...
Compiling ./KbdWindow.py ...
Compiling ./KeyCommon.py ...
Compiling ./KeyGtk.py ...
Compiling ./Keyboard.py ...
Compiling ./KeyboardGTK.py ...
Compiling ./KeyboardSVG.py ...
Compiling ./OnboardGtk.py ...
Compiling ./Pane.py ...
Compiling ./SnippetList.py ...
Compiling ./__init__.py ...
Compiling ./settings.py ...
Compiling ./utils.py ...
1
>>> exit()
------

** Patch added: "Use __future__ with for2.5"
   http://launchpadlibrarian.net/38309170/32-use_future_with_for_2.5.patch

** Changed in: onboard (Ubuntu)
       Status: New => Confirmed

** Changed in: onboard (Ubuntu)
   Importance: Undecided => Medium

-- 
SyntaxError in package
https://bugs.launchpad.net/bugs/460389
You received this bug notification because you are a member of
Accessibility, which is subscribed to onboard in ubuntu.



More information about the Ubuntu-accessibility-bugs mailing list