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 — Make `frame.f_locals.copy()` return a snapshot dict of `f_locals` · Issue #118921 · python/cpython

Make frame.f_locals.copy() return a snapshot dict of f_locals #118921

New issue
Copy link
New issue
Copy link
Closed
Closed
Make frame.f_locals.copy() return a snapshot dict of f_locals#118921
Copy link
Assignees
gaogaotiantian
Labels
type-featureA feature request or enhancementA feature request or enhancement

Description

@gaogaotiantian
gaogaotiantian
opened on May 10, 2024
Issue body actions

Feature or enhancement

Proposal:

Per PEP 667, frame.f_locals is now a write-through proxy (FrameLocalsProxy) for underlying fast local variables. In the beginning we did not implement the copy() method because we think dict(frame.f_locals) is a more explicit way to achieve the snapshot. However, there are existing code that's using frame.f_locals.copy() to take a snapshot. Moreover, types.MappingProxyType({}).copy() returns the copy of the underlying mapping so it's not unprecedented for a proxy.copy() to return a dict.

Thus, we should implement copy() method for FrameLocalsProxy and make it return a dict of snapshot of the current local variables.

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/pep-667-consistent-views-of-namespaces/46631/26

Linked PRs

  • gh-118921: Add copy() method for FrameLocalsProxy #118923
  • [3.13] gh-118921: Add copy() method for FrameLocalsProxy (GH-118923) #118933

Activity

  1. gaogaotiantian
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on May 10, 2024
  2. gaogaotiantian
    self-assigned this
    on May 10, 2024
  3. gvanrossum
    added a commit that references this issue on May 10, 2024

    gh-118921: Add `copy()` method for `FrameLocalsProxy` (#118923)

    35c4361
  4. miss-islington
    added a commit that references this issue on May 10, 2024

    pythongh-118921: Add `copy()` method for `FrameLocalsProxy` (pythonGH…

    cee09fe
  5. gvanrossum
    added a commit that references this issue on May 10, 2024

    [3.13] gh-118921: Add `copy()` method for `FrameLocalsProxy` (GH-118923…

    93ef7aa
  6. AlexWaygood
    closed this as completedon May 11, 2024
  7. rominf
    added 2 commits that reference this issue on Jul 10, 2024

    fix(tests): Fix exception on copying `frame.f_locals` (Python 3.13)

    5536c2a

    fix(tests): Fix exception on copying `frame.f_locals` (Python 3.13)

    13d7a2f
  8. sentrivana
    added 2 commits that reference this issue on Jul 16, 2024

    fix(tests): Fix exception on copying `frame.f_locals` (Python 3.13) (#…

    49b4cf3

    feat: Preliminary support for Python 3.13 (#3200)

    a98f660
  9. estyxx
    added a commit that references this issue on Jul 17, 2024

    pythongh-118921: Add `copy()` method for `FrameLocalsProxy` (python#1…

    78f500a
  10. arjennienhuis
    added a commit that references this issue on Sep 30, 2024

    feat: Preliminary support for Python 3.13 (getsentry#3200)

    869e366
  11. turicas
    added 3 commits that reference this issue on Jun 6, 2025

    feat: Preliminary support for Python 3.13 (getsentry#3200)

    298a192

    feat: Preliminary support for Python 3.13 (getsentry#3200)

    3b4a05f

    feat: Preliminary support for Python 3.13 (getsentry#3200)

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

Metadata

Metadata

Assignees

  • @gaogaotiantian
    gaogaotiantian

Labels

type-featureA feature request or enhancementA feature request or enhancement

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.