system-config-printer.py crashed with Error in setlocale() in Jaunty BETA

Bug #340932 reported by ramesh
54
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python2.6 (Ubuntu)
Invalid
High
Unassigned
system-config-printer (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: system-config-printer

Dear Sir

This is happens when clicking in Printing in system-administration - printing menu.

Ram

ProblemType: Crash
Architecture: i386
DistroRelease: Ubuntu 9.04
ExecutablePath: /usr/share/system-config-printer/system-config-printer.py
InterpreterPath: /usr/bin/python2.6
Package: system-config-printer-gnome 1.1.3+git20090218-0ubuntu7
PackageArchitecture: all
ProcCmdline: python /usr/share/system-config-printer/system-config-printer.py
ProcEnviron:
 LANG=en_IN
 SHELL=/bin/bash
PythonArgs: ['/usr/share/system-config-printer/system-config-printer.py']
SourcePackage: system-config-printer
Title: system-config-printer.py crashed with Error in setlocale()
Uname: Linux 2.6.28-9-generic i686
UserGroups: adm admin cdrom dialout lpadmin plugdev sambashare

The following is the verbose output on jaunty-beta-amd64 (fully updated).

Connected as user root
refresh
Created subscription 18
<monitor.Monitor instance at 0x2cee5a8>: printers and jobs lists provided
update_jobs
Authentication pass: 1
Authentication: password callback set
Authentication pass: 1
Authentication: password callback set
Traceback (most recent call last):
  File "/usr/share/system-config-printer/system-config-printer.py", line 6760, in <module>
    focus_on_map)
  File "/usr/share/system-config-printer/system-config-printer.py", line 6708, in main
    print_test_page, focus_on_map)
  File "/usr/share/system-config-printer/system-config-printer.py", line 819, in __init__
    self.populateList()
  File "/usr/share/system-config-printer/system-config-printer.py", line 1270, in populateList
    self.printers = cupshelpers.getPrinters(self.cups)
  File "/var/lib/python-support/python2.6/cupshelpers/cupshelpers.py", line 419, in getPrinters
    printer = Printer(name, connection, **printer)
  File "/var/lib/python-support/python2.6/cupshelpers/cupshelpers.py", line 40, in __init__
    self.update (**kw)
  File "/var/lib/python-support/python2.6/cupshelpers/cupshelpers.py", line 88, in update
    self._expand_flags()
  File "/var/lib/python-support/python2.6/cupshelpers/cupshelpers.py", line 68, in _expand_flags
    locale.setlocale (locale.LC_CTYPE, current_ctype)
  File "/usr/lib/python2.6/locale.py", line 513, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting
Exception AttributeError: "Printer instance has no attribute '_ppd'" in <bound method Printer.__del__ of <cupshelpers.Printer "epsonfx">> ignored

Revision history for this message
ramesh (rameshumaiyer) wrote :
sgtbug (sgtbug)
description: updated
Revision history for this message
sgtbug (sgtbug) wrote :

I changed my default language to en_US [English (United States)], and it is working. Please fix it for en_IN

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

Tim, it seems that system-config-printer crashes on certain locales. Can you have a look into it? Perhaps one could do a "try .... except ..." or some kind of fallback chain (en_IN -> en -> C, pt_BR -> pt -> C, ...).

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

I can reproduce this bug by simply executing

LANG=en_IN system-config-printer

in a terminal window.

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

Tim, the problem somes from a place where the locale is temporarily set to "C" for using the lower() method and setting the locale back to the original makes s-c-p crash. Is there no less invasive way to use lower() (or something equivalent) in a locale-neutral way? For some users s-c-p is completely non-functional now, depending on their locale.

Changed in system-config-printer (Ubuntu):
importance: Undecided → High
milestone: none → ubuntu-9.04
status: New → Triaged
Revision history for this message
Tim Waugh (twaugh) wrote :

Till, have you tried with current 1.0.x?

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

No, I am using 1.1.x. Does 1.0.x contain another (better) fix for Trac #151?

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

The problem is the patch of Trac #151:

https://fedorahosted.org/system-config-printer/ticket/151

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

Well, have you tried with current 1.1.x?

If you are seeing this fail:

        current_ctype = locale.setlocale (locale.LC_CTYPE)
        locale.setlocale (locale.LC_CTYPE, "C")
        ...
        locale.setlocale (locale.LC_CTYPE, current_ctype)

then it is certainly a Python bug.

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

I don't much like the current approach anyway. If you like, rewrite that part so that has a static mapping between the two names, like:

flagmap = { cups.CUPS_PRINTER_AUTHENTICATED: 'authenticated',
                    cups.CUPS_PRINTER_BIND: 'bind',
                    ... }
for flag, name in flagmap.iteritems ():
  setattr(self, name, bool(self.type & flag))

Then you don't need the locale or blacklist handling.

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

I think this is not a good idea as the set of attributes can change in future CUPS versions and this way we will miss access to new attributes or get error if attributes get removed.

So I better move this to Python.

affects: system-config-printer (Ubuntu) → python-defaults (Ubuntu)
affects: python-defaults (Ubuntu) → python2.6 (Ubuntu)
Revision history for this message
Tim Waugh (twaugh) wrote :

Well, you could use getattr for the actual flag values. Or, alternatively, it's very easy to write a locale-independent lower() function and use that instead.

Locale handling seems to be riddled with bugs in Python, so I'm in favour of avoiding it when possible.

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

Fixed upstream in the 1.1.x GIT branch, commit 33132c1.

Changed in python2.6 (Ubuntu):
status: Triaged → In Progress
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Fixed in system-config-printer_1.1.3+git20090218-0ubuntu18 (Jaunty).

Changed in python2.6 (Ubuntu):
status: In Progress → Triaged
Changed in system-config-printer (Ubuntu):
status: New → Fix Released
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Tim, thanks for your good hints. They helped me to find this solution.

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

Neat fix. Thanks.

Revision history for this message
Matthias Klose (doko) wrote :

Re: comment #9

> then it is certainly a Python bug.

import locale
current_ctype = locale.setlocale (locale.LC_CTYPE)
locale.setlocale (locale.LC_CTYPE, "C")
locale.setlocale (locale.LC_CTYPE, current_ctype)

this doesn't fail for me; unsure what I am supposed to fix for python.

Changed in python2.6 (Ubuntu):
status: Triaged → Incomplete
Revision history for this message
Matthias Klose (doko) wrote :

closing the python2.6 task as invalid

Changed in python2.6 (Ubuntu):
status: Incomplete → Invalid
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.