Python 2 compatibility fix

pull/2/head
Bernhard Mueller 7 years ago
parent 3583d77cb7
commit 02e8eff9e4
  1. 12
      ether/asm.py

@ -1,6 +1,7 @@
from ethereum import opcodes import sys
import codecs
import re import re
import codecs
from ethereum import opcodes
regex_PUSH = re.compile('^PUSH(\d*)$') regex_PUSH = re.compile('^PUSH(\d*)$')
@ -109,8 +110,13 @@ def disassemble(bytecode):
instruction = {} instruction = {}
try: try:
opcode = opcodes.opcodes[bytecode[i]] if (sys.version_info > (3, 0)):
opcode = opcodes.opcodes[bytecode[i]]
else:
opcode = opcodes.opcodes[ord(bytecode[i])]
except KeyError: except KeyError:
# invalid opcode # invalid opcode
disassembly.append({'opcode': "INVALID"}) disassembly.append({'opcode': "INVALID"})
i += 1 i += 1

Loading…
Cancel
Save