Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix __annotations__ getters and setters in type and module #106719

Closed
serhiy-storchaka opened this issue Jul 13, 2023 · 0 comments
Closed

Fix __annotations__ getters and setters in type and module #106719

serhiy-storchaka opened this issue Jul 13, 2023 · 0 comments
Labels
3.11 only security fixes 3.12 bugs and security fixes 3.13 bugs and security fixes type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Jul 13, 2023

There are several issues in the code of __annotations__ getters and setters in type and module types.

  • PyDict_Contains() returns -1 on error. The code interprets it as a positive answer.
  • Calling PyDict_Contains() is not needed in all these cases at first place. Just try to get or delete an attribute and analyze the result.
  • All errors raised when accessing module.__dict__ (including MemoryError and KeyboardInterrupt) are replaced with a TypeError.

Linked PRs

@serhiy-storchaka serhiy-storchaka added type-bug An unexpected behavior, bug, or error 3.11 only security fixes 3.12 bugs and security fixes 3.13 bugs and security fixes labels Jul 13, 2023
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Jul 13, 2023
…d module types

No longer suppress arbitrary errors. Simplify the code.
@terryjreedy terryjreedy changed the title Fix __annotations__ getters and setters in type and module Fix __annotations__ getters and setters in type and module Jul 14, 2023
@terryjreedy terryjreedy changed the title Fix __annotations__ getters and setters in type and module Fix __annotations__ getters and setters in type and module Jul 14, 2023
serhiy-storchaka added a commit that referenced this issue Jul 18, 2023
…le types (GH-106720)

No longer suppress arbitrary errors. Simplify the code.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 18, 2023
…d module types (pythonGH-106720)

No longer suppress arbitrary errors. Simplify the code.
(cherry picked from commit e1c295e)

Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Jul 18, 2023
…type and module types (pythonGH-106720)

No longer suppress arbitrary errors. Simplify the code..
(cherry picked from commit e1c295e)

Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit that referenced this issue Jul 18, 2023
…nd module types (GH-106720) (GH-106848)

gh-106719: Fix __annotations__ getter and setter in the type and module types (GH-106720)

No longer suppress arbitrary errors. Simplify the code.
(cherry picked from commit e1c295e)

Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit that referenced this issue Jul 18, 2023
…nd module types (GH-106720) (GH-106850)

No longer suppress arbitrary errors. Simplify the code.
(cherry picked from commit e1c295e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes 3.12 bugs and security fixes 3.13 bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant