mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Merge pull request #8131 from ethereum/python3
Use Python 3 instead of Python 2 (EOL'd)
This commit is contained in:
		
						commit
						8bd1e7045a
					
				| @ -1,18 +1,18 @@ | ||||
| #!/usr/bin/env python | ||||
| #!/usr/bin/env python3 | ||||
| 
 | ||||
| import sys | ||||
| import glob | ||||
| import subprocess | ||||
| import json | ||||
| 
 | ||||
| solc = sys.argv[1] | ||||
| report = open("report.txt", "wb") | ||||
| SOLC_BIN = sys.argv[1] | ||||
| REPORT_FILE = open("report.txt", "wb") | ||||
| 
 | ||||
| for optimize in [False, True]: | ||||
|     for f in sorted(glob.glob("*.sol")): | ||||
|         sources = {} | ||||
|         sources[f] = {'content': open(f, 'r').read()} | ||||
|         input = { | ||||
|         input_json = { | ||||
|             'language': 'Solidity', | ||||
|             'sources': sources, | ||||
|             'settings': { | ||||
| @ -22,20 +22,20 @@ for optimize in [False, True]: | ||||
|                 'outputSelection': {'*': {'*': ['evm.bytecode.object', 'metadata']}} | ||||
|             } | ||||
|         } | ||||
|         args = [solc, '--standard-json'] | ||||
|         args = [SOLC_BIN, '--standard-json'] | ||||
|         if optimize: | ||||
|             args += ['--optimize'] | ||||
|         proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||||
|         (out, err) = proc.communicate(json.dumps(input)) | ||||
|         (out, err) = proc.communicate(json.dumps(input_json)) | ||||
|         try: | ||||
|             result = json.loads(out.strip()) | ||||
|             for filename in sorted(result['contracts'].keys()): | ||||
|                 for contractName in sorted(result['contracts'][filename].keys()): | ||||
|                     contractData = result['contracts'][filename][contractName] | ||||
|                     if 'evm' in contractData and 'bytecode' in contractData['evm']: | ||||
|                         report.write(filename + ':' + contractName + ' ' + contractData['evm']['bytecode']['object'] + '\n') | ||||
|                         REPORT_FILE.write(filename + ':' + contractName + ' ' + contractData['evm']['bytecode']['object'] + '\n') | ||||
|                     else: | ||||
|                         report.write(filename + ':' + contractName + ' NO BYTECODE\n') | ||||
|                     report.write(filename + ':' + contractName + ' ' + contractData['metadata'] + '\n') | ||||
|                         REPORT_FILE.write(filename + ':' + contractName + ' NO BYTECODE\n') | ||||
|                     REPORT_FILE.write(filename + ':' + contractName + ' ' + contractData['metadata'] + '\n') | ||||
|         except KeyError: | ||||
|             report.write(f + ": ERROR\n") | ||||
|             REPORT_FILE.write(f + ": ERROR\n") | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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. | ||||
| @ -8,12 +8,9 @@ | ||||
| 
 | ||||
| import sys | ||||
| import re | ||||
| import os | ||||
| import hashlib | ||||
| from os.path import join | ||||
| 
 | ||||
| def extract_test_cases(path): | ||||
|     lines = open(path, 'rb').read().splitlines() | ||||
| def extract_test_cases(_path): | ||||
|     lines = open(_path, 'rb').read().splitlines() | ||||
| 
 | ||||
|     inside = False | ||||
|     delimiter = '' | ||||
| @ -42,8 +39,5 @@ def extract_test_cases(path): | ||||
|                 inside = True | ||||
|                 delimiter = m.group(1) | ||||
| 
 | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     path = sys.argv[1] | ||||
|     extract_test_cases(path) | ||||
| 
 | ||||
|     extract_test_cases(sys.argv[1]) | ||||
|  | ||||
| @ -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) | ||||
| 
 | ||||
|  | ||||
| @ -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: | ||||
|  | ||||
| @ -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. | ||||
|  | ||||
| @ -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 | ||||
| 
 | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
| @ -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. | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user