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-141781: Fix pdb line prefix binding#141779

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

Merged

Conversation

@pareshjoshij
Copy link
Contributor

@pareshjoshijpareshjoshij commentedNov 20, 2025
edited by bedevere-appbot
Loading

Description

This PR fixes a logic issue inpdb.print_stack_entry. Previously,prompt_prefix usedline_prefix as a default argument, which caused the value to be bound at definition time (when the module is imported).

This prevented users from customizingpdb.line_prefix dynamically after import, as the function would continue using the initial value.

Changes:

  • Changed the default argument ofprompt_prefix toNone.
  • Added a check inside the function to assignline_prefix ifprompt_prefix isNone.
  • Fixed a typo in the docstring of_get_tb_and_exceptions ("tracecack" -> "traceback").

Linked Issue

Fixes#141781

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

@pareshjoshijpareshjoshij changed the titleFix pdb line prefix bindinggh-141781: Fix pdb line prefix bindingNov 20, 2025
@gaogaotiantian
Copy link
Member

Okay even though this is not an officially documented behavior, it has been like this for a long time and there is some comments in the source code about it. Also it does not cost us too much to revert the behavior back (the old behavior also makes more sense).

In order to prevent cases like this happen in the future, could you also add a quick regression test on it? To make sure changingpdb.line_prefix can change the print out.

Also, even though minor, this still is still a behavior change. You need to add a news entry to it. Click the failedbedevere/news action will guide you to blurbit where you can log in with your github account and add a news entry easily.

Let me know if you are stuck.

@pareshjoshij
Copy link
ContributorAuthor

Thank you@gaogaotiantian sir for the guidance.
I’ve now added the regression test to ensure that updating pdb.line_prefix at runtime affects the output of print_stack_entry. The test swaps the value using support.swap_attr, calls print_stack_entry(frame, frame.f_lineno), and checks that the custom prefix appears in stdout.
I also added the required news entry

Please let me know if anything needs to be adjusted or improved. Thank you again for your help.❤️

@gaogaotiantian
Copy link
Member

Okay this behavior has been like this since the beginning, at least 25 years ago. However I still don't think it makes sense to be like this. I won't backport this because it's hardly a bug fix and it's definitely not a regression. Let's just silently fix this and keep this as an unsupported undocumented thing.

pareshjoshij reacted with heart emoji

@gaogaotiantiangaogaotiantian merged commitda1d468 intopython:mainNov 25, 2025
46 checks passed
@pareshjoshijpareshjoshij deleted the fix-pdb-line-prefix-binding branchNovember 25, 2025 08:02
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull requestDec 6, 2025
ashm-dev pushed a commit to ashm-dev/cpython that referenced this pull requestDec 8, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@gaogaotiantiangaogaotiantianAwaiting requested review from gaogaotiantiangaogaotiantian is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

pdb.line_prefix assignment ignored due to early binding

2 participants

@pareshjoshij@gaogaotiantian

[8]ページ先頭

©2009-2025 Movatter.jp