(self, module_name, name)
| 1233 | self.memoize(obj) |
| 1234 | |
| 1235 | def _save_toplevel_by_name(self, module_name, name): |
| 1236 | if self.proto >= 3: |
| 1237 | # Non-ASCII identifiers are supported only with protocols >= 3. |
| 1238 | encoding = "utf-8" |
| 1239 | else: |
| 1240 | if self.fix_imports: |
| 1241 | r_name_mapping = _compat_pickle.REVERSE_NAME_MAPPING |
| 1242 | r_import_mapping = _compat_pickle.REVERSE_IMPORT_MAPPING |
| 1243 | if (module_name, name) in r_name_mapping: |
| 1244 | module_name, name = r_name_mapping[(module_name, name)] |
| 1245 | elif module_name in r_import_mapping: |
| 1246 | module_name = r_import_mapping[module_name] |
| 1247 | encoding = "ascii" |
| 1248 | try: |
| 1249 | self.write(GLOBAL + bytes(module_name, encoding) + b'\n') |
| 1250 | except UnicodeEncodeError: |
| 1251 | raise PicklingError( |
| 1252 | f"can't pickle module identifier {module_name!r} using " |
| 1253 | f"pickle protocol {self.proto}") |
| 1254 | try: |
| 1255 | self.write(bytes(name, encoding) + b'\n') |
| 1256 | except UnicodeEncodeError: |
| 1257 | raise PicklingError( |
| 1258 | f"can't pickle global identifier {name!r} using " |
| 1259 | f"pickle protocol {self.proto}") |
| 1260 | |
| 1261 | def save_type(self, obj): |
| 1262 | if obj is type(None): |
no test coverage detected