Merge "Fix has_registry_receivers when super.__new__ is object.__new__"
This commit is contained in:
commit
9cdfd12a47
neutron
@ -83,7 +83,12 @@ def has_registry_receivers(klass):
|
||||
def replacement_new(cls, *args, **kwargs):
|
||||
if new_inherited:
|
||||
# class didn't define __new__ so we need to call inherited __new__
|
||||
instance = super(klass, cls).__new__(cls, *args, **kwargs)
|
||||
super_new = super(klass, cls).__new__
|
||||
if super_new is object.__new__:
|
||||
# object.__new__ doesn't accept args nor kwargs
|
||||
instance = super_new(cls)
|
||||
else:
|
||||
instance = super_new(cls, *args, **kwargs)
|
||||
else:
|
||||
instance = orig_new(cls, *args, **kwargs)
|
||||
if getattr(instance, '_DECORATED_METHODS_SUBSCRIBED', False):
|
||||
|
@ -52,6 +52,13 @@ class AnotherObjectWithDecoratedCallback(ObjectWithDecoratedCallback,
|
||||
self.counter2 += 1
|
||||
|
||||
|
||||
@registry.has_registry_receivers
|
||||
class CallbackClassWithParameters(object):
|
||||
|
||||
def __init__(self, dummy):
|
||||
pass
|
||||
|
||||
|
||||
class CallBacksManagerTestCase(base.BaseTestCase):
|
||||
|
||||
def test_decorated_inst_method_receives(self):
|
||||
@ -81,3 +88,6 @@ class CallBacksManagerTestCase(base.BaseTestCase):
|
||||
|
||||
def test_new_inheritance_not_broken(self):
|
||||
self.assertTrue(AnotherObjectWithDecoratedCallback().new_called)
|
||||
|
||||
def test_object_new_not_broken(self):
|
||||
CallbackClassWithParameters('dummy')
|
||||
|
Loading…
x
Reference in New Issue
Block a user