| 1125 | dispatch[set] = save_set |
| 1126 | |
| 1127 | def save_frozenset(self, obj): |
| 1128 | save = self.save |
| 1129 | write = self.write |
| 1130 | |
| 1131 | if self.proto < 4: |
| 1132 | self.save_reduce(frozenset, (list(obj),), obj=obj) |
| 1133 | return |
| 1134 | |
| 1135 | write(MARK) |
| 1136 | try: |
| 1137 | for item in obj: |
| 1138 | save(item) |
| 1139 | except BaseException as exc: |
| 1140 | exc.add_note(f'when serializing {_T(obj)} element') |
| 1141 | raise |
| 1142 | |
| 1143 | if id(obj) in self.memo: |
| 1144 | # If the object is already in the memo, this means it is |
| 1145 | # recursive. In this case, throw away everything we put on the |
| 1146 | # stack, and fetch the object back from the memo. |
| 1147 | write(POP_MARK + self.get(self.memo[id(obj)][0])) |
| 1148 | return |
| 1149 | |
| 1150 | write(FROZENSET) |
| 1151 | self.memoize(obj) |
| 1152 | dispatch[frozenset] = save_frozenset |
| 1153 | |
| 1154 | def save_global(self, obj, name=None): |