Problem
Trio still fails to import on an Android CPython 3.13 runtime because socket.if_indextoname and socket.if_nametoindex are not available. The failure is:
ImportError: cannot import name 'if_indextoname' from 'socket'
The failing code is currently:
if sys.implementation.name == "cpython":
from socket import (
if_indextoname as if_indextoname,
if_nametoindex as if_nametoindex,
)
Context
This appears related to #2915 and PR #2916.
PR #2916 added ImportError suppression for if_nameindex, but the imports for if_indextoname and if_nametoindex remained unprotected, because they were believed to be available on Android. However, they are missing in the CPython Android runtime used by our application.
Environment:
- Python: 3.13
- Architecture: Android arm64
- Android min API: 24
- Android target API: 36
- Trio: 0.33.0 and 0.34.0
A downstream workaround is:
if sys.implementation.name == "cpython":
with suppress(ImportError):
from socket import (
if_indextoname as if_indextoname,
if_nametoindex as if_nametoindex,
)
Expected behavior
Trio should either:
- suppress these optional imports as well; or
- explicitly document and enforce the Android runtime/API requirements needed for these functions to exist.
Since the functions are not needed by our application or by the Trio server used for TCP communication, suppressing the import appears to be the most compatible behavior.
Problem
Trio still fails to import on an Android CPython 3.13 runtime because
socket.if_indextonameandsocket.if_nametoindexare not available. The failure is:The failing code is currently:
Context
This appears related to #2915 and PR #2916.
PR #2916 added
ImportErrorsuppression forif_nameindex, but the imports forif_indextonameandif_nametoindexremained unprotected, because they were believed to be available on Android. However, they are missing in the CPython Android runtime used by our application.Environment:
A downstream workaround is:
Expected behavior
Trio should either:
Since the functions are not needed by our application or by the Trio server used for TCP communication, suppressing the import appears to be the most compatible behavior.