Skip to content

Commit

Permalink
hopefully fix it once and for all
Browse files Browse the repository at this point in the history
  • Loading branch information
BYK committed Sep 19, 2024
1 parent b9b1a48 commit e211b11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 0 additions & 1 deletion sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,6 @@ def _apply_breadcrumbs_to_event(self, event, hint, options):

event["breadcrumbs"]["values"].sort(key=lambda crumb: crumb["timestamp"])
except Exception as err:
print(err)
logger.warning("Error when sorting breadcrumbs", exc_info=err)
pass

Expand Down
11 changes: 8 additions & 3 deletions sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,20 @@ def datetime_from_isoformat(value):
# type: (str) -> datetime
try:
return datetime.fromisoformat(value)
except AttributeError:
except (AttributeError, ValueError):
# py 3.6
timestamp_format = (
"%Y-%m-%dT%H:%M:%S.%f" if "." in value else "%Y-%m-%dT%H:%M:%S"
)
if value.endswith("Z"):
value = value[:-1]
elif "+" in value:
timestamp_format += "%z"
else:
plus_idx = value.rfind("+")
if plus_idx != -1:
tz_colon_index = value.rfind(":", plus_idx)
if tz_colon_index != -1:
value = value[:tz_colon_index] + value[tz_colon_index + 1 :]
timestamp_format += "%z"

return datetime.strptime(value, timestamp_format)

Expand Down

0 comments on commit e211b11

Please sign in to comment.