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

gh-111178: Fix function signatures in codeobject.c #125180

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Oct 9, 2024

Copy link
Member

@markshannon markshannon left a comment

Choose a reason for hiding this comment

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

Looks correct.

I don't like adding macros that only have a few uses. I think it impairs readability.

@@ -16,6 +16,9 @@
#include "pycore_tuple.h" // _PyTuple_ITEMS()
#include "clinic/codeobject.c.h"

#define _PyCode_CAST(op) \
Copy link
Member

@markshannon markshannon Oct 9, 2024

Choose a reason for hiding this comment

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

I don't really like macros like this.
While they may save a few lines of code, they add cognitive load.

If I see PyCodeObject *co = _PyCode_CAST(self); I can guess what it does, but I don't know unless I look up the macro.

But, if I see

     assert(PyCode_Check(self));
     co = (PyCodeObject *)self;

I know what it does immediately.

@vstinner
Copy link
Member Author

vstinner commented Oct 9, 2024

Ok, I removed the macro.

@vstinner vstinner enabled auto-merge (squash) October 9, 2024 14:54
@vstinner vstinner merged commit 3ee474f into python:main Oct 9, 2024
35 checks passed
@vstinner vstinner deleted the ubsan_code branch October 9, 2024 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants