Message255337
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. |
|
Date |
User |
Action |
Args |
2015-11-25 12:29:50 | uosiu | set | recipients:
+ uosiu |
2015-11-25 12:29:50 | uosiu | set | messageid: <1448454590.41.0.350843358205.issue25731@psf.upfronthosting.co.za> |
2015-11-25 12:29:50 | uosiu | link | issue25731 messages |
2015-11-25 12:29:49 | uosiu | create | |
|