[issue6639] turtle: _tkinter.TclError: invalid command name ".10170160"

Lita Cho report at bugs.python.org
Sat May 24 01:32:07 CEST 2014


Lita Cho added the comment:

I was looking at this more, and from my understanding, the turtle code is continuing to run even when the TK window is destroyed. Thus the crash.

It looks like the drawing functions are being made on the fly with the following method:

for methodname in _tg_turtle_functions:
    pl1, pl2 = getmethparlist(eval('Turtle.' + methodname))
    if pl1 == "":
        print(">>>>>>", pl1, pl2)
        continue
    defstr = ("def %(key)s%(pl1)s: return _getpen().%(key)s%(pl2)s" %
                                   {'key':methodname, 'pl1':pl1, 'pl2':pl2})
    exec(defstr)
    eval(methodname).__doc__ = _turtle_docrevise(eval('Turtle.'+methodname).__doc__)

So while all the methods are being generated, I am going to add in a check to see if the window was destroyed before running the pen code. If it was, then I exit gratefully. The check will be duplicated for each pen method, but I feel it is the best way to contain the check within the turtle.py module. The other option would be to make the user check for it, which is not a good option.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6639>
_______________________________________


More information about the Python-bugs-list mailing list