8000 bpo-39981: Default values for AST nodes by isidentical · Pull Request #19031 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-39981: Default values for AST nodes #19031

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add AST._field_defaults for consistency
  • Loading branch information
isidentical committed May 5, 2020
commit fb7990e72006c2362a4bd2c4cee9bf9defa91229
9 changes: 5 additions & 4 deletions Parser/asdl_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,10 @@ def visitModule(self, mod):
Py_ssize_t i, numfields = 0;
int res = -1;
PyObject *key, *value, *fields, *field_defaults;
if (_PyObject_LookupAttr(Py_TYPE(self), astmodulestate_global->_fields, &fields) < 0) {
if (_PyObject_LookupAttr(self, astmodulestate_global->_fields, &fields) < 0) {
goto cleanup;
}
if (_PyObject_LookupAttr(Py_TYPE(self), astmodulestate_global->_field_defaults, &field_defaults) < 0) {
if (_PyObject_LookupAttr(self, astmodulestate_global->_field_defaults, &field_defaults) < 0) {
goto cleanup;
}
if (fields) {
Expand Down Expand Up @@ -833,7 +833,7 @@ def visitModule(self, mod):
)
{
Py_ssize_t i;
PyObject *fnames, *fdefaults;
PyObject *fnames, *fdefaults = NULL;
PyObject *result = NULL;

fnames = PyTuple_New(num_fields);
Expand Down Expand Up @@ -1004,7 +1004,8 @@ def visitModule(self, mod):
empty_tuple = PyTuple_New(0);
if (!empty_tuple ||
PyObject_SetAttrString(astmodulestate_global->AST_type, "_fields", empty_tuple) < 0 ||
PyObject_SetAttrString(astmodulestate_global->AST_type, "_attributes", empty_tuple) < 0) {
PyObject_SetAttrString(astmodulestate_global->AST_type, "_attributes", empty_tuple) < 0 ||
PyObject_SetAttrString(astmodulestate_global->AST_type, "_field_defaults", empty_tuple) < 0) {
Py_XDECREF(empty_tuple);
return -1;
}
Expand Down
9 changes: 5 additions & 4 deletions Python/Python-ast.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0