v.set("value")
self.assertTrue(v.side_effect)
- def test_trace(self):
+ def test_trace_old(self):
+ # Old interface
- v = Var(self.root)
+ v = Variable(self.root)
vname = str(v)
trace = []
def read_tracer(*args):
gc.collect()
self.assertEqual(trace, [('write', vname, '', 'u')])
- v = Var(self.root)
+ def test_trace(self):
++ v = Variable(self.root)
+ vname = str(v)
+ trace = []
+ def read_tracer(*args):
+ trace.append(('read',) + args)
+ def write_tracer(*args):
+ trace.append(('write',) + args)
+ tr1 = v.trace_add('read', read_tracer)
+ tr2 = v.trace_add(['write', 'unset'], write_tracer)
+ self.assertEqual(sorted(v.trace_info()), [
+ (('read',), tr1),
+ (('write', 'unset'), tr2)])
+ self.assertEqual(trace, [])
+
+ v.set('spam')
+ self.assertEqual(trace, [('write', vname, '', 'write')])
+
+ trace = []
+ v.get()
+ self.assertEqual(trace, [('read', vname, '', 'read')])
+
+ trace = []
+ info = sorted(v.trace_info())
+ v.trace_remove('write', tr1) # Wrong mode
+ self.assertEqual(sorted(v.trace_info()), info)
+ with self.assertRaises(TclError):
+ v.trace_remove('read', 'spam') # Wrong command name
+ self.assertEqual(sorted(v.trace_info()), info)
+ v.get()
+ self.assertEqual(trace, [('read', vname, '', 'read')])
+
+ trace = []
+ v.trace_remove('read', tr1)
+ self.assertEqual(v.trace_info(), [(('write', 'unset'), tr2)])
+ v.get()
+ self.assertEqual(trace, [])
+
+ trace = []
+ del write_tracer
+ gc.collect()
+ v.set('eggs')
+ self.assertEqual(trace, [('write', vname, '', 'write')])
+
+ trace = []
+ del v
+ gc.collect()
+ self.assertEqual(trace, [('write', vname, '', 'unset')])
+
class TestStringVar(TestBase):
Library
-------
-- Issue #22115: Fixed tracing Tkinter variables: trace_vdelete() with wrong
- mode no longer break tracing, trace_vinfo() now always returns a list of
- pairs of strings, tracing in the "u" mode now works.
+- Issue #22115: Added methods trace_add, trace_remove and trace_info in the
+ tkinter.Variable class. They replace old methods trace_variable, trace,
+ trace_vdelete and trace_vinfo that use obsolete Tcl commands and might
- not work in future versions of Tcl.
++ not work in future versions of Tcl. Fixed old tracing methods:
++ trace_vdelete() with wrong mode no longer break tracing, trace_vinfo() now
++ always returns a list of pairs of strings, tracing in the "u" mode now works.
+
+- Issue #26243: Only the level argument to zlib.compress() is keyword argument
+ now. The first argument is positional-only.
-- Fix a scoping issue in importlib.util.LazyLoader which triggered an
- UnboundLocalError when lazy-loading a module that was already put into
- sys.modules.
+- Issue #27038: Expose the DirEntry type as os.DirEntry. Code patch by
+ Jelle Zijlstra.
+
+- Issue #27186: Update os.fspath()/PyOS_FSPath() to check the return value of
+ __fspath__() to be either str or bytes.
+
+- Issue #18726: All optional parameters of the dump(), dumps(),
+ load() and loads() functions and JSONEncoder and JSONDecoder class
+ constructors in the json module are now keyword-only.
+
+- Issue #27319: Methods selection_set(), selection_add(), selection_remove()
+ and selection_toggle() of ttk.TreeView now allow passing multiple items as
+ multiple arguments instead of passing them as a tuple. Deprecated
+ undocumented ability of calling the selection() method with arguments.
- Issue #27079: Fixed curses.ascii functions isblank(), iscntrl() and ispunct().