(self, module_name, name)
| 1207 | self.memoize(obj) |
| 1208 | |
| 1209 | def _save_toplevel_by_name(self, module_name, name): |
| 1210 | if self.proto >= 3: |
| 1211 | # Non-ASCII identifiers are supported only with protocols >= 3. |
| 1212 | encoding = "utf-8" |
| 1213 | else: |
| 1214 | if self.fix_imports: |
| 1215 | r_name_mapping = _compat_pickle.REVERSE_NAME_MAPPING |
| 1216 | r_import_mapping = _compat_pickle.REVERSE_IMPORT_MAPPING |
| 1217 | if (module_name, name) in r_name_mapping: |
| 1218 | module_name, name = r_name_mapping[(module_name, name)] |
| 1219 | elif module_name in r_import_mapping: |
| 1220 | module_name = r_import_mapping[module_name] |
| 1221 | encoding = "ascii" |
| 1222 | try: |
| 1223 | self.write(GLOBAL + bytes(module_name, encoding) + b'\n') |
| 1224 | except UnicodeEncodeError: |
| 1225 | raise PicklingError( |
| 1226 | f"can't pickle module identifier {module_name!r} using " |
| 1227 | f"pickle protocol {self.proto}") |
| 1228 | try: |
| 1229 | self.write(bytes(name, encoding) + b'\n') |
| 1230 | except UnicodeEncodeError: |
| 1231 | raise PicklingError( |
| 1232 | f"can't pickle global identifier {name!r} using " |
| 1233 | f"pickle protocol {self.proto}") |
| 1234 | |
| 1235 | def save_type(self, obj): |
| 1236 | if obj is type(None): |
no test coverage detected