-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Closed as not planned
Description
The problem
I've a python script executed every hour from an automation and sometimes (I think it depends on the nested if it goes based on input parameters) it fails with:
Error executing script. Unexpected error for call_service at pos 1: AST constructor recursion depth mismatch (before=33, after=52)
Attached the script.
What version of Home Assistant Core has the issue?
core-2023.6.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Python Scripts
Link to integration documentation on our website
https://www.home-assistant.io/integrations/python_script/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
2023-06-27 13:00:01.422 ERROR (MainThread) [homeassistant.components.automation.aggiorna_previsioni_meteo] Aggiorna Previsioni Meteo: Error executing script. Unexpected error for call_service at pos 1: AST constructor recursion depth mismatch (before=33, after=52)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 452, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 688, in _async_call_service_step
await self._async_run_long_action(service_task)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 649, in _async_run_long_action
long_task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1910, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1956, in _execute_service
await self._hass.async_add_executor_job(
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 112, in python_script_service_handler
execute_script(hass, call.service, call.data)
File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 146, in execute_script
execute(hass, filename, source, data)
File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 153, in execute
compiled = compile_restricted_exec(source, filename=filename)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/RestrictedPython/compile.py", line 87, in compile_restricted_exec
return _compile_restricted_mode(
^^^^^^^^^^^^^^^^^^^^^^^^^
6BD2
File "/usr/local/lib/python3.11/site-packages/RestrictedPython/compile.py", line 52, in _compile_restricted_mode
c_ast = ast.parse(source, filename, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/ast.py", line 50, in parse
return compile(source, filename, mode, flags,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SystemError: AST constructor recursion depth mismatch (before=33, after=52)
2023-06-27 13:00:01.441 ERROR (MainThread) [homeassistant.components.automation.aggiorna_previsioni_meteo] While executing automation automation.aggiorna_previsioni_meteo
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 559, in async_trigger
await self.action_script.async_run(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1533, in async_run
await asyncio.shield(run.async_run())
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 410, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 454, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 477, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 452, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 688, in _async_call_service_step
await self._async_run_long_action(service_task)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 649, in _async_run_long_action
long_task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1910, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1956, in _execute_service
await self._hass.async_add_executor_job(
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 112, in python_script_service_handler
execute_script(hass, call.service, call.data)
File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 146, in execute_script
execute(hass, filename, source, data)
File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 153, in execute
compiled = compile_restricted_exec(source, filename=filename)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/RestrictedPython/compile.py", line 87, in compile_restricted_exec
return _compile_restricted_mode(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/RestrictedPython/compile.py", line 52, in _compile_restricted_mode
c_ast = ast.parse(source, filename, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/ast.py", line 50, in parse
return compile(source, filename, mode, flags,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SystemError: AST constructor recursion depth mismatch (before=33, after=52)
Additional information
No response
Nightenom and majkers