[3.9] bpo-41993: Fix possible issues in remove_module() (GH-22631)#22647
Merged
Conversation
* PyMapping_HasKey() is not safe because it silences all exceptions and can return incorrect result. * Informative exceptions from PyMapping_DelItem() are overridden with RuntimeError and the original exception raised before calling remove_module() is lost. * There is a race condition between PyMapping_HasKey() and PyMapping_DelItem(). (cherry picked from commit 8287aad) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Contributor
Author
|
@serhiy-storchaka: Status check is done, and it's a success ✅ . |
Contributor
Author
|
@serhiy-storchaka: Status check is done, and it's a success ✅ . |
1 similar comment
Contributor
Author
|
@serhiy-storchaka: Status check is done, and it's a success ✅ . |
serhiy-storchaka
approved these changes
Oct 11, 2020
brettcannon
approved these changes
Oct 13, 2020
| /* Remove name from sys.modules, if it's there. */ | ||
| /* Remove name from sys.modules, if it's there. | ||
| * Can be called with an exception raised. | ||
| * If fail to remove name a new exception will be chained with the old |
Member
There was a problem hiding this comment.
Suggested change
| * If fail to remove name a new exception will be chained with the old | |
| * If we fail to remove 'name' then a new exception will be chained with the old |
Member
There was a problem hiding this comment.
Thank you, but this is a backport, and different comment was committed in master. I think it is better to fix it in master first and backport to 3.9.
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.
the original exception raised before calling remove_module() is lost.
(cherry picked from commit 8287aad)
Co-authored-by: Serhiy Storchaka storchaka@gmail.com
https://bugs.python.org/issue41993