This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2014年06月29日 23:56 by ned.deily, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Messages (8) | |||
|---|---|---|---|
| msg221921 - (view) | Author: Ned Deily (ned.deily) * (Python committer) | Date: 2014年06月29日 23:56 | |
Although the turtledemo modules are not run directly during by "make test" or by "python -m test -uall", they are currently being inadvertently imported by test___all__. This can lead to test failures and side effects because some of the turtledemo modules execute code on import, rather than only when being run via calls to their main() functions. A quick glance shows problems with the following demos: clock (calls mode("logo") which causes a window to appear), colormixer (which unconditionally calls sys.setrecursionlimit()), and two_canvases (which is not structured using functions at all). Depending on how tests are run, these problems can cause serious side effects.
At a minimum,
1. test___all__ should be changed to exclude turtledemo modules.
It would also be nice to make the demos better citizens:
2. move the mode() call to main() in clock
3. move the setrecursionlimit call to main() and save and restore the original value on exit
4. restructure two_canvases to be like the other demos.
5. double-check all demos for other cases where interpreter state is changed and not restored.
|
|||
| msg221922 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2014年06月30日 00:11 | |
> 1. test___all__ should be changed to exclude turtledemo modules. Agreed. In general, the test suite shouldn't open any GUI windows except if the "gui" resource is enabled (which isn't the default). The turtledemo behaviour is quite new in that regard. |
|||
| msg221937 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2014年06月30日 02:12 | |
6. Add 'good citizenship' note to demohelp.txt. Also point out that all turtle initialiazation should be in main anyway (see 2. and 3. below). Demo should run independently of what other demos do. re 2: If the mode call is needed, it is a bug that it is not main() as another demo could change it. re 3: ditto, though much less likely. re 4: As mentioned in #14117, two_canvases is buggy in that the code is not displayed. I added a comment in the file about things that don't work. A main function is the next thing to try anyway. If no one does the turtledemo changes, I probably will soon. |
|||
| msg221966 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2014年06月30日 16:17 | |
I am working on the turtle demos now. Victor gave more info in #21884. I was partly wrong in my comments. turtledemo uses reload to re-initialize demos when one switches between them. I am tempted to remove this as part of discouraging side-effects on import. It is not a good example to be followed. |
|||
| msg221978 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2014年06月30日 20:10 | |
New changeset c173a34f20c0 by Terry Jan Reedy in branch '2.7': Issue #21882: In turtle demos, remove module scope gui and sys calls by http://hg.python.org/cpython/rev/c173a34f20c0 New changeset fcfa9c5a00fd by Terry Jan Reedy in branch '3.4': Issue #21882: In turtle demos, remove module scope gui and sys calls by http://hg.python.org/cpython/rev/fcfa9c5a00fd |
|||
| msg221981 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2014年06月30日 20:28 | |
2. Done 3. I just removed the setrecursionlimit call, added for 3.0. I moved the colormixer sliders around for longer than anyone is likely to and it ran fine. 4. two-canvases works fine now. The extra window just has to be clicked away. 5. nim had a call to turtle.Screen, now in main(). 6. Done Let's see what the buildbots say. 1. Since demos are part of the delivered stdlib, it could be argued that they should get minimal sanity check of being importable. I don't care either way. I leave this to either of you. |
|||
| msg221988 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2014年06月30日 22:11 | |
The __all__ test now passes on Snow Leapard. |
|||
| msg223772 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2014年07月23日 20:00 | |
I opened #22051 about removing reload to force better code. Since the tests are passing and I think the demo modules should be minimally tested by importing, and no one has said otherwise since the fix, I am closing this. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:05 | admin | set | github: 66081 |
| 2014年07月23日 20:00:27 | terry.reedy | set | status: open -> closed resolution: fixed messages: + msg223772 stage: commit review -> resolved |
| 2014年06月30日 22:11:35 | terry.reedy | set | messages: + msg221988 |
| 2014年06月30日 20:28:30 | terry.reedy | set | assignee: terry.reedy -> messages: + msg221981 stage: test needed -> commit review |
| 2014年06月30日 20:10:14 | python-dev | set | nosy:
+ python-dev messages: + msg221978 |
| 2014年06月30日 19:11:14 | ned.deily | link | issue21884 superseder |
| 2014年06月30日 16:30:14 | terry.reedy | link | issue14117 dependencies |
| 2014年06月30日 16:17:13 | terry.reedy | set | assignee: terry.reedy messages: + msg221966 |
| 2014年06月30日 13:28:56 | r.david.murray | set | nosy:
+ jesstess |
| 2014年06月30日 02:13:00 | terry.reedy | set | messages:
+ msg221937 versions: + Python 2.7 |
| 2014年06月30日 00:11:57 | pitrou | set | nosy:
+ terry.reedy, pitrou messages: + msg221922 |
| 2014年06月29日 23:56:01 | ned.deily | create | |