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: frozenset, when subclassed will yield warning upon call to super(...).__init__(iterable)
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, carsten.klein@axn-software.de, eric.araujo, rhettinger, stutzbach
Priority: normal Keywords:

Created on 2010-08-22 14:42 by carsten.klein@axn-software.de, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (7)
msg114676 - (view) Author: Carsten Klein (carsten.klein@axn-software.de) Date: 2010-08-22 14:42
Example

class a(frozenset):
    def __init__(self, iterable):
        super(a, self).__init__(iterable)


i = a([1,2,3])
> __main__:3: DeprecationWarning: object.__init__() takes no parameters
> a([1, 2, 3])


This might be due to the fact that the frozenset type structure does not initialize the tp_init field in setobject.c, thus inheriting the original __init__ from object.

Subclassing set will not issue that warning as it actually defines the tp_init field to (initroc)set_init.

This holds true also for the Python 2.7 release and maybe also later releases.

Expected behaviour: do not output that warning message and provide an initproc for the tp_field.
msg114677 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-08-22 14:50
Thank you for the report. 2.6 is in security mode, it does not get bug fixes anymore. Can you reproduce the bug with 2.7, 3.1 and 3.2?
msg114678 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2010-08-22 15:26
I can reproduce it in Python 3.1 and 3.2  I don't have a build of Python 2.7 handy at the moment to test it there.

In Python 3.2 and 2.7, DeprecationWarnings are silenced by default.  I had to start Python 3.2 with "-W always::DeprecationWarning" to see the problem.
msg114680 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-08-22 15:34
This is correct. immutable types should use __new__, not __init__.
msg114683 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-08-22 17:28
Thanks Benjamin.  I concur with your conclusion.
msg114889 - (view) Author: Carsten Klein (carsten.klein@axn-software.de) Date: 2010-08-25 09:07
Thanks for the information. Where is this documented? I cannot find it in the official Python docs... TIA.
msg114904 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-08-25 13:34
2010/8/25 Carsten Klein <report@bugs.python.org>:
>
> Carsten Klein <carsten.klein@axn-software.de> added the comment:
>
> Thanks for the information. Where is this documented? I cannot find it in the official Python docs... TIA.

http://docs.python.org/dev/reference/datamodel.html#object.__new__
History
Date User Action Args
2022-04-11 14:57:05adminsetgithub: 53868
2010-08-25 13:34:29benjamin.petersonsetmessages: + msg114904
2010-08-25 09:07:43carsten.klein@axn-software.desetmessages: + msg114889
2010-08-22 17:28:23rhettingersetmessages: + msg114683
2010-08-22 15:34:30benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg114680

resolution: not a bug
2010-08-22 15:26:13stutzbachsetmessages: + msg114678
2010-08-22 14:50:34eric.araujosetnosy: + rhettinger, eric.araujo, stutzbach
messages: + msg114677
components: + Interpreter Core, - None
2010-08-22 14:42:19carsten.klein@axn-software.decreate