File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 1
1
import sys
2
+ import math
2
3
3
4
from datetime import datetime
4
5
@@ -273,7 +274,12 @@ def _serialize_node_impl(
273
274
return _flatten_annotated (result )
274
275
275
276
if obj is None or isinstance (obj , (bool , number_types )):
276
- return obj if not should_repr_strings else safe_repr (obj )
277
+ if should_repr_strings or (
278
+ isinstance (obj , float ) and (math .isinf (obj ) or math .isnan (obj ))
279
+ ):
280
+ return safe_repr (obj )
281
+ else :
282
+ return obj
277
283
278
284
elif isinstance (obj , datetime ):
279
285
return (
Original file line number Diff line number Diff line change 15
15
capture_exception ,
16
16
capture_event ,
17
17
start_transaction ,
18
+ set_tag ,
18
19
)
19
20
from sentry_sdk .integrations .executing import ExecutingIntegration
20
21
from sentry_sdk .transport import Transport
@@ -463,6 +464,10 @@ def test_nan(sentry_init, capture_events):
463
464
events = capture_events ()
464
465
465
466
try :
467
+ # should_repr_strings=False
468
+ set_tag ("mynan" , float ("nan" ))
469
+
470
+ # should_repr_strings=True
466
471
nan = float ("nan" ) # noqa
467
472
1 / 0
468
473
except Exception :
@@ -472,6 +477,7 @@ def test_nan(sentry_init, capture_events):
472
477
frames = event ["exception" ]["values" ][0 ]["stacktrace" ]["frames" ]
473
478
(frame ,) = frames
474
479
assert frame ["vars" ]["nan" ] == "nan"
480
+ assert event ["tags" ]["mynan" ] == "nan"
475
481
476
482
477
483
def test_cyclic_frame_vars (sentry_init , capture_events ):
You can’t perform that action at this time.
0 commit comments