Bug 683546 - rhnreg_ks --help failed if LANG = de_DE.UTF-8
Summary: rhnreg_ks --help failed if LANG = de_DE.UTF-8
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Spacewalk
Classification: Community
Component: Clients
Version: 1.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Suchý
QA Contact: Red Hat Satellite QA List
URL:
Whiteboard:
Depends On:
Blocks: space14 697835 697905
TreeView+ depends on / blocked
 
Reported: 2011-03-09 16:56 UTC by Uwe Gansert
Modified: 2011-04-26 09:10 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 697905 (view as bug list)
Environment:
Last Closed: 2011-04-26 09:10:18 UTC
Embargoed:


Attachments (Terms of Use)
suggested fix (954 bytes, patch)
2011-03-09 16:56 UTC, Uwe Gansert
no flags Details | Diff

Description Uwe Gansert 2011-03-09 16:56:19 UTC
Created attachment 483262 [details]
suggested fix

d64:~ # export LANG=de_DE.UTF-8
d64:~ # rhnreg_ks --help
Ein Fehler trat auf:
<type 'exceptions.UnicodeDecodeError'>
Siehe /var/log/up2date für weitere Informationen

/var/log/up2date:
[Mon Jan 17 11:51:00 2011] up2date 
Traceback (most recent call last):
  File "/usr/sbin/rhnreg_ks", line 205, in <module>
    cli.run()
  File "rhncli.py", line 73, in run
  File "rhncli.py", line 112, in initialize
  File "/usr/lib64/python2.6/optparse.py", line 1378, in parse_args
    stop = self._process_args(largs, rargs, values)
  File "/usr/lib64/python2.6/optparse.py", line 1418, in _process_args
    self._process_long_opt(rargs, values)
  File "/usr/lib64/python2.6/optparse.py", line 1493, in _process_long_opt
    option.process(opt, value, values, self)
  File "/usr/lib64/python2.6/optparse.py", line 782, in process
    self.action, self.dest, opt, value, values, parser)
  File "/usr/lib64/python2.6/optparse.py", line 804, in take_action
    parser.print_help()
  File "/usr/lib64/python2.6/optparse.py", line 1648, in print_help
    file.write(self.format_help().encode(encoding, "replace"))
<type 'exceptions.UnicodeDecodeError'>: 'ascii' codec can't decode byte 0xc3 in
position 781: ordinal not in range(128)

d64:~ # export LANG=en_US.UTF-8
d64:~ # rhnreg_ks --help
Usage: rhnreg_ks [options]

Options:
  -v, --verbose         Show additional output
  --proxy=PROXY         Specify an http proxy to use
  --proxyUser=PROXYUSER
                        Specify a username to use with an authenticated http
                        proxy
  --proxyPassword=PROXYPASSWORD
                        Specify a password to use with an authenticated http
                        proxy
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  --profilename=PROFILENAME
                        Specify a profilename
  --username=USERNAME   Specify a username
  --password=PASSWORD   Specify a password
  --systemorgid=SYSTEMORGID
                        Specify an organizational id for this system
  --serverUrl=SERVERURL
                        Specify a url to use as a server
  --sslCACert=SSLCACERT
                        Specify a file to use as the ssl CA cert
  --activationkey=ACTIVATIONKEY
                        Specify an activation key
  --use-eus-channel     Subscribe this system to the EUS channel tied to the
                        system's redhat-release
  --contactinfo         [Deprecated] Read contact info from stdin
  --nohardware          Do not probe or upload any hardware info
  --nopackages          Do not profile or upload any package info
  --novirtinfo          Do not upload any virtualization info
  --norhnsd             Do not start rhnsd after completion
  --force               Register the system even if it is already registered

Comment 1 Miroslav Suchý 2011-03-10 13:10:40 UTC
provided patch can be shortened to:
_ = lambda x: unicode(gettext.gettext(x), 'utf-8'))

This problem was not even with de, it happened with other languages as well. And with different commands (e.g spacewalk-channel) as well.

I find what is the cause as the idiom
 _ = gettext.gettext
is used very often in other projects. Adelton find the change in python which is the cause:
http://svn.python.org/view?revision=46861&view=revision

And I find in python documentation that prefered idiom for translations in Unicode is:
http://docs.python.org/library/gettext.html#localizing-your-module

Fixed in spacewalk.git:
ceb71f81a3b64d8a71781f65f9d82b88340601e8

Comment 2 Miroslav Suchý 2011-04-11 07:45:02 UTC
Mass moving to ON_QA before release of Spacewalk 1.4

Comment 3 Miroslav Suchý 2011-04-26 09:10:18 UTC
Spacewalk 1.4 has been released


Note You need to log in before you can comment on or make changes to this bug.