summaryrefslogtreecommitdiff
path: root/Lib/copy.py
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-01-08 00:29:53 +0300
committerGitHub <noreply@github.com>2023-01-07 21:29:53 +0000
commit951303fd855838d47765dcd05471e14311dc9fdd (patch)
tree888e4a4e04d75358a6f6c3c7d25430ac802dbd72 /Lib/copy.py
parent6746135b0722a5359ce6346554c847afba603b5a (diff)
downloadcpython-git-951303fd855838d47765dcd05471e14311dc9fdd.tar.gz
gh-100815: Normalize `types` module usage in `copy` module (#100816)
Diffstat (limited to 'Lib/copy.py')
-rw-r--r--Lib/copy.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/Lib/copy.py b/Lib/copy.py
index 6e8c19bc65..da2908ef62 100644
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -101,13 +101,11 @@ _copy_dispatch = d = {}
def _copy_immutable(x):
return x
-for t in (type(None), int, float, bool, complex, str, tuple,
+for t in (types.NoneType, int, float, bool, complex, str, tuple,
bytes, frozenset, type, range, slice, property,
- types.BuiltinFunctionType, type(Ellipsis), type(NotImplemented),
- types.FunctionType, weakref.ref):
- d[t] = _copy_immutable
-t = getattr(types, "CodeType", None)
-if t is not None:
+ types.BuiltinFunctionType, types.EllipsisType,
+ types.NotImplementedType, types.FunctionType, types.CodeType,
+ weakref.ref):
d[t] = _copy_immutable
d[list] = list.copy
@@ -173,9 +171,9 @@ _deepcopy_dispatch = d = {}
def _deepcopy_atomic(x, memo):
return x
-d[type(None)] = _deepcopy_atomic
-d[type(Ellipsis)] = _deepcopy_atomic
-d[type(NotImplemented)] = _deepcopy_atomic
+d[types.NoneType] = _deepcopy_atomic
+d[types.EllipsisType] = _deepcopy_atomic
+d[types.NotImplementedType] = _deepcopy_atomic
d[int] = _deepcopy_atomic
d[float] = _deepcopy_atomic
d[bool] = _deepcopy_atomic