Navigation Menu

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

bpo-39988: Remove ast.AugLoad and ast.AugStore node classes. #19038

Merged
merged 7 commits into from Mar 17, 2020

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Mar 17, 2020

@isidentical
Copy link
Sponsor Member

@serhiy-storchaka can you remove the first commit, I think it is unrelated to this bug.

@serhiy-storchaka
Copy link
Member Author

This PR depends on #19037. After merging #19037 and synchronizing this PR with master the final diff will look cleaner. For now you can choose what commits you want to see in https://github.com/python/cpython/pull/19038/files.

Doc/whatsnew/3.9.rst Outdated Show resolved Hide resolved
Co-Authored-By: Batuhan Taşkaya <47358913+isidentical@users.noreply.github.com>
case AugLoad:
case AugStore:
break;
default:
Copy link
Member

@pablogsal pablogsal Mar 17, 2020

Choose a reason for hiding this comment

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

Could we keep the default just in case we receive some invalid value in the switch? (The same applies with the other ones). I may be missing the reason why you remove them, tough 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

It is impossible to get invalid value in ctx. compiler_nameop() is called either with a literal value or with e->v.Name.ctx, and it is validated before setting to e->v.Name.ctx.

It is more robust to not add the default because the compiler will warn if we add a new member to the expr_context_ty enum but do not have a corresponding case in a switch. If keep the default, the compiler would not catch this error at compile time.

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, thanks for the explanation!

Copy link
Member

@pablogsal pablogsal left a comment

Choose a reason for hiding this comment

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

LGTM!

Thanks Serhiy, this is a great improvement!

Comment on lines +5047 to +5049
VISIT(c, expr, e->v.Attribute.value);
ADDOP(c, DUP_TOP);
ADDOP_NAME(c, LOAD_ATTR, e->v.Attribute.attr, names);
Copy link
Member

Choose a reason for hiding this comment

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

Nice! I find this code much cleaner and straightforward :)

Python/compile.c Outdated
d_lineno = i->i_lineno - a->a_lineno;
if (d_lineno == 0)
Copy link
Member

@pablogsal pablogsal Mar 17, 2020

Choose a reason for hiding this comment

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

Nit: Pep 7 (Ignore if you want, I think this is also in the other PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants