Issue 15721: PEP 3121, 384 Refactoring applied to tkinter module (original) (raw)

Created on 2012-08-18 10:53 by Robin.Schreiber, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
_tkinter_pep3121-384_v0.patch Robin.Schreiber,2012-08-18 10:53
_tkinter_pep3121-384_v1.patch asvetlov,2012-10-06 15:27 review
_tkinter_pep3121-384_v2.patch asvetlov,2012-10-06 21:12 review
_tkinter_pep3121-384_v3.patch asvetlov,2012-10-06 21:36 review
_tkinter_pep3121-384_v4.patch asvetlov,2012-10-06 22:49 review
_tkinter_pep3121-384_v7.patch asvetlov,2012-10-07 09:59
_tkinter_pep384_v1.patch asvetlov,2012-10-07 14:26 review
Messages (24)
msg168504 - (view) Author: Robin Schreiber (Robin.Schreiber) * (Python triager) Date: 2012-08-18 10:53
Changes proposed in PEP3121 and PEP384 have now been applied to the tkinter module! When running the test form inside Python.exe (tkinter._test()), the litte "test-window" is rendered correctly. However there are still some error messages popping up inside the python shell (I am running this on OS X 10.8): >>> tkinter._test() 2012-08-18 12:46:24.775 python.exe[17410:707] speedup (null) 2012-08-18 12:46:24.776 python.exe[17410:707] ERROR: Unable to find method [_NSFullScreenTransition _startFullScreenTransitionForCGWindow:targetFrame:duration:]. 2012-08-18 12:46:24.776 python.exe[17410:707] ERROR: Unable to find method [_NSFullScreenTransition _startEnterFullScreenTransitionForCGWindow:targetFrame:duration:]. 2012-08-18 12:46:24.778 python.exe[17410:707] ERROR: Unable to find method [_NSFullScreenTransition startExitFullScreenTransitionForCGWindow:targetFrame:duration:]. [87221 refs] >>> I have no Idea how and where these are triggered.
msg168505 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-08-18 10:58
See http://www.python.org/download/mac/tcltk/ It may be that using a different build of Tcl/Tk solves that problem.
msg168522 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-08-18 18:52
What version of 10.8 are you seeing those messages with? And do you see them without the patch applied?
msg172210 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-06 15:27
Update patch conforming to current _tkinter code.
msg172213 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-06 15:55
I would to have all module state inside _tkinterstate structure. static variables like tcl_lock, tcl_state, quitMainLoop, errorInCmd etc should be moved into _tkinterstate also.
msg172222 - (view) Author: Robin Schreiber (Robin.Schreiber) * (Python triager) Date: 2012-10-06 17:04
Before I submitted this patch, I used to have these variables inside the modulestate, which caused severe problems. I do not know the exact reason, but my guess is that these variables have to be globally available for every thread (tcl variables are used for thread synchronization arent they?). As the modulestate may change depending on the thread, one can no longer guarantee that every thread within the process is operating on the same variable. This might not be nessecary, however as I mentioned, the naive approach of putting the variables inside the modulestate did not work out for me.
msg172230 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-06 18:03
I'm trying to make patch following myself recommendations. Looks good but not finished yet. Will publish it after all work done.
msg172245 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-06 21:12
Submit patch which store own state into module state. Still not finished yet: need to add checks for "ready state" in every access to fields of module state structure.
msg172248 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-06 21:36
Update patch to support TKINTER_PROTECT_LOADTK option.
msg172257 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-06 22:49
Upload version which check if _tkinter module was destroyed (for example, if it was call from daemon thread runing Tk app when main thread is exiting with interpreter finalization).
msg172288 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-07 09:59
The patch for current default branch.
msg172306 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-07 14:26
The patch is huge, then I like to apply it in two steps: first implement pep 384 than 3121. Attached first patch.
msg172883 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-10-14 13:54
New changeset bf9d118779f5 by Andrew Svetlov in branch 'default': Issue #15721: make _tkinter module pep384 compatible. http://hg.python.org/cpython/rev/bf9d118779f5
msg172969 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2012-10-15 13:35
Andrew, I have questions about the following part of commit bf9d118779f5: + PyTclObject_Type_slots[3].pfunc = PyObject_GenericGetAttr; First, the "3" refers to the position of Py_tp_getattro in the array, which is a fragile thing IMO. Then, this hack was not necessary before; why is it needed now? IIRC on Windows a static initializer cannot contain dll-imported variables, but function pointers are OK. Or do you have evidence of the contrary?
msg172985 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-15 16:37
Amaury, I completely agree with your objection. I've found this code in xxlimited.c and adapted to _tkinter source. If that weird code can be removed I will do it. I have no idea how we can catch/reproduce the problem, maybe Martin von Loewis can help as author of xxlimited.c code? As I know almost nobody make PEP 384 compliant modules for now and maybe there are couple of dark corners at least in the docs. See also #15650 for another question related to adaptation to pep3121.
msg174226 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-30 20:48
Amaury, you are right: PyTclObject_Type_slots[3].pfunc = PyObject_GenericGetAttr; is not required.
msg174227 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-10-30 20:49
New changeset 4eb6e07e8171 by Andrew Svetlov in branch 'default': Issue #15721: apply PEP 384 Refactoring to tkinter module. http://hg.python.org/cpython/rev/4eb6e07e8171
msg187261 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2013-04-18 15:42
Is any more work needed on this issue or can it be closed?
msg187380 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2013-04-19 18:26
No, PEP3121 patch is not ready yet but PEP384 has been applied.
msg194842 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-08-10 22:18
The first two patches (_tkinter_pep3121-384_v0.patch and _tkinter_pep3121-384_v1.patch) seemed to have the refcounts right, but Andrew's further patches lost the required Py_INCREF in the various new() functions (and the corresponding Py_DECREF in deallocs), which is the cause for the crash in #15667.
msg194843 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-08-10 22:22
New changeset 4d0c938870bc by Antoine Pitrou in branch 'default': Fix refcounting issue with extension types in tkinter. http://hg.python.org/cpython/rev/4d0c938870bc
msg231696 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-11-26 07:48
_tkinter classes are now heap types and they no longer have the __module__ attribute. >>> import _tkinter >>> _tkinter.TkappType.__module__ Traceback (most recent call last): File "", line 1, in AttributeError: __module__ See .
msg254680 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-11-15 08:23
This change causes a crash when create instances of _tkinter classes (). If this will not be fixed I suggest to revert the patch.
msg265154 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-08 18:31
Fixed in . Opened for documenting the catch.
History
Date User Action Args
2022-04-11 14:57:34 admin set github: 59926
2016-05-08 18:31:21 serhiy.storchaka set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2015-11-15 08:23:44 serhiy.storchaka set messages: +
2014-11-26 07:48:35 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2014-02-03 17:03:22 BreamoreBoy set nosy: - BreamoreBoy
2013-08-10 22:22:39 python-dev set messages: +
2013-08-10 22🔞03 pitrou set nosy: + pitroumessages: +
2013-04-19 18:26:06 asvetlov set messages: +
2013-04-18 15:42:27 BreamoreBoy set nosy: + BreamoreBoymessages: +
2012-11-08 13🔞59 Robin.Schreiber set keywords: + pep3121, - patch
2012-10-30 20:49:29 python-dev set messages: +
2012-10-30 20:48:21 asvetlov set messages: +
2012-10-15 16:37:06 asvetlov set messages: +
2012-10-15 13:35:47 amaury.forgeotdarc set nosy: + amaury.forgeotdarcmessages: +
2012-10-14 13:54:47 python-dev set nosy: + python-devmessages: +
2012-10-07 14:26:46 asvetlov set files: + _tkinter_pep384_v1.patchmessages: +
2012-10-07 09:59:56 asvetlov set files: + _tkinter_pep3121-384_v7.patchmessages: +
2012-10-06 22:49:19 asvetlov set files: + _tkinter_pep3121-384_v4.patchmessages: +
2012-10-06 21:36:39 asvetlov set files: + _tkinter_pep3121-384_v3.patchmessages: +
2012-10-06 21:24:32 asvetlov set stage: patch review
2012-10-06 21:12:40 asvetlov set files: + _tkinter_pep3121-384_v2.patchassignee: asvetlovmessages: +
2012-10-06 18:03:11 asvetlov set messages: +
2012-10-06 17:04:09 Robin.Schreiber set messages: +
2012-10-06 15:55:16 asvetlov set messages: +
2012-10-06 15:27:35 asvetlov set files: + _tkinter_pep3121-384_v1.patchmessages: +
2012-08-27 03:49:13 belopolsky link issue15787 dependencies
2012-08-20 10:42:46 asvetlov set nosy: + asvetlov
2012-08-18 18:52:01 ned.deily set nosy: + ned.deilymessages: +
2012-08-18 10:58:31 loewis set nosy: + loewismessages: +
2012-08-18 10:53:44 Robin.Schreiber create