From 44e892634bb60f295509b775064e6a958b764f1e Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 13 Jan 2020 16:14:18 +0100 Subject: [PATCH] Use Python 3 instead of Python 2 (EOL'd) --- scripts/bytecodecompare/prepare_report.py | 2 +- scripts/deps-ppa/static_z3.sh | 2 +- scripts/extract_test_cases.py | 2 +- scripts/fix_homebrew_paths_in_standalone_zip.py | 3 +-- scripts/isolate_tests.py | 9 +++++---- scripts/release.sh | 2 +- scripts/run_proofs.sh | 2 +- scripts/splitSources.py | 4 ++-- scripts/update_bugs_by_version.py | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts/bytecodecompare/prepare_report.py b/scripts/bytecodecompare/prepare_report.py index 41878bb86..847e3ee0e 100755 --- a/scripts/bytecodecompare/prepare_report.py +++ b/scripts/bytecodecompare/prepare_report.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys import glob diff --git a/scripts/deps-ppa/static_z3.sh b/scripts/deps-ppa/static_z3.sh index b38af9e9c..5a860bf7f 100755 --- a/scripts/deps-ppa/static_z3.sh +++ b/scripts/deps-ppa/static_z3.sh @@ -76,7 +76,7 @@ Build-Depends: debhelper (>= 9.0.0), git, libgmp-dev, dh-python, - python + python3 Standards-Version: 3.9.6 Homepage: https://github.com/Z3Prover/z3 Vcs-Git: git://github.com/Z3Prover/z3.git diff --git a/scripts/extract_test_cases.py b/scripts/extract_test_cases.py index 47c53f3c8..e6764b466 100755 --- a/scripts/extract_test_cases.py +++ b/scripts/extract_test_cases.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # This script reads C++ or RST source files and writes all # multi-line strings into individual files. diff --git a/scripts/fix_homebrew_paths_in_standalone_zip.py b/scripts/fix_homebrew_paths_in_standalone_zip.py index 38aa9685d..980ba1a88 100755 --- a/scripts/fix_homebrew_paths_in_standalone_zip.py +++ b/scripts/fix_homebrew_paths_in_standalone_zip.py @@ -43,7 +43,6 @@ import os import subprocess import sys - def readDependencies(fname): with open(fname) as f: o = subprocess.Popen(['otool', '-L', fname], stdout=subprocess.PIPE) @@ -55,7 +54,7 @@ def readDependencies(fname): command = "install_name_tool -change " + \ library + " @executable_path/./" + \ os.path.basename(library) + " " + fname - print command + print(command) os.system("chmod +w " + fname) os.system(command) diff --git a/scripts/isolate_tests.py b/scripts/isolate_tests.py index 9492ee137..e1a9da46c 100755 --- a/scripts/isolate_tests.py +++ b/scripts/isolate_tests.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # This script reads C++ or RST source files and writes all # multi-line strings into individual files. @@ -13,7 +13,7 @@ import hashlib from os.path import join, isfile def extract_test_cases(path): - lines = open(path, 'rb').read().splitlines() + lines = open(path, 'r').read().splitlines() inside = False delimiter = '' @@ -43,7 +43,7 @@ def extract_docs_cases(path): tests = [] # Collect all snippets of indented blocks - for l in open(path, 'rb').read().splitlines(): + for l in open(path, 'r').read().splitlines(): if l != '': if not inside and l.startswith(' '): # start new test @@ -71,7 +71,8 @@ def write_cases(f, tests): # When code examples are extracted they indented by 8 spaces, which violates the style guide, # so before checking remove 4 spaces from each line. remainder = re.sub(r'^ {4}', '', test, 0, re.MULTILINE) - open('test_%s_%s.sol' % (hashlib.sha256(test).hexdigest(), cleaned_filename), 'wb').write(remainder) + sol_filename = 'test_%s_%s.sol' % (hashlib.sha256(test.encode("utf-8")).hexdigest(), cleaned_filename) + open(sol_filename, 'w').write(remainder) def extract_and_write(f, path): if docs: diff --git a/scripts/release.sh b/scripts/release.sh index ebc7759f5..7d6eee85a 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -49,7 +49,7 @@ cp $REPO_ROOT/build/solc/solc $ZIP_TEMP_DIR # being for kernel-level dylibs. if [[ "$OSTYPE" == "darwin"* ]]; then - python $REPO_ROOT/scripts/fix_homebrew_paths_in_standalone_zip.py $ZIP_TEMP_DIR + python3 $REPO_ROOT/scripts/fix_homebrew_paths_in_standalone_zip.py $ZIP_TEMP_DIR fi # And ZIP it all up, with a filename suffix passed in on the command-line. diff --git a/scripts/run_proofs.sh b/scripts/run_proofs.sh index 3a89d6b70..bc6cd8e8a 100755 --- a/scripts/run_proofs.sh +++ b/scripts/run_proofs.sh @@ -12,7 +12,7 @@ for new_proof in $(git diff origin/develop --name-only test/formal/) do set +e echo "Proving $new_proof..." - output=$(python "$new_proof") + output=$(python3 "$new_proof") result=$? set -e diff --git a/scripts/splitSources.py b/scripts/splitSources.py index 0f6f1f86d..dd6d62eb3 100755 --- a/scripts/splitSources.py +++ b/scripts/splitSources.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # This script reads a syntaxTest file and writes all # sources into their own files. If one source-name specifies subdirectories @@ -57,6 +57,6 @@ if __name__ == '__main__': srcString = "" for src in createdSources: srcString += src + ' ' - print srcString + print(srcString) else: sys.exit(1) diff --git a/scripts/update_bugs_by_version.py b/scripts/update_bugs_by_version.py index 655ffe233..23b59c01b 100755 --- a/scripts/update_bugs_by_version.py +++ b/scripts/update_bugs_by_version.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # This script is used to generate the list of bugs per compiler version # from the list of bugs.