Bug 1693712
| Summary: | Switch to a string for RPM calls | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 8 | Reporter: | Panu Matilainen <pmatilai> |
| Component: | rpmlint | Assignee: | Thomas Woerner <twoerner> |
| Status: | CLOSED ERRATA | QA Contact: | Karel Srot <ksrot> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | medium | ||
| Version: | 8.0 | CC: | emrakova, twoerner |
| Target Milestone: | rc | Flags: | pm-rhel:
mirror+
|
| Target Release: | 8.0 | ||
| 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-11-05 21:13:21 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: | 1631292, 1715212 | ||
| Bug Blocks: | |||
|
Description
Panu Matilainen
2019-03-28 14:11:46 UTC
The change in the 8.1 rpm requires to also change rpmlint. Without a fix the output of rpmlint will contain warning messages. Here is a simple reproducer: $ rpmlint systemd | grep UnicodeWarning /var/str/source/Pkg.py:184: UnicodeWarning: decode() called on unicode string, see https://bugzilla.redhat.com/show_bug.cgi?id=1693751 s.decode('UTF-8') /var/str/source/Pkg.py:184: UnicodeWarning: decode() called on unicode string, see https://bugzilla.redhat.com/show_bug.cgi?id=1693751 s.decode('UTF-8') The proposed fix from #1693712#c0 is not working. Here is a working proposal: def is_utf8_bytestr(s): - try: - s.decode('UTF-8') - except UnicodeError: - return False - return True - + if isinstance(s, str): + try: + s.encode("utf8") + except UnicodeEncodeError: + return False + else: + return True + else: + try: + s.decode('UTF-8') + except UnicodeError: + return False + else: + return True The encode in the first part is only there to make sure that we really have something that can be utf8. A str type in Python3 should always be utf8, but it is possible also to add bad escape sequences. This test is revealing this. The output of the gating tests that will be added with #1682275 also contain lots of the warning lines. Oh, sorry, the proposed code was prior to adding the .decode() compatibility kludge. Which once again is causing more problems than its solving. I think we need to reconsider the compat thing on rpm side... Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2019:3437 |