Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-135751: traceback: add recent_first and show_lines parameter#135752

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

Already on GitHub?Sign in to your account

Open
methane wants to merge14 commits intopython:main
base:main
Choose a base branch
Loading
frommethane:traceback-show_lines

Conversation

methane
Copy link
Member

@methanemethane commentedJun 20, 2025
edited by github-actionsbot
Loading

@methanemethane requested a review fromCopilotJune 20, 2025 12:30
@methanemethane added type-featureA feature request or enhancement stdlibPython modules in the Lib dir labelsJun 20, 2025
Copy link

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds two new keyword-only parameters,show_lines andrecent_first, to thetraceback module’s formatting and printing APIs, allowing callers to suppress source lines or invert traceback order.

  • Introduceshow_lines andrecent_first across module-level functions andTracebackException/StackSummary methods
  • Update internal printing/formatting logic to pass these flags through
  • Extend tests and documentation to cover new behavior

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
Misc/NEWS.d/next/Library/2025-06-20-21-16-32…rstAnnounce new parameters in the NEWS file
Lib/traceback.pyCore implementation: API signatures and logic updates
Lib/test/test_traceback.pyNew unit tests forshow_lines andrecent_first flags
Doc/whatsnew/3.15.rstDocument what’s new section forshow_lines/recent_first
Doc/library/traceback.rstUpdate function/method docstrings to include new flags
Comments suppressed due to low confidence (4)

Lib/traceback.py:31

  • The first line of the docstring was truncated and now only mentionsextract_stack(). It should refer to bothextract_tb() andextract_stack(), e.g., "Print the list of tuples as returned byextract_tb() orextract_stack() as a formatted stack trace to the given file."
    extract_stack() as a formatted stack trace to the given file.

Doc/whatsnew/3.15.rst:181

  • [nitpick] Grammar in release notes: replace "It is default toTrue." with "Defaults toTrue." for clarity.
  It is default to ``True``.

Doc/library/traceback.rst:125

  • [nitpick] This sentence is duplicated immediately above; remove one instance to avoid redundancy.
   If *show_lines* is false, source code lines are not included in the output.

Doc/library/traceback.rst:175

  • [nitpick] Using "next" as a version string may be confusing. Consider using the actual upcoming version number or a placeholder like "3.x" for clarity.
   .. versionchanged:: next

methaneand others added2 commitsJune 20, 2025 21:37
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Member

@iritkatrieliritkatriel left a comment

Choose a reason for hiding this comment

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

I thinkshow_lines should be renamed to something likeshow_source.

@@ -1566,12 +1623,13 @@ def format(self, *, chain=True, _ctx=None, **kwargs):
_ctx.exception_group_depth = 0


def print(self, *, file=None, chain=True, **kwargs):
def print(self, *, file=None, chain=True,show_lines=True, recent_first=False,**kwargs):
"""Print the result of self.format(chain=chain) to 'file'."""
colorize = kwargs.get("colorize", False)
Copy link
Member

Choose a reason for hiding this comment

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

Why not add the new args via**kwargs as was done forcolorize? It would save having to update all the signatures.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I think colorize is in kwargs because of its hidden parameter. Callars determine use COLOR automatically by isatty() and env variables and pass it to here. colorize is not documented.

On the other hand, show_lines and recent_first are explicit parameter.
User need to determine and specify them manually.

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
methaneand others added3 commitsJune 21, 2025 08:57
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@iritkatrieliritkatrieliritkatriel left review comments

@hugovkhugovkhugovk left review comments

@brianschubertbrianschubertbrianschubert left review comments

Copilot code reviewCopilotCopilot left review comments

Assignees
No one assigned
Labels
awaiting core reviewstdlibPython modules in the Lib dirtype-featureA feature request or enhancement
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@methane@iritkatriel@hugovk@brianschubert

[8]ページ先頭

©2009-2025 Movatter.jp