File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import sys
2+ import math
23
34from datetime import datetime
45
@@ -273,7 +274,12 @@ def _serialize_node_impl(
273274 return _flatten_annotated (result )
274275
275276 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
277283
278284 elif isinstance (obj , datetime ):
279285 return (
Original file line number Diff line number Diff line change 1515 capture_exception ,
1616 capture_event ,
1717 start_transaction ,
18+ set_tag ,
1819)
1920from sentry_sdk .integrations .executing import ExecutingIntegration
2021from sentry_sdk .transport import Transport
@@ -463,6 +464,10 @@ def test_nan(sentry_init, capture_events):
463464 events = capture_events ()
464465
465466 try :
467+ # should_repr_strings=False
468+ set_tag ("mynan" , float ("nan" ))
469+
470+ # should_repr_strings=True
466471 nan = float ("nan" ) # noqa
467472 1 / 0
468473 except Exception :
@@ -472,6 +477,7 @@ def test_nan(sentry_init, capture_events):
472477 frames = event ["exception" ]["values" ][0 ]["stacktrace" ]["frames" ]
473478 (frame ,) = frames
474479 assert frame ["vars" ]["nan" ] == "nan"
480+ assert event ["tags" ]["mynan" ] == "nan"
475481
476482
477483def test_cyclic_frame_vars (sentry_init , capture_events ):
You can’t perform that action at this time.
0 commit comments