Fix ChainerBackend.delete_password to try all backends#740
Open
veeceey wants to merge 5 commits intojaraco:mainfrom
Open
Fix ChainerBackend.delete_password to try all backends#740veeceey wants to merge 5 commits intojaraco:mainfrom
veeceey wants to merge 5 commits intojaraco:mainfrom
Conversation
The delete_password method was only trying the first backend in the chain and returning immediately. This caused it to fail when a password existed in a lower priority backend but not in the highest priority one. Now delete_password iterates through all backends, catching PasswordDeleteError exceptions and continuing to try other backends, similar to how it already handles NotImplementedError. If all backends fail to delete the password, it raises the last PasswordDeleteError. This matches the behavior of get_password which also iterates through all backends to find a password. Fixes jaraco#697
mitya57
requested changes
Feb 13, 2026
Use 'if keyring == self.backends[-1]: raise' instead of collecting errors in a list - cleaner and avoids the unnecessary list allocation.
mitya57
approved these changes
Feb 14, 2026
Simplify HighPriorityKeyring to always return None / raise, remove unused storage logic, and exercise set_password stubs so all new lines in the diff are covered.
Remove type annotation from storage class variable to avoid triggering mypy's annotation-unchecked note on Windows CI.
Author
|
Pushed a fix for the Windows CI mypy failure — the The other two CI failures (Windows 3.9 pip install failure and pypy3.10 timeout/cancellation) appear to be transient infrastructure issues unrelated to these changes. |
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.
Summary
Fixes #697 where
ChainerBackend.delete_password()was only trying the first backend instead of iterating through all backends in the chain.The issue occurred when a password existed in a lower priority backend but not in the highest priority one. The
delete_passwordmethod would try only the first (highest priority) backend, get aPasswordDeleteError, and fail immediately.Changes
ChainerBackend.delete_password()to iterate through all backends, similar to howget_password()worksPasswordDeleteErrorexceptions and continues trying other backendsPasswordDeleteErrorencounteredTesting
Added two new test cases:
test_delete_password_tries_all_backends- Verifies that deletion succeeds when password exists only in a lower priority backendtest_delete_password_raises_if_all_backends_fail- Verifies that appropriate error is raised when password doesn't exist in any backendAll existing tests continue to pass.