Skip to content
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

skip ssl import if not available #3078

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

skip ssl import if not available #3078

wants to merge 2 commits into from

Conversation

dicej
Copy link

@dicej dicej commented Dec 18, 2023

Pull Request check-list

Please make sure to review and check all of these items:

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

utils.py has support for detecting whether the ssl module is available, and we can use this to omit SSL-specific funcionality while still providing other features (e.g. unencrypted connections).

Prior to this patch, the connection.py modules both triggered an ImportError due to unconditional imports of the ssl module. Now, we check utils.SSL_AVAILABLE prior to attempting the import and only raise an error later if (and only if) the application requests an encrypted connection. This helps support platforms such as wasm32-wasi where the ssl module is not built by default.

Ideally, this would be tested in CI using a Python built without ssl support. I'm not sure how feasible that is, though; I'm open to guidance on that aspect.

dicej and others added 2 commits December 18, 2023 10:09
`utils.py` has support for detecting whether the `ssl` module is available, and
we can use this to omit SSL-specific funcionality while still providing other
features (e.g. unencrypted connections).

Prior to this patch, the `connection.py` modules both triggered an `ImportError`
due to unconditional imports of the `ssl` module.  Now, we check
`utils.SSL_AVAILABLE` prior to attempting the import and only raise an error
later if (and only if) the application requests an encrypted connection.  This
helps support platforms such as `wasm32-wasi` where the `ssl` module is not
built by default.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
@codecov-commenter
Copy link

codecov-commenter commented Feb 22, 2024

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (2f88840) 91.84% compared to head (b94b105) 91.83%.
Report is 8 commits behind head on master.

Files Patch % Lines
redis/asyncio/connection.py 63.63% 4 Missing ⚠️
redis/connection.py 66.66% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3078      +/-   ##
==========================================
- Coverage   91.84%   91.83%   -0.01%     
==========================================
  Files         128      128              
  Lines       33232    33283      +51     
==========================================
+ Hits        30523    30567      +44     
- Misses       2709     2716       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

None yet

3 participants