Message166907
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 |
|
Date |
User |
Action |
Args |
2012-07-30 15:54:32 | pitrou | set | recipients:
+ pitrou, loewis, rhettinger, terry.reedy, ishimoto, jackdied, tim.golden, eric.araujo, mrabarnett, r.david.murray, brian.curtin, benrg |
2012-07-30 15:54:31 | pitrou | set | messageid: <1343663671.84.0.602840871573.issue8847@psf.upfronthosting.co.za> |
2012-07-30 15:54:31 | pitrou | link | issue8847 messages |
2012-07-30 15:54:30 | pitrou | create | |
|