Package: consensuscore / 1.1.1+dfsg-2

2to3.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
Description: Use 2to3 to convert from Python2 and Python3
Bug-Debian: https://bugs.debian.org/936328
Author: Andreas Tille <tille@debian.org>
Last-Update: Sat, 07 Dec 2019 12:44:55 +0100

--- a/make/Python.mk
+++ b/make/Python.mk
@@ -8,11 +8,11 @@ endif
 include make/Defs.mk
 
 ifeq (,$(wildcard $(PYTHON_INCLUDE)/Python.h))
-$(error python include not configured properly, cannot build python module!)
+$(error python3 include not configured properly, cannot build python3 module!)
 endif
 
 ifeq (,$(wildcard $(NUMPY_INCLUDE)/numpy/arrayobject.h))
-$(error numpy include not configured properly, cannot build python module!)
+$(error numpy include not configured properly, cannot build python3 module!)
 endif
 
 SWIG_CMD   := SWIG_LIB=$(SWIG_LIB) $(SWIG) -Wall -c++ -python -builtin
@@ -27,6 +27,6 @@ $(PYTHON_DLL): $(SWIG_INTERFACES) $(CXX_
 	$(CXX) $(SHLIB_FLAGS) $(INCLUDES) -I $(PYTHON_INCLUDE) -I $(NUMPY_INCLUDE) $(GEN_CXX) $(CXX_LIB) -o $(PYTHON_DLL)
 
 test-python: $(PYTHON_DLL)
-	@PYTHONPATH=$(PYTHON_BUILD_DIR) python src/Demos/Demo.py && echo "Python build is OK!"
+	@PYTHONPATH=$(PYTHON_BUILD_DIR) python3 src/Demos/Demo.py && echo "Python3 build is OK!"
 
 .PHONY: all test-python $(PYTHON_DLL)
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,5 @@
-#!/usr/bin/env python
-from __future__ import print_function
+#!/usr/bin/python3
+
 
 from distutils.command.build import build as _build
 from distutils.errors import CompileError
--- a/src/Demos/Demo.py
+++ b/src/Demos/Demo.py
@@ -1,4 +1,4 @@
-from __future__ import print_function
+
 import ConsensusCore as cc
 
 print(cc.Version.VersionString())
--- a/src/Tests/meson.build
+++ b/src/Tests/meson.build
@@ -53,7 +53,7 @@ test(
 
 if get_option('swig')
   test(
-    'quiver python import',
+    'quiver python3 import',
     quiver_python,
     args : [
       files('test_import.py')],
--- a/src/Tests/test_import.py
+++ b/src/Tests/test_import.py
@@ -1,4 +1,4 @@
-from __future__ import print_function
+
 import ConsensusCore as cc
 
 # basic test to verify that SWIG worked
--- a/tools/cpplint.py
+++ b/tools/cpplint.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 #
 # Copyright (c) 2009 Google Inc. All rights reserved.
 #
@@ -560,7 +560,7 @@ class _CppLintState(object):
 
   def PrintErrorCounts(self):
     """Print a summary of errors by category, and the total."""
-    for category, count in self.errors_by_category.iteritems():
+    for category, count in list(self.errors_by_category.items()):
       sys.stderr.write('Category \'%s\' errors found: %d\n' %
                        (category, count))
     sys.stderr.write('Total errors found: %d\n' % self.error_count)
@@ -1007,7 +1007,7 @@ def CheckForCopyright(filename, lines, e
 
   # We'll say it should occur by line 10. Don't forget there's a
   # dummy line at the front.
-  for line in xrange(1, min(len(lines), 11)):
+  for line in range(1, min(len(lines), 11)):
     if re.search(r'Copyright', lines[line], re.I): break
   else:                       # means no copyright line was found
     error(filename, 0, 'legal/copyright', 5,
@@ -1112,7 +1112,7 @@ def CheckForUnicodeReplacementCharacters
     error: The function to call with any errors found.
   """
   for linenum, line in enumerate(lines):
-    if u'\ufffd' in line:
+    if '\\ufffd' in line:
       error(filename, linenum, 'readability/utf8', 5,
             'Line contains invalid UTF-8 (or Unicode replacement character).')
 
@@ -1602,7 +1602,7 @@ def CheckForFunctionLengths(filename, cl
 
   if starting_func:
     body_found = False
-    for start_linenum in xrange(linenum, clean_lines.NumLines()):
+    for start_linenum in range(linenum, clean_lines.NumLines()):
       start_line = lines[start_linenum]
       joined_line += ' ' + start_line.lstrip()
       if Search(r'(;|})', start_line):  # Declarations and trivial functions
@@ -2136,7 +2136,7 @@ def GetLineWidth(line):
     The width of the line in column positions, accounting for Unicode
     combining characters and wide characters.
   """
-  if isinstance(line, unicode):
+  if isinstance(line, str):
     width = 0
     for uc in unicodedata.normalize('NFC', line):
       if unicodedata.east_asian_width(uc) in ('W', 'F'):
@@ -2472,7 +2472,7 @@ def _GetTextInside(text, start_pattern):
 
   # Give opening punctuations to get the matching close-punctuations.
   matching_punctuation = {'(': ')', '{': '}', '[': ']'}
-  closing_punctuation = set(matching_punctuation.itervalues())
+  closing_punctuation = set(matching_punctuation.values())
 
   # Find the position to start extracting text.
   match = re.search(start_pattern, text, re.M)
@@ -3022,7 +3022,7 @@ def CheckForIncludeWhatYouUse(filename,
   required = {}  # A map of header name to linenumber and the template entity.
                  # Example of required: { '<functional>': (1219, 'less<>') }
 
-  for linenum in xrange(clean_lines.NumLines()):
+  for linenum in range(clean_lines.NumLines()):
     line = clean_lines.elided[linenum]
     if not line or line[0] == '#':
       continue
@@ -3070,7 +3070,7 @@ def CheckForIncludeWhatYouUse(filename,
 
   # include_state is modified during iteration, so we iterate over a copy of
   # the keys.
-  header_keys = include_state.keys()
+  header_keys = list(include_state.keys())
   for header in header_keys:
     (same_module, common_path) = FilesBelongToSameModule(abs_filename, header)
     fullpath = common_path + header
@@ -3186,7 +3186,7 @@ def ProcessFileData(filename, file_exten
 
   RemoveMultiLineComments(filename, lines, error)
   clean_lines = CleansedLines(lines)
-  for line in xrange(clean_lines.NumLines()):
+  for line in range(clean_lines.NumLines()):
     ProcessLine(filename, file_extension, clean_lines, line,
                 include_state, function_state, class_state, error,
                 extra_check_functions)
--- a/tools/find_boost
+++ b/tools/find_boost
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 import os, re, sys
 from glob import glob
@@ -55,8 +55,8 @@ if __name__ == '__main__':
     else:
         boost = find_boost()
     if boost_version(boost) < BOOST_MINIMUM_VERSION:
-        print >> sys.stderr, "Boost version at least %s required!" \
-            % str_version(BOOST_MINIMUM_VERSION)
-        print >> sys.stderr, "Use --boost=<path> to specify boost location."
+        print("Boost version at least %s required!" \
+            % str_version(BOOST_MINIMUM_VERSION), file=sys.stderr)
+        print("Use --boost=<path> to specify boost location.", file=sys.stderr)
         sys.exit(1)
     print(boost)
--- a/tools/find_swig
+++ b/tools/find_swig
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 import os, re, sys
 from glob import glob
@@ -42,9 +42,9 @@ if __name__ == '__main__':
         swig = find_swig()
 
     if swig is None or swig_version(swig) < SWIG_MINIMUM_VERSION:
-        print >> sys.stderr, "SWIG version at least %s required!" \
-            % str_version(SWIG_MINIMUM_VERSION)
-        print >> sys.stderr, "Use --swig=<path> to specify SWIG location."
+        print("SWIG version at least %s required!" \
+            % str_version(SWIG_MINIMUM_VERSION), file=sys.stderr)
+        print("Use --swig=<path> to specify SWIG location.", file=sys.stderr)
         sys.exit(1)
     else:
         print(swig)
--- a/tools/git-clang-format
+++ b/tools/git-clang-format
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 #
 #===- git-clang-format - ClangFormat Git Integration ---------*- python -*--===#
 #
@@ -128,15 +128,15 @@ def main():
   if opts.verbose >= 1:
     ignored_files.difference_update(changed_lines)
     if ignored_files:
-      print 'Ignoring changes in the following files (wrong extension):'
+      print('Ignoring changes in the following files (wrong extension):')
       for filename in ignored_files:
-        print '   ', filename
+        print('   ', filename)
     if changed_lines:
-      print 'Running clang-format on the following files:'
+      print('Running clang-format on the following files:')
       for filename in changed_lines:
-        print '   ', filename
+        print('   ', filename)
   if not changed_lines:
-    print 'no modified files to format'
+    print('no modified files to format')
     return
   # The computed diff outputs absolute paths, so we must cd before accessing
   # those files.
@@ -146,20 +146,20 @@ def main():
                                                binary=opts.binary,
                                                style=opts.style)
   if opts.verbose >= 1:
-    print 'old tree:', old_tree
-    print 'new tree:', new_tree
+    print('old tree:', old_tree)
+    print('new tree:', new_tree)
   if old_tree == new_tree:
     if opts.verbose >= 0:
-      print 'clang-format did not modify any files'
+      print('clang-format did not modify any files')
   elif opts.diff:
     print_diff(old_tree, new_tree)
   else:
     changed_files = apply_changes(old_tree, new_tree, force=opts.force,
                                   patch_mode=opts.patch)
     if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
-      print 'changed files:'
+      print('changed files:')
       for filename in changed_files:
-        print '   ', filename
+        print('   ', filename)
 
 
 def load_git_config(non_string_options=None):
@@ -298,7 +298,7 @@ def filter_by_extension(dictionary, allo
   `allowed_extensions` must be a collection of lowercase file extensions,
   excluding the period."""
   allowed_extensions = frozenset(allowed_extensions)
-  for filename in dictionary.keys():
+  for filename in list(dictionary.keys()):
     base_ext = filename.rsplit('.', 1)
     if len(base_ext) == 1 or base_ext[1].lower() not in allowed_extensions:
       del dictionary[filename]
@@ -323,7 +323,7 @@ def run_clang_format_and_save_to_tree(ch
 
   Returns the object ID (SHA-1) of the created tree."""
   def index_info_generator():
-    for filename, line_ranges in changed_lines.iteritems():
+    for filename, line_ranges in changed_lines.items():
       mode = oct(os.stat(filename).st_mode)
       blob_id = clang_format_to_blob(filename, line_ranges, binary=binary,
                                      style=style)
@@ -431,10 +431,10 @@ def apply_changes(old_tree, new_tree, fo
   if not force:
     unstaged_files = run('git', 'diff-files', '--name-status', *changed_files)
     if unstaged_files:
-      print >>sys.stderr, ('The following files would be modified but '
-                           'have unstaged changes:')
-      print >>sys.stderr, unstaged_files
-      print >>sys.stderr, 'Please commit, stage, or stash them first.'
+      print(('The following files would be modified but '
+                           'have unstaged changes:'), file=sys.stderr)
+      print(unstaged_files, file=sys.stderr)
+      print('Please commit, stage, or stash them first.', file=sys.stderr)
       sys.exit(2)
   if patch_mode:
     # In patch mode, we could just as well create an index from the new tree
@@ -464,20 +464,20 @@ def run(*args, **kwargs):
   if p.returncode == 0:
     if stderr:
       if verbose:
-        print >>sys.stderr, '`%s` printed to stderr:' % ' '.join(args)
-      print >>sys.stderr, stderr.rstrip()
+        print('`%s` printed to stderr:' % ' '.join(args), file=sys.stderr)
+      print(stderr.rstrip(), file=sys.stderr)
     if strip:
       stdout = stdout.rstrip('\r\n')
     return stdout
   if verbose:
-    print >>sys.stderr, '`%s` returned %s' % (' '.join(args), p.returncode)
+    print('`%s` returned %s' % (' '.join(args), p.returncode), file=sys.stderr)
   if stderr:
-    print >>sys.stderr, stderr.rstrip()
+    print(stderr.rstrip(), file=sys.stderr)
   sys.exit(2)
 
 
 def die(message):
-  print >>sys.stderr, 'error:', message
+  print('error:', message, file=sys.stderr)
   sys.exit(2)