GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-101673: Fix pdb bug that local variable changes lost after longlist by gaogaotiantian · Pull Request #101674 · python/cpython

Conversation

@gaogaotiantian

@gaogaotiantian gaogaotiantian commented Feb 8, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

The bug is described in #101673.

Using f_code.co_name to check whether it's a frame module avoids reading f_local whose side effect reverts local variable changes in pdb.

  • Issue: pdb loses local variable change after command longlist #101673

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

arhadthedev, artemmukhin, ProgramRipper, jingxu94, sledgeh4w, tanloong, zhangwang997, shengbo-ma, kelerensheng, xnuohz, and 4 more reacted with thumbs up emoji
All reactions
  • 👍 14 reactions
@bedevere-bot bedevere-bot added the awaiting review label Feb 8, 2023
@bedevere-bot bedevere-bot mentioned this pull request Feb 8, 2023
pdb loses local variable change after command longlist #101673
Closed
@bedevere-bot

bedevere-bot commented Feb 8, 2023

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost

ghost commented Feb 8, 2023 •
edited by ghost
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@arhadthedev arhadthedev added the stdlib Standard Library Python modules in the Lib/ directory label Feb 8, 2023
@gaogaotiantian
Use f_code.co_name for module frame checking
3acb643
@gaogaotiantian
gaogaotiantian force-pushed the fix-issue-101673 branch from e0ac654 to 3acb643 Compare February 9, 2023 19:35
@bedevere-bot

bedevere-bot commented Feb 9, 2023

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

blurb-it Bot and others added 2 commits February 9, 2023 19:40
@blurb-it
📜🤖 Added by blurb_it.
6cfbe7c
@gaogaotiantian
Update 2023-02-09-19-40-41.gh-issue-101673.mX-Ppq.rst
bb2d818
Use double ticks for inline code
@artemmukhin

artemmukhin commented Mar 11, 2023

Copy link
Copy Markdown
Contributor

@iritkatriel I am wondering if you could be an appropriate reviewer for this. Could you please take a look?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gaogaotiantian
Add regression test for the bug
121e00b
@iritkatriel

iritkatriel commented Mar 12, 2023

Copy link
Copy Markdown
Member

Thanks for adding the test. Before merging this I would need to spend some time to understand why this happened and to convince myself that this is the right solution. If someone else reviews it before I get around to it that's obviously fine.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@artemmukhin

artemmukhin commented Mar 12, 2023

Copy link
Copy Markdown
Contributor

@iritkatriel Thank you for your quick response.

I have investigated the issue further and discovered that the problematic obj.f_globals is obj.f_locals check was introduced in 5ed2b5a to work around the limitation of inspect.getsourcelines, as the latter did not check that the given frame is a module-level frame.

However, inspect.getsourcelines was independently corrected in 91cb298 using the same object.f_code.co_name == "<module>" technique.

So I believe that we should consider replacing the custom pdb.getsourcelines function with direct inspect.getsourcelines invocations. After making this change, the updated test_pdb still passes. @gaogaotiantian WDYT?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gaogaotiantian

gaogaotiantian commented Mar 12, 2023

Copy link
Copy Markdown
Member Author

Yeah I think that’s the way to go. The original customized pdb version was to avoid module level frame issue and it would be nice to not to keep multiple identical code pieces around. The functionality seems to be the same. I’ll make the changes to use inspect version directly and remove the pdb version.

artemmukhin and vcyiqr reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gaogaotiantian
Use inspect.getsourcelines directly
5724f3f
@gaogaotiantian

gaogaotiantian commented Mar 12, 2023

Copy link
Copy Markdown
Member Author

As @ortem said, the reason we had a separate getsourcelines in pdb was because the inspect version did not deal with the module level frame. It does now so we can just switch back to inspect version and kept one less duplicated code piece. I did include the regression test for the issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

iritkatriel
iritkatriel approved these changes Mar 12, 2023
View reviewed changes

@iritkatriel iritkatriel left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Makes sense. Thank you!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Misc/NEWS.d/next/Library/2023-02-09-19-40-41.gh-issue-101673.mX-Ppq.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Mar 12, 2023
iritkatriel added 2 commits March 12, 2023 22:26
@iritkatriel
tweak news
ef602d8
@iritkatriel
Merge branch 'main' into fix-issue-101673
8b9fc42
@iritkatriel iritkatriel added 3.11 only security fixes 3.12 only security fixes needs backport to 3.11 only security fixes type-bug An unexpected behavior, bug, or error needs backport to 3.10 and removed 3.11 only security fixes 3.12 only security fixes labels Mar 12, 2023
@iritkatriel
iritkatriel merged commit 5d677c5 into python:main Mar 12, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label Mar 12, 2023
@miss-islington

miss-islington commented Mar 12, 2023

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington

miss-islington commented Mar 12, 2023

Copy link
Copy Markdown
Contributor

Sorry, @gaogaotiantian and @iritkatriel, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 5d677c556f03a34d1c2d86e4cc96025870c20c12 3.10

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington miss-islington assigned iritkatriel Mar 12, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 12, 2023
@gaogaotiantian @miss-islington
pythonGH-101673: Fix pdb bug where local variable changes are lost af…
bb6a288
…ter longlist (pythonGH-101674)

(cherry picked from commit 5d677c5)

Co-authored-by: gaogaotiantian <[email protected]>
@bedevere-bot

bedevere-bot commented Mar 12, 2023

Copy link
Copy Markdown

GH-102632 is a backport of this pull request to the 3.11 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Mar 12, 2023
iritkatriel pushed a commit to iritkatriel/cpython that referenced this pull request Mar 12, 2023
@gaogaotiantian @iritkatriel
pythonGH-101673: Fix pdb bug where local variable changes are lost af…
4e583c5
…ter longlist (python#101674)

(cherry picked from commit 5d677c5)
miss-islington added a commit that referenced this pull request Mar 12, 2023
@miss-islington @gaogaotiantian
GH-101673: Fix pdb bug where local variable changes are lost after lo…
7856026
…nglist (GH-101674)

(cherry picked from commit 5d677c5)

Co-authored-by: gaogaotiantian <[email protected]>
@bedevere-bot

bedevere-bot commented Mar 12, 2023

Copy link
Copy Markdown

GH-102633 is a backport of this pull request to the 3.10 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 label Mar 12, 2023
pablogsal pushed a commit that referenced this pull request Mar 13, 2023
@iritkatriel @gaogaotiantian
[3.10] GH-101673: Fix pdb bug where local variable changes are lost a…
d4f8faf
…fter longlist (#101674) (#102633)

GH-101673: Fix pdb bug where local variable changes are lost after longlist (#101674)

(cherry picked from commit 5d677c5)

Co-authored-by: gaogaotiantian <[email protected]>
@gaogaotiantian
gaogaotiantian deleted the fix-issue-101673 branch March 23, 2023 23:29
@arhadthedev arhadthedev mentioned this pull request Mar 30, 2023
gh-103124: Multiline statement support for pdb #103125
Merged
This was referenced Apr 3, 2023
pdb shows wrong line numbers for modules #103225
Closed
GH-103319: Fix inspect.getsourcelines() to return 1-based line numbers #103226
Open
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
@gaogaotiantian @warsaw
pythonGH-101673: Fix pdb bug where local variable changes are lost af…
21858fd
…ter longlist (python#101674)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iritkatriel iritkatriel iritkatriel approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@iritkatriel iritkatriel

Labels

stdlib Standard Library Python modules in the Lib/ directory type-bug An unexpected behavior, bug, or error

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@gaogaotiantian @bedevere-bot @artemmukhin @iritkatriel @miss-islington @arhadthedev
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.