-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
Conversation
There was a problem hiding this 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) |
There was a problem hiding this comment.
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.
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.
@brandtbucher, please address the review comments. Thanks! |
Sorry @vstinner, I didn't realize that PEP 7 applied to generated code. Fixed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM.
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. |
Thanks! |
https://bugs.python.org/issue38823