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.

Author terry.reedy
Recipients gpolo, klappnase, mark, roger.serwy, terry.reedy
Date 2012-06-24.19:25:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1340565936.28.0.303851844632.issue15133@psf.upfronthosting.co.za>
In-reply-to
Content
Mark: "Variable.get(self) returns self._tk.globalgetvar(self._name). String/Int/Double/Var call str/int/float as appropriate." was meant to say that String/Int/Double/Var.get(self) already call str/int/float on the result of self._tk.globalgetvar(self._name) before returning it. BooleanVar.get does not call bool, but instead calls self._tk.getboolean, which fails to always return a boolean.

Klappnase: I disagree, somehow. bool is a subclass of int, so that False, True are arithmetically indistinguishable from 0, 1. The main difference is on display and 'type(x) = int/bool' comparisons (which should be isinstance()). BooleanVar.get already returns False, True for the tcl boolean values '0', '1' set by tk rather than the user (which I expect should be the usual case for retrieval). So a Python/tkinter program has to be prepared to get proper booleans anyway. Since the purpose of Variables is to synchronize values between user code and tk, TypeVar().set(x).get() should be x when has the proper type. That is now true for everything but bool/Boolean.

I do wonder whether not converting or rejecting bad inputs to .set could cause problems with tk, but maybe some of that is handled later (and silently? if so bad) within _tkinter. I could be persuaded that a behavior fix should only be applied to 3.3.
History
Date User Action Args
2012-06-24 19:25:36terry.reedysetrecipients: + terry.reedy, klappnase, mark, gpolo, roger.serwy
2012-06-24 19:25:36terry.reedysetmessageid: <1340565936.28.0.303851844632.issue15133@psf.upfronthosting.co.za>
2012-06-24 19:25:35terry.reedylinkissue15133 messages
2012-06-24 19:25:34terry.reedycreate