Fixed some protected functions not working
This commit is contained in:
parent
8c0582477e
commit
bb8041e0fd
@ -20,16 +20,16 @@ HOOKS = defaultdict(list)
|
|||||||
# Error handler decorators
|
# Error handler decorators
|
||||||
|
|
||||||
class handle_error:
|
class handle_error:
|
||||||
|
|
||||||
|
instance = None
|
||||||
|
owner = object
|
||||||
|
|
||||||
def __new__(cls, func):
|
def __new__(cls, func):
|
||||||
if isinstance(func, cls): # already decorated
|
if isinstance(func, cls): # already decorated
|
||||||
return func
|
return func
|
||||||
|
|
||||||
self = super().__new__(cls)
|
self = super().__new__(cls)
|
||||||
|
|
||||||
self.func = func
|
self.func = func
|
||||||
self.instance = None
|
|
||||||
self.owner = object
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __get__(self, instance, owner):
|
def __get__(self, instance, owner):
|
||||||
@ -39,7 +39,7 @@ class handle_error:
|
|||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
self.func.__get__(self.instance, self.owner)(*args, **kwargs)
|
return self.func.__get__(self.instance, self.owner)(*args, **kwargs)
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc() # no matter what, we want it to print
|
traceback.print_exc() # no matter what, we want it to print
|
||||||
if kwargs.get("cli"): # client
|
if kwargs.get("cli"): # client
|
||||||
|
Loading…
x
Reference in New Issue
Block a user