46 lines
1.5 KiB
Diff
46 lines
1.5 KiB
Diff
From 4875475c43098e37a4d5d4e2ee2f9dfea643cc78 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
|
|
Date: Fri, 7 Apr 2017 09:26:35 +0300
|
|
Subject: [PATCH] Pkg.b2s: Pass through str as-is on Python 3
|
|
|
|
Things change, and we may start getting str where we previously got
|
|
bytes, such as what has apparently now happened with some versions of
|
|
the return value of magic.descriptor(fd) in Fedora Rawhide.
|
|
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1439941
|
|
---
|
|
Pkg.py | 4 ++--
|
|
test/test.Pkg.py | 4 ++++
|
|
2 files changed, 6 insertions(+), 2 deletions(-)
|
|
|
|
Index: rpmlint-rpmlint-1.9/Pkg.py
|
|
===================================================================
|
|
--- rpmlint-rpmlint-1.9.orig/Pkg.py
|
|
+++ rpmlint-rpmlint-1.9/Pkg.py
|
|
@@ -41,8 +41,8 @@ if sys.version_info[0] > 2:
|
|
unicode = str
|
|
|
|
def b2s(b):
|
|
- if b is None:
|
|
- return None
|
|
+ if b is None or isinstance(b, str):
|
|
+ return b
|
|
if isinstance(b, (list, tuple)):
|
|
return [b2s(x) for x in b]
|
|
return b.decode(errors='replace')
|
|
Index: rpmlint-rpmlint-1.9/test/test.Pkg.py
|
|
===================================================================
|
|
--- rpmlint-rpmlint-1.9.orig/test/test.Pkg.py
|
|
+++ rpmlint-rpmlint-1.9/test/test.Pkg.py
|
|
@@ -30,5 +30,10 @@ class TestPkg(unittest.TestCase):
|
|
):
|
|
self.assertFalse(Pkg.rangeCompare(req, prov))
|
|
|
|
+ def test_b2s(self):
|
|
+ for thing in ("foo", ["foo"]):
|
|
+ self.assertEqual(thing, Pkg.b2s(thing))
|
|
+
|
|
+
|
|
if __name__ == '__main__':
|
|
unittest.main()
|