Bug 1568366 - detect_releasever is broken under python3
Summary: detect_releasever is broken under python3
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jaroslav Mracek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Keywords: Triaged
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-04-17 11:14 UTC by Kamil Páral
Modified: 2018-06-28 08:21 UTC (History)
6 users (show)

(edit)
Clone Of:
(edit)
Last Closed: 2018-06-28 08:21:42 UTC


Attachments (Terms of Use)

Description Kamil Páral 2018-04-17 11:14:25 UTC
Description of problem:
dnf.rpm.detect_releasever() is behaving differently under Python2 and Python3. The difference is on this line:
https://github.com/rpm-software-management/dnf/blob/6517f47c94bdf2da2b1ce11605babee4d8cb8756/dnf/rpm/__init__.py#L49
where hdr[rpm.RPMTAG_PROVIDENAME] returns a list of strings under Python2, but a list of bytes under Python3, and therefore the following .index(distroverpkg) doesn't match anything.

Version-Release number of selected component (if applicable):
dnf-2.7.5-10.fc29.noarch
dnf-conf-2.7.5-10.fc29.noarch
dnf-plugins-core-2.1.5-4.fc28.noarch
dnf-yum-2.7.5-10.fc29.noarch
libdnf-0.11.1-3.fc28.x86_64
python2-dnf-2.7.5-10.fc29.noarch
python3-dnf-2.7.5-10.fc29.noarch
python3-dnf-plugins-core-2.1.5-4.fc28.noarch

How reproducible:
always

Steps to Reproduce:
1. I have modified fedora-release to have an extra provide:
# rpm -q --provides fedora-release | grep releasever
system-release(releasever) = rawhide
2. Under python2 I see:
# python -c 'import dnf; print dnf.rpm.detect_releasever("/")'
rawhide
3. Under python3 I see:
# python3 -c 'import dnf; print(dnf.rpm.detect_releasever("/"))'
29

After modifying the python3 dnf source, the hdr[rpm.RPMTAG_PROVIDENAME] contains:
[b'config(fedora-release)', b'fedora-release', b'fedora-release-nonproduct', b'fedora-release-standard', b'redhat-release', b'system-release', b'system-release(29)', b'system-release(releasever)']

And the caught exception is:
ValueError("'system-release(releasever)' is not in list",)

Comment 1 Jaroslav Mracek 2018-04-17 12:29:14 UTC
I created a patch https://github.com/rpm-software-management/dnf/pull/1062

Comment 2 Jaroslav Mracek 2018-06-28 08:21:42 UTC
The issue is solved by dnf-3.0.1-1 that was released into rawhide.


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