From 4de3fa7b5773a81c2430a9f59bad31ab4dfc33da Mon Sep 17 00:00:00 2001 From: Gen Xu Date: Wed, 15 Sep 2021 02:24:24 -0700 Subject: [PATCH] Add locals to tb_frame on exception --- src/dependency_injector/providers.pxd | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dependency_injector/providers.pxd b/src/dependency_injector/providers.pxd index eeae838b..d1beb771 100644 --- a/src/dependency_injector/providers.pxd +++ b/src/dependency_injector/providers.pxd @@ -575,9 +575,12 @@ cdef inline object __call( asyncio.ensure_future(args_kwargs_ready) return future_result - - return call(*args, **kwargs) - + try: + return call(*args, **kwargs) + except Exception as e: + e.__traceback__.tb_frame.f_locals.clear() + e.__traceback__.tb_frame.f_locals.update(locals()) + raise e cdef inline void __async_call_callback(object future_result, object call, object future): try: