Skip to content

Adding compatibility for Python 3.14#484

Closed
schluchc wants to merge 2 commits into
JoDehli:masterfrom
schluchc:master
Closed

Adding compatibility for Python 3.14#484
schluchc wants to merge 2 commits into
JoDehli:masterfrom
schluchc:master

Conversation

@schluchc

Copy link
Copy Markdown

When Python is upgraded from Python 3.12 to Pytohn 3.14 (not sure at what step exactly), it seems that some Python 2 syntax which was tolerated earlier is not supported anymore. Particularly, comma separated exceptions without parantheses:

except LoxoneConnectionError, LoxoneTokenError, LoxoneConnectionClosedOk:
which by now should be

except (
    LoxoneConnectionError,
    LoxoneTokenError,
    LoxoneConnectionClosedOk,
):

This merge request fixes those issues and creates compatibility to Python 3.14.

Specific failure HomeAssistant drops:

Setup failed for custom integration ‘loxone’: Unable to import component: Exception importing custom_components.loxone
 Traceback (most recent call last):
  File “/usr/src/homeassistant/homeassistant/loader.py”, line 1066, in _get_component
   ComponentProtocol, importlib.import_module(self.pkg_path)
             ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File “/usr/src/homeassistant/homeassistant/util/loop.py”, line 201, in protected_loop_func
   return func(*args, **kwargs)
  File “/usr/local/lib/python3.13/importlib/__init__.py”, line 88, in import_module
   return _bootstrap._gcd_import(name[level:], package, level)
       ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File “<frozen importlib._bootstrap>“, line 1387, in _gcd_import
  File “<frozen importlib._bootstrap>“, line 1360, in _find_and_load
  File “<frozen importlib._bootstrap>“, line 1331, in _find_and_load_unlocked
  File “<frozen importlib._bootstrap>“, line 935, in _load_unlocked
  File “<frozen importlib._bootstrap_external>“, line 1026, in exec_module
  File “<frozen importlib._bootstrap>“, line 488, in _call_with_frames_removed
  File “/config/custom_components/loxone/__init__.py”, line 38, in <module>
   from .coordinator import LoxoneCoordinator
  File “/config/custom_components/loxone/coordinator.py”, line 11, in <module>
   from .pyloxone_api.connection import LoxoneConnection, LoxoneException
  File “/config/custom_components/loxone/pyloxone_api/connection.py”, line 649
   except LoxoneConnectionError, LoxoneTokenError, LoxoneConnectionClosedOk:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 SyntaxError: multiple exception types must be parenthesized

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File “/usr/src/homeassistant/homeassistant/loader.py”, line 1006, in async_get_component
   comp = await self.hass.async_add_import_executor_job(
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     self._get_component, True
     ^^^^^^^^^^^^^^^^^^^^^^^^^
   )
   ^
  File “/usr/local/lib/python3.13/concurrent/futures/thread.py”, line 59, in run
   result = self.fn(*self.args, **self.kwargs)
  File “/usr/src/homeassistant/homeassistant/loader.py”, line 1077, in _get_component
   raise ImportError(f”Exception importing {self.pkg_path}“) from err
 ImportError: Exception importing custom_components.loxone

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File “/usr/src/homeassistant/homeassistant/loader.py”, line 1066, in _get_component
   ComponentProtocol, importlib.import_module(self.pkg_path)
             ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File “/usr/src/homeassistant/homeassistant/util/loop.py”, line 201, in protected_loop_func
   return func(*args, **kwargs)
  File “/usr/local/lib/python3.13/importlib/__init__.py”, line 88, in import_module
   return _bootstrap._gcd_import(name[level:], package, level)
       ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File “<frozen importlib._bootstrap>“, line 1387, in _gcd_import
  File “<frozen importlib._bootstrap>“, line 1360, in _find_and_load
  File “<frozen importlib._bootstrap>“, line 1331, in _find_and_load_unlocked
  File “<frozen importlib._bootstrap>“, line 935, in _load_unlocked
  File “<frozen importlib._bootstrap_external>“, line 1026, in exec_module
  File “<frozen importlib._bootstrap>“, line 488, in _call_with_frames_removed
  File “/config/custom_components/loxone/__init__.py”, line 38, in <module>
   from .coordinator import LoxoneCoordinator
  File “/config/custom_components/loxone/coordinator.py”, line 11, in <module>
   from .pyloxone_api.connection import LoxoneConnection, LoxoneException
  File “/config/custom_components/loxone/pyloxone_api/connection.py”, line 649
   except LoxoneConnectionError, LoxoneTokenError, LoxoneConnectionClosedOk:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 SyntaxError: multiple exception types must be parenthesized

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File “/usr/src/homeassistant/homeassistant/setup.py”, line 343, in _async_setup_component
   component = await integration.async_get_component()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File “/usr/src/homeassistant/homeassistant/loader.py”, line 1026, in async_get_component
   self._component_future.result()
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File “/usr/src/homeassistant/homeassistant/loader.py”, line 1018, in async_get_component
   comp = self._get_component()
  File “/usr/src/homeassistant/homeassistant/loader.py”, line 1077, in _get_component
   raise ImportError(f”Exception importing {self.pkg_path}“) from err
 ImportError: Exception importing custom_components.loxone

@schluchc

Copy link
Copy Markdown
Author

@JoDehli Awesome work btw! Just added my appreciation on buymeacoffee.com/JoDehli

@JoDehli

JoDehli commented May 19, 2026

Copy link
Copy Markdown
Owner

@schluchc thanks for your support. I use python 3.14 for development. I never got a error for the syntax. Are you sure it is not python3.15

@cschluchter-meteomatics

Copy link
Copy Markdown

@schluchc thanks for your support. I use python 3.14 for development. I never got a error for the syntax. Are you sure it is not python3.15

To be honest, I haven't understood why it stopped working. It was a power outage that caused an update on my HA which then caused this error. I'm running Python 3.14.2 in the container that runs HA.

@jmartasek

Copy link
Copy Markdown
Contributor

This seems like a bug introduced here: d8be321#diff-0f17abc8d5b9ce46fdcb6f936e90be32ab1332c3480765490ba503e7d73dfa28L19-L648

Not sure, however, how it has not failed sooner...

@JoDehli

JoDehli commented Jun 28, 2026

Copy link
Copy Markdown
Owner

should be fixed in the newest release.

@JoDehli JoDehli closed this Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants