Skip to content

Commit deeae2a

Browse files
gh-127802: Schedule removal of legacy tkinter variable trace methods in 3.17 (GH-152012)
The tkinter.Variable methods trace_variable(), trace(), trace_vdelete() and trace_vinfo(), deprecated since Python 3.14, are now scheduled for removal in Python 3.17. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent f991051 commit deeae2a

3 files changed

Lines changed: 28 additions & 9 deletions

File tree

Doc/deprecations/pending-removal-in-3.17.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,13 @@ Pending removal in Python 3.17
6868

6969
See :pep:`PEP 688 <688#current-options>` for more details.
7070
(Contributed by Shantanu Jain in :gh:`91896`.)
71+
72+
* :mod:`tkinter`:
73+
74+
- The :class:`!tkinter.Variable` methods :meth:`!trace_variable`,
75+
:meth:`!trace` (an alias of :meth:`!trace_variable`),
76+
:meth:`!trace_vdelete` and :meth:`!trace_vinfo`, deprecated since
77+
Python 3.14, are scheduled for removal in Python 3.17.
78+
Use :meth:`!trace_add`, :meth:`!trace_remove` and :meth:`!trace_info`
79+
instead.
80+
(Contributed by Serhiy Storchaka in :gh:`120220`.)

Lib/tkinter/__init__.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -505,12 +505,14 @@ def trace_variable(self, mode, callback):
505505
Return the name of the callback.
506506
507507
This deprecated method wraps a deprecated Tcl method removed
508-
in Tcl 9.0. Use trace_add() instead.
508+
in Tcl 9.0 and will be removed in Python 3.17. Use trace_add()
509+
instead.
509510
"""
510511
import warnings
511512
warnings.warn(
512-
"trace_variable() is deprecated and not supported with Tcl 9; "
513-
"use trace_add() instead.",
513+
"trace_variable() is deprecated and will be removed in Python "
514+
"3.17; use trace_add() instead. It is not supported with "
515+
"Tcl 9.",
514516
DeprecationWarning, stacklevel=2)
515517
cbname = self._register(callback)
516518
self._tk.call("trace", "variable", self._name, mode, cbname)
@@ -525,12 +527,14 @@ def trace_vdelete(self, mode, cbname):
525527
CBNAME is the name of the callback returned from trace_variable or trace.
526528
527529
This deprecated method wraps a deprecated Tcl method removed
528-
in Tcl 9.0. Use trace_remove() instead.
530+
in Tcl 9.0 and will be removed in Python 3.17. Use trace_remove()
531+
instead.
529532
"""
530533
import warnings
531534
warnings.warn(
532-
"trace_vdelete() is deprecated and not supported with Tcl 9; "
533-
"use trace_remove() instead.",
535+
"trace_vdelete() is deprecated and will be removed in Python "
536+
"3.17; use trace_remove() instead. It is not supported with "
537+
"Tcl 9.",
534538
DeprecationWarning, stacklevel=2)
535539
self._tk.call("trace", "vdelete", self._name, mode, cbname)
536540
cbname = self._tk.splitlist(cbname)[0]
@@ -548,12 +552,14 @@ def trace_vinfo(self):
548552
"""Return all trace callback information.
549553
550554
This deprecated method wraps a deprecated Tcl method removed
551-
in Tcl 9.0. Use trace_info() instead.
555+
in Tcl 9.0 and will be removed in Python 3.17. Use trace_info()
556+
instead.
552557
"""
553558
import warnings
554559
warnings.warn(
555-
"trace_vinfo() is deprecated and not supported with Tcl 9; "
556-
"use trace_info() instead.",
560+
"trace_vinfo() is deprecated and will be removed in Python "
561+
"3.17; use trace_info() instead. It is not supported with "
562+
"Tcl 9.",
557563
DeprecationWarning, stacklevel=2)
558564
return [self._tk.splitlist(x) for x in self._tk.splitlist(
559565
self._tk.call("trace", "vinfo", self._name))]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The deprecated :class:`tkinter.Variable` methods :meth:`!trace_variable`,
2+
:meth:`!trace`, :meth:`!trace_vdelete` and :meth:`!trace_vinfo` are now
3+
scheduled for removal in Python 3.17.

0 commit comments

Comments
 (0)