Skip to content

gh-121404: remove redundant c_nestlevel. more compiler abstractions. more macro usage consistency #123225

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

Merged
merged 2 commits into from
Aug 22, 2024

Conversation

iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Aug 22, 2024

@iritkatriel iritkatriel requested review from carljm and removed request for markshannon August 22, 2024 13:00
@iritkatriel iritkatriel added skip news interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Aug 22, 2024
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

Some nitpick.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@@ -92,11 +92,18 @@ static PySTEntryObject *compiler_symtable_entry(struct compiler *c);
#define FUTURE_FEATURES(C) compiler_future_features(C)
#define SYMTABLE(C) compiler_symtable(C)
#define SYMTABLE_ENTRY(C) compiler_symtable_entry(C)
#define OPTIMIZATION_LEVEL(C) compiler_optimization_level(C)
Copy link
Member

Choose a reason for hiding this comment

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

I realize we have some similar macros already, but is it really worth adding a macro that just replaces a slightly longer function call?

Copy link
Member Author

Choose a reason for hiding this comment

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

Eventually the functions will be in a different file, and potentially we will want to support alternative definitions of these macros. It's easier to redefine a macro than a function, and the code generation code is heavily macro-based anyway, so I think it makes sense to stick to this style.

Comment on lines +1500 to +1501
RETURN_IF_ERROR(ret);
return SUCCESS;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
RETURN_IF_ERROR(ret);
return SUCCESS;
return ret;

Copy link
Member Author

Choose a reason for hiding this comment

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

I deliberately didn't do this so that the pattern of checking for error with the macro is used everywhere. If you decide to add more code to this function, you can add it between line 1500 and 1501 without changing any of the existing code.

Comment on lines +2040 to 2041
RETURN_IF_ERROR(ret);
return SUCCESS;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
RETURN_IF_ERROR(ret);
return SUCCESS;
return ret;

@iritkatriel iritkatriel merged commit 4abc1c1 into python:main Aug 22, 2024
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants