@@ -67,21 +67,21 @@ def solc_parse_output(compiler_output):
67
67
""" Parses the compiler output. """
68
68
result = yaml .safe_load (compiler_output )['contracts' ]
69
69
70
- if 'bin' in result .values ()[0 ]:
70
+ if 'bin' in tuple ( result .values () )[0 ]:
71
71
for value in result .values ():
72
72
value ['bin_hex' ] = value ['bin' ]
73
73
74
74
# decoding can fail if the compiled contract has unresolved symbols
75
75
try :
76
- value ['bin' ] = value ['bin_hex' ]. decode ( 'hex' )
76
+ value ['bin' ] = decode_hex ( value ['bin_hex' ])
77
77
except TypeError :
78
78
pass
79
79
80
80
for json_data in ('abi' , 'devdoc' , 'userdoc' ):
81
81
# the values in the output can be configured through the
82
82
# --combined-json flag, check that it's present in the first value and
83
83
# assume all values are consistent
84
- if json_data not in result .values ()[0 ]:
84
+ if json_data not in tuple ( result .values () )[0 ]:
85
85
continue
86
86
87
87
for value in result .values ():
@@ -185,7 +185,7 @@ def solidity_resolve_address(hex_code, library_symbol, library_address):
185
185
raise ValueError ('Address should not contain the 0x prefix' )
186
186
187
187
try :
188
- _ = library_address . decode ( 'hex' )
188
+ _ = decode_hex ( library_address )
189
189
except TypeError :
190
190
raise ValueError ('library_address contains invalid characters, it must be hex encoded.' )
191
191
@@ -294,8 +294,11 @@ def compile_code(sourcecode, libraries=None, combined='bin,abi', optimize=True):
294
294
args = solc_arguments (libraries = libraries , combined = combined , optimize = optimize )
295
295
args .insert (0 , get_compiler_path ())
296
296
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 )
299
302
300
303
return solc_parse_output (stdoutdata )
301
304
0 commit comments