drop dead ssl.wrap_socket() fallback in _connect_to_remote_server - #278
Open
vbanos wants to merge 1 commit into
Open
drop dead ssl.wrap_socket() fallback in _connect_to_remote_server#278vbanos wants to merge 1 commit into
vbanos wants to merge 1 commit into
Conversation
The `except AttributeError` branch called `ssl.wrap_socket()`, which was deprecated in Python 3.6 and removed in Python 3.12. The branch was also unreachable in practice: `remote_connection_pool` is always constructed with `ssl_context=ssl_context` (see SingleThreadedMitmProxy.__init__), so the primary `context.wrap_socket()` call cannot raise AttributeError from a missing ssl_context. On top of that, the fallback's outer `raise` unconditionally re-raised the original AttributeError even after the inner assignment "succeeded", making the assignment useless. The warning message referred to Python 2.7.9+ / 3.4+, which is meaningless now that we require Python 3.9+.
Contributor
Author
|
I was just checking the code with some AI tools and came up with this finding. |
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.
The
except AttributeErrorbranch calledssl.wrap_socket(), which was deprecated in Python 3.6 and removed in Python 3.12. The branch was also unreachable in practice:remote_connection_poolis always constructed withssl_context=ssl_context(see SingleThreadedMitmProxy.init), so the primarycontext.wrap_socket()call cannot raise AttributeError from a missing ssl_context. On top of that, the fallback's outerraiseunconditionally re-raised the original AttributeError even after the inner assignment "succeeded", making the assignment useless. The warning message referred to Python 2.7.9+ / 3.4+, which is meaningless now that we require Python 3.9+.