apport-cli, apport-kde crashed with UnicodeEncodeError in many places

Bug #827090 reported by Rex Tsai
56
This bug affects 7 people
Affects Status Importance Assigned to Milestone
apport (Ubuntu)
Expired
Medium
Unassigned

Bug Description

apport does not manage stdio/stdout encoding correctly, it crashed if there is non ascii charsets. Users can not submit issue in many locales, need to switch LANGUAGE to en_US.

ProblemType: Crash
DistroRelease: Ubuntu 11.10
Package: apport 1.21.2-0ubuntu14
ProcVersionSignature: Ubuntu 3.0.0-8.11-generic 3.0.1
Uname: Linux 3.0.0-8-generic x86_64
Architecture: amd64
Date: Tue Aug 16 11:45:00 2011
ExecutablePath: /usr/bin/apport-cli
InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Release amd64 (20110426)
InterpreterPath: /usr/bin/python2.7
PackageArchitecture: all
ProcCmdline: /usr/bin/python /usr/bin/apport-cli /var/crash/_usr_lib_ibus-chewing_ibus-engine-chewing.1000.crash
ProcEnviron:
 LANG=en_US.UTF-8
 SHELL=/bin/bash
 PATH=(custom, user)
 LC_MESSAGES=en_US.UTF-8
 LANGUAGE=zh_TW:zh
PythonArgs: ['/usr/bin/apport-cli', '/var/crash/_usr_lib_ibus-chewing_ibus-engine-chewing.1000.crash']
SourcePackage: apport
Title: apport-cli crashed with UnicodeEncodeError in communicate(): 'ascii' codec can't encode characters in position 40-42: ordinal not in range(128)
UpgradeStatus: No upgrade log present (probably fresh install)
UserGroups: adm admin cdrom dialout libvirtd lpadmin plugdev sambashare vboxusers

Revision history for this message
Rex Tsai (chihchun) wrote :
visibility: private → public
Revision history for this message
Rex Tsai (chihchun) wrote :

By default, the python 2.7 on Ubuntu/Debian is using ascii as default encoding. There is an option in /usr/lib/python2.7/site.py, user can enable to support locale aware default string encodings, which is a system wide setting.

The better approach is to switch the default encoding to user's setting. Like

import locale
encoding = 'ascii'
loc = locale.getdefaultlocale()
if loc[1]:
    encoding = loc[1]

sys.setdefaultencoding(encoding)

Changed in apport (Ubuntu):
status: New → Confirmed
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Thanks for your report. Settign to 'Triaged' since it contains enough information and there is a duplicate.

Changed in apport (Ubuntu):
importance: Undecided → Medium
status: Confirmed → Triaged
Revision history for this message
Julian Taylor (jtaylor) wrote :

setdefaultencoding is disabled in site.py for a reason (and is removed in python3):
http://faassen.n--tree.net/blog/view/weblog/2005/08/02/0
http://tarekziade.wordpress.com/2008/01/08/syssetdefaultencoding-is-evil/

its better to properly fix your application, e.g. this fails:
python -c 'print u"\u03A9"' | cat
...
UnicodeEncodeError: 'ascii' codec can't encode character u'\u03a9'

this works:
python -c 'print u"\u03A9".encode("UTF-8")' | cat
Ω

tags: removed: need-duplicate-check
summary: - apport-cli crashed with UnicodeEncodeError in communicate(): 'ascii'
- codec can't encode characters in position 40-42: ordinal not in
- range(128)
+ apport-cli crashed with UnicodeEncodeError in many places
tags: added: l10n
removed: amd64 oneiric running-unity
description: updated
tags: added: oneiric precise
summary: - apport-cli crashed with UnicodeEncodeError in many places
+ apport-cli, apport-kde crashed with UnicodeEncodeError in many places
Revision history for this message
Rex Tsai (chihchun) wrote :

Dmitry, please upload the crashed backtrace of your issue, but not just change the bug summary. Thanks

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

This release of Ubuntu is no longer receiving maintenance updates. If this is still an issue on a maintained version of Ubuntu please let us know.

Changed in apport (Ubuntu):
status: Triaged → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for apport (Ubuntu) because there has been no activity for 60 days.]

Changed in apport (Ubuntu):
status: Incomplete → Expired
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.