Bug report
Bug description:
Issue
When callback_kwargs is a tuple, Option._check_callback raises TypeError instead of OptionError. The error message is formatted with %r % self.callback_kwargs. When callback_kwargs is a tuple, Python's % operator unpacks it as multiple format arguments, causing TypeError: not all arguments converted during string formatting.
Reproducer
from optparse import Option
Option('--foo', action='callback', callback=lambda *a: None, callback_kwargs=(1, 2))
# TypeError: not all arguments converted during string formatting
# Expected: OptionError
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
Bug report
Bug description:
Issue
When
callback_kwargsis a tuple,Option._check_callbackraisesTypeErrorinstead ofOptionError. The error message is formatted with%r % self.callback_kwargs. Whencallback_kwargsis a tuple, Python's%operator unpacks it as multiple format arguments, causingTypeError: not all arguments converted during string formatting.Reproducer
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
OptionErrorinOption._check_callbackwhencallback_kwargsis invalid #145822