Bug 1568366

Summary: detect_releasever is broken under python3
Product: [Fedora] Fedora Reporter: Kamil Páral <kparal>
Component: dnfAssignee: Jaroslav Mracek <jmracek>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: dmach, jmracek, mhatina, packaging-team-maint, rpm-software-management, vmukhame
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-06-28 08:21:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.