[New-bugs-announce] [issue19034] More useful repr for Tcl_Obj

Serhiy Storchaka report at bugs.python.org
Mon Sep 16 10:47:32 CEST 2013


New submission from Serhiy Storchaka:

Currently the repr() for Tcl_Obj is not very useful. It exposes only Tcl type name and Tcl object address.

>>> import tkinter.ttk
>>> tv = tkinter.ttk.Treeview()
>>> tv.tag_configure('test', foreground='blue')
{}
>>> str(tv.tag_configure('test', 'foreground'))
'blue'
>>> tv.tag_configure('test', 'foreground')
<color object at 0xb70f84b8>

You need explicitly call str to get more useful information. This is awkward when Tcl object hidden deeply in tuples or other data structure, or reported in a backtrace. Actually every Tcl object can be represented as a string. I propose to expose this representation in repr(). With proposed patch the output of the last command will be: <color object: 'blue'>.

----------
components: Tkinter
files: tkinter_repr.patch
keywords: patch
messages: 197881
nosy: gpolo, serhiy.storchaka, terry.reedy
priority: normal
severity: normal
stage: patch review
status: open
title: More useful repr for Tcl_Obj
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file31791/tkinter_repr.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19034>
_______________________________________


More information about the New-bugs-announce mailing list