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.

Author uosiu
Recipients uosiu
Date 2015-11-25.12:29:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1448454590.41.0.350843358205.issue25731@psf.upfronthosting.co.za>
In-reply-to
Content
When moving from python 2.7 to 3.5 I have found a problem with patching __new__ method on the class. It was done this way:
'''
patch('foo.bar.MyClass.__new__', return_value=mocked_instance)
'''
In works with python 2.7, but in 3.5 it fails with:
'''
TypeError: object() takes no parameters
'''

I have created minimal scenario that ilustrates this bug cause:
'''
class X:
    def __init__(self, a):
        pass


def new(cls, a):
    pass


X(1)
X.__new__ = new
X(1)
del X.__new__
X(1)
'''
Setting __new__ attribute and then deleting it has some side effect.
History
Date User Action Args
2015-11-25 12:29:50uosiusetrecipients: + uosiu
2015-11-25 12:29:50uosiusetmessageid: <1448454590.41.0.350843358205.issue25731@psf.upfronthosting.co.za>
2015-11-25 12:29:50uosiulinkissue25731 messages
2015-11-25 12:29:49uosiucreate