Skip to content

Commit

Permalink
fix: Handle exc_info=0 (#905)
Browse files Browse the repository at this point in the history
Co-authored-by: sentry-bot <markus+ghbot@sentry.io>
  • Loading branch information
untitaker and sentry-bot authored Nov 2, 2020
1 parent e6bd271 commit 37ab650
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion sentry_sdk/integrations/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ def _emit(self, record):
client_options = hub.client.options

# exc_info might be None or (None, None, None)
if record.exc_info is not None and record.exc_info[0] is not None:
#
# exc_info may also be any falsy value due to Python stdlib being
# liberal with what it receives and Celery's billiard being "liberal"
# with what it sends. See
# https://github.com/getsentry/sentry-python/issues/904
if record.exc_info and record.exc_info[0] is not None:
event, hint = event_from_exception(
record.exc_info,
client_options=client_options,
Expand Down
7 changes: 5 additions & 2 deletions tests/integrations/logging/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ def test_logging_works_with_many_loggers(sentry_init, capture_events, logger):


@pytest.mark.parametrize("integrations", [None, [], [LoggingIntegration()]])
def test_logging_defaults(integrations, sentry_init, capture_events):
@pytest.mark.parametrize(
"kwargs", [{"exc_info": None}, {}, {"exc_info": 0}, {"exc_info": False}]
)
def test_logging_defaults(integrations, sentry_init, capture_events, kwargs):
sentry_init(integrations=integrations)
events = capture_events()

logger.info("bread")
logger.critical("LOL")
logger.critical("LOL", **kwargs)
(event,) = events

assert event["level"] == "fatal"
Expand Down

0 comments on commit 37ab650

Please sign in to comment.