mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
GH-120097: Make FrameLocalsProxy a mapping (#120101)
* Register FrameLocalsProxy as a subclass of collections.abc.Mapping * Allow FrameLocalsProxy to matching mapping patterns
This commit is contained in:
parent
00257c746c
commit
d1c673b658
4 changed files with 20 additions and 1 deletions
|
@ -85,6 +85,10 @@ dict_values = type({}.values())
|
|||
dict_items = type({}.items())
|
||||
## misc ##
|
||||
mappingproxy = type(type.__dict__)
|
||||
def _get_framelocalsproxy():
|
||||
return type(sys._getframe().f_locals)
|
||||
framelocalsproxy = _get_framelocalsproxy()
|
||||
del _get_framelocalsproxy
|
||||
generator = type((lambda: (yield))())
|
||||
## coroutine ##
|
||||
async def _coro(): pass
|
||||
|
@ -836,6 +840,7 @@ class Mapping(Collection):
|
|||
__reversed__ = None
|
||||
|
||||
Mapping.register(mappingproxy)
|
||||
Mapping.register(framelocalsproxy)
|
||||
|
||||
|
||||
class MappingView(Sized):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue