Bug 242341 - yum info command fails with unicode error
yum info command fails with unicode error
Status: CLOSED DUPLICATE of bug 244080
Product: Fedora
Classification: Fedora
Component: yum (Show other bugs)
7
i686 Linux
low Severity low
: ---
: ---
Assigned To: James Antill
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-06-03 10:14 EDT by Matt Wette
Modified: 2014-01-21 17:58 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-06-13 14:30:31 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Matt Wette 2007-06-03 10:14:42 EDT
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. yum info
2.
3.
  
Actual results:
]# yum info > YUM_INFO
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in <module>
    yummain.main(sys.argv[1:])
  File "/usr/share/yum-cli/yummain.py", line 94, in main
    result, resultmsgs = base.doCommands()
  File "/usr/share/yum-cli/cli.py", line 264, in doCommands
    return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd,
self.extcmds)
  File "/usr/share/yum-cli/yumcommands.py", line 165, in doCommand
    base.listPkgs(ypl.available, 'Available Packages', basecmd)
  File "/usr/share/yum-cli/output.py", line 102, in listPkgs
    self.infoOutput(pkg)
  File "/usr/share/yum-cli/output.py", line 73, in infoOutput
    print _("Description:\n%s") % pkg.description
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb4' in position
109: ordinal not in range(128)



Expected results:
no error message

Additional info:
The YUM_INFO file is populated with expected data.
Comment 1 Doncho N. Gunchev 2007-06-06 12:40:08 EDT
Here's quicker way to reproduce - yum info package | cat. Example:
$ yum info ballz
...
Available Packages
Name   : ballz
Arch   : i386
Version: 1.0
Release: 1.fc7
Size   : 163 k
Repo   : fedora
Summary: Platform game with some puzzle elements
Description:
Ballz is a platformer with some puzzle elements. You take control of a ball
which is genetically modified by the British secret service. Your mission is
to rescue captured British soldiers from a prison in Iran.

The game was written in 72 hours for the TINS competition, a competition
similar to Speedhack. The name TINS is an recursive acronym for ‘TINS is
not Speedhack’.

$ yum info ballz | cat
...
Available Packages
Name   : ballz
Arch   : i386
Version: 1.0
Release: 1.fc7
Size   : 163 k
Repo   : fedora
Summary: Platform game with some puzzle elements
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in <module>
    yummain.main(sys.argv[1:])
  File "/usr/share/yum-cli/yummain.py", line 94, in main
    result, resultmsgs = base.doCommands()
  File "/usr/share/yum-cli/cli.py", line 264, in doCommands
    return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd,
self.extcmds)
  File "/usr/share/yum-cli/yumcommands.py", line 165, in doCommand
    base.listPkgs(ypl.available, 'Available Packages', basecmd)
  File "/usr/share/yum-cli/output.py", line 102, in listPkgs
    self.infoOutput(pkg)
  File "/usr/share/yum-cli/output.py", line 73, in infoOutput
    print _("Description:\n%s") % pkg.description
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position
363: ordinal not in range(128)

The strange thing is, that I have packages that show Cyrillic letters correctly
(xorg-x11-drv-vesa's description and summary are translated in Bulgarian for
example, but yum shows it fine with '| cat'), but this one with u'\u2018' (‘)
breaks it. The only thing I don't like in python is that it matters if the
script outputs to a terminal or to a file/pipe, but in this case it does not
look so simple...
Comment 2 Vladimir Mosgalin 2007-06-12 08:27:54 EDT
No, it's exactly the same problem as usual. You can't depend on output charset
detection when converting unicode strings to utf-8 or other encoding, it works
only when output is terminal and breaks on pipe (as soon as you try to output
something that isn't ascii). There are different workarounds, for example
storing strings only as unicode objects and explictly encode them to charset
from current locale, for example. Or having only utf-8 encoded string (which is
bad)..

For some reason, yum gets description of xorg-x11-drv-vesa as plain string,
utf-8 encoded. Yum just outputs it as is. So encoding problem doesn't happen, on
the other hand, if you were to run "LANG=bg_BG.CP1251 yum info" with CP1251
charset set in terminal, all other descriptions would look correct because they
would be recoded to CP1251, but xorg-x11-drv-vesa description will stay as utf-8
string..

This inconsistency is another bug, I suppose.
Comment 3 Jeremy Katz 2007-06-13 14:30:31 EDT

*** This bug has been marked as a duplicate of 244080 ***

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