diff --git a/pwndbg/memoize.py b/pwndbg/memoize.py index ca7736cbc..67abe17af 100644 --- a/pwndbg/memoize.py +++ b/pwndbg/memoize.py @@ -6,7 +6,6 @@ e.g. execution stops because of a SIGINT or breakpoint, or a new library/objfile are loaded, etc. """ -import collections import functools import sys @@ -14,6 +13,13 @@ import gdb import pwndbg.events +try: + # Python >= 3.10 + from collections.abc import Hashable +except ImportError: + # Python < 3.10 + from collections import Hashable + debug = False @@ -32,7 +38,7 @@ class memoize: def __call__(self, *args, **kwargs): how = None - if not isinstance(args, collections.abc.Hashable): + if not isinstance(args, Hashable): print("Cannot memoize %r!", file=sys.stderr) how = "Not memoizeable!" value = self.func(*args)