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
|
||||
'''
|
||||
|
||||
if not isinstance(bs, bytes):
|
||||
if sys.version_info.major < 3:
|
||||
bs = bytes(bs)
|
||||
else:
|
||||
bs = bytes(map(lambda c: ord(c), bs))
|
||||
if isinstance(bs, str) and sys.version_info.major >= 3:
|
||||
bs = bytes(map(lambda c: ord(c), bs))
|
||||
elif not isinstance(bs, bytes):
|
||||
raise TypeError("expected bs to be either 'str' or 'bytes' but got %s" % type(bs))
|
||||
|
||||
code = api.llvm.StringRefMemoryObject.new(bs, base_addr)
|
||||
idx = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue