classification
Title: tkinter with wantobjects=False has been broken for some time
Type: Stage:
Components: Tkinter Versions: Python 3.0
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: gpolo, loewis
Priority: normal Keywords: patch

Created on 2008-05-30 22:51 by gpolo, last changed 2008-05-31 13:29 by gpolo.

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
Messages (4)
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.
History
Date User Action Args
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