
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2009-08-04 00:09 bysrid, last changed2022-04-11 14:56 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| turtle_bug.patch | Lita.Cho,2014-05-28 03:22 | review | ||
| turtle_crash.patch | Lita.Cho,2014-06-02 21:35 | review | ||
| turtledemo_destroy.patch | serhiy.storchaka,2014-09-04 08:06 | review | ||
| Messages (12) | |||
|---|---|---|---|
| msg91248 -(view) | Author: Sridhar Ratnakumar (srid) | Date: 2009-08-04 00:09 | |
I tried the following turtle program; it was taking some time to draw .. so I pressed C-c after which I saw the exception traceback.> cat play.py from turtle import *def f(length, depth): if depth == 0: forward(length) else: f(length/3, depth-1) right(60) f(length/3, depth-1) left(120) f(length/3, depth-1) right(60) f(length/3, depth-1)f(500, 4)> python play.pyTraceback (most recent call last): File "/Users/sridharr/as/pypm/bin/python", line 41, in <module> execfile(sys.argv[0]) File "play.py", line 15, in <module> f(500, 4) File "play.py", line 11, in f f(length/3, depth-1) File "play.py", line 7, in f f(length/3, depth-1) File "play.py", line 9, in f f(length/3, depth-1) File "play.py", line 10, in f left(120) File "<string>", line 1, in left File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/turtle.py", line 1612, in left self._rotate(angle) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/turtle.py", line 3107, in _rotate self._update() File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/turtle.py", line 2562, in _update self._update_data() File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/turtle.py", line 2553, in _update_data self._pencolor, self._pensize) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/turtle.py", line 569, in _drawline self.cv.coords(lineitem, *cl) File "<string>", line 1, in coords File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/Tkinter.py", line 2136, in coords self.tk.call((self._w, 'coords') + args)))_tkinter.TclError: invalid command name ".10170160"> | |||
| msg109949 -(view) | Author: Mark Lawrence (BreamoreBoy)* | Date: 2010-07-11 00:03 | |
Anyone with turtle/Tkinter knowledge who can shed some light on this? | |||
| msg119414 -(view) | Author: Alexander Belopolsky (belopolsky)*![]() | Date: 2010-10-23 03:06 | |
I have come across the same bug. To reproduce, runDemo/turtle/tdemo_round_dance.py and kill the Tk window before the "dance" stops. The mysterious command name ".10170160" is simply the generated name for the canvas widget - '.' + repr(id(self)). See BaseWidget.__init__ in tkinter. | |||
| msg119711 -(view) | Author: Alexander Belopolsky (belopolsky)*![]() | Date: 2010-10-27 13:33 | |
Same error occurs when the python -m turtle demo is interrupted by closing the window. I think the correct fix is to exit when the window is closed, but I cannot figure out the best way to achieve that. This probably should be done at the application/test level. | |||
| msg219013 -(view) | Author: Lita Cho (Lita.Cho)* | Date: 2014-05-23 23:32 | |
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. | |||
| msg219248 -(view) | Author: Lita Cho (Lita.Cho)* | Date: 2014-05-28 03:22 | |
So I have a patch that fixes the original problem, but doesn't fix the crash with the tdemo_round_dance.py. However, I was wondering why TurtleScreen._RUNNING = True in the _destroy method. Can anyone shed some light on this? Here is the current state of my patch. | |||
| msg219643 -(view) | Author: Lita Cho (Lita.Cho)* | Date: 2014-06-02 21:35 | |
So it looks like the bug fix was really simple. I just needed to set TurtleScreen._RUNNING to True when the screen object tries to get destroyed. | |||
| msg219644 -(view) | Author: Lita Cho (Lita.Cho)* | Date: 2014-06-02 21:43 | |
Oops, pressed submit too soon.Now the programs raise a Terminator exception rather than a TclError, which I think is correct because the programs are calling Turtle methods when the TurtleScreen had been destroyed. I wasn't sure if it was better to return None rather than raise an exception, but I think raising exception is correct, as these programs are not calling mainloop to handle event loops. So when the user closes the window, round_dance.py should handle that. | |||
| msg224328 -(view) | Author: Lita Cho (Lita.Cho)* | Date: 2014-07-30 17:36 | |
I can make it worth such that it doesn't raise a Terminator error. This works great when working with Turtle on the command line. I basically check if the root exists for all Tk canvas calls. If it got destroyed, then it just returns. However, if you run the following recursive code, it will just keep popping up a window forever unless you Ctrl+C out of the program. So that is not going to work. I still believe raising an error is the proper approach. | |||
| msg226346 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2014-09-04 08:06 | |
Here is more complete patch. | |||
| msg227393 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2014-09-23 20:47 | |
Any feedback? | |||
| msg236410 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2015-02-22 15:28 | |
New changeset15dd9d6cc632 by Serhiy Storchaka in branch '2.7':Issue#6639: Module-level turtle functions no longer raise TclError afterhttps://hg.python.org/cpython/rev/15dd9d6cc632New changeset1628484c9408 by Serhiy Storchaka in branch '3.4':Issue#6639: Module-level turtle functions no longer raise TclError afterhttps://hg.python.org/cpython/rev/1628484c9408New changesetd8e494986caf by Serhiy Storchaka in branch 'default':Issue#6639: Module-level turtle functions no longer raise TclError afterhttps://hg.python.org/cpython/rev/d8e494986caf | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:51 | admin | set | github: 50888 |
| 2015-02-22 15:30:30 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2015-02-22 15:28:07 | python-dev | set | nosy: +python-dev messages: +msg236410 |
| 2015-02-15 15:45:04 | serhiy.storchaka | set | nosy: +terry.reedy |
| 2015-02-15 15:27:43 | serhiy.storchaka | set | assignee:serhiy.storchaka |
| 2014-09-23 20:47:58 | serhiy.storchaka | set | messages: +msg227393 |
| 2014-09-04 08:06:03 | serhiy.storchaka | set | files: +turtledemo_destroy.patch messages: +msg226346 |
| 2014-08-29 21:12:54 | terry.reedy | set | nosy: +serhiy.storchaka versions: + Python 3.4, Python 3.5, - Python 3.1, Python 3.2 |
| 2014-07-30 17:36:06 | Lita.Cho | set | messages: +msg224328 |
| 2014-07-13 17:22:21 | jesstess | set | keywords: +needs review stage: needs patch -> patch review |
| 2014-06-02 21:43:50 | Lita.Cho | set | messages: +msg219644 |
| 2014-06-02 21:35:35 | Lita.Cho | set | files: +turtle_crash.patch messages: +msg219643 |
| 2014-05-28 03:22:49 | Lita.Cho | set | files: +turtle_bug.patch keywords: +patch messages: +msg219248 |
| 2014-05-23 23:32:07 | Lita.Cho | set | messages: +msg219013 |
| 2014-05-23 21:07:29 | Lita.Cho | set | nosy:belopolsky,gregorlingl,ned.deily,asvetlov,srid,jesstess,Lita.Cho |
| 2014-05-23 19:53:59 | Lita.Cho | set | nosy: +jesstess,Lita.Cho |
| 2012-03-25 20:41:22 | asvetlov | set | nosy: +asvetlov |
| 2010-11-05 02:08:18 | belopolsky | link | issue1702036 superseder |
| 2010-10-28 01:12:24 | ned.deily | set | nosy: +ned.deily, -BreamoreBoy |
| 2010-10-27 13:33:39 | belopolsky | set | nosy: +gregorlingl messages: +msg119711 |
| 2010-10-23 03:06:02 | belopolsky | set | nosy: +belopolsky messages: +msg119414 |
| 2010-07-11 00:03:53 | BreamoreBoy | set | versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6 nosy: +BreamoreBoy messages: +msg109949 stage: needs patch |
| 2009-08-04 00:09:40 | srid | set | components: + Tkinter |
| 2009-08-04 00:09:24 | srid | create | |