scp-dbus-service.py crashed with Error in setlocale(): unsupported locale setting

Bug #748964 reported by Gorfou
204
This bug affects 11 people
Affects Status Importance Assigned to Milestone
system-config-printer (Ubuntu)
Fix Released
Critical
Unassigned

Bug Description

Binary package hint: system-config-printer

Having installed the multipurpose printer hp, I wanted to print a page of test and right away I had error.
The page of test did not work.

ProblemType: Crash
DistroRelease: Ubuntu 11.04
Package: system-config-printer-common 1.3.1+20110222-0ubuntu12
ProcVersionSignature: Ubuntu 2.6.38-7.39-generic 2.6.38
Uname: Linux 2.6.38-7-generic x86_64
Architecture: amd64
Date: Sun Apr 3 11:46:08 2011
ExecutablePath: /usr/share/system-config-printer/scp-dbus-service.py
InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Beta amd64 (20110330)
InterpreterPath: /usr/bin/python2.7
Lpstat: device for HP-Photosmart-2570-series: hp:/net/Photosmart_2570_series?zc=HPB49503
MachineType: Gigabyte Technology Co., Ltd. GA-MA790X-UD3P
Papersize: letter
PpdFiles: HP-Photosmart-2570-series: HP Photosmart 2570 Series, hpcups 3.11.1
ProcCmdline: /usr/bin/python /usr/share/system-config-printer/scp-dbus-service.py
ProcEnviron:
 LANGUAGE=en_US:en
 LANG=fr_FR.UTF-8
 LC_MESSAGES=en_US.UTF-8
 SHELL=/bin/bash
ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-2.6.38-7-generic root=UUID=9001715d-0dbe-43b9-b47c-31470e787770 ro quiet splash vt.handoff=7
PythonArgs: ['/usr/share/system-config-printer/scp-dbus-service.py']
SourcePackage: system-config-printer
Title: scp-dbus-service.py crashed with Error in setlocale(): unsupported locale setting
UpgradeStatus: No upgrade log present (probably fresh install)
UserGroups: adm admin cdrom dialout lpadmin plugdev sambashare
dmi.bios.date: 04/02/2010
dmi.bios.vendor: Award Software International, Inc.
dmi.bios.version: F7a
dmi.board.name: GA-MA790X-UD3P
dmi.board.vendor: Gigabyte Technology Co., Ltd.
dmi.board.version: x.x
dmi.chassis.type: 3
dmi.chassis.vendor: Gigabyte Technology Co., Ltd.
dmi.modalias: dmi:bvnAwardSoftwareInternational,Inc.:bvrF7a:bd04/02/2010:svnGigabyteTechnologyCo.,Ltd.:pnGA-MA790X-UD3P:pvr:rvnGigabyteTechnologyCo.,Ltd.:rnGA-MA790X-UD3P:rvrx.x:cvnGigabyteTechnologyCo.,Ltd.:ct3:cvr:
dmi.product.name: GA-MA790X-UD3P
dmi.sys.vendor: Gigabyte Technology Co., Ltd.

Revision history for this message
Gorfou (muad-dib57) wrote :
tags: removed: need-duplicate-check
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Looks like the applet does not work with any non-English locale. Tim, can you have a look into this?

visibility: private → public
Revision history for this message
Tim Waugh (twaugh) wrote :

Works here.

tags: added: bugpattern-needed
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

For me it looks like this is a problem of Python. I can reproduce the error by directly calling Python:

till@till:~$ LC_ALL=C python -c 'import locale; print locale.setlocale (locale.LC_ALL, "")'
C
till@till:~$ LC_ALL=en_US.UTF-8 python -c 'import locale; print locale.setlocale (locale.LC_ALL, "")'
en_US.UTF-8
till@till:~$ LC_ALL=de_DE.UTF-8 python -c 'import locale; print locale.setlocale (locale.LC_ALL, "")'
de_DE.UTF-8
till@till:~$ LC_ALL=en_US python -c 'import locale; print locale.setlocale (locale.LC_ALL, "")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/locale.py", line 531, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting
till@till:~$ LC_ALL=de_DE python -c 'import locale; print locale.setlocale (locale.LC_ALL, "")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/locale.py", line 531, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting
till@till:~$

This means that Python accepts locales with "UTF-8" specification but not without.

I am not a locale expert so I do not know what really needs to get fixed in Python or in Ubuntu's locales, but a workaround in system-config-printer by surrounding locale.setlocale() with "try: ... except: ..." could solve the problem. Tim, WDYT?

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

The attached patch fixes the problem. It simply surrounds the crashing locale.setlocale() call with "try: ... except: pass". TIM, WDYT? Is this correct? What is the locale.setlocale() call good for? The returned result is not used.

Changed in system-config-printer (Ubuntu):
status: New → Confirmed
importance: Undecided → High
milestone: none → ubuntu-11.04
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

To all users who reported this bug and its duplicates, you can test by applying the patch of comment #5 via the following commands in a terminal window.

cd /
sudo patch -p0 < scp-dbus-service-py-do-not-fail-on-bad-locale.patch

After that close all system-config-printer windows and start system-config-printer again. Does it work now?

Revision history for this message
Tim Waugh (twaugh) wrote :

I can apply that, sure. It's pretty silly that setlocale can fail though IMHO.

Till: setlocale is for initialising e.g. gettext().

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Tim applied the patch upstream as GIT rev 6b105d3. Thanks, Tim.

tags: added: patch-accepted-upstream
Changed in system-config-printer (Ubuntu):
status: Confirmed → In Progress
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Uploaded the fixed Ubuntu package for Natty, -0ubuntu16.

Changed in system-config-printer (Ubuntu):
status: In Progress → Fix Committed
Changed in system-config-printer (Ubuntu):
importance: High → Critical
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package system-config-printer - 1.3.1+20110222-0ubuntu16

---------------
system-config-printer (1.3.1+20110222-0ubuntu16) natty; urgency=low

  * debian/patches/67_scp-dbus-service-py-do-not-fail-on-bad-locale.patch:
    Ignore errors of locale.selocale() function calls (LP: #748964).
 -- Till Kamppeter <email address hidden> Mon, 18 Apr 2011 15:33:00 +0200

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.