diff --git a/Lib/argparse.py b/Lib/argparse.py index 0dbdd67a82f391..1d02021417a6d7 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -932,7 +932,10 @@ def __init__(self, def __call__(self, parser, namespace, values, option_string=None): if option_string in self.option_strings: - setattr(namespace, self.dest, not option_string.startswith('--no-')) + if not self.dest.startswith('no'): + setattr(namespace, self.dest, not option_string.startswith('--no-')) + else: + setattr(namespace, self.dest, option_string.count('no') == self.dest.count('no')) def format_usage(self): return ' | '.join(self.option_strings) diff --git a/Misc/NEWS.d/next/macOS/2024-04-19-13-35-28.gh-issue-117941.s9-8rd.rst b/Misc/NEWS.d/next/macOS/2024-04-19-13-35-28.gh-issue-117941.s9-8rd.rst new file mode 100644 index 00000000000000..ec162532bfdf0f --- /dev/null +++ b/Misc/NEWS.d/next/macOS/2024-04-19-13-35-28.gh-issue-117941.s9-8rd.rst @@ -0,0 +1 @@ +write!