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-38823: Clean up refleaks in _ast initialization. #17276

Merged
merged 4 commits into from
Feb 6, 2020

Conversation

brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Nov 20, 2019

Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

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

PR looks good to me.
The specific change is that error handling is done by the goto statement
and this decision is looking good to me for this situation.

@vstinner
Please take a look at @brandtbucher 's PR as the core developer.
Thank you for understanding.

Parser/asdl_c.py Outdated
@@ -998,17 +998,20 @@ def visitModule(self, mod):
self.emit("if (!init_types()) return NULL;", 1)
self.emit('m = PyState_FindModule(&_astmodule);', 1)
self.emit("if (!m) return NULL;", 1)
self.emit('if (PyModule_AddObject(m, "AST", astmodulestate_global->AST_type) < 0) goto error;', 1)
Copy link
Member

Choose a reason for hiding this comment

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

Please add braces, see PEP 7.

Suggested change
self.emit('if (PyModule_AddObject(m, "AST", astmodulestate_global->AST_type) < 0) goto error;', 1)
self.emit('if (PyModule_AddObject(m, "AST", astmodulestate_global->AST_type) < 0) { goto error; }', 1)

Same for changes below.

@csabella
Copy link
Contributor

@brandtbucher, please address the review comments. Thanks!

@brandtbucher
Copy link
Member Author

Sorry @vstinner, I didn't realize that PEP 7 applied to generated code. Fixed!

Copy link
Member

@shihai1991 shihai1991 left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM.

@vstinner vstinner merged commit d2f9667 into python:master Feb 6, 2020
@vstinner
Copy link
Member

vstinner commented Feb 6, 2020

I don't see the need to backport such change. Errors in _ast init function are very unlikely. I prefer to reduce the number of backported changes to stable branches to reduce the risk of regression.

@brandtbucher
Copy link
Member Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants