SyntaxError in KeyboardSVG.py with Python 2.5

Bug #460389 reported by Fridtjof Busse
50
This bug affects 9 people
Affects Status Importance Assigned to Milestone
onboard (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: python2.5

Installing python2.5-minimal (as a dependency of firmware-tools) give the following non-fatal error:

Richte python2.5-minimal ein (2.5.4-1ubuntu6) ...
Linking and byte-compiling packages for runtime python2.5...
/usr/lib/python2.5/site-packages/Onboard/KeyboardSVG.py:104: Warning: 'with' will become a reserved keyword in Python 2.6
Compiling /usr/lib/python2.5/site-packages/Onboard/KeyboardSVG.py ...
  File "/usr/lib/python2.5/site-packages/Onboard/KeyboardSVG.py", line 104
    with open(pane_svg_filename) as svg_file:
            ^
SyntaxError: invalid syntax

ProblemType: Bug
Architecture: amd64
Date: Sun Oct 25 13:27:12 2009
DistroRelease: Ubuntu 9.10
NonfreeKernelModules: nvidia
Package: python2.5-minimal 2.5.4-1ubuntu6
ProcEnviron:
 LANG=de_DE.UTF-8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.31-14.48-generic
SourcePackage: python2.5
Uname: Linux 2.6.31-14-generic x86_64

Related branches

Revision history for this message
Fridtjof Busse (fbusse-deactivatedaccount-deactivatedaccount) wrote :
affects: python2.5 (Ubuntu) → onboard (Ubuntu)
Revision history for this message
challman (challman) wrote :

Did you ever find a solution for this?

Revision history for this message
Fridtjof Busse (fbusse-deactivatedaccount-deactivatedaccount) wrote :

No, and I did not investigate any further.

Revision history for this message
TJ (tj) wrote :

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()
------

Changed in onboard (Ubuntu):
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
TJ (tj) wrote :
TJ (tj)
summary: - SyntaxError in package
+ SyntaxError in KeyboardSVG.py with Python 2.5
Revision history for this message
TJ (tj) wrote :
Changed in onboard (Ubuntu):
milestone: none → lucid-alpha-3
Revision history for this message
Francesco Fumanti (frafu) wrote :

Thanks TJ for the explanation of the problem and the instruction about how to fix it.

However, I wonder whether the patches are really necessary for karmic and lucid: are they not shipping by default python 2.6 that knows the "with" keyword?

Revision history for this message
TJ (tj) wrote : Re: [Bug 460389] Re: SyntaxError in KeyboardSVG.py with Python 2.5

On Thu, 2010-01-28 at 18:27 +0000, Francesco Fumanti wrote:
> Thanks TJ for the explanation of the problem and the instruction about
> how to fix it.
>
> However, I wonder whether the patches are really necessary for karmic
> and lucid: are they not shipping by default python 2.6 that knows the
> "with" keyword?

They are, but Python 2.5 is still an optional installation and for some
packages is still a dependency that gets installed.

That was how I met the issue - tried to install some other package
("rpm" which depends on "python-rpm" which depends on "python2.5") which
caused this issue when the python2.5 installation process tried to
byte-compile the packages from "/usr/share/pyshared/" into its
"site-packages/" directory.

Changed in onboard (Ubuntu):
status: Confirmed → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package onboard - 0.93.0-0ubuntu1

---------------
onboard (0.93.0-0ubuntu1) lucid; urgency=low

  * New upstream release (LP: #523403)
    - Add option to make onboard appear when unlocking the screen
    - Add possibility to do a middle click/right click by doing a left click
    - Fix for the translations (LP: #452897)
    - Replace with-keyword for compatibility with python < 2.6 (LP: #460389)
    - Do not launch settings dialog under GDM (LP: #440371)
    - Minimize to IconPalette if running under GDM, instead of disappearing
    - Fix capitalisation of the word GNOME (LP: #495526)
    - Check against version of auto module and not against version of package
    - Make it compatible to DistUtilsExtra.auto >= 2.10
    - Adjust permissions and fix typo (LP: #461491)
    - Fix long description in schemas file
    - Fix keysym of Del key
    - Fix taskbar icon visibility (LP: #456178)
  * debian/control:
    - Replace python-dev with python in Build-Depends
    - Update Standards-Version
    - Require python-distutils-extra >= 2.10
    - Add target to remove POT file on clean
  * debian/rules:
    - Add simple-patchsys.mk
 -- Francesco Fumanti <email address hidden> Wed, 17 Feb 2010 20:54:10 +0100

Changed in onboard (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers