[New-bugs-announce] [issue35098] Deleting __new__ does not restore previous behavior

Joy Diamond report at bugs.python.org
Sun Oct 28 20:16:25 EDT 2018


New submission from Joy Diamond <python.gem at gmail.com>:

Related: https://bugs.python.org/issue5322

Consider the following program:

class Color(object):
    __slots__ = (('name',))

    def __init__(self, name):
        self.name = name

green = Color('green')  #   Works
assert green.name == 'green'

Color.__new__ = 0
del Color.__new__

red = Color('red')      #   Fails in Python 3; works in Python 2 & pypy
assert red.name == 'red'

This works in Python 2, pypy, but fails in Python 3 as follows:

Traceback (most recent call last):
  File "x.py", line 13, in <module>
    red = Color('red')      #   Fails in Python 3; works in Python 2 & pypy
TypeError: object() takes no parameters

----------
messages: 328773
nosy: joydiamond
priority: normal
severity: normal
status: open
title: Deleting __new__ does not restore previous behavior
versions: Python 3.5, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35098>
_______________________________________


More information about the New-bugs-announce mailing list