File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ def _prepare_event(
118118 with capture_internal_exceptions ():
119119 event ["threads" ] = [
120120 {
121- "stacktrace" : current_stacktrace (),
121+ "stacktrace" : current_stacktrace (self . options [ "with_locals" ] ),
122122 "crashed" : False ,
123123 "current" : True ,
124124 }
Original file line number Diff line number Diff line change @@ -158,12 +158,13 @@ def _emit(self, record):
158158 return
159159
160160 hint = None # type: Optional[Dict[str, Any]]
161+ client_options = hub .client .options
161162
162163 # exc_info might be None or (None, None, None)
163164 if record .exc_info is not None and record .exc_info [0 ] is not None :
164165 event , hint = event_from_exception (
165166 record .exc_info ,
166- client_options = hub . client . options ,
167+ client_options = client_options ,
167168 mechanism = {"type" : "logging" , "handled" : True },
168169 )
169170 elif record .exc_info and record .exc_info [0 ] is None :
@@ -172,7 +173,7 @@ def _emit(self, record):
172173 with capture_internal_exceptions ():
173174 event ["threads" ] = [
174175 {
175- "stacktrace" : current_stacktrace (),
176+ "stacktrace" : current_stacktrace (client_options [ "with_locals" ] ),
176177 "crashed" : False ,
177178 "current" : True ,
178179 }
Original file line number Diff line number Diff line change @@ -143,6 +143,26 @@ def bar():
143143 assert functions [- 2 :] == ["foo" , "bar" ]
144144
145145
146+ def test_attach_stacktrace_enabled_no_locals ():
147+ events = []
148+ hub = Hub (
149+ Client (attach_stacktrace = True , with_locals = False , transport = events .append )
150+ )
151+
152+ def foo ():
153+ bar ()
154+
155+ def bar ():
156+ hub .capture_message ("HI" )
157+
158+ foo ()
159+
160+ event , = events
161+ thread , = event ["threads" ]
162+ local_vars = [x .get ("vars" ) for x in thread ["stacktrace" ]["frames" ]]
163+ assert local_vars [- 2 :] == [None , None ]
164+
165+
146166def test_attach_stacktrace_disabled ():
147167 events = []
148168 hub = Hub (Client (attach_stacktrace = False , transport = events .append ))
You can’t perform that action at this time.
0 commit comments