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.

classification
Title: tkinter string variable misinterpreted as boolean
Type: behavior Stage: resolved
Components: Tkinter Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Andreas Bolsch, iritkatriel, r.david.murray, serhiy.storchaka
Priority: normal Keywords:

Created on 2016-08-20 16:50 by Andreas Bolsch, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg273224 - (view) Author: Andreas Bolsch (Andreas Bolsch) Date: 2016-08-20 16:50
Applies to 2.7.10 and 2.7.12:

Installed LinuxCNC from source at https://github.com/LinuxCNC/linuxcnc :
./configure --with-realtime=uspace --enable-simulator --enable-non-distributable=yes --prefix=/usr --libdir=/usr/lib64
make
make install

Configured device as per attached files, that's a simulated XYZ-mill.

Now start application with: 
linuxcnc linuxcnc/configs/my-mill/my-mill.ini

The "Manual Control Widget" has a radio button denoted "X", "Y", "Z" with values "x", "y" and "z" to select the active axis. "X" and "Z" work as desired, but "Y" does not. Instead:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib64/python2.7/lib-tk/Tkinter.py", line 1537, in __call__
    return self.func(*args)
  File "/usr/bin/axis", line 2323, in jog_plus
    a = "xyzabcuvw".index(a)
ValueError: substring not found

Reason: The Tcl button variable "current_axis" gets "y" assigned to as desired. The corresponding python variable "a" however, gets "True". I've tracked that down to "FromObj" in "_tkinter.c" where "value->typePtr" equals "app->OldBooleanType". 

In 2.7.8 and 2.7.9 the behavior is ok, but in 2.7.10 and 2.7.12 button value "y" (and of course "yes", "no" etc.) is transformed into boolean a value ...    

This change of behaviour depends only on _tkinter.so, exchanging just *this single* file makes the problem (dis-) appear.
msg273230 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-08-20 17:27
Any chance you could provide a simple reproducer?  We'll need something for a unit test.
msg273308 - (view) Author: Andreas Bolsch (Andreas Bolsch) Date: 2016-08-21 17:14
I'm afraid I don't know Tcl nor python good enough to be able to strip this down to a reasonably simple test case.

However, I wonder what's going on there:

When the Tcl variable holding the radiobutton's value contains "x", "z", ..., value->typePtr always equals NULL in "FromObj" (both 2.7.8 and 2.7.12). But if the variable contains "y", "yes" etc., value->typePtr always equals app->OldBooleanType (again 2.7.8 and 2.7.12). And tcl8.6 has only one boolean type according to tclInt.h???

Now 2.7.8 doesn't handle that OldBooleanType in FromObj in any special way, whereas 2.7.12 does.

BTW: Setting Tkinter.wantobjects = 0 cures the problem but that's certainly not a sensible approach.
msg415932 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-03-24 09:59
This problem was reported for 2.7 without a manageable reproducer. I suggest we close it because it's unlikely that anyone will want to investigate this now unless it's reported again for a supported python version.
History
Date User Action Args
2022-04-11 14:58:35adminsetgithub: 72004
2022-04-02 12:43:00iritkatrielsetstatus: pending -> closed
stage: test needed -> resolved
2022-03-24 09:59:46iritkatrielsetstatus: open -> pending

nosy: + iritkatriel
messages: + msg415932

resolution: out of date
2016-08-21 17:14:36Andreas Bolschsetmessages: + msg273308
2016-08-20 17:50:42serhiy.storchakasetnosy: + serhiy.storchaka

stage: test needed
2016-08-20 17:27:05r.david.murraysetnosy: + r.david.murray

messages: + msg273230
title: String variable misinterpreted as boolean -> tkinter string variable misinterpreted as boolean
2016-08-20 16:50:27Andreas Bolschcreate