New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
frozenset, when subclassed will yield warning upon call to super(...).__init__(iterable) #53868
Comments
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. |
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? |
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. |
This is correct. immutable types should use __new__, not __init__. |
Thanks Benjamin. I concur with your conclusion. |
Thanks for the information. Where is this documented? I cannot find it in the official Python docs... TIA. |
2010/8/25 Carsten Klein <report@bugs.python.org>:
http://docs.python.org/dev/reference/datamodel.html#object.\_\_new__ |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: