Skip to content

Commit 51bfe2b

Browse files
committed
Changes per review.
1 parent f3598e1 commit 51bfe2b

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

Lib/tkinter/__init__.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -780,19 +780,17 @@ def after_cancel(self, id):
780780
def after_info(self, id=None):
781781
"""Return information about existing event handlers.
782782
783-
With no argument, return a list of the identifiers for all existing
784-
event handlers created by the after command for this interpreter.
785-
If id is supplied, it specifies an existing handler; id must have been
786-
the return value from some previous call to after or after_idle and it
787-
must not have triggered yet or been canceled. If the id doesn't exist,
788-
a TclError is raised. Othewise, the return value is a tuple
789-
containing (script, type) where type is either 'idle' or 'timer' to
790-
indicate what kind of event handler it is.
783+
With no argument, return a tuple of the identifiers for all existing
784+
event handlers created by the after and after_idle commands for this
785+
interpreter. If id is supplied, it specifies an existing handler; id
786+
must have been the return value from some previous call to after or
787+
after_idle and it must not have triggered yet or been canceled. If the
788+
id doesn't exist, a TclError is raised. Othewise, the return value is
789+
a tuple containing (script, type) where script is a reference to the
790+
function to be called by the event handler and type is either 'idle'
791+
or 'timer' to indicate what kind of event handler it is.
791792
"""
792-
if id is None:
793-
return self.tk.call('after', 'info')
794-
else:
795-
return self.tk.call('after', 'info', id)
793+
return self.tk.splitlist(self.tk.call('after', 'info', id))
796794

797795
def bell(self, displayof=0):
798796
"""Ring a display's bell."""

Lib/tkinter/test/test_tkinter/test_misc.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ def callback():
158158

159159
def test_after_info(self):
160160
root = self.root
161+
162+
# No events.
163+
self.assertEqual(root.after_info(), ())
164+
161165
# Add timer.
162166
timer = root.after(1, lambda: 'break')
163167

@@ -172,12 +176,12 @@ def test_after_info(self):
172176
# Only contains new events and not 'timer'.
173177
self.assertEqual(root.after_info(), (idle1, timer2, timer1))
174178

175-
# With a paramter returns a tuple of (script, type).
179+
# With a parameter returns a tuple of (script, type).
176180
timer1_info = root.after_info(timer1)
177-
self.assertIn('lambda', timer1_info[0])
181+
self.assertEqual(len(timer1_info), 2)
178182
self.assertEqual(timer1_info[1], 'timer')
179183
idle1_info = root.after_info(idle1)
180-
self.assertIn('lambda', idle1_info[0])
184+
self.assertEqual(len(idle1_info), 2)
181185
self.assertEqual(idle1_info[1], 'idle')
182186

183187
root.after_cancel(timer1)
@@ -190,6 +194,9 @@ def test_after_info(self):
190194
with self.assertRaises(tkinter.TclError):
191195
root.after_info(idle1)
192196

197+
# No events.
198+
self.assertEqual(root.after_info(), ())
199+
193200

194201
tests_gui = (MiscTest, )
195202

0 commit comments

Comments
 (0)