diff --git a/pwndbg/color.py b/pwndbg/color.py index 4d0fc892b..391b0e188 100644 --- a/pwndbg/color.py +++ b/pwndbg/color.py @@ -3,6 +3,8 @@ from __future__ import unicode_literals import functools +import six + import gdb import pwndbg.config import pwndbg.enhance @@ -93,7 +95,7 @@ def get(address, text = None): old_color = color color = lambda x: rwx(old_color(x)) - if text is None and isinstance(address, (long, int)) and address > 255: + if text is None and isinstance(address, six.integer_types) and address > 255: text = hex(int(address)) if text is None: text = str(int(address)) diff --git a/pwndbg/commands/auxv.py b/pwndbg/commands/auxv.py index e3151e4d5..ddf4641bb 100644 --- a/pwndbg/commands/auxv.py +++ b/pwndbg/commands/auxv.py @@ -1,6 +1,8 @@ from __future__ import print_function from __future__ import unicode_literals +import six + import gdb import pwndbg.auxv import pwndbg.chain @@ -15,4 +17,4 @@ def auxv(): """ for k,v in sorted(pwndbg.auxv.get().items()): if v is not None: - print(k.ljust(24), v if not isinstance(v, (long, int)) else pwndbg.chain.format(v)) + print(k.ljust(24), v if not isinstance(v, six.integer_types) else pwndbg.chain.format(v)) diff --git a/pwndbg/commands/heap.py b/pwndbg/commands/heap.py index 6bea9a8cd..ca0501a68 100644 --- a/pwndbg/commands/heap.py +++ b/pwndbg/commands/heap.py @@ -1,8 +1,9 @@ #!/usr/bin/env python - from __future__ import print_function from __future__ import unicode_literals +import six + import gdb import pwndbg.commands from pwndbg.color import bold @@ -152,7 +153,7 @@ def malloc_chunk(addr): """ Prints out the malloc_chunk at the specified address. """ - if not isinstance(addr, int): + if not isinstance(addr, six.integer_types): addr = int(addr) chunk = value_from_type('struct malloc_chunk', addr) diff --git a/pwndbg/commands/vmmap.py b/pwndbg/commands/vmmap.py index 18f41570c..a05f5a8a1 100644 --- a/pwndbg/commands/vmmap.py +++ b/pwndbg/commands/vmmap.py @@ -6,6 +6,8 @@ Command to print the vitual memory map a la /proc/self/maps. from __future__ import print_function from __future__ import unicode_literals +import six + import gdb import pwndbg.color import pwndbg.commands @@ -24,9 +26,9 @@ def vmmap(map=None): int_map = None str_map = None - if isinstance(map, pwndbg.compat.basestring): + if isinstance(map, six.string_types): str_map = map - elif isinstance(map, (long, int, gdb.Value)): + elif isinstance(map, six.integer_types + (gdb.Value,)): int_map = int(map) print(pwndbg.color.legend()) diff --git a/pwndbg/regs.py b/pwndbg/regs.py index f0bf23081..f261052db 100644 --- a/pwndbg/regs.py +++ b/pwndbg/regs.py @@ -13,6 +13,8 @@ import re import sys from types import ModuleType +import six + import gdb import pwndbg.arch import pwndbg.compat @@ -282,10 +284,10 @@ class module(ModuleType): @pwndbg.memoize.reset_on_stop def __getitem__(self, item): - if isinstance(item, int): + if isinstance(item, six.integer_types): return arch_to_regs[pwndbg.arch.current][item] - if not isinstance(item, pwndbg.compat.basestring): + if not isinstance(item, six.string_types): print("Unknown register type: %r" % (item)) import pdb, traceback traceback.print_stack() @@ -296,7 +298,7 @@ class module(ModuleType): item = item.lstrip('$') item = getattr(self, item.lower()) - if isinstance(item, (int,long)): + if isinstance(item, six.integer_types): return int(item) & pwndbg.arch.ptrmask return item diff --git a/pwndbg/symbol.py b/pwndbg/symbol.py index 4bb8ec903..0abca672a 100644 --- a/pwndbg/symbol.py +++ b/pwndbg/symbol.py @@ -18,6 +18,7 @@ import elftools.common.exceptions import elftools.elf.constants import elftools.elf.elffile import elftools.elf.segments +import six import gdb import pwndbg.elf @@ -190,7 +191,7 @@ def get(address, gdb_only=False): @pwndbg.memoize.reset_on_objfile def address(symbol): - if isinstance(symbol, (int,long)): + if isinstance(symbol, six.integer_types): return symbol try: diff --git a/pwndbg/typeinfo.py b/pwndbg/typeinfo.py index a03991402..69023920e 100644 --- a/pwndbg/typeinfo.py +++ b/pwndbg/typeinfo.py @@ -13,6 +13,8 @@ import subprocess import sys import tempfile +import six + import gdb import pwndbg.events import pwndbg.gcc