Ugly workaroud for RPM 4.14 vs 4.15 python3 bindings incompatibility

This commit is contained in:
si-gui 2020-11-04 14:27:12 +08:00
parent ae5a3b888a
commit 67b5681dfe
2 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,37 @@
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

View File

@ -2,7 +2,7 @@
Name: rpmlint Name: rpmlint
Version: 1.10 Version: 1.10
Release: 18 Release: 19
Summary: Check the RPM package of tools for common errors Summary: Check the RPM package of tools for common errors
License: GPLv2 License: GPLv2
URL: https://github.com/rpm-software-management/rpmlint URL: https://github.com/rpm-software-management/rpmlint
@ -15,6 +15,7 @@ Patch0002: rpmlint-1.10-flake-cleanups.patch
Patch0003: rpmlint-1.10-missing-files-exception.patch Patch0003: rpmlint-1.10-missing-files-exception.patch
Patch0004: rpmlint-1.10-py37mtime.patch Patch0004: rpmlint-1.10-py37mtime.patch
Patch0005: rpmlint-1.10-py37magic.patch Patch0005: rpmlint-1.10-py37magic.patch
Patch0006: rpmlint-1.10-ugly-workaroud-for-RPM-4.14-vs-4.15-python3-bindings-incompatibility.patch
BuildArch: noarch BuildArch: noarch
@ -61,5 +62,8 @@ install -pm 644 %{SOURCE1} %{buildroot}%{_datadir}/rpmlint/config
%{_mandir}/man1/* %{_mandir}/man1/*
%changelog %changelog
* Wed Nov 4 2020 Guoshuai Sun <sunguoshuai@huawei.com> - 1.10-19
- Ugly workaroud for RPM 4.14 vs 4.15 python3 bindings incompatibility
* Tue Feb 18 2020 wanjiankang <wanjiankang@huawei.com> - 1.10-18 * Tue Feb 18 2020 wanjiankang <wanjiankang@huawei.com> - 1.10-18
- Package init - Package init