@@ -477,6 +477,8 @@ cdef inline void __async_prepare_args_kwargs_callback(
477
477
for value, (key, _) in zip (result, future_args_kwargs):
478
478
args[key] = value
479
479
except Exception as exception:
480
+ exception.__traceback__.tb_frame.f_locals.clear()
481
+ exception.__traceback__.tb_frame.f_locals.update(locals ())
480
482
future_result.set_exception(exception)
481
483
else :
482
484
future_result.set_result(args)
@@ -525,6 +527,8 @@ cdef inline void __async_inject_attributes_callback(object future_result, object
525
527
for name, value in attributes.items():
526
528
setattr (instance, name, value)
527
529
except Exception as exception:
530
+ exception.__traceback__.tb_frame.f_locals.clear()
531
+ exception.__traceback__.tb_frame.f_locals.update(locals ())
528
532
future_result.set_exception(exception)
529
533
else :
530
534
future_result.set_result(instance)
@@ -575,15 +579,20 @@ cdef inline object __call(
575
579
asyncio.ensure_future(args_kwargs_ready)
576
580
577
581
return future_result
578
-
579
- return call(* args, ** kwargs)
580
-
582
+ try :
583
+ return call(* args, ** kwargs)
584
+ except Exception as exception:
585
+ exception.__traceback__.tb_frame.f_locals.clear()
586
+ exception.__traceback__.tb_frame.f_locals.update(locals ())
587
+ raise exception
581
588
582
589
cdef inline void __async_call_callback(object future_result, object call, object future):
583
590
try :
584
591
args, kwargs = future.result()
585
592
result = call(* args, ** kwargs)
586
593
except Exception as exception:
594
+ exception.__traceback__.tb_frame.f_locals.clear()
595
+ exception.__traceback__.tb_frame.f_locals.update(locals ())
587
596
future_result.set_exception(exception)
588
597
else :
589
598
if __is_future_or_coroutine(result):
@@ -597,6 +606,8 @@ cdef inline object __async_result_callback(object future_result, object future):
597
606
try :
598
607
result = future.result()
599
608
except Exception as exception:
609
+ exception.__traceback__.tb_frame.f_locals.clear()
610
+ exception.__traceback__.tb_frame.f_locals.update(locals ())
600
611
future_result.set_exception(exception)
601
612
else :
602
613
future_result.set_result(result)
0 commit comments