[issue11854] __or__ et al instantiate subclass of set without calling __init__

Santoso Wijaya report at bugs.python.org
Sat Apr 16 21:21:40 CEST 2011


Santoso Wijaya <santoso.wijaya at gmail.com> added the comment:

Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> class SetSub(set):
...     def __init__(self, *args, **kwargs):
...             print 'foo'
...             set.__init__(self, *args, **kwargs)
...
>>> a = SetSub([2,7])
foo
>>> b = set([1,7])
>>> a ^ b
SetSub([1, 2])


Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> class SetSub(set):
...     def __init__(self, *args, **kwargs):
...             print('foo')
...             set.__init__(self, *args, **kwargs)
...
>>> a = SetSub([2,7])
foo
>>> b = set([1,7])
>>> a ^ b
{1, 2}

----------
nosy: +santa4nt
versions: +Python 2.7, Python 3.1, Python 3.2, Python 3.3 -Python 2.6

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


More information about the Python-bugs-list mailing list