Repository navigation
Restore the stored settings when reconfigure_port fails - #160
Open
Happyfield7 wants to merge 1 commit into
Open
Happyfield7 wants to merge 1 commit into
Happyfield7 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #160 +/- ##
==========================================
+ Coverage 94.38% 94.48% +0.09%
==========================================
Files 25 25
Lines 4437 4457 +20
==========================================
+ Hits 4188 4211 +23
+ Misses 249 246 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Problem
reconfigure_port()stores the new settings before applying them and keeps them when applying raises. Backends that rebuild the configuration from the stored settings then fail on every later call. On a POSIX port without RTS/CTS support,reconfigure_port(rtscts=True)correctly raisesUnsupportedSetting, but a followingreconfigure_port(baudrate=19200)raises the same error,baudratereports 19200 while the line stays at 9600, and reopening the port fails too.Change
BaseSerial._staged_settings()stores the update for the backend to read and restores the changed fields if applying raises, re-raising the original error. The sync and asyncreconfigure_port()and the deprecated setters use it. A cancelled async reconfigure keeps the new values, since the executor may still apply them. The old settings are not reapplied to the port, because a second error could hide the first; if a backend fails after part of the update already reached the port (possible on Win32 and RFC 2217), the stored values can differ from the port for those fields.Testing
Unit tests with a stub backend cover the sync path and the deprecated setters; pty tests reproduce the case above on the sync and async API and check the line speed, and one checks that a cancelled reconfigure keeps the new values. The four bug tests fail without the change. Full suite passes on macOS and Debian sid.