]> git.pld-linux.org Git - packages/python-scales.git/blob - python-3.8.patch
- python 3.8 compatibility fix
[packages/python-scales.git] / python-3.8.patch
1 From ee69d45f1a7f928f7b241702e9be06007444115e Mon Sep 17 00:00:00 2001
2 From: Lumir Balhar <lbalhar@redhat.com>
3 Date: Fri, 30 Aug 2019 10:59:43 +0200
4 Subject: [PATCH] Use `html` module in Python 3 and cgi module in Python 2
5
6 `cgi.escape()` has been deprecated since Python 3.2 and
7 removed from Python 3.8.
8
9 Fixes: https://github.com/Cue/scales/issues/46
10 ---
11  src/greplin/scales/formats.py | 10 +++++++---
12  1 file changed, 7 insertions(+), 3 deletions(-)
13
14 diff --git a/src/greplin/scales/formats.py b/src/greplin/scales/formats.py
15 index c4ef979..b6a96d4 100644
16 --- a/src/greplin/scales/formats.py
17 +++ b/src/greplin/scales/formats.py
18 @@ -16,7 +16,11 @@
19  
20  from greplin import scales
21  
22 -import cgi
23 +try:
24 +  import html
25 +except ImportError:
26 +  # Python 2.7 has no html module
27 +  import cgi as html
28  import six
29  import json
30  import operator
31 @@ -105,7 +109,7 @@ def _htmlRenderDict(pathParts, statDict, output):
32  
33    output.write('<div class="level">')
34    for key in keys:
35 -    keyStr = cgi.escape(_utf8str(key))
36 +    keyStr = html.escape(_utf8str(key))
37      value = statDict[key]
38      if hasattr(value, '__call__'):
39        value = value()
40 @@ -119,7 +123,7 @@ def _htmlRenderDict(pathParts, statDict, output):
41          _htmlRenderDict(valuePath, value, output)
42      else:
43        output.write('<div><span class="key">%s</span> <span class="%s">%s</span></div>' %
44 -                   (keyStr, type(value).__name__, cgi.escape(_utf8str(value)).replace('\n', '<br/>')))
45 +                   (keyStr, type(value).__name__, html.escape(_utf8str(value)).replace('\n', '<br/>')))
46  
47    if links:
48      for link in links:
This page took 0.100469 seconds and 3 git commands to generate.