Repository navigation
fix(lm15): support targets (e.g. wasm) without ssl, fcntl, or home directory - #8
Merged
Merged
Conversation
…rectory
Push usage of these unsupported features out of module scope, and into the code
paths that need them, so that `import lm15` succeeds on CPython for wasm32-wasip2.
Each failure was a platform assumption made at module scope, where nothing can recover
from it:
- `_authlock` picked its locking primitive with `if os.name == "posix": import fcntl`. WASI
reports `posix` but does not ship `fcntl`.
- `auth` resolved three credential-path constants with `Path("~/...").expanduser()`, which
raises RuntimeError wherever no home directory can be determined.
- Both transports imported `ssl` at module scope, and componentize-py's embedded libpython
has no `_ssl`. TLS moves into `_ssl.py`, which imports `ssl` plainly because it cannot work
without it, and which nothing imports until a request names an https URL. That placement is
also what keeps its `except ssl.SSLError` clauses ordinary, an except clause being evaluated
whenever an exception passes it — plain-HTTP errors included.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
MaximeRivest
added a commit
that referenced
this pull request
Sep 15, 2026
…, with tests The no-fcntl/no-msvcrt branch raised UnsupportedFeatureError, a CapabilityError that speaks of a provider adapter; lm15-ts raises NotConfiguredError for the same host limitation, and that is what this is: a fact about the host's setup, with a way out (LM15_LOCK_DIR, or an explicit credential) the hint names. The lock directory also resolved ~/.cache with expanduser(), so on a host with no home directory a bare RuntimeError fired before the branch above was ever reached. Same error class, same hint, from there. Tests run each reduced target in a fresh interpreter: no ssl (import, plain HTTP, and the https refusal naming FetchTransport), no home directory, and no locking primitive. Changelog entry for #8. Signed-off-by: Maxime Rivest <mrive052@gmail.com>
MaximeRivest
added a commit
that referenced
this pull request
Sep 15, 2026
Signed-off-by: Maxime Rivest <mrive052@gmail.com>
Member
|
Merged, thanks — exactly the right shape (feature-detect the primitive, and pull Two follow-ups landed on top in b171d75:
Plus tests that run each reduced target in a fresh interpreter (no |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Push usage of these unsupported features out of module scope, and into the code paths that need them, so that
import lm15succeeds on CPython for wasm32-wasip2.Each failure was a platform assumption made at module scope, where nothing can recover from it:
_authlockpicked its locking primitive withif os.name == "posix": import fcntl. WASI reportsposixbut does not shipfcntl.authresolved three credential-path constants withPath("~/...").expanduser(), which raises RuntimeError wherever no home directory can be determined.Both transports imported
sslat module scope, and componentize-py's embedded libpython has no_ssl. TLS moves into_ssl.py, which importssslplainly because it cannot work without it, and which nothing imports until a request names an https URL. That placement is also what keeps itsexcept ssl.SSLErrorclauses ordinary, an except clause being evaluated whenever an exception passes it — plain-HTTP errors included.