@@ -35,24 +35,16 @@ def _proxy_span_arguments(args: List, kwargs: Dict) -> Tuple[List, Dict]:
35
35
36
36
37
37
def _call_on_real_instance (
38
- operand_stub : dd_trace_api ._Stub ,
39
- method_name : str ,
40
- retval_from_api : Optional [Any ],
41
- state_shared_with_api : Dict ,
42
- * args : List ,
43
- ** kwargs : Dict
38
+ operand_stub : dd_trace_api ._Stub , method_name : str , retval_from_api : Optional [Any ], * args : List , ** kwargs : Dict
44
39
) -> None :
45
40
"""
46
41
Call `method_name` on the real object corresponding to `operand_stub` with `args` and `kwargs` as arguments.
47
- Pass the return value back to the API layer via the mutable `state_shared_with_api`.
48
42
49
43
Store the value that will be returned from the API call we're in the middle of, for the purpose
50
44
of mapping from those Stub objects to their real counterparts.
51
45
"""
52
46
args , kwargs = _proxy_span_arguments (args , kwargs )
53
47
retval_from_impl = getattr (_STUB_TO_REAL [operand_stub ], method_name )(* args , ** kwargs )
54
- if "impl_return_value" in state_shared_with_api :
55
- state_shared_with_api ["impl_return_value" ] = retval_from_impl
56
48
if retval_from_api is not None :
57
49
_STUB_TO_REAL [retval_from_api ] = retval_from_impl
58
50
@@ -62,14 +54,10 @@ def _hook(name, hook_args):
62
54
if not dd_trace_api .__datadog_patch or not name .startswith (_DD_HOOK_PREFIX ):
63
55
return
64
56
args = hook_args [0 ][0 ]
65
- state_shared_with_api = args [0 ]
57
+ stub_self = args [0 ]
58
+ api_return_value = args [1 ]
66
59
_call_on_real_instance (
67
- state_shared_with_api .get ("stub_self" ),
68
- name .replace (_DD_HOOK_PREFIX , "" ).rsplit ("." , 1 )[- 1 ],
69
- state_shared_with_api .get ("api_return_value" ),
70
- state_shared_with_api ,
71
- * args [1 :],
72
- ** hook_args [0 ][1 ]
60
+ stub_self , name .replace (_DD_HOOK_PREFIX , "" ).rsplit ("." , 1 )[- 1 ], api_return_value , * args [2 :], ** hook_args [0 ][1 ]
73
61
)
74
62
75
63
0 commit comments