Skip to content

Avoid rebinding passed parameters#98

Open
puddly wants to merge 6 commits into
devfrom
puddly/fix-socket-close-errors
Open

Avoid rebinding passed parameters#98
puddly wants to merge 6 commits into
devfrom
puddly/fix-socket-close-errors

Conversation

@puddly
Copy link
Copy Markdown
Owner

@puddly puddly commented Jun 8, 2026

Fixes #96.

The underlying error is a bit subtle: we set exc to a default error if it is None (when the connection is closed gracefully) in order to flag future operations on the serial object. This unintentionally rebound exc and leaked the error to self._call_protocol_connection_lost(exc) as well.

This class of bug isn't flagged by mypy or ruff so I wrote a small custom pylint plugin to catch cases like this in addition to the new unit test for the underlying behavior.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 8, 2026

Codecov Report

❌ Patch coverage is 98.41270% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.23%. Comparing base (f9f1bf2) to head (3c2297b).
⚠️ Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
serialx/common.py 97.14% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev      #98      +/-   ##
==========================================
- Coverage   92.23%   92.23%   -0.01%     
==========================================
  Files          22       22              
  Lines        3632     3631       -1     
==========================================
- Hits         3350     3349       -1     
  Misses        282      282              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

OSError: [Errno 5] socket closed by peer when calling wait_closed()

1 participant