Antoine Pitrou added the comment:

For some reasons I was able to reproduce under 64-bit Windows with the 3.3b1 
official build, but neither with my own VS9.0-compiled build, nor with the 3.2 
official build.

To reproduce:

>>> class T(tuple): pass
...
>>> t = T((1,2))
>>> [] + t
(1, 2)
>>> [3,] + t
# crash

I tried to use the debugging symbols but it doesn't help a lot. The primary 
issue seems to be that the concatenation doesn't raise TypeError, and instead 
constructs an invalid object which then makes PyObject_Repr() crash.

Also, it is not the Python compiler, the same thing happens with constructor 
calls:

>>> list() + T([1,2])
(1, 2)
>>> list((3,)) + T([1,2])
# crash

And no it doesn't happen with list subclasses:

>>> class L(list): pass
...
>>> class T(tuple): pass
...
>>> L([]) + T([1,2])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "T") to list
>>> [] + T([1,2])
(1, 2)

Also, directly calling the __add__ method doesn't trigger the issue, but 
operator.add does:

>>> l + T([1,2])
(1, 2)
>>> operator.add(list(), T([1,2]))
(1, 2)
>>> list().__add__(T([1,2]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "T") to list

----------
nosy: +brian.curtin, pitrou, tim.golden

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8847>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to