[New-bugs-announce] [issue35162] Inconsistent behaviour around __new__
Barney Stratford
report at bugs.python.org
Sun Nov 4 09:46:46 EST 2018
New submission from Barney Stratford <barney_stratford at fastmail.fm>:
>>> class Eggs (object):
... def __init__ (self, number):
... self.__number = number
... def __repr__ (self):
... return "{} eggs".format (self.__number)
...
>>> Eggs (4)
4 eggs
>>> del Eggs.__new__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: __new__
>>> # As expected
...
>>> Eggs (4)
4 eggs
>>> Eggs.__new__ = None
>>> del Eggs.__new__
>>> Eggs (4)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object() takes no parameters
>>> # Wrong! Eggs has no __new__, so this should respond as earlier
...
This bug seems to be because the slotdef isn't updated when __new__ is deleted.
----------
messages: 329231
nosy: Barney Stratford
priority: normal
severity: normal
status: open
title: Inconsistent behaviour around __new__
type: behavior
versions: Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35162>
_______________________________________
More information about the New-bugs-announce
mailing list