8000 bpo-41810: Reintroduce `types.EllipsisType`, `.NoneType` & `.NotImplementedType` by BvB93 · Pull Request #22336 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-41810: Reintroduce types.EllipsisType, .NoneType & .NotImplementedType #22336

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

Merged
merged 13 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replaced type(...) and type(ellipsis) with types.EllipsisType
  • Loading branch information
Bas van Beek committed Sep 21, 2020
commit 0a97a885178adaf79d93041aed5bbab3c9e7d264
5 changes: 3 additions & 2 deletions Lib/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
:copyright: Copyright 2008 by Armin Ronacher.
:license: Python License.
"""
import types
import sys
from _ast import *
from contextlib import contextmanager, nullcontext
Expand Down Expand Up @@ -572,7 +573,7 @@ def __new__(cls, *args, **kwargs):
Str: (str,),
Bytes: (bytes,),
NameConstant: (type(None), bool),
Ellipsis: (type(...),),
Ellipsis: (types.EllipsisType,),
}
_const_types_not = {
Num: (bool,),
Expand All @@ -586,7 +587,7 @@ def __new__(cls, *args, **kwargs):
complex: 'Num',
str: 'Str',
bytes: 'Bytes',
type(...): 'Ellipsis',
types.EllipsisType: 'Ellipsis',
}

class slice(AST):
Expand Down
6 changes: 3 additions & 3 deletions Lib/copy.py
8000
Original file line numberDiff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def _copy_immutable(x):
return x
for t in (type(None), int, float, bool, complex, str, tuple,
bytes, frozenset, type, range, slice, property,
types.BuiltinFunctionType, type(Ellipsis), type(NotImplemented),
types.FunctionType, weakref.ref):
types.BuiltinFunctionType, types.EllipsisType,
type(NotImplemented), types.FunctionType, weakref.ref):
d[t] = _copy_immutable
t = getattr(types, "CodeType", None)
if t is not None:
Expand Down Expand Up @@ -182,7 +182,7 @@ def deepcopy(x, memo=None, _nil=[]):
def _deepcopy_atomic(x, memo):
return x
d[type(None)] = _deepcopy_atomic
d[type(Ellipsis)] = _deepcopy_atomic
d[types.EllipsisType] = _deepcopy_atomic
d[type(NotImplemented)] = _deepcopy_atomic
d[int] = _deepcopy_atomic
d[float] = _deepcopy_atomic
Expand Down
1 change: 0 additions & 1 deletion Lib/lib2to3/fixes/fix_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
'ComplexType' : 'complex',
'DictType': 'dict',
'DictionaryType' : 'dict',
'EllipsisType' : 'type(Ellipsis)',
#'FileType' : 'io.IOBase',
'FloatType': 'float',
'IntType': 'int',
Expand Down
4 changes: 2 additions & 2 deletions Lib/pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

"""

from types import FunctionType
from types import FunctionType, EllipsisType
from copyreg import dispatch_table
from copyreg import _extension_registry, _inverted_registry, _extension_cache
from itertools import islice
Expand Down Expand Up @@ -1121,7 +1121,7 @@ def save_type(self, obj):
return self.save_reduce(type, (None,), obj=obj)
elif obj is type(NotImplemented):
return self.save_reduce(type, (NotImplemented,), obj=obj)
elif obj is type(...):
elif obj is EllipsisType:
return self.save_reduce(type, (...,), obj=obj)
return self.save_global(obj)

Expand Down
0