classification
Title: tkinter with wantobjects=False has been broken for some time
Type: behavior Stage: resolved
Components: Tkinter Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Arfrever, Lita.Cho, asvetlov, gpolo, jesstess, loewis, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2008-05-30 22:51 by gpolo, last changed 2016-10-24 20:53 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
tkinter_wantobjects.diff gpolo, 2008-05-30 22:51 review
remove_wantobjects_internalRep.diff gpolo, 2008-05-31 13:29 review
tkinter_deprecate_wantobjects.patch serhiy.storchaka, 2013-09-20 20:57 review
Messages (16)
msg67562 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-05-30 22:51
This affects only py3k, but apparently tkinter has been in this
situation for more than 9 months now.
I see these lines at _tkinter.c:

const char *s = Tcl_GetStringResult(self->interp);
const char *p = s;

res = PyUnicode_FromStringAndSize(s, (int)(p-s));

and I was wondering how could res not end up being an empty string
always ? Then I did some quick tests here and the return is always an
empty string, when wantobjects is set to False. Maybe the second line
should be:

const char *p = strchr(s, '\0');

I've attached this correction. Not sure if it is the best way to solve
the problem.
msg67567 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-05-31 05:59
I think in Python 3, the whole wantobjects=False case should go. It was
a compatibility measure to support applications that didn't expect Tcl
objects; for Python 3, only a single case should be supported.
msg67575 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-05-31 12:18
I will agree that wantobjects=False should go, it is also discouraged to
use Tcl_GetStringResult because it may lose information. 

But something should be done at FromObj since it accesses Tcl_Obj fields
directly, and it may end up not using the current object representation
which may cause weird things like in issue1447222. Said that, I'm not
sure how to fix it for now.
msg67577 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-05-31 13:29
I've removed wantobjects and substituted some internalRep usage too.
msg197767 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-09-15 12:52
Looks as issue18877 is related to this. I have proposed for it a little different patch than first Guilherme's patch.

As for removing wantobjects, we perhaps can do this only in 3.4.
msg198167 - (view) Author: Roundup Robot (python-dev) Date: 2013-09-20 20:29
New changeset 08c45e18e7b2 by Serhiy Storchaka in branch '3.3':
Issue #3015: Fixed tkinter with wantobject=False.  Any Tcl command call
http://hg.python.org/cpython/rev/08c45e18e7b2

New changeset 65dd0de6b4a5 by Serhiy Storchaka in branch 'default':
Issue #3015: Fixed tkinter with wantobject=False.  Any Tcl command call
http://hg.python.org/cpython/rev/65dd0de6b4a5
msg198168 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-09-20 20:48
Here is a patch which change the default value for the wantobjects parameter of _tkinter.create() and adds deprecation warnings.
msg198169 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * Date: 2013-09-20 20:53
> Here is a patch

You again forgot to attach a patch :) .
msg198170 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-09-20 20:57
Oh, thanks Arfrever.
msg219012 - (view) Author: Lita Cho (Lita.Cho) * Date: 2014-05-23 23:23
I am in the process of reviewing this patch, but I don't know what "wantobjects" does. I can make a guess, I think it is a hack to make tcl objects work in Python. I am guessing this is less needed in Python 3.4, but still has some dependencies. 

If we can add in the documentation of what "wantobjects" is and why it is being depreciated somewhere, that would be great. I would do it myself, but I do need some direction.

I ran the tests, and it seems to run fine. The patch didn't have any new tests. We should add one that checks if the depreciation is working.
msg219171 - (view) Author: Jessica McKellar (jesstess) * Date: 2014-05-26 19:38
@Lita.Cho: (I'd like to this on the web but the links are still broken after the website port) if you search for `wantobjects` in `Doc/whatsnew/2.3.rst`, there's a description of why the parameter was added.
msg219177 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-05-26 20:47
Now I think we shouldn't deprecate and remove wantobjects=False. Tkinter was partially broken with wantobjects=False, on other hand, it was partially broken with wantobjects=True. Many bugs was fixed last months, all tests now work with wantobjects=False, and I hope Tkinter now correctly supports both mode.

Besides using in old third-party code, this parameter is very helpful for testing. Tcl/Tk changes internal details from release to release, so when in one release Tk function returns list or integer, in other release it can return special object ('dict' or 'pixel'). Tkinter should be more stable against changing of return type, and wantobjects=False helps in detecting some such cases.

I propose to close this issue as fixed.
msg219247 - (view) Author: Lita Cho (Lita.Cho) * Date: 2014-05-28 02:26
Serhiy, does that mean this is fixed the way it is? Do I need to do anything else to close out this issue? It looks like wantobjects is set to False, currently.
msg219267 - (view) Author: Roundup Robot (python-dev) Date: 2014-05-28 14:00
New changeset c69e8ea3bf10 by Serhiy Storchaka in branch 'default':
Issue #3015: _tkinter.create() now creates tkapp object with wantobject=1 by
http://hg.python.org/cpython/rev/c69e8ea3bf10
msg219268 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-05-28 14:04
Lita Cho, originally reported issue is fixed.

I asked Martin (and Guilherme if he is here). Are you agree to close this issue? See issue21585 about extending testing.
msg222813 - (view) Author: Lita Cho (Lita.Cho) * Date: 2014-07-12 00:23
That's perfect. I agree that this issue is closed! :)
History
Date User Action Args
2016-10-24 20:53:40serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2014-07-12 00:23:40Lita.Chosetmessages: + msg222813
2014-05-28 14:04:10serhiy.storchakasetmessages: + msg219268
2014-05-28 14:00:42python-devsetmessages: + msg219267
2014-05-28 02:26:36Lita.Chosetmessages: + msg219247
2014-05-26 20:47:08serhiy.storchakasetmessages: + msg219177
2014-05-26 19:38:24jesstesssetmessages: + msg219171
2014-05-23 23:23:10Lita.Chosetmessages: + msg219012
2014-05-23 18:36:38Lita.Chosetnosy: + jesstess, Lita.Cho
2013-12-19 07:57:04serhiy.storchakalinkissue18877 superseder
2013-09-20 20:57:56serhiy.storchakasetfiles: + tkinter_deprecate_wantobjects.patch

messages: + msg198170
2013-09-20 20:53:10Arfreversetnosy: + Arfrever
messages: + msg198169
2013-09-20 20:48:30serhiy.storchakasettype: behavior
stage: patch review
messages: + msg198168
versions: - Python 3.3
2013-09-20 20:29:14python-devsetnosy: + python-dev
messages: + msg198167
2013-09-20 20:08:34serhiy.storchakasetassignee: serhiy.storchaka
2013-09-15 12:52:14serhiy.storchakasetnosy: + serhiy.storchaka

messages: + msg197767
versions: + Python 3.3, Python 3.4, - Python 3.0
2012-03-22 22:39:43asvetlovsetnosy: + asvetlov
2008-05-31 13:29:45gpolosetfiles: + remove_wantobjects_internalRep.diff
messages: + msg67577
2008-05-31 12:18:34gpolosetmessages: + msg67575
2008-05-31 05:59:21loewissetnosy: + loewis
messages: + msg67567
2008-05-30 22:51:37gpolocreate