Skip to content

bpo-42116: Fix inspect.getsource handling of trailing comments #23630

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

Merged
merged 5 commits into from
Dec 4, 2020

Conversation

iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Dec 3, 2020

@taleinat
Copy link
Contributor

taleinat commented Dec 3, 2020

ISTM that we should only include comments indented at least as much as the function's inner indentation, rather than anything more than the outer indentation.

For example, in the following case, I would not expect the comment to be considered part of the function's code:

def foo():
    print("Hello")
  # a comment?

@iritkatriel
Copy link
Member Author

ISTM that we should only include comments indented at least as much as the function's inner indentation, rather than anything more than the outer indentation.

That's a good idea. It will make the code simpler, and we're talking about a non-PEP8 compliant edge case anyway.

Copy link
Contributor

@taleinat taleinat left a comment

Choose a reason for hiding this comment

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

Looks good! Just one minor suggestion for one of the test cases.

@taleinat taleinat added needs backport to 3.8 needs backport to 3.9 only security fixes type-bug An unexpected behavior, bug, or error labels Dec 4, 2020
@taleinat taleinat merged commit 6e1eec7 into python:master Dec 4, 2020
@miss-islington
Copy link
Contributor

Thanks @iritkatriel for the PR, and @taleinat for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 4, 2020
…nGH-23630)

(cherry picked from commit 6e1eec7)

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
@bedevere-bot
Copy link

GH-23643 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Dec 4, 2020
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 4, 2020
…nGH-23630)

(cherry picked from commit 6e1eec7)

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
@bedevere-bot
Copy link

GH-23644 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit that referenced this pull request Dec 4, 2020
)

(cherry picked from commit 6e1eec7)

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
miss-islington added a commit that referenced this pull request Dec 4, 2020
)

(cherry picked from commit 6e1eec7)

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants