rpmlint/rpmlint-1.10-ugly-workaroud-for-RPM-4.14-vs-4.15-python3-bindings-incompatibility.patch

38 lines
1.0 KiB
Diff
Raw Normal View History

From 8fd904b53c028dded0b308ee95f1a5ff998584fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Thu, 4 Jul 2019 00:31:49 +0200
Subject: [PATCH] Ugly workaround for RPM 4.14 vs 4.15 python3 bindings
incompatibility
Fixes https://github.com/rpm-software-management/rpmlint/issues/202
---
Pkg.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/Pkg.py b/Pkg.py
index 8cf701c..4c96098 100644
--- a/Pkg.py
+++ b/Pkg.py
@@ -164,8 +164,17 @@ def is_utf8(fname):
def is_utf8_bytestr(s):
+ """Returns True whether the given text is UTF-8.
+ Due to changes in rpm, needs to handle both bytes and unicode."""
try:
- s.decode('UTF-8')
+ if hasattr(s, 'decode'):
+ s.decode('utf-8')
+ elif hasattr(s, 'encode'):
+ s.encode('utf-8')
+ else:
+ unexpected = type(s).__name__
+ raise TypeError(
+ 'Expected str/unicode/bytes, not {}'.format(unexpected))
except UnicodeError:
return False
return True
--
2.23.0