Bug 1693760

Summary: rpmlint: Switch to a string for RPM calls (oncoming rpm API fix change)
Product: [Fedora] Fedora Reporter: Panu Matilainen <pmatilai>
Component: rpmlintAssignee: Tom "spot" Callaway <tcallawa>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: j, ppisar, tcallawa, tmz, twoerner
Target Milestone: ---   
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: 2019-07-01 08:48:02 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:
Bug Depends On:    
Bug Blocks: 1693751, 1779194    

Description Panu Matilainen 2019-03-28 15:07:35 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

Comment 1 Panu Matilainen 2019-03-29 07:05:57 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 
https://bugzilla.redhat.com/show_bug.cgi?id=1693751

Comment 2 Petr Pisar 2019-04-29 11:44:05 UTC
*** Bug 1699789 has been marked as a duplicate of this bug. ***

Comment 3 Petr Pisar 2019-07-01 08:48:02 UTC

*** This bug has been marked as a duplicate of bug 1722868 ***