[New-bugs-announce] [issue22214] Tkinter: Don't stringify callbacks arguments

Serhiy Storchaka report at bugs.python.org
Sun Aug 17 16:24:09 CEST 2014

New submission from Serhiy Storchaka:

Currently Tkinter supports two modes:

* When wantobjects=1 (default), all results of Tcl/Tk commands are converted to appropriate Python objects (int, float, str, bytes, tuple) if it is possible or to Tcl_Obj for unknown Tcl types.
* When wantobjects=0 (legacy mode), all results of Tcl/Tk commands are converted to strings.

But arguments of a callback are always converted to str, even when wantobjects=1. This can lost information ("42" is not distinguished from 42 or (42,)) and may be less efficient. Unfortunately we can't just change Tkinter to pass callback arguments as Python objects, this is backward incompatible change. Proposed patch introduces third mode wantobjects=2. It is the same as wantobjects=1, but callbacks now received . Default mode is still wantobjects=1, it can be changed in future. But in Tkinter applications (IDLE, Turtledemo, Pynche) we can use wantobjects=2 right now.

The only problem left is documenting it. The wantobjects parameter is not documented at all except an entry in "What's New in Python 2.3". Does anyone want to document this feature?

components: Tkinter
files: tkinter_obj_cmd.patch
keywords: patch
messages: 225446
nosy: gpolo, serhiy.storchaka, terry.reedy
priority: normal
severity: normal
stage: patch review
status: open
title: Tkinter: Don't stringify callbacks arguments
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file36393/tkinter_obj_cmd.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list