pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/f0ed293f6aec1c2ed22725301b77d6ccedc2d486

55097560d244c08.css" /> gh-103685: Fix tkinter.Menu.index() for Tk 8.7 (#103686) · python/cpython@f0ed293 · GitHub
Skip to content

Commit f0ed293

Browse files
chrstphrchvzterryjreedyblurb-it[bot]
authored
gh-103685: Fix tkinter.Menu.index() for Tk 8.7 (#103686)
--------- Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
1 parent bd2dca0 commit f0ed293

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

Lib/test/test_tkinter/test_widgets.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,11 @@ class MenuTest(AbstractWidgetTest, unittest.TestCase):
13771377
def create(self, **kwargs):
13781378
return tkinter.Menu(self.root, **kwargs)
13791379

1380+
def test_indexcommand_none(self):
1381+
widget = self.create()
1382+
i = widget.index('none')
1383+
self.assertIsNone(i)
1384+
13801385
def test_configure_postcommand(self):
13811386
widget = self.create()
13821387
self.checkCommandParam(widget, 'postcommand')

Lib/tkinter/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3430,8 +3430,7 @@ def entryconfigure(self, index, cnf=None, **kw):
34303430
def index(self, index):
34313431
"""Return the index of a menu item identified by INDEX."""
34323432
i = self.tk.call(self._w, 'index', index)
3433-
if i == 'none': return None
3434-
return self.tk.getint(i)
3433+
return None if i in ('', 'none') else self.tk.getint(i) # GH-103685.
34353434

34363435
def invoke(self, index):
34373436
"""Invoke a menu item identified by INDEX and execute
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Prepare :meth:`tkinter.Menu.index` for Tk 8.7 so that it does not raise ``TclError: expected integer but got ""`` when it should return ``None``.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy