GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-120220: Deprecate legacy methods for tracing variables in Tkinter by serhiy-storchaka · Pull Request #120223 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jun 7, 2024 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

They do not work with Tcl 9.0.
Use new methods added in Python 3.6.

  • Issue: Tkinter: emit deprecation warning for trace_variable() etc #120220

📚 Documentation preview 📚: https://cpython-previews--120223.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka
pythongh-120220: Deprecate legacy methods for tracing variables in Tk…
cd263e2
…inter

They do not work with Tcl 9.0.
Use new methods added in Python 3.6.
@bedevere-app bedevere-app Bot added the awaiting core review label Jun 7, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Jun 7, 2024
Tkinter: emit deprecation warning for trace_variable() etc #120220
Closed
serhiy-storchaka added 2 commits June 24, 2024 15:00
@serhiy-storchaka
Merge branch 'main' into deprecate-tkinter-trace-variable
5a75e86
@serhiy-storchaka
This is a part of Tcl, not Tk.
0917d8b
@serhiy-storchaka
serhiy-storchaka requested a review from terryjreedy June 24, 2024 15:58
@serhiy-storchaka

serhiy-storchaka commented Jun 24, 2024

Copy link
Copy Markdown
Member Author

@terryjreedy, could you please take a look? Are the warning messages OK?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka
Update docstrings.
4df88b7
terryjreedy
terryjreedy previously requested changes Jun 24, 2024
View reviewed changes

@terryjreedy terryjreedy left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wording seems good enough.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/tkinter/__init__.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/tkinter/__init__.py
"use trace_add() instead",
DeprecationWarning, stacklevel=2)
cbname = self._register(callback)
self._tk.call("trace", "variable", self._name, mode, cbname)

@terryjreedy terryjreedy Jun 24, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this line be wrapped in try...except TclError... for when run with tcl/tk 9?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Jun 24, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what to do after catching the exception?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@terryjreedy terryjreedy Jun 25, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raise a better error message -- IF the TclError message is unclear, such as not specifying that failure us 9.0 specific. I don't have 9.0 installed to test this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Jun 25, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message is "bad option "variable": must be add, info, or remove". It may be not so clear from Python's point of view, but you get a deprecation warning emitted immediately before error. I think that it is not worth to change the error. The error can also be raised for other reasons, so we would need to rely on parsing the error message, which can be changed in future.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@terryjreedy terryjreedy Jun 27, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about the case when people have DeprecationWarnings turned off. A possibility would be, when running tk9+, to immediately raise an error with more direct message 'This method does not exist in tk9, use...' right in trace_xyz itself.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Jun 28, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you suggest to write something like this?

        try:
            self._tk.call("trace", "variable", self._name, mode, cbname)
        except _tkinter.TclError as err:
            if str(err) == 'bad option "variable": must be add, info, or remove':
                raise TypeError('trace_variable() is not supported '
                                'with Tcl 9; use trace_add() instead')
            raise

This is too verbose and fragile. If they change the error message it will not work.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@TeamSpen210 TeamSpen210 Apr 11, 2025

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this could use an exception note, that way it won't change the type. Just needs the message to be clear another error may have occurred.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting changes and removed awaiting core review labels Jun 24, 2024
@bedevere-app

bedevere-app Bot commented Jun 24, 2024

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka added 3 commits June 24, 2024 23:04
@serhiy-storchaka
Update warning messages.
5dd8f3a
@serhiy-storchaka
Merge branch 'main' into deprecate-tkinter-trace-variable
3cba3b7
@serhiy-storchaka
Merge branch 'main' into deprecate-tkinter-trace-variable
887f01c
@serhiy-storchaka

serhiy-storchaka commented Apr 9, 2025

Copy link
Copy Markdown
Member Author

@terryjreedy, are you insisting on wrapping TclError? I don't like this, there is no precedence.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@terryjreedy
terryjreedy dismissed their stale review April 10, 2025 10:19

Comment was suggestion only.

@bedevere-app bedevere-app Bot added awaiting review and removed awaiting changes labels Apr 10, 2025
@terryjreedy

terryjreedy commented Apr 10, 2025

Copy link
Copy Markdown
Member

Whatever I said was meant to be suggestion. I dismissed change request. Merge when you want.

My personal priority for tkinter is to be able to have 9.0 available in a Windows installer. Let me know if I can do anything to help (other than the above).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka
serhiy-storchaka merged commit c46635a into python:main Apr 29, 2025
@bedevere-app bedevere-app Bot removed the awaiting review label Apr 29, 2025
@serhiy-storchaka
serhiy-storchaka deleted the deprecate-tkinter-trace-variable branch April 29, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@terryjreedy terryjreedy terryjreedy left review comments
+1 more reviewer
@TeamSpen210 TeamSpen210 TeamSpen210 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@serhiy-storchaka @terryjreedy @TeamSpen210
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.