(code:types.CodeType)
| 579 | |
| 580 | def _reconstruct_code(*args): return types.CodeType(*args) |
| 581 | def _serialize_code(code:types.CodeType): |
| 582 | args = inspect.signature(types.CodeType).parameters # NOTE: this works in Python 3.10 and up |
| 583 | return _reconstruct_code, tuple(code.__getattribute__('co_'+x.replace('codestring', 'code').replace('constants', 'consts')) for x in args) |
| 584 | copyreg.pickle(types.CodeType, _serialize_code) |
| 585 | |
| 586 | def _serialize_module(module:types.ModuleType): return importlib.import_module, (module.__name__,) |
nothing calls this directly
no test coverage detected
searching dependent graphs…