py3port: use encode() and decode() where applicable

This commit is contained in:
The MMGen Project 2018-10-31 14:16:00 +00:00
commit 04329b6757
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
28 changed files with 143 additions and 152 deletions

View file

@ -19,7 +19,7 @@ cmd_args = opts.init(opts_data)
lines = get_lines_from_file(cmd_args[0])
start = (1,0)[bool(opt.include_first_line)]
a = make_chksum_6(' '.join(lines[start:]).encode('utf8'))
a = make_chksum_6(' '.join(lines[start:]).encode())
if start == 1:
b = lines[0]
msg(("Checksum in file ({}) doesn't match computed value!".format(b),'Checksum in file OK')[a==b])

View file

@ -174,8 +174,8 @@ def compile_code(code):
cmd = ['solc','--optimize','--bin','--overwrite']
if not opt.stdout: cmd += ['--output-dir', opt.outdir or '.']
p = Popen(cmd,stdin=PIPE,stdout=PIPE,stderr=PIPE)
res = p.communicate(code)
o = res[0].replace('\r','').split('\n')
res = p.communicate(code.encode())
o = res[0].decode().replace('\r','').split('\n')
dmsg(res[1])
if opt.stdout:
return dict((k,o[i+2]) for k in ('SafeMath','Owned','Token') for i in range(len(o)) if k in o[i])