-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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: OptionErrorCPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
No status