8000 bpo-33211: Change line number of decorated nodes back to def by emmatyping · Pull Request #6460 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-33211: Change line number of decor 8000 ated nodes back to def #6460

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 19 commits into from
Closed
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
Next Next commit
Whitespace fixes
  • Loading branch information
emmatyping committed Apr 12, 2018
commit ae578b04d247c7555dc8351b569d22e32656bcef
6 changes: 3 additions & 3 deletions Python/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1686,11 +1686,11 @@ ast_for_decorated(struct compiling *c, const node *n)
TYPE(CHILD(n, 1)) == classdef);

if (TYPE(CHILD(n, 1)) == funcdef) {
return ast_for_funcdef(c, CHILD(n, 1), decorator_seq);
return ast_for_funcdef(c, CHILD(n, 1), decorator_seq);
} else if (TYPE(CHILD(n, 1)) == classdef) {
Copy link
Member

Choose a reason for hiding this comment

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

Actually now you can remove all elses.

Copy link
Member Author

Choose a reason for hiding this comment

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

You'd think so, sadly MSVC warns that not all code paths return if there isn't an else.

Copy link
Member

Choose a reason for hiding this comment

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

Even with Py_UNREACHABLE()?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, with the Py_UNREACHABLE() it is happy. Do you want something like this?

    if (TYPE(CHILD(n, 1)) == funcdef) {
        return ast_for_funcdef(c, CHILD(n, 1), decorator_seq);
    } else if (TYPE(CHILD(n, 1)) == classdef) {
        return ast_for_classdef(c, CHILD(n, 1), decorator_seq);
    } else if (TYPE(CHILD(n, 1)) == async_funcdef) {
        return ast_for_async_funcdef(c, CHILD(n, 1), decorator_seq);
    }
    Py_UNREACHABLE();

Copy link
Member

Choose a reason for hiding this comment

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

I suggest to remove other elses too.

return ast_for_classdef(c, CHILD(n, 1), decorator_seq);
return ast_for_classdef(c, CHILD(n, 1), decorator_seq);
} else if (TYPE(CHILD(n, 1)) == async_funcdef) {
return ast_for_async_funcdef(c, CHILD(n, 1), decorator_seq);
return ast_for_async_funcdef(c, CHILD(n, 1), decorator_seq);
}
}

Expand Down
0