mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Fix infinite recursion in LazyState (#48719)
If LazyState cannot parse the attributes of its row as JSON, it prints a message to the logger. Unfortunately, it passes `self` as a format argument to that message, which causes its `__repr__` method to be called, which then tries to retrieve `self.attributes` in order to display them. This leads to an infinite recursion and a crash of the entire core. To fix, send the database row to be printed in the log message, rather than the LazyState object that wraps around it.
This commit is contained in:
parent
42d2039560
commit
c4f9489d61
@ -715,7 +715,7 @@ class LazyState(State):
|
||||
self._attributes = json.loads(self._row.attributes)
|
||||
except ValueError:
|
||||
# When json.loads fails
|
||||
_LOGGER.exception("Error converting row to state: %s", self)
|
||||
_LOGGER.exception("Error converting row to state: %s", self._row)
|
||||
self._attributes = {}
|
||||
return self._attributes
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user