Skip to content

bpo-6700: Fix inspect.getsourcelines for module level frames/tracebacks #8864

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 4 commits into from
Aug 24, 2018

Conversation

vladima
Copy link
Contributor

@vladima vladima commented Aug 23, 2018

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

@the-knights-who-say-ni
Copy link

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!

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 like a good improvement! Two minor notes.

fodderModule = mod

def test_range_toplevel_frame(self):
self.assertSourceEqual(mod.currentframe, 1, 82)
Copy link
Contributor

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:].

Lib/inspect.py Outdated
if istraceback(object):
object = object.tb_frame

# for module or frame that correspond to module return all source lines
Copy link
Contributor

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
Copy link

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
Copy link
Contributor Author

vladima commented Aug 23, 2018

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

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

@vladima
Copy link
Contributor Author

vladima commented Aug 23, 2018

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 closed this Aug 24, 2018
@taleinat taleinat reopened this Aug 24, 2018
@taleinat taleinat merged commit 91cb298 into python:master Aug 24, 2018
@miss-islington
Copy link
Contributor

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
@bedevere-bot
Copy link

GH-8898 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 24, 2018
@bedevere-bot
Copy link

GH-8899 is a backport of this pull request to the 3.6 branch.

@miss-islington
Copy link
Contributor

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 taleinat added the type-bug An unexpected behavior, bug, or error label Aug 24, 2018
taleinat pushed a commit to taleinat/cpython that referenced this pull request Aug 24, 2018
…acebacks (pythonGH-8864).

(cherry picked from commit 91cb298)

Co-authored-by: Vladimir Matveev <[email protected]>
@bedevere-bot
Copy link

GH-8900 is a backport of this pull request to the 2.7 branch.

miss-islington added a commit that referenced this pull request Aug 24, 2018
…ks (GH-8864)

(cherry picked from commit 91cb298)

Co-authored-by: Vladimir Matveev <[email protected]>
miss-islington added a commit that referenced this pull request Aug 24, 2018
…ks (GH-8864)

(cherry picked from commit 91cb298)

Co-authored-by: Vladimir Matveev <[email protected]>
@vladima vladima deleted the fix6700 branch August 24, 2018 16:31
taleinat added a commit that referenced this pull request Aug 26, 2018
…acebacks (GH-8864)

(cherry picked from commit 91cb298)

Co-authored-by: Vladimir Matveev <[email protected]>
CuriousLearner added a commit to CuriousLearner/cpython that referenced this pull request Aug 27, 2018
* master: (104 commits)
  Fast path for exact floats in math.hypot() and math.dist() (pythonGH-8949)
  Remove AIX workaround test_subprocess (pythonGH-8939)
  bpo-34503: Fix refleak in PyErr_SetObject() (pythonGH-8934)
  closes bpo-34504: Remove the useless NULL check in PySequence_Check(). (pythonGH-8935)
  closes bpo-34501: PyType_FromSpecWithBases: Check spec->name before dereferencing it. (pythonGH-8930)
  closes bpo-34502: Remove a note about utf8_mode from sys.exit() docs. (pythonGH-8928)
  Remove unneeded PyErr_Clear() in _winapi_SetNamedPipeHandleState_impl() (pythonGH-8281)
  Fix markup in stdtypes documentation (pythonGH-8905)
  bpo-34395: Don't free allocated memory on realloc fail in load_mark() in _pickle.c. (pythonGH-8788)
  Fix upsizing of marks stack in pickle module. (pythonGH-8860)
  bpo-34171: Prevent creating Lib/trace.cover when run the trace module. (pythonGH-8841)
  closes bpo-34493: Objects/genobject.c: Add missing NULL check to compute_cr_origin() (pythonGH-8911)
  Fixed typo with asynccontextmanager code example (pythonGH-8845)
  bpo-34426: fix typo (__lltrace__ -> __ltrace__) (pythonGH-8822)
  bpo-13312: Avoid int underflow in time year. (pythonGH-8912)
  bpo-34492: Python/coreconfig.c: Fix _Py_wstrlist_copy() (pythonGH-8910)
  bpo-34448: Improve output of usable wchar_t check (pythonGH-8846)
  closes bpo-34471: _datetime: Add missing NULL check to tzinfo_from_isoformat_results. (pythonGH-8869)
  bpo-6700: Fix inspect.getsourcelines for module level frames/tracebacks (pythonGH-8864)
  Fix typo in the dataclasses's doc (pythonGH-8896)
  ...
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