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

Prevent setting non-existent struct fields (ctypesgen issue) #246

Closed
mara004 opened this issue Aug 12, 2023 · 3 comments
Closed

Prevent setting non-existent struct fields (ctypesgen issue) #246

mara004 opened this issue Aug 12, 2023 · 3 comments
Assignees
Labels
bug Something isn't working ctypesgen Issue related to ctypesgen enhancement New feature or request help wanted Extra attention is needed important (Possibly) important upstream The root cause of this issue is in an upstream dependency.

Comments

@mara004
Copy link
Member

mara004 commented Aug 12, 2023

Setting a wrong struct field silently passes. Think about a utility that would prevent this.
See bblanchon/pdfium-binaries#105 (comment) for context.

@mara004 mara004 added the enhancement New feature or request label Aug 12, 2023
@mara004 mara004 self-assigned this Aug 12, 2023
@mara004
Copy link
Member Author

mara004 commented Aug 13, 2023

Incidentally, an independent SO thread on this topic has been raised very recently: https://stackoverflow.com/questions/76887146/prevent-assignment-of-non-existent-field-in-ctypes-structure

@mara004
Copy link
Member Author

mara004 commented Aug 14, 2023

Turns out this is a ctypesgen issue, see ctypesgen/ctypesgen#183 (comment).
__slots__ can be used to prevent non-existent fields, but this only works if they're actually defined in the class body, not when added afterwards as ctypesgen does ATM.

@mara004 mara004 changed the title Consider safety measures for struct initialization Prevent setting non-existent struct fields (ctypesgen issue) Aug 14, 2023
@mara004 mara004 added upstream The root cause of this issue is in an upstream dependency. ctypesgen Issue related to ctypesgen bug Something isn't working help wanted Extra attention is needed important (Possibly) important labels Aug 14, 2023
@mara004
Copy link
Member Author

mara004 commented Sep 12, 2023

Done in our fork. Fix not upstreamed yet, though.

@mara004 mara004 closed this as completed Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ctypesgen Issue related to ctypesgen enhancement New feature or request help wanted Extra attention is needed important (Possibly) important upstream The root cause of this issue is in an upstream dependency.
Projects
None yet
Development

No branches or pull requests

1 participant