bpo-6700: Fix inspect.getsourcelines for module level frames/tracebacks by vladima · Pull Request #8864 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation13 Commits4 Checks0 Files changed

Conversation

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

[ Show hidden characters]({{ revealButtonHref }})

vladima

Fix inspect.getsourcelines for module level frames/tracebacks - if traceback object or frame correspond to the module - return all source lines.

https://bugs.python.org/issue6700

@vladima

@the-knights-who-say-ni

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

@vladima

taleinat

Choose a reason for hiding this comment

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

Looks like a good improvement! Two minor notes.

fodderModule = mod
def test_range_toplevel_frame(self):
self.assertSourceEqual(mod.currentframe, 1, 82)

Choose a reason for hiding this comment

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

The 82 here (and below) is fragile, it would need to be updated after almost any minor change to the "fodder module". I suggest using None, which is equivalent to an open-ended slice, e.g. lines[1:].

if istraceback(object):
object = object.tb_frame
# for module or frame that correspond to module return all source lines

Choose a reason for hiding this comment

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

"... correspond to a module return ..." -> "... corresponds to a module, return ..."

@bedevere-bot

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@vladima

@vladima

I have made the requested changes; please review again

@bedevere-bot

Thanks for making the requested changes!

@taleinat: please review the changes made to this pull request.

@vladima

Two failures in checks seem transient since they both fail on 'Update apt-get lists' step. Can I somehow request these checks to be re-run without making new commit?

@taleinat

taleinat

@miss-islington

Thanks @vladima for the PR, and @taleinat for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6, 3.7.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request

Aug 24, 2018

@vladima @miss-islington

…ks (pythonGH-8864)

(cherry picked from commit 91cb298)

Co-authored-by: Vladimir Matveev v2matveev@outlook.com

@bedevere-bot

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request

Aug 24, 2018

@vladima @miss-islington

…ks (pythonGH-8864)

(cherry picked from commit 91cb298)

Co-authored-by: Vladimir Matveev v2matveev@outlook.com

@bedevere-bot

@miss-islington

Sorry, @vladima and @taleinat, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 91cb298f811961277fd4cc4a32211899d48bedcb 2.7

taleinat pushed a commit to taleinat/cpython that referenced this pull request

Aug 24, 2018

@vladima @taleinat

…acebacks (pythonGH-8864).

(cherry picked from commit 91cb298)

Co-authored-by: Vladimir Matveev v2matveev@outlook.com

@bedevere-bot

miss-islington added a commit that referenced this pull request

Aug 24, 2018

@miss-islington @vladima

…ks (GH-8864)

(cherry picked from commit 91cb298)

Co-authored-by: Vladimir Matveev v2matveev@outlook.com

miss-islington added a commit that referenced this pull request

Aug 24, 2018

@miss-islington @vladima

…ks (GH-8864)

(cherry picked from commit 91cb298)

Co-authored-by: Vladimir Matveev v2matveev@outlook.com

taleinat added a commit that referenced this pull request

Aug 26, 2018

@taleinat @vladima

…acebacks (GH-8864)

(cherry picked from commit 91cb298)

Co-authored-by: Vladimir Matveev v2matveev@outlook.com

CuriousLearner added a commit to CuriousLearner/cpython that referenced this pull request

Aug 27, 2018

@CuriousLearner

Labels

type-bug

An unexpected behavior, bug, or error