Skip to content

gh-153422: Return bool from some tkinter query methods#153429

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:tkinter-boolean-returns
Jul 9, 2026
Merged

gh-153422: Return bool from some tkinter query methods#153429
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:tkinter-boolean-returns

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 9, 2026

Copy link
Copy Markdown
Member

The winfo_exists(), winfo_ismapped() and winfo_viewable() methods of tkinter widgets and Text.edit_modified() now return a bool instead of an integer or, depending on wantobjects, a string.

These were the only boolean-valued query methods still returning int/raw; all the others (tk_busy_status(), winfo_isdark(), Text.compare(), edit_canundo()/edit_canredo(), the selection_present()/selection_includes() methods, the ttk Treeview predicates, etc.) already return a proper bool. The winfo_* methods have coerced the result to int since the initial revision of tkinter, predating the bool type.

Existing boolean-return tests that only checked truthiness (or compared to 0/1 with assertEqual) are tightened to pin the exact type with assertIs.

🤖 Generated with Claude Code

The winfo_exists(), winfo_ismapped() and winfo_viewable() methods of
tkinter widgets and Text.edit_modified() now return a bool instead of an
integer or, depending on wantobjects, a string.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33514621 | 📁 Comparing fc4d6aa against main (cd9994e)

  🔍 Preview build  

3 files changed
± library/tkinter.html
± library/tkinter.ttk.html
± whatsnew/changelog.html

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) July 9, 2026 14:09
@serhiy-storchaka serhiy-storchaka merged commit dd8739a into python:main Jul 9, 2026
53 checks passed
@bedevere-app

bedevere-app Bot commented Jul 9, 2026

Copy link
Copy Markdown

GH-153439 is a backport of this pull request to the 3.15 branch.

serhiy-storchaka added a commit that referenced this pull request Jul 9, 2026
GH-153439)

The tests for PhotoImage.transparency_get(), Text.debug() and
Treeview.exists() now assert the exact bool type, and the documentation
and docstrings use "true"/"false" instead of "1"/"0".

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jul 9, 2026
GH-153439) (GH-153442)

The tests for PhotoImage.transparency_get(), Text.debug() and
Treeview.exists() now assert the exact bool type, and the documentation
and docstrings use "true"/"false" instead of "1"/"0".
(cherry picked from commit 1604c80)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant