mirror of
https://github.com/hugsy/gef.git
synced 2026-10-12 02:15:57 +00:00
Python 3.10 improvements (#1139)
## Description Follow-up PR for #1133 but purely esthetic, no functional changes Cleans up the code to make it more in comformance with Python 3.10 capabilities. Replaces: - type `Union` with `|` - type `Dict`/`Set`/`List`/`Tuple` with `dict`/`set`/`list`/`tuple` - `Optional` with ` | None` - `if:` ... `elif`... -> `match` Fixes: - `gdb.events.*Event` -> `gdb.*Event` - `GefHeapManager.malloc_align_address` had its `ceil` lambda moved as a proper (nested) function Lint: - `except:` -> `except Exception:` - removed a bunch of unused f-strings - `if not .. in ..` -> `if .. not in ..` - some short named variables renamed
This commit is contained in:
@@ -14,3 +14,4 @@ debug.log
|
||||
htmlcov
|
||||
.benchmarks
|
||||
site/
|
||||
untracked/
|
||||
|
||||
+7
-5
@@ -5,7 +5,7 @@ import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
from typing import Tuple
|
||||
|
||||
import unittest
|
||||
|
||||
import rpyc
|
||||
@@ -109,7 +109,9 @@ pi start_rpyc_service({self._port})
|
||||
return super().tearDown()
|
||||
|
||||
@property
|
||||
def gdb_version(self) -> Tuple[int, int]:
|
||||
res = [int(d) for d in re.search(r"(\d+)\D(\d+)", self._gdb.VERSION).groups()]
|
||||
assert len(res) >= 2
|
||||
return tuple(res)
|
||||
def gdb_version(self) -> tuple[int, int]:
|
||||
res = re.search(r"(\d+)\D(\d+)", self._gdb.VERSION)
|
||||
assert res
|
||||
groups = [int(d) for d in res.groups()]
|
||||
assert len(groups) == 2
|
||||
return groups[0], groups[1]
|
||||
|
||||
@@ -71,5 +71,5 @@ class GefRemoteCommand(RemoteGefUnitTestGeneric):
|
||||
with gdbserver_session(port=port) as _:
|
||||
gdb.execute(f"target remote {GDBSERVER_DEFAULT_HOST}:{port}")
|
||||
res: str = root.eval("str(gef.session.remote)")
|
||||
assert res.startswith(f"RemoteSession(target=':0', local='/tmp/")
|
||||
assert res.startswith("RemoteSession(target=':0', local='/tmp/")
|
||||
assert res.endswith(f"pid={gef.session.pid}, mode={gdbserver_mode})")
|
||||
|
||||
@@ -41,5 +41,5 @@ class ThemeCommand(RemoteGefUnitTestGeneric):
|
||||
gdb.execute(f"theme {t} {v}")
|
||||
|
||||
|
||||
res = gdb.execute(f"theme ___I_DONT_EXIST___", to_string=True)
|
||||
res = gdb.execute("theme ___I_DONT_EXIST___", to_string=True)
|
||||
self.assertIn("Invalid key", res)
|
||||
|
||||
Reference in New Issue
Block a user