[ python-Bugs-1721812 ] A subclass of set doesn't always have __init__ called.
SourceForge.net
noreply at sourceforge.net
Sat May 19 18:11:12 CEST 2007
Bugs item #1721812, was opened at 2007-05-19 14:03
Message generated for change (Comment added) made by gbrandl
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1721812&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: David Benbennick (dbenbenn)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: A subclass of set doesn't always have __init__ called.
Initial Comment:
Consider the following code:
>>> class foo(set):
... def __init__(self, iter):
... print "foo.__init__"
... set.__init__(self, iter)
...
>>> x = foo([1,2])
foo.__init__
>>> y = foo([2,3])
foo.__init__
>>> x & y
foo([2])
As you can see, the foo.__and__ method creates a new foo object without calling foo.__init__.
The problem is in Objects/setobject.c:make_new_set().
----------------------------------------------------------------------
>Comment By: Georg Brandl (gbrandl)
Date: 2007-05-19 16:11
Message:
Logged In: YES
user_id=849994
Originator: NO
Wasn't that fixed some time ago?
@OP: what Python version do you use?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1721812&group_id=5470
More information about the Python-bugs-list
mailing list