Comment 2 for bug 1435617

Revision history for this message
david@drmaciver.com (6-david-h) wrote :

The following demonstrates the source of the problem:

from __future__ import print_function

class TestList(list):

    def __iter__(self):
        yield 1
        yield 2
        yield 3

if __name__ == '__main__':
    x = TestList()

    x.extend([4, 5, 6])
    print(repr(tuple(x)))
    print(repr(list(x)))

Basically it looks like in CPython there's a special case for calling tuple on a list which bypasses all the normal methods.