[issue8847] crash appending list and namedtuple
Terry J. Reedy
report at bugs.python.org
Sat Jun 5 00:51:31 CEST 2010
Terry J. Reedy <tjreedy at udel.edu> added the comment:
More experiments
from collections import namedtuple
foo = namedtuple('foo', '')
a = [] + foo()
print (a, type(a), len(a))
# () <class 'tuple'> 0
ie, a standard empty tuple, whereas
a = [1,1] + foo()
crashes immediately. So the behavior of list()+namedtuple depends on the length of the list.
There are also some funny interactions. Adding
try:
a = foo()+[]
except TypeError:
print("correct TypeError")
after the 'foo = ' line in my original 5 line example causes the final print to crash, whereas adding the same 4 lines to the 4 line example at the beginning of this message does not obviously change anything.
David, since you omitted all details, I wonder if you tested in batch mode, as I did, and hence never tried to print the malformed object, or used different OS or hardware.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8847>
_______________________________________
More information about the Python-bugs-list
mailing list