Skip to content

drop dead ssl.wrap_socket() fallback in _connect_to_remote_server - #278

Open
vbanos wants to merge 1 commit into
internetarchive:masterfrom
vbanos:drop-ssl-wrap-socket-fallback
Open

drop dead ssl.wrap_socket() fallback in _connect_to_remote_server#278
vbanos wants to merge 1 commit into
internetarchive:masterfrom
vbanos:drop-ssl-wrap-socket-fallback

Conversation

@vbanos

@vbanos vbanos commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

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+.

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+.
@vbanos

vbanos commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

I was just checking the code with some AI tools and came up with this finding.

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