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 2016年07月25日 02:07 by martin.panter, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| tix_default_root.patch | serhiy.storchaka, 2016年07月25日 03:02 | review | ||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 552 | closed | dstufft, 2017年03月31日 16:36 | |
| Messages (14) | |||
|---|---|---|---|
| msg271206 - (view) | Author: Martin Panter (martin.panter) * (Python committer) | Date: 2016年07月25日 02:07 | |
$ ./python -m unittest -v test.test_{idle,tix}
. . .
test_tix (unittest.loader._FailedTest) ... ERROR
======================================================================
ERROR: test_tix (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_tix
Traceback (most recent call last):
File "/media/disk/home/proj/python/cpython/Lib/unittest/loader.py", line 153, in loadTestsFromName
module = __import__(module_name)
File "/media/disk/home/proj/python/cpython/Lib/test/test_tix.py", line 11, in <module>
from tkinter import tix, TclError
File "/media/disk/home/proj/python/cpython/Lib/tkinter/tix.py", line 30, in <module>
from tkinter import _cnfmerge, _default_root
ImportError: cannot import name '_default_root'
Without test_idle, test_tix is skipped for me:
$ ./python -m unittest -v test.test_tix
test_tix_available (test.test_tix.TestTix) ... skipped 'Tix not available'
Reverting to before revision 064b29dde096 (Issue 24137) also fixes the failure.
|
|||
| msg271219 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年07月25日 03:02 | |
There is a bug in tix. _default_root shouldn't be imported, since this is modifiable attribute. |
|||
| msg271220 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2016年07月25日 03:10 | |
I could reverse the effect of test_idle calling tk.NoDefaultRoot by adding tk._support_default_root = 1 tk._default_root = None at the very end, but I take Serhiy's comment as suggesting that there should be no need. |
|||
| msg271221 - (view) | Author: Zachary Ware (zach.ware) * (Python committer) | Date: 2016年07月25日 03:34 | |
I think there are two bugs to be fixed here: 1) as Serhiy said, if tix needs _default_root, it should use it as tkinter._default_root instead of importing it directly 2) test_idle should not permanently modify the tkinter namespace |
|||
| msg271225 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年07月25日 04:32 | |
New changeset 5c76f787e695 by Terry Jan Reedy in branch 'default': Issue #24137, issue #27611: Restore tkinter after test_idle. https://hg.python.org/cpython/rev/5c76f787e695 |
|||
| msg271226 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2016年07月25日 04:37 | |
#24137 only patched default, so either too many versions were selected or there is another bug in test_tix. Martin and Serhiy can sort that out. The restore patch I pushed is based on this from tkinter.__init__ ----- _support_default_root = 1 _default_root = None def NoDefaultRoot(): """Inhibit setting of default root window. Call this function to inhibit that the first instance of Tk is used for windows without an explicit parent window. """ global _support_default_root _support_default_root = 0 global _default_root _default_root = None del _default_root |
|||
| msg272822 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年08月16日 04:10 | |
New changeset a6a248479b66 by Terry Jan Reedy in branch 'default': Issue #27611, #24137: Only change tkinter when easily restored. https://hg.python.org/cpython/rev/a6a248479b66 |
|||
| msg272823 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2016年08月16日 04:11 | |
Ned Deily noticed the same problem when running with test.regrtest #27714. I cannot reproduce this issue when running both tests either with unittest or test.regrtest. F:\Python\dev>36\pcbuild\win32\python_d.exe -m unittest test.test_tix test.test_idle test.test_tix ............................................................................................................................................................................................................................. ---------------------------------------------------------------------- Ran 221 tests in 3.959s OK F:\Python\dev>36\pcbuild\win32\python_d.exe -m test -ugui test_tix test_idle test_tix Run tests sequentially 0:00:00 [1/3] test_tix 0:00:00 [2/3] test_idle 0:00:03 [3/3] test_tix All 3 tests OK. if __name__ == '__main__': unittest.main(verbosity=2, exit=False) + tk._support_default_root = 1 + tk._default_root = None Zach, I don't know of any way to get either unittest or test.regrtest to run anything in test_idle after it runs the test collector *and* the tests. Do you? The addition of tk.NoDefaultRoot() to both IDLE and its tests was suggested by Serhiy in #24137. Doing so exposed several issues in htests but no real bugs in IDLE itself. My patch to restore tkinter module only works when test_idle is run as main. So as far as that patch goes, tkinter should only changed when the test is run as main. I will move the call. I have already changed my check script to run test_idle this way. Otherwise, the easiest way to leave tkinter as it was when testing ends is to not change it. I am aware that tkinter tests avoid the by defining a mixin class with class methods that call and undo the call. It is used in 11 test classes within the tkinter and ttk tests. However, this refactoring would be harder to apply to IDLE tests and not sufficient in itself. It is at best a future project. I added a guard to IDLE's NoDefaultRoot call for when pyshell.main is broken into multiple testable functions. |
|||
| msg272839 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年08月16日 05:44 | |
New changeset cddd633b959f by Terry Jan Reedy in branch '2.7': Issue #27611: Don't import volatile attribute. https://hg.python.org/cpython/rev/cddd633b959f New changeset a42933335897 by Terry Jan Reedy in branch '3.5': Issue #27611: Don't import volatile attribute. https://hg.python.org/cpython/rev/a42933335897 |
|||
| msg272844 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年08月16日 07:09 | |
Terry, you committed not full patch. The tix module still doesn't work after NoDefaultRoot(). |
|||
| msg272846 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2016年08月16日 07:19 | |
What do you mean by 'does not work' and what did I omit? |
|||
| msg272860 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年08月16日 14:25 | |
DisplayStyle() fails with AttributeError after NoDefaultRoot(). Should be made following changes: 1. The refwindow option should have priority over _default_root. 2. Add the master keyword-only parameter for creating styles without refwindow (3.6 only). |
|||
| msg272862 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2016年08月16日 15:55 | |
This issue is about test_tix failing when run after test_idle, due to the conjunction of two specific causes, one old (tix importing _default_root), one new (IDLE deleting and not restoring _default_root). The new cause exposed the old. Fixing either cause would have negated the conjunction, but at Zack's urging, I fixed both. I even did one extra bit of cleanup in moving the tkinter and os imports to the top where they belong. In my view, my patch was more than complete and this issue is fixed and should have remained closed and should be reclosed. Serhiy, when I wrote the tix patch, I was aware that tix remains buggy in that it will fail if a *user* imports tix, removes _default_root, and calls either of the functions that unconditionally access the attribute. Since test_tix only tests that the tix can be imported and that tix.Tk runs, there may be more bugs. And more cleanups might be needed. However, patching tix to work better is a different issue than this one. If you want, open a new issue, add some tests, and write the patch you outlined. |
|||
| msg277376 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年09月25日 13:54 | |
New changeset 94a26aa1b1e0 by Serhiy Storchaka in branch '2.7': Issue #27611: Fixed support of default root window in the Tix module. https://hg.python.org/cpython/rev/94a26aa1b1e0 New changeset 7b458bcdab75 by Serhiy Storchaka in branch '3.5': Issue #27611: Fixed support of default root window in the tkinter.tix module. https://hg.python.org/cpython/rev/7b458bcdab75 New changeset ec3f5d21bec0 by Serhiy Storchaka in branch '3.6': Issue #27611: Fixed support of default root window in the tkinter.tix module. https://hg.python.org/cpython/rev/ec3f5d21bec0 New changeset 1c5e0dbcb2a0 by Serhiy Storchaka in branch 'default': Issue #27611: Fixed support of default root window in the tkinter.tix module. https://hg.python.org/cpython/rev/1c5e0dbcb2a0 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:34 | admin | set | github: 71798 |
| 2017年03月31日 16:36:37 | dstufft | set | pull_requests: + pull_request1089 |
| 2016年09月25日 14:45:24 | serhiy.storchaka | set | status: open -> closed |
| 2016年09月25日 13:54:44 | python-dev | set | messages: + msg277376 |
| 2016年08月16日 15:55:47 | terry.reedy | set | assignee: terry.reedy -> messages: + msg272862 |
| 2016年08月16日 14:25:35 | serhiy.storchaka | set | messages: + msg272860 |
| 2016年08月16日 07:19:24 | terry.reedy | set | messages: + msg272846 |
| 2016年08月16日 07:09:46 | serhiy.storchaka | set | status: closed -> open messages: + msg272844 |
| 2016年08月16日 05:46:09 | terry.reedy | set | status: open -> closed assignee: terry.reedy resolution: fixed stage: patch review -> resolved |
| 2016年08月16日 05:44:52 | python-dev | set | messages: + msg272839 |
| 2016年08月16日 04:11:24 | terry.reedy | set | messages: + msg272823 |
| 2016年08月16日 04:10:31 | python-dev | set | messages: + msg272822 |
| 2016年07月25日 04:37:35 | terry.reedy | set | messages: + msg271226 |
| 2016年07月25日 04:32:09 | python-dev | set | nosy:
+ python-dev messages: + msg271225 |
| 2016年07月25日 03:34:54 | zach.ware | set | nosy:
+ zach.ware messages: + msg271221 |
| 2016年07月25日 03:10:06 | terry.reedy | set | messages: + msg271220 |
| 2016年07月25日 03:02:43 | serhiy.storchaka | set | files:
+ tix_default_root.patch versions: + Python 2.7, Python 3.5 messages: + msg271219 keywords: + patch stage: patch review |
| 2016年07月25日 02:07:16 | martin.panter | create | |