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

Commit 857a783

Browse files
committed
use byte strings
1 parent abe2707 commit 857a783

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

ethereum/chain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class Chain(object):
110110
"""
111111
head_candidate = None
112112

113-
def __init__(self, env, genesis=None, new_head_cb=None, coinbase='\x00' * 20):
113+
def __init__(self, env, genesis=None, new_head_cb=None, coinbase=b'\x00' * 20):
114114
assert isinstance(env, Env)
115115
self.env = env
116116
self.db = self.blockchain = env.db

ethereum/ethash.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from functools import lru_cache
1010

1111

12-
cache_seeds = ['\x00' * 32]
12+
cache_seeds = [b'\x00' * 32]
1313

1414

1515
def mkcache(block_number):

ethereum/keys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def big_endian_to_int(value):
247247
if len(value) == 1:
248248
return ord(value)
249249
elif len(value) <= 8:
250-
return struct.unpack('>Q', value.rjust(8, '\x00'))[0]
250+
return struct.unpack('>Q', value.rjust(8, b'\x00'))[0]
251251
else:
252252
return int(encode_hex(value), 16)
253253

ethereum/transactions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def sign(self, key):
114114
115115
A potentially already existing signature would be overridden.
116116
"""
117-
if key in (0, '', '\x00' * 32, '0' * 64):
117+
if key in (0, '', b'\x00' * 32, '0' * 64):
118118
raise InvalidTransaction("Zero privkey cannot sign")
119119
rawhash = utils.sha3(rlp.encode(self, UnsignedTransaction))
120120

ethereum/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def zpad(x, l):
163163

164164
def zunpad(x):
165165
i = 0
166-
while i < len(x) and (x[i] == 0 or x[i] == '\x00'):
166+
while i < len(x) and (x[i] == 0 or x[i] == b'\x00'):
167167
i += 1
168168
return x[i:]
169169

@@ -254,7 +254,7 @@ def decode_addr(v):
254254

255255
def decode_int(v):
256256
'''decodes and integer from serialization'''
257-
if len(v) > 0 and (v[0] == '\x00' or v[0] == 0):
257+
if len(v) > 0 and (v[0] == b'\x00' or v[0] == 0):
258258
raise Exception("No leading zero bytes allowed for integers")
259259
return big_endian_to_int(v)
260260

0 commit comments

Comments
 (0)