Bug 1223034

Summary: [abrt] python-dnf: pycomp.py:88:write_to_file:UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 24: ordinal not in range(128)
Product: [Fedora] Fedora Reporter: Farid <shawnx>
Component: dnf-plugins-extrasAssignee: Radek Holy <rholy>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 22CC: heldwin, ignatenko, jkadlcik, jsilhan, jzeleny, mluscon, packaging-team-maint, pnemade, rholy, shawnx, tim.lauridsen, vmukhame
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
URL: https://retrace.fedoraproject.org/faf/reports/bthash/be015242f90b1edc82a40e96ee36a6d6b7c739e2
Whiteboard: abrt_hash:39a98c03c1ff61eb6e01b1f7f1f65845f00b4df9
Fixed In Version: dnf-plugins-extras-0.0.8-1.fc22 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-05-30 15:56:38 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:
Attachments:
Description Flags
File: backtrace
none
File: environ none

Description Farid 2015-05-19 16:09:42 UTC
Description of problem:
dnf migrate

Version-Release number of selected component:
python-dnf-1.0.0-1.fc22

Additional info:
reporter:       libreport-2.5.1
cmdline:        /usr/bin/python -OO /bin/dnf-2 migrate
dso_list:       python-dnf-plugins-extras-migrate-0.0.7-1.fc22.noarch
executable:     /bin/dnf-2
kernel:         4.0.2-300.fc22.x86_64
runlevel:       N 5
type:           Python
uid:            0

Truncated backtrace:
pycomp.py:88:write_to_file:UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 24: ordinal not in range(128)

Traceback (most recent call last):
  File "/bin/dnf-2", 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 185, in user_main
    errcode = main(args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 84, in main
    return _main(base, args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 134, in _main
    cli.run()
  File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 1077, in run
    return self.command.run(self.base.extcmds)
  File "/usr/lib/python2.7/site-packages/dnf-plugins/migrate.py", line 123, in run
    self.migrate_yumdb()
  File "/usr/lib/python2.7/site-packages/dnf-plugins/migrate.py", line 289, in migrate_yumdb
    setattr(dnfdata, attribute, value)
  File "/usr/lib/python2.7/site-packages/dnf/yum/rpmsack.py", line 295, in __setattr__
    self._write(attr, value)
  File "/usr/lib/python2.7/site-packages/dnf/yum/rpmsack.py", line 232, in _write
    dnf.pycomp.write_to_file(fo, value)
  File "/usr/lib/python2.7/site-packages/dnf/pycomp.py", line 88, in write_to_file
    f.write(content.encode('utf-8'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 24: ordinal not in range(128)

Local variables in innermost frame:
content: '-y install /home/smael/T\xc3\xa9l\xc3\xa9chargements/skype-4.3.0.37-fedora.i586.rpm'
f: <open file u'/var/lib/dnf/yumdb/t/f454a7a23f9b3e664fe07ac7de22123369c2cbf4-tcp_wrappers-libs-7.6-76.fc20-i686/command_line.tmp', mode 'w' at 0x7fb788f9f780>

Comment 1 Farid 2015-05-19 16:09:46 UTC
Created attachment 1027298 [details]
File: backtrace

Comment 2 Farid 2015-05-19 16:09:47 UTC
Created attachment 1027299 [details]
File: environ

Comment 3 Farid 2015-05-19 16:10:19 UTC
Another user experienced a similar problem:

dnf migrate

reporter:       libreport-2.5.1
cmdline:        /usr/bin/python -OO /bin/dnf migrate
event_log:      2015-05-19-18:09:59> (« report_uReport » terminé avec succès)
executable:     /bin/dnf
kernel:         4.0.2-300.fc22.x86_64
package:        dnf-1.0.0-1.fc22
reason:         pycomp.py:88:write_to_file:UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 24: ordinal not in range(128)
runlevel:       N 5
type:           Python
uid:            0

Comment 4 Radek Holy 2015-05-20 12:35:43 UTC
Thank you for the report.

The `dnf.pycomp.write_to_file` function is apparently broken. It does not work for non-ascii byte strings.

On the other hand, to be safe, I think that the migrate plugin should convert all the byte strings to Unicode strings. That would improve the plugin as well as work around the problem with `write_to_file`.

We'll take a look.

Comment 5 Radek Holy 2015-05-20 12:41:46 UTC
Let's improve the wording: "as a side effect, it would work around the problem with `write_to_file` as well."

Comment 6 Radek Holy 2015-05-22 07:31:30 UTC
It apparently affects a lot of people, taking...

Comment 8 Fedora Update System 2015-05-22 17:26:32 UTC
dnf-plugins-extras-0.0.8-1.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/dnf-plugins-extras-0.0.8-1.fc22

Comment 9 Fedora Update System 2015-05-26 03:14:59 UTC
Package dnf-plugins-extras-0.0.8-1.fc22:
* should fix your issue,
* was pushed to the Fedora 22 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-plugins-extras-0.0.8-1.fc22'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-8740/dnf-plugins-extras-0.0.8-1.fc22
then log in and leave karma (feedback).

Comment 10 Fedora Update System 2015-05-30 15:56:38 UTC
dnf-plugins-extras-0.0.8-1.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 11 Honza Silhan 2015-07-22 13:19:20 UTC
*** Bug 1224049 has been marked as a duplicate of this bug. ***