From d30414bb5331d91784c536d30e22c2ccb8126b7a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 15 Sep 2025 10:23:20 -0400 Subject: forall: fix crash with no command When callback= is used, optparse does not automatically initialize The destination when a dest= is not specified. Refine the test to allow dest= options when callback= is used even when it seems like it is otherwise redundant. Bug: b/436611422 Change-Id: I5185f95cb857ca6d37357cac77fb117a83db9c0c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/509861 Tested-by: Mike Frysinger Commit-Queue: Mike Frysinger Reviewed-by: Gavin Mak --- tests/test_subcmds.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_subcmds.py b/tests/test_subcmds.py index 2d680fb7..0683f1dd 100644 --- a/tests/test_subcmds.py +++ b/tests/test_subcmds.py @@ -94,7 +94,12 @@ class AllCommands(unittest.TestCase): """Block redundant dest= arguments.""" def _check_dest(opt): - if opt.dest is None or not opt._long_opts: + """Check the dest= setting.""" + # If the destination is not set, nothing to check. + # If long options are not set, then there's no implicit destination. + # If callback is used, then a destination might be needed because + # optparse cannot assume a value is always stored. + if opt.dest is None or not opt._long_opts or opt.callback: return long = opt._long_opts[0] -- cgit v1.2.3-54-g00ecf