mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
[3.13] GH-120097: Make FrameLocalsProxy a mapping (GH-120101) (GH-120749)
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
This commit is contained in:
parent
fda8aec625
commit
95b4f9c9ad
4 changed files with 20 additions and 1 deletions
|
@ -13,6 +13,7 @@ try:
|
|||
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
|
||||
|
@ -421,6 +422,17 @@ class TestFrameLocals(unittest.TestCase):
|
|||
with self.assertRaises(TypeError):
|
||||
copy.deepcopy(d)
|
||||
|
||||
def test_is_mapping(self):
|
||||
x = 1
|
||||
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")
|
||||
|
||||
def _x_stringlikes(self):
|
||||
class StringSubclass(str):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue