Issue 27817: tkinter string variable misinterpreted as boolean (original) (raw)
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.
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.