|
23 | 23 |
|
24 | 24 | """
|
25 | 25 |
|
26 |
| -from types import FunctionType, EllipsisType |
| 26 | +import types |
27 | 27 | from copyreg import dispatch_table
|
28 | 28 | from copyreg import _extension_registry, _inverted_registry, _extension_cache
|
29 | 29 | from itertools import islice
|
@@ -737,7 +737,7 @@ def save_reduce(self, func, args, state=None, listitems=None,
|
737 | 737 |
|
738 | 738 | def save_none(self, obj):
|
739 | 739 | self.write(NONE)
|
740 |
| - dispatch[type(None)] = save_none |
| 740 | + dispatch[types.NoneType] = save_none |
741 | 741 |
|
742 | 742 | def save_bool(self, obj):
|
743 | 743 | if self.proto >= 2:
|
@@ -1117,15 +1117,15 @@ def save_global(self, obj, name=None):
|
1117 | 1117 | self.memoize(obj)
|
1118 | 1118 |
|
1119 | 1119 | def save_type(self, obj):
|
1120 |
| - if obj is type(None): |
| 1120 | + if obj is types.NoneType: |
1121 | 1121 | return self.save_reduce(type, (None,), obj=obj)
|
1122 |
| - elif obj is type(NotImplemented): |
| 1122 | + elif obj is types.NotImplementedType: |
1123 | 1123 | return self.save_reduce(type, (NotImplemented,), obj=obj)
|
1124 |
| - elif obj is EllipsisType: |
| 1124 | + elif obj is types.EllipsisType: |
1125 | 1125 | return self.save_reduce(type, (...,), obj=obj)
|
1126 | 1126 | return self.save_global(obj)
|
1127 | 1127 |
|
1128 |
| - dispatch[FunctionType] = save_global |
| 1128 | + dispatch[types.FunctionType] = save_global |
1129 | 1129 | dispatch[type] = save_type
|
1130 | 1130 |
|
1131 | 1131 |
|
|
0 commit comments