← 返回首页
bpo-38823: Clean up refleaks in _ast initialization. by brandtbucher · Pull Request #17276 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

bpo-38823: Clean up refleaks in _ast initialization.#17276

Merged
vstinner merged 4 commits into
python:masterfrom
brandtbucher:_ast
Feb 6, 2020
Merged

bpo-38823: Clean up refleaks in _ast initialization.#17276
vstinner merged 4 commits into
python:masterfrom
brandtbucher:_ast

Conversation

brandtbucher commented Nov 20, 2019
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

corona10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

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.

Comment thread Parser/asdl_c.py Outdated
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

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.

Copy link
Copy Markdown
Contributor

@brandtbucher, please address the review comments. Thanks!

Copy link
Copy Markdown
Member Author

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

shihai1991 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Thanks, LGTM.

vstinner merged commit d2f9667 into python:master Feb 6, 2020

vstinner commented Feb 6, 2020

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

Thanks!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Footer

© 2026 GitHub, Inc.