-
Notifications
You must be signed in to change notification settings - Fork 0
fix: work around asyncssh/fido2 AttributeError on Python 3.14 non-Windows #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,9 +12,28 @@ | |
|
|
||
| import logging | ||
| import socket | ||
| import sys | ||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
| # asyncssh optionally imports fido2.client.windows for Windows WebAuthn support. | ||
| # fido2's Windows-specific module (win_api) uses ctypes.HRESULT, which Python 3.14 | ||
| # removed on non-Windows platforms, causing an AttributeError that asyncssh does not | ||
| # catch (it only catches ImportError in that code path). Pre-attempt the import here | ||
| # so that on failure we can replace the broken sys.modules entry with None, which | ||
| # makes Python raise ImportError instead — and asyncssh handles that gracefully. | ||
| if sys.platform != "win32": | ||
| try: | ||
| import fido2.client.windows # noqa: F401 | ||
| except (ImportError, OSError, AttributeError) as _fido2_err: | ||
| _LOGGER.debug( | ||
| "fido2.client.windows unavailable (%s); asyncssh Windows WebAuthn support disabled", | ||
| _fido2_err, | ||
| ) | ||
| sys.modules["fido2.client.windows"] = None # type: ignore[assignment] | ||
|
Comment on lines
+27
to
+35
|
||
|
|
||
| from asyncssh import HostKeyNotVerifiable, KeyImportError, PermissionDenied, connect, read_known_hosts | ||
|
|
||
| from homeassistant.const import CONF_USERNAME, CONF_PASSWORD, CONF_HOST, CONF_COMMAND, CONF_TIMEOUT | ||
|
|
@@ -35,8 +54,6 @@ | |
| CONST_DEFAULT_TIMEOUT, | ||
| ) | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class SshCommandCoordinator: | ||
| """Single owner of all SSH I/O for the SSH Command integration. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# noqa: F401won’t silence pylint’sunused-importcheck (and the workflow doesn’t disableunused-import), so this line is likely to fail CI. Prefer a pylint suppression (# pylint: disable=unused-import) or avoid binding an unused name by usingimportlib.import_module("fido2.client.windows")instead of a plain import.