Skip to content

Commit

Permalink
Remove more python2-specific stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Grazfather committed Jul 5, 2021
1 parent 7d1ab00 commit 80c768a
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions gef.py
Expand Up @@ -51,10 +51,6 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
#

from __future__ import print_function, division, absolute_import

import abc
import argparse
Expand Down Expand Up @@ -5087,10 +5083,10 @@ def load_module(self, file_path):
return module

def enumerate_structures_from_module(self, module):
_invalid = set(["BigEndianStructure", "LittleEndianStructure", "Structure"])
_structs = set([x for x in dir(module) \
_invalid = {"BigEndianStructure", "LittleEndianStructure", "Structure"}
_structs = {x for x in dir(module) \
if inspect.isclass(getattr(module, x)) \
and issubclass(getattr(module, x), ctypes.Structure)])
and issubclass(getattr(module, x), ctypes.Structure)}
return _structs - _invalid


Expand Down Expand Up @@ -5947,7 +5943,6 @@ def set_fs(uc, addr): return set_msr(uc, FSMSR, addr)
#
# @_hugsy_
#
from __future__ import print_function
import collections
import capstone, unicorn
Expand Down Expand Up @@ -9834,9 +9829,8 @@ def get_zone_base_address(name):

return None

class GenericFunction(gdb.Function):
class GenericFunction(gdb.Function, metaclass=abc.ABCMeta):
"""This is an abstract class for invoking convenience functions, should not be instantiated."""
__metaclass__ = abc.ABCMeta

@abc.abstractproperty
def _function_(self): pass
Expand Down Expand Up @@ -10076,7 +10070,7 @@ def load(self, initial=False):
self.loaded_functions.append(function_class_name())

def is_loaded(x):
return any(filter(lambda u: x == u[0], self.loaded_commands))
return any(u for u in self.loaded_commands if x == u[0])

for cmd, class_name in self.commands:
if is_loaded(cmd):
Expand All @@ -10100,7 +10094,7 @@ def is_loaded(x):
if initial:
gef_print("{:s} for {:s} ready, type `{:s}' to start, `{:s}' to configure"
.format(Color.greenify("GEF"), get_os(),
Color.colorify("gef","underline yellow"),
Color.colorify("gef", "underline yellow"),
Color.colorify("gef config", "underline pink")))

ver = "{:d}.{:d}".format(sys.version_info.major, sys.version_info.minor)
Expand Down Expand Up @@ -10192,7 +10186,7 @@ def invoke(self, args, from_tty):

if argc == 1:
prefix = argv[0]
names = list(filter(lambda x: x.startswith(prefix), __config__.keys()))
names = [x for x in __config__.keys() if x.startswith(prefix)]
if names:
if len(names) == 1:
gef_print(titlify("GEF configuration setting: {:s}".format(names[0])))
Expand Down Expand Up @@ -10449,7 +10443,7 @@ def __init__(self, alias, command, completer_class=gdb.COMPLETE_NONE, command_cl
if not p:
return

if list(filter(lambda x: x._alias == alias, __aliases__)):
if any(x for x in __aliases__ if x._alias == alias):
return

self._command = command
Expand Down

0 comments on commit 80c768a

Please sign in to comment.