This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: frozen?set operations create incorrectly initialized instances of subclasses
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.0, Python 2.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: alexhsamuel, amaury.forgeotdarc, mark.dickinson, theller
Priority: normal Keywords:

Created on 2008-11-19 17:41 by alexhsamuel, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fs.py alexhsamuel, 2008-11-19 17:41 code sample
Messages (4)
msg76062 - (view) Author: Alex Samuel (alexhsamuel) Date: 2008-11-19 17:41
Methods of set and frozenset that return new set or frozenset instances
return instances of subclasses, but these instances are not initialized
correctly.  In the attached code sample, z is an instance of MySet but
MySet.__new__ and MySet.__init__ are never called on it.  

It seems to me that such a method should return a fully-initialized
instance of the subclass.  Barring that, it should just return a set or
frozenset instance, not an instance of the subclass.
msg76063 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2008-11-19 18:05
The bug is that the set operations return instances of the subclass,
rather than instances of set.

This is already fixed for 3.0: see issue 1721812.  It was deemed too risky 
to backport the change to 2.x.
msg76064 - (view) Author: Alex Samuel (alexhsamuel) Date: 2008-11-19 18:32
In the sample code I attached, z is an instance of MySet under 3.0rc2.  Is 
that expected?

Thanks,
Alex

Mark Dickinson wrote:
> Mark Dickinson <dickinsm@gmail.com> added the comment:
> 
> The bug is that the set operations return instances of the subclass,
> rather than instances of set.
> 
> This is already fixed for 3.0: see issue 1721812.  It was deemed too risky 
> to backport the change to 2.x.
> 
> ----------
> assignee: theller -> 
> components: +Interpreter Core -ctypes
> nosy: +marketdickinson
> resolution:  -> duplicate
> status: open -> closed
> 
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue4357>
> _______________________________________
msg76068 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-11-19 18:35
Well, this was changed only three days ago.
Please wait for the next 3.0rc3...
History
Date User Action Args
2022-04-11 14:56:41adminsetgithub: 48607
2008-11-19 18:35:45amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg76068
2008-11-19 18:32:42alexhsamuelsetmessages: + msg76064
2008-11-19 18:05:47mark.dickinsonsetstatus: open -> closed
nosy: + mark.dickinson
messages: + msg76063
assignee: theller ->
components: + Interpreter Core, - ctypes
resolution: duplicate
2008-11-19 17:41:28alexhsamuelcreate