-
-
Notifications
You must be signed in to change notification settings - Fork 32k
GH-120097: Make FrameLocalsProxy a mapping #120101
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
except ImportError: | ||
_testcapi = None | ||
|
||
from collections.abc import Mapping | ||
from test import support | ||
from test.support import import_helper, threading_helper, Py_GIL_DISABLED | ||
from test.support.script_helper import assert_python_ok | ||
|
@@ -420,6 +421,17 @@ def test_unsupport(self): | |
with self.assertRaises(TypeError): | ||
copy.deepcopy(d) | ||
|
||
def test_is_mapping(self): | ||
x = 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The contents are irrelevant, but we want something just to make sure we are testing the right thing. |
||
d = sys._getframe().f_locals | ||
self.assertIsInstance(d, Mapping) | ||
match d: | ||
case {"x": value}: | ||
self.assertEqual(value, 1) | ||
kind = "mapping" | ||
case _: | ||
kind = "other" | ||
self.assertEqual(kind, "mapping") | ||
|
||
class TestFrameCApi(unittest.TestCase): | ||
def test_basic(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
``FrameLocalsProxy`` now subclasses ``collections.abc.Mapping`` and can be | ||
matched as a mapping in ``match`` statements |
Uh oh!
There was an error while loading. Please reload this page.