Bug 697905

Summary: commands failed if LANG = de_DE.UTF-8
Product: Red Hat Satellite 5 Reporter: Miroslav Suchý <msuchy>
Component: ClientAssignee: Miroslav Suchý <msuchy>
Status: CLOSED ERRATA QA Contact: Martin Minar <mminar>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 540CC: cperry, jhutar, mkoci, mminar, mmraka, ug
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: spacewalk-backend-1.2.13-44 rhn-virtualization-5.4.14-4 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 683546 Environment:
Last Closed: 2011-06-16 17:03:48 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 683546    
Bug Blocks: 677501    

Description Miroslav Suchý 2011-04-19 15:41:46 UTC
I'm clonning for Satellite and RHN Tools. As this bug will affect satellite-sync and rhn-virtualization

+++ This bug was initially created as a clone of Bug #683546 +++

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

--- Additional comment from msuchy on 2011-03-10 08:10:40 EST ---

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

--- Additional comment from msuchy on 2011-04-11 03:45:02 EDT ---

Mass moving to ON_QA before release of Spacewalk 1.4

Comment 1 Miroslav Suchý 2011-04-19 15:46:03 UTC
cherrypicked as 40abbbe50db2ea7288c72cf0661cd6570195f5b7

Comment 6 Clifford Perry 2011-06-16 17:03:48 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0878.html