mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.10] bpo-44353: Expand NewType tests for complex __qualname__ (GH-27311) (GH-27326)
Make NewType pickleable by name.
(cherry picked from commit e89ef0ad2a)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
45caee2715
commit
05f5d8e48c
2 changed files with 48 additions and 15 deletions
|
|
@ -2375,8 +2375,10 @@ def name_by_id(user_id: UserId) -> str:
|
|||
"""
|
||||
|
||||
def __init__(self, name, tp):
|
||||
self.__name__ = name
|
||||
self.__qualname__ = name
|
||||
if '.' in name:
|
||||
name = name.rpartition('.')[-1]
|
||||
self.__name__ = name
|
||||
self.__module__ = _callee(default='typing')
|
||||
self.__supertype__ = tp
|
||||
|
||||
|
|
@ -2386,6 +2388,9 @@ def __repr__(self):
|
|||
def __call__(self, x):
|
||||
return x
|
||||
|
||||
def __reduce__(self):
|
||||
return self.__qualname__
|
||||
|
||||
def __or__(self, other):
|
||||
return Union[self, other]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue