diff options
| author | blasty <peter@haxx.in> | 2026-08-21 12:12:53 +0200 |
|---|---|---|
| committer | blasty <peter@haxx.in> | 2026-08-21 12:12:53 +0200 |
| commit | ea22067c52ec335ea4d3a616cb2107d5fdbdf7b6 (patch) | |
| tree | df7afae5ed521d61ee75e49270c144325d9bf5fe /idatui/remote_ops.py | |
| parent | Merge PR #1 from mrexodia: Windows support and auto-refresh on events (diff) | |
| download | ida-tui-ea22067c52ec335ea4d3a616cb2107d5fdbdf7b6.tar.gz ida-tui-ea22067c52ec335ea4d3a616cb2107d5fdbdf7b6.tar.xz ida-tui-ea22067c52ec335ea4d3a616cb2107d5fdbdf7b6.zip | |
tests: repair the two seams the ida-nexus port left behind
Two scenario monkeypatch sites still hooked client.invoke -- the rename to
call() updated the call sites but not the patches, so reprime_is_free and
split_view crashed instead of counting. call() takes the remote_ops
declaration itself now, so both count by its __name__.
remote_ops imported RemoteModule inside _bindings(), which made
test_nexus_client (NEEDS_IDA = False) unrunnable under a stdlib-only
python3 -- the house rule tests/run.py --fast depends on. The import moves
to the same eagerly-if-present, bound-to-None-so-patchable contract
nexus_client uses, and the test injects FakeRemoteModule/FakeRemoteError
exactly like its other fakes: real names when the library is installed,
strict fakes when it is not.
Diffstat (limited to '')
| -rw-r--r-- | idatui/remote_ops.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/idatui/remote_ops.py b/idatui/remote_ops.py index a67b2b7..cbd1d49 100644 --- a/idatui/remote_ops.py +++ b/idatui/remote_ops.py @@ -11,6 +11,16 @@ from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from ida_domain import Database +# Same contract as nexus_client: ida_nexus is imported eagerly-if-present but +# never at hard import cost, and the name is bound to None rather than left +# undefined so it stays PATCHABLE -- the offline contract tests inject a fake +# RemoteModule here and run this module's binding logic under a stdlib-only +# python3 (tests/run.py --fast). +try: + from ida_nexus import RemoteModule +except ImportError: # library absent: bindings fail actionably on first use + RemoteModule = None # type: ignore[assignment,misc] + def operation_label() -> str: """Display attribution for the current call; ready for per-user context.""" @@ -1655,8 +1665,13 @@ def _bindings() -> dict[Callable[..., Any], Any]: with _BIND_LOCK: if _BOUND is not None: return _BOUND - from ida_nexus import RemoteModule - + # Gated on the binding, not a fresh import, so an injected fake is + # honoured (see the module docstring on the guarded import above). + if RemoteModule is None: + raise ImportError( + "The 'ida-nexus' package is required to execute remote " + "operations but is not installed in this interpreter." + ) operations_module = RemoteModule( Path(__file__), operation_label=operation_label, codec="json" ) |
