From 02e8eff9e420c9b97df9d69c5f25f9bcd2786a87 Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Tue, 19 Sep 2017 14:24:59 +0700 Subject: [PATCH] Python 2 compatibility fix --- ether/asm.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ether/asm.py b/ether/asm.py index 9113b14b..f4319011 100644 --- a/ether/asm.py +++ b/ether/asm.py @@ -1,6 +1,7 @@ -from ethereum import opcodes -import codecs +import sys import re +import codecs +from ethereum import opcodes regex_PUSH = re.compile('^PUSH(\d*)$') @@ -109,8 +110,13 @@ def disassemble(bytecode): instruction = {} 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: + # invalid opcode disassembly.append({'opcode': "INVALID"}) i += 1