Skip to content

FrameLocalsProxy is not a mapping #120097

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
markshannon opened this issue Jun 5, 2024 · 0 comments
Closed

FrameLocalsProxy is not a mapping #120097

markshannon opened this issue Jun 5, 2024 · 0 comments
Assignees
Labels
3.13 bugs and security fixes 3.14 bugs and security fixes type-bug An unexpected behavior, bug, or error

Comments

@markshannon
Copy link
Member

markshannon commented Jun 5, 2024

Bug report

Bug description:

FrameLocalsProxy should be a mapping. I.e. it should subclass collections.abc.Mapping and match {} in a match statement.

from collections.abc import Mapping
import sys

def f():
    return sys._getframe().f_locals

proxy = f()

assert(instance(proxy, Mapping))

match proxy:
    case {}:
        kind = "mapping"
    case _:
        kind = "other"

assert(kind == "mapping")

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

@markshannon markshannon added type-bug An unexpected behavior, bug, or error 3.13 bugs and security fixes 3.14 bugs and security fixes labels Jun 5, 2024
@markshannon markshannon self-assigned this Jun 5, 2024
markshannon added a commit that referenced this issue Jun 19, 2024
* Register FrameLocalsProxy as a subclass of collections.abc.Mapping

* Allow FrameLocalsProxy to matching mapping patterns
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 19, 2024
* Register FrameLocalsProxy as a subclass of collections.abc.Mapping

* Allow FrameLocalsProxy to matching mapping patterns
(cherry picked from commit d1c673b)

Co-authored-by: Mark Shannon <[email protected]>
mrahtz pushed a commit to mrahtz/cpython that referenced this issue Jun 30, 2024
* Register FrameLocalsProxy as a subclass of collections.abc.Mapping

* Allow FrameLocalsProxy to matching mapping patterns
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
* Register FrameLocalsProxy as a subclass of collections.abc.Mapping

* Allow FrameLocalsProxy to matching mapping patterns
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
* Register FrameLocalsProxy as a subclass of collections.abc.Mapping

* Allow FrameLocalsProxy to matching mapping patterns
markshannon pushed a commit that referenced this issue Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant