[Python-checkins] cpython (3.3): Issue #20067: Tkinter variables now work when wantobjects is false.

serhiy.storchaka python-checkins at python.org
Thu Dec 26 19:09:03 CET 2013


http://hg.python.org/cpython/rev/fbc1a39b68e4
changeset: 88197:fbc1a39b68e4
branch: 3.3
parent: 88193:e04fc45b7555
user: Serhiy Storchaka <storchaka at gmail.com>
date: Thu Dec 26 20:06:05 2013 +0200
summary:
 Issue #20067: Tkinter variables now work when wantobjects is false.
files:
 Lib/tkinter/__init__.py | 6 ++--
 Lib/tkinter/test/test_tkinter/test_variables.py | 15 ++++++----
 Misc/NEWS | 2 +
 3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -220,12 +220,12 @@
 _varnum += 1
 if value is not None:
 self.initialize(value)
- elif not self._tk.call("info", "exists", self._name):
+ elif not self._tk.getboolean(self._tk.call("info", "exists", self._name)):
 self.initialize(self._default)
 def __del__(self):
 """Unset the variable in Tcl."""
- if (self._tk is not None and self._tk.call("info", "exists",
- self._name)):
+ if (self._tk is not None and
+ self._tk.getboolean(self._tk.call("info", "exists", self._name))):
 self._tk.globalunsetvar(self._name)
 def __str__(self):
 """Return the name of the variable in Tcl."""
diff --git a/Lib/tkinter/test/test_tkinter/test_variables.py b/Lib/tkinter/test/test_tkinter/test_variables.py
--- a/Lib/tkinter/test/test_tkinter/test_variables.py
+++ b/Lib/tkinter/test/test_tkinter/test_variables.py
@@ -24,6 +24,9 @@
 
 class TestVariable(TestBase):
 
+ def info_exists(self, *args):
+ return self.root.getboolean(self.root.call("info", "exists", *args))
+
 def test_default(self):
 v = Variable(self.root)
 self.assertEqual("", v.get())
@@ -35,21 +38,21 @@
 self.assertEqual("varname", str(v))
 
 def test___del__(self):
- self.assertFalse(self.root.call("info", "exists", "varname"))
+ self.assertFalse(self.info_exists("varname"))
 v = Variable(self.root, "sample string", "varname")
- self.assertTrue(self.root.call("info", "exists", "varname"))
+ self.assertTrue(self.info_exists("varname"))
 del v
- self.assertFalse(self.root.call("info", "exists", "varname"))
+ self.assertFalse(self.info_exists("varname"))
 
 def test_dont_unset_not_existing(self):
- self.assertFalse(self.root.call("info", "exists", "varname"))
+ self.assertFalse(self.info_exists("varname"))
 v1 = Variable(self.root, name="name")
 v2 = Variable(self.root, name="name")
 del v1
- self.assertFalse(self.root.call("info", "exists", "name"))
+ self.assertFalse(self.info_exists("name"))
 # shouldn't raise exception
 del v2
- self.assertFalse(self.root.call("info", "exists", "name"))
+ self.assertFalse(self.info_exists("name"))
 
 def test___eq__(self):
 # values doesn't matter, only class and name are checked
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -29,6 +29,8 @@
 Library
 -------
 
+- Issue #20067: Tkinter variables now work when wantobjects is false.
+
 - Issue #19020: Tkinter now uses splitlist() instead of split() in configure
 methods.
 
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /