void-packages/srcpkgs/python-docutils/patches/0024-py3-Wrap-foo.keys-zip-foo-bar-in-list.patch
Doan Tran Cong Danh 6b24f153d7 python3-docutils: unbroken: import from upstream
All of those patches are picked from upstream.

    xbps-src check python3-docutils

works fine now!
2019-12-01 12:38:58 +01:00

147 lines
6.2 KiB
Diff

From 7e601f5444051a78c0dc3fd6e3676193e7a30076 Mon Sep 17 00:00:00 2001
From: Stephen Finucane <stephen@that.guru>
Date: Tue, 27 Aug 2019 12:11:15 +0000
Subject: [PATCH 24/26] py3: Wrap 'foo.keys()', 'zip(foo, bar') in 'list'
In Python 3, 'dict.keys()', 'zip' and 'map' no longer return a list but
rather types 'dict_keys', 'zip' and 'map', respectively. You can't
append to these types nor can you delete from them while in a loop. The
simple solution to both issues is to wrap things in 'list'.
Signed-off-by: Stephen Finucane <stephen@that.guru>
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8372 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com>
---
docutils/parsers/rst/tableparser.py | 2 +-
docutils/statemachine.py | 2 +-
docutils/utils/__init__.py | 2 +-
docutils/utils/math/math2html.py | 2 +-
docutils/writers/odf_odt/__init__.py | 3 +--
test/DocutilsTestSupport.py | 2 +-
test/test_functional.py | 2 +-
test/test_language.py | 2 +-
test/test_statemachine.py | 2 +-
9 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/docutils/parsers/rst/tableparser.py b/docutils/parsers/rst/tableparser.py
index 937aec8..408d6d8 100644
--- a/docutils/parsers/rst/tableparser.py
+++ b/docutils/parsers/rst/tableparser.py
@@ -290,7 +290,7 @@ class GridTableParser(TableParser):
rowindex = {}
for i in range(len(rowseps)):
rowindex[rowseps[i]] = i # row boundary -> row number mapping
- colseps = self.colseps.keys() # list of column boundaries
+ colseps = list(self.colseps.keys()) # list of column boundaries
colseps.sort()
colindex = {}
for i in range(len(colseps)):
diff --git a/docutils/statemachine.py b/docutils/statemachine.py
index 6bc03f5..0cbf9d3 100644
--- a/docutils/statemachine.py
+++ b/docutils/statemachine.py
@@ -1297,7 +1297,7 @@ class ViewList(object):
self.parent = None
def sort(self, *args):
- tmp = zip(self.data, self.items)
+ tmp = list(zip(self.data, self.items))
tmp.sort(*args)
self.data = [entry[0] for entry in tmp]
self.items = [entry[1] for entry in tmp]
diff --git a/docutils/utils/__init__.py b/docutils/utils/__init__.py
index cc1fd1a..437456b 100644
--- a/docutils/utils/__init__.py
+++ b/docutils/utils/__init__.py
@@ -618,7 +618,7 @@ def column_indices(text):
"""
# TODO: account for asian wide chars here instead of using dummy
# replacements in the tableparser?
- string_indices = range(len(text))
+ string_indices = list(range(len(text)))
for index in find_combining_chars(text):
string_indices[index] = None
return [i for i in string_indices if i is not None]
diff --git a/docutils/utils/math/math2html.py b/docutils/utils/math/math2html.py
index a7e2aed..53dd836 100644
--- a/docutils/utils/math/math2html.py
+++ b/docutils/utils/math/math2html.py
@@ -2819,7 +2819,7 @@ class Bracket(FormulaBit):
def innertext(self, pos):
"Parse some text inside the bracket, following textual rules."
- specialchars = FormulaConfig.symbolfunctions.keys()
+ specialchars = list(FormulaConfig.symbolfunctions.keys())
specialchars.append(FormulaConfig.starts['command'])
specialchars.append(FormulaConfig.starts['bracket'])
specialchars.append(Comment.start)
diff --git a/docutils/writers/odf_odt/__init__.py b/docutils/writers/odf_odt/__init__.py
index c79d4c1..ad32613 100644
--- a/docutils/writers/odf_odt/__init__.py
+++ b/docutils/writers/odf_odt/__init__.py
@@ -1169,8 +1169,7 @@ class ODFTranslator(nodes.GenericNodeVisitor):
fin = os.popen("paperconf -s 2> /dev/null")
content = fin.read()
content = content.split()
- content = map(float, content)
- content = list(content)
+ content = list(map(float, content))
w, h = content
except (IOError, ValueError):
w, h = 612, 792 # default to Letter
diff --git a/test/DocutilsTestSupport.py b/test/DocutilsTestSupport.py
index 47ba83c..222c202 100644
--- a/test/DocutilsTestSupport.py
+++ b/test/DocutilsTestSupport.py
@@ -811,7 +811,7 @@ class HtmlWriterPublishPartsTestCase(WriterPublishTestCase):
parts['html_prolog'] = parts['html_prolog'].replace(
self.standard_html_prolog, '')
# remove empty values:
- for key in parts.keys():
+ for key in list(parts.keys()):
if not parts[key]:
del parts[key]
# standard output format:
diff --git a/test/test_functional.py b/test/test_functional.py
index cdc75a0..b02c250 100755
--- a/test/test_functional.py
+++ b/test/test_functional.py
@@ -152,7 +152,7 @@ expected output and check it in:
del params['test_source']
del params['test_destination']
# Delete private stuff like params['__builtins__']:
- for key in params.keys():
+ for key in list(params.keys()):
if key.startswith('_'):
del params[key]
# Get output (automatically written to the output/ directory
diff --git a/test/test_language.py b/test/test_language.py
index 31ac613..48cd06b 100755
--- a/test/test_language.py
+++ b/test/test_language.py
@@ -52,7 +52,7 @@ class LanguageTestSuite(DocutilsTestSupport.CustomTestSuite):
match = self.language_module_pattern.match(mod)
if match:
languages[match.group(1)] = 1
- self.languages = languages.keys()
+ self.languages = list(languages.keys())
# test language tag normalization:
self.languages += ['en_gb', 'en_US', 'en-CA', 'de-DE', 'de-AT-1901',
'pt-BR', 'pt-foo-BR']
diff --git a/test/test_statemachine.py b/test/test_statemachine.py
index 6352ca4..87f5710 100755
--- a/test/test_statemachine.py
+++ b/test/test_statemachine.py
@@ -152,7 +152,7 @@ class SMWSTests(unittest.TestCase):
self.sm.unlink()
def test___init__(self):
- self.assertEqual(self.sm.states.keys(), ['MockState'])
+ self.assertEqual(list(self.sm.states.keys()), ['MockState'])
self.assertEqual(len(self.sm.states['MockState'].transitions), 4)
def test_get_indented(self):
--
2.24.0.375.geb5ae68d41