[packages/python-scales] - python 3.8 compatibility fix - rel 8
baggins
baggins at pld-linux.org
Tue Nov 5 08:26:00 CET 2019
commit 9fbd9fc20b24b257c8875de12f59ec26214037b5
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Tue Nov 5 08:24:24 2019 +0100
- python 3.8 compatibility fix
- rel 8
python-3.8.patch | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
python-scales.spec | 6 ++++--
2 files changed, 52 insertions(+), 2 deletions(-)
---
diff --git a/python-scales.spec b/python-scales.spec
index 67c0292..2046bb4 100644
--- a/python-scales.spec
+++ b/python-scales.spec
@@ -5,16 +5,17 @@
%bcond_without python2 # CPython 2.x module
%bcond_without python3 # CPython 3.x module
-%define module scales
+%define module scales
Summary: Stats for Python processes
Summary(pl.UTF-8): Statyski dla procesów Pythona
Name: python-%{module}
Version: 1.0.9
-Release: 7
+Release: 8
License: Apache
Group: Libraries/Python
Source0: https://pypi.python.org/packages/source/s/%{module}/%{module}-%{version}.tar.gz
# Source0-md5: c61167f2b5f506f0a34a7b8a295a9567
+Patch0: python-3.8.patch
URL: https://www.github.com/Cue/scales
BuildRequires: rpm-pythonprov
BuildRequires: rpmbuild(macros) >= 1.710
@@ -69,6 +70,7 @@ Dokumentacja API %{module}.
%prep
%setup -q -n %{module}-%{version}
+%patch0 -p1
%build
%if %{with python2}
diff --git a/python-3.8.patch b/python-3.8.patch
new file mode 100644
index 0000000..0649bce
--- /dev/null
+++ b/python-3.8.patch
@@ -0,0 +1,48 @@
+From ee69d45f1a7f928f7b241702e9be06007444115e Mon Sep 17 00:00:00 2001
+From: Lumir Balhar <lbalhar at redhat.com>
+Date: Fri, 30 Aug 2019 10:59:43 +0200
+Subject: [PATCH] Use `html` module in Python 3 and cgi module in Python 2
+
+`cgi.escape()` has been deprecated since Python 3.2 and
+removed from Python 3.8.
+
+Fixes: https://github.com/Cue/scales/issues/46
+---
+ src/greplin/scales/formats.py | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/src/greplin/scales/formats.py b/src/greplin/scales/formats.py
+index c4ef979..b6a96d4 100644
+--- a/src/greplin/scales/formats.py
++++ b/src/greplin/scales/formats.py
+@@ -16,7 +16,11 @@
+
+ from greplin import scales
+
+-import cgi
++try:
++ import html
++except ImportError:
++ # Python 2.7 has no html module
++ import cgi as html
+ import six
+ import json
+ import operator
+@@ -105,7 +109,7 @@ def _htmlRenderDict(pathParts, statDict, output):
+
+ output.write('<div class="level">')
+ for key in keys:
+- keyStr = cgi.escape(_utf8str(key))
++ keyStr = html.escape(_utf8str(key))
+ value = statDict[key]
+ if hasattr(value, '__call__'):
+ value = value()
+@@ -119,7 +123,7 @@ def _htmlRenderDict(pathParts, statDict, output):
+ _htmlRenderDict(valuePath, value, output)
+ else:
+ output.write('<div><span class="key">%s</span> <span class="%s">%s</span></div>' %
+- (keyStr, type(value).__name__, cgi.escape(_utf8str(value)).replace('\n', '<br/>')))
++ (keyStr, type(value).__name__, html.escape(_utf8str(value)).replace('\n', '<br/>')))
+
+ if links:
+ for link in links:
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/python-scales.git/commitdiff/9fbd9fc20b24b257c8875de12f59ec26214037b5
More information about the pld-cvs-commit
mailing list