Fix "'NoneType' has no attribute start|stop" logcontext errors (#7181)

Fixes #7179.
This commit is contained in:
Richard van der Hoff 2020-03-31 15:18:41 +01:00 committed by GitHub
parent fe1580bfd9
commit 60adcbed91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 7 deletions

View file

@ -539,6 +539,11 @@ def set_current_context(context: LoggingContextOrSentinel) -> LoggingContextOrSe
Returns:
The context that was previously active
"""
# everything blows up if we allow current_context to be set to None, so sanity-check
# that now.
if context is None:
raise TypeError("'context' argument may not be None")
current = current_context()
if current is not context: