only convert input bytes if they are a string and we are in python 3
in python 2 'str' and 'bytes' are the same. if input bytes are not a string or bytes, then raise a TypeError.
This commit is contained in:
parent
8de5c3faff
commit
3743146121
1 changed files with 4 additions and 5 deletions
|
|
@ -194,11 +194,10 @@ class Disassembler(object):
|
||||||
llvm.mc.Instr
|
llvm.mc.Instr
|
||||||
'''
|
'''
|
||||||
|
|
||||||
if not isinstance(bs, bytes):
|
if isinstance(bs, str) and sys.version_info.major >= 3:
|
||||||
if sys.version_info.major < 3:
|
bs = bytes(map(lambda c: ord(c), bs))
|
||||||
bs = bytes(bs)
|
elif not isinstance(bs, bytes):
|
||||||
else:
|
raise TypeError("expected bs to be either 'str' or 'bytes' but got %s" % type(bs))
|
||||||
bs = bytes(map(lambda c: ord(c), bs))
|
|
||||||
|
|
||||||
code = api.llvm.StringRefMemoryObject.new(bs, base_addr)
|
code = api.llvm.StringRefMemoryObject.new(bs, base_addr)
|
||||||
idx = 0
|
idx = 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue