[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

Stefan Krah report at bugs.python.org
Sun Jun 29 23:13:18 CEST 2014


Stefan Krah added the comment:

Andrew, thanks for signing the agreement!


[Sunny]
> Is this what you expect?

I find the initialization in os.stat_result somewhat strange. Also,
a certain use of unnamed fields that worked in 2.5 is now broken,
which we should sort out before proceeding any further:


Apply structseq_repr_issue.diff, then:

>>> from _testcapi import mk_structseq
>>> s = mk_structseq("unnamed_end")
>>> s[3]
3
>>> tuple(s)
(0, 1, 2, 3, 4)
>>> s
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: In structseq_repr(), member 3 name is NULL for type _testcapi.struct_unnamed_end


Perhaps we should just add the missing field names, like namedtuple
does with rename=True:

(a=1, b=2, c=3, _4=4, _5=5)


In any case, in 2.5 the entire tuple was printed as the repr,
regardless of unnamed fields.

----------
title: Enhance Object/structseq.c to match namedtuple and tuple	api -> Enhance Object/structseq.c to match namedtuple and tuple api
Added file: http://bugs.python.org/file35802/structseq_repr_issue.diff

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


More information about the Python-bugs-list mailing list