Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove the bogus default values of parameters in tkinter Misc.wait_variable(), setvar() and getvar() #152587

Description

@serhiy-storchaka

Misc.wait_variable(), Misc.setvar() and Misc.getvar() have default values for parameters that should be required: name='PY_VAR' (all three) and value='1' (setvar).

'PY_VAR' is not a meaningful variable name -- tkinter auto-generates names as PY_VAR0, PY_VAR1, etc., never the bare 'PY_VAR' -- so calling these methods without a name operates on a variable that almost never exists. Likewise, defaulting setvar's value to '1' is arbitrary.

These defaults were only recently documented (gh-86726) and should not be advertised. As a first step, undocument them (backported).

Then make the parameters required by dropping the defaults from wait_variable(name), getvar(name) and setvar(name, value) (the waitvar alias follows). This is a behavior change for 3.16 only; calls relying on the defaults will raise TypeError instead of silently operating on a useless variable. If this proves disruptive during the development period, it can be reverted.

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-tkintertype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions