Skip to content

Commit 65f1901

Browse files
Merge pull request #7501 from practicalswift/python3-fixes
Improve Python 3 compatibility
2 parents cca3398 + fccad8d commit 65f1901

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

benchmark/scripts/perf_test_driver/perf_test_driver.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#
1313
# ===---------------------------------------------------------------------===//
1414

15+
import functools
1516
import multiprocessing
1617
import os
1718
import re
@@ -106,7 +107,7 @@ def reduce_results(acc, r):
106107
acc['extra_data'] = r.merge_in_extra_data(acc['extra_data'])
107108
return acc
108109

109-
return reduce(reduce_results, results, {
110+
return functools.reduce(reduce_results, results, {
110111
'result': [],
111112
'has_failure': False,
112113
'max_test_len': 0,
@@ -124,7 +125,9 @@ def run(self, test_filter=None):
124125
self.data = [
125126
self.run_for_opt_level(binary, opt_level, test_filter)
126127
for binary, opt_level in self.targets]
127-
max_test_len = reduce(max, [d['max_test_len']for d in self.data])
128-
has_failure = reduce(max, [d['has_failure']for d in self.data])
128+
max_test_len = functools.reduce(max,
129+
[d['max_test_len'] for d in self.data])
130+
has_failure = functools.reduce(max,
131+
[d['has_failure'] for d in self.data])
129132
self.print_data(self.data, max_test_len)
130133
return not has_failure

test/Driver/Dependencies/Inputs/update-dependencies-bad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@
4545
sys.exit(129)
4646

4747
execDir = os.path.dirname(os.path.abspath(__file__))
48-
execfile(os.path.join(execDir, "update-dependencies.py"))
48+
exec(open(os.path.join(execDir, "update-dependencies.py")).read())

tools/SourceKit/bindings/python/sourcekitd/capi.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ def __get__(self, instance, instance_type=None):
6464
class Object(object):
6565

6666
def __init__(self, obj):
67+
import sys
68+
if sys.version_info > (3,):
69+
long = int
6770
if isinstance(obj, Object):
6871
self._obj = conf.lib.sourcekitd_request_retain(obj)
6972
elif isinstance(obj, (int, long, bool)):

0 commit comments

Comments
 (0)