Refactor _from server socket#820
Conversation
Documentation build overview
Show files changed (8 files in total): 📝 8 modified | ➕ 0 added | ➖ 0 deleted
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #820 +/- ##
==========================================
+ Coverage 78.32% 78.52% +0.20%
==========================================
Files 41 41
Lines 4788 4884 +96
Branches 547 485 -62
==========================================
+ Hits 3750 3835 +85
- Misses 900 909 +9
- Partials 138 140 +2 |
1f86831 to
b2f990a
Compare
This is the first in a sequence of refactors for this function. This step moves the initialization of the remote address to a separate helper function
Moves the check on ignorable errors into a separate function.
Puts the wrapping call into its own function.
the try hamdler had multiple statements
The accept() call is now handled in _accept_conn()
Helper function for security marks the socket fd as non-inheritable and sets the timeout.
Using helper functions this function now just has two main steps. First, socket creation. Second, connection configuration.
Added to deal with comment in _setup_conn_addr()
Added as a contrib.rst.
These tests cover code that was previous not covered.
2081bf2 to
ddd2b92
Compare
Update expected SSL error substrings to match the format returned by Python 3.15 on Windows Server 2025 runners. This unblocks CI coverage reports.
Better coverage and refactored some previous ones
ddd2b92 to
57031ff
Compare
avinashkamat48-design
left a comment
There was a problem hiding this comment.
In _wrap_socket_for_tls, the FatalSSLAlert branch now returns (None, {}) immediately, so the cleanup block below never closes raw_socket for that error path. The old _from_server_socket path simply returned, but with this refactor the helper comment says both TLS failure paths should close the socket. The NoSSLError branch reaches the close block, while FatalSSLAlert leaks the accepted socket unless the adapter already closed it. Could you either close before returning in that branch or move the common cleanup into a finally/single exit path?
This function in connections.py had become highly nested and complex, triggering linter warnings (C901, WPS505). Decomposed the logic into several smaller private methods.
❓ What kind of change does this PR introduce?
📋 What is the related issue number (starting with
#)Resolves #
❓ What is the current behavior? (You can also link to an open issue here)
❓ What is the new behavior (if this is a feature change)?
None
📋 Other information:
📋 Contribution checklist:
(If you're a first-timer, check out
[this guide on making great pull requests][making a lovely PR])
the changes have been approved
and description in grammatically correct, complete sentences
Will squash on approval