Skip to content

gh-126219: Fix crash in tkinter.Tk with non-BMP className on Tcl/Tk 8.x#151980

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:tkinter-className-nonbmp-crash
Open

gh-126219: Fix crash in tkinter.Tk with non-BMP className on Tcl/Tk 8.x#151980
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:tkinter-className-nonbmp-crash

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jun 23, 2026

Copy link
Copy Markdown
Member

tkinter.Tk(className='\U0010FFFF') (and the underlying _tkinter.create()) crashes with a segfault when tkinter is built against Tcl/Tk 8.x.

The class name is title-cased during Tk initialization, and Tcl 8.x crashes in Tcl_UtfToTitle() on non-BMP characters (encoded as 4-byte UTF-8 sequences). Such a className is now rejected with a ValueError before Tk is initialized.

Tcl 9 supports non-BMP characters and is not affected; the check is compiled out there.

Among the other string arguments of _tkinter.create(), only className is affected — screenName, baseName and use fail gracefully.

(The same Tcl 8.x bug also affects Tcl_UtfToUpper()/Tcl_UtfToLower(), reachable via e.g. tk.call('string', 'toupper', ...), but that is a general Tcl issue that cannot be guarded on the CPython side.)

🤖 Generated with Claude Code

@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 23, 2026
@serhiy-storchaka serhiy-storchaka force-pushed the tkinter-className-nonbmp-crash branch from f5c0917 to bf0f06a Compare June 23, 2026 11:29
…l/Tk 8.x

Tcl 8.x crashes when title-casing a non-BMP character during Tk
initialization, so such a className is now rejected with a ValueError.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka force-pushed the tkinter-className-nonbmp-crash branch from bf0f06a to 8088525 Compare June 23, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant