def default(obj): if isinstance(obj, PasteFile): return msgpack.ExtType(42, obj.to_dict()) raise TypeError('Unknown type: %r' % (obj,))