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

Commit 90168f1

Browse files
committed
Cherry-pick utils.py from 679c564
1 parent ccd1064 commit 90168f1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ethereum/utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def sha3(seed):
117117
sha3_count[0] += 1
118118
return sha3_256(to_string(seed))
119119

120-
assert encode_hex(sha3('')) == b'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
120+
assert encode_hex(sha3(b'')) == b'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
121121

122122

123123
def privtoaddr(x, extended=False):
@@ -143,9 +143,11 @@ def check_and_strip_checksum(x):
143143

144144

145145
def normalize_address(x, allow_blank=False):
146-
if allow_blank and (x == '' or x == b''):
146+
if is_numeric(x):
147+
return int_to_addr(x)
148+
if allow_blank and x in {'', b''}:
147149
return b''
148-
if len(x) in (42, 50) and x[:2] == '0x':
150+
if len(x) in (42, 50) and x[:2] in {'0x', b'0x'}:
149151
x = x[2:]
150152
if len(x) in (40, 48):
151153
x = decode_hex(x)
@@ -169,7 +171,7 @@ def zunpad(x):
169171

170172

171173
def int_to_addr(x):
172-
o = [''] * 20
174+
o = [b''] * 20
173175
for i in range(20):
174176
o[19 - i] = ascii_chr(x & 0xff)
175177
x >>= 8

0 commit comments

Comments
 (0)