Repository navigation
Bind ssl lazily after no_ssl so boto3 imports - #31
Merged
Merged
Conversation
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>
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.
Ports cloudflare/workers-py#292 (f3e7851).
no_sslmakesimport sslfail whileurllib3.util.ssl_,requests.adaptersandaiohttp.connectorload, so they skip thessl.create_default_context()entropy call. Their fallback code can leave the namesslunbound. botocore doesfrom urllib3.util.ssl_ import ssl, soimport boto3failed withImportError: cannot import name 'ssl' from 'urllib3.util.ssl_'.add_lazy_ssl_attributeruns afterno_ssland adds a module__getattr__that importssslon first access. It keeps any__getattr__the module already defines.Testing
test_boto3_import_at_top_levelimports boto3 at top level underwynd devon all three targets. Before 3.14 it setspython_process_pth_filesso crosswind's patches run, astest_fastapi_app_answersdoes.workers/.Reviewed with sol-loop: 1 round with gpt-6.1-sol. Sol verdict: approved
🤖 Generated with Claude Code