Bug 1693774 - rpmdeplint: Switch to a string for RPM calls (oncoming rpm API fix change)
Summary: rpmdeplint: Switch to a string for RPM calls (oncoming rpm API fix change)
Alias: None
Product: Fedora
Classification: Fedora
Component: rpmdeplint
Version: rawhide
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Miroslav Vadkerti
QA Contact: Fedora Extras Quality Assurance
Depends On:
Blocks: 1693751 1779194
TreeView+ depends on / blocked
Reported: 2019-03-28 15:30 UTC by Panu Matilainen
Modified: 2020-06-03 10:49 UTC (History)
4 users (show)

Fixed In Version: rpmdeplint-1.4-16.fc33
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2020-06-03 10:49:31 UTC
Type: Bug

Attachments (Terms of Use)

Description Panu Matilainen 2019-03-28 15:30:48 UTC
Description of problem:

Rpm's python3 API has been totally braindamaged all this time but people are only noticing now that it's starting to get used. 

We're changing rpm to return all string data as surrogate-escaped utf-8 python strings everywhere (instead of bytes with unknown encoding that the API doesn't otherwise even accept, see bug 1631292). This makes most rpm-scripts written for python2 just work with python3 too (from the rpm pov).

Most software that has kept python2 compatibility are automatically compatible with the fixed API, but unfortunately python3-only users need fixing for the new behavior.

There's at least one place in rpmdeplint that is affected, there's an explicit .decode() of rpm data in get_hawkey_package_arch() function.

As the broken rpm versions are widely in use, it's best to keep compatibility with both initially. Basically replace all the hardcoded .decode("utf-8") calls to header data with something like this:

def b2s(data):
    if isinstance(data, bytes):
        return data.decode('utf-8')
    return data

Comment 1 Panu Matilainen 2019-03-29 07:09:38 UTC
I was pointed out that the bug referred to in the message is a private RHEL bug, sorry about that. 
The public, Fedora side counterpart with the background story is the one blocked by this, ie 

Comment 2 Ben Cotton 2019-08-13 17:12:44 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 31 development cycle.
Changing version to '31'.

Comment 3 Ben Cotton 2019-08-13 19:26:42 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 31 development cycle.
Changing version to 31.

Comment 4 Dan Callaghan 2019-08-14 05:41:30 UTC
Miro, I hope you don't mind if I flip this bug over to you. I don't have time to work on rpmdeplint anymore.

Comment 5 Jens Petersen 2019-11-25 09:01:45 UTC
In Fedora 31, I tried

$ rpmdeplint check-repoclosure ghc-either-
Traceback (most recent call last):
  File "/usr/bin/rpmdeplint", line 11, in <module>
    load_entry_point('rpmdeplint==1.4', 'console_scripts', 'rpmdeplint')()
  File "/usr/lib/python3.7/site-packages/rpmdeplint/cli.py", line 232, in main
    return args.func(args)
  File "/usr/lib/python3.7/site-packages/rpmdeplint/cli.py", line 73, in cmd_check_repoclosure
    with dependency_analyzer_from_args(args) as analyzer:
  File "/usr/lib/python3.7/site-packages/rpmdeplint/cli.py", line 145, in dependency_analyzer_from_args
    sack_arches = {get_hawkey_package_arch(rpm) for rpm in rpms} - {'noarch'}
  File "/usr/lib/python3.7/site-packages/rpmdeplint/cli.py", line 145, in <setcomp>
    sack_arches = {get_hawkey_package_arch(rpm) for rpm in rpms} - {'noarch'}
  File "/usr/lib/python3.7/site-packages/rpmdeplint/__init__.py", line 39, in get_hawkey_package_arch
    pkg_arch = rpm_file[rpm.RPMTAG_ARCH].decode('utf8')
AttributeError: 'str' object has no attribute 'decode'

Is there a workaround or upstream fix for this?

Comment 6 František Zatloukal 2020-05-29 09:41:51 UTC
Should be fixed in rpmdeplint-1.4-16.fc33 , rpmdeplint-1.4-16.fc32, rpmdeplint-1.4-16.fc31 ( https://koji.fedoraproject.org/koji/packageinfo?packageID=23204 ) .

Jens, can you verify please?


Comment 7 František Zatloukal 2020-06-03 10:49:31 UTC
Fixed by: rpmdeplint-1.4-16.fc33

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