Skip to content

[3.9] bpo-41993: Fix possible issues in remove_module() (GH-22631)#22647

Merged
serhiy-storchaka merged 1 commit into
python:3.9from
miss-islington:backport-8287aad-3.9
Oct 14, 2020
Merged

[3.9] bpo-41993: Fix possible issues in remove_module() (GH-22631)#22647
serhiy-storchaka merged 1 commit into
python:3.9from
miss-islington:backport-8287aad-3.9

Conversation

@miss-islington
Copy link
Copy Markdown
Contributor

@miss-islington miss-islington commented Oct 11, 2020

  • 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

https://bugs.python.org/issue41993

* 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>
@miss-islington
Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka: Status check is done, and it's a success ✅ .

@miss-islington
Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka: Status check is done, and it's a success ✅ .

1 similar comment
@miss-islington
Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka: Status check is done, and it's a success ✅ .

Comment thread Python/import.c
/* 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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@serhiy-storchaka serhiy-storchaka merged commit 391a544 into python:3.9 Oct 14, 2020
@miss-islington miss-islington deleted the backport-8287aad-3.9 branch October 14, 2020 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants