fix: use bound-method param count for Dynamips create_nio detection

The inspect check tested unbound function signatures (3 params unbound vs
2 unbound) but node.manager.create_nio is a bound method — inspect
excludes 'self'.  Dynamips bound = 2 (node + nio_settings), standard
bound = 1 (nio_settings).  The old '== 3' never matched, so the extra
'node' arg was never passed.  Switch to '>= 2' and rewrite the test to
exercise the actual bound-method scenario.
This commit is contained in:
YueGuobin committed 2026-08-11 00:58:08 +08:00
1 parent e56488c2f7
commit 09a9555d02
2 files changed
+19 -14

No files matched your search

+5 -1
View File
@@ -191,8 +191,12 @@ async def create_batch_nios(
nio_settings = jsonable_encoder(entry.nio, exclude_unset=True)
# Dynamips.create_nio takes an extra positional `node` argument that
# the base signature does not include. Detect it via parameter count.
# Dynamips.create_nio(self, node, nio_settings) exposes one extra
# positional on the bound method compared to the standard signature
# (self, nio_settings). Detect it: standard == 1 bound param,
# Dynamips == 2 bound params (node + nio_settings).
sig = inspect.signature(node.manager.create_nio)
if len(sig.parameters) == 3:
if len(sig.parameters) >= 2:
nio = node.manager.create_nio(node, nio_settings)
else:
nio = node.manager.create_nio(nio_settings)