Skip to content

Bind ssl lazily after no_ssl so boto3 imports - #31

Merged
justanotherbyte merged 1 commit into
mainfrom
port/lazy-ssl-boto3
Oct 27, 2026
Merged

justanotherbyte merged 1 commit into
mainfrom
port/lazy-ssl-boto3

Conversation

@justanotherbyte

Copy link
Copy Markdown
Owner

Ports cloudflare/workers-py#292 (f3e7851).

no_ssl makes import ssl fail while urllib3.util.ssl_, requests.adapters and aiohttp.connector load, so they skip the ssl.create_default_context() entropy call. Their fallback code can leave the name ssl unbound. botocore does from urllib3.util.ssl_ import ssl, so import boto3 failed with ImportError: cannot import name 'ssl' from 'urllib3.util.ssl_'.

add_lazy_ssl_attribute runs after no_ssl and adds a module __getattr__ that imports ssl on first access. It keeps any __getattr__ the module already defines.

Testing

  • New e2e test test_boto3_import_at_top_level imports boto3 at top level under wynd dev on all three targets. Before 3.14 it sets python_process_pth_files so crosswind's patches run, as test_fastapi_app_answers does.
  • The test fails on all three targets with the fix reverted and passes with it.
  • ruff, ruff format, ty and pytest pass in workers/.

Reviewed with sol-loop: 1 round with gpt-6.1-sol. Sol verdict: approved

🤖 Generated with Claude Code

no_ssl makes `import ssl` fail while urllib3.util.ssl_ and similar modules
load, and their fallback code can leave the name `ssl` unbound. botocore does
`from urllib3.util.ssl_ import ssl`, so importing boto3 failed. After no_ssl,
add a module __getattr__ that imports ssl on first access.

Ported from cloudflare/workers-py#292 (f3e7851).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@justanotherbyte
justanotherbyte merged commit 597c77b into main Oct 27, 2026
8 checks passed
@justanotherbyte
justanotherbyte deleted the port/lazy-ssl-boto3 branch October 28, 2026 01:08
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.

1 participant