New submission from Barney Stratford <barney_stratf...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue35162>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to