Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.9] bpo-41384: Raise TclError in tkinter.OptionMenu (GH-21601) #21635

Merged
merged 1 commit into from Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/tkinter/__init__.py
Expand Up @@ -3965,7 +3965,7 @@ def __init__(self, master, variable, value, *values, **kwargs):
if 'command' in kwargs:
del kwargs['command']
if kwargs:
raise TclError('unknown option -'+kwargs.keys()[0])
raise TclError('unknown option -'+next(iter(kwargs)))
menu.add_command(label=value,
command=_setit(variable, value, callback))
for v in values:
Expand Down
4 changes: 4 additions & 0 deletions Lib/tkinter/test/test_tkinter/test_widgets.py
Expand Up @@ -307,6 +307,10 @@ class OptionMenuTest(MenubuttonTest, unittest.TestCase):
def create(self, default='b', values=('a', 'b', 'c'), **kwargs):
return tkinter.OptionMenu(self.root, None, default, *values, **kwargs)

def test_bad_kwarg(self):
with self.assertRaisesRegex(TclError, r"^unknown option -image$"):
tkinter.OptionMenu(self.root, None, 'b', image='')


@add_standard_options(IntegerSizeTests, StandardOptionsTests)
class EntryTest(AbstractWidgetTest, unittest.TestCase):
Expand Down
@@ -0,0 +1,2 @@
Raise TclError instead of TypeError when an unknown option is passed to
tkinter.OptionMenu.