Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit ee3a455

Browse files
committed
fixes for solidity compiler code
1 parent b610b2a commit ee3a455

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

ethereum/_solidity.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,21 @@ def solc_parse_output(compiler_output):
6767
""" Parses the compiler output. """
6868
result = yaml.safe_load(compiler_output)['contracts']
6969

70-
if 'bin' in result.values()[0]:
70+
if 'bin' in tuple(result.values())[0]:
7171
for value in result.values():
7272
value['bin_hex'] = value['bin']
7373

7474
# decoding can fail if the compiled contract has unresolved symbols
7575
try:
76-
value['bin'] = value['bin_hex'].decode('hex')
76+
value['bin'] = decode_hex(value['bin_hex'])
7777
except TypeError:
7878
pass
7979

8080
for json_data in ('abi', 'devdoc', 'userdoc'):
8181
# the values in the output can be configured through the
8282
# --combined-json flag, check that it's present in the first value and
8383
# assume all values are consistent
84-
if json_data not in result.values()[0]:
84+
if json_data not in tuple(result.values())[0]:
8585
continue
8686

8787
for value in result.values():
@@ -185,7 +185,7 @@ def solidity_resolve_address(hex_code, library_symbol, library_address):
185185
raise ValueError('Address should not contain the 0x prefix')
186186

187187
try:
188-
_ = library_address.decode('hex')
188+
_ = decode_hex(library_address)
189189
except TypeError:
190190
raise ValueError('library_address contains invalid characters, it must be hex encoded.')
191191

@@ -294,8 +294,11 @@ def compile_code(sourcecode, libraries=None, combined='bin,abi', optimize=True):
294294
args = solc_arguments(libraries=libraries, combined=combined, optimize=optimize)
295295
args.insert(0, get_compiler_path())
296296

297-
process = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
298-
stdoutdata, _ = process.communicate(input=sourcecode)
297+
process = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
298+
stdoutdata, stderrdata = process.communicate(input=utils.to_string(sourcecode))
299+
300+
if process.returncode != 0:
301+
raise CompileError(stderrdata)
299302

300303
return solc_parse_output(stdoutdata)
301304

0 commit comments

Comments
 (0)