Guard module being None (#25077)

This commit is contained in:
Paulus Schoutsen 2019-07-11 00:38:58 -07:00 committed by Pascal Vizeli
parent b8ee3536b3
commit 27d750db1c
2 changed files with 17 additions and 1 deletions

View file

@ -549,7 +549,13 @@ def deprecated(key: str,
- Once the invalidation_version is crossed, raises vol.Invalid if key
is detected
"""
module_name = inspect.getmodule(inspect.stack()[1][0]).__name__
module = inspect.getmodule(inspect.stack()[1][0])
if module is not None:
module_name = module.__name__
else:
# Unclear when it is None, but it happens, so let's guard.
# https://github.com/home-assistant/home-assistant/issues/24982
module_name = __name__
if replacement_key and invalidation_version:
warning = ("The '{key}' option (with value '{value}') is"