[issue11698] Improve repr for structseq objects to show named, but unindexed fields

Sunny K report at bugs.python.org
Thu Nov 7 13:45:28 CET 2013


Sunny K added the comment:

The previous patch had a wrong mapping between keys and values. The 
current implementation of repr means that duplicated keys will be
present when invisible fields are included. See points 2 and 3 in
http://bugs.python.org/issue1820#msg202330 for more explanation.

I have sidestepped that issue by placing invisible fields under the dict argument. This also plays well with the current code in 
structseq_new and eval(repr(obj)) works.

The output with the patch is:

$./python -c "import os; print(os.stat('LICENSE'))"
os.stat_result(st_mode=33188, st_ino=577299, st_dev=64512, st_nlink=1, st_uid=33616, st_gid=600, st_size=12749, st_atime=1382696747, 
st_mtime=1382361968, st_ctime=1382361968,
dict={'st_atime':1382696747.0, 'st_mtime':1382361968.0,
'st_ctime':1382361968.0, 'st_atime_ns':1382696747000000000, 
'st_mtime_ns':1382361968000000000, 'st_ctime_ns':1382361968000000000, 
'st_blksize':4096, 'st_blocks':32, 'st_rdev':0})

----------
Added file: http://bugs.python.org/file32527/structseq_2.patch

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


More information about the Python-bugs-list mailing list