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 1693712 - Switch to a string for RPM calls
Summary: Switch to a string for RPM calls
Keywords:
Status: NEW
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: rpmlint
Version: 8.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: Thomas Woerner
QA Contact: BaseOS QE Security Team
URL:
Whiteboard:
Depends On:
Blocks: 1631292
TreeView+ depends on / blocked
 
Reported: 2019-03-28 14:11 UTC by Panu Matilainen
Modified: 2019-03-28 14:12 UTC (History)
0 users

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


Attachments (Terms of Use)

Description Panu Matilainen 2019-03-28 14:11:46 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 like rpmlint need fixing for the new behavior.

There's at least one affected place in rpmlint, which will after the change start failing with the following traceback:

Traceback (most recent call last):
  File "/usr/bin/rpmlint", line 378, in <module>
    main()
  File "/usr/bin/rpmlint", line 166, in main
    runChecks(pkg)
  File "/usr/bin/rpmlint", line 223, in runChecks
    check.check(pkg)
  File "/usr/share/rpmlint/TagsCheck.py", line 695, in check
    self.check_summary(pkg, lang, ignored_words)
  File "/usr/share/rpmlint/TagsCheck.py", line 903, in check_summary
    if not Pkg.is_utf8_bytestr(summary):
  File "/usr/share/rpmlint/Pkg.py", line 168, in is_utf8_bytestr
    s.decode('UTF-8')
AttributeError: 'str' object has no attribute 'decode'

As the broken rpm versions are widely in use, it's best to keep compatibility with both initially. One possible way to fix this is simply:

--- Pkg.py.orig	2019-03-28 16:06:54.491218904 +0200
+++ Pkg.py	2019-03-28 16:07:13.412186582 +0200
@@ -168,6 +168,8 @@
         s.decode('UTF-8')
     except UnicodeError:
         return False
+    except AttributeError:
+        return True
     return True


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