bpo-32857: Raise error when tkinter after_cancel() is called with None. (GH-5701)

(cherry picked from commit 74382a3f17)

Co-authored-by: Cheryl Sabella <cheryl.sabella@gmail.com>
This commit is contained in:
Miss Islington (bot) 2018-03-04 04:00:33 -08:00 committed by GitHub
parent 0902a2d6b2
commit a5303dd9c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 115 additions and 3 deletions

View file

@ -739,6 +739,7 @@ class Misc:
if not func:
# I'd rather use time.sleep(ms*0.001)
self.tk.call('after', ms)
return None
else:
def callit():
try:
@ -762,11 +763,13 @@ class Misc:
"""Cancel scheduling of function identified with ID.
Identifier returned by after or after_idle must be
given as first parameter."""
given as first parameter.
"""
if not id:
raise ValueError('id must be a valid identifier returned from '
'after or after_idle')
try:
data = self.tk.call('after', 'info', id)
# In Tk 8.3, splitlist returns: (script, type)
# In Tk 8.4, splitlist may return (script, type) or (script,)
script = self.tk.splitlist(data)[0]
self.deletecommand(script)
except TclError: