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(
118
118
with capture_internal_exceptions ():
119
119
event ["threads" ] = [
120
120
{
121
- "stacktrace" : current_stacktrace (),
121
+ "stacktrace" : current_stacktrace (self . options [ "with_locals" ] ),
122
122
"crashed" : False ,
123
123
"current" : True ,
124
124
}
Original file line number Diff line number Diff line change @@ -158,12 +158,13 @@ def _emit(self, record):
158
158
return
159
159
160
160
hint = None # type: Optional[Dict[str, Any]]
161
+ client_options = hub .client .options
161
162
162
163
# exc_info might be None or (None, None, None)
163
164
if record .exc_info is not None and record .exc_info [0 ] is not None :
164
165
event , hint = event_from_exception (
165
166
record .exc_info ,
166
- client_options = hub . client . options ,
167
+ client_options = client_options ,
167
168
mechanism = {"type" : "logging" , "handled" : True },
168
169
)
169
170
elif record .exc_info and record .exc_info [0 ] is None :
@@ -172,7 +173,7 @@ def _emit(self, record):
172
173
with capture_internal_exceptions ():
173
174
event ["threads" ] = [
174
175
{
175
- "stacktrace" : current_stacktrace (),
176
+ "stacktrace" : current_stacktrace (client_options [ "with_locals" ] ),
176
177
"crashed" : False ,
177
178
"current" : True ,
178
179
}
Original file line number Diff line number Diff line change @@ -143,6 +143,26 @@ def bar():
143
143
assert functions [- 2 :] == ["foo" , "bar" ]
144
144
145
145
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
+
146
166
def test_attach_stacktrace_disabled ():
147
167
events = []
148
168
hub = Hub (Client (attach_stacktrace = False , transport = events .append ))
You can’t perform that action at this time.
0 commit comments