Bug 1123886 - [abrt] dnf: i18n.py:138:_exact_width_char:TypeError: must be unicode, not str
[abrt] dnf: i18n.py:138:_exact_width_char:TypeError: must be unicode, not str
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: dnf-plugins-core (Show other bugs)
20
x86_64 Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Miroslav Suchý
Fedora Extras Quality Assurance
https://retrace.fedoraproject.org/faf...
abrt_hash:3f34490b19c15f2d9cbd2d3dbbf...
:
: 1128096 1130391 1132109 1154801 (view as bug list)
Depends On: 1128135
Blocks:
  Show dependency treegraph
 
Reported: 2014-07-28 10:37 EDT by Marcela Mašláňová
Modified: 2014-11-10 01:13 EST (History)
16 users (show)

See Also:
Fixed In Version: dnf-plugins-core-0.1.1-4.fc20
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-09-23 00:29:23 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)
File: backtrace (1.34 KB, text/plain)
2014-07-28 10:37 EDT, Marcela Mašláňová
no flags Details
File: environ (2.46 KB, text/plain)
2014-07-28 10:37 EDT, Marcela Mašláňová
no flags Details

  None (edit)
Description Marcela Mašláňová 2014-07-28 10:37:51 EDT
Description of problem:
I was using dnf-plugins-core, but I'm surprised that abrt catch it.

