Don't get code_context when calling inspect.stack (#48849)

* Don't get code_context when calling inspect.stack

* Update homeassistant/helpers/config_validation.py
This commit is contained in:
Erik Montnemery 2021-04-09 07:26:09 +02:00 committed by GitHub
parent 19e047e801
commit d1df6e6fba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View file

@ -711,7 +711,7 @@ def deprecated(
- No warning if neither key nor replacement_key are provided
- Adds replacement_key with default value in this case
"""
module = inspect.getmodule(inspect.stack()[1][0])
module = inspect.getmodule(inspect.stack(context=0)[1].frame)
if module is not None:
module_name = module.__name__
else:

View file

@ -59,7 +59,7 @@ def get_deprecated(
and a warning is issued to the user.
"""
if old_name in config:
module = inspect.getmodule(inspect.stack()[1][0])
module = inspect.getmodule(inspect.stack(context=0)[1].frame)
if module is not None:
module_name = module.__name__
else:

View file

@ -85,7 +85,7 @@ def async_activate_log_queue_handler(hass: HomeAssistant) -> None:
def log_exception(format_err: Callable[..., Any], *args: Any) -> None:
"""Log an exception with additional context."""
module = inspect.getmodule(inspect.stack()[1][0])
module = inspect.getmodule(inspect.stack(context=0)[1].frame)
if module is not None:
module_name = module.__name__
else: