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 — Switching frame will erase the local variable changes in pdb · Issue #102864 · python/cpython

Switching frame will erase the local variable changes in pdb #102864

New issue
Copy link
New issue
Copy link
Closed
Closed
Switching frame will erase the local variable changes in pdb#102864
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@gaogaotiantian
gaogaotiantian
opened on Mar 21, 2023
Issue body actions

This issue is related to #101673 , where f_locals being accessed during the debugging clears the changes of local variables. We need to only do one access of f_locals before giving back control.

def f():
    a = 1
    breakpoint()
    print(a)

f()
> /home/gaogaotiantian/programs/mycpython/example.py(4)f()
-> print(a)
(Pdb) p a
1
(Pdb) !a = 2
(Pdb) p a
2
(Pdb) u
> /home/gaogaotiantian/programs/mycpython/example.py(6)<module>()
-> f()
(Pdb) d
> /home/gaogaotiantian/programs/mycpython/example.py(4)f()
-> print(a)
(Pdb) p a
1

The worst part is, print_stack_entry calls format_stack_entry which is a bdb function, and it accesses f_locals. To keep the maximum compatibility of bdb, I decided to leave it alone and only fix pdb.

Linked PRs

  • gh-102864: Remove access to f_locals in pdb #102865
  • gh-102864: Add switching frame test for pdb #119564

Activity

  1. gaogaotiantian
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Mar 21, 2023
  2. gaogaotiantian commented on Mar 21, 2023

    @gaogaotiantian
    gaogaotiantian
    on Mar 21, 2023
    MemberAuthor
    More actions

    @iritkatriel could you take a look at the issue when you have some time as you reviewed the related one so you might already know the fundamental problem.

  3. gaogaotiantian
    changed the title [-]Switching frame will erase the local variable changes[/-] [+]Switching frame will erase the local variable changes in pdb[/+] on Mar 21, 2023
  4. iritkatriel commented on Mar 21, 2023

    @iritkatriel
    iritkatriel
    on Mar 21, 2023
    Member
    More actions

    When was this issue introduced? Is it part of the 3.10/3.11 changes to frames?

  5. gaogaotiantian commented on Mar 21, 2023

    @gaogaotiantian
    gaogaotiantian
    on Mar 21, 2023
    MemberAuthor
    More actions

    Unfortunately no. This issue has been there for a long time. As far as I can tell, you can repro it on 3.8. If I had to guess, it's probably when Python started using FAST instead of local variable dict.

  6. arhadthedev
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Mar 22, 2023
  7. gaogaotiantian commented on May 5, 2024

    @gaogaotiantian
    gaogaotiantian
    on May 5, 2024
    MemberAuthor
    More actions

    This is fixed by PEP 667.

    Reacted by John Jones
  8. gaogaotiantian
    closed this as completedon May 5, 2024
  9. iritkatriel
    added a commit that references this issue on May 26, 2024

    gh-102864: Add switching frame test for pdb (#119564)

    5d04cc5
  10. estyxx
    added a commit that references this issue on Jul 17, 2024

    pythongh-102864: Add switching frame test for pdb (python#119564)

    a85ce6a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.