Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1693788 - Switch to a string for RPM calls (oncoming rpm API fix change)
Summary: Switch to a string for RPM calls (oncoming rpm API fix change)
Alias: None
Product: Fedora
Classification: Fedora
Component: rebase-helper
Version: rawhide
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Nikola Forró
QA Contact: Fedora Extras Quality Assurance
Depends On:
Blocks: 1693751
TreeView+ depends on / blocked
Reported: 2019-03-28 15:56 UTC by Panu Matilainen
Modified: 2019-03-29 07:09 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed:

Attachments (Terms of Use)

Description Panu Matilainen 2019-03-28 15:56:17 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 are at least one place in rebase-helper that is affected, there's a hardcoded .decode('utf-8') call in get_info_from_rpm() 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:54 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

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