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

Skip to content

[3.13] gh-156961: Fix tkinter.font.Font for a font name returned as a Tcl object (GH-157028) - #157405

Merged
serhiy-storchaka merged 1 commit into
python:3.13from
serhiy-storchaka:backport-62cbd34-3.13
Sep 13, 2026
Merged

[3.13] gh-156961: Fix tkinter.font.Font for a font name returned as a Tcl object (GH-157028)#157405
serhiy-storchaka merged 1 commit into
python:3.13from
serhiy-storchaka:backport-62cbd34-3.13

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Manual backport of GH-157028: the cherry-pick does not apply, because this branch has no wrapped font descriptions (gh-143990), so Font.name is always a string here and __str__ needs a different fix. The test for wrapping a Tcl object as a font description is omitted for the same reason.

Tk can return a font name as a Tcl object rather than a string, for example from ttk.Style().lookup("TButton", "font"), Menu.entrycget("font"), ttk.Entry.cget("font"), or the default value in the result of configure(). Such an object does not compare equal to a string, so it was not recognized as the name of an existing named font, and the code from the issue failed with TclError: named font TkDefaultFont does not already exist.

The object is now kept as is, so that it is passed back to Tk, which reuses the font resource cached in it. It is only converted where it is compared with a string.

…d as a Tcl object (pythonGH-157028)

Tk can return a font name as a Tcl object, for example from
ttk.Style().lookup("TButton", "font"), Menu.entrycget("font"),
ttk.Entry.cget("font"), or the default value in the result of
configure().  Such an object does not compare equal to a string, so it
was not recognized as the name of an existing named font.  Keep it as
is, so that it is passed back to Tk, and only convert it where it is
compared with a string.

(cherry picked from commit 62cbd34)
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) September 13, 2026 08:12
@serhiy-storchaka
serhiy-storchaka merged commit 593fe91 into python:3.13 Sep 13, 2026
43 of 44 checks passed
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