[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:
Łukasz Langa 2021-07-24 12:07:56 +02:00 committed by GitHub
parent 45caee2715
commit 05f5d8e48c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 15 deletions

View file

@ -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]