urlgrabber-ext-down Python 3 compat fix

Resolves: rhbz#1707657, rhbz#1688173
epel9
Pavel Raiskup 6 years ago
parent aac7cc644b
commit 223e7ae995

@ -0,0 +1,48 @@
From e7a01334f653661c657d4c4e6e1ad10aababfb5b Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Sun, 12 May 2019 08:54:01 +0200
Subject: [PATCH] urlgrabber-ext-down: another python 3 compat
Expect that _readlines() returns array of bytes objects in
Python 3 environments.
Fixes rhbz #1707657 and #1688173
---
scripts/urlgrabber-ext-down | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/scripts/urlgrabber-ext-down b/scripts/urlgrabber-ext-down
index bbaebd5..13d6dc7 100755
--- a/scripts/urlgrabber-ext-down
+++ b/scripts/urlgrabber-ext-down
@@ -19,12 +19,17 @@
# Boston, MA 02111-1307 USA
import time, os, errno, sys
+import six
from urlgrabber.grabber import \
_readlines, URLGrabberOptions, _loads, \
PyCurlFileObject, URLGrabError
def write(fmt, *arg):
- try: os.write(1, fmt % arg)
+ buf = fmt % arg
+ if six.PY3:
+ buf = buf.encode()
+ try:
+ os.write(1, buf)
except OSError as e:
if e.args[0] != errno.EPIPE: raise
sys.exit(1)
@@ -46,6 +51,8 @@ def main():
lines = _readlines(0)
if not lines: break
for line in lines:
+ if not isinstance(line, six.string_types):
+ line = line.decode('utf-8')
cnt += 1
opts = URLGrabberOptions()
opts._id = cnt
--
2.21.0

@ -11,7 +11,7 @@
Name: python-%{pypi_name}
Version: %{majorver}.%{minorver}.%{patchver}
Release: 1%{?dist}
Release: 2%{?dist}
Summary: A high-level cross-protocol url-grabber
License: LGPLv2+
@ -21,6 +21,8 @@ URL: http://urlgrabber.baseurl.org/
#Source0: http://urlgrabber.baseurl.org/download/urlgrabber-%{version}.tar.gz
Source0: https://github.com/rpm-software-management/urlgrabber/releases/download/urlgrabber-%{dashversion}/urlgrabber-%{version}.tar.gz
Patch0: 0001-urlgrabber-ext-down-another-python-3-compat.patch
BuildArch: noarch
%global _description\
@ -97,6 +99,9 @@ export URLGRABBER_EXT_DOWN="%{_builddir}/%{pypi_name}-%{version}/scripts/urlgrab
%{python3_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info
%changelog
* Sun May 12 2019 Pavel Raiskup <praiskup@redhat.com> - 4.0.0-2
- python3 compat work-around to fix mock (rhbz#1707657, rhbz#1688173)
* Mon Feb 25 2019 Neal Gompa <ngompa13@gmail.com> - 4.0.0-1
- Update to 4.0.0
- Add Python 3 subpackage and have binaries as Python 3

Loading…
Cancel
Save