Skip to content

python3 compat #25749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 0 additions & 138 deletions src/etc/2014-06-rewrite-bytes-macros.py

This file was deleted.

14 changes: 7 additions & 7 deletions src/etc/check-summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def summarise(fname):
summaries.append((fname, summary))

def count(t):
return sum(map(lambda (f, s): len(s.get(t, [])), summaries))
return sum(map(lambda f: len(f[1].get(t, [])), summaries))

logfiles = sys.argv[1:]
for files in map(glob.glob, logfiles):
Expand All @@ -43,15 +43,15 @@ def count(t):
failed = count('failed')
ignored = count('ignored')
measured = count('bench')
print "summary of %d test runs: %d passed; %d failed; %d ignored; %d measured" % \
(len(logfiles), ok, failed, ignored, measured)
print ""
print("summary of %d test runs: %d passed; %d failed; %d ignored; %d measured" %
(len(logfiles), ok, failed, ignored, measured))
print("")

if failed > 0:
print "failed tests:"
print("failed tests:")
for f, s in summaries:
failures = s.get('failed', [])
if len(failures) > 0:
print " %s:" % (f)
print(" %s:" % (f))
for test in failures:
print " %s" % (test)
print(" %s" % (test))
2 changes: 1 addition & 1 deletion src/etc/errorck.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import re

if len(sys.argv) < 2:
print "usage: errorck.py <src-dir>"
print("usage: errorck.py <src-dir>")
sys.exit(1)

src_dir = sys.argv[1]
Expand Down
53 changes: 28 additions & 25 deletions src/etc/featureck.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
# since the same version
# * Prints information about features

import sys, os, re
import sys
import os
import re
import codecs

if len(sys.argv) < 2:
print "usage: featurkck.py <src-dir>"
print("usage: featureck.py <src-dir>")
sys.exit(1)

src_dir = sys.argv[1]
Expand All @@ -47,7 +50,7 @@
line = line.replace("(", "").replace("),", "").replace(")", "")
parts = line.split(",")
if len(parts) != 3:
print "error: unexpected number of components in line: " + original_line
print("error: unexpected number of components in line: " + original_line)
sys.exit(1)
feature_name = parts[0].strip().replace('"', "")
since = parts[1].strip().replace('"', "")
Expand Down Expand Up @@ -79,7 +82,7 @@
continue

path = os.path.join(dirpath, filename)
with open(path, 'r') as f:
with codecs.open(filename=path, mode='r', encoding="utf-8") as f:
line_num = 0
for line in f:
line_num += 1
Expand Down Expand Up @@ -107,9 +110,9 @@
if not mm is None:
since = mm.group(1)
else:
print "error: misformed stability attribute"
print "line " + str(line_num) + " of " + path + ":"
print line
print("error: misformed stability attribute")
print("line %d of %:" % (line_num, path))
print(line)
errors = True

lib_features[feature_name] = feature_name
Expand All @@ -123,24 +126,24 @@
(expected_since, source_path, source_line_num, source_line) = \
lib_features_and_level.get((feature_name, level))
if since != expected_since:
print "error: mismatch in " + level + " feature '" + feature_name + "'"
print "line " + str(source_line_num) + " of " + source_path + ":"
print source_line
print "line " + str(line_num) + " of " + path + ":"
print line
print("error: mismatch in %s feature '%s'" % (level, feature_name))
print("line %d of %s:" % (source_line_num, source_path))
print(source_line)
print("line %d of %s:" % (line_num, path))
print(line)
errors = True

# Verify that this lib feature doesn't duplicate a lang feature
if feature_name in language_feature_names:
print "error: lib feature '" + feature_name + "' duplicates a lang feature"
print "line " + str(line_num) + " of " + path + ":"
print line
print("error: lib feature '%s' duplicates a lang feature" % (feature_name))
print("line %d of %s:" % (line_num, path))
print(line)
errors = True

else:
print "error: misformed stability attribute"
print "line " + str(line_num) + " of " + path + ":"
print line
print("error: misformed stability attribute")
print("line %d of %s:" % (line_num, path))
print(line)
errors = True

# Merge data about both lists
Expand Down Expand Up @@ -175,7 +178,7 @@
is_unstable = lib_features_and_level.get((name, "unstable")) is not None

if is_stable and is_unstable:
print "error: feature '" + name + "' is both stable and unstable"
print("error: feature '%s' is both stable and unstable" % (name))
errors = True

if is_stable:
Expand All @@ -192,21 +195,21 @@
for name in lib_feature_stats:
if language_feature_stats.get(name) is not None:
if not name in joint_features:
print "error: feature '" + name + "' is both a lang and lib feature but not whitelisted"
print("error: feature '%s' is both a lang and lib feature but not whitelisted" % (name))
errors = True
lang_status = language_feature_stats[name][3]
lib_status = lib_feature_stats[name][3]
lang_stable_since = language_feature_stats[name][4]
lib_stable_since = lib_feature_stats[name][4]

if lang_status != lib_status and lib_status != "deprecated":
print "error: feature '" + name + "' has lang status " + lang_status + \
" but lib status " + lib_status
print("error: feature '%s' has lang status %s " +
"but lib status %s" % (name, lang_status, lib_status))
errors = True

if lang_stable_since != lib_stable_since:
print "error: feature '" + name + "' has lang stable since " + lang_stable_since + \
" but lib stable since " + lib_stable_since
print("error: feature '%s' has lang stable since %s " +
"but lib stable since %s" % (name, lang_stable_since, lib_stable_since))
errors = True

merged_stats[name] = (name, True, True, lang_status, lang_stable_since)
Expand Down Expand Up @@ -240,5 +243,5 @@

print
for line in lines:
print "* " + line
print("* " + line)
print
12 changes: 6 additions & 6 deletions src/etc/tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def interesting_file(f):
check_linelength = True

if len(sys.argv) < 2:
print "usage: tidy.py <src-dir>"
print("usage: tidy.py <src-dir>")
sys.exit(1)

src_dir = sys.argv[1]
Expand Down Expand Up @@ -200,10 +200,10 @@ def interesting_file(f):

print
for ext in sorted(file_counts, key=file_counts.get, reverse=True):
print "* linted {} {} files".format(file_counts[ext], ext)
print "* linted {} other files".format(count_other_linted_files)
print "* total lines of code: {}".format(count_lines)
print "* total non-blank lines of code: {}".format(count_non_blank_lines)
print
print("* linted {} {} files".format(file_counts[ext], ext))
print("* linted {} other files".format(count_other_linted_files))
print("* total lines of code: {}".format(count_lines))
print("* total non-blank lines of code: {}".format(count_non_blank_lines))
print()

sys.exit(err)