def encode_and_decode_vint(x): f = BytesIO() vint.write_vint(f, x) return vint.read_vint(BytesIO(f.getvalue()))
def encode_and_decode_vint(x): f = StringIO() vint.write_vint(f, x) return vint.read_vint(StringIO(f.getvalue()))
def read_ioerror(port): mask = read_vuint(port) no = read_vint(port) if 1 & mask else None msg = read_bvec(port).decode('utf-8') if 2 & mask else None term = read_resolution(port) if 4 & mask else None return IOError(errno=no, message=msg, terminus=term)