dnf copr list bkabrda
=========================================================================================================== List of bkabrda coprs ===========================================================================================================
Traceback (most recent call last):
  File "/bin/dnf", line 36, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 200, in user_main
    errcode = main(args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 83, in main
    return _main(base, args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 133, in _main
    cli.run()
  File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 1171, in run
    return self.command.run(self.base.extcmds)
  File "/usr/lib/python2.7/site-packages/dnf-plugins/copr.py", line 132, in run
    msg = self.base.output.fmtKeyValFill(msg, desc)
  File "/usr/lib/python2.7/site-packages/dnf/cli/output.py", line 704, in fmtKeyValFill
    keylen = exact_width(key)
  File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 164, in exact_width
    return sum(_exact_width_char(c) for c in msg)
  File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 164, in <genexpr>
    return sum(_exact_width_char(c) for c in msg)
  File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 138, in _exact_width_char
    return 2 if unicodedata.east_asian_width(uchar) in ('W', 'F', 'A') else 1
TypeError: must be unicode, not str

Version-Release number of selected component:
dnf-0.5.4-1.fc20

Additional info:
reporter:       libreport-2.2.3
cmdline:        /usr/bin/python -OO /bin/dnf copr list bkabrda
dso_list:       dnf-plugins-core-0.1.1-2.fc20.noarch
executable:     /bin/dnf
kernel:         3.14.7-200.fc20.x86_64
runlevel:       N 5
type:           Python
uid:            0

Truncated backtrace:
i18n.py:138:_exact_width_char:TypeError: must be unicode, not str

Traceback (most recent call last):
  File "/bin/dnf", line 36, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 200, in user_main
    errcode = main(args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 83, in main
    return _main(base, args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 133, in _main
    cli.run()
  File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 1171, in run
    return self.command.run(self.base.extcmds)
  File "/usr/lib/python2.7/site-packages/dnf-plugins/copr.py", line 132, in run
    msg = self.base.output.fmtKeyValFill(msg, desc)
  File "/usr/lib/python2.7/site-packages/dnf/cli/output.py", line 704, in fmtKeyValFill
    keylen = exact_width(key)
  File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 164, in exact_width
    return sum(_exact_width_char(c) for c in msg)
  File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 164, in <genexpr>
    return sum(_exact_width_char(c) for c in msg)
  File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 138, in _exact_width_char
    return 2 if unicodedata.east_asian_width(uchar) in ('W', 'F', 'A') else 1
TypeError: must be unicode, not str

Local variables in innermost frame:
uchar: 'b'
Comment 1 Marcela Mašláňová 2014-07-28 10:37:54 EDT
Created attachment 921773 [details]
File: backtrace
Comment 2 Marcela Mašláňová 2014-07-28 10:37:55 EDT
Created attachment 921774 [details]
File: environ
Comment 3 Ales Kozumplik 2014-07-28 10:52:05 EDT
Moving to the COPR guys. Miroslav, plugins are not supposed to use output.fmtKeyValFill(), it is not in the API.

Also CCing jsilhan, FYI.
Comment 4 Miroslav Suchý 2014-08-08 05:54:01 EDT
*** Bug 1128096 has been marked as a duplicate of this bug. ***
Comment 5 Igor Gnatenko 2014-08-08 05:59:25 EDT
(In reply to Ales Kozumplik from comment #3)
> Moving to the COPR guys. Miroslav, plugins are not supposed to use
> output.fmtKeyValFill(), it is not in the API.
I did this earlier, because couldn't find API func to do this.

What now we have to fill this ?
Comment 6 Ales Kozumplik 2014-08-08 07:18:43 EDT
(In reply to Igor Gnatenko from comment #5)
> (In reply to Ales Kozumplik from comment #3)
> > Moving to the COPR guys. Miroslav, plugins are not supposed to use
> > output.fmtKeyValFill(), it is not in the API.
> I did this earlier, because couldn't find API func to do this.
> 

The correct approach is to open a bug against DNF describing the use case that you want the API to cover.
Comment 7 Igor Gnatenko 2014-08-08 07:29:00 EDT
Filled.
Comment 8 Honza Silhan 2014-08-15 05:05:32 EDT
*** Bug 1130391 has been marked as a duplicate of this bug. ***
Comment 9 Branislav Blaškovič 2014-08-19 08:11:46 EDT
I probably hit this too with dnf-plugins-core-0.1.1-3.fc20.noarch:

    $ sudo dnf copr search nitrate
    [sudo] password for bblaskov:
    ================================================== Matched: nitrate ===================================================
    Traceback (most recent call last):
      File "/bin/dnf", line 36, in <module>
        main.user_main(sys.argv[1:], exit_code=True)
      File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 200, in user_main
        errcode = main(args)
      File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 83, in main
        return _main(base, args)
      File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 133, in _main
        cli.run()
      File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 1171, in run
        return self.command.run(self.base.extcmds)
      File "/usr/lib/python2.7/site-packages/dnf-plugins/copr.py", line 153, in run
        msg = self.base.output.fmtKeyValFill(msg, desc)
      File "/usr/lib/python2.7/site-packages/dnf/cli/output.py", line 704, in fmtKeyValFill
        keylen = exact_width(key)
      File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 164, in exact_width
        return sum(_exact_width_char(c) for c in msg)
      File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 164, in <genexpr>
        return sum(_exact_width_char(c) for c in msg)
      File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 138, in _exact_width_char
        return 2 if unicodedata.east_asian_width(uchar) in ('W', 'F', 'A') else 1
    TypeError: must be unicode, not str
Comment 10 Adam Samalik 2014-08-19 10:32:09 EDT
I have made an easy workaround which fixes that:

https://asamalik.fedorapeople.org/dnf_copr_search_workaround.patch
Comment 11 Honza Silhan 2014-08-19 11:11:36 EDT
Adam, thanks for taking action but this patch could not work in Python 3. I made more complex patch that cover that but I need to test it.
Comment 12 Miroslav Suchý 2014-08-19 11:21:29 EDT
Adam I took your patch, but instead used dnf.i18n.ucd() (which is documented in API) and the value is not needed to encode. So I minimalized it.

Commited as b3be04f.
Comment 13 Guy Streeter 2014-08-21 10:38:05 EDT
Another user experienced a similar problem:

sudo dnf copr search python

reporter:       libreport-2.2.3
cmdline:        /usr/bin/python -OO /bin/dnf copr search python3
dso_list:       dnf-plugins-core-0.1.1-3.fc20.noarch
executable:     /bin/dnf
kernel:         3.15.8-200.mst.fc20.x86_64
package:        dnf-0.5.4-2.fc20
reason:         i18n.py:138:_exact_width_char:TypeError: must be unicode, not str
runlevel:       N 5
type:           Python
uid:            0
Comment 14 Honza Silhan 2014-08-22 04:39:29 EDT
*** Bug 1132109 has been marked as a duplicate of this bug. ***
Comment 15 Fedora Update System 2014-09-05 06:42:53 EDT
dnf-plugins-core-0.1.3-1.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/dnf-plugins-core-0.1.3-1.fc21
Comment 16 Fedora Update System 2014-09-05 20:57:26 EDT
Package dnf-plugins-core-0.1.3-1.fc21:
* should fix your issue,
* was pushed to the Fedora 21 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-plugins-core-0.1.3-1.fc21'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-10134/dnf-plugins-core-0.1.3-1.fc21
then log in and leave karma (feedback).
Comment 17 Branislav Blaškovič 2014-09-08 03:00:50 EDT
Why is this build for fc21 when this bug has target version set to fc20?

Will it be backported to fc20?
Comment 18 Miroslav Suchý 2014-09-08 03:25:35 EDT
The version field have semantics (you get this help, when you click on the label):
 This field is used to denote the version of the product that the problem is found in. 

So it was found in F20. But maintainers decided to fix it in F21. This is quite common to non-fatal bugs. Of course, you can always ask maintainers (akozumpl or jsilhan) to backport it to F20.
Comment 19 Branislav Blaškovič 2014-09-08 03:45:10 EDT
You are right. I will contact maintainers to submit patch to fc20 as well.
Thank you.
Comment 20 Fedora Update System 2014-09-23 00:29:23 EDT
dnf-plugins-core-0.1.3-1.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 21 Honza Silhan 2014-10-24 03:50:57 EDT
*** Bug 1154801 has been marked as a duplicate of this bug. ***
Comment 22 Honza Horak 2014-10-30 16:44:55 EDT
Could this be fixed in F20, please?
Comment 23 Fedora Update System 2014-11-05 13:29:34 EST
dnf-plugins-core-0.1.1-4.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/dnf-plugins-core-0.1.1-4.fc20
Comment 24 lnie 2014-11-06 01:02:53 EST
dnf-plugins-core-0.1.1-4.fc20 works
Comment 25 Fedora Update System 2014-11-10 01:13:28 EST
dnf-plugins-core-0.1.1-4.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

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