Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Accessing a tkinter object's string representation converts the object to a string on Windows #101830

Closed
Assignees
serhiy-storchaka
@daniilS

Description

@daniilS

Introduced in#16545
Affects Python 3.7+ on Windows only


TheFromObj function in_tkinter.c attempt to convert aTcl_Obj to an equivalent Python object if possible, and otherwise returns a_tkinter.Tcl_Obj with thetypename attribute set to the original object's type.

However, on Windows, accessing the resulting object's string representationcallsTcl_GetUnicodeFromObj, which converts theTcl_Obj to aString. This side effect isn't mentioned in the Tcl documentation, but isin the Tcl source code. As a result, retrieving the same tk property afterwards will return a Python string instead.

Minimal example:

importtkinterastkroot=tk.Tk()print(type(root.cget("padx")))_=str(root.cget("padx"))# should really not cause any side effectsprint(type(root.cget("padx")))# Windows:# <class '_tkinter.Tcl_Obj'># <class 'str'># Other platforms:# <class '_tkinter.Tcl_Obj'># <class '_tkinter.Tcl_Obj'>

Possible solutions:unicodeFromTclObj should copy the object before passing callingTcl_GetUnicodeFromObj, or handle Unicode without it like on other platforms.

Linked PRs

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp