diff --git a/0001-srpm_import-be-compatible-with-rhbz-1693751.patch b/0001-srpm_import-be-compatible-with-rhbz-1693751.patch new file mode 100644 index 0000000..ed8e9aa --- /dev/null +++ b/0001-srpm_import-be-compatible-with-rhbz-1693751.patch @@ -0,0 +1,57 @@ +From 3d9523be1ae64a84ce849fa199b3c1e01b3d805b Mon Sep 17 00:00:00 2001 +From: Pavel Raiskup +Date: Fri, 19 Apr 2019 19:21:02 +0200 +Subject: [PATCH] srpm_import: be compatible with rhbz#1693751 + +Older RPMs returned 'bytes' objects, newer return 'str'. + +If 'str' object is returned on Python 3 - it doesn't need to be +decoded, and it actually raises error [1]: + + >>> str('', encoding='utf-8') + Traceback (most recent call last): + File "", line 1, in + TypeError: decoding str is not supported + +This change also OK for Python 2 where str() has decode method +(str is alternative for bytes). + +[1] https://pagure.io/copr/copr/issue/677 + +Signed-off-by: Pavel Raiskup +--- + pyrpkg/__init__.py | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py +index f1ecc6f..8fe4ed0 100644 +--- a/pyrpkg/__init__.py ++++ b/pyrpkg/__init__.py +@@ -1248,8 +1248,8 @@ class Commands(object): + archlist = [pkg.header['arch'] for pkg in hdr.packages] + if not archlist: + raise rpkgError('No compatible build arches found in %s' % spec) +- if six.PY3: +- return [str(arch, encoding='utf-8') for arch in archlist] ++ if hasattr(archlist[0], 'decode'): ++ return [arch.decode('utf-8') for arch in archlist] + else: + return archlist + +@@ -1339,9 +1339,10 @@ class Commands(object): + hdr = koji.get_rpm_header(srpm) + name = hdr[rpm.RPMTAG_NAME] + contents = hdr[rpm.RPMTAG_FILENAMES] +- if six.PY3: +- name = str(name, encoding='utf-8') +- contents = [str(filename, encoding='utf-8') ++ if hasattr(name, 'decode'): ++ # RPM before rhbz#1693751 returned bytes ++ name = name.decode('utf-8') ++ contents = [filename.decode('utf-8') + for filename in contents] + except Exception as e: + raise rpkgError('Error querying srpm: {0}'.format(str(e))) +-- +2.20.1 + diff --git a/rpkg.spec b/rpkg.spec index 793481e..ff9b164 100644 --- a/rpkg.spec +++ b/rpkg.spec @@ -4,7 +4,7 @@ Name: rpkg Version: 1.57 -Release: 7%{?dist} +Release: 8%{?dist} Summary: Python library for interacting with rpm+git License: GPLv2+ and LGPLv2 @@ -25,6 +25,9 @@ Patch0: remove-koji-and-rpm-py-installer-from-requires.patch # https://pagure.io/rpkg/c/00a89ee07132a0d11ae35ce370cb0579b2b9defe Patch0001: 0001-Upload-.crate-files-to-lookaside-cache.patch +# https://pagure.io/rpkg/pull-request/439 +Patch0002: 0001-srpm_import-be-compatible-with-rhbz-1693751.patch + %if 0%{?fedora} || 0%{?rhel} > 7 # Enable python3 build by default %global with_python3 1 @@ -260,6 +263,9 @@ nosetests tests %changelog +* Fri Apr 19 2019 Pavel Raiskup - 1.57-8 +- compat fix with RPM after rhbz#1693751 + * Wed Mar 20 2019 Igor Gnatenko - 1.57-7 - Backport patch for uploading *.crate into lookaside