/* Generated by Cython 0.29.24 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "depends": [
            "edgedb/pgproto/debug.h"
        ],
        "extra_compile_args": [
            "-O2",
            "-std=gnu99",
            "-fsigned-char",
            "-Wall",
            "-Wsign-compare",
            "-Wconversion"
        ],
        "include_dirs": [
            "./edgedb/pgproto",
            "edgedb/pgproto/",
            "edgedb/datatypes"
        ],
        "name": "edgedb.protocol.protocol",
        "sources": [
            "edgedb/protocol/protocol.pyx"
        ]
    },
    "module_name": "edgedb.protocol.protocol"
}
END: Cython Metadata */

#ifndef PY_SSIZE_T_CLEAN
#define PY_SSIZE_T_CLEAN
#endif /* PY_SSIZE_T_CLEAN */
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_24"
#define CYTHON_HEX_VERSION 0x001D18F0
#define CYTHON_FUTURE_DIVISION 1
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x02070000
    #define HAVE_LONG_LONG
  #endif
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
  #define CYTHON_COMPILING_IN_PYPY 1
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #ifndef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL 1
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #endif
  #ifndef CYTHON_USE_DICT_VERSIONS
    #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  #endif
  #ifndef CYTHON_USE_EXC_INFO_STACK
    #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
  #undef SHIFT
  #undef BASE
  #undef MASK
  #ifdef SIZEOF_VOID_P
    enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  #endif
#endif
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus) && __cplusplus >= 201103L
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #elif __has_cpp_attribute(gnu::fallthrough)
      #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__ ) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #elif defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  #define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef METH_STACKLESS
  #define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
  #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
  #define PyMem_RawFree(p)             PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  *key = PyThread_create_key();
  return 0;
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  *key = Py_tss_NEEDS_INIT;
  return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  PyThread_delete_key(*key);
  *key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  return PyThread_get_key_value(*key);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #if defined(PyUnicode_IS_READY)
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #else
  #define __Pyx_PyUnicode_READY(op)       (0)
  #endif
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
  #else
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  #endif
  #else
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
  #endif
#else
  #define CYTHON_PEP393_ENABLED 0
  #define PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#ifndef PyObject_Unicode
  #define PyObject_Unicode             PyObject_Str
#endif
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#if PY_VERSION_HEX >= 0x030900A4
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
#else
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
#else
  #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif

#define __PYX_MARK_ERR_POS(f_index, lineno) \
    { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
#define __PYX_ERR(f_index, lineno, Ln_error) \
    { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#define __PYX_HAVE__edgedb__protocol__protocol
#define __PYX_HAVE_API__edgedb__protocol__protocol
/* Early includes */
#include <string.h>
#include <stdio.h>
#include "pythread.h"
#include <stdint.h>
#include "debug.h"
#include "datetime.h"
#include "./hton.h"
#include "datatypes.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif

typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
    return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime = NULL;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "edgedb/protocol/./lru.pyx",
  "edgedb/protocol/./codecs/./base.pyx",
  "stringsource",
  "edgedb/protocol/./codecs/./namedtuple.pyx",
  "edgedb/protocol/./codecs/codecs.pyx",
  "edgedb/protocol/protocol.pyx",
  "edgedb/protocol/./codecs/./scalar.pyx",
  "edgedb/protocol/./codecs/./tuple.pyx",
  "edgedb/protocol/./codecs/./object.pyx",
  "edgedb/protocol/./codecs/./array.pyx",
  "edgedb/protocol/./codecs/./set.pyx",
  "edgedb/protocol/./codecs/./enum.pyx",
  "edgedb/protocol/protocol.pxd",
  "edgedb/pgproto/./frb.pxd",
  "edgedb/pgproto/./buffer.pxd",
  ".eggs/Cython-0.29.24-py3.10.egg/Cython/Includes/cpython/datetime.pxd",
  ".eggs/Cython-0.29.24-py3.10.egg/Cython/Includes/cpython/type.pxd",
  ".eggs/Cython-0.29.24-py3.10.egg/Cython/Includes/cpython/bool.pxd",
  ".eggs/Cython-0.29.24-py3.10.egg/Cython/Includes/cpython/complex.pxd",
  "edgedb/datatypes/./relative_duration.pxd",
  "edgedb/datatypes/./enum.pxd",
  "edgedb/datatypes/./config_memory.pxd",
  "edgedb/protocol/./codecs/./edb_types.pxi",
};

/*--- Type declarations ---*/
struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer;
struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer;
struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext;
struct __pyx_obj_6edgedb_9datatypes_9datatypes_RelativeDuration;
struct __pyx_obj_6edgedb_9datatypes_9datatypes_EnumDescriptor;
struct __pyx_obj_6edgedb_9datatypes_9datatypes_EnumValue;
struct __pyx_obj_6edgedb_9datatypes_9datatypes_ConfigMemory;
struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping;
struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec;
struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride;
struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec;
struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec;
struct __pyx_obj_6edgedb_8protocol_8protocol_NullCodec;
struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec;
struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext;
struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec;
struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec;
struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec;
struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec;
struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec;
struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec;
struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec;
struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec;
struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry;
struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache;
struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol;
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message;
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly;
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect;
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse;
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute;
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute;
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query;
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous;
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump;
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync;
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore;
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect;
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl;
struct __pyx_obj___Pyx_EnumMeta;
struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer;
struct __pyx_opt_args_6edgedb_7pgproto_7pgproto_10ReadBuffer_redirect_messages;

/* "edgedb/pgproto/frb.pxd":10
 * cdef:
 * 
 *     struct FRBuffer:             # <<<<<<<<<<<<<<
 *         const char* buf
 *         ssize_t len
 */
struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer {
  char const *buf;
  Py_ssize_t len;
};

/* "edgedb/pgproto/buffer.pxd":62
 * 
 * 
 * ctypedef const char * (*try_consume_message_method)(object, ssize_t*)             # <<<<<<<<<<<<<<
 * ctypedef int32_t (*take_message_type_method)(object, char) except -1
 * ctypedef int32_t (*take_message_method)(object) except -1
 */
typedef char const *(*__pyx_t_6edgedb_7pgproto_7pgproto_try_consume_message_method)(PyObject *, Py_ssize_t *);

/* "edgedb/pgproto/buffer.pxd":63
 * 
 * ctypedef const char * (*try_consume_message_method)(object, ssize_t*)
 * ctypedef int32_t (*take_message_type_method)(object, char) except -1             # <<<<<<<<<<<<<<
 * ctypedef int32_t (*take_message_method)(object) except -1
 * ctypedef char (*get_message_type_method)(object)
 */
typedef int32_t (*__pyx_t_6edgedb_7pgproto_7pgproto_take_message_type_method)(PyObject *, char);

/* "edgedb/pgproto/buffer.pxd":64
 * ctypedef const char * (*try_consume_message_method)(object, ssize_t*)
 * ctypedef int32_t (*take_message_type_method)(object, char) except -1
 * ctypedef int32_t (*take_message_method)(object) except -1             # <<<<<<<<<<<<<<
 * ctypedef char (*get_message_type_method)(object)
 * 
 */
typedef int32_t (*__pyx_t_6edgedb_7pgproto_7pgproto_take_message_method)(PyObject *);

/* "edgedb/pgproto/buffer.pxd":65
 * ctypedef int32_t (*take_message_type_method)(object, char) except -1
 * ctypedef int32_t (*take_message_method)(object) except -1
 * ctypedef char (*get_message_type_method)(object)             # <<<<<<<<<<<<<<
 * 
 * 
 */
typedef char (*__pyx_t_6edgedb_7pgproto_7pgproto_get_message_type_method)(PyObject *);

/* "edgedb/pgproto/buffer.pxd":130
 *     cdef bytes consume_message(self)
 *     cdef discard_message(self)
 *     cdef redirect_messages(self, WriteBuffer buf, char mtype, int stop_at=?)             # <<<<<<<<<<<<<<
 *     cdef bytearray consume_messages(self, char mtype)
 *     cdef finish_message(self)
 */
struct __pyx_opt_args_6edgedb_7pgproto_7pgproto_10ReadBuffer_redirect_messages {
  int __pyx_n;
  int stop_at;
};

/* "edgedb/pgproto/codecs/__init__.pxd":14
 * 
 * 
 * ctypedef object (*encode_func)(CodecContext settings,             # <<<<<<<<<<<<<<
 *                                WriteBuffer buf,
 *                                object obj)
 */
typedef PyObject *(*__pyx_t_6edgedb_7pgproto_7pgproto_encode_func)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *);

/* "edgedb/pgproto/codecs/__init__.pxd":18
 *                                object obj)
 * 
 * ctypedef object (*decode_func)(CodecContext settings,             # <<<<<<<<<<<<<<
 *                                FRBuffer *buf)
 * 
 */
typedef PyObject *(*__pyx_t_6edgedb_7pgproto_7pgproto_decode_func)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *);
struct __pyx_opt_args_6edgedb_8protocol_8protocol_9BaseCodec_dump;
struct __pyx_opt_args_6edgedb_8protocol_8protocol_19CodecPythonOverride_dump;
struct __pyx_opt_args_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_dump;
struct __pyx_opt_args_6edgedb_8protocol_8protocol_10TupleCodec_dump;
struct __pyx_opt_args_6edgedb_8protocol_8protocol_14BaseArrayCodec_dump;

/* "edgedb/protocol/protocol.pxd":43
 * 
 * 
 * cpdef enum IoFormat:             # <<<<<<<<<<<<<<
 *     BINARY = b'b'
 *     JSON = b'j'
 */
enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat {

  /* "edgedb/protocol/protocol.pxd":46
 *     BINARY = b'b'
 *     JSON = b'j'
 *     JSON_ELEMENTS = b'J'             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_e_6edgedb_8protocol_8protocol_BINARY = 'b',
  __pyx_e_6edgedb_8protocol_8protocol_JSON = 'j',
  __pyx_e_6edgedb_8protocol_8protocol_JSON_ELEMENTS = 'J'
};

/* "edgedb/protocol/protocol.pxd":49
 * 
 * 
 * cdef enum TransactionStatus:             # <<<<<<<<<<<<<<
 *     TRANS_IDLE = 0                 # connection idle
 *     TRANS_ACTIVE = 1               # command in progress
 */
enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus {
  __pyx_e_6edgedb_8protocol_8protocol_TRANS_IDLE = 0,
  __pyx_e_6edgedb_8protocol_8protocol_TRANS_ACTIVE = 1,
  __pyx_e_6edgedb_8protocol_8protocol_TRANS_INTRANS = 2,
  __pyx_e_6edgedb_8protocol_8protocol_TRANS_INERROR = 3,
  __pyx_e_6edgedb_8protocol_8protocol_TRANS_UNKNOWN = 4
};

/* "edgedb/protocol/protocol.pxd":57
 * 
 * 
 * cdef enum EdgeParseFlags:             # <<<<<<<<<<<<<<
 *     PARSE_HAS_RESULT = 1 << 0
 *     PARSE_SINGLETON_RESULT = 1 << 1
 */
enum __pyx_t_6edgedb_8protocol_8protocol_EdgeParseFlags {

  /* "edgedb/protocol/protocol.pxd":59
 * cdef enum EdgeParseFlags:
 *     PARSE_HAS_RESULT = 1 << 0
 *     PARSE_SINGLETON_RESULT = 1 << 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_e_6edgedb_8protocol_8protocol_PARSE_HAS_RESULT = (1 << 0),
  __pyx_e_6edgedb_8protocol_8protocol_PARSE_SINGLETON_RESULT = (1 << 1)
};

/* "edgedb/protocol/protocol.pxd":62
 * 
 * 
 * cdef enum AuthenticationStatuses:             # <<<<<<<<<<<<<<
 *     AUTH_OK = 0
 *     AUTH_SASL = 10
 */
enum __pyx_t_6edgedb_8protocol_8protocol_AuthenticationStatuses {
  __pyx_e_6edgedb_8protocol_8protocol_AUTH_OK = 0,
  __pyx_e_6edgedb_8protocol_8protocol_AUTH_SASL = 10,
  __pyx_e_6edgedb_8protocol_8protocol_AUTH_SASL_CONTINUE = 11,
  __pyx_e_6edgedb_8protocol_8protocol_AUTH_SASL_FINAL = 12
};

/* "edgedb/protocol/codecs/base.pxd":32
 *     cdef decode(self, FRBuffer *buf)
 * 
 *     cdef dump(self, int level=?)             # <<<<<<<<<<<<<<
 * 
 * 
 */
struct __pyx_opt_args_6edgedb_8protocol_8protocol_9BaseCodec_dump {
  int __pyx_n;
  int level;
};

/* "edgedb/protocol/protocol.pxd":40
 * 
 * 
 * ctypedef object (*decode_row_method)(BaseCodec, FRBuffer *buf)             # <<<<<<<<<<<<<<
 * 
 * 
 */
typedef PyObject *(*__pyx_t_6edgedb_8protocol_8protocol_decode_row_method)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *);

/* "edgedb/protocol/codecs/base.pyx":66
 *         return self.decoder(self.codec.decode(buf))
 * 
 *     cdef dump(self, int level = 0):             # <<<<<<<<<<<<<<
 *         return f'{level * " "}<Python override>{self.name}'
 * 
 */
struct __pyx_opt_args_6edgedb_8protocol_8protocol_19CodecPythonOverride_dump {
  int __pyx_n;
  int level;
};

/* "edgedb/protocol/codecs/base.pyx":198
 *         self.descriptor = None
 * 
 *     cdef dump(self, int level = 0):             # <<<<<<<<<<<<<<
 *         buf = [f'{level * " "}{self.name}']
 *         for pos, codec in enumerate(self.fields_codecs):
 */
struct __pyx_opt_args_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_dump {
  int __pyx_n;
  int level;
};

/* "edgedb/protocol/codecs/tuple.pyx":61
 *         return result
 * 
 *     cdef dump(self, int level = 0):             # <<<<<<<<<<<<<<
 *         buf = [f'{level * " "}{self.name}']
 *         for codec in self.fields_codecs:
 */
struct __pyx_opt_args_6edgedb_8protocol_8protocol_10TupleCodec_dump {
  int __pyx_n;
  int level;
};

/* "edgedb/protocol/codecs/array.pyx":131
 *         return result
 * 
 *     cdef dump(self, int level = 0):             # <<<<<<<<<<<<<<
 *         return f'{level * " "}{self.name}\n{self.sub_codec.dump(level + 1)}'
 * 
 */
struct __pyx_opt_args_6edgedb_8protocol_8protocol_14BaseArrayCodec_dump {
  int __pyx_n;
  int level;
};

/* "edgedb/pgproto/buffer.pxd":8
 * 
 * 
 * cdef class WriteBuffer:             # <<<<<<<<<<<<<<
 *     cdef:
 *         # Preallocated small buffer
 */
struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer {
  PyObject_HEAD
  struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_vtab;
  int _smallbuf_inuse;
  char _smallbuf[0x400];
  char *_buf;
  Py_ssize_t _size;
  Py_ssize_t _length;
  int _view_count;
  int _message_mode;
};


/* "edgedb/pgproto/buffer.pxd":68
 * 
 * 
 * cdef class ReadBuffer:             # <<<<<<<<<<<<<<
 *     cdef:
 *         # A deque of buffers (bytes objects)
 */
struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer {
  PyObject_HEAD
  struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *__pyx_vtab;
  PyObject *_bufs;
  PyObject *_bufs_append;
  PyObject *_bufs_popleft;
  PyObject *_buf0;
  PyObject *_buf0_prev;
  int32_t _bufs_len;
  Py_ssize_t _pos0;
  Py_ssize_t _len0;
  Py_ssize_t _length;
  char _current_message_type;
  int32_t _current_message_len;
  Py_ssize_t _current_message_len_unread;
  int _current_message_ready;
};


/* "edgedb/pgproto/codecs/__init__.pxd":8
 * 
 * 
 * cdef class CodecContext:             # <<<<<<<<<<<<<<
 * 
 *     cpdef get_text_codec(self)
 */
struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext {
  PyObject_HEAD
  struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_vtab;
};


/* "edgedb/datatypes/relative_duration.pxd":24
 * 
 * @cython.final
 * cdef class RelativeDuration:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_6edgedb_9datatypes_9datatypes_RelativeDuration {
  PyObject_HEAD
  int64_t microseconds;
  int32_t days;
  int32_t months;
};


/* "edgedb/datatypes/enum.pxd":20
 * 
 * 
 * cdef class EnumDescriptor:             # <<<<<<<<<<<<<<
 *     cdef:
 *         object tid
 */
struct __pyx_obj_6edgedb_9datatypes_9datatypes_EnumDescriptor {
  PyObject_HEAD
  struct __pyx_vtabstruct_6edgedb_9datatypes_9datatypes_EnumDescriptor *__pyx_vtab;
  PyObject *tid;
  PyObject *index;
  PyObject *labels;
};


/* "edgedb/datatypes/enum.pxd":29
 * 
 * 
 * cdef class EnumValue:             # <<<<<<<<<<<<<<
 *     cdef:
 *         EnumDescriptor desc
 */
struct __pyx_obj_6edgedb_9datatypes_9datatypes_EnumValue {
  PyObject_HEAD
  struct __pyx_vtabstruct_6edgedb_9datatypes_9datatypes_EnumValue *__pyx_vtab;
  struct __pyx_obj_6edgedb_9datatypes_9datatypes_EnumDescriptor *desc;
  PyObject *label;
};


/* "edgedb/datatypes/config_memory.pxd":24
 * 
 * @cython.final
 * cdef class ConfigMemory:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_6edgedb_9datatypes_9datatypes_ConfigMemory {
  PyObject_HEAD
  int64_t _bytes;
};


/* "edgedb/protocol/lru.pxd":20
 * 
 * 
 * cdef class LRUMapping:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping {
  PyObject_HEAD
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_LRUMapping *__pyx_vtab;
  PyObject *_dict;
  int _maxsize;
  PyObject *_dict_move_to_end;
  PyObject *_dict_get;
};


/* "edgedb/protocol/codecs/base.pxd":20
 * 
 * 
 * cdef class BaseCodec:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec {
  PyObject_HEAD
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *__pyx_vtab;
  PyObject *tid;
  PyObject *name;
};


/* "edgedb/protocol/codecs/base.pxd":35
 * 
 * 
 * cdef class CodecPythonOverride(BaseCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec __pyx_base;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *codec;
  PyObject *encoder;
  PyObject *decoder;
};


/* "edgedb/protocol/codecs/base.pxd":49
 * 
 * 
 * cdef class BaseRecordCodec(BaseCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec __pyx_base;
  PyObject *fields_codecs;
  uint64_t encoder_flags;
};


/* "edgedb/protocol/codecs/base.pxd":58
 * 
 * 
 * cdef class EmptyTupleCodec(BaseCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec __pyx_base;
  PyObject *empty_tup;
};


/* "edgedb/protocol/codecs/base.pxd":64
 * 
 * 
 * cdef class NullCodec(BaseCodec):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_NullCodec {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec __pyx_base;
};


/* "edgedb/protocol/codecs/base.pxd":68
 * 
 * 
 * cdef class BaseNamedRecordCodec(BaseRecordCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec __pyx_base;
  PyObject *descriptor;
};


/* "edgedb/protocol/codecs/base.pxd":75
 * 
 * @cython.final
 * cdef class EdegDBCodecContext(pgproto.CodecContext):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext {
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext __pyx_base;
  PyObject *_codec;
};


/* "edgedb/protocol/codecs/scalar.pxd":21
 * 
 * @cython.final
 * cdef class ScalarCodec(BaseCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec __pyx_base;
  __pyx_t_6edgedb_7pgproto_7pgproto_encode_func c_encoder;
  __pyx_t_6edgedb_7pgproto_7pgproto_decode_func c_decoder;
};


/* "edgedb/protocol/codecs/tuple.pxd":21
 * 
 * @cython.final
 * cdef class TupleCodec(BaseRecordCodec):             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec __pyx_base;
};


/* "edgedb/protocol/codecs/namedtuple.pxd":21
 * 
 * @cython.final
 * cdef class NamedTupleCodec(BaseNamedRecordCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef encode_kwargs(self, WriteBuffer buf, dict obj)
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec __pyx_base;
};


/* "edgedb/protocol/codecs/object.pxd":21
 * 
 * @cython.final
 * cdef class ObjectCodec(BaseNamedRecordCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef encode_args(self, WriteBuffer buf, dict obj)
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec __pyx_base;
};


/* "edgedb/protocol/codecs/array.pxd":20
 * 
 * 
 * cdef class BaseArrayCodec(BaseCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec __pyx_base;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *sub_codec;
  int32_t cardinality;
};


/* "edgedb/protocol/codecs/array.pxd":35
 * 
 * @cython.final
 * cdef class ArrayCodec(BaseArrayCodec):             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec __pyx_base;
};


/* "edgedb/protocol/codecs/set.pxd":21
 * 
 * @cython.final
 * cdef class SetCodec(BaseArrayCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef inline _decode_array_set(self, FRBuffer *buf)
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec __pyx_base;
};


/* "edgedb/protocol/codecs/enum.pxd":21
 * 
 * @cython.final
 * cdef class EnumCodec(BaseCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec __pyx_base;
  PyObject *descriptor;
};


/* "edgedb/protocol/codecs/codecs.pxd":30
 * 
 * 
 * cdef class CodecsRegistry:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry {
  PyObject_HEAD
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_vtab;
  struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *codecs_build_cache;
  struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *codecs;
  PyObject *base_codec_overrides;
};


/* "edgedb/protocol/protocol.pxd":69
 * 
 * 
 * cdef class QueryCodecsCache:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache {
  PyObject_HEAD
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_vtab;
  struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *queries;
};


/* "edgedb/protocol/protocol.pxd":80
 * 
 * 
 * cdef class SansIOProtocol:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol {
  PyObject_HEAD
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_vtab;
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *buffer;
  int connected;
  int cancelled;
  PyObject *con;
  PyObject *con_params;
  int tls_compat;
  PyObject *backend_secret;
  enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus xact_status;
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *internal_reg;
  PyObject *server_settings;
  PyObject *last_status;
  PyObject *last_details;
  PyObject *protocol_version;
};


/* "edgedb/protocol/protocol.pyx":165
 *         raise NotImplementedError
 * 
 *     async def wait_for_message(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message {
  PyObject_HEAD
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self;
};


/* "edgedb/protocol/protocol.pyx":168
 *         raise NotImplementedError
 * 
 *     async def try_recv_eagerly(self):             # <<<<<<<<<<<<<<
 *         # If there's data in the socket try reading it into the
 *         # buffer.  Needed for blocking-io connections.
 */
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly {
  PyObject_HEAD
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self;
};


/* "edgedb/protocol/protocol.pyx":173
 *         raise NotImplementedError
 * 
 *     async def wait_for_connect(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect {
  PyObject_HEAD
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self;
};


/* "edgedb/protocol/protocol.pyx":224
 *             buf.write_int16(0)  # no headers
 * 
 *     async def _parse(             # <<<<<<<<<<<<<<
 *         self,
 *         query: str,
 */
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse {
  PyObject_HEAD
  PyObject *__pyx_v__;
  PyObject *__pyx_v_allow_capabilities;
  PyObject *__pyx_v_attrs;
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf;
  PyObject *__pyx_v_cardinality;
  PyObject *__pyx_v_exc;
  int __pyx_v_expect_one;
  PyObject *__pyx_v_implicit_limit;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_in_dc;
  PyObject *__pyx_v_in_type_id;
  PyObject *__pyx_v_inline_typeids;
  PyObject *__pyx_v_inline_typenames;
  enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __pyx_v_io_format;
  PyObject *__pyx_v_methname;
  char __pyx_v_mtype;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_out_dc;
  PyObject *__pyx_v_out_type_id;
  PyObject *__pyx_v_query;
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_reg;
  PyObject *__pyx_v_required_one;
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self;
  int16_t __pyx_v_type_size;
};


/* "edgedb/protocol/protocol.pyx":353
 *                 'the connection has been closed')
 * 
 *     async def _execute(self, BaseCodec in_dc, BaseCodec out_dc, args, kwargs):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer packet
 */
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute {
  PyObject_HEAD
  PyObject *__pyx_v_args;
  PyObject *__pyx_v_attrs;
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf;
  PyObject *__pyx_v_ex;
  PyObject *__pyx_v_exc;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_in_dc;
  PyObject *__pyx_v_kwargs;
  char __pyx_v_mtype;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_out_dc;
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_packet;
  PyObject *__pyx_v_result;
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self;
};


/* "edgedb/protocol/protocol.pyx":424
 *         return result, attrs
 * 
 *     async def _optimistic_execute(             # <<<<<<<<<<<<<<
 *         self,
 *         *,
 */
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute {
  PyObject_HEAD
  PyObject *__pyx_v_allow_capabilities;
  PyObject *__pyx_v_args;
  PyObject *__pyx_v_attrs;
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf;
  PyObject *__pyx_v_capabilities;
  PyObject *__pyx_v_ex;
  PyObject *__pyx_v_exc;
  int __pyx_v_expect_one;
  PyObject *__pyx_v_headers;
  PyObject *__pyx_v_implicit_limit;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_in_dc;
  int __pyx_v_inline_typeids;
  int __pyx_v_inline_typenames;
  PyObject *__pyx_v_io_format;
  PyObject *__pyx_v_kwargs;
  PyObject *__pyx_v_methname;
  char __pyx_v_mtype;
  PyObject *__pyx_v_new_cardinality;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_out_dc;
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_packet;
  struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_qc;
  PyObject *__pyx_v_query;
  int __pyx_v_re_exec;
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_reg;
  int __pyx_v_required_one;
  PyObject *__pyx_v_result;
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self;
};


/* "edgedb/protocol/protocol.pyx":551
 *             return result, attrs
 * 
 *     async def simple_query(self, str query, capabilities: enums.Capability):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer buf
 */
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query {
  PyObject_HEAD
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf;
  PyObject *__pyx_v_cap_bytes;
  PyObject *__pyx_v_capabilities;
  PyObject *__pyx_v_exc;
  char __pyx_v_mtype;
  PyObject *__pyx_v_query;
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self;
};


/* "edgedb/protocol/protocol.pyx":601
 *             raise exc
 * 
 *     async def execute_anonymous(             # <<<<<<<<<<<<<<
 *         self,
 *         *,
 */
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous {
  PyObject_HEAD
  PyObject *__pyx_v_allow_capabilities;
  PyObject *__pyx_v_args;
  PyObject *__pyx_v_attrs;
  PyObject *__pyx_v_capabilities;
  PyObject *__pyx_v_cardinality;
  PyObject *__pyx_v_codecs;
  int __pyx_v_expect_one;
  PyObject *__pyx_v_has_na_cardinality;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_headers;
  PyObject *__pyx_v_implicit_limit;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_in_dc;
  PyObject *__pyx_v_inline_typeids;
  PyObject *__pyx_v_inline_typenames;
  PyObject *__pyx_v_io_format;
  PyObject *__pyx_v_kwargs;
  PyObject *__pyx_v_methname;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_out_dc;
  struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_qc;
  PyObject *__pyx_v_query;
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_reg;
  PyObject *__pyx_v_required_one;
  PyObject *__pyx_v_ret;
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self;
};


/* "edgedb/protocol/protocol.pyx":719
 *                     return ret, attrs
 * 
 *     async def dump(self, header_callback, block_callback):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer buf
 */
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump {
  PyObject_HEAD
  PyObject *__pyx_v_block_callback;
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf;
  int __pyx_v_data_received;
  PyObject *__pyx_v_exc;
  PyObject *__pyx_v_header_callback;
  int __pyx_v_header_received;
  char __pyx_v_mtype;
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self;
};


/* "edgedb/protocol/protocol.pyx":786
 *             raise exc
 * 
 *     async def _sync(self):             # <<<<<<<<<<<<<<
 *         cdef char mtype
 *         self.write(WriteBuffer.new_message(SYNC_MSG).end_message())
 */
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync {
  PyObject_HEAD
  char __pyx_v_mtype;
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self;
};


/* "edgedb/protocol/protocol.pyx":800
 *                 self.fallthrough()
 * 
 *     async def restore(self, bytes header, data_gen):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer buf
 */
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore {
  PyObject_HEAD
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf;
  PyObject *__pyx_v_data;
  PyObject *__pyx_v_data_gen;
  PyObject *__pyx_v_exc;
  PyObject *__pyx_v_header;
  char __pyx_v_mtype;
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self;
  PyObject *__pyx_t_0;
};


/* "edgedb/protocol/protocol.pyx":891
 *             pass
 * 
 *     async def connect(self):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer ver_buf
 */
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect {
  PyObject_HEAD
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf;
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_handshake_buf;
  PyObject *__pyx_v_k;
  int16_t __pyx_v_major;
  int16_t __pyx_v_minor;
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_msg_buf;
  char __pyx_v_mtype;
  PyObject *__pyx_v_params;
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self;
  int32_t __pyx_v_status;
  PyObject *__pyx_v_v;
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_ver_buf;
};


/* "edgedb/protocol/protocol.pyx":989
 *             )
 * 
 *     async def _auth_sasl(self):             # <<<<<<<<<<<<<<
 *         num_methods = self.buffer.read_int32()
 *         if num_methods <= 0:
 */
struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl {
  PyObject_HEAD
  PyObject *__pyx_v_client_final;
  PyObject *__pyx_v_client_first;
  PyObject *__pyx_v_client_first_bare;
  PyObject *__pyx_v_client_nonce;
  PyObject *__pyx_v_exc;
  PyObject *__pyx_v_expected_server_sig;
  int32_t __pyx_v_i;
  PyObject *__pyx_v_itercount;
  PyObject *__pyx_v_method;
  PyObject *__pyx_v_methods;
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_msg_buf;
  char __pyx_v_mtype;
  int32_t __pyx_v_num_methods;
  PyObject *__pyx_v_salt;
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self;
  PyObject *__pyx_v_server_final;
  PyObject *__pyx_v_server_first;
  PyObject *__pyx_v_server_nonce;
  PyObject *__pyx_v_server_sig;
  int32_t __pyx_v_status;
};


/* "EnumBase":15
 * 
 * @cython.internal
 * cdef class __Pyx_EnumMeta(type):             # <<<<<<<<<<<<<<
 *     def __init__(cls, name, parents, dct):
 *         type.__init__(cls, name, parents, dct)
 */
struct __pyx_obj___Pyx_EnumMeta {
  PyHeapTypeObject __pyx_base;
};



/* "edgedb/pgproto/buffer.pxd":8
 * 
 * 
 * cdef class WriteBuffer:             # <<<<<<<<<<<<<<
 *     cdef:
 *         # Preallocated small buffer
 */

struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer {
  PyObject *(*len)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *);
  PyObject *(*write_len_prefixed_utf8)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *);
  PyObject *(*_check_readonly)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *);
  PyObject *(*_ensure_alloced)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, Py_ssize_t);
  PyObject *(*_reallocate)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, Py_ssize_t);
  PyObject *(*reset)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *);
  PyObject *(*start_message)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, char);
  PyObject *(*end_message)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *);
  PyObject *(*write_buffer)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *);
  PyObject *(*write_byte)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, char);
  PyObject *(*write_bytes)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *);
  PyObject *(*write_len_prefixed_buffer)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *);
  PyObject *(*write_len_prefixed_bytes)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *);
  PyObject *(*write_bytestring)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *);
  PyObject *(*write_str)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *, PyObject *);
  PyObject *(*write_frbuf)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *);
  PyObject *(*write_cstr)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, char const *, Py_ssize_t);
  PyObject *(*write_int16)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, int16_t);
  PyObject *(*write_int32)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, int32_t);
  PyObject *(*write_int64)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, int64_t);
  PyObject *(*write_float)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, float);
  PyObject *(*write_double)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, double);
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *(*new_message)(char);
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *(*new)(void);
};
static struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer;
static CYTHON_INLINE PyObject *__pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_len(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *);
static CYTHON_INLINE PyObject *__pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_write_len_prefixed_utf8(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *);


/* "edgedb/pgproto/buffer.pxd":68
 * 
 * 
 * cdef class ReadBuffer:             # <<<<<<<<<<<<<<
 *     cdef:
 *         # A deque of buffers (bytes objects)
 */

struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer {
  PyObject *(*len)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  char (*get_message_type)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  int32_t (*get_message_length)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  PyObject *(*feed_data)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *, PyObject *);
  PyObject *(*_ensure_first_buf)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  PyObject *(*_switch_to_next_buf)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  char (*read_byte)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  char const *(*_try_read_bytes)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *, Py_ssize_t);
  PyObject *(*_read_into)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *, char *, Py_ssize_t);
  PyObject *(*_read_and_discard)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *, Py_ssize_t);
  PyObject *(*read_bytes)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *, Py_ssize_t);
  PyObject *(*read_len_prefixed_bytes)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  PyObject *(*read_len_prefixed_utf8)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  PyObject *(*read_uuid)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  int64_t (*read_int64)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  int32_t (*read_int32)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  int16_t (*read_int16)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  PyObject *(*read_null_str)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  int32_t (*take_message)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  int32_t (*take_message_type)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *, char);
  int32_t (*put_message)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  char const *(*try_consume_message)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *, Py_ssize_t *);
  PyObject *(*consume_message)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  PyObject *(*discard_message)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  PyObject *(*redirect_messages)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, char, struct __pyx_opt_args_6edgedb_7pgproto_7pgproto_10ReadBuffer_redirect_messages *__pyx_optional_args);
  PyObject *(*consume_messages)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *, char);
  PyObject *(*finish_message)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  PyObject *(*_finish_message)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *(*new_message_parser)(PyObject *);
};
static struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *__pyx_vtabptr_6edgedb_7pgproto_7pgproto_ReadBuffer;
static CYTHON_INLINE PyObject *__pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_len(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
static CYTHON_INLINE char __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);
static CYTHON_INLINE int32_t __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_length(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *);


/* "edgedb/pgproto/codecs/__init__.pxd":8
 * 
 * 
 * cdef class CodecContext:             # <<<<<<<<<<<<<<
 * 
 *     cpdef get_text_codec(self)
 */

struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_CodecContext {
  PyObject *(*get_text_codec)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, int __pyx_skip_dispatch);
  PyObject *(*is_encoding_utf8)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *);
};
static struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_vtabptr_6edgedb_7pgproto_7pgproto_CodecContext;


/* "edgedb/datatypes/enum.pxd":20
 * 
 * 
 * cdef class EnumDescriptor:             # <<<<<<<<<<<<<<
 *     cdef:
 *         object tid
 */

struct __pyx_vtabstruct_6edgedb_9datatypes_9datatypes_EnumDescriptor {
  PyObject *(*get_index)(struct __pyx_obj_6edgedb_9datatypes_9datatypes_EnumDescriptor *, struct __pyx_obj_6edgedb_9datatypes_9datatypes_EnumValue *);
};
static struct __pyx_vtabstruct_6edgedb_9datatypes_9datatypes_EnumDescriptor *__pyx_vtabptr_6edgedb_9datatypes_9datatypes_EnumDescriptor;


/* "edgedb/datatypes/enum.pxd":29
 * 
 * 
 * cdef class EnumValue:             # <<<<<<<<<<<<<<
 *     cdef:
 *         EnumDescriptor desc
 */

struct __pyx_vtabstruct_6edgedb_9datatypes_9datatypes_EnumValue {
  PyObject *(*get_index)(struct __pyx_obj_6edgedb_9datatypes_9datatypes_EnumValue *);
};
static struct __pyx_vtabstruct_6edgedb_9datatypes_9datatypes_EnumValue *__pyx_vtabptr_6edgedb_9datatypes_9datatypes_EnumValue;


/* "edgedb/protocol/lru.pyx":26
 * 
 * 
 * cdef class LRUMapping:             # <<<<<<<<<<<<<<
 * 
 *     # We use an OrderedDict for LRU implementation.  Operations:
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_LRUMapping {
  PyObject *(*get)(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *, PyObject *, PyObject *);
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_LRUMapping *__pyx_vtabptr_6edgedb_8protocol_8protocol_LRUMapping;


/* "edgedb/protocol/codecs/base.pyx":33
 * 
 * 
 * cdef class BaseCodec:             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec {
  PyObject *(*get_tid)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *);
  PyObject *(*encode)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *);
  PyObject *(*decode)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *);
  PyObject *(*dump)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_opt_args_6edgedb_8protocol_8protocol_9BaseCodec_dump *__pyx_optional_args);
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseCodec;
static CYTHON_INLINE PyObject *__pyx_f_6edgedb_8protocol_8protocol_9BaseCodec_get_tid(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *);


/* "edgedb/protocol/codecs/base.pyx":53
 * 
 * 
 * cdef class CodecPythonOverride(BaseCodec):             # <<<<<<<<<<<<<<
 * 
 *     def __cinit__(self):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecPythonOverride {
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec __pyx_base;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*new)(PyObject *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, PyObject *, PyObject *);
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecPythonOverride *__pyx_vtabptr_6edgedb_8protocol_8protocol_CodecPythonOverride;


/* "edgedb/protocol/codecs/base.pyx":124
 * 
 * 
 * cdef class BaseRecordCodec(BaseCodec):             # <<<<<<<<<<<<<<
 * 
 *     def __cinit__(self):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseRecordCodec {
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec __pyx_base;
  PyObject *(*_check_encoder)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *);
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseRecordCodec *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseRecordCodec;


/* "edgedb/protocol/codecs/base.pyx":87
 * 
 * 
 * cdef class EmptyTupleCodec(BaseCodec):             # <<<<<<<<<<<<<<
 * 
 *     def __cinit__(self):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_EmptyTupleCodec {
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec __pyx_base;
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_EmptyTupleCodec *__pyx_vtabptr_6edgedb_8protocol_8protocol_EmptyTupleCodec;


/* "edgedb/protocol/codecs/base.pyx":117
 * 
 * 
 * cdef class NullCodec(BaseCodec):             # <<<<<<<<<<<<<<
 * 
 *     def __cinit__(self):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_NullCodec {
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec __pyx_base;
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_NullCodec *__pyx_vtabptr_6edgedb_8protocol_8protocol_NullCodec;


/* "edgedb/protocol/codecs/base.pyx":193
 * 
 * 
 * cdef class BaseNamedRecordCodec(BaseRecordCodec):             # <<<<<<<<<<<<<<
 * 
 *     def __cinit__(self):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseNamedRecordCodec {
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseRecordCodec __pyx_base;
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseNamedRecordCodec;


/* "edgedb/protocol/codecs/base.pyx":210
 * 
 * @cython.final
 * cdef class EdegDBCodecContext(pgproto.CodecContext):             # <<<<<<<<<<<<<<
 * 
 *     def __cinit__(self):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_EdegDBCodecContext {
  struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_CodecContext __pyx_base;
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_EdegDBCodecContext *__pyx_vtabptr_6edgedb_8protocol_8protocol_EdegDBCodecContext;


/* "edgedb/protocol/codecs/scalar.pyx":21
 * 
 * @cython.final
 * cdef class ScalarCodec(BaseCodec):             # <<<<<<<<<<<<<<
 * 
 *     def __cinit__(self):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_ScalarCodec {
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec __pyx_base;
  PyObject *(*derive)(struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *, PyObject *);
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*new)(PyObject *, PyObject *, __pyx_t_6edgedb_7pgproto_7pgproto_encode_func, __pyx_t_6edgedb_7pgproto_7pgproto_decode_func);
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_ScalarCodec *__pyx_vtabptr_6edgedb_8protocol_8protocol_ScalarCodec;
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_derive(struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *, PyObject *);
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_new(PyObject *, PyObject *, __pyx_t_6edgedb_7pgproto_7pgproto_encode_func, __pyx_t_6edgedb_7pgproto_7pgproto_decode_func);


/* "edgedb/protocol/codecs/tuple.pyx":21
 * 
 * @cython.final
 * cdef class TupleCodec(BaseRecordCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef decode(self, FRBuffer *buf):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_TupleCodec {
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseRecordCodec __pyx_base;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*new)(PyObject *, PyObject *);
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_TupleCodec *__pyx_vtabptr_6edgedb_8protocol_8protocol_TupleCodec;
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_10TupleCodec_new(PyObject *, PyObject *);


/* "edgedb/protocol/codecs/namedtuple.pyx":24
 * 
 * @cython.final
 * cdef class NamedTupleCodec(BaseNamedRecordCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef decode(self, FRBuffer *buf):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_NamedTupleCodec {
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseNamedRecordCodec __pyx_base;
  PyObject *(*encode_kwargs)(struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *);
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*new)(PyObject *, PyObject *, PyObject *);
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_NamedTupleCodec *__pyx_vtabptr_6edgedb_8protocol_8protocol_NamedTupleCodec;
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_15NamedTupleCodec_encode_kwargs(struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *);
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_15NamedTupleCodec_new(PyObject *, PyObject *, PyObject *);


/* "edgedb/protocol/codecs/object.pyx":21
 * 
 * @cython.final
 * cdef class ObjectCodec(BaseNamedRecordCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_ObjectCodec {
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseNamedRecordCodec __pyx_base;
  PyObject *(*encode_args)(struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *);
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*new)(PyObject *, PyObject *, PyObject *, PyObject *, PyObject *);
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_ObjectCodec *__pyx_vtabptr_6edgedb_8protocol_8protocol_ObjectCodec;
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_encode_args(struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *);
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_new(PyObject *, PyObject *, PyObject *, PyObject *, PyObject *);


/* "edgedb/protocol/codecs/array.pyx":25
 * 
 * 
 * cdef class BaseArrayCodec(BaseCodec):             # <<<<<<<<<<<<<<
 * 
 *     # Base codec for arrays & sets.
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseArrayCodec {
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec __pyx_base;
  PyObject *(*_new_collection)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *, Py_ssize_t);
  PyObject *(*_set_collection_item)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *, PyObject *, Py_ssize_t, PyObject *);
  PyObject *(*_decode_array)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *);
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseArrayCodec;
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec__decode_array(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *);


/* "edgedb/protocol/codecs/array.pyx":136
 * 
 * @cython.final
 * cdef class ArrayCodec(BaseArrayCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef _new_collection(self, Py_ssize_t size):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_ArrayCodec {
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseArrayCodec __pyx_base;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*new)(PyObject *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, int32_t);
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_ArrayCodec *__pyx_vtabptr_6edgedb_8protocol_8protocol_ArrayCodec;
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_10ArrayCodec_new(PyObject *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, int32_t);


/* "edgedb/protocol/codecs/set.pyx":21
 * 
 * @cython.final
 * cdef class SetCodec(BaseArrayCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef _new_collection(self, Py_ssize_t size):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SetCodec {
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseArrayCodec __pyx_base;
  PyObject *(*_decode_array_set)(struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *);
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*new)(PyObject *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *);
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SetCodec *__pyx_vtabptr_6edgedb_8protocol_8protocol_SetCodec;
static CYTHON_INLINE PyObject *__pyx_f_6edgedb_8protocol_8protocol_8SetCodec__decode_array_set(struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *);
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_8SetCodec_new(PyObject *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *);


/* "edgedb/protocol/codecs/enum.pyx":21
 * 
 * @cython.final
 * cdef class EnumCodec(BaseCodec):             # <<<<<<<<<<<<<<
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_EnumCodec {
  struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec __pyx_base;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*new)(PyObject *, PyObject *);
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_EnumCodec *__pyx_vtabptr_6edgedb_8protocol_8protocol_EnumCodec;
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_9EnumCodec_new(PyObject *, PyObject *);


/* "edgedb/protocol/codecs/codecs.pyx":58
 * 
 * 
 * cdef class CodecsRegistry:             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, *, cache_size=1000):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*_build_codec)(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *, PyObject *, PyObject *);
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*build_codec)(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *, PyObject *, PyObject *);
  PyObject *(*has_codec)(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *, PyObject *);
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*get_codec)(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *, PyObject *);
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_vtabptr_6edgedb_8protocol_8protocol_CodecsRegistry;


/* "edgedb/protocol/protocol.pyx":94
 * 
 * 
 * cdef class QueryCodecsCache:             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, *, cache_size=1000):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_QueryCodecsCache {
  PyObject *(*set)(struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *, PyObject *, enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, int, int, int, int, int, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, int);
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_vtabptr_6edgedb_8protocol_8protocol_QueryCodecsCache;


/* "edgedb/protocol/protocol.pyx":127
 * 
 * 
 * cdef class SansIOProtocol:             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, con_params, tls_compat):
 */

struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol {
  PyObject *(*encode_args)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *, PyObject *);
  PyObject *(*parse_data_messages)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, PyObject *);
  PyObject *(*parse_sync_message)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *);
  PyObject *(*parse_command_complete_message)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *);
  PyObject *(*parse_describe_type_message)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *);
  PyObject *(*_amend_parse_error)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, PyObject *, enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, int, int);
  PyObject *(*ignore_headers)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *);
  PyObject *(*parse_headers)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *);
  PyObject *(*write_headers)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *);
  PyObject *(*parse_error_message)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *);
  PyObject *(*write)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *);
  PyObject *(*abort)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, int __pyx_skip_dispatch);
  PyObject *(*reset_status)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *);
  PyObject *(*parse_system_config)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, PyObject *);
  PyObject *(*parse_server_settings)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, PyObject *, PyObject *);
  PyObject *(*fallthrough)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *);
  PyObject *(*write_execute_headers)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, int, int, int, uint64_t);
  PyObject *(*ensure_connected)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *);
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_vtabptr_6edgedb_8protocol_8protocol_SansIOProtocol;
static CYTHON_INLINE PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_ignore_headers(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *);

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* RaiseKeywordRequired.proto */
static void __Pyx_RaiseKeywordRequired(const char* func_name, PyObject* kw_name);

/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
    const char* function_name);

/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

/* PyObjectFormatSimple.proto */
#if CYTHON_COMPILING_IN_PYPY
    #define __Pyx_PyObject_FormatSimple(s, f) (\
        likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
        PyObject_Format(s, f))
#elif PY_MAJOR_VERSION < 3
    #define __Pyx_PyObject_FormatSimple(s, f) (\
        likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
        likely(PyString_CheckExact(s)) ? PyUnicode_FromEncodedObject(s, NULL, "strict") :\
        PyObject_Format(s, f))
#elif CYTHON_USE_TYPE_SLOTS
    #define __Pyx_PyObject_FormatSimple(s, f) (\
        likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
        likely(PyLong_CheckExact(s)) ? PyLong_Type.tp_str(s) :\
        likely(PyFloat_CheckExact(s)) ? PyFloat_Type.tp_str(s) :\
        PyObject_Format(s, f))
#else
    #define __Pyx_PyObject_FormatSimple(s, f) (\
        likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
        PyObject_Format(s, f))
#endif

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
    (sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
  static size_t __pyx_pyframe_localsplus_offset = 0;
  #include "frameobject.h"
  #define __Pxy_PyFrame_Initialize_Offsets()\
    ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
     (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  #define __Pyx_PyFrame_GetLocalsplus(frame)\
    (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif

/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

/* PyDictVersioning.proto */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
#define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
    (version_var) = __PYX_GET_DICT_VERSION(dict);\
    (cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
        (VAR) = __pyx_dict_cached_value;\
    } else {\
        (VAR) = __pyx_dict_cached_value = (LOOKUP);\
        __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
    }\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict)  (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
#endif

/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name)  {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
        (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
        __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
#define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
    PY_UINT64_T __pyx_dict_version;\
    PyObject *__pyx_dict_cached_value;\
    (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif

/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

/* PyObjectCall2Args.proto */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);

/* GetItemInt.proto */
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

/* ObjectGetItem.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
#else
#define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
#endif

/* PySequenceContains.proto */
static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
#endif

/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

/* GetAttr3.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);

/* KeywordStringCheck.proto */
static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);

/* PyUnicode_Unicode.proto */
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj);

/* IncludeStringH.proto */
#include <string.h>

/* JoinPyUnicode.proto */
static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
                                      Py_UCS4 max_char);

/* GCCDiagnostics.proto */
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#define __Pyx_HAS_GCC_DIAGNOSTIC
#endif

/* BuildPyUnicode.proto */
static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, char* chars, int clength,
                                                int prepend_sign, char padding_char);

/* CIntToPyUnicode.proto */
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_From_Py_ssize_t(Py_ssize_t value, Py_ssize_t width, char padding_char, char format_char);

/* GetTopmostException.proto */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
#endif

/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
#endif

/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* SliceObject.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

/* SwapException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddCObj(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_AddCObj(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* ListAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        __Pyx_SET_SIZE(list, len + 1);
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
#define __Pyx_PyObject_Dict_GetItem(obj, name)\
    (likely(PyDict_CheckExact(obj)) ?\
     __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
#endif

/* BytesEquals.proto */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

/* UnicodeEquals.proto */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

/* dict_getitem_default.proto */
static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value);

/* UnpackUnboundCMethod.proto */
typedef struct {
    PyObject *type;
    PyObject **method_name;
    PyCFunction func;
    PyObject *method;
    int flag;
} __Pyx_CachedCFunction;

/* CallUnboundCMethod1.proto */
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#else
#define __Pyx_CallUnboundCMethod1(cfunc, self, arg)  __Pyx__CallUnboundCMethod1(cfunc, self, arg)
#endif

/* CallUnboundCMethod2.proto */
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2);
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2);
#else
#define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2)  __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
#endif

/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

/* PyDictContains.proto */
static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
    int result = PyDict_Contains(dict, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* PyObjectFormatAndDecref.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f);
static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f);

/* PyIntCompare.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_RemainderObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceRemainder(op1, op2) : PyNumber_Remainder(op1, op2))
#endif

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_FloorDivideObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_FloorDivideObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceFloorDivide(op1, op2) : PyNumber_FloorDivide(op1, op2))
#endif

/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
    ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
        __Pyx__ArgTypeTest(obj, type, name, exact))
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);

/* IterFinish.proto */
static CYTHON_INLINE int __Pyx_IterFinish(void);

/* PyObjectGetMethod.proto */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);

/* PyObjectCallMethod0.proto */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);

/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

/* UnpackItemEndCheck.proto */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

/* RaiseNoneIterError.proto */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

/* UnpackTupleError.proto */
static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);

/* UnpackTuple2.proto */
#define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\
    (likely(is_tuple || PyTuple_Check(tuple)) ?\
        (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\
            __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\
            (__Pyx_UnpackTupleError(tuple, 2), -1)) :\
        __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple))
static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
    PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple);
static int __Pyx_unpack_tuple2_generic(
    PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple);

/* dict_iter.proto */
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
                                                   Py_ssize_t* p_orig_length, int* p_is_dict);
static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
                                              PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);

/* FetchCommonType.proto */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

/* PyObjectCallMethod1.proto */
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

/* CoroutineBase.proto */
typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *);
#if CYTHON_USE_EXC_INFO_STACK
#define __Pyx_ExcInfoStruct  _PyErr_StackItem
#else
typedef struct {
    PyObject *exc_type;
    PyObject *exc_value;
    PyObject *exc_traceback;
} __Pyx_ExcInfoStruct;
#endif
typedef struct {
    PyObject_HEAD
    __pyx_coroutine_body_t body;
    PyObject *closure;
    __Pyx_ExcInfoStruct gi_exc_state;
    PyObject *gi_weakreflist;
    PyObject *classobj;
    PyObject *yieldfrom;
    PyObject *gi_name;
    PyObject *gi_qualname;
    PyObject *gi_modulename;
    PyObject *gi_code;
    PyObject *gi_frame;
    int resume_label;
    char is_running;
} __pyx_CoroutineObject;
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
    PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
    PyObject *name, PyObject *qualname, PyObject *module_name);
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name);
static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self);
static int __Pyx_Coroutine_clear(PyObject *self);
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
static PyObject *__Pyx_Coroutine_Close(PyObject *self);
static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
#if CYTHON_USE_EXC_INFO_STACK
#define __Pyx_Coroutine_SwapException(self)
#define __Pyx_Coroutine_ResetAndClearException(self)  __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state)
#else
#define __Pyx_Coroutine_SwapException(self) {\
    __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\
    __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\
    }
#define __Pyx_Coroutine_ResetAndClearException(self) {\
    __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\
    (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\
    }
#endif
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
#else
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
#endif
static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state);

/* PyObject_GenericGetAttrNoDict.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
#endif

/* PatchModuleWithCoroutine.proto */
static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);

/* PatchGeneratorABC.proto */
static int __Pyx_patch_abc(void);

/* Coroutine.proto */
#define __Pyx_Coroutine_USED
static PyTypeObject *__pyx_CoroutineType = 0;
static PyTypeObject *__pyx_CoroutineAwaitType = 0;
#define __Pyx_Coroutine_CheckExact(obj) (Py_TYPE(obj) == __pyx_CoroutineType)
#define __Pyx_Coroutine_Check(obj) __Pyx_Coroutine_CheckExact(obj)
#define __Pyx_CoroutineAwait_CheckExact(obj) (Py_TYPE(obj) == __pyx_CoroutineAwaitType)
#define __Pyx_Coroutine_New(body, code, closure, name, qualname, module_name)\
    __Pyx__Coroutine_New(__pyx_CoroutineType, body, code, closure, name, qualname, module_name)
static int __pyx_Coroutine_init(void);
static PyObject *__Pyx__Coroutine_await(PyObject *coroutine);
typedef struct {
    PyObject_HEAD
    PyObject *coroutine;
} __pyx_CoroutineAwaitObject;
static PyObject *__Pyx_CoroutineAwait_Close(__pyx_CoroutineAwaitObject *self, PyObject *arg);
static PyObject *__Pyx_CoroutineAwait_Throw(__pyx_CoroutineAwaitObject *self, PyObject *args);

/* GetAwaitIter.proto */
static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o);
static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *o);

/* CoroutineYieldFrom.proto */
static CYTHON_INLINE PyObject* __Pyx_Coroutine_Yield_From(__pyx_CoroutineObject *gen, PyObject *source);

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);

/* ReturnWithStopIteration.proto */
#define __Pyx_ReturnWithStopIteration(value)\
    if (value == Py_None) PyErr_SetNone(PyExc_StopIteration); else __Pyx__ReturnWithStopIteration(value)
static void __Pyx__ReturnWithStopIteration(PyObject* value);

/* PyObjectSetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

/* AsyncIter.proto */
static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *o);
static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *o);

/* StopAsyncIteration.proto */
#define __Pyx_StopAsyncIteration_USED
static PyObject *__Pyx_PyExc_StopAsyncIteration;
static int __pyx_StopAsyncIteration_init(void);

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)

/* decode_c_string_utf16.proto */
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = 0;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = -1;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = 1;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}

/* decode_c_bytes.proto */
static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
         const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));

/* decode_bytes.proto */
static CYTHON_INLINE PyObject* __Pyx_decode_bytes(
         PyObject* string, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
    return __Pyx_decode_c_bytes(
        PyBytes_AS_STRING(string), PyBytes_GET_SIZE(string),
        start, stop, encoding, errors, decode_func);
}

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* HasAttr.proto */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);

/* WriteUnraisableException.proto */
static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

/* CallNextTpTraverse.proto */
static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse);

/* CallNextTpClear.proto */
static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc);

/* CallNextTpDealloc.proto */
static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc);

/* PyObject_GenericGetAttr.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
#endif

/* SetVTable.proto */
static int __Pyx_SetVtable(PyObject *dict, void *vtable);

/* PyObjectGetAttrStrNoError.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);

/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);

/* TypeImport.proto */
#ifndef __PYX_HAVE_RT_ImportType_proto
#define __PYX_HAVE_RT_ImportType_proto
enum __Pyx_ImportType_CheckSize {
   __Pyx_ImportType_CheckSize_Error = 0,
   __Pyx_ImportType_CheckSize_Warn = 1,
   __Pyx_ImportType_CheckSize_Ignore = 2
};
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
#endif

/* GetVTable.proto */
static void* __Pyx_GetVtable(PyObject *dict);

/* PatchInspect.proto */
static PyObject* __Pyx_patch_inspect(PyObject* module);

/* PatchAsyncIO.proto */
static PyObject* __Pyx_patch_asyncio(PyObject* module);

/* CalculateMetaclass.proto */
static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);

/* SetNameInClass.proto */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
#elif CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
#else
#define __Pyx_SetNameInClass(ns, name, value)  PyObject_SetItem(ns, name, value)
#endif

/* CythonFunctionShared.proto */
#define __Pyx_CyFunction_USED 1
#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
#define __Pyx_CYFUNCTION_CCLASS        0x04
#define __Pyx_CyFunction_GetClosure(f)\
    (((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f)\
    (((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f)\
    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
    PyCFunctionObject func;
#if PY_VERSION_HEX < 0x030500A0
    PyObject *func_weakreflist;
#endif
    PyObject *func_dict;
    PyObject *func_name;
    PyObject *func_qualname;
    PyObject *func_doc;
    PyObject *func_globals;
    PyObject *func_code;
    PyObject *func_closure;
    PyObject *func_classobj;
    void *defaults;
    int defaults_pyobjects;
    size_t defaults_size;  // used by FusedFunction for copying defaults
    int flags;
    PyObject *defaults_tuple;
    PyObject *defaults_kwdict;
    PyObject *(*defaults_getter)(PyObject *);
    PyObject *func_annotations;
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_Check(obj)  (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *self,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
                                                         size_t size,
                                                         int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
                                                            PyObject *tuple);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
                                                             PyObject *dict);
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
                                                              PyObject *dict);
static int __pyx_CyFunction_init(void);

/* CythonFunction.proto */
static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *closure,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);

/* Py3ClassCreate.proto */
static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
                                           PyObject *mkw, PyObject *modname, PyObject *doc);
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
                                      PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);

/* Globals.proto */
static PyObject* __Pyx_Globals(void);

/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_TransactionStatus(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus value);

/* CIntFromPy.proto */
static CYTHON_INLINE enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus __Pyx_PyInt_As_enum____pyx_t_6edgedb_8protocol_8protocol_TransactionStatus(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat value);

/* CIntFromPy.proto */
static CYTHON_INLINE enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __Pyx_PyInt_As_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_EdgeFieldCardinality(EdgeFieldCardinality value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int32_t(int32_t value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint16_t(uint16_t value);

/* CIntFromPy.proto */
static CYTHON_INLINE uint16_t __Pyx_PyInt_As_uint16_t(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint8_t(uint8_t value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value);

/* CIntFromPy.proto */
static CYTHON_INLINE int64_t __Pyx_PyInt_As_int64_t(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int64_t(int64_t value);

/* CIntFromPy.proto */
static CYTHON_INLINE int16_t __Pyx_PyInt_As_int16_t(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint64_t(uint64_t value);

/* CIntFromPy.proto */
static CYTHON_INLINE uint64_t __Pyx_PyInt_As_uint64_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int16_t(int16_t value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_char(char value);

/* CIntFromPy.proto */
static CYTHON_INLINE uint32_t __Pyx_PyInt_As_uint32_t(PyObject *);

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* FunctionImport.proto */
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);

/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_10LRUMapping_get(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_9BaseCodec_encode(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self, CYTHON_UNUSED struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, CYTHON_UNUSED PyObject *__pyx_v_obj); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_9BaseCodec_decode(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self, CYTHON_UNUSED struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_9BaseCodec_dump(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self, struct __pyx_opt_args_6edgedb_8protocol_8protocol_9BaseCodec_dump *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_19CodecPythonOverride_encode(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_19CodecPythonOverride_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_19CodecPythonOverride_dump(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *__pyx_v_self, struct __pyx_opt_args_6edgedb_8protocol_8protocol_19CodecPythonOverride_dump *__pyx_optional_args); /* proto*/
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_19CodecPythonOverride_new(PyObject *__pyx_v_tid, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_basecodec, PyObject *__pyx_v_encoder, PyObject *__pyx_v_decoder); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_15EmptyTupleCodec_encode(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_15EmptyTupleCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_15BaseRecordCodec__check_encoder(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_15BaseRecordCodec_encode(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_dump(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *__pyx_v_self, struct __pyx_opt_args_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_dump *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_18EdegDBCodecContext_get_text_codec(struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_18EdegDBCodecContext_is_encoding_utf8(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_encode(struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_derive(struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *__pyx_v_self, PyObject *__pyx_v_tid); /* proto*/
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_new(PyObject *__pyx_v_tid, PyObject *__pyx_v_name, __pyx_t_6edgedb_7pgproto_7pgproto_encode_func __pyx_v_encoder, __pyx_t_6edgedb_7pgproto_7pgproto_decode_func __pyx_v_decoder); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_10TupleCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_10TupleCodec_dump(struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec *__pyx_v_self, struct __pyx_opt_args_6edgedb_8protocol_8protocol_10TupleCodec_dump *__pyx_optional_args); /* proto*/
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_10TupleCodec_new(PyObject *__pyx_v_tid, PyObject *__pyx_v_fields_codecs); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_15NamedTupleCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_15NamedTupleCodec_encode_kwargs(struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj); /* proto*/
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_15NamedTupleCodec_new(PyObject *__pyx_v_tid, PyObject *__pyx_v_fields_names, PyObject *__pyx_v_fields_codecs); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_encode(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *__pyx_v_self, CYTHON_UNUSED struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, CYTHON_UNUSED PyObject *__pyx_v_obj); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_encode_args(struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf); /* proto*/
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_new(PyObject *__pyx_v_tid, PyObject *__pyx_v_names, PyObject *__pyx_v_flags, PyObject *__pyx_v_cards, PyObject *__pyx_v_codecs); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec__new_collection(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self, CYTHON_UNUSED Py_ssize_t __pyx_v_size); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec__set_collection_item(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_collection, CYTHON_UNUSED Py_ssize_t __pyx_v_i, CYTHON_UNUSED PyObject *__pyx_v_element); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec_encode(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec__decode_array(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec_dump(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self, struct __pyx_opt_args_6edgedb_8protocol_8protocol_14BaseArrayCodec_dump *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_10ArrayCodec__new_collection(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec *__pyx_v_self, Py_ssize_t __pyx_v_size); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_10ArrayCodec__set_collection_item(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec *__pyx_v_self, PyObject *__pyx_v_collection, Py_ssize_t __pyx_v_i, PyObject *__pyx_v_element); /* proto*/
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_10ArrayCodec_new(PyObject *__pyx_v_tid, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_sub_codec, int32_t __pyx_v_cardinality); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_8SetCodec__new_collection(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *__pyx_v_self, Py_ssize_t __pyx_v_size); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_8SetCodec__set_collection_item(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *__pyx_v_self, PyObject *__pyx_v_collection, Py_ssize_t __pyx_v_i, PyObject *__pyx_v_element); /* proto*/
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_8SetCodec_new(PyObject *__pyx_v_tid, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_sub_codec); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_8SetCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf); /* proto*/
static CYTHON_INLINE PyObject *__pyx_f_6edgedb_8protocol_8protocol_8SetCodec__decode_array_set(struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_9EnumCodec_encode(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_9EnumCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf); /* proto*/
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_9EnumCodec_new(PyObject *__pyx_v_tid, PyObject *__pyx_v_enum_labels); /* proto*/
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_14CodecsRegistry__build_codec(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_spec, PyObject *__pyx_v_codecs_list, PyObject *__pyx_v_protocol_version); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14CodecsRegistry_has_codec(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self, PyObject *__pyx_v_type_id); /* proto*/
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_14CodecsRegistry_get_codec(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self, PyObject *__pyx_v_type_id); /* proto*/
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_14CodecsRegistry_build_codec(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self, PyObject *__pyx_v_spec, PyObject *__pyx_v_protocol_version); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_16QueryCodecsCache_set(struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_self, PyObject *__pyx_v_query, enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __pyx_v_io_format, int __pyx_v_implicit_limit, int __pyx_v_inline_typenames, int __pyx_v_inline_typeids, int __pyx_v_expect_one, int __pyx_v_has_na_cardinality, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_in_type, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_out_type, int __pyx_v_capabilities); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_reset_status(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_abort(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_write(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, CYTHON_UNUSED struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf); /* proto*/
static CYTHON_INLINE PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_ignore_headers(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_write_headers(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_headers); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_write_execute_headers(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, int __pyx_v_implicit_limit, int __pyx_v_inline_typenames, int __pyx_v_inline_typeids, uint64_t __pyx_v_allow_capabilities); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_ensure_connected(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_system_config(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_codec, PyObject *__pyx_v_data); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_server_settings(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_val); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_fallthrough(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_encode_args(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_in_dc, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_describe_type_message(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_reg); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_data_messages(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_out_dc, PyObject *__pyx_v_result); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_command_complete_message(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_sync_message(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol__amend_parse_error(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_exc, enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __pyx_v_io_format, int __pyx_v_expect_one, int __pyx_v_required_one); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_headers(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_error_message(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto*/
static CYTHON_INLINE PyObject *__pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_len(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_self); /* proto*/
static CYTHON_INLINE PyObject *__pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_write_len_prefixed_utf8(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_self, PyObject *__pyx_v_s); /* proto*/
static CYTHON_INLINE PyObject *__pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_len(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *__pyx_v_self); /* proto*/
static CYTHON_INLINE char __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *__pyx_v_self); /* proto*/
static CYTHON_INLINE int32_t __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_length(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *__pyx_v_self); /* proto*/
static CYTHON_INLINE PyObject *__pyx_f_6edgedb_8protocol_8protocol_9BaseCodec_get_tid(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self); /* proto*/

/* Module declarations from 'cython' */

/* Module declarations from 'cpython.version' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;

/* Module declarations from 'libc.string' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from 'cpython.object' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'cpython.exc' */

/* Module declarations from 'cpython.module' */

/* Module declarations from 'cpython.mem' */

/* Module declarations from 'cpython.tuple' */

/* Module declarations from 'cpython.list' */

/* Module declarations from 'cpython.sequence' */

/* Module declarations from 'cpython.mapping' */

/* Module declarations from 'cpython.iterator' */

/* Module declarations from 'cpython.number' */

/* Module declarations from 'cpython.int' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.bool' */
static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;

/* Module declarations from 'cpython.long' */

/* Module declarations from 'cpython.float' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.complex' */
static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;

/* Module declarations from 'cpython.string' */

/* Module declarations from 'cpython.unicode' */

/* Module declarations from 'cpython.dict' */

/* Module declarations from 'cpython.instance' */

/* Module declarations from 'cpython.function' */

/* Module declarations from 'cpython.method' */

/* Module declarations from 'cpython.weakref' */

/* Module declarations from 'cpython.getargs' */

/* Module declarations from 'cpython.pythread' */

/* Module declarations from 'cpython.pystate' */

/* Module declarations from 'cpython.cobject' */

/* Module declarations from 'cpython.oldbuffer' */

/* Module declarations from 'cpython.set' */

/* Module declarations from 'cpython.buffer' */

/* Module declarations from 'cpython.bytes' */

/* Module declarations from 'cpython.pycapsule' */

/* Module declarations from 'datetime' */

/* Module declarations from 'cpython.datetime' */
static PyTypeObject *__pyx_ptype_7cpython_8datetime_date = 0;
static PyTypeObject *__pyx_ptype_7cpython_8datetime_time = 0;
static PyTypeObject *__pyx_ptype_7cpython_8datetime_datetime = 0;
static PyTypeObject *__pyx_ptype_7cpython_8datetime_timedelta = 0;
static PyTypeObject *__pyx_ptype_7cpython_8datetime_tzinfo = 0;
static CYTHON_INLINE void __pyx_f_7cpython_8datetime_import_datetime(void); /*proto*/

/* Module declarations from 'cpython' */

/* Module declarations from 'libc.stdint' */

/* Module declarations from 'edgedb.pgproto.pgproto' */
static PyTypeObject *__pyx_ptype_6edgedb_7pgproto_7pgproto_WriteBuffer = 0;
static PyTypeObject *__pyx_ptype_6edgedb_7pgproto_7pgproto_ReadBuffer = 0;
static PyTypeObject *__pyx_ptype_6edgedb_7pgproto_7pgproto_CodecContext = 0;
static CYTHON_INLINE Py_ssize_t __pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len(struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static CYTHON_INLINE void __pyx_f_6edgedb_7pgproto_7pgproto_frb_set_len(struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *, Py_ssize_t); /*proto*/
static CYTHON_INLINE void __pyx_f_6edgedb_7pgproto_7pgproto_frb_init(struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *, char const *, Py_ssize_t); /*proto*/
static CYTHON_INLINE char const *__pyx_f_6edgedb_7pgproto_7pgproto_frb_read(struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *, Py_ssize_t); /*proto*/
static CYTHON_INLINE char const *__pyx_f_6edgedb_7pgproto_7pgproto_frb_read_all(struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static CYTHON_INLINE struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_f_6edgedb_7pgproto_7pgproto_frb_slice_from(struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *, Py_ssize_t); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_frb_check)(struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *, Py_ssize_t); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_date_encode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_date_decode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_timestamp_encode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_timestamp_decode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_timestamptz_encode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_timestamptz_decode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_time_encode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_time_decode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_bool_encode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_bool_decode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_int2_encode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_int2_decode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_int4_encode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_int4_decode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_int8_encode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_int8_decode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_float4_encode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_float4_decode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_float8_encode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_float8_decode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_jsonb_encode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_jsonb_decode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_text_encode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_text_decode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_bytea_encode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_bytea_decode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_uuid_encode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_uuid_decode)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_numeric_encode_binary)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_7pgproto_7pgproto_numeric_decode_binary_ex)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *, int); /*proto*/

/* Module declarations from 'edgedb.pgproto' */

/* Module declarations from 'edgedb.pgproto.debug' */

/* Module declarations from 'edgedb.pgproto.hton' */

/* Module declarations from 'edgedb.datatypes' */

/* Module declarations from 'edgedb.datatypes.datatypes' */
static PyTypeObject *__pyx_ptype_6edgedb_9datatypes_9datatypes_RelativeDuration = 0;
static PyTypeObject *__pyx_ptype_6edgedb_9datatypes_9datatypes_EnumDescriptor = 0;
static PyTypeObject *__pyx_ptype_6edgedb_9datatypes_9datatypes_EnumValue = 0;
static PyTypeObject *__pyx_ptype_6edgedb_9datatypes_9datatypes_ConfigMemory = 0;
static PyObject *(*__pyx_f_6edgedb_9datatypes_9datatypes_record_desc_new)(PyObject *, PyObject *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_9datatypes_9datatypes_record_desc_pointer_name)(PyObject *, Py_ssize_t); /*proto*/
static PyObject *(*__pyx_f_6edgedb_9datatypes_9datatypes_record_desc_pointer_card)(PyObject *, Py_ssize_t); /*proto*/
static PyObject *(*__pyx_f_6edgedb_9datatypes_9datatypes_tuple_new)(Py_ssize_t); /*proto*/
static PyObject *(*__pyx_f_6edgedb_9datatypes_9datatypes_tuple_set)(PyObject *, Py_ssize_t, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_9datatypes_9datatypes_namedtuple_new)(PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_9datatypes_9datatypes_namedtuple_set)(PyObject *, Py_ssize_t, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_9datatypes_9datatypes_object_new)(PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_9datatypes_9datatypes_object_set)(PyObject *, Py_ssize_t, PyObject *); /*proto*/
static int (*__pyx_f_6edgedb_9datatypes_9datatypes_set_check)(PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_9datatypes_9datatypes_set_new)(Py_ssize_t); /*proto*/
static PyObject *(*__pyx_f_6edgedb_9datatypes_9datatypes_set_set)(PyObject *, Py_ssize_t, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_9datatypes_9datatypes_set_append)(PyObject *, PyObject *); /*proto*/
static PyObject *(*__pyx_f_6edgedb_9datatypes_9datatypes_array_new)(Py_ssize_t); /*proto*/
static PyObject *(*__pyx_f_6edgedb_9datatypes_9datatypes_array_set)(PyObject *, Py_ssize_t, PyObject *); /*proto*/

/* Module declarations from 'edgedb.protocol' */

/* Module declarations from 'edgedb.protocol.cpythonx' */

/* Module declarations from 'edgedb.protocol.protocol' */
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_LRUMapping = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_CodecPythonOverride = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_BaseRecordCodec = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_EmptyTupleCodec = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_NullCodec = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_BaseNamedRecordCodec = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_EdegDBCodecContext = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_ScalarCodec = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_TupleCodec = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_NamedTupleCodec = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_ObjectCodec = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_BaseArrayCodec = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_ArrayCodec = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_SetCodec = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_EnumCodec = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_CodecsRegistry = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_QueryCodecsCache = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol_SansIOProtocol = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect = 0;
static PyTypeObject *__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl = 0;
static PyTypeObject *__pyx_ptype___Pyx_EnumMeta = 0;
static PyObject *__pyx_v_6edgedb_8protocol_8protocol__LRU_MARKER = 0;
static uint64_t __pyx_v_6edgedb_8protocol_8protocol_RECORD_ENCODER_CHECKED;
static uint64_t __pyx_v_6edgedb_8protocol_8protocol_RECORD_ENCODER_INVALID;
static PyObject *__pyx_v_6edgedb_8protocol_8protocol_NULL_CODEC_ID = 0;
static PyObject *__pyx_v_6edgedb_8protocol_8protocol_EMPTY_TUPLE_CODEC_ID = 0;
static struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *__pyx_v_6edgedb_8protocol_8protocol_DEFAULT_CODEC_CONTEXT = 0;
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_6edgedb_8protocol_8protocol_NULL_CODEC = 0;
static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_6edgedb_8protocol_8protocol_EMPTY_TUPLE_CODEC = 0;
static PyObject *__pyx_v_6edgedb_8protocol_8protocol_BASE_SCALAR_CODECS = 0;
static PyObject *__pyx_v_6edgedb_8protocol_8protocol_OLD_ERROR_CODES = 0;
static PyObject *__pyx_v_6edgedb_8protocol_8protocol_result_cardinality_mismatch_code = 0;
static PyObject *__pyx_v_6edgedb_8protocol_8protocol_SYNC_MESSAGE = 0;
static PyObject *__pyx_v_6edgedb_8protocol_8protocol_FLUSH_MESSAGE = 0;
static PyObject *__Pyx_OrderedDict = 0;
static PyObject *__Pyx_EnumBase = 0;
static PyObject *__Pyx_globals = 0;
static CYTHON_INLINE int __pyx_f_6edgedb_8protocol_8protocol__is_trivial_container(PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_6edgedb_8protocol_8protocol__is_array_iterable(PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(PyObject *, __pyx_t_6edgedb_7pgproto_7pgproto_encode_func, __pyx_t_6edgedb_7pgproto_7pgproto_decode_func); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_time_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_date_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_timestamp_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_timestamptz_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_duration_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_duration_decode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_relative_duration_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_relative_duration_decode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_config_memory_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_config_memory_decode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_checked_decimal_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_decimal_decode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_ensure_is_int(PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_checked_int2_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_checked_int4_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_checked_int8_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_bigint_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_bigint_decode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codecs(void); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_LRUMapping__set_state(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *, PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_CodecsRegistry__set_state(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *, PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_QueryCodecsCache__set_state(struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *, PyObject *); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_SansIOProtocol__set_state(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, PyObject *); /*proto*/
static PyObject *__pyx_unpickle___Pyx_EnumMeta__set_state(struct __pyx_obj___Pyx_EnumMeta *, PyObject *); /*proto*/
#define __Pyx_MODULE_NAME "edgedb.protocol.protocol"
extern int __pyx_module_is_main_edgedb__protocol__protocol;
int __pyx_module_is_main_edgedb__protocol__protocol = 0;

/* Implementation of 'edgedb.protocol.protocol' */
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_LookupError;
static PyObject *__pyx_builtin_id;
static PyObject *__pyx_builtin_reversed;
static PyObject *__pyx_builtin_chr;
static const char __pyx_k_n[] = "n";
static const char __pyx_k_v[] = "v";
static const char __pyx_k__2[] = " ";
static const char __pyx_k_id[] = "id";
static const char __pyx_k_qc[] = "qc";
static const char __pyx_k_Set[] = "Set";
static const char __pyx_k__14[] = "...";
static const char __pyx_k__17[] = "{}{} := {}";
static const char __pyx_k__18[] = "\n";
static const char __pyx_k__29[] = ": ";
static const char __pyx_k__30[] = " (";
static const char __pyx_k__31[] = ")";
static const char __pyx_k__61[] = "";
static const char __pyx_k__62[] = "-";
static const char __pyx_k__68[] = "[]";
static const char __pyx_k__75[] = ".";
static const char __pyx_k__78[] = ", ";
static const char __pyx_k_big[] = "big";
static const char __pyx_k_chr[] = "chr";
static const char __pyx_k_cls[] = "cls";
static const char __pyx_k_dct[] = "dct";
static const char __pyx_k_doc[] = "__doc__";
static const char __pyx_k_get[] = "get";
static const char __pyx_k_got[] = ", got ";
static const char __pyx_k_msg[] = "msg";
static const char __pyx_k_new[] = "__new__";
static const char __pyx_k_ref[] = "ref";
static const char __pyx_k_reg[] = "reg";
static const char __pyx_k_res[] = "res";
static const char __pyx_k_s_s[] = "%s.%s";
static const char __pyx_k_std[] = "std";
static const char __pyx_k_str[] = "__str__";
static const char __pyx_k_0000[] = "0000";
static const char __pyx_k_Enum[] = "Enum";
static const char __pyx_k_JSON[] = "JSON";
static const char __pyx_k_None[] = "None";
static const char __pyx_k_UUID[] = "UUID";
static const char __pyx_k__106[] = "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000";
static const char __pyx_k__108[] = "\000\000\000\000";
static const char __pyx_k__109[] = "\000\000\000\004\000\000\000\000";
static const char __pyx_k_args[] = "args";
static const char __pyx_k_code[] = "_code";
static const char __pyx_k_days[] = "days";
static const char __pyx_k_dict[] = "__dict__";
static const char __pyx_k_dump[] = "dump";
static const char __pyx_k_enum[] = "enum";
static const char __pyx_k_init[] = "__init__";
static const char __pyx_k_json[] = "json";
static const char __pyx_k_keys[] = "keys";
static const char __pyx_k_last[] = "last";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_name[] = "__name__";
static const char __pyx_k_null[] = "null";
static const char __pyx_k_repr[] = "__repr__";
static const char __pyx_k_self[] = "self";
static const char __pyx_k_send[] = "send";
static const char __pyx_k_sync[] = "_sync";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_time[] = "time";
static const char __pyx_k_user[] = "user";
static const char __pyx_k_uuid[] = "uuid";
static const char __pyx_k_Array[] = "Array";
static const char __pyx_k_Sized[] = "Sized";
static const char __pyx_k_Tuple[] = "Tuple";
static const char __pyx_k_abort[] = "abort";
static const char __pyx_k_aiter[] = "__aiter__";
static const char __pyx_k_anext[] = "__anext__";
static const char __pyx_k_attrs[] = "_attrs";
static const char __pyx_k_await[] = "__await__";
static const char __pyx_k_bytes[] = "bytes";
static const char __pyx_k_cause[] = "__cause__";
static const char __pyx_k_class[] = "__class__";
static const char __pyx_k_clear[] = "clear";
static const char __pyx_k_close[] = "close";
static const char __pyx_k_enums[] = "enums";
static const char __pyx_k_extra[] = ", extra ";
static const char __pyx_k_in_dc[] = "in_dc";
static const char __pyx_k_items[] = "items";
static const char __pyx_k_parse[] = "_parse";
static const char __pyx_k_query[] = "query";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_s_s_d[] = "<%s.%s: %d>";
static const char __pyx_k_scram[] = "scram";
static const char __pyx_k_strip[] = "strip";
static const char __pyx_k_throw[] = "throw";
static const char __pyx_k_types[] = "types";
static const char __pyx_k_utf_8[] = "utf-8";
static const char __pyx_k_value[] = "value";
static const char __pyx_k_zfill[] = "zfill";
static const char __pyx_k_BINARY[] = "BINARY";
static const char __pyx_k_Object[] = "Object";
static const char __pyx_k_codecs[] = "codecs";
static const char __pyx_k_edgedb[] = "edgedb";
static const char __pyx_k_encode[] = "encode";
static const char __pyx_k_errors[] = "errors";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_header[] = "header";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_kwargs[] = "kwargs";
static const char __pyx_k_lookup[] = "lookup";
static const char __pyx_k_missed[] = ", missed ";
static const char __pyx_k_module[] = "__module__";
static const char __pyx_k_months[] = "months";
static const char __pyx_k_name_2[] = "name";
static const char __pyx_k_object[] = "object";
static const char __pyx_k_out_dc[] = "out_dc";
static const char __pyx_k_pickle[] = "pickle";
static const char __pyx_k_python[] = "python";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_typeid[] = "typeid";
static const char __pyx_k_typing[] = "typing";
static const char __pyx_k_tzinfo[] = "tzinfo";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_values[] = "values";
static const char __pyx_k_Decimal[] = "Decimal";
static const char __pyx_k_IntEnum[] = "IntEnum";
static const char __pyx_k_Mapping[] = "Mapping";
static const char __pyx_k_anytype[] = "anytype";
static const char __pyx_k_asyncio[] = "asyncio";
static const char __pyx_k_bytes_2[] = "_bytes";
static const char __pyx_k_connect[] = "connect";
static const char __pyx_k_decimal[] = "decimal";
static const char __pyx_k_decoder[] = "decoder";
static const char __pyx_k_encoder[] = "encoder";
static const char __pyx_k_execute[] = "_execute";
static const char __pyx_k_inspect[] = "inspect";
static const char __pyx_k_maxsize[] = "maxsize";
static const char __pyx_k_members[] = "__members__";
static const char __pyx_k_parents[] = "parents";
static const char __pyx_k_pgproto[] = "pgproto";
static const char __pyx_k_popitem[] = "popitem";
static const char __pyx_k_prepare[] = "__prepare__";
static const char __pyx_k_restore[] = "restore";
static const char __pyx_k_std_str[] = "std::str";
static const char __pyx_k_weakref[] = "weakref";
static const char __pyx_k_EnumBase[] = "EnumBase";
static const char __pyx_k_EnumType[] = "EnumType";
static const char __pyx_k_IoFormat[] = "IoFormat";
static const char __pyx_k_Iterable[] = "Iterable";
static const char __pyx_k_KeyError[] = "KeyError";
static const char __pyx_k_SetCodec[] = "SetCodec";
static const char __pyx_k_SizedABC[] = "SizedABC";
static const char __pyx_k_TYPE_IDS[] = "TYPE_IDS";
static const char __pyx_k_anytuple[] = "anytuple";
static const char __pyx_k_argument[] = "argument $";
static const char __pyx_k_data_gen[] = "data_gen";
static const char __pyx_k_database[] = "database";
static const char __pyx_k_datetime[] = "datetime";
static const char __pyx_k_expected[] = "expected ";
static const char __pyx_k_get_code[] = "get_code";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_no_input[] = "no-input";
static const char __pyx_k_password[] = "password";
static const char __pyx_k_pyx_type[] = "__pyx_type";
static const char __pyx_k_qualname[] = "__qualname__";
static const char __pyx_k_reversed[] = "reversed";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_std_bool[] = "std::bool";
static const char __pyx_k_std_json[] = "std::json";
static const char __pyx_k_std_uuid[] = "std::uuid";
static const char __pyx_k_BaseCodec[] = "BaseCodec";
static const char __pyx_k_EnumCodec[] = "EnumCodec";
static const char __pyx_k_NullCodec[] = "NullCodec";
static const char __pyx_k_TypeError[] = "TypeError";
static const char __pyx_k_arguments[] = " arguments";
static const char __pyx_k_auth_sasl[] = "_auth_sasl";
static const char __pyx_k_datatypes[] = "datatypes";
static const char __pyx_k_enumerate[] = "enumerate";
static const char __pyx_k_from_code[] = "_from_code";
static const char __pyx_k_io_format[] = "io_format";
static const char __pyx_k_metaclass[] = "__metaclass__";
static const char __pyx_k_pyx_state[] = "__pyx_state";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_std_bytes[] = "std::bytes";
static const char __pyx_k_std_int16[] = "std::int16";
static const char __pyx_k_std_int32[] = "std::int32";
static const char __pyx_k_std_int64[] = "std::int64";
static const char __pyx_k_timedelta[] = "timedelta";
static const char __pyx_k_ArrayCodec[] = "ArrayCodec";
static const char __pyx_k_LRUMapping[] = "LRUMapping";
static const char __pyx_k_MappingABC[] = "MappingABC";
static const char __pyx_k_NamedTuple[] = "NamedTuple";
static const char __pyx_k_TupleCodec[] = "TupleCodec";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_cache_size[] = "cache_size";
static const char __pyx_k_cfg_memory[] = "cfg::memory";
static const char __pyx_k_con_params[] = "con_params";
static const char __pyx_k_expect_one[] = "expect_one";
static const char __pyx_k_expected_2[] = ", expected ";
static const char __pyx_k_from_bytes[] = "from_bytes";
static const char __pyx_k_null_codec[] = "null-codec";
static const char __pyx_k_pyx_result[] = "__pyx_result";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_std_bigint[] = "std::bigint";
static const char __pyx_k_tls_compat[] = "tls_compat";
static const char __pyx_k_ClientError[] = "ClientError";
static const char __pyx_k_EdgeDBError[] = "EdgeDBError";
static const char __pyx_k_IterableABC[] = "IterableABC";
static const char __pyx_k_LookupError[] = "LookupError";
static const char __pyx_k_NoDataError[] = "NoDataError";
static const char __pyx_k_ObjectCodec[] = "ObjectCodec";
static const char __pyx_k_OrderedDict[] = "OrderedDict";
static const char __pyx_k_PickleError[] = "PickleError";
static const char __pyx_k_ScalarCodec[] = "ScalarCodec";
static const char __pyx_k_collections[] = "collections";
static const char __pyx_k_empty_tuple[] = "empty-tuple";
static const char __pyx_k_move_to_end[] = "move_to_end";
static const char __pyx_k_std_decimal[] = "std::decimal";
static const char __pyx_k_std_float32[] = "std::float32";
static const char __pyx_k_std_float64[] = "std::float64";
static const char __pyx_k_Pyx_EnumBase[] = "__Pyx_EnumBase";
static const char __pyx_k_RuntimeError[] = "RuntimeError";
static const char __pyx_k_capabilities[] = "capabilities";
static const char __pyx_k_elements_got[] = " elements, got ";
static const char __pyx_k_microseconds[] = "microseconds";
static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
static const char __pyx_k_query_single[] = "query_single";
static const char __pyx_k_required_one[] = "required_one";
static const char __pyx_k_simple_query[] = "simple_query";
static const char __pyx_k_std_datetime[] = "std::datetime";
static const char __pyx_k_std_duration[] = "std::duration";
static const char __pyx_k_stringsource[] = "stringsource";
static const char __pyx_k_EdgeDBMessage[] = "EdgeDBMessage";
static const char __pyx_k_JSON_ELEMENTS[] = "JSON_ELEMENTS";
static const char __pyx_k_ProtocolError[] = "ProtocolError";
static const char __pyx_k_SCRAM_SHA_256[] = "SCRAM-SHA-256";
static const char __pyx_k_asyncio_tasks[] = "asyncio.tasks";
static const char __pyx_k_not_connected[] = "not connected";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_system_config[] = "system_config";
static const char __pyx_k_BaseArrayCodec[] = "BaseArrayCodec";
static const char __pyx_k_CodecsRegistry[] = "CodecsRegistry";
static const char __pyx_k_InterfaceError[] = "InterfaceError";
static const char __pyx_k_SansIOProtocol[] = "SansIOProtocol";
static const char __pyx_k_block_callback[] = "block_callback";
static const char __pyx_k_cal_local_date[] = "cal::local_date";
static const char __pyx_k_cal_local_time[] = "cal::local_time";
static const char __pyx_k_edgedb_pgproto[] = "edgedb.pgproto";
static const char __pyx_k_generate_nonce[] = "generate_nonce";
static const char __pyx_k_implicit_limit[] = "implicit_limit";
static const char __pyx_k_inline_typeids[] = "inline_typeids";
static const char __pyx_k_on_log_message[] = "_on_log_message";
static const char __pyx_k_BaseRecordCodec[] = "BaseRecordCodec";
static const char __pyx_k_EMPTY_NULL_DATA[] = "EMPTY_NULL_DATA";
static const char __pyx_k_EmptyTupleCodec[] = "EmptyTupleCodec";
static const char __pyx_k_NamedTupleCodec[] = "NamedTupleCodec";
static const char __pyx_k_Python_override[] = "<Python override>";
static const char __pyx_k_collections_abc[] = "collections.abc";
static const char __pyx_k_expected_an_int[] = "expected an int";
static const char __pyx_k_header_callback[] = "header_callback";
static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_ALL_CAPABILITIES[] = "ALL_CAPABILITIES";
static const char __pyx_k_MappingProxyType[] = "MappingProxyType";
static const char __pyx_k_QueryCodecsCache[] = "QueryCodecsCache";
static const char __pyx_k_edgedb_datatypes[] = "edgedb.datatypes";
static const char __pyx_k_inline_typenames[] = "inline_typenames";
static const char __pyx_k_returned_no_data[] = "() returned no data";
static const char __pyx_k_try_recv_eagerly[] = "try_recv_eagerly";
static const char __pyx_k_wait_for_connect[] = "wait_for_connect";
static const char __pyx_k_wait_for_message[] = "wait_for_message";
static const char __pyx_k_EMPTY_RECORD_DATA[] = "EMPTY_RECORD_DATA";
static const char __pyx_k_already_connected[] = "already connected";
static const char __pyx_k_execute_anonymous[] = "execute_anonymous";
static const char __pyx_k_keyword_arguments[] = " keyword arguments";
static const char __pyx_k_query_single_json[] = "query_single_json";
static const char __pyx_k_EdegDBCodecContext[] = "EdegDBCodecContext";
static const char __pyx_k_Pyx_EnumBase___new[] = "__Pyx_EnumBase.__new__";
static const char __pyx_k_Pyx_EnumBase___str[] = "__Pyx_EnumBase.__str__";
static const char __pyx_k_QueryArgumentError[] = "QueryArgumentError";
static const char __pyx_k_allow_capabilities[] = "allow_capabilities";
static const char __pyx_k_asyncio_coroutines[] = "asyncio.coroutines";
static const char __pyx_k_cal_local_datetime[] = "cal::local_datetime";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_optimistic_execute[] = "_optimistic_execute";
static const char __pyx_k_query_executed_via[] = "query executed via ";
static const char __pyx_k_CodecPythonOverride[] = "CodecPythonOverride";
static const char __pyx_k_NotImplementedError[] = "NotImplementedError";
static const char __pyx_k_Pyx_EnumBase___repr[] = "__Pyx_EnumBase.__repr__";
static const char __pyx_k_QUERY_SINGLE_METHOD[] = "_QUERY_SINGLE_METHOD";
static const char __pyx_k_SansIOProtocol_dump[] = "SansIOProtocol.dump";
static const char __pyx_k_BaseNamedRecordCodec[] = "BaseNamedRecordCodec";
static const char __pyx_k_InvalidArgumentError[] = "InvalidArgumentError";
static const char __pyx_k_SansIOProtocol__sync[] = "SansIOProtocol._sync";
static const char __pyx_k_Unknown_enum_value_s[] = "Unknown enum value: '%s'";
static const char __pyx_k_bad_bigint_sign_data[] = "bad bigint sign data";
static const char __pyx_k_ClientConnectionError[] = "ClientConnectionError";
static const char __pyx_k_SansIOProtocol__parse[] = "SansIOProtocol._parse";
static const char __pyx_k_base_scalar_codec_for[] = "base scalar codec for ";
static const char __pyx_k_cal_relative_duration[] = "cal::relative_duration";
static const char __pyx_k_invalid_array_element[] = "invalid array element: {}";
static const char __pyx_k_invalid_buffer_length[] = "invalid buffer length";
static const char __pyx_k_is_already_registered[] = " is already registered";
static const char __pyx_k_neither_are_supported[] = ", neither are supported.";
static const char __pyx_k_query_required_single[] = "query_required_single";
static const char __pyx_k_typeid_must_be_a_UUID[] = "typeid must be a UUID";
static const char __pyx_k_SansIOProtocol_connect[] = "SansIOProtocol.connect";
static const char __pyx_k_SansIOProtocol_restore[] = "SansIOProtocol.restore";
static const char __pyx_k_edgedb_pgproto_pgproto[] = "edgedb.pgproto.pgproto";
static const char __pyx_k_fetchall_json_elements[] = "_fetchall_json_elements";
static const char __pyx_k_SansIOProtocol__execute[] = "SansIOProtocol._execute";
static const char __pyx_k_pyx_unpickle_LRUMapping[] = "__pyx_unpickle_LRUMapping";
static const char __pyx_k_unexpected_message_type[] = "unexpected message type ";
static const char __pyx_k_as_it_returns_a_multiset[] = "() as it returns a multiset";
static const char __pyx_k_edgedb_protocol_protocol[] = "edgedb.protocol.protocol";
static const char __pyx_k_SansIOProtocol__auth_sasl[] = "SansIOProtocol._auth_sasl";
static const char __pyx_k_elements_in_the_tuple_got[] = " elements in the tuple, got ";
static const char __pyx_k_build_client_final_message[] = "build_client_final_message";
static const char __pyx_k_build_client_first_message[] = "build_client_first_message";
static const char __pyx_k_more_than_one_header_block[] = "more than one header block";
static const char __pyx_k_parse_server_final_message[] = "parse_server_final_message";
static const char __pyx_k_parse_server_first_message[] = "parse_server_first_message";
static const char __pyx_k_query_required_single_json[] = "query_required_single_json";
static const char __pyx_k_suggested_pool_concurrency[] = "suggested_pool_concurrency";
static const char __pyx_k_ClientConnectionClosedError[] = "ClientConnectionClosedError";
static const char __pyx_k_SansIOProtocol_simple_query[] = "SansIOProtocol.simple_query";
static const char __pyx_k_expected_no_named_arguments[] = "expected no named arguments";
static const char __pyx_k_invalid_array_size_received[] = "invalid array size: received ";
static const char __pyx_k_pyx_unpickle_CodecsRegistry[] = "__pyx_unpickle_CodecsRegistry";
static const char __pyx_k_pyx_unpickle_SansIOProtocol[] = "__pyx_unpickle_SansIOProtocol";
static const char __pyx_k_pyx_unpickle___Pyx_EnumMeta[] = "__pyx_unpickle___Pyx_EnumMeta";
static const char __pyx_k_cannot_decode_Tuple_expected[] = "cannot decode Tuple: expected ";
static const char __pyx_k_expected_a_Decimal_or_an_int[] = "expected a Decimal or an int";
static const char __pyx_k_first_message_is_not_DataMsg[] = "first message is not \"DataMsg\"";
static const char __pyx_k_cannot_decode_Object_expected[] = "cannot decode Object: expected ";
static const char __pyx_k_cannot_find_known_ID_for_type[] = "cannot find known ID for type ";
static const char __pyx_k_header_block_after_data_block[] = "header block after data block";
static const char __pyx_k_header_block_was_not_received[] = "header block was not received";
static const char __pyx_k_is_required_but_received_None[] = " is required, but received None";
static const char __pyx_k_non_idle_status_after_connect[] = "non-idle status after connect";
static const char __pyx_k_pyx_unpickle_QueryCodecsCache[] = "__pyx_unpickle_QueryCodecsCache";
static const char __pyx_k_query_cannot_be_executed_with[] = "query cannot be executed with ";
static const char __pyx_k_too_many_elements_for_a_tuple[] = "too many elements for a tuple";
static const char __pyx_k_ResultCardinalityMismatchError[] = "ResultCardinalityMismatchError";
static const char __pyx_k_as_it_does_not_return_any_data[] = "() as it does not return any data";
static const char __pyx_k_data_block_before_header_block[] = "data block before header block";
static const char __pyx_k_the_connection_has_been_closed[] = "the connection has been closed";
static const char __pyx_k_SansIOProtocol_try_recv_eagerly[] = "SansIOProtocol.try_recv_eagerly";
static const char __pyx_k_SansIOProtocol_wait_for_connect[] = "SansIOProtocol.wait_for_connect";
static const char __pyx_k_SansIOProtocol_wait_for_message[] = "SansIOProtocol.wait_for_message";
static const char __pyx_k_bigint_data_has_fractional_part[] = "bigint data has fractional part";
static const char __pyx_k_does_not_correspond_to_any_know[] = " does not correspond to any known base type";
static const char __pyx_k_expected_a_record_with_a_single[] = "expected a record with a single element as an array set element envelope";
static const char __pyx_k_make_missing_args_error_message[] = "_make_missing_args_error_message";
static const char __pyx_k_python_is_the_only_valid_format[] = "\"python\" is the only valid format";
static const char __pyx_k_result_is_not_an_edgedb_Set_but[] = "result is not an edgedb.Set, but ";
static const char __pyx_k_unable_to_decode_data_to_Python[] = "unable to decode data to Python objects";
static const char __pyx_k_unexpected_query_argument_codec[] = "unexpected query argument codec";
static const char __pyx_k_00000000_0000_0000_0000_00000000[] = "00000000-0000-0000-0000-000000000001";
static const char __pyx_k_Incompatible_checksums_s_vs_0x32[] = "Incompatible checksums (%s vs 0x324635c = (base_codec_overrides, codecs, codecs_build_cache))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x53[] = "Incompatible checksums (%s vs 0x53368d7 = (_dict, _dict_get, _dict_move_to_end, _maxsize))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x5d[] = "Incompatible checksums (%s vs 0x5da7eb4 = (queries))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xad[] = "Incompatible checksums (%s vs 0xadcaa09 = (backend_secret, buffer, cancelled, con, con_params, connected, internal_reg, last_details, last_status, protocol_version, server_settings, tls_compat, xact_status))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xd4[] = "Incompatible checksums (%s vs 0xd41d8cd = ())";
static const char __pyx_k_SansIOProtocol__optimistic_execu[] = "SansIOProtocol._optimistic_execute";
static const char __pyx_k_SansIOProtocol_execute_anonymous[] = "SansIOProtocol.execute_anonymous";
static const char __pyx_k_a_datetime_datetime_object_was_e[] = "a datetime.datetime object was expected, got ";
static const char __pyx_k_a_naive_date_object_tzinfo_is_No[] = "a naive date object (tzinfo is None) was expected";
static const char __pyx_k_a_naive_datetime_object_tzinfo_i[] = "a naive datetime object (tzinfo is None) was expected";
static const char __pyx_k_a_naive_time_object_tzinfo_is_No[] = "a naive time object (tzinfo is None) was expected";
static const char __pyx_k_a_scalar_codec_expected_for_base[] = "a scalar codec expected for base scalar type, got ";
static const char __pyx_k_a_sized_iterable_container_expec[] = "a sized iterable container expected (got type {!r})";
static const char __pyx_k_a_str_or_edgedb_EnumValue_is_exp[] = "a str or edgedb.EnumValue is expected as a valid enum argument, got ";
static const char __pyx_k_a_timezone_aware_datetime_object[] = "a timezone-aware datetime object (tzinfo is not None) was expected";
static const char __pyx_k_argument_tuples_only_support_sca[] = "argument tuples only support scalars and arrays of scalars";
static const char __pyx_k_cannot_decode_NamedTuple_expecte[] = "cannot decode NamedTuple: expected ";
static const char __pyx_k_cannot_decode_empty_Tuple_expect[] = "cannot decode empty Tuple: expected 0 elements, got ";
static const char __pyx_k_cannot_encode_empty_Tuple_expect[] = "cannot encode empty Tuple: expected a tuple, got ";
static const char __pyx_k_cannot_handle_arrays_with_more_t[] = "cannot handle arrays with more than one dimension";
static const char __pyx_k_cannot_not_build_codec_empty_typ[] = "cannot not build codec; empty type desc";
static const char __pyx_k_codecs_are_not_supposed_to_be_in[] = "codecs are not supposed to be instantiated directly";
static const char __pyx_k_either_positional_or_named_argum[] = "either positional or named arguments are supported; not both";
static const char __pyx_k_expected_SASLContinue_from_the_s[] = "expected SASLContinue from the server, received ";
static const char __pyx_k_expected_SASLFinal_from_the_serv[] = "expected SASLFinal from the server, received ";
static const char __pyx_k_expected_a_two_dimensional_array[] = "expected a two-dimensional array for a set of arrays";
static const char __pyx_k_expected_named_arguments_got_pos[] = "expected named arguments, got positional arguments";
static const char __pyx_k_expected_no_positional_arguments[] = "expected no positional arguments";
static const char __pyx_k_expected_positional_arguments_go[] = "expected positional arguments, got named arguments";
static const char __pyx_k_invalid_input_for_query_argument[] = "invalid input for query argument ${n}: {v} ({msg})";
static const char __pyx_k_invalid_number_of_columns_expect[] = "invalid number of columns: expected 1 got ";
static const char __pyx_k_maxsize_is_expected_to_be_greate[] = "maxsize is expected to be greater than 0, got ";
static const char __pyx_k_no_codec_implementation_for_Edge[] = "no codec implementation for EdgeDB data class ";
static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
static const char __pyx_k_non_zero_reserved_bytes_in_durat[] = "non-zero reserved bytes in duration";
static const char __pyx_k_only_1_dimensional_arrays_are_su[] = "only 1-dimensional arrays are supported";
static const char __pyx_k_only_arrays_of_scalars_are_suppo[] = "only arrays of scalars are supported";
static const char __pyx_k_server_SCRAM_proof_does_not_matc[] = "server SCRAM proof does not match";
static const char __pyx_k_the_connection_has_been_closed_b[] = "the connection has been closed because an operation was cancelled on it";
static const char __pyx_k_the_protocol_version_requires_TL[] = "the protocol version requires TLS: {}.{}";
static const char __pyx_k_the_server_offered_the_following[] = "the server offered the following SASL authentication methods: ";
static const char __pyx_k_the_server_requested_SASL_authen[] = "the server requested SASL authentication but did not offer any methods";
static const char __pyx_k_the_server_requested_an_unsuppor[] = "the server requested an unsupported version of the protocol: ";
static const char __pyx_k_too_many_elements_in_array_value[] = "too many elements in array value";
static const char __pyx_k_unexpected_NULL_value_in_array_s[] = "unexpected NULL value in array set element ";
static const char __pyx_k_unexpected_trailing_data_in_buff[] = "unexpected trailing data in buffer after tuple element decoding: ";
static const char __pyx_k_unsupported_authentication_metho[] = "unsupported authentication method requested by the server: ";
static const char __pyx_k_00000000_0000_0000_0000_00000000_2[] = "00000000-0000-0000-0000-000000000002";
static const char __pyx_k_00000000_0000_0000_0000_00000000_3[] = "00000000-0000-0000-0000-0000000000f0";
static const char __pyx_k_00000000_0000_0000_0000_00000000_4[] = "00000000-0000-0000-0000-0000000000ff";
static const char __pyx_k_00000000_0000_0000_0000_00000000_5[] = "00000000-0000-0000-0000-000000000100";
static const char __pyx_k_00000000_0000_0000_0000_00000000_6[] = "00000000-0000-0000-0000-000000000101";
static const char __pyx_k_00000000_0000_0000_0000_00000000_7[] = "00000000-0000-0000-0000-000000000102";
static const char __pyx_k_00000000_0000_0000_0000_00000000_8[] = "00000000-0000-0000-0000-000000000103";
static const char __pyx_k_00000000_0000_0000_0000_00000000_9[] = "00000000-0000-0000-0000-000000000104";
static const char __pyx_k_a_datetime_datetime_object_was_e_2[] = "a datetime.datetime object was expected";
static const char __pyx_k_cannot_encode_empty_Tuple_expect_2[] = "cannot encode empty Tuple: expected 0 elements, got ";
static const char __pyx_k_invalid_input_for_query_argument_2[] = "invalid input for query argument $";
static const char __pyx_k_unexpected_trailing_data_in_buff_2[] = "unexpected trailing data in buffer after named tuple element decoding: ";
static const char __pyx_k_unexpected_trailing_data_in_buff_3[] = "unexpected trailing data in buffer after object element decoding: ";
static const char __pyx_k_unexpected_trailing_data_in_buff_4[] = "unexpected trailing data in buffer after array element decoding: ";
static const char __pyx_k_unexpected_trailing_data_in_buff_5[] = "unexpected trailing data in buffer after set element decoding: ";
static const char __pyx_k_unexpected_trailing_data_in_buff_6[] = "unexpected trailing data in buffer after data message decoding: ";
static const char __pyx_k_00000000_0000_0000_0000_00000000_10[] = "00000000-0000-0000-0000-000000000105";
static const char __pyx_k_00000000_0000_0000_0000_00000000_11[] = "00000000-0000-0000-0000-000000000106";
static const char __pyx_k_00000000_0000_0000_0000_00000000_12[] = "00000000-0000-0000-0000-000000000107";
static const char __pyx_k_00000000_0000_0000_0000_00000000_13[] = "00000000-0000-0000-0000-000000000108";
static const char __pyx_k_00000000_0000_0000_0000_00000000_14[] = "00000000-0000-0000-0000-000000000109";
static const char __pyx_k_00000000_0000_0000_0000_00000000_15[] = "00000000-0000-0000-0000-00000000010a";
static const char __pyx_k_00000000_0000_0000_0000_00000000_16[] = "00000000-0000-0000-0000-00000000010b";
static const char __pyx_k_00000000_0000_0000_0000_00000000_17[] = "00000000-0000-0000-0000-00000000010c";
static const char __pyx_k_00000000_0000_0000_0000_00000000_18[] = "00000000-0000-0000-0000-00000000010d";
static const char __pyx_k_00000000_0000_0000_0000_00000000_19[] = "00000000-0000-0000-0000-00000000010e";
static const char __pyx_k_00000000_0000_0000_0000_00000000_20[] = "00000000-0000-0000-0000-00000000010f";
static const char __pyx_k_00000000_0000_0000_0000_00000000_21[] = "00000000-0000-0000-0000-000000000110";
static const char __pyx_k_00000000_0000_0000_0000_00000000_22[] = "00000000-0000-0000-0000-000000000111";
static const char __pyx_k_00000000_0000_0000_0000_00000000_23[] = "00000000-0000-0000-0000-000000000130";
static PyObject *__pyx_kp_u_0000;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_10;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_11;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_12;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_13;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_14;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_15;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_16;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_17;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_18;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_19;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_2;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_20;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_21;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_22;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_23;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_3;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_4;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_5;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_6;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_7;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_8;
static PyObject *__pyx_kp_u_00000000_0000_0000_0000_00000000_9;
static PyObject *__pyx_n_s_ALL_CAPABILITIES;
static PyObject *__pyx_n_u_Array;
static PyObject *__pyx_n_s_ArrayCodec;
static PyObject *__pyx_n_s_BINARY;
static PyObject *__pyx_n_s_BaseArrayCodec;
static PyObject *__pyx_n_s_BaseCodec;
static PyObject *__pyx_n_s_BaseNamedRecordCodec;
static PyObject *__pyx_n_s_BaseRecordCodec;
static PyObject *__pyx_n_s_ClientConnectionClosedError;
static PyObject *__pyx_n_s_ClientConnectionError;
static PyObject *__pyx_n_s_ClientError;
static PyObject *__pyx_n_s_CodecPythonOverride;
static PyObject *__pyx_n_s_CodecsRegistry;
static PyObject *__pyx_n_s_Decimal;
static PyObject *__pyx_n_s_EMPTY_NULL_DATA;
static PyObject *__pyx_n_s_EMPTY_RECORD_DATA;
static PyObject *__pyx_n_s_EdegDBCodecContext;
static PyObject *__pyx_n_s_EdgeDBError;
static PyObject *__pyx_n_s_EdgeDBMessage;
static PyObject *__pyx_n_s_EmptyTupleCodec;
static PyObject *__pyx_n_u_Enum;
static PyObject *__pyx_n_s_EnumBase;
static PyObject *__pyx_n_s_EnumCodec;
static PyObject *__pyx_n_s_EnumType;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x32;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x53;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x5d;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xad;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xd4;
static PyObject *__pyx_n_s_IntEnum;
static PyObject *__pyx_n_s_InterfaceError;
static PyObject *__pyx_n_s_InvalidArgumentError;
static PyObject *__pyx_n_s_IoFormat;
static PyObject *__pyx_n_s_Iterable;
static PyObject *__pyx_n_s_IterableABC;
static PyObject *__pyx_n_s_JSON;
static PyObject *__pyx_n_s_JSON_ELEMENTS;
static PyObject *__pyx_n_s_KeyError;
static PyObject *__pyx_n_s_LRUMapping;
static PyObject *__pyx_n_s_LookupError;
static PyObject *__pyx_n_s_Mapping;
static PyObject *__pyx_n_s_MappingABC;
static PyObject *__pyx_n_s_MappingProxyType;
static PyObject *__pyx_n_u_NamedTuple;
static PyObject *__pyx_n_s_NamedTupleCodec;
static PyObject *__pyx_n_s_NoDataError;
static PyObject *__pyx_kp_u_None;
static PyObject *__pyx_n_s_NotImplementedError;
static PyObject *__pyx_n_s_NullCodec;
static PyObject *__pyx_n_u_Object;
static PyObject *__pyx_n_s_ObjectCodec;
static PyObject *__pyx_n_s_OrderedDict;
static PyObject *__pyx_n_s_PickleError;
static PyObject *__pyx_n_s_ProtocolError;
static PyObject *__pyx_kp_u_Python_override;
static PyObject *__pyx_n_s_Pyx_EnumBase;
static PyObject *__pyx_n_s_Pyx_EnumBase___new;
static PyObject *__pyx_n_s_Pyx_EnumBase___repr;
static PyObject *__pyx_n_s_Pyx_EnumBase___str;
static PyObject *__pyx_n_s_QUERY_SINGLE_METHOD;
static PyObject *__pyx_n_s_QueryArgumentError;
static PyObject *__pyx_n_s_QueryCodecsCache;
static PyObject *__pyx_n_s_ResultCardinalityMismatchError;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_kp_b_SCRAM_SHA_256;
static PyObject *__pyx_n_s_SansIOProtocol;
static PyObject *__pyx_n_s_SansIOProtocol__auth_sasl;
static PyObject *__pyx_n_s_SansIOProtocol__execute;
static PyObject *__pyx_n_s_SansIOProtocol__optimistic_execu;
static PyObject *__pyx_n_s_SansIOProtocol__parse;
static PyObject *__pyx_n_s_SansIOProtocol__sync;
static PyObject *__pyx_n_s_SansIOProtocol_connect;
static PyObject *__pyx_n_s_SansIOProtocol_dump;
static PyObject *__pyx_n_s_SansIOProtocol_execute_anonymous;
static PyObject *__pyx_n_s_SansIOProtocol_restore;
static PyObject *__pyx_n_s_SansIOProtocol_simple_query;
static PyObject *__pyx_n_s_SansIOProtocol_try_recv_eagerly;
static PyObject *__pyx_n_s_SansIOProtocol_wait_for_connect;
static PyObject *__pyx_n_s_SansIOProtocol_wait_for_message;
static PyObject *__pyx_n_s_ScalarCodec;
static PyObject *__pyx_n_u_Set;
static PyObject *__pyx_n_s_SetCodec;
static PyObject *__pyx_n_s_Sized;
static PyObject *__pyx_n_s_SizedABC;
static PyObject *__pyx_n_s_TYPE_IDS;
static PyObject *__pyx_n_u_Tuple;
static PyObject *__pyx_n_s_TupleCodec;
static PyObject *__pyx_n_s_TypeError;
static PyObject *__pyx_n_s_UUID;
static PyObject *__pyx_kp_s_Unknown_enum_value_s;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_kp_b__106;
static PyObject *__pyx_kp_b__108;
static PyObject *__pyx_kp_b__109;
static PyObject *__pyx_kp_u__14;
static PyObject *__pyx_kp_u__17;
static PyObject *__pyx_kp_u__18;
static PyObject *__pyx_kp_u__2;
static PyObject *__pyx_kp_u__29;
static PyObject *__pyx_kp_u__30;
static PyObject *__pyx_kp_u__31;
static PyObject *__pyx_kp_b__61;
static PyObject *__pyx_kp_u__61;
static PyObject *__pyx_kp_u__62;
static PyObject *__pyx_kp_u__68;
static PyObject *__pyx_kp_u__75;
static PyObject *__pyx_kp_u__78;
static PyObject *__pyx_kp_u_a_datetime_datetime_object_was_e;
static PyObject *__pyx_kp_u_a_datetime_datetime_object_was_e_2;
static PyObject *__pyx_kp_u_a_naive_date_object_tzinfo_is_No;
static PyObject *__pyx_kp_u_a_naive_datetime_object_tzinfo_i;
static PyObject *__pyx_kp_u_a_naive_time_object_tzinfo_is_No;
static PyObject *__pyx_kp_u_a_scalar_codec_expected_for_base;
static PyObject *__pyx_kp_u_a_sized_iterable_container_expec;
static PyObject *__pyx_kp_u_a_str_or_edgedb_EnumValue_is_exp;
static PyObject *__pyx_kp_u_a_timezone_aware_datetime_object;
static PyObject *__pyx_n_s_abort;
static PyObject *__pyx_n_s_aiter;
static PyObject *__pyx_n_s_allow_capabilities;
static PyObject *__pyx_kp_u_already_connected;
static PyObject *__pyx_n_s_anext;
static PyObject *__pyx_n_u_anytuple;
static PyObject *__pyx_n_u_anytype;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_kp_u_argument;
static PyObject *__pyx_kp_u_argument_tuples_only_support_sca;
static PyObject *__pyx_kp_u_arguments;
static PyObject *__pyx_kp_u_as_it_does_not_return_any_data;
static PyObject *__pyx_kp_u_as_it_returns_a_multiset;
static PyObject *__pyx_n_s_asyncio;
static PyObject *__pyx_n_s_asyncio_coroutines;
static PyObject *__pyx_n_s_asyncio_tasks;
static PyObject *__pyx_n_s_attrs;
static PyObject *__pyx_n_s_auth_sasl;
static PyObject *__pyx_n_s_await;
static PyObject *__pyx_kp_u_bad_bigint_sign_data;
static PyObject *__pyx_kp_u_base_scalar_codec_for;
static PyObject *__pyx_n_u_big;
static PyObject *__pyx_kp_u_bigint_data_has_fractional_part;
static PyObject *__pyx_n_s_block_callback;
static PyObject *__pyx_n_s_build_client_final_message;
static PyObject *__pyx_n_s_build_client_first_message;
static PyObject *__pyx_n_s_bytes;
static PyObject *__pyx_n_s_bytes_2;
static PyObject *__pyx_n_s_cache_size;
static PyObject *__pyx_kp_u_cal_local_date;
static PyObject *__pyx_kp_u_cal_local_datetime;
static PyObject *__pyx_kp_u_cal_local_time;
static PyObject *__pyx_kp_u_cal_relative_duration;
static PyObject *__pyx_kp_u_cannot_decode_NamedTuple_expecte;
static PyObject *__pyx_kp_u_cannot_decode_Object_expected;
static PyObject *__pyx_kp_u_cannot_decode_Tuple_expected;
static PyObject *__pyx_kp_u_cannot_decode_empty_Tuple_expect;
static PyObject *__pyx_kp_u_cannot_encode_empty_Tuple_expect;
static PyObject *__pyx_kp_u_cannot_encode_empty_Tuple_expect_2;
static PyObject *__pyx_kp_u_cannot_find_known_ID_for_type;
static PyObject *__pyx_kp_u_cannot_handle_arrays_with_more_t;
static PyObject *__pyx_kp_u_cannot_not_build_codec_empty_typ;
static PyObject *__pyx_n_s_capabilities;
static PyObject *__pyx_n_s_cause;
static PyObject *__pyx_kp_u_cfg_memory;
static PyObject *__pyx_n_s_chr;
static PyObject *__pyx_n_s_class;
static PyObject *__pyx_n_s_clear;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_close;
static PyObject *__pyx_n_s_cls;
static PyObject *__pyx_n_s_code;
static PyObject *__pyx_n_s_codecs;
static PyObject *__pyx_kp_u_codecs_are_not_supposed_to_be_in;
static PyObject *__pyx_n_s_collections;
static PyObject *__pyx_n_s_collections_abc;
static PyObject *__pyx_n_s_con_params;
static PyObject *__pyx_n_s_connect;
static PyObject *__pyx_kp_u_data_block_before_header_block;
static PyObject *__pyx_n_s_data_gen;
static PyObject *__pyx_n_s_database;
static PyObject *__pyx_n_u_database;
static PyObject *__pyx_n_s_datatypes;
static PyObject *__pyx_n_s_datetime;
static PyObject *__pyx_n_s_days;
static PyObject *__pyx_n_s_dct;
static PyObject *__pyx_n_s_decimal;
static PyObject *__pyx_n_s_decoder;
static PyObject *__pyx_n_s_dict;
static PyObject *__pyx_n_s_doc;
static PyObject *__pyx_kp_u_does_not_correspond_to_any_know;
static PyObject *__pyx_n_s_dump;
static PyObject *__pyx_n_s_edgedb;
static PyObject *__pyx_n_s_edgedb_datatypes;
static PyObject *__pyx_n_s_edgedb_pgproto;
static PyObject *__pyx_n_s_edgedb_pgproto_pgproto;
static PyObject *__pyx_n_s_edgedb_protocol_protocol;
static PyObject *__pyx_kp_u_either_positional_or_named_argum;
static PyObject *__pyx_kp_u_elements_got;
static PyObject *__pyx_kp_u_elements_in_the_tuple_got;
static PyObject *__pyx_kp_u_empty_tuple;
static PyObject *__pyx_n_s_encode;
static PyObject *__pyx_n_s_encoder;
static PyObject *__pyx_n_s_enum;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_n_s_enums;
static PyObject *__pyx_n_s_errors;
static PyObject *__pyx_n_s_execute;
static PyObject *__pyx_n_s_execute_anonymous;
static PyObject *__pyx_n_s_expect_one;
static PyObject *__pyx_kp_u_expected;
static PyObject *__pyx_kp_u_expected_2;
static PyObject *__pyx_kp_u_expected_SASLContinue_from_the_s;
static PyObject *__pyx_kp_u_expected_SASLFinal_from_the_serv;
static PyObject *__pyx_kp_u_expected_a_Decimal_or_an_int;
static PyObject *__pyx_kp_u_expected_a_record_with_a_single;
static PyObject *__pyx_kp_u_expected_a_two_dimensional_array;
static PyObject *__pyx_kp_u_expected_an_int;
static PyObject *__pyx_kp_u_expected_named_arguments_got_pos;
static PyObject *__pyx_kp_u_expected_no_named_arguments;
static PyObject *__pyx_kp_u_expected_no_positional_arguments;
static PyObject *__pyx_kp_u_expected_positional_arguments_go;
static PyObject *__pyx_kp_u_extra;
static PyObject *__pyx_n_u_fetchall_json_elements;
static PyObject *__pyx_kp_u_first_message_is_not_DataMsg;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_s_from_bytes;
static PyObject *__pyx_n_s_from_code;
static PyObject *__pyx_n_s_generate_nonce;
static PyObject *__pyx_n_s_get;
static PyObject *__pyx_n_s_get_code;
static PyObject *__pyx_n_s_getstate;
static PyObject *__pyx_kp_u_got;
static PyObject *__pyx_n_s_header;
static PyObject *__pyx_kp_u_header_block_after_data_block;
static PyObject *__pyx_kp_u_header_block_was_not_received;
static PyObject *__pyx_n_s_header_callback;
static PyObject *__pyx_n_s_id;
static PyObject *__pyx_n_s_implicit_limit;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_in_dc;
static PyObject *__pyx_n_s_init;
static PyObject *__pyx_n_s_inline_typeids;
static PyObject *__pyx_n_s_inline_typenames;
static PyObject *__pyx_n_s_inspect;
static PyObject *__pyx_kp_u_invalid_array_element;
static PyObject *__pyx_kp_u_invalid_array_size_received;
static PyObject *__pyx_kp_u_invalid_buffer_length;
static PyObject *__pyx_kp_u_invalid_input_for_query_argument;
static PyObject *__pyx_kp_u_invalid_input_for_query_argument_2;
static PyObject *__pyx_kp_u_invalid_number_of_columns_expect;
static PyObject *__pyx_n_s_io_format;
static PyObject *__pyx_kp_u_is_already_registered;
static PyObject *__pyx_kp_u_is_required_but_received_None;
static PyObject *__pyx_n_s_items;
static PyObject *__pyx_n_s_json;
static PyObject *__pyx_n_s_keys;
static PyObject *__pyx_kp_u_keyword_arguments;
static PyObject *__pyx_n_s_kwargs;
static PyObject *__pyx_n_s_last;
static PyObject *__pyx_n_s_lookup;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_make_missing_args_error_message;
static PyObject *__pyx_n_s_maxsize;
static PyObject *__pyx_kp_u_maxsize_is_expected_to_be_greate;
static PyObject *__pyx_n_s_members;
static PyObject *__pyx_n_s_metaclass;
static PyObject *__pyx_n_s_microseconds;
static PyObject *__pyx_kp_u_missed;
static PyObject *__pyx_n_s_module;
static PyObject *__pyx_n_s_months;
static PyObject *__pyx_kp_u_more_than_one_header_block;
static PyObject *__pyx_n_s_move_to_end;
static PyObject *__pyx_n_s_msg;
static PyObject *__pyx_n_b_n;
static PyObject *__pyx_n_s_n;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_name_2;
static PyObject *__pyx_kp_u_neither_are_supported;
static PyObject *__pyx_n_s_new;
static PyObject *__pyx_kp_u_no_codec_implementation_for_Edge;
static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
static PyObject *__pyx_kp_u_no_input;
static PyObject *__pyx_kp_u_non_idle_status_after_connect;
static PyObject *__pyx_kp_u_non_zero_reserved_bytes_in_durat;
static PyObject *__pyx_kp_u_not_connected;
static PyObject *__pyx_n_u_null;
static PyObject *__pyx_kp_u_null_codec;
static PyObject *__pyx_n_s_object;
static PyObject *__pyx_n_s_on_log_message;
static PyObject *__pyx_kp_u_only_1_dimensional_arrays_are_su;
static PyObject *__pyx_kp_u_only_arrays_of_scalars_are_suppo;
static PyObject *__pyx_n_s_optimistic_execute;
static PyObject *__pyx_n_s_out_dc;
static PyObject *__pyx_n_s_parents;
static PyObject *__pyx_n_s_parse;
static PyObject *__pyx_n_s_parse_server_final_message;
static PyObject *__pyx_n_s_parse_server_first_message;
static PyObject *__pyx_n_s_password;
static PyObject *__pyx_n_s_pgproto;
static PyObject *__pyx_n_s_pickle;
static PyObject *__pyx_n_s_popitem;
static PyObject *__pyx_n_s_prepare;
static PyObject *__pyx_n_u_python;
static PyObject *__pyx_kp_u_python_is_the_only_valid_format;
static PyObject *__pyx_n_s_pyx_PickleError;
static PyObject *__pyx_n_s_pyx_checksum;
static PyObject *__pyx_n_s_pyx_result;
static PyObject *__pyx_n_s_pyx_state;
static PyObject *__pyx_n_s_pyx_type;
static PyObject *__pyx_n_s_pyx_unpickle_CodecsRegistry;
static PyObject *__pyx_n_s_pyx_unpickle_LRUMapping;
static PyObject *__pyx_n_s_pyx_unpickle_QueryCodecsCache;
static PyObject *__pyx_n_s_pyx_unpickle_SansIOProtocol;
static PyObject *__pyx_n_s_pyx_unpickle___Pyx_EnumMeta;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_qc;
static PyObject *__pyx_n_s_qualname;
static PyObject *__pyx_n_s_query;
static PyObject *__pyx_kp_u_query_cannot_be_executed_with;
static PyObject *__pyx_kp_u_query_executed_via;
static PyObject *__pyx_n_u_query_required_single;
static PyObject *__pyx_n_u_query_required_single_json;
static PyObject *__pyx_n_u_query_single;
static PyObject *__pyx_n_u_query_single_json;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_reduce_cython;
static PyObject *__pyx_n_s_reduce_ex;
static PyObject *__pyx_n_s_ref;
static PyObject *__pyx_n_s_reg;
static PyObject *__pyx_n_s_repr;
static PyObject *__pyx_n_s_required_one;
static PyObject *__pyx_n_s_res;
static PyObject *__pyx_n_s_restore;
static PyObject *__pyx_kp_u_result_is_not_an_edgedb_Set_but;
static PyObject *__pyx_kp_u_returned_no_data;
static PyObject *__pyx_n_s_reversed;
static PyObject *__pyx_kp_s_s_s;
static PyObject *__pyx_kp_s_s_s_d;
static PyObject *__pyx_n_s_scram;
static PyObject *__pyx_n_s_self;
static PyObject *__pyx_n_s_send;
static PyObject *__pyx_kp_u_server_SCRAM_proof_does_not_matc;
static PyObject *__pyx_n_s_setstate;
static PyObject *__pyx_n_s_setstate_cython;
static PyObject *__pyx_n_s_simple_query;
static PyObject *__pyx_n_u_std;
static PyObject *__pyx_kp_u_std_bigint;
static PyObject *__pyx_kp_u_std_bool;
static PyObject *__pyx_kp_u_std_bytes;
static PyObject *__pyx_kp_u_std_datetime;
static PyObject *__pyx_kp_u_std_decimal;
static PyObject *__pyx_kp_u_std_duration;
static PyObject *__pyx_kp_u_std_float32;
static PyObject *__pyx_kp_u_std_float64;
static PyObject *__pyx_kp_u_std_int16;
static PyObject *__pyx_kp_u_std_int32;
static PyObject *__pyx_kp_u_std_int64;
static PyObject *__pyx_kp_u_std_json;
static PyObject *__pyx_kp_u_std_str;
static PyObject *__pyx_kp_u_std_uuid;
static PyObject *__pyx_n_s_str;
static PyObject *__pyx_kp_s_stringsource;
static PyObject *__pyx_n_s_strip;
static PyObject *__pyx_n_u_suggested_pool_concurrency;
static PyObject *__pyx_n_s_sync;
static PyObject *__pyx_n_u_system_config;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_kp_u_the_connection_has_been_closed;
static PyObject *__pyx_kp_u_the_connection_has_been_closed_b;
static PyObject *__pyx_kp_u_the_protocol_version_requires_TL;
static PyObject *__pyx_kp_u_the_server_offered_the_following;
static PyObject *__pyx_kp_u_the_server_requested_SASL_authen;
static PyObject *__pyx_kp_u_the_server_requested_an_unsuppor;
static PyObject *__pyx_n_s_throw;
static PyObject *__pyx_n_s_time;
static PyObject *__pyx_n_s_timedelta;
static PyObject *__pyx_n_s_tls_compat;
static PyObject *__pyx_kp_u_too_many_elements_for_a_tuple;
static PyObject *__pyx_kp_u_too_many_elements_in_array_value;
static PyObject *__pyx_n_s_try_recv_eagerly;
static PyObject *__pyx_n_s_typeid;
static PyObject *__pyx_kp_u_typeid_must_be_a_UUID;
static PyObject *__pyx_n_s_types;
static PyObject *__pyx_n_s_typing;
static PyObject *__pyx_n_u_tzinfo;
static PyObject *__pyx_kp_u_unable_to_decode_data_to_Python;
static PyObject *__pyx_kp_u_unexpected_NULL_value_in_array_s;
static PyObject *__pyx_kp_u_unexpected_message_type;
static PyObject *__pyx_kp_u_unexpected_query_argument_codec;
static PyObject *__pyx_kp_u_unexpected_trailing_data_in_buff;
static PyObject *__pyx_kp_u_unexpected_trailing_data_in_buff_2;
static PyObject *__pyx_kp_u_unexpected_trailing_data_in_buff_3;
static PyObject *__pyx_kp_u_unexpected_trailing_data_in_buff_4;
static PyObject *__pyx_kp_u_unexpected_trailing_data_in_buff_5;
static PyObject *__pyx_kp_u_unexpected_trailing_data_in_buff_6;
static PyObject *__pyx_kp_u_unsupported_authentication_metho;
static PyObject *__pyx_n_s_update;
static PyObject *__pyx_n_s_user;
static PyObject *__pyx_n_u_user;
static PyObject *__pyx_kp_u_utf_8;
static PyObject *__pyx_n_s_uuid;
static PyObject *__pyx_n_s_v;
static PyObject *__pyx_n_s_value;
static PyObject *__pyx_n_s_values;
static PyObject *__pyx_n_s_wait_for_connect;
static PyObject *__pyx_n_s_wait_for_message;
static PyObject *__pyx_n_s_weakref;
static PyObject *__pyx_n_s_zfill;
static int __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping___init__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self, PyObject *__pyx_v_maxsize); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_2__getitem__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_4__setitem__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_o); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_6__delitem__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_8__contains__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static Py_ssize_t __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_10__len__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_12__iter__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_14clear(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_16__reduce_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_18__setstate_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_9BaseCodec___init__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_9BaseCodec_2__cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_9BaseCodec_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_9BaseCodec_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_19CodecPythonOverride___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_19CodecPythonOverride_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_19CodecPythonOverride_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_15EmptyTupleCodec___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_15EmptyTupleCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_15EmptyTupleCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_9NullCodec___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_NullCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_9NullCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_NullCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_9NullCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_NullCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_15BaseRecordCodec___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_15BaseRecordCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_15BaseRecordCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_18EdegDBCodecContext___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_18EdegDBCodecContext_2get_text_codec(struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_18EdegDBCodecContext_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_18EdegDBCodecContext_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_11ScalarCodec___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_11ScalarCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_11ScalarCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10TupleCodec___reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10TupleCodec_2__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_15NamedTupleCodec__make_missing_args_error_message(struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *__pyx_v_self, PyObject *__pyx_v_args); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_15NamedTupleCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_15NamedTupleCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_11ObjectCodec__make_missing_args_error_message(struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *__pyx_v_self, PyObject *__pyx_v_args); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_11ObjectCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_11ObjectCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_14BaseArrayCodec___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14BaseArrayCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14BaseArrayCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10ArrayCodec___reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10ArrayCodec_2__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_8SetCodec___reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_8SetCodec_2__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_9EnumCodec___reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_9EnumCodec_2__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_14CodecsRegistry___init__(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self, PyObject *__pyx_v_cache_size); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14CodecsRegistry_2clear_cache(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14CodecsRegistry_4set_type_codec(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self, PyObject *__pyx_v_typeid, PyObject *__pyx_v_encoder, PyObject *__pyx_v_decoder, PyObject *__pyx_v_format); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14CodecsRegistry_6__reduce_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14CodecsRegistry_8__setstate_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_16QueryCodecsCache___init__(struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_self, PyObject *__pyx_v_cache_size); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_16QueryCodecsCache_2get(struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_self, PyObject *__pyx_v_query, enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __pyx_v_io_format, int __pyx_v_implicit_limit, int __pyx_v_inline_typenames, int __pyx_v_inline_typeids, int __pyx_v_expect_one); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_16QueryCodecsCache_4__reduce_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_16QueryCodecsCache_6__setstate_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol___init__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_con_params, PyObject *__pyx_v_tls_compat); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_2get_settings(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_4is_in_transaction(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_6set_connection(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_con); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_8abort(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_10wait_for_message(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_13try_recv_eagerly(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_16wait_for_connect(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_19_parse(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_query, struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_reg, enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __pyx_v_io_format, int __pyx_v_expect_one, PyObject *__pyx_v_required_one, PyObject *__pyx_v_implicit_limit, PyObject *__pyx_v_inline_typenames, PyObject *__pyx_v_inline_typeids, PyObject *__pyx_v_allow_capabilities); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_22_execute(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_in_dc, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_out_dc, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_25_optimistic_execute(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_query, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_reg, struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_qc, PyObject *__pyx_v_io_format, int __pyx_v_expect_one, int __pyx_v_required_one, PyObject *__pyx_v_implicit_limit, int __pyx_v_inline_typenames, int __pyx_v_inline_typeids, PyObject *__pyx_v_allow_capabilities, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_in_dc, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_out_dc); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_28simple_query(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_query, PyObject *__pyx_v_capabilities); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_31execute_anonymous(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_query, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_reg, struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_qc, PyObject *__pyx_v_io_format, int __pyx_v_expect_one, PyObject *__pyx_v_required_one, PyObject *__pyx_v_implicit_limit, PyObject *__pyx_v_inline_typenames, PyObject *__pyx_v_inline_typeids, PyObject *__pyx_v_allow_capabilities); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_34dump(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_header_callback, PyObject *__pyx_v_block_callback); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_37_sync(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_40restore(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_header, PyObject *__pyx_v_data_gen); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_43terminate(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_45connect(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_48_auth_sasl(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_9connected___get__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_9cancelled___get__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_10con_params___get__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_10tls_compat___get__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_11last_status___get__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_12last_details___get__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_16protocol_version___get__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_51__reduce_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_53__setstate_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol___pyx_unpickle_LRUMapping(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_2__pyx_unpickle_CodecsRegistry(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_4__pyx_unpickle_QueryCodecsCache(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_6__pyx_unpickle_SansIOProtocol(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_8EnumBase_14__Pyx_EnumMeta___init__(struct __pyx_obj___Pyx_EnumMeta *__pyx_v_cls, PyObject *__pyx_v_name, PyObject *__pyx_v_parents, PyObject *__pyx_v_dct); /* proto */
static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumMeta_2__iter__(struct __pyx_obj___Pyx_EnumMeta *__pyx_v_cls); /* proto */
static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumMeta_4__getitem__(struct __pyx_obj___Pyx_EnumMeta *__pyx_v_cls, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumMeta_6__reduce_cython__(struct __pyx_obj___Pyx_EnumMeta *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumMeta_8__setstate_cython__(struct __pyx_obj___Pyx_EnumMeta *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumBase___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_value, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumBase_2__repr__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumBase_4__str__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8EnumBase___pyx_unpickle___Pyx_EnumMeta(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_LRUMapping(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_BaseCodec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_CodecPythonOverride(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_BaseRecordCodec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_EmptyTupleCodec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_NullCodec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_BaseNamedRecordCodec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_EdegDBCodecContext(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_ScalarCodec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_TupleCodec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_NamedTupleCodec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_ObjectCodec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_BaseArrayCodec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_ArrayCodec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_SetCodec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_EnumCodec(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_CodecsRegistry(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_QueryCodecsCache(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_SansIOProtocol(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new___Pyx_EnumMeta(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_get = {0, &__pyx_n_s_get, 0, 0, 0};
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_11;
static PyObject *__pyx_int_12;
static PyObject *__pyx_int_13;
static PyObject *__pyx_int_40;
static PyObject *__pyx_int_200;
static PyObject *__pyx_int_1000;
static PyObject *__pyx_int_4097;
static PyObject *__pyx_int_10000;
static PyObject *__pyx_int_65281;
static PyObject *__pyx_int_65282;
static PyObject *__pyx_int_65283;
static PyObject *__pyx_int_65284;
static PyObject *__pyx_int_52716380;
static PyObject *__pyx_int_84082689;
static PyObject *__pyx_int_84082690;
static PyObject *__pyx_int_84082945;
static PyObject *__pyx_int_84082946;
static PyObject *__pyx_int_87255255;
static PyObject *__pyx_int_98205364;
static PyObject *__pyx_int_182233609;
static PyObject *__pyx_int_222419149;
static PyObject *__pyx_int_18446744073709551615;
static enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __pyx_k__66;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__7;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_slice__13;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_tuple__28;
static PyObject *__pyx_tuple__32;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__34;
static PyObject *__pyx_tuple__35;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__37;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__39;
static PyObject *__pyx_tuple__40;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__44;
static PyObject *__pyx_tuple__45;
static PyObject *__pyx_tuple__46;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__48;
static PyObject *__pyx_tuple__49;
static PyObject *__pyx_tuple__50;
static PyObject *__pyx_tuple__51;
static PyObject *__pyx_tuple__52;
static PyObject *__pyx_tuple__53;
static PyObject *__pyx_tuple__54;
static PyObject *__pyx_tuple__55;
static PyObject *__pyx_tuple__56;
static PyObject *__pyx_tuple__57;
static PyObject *__pyx_tuple__58;
static PyObject *__pyx_tuple__59;
static PyObject *__pyx_tuple__60;
static PyObject *__pyx_tuple__63;
static PyObject *__pyx_tuple__64;
static PyObject *__pyx_tuple__65;
static PyObject *__pyx_tuple__67;
static PyObject *__pyx_tuple__69;
static PyObject *__pyx_tuple__70;
static PyObject *__pyx_tuple__71;
static PyObject *__pyx_tuple__72;
static PyObject *__pyx_tuple__73;
static PyObject *__pyx_tuple__74;
static PyObject *__pyx_tuple__76;
static PyObject *__pyx_tuple__77;
static PyObject *__pyx_tuple__79;
static PyObject *__pyx_tuple__80;
static PyObject *__pyx_tuple__81;
static PyObject *__pyx_tuple__82;
static PyObject *__pyx_tuple__83;
static PyObject *__pyx_tuple__84;
static PyObject *__pyx_tuple__85;
static PyObject *__pyx_tuple__86;
static PyObject *__pyx_tuple__87;
static PyObject *__pyx_tuple__88;
static PyObject *__pyx_tuple__89;
static PyObject *__pyx_tuple__90;
static PyObject *__pyx_tuple__91;
static PyObject *__pyx_tuple__92;
static PyObject *__pyx_tuple__93;
static PyObject *__pyx_tuple__94;
static PyObject *__pyx_tuple__95;
static PyObject *__pyx_tuple__96;
static PyObject *__pyx_tuple__97;
static PyObject *__pyx_tuple__98;
static PyObject *__pyx_tuple__99;
static PyObject *__pyx_tuple__100;
static PyObject *__pyx_tuple__101;
static PyObject *__pyx_tuple__102;
static PyObject *__pyx_tuple__103;
static PyObject *__pyx_tuple__104;
static PyObject *__pyx_tuple__105;
static PyObject *__pyx_tuple__107;
static PyObject *__pyx_tuple__110;
static PyObject *__pyx_tuple__112;
static PyObject *__pyx_tuple__114;
static PyObject *__pyx_tuple__116;
static PyObject *__pyx_tuple__118;
static PyObject *__pyx_tuple__120;
static PyObject *__pyx_tuple__121;
static PyObject *__pyx_tuple__123;
static PyObject *__pyx_tuple__125;
static PyObject *__pyx_codeobj__111;
static PyObject *__pyx_codeobj__113;
static PyObject *__pyx_codeobj__115;
static PyObject *__pyx_codeobj__117;
static PyObject *__pyx_codeobj__119;
static PyObject *__pyx_codeobj__122;
static PyObject *__pyx_codeobj__124;
static PyObject *__pyx_codeobj__126;
/* Late includes */

/* "edgedb/protocol/lru.pyx":46
 *     # beginning of it.
 * 
 *     def __init__(self, *, maxsize):             # <<<<<<<<<<<<<<
 *         if maxsize <= 0:
 *             raise ValueError(
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_maxsize = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_maxsize,0};
    PyObject* values[1] = {0};
    if (likely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_maxsize)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s_maxsize); __PYX_ERR(0, 46, __pyx_L3_error)
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "__init__") < 0)) __PYX_ERR(0, 46, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
      goto __pyx_L5_argtuple_error;
    } else {
      __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s_maxsize); __PYX_ERR(0, 46, __pyx_L3_error)
    }
    __pyx_v_maxsize = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 46, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.LRUMapping.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping___init__(((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_v_self), __pyx_v_maxsize);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping___init__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self, PyObject *__pyx_v_maxsize) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "edgedb/protocol/lru.pyx":47
 * 
 *     def __init__(self, *, maxsize):
 *         if maxsize <= 0:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 f'maxsize is expected to be greater than 0, got {maxsize}')
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_maxsize, __pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 47, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/lru.pyx":49
 *         if maxsize <= 0:
 *             raise ValueError(
 *                 f'maxsize is expected to be greater than 0, got {maxsize}')             # <<<<<<<<<<<<<<
 * 
 *         self._dict = collections.OrderedDict()
 */
    __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_v_maxsize, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_maxsize_is_expected_to_be_greate, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/lru.pyx":48
 *     def __init__(self, *, maxsize):
 *         if maxsize <= 0:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 f'maxsize is expected to be greater than 0, got {maxsize}')
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 48, __pyx_L1_error)

    /* "edgedb/protocol/lru.pyx":47
 * 
 *     def __init__(self, *, maxsize):
 *         if maxsize <= 0:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 f'maxsize is expected to be greater than 0, got {maxsize}')
 */
  }

  /* "edgedb/protocol/lru.pyx":51
 *                 f'maxsize is expected to be greater than 0, got {maxsize}')
 * 
 *         self._dict = collections.OrderedDict()             # <<<<<<<<<<<<<<
 *         self._dict_move_to_end = self._dict.move_to_end
 *         self._dict_get = self._dict.get
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_collections); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_dict);
  __Pyx_DECREF(__pyx_v_self->_dict);
  __pyx_v_self->_dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/lru.pyx":52
 * 
 *         self._dict = collections.OrderedDict()
 *         self._dict_move_to_end = self._dict.move_to_end             # <<<<<<<<<<<<<<
 *         self._dict_get = self._dict.get
 *         self._maxsize = maxsize
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_dict, __pyx_n_s_move_to_end); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_dict_move_to_end);
  __Pyx_DECREF(__pyx_v_self->_dict_move_to_end);
  __pyx_v_self->_dict_move_to_end = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/lru.pyx":53
 *         self._dict = collections.OrderedDict()
 *         self._dict_move_to_end = self._dict.move_to_end
 *         self._dict_get = self._dict.get             # <<<<<<<<<<<<<<
 *         self._maxsize = maxsize
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_dict, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_dict_get);
  __Pyx_DECREF(__pyx_v_self->_dict_get);
  __pyx_v_self->_dict_get = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/lru.pyx":54
 *         self._dict_move_to_end = self._dict.move_to_end
 *         self._dict_get = self._dict.get
 *         self._maxsize = maxsize             # <<<<<<<<<<<<<<
 * 
 *     cdef get(self, key, default):
 */
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_maxsize); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 54, __pyx_L1_error)
  __pyx_v_self->_maxsize = __pyx_t_5;

  /* "edgedb/protocol/lru.pyx":46
 *     # beginning of it.
 * 
 *     def __init__(self, *, maxsize):             # <<<<<<<<<<<<<<
 *         if maxsize <= 0:
 *             raise ValueError(
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("edgedb.protocol.protocol.LRUMapping.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/lru.pyx":56
 *         self._maxsize = maxsize
 * 
 *     cdef get(self, key, default):             # <<<<<<<<<<<<<<
 *         o = self._dict_get(key, _LRU_MARKER)
 *         if o is _LRU_MARKER:
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_10LRUMapping_get(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  PyObject *__pyx_v_o = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get", 0);

  /* "edgedb/protocol/lru.pyx":57
 * 
 *     cdef get(self, key, default):
 *         o = self._dict_get(key, _LRU_MARKER)             # <<<<<<<<<<<<<<
 *         if o is _LRU_MARKER:
 *             return default
 */
  __Pyx_INCREF(__pyx_v_self->_dict_get);
  __pyx_t_2 = __pyx_v_self->_dict_get; __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_key, __pyx_v_6edgedb_8protocol_8protocol__LRU_MARKER};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_key, __pyx_v_6edgedb_8protocol_8protocol__LRU_MARKER};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 57, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_key);
    __Pyx_GIVEREF(__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_key);
    __Pyx_INCREF(__pyx_v_6edgedb_8protocol_8protocol__LRU_MARKER);
    __Pyx_GIVEREF(__pyx_v_6edgedb_8protocol_8protocol__LRU_MARKER);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_6edgedb_8protocol_8protocol__LRU_MARKER);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_o = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/lru.pyx":58
 *     cdef get(self, key, default):
 *         o = self._dict_get(key, _LRU_MARKER)
 *         if o is _LRU_MARKER:             # <<<<<<<<<<<<<<
 *             return default
 *         self._dict_move_to_end(key)  # last=True
 */
  __pyx_t_6 = (__pyx_v_o == __pyx_v_6edgedb_8protocol_8protocol__LRU_MARKER);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "edgedb/protocol/lru.pyx":59
 *         o = self._dict_get(key, _LRU_MARKER)
 *         if o is _LRU_MARKER:
 *             return default             # <<<<<<<<<<<<<<
 *         self._dict_move_to_end(key)  # last=True
 *         return o
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_default);
    __pyx_r = __pyx_v_default;
    goto __pyx_L0;

    /* "edgedb/protocol/lru.pyx":58
 *     cdef get(self, key, default):
 *         o = self._dict_get(key, _LRU_MARKER)
 *         if o is _LRU_MARKER:             # <<<<<<<<<<<<<<
 *             return default
 *         self._dict_move_to_end(key)  # last=True
 */
  }

  /* "edgedb/protocol/lru.pyx":60
 *         if o is _LRU_MARKER:
 *             return default
 *         self._dict_move_to_end(key)  # last=True             # <<<<<<<<<<<<<<
 *         return o
 * 
 */
  __Pyx_INCREF(__pyx_v_self->_dict_move_to_end);
  __pyx_t_2 = __pyx_v_self->_dict_move_to_end; __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_v_key) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_key);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/lru.pyx":61
 *             return default
 *         self._dict_move_to_end(key)  # last=True
 *         return o             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, key):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_o);
  __pyx_r = __pyx_v_o;
  goto __pyx_L0;

  /* "edgedb/protocol/lru.pyx":56
 *         self._maxsize = maxsize
 * 
 *     cdef get(self, key, default):             # <<<<<<<<<<<<<<
 *         o = self._dict_get(key, _LRU_MARKER)
 *         if o is _LRU_MARKER:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("edgedb.protocol.protocol.LRUMapping.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_o);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/lru.pyx":63
 *         return o
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         o = self._dict[key]
 *         self._dict_move_to_end(key)  # last=True
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_2__getitem__(((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_v_self), ((PyObject *)__pyx_v_key));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_2__getitem__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_v_o = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "edgedb/protocol/lru.pyx":64
 * 
 *     def __getitem__(self, key):
 *         o = self._dict[key]             # <<<<<<<<<<<<<<
 *         self._dict_move_to_end(key)  # last=True
 *         return o
 */
  __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_self->_dict, __pyx_v_key); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_o = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/lru.pyx":65
 *     def __getitem__(self, key):
 *         o = self._dict[key]
 *         self._dict_move_to_end(key)  # last=True             # <<<<<<<<<<<<<<
 *         return o
 * 
 */
  __Pyx_INCREF(__pyx_v_self->_dict_move_to_end);
  __pyx_t_2 = __pyx_v_self->_dict_move_to_end; __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_key) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_key);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/lru.pyx":66
 *         o = self._dict[key]
 *         self._dict_move_to_end(key)  # last=True
 *         return o             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, key, o):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_o);
  __pyx_r = __pyx_v_o;
  goto __pyx_L0;

  /* "edgedb/protocol/lru.pyx":63
 *         return o
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         o = self._dict[key]
 *         self._dict_move_to_end(key)  # last=True
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.LRUMapping.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_o);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/lru.pyx":68
 *         return o
 * 
 *     def __setitem__(self, key, o):             # <<<<<<<<<<<<<<
 *         if key in self._dict:
 *             self._dict[key] = o
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_5__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_o); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_5__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_4__setitem__(((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_v_self), ((PyObject *)__pyx_v_key), ((PyObject *)__pyx_v_o));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_4__setitem__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setitem__", 0);

  /* "edgedb/protocol/lru.pyx":69
 * 
 *     def __setitem__(self, key, o):
 *         if key in self._dict:             # <<<<<<<<<<<<<<
 *             self._dict[key] = o
 *             self._dict_move_to_end(key)  # last=True
 */
  __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_key, __pyx_v_self->_dict, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 69, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "edgedb/protocol/lru.pyx":70
 *     def __setitem__(self, key, o):
 *         if key in self._dict:
 *             self._dict[key] = o             # <<<<<<<<<<<<<<
 *             self._dict_move_to_end(key)  # last=True
 *         else:
 */
    if (unlikely(PyObject_SetItem(__pyx_v_self->_dict, __pyx_v_key, __pyx_v_o) < 0)) __PYX_ERR(0, 70, __pyx_L1_error)

    /* "edgedb/protocol/lru.pyx":71
 *         if key in self._dict:
 *             self._dict[key] = o
 *             self._dict_move_to_end(key)  # last=True             # <<<<<<<<<<<<<<
 *         else:
 *             self._dict[key] = o
 */
    __Pyx_INCREF(__pyx_v_self->_dict_move_to_end);
    __pyx_t_4 = __pyx_v_self->_dict_move_to_end; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_key) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_key);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "edgedb/protocol/lru.pyx":69
 * 
 *     def __setitem__(self, key, o):
 *         if key in self._dict:             # <<<<<<<<<<<<<<
 *             self._dict[key] = o
 *             self._dict_move_to_end(key)  # last=True
 */
    goto __pyx_L3;
  }

  /* "edgedb/protocol/lru.pyx":73
 *             self._dict_move_to_end(key)  # last=True
 *         else:
 *             self._dict[key] = o             # <<<<<<<<<<<<<<
 *             if len(self._dict) > self._maxsize:
 *                 self._dict.popitem(last=False)
 */
  /*else*/ {
    if (unlikely(PyObject_SetItem(__pyx_v_self->_dict, __pyx_v_key, __pyx_v_o) < 0)) __PYX_ERR(0, 73, __pyx_L1_error)

    /* "edgedb/protocol/lru.pyx":74
 *         else:
 *             self._dict[key] = o
 *             if len(self._dict) > self._maxsize:             # <<<<<<<<<<<<<<
 *                 self._dict.popitem(last=False)
 * 
 */
    __pyx_t_3 = __pyx_v_self->_dict;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_6 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 74, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = ((__pyx_t_6 > __pyx_v_self->_maxsize) != 0);
    if (__pyx_t_2) {

      /* "edgedb/protocol/lru.pyx":75
 *             self._dict[key] = o
 *             if len(self._dict) > self._maxsize:
 *                 self._dict.popitem(last=False)             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self, key):
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_dict, __pyx_n_s_popitem); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 75, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 75, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_last, Py_False) < 0) __PYX_ERR(0, 75, __pyx_L1_error)
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 75, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "edgedb/protocol/lru.pyx":74
 *         else:
 *             self._dict[key] = o
 *             if len(self._dict) > self._maxsize:             # <<<<<<<<<<<<<<
 *                 self._dict.popitem(last=False)
 * 
 */
    }
  }
  __pyx_L3:;

  /* "edgedb/protocol/lru.pyx":68
 *         return o
 * 
 *     def __setitem__(self, key, o):             # <<<<<<<<<<<<<<
 *         if key in self._dict:
 *             self._dict[key] = o
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("edgedb.protocol.protocol.LRUMapping.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/lru.pyx":77
 *                 self._dict.popitem(last=False)
 * 
 *     def __delitem__(self, key):             # <<<<<<<<<<<<<<
 *         del self._dict[key]
 * 
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_7__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_7__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__delitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_6__delitem__(((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_v_self), ((PyObject *)__pyx_v_key));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_6__delitem__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__delitem__", 0);

  /* "edgedb/protocol/lru.pyx":78
 * 
 *     def __delitem__(self, key):
 *         del self._dict[key]             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, key):
 */
  if (unlikely(PyObject_DelItem(__pyx_v_self->_dict, __pyx_v_key) < 0)) __PYX_ERR(0, 78, __pyx_L1_error)

  /* "edgedb/protocol/lru.pyx":77
 *                 self._dict.popitem(last=False)
 * 
 *     def __delitem__(self, key):             # <<<<<<<<<<<<<<
 *         del self._dict[key]
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.LRUMapping.__delitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/lru.pyx":80
 *         del self._dict[key]
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         return key in self._dict
 * 
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_9__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_9__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_8__contains__(((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_v_self), ((PyObject *)__pyx_v_key));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_8__contains__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__contains__", 0);

  /* "edgedb/protocol/lru.pyx":81
 * 
 *     def __contains__(self, key):
 *         return key in self._dict             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_key, __pyx_v_self->_dict, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 81, __pyx_L1_error)
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "edgedb/protocol/lru.pyx":80
 *         del self._dict[key]
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         return key in self._dict
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.LRUMapping.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/lru.pyx":83
 *         return key in self._dict
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return len(self._dict)
 * 
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_11__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_11__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_10__len__(((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_10__len__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "edgedb/protocol/lru.pyx":84
 * 
 *     def __len__(self):
 *         return len(self._dict)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_t_1 = __pyx_v_self->_dict;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 84, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  /* "edgedb/protocol/lru.pyx":83
 *         return key in self._dict
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return len(self._dict)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.LRUMapping.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/lru.pyx":86
 *         return len(self._dict)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return iter(self._dict)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_13__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_13__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_12__iter__(((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_12__iter__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "edgedb/protocol/lru.pyx":87
 * 
 *     def __iter__(self):
 *         return iter(self._dict)             # <<<<<<<<<<<<<<
 * 
 *     def clear(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_v_self->_dict;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/lru.pyx":86
 *         return len(self._dict)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return iter(self._dict)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("edgedb.protocol.protocol.LRUMapping.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/lru.pyx":89
 *         return iter(self._dict)
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self._dict.clear()
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_15clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_15clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_14clear(((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_14clear(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("clear", 0);

  /* "edgedb/protocol/lru.pyx":90
 * 
 *     def clear(self):
 *         self._dict.clear()             # <<<<<<<<<<<<<<
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_dict, __pyx_n_s_clear); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/lru.pyx":89
 *         return iter(self._dict)
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self._dict.clear()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.LRUMapping.clear", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_17__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_17__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_16__reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_16__reduce_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self._dict, self._dict_get, self._dict_move_to_end, self._maxsize)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_maxsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->_dict);
  __Pyx_GIVEREF(__pyx_v_self->_dict);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->_dict);
  __Pyx_INCREF(__pyx_v_self->_dict_get);
  __Pyx_GIVEREF(__pyx_v_self->_dict_get);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->_dict_get);
  __Pyx_INCREF(__pyx_v_self->_dict_move_to_end);
  __Pyx_GIVEREF(__pyx_v_self->_dict_move_to_end);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_self->_dict_move_to_end);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self._dict, self._dict_get, self._dict_move_to_end, self._maxsize)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__dict = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "(tree fragment)":7
 *     state = (self._dict, self._dict_get, self._dict_move_to_end, self._maxsize)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_3 = (__pyx_v__dict != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._dict is not None or self._dict_get is not None or self._dict_move_to_end is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self._dict, self._dict_get, self._dict_move_to_end, self._maxsize)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self._dict is not None or self._dict_get is not None or self._dict_move_to_end is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_LRUMapping, (type(self), 0x53368d7, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->_dict != Py_None);
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->_dict_get != Py_None);
    __pyx_t_3 = (__pyx_t_5 != 0);
    if (!__pyx_t_3) {
    } else {
      __pyx_t_4 = __pyx_t_3;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_3 = (__pyx_v_self->_dict_move_to_end != Py_None);
    __pyx_t_5 = (__pyx_t_3 != 0);
    __pyx_t_4 = __pyx_t_5;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_4;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._dict is not None or self._dict_get is not None or self._dict_move_to_end is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_LRUMapping, (type(self), 0x53368d7, None), state
 *     else:
 */
  __pyx_t_4 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":13
 *         use_setstate = self._dict is not None or self._dict_get is not None or self._dict_move_to_end is not None
 *     if use_setstate:
 *         return __pyx_unpickle_LRUMapping, (type(self), 0x53368d7, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_LRUMapping, (type(self), 0x53368d7, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle_LRUMapping); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_87255255);
    __Pyx_GIVEREF(__pyx_int_87255255);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_87255255);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._dict is not None or self._dict_get is not None or self._dict_move_to_end is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_LRUMapping, (type(self), 0x53368d7, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_LRUMapping, (type(self), 0x53368d7, None), state
 *     else:
 *         return __pyx_unpickle_LRUMapping, (type(self), 0x53368d7, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_LRUMapping__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_LRUMapping); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_87255255);
    __Pyx_GIVEREF(__pyx_int_87255255);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_87255255);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_6 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("edgedb.protocol.protocol.LRUMapping.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_LRUMapping, (type(self), 0x53368d7, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_LRUMapping__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_19__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_19__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_18__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10LRUMapping_18__setstate_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_LRUMapping, (type(self), 0x53368d7, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_LRUMapping__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_LRUMapping__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_LRUMapping, (type(self), 0x53368d7, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_LRUMapping__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.LRUMapping.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":35
 * cdef class BaseCodec:
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         raise RuntimeError(
 *             'codecs are not supposed to be instantiated directly')
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_9BaseCodec___init__(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_9BaseCodec___init__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "edgedb/protocol/codecs/base.pyx":36
 * 
 *     def __init__(self):
 *         raise RuntimeError(             # <<<<<<<<<<<<<<
 *             'codecs are not supposed to be instantiated directly')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(1, 36, __pyx_L1_error)

  /* "edgedb/protocol/codecs/base.pyx":35
 * cdef class BaseCodec:
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         raise RuntimeError(
 *             'codecs are not supposed to be instantiated directly')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseCodec.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":39
 *             'codecs are not supposed to be instantiated directly')
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.tid = None
 *         self.name = None
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_3__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_3__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_9BaseCodec_2__cinit__(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_9BaseCodec_2__cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "edgedb/protocol/codecs/base.pyx":40
 * 
 *     def __cinit__(self):
 *         self.tid = None             # <<<<<<<<<<<<<<
 *         self.name = None
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->tid);
  __Pyx_DECREF(__pyx_v_self->tid);
  __pyx_v_self->tid = ((PyObject*)Py_None);

  /* "edgedb/protocol/codecs/base.pyx":41
 *     def __cinit__(self):
 *         self.tid = None
 *         self.name = None             # <<<<<<<<<<<<<<
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(__pyx_v_self->name);
  __pyx_v_self->name = ((PyObject*)Py_None);

  /* "edgedb/protocol/codecs/base.pyx":39
 *             'codecs are not supposed to be instantiated directly')
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.tid = None
 *         self.name = None
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":43
 *         self.name = None
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_9BaseCodec_encode(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self, CYTHON_UNUSED struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, CYTHON_UNUSED PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("encode", 0);

  /* "edgedb/protocol/codecs/base.pyx":44
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef decode(self, FRBuffer *buf):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
  __PYX_ERR(1, 44, __pyx_L1_error)

  /* "edgedb/protocol/codecs/base.pyx":43
 *         self.name = None
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseCodec.encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":46
 *         raise NotImplementedError
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_9BaseCodec_decode(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self, CYTHON_UNUSED struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("decode", 0);

  /* "edgedb/protocol/codecs/base.pyx":47
 * 
 *     cdef decode(self, FRBuffer *buf):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef dump(self, int level = 0):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
  __PYX_ERR(1, 47, __pyx_L1_error)

  /* "edgedb/protocol/codecs/base.pyx":46
 *         raise NotImplementedError
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseCodec.decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":49
 *         raise NotImplementedError
 * 
 *     cdef dump(self, int level = 0):             # <<<<<<<<<<<<<<
 *         return f'{level * " "}{self.name}'
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_9BaseCodec_dump(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self, struct __pyx_opt_args_6edgedb_8protocol_8protocol_9BaseCodec_dump *__pyx_optional_args) {
  int __pyx_v_level = ((int)0);
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dump", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_level = __pyx_optional_args->level;
    }
  }

  /* "edgedb/protocol/codecs/base.pyx":50
 * 
 *     cdef dump(self, int level = 0):
 *         return f'{level * " "}{self.name}'             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_level); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Multiply(__pyx_t_1, __pyx_kp_u__2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyUnicode_Unicode(__pyx_v_self->name); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/base.pyx":49
 *         raise NotImplementedError
 * 
 *     cdef dump(self, int level = 0):             # <<<<<<<<<<<<<<
 *         return f'{level * " "}{self.name}'
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseCodec.dump", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_9BaseCodec_4__reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_9BaseCodec_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseCodec.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_9BaseCodec_6__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_9BaseCodec_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseCodec.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":55
 * cdef class CodecPythonOverride(BaseCodec):
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.codec = None
 *         self.encoder = None
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_19CodecPythonOverride_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_19CodecPythonOverride_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_19CodecPythonOverride___cinit__(((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_19CodecPythonOverride___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "edgedb/protocol/codecs/base.pyx":56
 * 
 *     def __cinit__(self):
 *         self.codec = None             # <<<<<<<<<<<<<<
 *         self.encoder = None
 *         self.decoder = None
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->codec);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->codec));
  __pyx_v_self->codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)Py_None);

  /* "edgedb/protocol/codecs/base.pyx":57
 *     def __cinit__(self):
 *         self.codec = None
 *         self.encoder = None             # <<<<<<<<<<<<<<
 *         self.decoder = None
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->encoder);
  __Pyx_DECREF(__pyx_v_self->encoder);
  __pyx_v_self->encoder = Py_None;

  /* "edgedb/protocol/codecs/base.pyx":58
 *         self.codec = None
 *         self.encoder = None
 *         self.decoder = None             # <<<<<<<<<<<<<<
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->decoder);
  __Pyx_DECREF(__pyx_v_self->decoder);
  __pyx_v_self->decoder = Py_None;

  /* "edgedb/protocol/codecs/base.pyx":55
 * cdef class CodecPythonOverride(BaseCodec):
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.codec = None
 *         self.encoder = None
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":60
 *         self.decoder = None
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         self.codec.encode(buf, self.encoder(obj))
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_19CodecPythonOverride_encode(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("encode", 0);

  /* "edgedb/protocol/codecs/base.pyx":61
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):
 *         self.codec.encode(buf, self.encoder(obj))             # <<<<<<<<<<<<<<
 * 
 *     cdef decode(self, FRBuffer *buf):
 */
  __Pyx_INCREF(__pyx_v_self->encoder);
  __pyx_t_2 = __pyx_v_self->encoder; __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_obj) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_obj);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_self->codec->__pyx_vtab)->encode(__pyx_v_self->codec, __pyx_v_buf, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/base.pyx":60
 *         self.decoder = None
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         self.codec.encode(buf, self.encoder(obj))
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecPythonOverride.encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":63
 *         self.codec.encode(buf, self.encoder(obj))
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         return self.decoder(self.codec.decode(buf))
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_19CodecPythonOverride_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("decode", 0);

  /* "edgedb/protocol/codecs/base.pyx":64
 * 
 *     cdef decode(self, FRBuffer *buf):
 *         return self.decoder(self.codec.decode(buf))             # <<<<<<<<<<<<<<
 * 
 *     cdef dump(self, int level = 0):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_self->codec->__pyx_vtab)->decode(__pyx_v_self->codec, __pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 64, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->decoder);
  __pyx_t_3 = __pyx_v_self->decoder; __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 64, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/base.pyx":63
 *         self.codec.encode(buf, self.encoder(obj))
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         return self.decoder(self.codec.decode(buf))
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecPythonOverride.decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":66
 *         return self.decoder(self.codec.decode(buf))
 * 
 *     cdef dump(self, int level = 0):             # <<<<<<<<<<<<<<
 *         return f'{level * " "}<Python override>{self.name}'
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_19CodecPythonOverride_dump(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *__pyx_v_self, struct __pyx_opt_args_6edgedb_8protocol_8protocol_19CodecPythonOverride_dump *__pyx_optional_args) {
  int __pyx_v_level = ((int)0);
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_UCS4 __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dump", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_level = __pyx_optional_args->level;
    }
  }

  /* "edgedb/protocol/codecs/base.pyx":67
 * 
 *     cdef dump(self, int level = 0):
 *         return f'{level * " "}<Python override>{self.name}'             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = 0;
  __pyx_t_3 = 127;
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_level); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_4, __pyx_kp_u__2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_t_5, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3;
  __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_kp_u_Python_override);
  __pyx_t_2 += 17;
  __Pyx_GIVEREF(__pyx_kp_u_Python_override);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u_Python_override);
  __pyx_t_4 = __Pyx_PyUnicode_Unicode(__pyx_v_self->__pyx_base.name); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3;
  __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/base.pyx":66
 *         return self.decoder(self.codec.decode(buf))
 * 
 *     cdef dump(self, int level = 0):             # <<<<<<<<<<<<<<
 *         return f'{level * " "}<Python override>{self.name}'
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecPythonOverride.dump", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":70
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid,             # <<<<<<<<<<<<<<
 *                        BaseCodec basecodec,
 *                        object encoder,
 */

static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_19CodecPythonOverride_new(PyObject *__pyx_v_tid, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_basecodec, PyObject *__pyx_v_encoder, PyObject *__pyx_v_decoder) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *__pyx_v_codec = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("new", 0);

  /* "edgedb/protocol/codecs/base.pyx":78
 *             CodecPythonOverride codec
 * 
 *         codec = CodecPythonOverride.__new__(CodecPythonOverride)             # <<<<<<<<<<<<<<
 *         codec.tid = tid
 *         codec.name = basecodec.name
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_6edgedb_8protocol_8protocol_CodecPythonOverride(((PyTypeObject *)__pyx_ptype_6edgedb_8protocol_8protocol_CodecPythonOverride), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 78, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/base.pyx":79
 * 
 *         codec = CodecPythonOverride.__new__(CodecPythonOverride)
 *         codec.tid = tid             # <<<<<<<<<<<<<<
 *         codec.name = basecodec.name
 *         codec.codec = basecodec
 */
  __Pyx_INCREF(__pyx_v_tid);
  __Pyx_GIVEREF(__pyx_v_tid);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.tid);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.tid);
  __pyx_v_codec->__pyx_base.tid = __pyx_v_tid;

  /* "edgedb/protocol/codecs/base.pyx":80
 *         codec = CodecPythonOverride.__new__(CodecPythonOverride)
 *         codec.tid = tid
 *         codec.name = basecodec.name             # <<<<<<<<<<<<<<
 *         codec.codec = basecodec
 *         codec.encoder = encoder
 */
  __pyx_t_1 = __pyx_v_basecodec->name;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.name);
  __pyx_v_codec->__pyx_base.name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/base.pyx":81
 *         codec.tid = tid
 *         codec.name = basecodec.name
 *         codec.codec = basecodec             # <<<<<<<<<<<<<<
 *         codec.encoder = encoder
 *         codec.decoder = decoder
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_basecodec));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_basecodec));
  __Pyx_GOTREF(__pyx_v_codec->codec);
  __Pyx_DECREF(((PyObject *)__pyx_v_codec->codec));
  __pyx_v_codec->codec = __pyx_v_basecodec;

  /* "edgedb/protocol/codecs/base.pyx":82
 *         codec.name = basecodec.name
 *         codec.codec = basecodec
 *         codec.encoder = encoder             # <<<<<<<<<<<<<<
 *         codec.decoder = decoder
 *         return codec
 */
  __Pyx_INCREF(__pyx_v_encoder);
  __Pyx_GIVEREF(__pyx_v_encoder);
  __Pyx_GOTREF(__pyx_v_codec->encoder);
  __Pyx_DECREF(__pyx_v_codec->encoder);
  __pyx_v_codec->encoder = __pyx_v_encoder;

  /* "edgedb/protocol/codecs/base.pyx":83
 *         codec.codec = basecodec
 *         codec.encoder = encoder
 *         codec.decoder = decoder             # <<<<<<<<<<<<<<
 *         return codec
 * 
 */
  __Pyx_INCREF(__pyx_v_decoder);
  __Pyx_GIVEREF(__pyx_v_decoder);
  __Pyx_GOTREF(__pyx_v_codec->decoder);
  __Pyx_DECREF(__pyx_v_codec->decoder);
  __pyx_v_codec->decoder = __pyx_v_decoder;

  /* "edgedb/protocol/codecs/base.pyx":84
 *         codec.encoder = encoder
 *         codec.decoder = decoder
 *         return codec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_codec));
  __pyx_r = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_codec);
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/base.pyx":70
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid,             # <<<<<<<<<<<<<<
 *                        BaseCodec basecodec,
 *                        object encoder,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecPythonOverride.new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_19CodecPythonOverride_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_19CodecPythonOverride_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_19CodecPythonOverride_2__reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_19CodecPythonOverride_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecPythonOverride.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_19CodecPythonOverride_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_19CodecPythonOverride_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_19CodecPythonOverride_4__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_19CodecPythonOverride_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecPythonOverride.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":89
 * cdef class EmptyTupleCodec(BaseCodec):
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.tid = EMPTY_TUPLE_CODEC_ID
 *         self.name = 'no-input'
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_15EmptyTupleCodec_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_15EmptyTupleCodec_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_15EmptyTupleCodec___cinit__(((struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_15EmptyTupleCodec___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "edgedb/protocol/codecs/base.pyx":90
 * 
 *     def __cinit__(self):
 *         self.tid = EMPTY_TUPLE_CODEC_ID             # <<<<<<<<<<<<<<
 *         self.name = 'no-input'
 *         self.empty_tup = None
 */
  __Pyx_INCREF(__pyx_v_6edgedb_8protocol_8protocol_EMPTY_TUPLE_CODEC_ID);
  __Pyx_GIVEREF(__pyx_v_6edgedb_8protocol_8protocol_EMPTY_TUPLE_CODEC_ID);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.tid);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.tid);
  __pyx_v_self->__pyx_base.tid = __pyx_v_6edgedb_8protocol_8protocol_EMPTY_TUPLE_CODEC_ID;

  /* "edgedb/protocol/codecs/base.pyx":91
 *     def __cinit__(self):
 *         self.tid = EMPTY_TUPLE_CODEC_ID
 *         self.name = 'no-input'             # <<<<<<<<<<<<<<
 *         self.empty_tup = None
 * 
 */
  __Pyx_INCREF(__pyx_kp_u_no_input);
  __Pyx_GIVEREF(__pyx_kp_u_no_input);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.name);
  __pyx_v_self->__pyx_base.name = __pyx_kp_u_no_input;

  /* "edgedb/protocol/codecs/base.pyx":92
 *         self.tid = EMPTY_TUPLE_CODEC_ID
 *         self.name = 'no-input'
 *         self.empty_tup = None             # <<<<<<<<<<<<<<
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->empty_tup);
  __Pyx_DECREF(__pyx_v_self->empty_tup);
  __pyx_v_self->empty_tup = Py_None;

  /* "edgedb/protocol/codecs/base.pyx":89
 * cdef class EmptyTupleCodec(BaseCodec):
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.tid = EMPTY_TUPLE_CODEC_ID
 *         self.name = 'no-input'
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":94
 *         self.empty_tup = None
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         if type(obj) is not tuple:
 *             raise RuntimeError(
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_15EmptyTupleCodec_encode(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("encode", 0);

  /* "edgedb/protocol/codecs/base.pyx":95
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):
 *         if type(obj) is not tuple:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'cannot encode empty Tuple: expected a tuple, '
 */
  __pyx_t_1 = (((PyObject *)Py_TYPE(__pyx_v_obj)) != ((PyObject *)(&PyTuple_Type)));
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/codecs/base.pyx":98
 *             raise RuntimeError(
 *                 f'cannot encode empty Tuple: expected a tuple, '
 *                 f'got {type(obj).__name__}')             # <<<<<<<<<<<<<<
 *         if len(obj) != 0:
 *             raise RuntimeError(
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_obj)), __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 98, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 98, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "edgedb/protocol/codecs/base.pyx":97
 *         if type(obj) is not tuple:
 *             raise RuntimeError(
 *                 f'cannot encode empty Tuple: expected a tuple, '             # <<<<<<<<<<<<<<
 *                 f'got {type(obj).__name__}')
 *         if len(obj) != 0:
 */
    __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_cannot_encode_empty_Tuple_expect, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 97, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "edgedb/protocol/codecs/base.pyx":96
 *     cdef encode(self, WriteBuffer buf, object obj):
 *         if type(obj) is not tuple:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 f'cannot encode empty Tuple: expected a tuple, '
 *                 f'got {type(obj).__name__}')
 */
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 96, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(1, 96, __pyx_L1_error)

    /* "edgedb/protocol/codecs/base.pyx":95
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):
 *         if type(obj) is not tuple:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'cannot encode empty Tuple: expected a tuple, '
 */
  }

  /* "edgedb/protocol/codecs/base.pyx":99
 *                 f'cannot encode empty Tuple: expected a tuple, '
 *                 f'got {type(obj).__name__}')
 *         if len(obj) != 0:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'cannot encode empty Tuple: expected 0 elements, '
 */
  __pyx_t_5 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 99, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_5 != 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/codecs/base.pyx":102
 *             raise RuntimeError(
 *                 f'cannot encode empty Tuple: expected 0 elements, '
 *                 f'got {len(obj)}')             # <<<<<<<<<<<<<<
 *         buf.write_bytes(EMPTY_RECORD_DATA)
 * 
 */
    __pyx_t_5 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 102, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_5, 0, ' ', 'd'); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 102, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "edgedb/protocol/codecs/base.pyx":101
 *         if len(obj) != 0:
 *             raise RuntimeError(
 *                 f'cannot encode empty Tuple: expected 0 elements, '             # <<<<<<<<<<<<<<
 *                 f'got {len(obj)}')
 *         buf.write_bytes(EMPTY_RECORD_DATA)
 */
    __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_cannot_encode_empty_Tuple_expect_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 101, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "edgedb/protocol/codecs/base.pyx":100
 *                 f'got {type(obj).__name__}')
 *         if len(obj) != 0:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 f'cannot encode empty Tuple: expected 0 elements, '
 *                 f'got {len(obj)}')
 */
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 100, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(1, 100, __pyx_L1_error)

    /* "edgedb/protocol/codecs/base.pyx":99
 *                 f'cannot encode empty Tuple: expected a tuple, '
 *                 f'got {type(obj).__name__}')
 *         if len(obj) != 0:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'cannot encode empty Tuple: expected 0 elements, '
 */
  }

  /* "edgedb/protocol/codecs/base.pyx":103
 *                 f'cannot encode empty Tuple: expected 0 elements, '
 *                 f'got {len(obj)}')
 *         buf.write_bytes(EMPTY_RECORD_DATA)             # <<<<<<<<<<<<<<
 * 
 *     cdef decode(self, FRBuffer *buf):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_EMPTY_RECORD_DATA); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 103, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(1, 103, __pyx_L1_error)
  __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_bytes(__pyx_v_buf, ((PyObject*)__pyx_t_4)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 103, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "edgedb/protocol/codecs/base.pyx":94
 *         self.empty_tup = None
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         if type(obj) is not tuple:
 *             raise RuntimeError(
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("edgedb.protocol.protocol.EmptyTupleCodec.encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":105
 *         buf.write_bytes(EMPTY_RECORD_DATA)
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 *         if elem_count != 0:
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_15EmptyTupleCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  Py_ssize_t __pyx_v_elem_count;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("decode", 0);

  /* "edgedb/protocol/codecs/base.pyx":106
 * 
 *     cdef decode(self, FRBuffer *buf):
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 *         if elem_count != 0:
 *             raise RuntimeError(
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(1, 106, __pyx_L1_error)
  __pyx_v_elem_count = ((Py_ssize_t)((uint32_t)unpack_int32(__pyx_t_1)));

  /* "edgedb/protocol/codecs/base.pyx":107
 *     cdef decode(self, FRBuffer *buf):
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 *         if elem_count != 0:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'cannot decode empty Tuple: expected 0 elements, '
 */
  __pyx_t_2 = ((__pyx_v_elem_count != 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/codecs/base.pyx":110
 *             raise RuntimeError(
 *                 f'cannot decode empty Tuple: expected 0 elements, '
 *                 f'got {elem_count}')             # <<<<<<<<<<<<<<
 * 
 *         if self.empty_tup is None:
 */
    __pyx_t_3 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_v_elem_count, 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "edgedb/protocol/codecs/base.pyx":109
 *         if elem_count != 0:
 *             raise RuntimeError(
 *                 f'cannot decode empty Tuple: expected 0 elements, '             # <<<<<<<<<<<<<<
 *                 f'got {elem_count}')
 * 
 */
    __pyx_t_4 = __Pyx_PyUnicode_Concat(__pyx_kp_u_cannot_decode_empty_Tuple_expect, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 109, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "edgedb/protocol/codecs/base.pyx":108
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 *         if elem_count != 0:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 f'cannot decode empty Tuple: expected 0 elements, '
 *                 f'got {elem_count}')
 */
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 108, __pyx_L1_error)

    /* "edgedb/protocol/codecs/base.pyx":107
 *     cdef decode(self, FRBuffer *buf):
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 *         if elem_count != 0:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'cannot decode empty Tuple: expected 0 elements, '
 */
  }

  /* "edgedb/protocol/codecs/base.pyx":112
 *                 f'got {elem_count}')
 * 
 *         if self.empty_tup is None:             # <<<<<<<<<<<<<<
 *             self.empty_tup = datatypes.tuple_new(0)
 *         return self.empty_tup
 */
  __pyx_t_2 = (__pyx_v_self->empty_tup == Py_None);
  __pyx_t_5 = (__pyx_t_2 != 0);
  if (__pyx_t_5) {

    /* "edgedb/protocol/codecs/base.pyx":113
 * 
 *         if self.empty_tup is None:
 *             self.empty_tup = datatypes.tuple_new(0)             # <<<<<<<<<<<<<<
 *         return self.empty_tup
 * 
 */
    __pyx_t_3 = __pyx_f_6edgedb_9datatypes_9datatypes_tuple_new(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->empty_tup);
    __Pyx_DECREF(__pyx_v_self->empty_tup);
    __pyx_v_self->empty_tup = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "edgedb/protocol/codecs/base.pyx":112
 *                 f'got {elem_count}')
 * 
 *         if self.empty_tup is None:             # <<<<<<<<<<<<<<
 *             self.empty_tup = datatypes.tuple_new(0)
 *         return self.empty_tup
 */
  }

  /* "edgedb/protocol/codecs/base.pyx":114
 *         if self.empty_tup is None:
 *             self.empty_tup = datatypes.tuple_new(0)
 *         return self.empty_tup             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->empty_tup);
  __pyx_r = __pyx_v_self->empty_tup;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/base.pyx":105
 *         buf.write_bytes(EMPTY_RECORD_DATA)
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 *         if elem_count != 0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("edgedb.protocol.protocol.EmptyTupleCodec.decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_15EmptyTupleCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_15EmptyTupleCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_15EmptyTupleCodec_2__reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_15EmptyTupleCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.EmptyTupleCodec.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_15EmptyTupleCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_15EmptyTupleCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_15EmptyTupleCodec_4__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_15EmptyTupleCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.EmptyTupleCodec.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":119
 * cdef class NullCodec(BaseCodec):
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.tid = NULL_CODEC_ID
 *         self.name = 'null-codec'
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_9NullCodec_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_9NullCodec_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_9NullCodec___cinit__(((struct __pyx_obj_6edgedb_8protocol_8protocol_NullCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_9NullCodec___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_NullCodec *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "edgedb/protocol/codecs/base.pyx":120
 * 
 *     def __cinit__(self):
 *         self.tid = NULL_CODEC_ID             # <<<<<<<<<<<<<<
 *         self.name = 'null-codec'
 * 
 */
  __Pyx_INCREF(__pyx_v_6edgedb_8protocol_8protocol_NULL_CODEC_ID);
  __Pyx_GIVEREF(__pyx_v_6edgedb_8protocol_8protocol_NULL_CODEC_ID);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.tid);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.tid);
  __pyx_v_self->__pyx_base.tid = __pyx_v_6edgedb_8protocol_8protocol_NULL_CODEC_ID;

  /* "edgedb/protocol/codecs/base.pyx":121
 *     def __cinit__(self):
 *         self.tid = NULL_CODEC_ID
 *         self.name = 'null-codec'             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_INCREF(__pyx_kp_u_null_codec);
  __Pyx_GIVEREF(__pyx_kp_u_null_codec);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.name);
  __pyx_v_self->__pyx_base.name = __pyx_kp_u_null_codec;

  /* "edgedb/protocol/codecs/base.pyx":119
 * cdef class NullCodec(BaseCodec):
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.tid = NULL_CODEC_ID
 *         self.name = 'null-codec'
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_9NullCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_9NullCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_9NullCodec_2__reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_NullCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_9NullCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_NullCodec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.NullCodec.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_9NullCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_9NullCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_9NullCodec_4__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_NullCodec *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_9NullCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_NullCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.NullCodec.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":126
 * cdef class BaseRecordCodec(BaseCodec):
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.fields_codecs = ()
 *         self.encoder_flags = 0
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_15BaseRecordCodec_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_15BaseRecordCodec_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_15BaseRecordCodec___cinit__(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_15BaseRecordCodec___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "edgedb/protocol/codecs/base.pyx":127
 * 
 *     def __cinit__(self):
 *         self.fields_codecs = ()             # <<<<<<<<<<<<<<
 *         self.encoder_flags = 0
 * 
 */
  __Pyx_INCREF(__pyx_empty_tuple);
  __Pyx_GIVEREF(__pyx_empty_tuple);
  __Pyx_GOTREF(__pyx_v_self->fields_codecs);
  __Pyx_DECREF(__pyx_v_self->fields_codecs);
  __pyx_v_self->fields_codecs = __pyx_empty_tuple;

  /* "edgedb/protocol/codecs/base.pyx":128
 *     def __cinit__(self):
 *         self.fields_codecs = ()
 *         self.encoder_flags = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef _check_encoder(self):
 */
  __pyx_v_self->encoder_flags = 0;

  /* "edgedb/protocol/codecs/base.pyx":126
 * cdef class BaseRecordCodec(BaseCodec):
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.fields_codecs = ()
 *         self.encoder_flags = 0
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":130
 *         self.encoder_flags = 0
 * 
 *     cdef _check_encoder(self):             # <<<<<<<<<<<<<<
 *         if not (self.encoder_flags & RECORD_ENCODER_CHECKED):
 *             for codec in self.fields_codecs:
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_15BaseRecordCodec__check_encoder(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *__pyx_v_self) {
  PyObject *__pyx_v_codec = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_check_encoder", 0);

  /* "edgedb/protocol/codecs/base.pyx":131
 * 
 *     cdef _check_encoder(self):
 *         if not (self.encoder_flags & RECORD_ENCODER_CHECKED):             # <<<<<<<<<<<<<<
 *             for codec in self.fields_codecs:
 *                 if not isinstance(codec, (ScalarCodec, ArrayCodec, EnumCodec)):
 */
  __pyx_t_1 = ((!((__pyx_v_self->encoder_flags & __pyx_v_6edgedb_8protocol_8protocol_RECORD_ENCODER_CHECKED) != 0)) != 0);
  if (__pyx_t_1) {

    /* "edgedb/protocol/codecs/base.pyx":132
 *     cdef _check_encoder(self):
 *         if not (self.encoder_flags & RECORD_ENCODER_CHECKED):
 *             for codec in self.fields_codecs:             # <<<<<<<<<<<<<<
 *                 if not isinstance(codec, (ScalarCodec, ArrayCodec, EnumCodec)):
 *                     self.encoder_flags |= RECORD_ENCODER_INVALID
 */
    if (unlikely(__pyx_v_self->fields_codecs == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 132, __pyx_L1_error)
    }
    __pyx_t_2 = __pyx_v_self->fields_codecs; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    for (;;) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 132, __pyx_L1_error)
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 132, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_codec, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "edgedb/protocol/codecs/base.pyx":133
 *         if not (self.encoder_flags & RECORD_ENCODER_CHECKED):
 *             for codec in self.fields_codecs:
 *                 if not isinstance(codec, (ScalarCodec, ArrayCodec, EnumCodec)):             # <<<<<<<<<<<<<<
 *                     self.encoder_flags |= RECORD_ENCODER_INVALID
 *                     break
 */
      __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_codec, __pyx_ptype_6edgedb_8protocol_8protocol_ScalarCodec); 
      __pyx_t_6 = (__pyx_t_5 != 0);
      if (!__pyx_t_6) {
      } else {
        __pyx_t_1 = __pyx_t_6;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_6 = __Pyx_TypeCheck(__pyx_v_codec, __pyx_ptype_6edgedb_8protocol_8protocol_ArrayCodec); 
      __pyx_t_5 = (__pyx_t_6 != 0);
      if (!__pyx_t_5) {
      } else {
        __pyx_t_1 = __pyx_t_5;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_codec, __pyx_ptype_6edgedb_8protocol_8protocol_EnumCodec); 
      __pyx_t_6 = (__pyx_t_5 != 0);
      __pyx_t_1 = __pyx_t_6;
      __pyx_L7_bool_binop_done:;
      __pyx_t_6 = ((!(__pyx_t_1 != 0)) != 0);
      if (__pyx_t_6) {

        /* "edgedb/protocol/codecs/base.pyx":134
 *             for codec in self.fields_codecs:
 *                 if not isinstance(codec, (ScalarCodec, ArrayCodec, EnumCodec)):
 *                     self.encoder_flags |= RECORD_ENCODER_INVALID             # <<<<<<<<<<<<<<
 *                     break
 *             self.encoder_flags |= RECORD_ENCODER_CHECKED
 */
        __pyx_v_self->encoder_flags = (__pyx_v_self->encoder_flags | __pyx_v_6edgedb_8protocol_8protocol_RECORD_ENCODER_INVALID);

        /* "edgedb/protocol/codecs/base.pyx":135
 *                 if not isinstance(codec, (ScalarCodec, ArrayCodec, EnumCodec)):
 *                     self.encoder_flags |= RECORD_ENCODER_INVALID
 *                     break             # <<<<<<<<<<<<<<
 *             self.encoder_flags |= RECORD_ENCODER_CHECKED
 * 
 */
        goto __pyx_L5_break;

        /* "edgedb/protocol/codecs/base.pyx":133
 *         if not (self.encoder_flags & RECORD_ENCODER_CHECKED):
 *             for codec in self.fields_codecs:
 *                 if not isinstance(codec, (ScalarCodec, ArrayCodec, EnumCodec)):             # <<<<<<<<<<<<<<
 *                     self.encoder_flags |= RECORD_ENCODER_INVALID
 *                     break
 */
      }

      /* "edgedb/protocol/codecs/base.pyx":132
 *     cdef _check_encoder(self):
 *         if not (self.encoder_flags & RECORD_ENCODER_CHECKED):
 *             for codec in self.fields_codecs:             # <<<<<<<<<<<<<<
 *                 if not isinstance(codec, (ScalarCodec, ArrayCodec, EnumCodec)):
 *                     self.encoder_flags |= RECORD_ENCODER_INVALID
 */
    }
    __pyx_L5_break:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "edgedb/protocol/codecs/base.pyx":136
 *                     self.encoder_flags |= RECORD_ENCODER_INVALID
 *                     break
 *             self.encoder_flags |= RECORD_ENCODER_CHECKED             # <<<<<<<<<<<<<<
 * 
 *         if self.encoder_flags & RECORD_ENCODER_INVALID:
 */
    __pyx_v_self->encoder_flags = (__pyx_v_self->encoder_flags | __pyx_v_6edgedb_8protocol_8protocol_RECORD_ENCODER_CHECKED);

    /* "edgedb/protocol/codecs/base.pyx":131
 * 
 *     cdef _check_encoder(self):
 *         if not (self.encoder_flags & RECORD_ENCODER_CHECKED):             # <<<<<<<<<<<<<<
 *             for codec in self.fields_codecs:
 *                 if not isinstance(codec, (ScalarCodec, ArrayCodec, EnumCodec)):
 */
  }

  /* "edgedb/protocol/codecs/base.pyx":138
 *             self.encoder_flags |= RECORD_ENCODER_CHECKED
 * 
 *         if self.encoder_flags & RECORD_ENCODER_INVALID:             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'argument tuples only support scalars and arrays of scalars')
 */
  __pyx_t_6 = ((__pyx_v_self->encoder_flags & __pyx_v_6edgedb_8protocol_8protocol_RECORD_ENCODER_INVALID) != 0);
  if (unlikely(__pyx_t_6)) {

    /* "edgedb/protocol/codecs/base.pyx":139
 * 
 *         if self.encoder_flags & RECORD_ENCODER_INVALID:
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'argument tuples only support scalars and arrays of scalars')
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 139, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(1, 139, __pyx_L1_error)

    /* "edgedb/protocol/codecs/base.pyx":138
 *             self.encoder_flags |= RECORD_ENCODER_CHECKED
 * 
 *         if self.encoder_flags & RECORD_ENCODER_INVALID:             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'argument tuples only support scalars and arrays of scalars')
 */
  }

  /* "edgedb/protocol/codecs/base.pyx":130
 *         self.encoder_flags = 0
 * 
 *     cdef _check_encoder(self):             # <<<<<<<<<<<<<<
 *         if not (self.encoder_flags & RECORD_ENCODER_CHECKED):
 *             for codec in self.fields_codecs:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseRecordCodec._check_encoder", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_codec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":142
 *                 'argument tuples only support scalars and arrays of scalars')
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer elem_data
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_15BaseRecordCodec_encode(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_elem_data = 0;
  Py_ssize_t __pyx_v_objlen;
  Py_ssize_t __pyx_v_i;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_sub_codec = 0;
  PyObject *__pyx_v_item = NULL;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_v_value_repr = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  Py_UCS4 __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  Py_ssize_t __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  int __pyx_t_20;
  char const *__pyx_t_21;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  PyObject *__pyx_t_27 = NULL;
  int32_t __pyx_t_28;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("encode", 0);

  /* "edgedb/protocol/codecs/base.pyx":149
 *             BaseCodec sub_codec
 * 
 *         self._check_encoder()             # <<<<<<<<<<<<<<
 * 
 *         if not _is_array_iterable(obj):
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseRecordCodec *)__pyx_v_self->__pyx_base.__pyx_vtab)->_check_encoder(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/base.pyx":151
 *         self._check_encoder()
 * 
 *         if not _is_array_iterable(obj):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'a sized iterable container expected (got type {!r})'.format(
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol__is_array_iterable(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 151, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "edgedb/protocol/codecs/base.pyx":153
 *         if not _is_array_iterable(obj):
 *             raise TypeError(
 *                 'a sized iterable container expected (got type {!r})'.format(             # <<<<<<<<<<<<<<
 *                     type(obj).__name__))
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_a_sized_iterable_container_expec, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "edgedb/protocol/codecs/base.pyx":154
 *             raise TypeError(
 *                 'a sized iterable container expected (got type {!r})'.format(
 *                     type(obj).__name__))             # <<<<<<<<<<<<<<
 * 
 *         objlen = len(obj)
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_obj)), __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "edgedb/protocol/codecs/base.pyx":152
 * 
 *         if not _is_array_iterable(obj):
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'a sized iterable container expected (got type {!r})'.format(
 *                     type(obj).__name__))
 */
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 152, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(1, 152, __pyx_L1_error)

    /* "edgedb/protocol/codecs/base.pyx":151
 *         self._check_encoder()
 * 
 *         if not _is_array_iterable(obj):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'a sized iterable container expected (got type {!r})'.format(
 */
  }

  /* "edgedb/protocol/codecs/base.pyx":156
 *                     type(obj).__name__))
 * 
 *         objlen = len(obj)             # <<<<<<<<<<<<<<
 *         if objlen == 0:
 *             buf.write_bytes(EMPTY_RECORD_DATA)
 */
  __pyx_t_7 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(1, 156, __pyx_L1_error)
  __pyx_v_objlen = __pyx_t_7;

  /* "edgedb/protocol/codecs/base.pyx":157
 * 
 *         objlen = len(obj)
 *         if objlen == 0:             # <<<<<<<<<<<<<<
 *             buf.write_bytes(EMPTY_RECORD_DATA)
 *             return
 */
  __pyx_t_3 = ((__pyx_v_objlen == 0) != 0);
  if (__pyx_t_3) {

    /* "edgedb/protocol/codecs/base.pyx":158
 *         objlen = len(obj)
 *         if objlen == 0:
 *             buf.write_bytes(EMPTY_RECORD_DATA)             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_EMPTY_RECORD_DATA); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 158, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(1, 158, __pyx_L1_error)
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_bytes(__pyx_v_buf, ((PyObject*)__pyx_t_4)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 158, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/base.pyx":159
 *         if objlen == 0:
 *             buf.write_bytes(EMPTY_RECORD_DATA)
 *             return             # <<<<<<<<<<<<<<
 * 
 *         if objlen > _MAXINT32:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "edgedb/protocol/codecs/base.pyx":157
 * 
 *         objlen = len(obj)
 *         if objlen == 0:             # <<<<<<<<<<<<<<
 *             buf.write_bytes(EMPTY_RECORD_DATA)
 *             return
 */
  }

  /* "edgedb/protocol/codecs/base.pyx":161
 *             return
 * 
 *         if objlen > _MAXINT32:             # <<<<<<<<<<<<<<
 *             raise ValueError('too many elements for a tuple')
 * 
 */
  __pyx_t_3 = ((__pyx_v_objlen > 0x7FFFFFFF) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "edgedb/protocol/codecs/base.pyx":162
 * 
 *         if objlen > _MAXINT32:
 *             raise ValueError('too many elements for a tuple')             # <<<<<<<<<<<<<<
 * 
 *         if objlen != len(self.fields_codecs):
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 162, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(1, 162, __pyx_L1_error)

    /* "edgedb/protocol/codecs/base.pyx":161
 *             return
 * 
 *         if objlen > _MAXINT32:             # <<<<<<<<<<<<<<
 *             raise ValueError('too many elements for a tuple')
 * 
 */
  }

  /* "edgedb/protocol/codecs/base.pyx":164
 *             raise ValueError('too many elements for a tuple')
 * 
 *         if objlen != len(self.fields_codecs):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 f'expected {len(self.fields_codecs)} elements in the tuple, '
 */
  __pyx_t_1 = __pyx_v_self->fields_codecs;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 164, __pyx_L1_error)
  }
  __pyx_t_7 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(1, 164, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((__pyx_v_objlen != __pyx_t_7) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "edgedb/protocol/codecs/base.pyx":166
 *         if objlen != len(self.fields_codecs):
 *             raise ValueError(
 *                 f'expected {len(self.fields_codecs)} elements in the tuple, '             # <<<<<<<<<<<<<<
 *                 f'got {objlen}')
 * 
 */
    __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 166, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = 0;
    __pyx_t_8 = 127;
    __Pyx_INCREF(__pyx_kp_u_expected);
    __pyx_t_7 += 9;
    __Pyx_GIVEREF(__pyx_kp_u_expected);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_expected);
    __pyx_t_4 = __pyx_v_self->fields_codecs;
    __Pyx_INCREF(__pyx_t_4);
    if (unlikely(__pyx_t_4 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(1, 166, __pyx_L1_error)
    }
    __pyx_t_9 = PyTuple_GET_SIZE(__pyx_t_4); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(1, 166, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_9, 0, ' ', 'd'); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 166, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_INCREF(__pyx_kp_u_elements_in_the_tuple_got);
    __pyx_t_7 += 28;
    __Pyx_GIVEREF(__pyx_kp_u_elements_in_the_tuple_got);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_elements_in_the_tuple_got);

    /* "edgedb/protocol/codecs/base.pyx":167
 *             raise ValueError(
 *                 f'expected {len(self.fields_codecs)} elements in the tuple, '
 *                 f'got {objlen}')             # <<<<<<<<<<<<<<
 * 
 *         elem_data = WriteBuffer.new()
 */
    __pyx_t_4 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_v_objlen, 0, ' ', 'd'); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 167, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "edgedb/protocol/codecs/base.pyx":166
 *         if objlen != len(self.fields_codecs):
 *             raise ValueError(
 *                 f'expected {len(self.fields_codecs)} elements in the tuple, '             # <<<<<<<<<<<<<<
 *                 f'got {objlen}')
 * 
 */
    __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_1, 4, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 166, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/base.pyx":165
 * 
 *         if objlen != len(self.fields_codecs):
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 f'expected {len(self.fields_codecs)} elements in the tuple, '
 *                 f'got {objlen}')
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 165, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(1, 165, __pyx_L1_error)

    /* "edgedb/protocol/codecs/base.pyx":164
 *             raise ValueError('too many elements for a tuple')
 * 
 *         if objlen != len(self.fields_codecs):             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 f'expected {len(self.fields_codecs)} elements in the tuple, '
 */
  }

  /* "edgedb/protocol/codecs/base.pyx":169
 *                 f'got {objlen}')
 * 
 *         elem_data = WriteBuffer.new()             # <<<<<<<<<<<<<<
 *         for i in range(objlen):
 *             item = obj[i]
 */
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_elem_data = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/base.pyx":170
 * 
 *         elem_data = WriteBuffer.new()
 *         for i in range(objlen):             # <<<<<<<<<<<<<<
 *             item = obj[i]
 *             elem_data.write_int32(0)  # reserved bytes
 */
  __pyx_t_7 = __pyx_v_objlen;
  __pyx_t_9 = __pyx_t_7;
  for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
    __pyx_v_i = __pyx_t_10;

    /* "edgedb/protocol/codecs/base.pyx":171
 *         elem_data = WriteBuffer.new()
 *         for i in range(objlen):
 *             item = obj[i]             # <<<<<<<<<<<<<<
 *             elem_data.write_int32(0)  # reserved bytes
 *             if item is None:
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_obj, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 171, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/base.pyx":172
 *         for i in range(objlen):
 *             item = obj[i]
 *             elem_data.write_int32(0)  # reserved bytes             # <<<<<<<<<<<<<<
 *             if item is None:
 *                 elem_data.write_int32(-1)
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_elem_data->__pyx_vtab)->write_int32(__pyx_v_elem_data, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/base.pyx":173
 *             item = obj[i]
 *             elem_data.write_int32(0)  # reserved bytes
 *             if item is None:             # <<<<<<<<<<<<<<
 *                 elem_data.write_int32(-1)
 *             else:
 */
    __pyx_t_3 = (__pyx_v_item == Py_None);
    __pyx_t_2 = (__pyx_t_3 != 0);
    if (__pyx_t_2) {

      /* "edgedb/protocol/codecs/base.pyx":174
 *             elem_data.write_int32(0)  # reserved bytes
 *             if item is None:
 *                 elem_data.write_int32(-1)             # <<<<<<<<<<<<<<
 *             else:
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])
 */
      __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_elem_data->__pyx_vtab)->write_int32(__pyx_v_elem_data, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "edgedb/protocol/codecs/base.pyx":173
 *             item = obj[i]
 *             elem_data.write_int32(0)  # reserved bytes
 *             if item is None:             # <<<<<<<<<<<<<<
 *                 elem_data.write_int32(-1)
 *             else:
 */
      goto __pyx_L9;
    }

    /* "edgedb/protocol/codecs/base.pyx":176
 *                 elem_data.write_int32(-1)
 *             else:
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])             # <<<<<<<<<<<<<<
 *                 try:
 *                     sub_codec.encode(elem_data, item)
 */
    /*else*/ {
      if (unlikely(__pyx_v_self->fields_codecs == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(1, 176, __pyx_L1_error)
      }
      __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_self->fields_codecs, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 176, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1;
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF_SET(__pyx_v_sub_codec, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "edgedb/protocol/codecs/base.pyx":177
 *             else:
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])
 *                 try:             # <<<<<<<<<<<<<<
 *                     sub_codec.encode(elem_data, item)
 *                 except (TypeError, ValueError) as e:
 */
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        __Pyx_XGOTREF(__pyx_t_11);
        __Pyx_XGOTREF(__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_13);
        /*try:*/ {

          /* "edgedb/protocol/codecs/base.pyx":178
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])
 *                 try:
 *                     sub_codec.encode(elem_data, item)             # <<<<<<<<<<<<<<
 *                 except (TypeError, ValueError) as e:
 *                     value_repr = repr(item)
 */
          __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_sub_codec->__pyx_vtab)->encode(__pyx_v_sub_codec, __pyx_v_elem_data, __pyx_v_item); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 178, __pyx_L10_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "edgedb/protocol/codecs/base.pyx":177
 *             else:
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])
 *                 try:             # <<<<<<<<<<<<<<
 *                     sub_codec.encode(elem_data, item)
 *                 except (TypeError, ValueError) as e:
 */
        }
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L17_try_end;
        __pyx_L10_error:;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "edgedb/protocol/codecs/base.pyx":179
 *                 try:
 *                     sub_codec.encode(elem_data, item)
 *                 except (TypeError, ValueError) as e:             # <<<<<<<<<<<<<<
 *                     value_repr = repr(item)
 *                     if len(value_repr) > 40:
 */
        __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
        if (__pyx_t_14) {
          __Pyx_AddTraceback("edgedb.protocol.protocol.BaseRecordCodec.encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_1, &__pyx_t_5) < 0) __PYX_ERR(1, 179, __pyx_L12_except_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_1);
          __pyx_v_e = __pyx_t_1;
          /*try:*/ {

            /* "edgedb/protocol/codecs/base.pyx":180
 *                     sub_codec.encode(elem_data, item)
 *                 except (TypeError, ValueError) as e:
 *                     value_repr = repr(item)             # <<<<<<<<<<<<<<
 *                     if len(value_repr) > 40:
 *                         value_repr = value_repr[:40] + '...'
 */
            __pyx_t_6 = PyObject_Repr(__pyx_v_item); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 180, __pyx_L23_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_v_value_repr = __pyx_t_6;
            __pyx_t_6 = 0;

            /* "edgedb/protocol/codecs/base.pyx":181
 *                 except (TypeError, ValueError) as e:
 *                     value_repr = repr(item)
 *                     if len(value_repr) > 40:             # <<<<<<<<<<<<<<
 *                         value_repr = value_repr[:40] + '...'
 *                     raise errors.InvalidArgumentError(
 */
            __pyx_t_15 = PyObject_Length(__pyx_v_value_repr); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(1, 181, __pyx_L23_error)
            __pyx_t_2 = ((__pyx_t_15 > 40) != 0);
            if (__pyx_t_2) {

              /* "edgedb/protocol/codecs/base.pyx":182
 *                     value_repr = repr(item)
 *                     if len(value_repr) > 40:
 *                         value_repr = value_repr[:40] + '...'             # <<<<<<<<<<<<<<
 *                     raise errors.InvalidArgumentError(
 *                         'invalid input for query argument'
 */
              __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_v_value_repr, 0, 40, NULL, NULL, &__pyx_slice__13, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 182, __pyx_L23_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_16 = PyNumber_Add(__pyx_t_6, __pyx_kp_u__14); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 182, __pyx_L23_error)
              __Pyx_GOTREF(__pyx_t_16);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF_SET(__pyx_v_value_repr, __pyx_t_16);
              __pyx_t_16 = 0;

              /* "edgedb/protocol/codecs/base.pyx":181
 *                 except (TypeError, ValueError) as e:
 *                     value_repr = repr(item)
 *                     if len(value_repr) > 40:             # <<<<<<<<<<<<<<
 *                         value_repr = value_repr[:40] + '...'
 *                     raise errors.InvalidArgumentError(
 */
            }

            /* "edgedb/protocol/codecs/base.pyx":183
 *                     if len(value_repr) > 40:
 *                         value_repr = value_repr[:40] + '...'
 *                     raise errors.InvalidArgumentError(             # <<<<<<<<<<<<<<
 *                         'invalid input for query argument'
 *                         ' ${n}: {v} ({msg})'.format(
 */
            __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_errors); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 183, __pyx_L23_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_InvalidArgumentError); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 183, __pyx_L23_error)
            __Pyx_GOTREF(__pyx_t_17);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

            /* "edgedb/protocol/codecs/base.pyx":185
 *                     raise errors.InvalidArgumentError(
 *                         'invalid input for query argument'
 *                         ' ${n}: {v} ({msg})'.format(             # <<<<<<<<<<<<<<
 *                             n=i, v=value_repr, msg=e)) from e
 * 
 */
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_invalid_input_for_query_argument, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 185, __pyx_L23_error)
            __Pyx_GOTREF(__pyx_t_6);

            /* "edgedb/protocol/codecs/base.pyx":186
 *                         'invalid input for query argument'
 *                         ' ${n}: {v} ({msg})'.format(
 *                             n=i, v=value_repr, msg=e)) from e             # <<<<<<<<<<<<<<
 * 
 *         buf.write_int32(4 + elem_data.len())  # buffer length
 */
            __pyx_t_18 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 186, __pyx_L23_error)
            __Pyx_GOTREF(__pyx_t_18);
            __pyx_t_19 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 186, __pyx_L23_error)
            __Pyx_GOTREF(__pyx_t_19);
            if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_n, __pyx_t_19) < 0) __PYX_ERR(1, 186, __pyx_L23_error)
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_v, __pyx_v_value_repr) < 0) __PYX_ERR(1, 186, __pyx_L23_error)
            if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_msg, __pyx_v_e) < 0) __PYX_ERR(1, 186, __pyx_L23_error)

            /* "edgedb/protocol/codecs/base.pyx":185
 *                     raise errors.InvalidArgumentError(
 *                         'invalid input for query argument'
 *                         ' ${n}: {v} ({msg})'.format(             # <<<<<<<<<<<<<<
 *                             n=i, v=value_repr, msg=e)) from e
 * 
 */
            __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, __pyx_t_18); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 185, __pyx_L23_error)
            __Pyx_GOTREF(__pyx_t_19);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            __pyx_t_18 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_17))) {
              __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_17);
              if (likely(__pyx_t_18)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
                __Pyx_INCREF(__pyx_t_18);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_17, function);
              }
            }
            __pyx_t_16 = (__pyx_t_18) ? __Pyx_PyObject_Call2Args(__pyx_t_17, __pyx_t_18, __pyx_t_19) : __Pyx_PyObject_CallOneArg(__pyx_t_17, __pyx_t_19);
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 183, __pyx_L23_error)
            __Pyx_GOTREF(__pyx_t_16);
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

            /* "edgedb/protocol/codecs/base.pyx":186
 *                         'invalid input for query argument'
 *                         ' ${n}: {v} ({msg})'.format(
 *                             n=i, v=value_repr, msg=e)) from e             # <<<<<<<<<<<<<<
 * 
 *         buf.write_int32(4 + elem_data.len())  # buffer length
 */
            __Pyx_Raise(__pyx_t_16, 0, 0, __pyx_v_e);
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            __PYX_ERR(1, 183, __pyx_L23_error)
          }

          /* "edgedb/protocol/codecs/base.pyx":179
 *                 try:
 *                     sub_codec.encode(elem_data, item)
 *                 except (TypeError, ValueError) as e:             # <<<<<<<<<<<<<<
 *                     value_repr = repr(item)
 *                     if len(value_repr) > 40:
 */
          /*finally:*/ {
            __pyx_L23_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_declare
              __Pyx_PyThreadState_assign
              __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0;
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27);
              if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24) < 0)) __Pyx_ErrFetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
              __Pyx_XGOTREF(__pyx_t_22);
              __Pyx_XGOTREF(__pyx_t_23);
              __Pyx_XGOTREF(__pyx_t_24);
              __Pyx_XGOTREF(__pyx_t_25);
              __Pyx_XGOTREF(__pyx_t_26);
              __Pyx_XGOTREF(__pyx_t_27);
              __pyx_t_14 = __pyx_lineno; __pyx_t_20 = __pyx_clineno; __pyx_t_21 = __pyx_filename;
              {
                __Pyx_DECREF(__pyx_v_e);
                __pyx_v_e = NULL;
              }
              if (PY_MAJOR_VERSION >= 3) {
                __Pyx_XGIVEREF(__pyx_t_25);
                __Pyx_XGIVEREF(__pyx_t_26);
                __Pyx_XGIVEREF(__pyx_t_27);
                __Pyx_ExceptionReset(__pyx_t_25, __pyx_t_26, __pyx_t_27);
              }
              __Pyx_XGIVEREF(__pyx_t_22);
              __Pyx_XGIVEREF(__pyx_t_23);
              __Pyx_XGIVEREF(__pyx_t_24);
              __Pyx_ErrRestore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
              __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0;
              __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_20; __pyx_filename = __pyx_t_21;
              goto __pyx_L12_except_error;
            }
          }
        }
        goto __pyx_L12_except_error;
        __pyx_L12_except_error:;

        /* "edgedb/protocol/codecs/base.pyx":177
 *             else:
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])
 *                 try:             # <<<<<<<<<<<<<<
 *                     sub_codec.encode(elem_data, item)
 *                 except (TypeError, ValueError) as e:
 */
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
        goto __pyx_L1_error;
        __pyx_L17_try_end:;
      }
    }
    __pyx_L9:;
  }

  /* "edgedb/protocol/codecs/base.pyx":188
 *                             n=i, v=value_repr, msg=e)) from e
 * 
 *         buf.write_int32(4 + elem_data.len())  # buffer length             # <<<<<<<<<<<<<<
 *         buf.write_int32(<int32_t><uint32_t>objlen)
 *         buf.write_buffer(elem_data)
 */
  __pyx_t_5 = __pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_len(__pyx_v_elem_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_PyInt_AddCObj(__pyx_int_4, __pyx_t_5, 4, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_28 = __Pyx_PyInt_As_int32_t(__pyx_t_1); if (unlikely((__pyx_t_28 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(1, 188, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, __pyx_t_28); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/base.pyx":189
 * 
 *         buf.write_int32(4 + elem_data.len())  # buffer length
 *         buf.write_int32(<int32_t><uint32_t>objlen)             # <<<<<<<<<<<<<<
 *         buf.write_buffer(elem_data)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, ((int32_t)((uint32_t)__pyx_v_objlen))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/base.pyx":190
 *         buf.write_int32(4 + elem_data.len())  # buffer length
 *         buf.write_int32(<int32_t><uint32_t>objlen)
 *         buf.write_buffer(elem_data)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_buffer(__pyx_v_buf, __pyx_v_elem_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/base.pyx":142
 *                 'argument tuples only support scalars and arrays of scalars')
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer elem_data
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseRecordCodec.encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_elem_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_sub_codec);
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XDECREF(__pyx_v_value_repr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_15BaseRecordCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_15BaseRecordCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_15BaseRecordCodec_2__reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_15BaseRecordCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseRecordCodec.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_15BaseRecordCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_15BaseRecordCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_15BaseRecordCodec_4__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_15BaseRecordCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseRecordCodec.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":195
 * cdef class BaseNamedRecordCodec(BaseRecordCodec):
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.descriptor = None
 * 
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec___cinit__(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "edgedb/protocol/codecs/base.pyx":196
 * 
 *     def __cinit__(self):
 *         self.descriptor = None             # <<<<<<<<<<<<<<
 * 
 *     cdef dump(self, int level = 0):
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->descriptor);
  __Pyx_DECREF(__pyx_v_self->descriptor);
  __pyx_v_self->descriptor = Py_None;

  /* "edgedb/protocol/codecs/base.pyx":195
 * cdef class BaseNamedRecordCodec(BaseRecordCodec):
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.descriptor = None
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":198
 *         self.descriptor = None
 * 
 *     cdef dump(self, int level = 0):             # <<<<<<<<<<<<<<
 *         buf = [f'{level * " "}{self.name}']
 *         for pos, codec in enumerate(self.fields_codecs):
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_dump(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *__pyx_v_self, struct __pyx_opt_args_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_dump *__pyx_optional_args) {
  int __pyx_v_level = ((int)0);
  PyObject *__pyx_v_buf = NULL;
  PyObject *__pyx_v_pos = NULL;
  PyObject *__pyx_v_codec = NULL;
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  struct __pyx_opt_args_6edgedb_8protocol_8protocol_9BaseCodec_dump __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dump", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_level = __pyx_optional_args->level;
    }
  }

  /* "edgedb/protocol/codecs/base.pyx":199
 * 
 *     cdef dump(self, int level = 0):
 *         buf = [f'{level * " "}{self.name}']             # <<<<<<<<<<<<<<
 *         for pos, codec in enumerate(self.fields_codecs):
 *             name = datatypes.record_desc_pointer_name(self.descriptor, pos)
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_level); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Multiply(__pyx_t_1, __pyx_kp_u__2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyUnicode_Unicode(__pyx_v_self->__pyx_base.__pyx_base.name); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_buf = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/base.pyx":200
 *     cdef dump(self, int level = 0):
 *         buf = [f'{level * " "}{self.name}']
 *         for pos, codec in enumerate(self.fields_codecs):             # <<<<<<<<<<<<<<
 *             name = datatypes.record_desc_pointer_name(self.descriptor, pos)
 *             buf.append('{}{} := {}'.format(
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_2 = __pyx_int_0;
  __pyx_t_3 = __pyx_v_self->__pyx_base.fields_codecs; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 200, __pyx_L1_error)
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 200, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_codec, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_pos, __pyx_t_2);
    __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 200, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2);
    __pyx_t_2 = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/base.pyx":201
 *         buf = [f'{level * " "}{self.name}']
 *         for pos, codec in enumerate(self.fields_codecs):
 *             name = datatypes.record_desc_pointer_name(self.descriptor, pos)             # <<<<<<<<<<<<<<
 *             buf.append('{}{} := {}'.format(
 *                 (level + 1) * " ",
 */
    __pyx_t_1 = __pyx_v_self->descriptor;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_pos); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 201, __pyx_L1_error)
    __pyx_t_6 = __pyx_f_6edgedb_9datatypes_9datatypes_record_desc_pointer_name(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 201, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "edgedb/protocol/codecs/base.pyx":202
 *         for pos, codec in enumerate(self.fields_codecs):
 *             name = datatypes.record_desc_pointer_name(self.descriptor, pos)
 *             buf.append('{}{} := {}'.format(             # <<<<<<<<<<<<<<
 *                 (level + 1) * " ",
 *                 name,
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__17, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 202, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "edgedb/protocol/codecs/base.pyx":203
 *             name = datatypes.record_desc_pointer_name(self.descriptor, pos)
 *             buf.append('{}{} := {}'.format(
 *                 (level + 1) * " ",             # <<<<<<<<<<<<<<
 *                 name,
 *                 (<BaseCodec>codec).dump(level + 1).strip()))
 */
    __pyx_t_7 = __Pyx_PyInt_From_long((__pyx_v_level + 1)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 203, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyNumber_Multiply(__pyx_t_7, __pyx_kp_u__2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 203, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "edgedb/protocol/codecs/base.pyx":205
 *                 (level + 1) * " ",
 *                 name,
 *                 (<BaseCodec>codec).dump(level + 1).strip()))             # <<<<<<<<<<<<<<
 *         return '\n'.join(buf)
 * 
 */
    __pyx_t_10.__pyx_n = 1;
    __pyx_t_10.level = (__pyx_v_level + 1);
    __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_codec)->__pyx_vtab)->dump(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_codec), &__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 205, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_strip); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 205, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
      }
    }
    __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_9) : __Pyx_PyObject_CallNoArg(__pyx_t_11);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 205, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = NULL;
    __pyx_t_12 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_12 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_t_8, __pyx_v_name, __pyx_t_7};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 202, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_t_8, __pyx_v_name, __pyx_t_7};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 202, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 202, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_11) {
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_11); __pyx_t_11 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_12, __pyx_t_8);
      __Pyx_INCREF(__pyx_v_name);
      __Pyx_GIVEREF(__pyx_v_name);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_12, __pyx_v_name);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_12, __pyx_t_7);
      __pyx_t_8 = 0;
      __pyx_t_7 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 202, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/base.pyx":202
 *         for pos, codec in enumerate(self.fields_codecs):
 *             name = datatypes.record_desc_pointer_name(self.descriptor, pos)
 *             buf.append('{}{} := {}'.format(             # <<<<<<<<<<<<<<
 *                 (level + 1) * " ",
 *                 name,
 */
    __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_buf, __pyx_t_6); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(1, 202, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "edgedb/protocol/codecs/base.pyx":200
 *     cdef dump(self, int level = 0):
 *         buf = [f'{level * " "}{self.name}']
 *         for pos, codec in enumerate(self.fields_codecs):             # <<<<<<<<<<<<<<
 *             name = datatypes.record_desc_pointer_name(self.descriptor, pos)
 *             buf.append('{}{} := {}'.format(
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/base.pyx":206
 *                 name,
 *                 (<BaseCodec>codec).dump(level + 1).strip()))
 *         return '\n'.join(buf)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyUnicode_Join(__pyx_kp_u__18, __pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/base.pyx":198
 *         self.descriptor = None
 * 
 *     cdef dump(self, int level = 0):             # <<<<<<<<<<<<<<
 *         buf = [f'{level * " "}{self.name}']
 *         for pos, codec in enumerate(self.fields_codecs):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseNamedRecordCodec.dump", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_buf);
  __Pyx_XDECREF(__pyx_v_pos);
  __Pyx_XDECREF(__pyx_v_codec);
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_2__reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseNamedRecordCodec.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_4__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseNamedRecordCodec.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":212
 * cdef class EdegDBCodecContext(pgproto.CodecContext):
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self._codec = codecs.lookup('utf-8')
 * 
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_18EdegDBCodecContext_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_18EdegDBCodecContext_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_18EdegDBCodecContext___cinit__(((struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_18EdegDBCodecContext___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "edgedb/protocol/codecs/base.pyx":213
 * 
 *     def __cinit__(self):
 *         self._codec = codecs.lookup('utf-8')             # <<<<<<<<<<<<<<
 * 
 *     cpdef get_text_codec(self):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_codecs); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lookup); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_kp_u_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_utf_8);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_codec);
  __Pyx_DECREF(__pyx_v_self->_codec);
  __pyx_v_self->_codec = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/base.pyx":212
 * cdef class EdegDBCodecContext(pgproto.CodecContext):
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self._codec = codecs.lookup('utf-8')
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.EdegDBCodecContext.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":215
 *         self._codec = codecs.lookup('utf-8')
 * 
 *     cpdef get_text_codec(self):             # <<<<<<<<<<<<<<
 *         return self._codec
 * 
 */

static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_18EdegDBCodecContext_3get_text_codec(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_18EdegDBCodecContext_get_text_codec(struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_text_codec", 0);

  /* "edgedb/protocol/codecs/base.pyx":216
 * 
 *     cpdef get_text_codec(self):
 *         return self._codec             # <<<<<<<<<<<<<<
 * 
 *     cdef is_encoding_utf8(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_codec);
  __pyx_r = __pyx_v_self->_codec;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/base.pyx":215
 *         self._codec = codecs.lookup('utf-8')
 * 
 *     cpdef get_text_codec(self):             # <<<<<<<<<<<<<<
 *         return self._codec
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_18EdegDBCodecContext_3get_text_codec(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_18EdegDBCodecContext_3get_text_codec(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_text_codec (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_18EdegDBCodecContext_2get_text_codec(((struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_18EdegDBCodecContext_2get_text_codec(struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_text_codec", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_18EdegDBCodecContext_get_text_codec(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 215, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.EdegDBCodecContext.get_text_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pyx":218
 *         return self._codec
 * 
 *     cdef is_encoding_utf8(self):             # <<<<<<<<<<<<<<
 *         return True
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_18EdegDBCodecContext_is_encoding_utf8(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_encoding_utf8", 0);

  /* "edgedb/protocol/codecs/base.pyx":219
 * 
 *     cdef is_encoding_utf8(self):
 *         return True             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_True);
  __pyx_r = Py_True;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/base.pyx":218
 *         return self._codec
 * 
 *     cdef is_encoding_utf8(self):             # <<<<<<<<<<<<<<
 *         return True
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_18EdegDBCodecContext_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_18EdegDBCodecContext_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_18EdegDBCodecContext_4__reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_18EdegDBCodecContext_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.EdegDBCodecContext.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_18EdegDBCodecContext_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_18EdegDBCodecContext_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_18EdegDBCodecContext_6__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_18EdegDBCodecContext_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.EdegDBCodecContext.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/scalar.pyx":23
 * cdef class ScalarCodec(BaseCodec):
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.c_encoder = NULL
 *         self.c_decoder = NULL
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_11ScalarCodec_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_11ScalarCodec_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_11ScalarCodec___cinit__(((struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_11ScalarCodec___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "edgedb/protocol/codecs/scalar.pyx":24
 * 
 *     def __cinit__(self):
 *         self.c_encoder = NULL             # <<<<<<<<<<<<<<
 *         self.c_decoder = NULL
 * 
 */
  __pyx_v_self->c_encoder = NULL;

  /* "edgedb/protocol/codecs/scalar.pyx":25
 *     def __cinit__(self):
 *         self.c_encoder = NULL
 *         self.c_decoder = NULL             # <<<<<<<<<<<<<<
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):
 */
  __pyx_v_self->c_decoder = NULL;

  /* "edgedb/protocol/codecs/scalar.pyx":23
 * cdef class ScalarCodec(BaseCodec):
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.c_encoder = NULL
 *         self.c_decoder = NULL
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/scalar.pyx":27
 *         self.c_decoder = NULL
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         self.c_encoder(DEFAULT_CODEC_CONTEXT, buf, obj)
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_encode(struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("encode", 0);

  /* "edgedb/protocol/codecs/scalar.pyx":28
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):
 *         self.c_encoder(DEFAULT_CODEC_CONTEXT, buf, obj)             # <<<<<<<<<<<<<<
 * 
 *     cdef decode(self, FRBuffer *buf):
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_6edgedb_8protocol_8protocol_DEFAULT_CODEC_CONTEXT);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __pyx_v_self->c_encoder(((struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *)__pyx_t_1), __pyx_v_buf, __pyx_v_obj); if (unlikely(!__pyx_t_2)) __PYX_ERR(6, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/scalar.pyx":27
 *         self.c_decoder = NULL
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         self.c_encoder(DEFAULT_CODEC_CONTEXT, buf, obj)
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ScalarCodec.encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/scalar.pyx":30
 *         self.c_encoder(DEFAULT_CODEC_CONTEXT, buf, obj)
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         return self.c_decoder(DEFAULT_CODEC_CONTEXT, buf)
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("decode", 0);

  /* "edgedb/protocol/codecs/scalar.pyx":31
 * 
 *     cdef decode(self, FRBuffer *buf):
 *         return self.c_decoder(DEFAULT_CODEC_CONTEXT, buf)             # <<<<<<<<<<<<<<
 * 
 *     cdef derive(self, bytes tid):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_v_6edgedb_8protocol_8protocol_DEFAULT_CODEC_CONTEXT);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __pyx_v_self->c_decoder(((struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *)__pyx_t_1), __pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(6, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/scalar.pyx":30
 *         self.c_encoder(DEFAULT_CODEC_CONTEXT, buf, obj)
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         return self.c_decoder(DEFAULT_CODEC_CONTEXT, buf)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ScalarCodec.decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/scalar.pyx":33
 *         return self.c_decoder(DEFAULT_CODEC_CONTEXT, buf)
 * 
 *     cdef derive(self, bytes tid):             # <<<<<<<<<<<<<<
 *         return ScalarCodec.new(tid, self.name, self.c_encoder, self.c_decoder)
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_derive(struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *__pyx_v_self, PyObject *__pyx_v_tid) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("derive", 0);

  /* "edgedb/protocol/codecs/scalar.pyx":34
 * 
 *     cdef derive(self, bytes tid):
 *         return ScalarCodec.new(tid, self.name, self.c_encoder, self.c_decoder)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_v_self->__pyx_base.name;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = ((PyObject *)__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_new(__pyx_v_tid, ((PyObject*)__pyx_t_1), __pyx_v_self->c_encoder, __pyx_v_self->c_decoder)); if (unlikely(!__pyx_t_2)) __PYX_ERR(6, 34, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/scalar.pyx":33
 *         return self.c_decoder(DEFAULT_CODEC_CONTEXT, buf)
 * 
 *     cdef derive(self, bytes tid):             # <<<<<<<<<<<<<<
 *         return ScalarCodec.new(tid, self.name, self.c_encoder, self.c_decoder)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ScalarCodec.derive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/scalar.pyx":37
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid, str name,             # <<<<<<<<<<<<<<
 *                        pgproto.encode_func encoder,
 *                        pgproto.decode_func decoder):
 */

static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_new(PyObject *__pyx_v_tid, PyObject *__pyx_v_name, __pyx_t_6edgedb_7pgproto_7pgproto_encode_func __pyx_v_encoder, __pyx_t_6edgedb_7pgproto_7pgproto_decode_func __pyx_v_decoder) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *__pyx_v_codec = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("new", 0);

  /* "edgedb/protocol/codecs/scalar.pyx":43
 *             ScalarCodec codec
 * 
 *         codec = ScalarCodec.__new__(ScalarCodec)             # <<<<<<<<<<<<<<
 * 
 *         codec.tid = tid
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_6edgedb_8protocol_8protocol_ScalarCodec(((PyTypeObject *)__pyx_ptype_6edgedb_8protocol_8protocol_ScalarCodec), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 43, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/scalar.pyx":45
 *         codec = ScalarCodec.__new__(ScalarCodec)
 * 
 *         codec.tid = tid             # <<<<<<<<<<<<<<
 *         codec.name = name
 *         codec.c_encoder = encoder
 */
  __Pyx_INCREF(__pyx_v_tid);
  __Pyx_GIVEREF(__pyx_v_tid);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.tid);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.tid);
  __pyx_v_codec->__pyx_base.tid = __pyx_v_tid;

  /* "edgedb/protocol/codecs/scalar.pyx":46
 * 
 *         codec.tid = tid
 *         codec.name = name             # <<<<<<<<<<<<<<
 *         codec.c_encoder = encoder
 *         codec.c_decoder = decoder
 */
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.name);
  __pyx_v_codec->__pyx_base.name = __pyx_v_name;

  /* "edgedb/protocol/codecs/scalar.pyx":47
 *         codec.tid = tid
 *         codec.name = name
 *         codec.c_encoder = encoder             # <<<<<<<<<<<<<<
 *         codec.c_decoder = decoder
 * 
 */
  __pyx_v_codec->c_encoder = __pyx_v_encoder;

  /* "edgedb/protocol/codecs/scalar.pyx":48
 *         codec.name = name
 *         codec.c_encoder = encoder
 *         codec.c_decoder = decoder             # <<<<<<<<<<<<<<
 * 
 *         return codec
 */
  __pyx_v_codec->c_decoder = __pyx_v_decoder;

  /* "edgedb/protocol/codecs/scalar.pyx":50
 *         codec.c_decoder = decoder
 * 
 *         return codec             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_codec));
  __pyx_r = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_codec);
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/scalar.pyx":37
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid, str name,             # <<<<<<<<<<<<<<
 *                        pgproto.encode_func encoder,
 *                        pgproto.decode_func decoder):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ScalarCodec.new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_11ScalarCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_11ScalarCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_11ScalarCodec_2__reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_11ScalarCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ScalarCodec.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_11ScalarCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_11ScalarCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_11ScalarCodec_4__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_11ScalarCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ScalarCodec.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/tuple.pyx":23
 * cdef class TupleCodec(BaseRecordCodec):
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         cdef:
 *             object result
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_10TupleCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  PyObject *__pyx_v_result = 0;
  Py_ssize_t __pyx_v_elem_count;
  Py_ssize_t __pyx_v_i;
  int32_t __pyx_v_elem_len;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_elem_codec = 0;
  struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer __pyx_v_elem_buf;
  PyObject *__pyx_v_fields_codecs = 0;
  PyObject *__pyx_v_elem = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char const *__pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  Py_UCS4 __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("decode", 0);

  /* "edgedb/protocol/codecs/tuple.pyx":31
 *             BaseCodec elem_codec
 *             FRBuffer elem_buf
 *             tuple fields_codecs = (<BaseRecordCodec>self).fields_codecs             # <<<<<<<<<<<<<<
 * 
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 */
  __pyx_t_1 = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *)__pyx_v_self)->fields_codecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_fields_codecs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/tuple.pyx":33
 *             tuple fields_codecs = (<BaseRecordCodec>self).fields_codecs
 * 
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 * 
 *         if elem_count != len(fields_codecs):
 */
  __pyx_t_2 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == ((char const *)NULL))) __PYX_ERR(7, 33, __pyx_L1_error)
  __pyx_v_elem_count = ((Py_ssize_t)((uint32_t)unpack_int32(__pyx_t_2)));

  /* "edgedb/protocol/codecs/tuple.pyx":35
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 * 
 *         if elem_count != len(fields_codecs):             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'cannot decode Tuple: expected {len(fields_codecs)} '
 */
  if (unlikely(__pyx_v_fields_codecs == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(7, 35, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v_fields_codecs); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(7, 35, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_v_elem_count != __pyx_t_3) != 0);
  if (unlikely(__pyx_t_4)) {

    /* "edgedb/protocol/codecs/tuple.pyx":37
 *         if elem_count != len(fields_codecs):
 *             raise RuntimeError(
 *                 f'cannot decode Tuple: expected {len(fields_codecs)} '             # <<<<<<<<<<<<<<
 *                 f'elements, got {elem_count}')
 * 
 */
    __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 37, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = 0;
    __pyx_t_5 = 127;
    __Pyx_INCREF(__pyx_kp_u_cannot_decode_Tuple_expected);
    __pyx_t_3 += 30;
    __Pyx_GIVEREF(__pyx_kp_u_cannot_decode_Tuple_expected);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_cannot_decode_Tuple_expected);
    if (unlikely(__pyx_v_fields_codecs == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(7, 37, __pyx_L1_error)
    }
    __pyx_t_6 = PyTuple_GET_SIZE(__pyx_v_fields_codecs); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(7, 37, __pyx_L1_error)
    __pyx_t_7 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_6, 0, ' ', 'd'); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 37, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_INCREF(__pyx_kp_u_elements_got);
    __pyx_t_3 += 15;
    __Pyx_GIVEREF(__pyx_kp_u_elements_got);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_elements_got);

    /* "edgedb/protocol/codecs/tuple.pyx":38
 *             raise RuntimeError(
 *                 f'cannot decode Tuple: expected {len(fields_codecs)} '
 *                 f'elements, got {elem_count}')             # <<<<<<<<<<<<<<
 * 
 *         result = datatypes.tuple_new(elem_count)
 */
    __pyx_t_7 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_v_elem_count, 0, ' ', 'd'); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 38, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "edgedb/protocol/codecs/tuple.pyx":37
 *         if elem_count != len(fields_codecs):
 *             raise RuntimeError(
 *                 f'cannot decode Tuple: expected {len(fields_codecs)} '             # <<<<<<<<<<<<<<
 *                 f'elements, got {elem_count}')
 * 
 */
    __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_1, 4, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 37, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/tuple.pyx":36
 * 
 *         if elem_count != len(fields_codecs):
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 f'cannot decode Tuple: expected {len(fields_codecs)} '
 *                 f'elements, got {elem_count}')
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 36, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(7, 36, __pyx_L1_error)

    /* "edgedb/protocol/codecs/tuple.pyx":35
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 * 
 *         if elem_count != len(fields_codecs):             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'cannot decode Tuple: expected {len(fields_codecs)} '
 */
  }

  /* "edgedb/protocol/codecs/tuple.pyx":40
 *                 f'elements, got {elem_count}')
 * 
 *         result = datatypes.tuple_new(elem_count)             # <<<<<<<<<<<<<<
 * 
 *         for i in range(elem_count):
 */
  __pyx_t_1 = __pyx_f_6edgedb_9datatypes_9datatypes_tuple_new(__pyx_v_elem_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/tuple.pyx":42
 *         result = datatypes.tuple_new(elem_count)
 * 
 *         for i in range(elem_count):             # <<<<<<<<<<<<<<
 *             frb_read(buf, 4)  # reserved
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 */
  __pyx_t_3 = __pyx_v_elem_count;
  __pyx_t_6 = __pyx_t_3;
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_6; __pyx_t_8+=1) {
    __pyx_v_i = __pyx_t_8;

    /* "edgedb/protocol/codecs/tuple.pyx":43
 * 
 *         for i in range(elem_count):
 *             frb_read(buf, 4)  # reserved             # <<<<<<<<<<<<<<
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 * 
 */
    __pyx_t_2 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == ((char const *)NULL))) __PYX_ERR(7, 43, __pyx_L1_error)

    /* "edgedb/protocol/codecs/tuple.pyx":44
 *         for i in range(elem_count):
 *             frb_read(buf, 4)  # reserved
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 * 
 *             if elem_len == -1:
 */
    __pyx_t_2 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == ((char const *)NULL))) __PYX_ERR(7, 44, __pyx_L1_error)
    __pyx_v_elem_len = unpack_int32(__pyx_t_2);

    /* "edgedb/protocol/codecs/tuple.pyx":46
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 * 
 *             if elem_len == -1:             # <<<<<<<<<<<<<<
 *                 elem = None
 *             else:
 */
    __pyx_t_4 = ((__pyx_v_elem_len == -1L) != 0);
    if (__pyx_t_4) {

      /* "edgedb/protocol/codecs/tuple.pyx":47
 * 
 *             if elem_len == -1:
 *                 elem = None             # <<<<<<<<<<<<<<
 *             else:
 *                 elem_codec = <BaseCodec>fields_codecs[i]
 */
      __Pyx_INCREF(Py_None);
      __Pyx_XDECREF_SET(__pyx_v_elem, Py_None);

      /* "edgedb/protocol/codecs/tuple.pyx":46
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 * 
 *             if elem_len == -1:             # <<<<<<<<<<<<<<
 *                 elem = None
 *             else:
 */
      goto __pyx_L6;
    }

    /* "edgedb/protocol/codecs/tuple.pyx":49
 *                 elem = None
 *             else:
 *                 elem_codec = <BaseCodec>fields_codecs[i]             # <<<<<<<<<<<<<<
 *                 elem = elem_codec.decode(
 *                     frb_slice_from(&elem_buf, buf, elem_len))
 */
    /*else*/ {
      if (unlikely(__pyx_v_fields_codecs == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(7, 49, __pyx_L1_error)
      }
      __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_fields_codecs, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 49, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = __pyx_t_1;
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_7));
      __pyx_t_7 = 0;

      /* "edgedb/protocol/codecs/tuple.pyx":50
 *             else:
 *                 elem_codec = <BaseCodec>fields_codecs[i]
 *                 elem = elem_codec.decode(             # <<<<<<<<<<<<<<
 *                     frb_slice_from(&elem_buf, buf, elem_len))
 *                 if frb_get_len(&elem_buf):
 */
      __pyx_t_7 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_elem_codec->__pyx_vtab)->decode(__pyx_v_elem_codec, __pyx_f_6edgedb_7pgproto_7pgproto_frb_slice_from((&__pyx_v_elem_buf), __pyx_v_buf, __pyx_v_elem_len)); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 50, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "edgedb/protocol/codecs/tuple.pyx":52
 *                 elem = elem_codec.decode(
 *                     frb_slice_from(&elem_buf, buf, elem_len))
 *                 if frb_get_len(&elem_buf):             # <<<<<<<<<<<<<<
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after '
 */
      __pyx_t_4 = (__pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len((&__pyx_v_elem_buf)) != 0);
      if (unlikely(__pyx_t_4)) {

        /* "edgedb/protocol/codecs/tuple.pyx":55
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after '
 *                         f'tuple element decoding: {frb_get_len(&elem_buf)}')             # <<<<<<<<<<<<<<
 * 
 *             datatypes.tuple_set(result, i, elem)
 */
        __pyx_t_7 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len((&__pyx_v_elem_buf)), 0, ' ', 'd'); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 55, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);

        /* "edgedb/protocol/codecs/tuple.pyx":54
 *                 if frb_get_len(&elem_buf):
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after '             # <<<<<<<<<<<<<<
 *                         f'tuple element decoding: {frb_get_len(&elem_buf)}')
 * 
 */
        __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_unexpected_trailing_data_in_buff, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 54, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "edgedb/protocol/codecs/tuple.pyx":53
 *                     frb_slice_from(&elem_buf, buf, elem_len))
 *                 if frb_get_len(&elem_buf):
 *                     raise RuntimeError(             # <<<<<<<<<<<<<<
 *                         f'unexpected trailing data in buffer after '
 *                         f'tuple element decoding: {frb_get_len(&elem_buf)}')
 */
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 53, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_Raise(__pyx_t_7, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __PYX_ERR(7, 53, __pyx_L1_error)

        /* "edgedb/protocol/codecs/tuple.pyx":52
 *                 elem = elem_codec.decode(
 *                     frb_slice_from(&elem_buf, buf, elem_len))
 *                 if frb_get_len(&elem_buf):             # <<<<<<<<<<<<<<
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after '
 */
      }
    }
    __pyx_L6:;

    /* "edgedb/protocol/codecs/tuple.pyx":57
 *                         f'tuple element decoding: {frb_get_len(&elem_buf)}')
 * 
 *             datatypes.tuple_set(result, i, elem)             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
    __pyx_t_7 = __pyx_f_6edgedb_9datatypes_9datatypes_tuple_set(__pyx_v_result, __pyx_v_i, __pyx_v_elem); if (unlikely(!__pyx_t_7)) __PYX_ERR(7, 57, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }

  /* "edgedb/protocol/codecs/tuple.pyx":59
 *             datatypes.tuple_set(result, i, elem)
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cdef dump(self, int level = 0):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/tuple.pyx":23
 * cdef class TupleCodec(BaseRecordCodec):
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         cdef:
 *             object result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("edgedb.protocol.protocol.TupleCodec.decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF((PyObject *)__pyx_v_elem_codec);
  __Pyx_XDECREF(__pyx_v_fields_codecs);
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/tuple.pyx":61
 *         return result
 * 
 *     cdef dump(self, int level = 0):             # <<<<<<<<<<<<<<
 *         buf = [f'{level * " "}{self.name}']
 *         for codec in self.fields_codecs:
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_10TupleCodec_dump(struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec *__pyx_v_self, struct __pyx_opt_args_6edgedb_8protocol_8protocol_10TupleCodec_dump *__pyx_optional_args) {
  int __pyx_v_level = ((int)0);
  PyObject *__pyx_v_buf = NULL;
  PyObject *__pyx_v_codec = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  struct __pyx_opt_args_6edgedb_8protocol_8protocol_9BaseCodec_dump __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dump", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_level = __pyx_optional_args->level;
    }
  }

  /* "edgedb/protocol/codecs/tuple.pyx":62
 * 
 *     cdef dump(self, int level = 0):
 *         buf = [f'{level * " "}{self.name}']             # <<<<<<<<<<<<<<
 *         for codec in self.fields_codecs:
 *             buf.append((<BaseCodec>codec).dump(level + 1))
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_level); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Multiply(__pyx_t_1, __pyx_kp_u__2); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyUnicode_Unicode(__pyx_v_self->__pyx_base.__pyx_base.name); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_buf = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/tuple.pyx":63
 *     cdef dump(self, int level = 0):
 *         buf = [f'{level * " "}{self.name}']
 *         for codec in self.fields_codecs:             # <<<<<<<<<<<<<<
 *             buf.append((<BaseCodec>codec).dump(level + 1))
 *         return '\n'.join(buf)
 */
  if (unlikely(__pyx_v_self->__pyx_base.fields_codecs == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(7, 63, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_v_self->__pyx_base.fields_codecs; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(7, 63, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 63, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_codec, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "edgedb/protocol/codecs/tuple.pyx":64
 *         buf = [f'{level * " "}{self.name}']
 *         for codec in self.fields_codecs:
 *             buf.append((<BaseCodec>codec).dump(level + 1))             # <<<<<<<<<<<<<<
 *         return '\n'.join(buf)
 * 
 */
    __pyx_t_5.__pyx_n = 1;
    __pyx_t_5.level = (__pyx_v_level + 1);
    __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_codec)->__pyx_vtab)->dump(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_codec), &__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(7, 64, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_buf, __pyx_t_3); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(7, 64, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "edgedb/protocol/codecs/tuple.pyx":63
 *     cdef dump(self, int level = 0):
 *         buf = [f'{level * " "}{self.name}']
 *         for codec in self.fields_codecs:             # <<<<<<<<<<<<<<
 *             buf.append((<BaseCodec>codec).dump(level + 1))
 *         return '\n'.join(buf)
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/tuple.pyx":65
 *         for codec in self.fields_codecs:
 *             buf.append((<BaseCodec>codec).dump(level + 1))
 *         return '\n'.join(buf)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyUnicode_Join(__pyx_kp_u__18, __pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(7, 65, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/tuple.pyx":61
 *         return result
 * 
 *     cdef dump(self, int level = 0):             # <<<<<<<<<<<<<<
 *         buf = [f'{level * " "}{self.name}']
 *         for codec in self.fields_codecs:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.TupleCodec.dump", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_buf);
  __Pyx_XDECREF(__pyx_v_codec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/tuple.pyx":68
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid, tuple fields_codecs):             # <<<<<<<<<<<<<<
 *         cdef:
 *             TupleCodec codec
 */

static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_10TupleCodec_new(PyObject *__pyx_v_tid, PyObject *__pyx_v_fields_codecs) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec *__pyx_v_codec = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("new", 0);

  /* "edgedb/protocol/codecs/tuple.pyx":72
 *             TupleCodec codec
 * 
 *         codec = TupleCodec.__new__(TupleCodec)             # <<<<<<<<<<<<<<
 * 
 *         codec.tid = tid
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_6edgedb_8protocol_8protocol_TupleCodec(((PyTypeObject *)__pyx_ptype_6edgedb_8protocol_8protocol_TupleCodec), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 72, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/tuple.pyx":74
 *         codec = TupleCodec.__new__(TupleCodec)
 * 
 *         codec.tid = tid             # <<<<<<<<<<<<<<
 *         codec.name = 'Tuple'
 *         codec.fields_codecs = fields_codecs
 */
  __Pyx_INCREF(__pyx_v_tid);
  __Pyx_GIVEREF(__pyx_v_tid);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.__pyx_base.tid);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.__pyx_base.tid);
  __pyx_v_codec->__pyx_base.__pyx_base.tid = __pyx_v_tid;

  /* "edgedb/protocol/codecs/tuple.pyx":75
 * 
 *         codec.tid = tid
 *         codec.name = 'Tuple'             # <<<<<<<<<<<<<<
 *         codec.fields_codecs = fields_codecs
 * 
 */
  __Pyx_INCREF(__pyx_n_u_Tuple);
  __Pyx_GIVEREF(__pyx_n_u_Tuple);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.__pyx_base.name);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.__pyx_base.name);
  __pyx_v_codec->__pyx_base.__pyx_base.name = __pyx_n_u_Tuple;

  /* "edgedb/protocol/codecs/tuple.pyx":76
 *         codec.tid = tid
 *         codec.name = 'Tuple'
 *         codec.fields_codecs = fields_codecs             # <<<<<<<<<<<<<<
 * 
 *         return codec
 */
  __Pyx_INCREF(__pyx_v_fields_codecs);
  __Pyx_GIVEREF(__pyx_v_fields_codecs);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.fields_codecs);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.fields_codecs);
  __pyx_v_codec->__pyx_base.fields_codecs = __pyx_v_fields_codecs;

  /* "edgedb/protocol/codecs/tuple.pyx":78
 *         codec.fields_codecs = fields_codecs
 * 
 *         return codec             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_codec));
  __pyx_r = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_codec);
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/tuple.pyx":68
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid, tuple fields_codecs):             # <<<<<<<<<<<<<<
 *         cdef:
 *             TupleCodec codec
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.TupleCodec.new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10TupleCodec_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10TupleCodec_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_10TupleCodec___reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10TupleCodec___reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.TupleCodec.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10TupleCodec_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10TupleCodec_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_10TupleCodec_2__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10TupleCodec_2__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.TupleCodec.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/namedtuple.pyx":26
 * cdef class NamedTupleCodec(BaseNamedRecordCodec):
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         cdef:
 *             object result
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_15NamedTupleCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  PyObject *__pyx_v_result = 0;
  Py_ssize_t __pyx_v_elem_count;
  Py_ssize_t __pyx_v_i;
  int32_t __pyx_v_elem_len;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_elem_codec = 0;
  struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer __pyx_v_elem_buf;
  PyObject *__pyx_v_fields_codecs = 0;
  PyObject *__pyx_v_elem = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char const *__pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  Py_UCS4 __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("decode", 0);

  /* "edgedb/protocol/codecs/namedtuple.pyx":34
 *             BaseCodec elem_codec
 *             FRBuffer elem_buf
 *             tuple fields_codecs = (<BaseRecordCodec>self).fields_codecs             # <<<<<<<<<<<<<<
 * 
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 */
  __pyx_t_1 = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *)__pyx_v_self)->fields_codecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_fields_codecs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":36
 *             tuple fields_codecs = (<BaseRecordCodec>self).fields_codecs
 * 
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 * 
 *         if elem_count != len(fields_codecs):
 */
  __pyx_t_2 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == ((char const *)NULL))) __PYX_ERR(3, 36, __pyx_L1_error)
  __pyx_v_elem_count = ((Py_ssize_t)((uint32_t)unpack_int32(__pyx_t_2)));

  /* "edgedb/protocol/codecs/namedtuple.pyx":38
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 * 
 *         if elem_count != len(fields_codecs):             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'cannot decode NamedTuple: expected {len(fields_codecs)} '
 */
  if (unlikely(__pyx_v_fields_codecs == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(3, 38, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v_fields_codecs); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(3, 38, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_v_elem_count != __pyx_t_3) != 0);
  if (unlikely(__pyx_t_4)) {

    /* "edgedb/protocol/codecs/namedtuple.pyx":40
 *         if elem_count != len(fields_codecs):
 *             raise RuntimeError(
 *                 f'cannot decode NamedTuple: expected {len(fields_codecs)} '             # <<<<<<<<<<<<<<
 *                 f'elements, got {elem_count}')
 * 
 */
    __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 40, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = 0;
    __pyx_t_5 = 127;
    __Pyx_INCREF(__pyx_kp_u_cannot_decode_NamedTuple_expecte);
    __pyx_t_3 += 35;
    __Pyx_GIVEREF(__pyx_kp_u_cannot_decode_NamedTuple_expecte);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_cannot_decode_NamedTuple_expecte);
    if (unlikely(__pyx_v_fields_codecs == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(3, 40, __pyx_L1_error)
    }
    __pyx_t_6 = PyTuple_GET_SIZE(__pyx_v_fields_codecs); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(3, 40, __pyx_L1_error)
    __pyx_t_7 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_6, 0, ' ', 'd'); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 40, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_INCREF(__pyx_kp_u_elements_got);
    __pyx_t_3 += 15;
    __Pyx_GIVEREF(__pyx_kp_u_elements_got);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_elements_got);

    /* "edgedb/protocol/codecs/namedtuple.pyx":41
 *             raise RuntimeError(
 *                 f'cannot decode NamedTuple: expected {len(fields_codecs)} '
 *                 f'elements, got {elem_count}')             # <<<<<<<<<<<<<<
 * 
 *         result = datatypes.namedtuple_new(self.descriptor)
 */
    __pyx_t_7 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_v_elem_count, 0, ' ', 'd'); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 41, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "edgedb/protocol/codecs/namedtuple.pyx":40
 *         if elem_count != len(fields_codecs):
 *             raise RuntimeError(
 *                 f'cannot decode NamedTuple: expected {len(fields_codecs)} '             # <<<<<<<<<<<<<<
 *                 f'elements, got {elem_count}')
 * 
 */
    __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_1, 4, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 40, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/namedtuple.pyx":39
 * 
 *         if elem_count != len(fields_codecs):
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 f'cannot decode NamedTuple: expected {len(fields_codecs)} '
 *                 f'elements, got {elem_count}')
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 39, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(3, 39, __pyx_L1_error)

    /* "edgedb/protocol/codecs/namedtuple.pyx":38
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 * 
 *         if elem_count != len(fields_codecs):             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'cannot decode NamedTuple: expected {len(fields_codecs)} '
 */
  }

  /* "edgedb/protocol/codecs/namedtuple.pyx":43
 *                 f'elements, got {elem_count}')
 * 
 *         result = datatypes.namedtuple_new(self.descriptor)             # <<<<<<<<<<<<<<
 * 
 *         for i in range(elem_count):
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.descriptor;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_7 = __pyx_f_6edgedb_9datatypes_9datatypes_namedtuple_new(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_result = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":45
 *         result = datatypes.namedtuple_new(self.descriptor)
 * 
 *         for i in range(elem_count):             # <<<<<<<<<<<<<<
 *             frb_read(buf, 4)  # reserved
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 */
  __pyx_t_3 = __pyx_v_elem_count;
  __pyx_t_6 = __pyx_t_3;
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_6; __pyx_t_8+=1) {
    __pyx_v_i = __pyx_t_8;

    /* "edgedb/protocol/codecs/namedtuple.pyx":46
 * 
 *         for i in range(elem_count):
 *             frb_read(buf, 4)  # reserved             # <<<<<<<<<<<<<<
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 * 
 */
    __pyx_t_2 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == ((char const *)NULL))) __PYX_ERR(3, 46, __pyx_L1_error)

    /* "edgedb/protocol/codecs/namedtuple.pyx":47
 *         for i in range(elem_count):
 *             frb_read(buf, 4)  # reserved
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 * 
 *             if elem_len == -1:
 */
    __pyx_t_2 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == ((char const *)NULL))) __PYX_ERR(3, 47, __pyx_L1_error)
    __pyx_v_elem_len = unpack_int32(__pyx_t_2);

    /* "edgedb/protocol/codecs/namedtuple.pyx":49
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 * 
 *             if elem_len == -1:             # <<<<<<<<<<<<<<
 *                 elem = None
 *             else:
 */
    __pyx_t_4 = ((__pyx_v_elem_len == -1L) != 0);
    if (__pyx_t_4) {

      /* "edgedb/protocol/codecs/namedtuple.pyx":50
 * 
 *             if elem_len == -1:
 *                 elem = None             # <<<<<<<<<<<<<<
 *             else:
 *                 elem_codec = <BaseCodec>fields_codecs[i]
 */
      __Pyx_INCREF(Py_None);
      __Pyx_XDECREF_SET(__pyx_v_elem, Py_None);

      /* "edgedb/protocol/codecs/namedtuple.pyx":49
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 * 
 *             if elem_len == -1:             # <<<<<<<<<<<<<<
 *                 elem = None
 *             else:
 */
      goto __pyx_L6;
    }

    /* "edgedb/protocol/codecs/namedtuple.pyx":52
 *                 elem = None
 *             else:
 *                 elem_codec = <BaseCodec>fields_codecs[i]             # <<<<<<<<<<<<<<
 *                 elem = elem_codec.decode(
 *                     frb_slice_from(&elem_buf, buf, elem_len))
 */
    /*else*/ {
      if (unlikely(__pyx_v_fields_codecs == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(3, 52, __pyx_L1_error)
      }
      __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v_fields_codecs, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 52, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = __pyx_t_7;
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "edgedb/protocol/codecs/namedtuple.pyx":53
 *             else:
 *                 elem_codec = <BaseCodec>fields_codecs[i]
 *                 elem = elem_codec.decode(             # <<<<<<<<<<<<<<
 *                     frb_slice_from(&elem_buf, buf, elem_len))
 *                 if frb_get_len(&elem_buf):
 */
      __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_elem_codec->__pyx_vtab)->decode(__pyx_v_elem_codec, __pyx_f_6edgedb_7pgproto_7pgproto_frb_slice_from((&__pyx_v_elem_buf), __pyx_v_buf, __pyx_v_elem_len)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 53, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "edgedb/protocol/codecs/namedtuple.pyx":55
 *                 elem = elem_codec.decode(
 *                     frb_slice_from(&elem_buf, buf, elem_len))
 *                 if frb_get_len(&elem_buf):             # <<<<<<<<<<<<<<
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after named '
 */
      __pyx_t_4 = (__pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len((&__pyx_v_elem_buf)) != 0);
      if (unlikely(__pyx_t_4)) {

        /* "edgedb/protocol/codecs/namedtuple.pyx":58
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after named '
 *                         f'tuple element decoding: {frb_get_len(&elem_buf)}')             # <<<<<<<<<<<<<<
 * 
 *             datatypes.namedtuple_set(result, i, elem)
 */
        __pyx_t_1 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len((&__pyx_v_elem_buf)), 0, ' ', 'd'); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 58, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);

        /* "edgedb/protocol/codecs/namedtuple.pyx":57
 *                 if frb_get_len(&elem_buf):
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after named '             # <<<<<<<<<<<<<<
 *                         f'tuple element decoding: {frb_get_len(&elem_buf)}')
 * 
 */
        __pyx_t_7 = __Pyx_PyUnicode_Concat(__pyx_kp_u_unexpected_trailing_data_in_buff_2, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 57, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "edgedb/protocol/codecs/namedtuple.pyx":56
 *                     frb_slice_from(&elem_buf, buf, elem_len))
 *                 if frb_get_len(&elem_buf):
 *                     raise RuntimeError(             # <<<<<<<<<<<<<<
 *                         f'unexpected trailing data in buffer after named '
 *                         f'tuple element decoding: {frb_get_len(&elem_buf)}')
 */
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 56, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(3, 56, __pyx_L1_error)

        /* "edgedb/protocol/codecs/namedtuple.pyx":55
 *                 elem = elem_codec.decode(
 *                     frb_slice_from(&elem_buf, buf, elem_len))
 *                 if frb_get_len(&elem_buf):             # <<<<<<<<<<<<<<
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after named '
 */
      }
    }
    __pyx_L6:;

    /* "edgedb/protocol/codecs/namedtuple.pyx":60
 *                         f'tuple element decoding: {frb_get_len(&elem_buf)}')
 * 
 *             datatypes.namedtuple_set(result, i, elem)             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
    __pyx_t_1 = __pyx_f_6edgedb_9datatypes_9datatypes_namedtuple_set(__pyx_v_result, __pyx_v_i, __pyx_v_elem); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 60, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "edgedb/protocol/codecs/namedtuple.pyx":62
 *             datatypes.namedtuple_set(result, i, elem)
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cdef encode_kwargs(self, WriteBuffer buf, dict obj):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":26
 * cdef class NamedTupleCodec(BaseNamedRecordCodec):
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         cdef:
 *             object result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("edgedb.protocol.protocol.NamedTupleCodec.decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF((PyObject *)__pyx_v_elem_codec);
  __Pyx_XDECREF(__pyx_v_fields_codecs);
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/namedtuple.pyx":64
 *         return result
 * 
 *     cdef encode_kwargs(self, WriteBuffer buf, dict obj):             # <<<<<<<<<<<<<<
 *         # Compatibility with old protocols. The 0.12 protocol
 *         # uses `ObjectCodec.encode_args()`.
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_15NamedTupleCodec_encode_kwargs(struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_elem_data = 0;
  Py_ssize_t __pyx_v_objlen;
  Py_ssize_t __pyx_v_i;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_sub_codec = 0;
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_arg = NULL;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_v_value_repr = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  Py_ssize_t __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  int __pyx_t_19;
  char const *__pyx_t_20;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  int32_t __pyx_t_27;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("encode_kwargs", 0);

  /* "edgedb/protocol/codecs/namedtuple.pyx":73
 *             BaseCodec sub_codec
 * 
 *         self._check_encoder()             # <<<<<<<<<<<<<<
 * 
 *         objlen = len(obj)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_NamedTupleCodec *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._check_encoder(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 73, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":75
 *         self._check_encoder()
 * 
 *         objlen = len(obj)             # <<<<<<<<<<<<<<
 *         if objlen != len(self.fields_codecs):
 *             raise self._make_missing_args_error_message(obj)
 */
  if (unlikely(__pyx_v_obj == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(3, 75, __pyx_L1_error)
  }
  __pyx_t_2 = PyDict_Size(__pyx_v_obj); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(3, 75, __pyx_L1_error)
  __pyx_v_objlen = __pyx_t_2;

  /* "edgedb/protocol/codecs/namedtuple.pyx":76
 * 
 *         objlen = len(obj)
 *         if objlen != len(self.fields_codecs):             # <<<<<<<<<<<<<<
 *             raise self._make_missing_args_error_message(obj)
 * 
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.__pyx_base.fields_codecs;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(3, 76, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(3, 76, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((__pyx_v_objlen != __pyx_t_2) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "edgedb/protocol/codecs/namedtuple.pyx":77
 *         objlen = len(obj)
 *         if objlen != len(self.fields_codecs):
 *             raise self._make_missing_args_error_message(obj)             # <<<<<<<<<<<<<<
 * 
 *         elem_data = WriteBuffer.new()
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_make_missing_args_error_message); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 77, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_obj) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_obj);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 77, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(3, 77, __pyx_L1_error)

    /* "edgedb/protocol/codecs/namedtuple.pyx":76
 * 
 *         objlen = len(obj)
 *         if objlen != len(self.fields_codecs):             # <<<<<<<<<<<<<<
 *             raise self._make_missing_args_error_message(obj)
 * 
 */
  }

  /* "edgedb/protocol/codecs/namedtuple.pyx":79
 *             raise self._make_missing_args_error_message(obj)
 * 
 *         elem_data = WriteBuffer.new()             # <<<<<<<<<<<<<<
 *         for i in range(objlen):
 *             name = datatypes.record_desc_pointer_name(self.descriptor, i)
 */
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 79, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_elem_data = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":80
 * 
 *         elem_data = WriteBuffer.new()
 *         for i in range(objlen):             # <<<<<<<<<<<<<<
 *             name = datatypes.record_desc_pointer_name(self.descriptor, i)
 *             try:
 */
  __pyx_t_2 = __pyx_v_objlen;
  __pyx_t_6 = __pyx_t_2;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;

    /* "edgedb/protocol/codecs/namedtuple.pyx":81
 *         elem_data = WriteBuffer.new()
 *         for i in range(objlen):
 *             name = datatypes.record_desc_pointer_name(self.descriptor, i)             # <<<<<<<<<<<<<<
 *             try:
 *                 arg = obj[name]
 */
    __pyx_t_1 = __pyx_v_self->__pyx_base.descriptor;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_4 = __pyx_f_6edgedb_9datatypes_9datatypes_record_desc_pointer_name(__pyx_t_1, __pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 81, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "edgedb/protocol/codecs/namedtuple.pyx":82
 *         for i in range(objlen):
 *             name = datatypes.record_desc_pointer_name(self.descriptor, i)
 *             try:             # <<<<<<<<<<<<<<
 *                 arg = obj[name]
 *             except KeyError:
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      /*try:*/ {

        /* "edgedb/protocol/codecs/namedtuple.pyx":83
 *             name = datatypes.record_desc_pointer_name(self.descriptor, i)
 *             try:
 *                 arg = obj[name]             # <<<<<<<<<<<<<<
 *             except KeyError:
 *                 raise self._make_missing_args_error_message(obj) from None
 */
        if (unlikely(__pyx_v_obj == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(3, 83, __pyx_L6_error)
        }
        __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_obj, __pyx_v_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 83, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_4);
        __pyx_t_4 = 0;

        /* "edgedb/protocol/codecs/namedtuple.pyx":82
 *         for i in range(objlen):
 *             name = datatypes.record_desc_pointer_name(self.descriptor, i)
 *             try:             # <<<<<<<<<<<<<<
 *                 arg = obj[name]
 *             except KeyError:
 */
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L13_try_end;
      __pyx_L6_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "edgedb/protocol/codecs/namedtuple.pyx":84
 *             try:
 *                 arg = obj[name]
 *             except KeyError:             # <<<<<<<<<<<<<<
 *                 raise self._make_missing_args_error_message(obj) from None
 * 
 */
      __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
      if (__pyx_t_11) {
        __Pyx_AddTraceback("edgedb.protocol.protocol.NamedTupleCodec.encode_kwargs", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_1, &__pyx_t_5) < 0) __PYX_ERR(3, 84, __pyx_L8_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_5);

        /* "edgedb/protocol/codecs/namedtuple.pyx":85
 *                 arg = obj[name]
 *             except KeyError:
 *                 raise self._make_missing_args_error_message(obj) from None             # <<<<<<<<<<<<<<
 * 
 *             elem_data.write_int32(0)  # reserved bytes
 */
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_make_missing_args_error_message); if (unlikely(!__pyx_t_13)) __PYX_ERR(3, 85, __pyx_L8_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_14 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
          if (likely(__pyx_t_14)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
            __Pyx_INCREF(__pyx_t_14);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_13, function);
          }
        }
        __pyx_t_12 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_14, __pyx_v_obj) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_v_obj);
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 85, __pyx_L8_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_Raise(__pyx_t_12, 0, 0, Py_None);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __PYX_ERR(3, 85, __pyx_L8_except_error)
      }
      goto __pyx_L8_except_error;
      __pyx_L8_except_error:;

      /* "edgedb/protocol/codecs/namedtuple.pyx":82
 *         for i in range(objlen):
 *             name = datatypes.record_desc_pointer_name(self.descriptor, i)
 *             try:             # <<<<<<<<<<<<<<
 *                 arg = obj[name]
 *             except KeyError:
 */
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      goto __pyx_L1_error;
      __pyx_L13_try_end:;
    }

    /* "edgedb/protocol/codecs/namedtuple.pyx":87
 *                 raise self._make_missing_args_error_message(obj) from None
 * 
 *             elem_data.write_int32(0)  # reserved bytes             # <<<<<<<<<<<<<<
 *             if arg is None:
 *                 elem_data.write_int32(-1)
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_elem_data->__pyx_vtab)->write_int32(__pyx_v_elem_data, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 87, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "edgedb/protocol/codecs/namedtuple.pyx":88
 * 
 *             elem_data.write_int32(0)  # reserved bytes
 *             if arg is None:             # <<<<<<<<<<<<<<
 *                 elem_data.write_int32(-1)
 *             else:
 */
    __pyx_t_3 = (__pyx_v_arg == Py_None);
    __pyx_t_15 = (__pyx_t_3 != 0);
    if (__pyx_t_15) {

      /* "edgedb/protocol/codecs/namedtuple.pyx":89
 *             elem_data.write_int32(0)  # reserved bytes
 *             if arg is None:
 *                 elem_data.write_int32(-1)             # <<<<<<<<<<<<<<
 *             else:
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])
 */
      __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_elem_data->__pyx_vtab)->write_int32(__pyx_v_elem_data, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 89, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "edgedb/protocol/codecs/namedtuple.pyx":88
 * 
 *             elem_data.write_int32(0)  # reserved bytes
 *             if arg is None:             # <<<<<<<<<<<<<<
 *                 elem_data.write_int32(-1)
 *             else:
 */
      goto __pyx_L16;
    }

    /* "edgedb/protocol/codecs/namedtuple.pyx":91
 *                 elem_data.write_int32(-1)
 *             else:
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])             # <<<<<<<<<<<<<<
 *                 try:
 *                     sub_codec.encode(elem_data, arg)
 */
    /*else*/ {
      if (unlikely(__pyx_v_self->__pyx_base.__pyx_base.fields_codecs == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(3, 91, __pyx_L1_error)
      }
      __pyx_t_5 = __Pyx_GetItemInt_Tuple(__pyx_v_self->__pyx_base.__pyx_base.fields_codecs, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 91, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __pyx_t_5;
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF_SET(__pyx_v_sub_codec, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "edgedb/protocol/codecs/namedtuple.pyx":92
 *             else:
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])
 *                 try:             # <<<<<<<<<<<<<<
 *                     sub_codec.encode(elem_data, arg)
 *                 except (TypeError, ValueError) as e:
 */
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_8);
        /*try:*/ {

          /* "edgedb/protocol/codecs/namedtuple.pyx":93
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])
 *                 try:
 *                     sub_codec.encode(elem_data, arg)             # <<<<<<<<<<<<<<
 *                 except (TypeError, ValueError) as e:
 *                     value_repr = repr(arg)
 */
          __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_sub_codec->__pyx_vtab)->encode(__pyx_v_sub_codec, __pyx_v_elem_data, __pyx_v_arg); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 93, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "edgedb/protocol/codecs/namedtuple.pyx":92
 *             else:
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])
 *                 try:             # <<<<<<<<<<<<<<
 *                     sub_codec.encode(elem_data, arg)
 *                 except (TypeError, ValueError) as e:
 */
        }
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L24_try_end;
        __pyx_L17_error:;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "edgedb/protocol/codecs/namedtuple.pyx":94
 *                 try:
 *                     sub_codec.encode(elem_data, arg)
 *                 except (TypeError, ValueError) as e:             # <<<<<<<<<<<<<<
 *                     value_repr = repr(arg)
 *                     if len(value_repr) > 40:
 */
        __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
        if (__pyx_t_11) {
          __Pyx_AddTraceback("edgedb.protocol.protocol.NamedTupleCodec.encode_kwargs", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_4) < 0) __PYX_ERR(3, 94, __pyx_L19_except_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __pyx_v_e = __pyx_t_5;
          /*try:*/ {

            /* "edgedb/protocol/codecs/namedtuple.pyx":95
 *                     sub_codec.encode(elem_data, arg)
 *                 except (TypeError, ValueError) as e:
 *                     value_repr = repr(arg)             # <<<<<<<<<<<<<<
 *                     if len(value_repr) > 40:
 *                         value_repr = value_repr[:40] + '...'
 */
            __pyx_t_12 = PyObject_Repr(__pyx_v_arg); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 95, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_v_value_repr = __pyx_t_12;
            __pyx_t_12 = 0;

            /* "edgedb/protocol/codecs/namedtuple.pyx":96
 *                 except (TypeError, ValueError) as e:
 *                     value_repr = repr(arg)
 *                     if len(value_repr) > 40:             # <<<<<<<<<<<<<<
 *                         value_repr = value_repr[:40] + '...'
 *                     raise errors.InvalidArgumentError(
 */
            __pyx_t_16 = PyObject_Length(__pyx_v_value_repr); if (unlikely(__pyx_t_16 == ((Py_ssize_t)-1))) __PYX_ERR(3, 96, __pyx_L30_error)
            __pyx_t_15 = ((__pyx_t_16 > 40) != 0);
            if (__pyx_t_15) {

              /* "edgedb/protocol/codecs/namedtuple.pyx":97
 *                     value_repr = repr(arg)
 *                     if len(value_repr) > 40:
 *                         value_repr = value_repr[:40] + '...'             # <<<<<<<<<<<<<<
 *                     raise errors.InvalidArgumentError(
 *                         'invalid input for query argument'
 */
              __pyx_t_12 = __Pyx_PyObject_GetSlice(__pyx_v_value_repr, 0, 40, NULL, NULL, &__pyx_slice__13, 0, 1, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 97, __pyx_L30_error)
              __Pyx_GOTREF(__pyx_t_12);
              __pyx_t_13 = PyNumber_Add(__pyx_t_12, __pyx_kp_u__14); if (unlikely(!__pyx_t_13)) __PYX_ERR(3, 97, __pyx_L30_error)
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_DECREF_SET(__pyx_v_value_repr, __pyx_t_13);
              __pyx_t_13 = 0;

              /* "edgedb/protocol/codecs/namedtuple.pyx":96
 *                 except (TypeError, ValueError) as e:
 *                     value_repr = repr(arg)
 *                     if len(value_repr) > 40:             # <<<<<<<<<<<<<<
 *                         value_repr = value_repr[:40] + '...'
 *                     raise errors.InvalidArgumentError(
 */
            }

            /* "edgedb/protocol/codecs/namedtuple.pyx":98
 *                     if len(value_repr) > 40:
 *                         value_repr = value_repr[:40] + '...'
 *                     raise errors.InvalidArgumentError(             # <<<<<<<<<<<<<<
 *                         'invalid input for query argument'
 *                         ' ${n}: {v} ({msg})'.format(
 */
            __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_errors); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 98, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_InvalidArgumentError); if (unlikely(!__pyx_t_14)) __PYX_ERR(3, 98, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

            /* "edgedb/protocol/codecs/namedtuple.pyx":100
 *                     raise errors.InvalidArgumentError(
 *                         'invalid input for query argument'
 *                         ' ${n}: {v} ({msg})'.format(             # <<<<<<<<<<<<<<
 *                             n=name, v=value_repr, msg=e)) from e
 * 
 */
            __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_invalid_input_for_query_argument, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 100, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_12);

            /* "edgedb/protocol/codecs/namedtuple.pyx":101
 *                         'invalid input for query argument'
 *                         ' ${n}: {v} ({msg})'.format(
 *                             n=name, v=value_repr, msg=e)) from e             # <<<<<<<<<<<<<<
 * 
 *         buf.write_int32(4 + elem_data.len())  # buffer length
 */
            __pyx_t_17 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_17)) __PYX_ERR(3, 101, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_17);
            if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_n, __pyx_v_name) < 0) __PYX_ERR(3, 101, __pyx_L30_error)
            if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_v, __pyx_v_value_repr) < 0) __PYX_ERR(3, 101, __pyx_L30_error)
            if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_msg, __pyx_v_e) < 0) __PYX_ERR(3, 101, __pyx_L30_error)

            /* "edgedb/protocol/codecs/namedtuple.pyx":100
 *                     raise errors.InvalidArgumentError(
 *                         'invalid input for query argument'
 *                         ' ${n}: {v} ({msg})'.format(             # <<<<<<<<<<<<<<
 *                             n=name, v=value_repr, msg=e)) from e
 * 
 */
            __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_empty_tuple, __pyx_t_17); if (unlikely(!__pyx_t_18)) __PYX_ERR(3, 100, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_18);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __pyx_t_17 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
              __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_14);
              if (likely(__pyx_t_17)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
                __Pyx_INCREF(__pyx_t_17);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_14, function);
              }
            }
            __pyx_t_13 = (__pyx_t_17) ? __Pyx_PyObject_Call2Args(__pyx_t_14, __pyx_t_17, __pyx_t_18) : __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_18);
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            if (unlikely(!__pyx_t_13)) __PYX_ERR(3, 98, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

            /* "edgedb/protocol/codecs/namedtuple.pyx":101
 *                         'invalid input for query argument'
 *                         ' ${n}: {v} ({msg})'.format(
 *                             n=name, v=value_repr, msg=e)) from e             # <<<<<<<<<<<<<<
 * 
 *         buf.write_int32(4 + elem_data.len())  # buffer length
 */
            __Pyx_Raise(__pyx_t_13, 0, 0, __pyx_v_e);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __PYX_ERR(3, 98, __pyx_L30_error)
          }

          /* "edgedb/protocol/codecs/namedtuple.pyx":94
 *                 try:
 *                     sub_codec.encode(elem_data, arg)
 *                 except (TypeError, ValueError) as e:             # <<<<<<<<<<<<<<
 *                     value_repr = repr(arg)
 *                     if len(value_repr) > 40:
 */
          /*finally:*/ {
            __pyx_L30_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_declare
              __Pyx_PyThreadState_assign
              __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26);
              if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
              __Pyx_XGOTREF(__pyx_t_21);
              __Pyx_XGOTREF(__pyx_t_22);
              __Pyx_XGOTREF(__pyx_t_23);
              __Pyx_XGOTREF(__pyx_t_24);
              __Pyx_XGOTREF(__pyx_t_25);
              __Pyx_XGOTREF(__pyx_t_26);
              __pyx_t_11 = __pyx_lineno; __pyx_t_19 = __pyx_clineno; __pyx_t_20 = __pyx_filename;
              {
                __Pyx_DECREF(__pyx_v_e);
                __pyx_v_e = NULL;
              }
              if (PY_MAJOR_VERSION >= 3) {
                __Pyx_XGIVEREF(__pyx_t_24);
                __Pyx_XGIVEREF(__pyx_t_25);
                __Pyx_XGIVEREF(__pyx_t_26);
                __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26);
              }
              __Pyx_XGIVEREF(__pyx_t_21);
              __Pyx_XGIVEREF(__pyx_t_22);
              __Pyx_XGIVEREF(__pyx_t_23);
              __Pyx_ErrRestore(__pyx_t_21, __pyx_t_22, __pyx_t_23);
              __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
              __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_19; __pyx_filename = __pyx_t_20;
              goto __pyx_L19_except_error;
            }
          }
        }
        goto __pyx_L19_except_error;
        __pyx_L19_except_error:;

        /* "edgedb/protocol/codecs/namedtuple.pyx":92
 *             else:
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])
 *                 try:             # <<<<<<<<<<<<<<
 *                     sub_codec.encode(elem_data, arg)
 *                 except (TypeError, ValueError) as e:
 */
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_9, __pyx_t_8);
        goto __pyx_L1_error;
        __pyx_L24_try_end:;
      }
    }
    __pyx_L16:;
  }

  /* "edgedb/protocol/codecs/namedtuple.pyx":103
 *                             n=name, v=value_repr, msg=e)) from e
 * 
 *         buf.write_int32(4 + elem_data.len())  # buffer length             # <<<<<<<<<<<<<<
 *         buf.write_int32(<int32_t><uint32_t>objlen)
 *         buf.write_buffer(elem_data)
 */
  __pyx_t_4 = __pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_len(__pyx_v_elem_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 103, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_AddCObj(__pyx_int_4, __pyx_t_4, 4, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 103, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_27 = __Pyx_PyInt_As_int32_t(__pyx_t_5); if (unlikely((__pyx_t_27 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(3, 103, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, __pyx_t_27); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 103, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":104
 * 
 *         buf.write_int32(4 + elem_data.len())  # buffer length
 *         buf.write_int32(<int32_t><uint32_t>objlen)             # <<<<<<<<<<<<<<
 *         buf.write_buffer(elem_data)
 * 
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, ((int32_t)((uint32_t)__pyx_v_objlen))); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":105
 *         buf.write_int32(4 + elem_data.len())  # buffer length
 *         buf.write_int32(<int32_t><uint32_t>objlen)
 *         buf.write_buffer(elem_data)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_buffer(__pyx_v_buf, __pyx_v_elem_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":64
 *         return result
 * 
 *     cdef encode_kwargs(self, WriteBuffer buf, dict obj):             # <<<<<<<<<<<<<<
 *         # Compatibility with old protocols. The 0.12 protocol
 *         # uses `ObjectCodec.encode_args()`.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_AddTraceback("edgedb.protocol.protocol.NamedTupleCodec.encode_kwargs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_elem_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_sub_codec);
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_arg);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XDECREF(__pyx_v_value_repr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/namedtuple.pyx":108
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid, tuple fields_names, tuple fields_codecs):             # <<<<<<<<<<<<<<
 *         cdef:
 *             NamedTupleCodec codec
 */

static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_15NamedTupleCodec_new(PyObject *__pyx_v_tid, PyObject *__pyx_v_fields_names, PyObject *__pyx_v_fields_codecs) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *__pyx_v_codec = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("new", 0);

  /* "edgedb/protocol/codecs/namedtuple.pyx":112
 *             NamedTupleCodec codec
 * 
 *         codec = NamedTupleCodec.__new__(NamedTupleCodec)             # <<<<<<<<<<<<<<
 * 
 *         codec.tid = tid
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_6edgedb_8protocol_8protocol_NamedTupleCodec(((PyTypeObject *)__pyx_ptype_6edgedb_8protocol_8protocol_NamedTupleCodec), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 112, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":114
 *         codec = NamedTupleCodec.__new__(NamedTupleCodec)
 * 
 *         codec.tid = tid             # <<<<<<<<<<<<<<
 *         codec.name = 'NamedTuple'
 *         codec.descriptor = datatypes.record_desc_new(
 */
  __Pyx_INCREF(__pyx_v_tid);
  __Pyx_GIVEREF(__pyx_v_tid);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.__pyx_base.__pyx_base.tid);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.__pyx_base.__pyx_base.tid);
  __pyx_v_codec->__pyx_base.__pyx_base.__pyx_base.tid = __pyx_v_tid;

  /* "edgedb/protocol/codecs/namedtuple.pyx":115
 * 
 *         codec.tid = tid
 *         codec.name = 'NamedTuple'             # <<<<<<<<<<<<<<
 *         codec.descriptor = datatypes.record_desc_new(
 *             fields_names, <object>NULL, <object>NULL)
 */
  __Pyx_INCREF(__pyx_n_u_NamedTuple);
  __Pyx_GIVEREF(__pyx_n_u_NamedTuple);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.__pyx_base.__pyx_base.name);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.__pyx_base.__pyx_base.name);
  __pyx_v_codec->__pyx_base.__pyx_base.__pyx_base.name = __pyx_n_u_NamedTuple;

  /* "edgedb/protocol/codecs/namedtuple.pyx":116
 *         codec.tid = tid
 *         codec.name = 'NamedTuple'
 *         codec.descriptor = datatypes.record_desc_new(             # <<<<<<<<<<<<<<
 *             fields_names, <object>NULL, <object>NULL)
 *         codec.fields_codecs = fields_codecs
 */
  __pyx_t_1 = __pyx_f_6edgedb_9datatypes_9datatypes_record_desc_new(__pyx_v_fields_names, ((PyObject *)NULL), ((PyObject *)NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.descriptor);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.descriptor);
  __pyx_v_codec->__pyx_base.descriptor = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":118
 *         codec.descriptor = datatypes.record_desc_new(
 *             fields_names, <object>NULL, <object>NULL)
 *         codec.fields_codecs = fields_codecs             # <<<<<<<<<<<<<<
 * 
 *         return codec
 */
  __Pyx_INCREF(__pyx_v_fields_codecs);
  __Pyx_GIVEREF(__pyx_v_fields_codecs);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.__pyx_base.fields_codecs);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.__pyx_base.fields_codecs);
  __pyx_v_codec->__pyx_base.__pyx_base.fields_codecs = __pyx_v_fields_codecs;

  /* "edgedb/protocol/codecs/namedtuple.pyx":120
 *         codec.fields_codecs = fields_codecs
 * 
 *         return codec             # <<<<<<<<<<<<<<
 * 
 *     def _make_missing_args_error_message(self, args):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_codec));
  __pyx_r = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_codec);
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":108
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid, tuple fields_names, tuple fields_codecs):             # <<<<<<<<<<<<<<
 *         cdef:
 *             NamedTupleCodec codec
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.NamedTupleCodec.new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/namedtuple.pyx":122
 *         return codec
 * 
 *     def _make_missing_args_error_message(self, args):             # <<<<<<<<<<<<<<
 *         required_args = set()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_15NamedTupleCodec_1_make_missing_args_error_message(PyObject *__pyx_v_self, PyObject *__pyx_v_args); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_15NamedTupleCodec_1_make_missing_args_error_message(PyObject *__pyx_v_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_make_missing_args_error_message (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_15NamedTupleCodec__make_missing_args_error_message(((struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *)__pyx_v_self), ((PyObject *)__pyx_v_args));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_15NamedTupleCodec__make_missing_args_error_message(struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *__pyx_v_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_v_required_args = NULL;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_passed_args = NULL;
  PyObject *__pyx_v_missed_args = NULL;
  PyObject *__pyx_v_extra_args = NULL;
  PyObject *__pyx_v_error_message = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  Py_UCS4 __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_make_missing_args_error_message", 0);

  /* "edgedb/protocol/codecs/namedtuple.pyx":123
 * 
 *     def _make_missing_args_error_message(self, args):
 *         required_args = set()             # <<<<<<<<<<<<<<
 * 
 *         for i in range(len(self.fields_codecs)):
 */
  __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_required_args = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":125
 *         required_args = set()
 * 
 *         for i in range(len(self.fields_codecs)):             # <<<<<<<<<<<<<<
 *             name = datatypes.record_desc_pointer_name(self.descriptor, i)
 *             required_args.add(name)
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.__pyx_base.fields_codecs;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(3, 125, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(3, 125, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_t_2;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "edgedb/protocol/codecs/namedtuple.pyx":126
 * 
 *         for i in range(len(self.fields_codecs)):
 *             name = datatypes.record_desc_pointer_name(self.descriptor, i)             # <<<<<<<<<<<<<<
 *             required_args.add(name)
 * 
 */
    __pyx_t_1 = __pyx_v_self->__pyx_base.descriptor;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_5 = __pyx_f_6edgedb_9datatypes_9datatypes_record_desc_pointer_name(__pyx_t_1, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 126, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "edgedb/protocol/codecs/namedtuple.pyx":127
 *         for i in range(len(self.fields_codecs)):
 *             name = datatypes.record_desc_pointer_name(self.descriptor, i)
 *             required_args.add(name)             # <<<<<<<<<<<<<<
 * 
 *         passed_args = set(args.keys())
 */
    __pyx_t_6 = PySet_Add(__pyx_v_required_args, __pyx_v_name); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(3, 127, __pyx_L1_error)
  }

  /* "edgedb/protocol/codecs/namedtuple.pyx":129
 *             required_args.add(name)
 * 
 *         passed_args = set(args.keys())             # <<<<<<<<<<<<<<
 *         missed_args = required_args - passed_args
 *         extra_args = passed_args - required_args
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_args, __pyx_n_s_keys); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PySet_New(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_passed_args = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":130
 * 
 *         passed_args = set(args.keys())
 *         missed_args = required_args - passed_args             # <<<<<<<<<<<<<<
 *         extra_args = passed_args - required_args
 * 
 */
  __pyx_t_1 = PyNumber_Subtract(__pyx_v_required_args, __pyx_v_passed_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_missed_args = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":131
 *         passed_args = set(args.keys())
 *         missed_args = required_args - passed_args
 *         extra_args = passed_args - required_args             # <<<<<<<<<<<<<<
 * 
 *         error_message = f'expected {required_args} keyword arguments'
 */
  __pyx_t_1 = PyNumber_Subtract(__pyx_v_passed_args, __pyx_v_required_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_extra_args = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":133
 *         extra_args = passed_args - required_args
 * 
 *         error_message = f'expected {required_args} keyword arguments'             # <<<<<<<<<<<<<<
 *         error_message += f', got {passed_args}'
 * 
 */
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = 0;
  __pyx_t_8 = 127;
  __Pyx_INCREF(__pyx_kp_u_expected);
  __pyx_t_2 += 9;
  __Pyx_GIVEREF(__pyx_kp_u_expected);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_expected);
  __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_v_required_args, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_8;
  __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
  __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_kp_u_keyword_arguments);
  __pyx_t_2 += 18;
  __Pyx_GIVEREF(__pyx_kp_u_keyword_arguments);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_keyword_arguments);
  __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_error_message = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":134
 * 
 *         error_message = f'expected {required_args} keyword arguments'
 *         error_message += f', got {passed_args}'             # <<<<<<<<<<<<<<
 * 
 *         missed_args = set(required_args) - set(passed_args)
 */
  __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_v_passed_args, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_got, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyUnicode_Concat(__pyx_v_error_message, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_error_message, ((PyObject*)__pyx_t_5));
  __pyx_t_5 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":136
 *         error_message += f', got {passed_args}'
 * 
 *         missed_args = set(required_args) - set(passed_args)             # <<<<<<<<<<<<<<
 *         if missed_args:
 *             error_message += f', missed {missed_args}'
 */
  __pyx_t_5 = PySet_New(__pyx_v_required_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PySet_New(__pyx_v_passed_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyNumber_Subtract(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_missed_args, __pyx_t_7);
  __pyx_t_7 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":137
 * 
 *         missed_args = set(required_args) - set(passed_args)
 *         if missed_args:             # <<<<<<<<<<<<<<
 *             error_message += f', missed {missed_args}'
 * 
 */
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_missed_args); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(3, 137, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "edgedb/protocol/codecs/namedtuple.pyx":138
 *         missed_args = set(required_args) - set(passed_args)
 *         if missed_args:
 *             error_message += f', missed {missed_args}'             # <<<<<<<<<<<<<<
 * 
 *         extra_args = set(passed_args) - set(required_args)
 */
    __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_v_missed_args, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_missed, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyUnicode_Concat(__pyx_v_error_message, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_error_message, ((PyObject*)__pyx_t_7));
    __pyx_t_7 = 0;

    /* "edgedb/protocol/codecs/namedtuple.pyx":137
 * 
 *         missed_args = set(required_args) - set(passed_args)
 *         if missed_args:             # <<<<<<<<<<<<<<
 *             error_message += f', missed {missed_args}'
 * 
 */
  }

  /* "edgedb/protocol/codecs/namedtuple.pyx":140
 *             error_message += f', missed {missed_args}'
 * 
 *         extra_args = set(passed_args) - set(required_args)             # <<<<<<<<<<<<<<
 *         if extra_args:
 *             error_message += f', extra {extra_args}'
 */
  __pyx_t_7 = PySet_New(__pyx_v_passed_args); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = PySet_New(__pyx_v_required_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyNumber_Subtract(__pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_extra_args, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":141
 * 
 *         extra_args = set(passed_args) - set(required_args)
 *         if extra_args:             # <<<<<<<<<<<<<<
 *             error_message += f', extra {extra_args}'
 * 
 */
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_extra_args); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(3, 141, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "edgedb/protocol/codecs/namedtuple.pyx":142
 *         extra_args = set(passed_args) - set(required_args)
 *         if extra_args:
 *             error_message += f', extra {extra_args}'             # <<<<<<<<<<<<<<
 * 
 *         return errors.QueryArgumentError(error_message)
 */
    __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_v_extra_args, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 142, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_extra, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 142, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyUnicode_Concat(__pyx_v_error_message, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 142, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_error_message, ((PyObject*)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "edgedb/protocol/codecs/namedtuple.pyx":141
 * 
 *         extra_args = set(passed_args) - set(required_args)
 *         if extra_args:             # <<<<<<<<<<<<<<
 *             error_message += f', extra {extra_args}'
 * 
 */
  }

  /* "edgedb/protocol/codecs/namedtuple.pyx":144
 *             error_message += f', extra {extra_args}'
 * 
 *         return errors.QueryArgumentError(error_message)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_errors); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_QueryArgumentError); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_5 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_1, __pyx_v_error_message) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_error_message);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":122
 *         return codec
 * 
 *     def _make_missing_args_error_message(self, args):             # <<<<<<<<<<<<<<
 *         required_args = set()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("edgedb.protocol.protocol.NamedTupleCodec._make_missing_args_error_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_required_args);
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_passed_args);
  __Pyx_XDECREF(__pyx_v_missed_args);
  __Pyx_XDECREF(__pyx_v_extra_args);
  __Pyx_XDECREF(__pyx_v_error_message);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_15NamedTupleCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_15NamedTupleCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_15NamedTupleCodec_2__reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_15NamedTupleCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.NamedTupleCodec.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_15NamedTupleCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_15NamedTupleCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_15NamedTupleCodec_4__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_15NamedTupleCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.NamedTupleCodec.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/object.pyx":23
 * cdef class ObjectCodec(BaseNamedRecordCodec):
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_encode(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *__pyx_v_self, CYTHON_UNUSED struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, CYTHON_UNUSED PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("encode", 0);

  /* "edgedb/protocol/codecs/object.pyx":24
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef encode_args(self, WriteBuffer buf, dict obj):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
  __PYX_ERR(8, 24, __pyx_L1_error)

  /* "edgedb/protocol/codecs/object.pyx":23
 * cdef class ObjectCodec(BaseNamedRecordCodec):
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.ObjectCodec.encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/object.pyx":26
 *         raise NotImplementedError
 * 
 *     cdef encode_args(self, WriteBuffer buf, dict obj):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer elem_data
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_encode_args(struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_elem_data = 0;
  Py_ssize_t __pyx_v_objlen;
  Py_ssize_t __pyx_v_i;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_sub_codec = 0;
  PyObject *__pyx_v_descriptor = 0;
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_arg = NULL;
  PyObject *__pyx_v_card = NULL;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_v_value_repr = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  Py_ssize_t __pyx_t_16;
  Py_UCS4 __pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  int __pyx_t_19;
  char const *__pyx_t_20;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  int32_t __pyx_t_27;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("encode_args", 0);

  /* "edgedb/protocol/codecs/object.pyx":32
 *             Py_ssize_t i
 *             BaseCodec sub_codec
 *             descriptor = (<BaseNamedRecordCodec>self).descriptor             # <<<<<<<<<<<<<<
 * 
 *         self._check_encoder()
 */
  __pyx_t_1 = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *)__pyx_v_self)->descriptor;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_descriptor = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/object.pyx":34
 *             descriptor = (<BaseNamedRecordCodec>self).descriptor
 * 
 *         self._check_encoder()             # <<<<<<<<<<<<<<
 * 
 *         objlen = len(obj)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_ObjectCodec *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._check_encoder(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 34, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/object.pyx":36
 *         self._check_encoder()
 * 
 *         objlen = len(obj)             # <<<<<<<<<<<<<<
 *         if objlen != len(self.fields_codecs):
 *             raise self._make_missing_args_error_message(obj)
 */
  if (unlikely(__pyx_v_obj == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(8, 36, __pyx_L1_error)
  }
  __pyx_t_2 = PyDict_Size(__pyx_v_obj); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(8, 36, __pyx_L1_error)
  __pyx_v_objlen = __pyx_t_2;

  /* "edgedb/protocol/codecs/object.pyx":37
 * 
 *         objlen = len(obj)
 *         if objlen != len(self.fields_codecs):             # <<<<<<<<<<<<<<
 *             raise self._make_missing_args_error_message(obj)
 * 
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.__pyx_base.fields_codecs;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(8, 37, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(8, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((__pyx_v_objlen != __pyx_t_2) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "edgedb/protocol/codecs/object.pyx":38
 *         objlen = len(obj)
 *         if objlen != len(self.fields_codecs):
 *             raise self._make_missing_args_error_message(obj)             # <<<<<<<<<<<<<<
 * 
 *         elem_data = WriteBuffer.new()
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_make_missing_args_error_message); if (unlikely(!__pyx_t_4)) __PYX_ERR(8, 38, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_obj) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_obj);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 38, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(8, 38, __pyx_L1_error)

    /* "edgedb/protocol/codecs/object.pyx":37
 * 
 *         objlen = len(obj)
 *         if objlen != len(self.fields_codecs):             # <<<<<<<<<<<<<<
 *             raise self._make_missing_args_error_message(obj)
 * 
 */
  }

  /* "edgedb/protocol/codecs/object.pyx":40
 *             raise self._make_missing_args_error_message(obj)
 * 
 *         elem_data = WriteBuffer.new()             # <<<<<<<<<<<<<<
 *         for i in range(objlen):
 *             name = datatypes.record_desc_pointer_name(descriptor, i)
 */
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_elem_data = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/object.pyx":41
 * 
 *         elem_data = WriteBuffer.new()
 *         for i in range(objlen):             # <<<<<<<<<<<<<<
 *             name = datatypes.record_desc_pointer_name(descriptor, i)
 *             try:
 */
  __pyx_t_2 = __pyx_v_objlen;
  __pyx_t_6 = __pyx_t_2;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;

    /* "edgedb/protocol/codecs/object.pyx":42
 *         elem_data = WriteBuffer.new()
 *         for i in range(objlen):
 *             name = datatypes.record_desc_pointer_name(descriptor, i)             # <<<<<<<<<<<<<<
 *             try:
 *                 arg = obj[name]
 */
    __pyx_t_1 = __pyx_f_6edgedb_9datatypes_9datatypes_record_desc_pointer_name(__pyx_v_descriptor, __pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 42, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/object.pyx":43
 *         for i in range(objlen):
 *             name = datatypes.record_desc_pointer_name(descriptor, i)
 *             try:             # <<<<<<<<<<<<<<
 *                 arg = obj[name]
 *             except KeyError:
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      /*try:*/ {

        /* "edgedb/protocol/codecs/object.pyx":44
 *             name = datatypes.record_desc_pointer_name(descriptor, i)
 *             try:
 *                 arg = obj[name]             # <<<<<<<<<<<<<<
 *             except KeyError:
 *                 raise self._make_missing_args_error_message(obj) from None
 */
        if (unlikely(__pyx_v_obj == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(8, 44, __pyx_L6_error)
        }
        __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_obj, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 44, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "edgedb/protocol/codecs/object.pyx":43
 *         for i in range(objlen):
 *             name = datatypes.record_desc_pointer_name(descriptor, i)
 *             try:             # <<<<<<<<<<<<<<
 *                 arg = obj[name]
 *             except KeyError:
 */
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L13_try_end;
      __pyx_L6_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "edgedb/protocol/codecs/object.pyx":45
 *             try:
 *                 arg = obj[name]
 *             except KeyError:             # <<<<<<<<<<<<<<
 *                 raise self._make_missing_args_error_message(obj) from None
 * 
 */
      __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
      if (__pyx_t_11) {
        __Pyx_AddTraceback("edgedb.protocol.protocol.ObjectCodec.encode_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_5) < 0) __PYX_ERR(8, 45, __pyx_L8_except_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_5);

        /* "edgedb/protocol/codecs/object.pyx":46
 *                 arg = obj[name]
 *             except KeyError:
 *                 raise self._make_missing_args_error_message(obj) from None             # <<<<<<<<<<<<<<
 * 
 *             card = datatypes.record_desc_pointer_card(descriptor, i)
 */
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_make_missing_args_error_message); if (unlikely(!__pyx_t_13)) __PYX_ERR(8, 46, __pyx_L8_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_14 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
          if (likely(__pyx_t_14)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
            __Pyx_INCREF(__pyx_t_14);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_13, function);
          }
        }
        __pyx_t_12 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_14, __pyx_v_obj) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_v_obj);
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        if (unlikely(!__pyx_t_12)) __PYX_ERR(8, 46, __pyx_L8_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_Raise(__pyx_t_12, 0, 0, Py_None);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __PYX_ERR(8, 46, __pyx_L8_except_error)
      }
      goto __pyx_L8_except_error;
      __pyx_L8_except_error:;

      /* "edgedb/protocol/codecs/object.pyx":43
 *         for i in range(objlen):
 *             name = datatypes.record_desc_pointer_name(descriptor, i)
 *             try:             # <<<<<<<<<<<<<<
 *                 arg = obj[name]
 *             except KeyError:
 */
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      goto __pyx_L1_error;
      __pyx_L13_try_end:;
    }

    /* "edgedb/protocol/codecs/object.pyx":48
 *                 raise self._make_missing_args_error_message(obj) from None
 * 
 *             card = datatypes.record_desc_pointer_card(descriptor, i)             # <<<<<<<<<<<<<<
 * 
 *             elem_data.write_int32(0)  # reserved bytes
 */
    __pyx_t_5 = __pyx_f_6edgedb_9datatypes_9datatypes_record_desc_pointer_card(__pyx_v_descriptor, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(8, 48, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XDECREF_SET(__pyx_v_card, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "edgedb/protocol/codecs/object.pyx":50
 *             card = datatypes.record_desc_pointer_card(descriptor, i)
 * 
 *             elem_data.write_int32(0)  # reserved bytes             # <<<<<<<<<<<<<<
 *             if arg is None:
 *                 if card in {datatypes.EdgeFieldCardinality.ONE,
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_elem_data->__pyx_vtab)->write_int32(__pyx_v_elem_data, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(8, 50, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "edgedb/protocol/codecs/object.pyx":51
 * 
 *             elem_data.write_int32(0)  # reserved bytes
 *             if arg is None:             # <<<<<<<<<<<<<<
 *                 if card in {datatypes.EdgeFieldCardinality.ONE,
 *                             datatypes.EdgeFieldCardinality.AT_LEAST_ONE}:
 */
    __pyx_t_3 = (__pyx_v_arg == Py_None);
    __pyx_t_15 = (__pyx_t_3 != 0);
    if (__pyx_t_15) {

      /* "edgedb/protocol/codecs/object.pyx":52
 *             elem_data.write_int32(0)  # reserved bytes
 *             if arg is None:
 *                 if card in {datatypes.EdgeFieldCardinality.ONE,             # <<<<<<<<<<<<<<
 *                             datatypes.EdgeFieldCardinality.AT_LEAST_ONE}:
 *                     raise errors.InvalidArgumentError(
 */
      __Pyx_INCREF(__pyx_v_card);
      __pyx_t_5 = __pyx_v_card;
      __pyx_t_4 = __Pyx_PyInt_From_EdgeFieldCardinality(ONE); if (unlikely(!__pyx_t_4)) __PYX_ERR(8, 52, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_5, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 52, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(8, 52, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!__pyx_t_3) {
      } else {
        __pyx_t_15 = __pyx_t_3;
        goto __pyx_L18_bool_binop_done;
      }

      /* "edgedb/protocol/codecs/object.pyx":53
 *             if arg is None:
 *                 if card in {datatypes.EdgeFieldCardinality.ONE,
 *                             datatypes.EdgeFieldCardinality.AT_LEAST_ONE}:             # <<<<<<<<<<<<<<
 *                     raise errors.InvalidArgumentError(
 *                         f'argument ${name} is required, but received None'
 */
      __pyx_t_1 = __Pyx_PyInt_From_EdgeFieldCardinality(AT_LEAST_ONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 53, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = PyObject_RichCompare(__pyx_t_5, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(8, 52, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "edgedb/protocol/codecs/object.pyx":52
 *             elem_data.write_int32(0)  # reserved bytes
 *             if arg is None:
 *                 if card in {datatypes.EdgeFieldCardinality.ONE,             # <<<<<<<<<<<<<<
 *                             datatypes.EdgeFieldCardinality.AT_LEAST_ONE}:
 *                     raise errors.InvalidArgumentError(
 */
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(8, 52, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_15 = __pyx_t_3;
      __pyx_L18_bool_binop_done:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_3 = (__pyx_t_15 != 0);
      if (unlikely(__pyx_t_3)) {

        /* "edgedb/protocol/codecs/object.pyx":54
 *                 if card in {datatypes.EdgeFieldCardinality.ONE,
 *                             datatypes.EdgeFieldCardinality.AT_LEAST_ONE}:
 *                     raise errors.InvalidArgumentError(             # <<<<<<<<<<<<<<
 *                         f'argument ${name} is required, but received None'
 *                     )
 */
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_errors); if (unlikely(!__pyx_t_4)) __PYX_ERR(8, 54, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_InvalidArgumentError); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 54, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "edgedb/protocol/codecs/object.pyx":55
 *                             datatypes.EdgeFieldCardinality.AT_LEAST_ONE}:
 *                     raise errors.InvalidArgumentError(
 *                         f'argument ${name} is required, but received None'             # <<<<<<<<<<<<<<
 *                     )
 *                 elem_data.write_int32(-1)
 */
        __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(8, 55, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_16 = 0;
        __pyx_t_17 = 127;
        __Pyx_INCREF(__pyx_kp_u_argument);
        __pyx_t_16 += 10;
        __Pyx_GIVEREF(__pyx_kp_u_argument);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_u_argument);
        __pyx_t_12 = __Pyx_PyObject_FormatSimple(__pyx_v_name, __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(8, 55, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) : __pyx_t_17;
        __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_12);
        __pyx_t_12 = 0;
        __Pyx_INCREF(__pyx_kp_u_is_required_but_received_None);
        __pyx_t_16 += 31;
        __Pyx_GIVEREF(__pyx_kp_u_is_required_but_received_None);
        PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_kp_u_is_required_but_received_None);
        __pyx_t_12 = __Pyx_PyUnicode_Join(__pyx_t_4, 3, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(8, 55, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_1, function);
          }
        }
        __pyx_t_5 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_12);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(8, 54, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_Raise(__pyx_t_5, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __PYX_ERR(8, 54, __pyx_L1_error)

        /* "edgedb/protocol/codecs/object.pyx":52
 *             elem_data.write_int32(0)  # reserved bytes
 *             if arg is None:
 *                 if card in {datatypes.EdgeFieldCardinality.ONE,             # <<<<<<<<<<<<<<
 *                             datatypes.EdgeFieldCardinality.AT_LEAST_ONE}:
 *                     raise errors.InvalidArgumentError(
 */
      }

      /* "edgedb/protocol/codecs/object.pyx":57
 *                         f'argument ${name} is required, but received None'
 *                     )
 *                 elem_data.write_int32(-1)             # <<<<<<<<<<<<<<
 *             else:
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])
 */
      __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_elem_data->__pyx_vtab)->write_int32(__pyx_v_elem_data, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(8, 57, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "edgedb/protocol/codecs/object.pyx":51
 * 
 *             elem_data.write_int32(0)  # reserved bytes
 *             if arg is None:             # <<<<<<<<<<<<<<
 *                 if card in {datatypes.EdgeFieldCardinality.ONE,
 *                             datatypes.EdgeFieldCardinality.AT_LEAST_ONE}:
 */
      goto __pyx_L16;
    }

    /* "edgedb/protocol/codecs/object.pyx":59
 *                 elem_data.write_int32(-1)
 *             else:
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])             # <<<<<<<<<<<<<<
 *                 try:
 *                     sub_codec.encode(elem_data, arg)
 */
    /*else*/ {
      if (unlikely(__pyx_v_self->__pyx_base.__pyx_base.fields_codecs == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(8, 59, __pyx_L1_error)
      }
      __pyx_t_5 = __Pyx_GetItemInt_Tuple(__pyx_v_self->__pyx_base.__pyx_base.fields_codecs, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(8, 59, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __pyx_t_5;
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF_SET(__pyx_v_sub_codec, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "edgedb/protocol/codecs/object.pyx":60
 *             else:
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])
 *                 try:             # <<<<<<<<<<<<<<
 *                     sub_codec.encode(elem_data, arg)
 *                 except (TypeError, ValueError) as e:
 */
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_8);
        /*try:*/ {

          /* "edgedb/protocol/codecs/object.pyx":61
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])
 *                 try:
 *                     sub_codec.encode(elem_data, arg)             # <<<<<<<<<<<<<<
 *                 except (TypeError, ValueError) as e:
 *                     value_repr = repr(arg)
 */
          __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_sub_codec->__pyx_vtab)->encode(__pyx_v_sub_codec, __pyx_v_elem_data, __pyx_v_arg); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 61, __pyx_L20_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "edgedb/protocol/codecs/object.pyx":60
 *             else:
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])
 *                 try:             # <<<<<<<<<<<<<<
 *                     sub_codec.encode(elem_data, arg)
 *                 except (TypeError, ValueError) as e:
 */
        }
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L27_try_end;
        __pyx_L20_error:;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "edgedb/protocol/codecs/object.pyx":62
 *                 try:
 *                     sub_codec.encode(elem_data, arg)
 *                 except (TypeError, ValueError) as e:             # <<<<<<<<<<<<<<
 *                     value_repr = repr(arg)
 *                     if len(value_repr) > 40:
 */
        __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
        if (__pyx_t_11) {
          __Pyx_AddTraceback("edgedb.protocol.protocol.ObjectCodec.encode_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_12) < 0) __PYX_ERR(8, 62, __pyx_L22_except_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_5);
          __pyx_v_e = __pyx_t_5;
          /*try:*/ {

            /* "edgedb/protocol/codecs/object.pyx":63
 *                     sub_codec.encode(elem_data, arg)
 *                 except (TypeError, ValueError) as e:
 *                     value_repr = repr(arg)             # <<<<<<<<<<<<<<
 *                     if len(value_repr) > 40:
 *                         value_repr = value_repr[:40] + '...'
 */
            __pyx_t_4 = PyObject_Repr(__pyx_v_arg); if (unlikely(!__pyx_t_4)) __PYX_ERR(8, 63, __pyx_L33_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_v_value_repr = __pyx_t_4;
            __pyx_t_4 = 0;

            /* "edgedb/protocol/codecs/object.pyx":64
 *                 except (TypeError, ValueError) as e:
 *                     value_repr = repr(arg)
 *                     if len(value_repr) > 40:             # <<<<<<<<<<<<<<
 *                         value_repr = value_repr[:40] + '...'
 *                     raise errors.InvalidArgumentError(
 */
            __pyx_t_16 = PyObject_Length(__pyx_v_value_repr); if (unlikely(__pyx_t_16 == ((Py_ssize_t)-1))) __PYX_ERR(8, 64, __pyx_L33_error)
            __pyx_t_3 = ((__pyx_t_16 > 40) != 0);
            if (__pyx_t_3) {

              /* "edgedb/protocol/codecs/object.pyx":65
 *                     value_repr = repr(arg)
 *                     if len(value_repr) > 40:
 *                         value_repr = value_repr[:40] + '...'             # <<<<<<<<<<<<<<
 *                     raise errors.InvalidArgumentError(
 *                         'invalid input for query argument'
 */
              __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_value_repr, 0, 40, NULL, NULL, &__pyx_slice__13, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(8, 65, __pyx_L33_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_13 = PyNumber_Add(__pyx_t_4, __pyx_kp_u__14); if (unlikely(!__pyx_t_13)) __PYX_ERR(8, 65, __pyx_L33_error)
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF_SET(__pyx_v_value_repr, __pyx_t_13);
              __pyx_t_13 = 0;

              /* "edgedb/protocol/codecs/object.pyx":64
 *                 except (TypeError, ValueError) as e:
 *                     value_repr = repr(arg)
 *                     if len(value_repr) > 40:             # <<<<<<<<<<<<<<
 *                         value_repr = value_repr[:40] + '...'
 *                     raise errors.InvalidArgumentError(
 */
            }

            /* "edgedb/protocol/codecs/object.pyx":66
 *                     if len(value_repr) > 40:
 *                         value_repr = value_repr[:40] + '...'
 *                     raise errors.InvalidArgumentError(             # <<<<<<<<<<<<<<
 *                         'invalid input for query argument'
 *                         f' ${name}: {value_repr} ({e})') from e
 */
            __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_errors); if (unlikely(!__pyx_t_4)) __PYX_ERR(8, 66, __pyx_L33_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_InvalidArgumentError); if (unlikely(!__pyx_t_14)) __PYX_ERR(8, 66, __pyx_L33_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

            /* "edgedb/protocol/codecs/object.pyx":67
 *                         value_repr = value_repr[:40] + '...'
 *                     raise errors.InvalidArgumentError(
 *                         'invalid input for query argument'             # <<<<<<<<<<<<<<
 *                         f' ${name}: {value_repr} ({e})') from e
 * 
 */
            __pyx_t_4 = PyTuple_New(7); if (unlikely(!__pyx_t_4)) __PYX_ERR(8, 67, __pyx_L33_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_16 = 0;
            __pyx_t_17 = 127;
            __Pyx_INCREF(__pyx_kp_u_invalid_input_for_query_argument_2);
            __pyx_t_16 += 34;
            __Pyx_GIVEREF(__pyx_kp_u_invalid_input_for_query_argument_2);
            PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_u_invalid_input_for_query_argument_2);

            /* "edgedb/protocol/codecs/object.pyx":68
 *                     raise errors.InvalidArgumentError(
 *                         'invalid input for query argument'
 *                         f' ${name}: {value_repr} ({e})') from e             # <<<<<<<<<<<<<<
 * 
 *         buf.write_int32(4 + elem_data.len())  # buffer length
 */
            __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_name, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(8, 68, __pyx_L33_error)
            __Pyx_GOTREF(__pyx_t_18);
            __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_17;
            __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18);
            __Pyx_GIVEREF(__pyx_t_18);
            PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_18);
            __pyx_t_18 = 0;
            __Pyx_INCREF(__pyx_kp_u__29);
            __pyx_t_16 += 2;
            __Pyx_GIVEREF(__pyx_kp_u__29);
            PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_kp_u__29);
            __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_value_repr, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(8, 68, __pyx_L33_error)
            __Pyx_GOTREF(__pyx_t_18);
            __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_17;
            __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18);
            __Pyx_GIVEREF(__pyx_t_18);
            PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_18);
            __pyx_t_18 = 0;
            __Pyx_INCREF(__pyx_kp_u__30);
            __pyx_t_16 += 2;
            __Pyx_GIVEREF(__pyx_kp_u__30);
            PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_kp_u__30);
            __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(8, 68, __pyx_L33_error)
            __Pyx_GOTREF(__pyx_t_18);
            __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_17;
            __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18);
            __Pyx_GIVEREF(__pyx_t_18);
            PyTuple_SET_ITEM(__pyx_t_4, 5, __pyx_t_18);
            __pyx_t_18 = 0;
            __Pyx_INCREF(__pyx_kp_u__31);
            __pyx_t_16 += 1;
            __Pyx_GIVEREF(__pyx_kp_u__31);
            PyTuple_SET_ITEM(__pyx_t_4, 6, __pyx_kp_u__31);

            /* "edgedb/protocol/codecs/object.pyx":67
 *                         value_repr = value_repr[:40] + '...'
 *                     raise errors.InvalidArgumentError(
 *                         'invalid input for query argument'             # <<<<<<<<<<<<<<
 *                         f' ${name}: {value_repr} ({e})') from e
 * 
 */
            __pyx_t_18 = __Pyx_PyUnicode_Join(__pyx_t_4, 7, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_18)) __PYX_ERR(8, 67, __pyx_L33_error)
            __Pyx_GOTREF(__pyx_t_18);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_4 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_14);
              if (likely(__pyx_t_4)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_14, function);
              }
            }
            __pyx_t_13 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_14, __pyx_t_4, __pyx_t_18) : __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_18);
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            if (unlikely(!__pyx_t_13)) __PYX_ERR(8, 66, __pyx_L33_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

            /* "edgedb/protocol/codecs/object.pyx":68
 *                     raise errors.InvalidArgumentError(
 *                         'invalid input for query argument'
 *                         f' ${name}: {value_repr} ({e})') from e             # <<<<<<<<<<<<<<
 * 
 *         buf.write_int32(4 + elem_data.len())  # buffer length
 */
            __Pyx_Raise(__pyx_t_13, 0, 0, __pyx_v_e);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __PYX_ERR(8, 66, __pyx_L33_error)
          }

          /* "edgedb/protocol/codecs/object.pyx":62
 *                 try:
 *                     sub_codec.encode(elem_data, arg)
 *                 except (TypeError, ValueError) as e:             # <<<<<<<<<<<<<<
 *                     value_repr = repr(arg)
 *                     if len(value_repr) > 40:
 */
          /*finally:*/ {
            __pyx_L33_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_declare
              __Pyx_PyThreadState_assign
              __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26);
              if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
              __Pyx_XGOTREF(__pyx_t_21);
              __Pyx_XGOTREF(__pyx_t_22);
              __Pyx_XGOTREF(__pyx_t_23);
              __Pyx_XGOTREF(__pyx_t_24);
              __Pyx_XGOTREF(__pyx_t_25);
              __Pyx_XGOTREF(__pyx_t_26);
              __pyx_t_11 = __pyx_lineno; __pyx_t_19 = __pyx_clineno; __pyx_t_20 = __pyx_filename;
              {
                __Pyx_DECREF(__pyx_v_e);
                __pyx_v_e = NULL;
              }
              if (PY_MAJOR_VERSION >= 3) {
                __Pyx_XGIVEREF(__pyx_t_24);
                __Pyx_XGIVEREF(__pyx_t_25);
                __Pyx_XGIVEREF(__pyx_t_26);
                __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26);
              }
              __Pyx_XGIVEREF(__pyx_t_21);
              __Pyx_XGIVEREF(__pyx_t_22);
              __Pyx_XGIVEREF(__pyx_t_23);
              __Pyx_ErrRestore(__pyx_t_21, __pyx_t_22, __pyx_t_23);
              __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
              __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_19; __pyx_filename = __pyx_t_20;
              goto __pyx_L22_except_error;
            }
          }
        }
        goto __pyx_L22_except_error;
        __pyx_L22_except_error:;

        /* "edgedb/protocol/codecs/object.pyx":60
 *             else:
 *                 sub_codec = <BaseCodec>(self.fields_codecs[i])
 *                 try:             # <<<<<<<<<<<<<<
 *                     sub_codec.encode(elem_data, arg)
 *                 except (TypeError, ValueError) as e:
 */
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_9, __pyx_t_8);
        goto __pyx_L1_error;
        __pyx_L27_try_end:;
      }
    }
    __pyx_L16:;
  }

  /* "edgedb/protocol/codecs/object.pyx":70
 *                         f' ${name}: {value_repr} ({e})') from e
 * 
 *         buf.write_int32(4 + elem_data.len())  # buffer length             # <<<<<<<<<<<<<<
 *         buf.write_int32(<int32_t><uint32_t>objlen)
 *         buf.write_buffer(elem_data)
 */
  __pyx_t_12 = __pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_len(__pyx_v_elem_data); if (unlikely(!__pyx_t_12)) __PYX_ERR(8, 70, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_5 = __Pyx_PyInt_AddCObj(__pyx_int_4, __pyx_t_12, 4, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(8, 70, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_27 = __Pyx_PyInt_As_int32_t(__pyx_t_5); if (unlikely((__pyx_t_27 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(8, 70, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, __pyx_t_27); if (unlikely(!__pyx_t_5)) __PYX_ERR(8, 70, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "edgedb/protocol/codecs/object.pyx":71
 * 
 *         buf.write_int32(4 + elem_data.len())  # buffer length
 *         buf.write_int32(<int32_t><uint32_t>objlen)             # <<<<<<<<<<<<<<
 *         buf.write_buffer(elem_data)
 * 
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, ((int32_t)((uint32_t)__pyx_v_objlen))); if (unlikely(!__pyx_t_5)) __PYX_ERR(8, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "edgedb/protocol/codecs/object.pyx":72
 *         buf.write_int32(4 + elem_data.len())  # buffer length
 *         buf.write_int32(<int32_t><uint32_t>objlen)
 *         buf.write_buffer(elem_data)             # <<<<<<<<<<<<<<
 * 
 *     def _make_missing_args_error_message(self, args):
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_buffer(__pyx_v_buf, __pyx_v_elem_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(8, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "edgedb/protocol/codecs/object.pyx":26
 *         raise NotImplementedError
 * 
 *     cdef encode_args(self, WriteBuffer buf, dict obj):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer elem_data
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ObjectCodec.encode_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_elem_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_sub_codec);
  __Pyx_XDECREF(__pyx_v_descriptor);
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_arg);
  __Pyx_XDECREF(__pyx_v_card);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XDECREF(__pyx_v_value_repr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/object.pyx":74
 *         buf.write_buffer(elem_data)
 * 
 *     def _make_missing_args_error_message(self, args):             # <<<<<<<<<<<<<<
 *         cdef descriptor = (<BaseNamedRecordCodec>self).descriptor
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_11ObjectCodec_1_make_missing_args_error_message(PyObject *__pyx_v_self, PyObject *__pyx_v_args); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_11ObjectCodec_1_make_missing_args_error_message(PyObject *__pyx_v_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_make_missing_args_error_message (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_11ObjectCodec__make_missing_args_error_message(((struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *)__pyx_v_self), ((PyObject *)__pyx_v_args));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_11ObjectCodec__make_missing_args_error_message(struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *__pyx_v_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_v_descriptor = 0;
  PyObject *__pyx_v_required_args = NULL;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_passed_args = NULL;
  PyObject *__pyx_v_missed_args = NULL;
  PyObject *__pyx_v_extra_args = NULL;
  PyObject *__pyx_v_error_message = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_UCS4 __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_make_missing_args_error_message", 0);

  /* "edgedb/protocol/codecs/object.pyx":75
 * 
 *     def _make_missing_args_error_message(self, args):
 *         cdef descriptor = (<BaseNamedRecordCodec>self).descriptor             # <<<<<<<<<<<<<<
 * 
 *         required_args = set()
 */
  __pyx_t_1 = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *)__pyx_v_self)->descriptor;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_descriptor = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/object.pyx":77
 *         cdef descriptor = (<BaseNamedRecordCodec>self).descriptor
 * 
 *         required_args = set()             # <<<<<<<<<<<<<<
 * 
 *         for i in range(len(self.fields_codecs)):
 */
  __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 77, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_required_args = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/object.pyx":79
 *         required_args = set()
 * 
 *         for i in range(len(self.fields_codecs)):             # <<<<<<<<<<<<<<
 *             name = datatypes.record_desc_pointer_name(descriptor, i)
 *             required_args.add(name)
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.__pyx_base.fields_codecs;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(8, 79, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(8, 79, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_t_2;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "edgedb/protocol/codecs/object.pyx":80
 * 
 *         for i in range(len(self.fields_codecs)):
 *             name = datatypes.record_desc_pointer_name(descriptor, i)             # <<<<<<<<<<<<<<
 *             required_args.add(name)
 * 
 */
    __pyx_t_1 = __pyx_f_6edgedb_9datatypes_9datatypes_record_desc_pointer_name(__pyx_v_descriptor, __pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 80, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/object.pyx":81
 *         for i in range(len(self.fields_codecs)):
 *             name = datatypes.record_desc_pointer_name(descriptor, i)
 *             required_args.add(name)             # <<<<<<<<<<<<<<
 * 
 *         passed_args = set(args.keys())
 */
    __pyx_t_5 = PySet_Add(__pyx_v_required_args, __pyx_v_name); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(8, 81, __pyx_L1_error)
  }

  /* "edgedb/protocol/codecs/object.pyx":83
 *             required_args.add(name)
 * 
 *         passed_args = set(args.keys())             # <<<<<<<<<<<<<<
 *         missed_args = required_args - passed_args
 *         extra_args = passed_args - required_args
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_args, __pyx_n_s_keys); if (unlikely(!__pyx_t_6)) __PYX_ERR(8, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PySet_New(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(8, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_passed_args = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "edgedb/protocol/codecs/object.pyx":84
 * 
 *         passed_args = set(args.keys())
 *         missed_args = required_args - passed_args             # <<<<<<<<<<<<<<
 *         extra_args = passed_args - required_args
 * 
 */
  __pyx_t_6 = PyNumber_Subtract(__pyx_v_required_args, __pyx_v_passed_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(8, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_missed_args = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "edgedb/protocol/codecs/object.pyx":85
 *         passed_args = set(args.keys())
 *         missed_args = required_args - passed_args
 *         extra_args = passed_args - required_args             # <<<<<<<<<<<<<<
 * 
 *         error_message = f'expected {required_args} arguments'
 */
  __pyx_t_6 = PyNumber_Subtract(__pyx_v_passed_args, __pyx_v_required_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(8, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_extra_args = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "edgedb/protocol/codecs/object.pyx":87
 *         extra_args = passed_args - required_args
 * 
 *         error_message = f'expected {required_args} arguments'             # <<<<<<<<<<<<<<
 *         error_message += f', got {passed_args}'
 * 
 */
  __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(8, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = 0;
  __pyx_t_8 = 127;
  __Pyx_INCREF(__pyx_kp_u_expected);
  __pyx_t_2 += 9;
  __Pyx_GIVEREF(__pyx_kp_u_expected);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_kp_u_expected);
  __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_v_required_args, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_8;
  __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __Pyx_INCREF(__pyx_kp_u_arguments);
  __pyx_t_2 += 10;
  __Pyx_GIVEREF(__pyx_kp_u_arguments);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_kp_u_arguments);
  __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_6, 3, __pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_error_message = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/object.pyx":88
 * 
 *         error_message = f'expected {required_args} arguments'
 *         error_message += f', got {passed_args}'             # <<<<<<<<<<<<<<
 * 
 *         missed_args = set(required_args) - set(passed_args)
 */
  __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_v_passed_args, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyUnicode_Concat(__pyx_kp_u_got, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(8, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_v_error_message, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_error_message, ((PyObject*)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/object.pyx":90
 *         error_message += f', got {passed_args}'
 * 
 *         missed_args = set(required_args) - set(passed_args)             # <<<<<<<<<<<<<<
 *         if missed_args:
 *             error_message += f', missed {missed_args}'
 */
  __pyx_t_1 = PySet_New(__pyx_v_required_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 90, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PySet_New(__pyx_v_passed_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(8, 90, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyNumber_Subtract(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(8, 90, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_missed_args, __pyx_t_7);
  __pyx_t_7 = 0;

  /* "edgedb/protocol/codecs/object.pyx":91
 * 
 *         missed_args = set(required_args) - set(passed_args)
 *         if missed_args:             # <<<<<<<<<<<<<<
 *             error_message += f', missed {missed_args}'
 * 
 */
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_missed_args); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(8, 91, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "edgedb/protocol/codecs/object.pyx":92
 *         missed_args = set(required_args) - set(passed_args)
 *         if missed_args:
 *             error_message += f', missed {missed_args}'             # <<<<<<<<<<<<<<
 * 
 *         extra_args = set(passed_args) - set(required_args)
 */
    __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_v_missed_args, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(8, 92, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = __Pyx_PyUnicode_Concat(__pyx_kp_u_missed, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(8, 92, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyUnicode_Concat(__pyx_v_error_message, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(8, 92, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_error_message, ((PyObject*)__pyx_t_7));
    __pyx_t_7 = 0;

    /* "edgedb/protocol/codecs/object.pyx":91
 * 
 *         missed_args = set(required_args) - set(passed_args)
 *         if missed_args:             # <<<<<<<<<<<<<<
 *             error_message += f', missed {missed_args}'
 * 
 */
  }

  /* "edgedb/protocol/codecs/object.pyx":94
 *             error_message += f', missed {missed_args}'
 * 
 *         extra_args = set(passed_args) - set(required_args)             # <<<<<<<<<<<<<<
 *         if extra_args:
 *             error_message += f', extra {extra_args}'
 */
  __pyx_t_7 = PySet_New(__pyx_v_passed_args); if (unlikely(!__pyx_t_7)) __PYX_ERR(8, 94, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = PySet_New(__pyx_v_required_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(8, 94, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 94, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_extra_args, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/object.pyx":95
 * 
 *         extra_args = set(passed_args) - set(required_args)
 *         if extra_args:             # <<<<<<<<<<<<<<
 *             error_message += f', extra {extra_args}'
 * 
 */
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_extra_args); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(8, 95, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "edgedb/protocol/codecs/object.pyx":96
 *         extra_args = set(passed_args) - set(required_args)
 *         if extra_args:
 *             error_message += f', extra {extra_args}'             # <<<<<<<<<<<<<<
 * 
 *         return errors.QueryArgumentError(error_message)
 */
    __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_v_extra_args, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 96, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyUnicode_Concat(__pyx_kp_u_extra, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(8, 96, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_v_error_message, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 96, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_error_message, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/object.pyx":95
 * 
 *         extra_args = set(passed_args) - set(required_args)
 *         if extra_args:             # <<<<<<<<<<<<<<
 *             error_message += f', extra {extra_args}'
 * 
 */
  }

  /* "edgedb/protocol/codecs/object.pyx":98
 *             error_message += f', extra {extra_args}'
 * 
 *         return errors.QueryArgumentError(error_message)             # <<<<<<<<<<<<<<
 * 
 *     cdef decode(self, FRBuffer *buf):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_errors); if (unlikely(!__pyx_t_6)) __PYX_ERR(8, 98, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_QueryArgumentError); if (unlikely(!__pyx_t_7)) __PYX_ERR(8, 98, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_6, __pyx_v_error_message) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_error_message);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 98, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/object.pyx":74
 *         buf.write_buffer(elem_data)
 * 
 *     def _make_missing_args_error_message(self, args):             # <<<<<<<<<<<<<<
 *         cdef descriptor = (<BaseNamedRecordCodec>self).descriptor
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ObjectCodec._make_missing_args_error_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_descriptor);
  __Pyx_XDECREF(__pyx_v_required_args);
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_passed_args);
  __Pyx_XDECREF(__pyx_v_missed_args);
  __Pyx_XDECREF(__pyx_v_extra_args);
  __Pyx_XDECREF(__pyx_v_error_message);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/object.pyx":100
 *         return errors.QueryArgumentError(error_message)
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         cdef:
 *             object result
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  PyObject *__pyx_v_result = 0;
  Py_ssize_t __pyx_v_elem_count;
  Py_ssize_t __pyx_v_i;
  int32_t __pyx_v_elem_len;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_elem_codec = 0;
  struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer __pyx_v_elem_buf;
  PyObject *__pyx_v_fields_codecs = 0;
  PyObject *__pyx_v_descriptor = 0;
  PyObject *__pyx_v_elem = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char const *__pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  Py_UCS4 __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("decode", 0);

  /* "edgedb/protocol/codecs/object.pyx":108
 *             BaseCodec elem_codec
 *             FRBuffer elem_buf
 *             tuple fields_codecs = (<BaseRecordCodec>self).fields_codecs             # <<<<<<<<<<<<<<
 *             descriptor = (<BaseNamedRecordCodec>self).descriptor
 * 
 */
  __pyx_t_1 = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *)__pyx_v_self)->fields_codecs;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_fields_codecs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/object.pyx":109
 *             FRBuffer elem_buf
 *             tuple fields_codecs = (<BaseRecordCodec>self).fields_codecs
 *             descriptor = (<BaseNamedRecordCodec>self).descriptor             # <<<<<<<<<<<<<<
 * 
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 */
  __pyx_t_1 = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *)__pyx_v_self)->descriptor;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_descriptor = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/object.pyx":111
 *             descriptor = (<BaseNamedRecordCodec>self).descriptor
 * 
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 * 
 *         if elem_count != len(fields_codecs):
 */
  __pyx_t_2 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == ((char const *)NULL))) __PYX_ERR(8, 111, __pyx_L1_error)
  __pyx_v_elem_count = ((Py_ssize_t)((uint32_t)unpack_int32(__pyx_t_2)));

  /* "edgedb/protocol/codecs/object.pyx":113
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 * 
 *         if elem_count != len(fields_codecs):             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'cannot decode Object: expected {len(fields_codecs)} '
 */
  if (unlikely(__pyx_v_fields_codecs == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(8, 113, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v_fields_codecs); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(8, 113, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_v_elem_count != __pyx_t_3) != 0);
  if (unlikely(__pyx_t_4)) {

    /* "edgedb/protocol/codecs/object.pyx":115
 *         if elem_count != len(fields_codecs):
 *             raise RuntimeError(
 *                 f'cannot decode Object: expected {len(fields_codecs)} '             # <<<<<<<<<<<<<<
 *                 f'elements, got {elem_count}')
 * 
 */
    __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 115, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = 0;
    __pyx_t_5 = 127;
    __Pyx_INCREF(__pyx_kp_u_cannot_decode_Object_expected);
    __pyx_t_3 += 31;
    __Pyx_GIVEREF(__pyx_kp_u_cannot_decode_Object_expected);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_cannot_decode_Object_expected);
    if (unlikely(__pyx_v_fields_codecs == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(8, 115, __pyx_L1_error)
    }
    __pyx_t_6 = PyTuple_GET_SIZE(__pyx_v_fields_codecs); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(8, 115, __pyx_L1_error)
    __pyx_t_7 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_6, 0, ' ', 'd'); if (unlikely(!__pyx_t_7)) __PYX_ERR(8, 115, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_INCREF(__pyx_kp_u_elements_got);
    __pyx_t_3 += 15;
    __Pyx_GIVEREF(__pyx_kp_u_elements_got);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_elements_got);

    /* "edgedb/protocol/codecs/object.pyx":116
 *             raise RuntimeError(
 *                 f'cannot decode Object: expected {len(fields_codecs)} '
 *                 f'elements, got {elem_count}')             # <<<<<<<<<<<<<<
 * 
 *         result = datatypes.object_new(descriptor)
 */
    __pyx_t_7 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_v_elem_count, 0, ' ', 'd'); if (unlikely(!__pyx_t_7)) __PYX_ERR(8, 116, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "edgedb/protocol/codecs/object.pyx":115
 *         if elem_count != len(fields_codecs):
 *             raise RuntimeError(
 *                 f'cannot decode Object: expected {len(fields_codecs)} '             # <<<<<<<<<<<<<<
 *                 f'elements, got {elem_count}')
 * 
 */
    __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_1, 4, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(8, 115, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/object.pyx":114
 * 
 *         if elem_count != len(fields_codecs):
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 f'cannot decode Object: expected {len(fields_codecs)} '
 *                 f'elements, got {elem_count}')
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 114, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(8, 114, __pyx_L1_error)

    /* "edgedb/protocol/codecs/object.pyx":113
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 * 
 *         if elem_count != len(fields_codecs):             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'cannot decode Object: expected {len(fields_codecs)} '
 */
  }

  /* "edgedb/protocol/codecs/object.pyx":118
 *                 f'elements, got {elem_count}')
 * 
 *         result = datatypes.object_new(descriptor)             # <<<<<<<<<<<<<<
 * 
 *         for i in range(elem_count):
 */
  __pyx_t_1 = __pyx_f_6edgedb_9datatypes_9datatypes_object_new(__pyx_v_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/object.pyx":120
 *         result = datatypes.object_new(descriptor)
 * 
 *         for i in range(elem_count):             # <<<<<<<<<<<<<<
 *             frb_read(buf, 4)  # reserved
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 */
  __pyx_t_3 = __pyx_v_elem_count;
  __pyx_t_6 = __pyx_t_3;
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_6; __pyx_t_8+=1) {
    __pyx_v_i = __pyx_t_8;

    /* "edgedb/protocol/codecs/object.pyx":121
 * 
 *         for i in range(elem_count):
 *             frb_read(buf, 4)  # reserved             # <<<<<<<<<<<<<<
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 * 
 */
    __pyx_t_2 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == ((char const *)NULL))) __PYX_ERR(8, 121, __pyx_L1_error)

    /* "edgedb/protocol/codecs/object.pyx":122
 *         for i in range(elem_count):
 *             frb_read(buf, 4)  # reserved
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 * 
 *             if elem_len == -1:
 */
    __pyx_t_2 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_2 == ((char const *)NULL))) __PYX_ERR(8, 122, __pyx_L1_error)
    __pyx_v_elem_len = unpack_int32(__pyx_t_2);

    /* "edgedb/protocol/codecs/object.pyx":124
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 * 
 *             if elem_len == -1:             # <<<<<<<<<<<<<<
 *                 elem = None
 *             else:
 */
    __pyx_t_4 = ((__pyx_v_elem_len == -1L) != 0);
    if (__pyx_t_4) {

      /* "edgedb/protocol/codecs/object.pyx":125
 * 
 *             if elem_len == -1:
 *                 elem = None             # <<<<<<<<<<<<<<
 *             else:
 *                 elem_codec = <BaseCodec>fields_codecs[i]
 */
      __Pyx_INCREF(Py_None);
      __Pyx_XDECREF_SET(__pyx_v_elem, Py_None);

      /* "edgedb/protocol/codecs/object.pyx":124
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 * 
 *             if elem_len == -1:             # <<<<<<<<<<<<<<
 *                 elem = None
 *             else:
 */
      goto __pyx_L6;
    }

    /* "edgedb/protocol/codecs/object.pyx":127
 *                 elem = None
 *             else:
 *                 elem_codec = <BaseCodec>fields_codecs[i]             # <<<<<<<<<<<<<<
 *                 elem = elem_codec.decode(
 *                     frb_slice_from(&elem_buf, buf, elem_len))
 */
    /*else*/ {
      if (unlikely(__pyx_v_fields_codecs == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(8, 127, __pyx_L1_error)
      }
      __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_fields_codecs, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 127, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = __pyx_t_1;
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF_SET(__pyx_v_elem_codec, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_7));
      __pyx_t_7 = 0;

      /* "edgedb/protocol/codecs/object.pyx":128
 *             else:
 *                 elem_codec = <BaseCodec>fields_codecs[i]
 *                 elem = elem_codec.decode(             # <<<<<<<<<<<<<<
 *                     frb_slice_from(&elem_buf, buf, elem_len))
 *                 if frb_get_len(&elem_buf):
 */
      __pyx_t_7 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_elem_codec->__pyx_vtab)->decode(__pyx_v_elem_codec, __pyx_f_6edgedb_7pgproto_7pgproto_frb_slice_from((&__pyx_v_elem_buf), __pyx_v_buf, __pyx_v_elem_len)); if (unlikely(!__pyx_t_7)) __PYX_ERR(8, 128, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "edgedb/protocol/codecs/object.pyx":130
 *                 elem = elem_codec.decode(
 *                     frb_slice_from(&elem_buf, buf, elem_len))
 *                 if frb_get_len(&elem_buf):             # <<<<<<<<<<<<<<
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after '
 */
      __pyx_t_4 = (__pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len((&__pyx_v_elem_buf)) != 0);
      if (unlikely(__pyx_t_4)) {

        /* "edgedb/protocol/codecs/object.pyx":133
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after '
 *                         f'object element decoding: {frb_get_len(&elem_buf)}')             # <<<<<<<<<<<<<<
 * 
 *             datatypes.object_set(result, i, elem)
 */
        __pyx_t_7 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len((&__pyx_v_elem_buf)), 0, ' ', 'd'); if (unlikely(!__pyx_t_7)) __PYX_ERR(8, 133, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);

        /* "edgedb/protocol/codecs/object.pyx":132
 *                 if frb_get_len(&elem_buf):
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after '             # <<<<<<<<<<<<<<
 *                         f'object element decoding: {frb_get_len(&elem_buf)}')
 * 
 */
        __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_unexpected_trailing_data_in_buff_3, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 132, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "edgedb/protocol/codecs/object.pyx":131
 *                     frb_slice_from(&elem_buf, buf, elem_len))
 *                 if frb_get_len(&elem_buf):
 *                     raise RuntimeError(             # <<<<<<<<<<<<<<
 *                         f'unexpected trailing data in buffer after '
 *                         f'object element decoding: {frb_get_len(&elem_buf)}')
 */
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(8, 131, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_Raise(__pyx_t_7, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __PYX_ERR(8, 131, __pyx_L1_error)

        /* "edgedb/protocol/codecs/object.pyx":130
 *                 elem = elem_codec.decode(
 *                     frb_slice_from(&elem_buf, buf, elem_len))
 *                 if frb_get_len(&elem_buf):             # <<<<<<<<<<<<<<
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after '
 */
      }
    }
    __pyx_L6:;

    /* "edgedb/protocol/codecs/object.pyx":135
 *                         f'object element decoding: {frb_get_len(&elem_buf)}')
 * 
 *             datatypes.object_set(result, i, elem)             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
    __pyx_t_7 = __pyx_f_6edgedb_9datatypes_9datatypes_object_set(__pyx_v_result, __pyx_v_i, __pyx_v_elem); if (unlikely(!__pyx_t_7)) __PYX_ERR(8, 135, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }

  /* "edgedb/protocol/codecs/object.pyx":137
 *             datatypes.object_set(result, i, elem)
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/object.pyx":100
 *         return errors.QueryArgumentError(error_message)
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         cdef:
 *             object result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ObjectCodec.decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF((PyObject *)__pyx_v_elem_codec);
  __Pyx_XDECREF(__pyx_v_fields_codecs);
  __Pyx_XDECREF(__pyx_v_descriptor);
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/object.pyx":140
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid, tuple names, tuple flags, tuple cards,             # <<<<<<<<<<<<<<
 *                        tuple codecs):
 *         cdef:
 */

static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_new(PyObject *__pyx_v_tid, PyObject *__pyx_v_names, PyObject *__pyx_v_flags, PyObject *__pyx_v_cards, PyObject *__pyx_v_codecs) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *__pyx_v_codec = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("new", 0);

  /* "edgedb/protocol/codecs/object.pyx":145
 *             ObjectCodec codec
 * 
 *         codec = ObjectCodec.__new__(ObjectCodec)             # <<<<<<<<<<<<<<
 * 
 *         codec.tid = tid
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_6edgedb_8protocol_8protocol_ObjectCodec(((PyTypeObject *)__pyx_ptype_6edgedb_8protocol_8protocol_ObjectCodec), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 145, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/object.pyx":147
 *         codec = ObjectCodec.__new__(ObjectCodec)
 * 
 *         codec.tid = tid             # <<<<<<<<<<<<<<
 *         codec.name = 'Object'
 *         codec.descriptor = datatypes.record_desc_new(names, flags, cards)
 */
  __Pyx_INCREF(__pyx_v_tid);
  __Pyx_GIVEREF(__pyx_v_tid);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.__pyx_base.__pyx_base.tid);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.__pyx_base.__pyx_base.tid);
  __pyx_v_codec->__pyx_base.__pyx_base.__pyx_base.tid = __pyx_v_tid;

  /* "edgedb/protocol/codecs/object.pyx":148
 * 
 *         codec.tid = tid
 *         codec.name = 'Object'             # <<<<<<<<<<<<<<
 *         codec.descriptor = datatypes.record_desc_new(names, flags, cards)
 *         codec.fields_codecs = codecs
 */
  __Pyx_INCREF(__pyx_n_u_Object);
  __Pyx_GIVEREF(__pyx_n_u_Object);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.__pyx_base.__pyx_base.name);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.__pyx_base.__pyx_base.name);
  __pyx_v_codec->__pyx_base.__pyx_base.__pyx_base.name = __pyx_n_u_Object;

  /* "edgedb/protocol/codecs/object.pyx":149
 *         codec.tid = tid
 *         codec.name = 'Object'
 *         codec.descriptor = datatypes.record_desc_new(names, flags, cards)             # <<<<<<<<<<<<<<
 *         codec.fields_codecs = codecs
 * 
 */
  __pyx_t_1 = __pyx_f_6edgedb_9datatypes_9datatypes_record_desc_new(__pyx_v_names, __pyx_v_flags, __pyx_v_cards); if (unlikely(!__pyx_t_1)) __PYX_ERR(8, 149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.descriptor);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.descriptor);
  __pyx_v_codec->__pyx_base.descriptor = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/object.pyx":150
 *         codec.name = 'Object'
 *         codec.descriptor = datatypes.record_desc_new(names, flags, cards)
 *         codec.fields_codecs = codecs             # <<<<<<<<<<<<<<
 * 
 *         return codec
 */
  __Pyx_INCREF(__pyx_v_codecs);
  __Pyx_GIVEREF(__pyx_v_codecs);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.__pyx_base.fields_codecs);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.__pyx_base.fields_codecs);
  __pyx_v_codec->__pyx_base.__pyx_base.fields_codecs = __pyx_v_codecs;

  /* "edgedb/protocol/codecs/object.pyx":152
 *         codec.fields_codecs = codecs
 * 
 *         return codec             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_codec));
  __pyx_r = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_codec);
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/object.pyx":140
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid, tuple names, tuple flags, tuple cards,             # <<<<<<<<<<<<<<
 *                        tuple codecs):
 *         cdef:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ObjectCodec.new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_11ObjectCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_11ObjectCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_11ObjectCodec_2__reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_11ObjectCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ObjectCodec.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_11ObjectCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_11ObjectCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_11ObjectCodec_4__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_11ObjectCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ObjectCodec.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/array.pyx":29
 *     # Base codec for arrays & sets.
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.sub_codec = None
 *         self.cardinality = -1
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_14BaseArrayCodec_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_14BaseArrayCodec_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14BaseArrayCodec___cinit__(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_14BaseArrayCodec___cinit__(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "edgedb/protocol/codecs/array.pyx":30
 * 
 *     def __cinit__(self):
 *         self.sub_codec = None             # <<<<<<<<<<<<<<
 *         self.cardinality = -1
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->sub_codec);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->sub_codec));
  __pyx_v_self->sub_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)Py_None);

  /* "edgedb/protocol/codecs/array.pyx":31
 *     def __cinit__(self):
 *         self.sub_codec = None
 *         self.cardinality = -1             # <<<<<<<<<<<<<<
 * 
 *     cdef _new_collection(self, Py_ssize_t size):
 */
  __pyx_v_self->cardinality = -1;

  /* "edgedb/protocol/codecs/array.pyx":29
 *     # Base codec for arrays & sets.
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.sub_codec = None
 *         self.cardinality = -1
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/array.pyx":33
 *         self.cardinality = -1
 * 
 *     cdef _new_collection(self, Py_ssize_t size):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec__new_collection(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self, CYTHON_UNUSED Py_ssize_t __pyx_v_size) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_new_collection", 0);

  /* "edgedb/protocol/codecs/array.pyx":34
 * 
 *     cdef _new_collection(self, Py_ssize_t size):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef _set_collection_item(self, object collection, Py_ssize_t i,
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
  __PYX_ERR(9, 34, __pyx_L1_error)

  /* "edgedb/protocol/codecs/array.pyx":33
 *         self.cardinality = -1
 * 
 *     cdef _new_collection(self, Py_ssize_t size):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseArrayCodec._new_collection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/array.pyx":36
 *         raise NotImplementedError
 * 
 *     cdef _set_collection_item(self, object collection, Py_ssize_t i,             # <<<<<<<<<<<<<<
 *                               object element):
 *         raise NotImplementedError
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec__set_collection_item(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_collection, CYTHON_UNUSED Py_ssize_t __pyx_v_i, CYTHON_UNUSED PyObject *__pyx_v_element) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_set_collection_item", 0);

  /* "edgedb/protocol/codecs/array.pyx":38
 *     cdef _set_collection_item(self, object collection, Py_ssize_t i,
 *                               object element):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
  __PYX_ERR(9, 38, __pyx_L1_error)

  /* "edgedb/protocol/codecs/array.pyx":36
 *         raise NotImplementedError
 * 
 *     cdef _set_collection_item(self, object collection, Py_ssize_t i,             # <<<<<<<<<<<<<<
 *                               object element):
 *         raise NotImplementedError
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseArrayCodec._set_collection_item", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/array.pyx":40
 *         raise NotImplementedError
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer elem_data
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec_encode(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_elem_data = 0;
  int32_t __pyx_v_ndims;
  Py_ssize_t __pyx_v_objlen;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_item = NULL;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_t_17;
  char const *__pyx_t_18;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  int32_t __pyx_t_25;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("encode", 0);

  /* "edgedb/protocol/codecs/array.pyx":43
 *         cdef:
 *             WriteBuffer elem_data
 *             int32_t ndims = 1             # <<<<<<<<<<<<<<
 *             Py_ssize_t objlen
 *             Py_ssize_t i
 */
  __pyx_v_ndims = 1;

  /* "edgedb/protocol/codecs/array.pyx":47
 *             Py_ssize_t i
 * 
 *         if not isinstance(self.sub_codec, ScalarCodec):             # <<<<<<<<<<<<<<
 *             raise TypeError('only arrays of scalars are supported')
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->sub_codec);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_t_1, __pyx_ptype_6edgedb_8protocol_8protocol_ScalarCodec); 
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((!(__pyx_t_2 != 0)) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "edgedb/protocol/codecs/array.pyx":48
 * 
 *         if not isinstance(self.sub_codec, ScalarCodec):
 *             raise TypeError('only arrays of scalars are supported')             # <<<<<<<<<<<<<<
 * 
 *         if not _is_array_iterable(obj):
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 48, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(9, 48, __pyx_L1_error)

    /* "edgedb/protocol/codecs/array.pyx":47
 *             Py_ssize_t i
 * 
 *         if not isinstance(self.sub_codec, ScalarCodec):             # <<<<<<<<<<<<<<
 *             raise TypeError('only arrays of scalars are supported')
 * 
 */
  }

  /* "edgedb/protocol/codecs/array.pyx":50
 *             raise TypeError('only arrays of scalars are supported')
 * 
 *         if not _is_array_iterable(obj):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'a sized iterable container expected (got type {!r})'.format(
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol__is_array_iterable(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(9, 50, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = ((!__pyx_t_3) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/codecs/array.pyx":52
 *         if not _is_array_iterable(obj):
 *             raise TypeError(
 *                 'a sized iterable container expected (got type {!r})'.format(             # <<<<<<<<<<<<<<
 *                     type(obj).__name__))
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_a_sized_iterable_container_expec, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 52, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "edgedb/protocol/codecs/array.pyx":53
 *             raise TypeError(
 *                 'a sized iterable container expected (got type {!r})'.format(
 *                     type(obj).__name__))             # <<<<<<<<<<<<<<
 * 
 *         objlen = len(obj)
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_obj)), __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(9, 53, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 52, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "edgedb/protocol/codecs/array.pyx":51
 * 
 *         if not _is_array_iterable(obj):
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'a sized iterable container expected (got type {!r})'.format(
 *                     type(obj).__name__))
 */
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 51, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(9, 51, __pyx_L1_error)

    /* "edgedb/protocol/codecs/array.pyx":50
 *             raise TypeError('only arrays of scalars are supported')
 * 
 *         if not _is_array_iterable(obj):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 'a sized iterable container expected (got type {!r})'.format(
 */
  }

  /* "edgedb/protocol/codecs/array.pyx":55
 *                     type(obj).__name__))
 * 
 *         objlen = len(obj)             # <<<<<<<<<<<<<<
 *         if objlen > _MAXINT32:
 *             raise ValueError('too many elements in array value')
 */
  __pyx_t_7 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(9, 55, __pyx_L1_error)
  __pyx_v_objlen = __pyx_t_7;

  /* "edgedb/protocol/codecs/array.pyx":56
 * 
 *         objlen = len(obj)
 *         if objlen > _MAXINT32:             # <<<<<<<<<<<<<<
 *             raise ValueError('too many elements in array value')
 * 
 */
  __pyx_t_2 = ((__pyx_v_objlen > 0x7FFFFFFF) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/codecs/array.pyx":57
 *         objlen = len(obj)
 *         if objlen > _MAXINT32:
 *             raise ValueError('too many elements in array value')             # <<<<<<<<<<<<<<
 * 
 *         elem_data = WriteBuffer.new()
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 57, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(9, 57, __pyx_L1_error)

    /* "edgedb/protocol/codecs/array.pyx":56
 * 
 *         objlen = len(obj)
 *         if objlen > _MAXINT32:             # <<<<<<<<<<<<<<
 *             raise ValueError('too many elements in array value')
 * 
 */
  }

  /* "edgedb/protocol/codecs/array.pyx":59
 *             raise ValueError('too many elements in array value')
 * 
 *         elem_data = WriteBuffer.new()             # <<<<<<<<<<<<<<
 *         for i in range(objlen):
 *             item = obj[i]
 */
  __pyx_t_4 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new()); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_elem_data = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "edgedb/protocol/codecs/array.pyx":60
 * 
 *         elem_data = WriteBuffer.new()
 *         for i in range(objlen):             # <<<<<<<<<<<<<<
 *             item = obj[i]
 *             if item is None:
 */
  __pyx_t_7 = __pyx_v_objlen;
  __pyx_t_8 = __pyx_t_7;
  for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
    __pyx_v_i = __pyx_t_9;

    /* "edgedb/protocol/codecs/array.pyx":61
 *         elem_data = WriteBuffer.new()
 *         for i in range(objlen):
 *             item = obj[i]             # <<<<<<<<<<<<<<
 *             if item is None:
 *                 elem_data.write_int32(-1)
 */
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_obj, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "edgedb/protocol/codecs/array.pyx":62
 *         for i in range(objlen):
 *             item = obj[i]
 *             if item is None:             # <<<<<<<<<<<<<<
 *                 elem_data.write_int32(-1)
 *             else:
 */
    __pyx_t_2 = (__pyx_v_item == Py_None);
    __pyx_t_3 = (__pyx_t_2 != 0);
    if (__pyx_t_3) {

      /* "edgedb/protocol/codecs/array.pyx":63
 *             item = obj[i]
 *             if item is None:
 *                 elem_data.write_int32(-1)             # <<<<<<<<<<<<<<
 *             else:
 *                 try:
 */
      __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_elem_data->__pyx_vtab)->write_int32(__pyx_v_elem_data, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 63, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "edgedb/protocol/codecs/array.pyx":62
 *         for i in range(objlen):
 *             item = obj[i]
 *             if item is None:             # <<<<<<<<<<<<<<
 *                 elem_data.write_int32(-1)
 *             else:
 */
      goto __pyx_L8;
    }

    /* "edgedb/protocol/codecs/array.pyx":65
 *                 elem_data.write_int32(-1)
 *             else:
 *                 try:             # <<<<<<<<<<<<<<
 *                     self.sub_codec.encode(elem_data, item)
 *                 except TypeError as e:
 */
    /*else*/ {
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_11);
        __Pyx_XGOTREF(__pyx_t_12);
        /*try:*/ {

          /* "edgedb/protocol/codecs/array.pyx":66
 *             else:
 *                 try:
 *                     self.sub_codec.encode(elem_data, item)             # <<<<<<<<<<<<<<
 *                 except TypeError as e:
 *                     raise ValueError(
 */
          __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_self->sub_codec->__pyx_vtab)->encode(__pyx_v_self->sub_codec, __pyx_v_elem_data, __pyx_v_item); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 66, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "edgedb/protocol/codecs/array.pyx":65
 *                 elem_data.write_int32(-1)
 *             else:
 *                 try:             # <<<<<<<<<<<<<<
 *                     self.sub_codec.encode(elem_data, item)
 *                 except TypeError as e:
 */
        }
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        goto __pyx_L16_try_end;
        __pyx_L9_error:;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "edgedb/protocol/codecs/array.pyx":67
 *                 try:
 *                     self.sub_codec.encode(elem_data, item)
 *                 except TypeError as e:             # <<<<<<<<<<<<<<
 *                     raise ValueError(
 *                         'invalid array element: {}'.format(
 */
        __pyx_t_13 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
        if (__pyx_t_13) {
          __Pyx_AddTraceback("edgedb.protocol.protocol.BaseArrayCodec.encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_1, &__pyx_t_5) < 0) __PYX_ERR(9, 67, __pyx_L11_except_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_1);
          __pyx_v_e = __pyx_t_1;
          /*try:*/ {

            /* "edgedb/protocol/codecs/array.pyx":69
 *                 except TypeError as e:
 *                     raise ValueError(
 *                         'invalid array element: {}'.format(             # <<<<<<<<<<<<<<
 *                             e.args[0])) from None
 * 
 */
            __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_invalid_array_element, __pyx_n_s_format); if (unlikely(!__pyx_t_14)) __PYX_ERR(9, 69, __pyx_L22_error)
            __Pyx_GOTREF(__pyx_t_14);

            /* "edgedb/protocol/codecs/array.pyx":70
 *                     raise ValueError(
 *                         'invalid array element: {}'.format(
 *                             e.args[0])) from None             # <<<<<<<<<<<<<<
 * 
 *         buf.write_int32(12 + 8 * ndims + elem_data.len())  # buffer length
 */
            __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_args); if (unlikely(!__pyx_t_15)) __PYX_ERR(9, 70, __pyx_L22_error)
            __Pyx_GOTREF(__pyx_t_15);
            __pyx_t_16 = __Pyx_GetItemInt(__pyx_t_15, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_16)) __PYX_ERR(9, 70, __pyx_L22_error)
            __Pyx_GOTREF(__pyx_t_16);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __pyx_t_15 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
              __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14);
              if (likely(__pyx_t_15)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
                __Pyx_INCREF(__pyx_t_15);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_14, function);
              }
            }
            __pyx_t_6 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_14, __pyx_t_15, __pyx_t_16) : __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_16);
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(9, 69, __pyx_L22_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

            /* "edgedb/protocol/codecs/array.pyx":68
 *                     self.sub_codec.encode(elem_data, item)
 *                 except TypeError as e:
 *                     raise ValueError(             # <<<<<<<<<<<<<<
 *                         'invalid array element: {}'.format(
 *                             e.args[0])) from None
 */
            __pyx_t_14 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_14)) __PYX_ERR(9, 68, __pyx_L22_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

            /* "edgedb/protocol/codecs/array.pyx":70
 *                     raise ValueError(
 *                         'invalid array element: {}'.format(
 *                             e.args[0])) from None             # <<<<<<<<<<<<<<
 * 
 *         buf.write_int32(12 + 8 * ndims + elem_data.len())  # buffer length
 */
            __Pyx_Raise(__pyx_t_14, 0, 0, Py_None);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __PYX_ERR(9, 68, __pyx_L22_error)
          }

          /* "edgedb/protocol/codecs/array.pyx":67
 *                 try:
 *                     self.sub_codec.encode(elem_data, item)
 *                 except TypeError as e:             # <<<<<<<<<<<<<<
 *                     raise ValueError(
 *                         'invalid array element: {}'.format(
 */
          /*finally:*/ {
            __pyx_L22_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_declare
              __Pyx_PyThreadState_assign
              __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
              if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
              __Pyx_XGOTREF(__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_20);
              __Pyx_XGOTREF(__pyx_t_21);
              __Pyx_XGOTREF(__pyx_t_22);
              __Pyx_XGOTREF(__pyx_t_23);
              __Pyx_XGOTREF(__pyx_t_24);
              __pyx_t_13 = __pyx_lineno; __pyx_t_17 = __pyx_clineno; __pyx_t_18 = __pyx_filename;
              {
                __Pyx_DECREF(__pyx_v_e);
                __pyx_v_e = NULL;
              }
              if (PY_MAJOR_VERSION >= 3) {
                __Pyx_XGIVEREF(__pyx_t_22);
                __Pyx_XGIVEREF(__pyx_t_23);
                __Pyx_XGIVEREF(__pyx_t_24);
                __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24);
              }
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_XGIVEREF(__pyx_t_20);
              __Pyx_XGIVEREF(__pyx_t_21);
              __Pyx_ErrRestore(__pyx_t_19, __pyx_t_20, __pyx_t_21);
              __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0;
              __pyx_lineno = __pyx_t_13; __pyx_clineno = __pyx_t_17; __pyx_filename = __pyx_t_18;
              goto __pyx_L11_except_error;
            }
          }
        }
        goto __pyx_L11_except_error;
        __pyx_L11_except_error:;

        /* "edgedb/protocol/codecs/array.pyx":65
 *                 elem_data.write_int32(-1)
 *             else:
 *                 try:             # <<<<<<<<<<<<<<
 *                     self.sub_codec.encode(elem_data, item)
 *                 except TypeError as e:
 */
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
        goto __pyx_L1_error;
        __pyx_L16_try_end:;
      }
    }
    __pyx_L8:;
  }

  /* "edgedb/protocol/codecs/array.pyx":72
 *                             e.args[0])) from None
 * 
 *         buf.write_int32(12 + 8 * ndims + elem_data.len())  # buffer length             # <<<<<<<<<<<<<<
 *         buf.write_int32(ndims)  # number of dimensions
 *         buf.write_int32(0)  # flags
 */
  __pyx_t_5 = __Pyx_PyInt_From_long((12 + (8 * __pyx_v_ndims))); if (unlikely(!__pyx_t_5)) __PYX_ERR(9, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_len(__pyx_v_elem_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyNumber_Add(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_25 = __Pyx_PyInt_As_int32_t(__pyx_t_4); if (unlikely((__pyx_t_25 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(9, 72, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, __pyx_t_25); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "edgedb/protocol/codecs/array.pyx":73
 * 
 *         buf.write_int32(12 + 8 * ndims + elem_data.len())  # buffer length
 *         buf.write_int32(ndims)  # number of dimensions             # <<<<<<<<<<<<<<
 *         buf.write_int32(0)  # flags
 *         buf.write_int32(0)  # reserved
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, __pyx_v_ndims); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 73, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "edgedb/protocol/codecs/array.pyx":74
 *         buf.write_int32(12 + 8 * ndims + elem_data.len())  # buffer length
 *         buf.write_int32(ndims)  # number of dimensions
 *         buf.write_int32(0)  # flags             # <<<<<<<<<<<<<<
 *         buf.write_int32(0)  # reserved
 * 
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "edgedb/protocol/codecs/array.pyx":75
 *         buf.write_int32(ndims)  # number of dimensions
 *         buf.write_int32(0)  # flags
 *         buf.write_int32(0)  # reserved             # <<<<<<<<<<<<<<
 * 
 *         buf.write_int32(<int32_t>objlen)
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "edgedb/protocol/codecs/array.pyx":77
 *         buf.write_int32(0)  # reserved
 * 
 *         buf.write_int32(<int32_t>objlen)             # <<<<<<<<<<<<<<
 *         buf.write_int32(1)
 * 
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, ((int32_t)__pyx_v_objlen)); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 77, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "edgedb/protocol/codecs/array.pyx":78
 * 
 *         buf.write_int32(<int32_t>objlen)
 *         buf.write_int32(1)             # <<<<<<<<<<<<<<
 * 
 *         buf.write_buffer(elem_data)
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "edgedb/protocol/codecs/array.pyx":80
 *         buf.write_int32(1)
 * 
 *         buf.write_buffer(elem_data)             # <<<<<<<<<<<<<<
 * 
 *     cdef decode(self, FRBuffer *buf):
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_buffer(__pyx_v_buf, __pyx_v_elem_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 80, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "edgedb/protocol/codecs/array.pyx":40
 *         raise NotImplementedError
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer elem_data
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseArrayCodec.encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_elem_data);
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/array.pyx":82
 *         buf.write_buffer(elem_data)
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         return self._decode_array(buf)
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("decode", 0);

  /* "edgedb/protocol/codecs/array.pyx":83
 * 
 *     cdef decode(self, FRBuffer *buf):
 *         return self._decode_array(buf)             # <<<<<<<<<<<<<<
 * 
 *     cdef inline _decode_array(self, FRBuffer *buf):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec__decode_array(__pyx_v_self, __pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/array.pyx":82
 *         buf.write_buffer(elem_data)
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         return self._decode_array(buf)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseArrayCodec.decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/array.pyx":85
 *         return self._decode_array(buf)
 * 
 *     cdef inline _decode_array(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         cdef:
 *             Py_ssize_t elem_count
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec__decode_array(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  Py_ssize_t __pyx_v_elem_count;
  int32_t __pyx_v_ndims;
  PyObject *__pyx_v_result = 0;
  Py_ssize_t __pyx_v_i;
  int32_t __pyx_v_elem_len;
  struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer __pyx_v_elem_buf;
  PyObject *__pyx_v_elem = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  Py_UCS4 __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_decode_array", 0);

  /* "edgedb/protocol/codecs/array.pyx":88
 *         cdef:
 *             Py_ssize_t elem_count
 *             int32_t ndims = hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 *             object result
 *             Py_ssize_t i
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(9, 88, __pyx_L1_error)
  __pyx_v_ndims = unpack_int32(__pyx_t_1);

  /* "edgedb/protocol/codecs/array.pyx":94
 *             FRBuffer elem_buf
 * 
 *         frb_read(buf, 4)  # ignore flags             # <<<<<<<<<<<<<<
 *         frb_read(buf, 4)  # reserved
 * 
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(9, 94, __pyx_L1_error)

  /* "edgedb/protocol/codecs/array.pyx":95
 * 
 *         frb_read(buf, 4)  # ignore flags
 *         frb_read(buf, 4)  # reserved             # <<<<<<<<<<<<<<
 * 
 *         if ndims > 1:
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(9, 95, __pyx_L1_error)

  /* "edgedb/protocol/codecs/array.pyx":97
 *         frb_read(buf, 4)  # reserved
 * 
 *         if ndims > 1:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('only 1-dimensional arrays are supported')
 * 
 */
  __pyx_t_2 = ((__pyx_v_ndims > 1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/codecs/array.pyx":98
 * 
 *         if ndims > 1:
 *             raise RuntimeError('only 1-dimensional arrays are supported')             # <<<<<<<<<<<<<<
 * 
 *         if ndims == 0:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 98, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(9, 98, __pyx_L1_error)

    /* "edgedb/protocol/codecs/array.pyx":97
 *         frb_read(buf, 4)  # reserved
 * 
 *         if ndims > 1:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('only 1-dimensional arrays are supported')
 * 
 */
  }

  /* "edgedb/protocol/codecs/array.pyx":100
 *             raise RuntimeError('only 1-dimensional arrays are supported')
 * 
 *         if ndims == 0:             # <<<<<<<<<<<<<<
 *             return self._new_collection(0)
 * 
 */
  __pyx_t_2 = ((__pyx_v_ndims == 0) != 0);
  if (__pyx_t_2) {

    /* "edgedb/protocol/codecs/array.pyx":101
 * 
 *         if ndims == 0:
 *             return self._new_collection(0)             # <<<<<<<<<<<<<<
 * 
 *         assert ndims == 1
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseArrayCodec *)__pyx_v_self->__pyx_base.__pyx_vtab)->_new_collection(__pyx_v_self, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 101, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "edgedb/protocol/codecs/array.pyx":100
 *             raise RuntimeError('only 1-dimensional arrays are supported')
 * 
 *         if ndims == 0:             # <<<<<<<<<<<<<<
 *             return self._new_collection(0)
 * 
 */
  }

  /* "edgedb/protocol/codecs/array.pyx":103
 *             return self._new_collection(0)
 * 
 *         assert ndims == 1             # <<<<<<<<<<<<<<
 * 
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_ndims == 1) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(9, 103, __pyx_L1_error)
    }
  }
  #endif

  /* "edgedb/protocol/codecs/array.pyx":105
 *         assert ndims == 1
 * 
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 *         if self.cardinality != -1 and elem_count != self.cardinality:
 *             raise ValueError(
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(9, 105, __pyx_L1_error)
  __pyx_v_elem_count = ((Py_ssize_t)((uint32_t)unpack_int32(__pyx_t_1)));

  /* "edgedb/protocol/codecs/array.pyx":106
 * 
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 *         if self.cardinality != -1 and elem_count != self.cardinality:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 f'invalid array size: received {elem_count}, '
 */
  __pyx_t_4 = ((__pyx_v_self->cardinality != -1L) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_elem_count != __pyx_v_self->cardinality) != 0);
  __pyx_t_2 = __pyx_t_4;
  __pyx_L6_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/codecs/array.pyx":108
 *         if self.cardinality != -1 and elem_count != self.cardinality:
 *             raise ValueError(
 *                 f'invalid array size: received {elem_count}, '             # <<<<<<<<<<<<<<
 *                 f'expected {self.cardinality}'
 *             )
 */
    __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = 0;
    __pyx_t_6 = 127;
    __Pyx_INCREF(__pyx_kp_u_invalid_array_size_received);
    __pyx_t_5 += 29;
    __Pyx_GIVEREF(__pyx_kp_u_invalid_array_size_received);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_invalid_array_size_received);
    __pyx_t_7 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_v_elem_count, 0, ' ', 'd'); if (unlikely(!__pyx_t_7)) __PYX_ERR(9, 108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_INCREF(__pyx_kp_u_expected_2);
    __pyx_t_5 += 11;
    __Pyx_GIVEREF(__pyx_kp_u_expected_2);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_expected_2);

    /* "edgedb/protocol/codecs/array.pyx":109
 *             raise ValueError(
 *                 f'invalid array size: received {elem_count}, '
 *                 f'expected {self.cardinality}'             # <<<<<<<<<<<<<<
 *             )
 * 
 */
    __pyx_t_7 = __Pyx_PyInt_From_int32_t(__pyx_v_self->cardinality); if (unlikely(!__pyx_t_7)) __PYX_ERR(9, 109, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_FormatSimple(__pyx_t_7, __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(9, 109, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_6;
    __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "edgedb/protocol/codecs/array.pyx":108
 *         if self.cardinality != -1 and elem_count != self.cardinality:
 *             raise ValueError(
 *                 f'invalid array size: received {elem_count}, '             # <<<<<<<<<<<<<<
 *                 f'expected {self.cardinality}'
 *             )
 */
    __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_3, 4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(9, 108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "edgedb/protocol/codecs/array.pyx":107
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 *         if self.cardinality != -1 and elem_count != self.cardinality:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 f'invalid array size: received {elem_count}, '
 *                 f'expected {self.cardinality}'
 */
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(9, 107, __pyx_L1_error)

    /* "edgedb/protocol/codecs/array.pyx":106
 * 
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 *         if self.cardinality != -1 and elem_count != self.cardinality:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 f'invalid array size: received {elem_count}, '
 */
  }

  /* "edgedb/protocol/codecs/array.pyx":112
 *             )
 * 
 *         frb_read(buf, 4)  # Ignore the lower bound information             # <<<<<<<<<<<<<<
 * 
 *         result = self._new_collection(elem_count)
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(9, 112, __pyx_L1_error)

  /* "edgedb/protocol/codecs/array.pyx":114
 *         frb_read(buf, 4)  # Ignore the lower bound information
 * 
 *         result = self._new_collection(elem_count)             # <<<<<<<<<<<<<<
 *         for i in range(elem_count):
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseArrayCodec *)__pyx_v_self->__pyx_base.__pyx_vtab)->_new_collection(__pyx_v_self, __pyx_v_elem_count); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "edgedb/protocol/codecs/array.pyx":115
 * 
 *         result = self._new_collection(elem_count)
 *         for i in range(elem_count):             # <<<<<<<<<<<<<<
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 *             if elem_len == -1:
 */
  __pyx_t_5 = __pyx_v_elem_count;
  __pyx_t_9 = __pyx_t_5;
  for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
    __pyx_v_i = __pyx_t_10;

    /* "edgedb/protocol/codecs/array.pyx":116
 *         result = self._new_collection(elem_count)
 *         for i in range(elem_count):
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 *             if elem_len == -1:
 *                 elem = None
 */
    __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(9, 116, __pyx_L1_error)
    __pyx_v_elem_len = unpack_int32(__pyx_t_1);

    /* "edgedb/protocol/codecs/array.pyx":117
 *         for i in range(elem_count):
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 *             if elem_len == -1:             # <<<<<<<<<<<<<<
 *                 elem = None
 *             else:
 */
    __pyx_t_2 = ((__pyx_v_elem_len == -1L) != 0);
    if (__pyx_t_2) {

      /* "edgedb/protocol/codecs/array.pyx":118
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 *             if elem_len == -1:
 *                 elem = None             # <<<<<<<<<<<<<<
 *             else:
 *                 frb_slice_from(&elem_buf, buf, elem_len)
 */
      __Pyx_INCREF(Py_None);
      __Pyx_XDECREF_SET(__pyx_v_elem, Py_None);

      /* "edgedb/protocol/codecs/array.pyx":117
 *         for i in range(elem_count):
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 *             if elem_len == -1:             # <<<<<<<<<<<<<<
 *                 elem = None
 *             else:
 */
      goto __pyx_L10;
    }

    /* "edgedb/protocol/codecs/array.pyx":120
 *                 elem = None
 *             else:
 *                 frb_slice_from(&elem_buf, buf, elem_len)             # <<<<<<<<<<<<<<
 *                 elem = self.sub_codec.decode(&elem_buf)
 *                 if frb_get_len(&elem_buf):
 */
    /*else*/ {
      (void)(__pyx_f_6edgedb_7pgproto_7pgproto_frb_slice_from((&__pyx_v_elem_buf), __pyx_v_buf, __pyx_v_elem_len));

      /* "edgedb/protocol/codecs/array.pyx":121
 *             else:
 *                 frb_slice_from(&elem_buf, buf, elem_len)
 *                 elem = self.sub_codec.decode(&elem_buf)             # <<<<<<<<<<<<<<
 *                 if frb_get_len(&elem_buf):
 *                     raise RuntimeError(
 */
      __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_self->sub_codec->__pyx_vtab)->decode(__pyx_v_self->sub_codec, (&__pyx_v_elem_buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 121, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "edgedb/protocol/codecs/array.pyx":122
 *                 frb_slice_from(&elem_buf, buf, elem_len)
 *                 elem = self.sub_codec.decode(&elem_buf)
 *                 if frb_get_len(&elem_buf):             # <<<<<<<<<<<<<<
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after '
 */
      __pyx_t_2 = (__pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len((&__pyx_v_elem_buf)) != 0);
      if (unlikely(__pyx_t_2)) {

        /* "edgedb/protocol/codecs/array.pyx":125
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after '
 *                         f'array element decoding: {frb_get_len(&elem_buf)}')             # <<<<<<<<<<<<<<
 * 
 *             self._set_collection_item(result, i, elem)
 */
        __pyx_t_3 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len((&__pyx_v_elem_buf)), 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 125, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);

        /* "edgedb/protocol/codecs/array.pyx":124
 *                 if frb_get_len(&elem_buf):
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after '             # <<<<<<<<<<<<<<
 *                         f'array element decoding: {frb_get_len(&elem_buf)}')
 * 
 */
        __pyx_t_8 = __Pyx_PyUnicode_Concat(__pyx_kp_u_unexpected_trailing_data_in_buff_4, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(9, 124, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "edgedb/protocol/codecs/array.pyx":123
 *                 elem = self.sub_codec.decode(&elem_buf)
 *                 if frb_get_len(&elem_buf):
 *                     raise RuntimeError(             # <<<<<<<<<<<<<<
 *                         f'unexpected trailing data in buffer after '
 *                         f'array element decoding: {frb_get_len(&elem_buf)}')
 */
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 123, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __PYX_ERR(9, 123, __pyx_L1_error)

        /* "edgedb/protocol/codecs/array.pyx":122
 *                 frb_slice_from(&elem_buf, buf, elem_len)
 *                 elem = self.sub_codec.decode(&elem_buf)
 *                 if frb_get_len(&elem_buf):             # <<<<<<<<<<<<<<
 *                     raise RuntimeError(
 *                         f'unexpected trailing data in buffer after '
 */
      }
    }
    __pyx_L10:;

    /* "edgedb/protocol/codecs/array.pyx":127
 *                         f'array element decoding: {frb_get_len(&elem_buf)}')
 * 
 *             self._set_collection_item(result, i, elem)             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseArrayCodec *)__pyx_v_self->__pyx_base.__pyx_vtab)->_set_collection_item(__pyx_v_self, __pyx_v_result, __pyx_v_i, __pyx_v_elem); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 127, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }

  /* "edgedb/protocol/codecs/array.pyx":129
 *             self._set_collection_item(result, i, elem)
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cdef dump(self, int level = 0):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/array.pyx":85
 *         return self._decode_array(buf)
 * 
 *     cdef inline _decode_array(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         cdef:
 *             Py_ssize_t elem_count
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseArrayCodec._decode_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/array.pyx":131
 *         return result
 * 
 *     cdef dump(self, int level = 0):             # <<<<<<<<<<<<<<
 *         return f'{level * " "}{self.name}\n{self.sub_codec.dump(level + 1)}'
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec_dump(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self, struct __pyx_opt_args_6edgedb_8protocol_8protocol_14BaseArrayCodec_dump *__pyx_optional_args) {
  int __pyx_v_level = ((int)0);
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_UCS4 __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  struct __pyx_opt_args_6edgedb_8protocol_8protocol_9BaseCodec_dump __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dump", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_level = __pyx_optional_args->level;
    }
  }

  /* "edgedb/protocol/codecs/array.pyx":132
 * 
 *     cdef dump(self, int level = 0):
 *         return f'{level * " "}{self.name}\n{self.sub_codec.dump(level + 1)}'             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = 0;
  __pyx_t_3 = 127;
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_level); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_4, __pyx_kp_u__2); if (unlikely(!__pyx_t_5)) __PYX_ERR(9, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_t_5, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3;
  __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyUnicode_Unicode(__pyx_v_self->__pyx_base.name); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3;
  __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
  __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_kp_u__18);
  __pyx_t_2 += 1;
  __Pyx_GIVEREF(__pyx_kp_u__18);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__18);
  __pyx_t_6.__pyx_n = 1;
  __pyx_t_6.level = (__pyx_v_level + 1);
  __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_self->sub_codec->__pyx_vtab)->dump(__pyx_v_self->sub_codec, &__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(9, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_t_4, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(9, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_3;
  __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_1, 4, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(9, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/array.pyx":131
 *         return result
 * 
 *     cdef dump(self, int level = 0):             # <<<<<<<<<<<<<<
 *         return f'{level * " "}{self.name}\n{self.sub_codec.dump(level + 1)}'
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseArrayCodec.dump", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14BaseArrayCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14BaseArrayCodec_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14BaseArrayCodec_2__reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14BaseArrayCodec_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseArrayCodec.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14BaseArrayCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14BaseArrayCodec_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14BaseArrayCodec_4__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14BaseArrayCodec_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.BaseArrayCodec.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/array.pyx":138
 * cdef class ArrayCodec(BaseArrayCodec):
 * 
 *     cdef _new_collection(self, Py_ssize_t size):             # <<<<<<<<<<<<<<
 *         return datatypes.array_new(size)
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_10ArrayCodec__new_collection(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec *__pyx_v_self, Py_ssize_t __pyx_v_size) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_new_collection", 0);

  /* "edgedb/protocol/codecs/array.pyx":139
 * 
 *     cdef _new_collection(self, Py_ssize_t size):
 *         return datatypes.array_new(size)             # <<<<<<<<<<<<<<
 * 
 *     cdef _set_collection_item(self, object collection, Py_ssize_t i,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6edgedb_9datatypes_9datatypes_array_new(__pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 139, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/array.pyx":138
 * cdef class ArrayCodec(BaseArrayCodec):
 * 
 *     cdef _new_collection(self, Py_ssize_t size):             # <<<<<<<<<<<<<<
 *         return datatypes.array_new(size)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ArrayCodec._new_collection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/array.pyx":141
 *         return datatypes.array_new(size)
 * 
 *     cdef _set_collection_item(self, object collection, Py_ssize_t i,             # <<<<<<<<<<<<<<
 *                               object element):
 *         datatypes.array_set(collection, i, element)
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_10ArrayCodec__set_collection_item(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec *__pyx_v_self, PyObject *__pyx_v_collection, Py_ssize_t __pyx_v_i, PyObject *__pyx_v_element) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_set_collection_item", 0);

  /* "edgedb/protocol/codecs/array.pyx":143
 *     cdef _set_collection_item(self, object collection, Py_ssize_t i,
 *                               object element):
 *         datatypes.array_set(collection, i, element)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __pyx_t_1 = __pyx_f_6edgedb_9datatypes_9datatypes_array_set(__pyx_v_collection, __pyx_v_i, __pyx_v_element); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/array.pyx":141
 *         return datatypes.array_new(size)
 * 
 *     cdef _set_collection_item(self, object collection, Py_ssize_t i,             # <<<<<<<<<<<<<<
 *                               object element):
 *         datatypes.array_set(collection, i, element)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ArrayCodec._set_collection_item", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/array.pyx":146
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid, BaseCodec sub_codec, int32_t cardinality):             # <<<<<<<<<<<<<<
 *         cdef:
 *             ArrayCodec codec
 */

static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_10ArrayCodec_new(PyObject *__pyx_v_tid, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_sub_codec, int32_t __pyx_v_cardinality) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec *__pyx_v_codec = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("new", 0);

  /* "edgedb/protocol/codecs/array.pyx":150
 *             ArrayCodec codec
 * 
 *         codec = ArrayCodec.__new__(ArrayCodec)             # <<<<<<<<<<<<<<
 * 
 *         codec.tid = tid
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_6edgedb_8protocol_8protocol_ArrayCodec(((PyTypeObject *)__pyx_ptype_6edgedb_8protocol_8protocol_ArrayCodec), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 150, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/array.pyx":152
 *         codec = ArrayCodec.__new__(ArrayCodec)
 * 
 *         codec.tid = tid             # <<<<<<<<<<<<<<
 *         codec.name = 'Array'
 *         codec.sub_codec = sub_codec
 */
  __Pyx_INCREF(__pyx_v_tid);
  __Pyx_GIVEREF(__pyx_v_tid);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.__pyx_base.tid);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.__pyx_base.tid);
  __pyx_v_codec->__pyx_base.__pyx_base.tid = __pyx_v_tid;

  /* "edgedb/protocol/codecs/array.pyx":153
 * 
 *         codec.tid = tid
 *         codec.name = 'Array'             # <<<<<<<<<<<<<<
 *         codec.sub_codec = sub_codec
 *         codec.cardinality = cardinality
 */
  __Pyx_INCREF(__pyx_n_u_Array);
  __Pyx_GIVEREF(__pyx_n_u_Array);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.__pyx_base.name);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.__pyx_base.name);
  __pyx_v_codec->__pyx_base.__pyx_base.name = __pyx_n_u_Array;

  /* "edgedb/protocol/codecs/array.pyx":154
 *         codec.tid = tid
 *         codec.name = 'Array'
 *         codec.sub_codec = sub_codec             # <<<<<<<<<<<<<<
 *         codec.cardinality = cardinality
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_sub_codec));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_sub_codec));
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.sub_codec);
  __Pyx_DECREF(((PyObject *)__pyx_v_codec->__pyx_base.sub_codec));
  __pyx_v_codec->__pyx_base.sub_codec = __pyx_v_sub_codec;

  /* "edgedb/protocol/codecs/array.pyx":155
 *         codec.name = 'Array'
 *         codec.sub_codec = sub_codec
 *         codec.cardinality = cardinality             # <<<<<<<<<<<<<<
 * 
 *         return codec
 */
  __pyx_v_codec->__pyx_base.cardinality = __pyx_v_cardinality;

  /* "edgedb/protocol/codecs/array.pyx":157
 *         codec.cardinality = cardinality
 * 
 *         return codec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_codec));
  __pyx_r = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_codec);
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/array.pyx":146
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid, BaseCodec sub_codec, int32_t cardinality):             # <<<<<<<<<<<<<<
 *         cdef:
 *             ArrayCodec codec
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ArrayCodec.new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10ArrayCodec_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10ArrayCodec_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_10ArrayCodec___reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10ArrayCodec___reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ArrayCodec.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10ArrayCodec_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_10ArrayCodec_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_10ArrayCodec_2__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_10ArrayCodec_2__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ArrayCodec.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/array.pyx":160
 * 
 * 
 * cdef inline bint _is_trivial_container(object obj):             # <<<<<<<<<<<<<<
 *     return cpython.PyUnicode_Check(obj) or cpython.PyBytes_Check(obj) or \
 *             cpythonx.PyByteArray_Check(obj) or cpythonx.PyMemoryView_Check(obj)
 */

static CYTHON_INLINE int __pyx_f_6edgedb_8protocol_8protocol__is_trivial_container(PyObject *__pyx_v_obj) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("_is_trivial_container", 0);

  /* "edgedb/protocol/codecs/array.pyx":161
 * 
 * cdef inline bint _is_trivial_container(object obj):
 *     return cpython.PyUnicode_Check(obj) or cpython.PyBytes_Check(obj) or \             # <<<<<<<<<<<<<<
 *             cpythonx.PyByteArray_Check(obj) or cpythonx.PyMemoryView_Check(obj)
 * 
 */
  __pyx_t_2 = (PyUnicode_Check(__pyx_v_obj) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_2 = (PyBytes_Check(__pyx_v_obj) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L3_bool_binop_done;
  }

  /* "edgedb/protocol/codecs/array.pyx":162
 * cdef inline bint _is_trivial_container(object obj):
 *     return cpython.PyUnicode_Check(obj) or cpython.PyBytes_Check(obj) or \
 *             cpythonx.PyByteArray_Check(obj) or cpythonx.PyMemoryView_Check(obj)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = (PyByteArray_Check(__pyx_v_obj) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_2 = (PyMemoryView_Check(__pyx_v_obj) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L3_bool_binop_done:;
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/array.pyx":160
 * 
 * 
 * cdef inline bint _is_trivial_container(object obj):             # <<<<<<<<<<<<<<
 *     return cpython.PyUnicode_Check(obj) or cpython.PyBytes_Check(obj) or \
 *             cpythonx.PyByteArray_Check(obj) or cpythonx.PyMemoryView_Check(obj)
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/array.pyx":165
 * 
 * 
 * cdef inline _is_array_iterable(object obj):             # <<<<<<<<<<<<<<
 *     return (
 *         cpython.PyTuple_Check(obj) or
 */

static CYTHON_INLINE PyObject *__pyx_f_6edgedb_8protocol_8protocol__is_array_iterable(PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_is_array_iterable", 0);

  /* "edgedb/protocol/codecs/array.pyx":166
 * 
 * cdef inline _is_array_iterable(object obj):
 *     return (             # <<<<<<<<<<<<<<
 *         cpython.PyTuple_Check(obj) or
 *         cpython.PyList_Check(obj) or
 */
  __Pyx_XDECREF(__pyx_r);

  /* "edgedb/protocol/codecs/array.pyx":167
 * cdef inline _is_array_iterable(object obj):
 *     return (
 *         cpython.PyTuple_Check(obj) or             # <<<<<<<<<<<<<<
 *         cpython.PyList_Check(obj) or
 *         (
 */
  __pyx_t_2 = PyTuple_Check(__pyx_v_obj);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 167, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3_bool_binop_done;
  }

  /* "edgedb/protocol/codecs/array.pyx":168
 *     return (
 *         cpython.PyTuple_Check(obj) or
 *         cpython.PyList_Check(obj) or             # <<<<<<<<<<<<<<
 *         (
 *             isinstance(obj, IterableABC) and
 */
  __pyx_t_2 = PyList_Check(__pyx_v_obj);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 168, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3_bool_binop_done;
  }

  /* "edgedb/protocol/codecs/array.pyx":170
 *         cpython.PyList_Check(obj) or
 *         (
 *             isinstance(obj, IterableABC) and             # <<<<<<<<<<<<<<
 *             isinstance(obj, SizedABC) and
 *             not _is_trivial_container(obj) and
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_IterableABC); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_3); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(9, 170, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {
  } else {
    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 170, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3_bool_binop_done;
  }

  /* "edgedb/protocol/codecs/array.pyx":171
 *         (
 *             isinstance(obj, IterableABC) and
 *             isinstance(obj, SizedABC) and             # <<<<<<<<<<<<<<
 *             not _is_trivial_container(obj) and
 *             not isinstance(obj, MappingABC)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_SizedABC); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_3); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(9, 171, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {
  } else {
    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 171, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3_bool_binop_done;
  }

  /* "edgedb/protocol/codecs/array.pyx":172
 *             isinstance(obj, IterableABC) and
 *             isinstance(obj, SizedABC) and
 *             not _is_trivial_container(obj) and             # <<<<<<<<<<<<<<
 *             not isinstance(obj, MappingABC)
 *         )
 */
  __pyx_t_2 = (!(__pyx_f_6edgedb_8protocol_8protocol__is_trivial_container(__pyx_v_obj) != 0));
  if (__pyx_t_2) {
  } else {
    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3_bool_binop_done;
  }

  /* "edgedb/protocol/codecs/array.pyx":173
 *             isinstance(obj, SizedABC) and
 *             not _is_trivial_container(obj) and
 *             not isinstance(obj, MappingABC)             # <<<<<<<<<<<<<<
 *         )
 *     )
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_MappingABC); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_3); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(9, 173, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = (!(__pyx_t_2 != 0));
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(9, 173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_L3_bool_binop_done:;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/array.pyx":165
 * 
 * 
 * cdef inline _is_array_iterable(object obj):             # <<<<<<<<<<<<<<
 *     return (
 *         cpython.PyTuple_Check(obj) or
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol._is_array_iterable", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/set.pyx":23
 * cdef class SetCodec(BaseArrayCodec):
 * 
 *     cdef _new_collection(self, Py_ssize_t size):             # <<<<<<<<<<<<<<
 *         return datatypes.set_new(size)
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_8SetCodec__new_collection(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *__pyx_v_self, Py_ssize_t __pyx_v_size) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_new_collection", 0);

  /* "edgedb/protocol/codecs/set.pyx":24
 * 
 *     cdef _new_collection(self, Py_ssize_t size):
 *         return datatypes.set_new(size)             # <<<<<<<<<<<<<<
 * 
 *     cdef _set_collection_item(self, object collection, Py_ssize_t i,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6edgedb_9datatypes_9datatypes_set_new(__pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(10, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/set.pyx":23
 * cdef class SetCodec(BaseArrayCodec):
 * 
 *     cdef _new_collection(self, Py_ssize_t size):             # <<<<<<<<<<<<<<
 *         return datatypes.set_new(size)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SetCodec._new_collection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/set.pyx":26
 *         return datatypes.set_new(size)
 * 
 *     cdef _set_collection_item(self, object collection, Py_ssize_t i,             # <<<<<<<<<<<<<<
 *                               object element):
 *         datatypes.set_set(collection, i, element)
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_8SetCodec__set_collection_item(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *__pyx_v_self, PyObject *__pyx_v_collection, Py_ssize_t __pyx_v_i, PyObject *__pyx_v_element) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_set_collection_item", 0);

  /* "edgedb/protocol/codecs/set.pyx":28
 *     cdef _set_collection_item(self, object collection, Py_ssize_t i,
 *                               object element):
 *         datatypes.set_set(collection, i, element)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __pyx_t_1 = __pyx_f_6edgedb_9datatypes_9datatypes_set_set(__pyx_v_collection, __pyx_v_i, __pyx_v_element); if (unlikely(!__pyx_t_1)) __PYX_ERR(10, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/set.pyx":26
 *         return datatypes.set_new(size)
 * 
 *     cdef _set_collection_item(self, object collection, Py_ssize_t i,             # <<<<<<<<<<<<<<
 *                               object element):
 *         datatypes.set_set(collection, i, element)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SetCodec._set_collection_item", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/set.pyx":31
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid, BaseCodec sub_codec):             # <<<<<<<<<<<<<<
 *         cdef:
 *             SetCodec codec
 */

static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_8SetCodec_new(PyObject *__pyx_v_tid, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_sub_codec) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *__pyx_v_codec = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("new", 0);

  /* "edgedb/protocol/codecs/set.pyx":35
 *             SetCodec codec
 * 
 *         codec = SetCodec.__new__(SetCodec)             # <<<<<<<<<<<<<<
 * 
 *         codec.tid = tid
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_6edgedb_8protocol_8protocol_SetCodec(((PyTypeObject *)__pyx_ptype_6edgedb_8protocol_8protocol_SetCodec), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(10, 35, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/set.pyx":37
 *         codec = SetCodec.__new__(SetCodec)
 * 
 *         codec.tid = tid             # <<<<<<<<<<<<<<
 *         codec.name = 'Set'
 *         codec.sub_codec = sub_codec
 */
  __Pyx_INCREF(__pyx_v_tid);
  __Pyx_GIVEREF(__pyx_v_tid);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.__pyx_base.tid);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.__pyx_base.tid);
  __pyx_v_codec->__pyx_base.__pyx_base.tid = __pyx_v_tid;

  /* "edgedb/protocol/codecs/set.pyx":38
 * 
 *         codec.tid = tid
 *         codec.name = 'Set'             # <<<<<<<<<<<<<<
 *         codec.sub_codec = sub_codec
 * 
 */
  __Pyx_INCREF(__pyx_n_u_Set);
  __Pyx_GIVEREF(__pyx_n_u_Set);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.__pyx_base.name);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.__pyx_base.name);
  __pyx_v_codec->__pyx_base.__pyx_base.name = __pyx_n_u_Set;

  /* "edgedb/protocol/codecs/set.pyx":39
 *         codec.tid = tid
 *         codec.name = 'Set'
 *         codec.sub_codec = sub_codec             # <<<<<<<<<<<<<<
 * 
 *         return codec
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_sub_codec));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_sub_codec));
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.sub_codec);
  __Pyx_DECREF(((PyObject *)__pyx_v_codec->__pyx_base.sub_codec));
  __pyx_v_codec->__pyx_base.sub_codec = __pyx_v_sub_codec;

  /* "edgedb/protocol/codecs/set.pyx":41
 *         codec.sub_codec = sub_codec
 * 
 *         return codec             # <<<<<<<<<<<<<<
 * 
 *     cdef decode(self, FRBuffer *buf):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_codec));
  __pyx_r = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_codec);
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/set.pyx":31
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid, BaseCodec sub_codec):             # <<<<<<<<<<<<<<
 *         cdef:
 *             SetCodec codec
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SetCodec.new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/set.pyx":43
 *         return codec
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         if type(self.sub_codec) is ArrayCodec:
 *             # This is a set of arrays encoded as an array
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_8SetCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("decode", 0);

  /* "edgedb/protocol/codecs/set.pyx":44
 * 
 *     cdef decode(self, FRBuffer *buf):
 *         if type(self.sub_codec) is ArrayCodec:             # <<<<<<<<<<<<<<
 *             # This is a set of arrays encoded as an array
 *             # of single-element records.
 */
  __pyx_t_1 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self->__pyx_base.sub_codec))) == ((PyObject *)__pyx_ptype_6edgedb_8protocol_8protocol_ArrayCodec));
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "edgedb/protocol/codecs/set.pyx":47
 *             # This is a set of arrays encoded as an array
 *             # of single-element records.
 *             return self._decode_array_set(buf)             # <<<<<<<<<<<<<<
 *         else:
 *             # Set of non-arrays.
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __pyx_f_6edgedb_8protocol_8protocol_8SetCodec__decode_array_set(__pyx_v_self, __pyx_v_buf); if (unlikely(!__pyx_t_3)) __PYX_ERR(10, 47, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "edgedb/protocol/codecs/set.pyx":44
 * 
 *     cdef decode(self, FRBuffer *buf):
 *         if type(self.sub_codec) is ArrayCodec:             # <<<<<<<<<<<<<<
 *             # This is a set of arrays encoded as an array
 *             # of single-element records.
 */
  }

  /* "edgedb/protocol/codecs/set.pyx":50
 *         else:
 *             # Set of non-arrays.
 *             return self._decode_array(buf)             # <<<<<<<<<<<<<<
 * 
 *     cdef inline _decode_array_set(self, FRBuffer *buf):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SetCodec *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._decode_array(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *)__pyx_v_self), __pyx_v_buf); if (unlikely(!__pyx_t_3)) __PYX_ERR(10, 50, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "edgedb/protocol/codecs/set.pyx":43
 *         return codec
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         if type(self.sub_codec) is ArrayCodec:
 *             # This is a set of arrays encoded as an array
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SetCodec.decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/set.pyx":52
 *             return self._decode_array(buf)
 * 
 *     cdef inline _decode_array_set(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         cdef:
 *             object result
 */

static CYTHON_INLINE PyObject *__pyx_f_6edgedb_8protocol_8protocol_8SetCodec__decode_array_set(struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  PyObject *__pyx_v_result = 0;
  PyObject *__pyx_v_elem = 0;
  Py_ssize_t __pyx_v_elem_count;
  Py_ssize_t __pyx_v_recsize;
  Py_ssize_t __pyx_v_i;
  int32_t __pyx_v_elem_len;
  int32_t __pyx_v_ndims;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_sub_codec = 0;
  struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer __pyx_v_elem_buf;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_decode_array_set", 0);

  /* "edgedb/protocol/codecs/set.pyx":60
 *             Py_ssize_t i
 *             int32_t elem_len
 *             int32_t ndims = hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 *             BaseCodec sub_codec = <BaseCodec>self.sub_codec
 *             FRBuffer elem_buf
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(10, 60, __pyx_L1_error)
  __pyx_v_ndims = unpack_int32(__pyx_t_1);

  /* "edgedb/protocol/codecs/set.pyx":61
 *             int32_t elem_len
 *             int32_t ndims = hton.unpack_int32(frb_read(buf, 4))
 *             BaseCodec sub_codec = <BaseCodec>self.sub_codec             # <<<<<<<<<<<<<<
 *             FRBuffer elem_buf
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base.sub_codec);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_sub_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/set.pyx":64
 *             FRBuffer elem_buf
 * 
 *         frb_read(buf, 4)  # ignore flags             # <<<<<<<<<<<<<<
 *         frb_read(buf, 4)  # ignore reserved
 * 
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(10, 64, __pyx_L1_error)

  /* "edgedb/protocol/codecs/set.pyx":65
 * 
 *         frb_read(buf, 4)  # ignore flags
 *         frb_read(buf, 4)  # ignore reserved             # <<<<<<<<<<<<<<
 * 
 *         if ndims == 0:
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(10, 65, __pyx_L1_error)

  /* "edgedb/protocol/codecs/set.pyx":67
 *         frb_read(buf, 4)  # ignore reserved
 * 
 *         if ndims == 0:             # <<<<<<<<<<<<<<
 *             # Special case for an empty set.
 *             return self._new_collection(0)
 */
  __pyx_t_3 = ((__pyx_v_ndims == 0) != 0);
  if (__pyx_t_3) {

    /* "edgedb/protocol/codecs/set.pyx":69
 *         if ndims == 0:
 *             # Special case for an empty set.
 *             return self._new_collection(0)             # <<<<<<<<<<<<<<
 *         elif ndims > 1:
 *             raise RuntimeError('expected a two-dimensional array for a '
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_f_6edgedb_8protocol_8protocol_8SetCodec__new_collection(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *)__pyx_v_self), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 69, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "edgedb/protocol/codecs/set.pyx":67
 *         frb_read(buf, 4)  # ignore reserved
 * 
 *         if ndims == 0:             # <<<<<<<<<<<<<<
 *             # Special case for an empty set.
 *             return self._new_collection(0)
 */
  }

  /* "edgedb/protocol/codecs/set.pyx":70
 *             # Special case for an empty set.
 *             return self._new_collection(0)
 *         elif ndims > 1:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('expected a two-dimensional array for a '
 *                                'set of arrays')
 */
  __pyx_t_3 = ((__pyx_v_ndims > 1) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "edgedb/protocol/codecs/set.pyx":71
 *             return self._new_collection(0)
 *         elif ndims > 1:
 *             raise RuntimeError('expected a two-dimensional array for a '             # <<<<<<<<<<<<<<
 *                                'set of arrays')
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 71, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(10, 71, __pyx_L1_error)

    /* "edgedb/protocol/codecs/set.pyx":70
 *             # Special case for an empty set.
 *             return self._new_collection(0)
 *         elif ndims > 1:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('expected a two-dimensional array for a '
 *                                'set of arrays')
 */
  }

  /* "edgedb/protocol/codecs/set.pyx":74
 *                                'set of arrays')
 * 
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 *         frb_read(buf, 4)  # Ignore the lower bound information
 * 
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(10, 74, __pyx_L1_error)
  __pyx_v_elem_count = ((Py_ssize_t)((uint32_t)unpack_int32(__pyx_t_1)));

  /* "edgedb/protocol/codecs/set.pyx":75
 * 
 *         elem_count = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 *         frb_read(buf, 4)  # Ignore the lower bound information             # <<<<<<<<<<<<<<
 * 
 *         result = self._new_collection(elem_count)
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(10, 75, __pyx_L1_error)

  /* "edgedb/protocol/codecs/set.pyx":77
 *         frb_read(buf, 4)  # Ignore the lower bound information
 * 
 *         result = self._new_collection(elem_count)             # <<<<<<<<<<<<<<
 *         for i in range(elem_count):
 *             frb_read(buf, 4)  # ignore array element size
 */
  __pyx_t_2 = __pyx_f_6edgedb_8protocol_8protocol_8SetCodec__new_collection(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *)__pyx_v_self), __pyx_v_elem_count); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 77, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_result = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/set.pyx":78
 * 
 *         result = self._new_collection(elem_count)
 *         for i in range(elem_count):             # <<<<<<<<<<<<<<
 *             frb_read(buf, 4)  # ignore array element size
 * 
 */
  __pyx_t_4 = __pyx_v_elem_count;
  __pyx_t_5 = __pyx_t_4;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
    __pyx_v_i = __pyx_t_6;

    /* "edgedb/protocol/codecs/set.pyx":79
 *         result = self._new_collection(elem_count)
 *         for i in range(elem_count):
 *             frb_read(buf, 4)  # ignore array element size             # <<<<<<<<<<<<<<
 * 
 *             recsize = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 */
    __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(10, 79, __pyx_L1_error)

    /* "edgedb/protocol/codecs/set.pyx":81
 *             frb_read(buf, 4)  # ignore array element size
 * 
 *             recsize = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 *             if recsize != 1:
 *                 raise RuntimeError(
 */
    __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(10, 81, __pyx_L1_error)
    __pyx_v_recsize = ((Py_ssize_t)((uint32_t)unpack_int32(__pyx_t_1)));

    /* "edgedb/protocol/codecs/set.pyx":82
 * 
 *             recsize = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 *             if recsize != 1:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     'expected a record with a single element as an array set '
 */
    __pyx_t_3 = ((__pyx_v_recsize != 1) != 0);
    if (unlikely(__pyx_t_3)) {

      /* "edgedb/protocol/codecs/set.pyx":83
 *             recsize = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 *             if recsize != 1:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'expected a record with a single element as an array set '
 *                     'element envelope')
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 83, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(10, 83, __pyx_L1_error)

      /* "edgedb/protocol/codecs/set.pyx":82
 * 
 *             recsize = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 *             if recsize != 1:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     'expected a record with a single element as an array set '
 */
    }

    /* "edgedb/protocol/codecs/set.pyx":87
 *                     'element envelope')
 * 
 *             frb_read(buf, 4)  # reserved             # <<<<<<<<<<<<<<
 * 
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 */
    __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(10, 87, __pyx_L1_error)

    /* "edgedb/protocol/codecs/set.pyx":89
 *             frb_read(buf, 4)  # reserved
 * 
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 *             if elem_len == -1:
 *                 raise RuntimeError(
 */
    __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(10, 89, __pyx_L1_error)
    __pyx_v_elem_len = unpack_int32(__pyx_t_1);

    /* "edgedb/protocol/codecs/set.pyx":90
 * 
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 *             if elem_len == -1:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     'unexpected NULL value in array set element ')
 */
    __pyx_t_3 = ((__pyx_v_elem_len == -1L) != 0);
    if (unlikely(__pyx_t_3)) {

      /* "edgedb/protocol/codecs/set.pyx":91
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 *             if elem_len == -1:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'unexpected NULL value in array set element ')
 * 
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 91, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(10, 91, __pyx_L1_error)

      /* "edgedb/protocol/codecs/set.pyx":90
 * 
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 *             if elem_len == -1:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     'unexpected NULL value in array set element ')
 */
    }

    /* "edgedb/protocol/codecs/set.pyx":94
 *                     'unexpected NULL value in array set element ')
 * 
 *             frb_slice_from(&elem_buf, buf, elem_len)             # <<<<<<<<<<<<<<
 *             elem = sub_codec.decode(&elem_buf)
 *             if frb_get_len(&elem_buf):
 */
    (void)(__pyx_f_6edgedb_7pgproto_7pgproto_frb_slice_from((&__pyx_v_elem_buf), __pyx_v_buf, __pyx_v_elem_len));

    /* "edgedb/protocol/codecs/set.pyx":95
 * 
 *             frb_slice_from(&elem_buf, buf, elem_len)
 *             elem = sub_codec.decode(&elem_buf)             # <<<<<<<<<<<<<<
 *             if frb_get_len(&elem_buf):
 *                 raise RuntimeError(
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_sub_codec->__pyx_vtab)->decode(__pyx_v_sub_codec, (&__pyx_v_elem_buf)); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 95, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_elem, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "edgedb/protocol/codecs/set.pyx":96
 *             frb_slice_from(&elem_buf, buf, elem_len)
 *             elem = sub_codec.decode(&elem_buf)
 *             if frb_get_len(&elem_buf):             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     f'unexpected trailing data in buffer after '
 */
    __pyx_t_3 = (__pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len((&__pyx_v_elem_buf)) != 0);
    if (unlikely(__pyx_t_3)) {

      /* "edgedb/protocol/codecs/set.pyx":99
 *                 raise RuntimeError(
 *                     f'unexpected trailing data in buffer after '
 *                     f'set element decoding: {frb_get_len(&elem_buf)}')             # <<<<<<<<<<<<<<
 *             self._set_collection_item(result, i, elem)
 * 
 */
      __pyx_t_2 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len((&__pyx_v_elem_buf)), 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 99, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);

      /* "edgedb/protocol/codecs/set.pyx":98
 *             if frb_get_len(&elem_buf):
 *                 raise RuntimeError(
 *                     f'unexpected trailing data in buffer after '             # <<<<<<<<<<<<<<
 *                     f'set element decoding: {frb_get_len(&elem_buf)}')
 *             self._set_collection_item(result, i, elem)
 */
      __pyx_t_7 = __Pyx_PyUnicode_Concat(__pyx_kp_u_unexpected_trailing_data_in_buff_5, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(10, 98, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "edgedb/protocol/codecs/set.pyx":97
 *             elem = sub_codec.decode(&elem_buf)
 *             if frb_get_len(&elem_buf):
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     f'unexpected trailing data in buffer after '
 *                     f'set element decoding: {frb_get_len(&elem_buf)}')
 */
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 97, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(10, 97, __pyx_L1_error)

      /* "edgedb/protocol/codecs/set.pyx":96
 *             frb_slice_from(&elem_buf, buf, elem_len)
 *             elem = sub_codec.decode(&elem_buf)
 *             if frb_get_len(&elem_buf):             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     f'unexpected trailing data in buffer after '
 */
    }

    /* "edgedb/protocol/codecs/set.pyx":100
 *                     f'unexpected trailing data in buffer after '
 *                     f'set element decoding: {frb_get_len(&elem_buf)}')
 *             self._set_collection_item(result, i, elem)             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
    __pyx_t_2 = __pyx_f_6edgedb_8protocol_8protocol_8SetCodec__set_collection_item(((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *)__pyx_v_self), __pyx_v_result, __pyx_v_i, __pyx_v_elem); if (unlikely(!__pyx_t_2)) __PYX_ERR(10, 100, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "edgedb/protocol/codecs/set.pyx":102
 *             self._set_collection_item(result, i, elem)
 * 
 *         return result             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/set.pyx":52
 *             return self._decode_array(buf)
 * 
 *     cdef inline _decode_array_set(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         cdef:
 *             object result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SetCodec._decode_array_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_elem);
  __Pyx_XDECREF((PyObject *)__pyx_v_sub_codec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_8SetCodec_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_8SetCodec_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_8SetCodec___reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_8SetCodec___reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SetCodec.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_8SetCodec_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_8SetCodec_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_8SetCodec_2__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_8SetCodec_2__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SetCodec.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/enum.pyx":23
 * cdef class EnumCodec(BaseCodec):
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         if not isinstance(obj, (datatypes.EnumValue, str)):
 *             raise TypeError(
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_9EnumCodec_encode(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("encode", 0);

  /* "edgedb/protocol/codecs/enum.pyx":24
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):
 *         if not isinstance(obj, (datatypes.EnumValue, str)):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 f'a str or edgedb.EnumValue is expected as a valid '
 */
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_6edgedb_9datatypes_9datatypes_EnumValue); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = PyUnicode_Check(__pyx_v_obj); 
  __pyx_t_2 = (__pyx_t_3 != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/codecs/enum.pyx":27
 *             raise TypeError(
 *                 f'a str or edgedb.EnumValue is expected as a valid '
 *                 f'enum argument, got {type(obj).__name__}')             # <<<<<<<<<<<<<<
 *         pgproto.text_encode(DEFAULT_CODEC_CONTEXT, buf, str(obj))
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_obj)), __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 27, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_t_4, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 27, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "edgedb/protocol/codecs/enum.pyx":26
 *         if not isinstance(obj, (datatypes.EnumValue, str)):
 *             raise TypeError(
 *                 f'a str or edgedb.EnumValue is expected as a valid '             # <<<<<<<<<<<<<<
 *                 f'enum argument, got {type(obj).__name__}')
 *         pgproto.text_encode(DEFAULT_CODEC_CONTEXT, buf, str(obj))
 */
    __pyx_t_4 = __Pyx_PyUnicode_Concat(__pyx_kp_u_a_str_or_edgedb_EnumValue_is_exp, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 26, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "edgedb/protocol/codecs/enum.pyx":25
 *     cdef encode(self, WriteBuffer buf, object obj):
 *         if not isinstance(obj, (datatypes.EnumValue, str)):
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 f'a str or edgedb.EnumValue is expected as a valid '
 *                 f'enum argument, got {type(obj).__name__}')
 */
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(11, 25, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(11, 25, __pyx_L1_error)

    /* "edgedb/protocol/codecs/enum.pyx":24
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):
 *         if not isinstance(obj, (datatypes.EnumValue, str)):             # <<<<<<<<<<<<<<
 *             raise TypeError(
 *                 f'a str or edgedb.EnumValue is expected as a valid '
 */
  }

  /* "edgedb/protocol/codecs/enum.pyx":28
 *                 f'a str or edgedb.EnumValue is expected as a valid '
 *                 f'enum argument, got {type(obj).__name__}')
 *         pgproto.text_encode(DEFAULT_CODEC_CONTEXT, buf, str(obj))             # <<<<<<<<<<<<<<
 * 
 *     cdef decode(self, FRBuffer *buf):
 */
  __pyx_t_5 = ((PyObject *)__pyx_v_6edgedb_8protocol_8protocol_DEFAULT_CODEC_CONTEXT);
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(11, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __pyx_f_6edgedb_7pgproto_7pgproto_text_encode(((struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *)__pyx_t_5), __pyx_v_buf, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(11, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "edgedb/protocol/codecs/enum.pyx":23
 * cdef class EnumCodec(BaseCodec):
 * 
 *     cdef encode(self, WriteBuffer buf, object obj):             # <<<<<<<<<<<<<<
 *         if not isinstance(obj, (datatypes.EnumValue, str)):
 *             raise TypeError(
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("edgedb.protocol.protocol.EnumCodec.encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/enum.pyx":30
 *         pgproto.text_encode(DEFAULT_CODEC_CONTEXT, buf, str(obj))
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         label = pgproto.text_decode(DEFAULT_CODEC_CONTEXT, buf)
 *         return datatypes.EnumValue(self.descriptor, label)
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_9EnumCodec_decode(struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  PyObject *__pyx_v_label = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("decode", 0);

  /* "edgedb/protocol/codecs/enum.pyx":31
 * 
 *     cdef decode(self, FRBuffer *buf):
 *         label = pgproto.text_decode(DEFAULT_CODEC_CONTEXT, buf)             # <<<<<<<<<<<<<<
 *         return datatypes.EnumValue(self.descriptor, label)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_6edgedb_8protocol_8protocol_DEFAULT_CODEC_CONTEXT);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_6edgedb_7pgproto_7pgproto_text_decode(((struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *)__pyx_t_1), __pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_label = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/enum.pyx":32
 *     cdef decode(self, FRBuffer *buf):
 *         label = pgproto.text_decode(DEFAULT_CODEC_CONTEXT, buf)
 *         return datatypes.EnumValue(self.descriptor, label)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->descriptor);
  __Pyx_GIVEREF(__pyx_v_self->descriptor);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->descriptor);
  __Pyx_INCREF(__pyx_v_label);
  __Pyx_GIVEREF(__pyx_v_label);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_label);
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6edgedb_9datatypes_9datatypes_EnumValue), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/enum.pyx":30
 *         pgproto.text_encode(DEFAULT_CODEC_CONTEXT, buf, str(obj))
 * 
 *     cdef decode(self, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *         label = pgproto.text_decode(DEFAULT_CODEC_CONTEXT, buf)
 *         return datatypes.EnumValue(self.descriptor, label)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("edgedb.protocol.protocol.EnumCodec.decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_label);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/enum.pyx":35
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid, tuple enum_labels):             # <<<<<<<<<<<<<<
 *         cdef:
 *             EnumCodec codec
 */

static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_9EnumCodec_new(PyObject *__pyx_v_tid, PyObject *__pyx_v_enum_labels) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *__pyx_v_codec = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("new", 0);

  /* "edgedb/protocol/codecs/enum.pyx":39
 *             EnumCodec codec
 * 
 *         codec = EnumCodec.__new__(EnumCodec)             # <<<<<<<<<<<<<<
 * 
 *         codec.tid = tid
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_6edgedb_8protocol_8protocol_EnumCodec(((PyTypeObject *)__pyx_ptype_6edgedb_8protocol_8protocol_EnumCodec), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 39, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/enum.pyx":41
 *         codec = EnumCodec.__new__(EnumCodec)
 * 
 *         codec.tid = tid             # <<<<<<<<<<<<<<
 *         codec.name = 'Enum'
 *         codec.descriptor = datatypes.EnumDescriptor(
 */
  __Pyx_INCREF(__pyx_v_tid);
  __Pyx_GIVEREF(__pyx_v_tid);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.tid);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.tid);
  __pyx_v_codec->__pyx_base.tid = __pyx_v_tid;

  /* "edgedb/protocol/codecs/enum.pyx":42
 * 
 *         codec.tid = tid
 *         codec.name = 'Enum'             # <<<<<<<<<<<<<<
 *         codec.descriptor = datatypes.EnumDescriptor(
 *             pgproto.UUID(tid), enum_labels)
 */
  __Pyx_INCREF(__pyx_n_u_Enum);
  __Pyx_GIVEREF(__pyx_n_u_Enum);
  __Pyx_GOTREF(__pyx_v_codec->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_codec->__pyx_base.name);
  __pyx_v_codec->__pyx_base.name = __pyx_n_u_Enum;

  /* "edgedb/protocol/codecs/enum.pyx":44
 *         codec.name = 'Enum'
 *         codec.descriptor = datatypes.EnumDescriptor(
 *             pgproto.UUID(tid), enum_labels)             # <<<<<<<<<<<<<<
 * 
 *         return codec
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pgproto); if (unlikely(!__pyx_t_2)) __PYX_ERR(11, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_tid) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_tid);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "edgedb/protocol/codecs/enum.pyx":43
 *         codec.tid = tid
 *         codec.name = 'Enum'
 *         codec.descriptor = datatypes.EnumDescriptor(             # <<<<<<<<<<<<<<
 *             pgproto.UUID(tid), enum_labels)
 * 
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(11, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_enum_labels);
  __Pyx_GIVEREF(__pyx_v_enum_labels);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_enum_labels);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6edgedb_9datatypes_9datatypes_EnumDescriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(11, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_codec->descriptor);
  __Pyx_DECREF(__pyx_v_codec->descriptor);
  __pyx_v_codec->descriptor = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/enum.pyx":46
 *             pgproto.UUID(tid), enum_labels)
 * 
 *         return codec             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_codec));
  __pyx_r = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_codec);
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/enum.pyx":35
 * 
 *     @staticmethod
 *     cdef BaseCodec new(bytes tid, tuple enum_labels):             # <<<<<<<<<<<<<<
 *         cdef:
 *             EnumCodec codec
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.EnumCodec.new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_9EnumCodec_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_9EnumCodec_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_9EnumCodec___reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_9EnumCodec___reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.EnumCodec.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_9EnumCodec_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_9EnumCodec_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_9EnumCodec_2__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_9EnumCodec_2__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.EnumCodec.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":60
 * cdef class CodecsRegistry:
 * 
 *     def __init__(self, *, cache_size=1000):             # <<<<<<<<<<<<<<
 *         self.codecs_build_cache = LRUMapping(maxsize=_CODECS_BUILD_CACHE_SIZE)
 *         self.codecs = LRUMapping(maxsize=cache_size)
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_14CodecsRegistry_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_14CodecsRegistry_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_cache_size = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cache_size,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_1000);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (kw_args == 1) {
        const Py_ssize_t index = 0;
        PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
        if (value) { values[index] = value; kw_args--; }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "__init__") < 0)) __PYX_ERR(4, 60, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
      goto __pyx_L5_argtuple_error;
    } else {
    }
    __pyx_v_cache_size = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 60, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecsRegistry.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14CodecsRegistry___init__(((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v_self), __pyx_v_cache_size);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_14CodecsRegistry___init__(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self, PyObject *__pyx_v_cache_size) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":61
 * 
 *     def __init__(self, *, cache_size=1000):
 *         self.codecs_build_cache = LRUMapping(maxsize=_CODECS_BUILD_CACHE_SIZE)             # <<<<<<<<<<<<<<
 *         self.codecs = LRUMapping(maxsize=cache_size)
 *         self.base_codec_overrides = {}
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_maxsize, __pyx_int_200) < 0) __PYX_ERR(4, 61, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6edgedb_8protocol_8protocol_LRUMapping), __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->codecs_build_cache);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->codecs_build_cache));
  __pyx_v_self->codecs_build_cache = ((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":62
 *     def __init__(self, *, cache_size=1000):
 *         self.codecs_build_cache = LRUMapping(maxsize=_CODECS_BUILD_CACHE_SIZE)
 *         self.codecs = LRUMapping(maxsize=cache_size)             # <<<<<<<<<<<<<<
 *         self.base_codec_overrides = {}
 * 
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_maxsize, __pyx_v_cache_size) < 0) __PYX_ERR(4, 62, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6edgedb_8protocol_8protocol_LRUMapping), __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->codecs);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->codecs));
  __pyx_v_self->codecs = ((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":63
 *         self.codecs_build_cache = LRUMapping(maxsize=_CODECS_BUILD_CACHE_SIZE)
 *         self.codecs = LRUMapping(maxsize=cache_size)
 *         self.base_codec_overrides = {}             # <<<<<<<<<<<<<<
 * 
 *     def clear_cache(self):
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 63, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->base_codec_overrides);
  __Pyx_DECREF(__pyx_v_self->base_codec_overrides);
  __pyx_v_self->base_codec_overrides = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":60
 * cdef class CodecsRegistry:
 * 
 *     def __init__(self, *, cache_size=1000):             # <<<<<<<<<<<<<<
 *         self.codecs_build_cache = LRUMapping(maxsize=_CODECS_BUILD_CACHE_SIZE)
 *         self.codecs = LRUMapping(maxsize=cache_size)
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecsRegistry.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":65
 *         self.base_codec_overrides = {}
 * 
 *     def clear_cache(self):             # <<<<<<<<<<<<<<
 *         self.codecs.clear()
 *         self.codecs_build_cache.clear()
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14CodecsRegistry_3clear_cache(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14CodecsRegistry_3clear_cache(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear_cache (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14CodecsRegistry_2clear_cache(((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14CodecsRegistry_2clear_cache(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("clear_cache", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":66
 * 
 *     def clear_cache(self):
 *         self.codecs.clear()             # <<<<<<<<<<<<<<
 *         self.codecs_build_cache.clear()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->codecs), __pyx_n_s_clear); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":67
 *     def clear_cache(self):
 *         self.codecs.clear()
 *         self.codecs_build_cache.clear()             # <<<<<<<<<<<<<<
 * 
 *     def set_type_codec(self, typeid, *, encoder, decoder, format):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->codecs_build_cache), __pyx_n_s_clear); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":65
 *         self.base_codec_overrides = {}
 * 
 *     def clear_cache(self):             # <<<<<<<<<<<<<<
 *         self.codecs.clear()
 *         self.codecs_build_cache.clear()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecsRegistry.clear_cache", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":69
 *         self.codecs_build_cache.clear()
 * 
 *     def set_type_codec(self, typeid, *, encoder, decoder, format):             # <<<<<<<<<<<<<<
 *         if format != 'python':
 *             raise ValueError('"python" is the only valid format')
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14CodecsRegistry_5set_type_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14CodecsRegistry_5set_type_codec(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_typeid = 0;
  PyObject *__pyx_v_encoder = 0;
  PyObject *__pyx_v_decoder = 0;
  PyObject *__pyx_v_format = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_type_codec (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_typeid,&__pyx_n_s_encoder,&__pyx_n_s_decoder,&__pyx_n_s_format,0};
    PyObject* values[4] = {0,0,0,0};
    if (likely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_typeid)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_encoder)) != 0)) kw_args--;
        else {
          __Pyx_RaiseKeywordRequired("set_type_codec", __pyx_n_s_encoder); __PYX_ERR(4, 69, __pyx_L3_error)
        }
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_decoder)) != 0)) kw_args--;
        else {
          __Pyx_RaiseKeywordRequired("set_type_codec", __pyx_n_s_decoder); __PYX_ERR(4, 69, __pyx_L3_error)
        }
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--;
        else {
          __Pyx_RaiseKeywordRequired("set_type_codec", __pyx_n_s_format); __PYX_ERR(4, 69, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_type_codec") < 0)) __PYX_ERR(4, 69, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      __Pyx_RaiseKeywordRequired("set_type_codec", __pyx_n_s_encoder); __PYX_ERR(4, 69, __pyx_L3_error)
    }
    __pyx_v_typeid = values[0];
    __pyx_v_encoder = values[1];
    __pyx_v_decoder = values[2];
    __pyx_v_format = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_type_codec", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(4, 69, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecsRegistry.set_type_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14CodecsRegistry_4set_type_codec(((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v_self), __pyx_v_typeid, __pyx_v_encoder, __pyx_v_decoder, __pyx_v_format);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14CodecsRegistry_4set_type_codec(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self, PyObject *__pyx_v_typeid, PyObject *__pyx_v_encoder, PyObject *__pyx_v_decoder, PyObject *__pyx_v_format) {
  PyObject *__pyx_v_basecodec = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_type_codec", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":70
 * 
 *     def set_type_codec(self, typeid, *, encoder, decoder, format):
 *         if format != 'python':             # <<<<<<<<<<<<<<
 *             raise ValueError('"python" is the only valid format')
 *         if not isinstance(typeid, uuid.UUID):
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_format, __pyx_n_u_python, Py_NE)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(4, 70, __pyx_L1_error)
  if (unlikely(__pyx_t_1)) {

    /* "edgedb/protocol/codecs/codecs.pyx":71
 *     def set_type_codec(self, typeid, *, encoder, decoder, format):
 *         if format != 'python':
 *             raise ValueError('"python" is the only valid format')             # <<<<<<<<<<<<<<
 *         if not isinstance(typeid, uuid.UUID):
 *             raise TypeError('typeid must be a UUID')
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 71, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(4, 71, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":70
 * 
 *     def set_type_codec(self, typeid, *, encoder, decoder, format):
 *         if format != 'python':             # <<<<<<<<<<<<<<
 *             raise ValueError('"python" is the only valid format')
 *         if not isinstance(typeid, uuid.UUID):
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":72
 *         if format != 'python':
 *             raise ValueError('"python" is the only valid format')
 *         if not isinstance(typeid, uuid.UUID):             # <<<<<<<<<<<<<<
 *             raise TypeError('typeid must be a UUID')
 *         basecodec = BASE_SCALAR_CODECS.get(typeid.bytes)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_1 = PyObject_IsInstance(__pyx_v_typeid, __pyx_t_3); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(4, 72, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = ((!(__pyx_t_1 != 0)) != 0);
  if (unlikely(__pyx_t_4)) {

    /* "edgedb/protocol/codecs/codecs.pyx":73
 *             raise ValueError('"python" is the only valid format')
 *         if not isinstance(typeid, uuid.UUID):
 *             raise TypeError('typeid must be a UUID')             # <<<<<<<<<<<<<<
 *         basecodec = BASE_SCALAR_CODECS.get(typeid.bytes)
 *         if basecodec is None:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 73, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 73, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":72
 *         if format != 'python':
 *             raise ValueError('"python" is the only valid format')
 *         if not isinstance(typeid, uuid.UUID):             # <<<<<<<<<<<<<<
 *             raise TypeError('typeid must be a UUID')
 *         basecodec = BASE_SCALAR_CODECS.get(typeid.bytes)
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":74
 *         if not isinstance(typeid, uuid.UUID):
 *             raise TypeError('typeid must be a UUID')
 *         basecodec = BASE_SCALAR_CODECS.get(typeid.bytes)             # <<<<<<<<<<<<<<
 *         if basecodec is None:
 *             raise ValueError(
 */
  if (unlikely(__pyx_v_6edgedb_8protocol_8protocol_BASE_SCALAR_CODECS == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get");
    __PYX_ERR(4, 74, __pyx_L1_error)
  }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_typeid, __pyx_n_s_bytes); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_6edgedb_8protocol_8protocol_BASE_SCALAR_CODECS, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_basecodec = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":75
 *             raise TypeError('typeid must be a UUID')
 *         basecodec = BASE_SCALAR_CODECS.get(typeid.bytes)
 *         if basecodec is None:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 f'{typeid} does not correspond to any known base type')
 */
  __pyx_t_4 = (__pyx_v_basecodec == Py_None);
  __pyx_t_1 = (__pyx_t_4 != 0);
  if (unlikely(__pyx_t_1)) {

    /* "edgedb/protocol/codecs/codecs.pyx":77
 *         if basecodec is None:
 *             raise ValueError(
 *                 f'{typeid} does not correspond to any known base type')             # <<<<<<<<<<<<<<
 *         self.base_codec_overrides[typeid.bytes] = CodecPythonOverride.new(
 *             typeid.bytes,
 */
    __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_v_typeid, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 77, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_t_2, __pyx_kp_u_does_not_correspond_to_any_know); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 77, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":76
 *         basecodec = BASE_SCALAR_CODECS.get(typeid.bytes)
 *         if basecodec is None:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 f'{typeid} does not correspond to any known base type')
 *         self.base_codec_overrides[typeid.bytes] = CodecPythonOverride.new(
 */
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 76, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(4, 76, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":75
 *             raise TypeError('typeid must be a UUID')
 *         basecodec = BASE_SCALAR_CODECS.get(typeid.bytes)
 *         if basecodec is None:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 f'{typeid} does not correspond to any known base type')
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":79
 *                 f'{typeid} does not correspond to any known base type')
 *         self.base_codec_overrides[typeid.bytes] = CodecPythonOverride.new(
 *             typeid.bytes,             # <<<<<<<<<<<<<<
 *             basecodec,
 *             encoder,
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_typeid, __pyx_n_s_bytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 79, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(4, 79, __pyx_L1_error)

  /* "edgedb/protocol/codecs/codecs.pyx":80
 *         self.base_codec_overrides[typeid.bytes] = CodecPythonOverride.new(
 *             typeid.bytes,
 *             basecodec,             # <<<<<<<<<<<<<<
 *             encoder,
 *             decoder,
 */
  if (!(likely(((__pyx_v_basecodec) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_basecodec, __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec))))) __PYX_ERR(4, 80, __pyx_L1_error)

  /* "edgedb/protocol/codecs/codecs.pyx":78
 *             raise ValueError(
 *                 f'{typeid} does not correspond to any known base type')
 *         self.base_codec_overrides[typeid.bytes] = CodecPythonOverride.new(             # <<<<<<<<<<<<<<
 *             typeid.bytes,
 *             basecodec,
 */
  __pyx_t_3 = ((PyObject *)__pyx_f_6edgedb_8protocol_8protocol_19CodecPythonOverride_new(((PyObject*)__pyx_t_2), ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_basecodec), __pyx_v_encoder, __pyx_v_decoder)); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(__pyx_v_self->base_codec_overrides == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 78, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_typeid, __pyx_n_s_bytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(PyDict_SetItem(__pyx_v_self->base_codec_overrides, __pyx_t_2, __pyx_t_3) < 0)) __PYX_ERR(4, 78, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":69
 *         self.codecs_build_cache.clear()
 * 
 *     def set_type_codec(self, typeid, *, encoder, decoder, format):             # <<<<<<<<<<<<<<
 *         if format != 'python':
 *             raise ValueError('"python" is the only valid format')
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecsRegistry.set_type_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_basecodec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":85
 *         )
 * 
 *     cdef BaseCodec _build_codec(self, FRBuffer *spec, list codecs_list,             # <<<<<<<<<<<<<<
 *                                 protocol_version):
 *         cdef:
 */

static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_14CodecsRegistry__build_codec(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_spec, PyObject *__pyx_v_codecs_list, PyObject *__pyx_v_protocol_version) {
  uint8_t __pyx_v_t;
  PyObject *__pyx_v_tid = 0;
  uint16_t __pyx_v_els;
  uint16_t __pyx_v_i;
  uint32_t __pyx_v_str_len;
  uint16_t __pyx_v_pos;
  int32_t __pyx_v_dim_len;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_res = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_sub_codec = 0;
  PyObject *__pyx_v_codecs = NULL;
  PyObject *__pyx_v_names = NULL;
  PyObject *__pyx_v_flags = NULL;
  PyObject *__pyx_v_cards = NULL;
  uint32_t __pyx_v_flag;
  long __pyx_v_cardinality;
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_codec = NULL;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  uint16_t __pyx_t_5;
  uint16_t __pyx_t_6;
  uint16_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_build_codec", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":88
 *                                 protocol_version):
 *         cdef:
 *             uint8_t t = <uint8_t>(frb_read(spec, 1)[0])             # <<<<<<<<<<<<<<
 *             bytes tid = frb_read(spec, 16)[:16]
 *             uint16_t els
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 1); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 88, __pyx_L1_error)
  __pyx_v_t = ((uint8_t)(__pyx_t_1[0]));

  /* "edgedb/protocol/codecs/codecs.pyx":89
 *         cdef:
 *             uint8_t t = <uint8_t>(frb_read(spec, 1)[0])
 *             bytes tid = frb_read(spec, 16)[:16]             # <<<<<<<<<<<<<<
 *             uint16_t els
 *             uint16_t i
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 16); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 89, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_t_1 + 0, 16 - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_tid = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":98
 *             BaseCodec sub_codec
 * 
 *         res = self.codecs.get(tid, None)             # <<<<<<<<<<<<<<
 *         if res is None:
 *             res = self.codecs_build_cache.get(tid, None)
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_v_self->codecs->__pyx_vtab)->get(__pyx_v_self->codecs, __pyx_v_tid, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 98, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec))))) __PYX_ERR(4, 98, __pyx_L1_error)
  __pyx_v_res = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":99
 * 
 *         res = self.codecs.get(tid, None)
 *         if res is None:             # <<<<<<<<<<<<<<
 *             res = self.codecs_build_cache.get(tid, None)
 *         if res is not None:
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_res) == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "edgedb/protocol/codecs/codecs.pyx":100
 *         res = self.codecs.get(tid, None)
 *         if res is None:
 *             res = self.codecs_build_cache.get(tid, None)             # <<<<<<<<<<<<<<
 *         if res is not None:
 *             # We have a codec for this "tid"; advance the buffer
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_v_self->codecs_build_cache->__pyx_vtab)->get(__pyx_v_self->codecs_build_cache, __pyx_v_tid, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 100, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec))))) __PYX_ERR(4, 100, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_res, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":99
 * 
 *         res = self.codecs.get(tid, None)
 *         if res is None:             # <<<<<<<<<<<<<<
 *             res = self.codecs_build_cache.get(tid, None)
 *         if res is not None:
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":101
 *         if res is None:
 *             res = self.codecs_build_cache.get(tid, None)
 *         if res is not None:             # <<<<<<<<<<<<<<
 *             # We have a codec for this "tid"; advance the buffer
 *             # so that we can process the next codec.
 */
  __pyx_t_4 = (((PyObject *)__pyx_v_res) != Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {

    /* "edgedb/protocol/codecs/codecs.pyx":105
 *             # so that we can process the next codec.
 * 
 *             if t == CTYPE_SET:             # <<<<<<<<<<<<<<
 *                 frb_read(spec, 2)
 * 
 */
    __pyx_t_3 = ((__pyx_v_t == 0) != 0);
    if (__pyx_t_3) {

      /* "edgedb/protocol/codecs/codecs.pyx":106
 * 
 *             if t == CTYPE_SET:
 *                 frb_read(spec, 2)             # <<<<<<<<<<<<<<
 * 
 *             elif t == CTYPE_SHAPE:
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 106, __pyx_L1_error)

      /* "edgedb/protocol/codecs/codecs.pyx":105
 *             # so that we can process the next codec.
 * 
 *             if t == CTYPE_SET:             # <<<<<<<<<<<<<<
 *                 frb_read(spec, 2)
 * 
 */
      goto __pyx_L5;
    }

    /* "edgedb/protocol/codecs/codecs.pyx":108
 *                 frb_read(spec, 2)
 * 
 *             elif t == CTYPE_SHAPE:             # <<<<<<<<<<<<<<
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):
 */
    __pyx_t_3 = ((__pyx_v_t == 1) != 0);
    if (__pyx_t_3) {

      /* "edgedb/protocol/codecs/codecs.pyx":109
 * 
 *             elif t == CTYPE_SHAPE:
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 *                 for i in range(els):
 *                     if protocol_version >= (0, 11):
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 109, __pyx_L1_error)
      __pyx_v_els = ((uint16_t)unpack_int16(__pyx_t_1));

      /* "edgedb/protocol/codecs/codecs.pyx":110
 *             elif t == CTYPE_SHAPE:
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):             # <<<<<<<<<<<<<<
 *                     if protocol_version >= (0, 11):
 *                         frb_read(spec, 4)  # flags
 */
      __pyx_t_5 = __pyx_v_els;
      __pyx_t_6 = __pyx_t_5;
      for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
        __pyx_v_i = __pyx_t_7;

        /* "edgedb/protocol/codecs/codecs.pyx":111
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):
 *                     if protocol_version >= (0, 11):             # <<<<<<<<<<<<<<
 *                         frb_read(spec, 4)  # flags
 *                         frb_read(spec, 1)  # cardinality
 */
        __pyx_t_2 = PyObject_RichCompare(__pyx_v_protocol_version, __pyx_tuple__50, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 111, __pyx_L1_error)
        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(4, 111, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (__pyx_t_3) {

          /* "edgedb/protocol/codecs/codecs.pyx":112
 *                 for i in range(els):
 *                     if protocol_version >= (0, 11):
 *                         frb_read(spec, 4)  # flags             # <<<<<<<<<<<<<<
 *                         frb_read(spec, 1)  # cardinality
 *                     else:
 */
          __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 112, __pyx_L1_error)

          /* "edgedb/protocol/codecs/codecs.pyx":113
 *                     if protocol_version >= (0, 11):
 *                         frb_read(spec, 4)  # flags
 *                         frb_read(spec, 1)  # cardinality             # <<<<<<<<<<<<<<
 *                     else:
 *                         frb_read(spec, 1)  # flags
 */
          __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 1); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 113, __pyx_L1_error)

          /* "edgedb/protocol/codecs/codecs.pyx":111
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):
 *                     if protocol_version >= (0, 11):             # <<<<<<<<<<<<<<
 *                         frb_read(spec, 4)  # flags
 *                         frb_read(spec, 1)  # cardinality
 */
          goto __pyx_L8;
        }

        /* "edgedb/protocol/codecs/codecs.pyx":115
 *                         frb_read(spec, 1)  # cardinality
 *                     else:
 *                         frb_read(spec, 1)  # flags             # <<<<<<<<<<<<<<
 *                     str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                     # read the <str> (`str_len` bytes) and <pos> (2 bytes)
 */
        /*else*/ {
          __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 1); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 115, __pyx_L1_error)
        }
        __pyx_L8:;

        /* "edgedb/protocol/codecs/codecs.pyx":116
 *                     else:
 *                         frb_read(spec, 1)  # flags
 *                     str_len = hton.unpack_uint32(frb_read(spec, 4))             # <<<<<<<<<<<<<<
 *                     # read the <str> (`str_len` bytes) and <pos> (2 bytes)
 *                     frb_read(spec, str_len + 2)
 */
        __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 116, __pyx_L1_error)
        __pyx_v_str_len = unpack_uint32(__pyx_t_1);

        /* "edgedb/protocol/codecs/codecs.pyx":118
 *                     str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                     # read the <str> (`str_len` bytes) and <pos> (2 bytes)
 *                     frb_read(spec, str_len + 2)             # <<<<<<<<<<<<<<
 * 
 *             elif t == CTYPE_BASE_SCALAR:
 */
        __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, (__pyx_v_str_len + 2)); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 118, __pyx_L1_error)
      }

      /* "edgedb/protocol/codecs/codecs.pyx":108
 *                 frb_read(spec, 2)
 * 
 *             elif t == CTYPE_SHAPE:             # <<<<<<<<<<<<<<
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):
 */
      goto __pyx_L5;
    }

    /* "edgedb/protocol/codecs/codecs.pyx":120
 *                     frb_read(spec, str_len + 2)
 * 
 *             elif t == CTYPE_BASE_SCALAR:             # <<<<<<<<<<<<<<
 *                 pass
 * 
 */
    __pyx_t_3 = ((__pyx_v_t == 2) != 0);
    if (__pyx_t_3) {
      goto __pyx_L5;
    }

    /* "edgedb/protocol/codecs/codecs.pyx":123
 *                 pass
 * 
 *             elif t == CTYPE_SCALAR:             # <<<<<<<<<<<<<<
 *                 frb_read(spec, 2)
 * 
 */
    __pyx_t_3 = ((__pyx_v_t == 3) != 0);
    if (__pyx_t_3) {

      /* "edgedb/protocol/codecs/codecs.pyx":124
 * 
 *             elif t == CTYPE_SCALAR:
 *                 frb_read(spec, 2)             # <<<<<<<<<<<<<<
 * 
 *             elif t == CTYPE_TUPLE:
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 124, __pyx_L1_error)

      /* "edgedb/protocol/codecs/codecs.pyx":123
 *                 pass
 * 
 *             elif t == CTYPE_SCALAR:             # <<<<<<<<<<<<<<
 *                 frb_read(spec, 2)
 * 
 */
      goto __pyx_L5;
    }

    /* "edgedb/protocol/codecs/codecs.pyx":126
 *                 frb_read(spec, 2)
 * 
 *             elif t == CTYPE_TUPLE:             # <<<<<<<<<<<<<<
 *                 # tuple
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 */
    __pyx_t_3 = ((__pyx_v_t == 4) != 0);
    if (__pyx_t_3) {

      /* "edgedb/protocol/codecs/codecs.pyx":128
 *             elif t == CTYPE_TUPLE:
 *                 # tuple
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 *                 for i in range(els):
 *                     frb_read(spec, 2)
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 128, __pyx_L1_error)
      __pyx_v_els = ((uint16_t)unpack_int16(__pyx_t_1));

      /* "edgedb/protocol/codecs/codecs.pyx":129
 *                 # tuple
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):             # <<<<<<<<<<<<<<
 *                     frb_read(spec, 2)
 * 
 */
      __pyx_t_5 = __pyx_v_els;
      __pyx_t_6 = __pyx_t_5;
      for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
        __pyx_v_i = __pyx_t_7;

        /* "edgedb/protocol/codecs/codecs.pyx":130
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):
 *                     frb_read(spec, 2)             # <<<<<<<<<<<<<<
 * 
 *             elif t == CTYPE_NAMEDTUPLE:
 */
        __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 130, __pyx_L1_error)
      }

      /* "edgedb/protocol/codecs/codecs.pyx":126
 *                 frb_read(spec, 2)
 * 
 *             elif t == CTYPE_TUPLE:             # <<<<<<<<<<<<<<
 *                 # tuple
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 */
      goto __pyx_L5;
    }

    /* "edgedb/protocol/codecs/codecs.pyx":132
 *                     frb_read(spec, 2)
 * 
 *             elif t == CTYPE_NAMEDTUPLE:             # <<<<<<<<<<<<<<
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):
 */
    __pyx_t_3 = ((__pyx_v_t == 5) != 0);
    if (__pyx_t_3) {

      /* "edgedb/protocol/codecs/codecs.pyx":133
 * 
 *             elif t == CTYPE_NAMEDTUPLE:
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 *                 for i in range(els):
 *                     str_len = hton.unpack_uint32(frb_read(spec, 4))
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 133, __pyx_L1_error)
      __pyx_v_els = ((uint16_t)unpack_int16(__pyx_t_1));

      /* "edgedb/protocol/codecs/codecs.pyx":134
 *             elif t == CTYPE_NAMEDTUPLE:
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):             # <<<<<<<<<<<<<<
 *                     str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                     frb_read(spec, str_len + 2)
 */
      __pyx_t_5 = __pyx_v_els;
      __pyx_t_6 = __pyx_t_5;
      for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
        __pyx_v_i = __pyx_t_7;

        /* "edgedb/protocol/codecs/codecs.pyx":135
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):
 *                     str_len = hton.unpack_uint32(frb_read(spec, 4))             # <<<<<<<<<<<<<<
 *                     frb_read(spec, str_len + 2)
 * 
 */
        __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 135, __pyx_L1_error)
        __pyx_v_str_len = unpack_uint32(__pyx_t_1);

        /* "edgedb/protocol/codecs/codecs.pyx":136
 *                 for i in range(els):
 *                     str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                     frb_read(spec, str_len + 2)             # <<<<<<<<<<<<<<
 * 
 *             elif t == CTYPE_ARRAY:
 */
        __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, (__pyx_v_str_len + 2)); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 136, __pyx_L1_error)
      }

      /* "edgedb/protocol/codecs/codecs.pyx":132
 *                     frb_read(spec, 2)
 * 
 *             elif t == CTYPE_NAMEDTUPLE:             # <<<<<<<<<<<<<<
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):
 */
      goto __pyx_L5;
    }

    /* "edgedb/protocol/codecs/codecs.pyx":138
 *                     frb_read(spec, str_len + 2)
 * 
 *             elif t == CTYPE_ARRAY:             # <<<<<<<<<<<<<<
 *                 frb_read(spec, 2)
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 */
    __pyx_t_3 = ((__pyx_v_t == 6) != 0);
    if (__pyx_t_3) {

      /* "edgedb/protocol/codecs/codecs.pyx":139
 * 
 *             elif t == CTYPE_ARRAY:
 *                 frb_read(spec, 2)             # <<<<<<<<<<<<<<
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 if els != 1:
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 139, __pyx_L1_error)

      /* "edgedb/protocol/codecs/codecs.pyx":140
 *             elif t == CTYPE_ARRAY:
 *                 frb_read(spec, 2)
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 *                 if els != 1:
 *                     raise NotImplementedError(
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 140, __pyx_L1_error)
      __pyx_v_els = ((uint16_t)unpack_int16(__pyx_t_1));

      /* "edgedb/protocol/codecs/codecs.pyx":141
 *                 frb_read(spec, 2)
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 if els != 1:             # <<<<<<<<<<<<<<
 *                     raise NotImplementedError(
 *                         'cannot handle arrays with more than one dimension')
 */
      __pyx_t_3 = ((__pyx_v_els != 1) != 0);
      if (unlikely(__pyx_t_3)) {

        /* "edgedb/protocol/codecs/codecs.pyx":142
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 if els != 1:
 *                     raise NotImplementedError(             # <<<<<<<<<<<<<<
 *                         'cannot handle arrays with more than one dimension')
 *                 # First dimension length.
 */
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 142, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __PYX_ERR(4, 142, __pyx_L1_error)

        /* "edgedb/protocol/codecs/codecs.pyx":141
 *                 frb_read(spec, 2)
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 if els != 1:             # <<<<<<<<<<<<<<
 *                     raise NotImplementedError(
 *                         'cannot handle arrays with more than one dimension')
 */
      }

      /* "edgedb/protocol/codecs/codecs.pyx":145
 *                         'cannot handle arrays with more than one dimension')
 *                 # First dimension length.
 *                 frb_read(spec, 4)             # <<<<<<<<<<<<<<
 * 
 *             elif t == CTYPE_ENUM:
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 145, __pyx_L1_error)

      /* "edgedb/protocol/codecs/codecs.pyx":138
 *                     frb_read(spec, str_len + 2)
 * 
 *             elif t == CTYPE_ARRAY:             # <<<<<<<<<<<<<<
 *                 frb_read(spec, 2)
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 */
      goto __pyx_L5;
    }

    /* "edgedb/protocol/codecs/codecs.pyx":147
 *                 frb_read(spec, 4)
 * 
 *             elif t == CTYPE_ENUM:             # <<<<<<<<<<<<<<
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):
 */
    __pyx_t_3 = ((__pyx_v_t == 7) != 0);
    if (__pyx_t_3) {

      /* "edgedb/protocol/codecs/codecs.pyx":148
 * 
 *             elif t == CTYPE_ENUM:
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 *                 for i in range(els):
 *                     str_len = hton.unpack_uint32(frb_read(spec, 4))
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 148, __pyx_L1_error)
      __pyx_v_els = ((uint16_t)unpack_int16(__pyx_t_1));

      /* "edgedb/protocol/codecs/codecs.pyx":149
 *             elif t == CTYPE_ENUM:
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):             # <<<<<<<<<<<<<<
 *                     str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                     frb_read(spec, str_len)
 */
      __pyx_t_5 = __pyx_v_els;
      __pyx_t_6 = __pyx_t_5;
      for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
        __pyx_v_i = __pyx_t_7;

        /* "edgedb/protocol/codecs/codecs.pyx":150
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):
 *                     str_len = hton.unpack_uint32(frb_read(spec, 4))             # <<<<<<<<<<<<<<
 *                     frb_read(spec, str_len)
 * 
 */
        __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 150, __pyx_L1_error)
        __pyx_v_str_len = unpack_uint32(__pyx_t_1);

        /* "edgedb/protocol/codecs/codecs.pyx":151
 *                 for i in range(els):
 *                     str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                     frb_read(spec, str_len)             # <<<<<<<<<<<<<<
 * 
 *             elif (t >= 0x7f and t <= 0xff):
 */
        __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, __pyx_v_str_len); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 151, __pyx_L1_error)
      }

      /* "edgedb/protocol/codecs/codecs.pyx":147
 *                 frb_read(spec, 4)
 * 
 *             elif t == CTYPE_ENUM:             # <<<<<<<<<<<<<<
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):
 */
      goto __pyx_L5;
    }

    /* "edgedb/protocol/codecs/codecs.pyx":153
 *                     frb_read(spec, str_len)
 * 
 *             elif (t >= 0x7f and t <= 0xff):             # <<<<<<<<<<<<<<
 *                 # Ignore all type annotations.
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))
 */
    __pyx_t_4 = ((__pyx_v_t >= 0x7f) != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_3 = __pyx_t_4;
      goto __pyx_L16_bool_binop_done;
    }
    __pyx_t_4 = ((__pyx_v_t <= 0xff) != 0);
    __pyx_t_3 = __pyx_t_4;
    __pyx_L16_bool_binop_done:;
    if (likely(__pyx_t_3)) {

      /* "edgedb/protocol/codecs/codecs.pyx":155
 *             elif (t >= 0x7f and t <= 0xff):
 *                 # Ignore all type annotations.
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))             # <<<<<<<<<<<<<<
 *                 frb_read(spec, str_len)
 *                 return None
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 155, __pyx_L1_error)
      __pyx_v_str_len = unpack_uint32(__pyx_t_1);

      /* "edgedb/protocol/codecs/codecs.pyx":156
 *                 # Ignore all type annotations.
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                 frb_read(spec, str_len)             # <<<<<<<<<<<<<<
 *                 return None
 * 
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, __pyx_v_str_len); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 156, __pyx_L1_error)

      /* "edgedb/protocol/codecs/codecs.pyx":157
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                 frb_read(spec, str_len)
 *                 return None             # <<<<<<<<<<<<<<
 * 
 *             else:
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_r = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)Py_None); __Pyx_INCREF(Py_None);
      goto __pyx_L0;

      /* "edgedb/protocol/codecs/codecs.pyx":153
 *                     frb_read(spec, str_len)
 * 
 *             elif (t >= 0x7f and t <= 0xff):             # <<<<<<<<<<<<<<
 *                 # Ignore all type annotations.
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))
 */
    }

    /* "edgedb/protocol/codecs/codecs.pyx":160
 * 
 *             else:
 *                 raise NotImplementedError(             # <<<<<<<<<<<<<<
 *                     f'no codec implementation for EdgeDB data class {t}')
 * 
 */
    /*else*/ {

      /* "edgedb/protocol/codecs/codecs.pyx":161
 *             else:
 *                 raise NotImplementedError(
 *                     f'no codec implementation for EdgeDB data class {t}')             # <<<<<<<<<<<<<<
 * 
 *             return res
 */
      __pyx_t_2 = __Pyx_PyInt_From_uint8_t(__pyx_v_t); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 161, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 161, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_no_codec_implementation_for_Edge, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 161, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "edgedb/protocol/codecs/codecs.pyx":160
 * 
 *             else:
 *                 raise NotImplementedError(             # <<<<<<<<<<<<<<
 *                     f'no codec implementation for EdgeDB data class {t}')
 * 
 */
      __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_NotImplementedError, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(4, 160, __pyx_L1_error)
    }
    __pyx_L5:;

    /* "edgedb/protocol/codecs/codecs.pyx":163
 *                     f'no codec implementation for EdgeDB data class {t}')
 * 
 *             return res             # <<<<<<<<<<<<<<
 * 
 *         if t == CTYPE_SET:
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_res));
    __pyx_r = __pyx_v_res;
    goto __pyx_L0;

    /* "edgedb/protocol/codecs/codecs.pyx":101
 *         if res is None:
 *             res = self.codecs_build_cache.get(tid, None)
 *         if res is not None:             # <<<<<<<<<<<<<<
 *             # We have a codec for this "tid"; advance the buffer
 *             # so that we can process the next codec.
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":165
 *             return res
 * 
 *         if t == CTYPE_SET:             # <<<<<<<<<<<<<<
 *             pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             sub_codec = <BaseCodec>codecs_list[pos]
 */
  switch (__pyx_v_t) {
    case 0:

    /* "edgedb/protocol/codecs/codecs.pyx":166
 * 
 *         if t == CTYPE_SET:
 *             pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 *             sub_codec = <BaseCodec>codecs_list[pos]
 *             res = SetCodec.new(tid, sub_codec)
 */
    __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 166, __pyx_L1_error)
    __pyx_v_pos = ((uint16_t)unpack_int16(__pyx_t_1));

    /* "edgedb/protocol/codecs/codecs.pyx":167
 *         if t == CTYPE_SET:
 *             pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             sub_codec = <BaseCodec>codecs_list[pos]             # <<<<<<<<<<<<<<
 *             res = SetCodec.new(tid, sub_codec)
 * 
 */
    if (unlikely(__pyx_v_codecs_list == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(4, 167, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_GetItemInt_List(__pyx_v_codecs_list, __pyx_v_pos, uint16_t, 0, __Pyx_PyInt_From_uint16_t, 1, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 167, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_2 = __pyx_t_8;
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_v_sub_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":168
 *             pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             sub_codec = <BaseCodec>codecs_list[pos]
 *             res = SetCodec.new(tid, sub_codec)             # <<<<<<<<<<<<<<
 * 
 *         elif t == CTYPE_SHAPE:
 */
    __pyx_t_2 = ((PyObject *)__pyx_f_6edgedb_8protocol_8protocol_8SetCodec_new(__pyx_v_tid, __pyx_v_sub_codec)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 168, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_res, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":165
 *             return res
 * 
 *         if t == CTYPE_SET:             # <<<<<<<<<<<<<<
 *             pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             sub_codec = <BaseCodec>codecs_list[pos]
 */
    break;
    case 1:

    /* "edgedb/protocol/codecs/codecs.pyx":171
 * 
 *         elif t == CTYPE_SHAPE:
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 *             codecs = cpython.PyTuple_New(els)
 *             names = cpython.PyTuple_New(els)
 */
    __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 171, __pyx_L1_error)
    __pyx_v_els = ((uint16_t)unpack_int16(__pyx_t_1));

    /* "edgedb/protocol/codecs/codecs.pyx":172
 *         elif t == CTYPE_SHAPE:
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             codecs = cpython.PyTuple_New(els)             # <<<<<<<<<<<<<<
 *             names = cpython.PyTuple_New(els)
 *             flags = cpython.PyTuple_New(els)
 */
    __pyx_t_2 = PyTuple_New(__pyx_v_els); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_codecs = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":173
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             codecs = cpython.PyTuple_New(els)
 *             names = cpython.PyTuple_New(els)             # <<<<<<<<<<<<<<
 *             flags = cpython.PyTuple_New(els)
 *             cards = cpython.PyTuple_New(els)
 */
    __pyx_t_2 = PyTuple_New(__pyx_v_els); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 173, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_names = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":174
 *             codecs = cpython.PyTuple_New(els)
 *             names = cpython.PyTuple_New(els)
 *             flags = cpython.PyTuple_New(els)             # <<<<<<<<<<<<<<
 *             cards = cpython.PyTuple_New(els)
 *             for i in range(els):
 */
    __pyx_t_2 = PyTuple_New(__pyx_v_els); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 174, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_flags = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":175
 *             names = cpython.PyTuple_New(els)
 *             flags = cpython.PyTuple_New(els)
 *             cards = cpython.PyTuple_New(els)             # <<<<<<<<<<<<<<
 *             for i in range(els):
 *                 if protocol_version >= (0, 11):
 */
    __pyx_t_2 = PyTuple_New(__pyx_v_els); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 175, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_cards = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":176
 *             flags = cpython.PyTuple_New(els)
 *             cards = cpython.PyTuple_New(els)
 *             for i in range(els):             # <<<<<<<<<<<<<<
 *                 if protocol_version >= (0, 11):
 *                     flag = hton.unpack_uint32(frb_read(spec, 4))  # flags
 */
    __pyx_t_5 = __pyx_v_els;
    __pyx_t_6 = __pyx_t_5;
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
      __pyx_v_i = __pyx_t_7;

      /* "edgedb/protocol/codecs/codecs.pyx":177
 *             cards = cpython.PyTuple_New(els)
 *             for i in range(els):
 *                 if protocol_version >= (0, 11):             # <<<<<<<<<<<<<<
 *                     flag = hton.unpack_uint32(frb_read(spec, 4))  # flags
 *                     cardinality = <uint8_t>frb_read(spec, 1)[0]
 */
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_protocol_version, __pyx_tuple__50, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 177, __pyx_L1_error)
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(4, 177, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_3) {

        /* "edgedb/protocol/codecs/codecs.pyx":178
 *             for i in range(els):
 *                 if protocol_version >= (0, 11):
 *                     flag = hton.unpack_uint32(frb_read(spec, 4))  # flags             # <<<<<<<<<<<<<<
 *                     cardinality = <uint8_t>frb_read(spec, 1)[0]
 *                 else:
 */
        __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 178, __pyx_L1_error)
        __pyx_v_flag = unpack_uint32(__pyx_t_1);

        /* "edgedb/protocol/codecs/codecs.pyx":179
 *                 if protocol_version >= (0, 11):
 *                     flag = hton.unpack_uint32(frb_read(spec, 4))  # flags
 *                     cardinality = <uint8_t>frb_read(spec, 1)[0]             # <<<<<<<<<<<<<<
 *                 else:
 *                     flag = <uint8_t>frb_read(spec, 1)[0]  # flags
 */
        __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 1); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 179, __pyx_L1_error)
        __pyx_v_cardinality = ((uint8_t)(__pyx_t_1[0]));

        /* "edgedb/protocol/codecs/codecs.pyx":177
 *             cards = cpython.PyTuple_New(els)
 *             for i in range(els):
 *                 if protocol_version >= (0, 11):             # <<<<<<<<<<<<<<
 *                     flag = hton.unpack_uint32(frb_read(spec, 4))  # flags
 *                     cardinality = <uint8_t>frb_read(spec, 1)[0]
 */
        goto __pyx_L20;
      }

      /* "edgedb/protocol/codecs/codecs.pyx":181
 *                     cardinality = <uint8_t>frb_read(spec, 1)[0]
 *                 else:
 *                     flag = <uint8_t>frb_read(spec, 1)[0]  # flags             # <<<<<<<<<<<<<<
 *                     cardinality = 0
 * 
 */
      /*else*/ {
        __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 1); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 181, __pyx_L1_error)
        __pyx_v_flag = ((uint8_t)(__pyx_t_1[0]));

        /* "edgedb/protocol/codecs/codecs.pyx":182
 *                 else:
 *                     flag = <uint8_t>frb_read(spec, 1)[0]  # flags
 *                     cardinality = 0             # <<<<<<<<<<<<<<
 * 
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))
 */
        __pyx_v_cardinality = 0;
      }
      __pyx_L20:;

      /* "edgedb/protocol/codecs/codecs.pyx":184
 *                     cardinality = 0
 * 
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))             # <<<<<<<<<<<<<<
 *                 name = cpythonx.PyUnicode_FromStringAndSize(
 *                     frb_read(spec, str_len), str_len)
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 184, __pyx_L1_error)
      __pyx_v_str_len = unpack_uint32(__pyx_t_1);

      /* "edgedb/protocol/codecs/codecs.pyx":186
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                 name = cpythonx.PyUnicode_FromStringAndSize(
 *                     frb_read(spec, str_len), str_len)             # <<<<<<<<<<<<<<
 *                 pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 * 
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, __pyx_v_str_len); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 186, __pyx_L1_error)

      /* "edgedb/protocol/codecs/codecs.pyx":185
 * 
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                 name = cpythonx.PyUnicode_FromStringAndSize(             # <<<<<<<<<<<<<<
 *                     frb_read(spec, str_len), str_len)
 *                 pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 */
      __pyx_t_2 = PyUnicode_FromStringAndSize(__pyx_t_1, __pyx_v_str_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "edgedb/protocol/codecs/codecs.pyx":187
 *                 name = cpythonx.PyUnicode_FromStringAndSize(
 *                     frb_read(spec, str_len), str_len)
 *                 pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 * 
 *                 cpython.Py_INCREF(name)
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 187, __pyx_L1_error)
      __pyx_v_pos = ((uint16_t)unpack_int16(__pyx_t_1));

      /* "edgedb/protocol/codecs/codecs.pyx":189
 *                 pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 * 
 *                 cpython.Py_INCREF(name)             # <<<<<<<<<<<<<<
 *                 cpython.PyTuple_SetItem(names, i, name)
 * 
 */
      Py_INCREF(__pyx_v_name);

      /* "edgedb/protocol/codecs/codecs.pyx":190
 * 
 *                 cpython.Py_INCREF(name)
 *                 cpython.PyTuple_SetItem(names, i, name)             # <<<<<<<<<<<<<<
 * 
 *                 sub_codec = codecs_list[pos]
 */
      __pyx_t_9 = PyTuple_SetItem(__pyx_v_names, __pyx_v_i, __pyx_v_name); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(4, 190, __pyx_L1_error)

      /* "edgedb/protocol/codecs/codecs.pyx":192
 *                 cpython.PyTuple_SetItem(names, i, name)
 * 
 *                 sub_codec = codecs_list[pos]             # <<<<<<<<<<<<<<
 *                 cpython.Py_INCREF(sub_codec)
 *                 cpython.PyTuple_SetItem(codecs, i, sub_codec)
 */
      if (unlikely(__pyx_v_codecs_list == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(4, 192, __pyx_L1_error)
      }
      __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_codecs_list, __pyx_v_pos, uint16_t, 0, __Pyx_PyInt_From_uint16_t, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 192, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec))))) __PYX_ERR(4, 192, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_sub_codec, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_2));
      __pyx_t_2 = 0;

      /* "edgedb/protocol/codecs/codecs.pyx":193
 * 
 *                 sub_codec = codecs_list[pos]
 *                 cpython.Py_INCREF(sub_codec)             # <<<<<<<<<<<<<<
 *                 cpython.PyTuple_SetItem(codecs, i, sub_codec)
 * 
 */
      Py_INCREF(((PyObject *)__pyx_v_sub_codec));

      /* "edgedb/protocol/codecs/codecs.pyx":194
 *                 sub_codec = codecs_list[pos]
 *                 cpython.Py_INCREF(sub_codec)
 *                 cpython.PyTuple_SetItem(codecs, i, sub_codec)             # <<<<<<<<<<<<<<
 * 
 *                 cpython.Py_INCREF(flag)
 */
      __pyx_t_9 = PyTuple_SetItem(__pyx_v_codecs, __pyx_v_i, ((PyObject *)__pyx_v_sub_codec)); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(4, 194, __pyx_L1_error)

      /* "edgedb/protocol/codecs/codecs.pyx":196
 *                 cpython.PyTuple_SetItem(codecs, i, sub_codec)
 * 
 *                 cpython.Py_INCREF(flag)             # <<<<<<<<<<<<<<
 *                 cpython.PyTuple_SetItem(flags, i, flag)
 * 
 */
      __pyx_t_2 = __Pyx_PyInt_From_uint32_t(__pyx_v_flag); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 196, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      Py_INCREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "edgedb/protocol/codecs/codecs.pyx":197
 * 
 *                 cpython.Py_INCREF(flag)
 *                 cpython.PyTuple_SetItem(flags, i, flag)             # <<<<<<<<<<<<<<
 * 
 *                 cpython.Py_INCREF(cardinality)
 */
      __pyx_t_2 = __Pyx_PyInt_From_uint32_t(__pyx_v_flag); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 197, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = PyTuple_SetItem(__pyx_v_flags, __pyx_v_i, __pyx_t_2); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(4, 197, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "edgedb/protocol/codecs/codecs.pyx":199
 *                 cpython.PyTuple_SetItem(flags, i, flag)
 * 
 *                 cpython.Py_INCREF(cardinality)             # <<<<<<<<<<<<<<
 *                 cpython.PyTuple_SetItem(cards, i, cardinality)
 * 
 */
      __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_cardinality); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      Py_INCREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "edgedb/protocol/codecs/codecs.pyx":200
 * 
 *                 cpython.Py_INCREF(cardinality)
 *                 cpython.PyTuple_SetItem(cards, i, cardinality)             # <<<<<<<<<<<<<<
 * 
 *             res = ObjectCodec.new(tid, names, flags, cards, codecs)
 */
      __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_cardinality); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 200, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = PyTuple_SetItem(__pyx_v_cards, __pyx_v_i, __pyx_t_2); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(4, 200, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }

    /* "edgedb/protocol/codecs/codecs.pyx":202
 *                 cpython.PyTuple_SetItem(cards, i, cardinality)
 * 
 *             res = ObjectCodec.new(tid, names, flags, cards, codecs)             # <<<<<<<<<<<<<<
 * 
 *         elif t == CTYPE_BASE_SCALAR:
 */
    __pyx_t_2 = ((PyObject *)__pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_new(__pyx_v_tid, __pyx_v_names, __pyx_v_flags, __pyx_v_cards, __pyx_v_codecs)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 202, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_res, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":170
 *             res = SetCodec.new(tid, sub_codec)
 * 
 *         elif t == CTYPE_SHAPE:             # <<<<<<<<<<<<<<
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             codecs = cpython.PyTuple_New(els)
 */
    break;
    case 2:

    /* "edgedb/protocol/codecs/codecs.pyx":205
 * 
 *         elif t == CTYPE_BASE_SCALAR:
 *             if tid in self.base_codec_overrides:             # <<<<<<<<<<<<<<
 *                 return self.base_codec_overrides[tid]
 *             else:
 */
    if (unlikely(__pyx_v_self->base_codec_overrides == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(4, 205, __pyx_L1_error)
    }
    __pyx_t_3 = (__Pyx_PyDict_ContainsTF(__pyx_v_tid, __pyx_v_self->base_codec_overrides, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(4, 205, __pyx_L1_error)
    __pyx_t_4 = (__pyx_t_3 != 0);
    if (__pyx_t_4) {

      /* "edgedb/protocol/codecs/codecs.pyx":206
 *         elif t == CTYPE_BASE_SCALAR:
 *             if tid in self.base_codec_overrides:
 *                 return self.base_codec_overrides[tid]             # <<<<<<<<<<<<<<
 *             else:
 *                 res = <BaseCodec>BASE_SCALAR_CODECS[tid]
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      if (unlikely(__pyx_v_self->base_codec_overrides == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(4, 206, __pyx_L1_error)
      }
      __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->base_codec_overrides, __pyx_v_tid); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 206, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec))))) __PYX_ERR(4, 206, __pyx_L1_error)
      __pyx_r = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_2);
      __pyx_t_2 = 0;
      goto __pyx_L0;

      /* "edgedb/protocol/codecs/codecs.pyx":205
 * 
 *         elif t == CTYPE_BASE_SCALAR:
 *             if tid in self.base_codec_overrides:             # <<<<<<<<<<<<<<
 *                 return self.base_codec_overrides[tid]
 *             else:
 */
    }

    /* "edgedb/protocol/codecs/codecs.pyx":208
 *                 return self.base_codec_overrides[tid]
 *             else:
 *                 res = <BaseCodec>BASE_SCALAR_CODECS[tid]             # <<<<<<<<<<<<<<
 * 
 *         elif t == CTYPE_SCALAR:
 */
    /*else*/ {
      if (unlikely(__pyx_v_6edgedb_8protocol_8protocol_BASE_SCALAR_CODECS == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(4, 208, __pyx_L1_error)
      }
      __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_6edgedb_8protocol_8protocol_BASE_SCALAR_CODECS, __pyx_v_tid); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 208, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = __pyx_t_2;
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_res, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_8));
      __pyx_t_8 = 0;
    }

    /* "edgedb/protocol/codecs/codecs.pyx":204
 *             res = ObjectCodec.new(tid, names, flags, cards, codecs)
 * 
 *         elif t == CTYPE_BASE_SCALAR:             # <<<<<<<<<<<<<<
 *             if tid in self.base_codec_overrides:
 *                 return self.base_codec_overrides[tid]
 */
    break;
    case 3:

    /* "edgedb/protocol/codecs/codecs.pyx":211
 * 
 *         elif t == CTYPE_SCALAR:
 *             pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 *             codec = codecs_list[pos]
 *             if type(codec) is not ScalarCodec:
 */
    __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 211, __pyx_L1_error)
    __pyx_v_pos = ((uint16_t)unpack_int16(__pyx_t_1));

    /* "edgedb/protocol/codecs/codecs.pyx":212
 *         elif t == CTYPE_SCALAR:
 *             pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             codec = codecs_list[pos]             # <<<<<<<<<<<<<<
 *             if type(codec) is not ScalarCodec:
 *                 raise RuntimeError(
 */
    if (unlikely(__pyx_v_codecs_list == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(4, 212, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_GetItemInt_List(__pyx_v_codecs_list, __pyx_v_pos, uint16_t, 0, __Pyx_PyInt_From_uint16_t, 1, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 212, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_v_codec = __pyx_t_8;
    __pyx_t_8 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":213
 *             pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             codec = codecs_list[pos]
 *             if type(codec) is not ScalarCodec:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     f'a scalar codec expected for base scalar type, '
 */
    __pyx_t_4 = (((PyObject *)Py_TYPE(__pyx_v_codec)) != ((PyObject *)__pyx_ptype_6edgedb_8protocol_8protocol_ScalarCodec));
    __pyx_t_3 = (__pyx_t_4 != 0);
    if (unlikely(__pyx_t_3)) {

      /* "edgedb/protocol/codecs/codecs.pyx":216
 *                 raise RuntimeError(
 *                     f'a scalar codec expected for base scalar type, '
 *                     f'got {type(codec).__name__}')             # <<<<<<<<<<<<<<
 *             res = (<ScalarCodec>codecs_list[pos]).derive(tid)
 * 
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_codec)), __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 216, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_t_8, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 216, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "edgedb/protocol/codecs/codecs.pyx":215
 *             if type(codec) is not ScalarCodec:
 *                 raise RuntimeError(
 *                     f'a scalar codec expected for base scalar type, '             # <<<<<<<<<<<<<<
 *                     f'got {type(codec).__name__}')
 *             res = (<ScalarCodec>codecs_list[pos]).derive(tid)
 */
      __pyx_t_8 = __Pyx_PyUnicode_Concat(__pyx_kp_u_a_scalar_codec_expected_for_base, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 215, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "edgedb/protocol/codecs/codecs.pyx":214
 *             codec = codecs_list[pos]
 *             if type(codec) is not ScalarCodec:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     f'a scalar codec expected for base scalar type, '
 *                     f'got {type(codec).__name__}')
 */
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 214, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(4, 214, __pyx_L1_error)

      /* "edgedb/protocol/codecs/codecs.pyx":213
 *             pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             codec = codecs_list[pos]
 *             if type(codec) is not ScalarCodec:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     f'a scalar codec expected for base scalar type, '
 */
    }

    /* "edgedb/protocol/codecs/codecs.pyx":217
 *                     f'a scalar codec expected for base scalar type, '
 *                     f'got {type(codec).__name__}')
 *             res = (<ScalarCodec>codecs_list[pos]).derive(tid)             # <<<<<<<<<<<<<<
 * 
 *         elif t == CTYPE_TUPLE:
 */
    if (unlikely(__pyx_v_codecs_list == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(4, 217, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_codecs_list, __pyx_v_pos, uint16_t, 0, __Pyx_PyInt_From_uint16_t, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 217, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = __pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_derive(((struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *)__pyx_t_2), __pyx_v_tid); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 217, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec))))) __PYX_ERR(4, 217, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_res, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_8));
    __pyx_t_8 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":210
 *                 res = <BaseCodec>BASE_SCALAR_CODECS[tid]
 * 
 *         elif t == CTYPE_SCALAR:             # <<<<<<<<<<<<<<
 *             pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             codec = codecs_list[pos]
 */
    break;
    case 4:

    /* "edgedb/protocol/codecs/codecs.pyx":220
 * 
 *         elif t == CTYPE_TUPLE:
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 *             codecs = cpython.PyTuple_New(els)
 *             for i in range(els):
 */
    __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 220, __pyx_L1_error)
    __pyx_v_els = ((uint16_t)unpack_int16(__pyx_t_1));

    /* "edgedb/protocol/codecs/codecs.pyx":221
 *         elif t == CTYPE_TUPLE:
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             codecs = cpython.PyTuple_New(els)             # <<<<<<<<<<<<<<
 *             for i in range(els):
 *                 pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 */
    __pyx_t_8 = PyTuple_New(__pyx_v_els); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 221, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_v_codecs = ((PyObject*)__pyx_t_8);
    __pyx_t_8 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":222
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             codecs = cpython.PyTuple_New(els)
 *             for i in range(els):             # <<<<<<<<<<<<<<
 *                 pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 * 
 */
    __pyx_t_5 = __pyx_v_els;
    __pyx_t_6 = __pyx_t_5;
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
      __pyx_v_i = __pyx_t_7;

      /* "edgedb/protocol/codecs/codecs.pyx":223
 *             codecs = cpython.PyTuple_New(els)
 *             for i in range(els):
 *                 pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 * 
 *                 sub_codec = codecs_list[pos]
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 223, __pyx_L1_error)
      __pyx_v_pos = ((uint16_t)unpack_int16(__pyx_t_1));

      /* "edgedb/protocol/codecs/codecs.pyx":225
 *                 pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 * 
 *                 sub_codec = codecs_list[pos]             # <<<<<<<<<<<<<<
 *                 cpython.Py_INCREF(sub_codec)
 *                 cpython.PyTuple_SetItem(codecs, i, sub_codec)
 */
      if (unlikely(__pyx_v_codecs_list == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(4, 225, __pyx_L1_error)
      }
      __pyx_t_8 = __Pyx_GetItemInt_List(__pyx_v_codecs_list, __pyx_v_pos, uint16_t, 0, __Pyx_PyInt_From_uint16_t, 1, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 225, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec))))) __PYX_ERR(4, 225, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_sub_codec, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_8));
      __pyx_t_8 = 0;

      /* "edgedb/protocol/codecs/codecs.pyx":226
 * 
 *                 sub_codec = codecs_list[pos]
 *                 cpython.Py_INCREF(sub_codec)             # <<<<<<<<<<<<<<
 *                 cpython.PyTuple_SetItem(codecs, i, sub_codec)
 * 
 */
      Py_INCREF(((PyObject *)__pyx_v_sub_codec));

      /* "edgedb/protocol/codecs/codecs.pyx":227
 *                 sub_codec = codecs_list[pos]
 *                 cpython.Py_INCREF(sub_codec)
 *                 cpython.PyTuple_SetItem(codecs, i, sub_codec)             # <<<<<<<<<<<<<<
 * 
 *             res = TupleCodec.new(tid, codecs)
 */
      __pyx_t_9 = PyTuple_SetItem(__pyx_v_codecs, __pyx_v_i, ((PyObject *)__pyx_v_sub_codec)); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(4, 227, __pyx_L1_error)
    }

    /* "edgedb/protocol/codecs/codecs.pyx":229
 *                 cpython.PyTuple_SetItem(codecs, i, sub_codec)
 * 
 *             res = TupleCodec.new(tid, codecs)             # <<<<<<<<<<<<<<
 * 
 *         elif t == CTYPE_NAMEDTUPLE:
 */
    __pyx_t_8 = ((PyObject *)__pyx_f_6edgedb_8protocol_8protocol_10TupleCodec_new(__pyx_v_tid, __pyx_v_codecs)); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 229, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF_SET(__pyx_v_res, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_8));
    __pyx_t_8 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":219
 *             res = (<ScalarCodec>codecs_list[pos]).derive(tid)
 * 
 *         elif t == CTYPE_TUPLE:             # <<<<<<<<<<<<<<
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             codecs = cpython.PyTuple_New(els)
 */
    break;
    case 5:

    /* "edgedb/protocol/codecs/codecs.pyx":232
 * 
 *         elif t == CTYPE_NAMEDTUPLE:
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 *             codecs = cpython.PyTuple_New(els)
 *             names = cpython.PyTuple_New(els)
 */
    __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 232, __pyx_L1_error)
    __pyx_v_els = ((uint16_t)unpack_int16(__pyx_t_1));

    /* "edgedb/protocol/codecs/codecs.pyx":233
 *         elif t == CTYPE_NAMEDTUPLE:
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             codecs = cpython.PyTuple_New(els)             # <<<<<<<<<<<<<<
 *             names = cpython.PyTuple_New(els)
 *             for i in range(els):
 */
    __pyx_t_8 = PyTuple_New(__pyx_v_els); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 233, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_v_codecs = ((PyObject*)__pyx_t_8);
    __pyx_t_8 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":234
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             codecs = cpython.PyTuple_New(els)
 *             names = cpython.PyTuple_New(els)             # <<<<<<<<<<<<<<
 *             for i in range(els):
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))
 */
    __pyx_t_8 = PyTuple_New(__pyx_v_els); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_v_names = ((PyObject*)__pyx_t_8);
    __pyx_t_8 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":235
 *             codecs = cpython.PyTuple_New(els)
 *             names = cpython.PyTuple_New(els)
 *             for i in range(els):             # <<<<<<<<<<<<<<
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                 name = cpythonx.PyUnicode_FromStringAndSize(
 */
    __pyx_t_5 = __pyx_v_els;
    __pyx_t_6 = __pyx_t_5;
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
      __pyx_v_i = __pyx_t_7;

      /* "edgedb/protocol/codecs/codecs.pyx":236
 *             names = cpython.PyTuple_New(els)
 *             for i in range(els):
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))             # <<<<<<<<<<<<<<
 *                 name = cpythonx.PyUnicode_FromStringAndSize(
 *                     frb_read(spec, str_len), str_len)
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 236, __pyx_L1_error)
      __pyx_v_str_len = unpack_uint32(__pyx_t_1);

      /* "edgedb/protocol/codecs/codecs.pyx":238
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                 name = cpythonx.PyUnicode_FromStringAndSize(
 *                     frb_read(spec, str_len), str_len)             # <<<<<<<<<<<<<<
 *                 pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 * 
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, __pyx_v_str_len); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 238, __pyx_L1_error)

      /* "edgedb/protocol/codecs/codecs.pyx":237
 *             for i in range(els):
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                 name = cpythonx.PyUnicode_FromStringAndSize(             # <<<<<<<<<<<<<<
 *                     frb_read(spec, str_len), str_len)
 *                 pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 */
      __pyx_t_8 = PyUnicode_FromStringAndSize(__pyx_t_1, __pyx_v_str_len); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 237, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "edgedb/protocol/codecs/codecs.pyx":239
 *                 name = cpythonx.PyUnicode_FromStringAndSize(
 *                     frb_read(spec, str_len), str_len)
 *                 pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 * 
 *                 cpython.Py_INCREF(name)
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 239, __pyx_L1_error)
      __pyx_v_pos = ((uint16_t)unpack_int16(__pyx_t_1));

      /* "edgedb/protocol/codecs/codecs.pyx":241
 *                 pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 * 
 *                 cpython.Py_INCREF(name)             # <<<<<<<<<<<<<<
 *                 cpython.PyTuple_SetItem(names, i, name)
 * 
 */
      Py_INCREF(__pyx_v_name);

      /* "edgedb/protocol/codecs/codecs.pyx":242
 * 
 *                 cpython.Py_INCREF(name)
 *                 cpython.PyTuple_SetItem(names, i, name)             # <<<<<<<<<<<<<<
 * 
 *                 sub_codec = codecs_list[pos]
 */
      __pyx_t_9 = PyTuple_SetItem(__pyx_v_names, __pyx_v_i, __pyx_v_name); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(4, 242, __pyx_L1_error)

      /* "edgedb/protocol/codecs/codecs.pyx":244
 *                 cpython.PyTuple_SetItem(names, i, name)
 * 
 *                 sub_codec = codecs_list[pos]             # <<<<<<<<<<<<<<
 *                 cpython.Py_INCREF(sub_codec)
 *                 cpython.PyTuple_SetItem(codecs, i, sub_codec)
 */
      if (unlikely(__pyx_v_codecs_list == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(4, 244, __pyx_L1_error)
      }
      __pyx_t_8 = __Pyx_GetItemInt_List(__pyx_v_codecs_list, __pyx_v_pos, uint16_t, 0, __Pyx_PyInt_From_uint16_t, 1, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 244, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec))))) __PYX_ERR(4, 244, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_sub_codec, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_8));
      __pyx_t_8 = 0;

      /* "edgedb/protocol/codecs/codecs.pyx":245
 * 
 *                 sub_codec = codecs_list[pos]
 *                 cpython.Py_INCREF(sub_codec)             # <<<<<<<<<<<<<<
 *                 cpython.PyTuple_SetItem(codecs, i, sub_codec)
 * 
 */
      Py_INCREF(((PyObject *)__pyx_v_sub_codec));

      /* "edgedb/protocol/codecs/codecs.pyx":246
 *                 sub_codec = codecs_list[pos]
 *                 cpython.Py_INCREF(sub_codec)
 *                 cpython.PyTuple_SetItem(codecs, i, sub_codec)             # <<<<<<<<<<<<<<
 * 
 *             res = NamedTupleCodec.new(tid, names, codecs)
 */
      __pyx_t_9 = PyTuple_SetItem(__pyx_v_codecs, __pyx_v_i, ((PyObject *)__pyx_v_sub_codec)); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(4, 246, __pyx_L1_error)
    }

    /* "edgedb/protocol/codecs/codecs.pyx":248
 *                 cpython.PyTuple_SetItem(codecs, i, sub_codec)
 * 
 *             res = NamedTupleCodec.new(tid, names, codecs)             # <<<<<<<<<<<<<<
 * 
 *         elif t == CTYPE_ENUM:
 */
    __pyx_t_8 = ((PyObject *)__pyx_f_6edgedb_8protocol_8protocol_15NamedTupleCodec_new(__pyx_v_tid, __pyx_v_names, __pyx_v_codecs)); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 248, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF_SET(__pyx_v_res, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_8));
    __pyx_t_8 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":231
 *             res = TupleCodec.new(tid, codecs)
 * 
 *         elif t == CTYPE_NAMEDTUPLE:             # <<<<<<<<<<<<<<
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             codecs = cpython.PyTuple_New(els)
 */
    break;
    case 7:

    /* "edgedb/protocol/codecs/codecs.pyx":251
 * 
 *         elif t == CTYPE_ENUM:
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 *             names = cpython.PyTuple_New(els)
 *             for i in range(els):
 */
    __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 251, __pyx_L1_error)
    __pyx_v_els = ((uint16_t)unpack_int16(__pyx_t_1));

    /* "edgedb/protocol/codecs/codecs.pyx":252
 *         elif t == CTYPE_ENUM:
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             names = cpython.PyTuple_New(els)             # <<<<<<<<<<<<<<
 *             for i in range(els):
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))
 */
    __pyx_t_8 = PyTuple_New(__pyx_v_els); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 252, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_v_names = ((PyObject*)__pyx_t_8);
    __pyx_t_8 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":253
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             names = cpython.PyTuple_New(els)
 *             for i in range(els):             # <<<<<<<<<<<<<<
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                 name = cpythonx.PyUnicode_FromStringAndSize(
 */
    __pyx_t_5 = __pyx_v_els;
    __pyx_t_6 = __pyx_t_5;
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
      __pyx_v_i = __pyx_t_7;

      /* "edgedb/protocol/codecs/codecs.pyx":254
 *             names = cpython.PyTuple_New(els)
 *             for i in range(els):
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))             # <<<<<<<<<<<<<<
 *                 name = cpythonx.PyUnicode_FromStringAndSize(
 *                     frb_read(spec, str_len), str_len)
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 254, __pyx_L1_error)
      __pyx_v_str_len = unpack_uint32(__pyx_t_1);

      /* "edgedb/protocol/codecs/codecs.pyx":256
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                 name = cpythonx.PyUnicode_FromStringAndSize(
 *                     frb_read(spec, str_len), str_len)             # <<<<<<<<<<<<<<
 * 
 *                 cpython.Py_INCREF(name)
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, __pyx_v_str_len); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 256, __pyx_L1_error)

      /* "edgedb/protocol/codecs/codecs.pyx":255
 *             for i in range(els):
 *                 str_len = hton.unpack_uint32(frb_read(spec, 4))
 *                 name = cpythonx.PyUnicode_FromStringAndSize(             # <<<<<<<<<<<<<<
 *                     frb_read(spec, str_len), str_len)
 * 
 */
      __pyx_t_8 = PyUnicode_FromStringAndSize(__pyx_t_1, __pyx_v_str_len); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 255, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "edgedb/protocol/codecs/codecs.pyx":258
 *                     frb_read(spec, str_len), str_len)
 * 
 *                 cpython.Py_INCREF(name)             # <<<<<<<<<<<<<<
 *                 cpython.PyTuple_SetItem(names, i, name)
 * 
 */
      Py_INCREF(__pyx_v_name);

      /* "edgedb/protocol/codecs/codecs.pyx":259
 * 
 *                 cpython.Py_INCREF(name)
 *                 cpython.PyTuple_SetItem(names, i, name)             # <<<<<<<<<<<<<<
 * 
 *             res = EnumCodec.new(tid, names)
 */
      __pyx_t_9 = PyTuple_SetItem(__pyx_v_names, __pyx_v_i, __pyx_v_name); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(4, 259, __pyx_L1_error)
    }

    /* "edgedb/protocol/codecs/codecs.pyx":261
 *                 cpython.PyTuple_SetItem(names, i, name)
 * 
 *             res = EnumCodec.new(tid, names)             # <<<<<<<<<<<<<<
 * 
 *         elif t == CTYPE_ARRAY:
 */
    __pyx_t_8 = ((PyObject *)__pyx_f_6edgedb_8protocol_8protocol_9EnumCodec_new(__pyx_v_tid, __pyx_v_names)); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 261, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF_SET(__pyx_v_res, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_8));
    __pyx_t_8 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":250
 *             res = NamedTupleCodec.new(tid, names, codecs)
 * 
 *         elif t == CTYPE_ENUM:             # <<<<<<<<<<<<<<
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             names = cpython.PyTuple_New(els)
 */
    break;
    case 6:

    /* "edgedb/protocol/codecs/codecs.pyx":264
 * 
 *         elif t == CTYPE_ARRAY:
 *             pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             if els != 1:
 */
    __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 264, __pyx_L1_error)
    __pyx_v_pos = ((uint16_t)unpack_int16(__pyx_t_1));

    /* "edgedb/protocol/codecs/codecs.pyx":265
 *         elif t == CTYPE_ARRAY:
 *             pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))             # <<<<<<<<<<<<<<
 *             if els != 1:
 *                 raise NotImplementedError(
 */
    __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 265, __pyx_L1_error)
    __pyx_v_els = ((uint16_t)unpack_int16(__pyx_t_1));

    /* "edgedb/protocol/codecs/codecs.pyx":266
 *             pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             if els != 1:             # <<<<<<<<<<<<<<
 *                 raise NotImplementedError(
 *                     'cannot handle arrays with more than one dimension')
 */
    __pyx_t_3 = ((__pyx_v_els != 1) != 0);
    if (unlikely(__pyx_t_3)) {

      /* "edgedb/protocol/codecs/codecs.pyx":267
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             if els != 1:
 *                 raise NotImplementedError(             # <<<<<<<<<<<<<<
 *                     'cannot handle arrays with more than one dimension')
 *             # First dimension length.
 */
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 267, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(4, 267, __pyx_L1_error)

      /* "edgedb/protocol/codecs/codecs.pyx":266
 *             pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             if els != 1:             # <<<<<<<<<<<<<<
 *                 raise NotImplementedError(
 *                     'cannot handle arrays with more than one dimension')
 */
    }

    /* "edgedb/protocol/codecs/codecs.pyx":270
 *                     'cannot handle arrays with more than one dimension')
 *             # First dimension length.
 *             dim_len = hton.unpack_int32(frb_read(spec, 4))             # <<<<<<<<<<<<<<
 *             sub_codec = <BaseCodec>codecs_list[pos]
 *             res = ArrayCodec.new(tid, sub_codec, dim_len)
 */
    __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_spec, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 270, __pyx_L1_error)
    __pyx_v_dim_len = unpack_int32(__pyx_t_1);

    /* "edgedb/protocol/codecs/codecs.pyx":271
 *             # First dimension length.
 *             dim_len = hton.unpack_int32(frb_read(spec, 4))
 *             sub_codec = <BaseCodec>codecs_list[pos]             # <<<<<<<<<<<<<<
 *             res = ArrayCodec.new(tid, sub_codec, dim_len)
 * 
 */
    if (unlikely(__pyx_v_codecs_list == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(4, 271, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_GetItemInt_List(__pyx_v_codecs_list, __pyx_v_pos, uint16_t, 0, __Pyx_PyInt_From_uint16_t, 1, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 271, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_2 = __pyx_t_8;
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_v_sub_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":272
 *             dim_len = hton.unpack_int32(frb_read(spec, 4))
 *             sub_codec = <BaseCodec>codecs_list[pos]
 *             res = ArrayCodec.new(tid, sub_codec, dim_len)             # <<<<<<<<<<<<<<
 * 
 *         else:
 */
    __pyx_t_2 = ((PyObject *)__pyx_f_6edgedb_8protocol_8protocol_10ArrayCodec_new(__pyx_v_tid, __pyx_v_sub_codec, __pyx_v_dim_len)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_res, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":263
 *             res = EnumCodec.new(tid, names)
 * 
 *         elif t == CTYPE_ARRAY:             # <<<<<<<<<<<<<<
 *             pos = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *             els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 */
    break;
    default:

    /* "edgedb/protocol/codecs/codecs.pyx":276
 *         else:
 *             raise NotImplementedError(
 *                 f'no codec implementation for EdgeDB data class {t}')             # <<<<<<<<<<<<<<
 * 
 *         self.codecs_build_cache[tid] = res
 */
    __pyx_t_2 = __Pyx_PyInt_From_uint8_t(__pyx_v_t); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_no_codec_implementation_for_Edge, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":275
 * 
 *         else:
 *             raise NotImplementedError(             # <<<<<<<<<<<<<<
 *                 f'no codec implementation for EdgeDB data class {t}')
 * 
 */
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_NotImplementedError, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_8, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __PYX_ERR(4, 275, __pyx_L1_error)
    break;
  }

  /* "edgedb/protocol/codecs/codecs.pyx":278
 *                 f'no codec implementation for EdgeDB data class {t}')
 * 
 *         self.codecs_build_cache[tid] = res             # <<<<<<<<<<<<<<
 *         return res
 * 
 */
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->codecs_build_cache), __pyx_v_tid, ((PyObject *)__pyx_v_res)) < 0)) __PYX_ERR(4, 278, __pyx_L1_error)

  /* "edgedb/protocol/codecs/codecs.pyx":279
 * 
 *         self.codecs_build_cache[tid] = res
 *         return res             # <<<<<<<<<<<<<<
 * 
 *     cdef has_codec(self, bytes type_id):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_res));
  __pyx_r = __pyx_v_res;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/codecs.pyx":85
 *         )
 * 
 *     cdef BaseCodec _build_codec(self, FRBuffer *spec, list codecs_list,             # <<<<<<<<<<<<<<
 *                                 protocol_version):
 *         cdef:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecsRegistry._build_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_tid);
  __Pyx_XDECREF((PyObject *)__pyx_v_res);
  __Pyx_XDECREF((PyObject *)__pyx_v_sub_codec);
  __Pyx_XDECREF(__pyx_v_codecs);
  __Pyx_XDECREF(__pyx_v_names);
  __Pyx_XDECREF(__pyx_v_flags);
  __Pyx_XDECREF(__pyx_v_cards);
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_codec);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":281
 *         return res
 * 
 *     cdef has_codec(self, bytes type_id):             # <<<<<<<<<<<<<<
 *         return (
 *             type_id in self.codecs or
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14CodecsRegistry_has_codec(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self, PyObject *__pyx_v_type_id) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("has_codec", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":282
 * 
 *     cdef has_codec(self, bytes type_id):
 *         return (             # <<<<<<<<<<<<<<
 *             type_id in self.codecs or
 *             type_id in {NULL_CODEC_ID, EMPTY_TUPLE_CODEC_ID}
 */
  __Pyx_XDECREF(__pyx_r);

  /* "edgedb/protocol/codecs/codecs.pyx":283
 *     cdef has_codec(self, bytes type_id):
 *         return (
 *             type_id in self.codecs or             # <<<<<<<<<<<<<<
 *             type_id in {NULL_CODEC_ID, EMPTY_TUPLE_CODEC_ID}
 *         )
 */
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_type_id, ((PyObject *)__pyx_v_self->codecs), Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(4, 283, __pyx_L1_error)
  if (!__pyx_t_2) {
  } else {
    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3_bool_binop_done;
  }

  /* "edgedb/protocol/codecs/codecs.pyx":284
 *         return (
 *             type_id in self.codecs or
 *             type_id in {NULL_CODEC_ID, EMPTY_TUPLE_CODEC_ID}             # <<<<<<<<<<<<<<
 *         )
 * 
 */
  __Pyx_INCREF(__pyx_v_type_id);
  __pyx_t_4 = __pyx_v_type_id;
  __pyx_t_5 = (__Pyx_PyBytes_Equals(__pyx_t_4, __pyx_v_6edgedb_8protocol_8protocol_NULL_CODEC_ID, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(4, 284, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_2 = __pyx_t_6;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_6 = (__Pyx_PyBytes_Equals(__pyx_t_4, __pyx_v_6edgedb_8protocol_8protocol_EMPTY_TUPLE_CODEC_ID, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(4, 284, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_6 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L5_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = __pyx_t_2;
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_L3_bool_binop_done:;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/codecs.pyx":281
 *         return res
 * 
 *     cdef has_codec(self, bytes type_id):             # <<<<<<<<<<<<<<
 *         return (
 *             type_id in self.codecs or
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecsRegistry.has_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":287
 *         )
 * 
 *     cdef BaseCodec get_codec(self, bytes type_id):             # <<<<<<<<<<<<<<
 *         try:
 *             return <BaseCodec>self.codecs[type_id]
 */

static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_14CodecsRegistry_get_codec(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self, PyObject *__pyx_v_type_id) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_codec", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":288
 * 
 *     cdef BaseCodec get_codec(self, bytes type_id):
 *         try:             # <<<<<<<<<<<<<<
 *             return <BaseCodec>self.codecs[type_id]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "edgedb/protocol/codecs/codecs.pyx":289
 *     cdef BaseCodec get_codec(self, bytes type_id):
 *         try:
 *             return <BaseCodec>self.codecs[type_id]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             pass
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->codecs), __pyx_v_type_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 289, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_4)));
      __pyx_r = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L7_try_return;

      /* "edgedb/protocol/codecs/codecs.pyx":288
 * 
 *     cdef BaseCodec get_codec(self, bytes type_id):
 *         try:             # <<<<<<<<<<<<<<
 *             return <BaseCodec>self.codecs[type_id]
 *         except KeyError:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":290
 *         try:
 *             return <BaseCodec>self.codecs[type_id]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             pass
 * 
 */
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_5) {
      __Pyx_ErrRestore(0,0,0);
      goto __pyx_L4_exception_handled;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "edgedb/protocol/codecs/codecs.pyx":288
 * 
 *     cdef BaseCodec get_codec(self, bytes type_id):
 *         try:             # <<<<<<<<<<<<<<
 *             return <BaseCodec>self.codecs[type_id]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  }

  /* "edgedb/protocol/codecs/codecs.pyx":293
 *             pass
 * 
 *         if type_id == NULL_CODEC_ID:             # <<<<<<<<<<<<<<
 *             return NULL_CODEC
 * 
 */
  __pyx_t_6 = (__Pyx_PyBytes_Equals(__pyx_v_type_id, __pyx_v_6edgedb_8protocol_8protocol_NULL_CODEC_ID, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(4, 293, __pyx_L1_error)
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "edgedb/protocol/codecs/codecs.pyx":294
 * 
 *         if type_id == NULL_CODEC_ID:
 *             return NULL_CODEC             # <<<<<<<<<<<<<<
 * 
 *         if type_id == EMPTY_TUPLE_CODEC_ID:
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_6edgedb_8protocol_8protocol_NULL_CODEC));
    __pyx_r = __pyx_v_6edgedb_8protocol_8protocol_NULL_CODEC;
    goto __pyx_L0;

    /* "edgedb/protocol/codecs/codecs.pyx":293
 *             pass
 * 
 *         if type_id == NULL_CODEC_ID:             # <<<<<<<<<<<<<<
 *             return NULL_CODEC
 * 
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":296
 *             return NULL_CODEC
 * 
 *         if type_id == EMPTY_TUPLE_CODEC_ID:             # <<<<<<<<<<<<<<
 *             return EMPTY_TUPLE_CODEC
 * 
 */
  __pyx_t_7 = (__Pyx_PyBytes_Equals(__pyx_v_type_id, __pyx_v_6edgedb_8protocol_8protocol_EMPTY_TUPLE_CODEC_ID, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(4, 296, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_7 != 0);
  if (__pyx_t_6) {

    /* "edgedb/protocol/codecs/codecs.pyx":297
 * 
 *         if type_id == EMPTY_TUPLE_CODEC_ID:
 *             return EMPTY_TUPLE_CODEC             # <<<<<<<<<<<<<<
 * 
 *         raise LookupError
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_6edgedb_8protocol_8protocol_EMPTY_TUPLE_CODEC));
    __pyx_r = __pyx_v_6edgedb_8protocol_8protocol_EMPTY_TUPLE_CODEC;
    goto __pyx_L0;

    /* "edgedb/protocol/codecs/codecs.pyx":296
 *             return NULL_CODEC
 * 
 *         if type_id == EMPTY_TUPLE_CODEC_ID:             # <<<<<<<<<<<<<<
 *             return EMPTY_TUPLE_CODEC
 * 
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":299
 *             return EMPTY_TUPLE_CODEC
 * 
 *         raise LookupError             # <<<<<<<<<<<<<<
 * 
 *     cdef BaseCodec build_codec(self, bytes spec, protocol_version):
 */
  __Pyx_Raise(__pyx_builtin_LookupError, 0, 0, 0);
  __PYX_ERR(4, 299, __pyx_L1_error)

  /* "edgedb/protocol/codecs/codecs.pyx":287
 *         )
 * 
 *     cdef BaseCodec get_codec(self, bytes type_id):             # <<<<<<<<<<<<<<
 *         try:
 *             return <BaseCodec>self.codecs[type_id]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecsRegistry.get_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":301
 *         raise LookupError
 * 
 *     cdef BaseCodec build_codec(self, bytes spec, protocol_version):             # <<<<<<<<<<<<<<
 *         cdef:
 *             FRBuffer buf
 */

static struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_f_6edgedb_8protocol_8protocol_14CodecsRegistry_build_codec(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self, PyObject *__pyx_v_spec, PyObject *__pyx_v_protocol_version) {
  struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer __pyx_v_buf;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_res = 0;
  PyObject *__pyx_v_codecs_list = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("build_codec", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":309
 *         frb_init(
 *             &buf,
 *             cpython.PyBytes_AsString(spec),             # <<<<<<<<<<<<<<
 *             cpython.Py_SIZE(spec))
 * 
 */
  __pyx_t_1 = PyBytes_AsString(__pyx_v_spec); if (unlikely(__pyx_t_1 == ((char *)NULL))) __PYX_ERR(4, 309, __pyx_L1_error)

  /* "edgedb/protocol/codecs/codecs.pyx":307
 *             list codecs_list
 * 
 *         frb_init(             # <<<<<<<<<<<<<<
 *             &buf,
 *             cpython.PyBytes_AsString(spec),
 */
  __pyx_f_6edgedb_7pgproto_7pgproto_frb_init((&__pyx_v_buf), __pyx_t_1, Py_SIZE(__pyx_v_spec));

  /* "edgedb/protocol/codecs/codecs.pyx":312
 *             cpython.Py_SIZE(spec))
 * 
 *         codecs_list = []             # <<<<<<<<<<<<<<
 *         while frb_get_len(&buf):
 *             res = self._build_codec(&buf, codecs_list, protocol_version)
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_codecs_list = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":313
 * 
 *         codecs_list = []
 *         while frb_get_len(&buf):             # <<<<<<<<<<<<<<
 *             res = self._build_codec(&buf, codecs_list, protocol_version)
 *             if res is None:
 */
  while (1) {
    __pyx_t_3 = (__pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len((&__pyx_v_buf)) != 0);
    if (!__pyx_t_3) break;

    /* "edgedb/protocol/codecs/codecs.pyx":314
 *         codecs_list = []
 *         while frb_get_len(&buf):
 *             res = self._build_codec(&buf, codecs_list, protocol_version)             # <<<<<<<<<<<<<<
 *             if res is None:
 *                 # An annotation; ignore.
 */
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v_self->__pyx_vtab)->_build_codec(__pyx_v_self, (&__pyx_v_buf), __pyx_v_codecs_list, __pyx_v_protocol_version)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 314, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_res, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":315
 *         while frb_get_len(&buf):
 *             res = self._build_codec(&buf, codecs_list, protocol_version)
 *             if res is None:             # <<<<<<<<<<<<<<
 *                 # An annotation; ignore.
 *                 continue
 */
    __pyx_t_3 = (((PyObject *)__pyx_v_res) == Py_None);
    __pyx_t_4 = (__pyx_t_3 != 0);
    if (__pyx_t_4) {

      /* "edgedb/protocol/codecs/codecs.pyx":317
 *             if res is None:
 *                 # An annotation; ignore.
 *                 continue             # <<<<<<<<<<<<<<
 *             codecs_list.append(res)
 *             self.codecs[res.tid] = res
 */
      goto __pyx_L3_continue;

      /* "edgedb/protocol/codecs/codecs.pyx":315
 *         while frb_get_len(&buf):
 *             res = self._build_codec(&buf, codecs_list, protocol_version)
 *             if res is None:             # <<<<<<<<<<<<<<
 *                 # An annotation; ignore.
 *                 continue
 */
    }

    /* "edgedb/protocol/codecs/codecs.pyx":318
 *                 # An annotation; ignore.
 *                 continue
 *             codecs_list.append(res)             # <<<<<<<<<<<<<<
 *             self.codecs[res.tid] = res
 * 
 */
    __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_codecs_list, ((PyObject *)__pyx_v_res)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(4, 318, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":319
 *                 continue
 *             codecs_list.append(res)
 *             self.codecs[res.tid] = res             # <<<<<<<<<<<<<<
 * 
 *         if not codecs_list:
 */
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->codecs), __pyx_v_res->tid, ((PyObject *)__pyx_v_res)) < 0)) __PYX_ERR(4, 319, __pyx_L1_error)
    __pyx_L3_continue:;
  }

  /* "edgedb/protocol/codecs/codecs.pyx":321
 *             self.codecs[res.tid] = res
 * 
 *         if not codecs_list:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(f'cannot not build codec; empty type desc')
 * 
 */
  __pyx_t_4 = (PyList_GET_SIZE(__pyx_v_codecs_list) != 0);
  __pyx_t_3 = ((!__pyx_t_4) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "edgedb/protocol/codecs/codecs.pyx":322
 * 
 *         if not codecs_list:
 *             raise RuntimeError(f'cannot not build codec; empty type desc')             # <<<<<<<<<<<<<<
 * 
 *         return codecs_list[-1]
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 322, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(4, 322, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":321
 *             self.codecs[res.tid] = res
 * 
 *         if not codecs_list:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(f'cannot not build codec; empty type desc')
 * 
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":324
 *             raise RuntimeError(f'cannot not build codec; empty type desc')
 * 
 *         return codecs_list[-1]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_codecs_list, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 324, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec))))) __PYX_ERR(4, 324, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/codecs.pyx":301
 *         raise LookupError
 * 
 *     cdef BaseCodec build_codec(self, bytes spec, protocol_version):             # <<<<<<<<<<<<<<
 *         cdef:
 *             FRBuffer buf
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecsRegistry.build_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_res);
  __Pyx_XDECREF(__pyx_v_codecs_list);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14CodecsRegistry_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14CodecsRegistry_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14CodecsRegistry_6__reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14CodecsRegistry_6__reduce_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.base_codec_overrides, self.codecs, self.codecs_build_cache)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->base_codec_overrides);
  __Pyx_GIVEREF(__pyx_v_self->base_codec_overrides);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->base_codec_overrides);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->codecs));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->codecs));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self->codecs));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->codecs_build_cache));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->codecs_build_cache));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_self->codecs_build_cache));
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.base_codec_overrides, self.codecs, self.codecs_build_cache)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self.base_codec_overrides, self.codecs, self.codecs_build_cache)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.base_codec_overrides is not None or self.codecs is not None or self.codecs_build_cache is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.base_codec_overrides, self.codecs, self.codecs_build_cache)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.base_codec_overrides is not None or self.codecs is not None or self.codecs_build_cache is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_CodecsRegistry, (type(self), 0x324635c, None), state
 */
  /*else*/ {
    __pyx_t_2 = (__pyx_v_self->base_codec_overrides != ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (((PyObject *)__pyx_v_self->codecs) != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((PyObject *)__pyx_v_self->codecs_build_cache) != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    __pyx_t_3 = __pyx_t_5;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.base_codec_overrides is not None or self.codecs is not None or self.codecs_build_cache is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_CodecsRegistry, (type(self), 0x324635c, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self.base_codec_overrides is not None or self.codecs is not None or self.codecs_build_cache is not None
 *     if use_setstate:
 *         return __pyx_unpickle_CodecsRegistry, (type(self), 0x324635c, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_CodecsRegistry, (type(self), 0x324635c, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_CodecsRegistry); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_52716380);
    __Pyx_GIVEREF(__pyx_int_52716380);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_52716380);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.base_codec_overrides is not None or self.codecs is not None or self.codecs_build_cache is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_CodecsRegistry, (type(self), 0x324635c, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_CodecsRegistry, (type(self), 0x324635c, None), state
 *     else:
 *         return __pyx_unpickle_CodecsRegistry, (type(self), 0x324635c, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_CodecsRegistry__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_CodecsRegistry); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_52716380);
    __Pyx_GIVEREF(__pyx_int_52716380);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_52716380);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecsRegistry.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_CodecsRegistry, (type(self), 0x324635c, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_CodecsRegistry__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14CodecsRegistry_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14CodecsRegistry_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14CodecsRegistry_8__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14CodecsRegistry_8__setstate_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_CodecsRegistry, (type(self), 0x324635c, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_CodecsRegistry__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_CodecsRegistry__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_CodecsRegistry, (type(self), 0x324635c, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_CodecsRegistry__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.CodecsRegistry.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":330
 * 
 * 
 * cdef register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         str name,
 *         pgproto.encode_func encoder,
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(PyObject *__pyx_v_name, __pyx_t_6edgedb_7pgproto_7pgproto_encode_func __pyx_v_encoder, __pyx_t_6edgedb_7pgproto_7pgproto_decode_func __pyx_v_decoder) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_codec = 0;
  PyObject *__pyx_v_tid = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  Py_UCS4 __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("register_base_scalar_codec", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":338
 *         BaseCodec codec
 * 
 *     tid = TYPE_IDS.get(name)             # <<<<<<<<<<<<<<
 *     if tid is None:
 *         raise RuntimeError(f'cannot find known ID for type {name!r}')
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_TYPE_IDS); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_name) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_name);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_tid = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":339
 * 
 *     tid = TYPE_IDS.get(name)
 *     if tid is None:             # <<<<<<<<<<<<<<
 *         raise RuntimeError(f'cannot find known ID for type {name!r}')
 *     tid = tid.bytes
 */
  __pyx_t_4 = (__pyx_v_tid == Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (unlikely(__pyx_t_5)) {

    /* "edgedb/protocol/codecs/codecs.pyx":340
 *     tid = TYPE_IDS.get(name)
 *     if tid is None:
 *         raise RuntimeError(f'cannot find known ID for type {name!r}')             # <<<<<<<<<<<<<<
 *     tid = tid.bytes
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_name), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 340, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_cannot_find_known_ID_for_type, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 340, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 340, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(4, 340, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":339
 * 
 *     tid = TYPE_IDS.get(name)
 *     if tid is None:             # <<<<<<<<<<<<<<
 *         raise RuntimeError(f'cannot find known ID for type {name!r}')
 *     tid = tid.bytes
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":341
 *     if tid is None:
 *         raise RuntimeError(f'cannot find known ID for type {name!r}')
 *     tid = tid.bytes             # <<<<<<<<<<<<<<
 * 
 *     if tid in BASE_SCALAR_CODECS:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_tid, __pyx_n_s_bytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_tid, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":343
 *     tid = tid.bytes
 * 
 *     if tid in BASE_SCALAR_CODECS:             # <<<<<<<<<<<<<<
 *         raise RuntimeError(f'base scalar codec for {id} is already registered')
 * 
 */
  if (unlikely(__pyx_v_6edgedb_8protocol_8protocol_BASE_SCALAR_CODECS == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(4, 343, __pyx_L1_error)
  }
  __pyx_t_5 = (__Pyx_PyDict_ContainsTF(__pyx_v_tid, __pyx_v_6edgedb_8protocol_8protocol_BASE_SCALAR_CODECS, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(4, 343, __pyx_L1_error)
  __pyx_t_4 = (__pyx_t_5 != 0);
  if (unlikely(__pyx_t_4)) {

    /* "edgedb/protocol/codecs/codecs.pyx":344
 * 
 *     if tid in BASE_SCALAR_CODECS:
 *         raise RuntimeError(f'base scalar codec for {id} is already registered')             # <<<<<<<<<<<<<<
 * 
 *     codec = ScalarCodec.new(tid, name, encoder, decoder)
 */
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_7 = 127;
    __Pyx_INCREF(__pyx_kp_u_base_scalar_codec_for);
    __pyx_t_6 += 22;
    __Pyx_GIVEREF(__pyx_kp_u_base_scalar_codec_for);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_base_scalar_codec_for);
    __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_builtin_id, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_7;
    __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_INCREF(__pyx_kp_u_is_already_registered);
    __pyx_t_6 += 22;
    __Pyx_GIVEREF(__pyx_kp_u_is_already_registered);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_is_already_registered);
    __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(4, 344, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":343
 *     tid = tid.bytes
 * 
 *     if tid in BASE_SCALAR_CODECS:             # <<<<<<<<<<<<<<
 *         raise RuntimeError(f'base scalar codec for {id} is already registered')
 * 
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":346
 *         raise RuntimeError(f'base scalar codec for {id} is already registered')
 * 
 *     codec = ScalarCodec.new(tid, name, encoder, decoder)             # <<<<<<<<<<<<<<
 *     BASE_SCALAR_CODECS[tid] = codec
 * 
 */
  if (!(likely(PyBytes_CheckExact(__pyx_v_tid))||((__pyx_v_tid) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_tid)->tp_name), 0))) __PYX_ERR(4, 346, __pyx_L1_error)
  __pyx_t_1 = ((PyObject *)__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_new(((PyObject*)__pyx_v_tid), __pyx_v_name, __pyx_v_encoder, __pyx_v_decoder)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":347
 * 
 *     codec = ScalarCodec.new(tid, name, encoder, decoder)
 *     BASE_SCALAR_CODECS[tid] = codec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (unlikely(__pyx_v_6edgedb_8protocol_8protocol_BASE_SCALAR_CODECS == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(4, 347, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_6edgedb_8protocol_8protocol_BASE_SCALAR_CODECS, __pyx_v_tid, ((PyObject *)__pyx_v_codec)) < 0)) __PYX_ERR(4, 347, __pyx_L1_error)

  /* "edgedb/protocol/codecs/codecs.pyx":330
 * 
 * 
 * cdef register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         str name,
 *         pgproto.encode_func encoder,
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.register_base_scalar_codec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
  __Pyx_XDECREF(__pyx_v_tid);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":350
 * 
 * 
 * cdef time_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     if getattr(obj, 'tzinfo', None) is not None:
 *         raise TypeError(
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_time_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("time_encode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":351
 * 
 * cdef time_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     if getattr(obj, 'tzinfo', None) is not None:             # <<<<<<<<<<<<<<
 *         raise TypeError(
 *             f'a naive time object (tzinfo is None) was expected')
 */
  __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_obj, __pyx_n_u_tzinfo, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__pyx_t_1 != Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (unlikely(__pyx_t_3)) {

    /* "edgedb/protocol/codecs/codecs.pyx":352
 * cdef time_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     if getattr(obj, 'tzinfo', None) is not None:
 *         raise TypeError(             # <<<<<<<<<<<<<<
 *             f'a naive time object (tzinfo is None) was expected')
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__53, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 352, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(4, 352, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":351
 * 
 * cdef time_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     if getattr(obj, 'tzinfo', None) is not None:             # <<<<<<<<<<<<<<
 *         raise TypeError(
 *             f'a naive time object (tzinfo is None) was expected')
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":355
 *             f'a naive time object (tzinfo is None) was expected')
 * 
 *     pgproto.time_encode(settings, buf, obj)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_time_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":350
 * 
 * 
 * cdef time_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     if getattr(obj, 'tzinfo', None) is not None:
 *         raise TypeError(
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.time_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":358
 * 
 * 
 * cdef date_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     # Python `datetime.date` object does not have a `tzinfo` attribute
 *     # nor it is timezone-aware.  But since we're accepting duck types
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_date_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("date_encode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":362
 *     # nor it is timezone-aware.  But since we're accepting duck types
 *     # let's ensure it doesn't have tzinfo anyways.
 *     if getattr(obj, 'tzinfo', None) is not None:             # <<<<<<<<<<<<<<
 *         raise TypeError(
 *             f'a naive date object (tzinfo is None) was expected')
 */
  __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_obj, __pyx_n_u_tzinfo, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 362, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__pyx_t_1 != Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (unlikely(__pyx_t_3)) {

    /* "edgedb/protocol/codecs/codecs.pyx":363
 *     # let's ensure it doesn't have tzinfo anyways.
 *     if getattr(obj, 'tzinfo', None) is not None:
 *         raise TypeError(             # <<<<<<<<<<<<<<
 *             f'a naive date object (tzinfo is None) was expected')
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 363, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(4, 363, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":362
 *     # nor it is timezone-aware.  But since we're accepting duck types
 *     # let's ensure it doesn't have tzinfo anyways.
 *     if getattr(obj, 'tzinfo', None) is not None:             # <<<<<<<<<<<<<<
 *         raise TypeError(
 *             f'a naive date object (tzinfo is None) was expected')
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":366
 *             f'a naive date object (tzinfo is None) was expected')
 * 
 *     pgproto.date_encode(settings, buf, obj)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_date_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 366, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":358
 * 
 * 
 * cdef date_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     # Python `datetime.date` object does not have a `tzinfo` attribute
 *     # nor it is timezone-aware.  But since we're accepting duck types
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.date_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":369
 * 
 * 
 * cdef timestamp_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     if not cpython.datetime.PyDateTime_Check(obj):
 *         raise TypeError(
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_timestamp_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("timestamp_encode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":370
 * 
 * cdef timestamp_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     if not cpython.datetime.PyDateTime_Check(obj):             # <<<<<<<<<<<<<<
 *         raise TypeError(
 *             f'a datetime.datetime object was expected, got {obj!r}')
 */
  __pyx_t_1 = ((!(PyDateTime_Check(__pyx_v_obj) != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "edgedb/protocol/codecs/codecs.pyx":372
 *     if not cpython.datetime.PyDateTime_Check(obj):
 *         raise TypeError(
 *             f'a datetime.datetime object was expected, got {obj!r}')             # <<<<<<<<<<<<<<
 * 
 *     if getattr(obj, 'tzinfo', None) is not None:
 */
    __pyx_t_2 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_obj), __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 372, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_a_datetime_datetime_object_was_e, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 372, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":371
 * cdef timestamp_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     if not cpython.datetime.PyDateTime_Check(obj):
 *         raise TypeError(             # <<<<<<<<<<<<<<
 *             f'a datetime.datetime object was expected, got {obj!r}')
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(4, 371, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":370
 * 
 * cdef timestamp_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     if not cpython.datetime.PyDateTime_Check(obj):             # <<<<<<<<<<<<<<
 *         raise TypeError(
 *             f'a datetime.datetime object was expected, got {obj!r}')
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":374
 *             f'a datetime.datetime object was expected, got {obj!r}')
 * 
 *     if getattr(obj, 'tzinfo', None) is not None:             # <<<<<<<<<<<<<<
 *         raise TypeError(
 *             f'a naive datetime object (tzinfo is None) was expected')
 */
  __pyx_t_2 = __Pyx_GetAttr3(__pyx_v_obj, __pyx_n_u_tzinfo, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = (__pyx_t_2 != Py_None);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_4)) {

    /* "edgedb/protocol/codecs/codecs.pyx":375
 * 
 *     if getattr(obj, 'tzinfo', None) is not None:
 *         raise TypeError(             # <<<<<<<<<<<<<<
 *             f'a naive datetime object (tzinfo is None) was expected')
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__55, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 375, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(4, 375, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":374
 *             f'a datetime.datetime object was expected, got {obj!r}')
 * 
 *     if getattr(obj, 'tzinfo', None) is not None:             # <<<<<<<<<<<<<<
 *         raise TypeError(
 *             f'a naive datetime object (tzinfo is None) was expected')
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":378
 *             f'a naive datetime object (tzinfo is None) was expected')
 * 
 *     pgproto.timestamp_encode(settings, buf, obj)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __pyx_f_6edgedb_7pgproto_7pgproto_timestamp_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_obj); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":369
 * 
 * 
 * cdef timestamp_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     if not cpython.datetime.PyDateTime_Check(obj):
 *         raise TypeError(
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.timestamp_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":381
 * 
 * 
 * cdef timestamptz_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     if not cpython.datetime.PyDateTime_Check(obj):
 *         raise TypeError(
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_timestamptz_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("timestamptz_encode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":382
 * 
 * cdef timestamptz_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     if not cpython.datetime.PyDateTime_Check(obj):             # <<<<<<<<<<<<<<
 *         raise TypeError(
 *             f'a datetime.datetime object was expected')
 */
  __pyx_t_1 = ((!(PyDateTime_Check(__pyx_v_obj) != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "edgedb/protocol/codecs/codecs.pyx":383
 * cdef timestamptz_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     if not cpython.datetime.PyDateTime_Check(obj):
 *         raise TypeError(             # <<<<<<<<<<<<<<
 *             f'a datetime.datetime object was expected')
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__56, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(4, 383, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":382
 * 
 * cdef timestamptz_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     if not cpython.datetime.PyDateTime_Check(obj):             # <<<<<<<<<<<<<<
 *         raise TypeError(
 *             f'a datetime.datetime object was expected')
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":386
 *             f'a datetime.datetime object was expected')
 * 
 *     if getattr(obj, 'tzinfo', None) is None:             # <<<<<<<<<<<<<<
 *         raise TypeError(
 *             f'a timezone-aware datetime object (tzinfo is not None) '
 */
  __pyx_t_2 = __Pyx_GetAttr3(__pyx_v_obj, __pyx_n_u_tzinfo, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = (__pyx_t_2 == Py_None);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_3)) {

    /* "edgedb/protocol/codecs/codecs.pyx":387
 * 
 *     if getattr(obj, 'tzinfo', None) is None:
 *         raise TypeError(             # <<<<<<<<<<<<<<
 *             f'a timezone-aware datetime object (tzinfo is not None) '
 *             f'was expected')
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(4, 387, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":386
 *             f'a datetime.datetime object was expected')
 * 
 *     if getattr(obj, 'tzinfo', None) is None:             # <<<<<<<<<<<<<<
 *         raise TypeError(
 *             f'a timezone-aware datetime object (tzinfo is not None) '
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":391
 *             f'was expected')
 * 
 *     pgproto.timestamptz_encode(settings, buf, obj)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __pyx_f_6edgedb_7pgproto_7pgproto_timestamptz_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_obj); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":381
 * 
 * 
 * cdef timestamptz_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     if not cpython.datetime.PyDateTime_Check(obj):
 *         raise TypeError(
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("edgedb.protocol.protocol.timestamptz_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":394
 * 
 * 
 * cdef duration_encode(pgproto.CodecContext settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
 *                      object obj):
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_duration_encode(CYTHON_UNUSED struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_v_microseconds = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int64_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("duration_encode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":397
 *                      object obj):
 * 
 *     cdef microseconds = obj / datetime.timedelta(microseconds=1)             # <<<<<<<<<<<<<<
 * 
 *     buf.write_int32(16)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_timedelta); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_microseconds, __pyx_int_1) < 0) __PYX_ERR(4, 397, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_v_obj, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_microseconds = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":399
 *     cdef microseconds = obj / datetime.timedelta(microseconds=1)
 * 
 *     buf.write_int32(16)             # <<<<<<<<<<<<<<
 *     buf.write_int64(microseconds)
 *     buf.write_int32(0)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, 16); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":400
 * 
 *     buf.write_int32(16)
 *     buf.write_int64(microseconds)             # <<<<<<<<<<<<<<
 *     buf.write_int32(0)
 *     buf.write_int32(0)
 */
  __pyx_t_4 = __Pyx_PyInt_As_int64_t(__pyx_v_microseconds); if (unlikely((__pyx_t_4 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 400, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int64(__pyx_v_buf, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":401
 *     buf.write_int32(16)
 *     buf.write_int64(microseconds)
 *     buf.write_int32(0)             # <<<<<<<<<<<<<<
 *     buf.write_int32(0)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":402
 *     buf.write_int64(microseconds)
 *     buf.write_int32(0)
 *     buf.write_int32(0)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":394
 * 
 * 
 * cdef duration_encode(pgproto.CodecContext settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
 *                      object obj):
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.duration_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_microseconds);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":405
 * 
 * 
 * cdef duration_decode(pgproto.CodecContext settings, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int32_t days
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_duration_decode(CYTHON_UNUSED struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  int32_t __pyx_v_days;
  int32_t __pyx_v_months;
  int64_t __pyx_v_microseconds;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("duration_decode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":411
 *         int64_t microseconds
 * 
 *     microseconds = hton.unpack_int64(frb_read(buf, 8))             # <<<<<<<<<<<<<<
 *     days = hton.unpack_int32(frb_read(buf, 4))
 *     months = hton.unpack_int32(frb_read(buf, 4))
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 411, __pyx_L1_error)
  __pyx_v_microseconds = unpack_int64(__pyx_t_1);

  /* "edgedb/protocol/codecs/codecs.pyx":412
 * 
 *     microseconds = hton.unpack_int64(frb_read(buf, 8))
 *     days = hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 *     months = hton.unpack_int32(frb_read(buf, 4))
 *     if days != 0 or months != 0:
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 412, __pyx_L1_error)
  __pyx_v_days = unpack_int32(__pyx_t_1);

  /* "edgedb/protocol/codecs/codecs.pyx":413
 *     microseconds = hton.unpack_int64(frb_read(buf, 8))
 *     days = hton.unpack_int32(frb_read(buf, 4))
 *     months = hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 *     if days != 0 or months != 0:
 *         raise RuntimeError(f'non-zero reserved bytes in duration')
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 413, __pyx_L1_error)
  __pyx_v_months = unpack_int32(__pyx_t_1);

  /* "edgedb/protocol/codecs/codecs.pyx":414
 *     days = hton.unpack_int32(frb_read(buf, 4))
 *     months = hton.unpack_int32(frb_read(buf, 4))
 *     if days != 0 or months != 0:             # <<<<<<<<<<<<<<
 *         raise RuntimeError(f'non-zero reserved bytes in duration')
 * 
 */
  __pyx_t_3 = ((__pyx_v_days != 0) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_2 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = ((__pyx_v_months != 0) != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/codecs/codecs.pyx":415
 *     months = hton.unpack_int32(frb_read(buf, 4))
 *     if days != 0 or months != 0:
 *         raise RuntimeError(f'non-zero reserved bytes in duration')             # <<<<<<<<<<<<<<
 * 
 *     return datetime.timedelta(microseconds=microseconds)
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 415, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(4, 415, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":414
 *     days = hton.unpack_int32(frb_read(buf, 4))
 *     months = hton.unpack_int32(frb_read(buf, 4))
 *     if days != 0 or months != 0:             # <<<<<<<<<<<<<<
 *         raise RuntimeError(f'non-zero reserved bytes in duration')
 * 
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":417
 *         raise RuntimeError(f'non-zero reserved bytes in duration')
 * 
 *     return datetime.timedelta(microseconds=microseconds)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_timedelta); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyInt_From_int64_t(__pyx_v_microseconds); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_microseconds, __pyx_t_6) < 0) __PYX_ERR(4, 417, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(4, 417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/codecs.pyx":405
 * 
 * 
 * cdef duration_decode(pgproto.CodecContext settings, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int32_t days
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("edgedb.protocol.protocol.duration_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":420
 * 
 * 
 * cdef relative_duration_encode(pgproto.CodecContext settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
 *                           object obj):
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_relative_duration_encode(CYTHON_UNUSED struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_v_microseconds = 0;
  PyObject *__pyx_v_days = 0;
  PyObject *__pyx_v_months = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int64_t __pyx_t_2;
  int32_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("relative_duration_encode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":424
 * 
 *     cdef:
 *         microseconds = obj.microseconds             # <<<<<<<<<<<<<<
 *         days = obj.days
 *         months = obj.months
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_microseconds); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_microseconds = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":425
 *     cdef:
 *         microseconds = obj.microseconds
 *         days = obj.days             # <<<<<<<<<<<<<<
 *         months = obj.months
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_days); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_days = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":426
 *         microseconds = obj.microseconds
 *         days = obj.days
 *         months = obj.months             # <<<<<<<<<<<<<<
 * 
 *     buf.write_int32(16)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_months); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_months = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":428
 *         months = obj.months
 * 
 *     buf.write_int32(16)             # <<<<<<<<<<<<<<
 *     buf.write_int64(microseconds)
 *     buf.write_int32(days)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, 16); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":429
 * 
 *     buf.write_int32(16)
 *     buf.write_int64(microseconds)             # <<<<<<<<<<<<<<
 *     buf.write_int32(days)
 *     buf.write_int32(months)
 */
  __pyx_t_2 = __Pyx_PyInt_As_int64_t(__pyx_v_microseconds); if (unlikely((__pyx_t_2 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 429, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int64(__pyx_v_buf, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":430
 *     buf.write_int32(16)
 *     buf.write_int64(microseconds)
 *     buf.write_int32(days)             # <<<<<<<<<<<<<<
 *     buf.write_int32(months)
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_As_int32_t(__pyx_v_days); if (unlikely((__pyx_t_3 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 430, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":431
 *     buf.write_int64(microseconds)
 *     buf.write_int32(days)
 *     buf.write_int32(months)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_As_int32_t(__pyx_v_months); if (unlikely((__pyx_t_3 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 431, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":420
 * 
 * 
 * cdef relative_duration_encode(pgproto.CodecContext settings, WriteBuffer buf,             # <<<<<<<<<<<<<<
 *                           object obj):
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.relative_duration_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_microseconds);
  __Pyx_XDECREF(__pyx_v_days);
  __Pyx_XDECREF(__pyx_v_months);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":434
 * 
 * 
 * cdef relative_duration_decode(pgproto.CodecContext settings, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int32_t days
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_relative_duration_decode(CYTHON_UNUSED struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  int32_t __pyx_v_days;
  int32_t __pyx_v_months;
  int64_t __pyx_v_microseconds;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("relative_duration_decode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":440
 *         int64_t microseconds
 * 
 *     microseconds = hton.unpack_int64(frb_read(buf, 8))             # <<<<<<<<<<<<<<
 *     days = hton.unpack_int32(frb_read(buf, 4))
 *     months = hton.unpack_int32(frb_read(buf, 4))
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 440, __pyx_L1_error)
  __pyx_v_microseconds = unpack_int64(__pyx_t_1);

  /* "edgedb/protocol/codecs/codecs.pyx":441
 * 
 *     microseconds = hton.unpack_int64(frb_read(buf, 8))
 *     days = hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 *     months = hton.unpack_int32(frb_read(buf, 4))
 * 
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 441, __pyx_L1_error)
  __pyx_v_days = unpack_int32(__pyx_t_1);

  /* "edgedb/protocol/codecs/codecs.pyx":442
 *     microseconds = hton.unpack_int64(frb_read(buf, 8))
 *     days = hton.unpack_int32(frb_read(buf, 4))
 *     months = hton.unpack_int32(frb_read(buf, 4))             # <<<<<<<<<<<<<<
 * 
 *     return datatypes.RelativeDuration(
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 4); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 442, __pyx_L1_error)
  __pyx_v_months = unpack_int32(__pyx_t_1);

  /* "edgedb/protocol/codecs/codecs.pyx":444
 *     months = hton.unpack_int32(frb_read(buf, 4))
 * 
 *     return datatypes.RelativeDuration(             # <<<<<<<<<<<<<<
 *         microseconds=microseconds, days=days, months=months)
 * 
 */
  __Pyx_XDECREF(__pyx_r);

  /* "edgedb/protocol/codecs/codecs.pyx":445
 * 
 *     return datatypes.RelativeDuration(
 *         microseconds=microseconds, days=days, months=months)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_int64_t(__pyx_v_microseconds); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_microseconds, __pyx_t_3) < 0) __PYX_ERR(4, 445, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_int32_t(__pyx_v_days); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_days, __pyx_t_3) < 0) __PYX_ERR(4, 445, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_int32_t(__pyx_v_months); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_months, __pyx_t_3) < 0) __PYX_ERR(4, 445, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":444
 *     months = hton.unpack_int32(frb_read(buf, 4))
 * 
 *     return datatypes.RelativeDuration(             # <<<<<<<<<<<<<<
 *         microseconds=microseconds, days=days, months=months)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6edgedb_9datatypes_9datatypes_RelativeDuration), __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/codecs.pyx":434
 * 
 * 
 * cdef relative_duration_decode(pgproto.CodecContext settings, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int32_t days
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.relative_duration_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":448
 * 
 * 
 * cdef config_memory_encode(pgproto.CodecContext settings,             # <<<<<<<<<<<<<<
 *                           WriteBuffer buf,
 *                           object obj):
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_config_memory_encode(CYTHON_UNUSED struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_v_bytes = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int64_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("config_memory_encode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":452
 *                           object obj):
 *     cdef:
 *         bytes = obj._bytes             # <<<<<<<<<<<<<<
 * 
 *     buf.write_int32(8)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_bytes_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 452, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_bytes = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":454
 *         bytes = obj._bytes
 * 
 *     buf.write_int32(8)             # <<<<<<<<<<<<<<
 *     buf.write_int64(bytes)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, 8); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":455
 * 
 *     buf.write_int32(8)
 *     buf.write_int64(bytes)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_As_int64_t(__pyx_v_bytes); if (unlikely((__pyx_t_2 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 455, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int64(__pyx_v_buf, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":448
 * 
 * 
 * cdef config_memory_encode(pgproto.CodecContext settings,             # <<<<<<<<<<<<<<
 *                           WriteBuffer buf,
 *                           object obj):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.config_memory_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bytes);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":458
 * 
 * 
 * cdef config_memory_decode(pgproto.CodecContext settings, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t bytes
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_config_memory_decode(CYTHON_UNUSED struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  int64_t __pyx_v_bytes;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("config_memory_decode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":462
 *         int64_t bytes
 * 
 *     bytes = hton.unpack_int64(frb_read(buf, 8))             # <<<<<<<<<<<<<<
 * 
 *     return datatypes.ConfigMemory(bytes=bytes)
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 8); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 462, __pyx_L1_error)
  __pyx_v_bytes = unpack_int64(__pyx_t_1);

  /* "edgedb/protocol/codecs/codecs.pyx":464
 *     bytes = hton.unpack_int64(frb_read(buf, 8))
 * 
 *     return datatypes.ConfigMemory(bytes=bytes)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_int64_t(__pyx_v_bytes); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_bytes, __pyx_t_3) < 0) __PYX_ERR(4, 464, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6edgedb_9datatypes_9datatypes_ConfigMemory), __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/codecs.pyx":458
 * 
 * 
 * cdef config_memory_decode(pgproto.CodecContext settings, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         int64_t bytes
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.config_memory_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":467
 * 
 * 
 * cdef checked_decimal_encode(             # <<<<<<<<<<<<<<
 *     pgproto.CodecContext settings, WriteBuffer buf, obj
 * ):
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_checked_decimal_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checked_decimal_encode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":470
 *     pgproto.CodecContext settings, WriteBuffer buf, obj
 * ):
 *     if not isinstance(obj, decimal.Decimal) and not isinstance(obj, int):             # <<<<<<<<<<<<<<
 *         raise TypeError('expected a Decimal or an int')
 *     pgproto.numeric_encode_binary(settings, buf, obj)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_decimal); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 470, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 470, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_3); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(4, 470, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = ((!(__pyx_t_4 != 0)) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = PyInt_Check(__pyx_v_obj); 
  __pyx_t_4 = ((!(__pyx_t_5 != 0)) != 0);
  __pyx_t_1 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_1)) {

    /* "edgedb/protocol/codecs/codecs.pyx":471
 * ):
 *     if not isinstance(obj, decimal.Decimal) and not isinstance(obj, int):
 *         raise TypeError('expected a Decimal or an int')             # <<<<<<<<<<<<<<
 *     pgproto.numeric_encode_binary(settings, buf, obj)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 471, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 471, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":470
 *     pgproto.CodecContext settings, WriteBuffer buf, obj
 * ):
 *     if not isinstance(obj, decimal.Decimal) and not isinstance(obj, int):             # <<<<<<<<<<<<<<
 *         raise TypeError('expected a Decimal or an int')
 *     pgproto.numeric_encode_binary(settings, buf, obj)
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":472
 *     if not isinstance(obj, decimal.Decimal) and not isinstance(obj, int):
 *         raise TypeError('expected a Decimal or an int')
 *     pgproto.numeric_encode_binary(settings, buf, obj)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __pyx_f_6edgedb_7pgproto_7pgproto_numeric_encode_binary(__pyx_v_settings, __pyx_v_buf, __pyx_v_obj); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 472, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":467
 * 
 * 
 * cdef checked_decimal_encode(             # <<<<<<<<<<<<<<
 *     pgproto.CodecContext settings, WriteBuffer buf, obj
 * ):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.checked_decimal_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":475
 * 
 * 
 * cdef decimal_decode(pgproto.CodecContext settings, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *     return pgproto.numeric_decode_binary_ex(settings, buf, True)
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_decimal_decode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("decimal_decode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":476
 * 
 * cdef decimal_decode(pgproto.CodecContext settings, FRBuffer *buf):
 *     return pgproto.numeric_decode_binary_ex(settings, buf, True)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_numeric_decode_binary_ex(__pyx_v_settings, __pyx_v_buf, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 476, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/codecs.pyx":475
 * 
 * 
 * cdef decimal_decode(pgproto.CodecContext settings, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *     return pgproto.numeric_decode_binary_ex(settings, buf, True)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.decimal_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":479
 * 
 * 
 * cdef ensure_is_int(obj):             # <<<<<<<<<<<<<<
 *     if type(obj) is not int and not isinstance(obj, int):
 *         raise TypeError('expected an int')
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_ensure_is_int(PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ensure_is_int", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":480
 * 
 * cdef ensure_is_int(obj):
 *     if type(obj) is not int and not isinstance(obj, int):             # <<<<<<<<<<<<<<
 *         raise TypeError('expected an int')
 * 
 */
  __pyx_t_2 = (((PyObject *)Py_TYPE(__pyx_v_obj)) != ((PyObject *)(&PyInt_Type)));
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = PyInt_Check(__pyx_v_obj); 
  __pyx_t_2 = ((!(__pyx_t_3 != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_1)) {

    /* "edgedb/protocol/codecs/codecs.pyx":481
 * cdef ensure_is_int(obj):
 *     if type(obj) is not int and not isinstance(obj, int):
 *         raise TypeError('expected an int')             # <<<<<<<<<<<<<<
 * 
 * cdef checked_int2_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__60, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(4, 481, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(4, 481, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":480
 * 
 * cdef ensure_is_int(obj):
 *     if type(obj) is not int and not isinstance(obj, int):             # <<<<<<<<<<<<<<
 *         raise TypeError('expected an int')
 * 
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":479
 * 
 * 
 * cdef ensure_is_int(obj):             # <<<<<<<<<<<<<<
 *     if type(obj) is not int and not isinstance(obj, int):
 *         raise TypeError('expected an int')
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("edgedb.protocol.protocol.ensure_is_int", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":483
 *         raise TypeError('expected an int')
 * 
 * cdef checked_int2_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     ensure_is_int(obj)
 *     pgproto.int2_encode(settings, buf, obj)
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_checked_int2_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checked_int2_encode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":484
 * 
 * cdef checked_int2_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     ensure_is_int(obj)             # <<<<<<<<<<<<<<
 *     pgproto.int2_encode(settings, buf, obj)
 * 
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_ensure_is_int(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":485
 * cdef checked_int2_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     ensure_is_int(obj)
 *     pgproto.int2_encode(settings, buf, obj)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_int2_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":483
 *         raise TypeError('expected an int')
 * 
 * cdef checked_int2_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     ensure_is_int(obj)
 *     pgproto.int2_encode(settings, buf, obj)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.checked_int2_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":488
 * 
 * 
 * cdef checked_int4_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     ensure_is_int(obj)
 *     pgproto.int4_encode(settings, buf, obj)
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_checked_int4_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checked_int4_encode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":489
 * 
 * cdef checked_int4_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     ensure_is_int(obj)             # <<<<<<<<<<<<<<
 *     pgproto.int4_encode(settings, buf, obj)
 * 
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_ensure_is_int(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 489, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":490
 * cdef checked_int4_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     ensure_is_int(obj)
 *     pgproto.int4_encode(settings, buf, obj)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_int4_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 490, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":488
 * 
 * 
 * cdef checked_int4_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     ensure_is_int(obj)
 *     pgproto.int4_encode(settings, buf, obj)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.checked_int4_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":493
 * 
 * 
 * cdef checked_int8_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     ensure_is_int(obj)
 *     pgproto.int8_encode(settings, buf, obj)
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_checked_int8_encode(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("checked_int8_encode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":494
 * 
 * cdef checked_int8_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     ensure_is_int(obj)             # <<<<<<<<<<<<<<
 *     pgproto.int8_encode(settings, buf, obj)
 * 
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_ensure_is_int(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 494, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":495
 * cdef checked_int8_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     ensure_is_int(obj)
 *     pgproto.int8_encode(settings, buf, obj)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_int8_encode(__pyx_v_settings, __pyx_v_buf, __pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 495, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":493
 * 
 * 
 * cdef checked_int8_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     ensure_is_int(obj)
 *     pgproto.int8_encode(settings, buf, obj)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.checked_int8_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":498
 * 
 * 
 * cdef bigint_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef:
 *         uint16_t sign = NUMERIC_POS
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_bigint_encode(CYTHON_UNUSED struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_obj) {
  uint16_t __pyx_v_sign;
  PyObject *__pyx_v_digits = 0;
  PyObject *__pyx_v_mod = NULL;
  PyObject *__pyx_v_dig = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int16_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("bigint_encode", 0);
  __Pyx_INCREF(__pyx_v_obj);

  /* "edgedb/protocol/codecs/codecs.pyx":500
 * cdef bigint_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     cdef:
 *         uint16_t sign = NUMERIC_POS             # <<<<<<<<<<<<<<
 *         list digits = []
 * 
 */
  __pyx_v_sign = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":501
 *     cdef:
 *         uint16_t sign = NUMERIC_POS
 *         list digits = []             # <<<<<<<<<<<<<<
 * 
 *     ensure_is_int(obj)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_digits = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":503
 *         list digits = []
 * 
 *     ensure_is_int(obj)             # <<<<<<<<<<<<<<
 * 
 *     if obj == 0:
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_ensure_is_int(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 503, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":505
 *     ensure_is_int(obj)
 * 
 *     if obj == 0:             # <<<<<<<<<<<<<<
 *         buf.write_int32(8)  # len
 *         buf.write_int32(0)  # ndigits + weight
 */
  __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_v_obj, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(4, 505, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "edgedb/protocol/codecs/codecs.pyx":506
 * 
 *     if obj == 0:
 *         buf.write_int32(8)  # len             # <<<<<<<<<<<<<<
 *         buf.write_int32(0)  # ndigits + weight
 *         buf.write_int16(NUMERIC_POS)  # sign
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, 8); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 506, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":507
 *     if obj == 0:
 *         buf.write_int32(8)  # len
 *         buf.write_int32(0)  # ndigits + weight             # <<<<<<<<<<<<<<
 *         buf.write_int16(NUMERIC_POS)  # sign
 *         buf.write_int16(0)  # dscale
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 507, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":508
 *         buf.write_int32(8)  # len
 *         buf.write_int32(0)  # ndigits + weight
 *         buf.write_int16(NUMERIC_POS)  # sign             # <<<<<<<<<<<<<<
 *         buf.write_int16(0)  # dscale
 *         return
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int16(__pyx_v_buf, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 508, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":509
 *         buf.write_int32(0)  # ndigits + weight
 *         buf.write_int16(NUMERIC_POS)  # sign
 *         buf.write_int16(0)  # dscale             # <<<<<<<<<<<<<<
 *         return
 * 
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int16(__pyx_v_buf, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 509, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":510
 *         buf.write_int16(NUMERIC_POS)  # sign
 *         buf.write_int16(0)  # dscale
 *         return             # <<<<<<<<<<<<<<
 * 
 *     if obj < 0:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "edgedb/protocol/codecs/codecs.pyx":505
 *     ensure_is_int(obj)
 * 
 *     if obj == 0:             # <<<<<<<<<<<<<<
 *         buf.write_int32(8)  # len
 *         buf.write_int32(0)  # ndigits + weight
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":512
 *         return
 * 
 *     if obj < 0:             # <<<<<<<<<<<<<<
 *         sign = NUMERIC_NEG
 *         obj = -obj
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_obj, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 512, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(4, 512, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "edgedb/protocol/codecs/codecs.pyx":513
 * 
 *     if obj < 0:
 *         sign = NUMERIC_NEG             # <<<<<<<<<<<<<<
 *         obj = -obj
 * 
 */
    __pyx_v_sign = 0x4000;

    /* "edgedb/protocol/codecs/codecs.pyx":514
 *     if obj < 0:
 *         sign = NUMERIC_NEG
 *         obj = -obj             # <<<<<<<<<<<<<<
 * 
 *     while obj:
 */
    __pyx_t_1 = PyNumber_Negative(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 514, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":512
 *         return
 * 
 *     if obj < 0:             # <<<<<<<<<<<<<<
 *         sign = NUMERIC_NEG
 *         obj = -obj
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":516
 *         obj = -obj
 * 
 *     while obj:             # <<<<<<<<<<<<<<
 *         mod = obj % NBASE
 *         obj //= NBASE
 */
  while (1) {
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(4, 516, __pyx_L1_error)
    if (!__pyx_t_2) break;

    /* "edgedb/protocol/codecs/codecs.pyx":517
 * 
 *     while obj:
 *         mod = obj % NBASE             # <<<<<<<<<<<<<<
 *         obj //= NBASE
 *         digits.append(mod)
 */
    __pyx_t_1 = __Pyx_PyInt_RemainderObjC(__pyx_v_obj, __pyx_int_10000, 0x2710, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_mod, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":518
 *     while obj:
 *         mod = obj % NBASE
 *         obj //= NBASE             # <<<<<<<<<<<<<<
 *         digits.append(mod)
 * 
 */
    __pyx_t_1 = __Pyx_PyInt_FloorDivideObjC(__pyx_v_obj, __pyx_int_10000, 0x2710, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":519
 *         mod = obj % NBASE
 *         obj //= NBASE
 *         digits.append(mod)             # <<<<<<<<<<<<<<
 * 
 *     buf.write_int32(8 + len(digits) * 2)  # len
 */
    __pyx_t_3 = __Pyx_PyList_Append(__pyx_v_digits, __pyx_v_mod); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(4, 519, __pyx_L1_error)
  }

  /* "edgedb/protocol/codecs/codecs.pyx":521
 *         digits.append(mod)
 * 
 *     buf.write_int32(8 + len(digits) * 2)  # len             # <<<<<<<<<<<<<<
 *     buf.write_int16(len(digits))  # ndigits
 *     buf.write_int16(len(digits) - 1)  # weight
 */
  __pyx_t_4 = PyList_GET_SIZE(__pyx_v_digits); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(4, 521, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int32(__pyx_v_buf, (8 + (__pyx_t_4 * 2))); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 521, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":522
 * 
 *     buf.write_int32(8 + len(digits) * 2)  # len
 *     buf.write_int16(len(digits))  # ndigits             # <<<<<<<<<<<<<<
 *     buf.write_int16(len(digits) - 1)  # weight
 *     buf.write_int16(sign)  # sign
 */
  __pyx_t_4 = PyList_GET_SIZE(__pyx_v_digits); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(4, 522, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int16(__pyx_v_buf, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 522, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":523
 *     buf.write_int32(8 + len(digits) * 2)  # len
 *     buf.write_int16(len(digits))  # ndigits
 *     buf.write_int16(len(digits) - 1)  # weight             # <<<<<<<<<<<<<<
 *     buf.write_int16(sign)  # sign
 *     buf.write_int16(0)  # dscale
 */
  __pyx_t_4 = PyList_GET_SIZE(__pyx_v_digits); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(4, 523, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int16(__pyx_v_buf, (__pyx_t_4 - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 523, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":524
 *     buf.write_int16(len(digits))  # ndigits
 *     buf.write_int16(len(digits) - 1)  # weight
 *     buf.write_int16(sign)  # sign             # <<<<<<<<<<<<<<
 *     buf.write_int16(0)  # dscale
 *     for dig in reversed(digits):
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int16(__pyx_v_buf, __pyx_v_sign); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 524, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":525
 *     buf.write_int16(len(digits) - 1)  # weight
 *     buf.write_int16(sign)  # sign
 *     buf.write_int16(0)  # dscale             # <<<<<<<<<<<<<<
 *     for dig in reversed(digits):
 *         buf.write_int16(dig)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int16(__pyx_v_buf, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 525, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":526
 *     buf.write_int16(sign)  # sign
 *     buf.write_int16(0)  # dscale
 *     for dig in reversed(digits):             # <<<<<<<<<<<<<<
 *         buf.write_int16(dig)
 * 
 */
  __pyx_t_1 = __pyx_v_digits; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = PyList_GET_SIZE(__pyx_t_1) - 1;
  for (;;) {
    if (__pyx_t_4 < 0) break;
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4--; if (unlikely(0 < 0)) __PYX_ERR(4, 526, __pyx_L1_error)
    #else
    __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4--; if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 526, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_dig, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":527
 *     buf.write_int16(0)  # dscale
 *     for dig in reversed(digits):
 *         buf.write_int16(dig)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_6 = __Pyx_PyInt_As_int16_t(__pyx_v_dig); if (unlikely((__pyx_t_6 == ((int16_t)-1)) && PyErr_Occurred())) __PYX_ERR(4, 527, __pyx_L1_error)
    __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int16(__pyx_v_buf, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 527, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "edgedb/protocol/codecs/codecs.pyx":526
 *     buf.write_int16(sign)  # sign
 *     buf.write_int16(0)  # dscale
 *     for dig in reversed(digits):             # <<<<<<<<<<<<<<
 *         buf.write_int16(dig)
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":498
 * 
 * 
 * cdef bigint_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):             # <<<<<<<<<<<<<<
 *     cdef:
 *         uint16_t sign = NUMERIC_POS
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("edgedb.protocol.protocol.bigint_encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_digits);
  __Pyx_XDECREF(__pyx_v_mod);
  __Pyx_XDECREF(__pyx_v_dig);
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":530
 * 
 * 
 * cdef bigint_decode(pgproto.CodecContext settings, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         uint16_t ndigits = <uint16_t>hton.unpack_int16(frb_read(buf, 2))
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_bigint_decode(CYTHON_UNUSED struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *__pyx_v_settings, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_buf) {
  uint16_t __pyx_v_ndigits;
  uint16_t __pyx_v_weight;
  uint16_t __pyx_v_sign;
  uint16_t __pyx_v_dscale;
  PyObject *__pyx_v_result = 0;
  int32_t __pyx_v_i;
  uint16_t __pyx_v_d;
  PyObject *__pyx_v_num = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("bigint_decode", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":532
 * cdef bigint_decode(pgproto.CodecContext settings, FRBuffer *buf):
 *     cdef:
 *         uint16_t ndigits = <uint16_t>hton.unpack_int16(frb_read(buf, 2))             # <<<<<<<<<<<<<<
 *         uint16_t weight = <uint16_t>hton.unpack_int16(frb_read(buf, 2))
 *         uint16_t sign = <uint16_t>hton.unpack_int16(frb_read(buf, 2))
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 532, __pyx_L1_error)
  __pyx_v_ndigits = ((uint16_t)unpack_int16(__pyx_t_1));

  /* "edgedb/protocol/codecs/codecs.pyx":533
 *     cdef:
 *         uint16_t ndigits = <uint16_t>hton.unpack_int16(frb_read(buf, 2))
 *         uint16_t weight = <uint16_t>hton.unpack_int16(frb_read(buf, 2))             # <<<<<<<<<<<<<<
 *         uint16_t sign = <uint16_t>hton.unpack_int16(frb_read(buf, 2))
 *         uint16_t dscale = <uint16_t>hton.unpack_int16(frb_read(buf, 2))
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 533, __pyx_L1_error)
  __pyx_v_weight = ((uint16_t)unpack_int16(__pyx_t_1));

  /* "edgedb/protocol/codecs/codecs.pyx":534
 *         uint16_t ndigits = <uint16_t>hton.unpack_int16(frb_read(buf, 2))
 *         uint16_t weight = <uint16_t>hton.unpack_int16(frb_read(buf, 2))
 *         uint16_t sign = <uint16_t>hton.unpack_int16(frb_read(buf, 2))             # <<<<<<<<<<<<<<
 *         uint16_t dscale = <uint16_t>hton.unpack_int16(frb_read(buf, 2))
 *         result = ''
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 534, __pyx_L1_error)
  __pyx_v_sign = ((uint16_t)unpack_int16(__pyx_t_1));

  /* "edgedb/protocol/codecs/codecs.pyx":535
 *         uint16_t weight = <uint16_t>hton.unpack_int16(frb_read(buf, 2))
 *         uint16_t sign = <uint16_t>hton.unpack_int16(frb_read(buf, 2))
 *         uint16_t dscale = <uint16_t>hton.unpack_int16(frb_read(buf, 2))             # <<<<<<<<<<<<<<
 *         result = ''
 *         int32_t i = <int32_t>weight
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 535, __pyx_L1_error)
  __pyx_v_dscale = ((uint16_t)unpack_int16(__pyx_t_1));

  /* "edgedb/protocol/codecs/codecs.pyx":536
 *         uint16_t sign = <uint16_t>hton.unpack_int16(frb_read(buf, 2))
 *         uint16_t dscale = <uint16_t>hton.unpack_int16(frb_read(buf, 2))
 *         result = ''             # <<<<<<<<<<<<<<
 *         int32_t i = <int32_t>weight
 *         uint16_t d = 0
 */
  __Pyx_INCREF(__pyx_kp_u__61);
  __pyx_v_result = __pyx_kp_u__61;

  /* "edgedb/protocol/codecs/codecs.pyx":537
 *         uint16_t dscale = <uint16_t>hton.unpack_int16(frb_read(buf, 2))
 *         result = ''
 *         int32_t i = <int32_t>weight             # <<<<<<<<<<<<<<
 *         uint16_t d = 0
 * 
 */
  __pyx_v_i = ((int32_t)__pyx_v_weight);

  /* "edgedb/protocol/codecs/codecs.pyx":538
 *         result = ''
 *         int32_t i = <int32_t>weight
 *         uint16_t d = 0             # <<<<<<<<<<<<<<
 * 
 *     if sign == NUMERIC_NEG:
 */
  __pyx_v_d = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":540
 *         uint16_t d = 0
 * 
 *     if sign == NUMERIC_NEG:             # <<<<<<<<<<<<<<
 *         result = '-'
 *     elif sign != NUMERIC_POS:
 */
  __pyx_t_2 = ((__pyx_v_sign == 0x4000) != 0);
  if (__pyx_t_2) {

    /* "edgedb/protocol/codecs/codecs.pyx":541
 * 
 *     if sign == NUMERIC_NEG:
 *         result = '-'             # <<<<<<<<<<<<<<
 *     elif sign != NUMERIC_POS:
 *         raise ValueError("bad bigint sign data")
 */
    __Pyx_INCREF(__pyx_kp_u__62);
    __Pyx_DECREF_SET(__pyx_v_result, __pyx_kp_u__62);

    /* "edgedb/protocol/codecs/codecs.pyx":540
 *         uint16_t d = 0
 * 
 *     if sign == NUMERIC_NEG:             # <<<<<<<<<<<<<<
 *         result = '-'
 *     elif sign != NUMERIC_POS:
 */
    goto __pyx_L3;
  }

  /* "edgedb/protocol/codecs/codecs.pyx":542
 *     if sign == NUMERIC_NEG:
 *         result = '-'
 *     elif sign != NUMERIC_POS:             # <<<<<<<<<<<<<<
 *         raise ValueError("bad bigint sign data")
 * 
 */
  __pyx_t_2 = ((__pyx_v_sign != 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/codecs/codecs.pyx":543
 *         result = '-'
 *     elif sign != NUMERIC_POS:
 *         raise ValueError("bad bigint sign data")             # <<<<<<<<<<<<<<
 * 
 *     if dscale != 0:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 543, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":542
 *     if sign == NUMERIC_NEG:
 *         result = '-'
 *     elif sign != NUMERIC_POS:             # <<<<<<<<<<<<<<
 *         raise ValueError("bad bigint sign data")
 * 
 */
  }
  __pyx_L3:;

  /* "edgedb/protocol/codecs/codecs.pyx":545
 *         raise ValueError("bad bigint sign data")
 * 
 *     if dscale != 0:             # <<<<<<<<<<<<<<
 *         raise ValueError("bigint data has fractional part")
 * 
 */
  __pyx_t_2 = ((__pyx_v_dscale != 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/codecs/codecs.pyx":546
 * 
 *     if dscale != 0:
 *         raise ValueError("bigint data has fractional part")             # <<<<<<<<<<<<<<
 * 
 *     if ndigits == 0:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 546, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(4, 546, __pyx_L1_error)

    /* "edgedb/protocol/codecs/codecs.pyx":545
 *         raise ValueError("bad bigint sign data")
 * 
 *     if dscale != 0:             # <<<<<<<<<<<<<<
 *         raise ValueError("bigint data has fractional part")
 * 
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":548
 *         raise ValueError("bigint data has fractional part")
 * 
 *     if ndigits == 0:             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  __pyx_t_2 = ((__pyx_v_ndigits == 0) != 0);
  if (__pyx_t_2) {

    /* "edgedb/protocol/codecs/codecs.pyx":549
 * 
 *     if ndigits == 0:
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     while i >= 0:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_int_0);
    __pyx_r = __pyx_int_0;
    goto __pyx_L0;

    /* "edgedb/protocol/codecs/codecs.pyx":548
 *         raise ValueError("bigint data has fractional part")
 * 
 *     if ndigits == 0:             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  }

  /* "edgedb/protocol/codecs/codecs.pyx":551
 *         return 0
 * 
 *     while i >= 0:             # <<<<<<<<<<<<<<
 *         if i <= weight and d < ndigits:
 *             num = str(<uint16_t>hton.unpack_int16(frb_read(buf, 2)))
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_i >= 0) != 0);
    if (!__pyx_t_2) break;

    /* "edgedb/protocol/codecs/codecs.pyx":552
 * 
 *     while i >= 0:
 *         if i <= weight and d < ndigits:             # <<<<<<<<<<<<<<
 *             num = str(<uint16_t>hton.unpack_int16(frb_read(buf, 2)))
 *             result += num.zfill(4)
 */
    __pyx_t_4 = ((__pyx_v_i <= __pyx_v_weight) != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_2 = __pyx_t_4;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_4 = ((__pyx_v_d < __pyx_v_ndigits) != 0);
    __pyx_t_2 = __pyx_t_4;
    __pyx_L9_bool_binop_done:;
    if (__pyx_t_2) {

      /* "edgedb/protocol/codecs/codecs.pyx":553
 *     while i >= 0:
 *         if i <= weight and d < ndigits:
 *             num = str(<uint16_t>hton.unpack_int16(frb_read(buf, 2)))             # <<<<<<<<<<<<<<
 *             result += num.zfill(4)
 *             d += 1
 */
      __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_buf, 2); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(4, 553, __pyx_L1_error)
      __pyx_t_3 = __Pyx_PyInt_From_uint16_t(((uint16_t)unpack_int16(__pyx_t_1))); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 553, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 553, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_num, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "edgedb/protocol/codecs/codecs.pyx":554
 *         if i <= weight and d < ndigits:
 *             num = str(<uint16_t>hton.unpack_int16(frb_read(buf, 2)))
 *             result += num.zfill(4)             # <<<<<<<<<<<<<<
 *             d += 1
 *         else:
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_num, __pyx_n_s_zfill); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 554, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_5 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_6, __pyx_int_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_int_4);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(4, 554, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 554, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "edgedb/protocol/codecs/codecs.pyx":555
 *             num = str(<uint16_t>hton.unpack_int16(frb_read(buf, 2)))
 *             result += num.zfill(4)
 *             d += 1             # <<<<<<<<<<<<<<
 *         else:
 *             result += '0000'
 */
      __pyx_v_d = (__pyx_v_d + 1);

      /* "edgedb/protocol/codecs/codecs.pyx":552
 * 
 *     while i >= 0:
 *         if i <= weight and d < ndigits:             # <<<<<<<<<<<<<<
 *             num = str(<uint16_t>hton.unpack_int16(frb_read(buf, 2)))
 *             result += num.zfill(4)
 */
      goto __pyx_L8;
    }

    /* "edgedb/protocol/codecs/codecs.pyx":557
 *             d += 1
 *         else:
 *             result += '0000'             # <<<<<<<<<<<<<<
 *         i -= 1
 * 
 */
    /*else*/ {
      __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_kp_u_0000); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 557, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_3);
      __pyx_t_3 = 0;
    }
    __pyx_L8:;

    /* "edgedb/protocol/codecs/codecs.pyx":558
 *         else:
 *             result += '0000'
 *         i -= 1             # <<<<<<<<<<<<<<
 * 
 *     return int(result)
 */
    __pyx_v_i = (__pyx_v_i - 1);
  }

  /* "edgedb/protocol/codecs/codecs.pyx":560
 *         i -= 1
 * 
 *     return int(result)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(4, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/codecs.pyx":530
 * 
 * 
 * cdef bigint_decode(pgproto.CodecContext settings, FRBuffer *buf):             # <<<<<<<<<<<<<<
 *     cdef:
 *         uint16_t ndigits = <uint16_t>hton.unpack_int16(frb_read(buf, 2))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("edgedb.protocol.protocol.bigint_decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_num);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/codecs.pyx":563
 * 
 * 
 * cdef register_base_scalar_codecs():             # <<<<<<<<<<<<<<
 *     register_base_scalar_codec(
 *         'std::uuid',
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codecs(void) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("register_base_scalar_codecs", 0);

  /* "edgedb/protocol/codecs/codecs.pyx":564
 * 
 * cdef register_base_scalar_codecs():
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'std::uuid',
 *         pgproto.uuid_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_std_uuid, __pyx_f_6edgedb_7pgproto_7pgproto_uuid_encode, __pyx_f_6edgedb_7pgproto_7pgproto_uuid_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":569
 *         pgproto.uuid_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'std::str',
 *         pgproto.text_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_std_str, __pyx_f_6edgedb_7pgproto_7pgproto_text_encode, __pyx_f_6edgedb_7pgproto_7pgproto_text_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":574
 *         pgproto.text_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'std::bytes',
 *         pgproto.bytea_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_std_bytes, __pyx_f_6edgedb_7pgproto_7pgproto_bytea_encode, __pyx_f_6edgedb_7pgproto_7pgproto_bytea_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":579
 *         pgproto.bytea_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'std::int16',
 *         checked_int2_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_std_int16, __pyx_f_6edgedb_8protocol_8protocol_checked_int2_encode, __pyx_f_6edgedb_7pgproto_7pgproto_int2_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 579, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":584
 *         pgproto.int2_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'std::int32',
 *         checked_int4_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_std_int32, __pyx_f_6edgedb_8protocol_8protocol_checked_int4_encode, __pyx_f_6edgedb_7pgproto_7pgproto_int4_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":589
 *         pgproto.int4_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'std::int64',
 *         checked_int8_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_std_int64, __pyx_f_6edgedb_8protocol_8protocol_checked_int8_encode, __pyx_f_6edgedb_7pgproto_7pgproto_int8_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":594
 *         pgproto.int8_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'std::float32',
 *         pgproto.float4_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_std_float32, __pyx_f_6edgedb_7pgproto_7pgproto_float4_encode, __pyx_f_6edgedb_7pgproto_7pgproto_float4_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":599
 *         pgproto.float4_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'std::float64',
 *         pgproto.float8_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_std_float64, __pyx_f_6edgedb_7pgproto_7pgproto_float8_encode, __pyx_f_6edgedb_7pgproto_7pgproto_float8_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 599, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":604
 *         pgproto.float8_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'std::decimal',
 *         checked_decimal_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_std_decimal, __pyx_f_6edgedb_8protocol_8protocol_checked_decimal_encode, __pyx_f_6edgedb_8protocol_8protocol_decimal_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 604, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":609
 *         decimal_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'std::bigint',
 *         bigint_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_std_bigint, __pyx_f_6edgedb_8protocol_8protocol_bigint_encode, __pyx_f_6edgedb_8protocol_8protocol_bigint_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 609, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":614
 *         bigint_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'std::bool',
 *         pgproto.bool_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_std_bool, __pyx_f_6edgedb_7pgproto_7pgproto_bool_encode, __pyx_f_6edgedb_7pgproto_7pgproto_bool_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 614, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":619
 *         pgproto.bool_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'std::datetime',
 *         timestamptz_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_std_datetime, __pyx_f_6edgedb_8protocol_8protocol_timestamptz_encode, __pyx_f_6edgedb_7pgproto_7pgproto_timestamptz_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 619, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":624
 *         pgproto.timestamptz_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'cal::local_datetime',
 *         timestamp_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_cal_local_datetime, __pyx_f_6edgedb_8protocol_8protocol_timestamp_encode, __pyx_f_6edgedb_7pgproto_7pgproto_timestamp_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 624, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":629
 *         pgproto.timestamp_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'cal::local_date',
 *         date_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_cal_local_date, __pyx_f_6edgedb_8protocol_8protocol_date_encode, __pyx_f_6edgedb_7pgproto_7pgproto_date_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":634
 *         pgproto.date_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'cal::local_time',
 *         time_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_cal_local_time, __pyx_f_6edgedb_8protocol_8protocol_time_encode, __pyx_f_6edgedb_7pgproto_7pgproto_time_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":639
 *         pgproto.time_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'std::duration',
 *         duration_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_std_duration, __pyx_f_6edgedb_8protocol_8protocol_duration_encode, __pyx_f_6edgedb_8protocol_8protocol_duration_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 639, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":644
 *         duration_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'std::json',
 *         pgproto.jsonb_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_std_json, __pyx_f_6edgedb_7pgproto_7pgproto_jsonb_encode, __pyx_f_6edgedb_7pgproto_7pgproto_jsonb_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 644, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":649
 *         pgproto.jsonb_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'cal::relative_duration',
 *         relative_duration_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_cal_relative_duration, __pyx_f_6edgedb_8protocol_8protocol_relative_duration_encode, __pyx_f_6edgedb_8protocol_8protocol_relative_duration_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 649, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":654
 *         relative_duration_decode)
 * 
 *     register_base_scalar_codec(             # <<<<<<<<<<<<<<
 *         'cfg::memory',
 *         config_memory_encode,
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codec(__pyx_kp_u_cfg_memory, __pyx_f_6edgedb_8protocol_8protocol_config_memory_encode, __pyx_f_6edgedb_8protocol_8protocol_config_memory_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 654, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":563
 * 
 * 
 * cdef register_base_scalar_codecs():             # <<<<<<<<<<<<<<
 *     register_base_scalar_codec(
 *         'std::uuid',
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.register_base_scalar_codecs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":96
 * cdef class QueryCodecsCache:
 * 
 *     def __init__(self, *, cache_size=1000):             # <<<<<<<<<<<<<<
 *         self.queries = LRUMapping(maxsize=cache_size)
 * 
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_16QueryCodecsCache_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_16QueryCodecsCache_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_cache_size = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cache_size,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_1000);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (kw_args == 1) {
        const Py_ssize_t index = 0;
        PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
        if (value) { values[index] = value; kw_args--; }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "__init__") < 0)) __PYX_ERR(5, 96, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
      goto __pyx_L5_argtuple_error;
    } else {
    }
    __pyx_v_cache_size = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 96, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.QueryCodecsCache.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_16QueryCodecsCache___init__(((struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *)__pyx_v_self), __pyx_v_cache_size);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_16QueryCodecsCache___init__(struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_self, PyObject *__pyx_v_cache_size) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "edgedb/protocol/protocol.pyx":97
 * 
 *     def __init__(self, *, cache_size=1000):
 *         self.queries = LRUMapping(maxsize=cache_size)             # <<<<<<<<<<<<<<
 * 
 *     def get(
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 97, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_maxsize, __pyx_v_cache_size) < 0) __PYX_ERR(5, 97, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6edgedb_8protocol_8protocol_LRUMapping), __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 97, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->queries);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->queries));
  __pyx_v_self->queries = ((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":96
 * cdef class QueryCodecsCache:
 * 
 *     def __init__(self, *, cache_size=1000):             # <<<<<<<<<<<<<<
 *         self.queries = LRUMapping(maxsize=cache_size)
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("edgedb.protocol.protocol.QueryCodecsCache.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":99
 *         self.queries = LRUMapping(maxsize=cache_size)
 * 
 *     def get(             # <<<<<<<<<<<<<<
 *         self, str query, IoFormat io_format,
 *         int implicit_limit, bint inline_typenames, bint inline_typeids,
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_16QueryCodecsCache_3get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_16QueryCodecsCache_3get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_query = 0;
  enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __pyx_v_io_format;
  int __pyx_v_implicit_limit;
  int __pyx_v_inline_typenames;
  int __pyx_v_inline_typeids;
  int __pyx_v_expect_one;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_query,&__pyx_n_s_io_format,&__pyx_n_s_implicit_limit,&__pyx_n_s_inline_typenames,&__pyx_n_s_inline_typeids,&__pyx_n_s_expect_one,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_query)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_io_format)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get", 1, 6, 6, 1); __PYX_ERR(5, 99, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_implicit_limit)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get", 1, 6, 6, 2); __PYX_ERR(5, 99, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inline_typenames)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get", 1, 6, 6, 3); __PYX_ERR(5, 99, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inline_typeids)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get", 1, 6, 6, 4); __PYX_ERR(5, 99, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_expect_one)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get", 1, 6, 6, 5); __PYX_ERR(5, 99, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(5, 99, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
    }
    __pyx_v_query = ((PyObject*)values[0]);
    __pyx_v_io_format = ((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)__Pyx_PyInt_As_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(values[1])); if (unlikely(PyErr_Occurred())) __PYX_ERR(5, 100, __pyx_L3_error)
    __pyx_v_implicit_limit = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_implicit_limit == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 101, __pyx_L3_error)
    __pyx_v_inline_typenames = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_inline_typenames == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 101, __pyx_L3_error)
    __pyx_v_inline_typeids = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_inline_typeids == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 101, __pyx_L3_error)
    __pyx_v_expect_one = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_expect_one == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 102, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 99, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.QueryCodecsCache.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_query), (&PyUnicode_Type), 1, "query", 1))) __PYX_ERR(5, 100, __pyx_L1_error)
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_16QueryCodecsCache_2get(((struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *)__pyx_v_self), __pyx_v_query, __pyx_v_io_format, __pyx_v_implicit_limit, __pyx_v_inline_typenames, __pyx_v_inline_typeids, __pyx_v_expect_one);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_16QueryCodecsCache_2get(struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_self, PyObject *__pyx_v_query, enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __pyx_v_io_format, int __pyx_v_implicit_limit, int __pyx_v_inline_typenames, int __pyx_v_inline_typeids, int __pyx_v_expect_one) {
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get", 0);

  /* "edgedb/protocol/protocol.pyx":105
 *     ):
 *         key = (
 *             query, io_format, implicit_limit, inline_typenames, inline_typeids,             # <<<<<<<<<<<<<<
 *             expect_one
 *         )
 */
  __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_v_io_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_implicit_limit); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_inline_typenames); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_inline_typeids); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "edgedb/protocol/protocol.pyx":106
 *         key = (
 *             query, io_format, implicit_limit, inline_typenames, inline_typeids,
 *             expect_one             # <<<<<<<<<<<<<<
 *         )
 *         return self.queries.get(key, None)
 */
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_expect_one); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "edgedb/protocol/protocol.pyx":105
 *     ):
 *         key = (
 *             query, io_format, implicit_limit, inline_typenames, inline_typeids,             # <<<<<<<<<<<<<<
 *             expect_one
 *         )
 */
  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_query);
  __Pyx_GIVEREF(__pyx_v_query);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_query);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_t_5);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_v_key = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "edgedb/protocol/protocol.pyx":108
 *             expect_one
 *         )
 *         return self.queries.get(key, None)             # <<<<<<<<<<<<<<
 * 
 *     cdef set(
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_v_self->queries->__pyx_vtab)->get(__pyx_v_self->queries, __pyx_v_key, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/protocol.pyx":99
 *         self.queries = LRUMapping(maxsize=cache_size)
 * 
 *     def get(             # <<<<<<<<<<<<<<
 *         self, str query, IoFormat io_format,
 *         int implicit_limit, bint inline_typenames, bint inline_typeids,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("edgedb.protocol.protocol.QueryCodecsCache.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":110
 *         return self.queries.get(key, None)
 * 
 *     cdef set(             # <<<<<<<<<<<<<<
 *         self, str query, IoFormat io_format,
 *         int implicit_limit, bint inline_typenames, bint inline_typeids,
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_16QueryCodecsCache_set(struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_self, PyObject *__pyx_v_query, enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __pyx_v_io_format, int __pyx_v_implicit_limit, int __pyx_v_inline_typenames, int __pyx_v_inline_typeids, int __pyx_v_expect_one, int __pyx_v_has_na_cardinality, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_in_type, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_out_type, int __pyx_v_capabilities) {
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set", 0);

  /* "edgedb/protocol/protocol.pyx":117
 *     ):
 *         key = (
 *             query, io_format, implicit_limit, inline_typenames, inline_typeids,             # <<<<<<<<<<<<<<
 *             expect_one
 *         )
 */
  __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_v_io_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_implicit_limit); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_inline_typenames); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_inline_typeids); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "edgedb/protocol/protocol.pyx":118
 *         key = (
 *             query, io_format, implicit_limit, inline_typenames, inline_typeids,
 *             expect_one             # <<<<<<<<<<<<<<
 *         )
 *         assert in_type is not None
 */
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_expect_one); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "edgedb/protocol/protocol.pyx":117
 *     ):
 *         key = (
 *             query, io_format, implicit_limit, inline_typenames, inline_typeids,             # <<<<<<<<<<<<<<
 *             expect_one
 *         )
 */
  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_query);
  __Pyx_GIVEREF(__pyx_v_query);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_query);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_t_5);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_v_key = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "edgedb/protocol/protocol.pyx":120
 *             expect_one
 *         )
 *         assert in_type is not None             # <<<<<<<<<<<<<<
 *         assert out_type is not None
 *         self.queries[key] = (
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_7 = (((PyObject *)__pyx_v_in_type) != Py_None);
    if (unlikely(!(__pyx_t_7 != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(5, 120, __pyx_L1_error)
    }
  }
  #endif

  /* "edgedb/protocol/protocol.pyx":121
 *         )
 *         assert in_type is not None
 *         assert out_type is not None             # <<<<<<<<<<<<<<
 *         self.queries[key] = (
 *             has_na_cardinality, in_type, out_type, capabilities
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_7 = (((PyObject *)__pyx_v_out_type) != Py_None);
    if (unlikely(!(__pyx_t_7 != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(5, 121, __pyx_L1_error)
    }
  }
  #endif

  /* "edgedb/protocol/protocol.pyx":123
 *         assert out_type is not None
 *         self.queries[key] = (
 *             has_na_cardinality, in_type, out_type, capabilities             # <<<<<<<<<<<<<<
 *         )
 * 
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_v_has_na_cardinality); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_capabilities); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_v_in_type));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_in_type));
  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_in_type));
  __Pyx_INCREF(((PyObject *)__pyx_v_out_type));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_out_type));
  PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_v_out_type));
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_5);
  __pyx_t_6 = 0;
  __pyx_t_5 = 0;

  /* "edgedb/protocol/protocol.pyx":122
 *         assert in_type is not None
 *         assert out_type is not None
 *         self.queries[key] = (             # <<<<<<<<<<<<<<
 *             has_na_cardinality, in_type, out_type, capabilities
 *         )
 */
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->queries), __pyx_v_key, __pyx_t_4) < 0)) __PYX_ERR(5, 122, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "edgedb/protocol/protocol.pyx":110
 *         return self.queries.get(key, None)
 * 
 *     cdef set(             # <<<<<<<<<<<<<<
 *         self, str query, IoFormat io_format,
 *         int implicit_limit, bint inline_typenames, bint inline_typeids,
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("edgedb.protocol.protocol.QueryCodecsCache.set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_16QueryCodecsCache_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_16QueryCodecsCache_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_16QueryCodecsCache_4__reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_16QueryCodecsCache_4__reduce_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.queries,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->queries));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->queries));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->queries));
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.queries,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self.queries,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.queries is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.queries,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.queries is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_QueryCodecsCache, (type(self), 0x5da7eb4, None), state
 */
  /*else*/ {
    __pyx_t_3 = (((PyObject *)__pyx_v_self->queries) != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.queries is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_QueryCodecsCache, (type(self), 0x5da7eb4, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self.queries is not None
 *     if use_setstate:
 *         return __pyx_unpickle_QueryCodecsCache, (type(self), 0x5da7eb4, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_QueryCodecsCache, (type(self), 0x5da7eb4, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_QueryCodecsCache); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_98205364);
    __Pyx_GIVEREF(__pyx_int_98205364);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_98205364);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.queries is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_QueryCodecsCache, (type(self), 0x5da7eb4, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_QueryCodecsCache, (type(self), 0x5da7eb4, None), state
 *     else:
 *         return __pyx_unpickle_QueryCodecsCache, (type(self), 0x5da7eb4, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_QueryCodecsCache__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_QueryCodecsCache); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_98205364);
    __Pyx_GIVEREF(__pyx_int_98205364);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_98205364);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("edgedb.protocol.protocol.QueryCodecsCache.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_QueryCodecsCache, (type(self), 0x5da7eb4, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_QueryCodecsCache__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_16QueryCodecsCache_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_16QueryCodecsCache_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_16QueryCodecsCache_6__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_16QueryCodecsCache_6__setstate_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_QueryCodecsCache, (type(self), 0x5da7eb4, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_QueryCodecsCache__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_QueryCodecsCache__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_QueryCodecsCache, (type(self), 0x5da7eb4, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_QueryCodecsCache__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.QueryCodecsCache.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":129
 * cdef class SansIOProtocol:
 * 
 *     def __init__(self, con_params, tls_compat):             # <<<<<<<<<<<<<<
 *         self.buffer = ReadBuffer()
 * 
 */

/* Python wrapper */
static int __pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_con_params = 0;
  PyObject *__pyx_v_tls_compat = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_con_params,&__pyx_n_s_tls_compat,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_con_params)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tls_compat)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(5, 129, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(5, 129, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_con_params = values[0];
    __pyx_v_tls_compat = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 129, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol___init__(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self), __pyx_v_con_params, __pyx_v_tls_compat);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol___init__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_con_params, PyObject *__pyx_v_tls_compat) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "edgedb/protocol/protocol.pyx":130
 * 
 *     def __init__(self, con_params, tls_compat):
 *         self.buffer = ReadBuffer()             # <<<<<<<<<<<<<<
 * 
 *         self.con_params = con_params
 */
  __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6edgedb_7pgproto_7pgproto_ReadBuffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->buffer);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->buffer));
  __pyx_v_self->buffer = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":132
 *         self.buffer = ReadBuffer()
 * 
 *         self.con_params = con_params             # <<<<<<<<<<<<<<
 *         self.tls_compat = tls_compat
 * 
 */
  __Pyx_INCREF(__pyx_v_con_params);
  __Pyx_GIVEREF(__pyx_v_con_params);
  __Pyx_GOTREF(__pyx_v_self->con_params);
  __Pyx_DECREF(__pyx_v_self->con_params);
  __pyx_v_self->con_params = __pyx_v_con_params;

  /* "edgedb/protocol/protocol.pyx":133
 * 
 *         self.con_params = con_params
 *         self.tls_compat = tls_compat             # <<<<<<<<<<<<<<
 * 
 *         self.connected = False
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_tls_compat); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 133, __pyx_L1_error)
  __pyx_v_self->tls_compat = __pyx_t_2;

  /* "edgedb/protocol/protocol.pyx":135
 *         self.tls_compat = tls_compat
 * 
 *         self.connected = False             # <<<<<<<<<<<<<<
 *         self.cancelled = False
 *         self.backend_secret = None
 */
  __pyx_v_self->connected = 0;

  /* "edgedb/protocol/protocol.pyx":136
 * 
 *         self.connected = False
 *         self.cancelled = False             # <<<<<<<<<<<<<<
 *         self.backend_secret = None
 * 
 */
  __pyx_v_self->cancelled = 0;

  /* "edgedb/protocol/protocol.pyx":137
 *         self.connected = False
 *         self.cancelled = False
 *         self.backend_secret = None             # <<<<<<<<<<<<<<
 * 
 *         self.xact_status = TRANS_UNKNOWN
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->backend_secret);
  __Pyx_DECREF(__pyx_v_self->backend_secret);
  __pyx_v_self->backend_secret = Py_None;

  /* "edgedb/protocol/protocol.pyx":139
 *         self.backend_secret = None
 * 
 *         self.xact_status = TRANS_UNKNOWN             # <<<<<<<<<<<<<<
 * 
 *         self.internal_reg = CodecsRegistry()
 */
  __pyx_v_self->xact_status = __pyx_e_6edgedb_8protocol_8protocol_TRANS_UNKNOWN;

  /* "edgedb/protocol/protocol.pyx":141
 *         self.xact_status = TRANS_UNKNOWN
 * 
 *         self.internal_reg = CodecsRegistry()             # <<<<<<<<<<<<<<
 *         self.server_settings = {}
 *         self.reset_status()
 */
  __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6edgedb_8protocol_8protocol_CodecsRegistry)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->internal_reg);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->internal_reg));
  __pyx_v_self->internal_reg = ((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":142
 * 
 *         self.internal_reg = CodecsRegistry()
 *         self.server_settings = {}             # <<<<<<<<<<<<<<
 *         self.reset_status()
 *         self.protocol_version = (PROTO_VER_MAJOR, 0)
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->server_settings);
  __Pyx_DECREF(__pyx_v_self->server_settings);
  __pyx_v_self->server_settings = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":143
 *         self.internal_reg = CodecsRegistry()
 *         self.server_settings = {}
 *         self.reset_status()             # <<<<<<<<<<<<<<
 *         self.protocol_version = (PROTO_VER_MAJOR, 0)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self->__pyx_vtab)->reset_status(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":144
 *         self.server_settings = {}
 *         self.reset_status()
 *         self.protocol_version = (PROTO_VER_MAJOR, 0)             # <<<<<<<<<<<<<<
 * 
 *     cdef reset_status(self):
 */
  __Pyx_INCREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);
  __Pyx_GOTREF(__pyx_v_self->protocol_version);
  __Pyx_DECREF(__pyx_v_self->protocol_version);
  __pyx_v_self->protocol_version = __pyx_tuple__65;

  /* "edgedb/protocol/protocol.pyx":129
 * cdef class SansIOProtocol:
 * 
 *     def __init__(self, con_params, tls_compat):             # <<<<<<<<<<<<<<
 *         self.buffer = ReadBuffer()
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":146
 *         self.protocol_version = (PROTO_VER_MAJOR, 0)
 * 
 *     cdef reset_status(self):             # <<<<<<<<<<<<<<
 *         self.last_status = None
 *         self.last_details = None
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_reset_status(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset_status", 0);

  /* "edgedb/protocol/protocol.pyx":147
 * 
 *     cdef reset_status(self):
 *         self.last_status = None             # <<<<<<<<<<<<<<
 *         self.last_details = None
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->last_status);
  __Pyx_DECREF(__pyx_v_self->last_status);
  __pyx_v_self->last_status = ((PyObject*)Py_None);

  /* "edgedb/protocol/protocol.pyx":148
 *     cdef reset_status(self):
 *         self.last_status = None
 *         self.last_details = None             # <<<<<<<<<<<<<<
 * 
 *     def get_settings(self):
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->last_details);
  __Pyx_DECREF(__pyx_v_self->last_details);
  __pyx_v_self->last_details = ((PyObject*)Py_None);

  /* "edgedb/protocol/protocol.pyx":146
 *         self.protocol_version = (PROTO_VER_MAJOR, 0)
 * 
 *     cdef reset_status(self):             # <<<<<<<<<<<<<<
 *         self.last_status = None
 *         self.last_details = None
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":150
 *         self.last_details = None
 * 
 *     def get_settings(self):             # <<<<<<<<<<<<<<
 *         return types.MappingProxyType(self.server_settings)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_3get_settings(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_3get_settings(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_settings (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_2get_settings(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_2get_settings(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_settings", 0);

  /* "edgedb/protocol/protocol.pyx":151
 * 
 *     def get_settings(self):
 *         return types.MappingProxyType(self.server_settings)             # <<<<<<<<<<<<<<
 * 
 *     def is_in_transaction(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_MappingProxyType); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_self->server_settings) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->server_settings);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/protocol.pyx":150
 *         self.last_details = None
 * 
 *     def get_settings(self):             # <<<<<<<<<<<<<<
 *         return types.MappingProxyType(self.server_settings)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.get_settings", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":153
 *         return types.MappingProxyType(self.server_settings)
 * 
 *     def is_in_transaction(self):             # <<<<<<<<<<<<<<
 *         return self.xact_status in (TRANS_INTRANS, TRANS_INERROR)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_5is_in_transaction(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_5is_in_transaction(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_in_transaction (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_4is_in_transaction(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_4is_in_transaction(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_in_transaction", 0);

  /* "edgedb/protocol/protocol.pyx":154
 * 
 *     def is_in_transaction(self):
 *         return self.xact_status in (TRANS_INTRANS, TRANS_INERROR)             # <<<<<<<<<<<<<<
 * 
 *     def set_connection(self, con):
 */
  __Pyx_XDECREF(__pyx_r);
  switch (__pyx_v_self->xact_status) {
    case __pyx_e_6edgedb_8protocol_8protocol_TRANS_INTRANS:
    case __pyx_e_6edgedb_8protocol_8protocol_TRANS_INERROR:
    __pyx_t_1 = 1;
    break;
    default:
    __pyx_t_1 = 0;
    break;
  }
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 154, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/protocol.pyx":153
 *         return types.MappingProxyType(self.server_settings)
 * 
 *     def is_in_transaction(self):             # <<<<<<<<<<<<<<
 *         return self.xact_status in (TRANS_INTRANS, TRANS_INERROR)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.is_in_transaction", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":156
 *         return self.xact_status in (TRANS_INTRANS, TRANS_INERROR)
 * 
 *     def set_connection(self, con):             # <<<<<<<<<<<<<<
 *         self.con = weakref.ref(con)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_7set_connection(PyObject *__pyx_v_self, PyObject *__pyx_v_con); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_7set_connection(PyObject *__pyx_v_self, PyObject *__pyx_v_con) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_connection (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_6set_connection(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self), ((PyObject *)__pyx_v_con));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_6set_connection(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_con) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_connection", 0);

  /* "edgedb/protocol/protocol.pyx":157
 * 
 *     def set_connection(self, con):
 *         self.con = weakref.ref(con)             # <<<<<<<<<<<<<<
 * 
 *     cpdef abort(self):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_weakref); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ref); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_con) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_con);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->con);
  __Pyx_DECREF(__pyx_v_self->con);
  __pyx_v_self->con = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":156
 *         return self.xact_status in (TRANS_INTRANS, TRANS_INERROR)
 * 
 *     def set_connection(self, con):             # <<<<<<<<<<<<<<
 *         self.con = weakref.ref(con)
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.set_connection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":159
 *         self.con = weakref.ref(con)
 * 
 *     cpdef abort(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_9abort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_abort(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("abort", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_abort); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 159, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_9abort)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 159, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "edgedb/protocol/protocol.pyx":160
 * 
 *     cpdef abort(self):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef write(self, WriteBuffer buf):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
  __PYX_ERR(5, 160, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":159
 *         self.con = weakref.ref(con)
 * 
 *     cpdef abort(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.abort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_9abort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_9abort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("abort (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_8abort(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_8abort(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("abort", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_abort(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.abort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":162
 *         raise NotImplementedError
 * 
 *     cdef write(self, WriteBuffer buf):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_write(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, CYTHON_UNUSED struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("write", 0);

  /* "edgedb/protocol/protocol.pyx":163
 * 
 *     cdef write(self, WriteBuffer buf):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     async def wait_for_message(self):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
  __PYX_ERR(5, 163, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":162
 *         raise NotImplementedError
 * 
 *     cdef write(self, WriteBuffer buf):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_12generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "edgedb/protocol/protocol.pyx":165
 *         raise NotImplementedError
 * 
 *     async def wait_for_message(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_11wait_for_message(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_11wait_for_message(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wait_for_message (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_10wait_for_message(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_10wait_for_message(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("wait_for_message", 0);
  __pyx_cur_scope = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message *)__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message(__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 165, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_12generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_wait_for_message, __pyx_n_s_SansIOProtocol_wait_for_message, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(5, 165, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.wait_for_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_12generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message *__pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wait_for_message", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 165, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":166
 * 
 *     async def wait_for_message(self):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     async def try_recv_eagerly(self):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
  __PYX_ERR(5, 166, __pyx_L1_error)
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "edgedb/protocol/protocol.pyx":165
 *         raise NotImplementedError
 * 
 *     async def wait_for_message(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("wait_for_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_15generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "edgedb/protocol/protocol.pyx":168
 *         raise NotImplementedError
 * 
 *     async def try_recv_eagerly(self):             # <<<<<<<<<<<<<<
 *         # If there's data in the socket try reading it into the
 *         # buffer.  Needed for blocking-io connections.
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_14try_recv_eagerly(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_14try_recv_eagerly(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("try_recv_eagerly (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_13try_recv_eagerly(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_13try_recv_eagerly(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("try_recv_eagerly", 0);
  __pyx_cur_scope = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly *)__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly(__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 168, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_15generator1, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_try_recv_eagerly, __pyx_n_s_SansIOProtocol_try_recv_eagerly, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(5, 168, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.try_recv_eagerly", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_15generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly *__pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("try_recv_eagerly", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 168, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":171
 *         # If there's data in the socket try reading it into the
 *         # buffer.  Needed for blocking-io connections.
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     async def wait_for_connect(self):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
  __PYX_ERR(5, 171, __pyx_L1_error)
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "edgedb/protocol/protocol.pyx":168
 *         raise NotImplementedError
 * 
 *     async def try_recv_eagerly(self):             # <<<<<<<<<<<<<<
 *         # If there's data in the socket try reading it into the
 *         # buffer.  Needed for blocking-io connections.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("try_recv_eagerly", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_18generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "edgedb/protocol/protocol.pyx":173
 *         raise NotImplementedError
 * 
 *     async def wait_for_connect(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_17wait_for_connect(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_17wait_for_connect(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wait_for_connect (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_16wait_for_connect(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_16wait_for_connect(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("wait_for_connect", 0);
  __pyx_cur_scope = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect *)__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect(__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 173, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_18generator2, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_wait_for_connect, __pyx_n_s_SansIOProtocol_wait_for_connect, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(5, 173, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.wait_for_connect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_18generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect *__pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wait_for_connect", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 173, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":174
 * 
 *     async def wait_for_connect(self):
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *     cdef inline ignore_headers(self):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
  __PYX_ERR(5, 174, __pyx_L1_error)
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "edgedb/protocol/protocol.pyx":173
 *         raise NotImplementedError
 * 
 *     async def wait_for_connect(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("wait_for_connect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":176
 *         raise NotImplementedError
 * 
 *     cdef inline ignore_headers(self):             # <<<<<<<<<<<<<<
 *         cdef uint16_t num_fields = <uint16_t>self.buffer.read_int16()
 *         while num_fields:
 */

static CYTHON_INLINE PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_ignore_headers(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  uint16_t __pyx_v_num_fields;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int16_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ignore_headers", 0);

  /* "edgedb/protocol/protocol.pyx":177
 * 
 *     cdef inline ignore_headers(self):
 *         cdef uint16_t num_fields = <uint16_t>self.buffer.read_int16()             # <<<<<<<<<<<<<<
 *         while num_fields:
 *             self.buffer.read_int16()
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_int16(__pyx_v_self->buffer); if (unlikely(__pyx_t_1 == ((int16_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 177, __pyx_L1_error)
  __pyx_v_num_fields = ((uint16_t)__pyx_t_1);

  /* "edgedb/protocol/protocol.pyx":178
 *     cdef inline ignore_headers(self):
 *         cdef uint16_t num_fields = <uint16_t>self.buffer.read_int16()
 *         while num_fields:             # <<<<<<<<<<<<<<
 *             self.buffer.read_int16()
 *             self.buffer.read_len_prefixed_bytes()
 */
  while (1) {
    __pyx_t_2 = (__pyx_v_num_fields != 0);
    if (!__pyx_t_2) break;

    /* "edgedb/protocol/protocol.pyx":179
 *         cdef uint16_t num_fields = <uint16_t>self.buffer.read_int16()
 *         while num_fields:
 *             self.buffer.read_int16()             # <<<<<<<<<<<<<<
 *             self.buffer.read_len_prefixed_bytes()
 *             num_fields -= 1
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_int16(__pyx_v_self->buffer); if (unlikely(__pyx_t_1 == ((int16_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 179, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":180
 *         while num_fields:
 *             self.buffer.read_int16()
 *             self.buffer.read_len_prefixed_bytes()             # <<<<<<<<<<<<<<
 *             num_fields -= 1
 * 
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_len_prefixed_bytes(__pyx_v_self->buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 180, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "edgedb/protocol/protocol.pyx":181
 *             self.buffer.read_int16()
 *             self.buffer.read_len_prefixed_bytes()
 *             num_fields -= 1             # <<<<<<<<<<<<<<
 * 
 *     cdef write_headers(self, buf: WriteBuffer, headers: dict):
 */
    __pyx_v_num_fields = (__pyx_v_num_fields - 1);
  }

  /* "edgedb/protocol/protocol.pyx":176
 *         raise NotImplementedError
 * 
 *     cdef inline ignore_headers(self):             # <<<<<<<<<<<<<<
 *         cdef uint16_t num_fields = <uint16_t>self.buffer.read_int16()
 *         while num_fields:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.ignore_headers", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":183
 *             num_fields -= 1
 * 
 *     cdef write_headers(self, buf: WriteBuffer, headers: dict):             # <<<<<<<<<<<<<<
 *         buf.write_int16(len(headers))
 *         for k, v in headers.items():
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_write_headers(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_headers) {
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  uint16_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("write_headers", 0);

  /* "edgedb/protocol/protocol.pyx":184
 * 
 *     cdef write_headers(self, buf: WriteBuffer, headers: dict):
 *         buf.write_int16(len(headers))             # <<<<<<<<<<<<<<
 *         for k, v in headers.items():
 *             buf.write_int16(<int16_t><uint16_t>k)
 */
  if (unlikely(__pyx_v_headers == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(5, 184, __pyx_L1_error)
  }
  __pyx_t_1 = PyDict_Size(__pyx_v_headers); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(5, 184, __pyx_L1_error)
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int16(__pyx_v_buf, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 184, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":185
 *     cdef write_headers(self, buf: WriteBuffer, headers: dict):
 *         buf.write_int16(len(headers))
 *         for k, v in headers.items():             # <<<<<<<<<<<<<<
 *             buf.write_int16(<int16_t><uint16_t>k)
 *             if isinstance(v, bytes):
 */
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v_headers == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
    __PYX_ERR(5, 185, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_headers, 1, __pyx_n_s_items, (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_2);
  __pyx_t_2 = __pyx_t_5;
  __pyx_t_5 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_3, &__pyx_t_1, &__pyx_t_5, &__pyx_t_6, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(5, 185, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "edgedb/protocol/protocol.pyx":186
 *         buf.write_int16(len(headers))
 *         for k, v in headers.items():
 *             buf.write_int16(<int16_t><uint16_t>k)             # <<<<<<<<<<<<<<
 *             if isinstance(v, bytes):
 *                 buf.write_len_prefixed_bytes(v)
 */
    __pyx_t_8 = __Pyx_PyInt_As_uint16_t(__pyx_v_k); if (unlikely((__pyx_t_8 == ((uint16_t)-1)) && PyErr_Occurred())) __PYX_ERR(5, 186, __pyx_L1_error)
    __pyx_t_6 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int16(__pyx_v_buf, ((int16_t)((uint16_t)__pyx_t_8))); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 186, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "edgedb/protocol/protocol.pyx":187
 *         for k, v in headers.items():
 *             buf.write_int16(<int16_t><uint16_t>k)
 *             if isinstance(v, bytes):             # <<<<<<<<<<<<<<
 *                 buf.write_len_prefixed_bytes(v)
 *             else:
 */
    __pyx_t_9 = PyBytes_Check(__pyx_v_v); 
    __pyx_t_10 = (__pyx_t_9 != 0);
    if (__pyx_t_10) {

      /* "edgedb/protocol/protocol.pyx":188
 *             buf.write_int16(<int16_t><uint16_t>k)
 *             if isinstance(v, bytes):
 *                 buf.write_len_prefixed_bytes(v)             # <<<<<<<<<<<<<<
 *             else:
 *                 buf.write_len_prefixed_utf8(str(v))
 */
      if (!(likely(PyBytes_CheckExact(__pyx_v_v))||((__pyx_v_v) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_v)->tp_name), 0))) __PYX_ERR(5, 188, __pyx_L1_error)
      __pyx_t_6 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_len_prefixed_bytes(__pyx_v_buf, ((PyObject*)__pyx_v_v)); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 188, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "edgedb/protocol/protocol.pyx":187
 *         for k, v in headers.items():
 *             buf.write_int16(<int16_t><uint16_t>k)
 *             if isinstance(v, bytes):             # <<<<<<<<<<<<<<
 *                 buf.write_len_prefixed_bytes(v)
 *             else:
 */
      goto __pyx_L5;
    }

    /* "edgedb/protocol/protocol.pyx":190
 *                 buf.write_len_prefixed_bytes(v)
 *             else:
 *                 buf.write_len_prefixed_utf8(str(v))             # <<<<<<<<<<<<<<
 * 
 *     cdef write_execute_headers(
 */
    /*else*/ {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_v); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 190, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_write_len_prefixed_utf8(__pyx_v_buf, ((PyObject*)__pyx_t_6)); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 190, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __pyx_L5:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":183
 *             num_fields -= 1
 * 
 *     cdef write_headers(self, buf: WriteBuffer, headers: dict):             # <<<<<<<<<<<<<<
 *         buf.write_int16(len(headers))
 *         for k, v in headers.items():
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.write_headers", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":192
 *                 buf.write_len_prefixed_utf8(str(v))
 * 
 *     cdef write_execute_headers(             # <<<<<<<<<<<<<<
 *         self,
 *         WriteBuffer buf,
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_write_execute_headers(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, int __pyx_v_implicit_limit, int __pyx_v_inline_typenames, int __pyx_v_inline_typeids, uint64_t __pyx_v_allow_capabilities) {
  PyObject *__pyx_v_val = 0;
  PyObject *__pyx_v_headers = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  char *__pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("write_execute_headers", 0);

  /* "edgedb/protocol/protocol.pyx":202
 *         cdef bytes val
 *         if (
 *             implicit_limit or             # <<<<<<<<<<<<<<
 *             inline_typenames or inline_typeids or
 *             allow_capabilities != ALL_CAPABILITIES
 */
  __pyx_t_2 = (__pyx_v_implicit_limit != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }

  /* "edgedb/protocol/protocol.pyx":203
 *         if (
 *             implicit_limit or
 *             inline_typenames or inline_typeids or             # <<<<<<<<<<<<<<
 *             allow_capabilities != ALL_CAPABILITIES
 *         ):
 */
  __pyx_t_2 = (__pyx_v_inline_typenames != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_inline_typeids != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }

  /* "edgedb/protocol/protocol.pyx":204
 *             implicit_limit or
 *             inline_typenames or inline_typeids or
 *             allow_capabilities != ALL_CAPABILITIES             # <<<<<<<<<<<<<<
 *         ):
 *             headers = {}
 */
  __pyx_t_3 = __Pyx_PyInt_From_uint64_t(__pyx_v_allow_capabilities); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_ALL_CAPABILITIES); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 204, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(5, 204, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;

  /* "edgedb/protocol/protocol.pyx":201
 *     ):
 *         cdef bytes val
 *         if (             # <<<<<<<<<<<<<<
 *             implicit_limit or
 *             inline_typenames or inline_typeids or
 */
  if (__pyx_t_1) {

    /* "edgedb/protocol/protocol.pyx":206
 *             allow_capabilities != ALL_CAPABILITIES
 *         ):
 *             headers = {}             # <<<<<<<<<<<<<<
 *             if implicit_limit:
 *                 headers[QUERY_OPT_IMPLICIT_LIMIT] = implicit_limit
 */
    __pyx_t_5 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 206, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_v_headers = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "edgedb/protocol/protocol.pyx":207
 *         ):
 *             headers = {}
 *             if implicit_limit:             # <<<<<<<<<<<<<<
 *                 headers[QUERY_OPT_IMPLICIT_LIMIT] = implicit_limit
 *             if inline_typenames:
 */
    __pyx_t_1 = (__pyx_v_implicit_limit != 0);
    if (__pyx_t_1) {

      /* "edgedb/protocol/protocol.pyx":208
 *             headers = {}
 *             if implicit_limit:
 *                 headers[QUERY_OPT_IMPLICIT_LIMIT] = implicit_limit             # <<<<<<<<<<<<<<
 *             if inline_typenames:
 *                 headers[QUERY_OPT_INLINE_TYPENAMES] = True
 */
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_implicit_limit); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 208, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (unlikely(PyDict_SetItem(__pyx_v_headers, __pyx_int_65281, __pyx_t_5) < 0)) __PYX_ERR(5, 208, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "edgedb/protocol/protocol.pyx":207
 *         ):
 *             headers = {}
 *             if implicit_limit:             # <<<<<<<<<<<<<<
 *                 headers[QUERY_OPT_IMPLICIT_LIMIT] = implicit_limit
 *             if inline_typenames:
 */
    }

    /* "edgedb/protocol/protocol.pyx":209
 *             if implicit_limit:
 *                 headers[QUERY_OPT_IMPLICIT_LIMIT] = implicit_limit
 *             if inline_typenames:             # <<<<<<<<<<<<<<
 *                 headers[QUERY_OPT_INLINE_TYPENAMES] = True
 *             if inline_typeids:
 */
    __pyx_t_1 = (__pyx_v_inline_typenames != 0);
    if (__pyx_t_1) {

      /* "edgedb/protocol/protocol.pyx":210
 *                 headers[QUERY_OPT_IMPLICIT_LIMIT] = implicit_limit
 *             if inline_typenames:
 *                 headers[QUERY_OPT_INLINE_TYPENAMES] = True             # <<<<<<<<<<<<<<
 *             if inline_typeids:
 *                 headers[QUERY_OPT_INLINE_TYPEIDS] = True
 */
      if (unlikely(PyDict_SetItem(__pyx_v_headers, __pyx_int_65282, Py_True) < 0)) __PYX_ERR(5, 210, __pyx_L1_error)

      /* "edgedb/protocol/protocol.pyx":209
 *             if implicit_limit:
 *                 headers[QUERY_OPT_IMPLICIT_LIMIT] = implicit_limit
 *             if inline_typenames:             # <<<<<<<<<<<<<<
 *                 headers[QUERY_OPT_INLINE_TYPENAMES] = True
 *             if inline_typeids:
 */
    }

    /* "edgedb/protocol/protocol.pyx":211
 *             if inline_typenames:
 *                 headers[QUERY_OPT_INLINE_TYPENAMES] = True
 *             if inline_typeids:             # <<<<<<<<<<<<<<
 *                 headers[QUERY_OPT_INLINE_TYPEIDS] = True
 *             if allow_capabilities != ALL_CAPABILITIES:
 */
    __pyx_t_1 = (__pyx_v_inline_typeids != 0);
    if (__pyx_t_1) {

      /* "edgedb/protocol/protocol.pyx":212
 *                 headers[QUERY_OPT_INLINE_TYPENAMES] = True
 *             if inline_typeids:
 *                 headers[QUERY_OPT_INLINE_TYPEIDS] = True             # <<<<<<<<<<<<<<
 *             if allow_capabilities != ALL_CAPABILITIES:
 *                 val = cpython.PyBytes_FromStringAndSize(NULL, sizeof(uint64_t))
 */
      if (unlikely(PyDict_SetItem(__pyx_v_headers, __pyx_int_65283, Py_True) < 0)) __PYX_ERR(5, 212, __pyx_L1_error)

      /* "edgedb/protocol/protocol.pyx":211
 *             if inline_typenames:
 *                 headers[QUERY_OPT_INLINE_TYPENAMES] = True
 *             if inline_typeids:             # <<<<<<<<<<<<<<
 *                 headers[QUERY_OPT_INLINE_TYPEIDS] = True
 *             if allow_capabilities != ALL_CAPABILITIES:
 */
    }

    /* "edgedb/protocol/protocol.pyx":213
 *             if inline_typeids:
 *                 headers[QUERY_OPT_INLINE_TYPEIDS] = True
 *             if allow_capabilities != ALL_CAPABILITIES:             # <<<<<<<<<<<<<<
 *                 val = cpython.PyBytes_FromStringAndSize(NULL, sizeof(uint64_t))
 *                 hton.pack_int64(
 */
    __pyx_t_5 = __Pyx_PyInt_From_uint64_t(__pyx_v_allow_capabilities); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 213, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_ALL_CAPABILITIES); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 213, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 213, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(5, 213, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_1) {

      /* "edgedb/protocol/protocol.pyx":214
 *                 headers[QUERY_OPT_INLINE_TYPEIDS] = True
 *             if allow_capabilities != ALL_CAPABILITIES:
 *                 val = cpython.PyBytes_FromStringAndSize(NULL, sizeof(uint64_t))             # <<<<<<<<<<<<<<
 *                 hton.pack_int64(
 *                     cpython.PyBytes_AsString(val),
 */
      __pyx_t_3 = PyBytes_FromStringAndSize(NULL, (sizeof(uint64_t))); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 214, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_val = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;

      /* "edgedb/protocol/protocol.pyx":216
 *                 val = cpython.PyBytes_FromStringAndSize(NULL, sizeof(uint64_t))
 *                 hton.pack_int64(
 *                     cpython.PyBytes_AsString(val),             # <<<<<<<<<<<<<<
 *                     <int64_t><uint64_t>allow_capabilities
 *                 )
 */
      __pyx_t_6 = PyBytes_AsString(__pyx_v_val); if (unlikely(__pyx_t_6 == ((char *)NULL))) __PYX_ERR(5, 216, __pyx_L1_error)

      /* "edgedb/protocol/protocol.pyx":215
 *             if allow_capabilities != ALL_CAPABILITIES:
 *                 val = cpython.PyBytes_FromStringAndSize(NULL, sizeof(uint64_t))
 *                 hton.pack_int64(             # <<<<<<<<<<<<<<
 *                     cpython.PyBytes_AsString(val),
 *                     <int64_t><uint64_t>allow_capabilities
 */
      pack_int64(__pyx_t_6, ((int64_t)((uint64_t)__pyx_v_allow_capabilities)));

      /* "edgedb/protocol/protocol.pyx":219
 *                     <int64_t><uint64_t>allow_capabilities
 *                 )
 *                 headers[QUERY_OPT_ALLOW_CAPABILITIES] = val             # <<<<<<<<<<<<<<
 *             self.write_headers(buf, headers)
 *         else:
 */
      if (unlikely(PyDict_SetItem(__pyx_v_headers, __pyx_int_65284, __pyx_v_val) < 0)) __PYX_ERR(5, 219, __pyx_L1_error)

      /* "edgedb/protocol/protocol.pyx":213
 *             if inline_typeids:
 *                 headers[QUERY_OPT_INLINE_TYPEIDS] = True
 *             if allow_capabilities != ALL_CAPABILITIES:             # <<<<<<<<<<<<<<
 *                 val = cpython.PyBytes_FromStringAndSize(NULL, sizeof(uint64_t))
 *                 hton.pack_int64(
 */
    }

    /* "edgedb/protocol/protocol.pyx":220
 *                 )
 *                 headers[QUERY_OPT_ALLOW_CAPABILITIES] = val
 *             self.write_headers(buf, headers)             # <<<<<<<<<<<<<<
 *         else:
 *             buf.write_int16(0)  # no headers
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self->__pyx_vtab)->write_headers(__pyx_v_self, __pyx_v_buf, __pyx_v_headers); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 220, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "edgedb/protocol/protocol.pyx":201
 *     ):
 *         cdef bytes val
 *         if (             # <<<<<<<<<<<<<<
 *             implicit_limit or
 *             inline_typenames or inline_typeids or
 */
    goto __pyx_L3;
  }

  /* "edgedb/protocol/protocol.pyx":222
 *             self.write_headers(buf, headers)
 *         else:
 *             buf.write_int16(0)  # no headers             # <<<<<<<<<<<<<<
 * 
 *     async def _parse(
 */
  /*else*/ {
    __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_int16(__pyx_v_buf, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "edgedb/protocol/protocol.pyx":192
 *                 buf.write_len_prefixed_utf8(str(v))
 * 
 *     cdef write_execute_headers(             # <<<<<<<<<<<<<<
 *         self,
 *         WriteBuffer buf,
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.write_execute_headers", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XDECREF(__pyx_v_headers);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_21generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "edgedb/protocol/protocol.pyx":224
 *             buf.write_int16(0)  # no headers
 * 
 *     async def _parse(             # <<<<<<<<<<<<<<
 *         self,
 *         query: str,
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_20_parse(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_20_parse(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_query = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_reg = 0;
  enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __pyx_v_io_format;
  int __pyx_v_expect_one;
  PyObject *__pyx_v_required_one = 0;
  PyObject *__pyx_v_implicit_limit = 0;
  PyObject *__pyx_v_inline_typenames = 0;
  PyObject *__pyx_v_inline_typeids = 0;
  PyObject *__pyx_v_allow_capabilities = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_parse (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_query,&__pyx_n_s_reg,&__pyx_n_s_io_format,&__pyx_n_s_expect_one,&__pyx_n_s_required_one,&__pyx_n_s_implicit_limit,&__pyx_n_s_inline_typenames,&__pyx_n_s_inline_typeids,&__pyx_n_s_allow_capabilities,0};
    PyObject* values[9] = {0,0,0,0,0,0,0,0,0};

    /* "edgedb/protocol/protocol.pyx":231
 *         io_format: IoFormat=IoFormat.BINARY,
 *         expect_one: bint=False,
 *         required_one: bool=False,             # <<<<<<<<<<<<<<
 *         implicit_limit: int=0,
 *         inline_typenames: bool=False,
 */
    values[4] = ((PyObject *)Py_False);
    values[5] = ((PyObject *)__pyx_int_0);

    /* "edgedb/protocol/protocol.pyx":233
 *         required_one: bool=False,
 *         implicit_limit: int=0,
 *         inline_typenames: bool=False,             # <<<<<<<<<<<<<<
 *         inline_typeids: bool=False,
 *         allow_capabilities: typing.Optional[int] = None,
 */
    values[6] = ((PyObject *)Py_False);

    /* "edgedb/protocol/protocol.pyx":234
 *         implicit_limit: int=0,
 *         inline_typenames: bool=False,
 *         inline_typeids: bool=False,             # <<<<<<<<<<<<<<
 *         allow_capabilities: typing.Optional[int] = None,
 *     ):
 */
    values[7] = ((PyObject *)Py_False);

    /* "edgedb/protocol/protocol.pyx":235
 *         inline_typenames: bool=False,
 *         inline_typeids: bool=False,
 *         allow_capabilities: typing.Optional[int] = None,             # <<<<<<<<<<<<<<
 *     ):
 *         cdef:
 */
    values[8] = ((PyObject *)Py_None);
    if (likely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_query)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reg)) != 0)) kw_args--;
        else {
          __Pyx_RaiseKeywordRequired("_parse", __pyx_n_s_reg); __PYX_ERR(5, 224, __pyx_L3_error)
        }
      }
      if (kw_args > 0 && likely(kw_args <= 7)) {
        Py_ssize_t index;
        for (index = 2; index < 9 && kw_args > 0; index++) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_parse") < 0)) __PYX_ERR(5, 224, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      __Pyx_RaiseKeywordRequired("_parse", __pyx_n_s_reg); __PYX_ERR(5, 224, __pyx_L3_error)
    }
    __pyx_v_query = ((PyObject*)values[0]);
    __pyx_v_reg = ((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)values[1]);
    if (values[2]) {
      __pyx_v_io_format = ((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)__Pyx_PyInt_As_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(values[2])); if (unlikely(PyErr_Occurred())) __PYX_ERR(5, 229, __pyx_L3_error)
    } else {
      __pyx_v_io_format = __pyx_k__66;
    }
    if (values[3]) {
      __pyx_v_expect_one = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_expect_one == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 230, __pyx_L3_error)
    } else {

      /* "edgedb/protocol/protocol.pyx":230
 *         reg: CodecsRegistry,
 *         io_format: IoFormat=IoFormat.BINARY,
 *         expect_one: bint=False,             # <<<<<<<<<<<<<<
 *         required_one: bool=False,
 *         implicit_limit: int=0,
 */
      __pyx_v_expect_one = ((int)0);
    }
    __pyx_v_required_one = values[4];
    __pyx_v_implicit_limit = values[5];
    __pyx_v_inline_typenames = values[6];
    __pyx_v_inline_typeids = values[7];
    __pyx_v_allow_capabilities = values[8];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_parse", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 224, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol._parse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_query), (&PyUnicode_Type), 1, "query", 1))) __PYX_ERR(5, 226, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reg), __pyx_ptype_6edgedb_8protocol_8protocol_CodecsRegistry, 1, "reg", 0))) __PYX_ERR(5, 228, __pyx_L1_error)
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_19_parse(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self), __pyx_v_query, __pyx_v_reg, __pyx_v_io_format, __pyx_v_expect_one, __pyx_v_required_one, __pyx_v_implicit_limit, __pyx_v_inline_typenames, __pyx_v_inline_typeids, __pyx_v_allow_capabilities);

  /* "edgedb/protocol/protocol.pyx":224
 *             buf.write_int16(0)  # no headers
 * 
 *     async def _parse(             # <<<<<<<<<<<<<<
 *         self,
 *         query: str,
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_19_parse(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_query, struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_reg, enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __pyx_v_io_format, int __pyx_v_expect_one, PyObject *__pyx_v_required_one, PyObject *__pyx_v_implicit_limit, PyObject *__pyx_v_inline_typenames, PyObject *__pyx_v_inline_typeids, PyObject *__pyx_v_allow_capabilities) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_parse", 0);
  __pyx_cur_scope = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse *)__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse(__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 224, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_query = __pyx_v_query;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_query);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_query);
  __pyx_cur_scope->__pyx_v_reg = __pyx_v_reg;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_reg);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_reg);
  __pyx_cur_scope->__pyx_v_io_format = __pyx_v_io_format;
  __pyx_cur_scope->__pyx_v_expect_one = __pyx_v_expect_one;
  __pyx_cur_scope->__pyx_v_required_one = __pyx_v_required_one;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_required_one);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_required_one);
  __pyx_cur_scope->__pyx_v_implicit_limit = __pyx_v_implicit_limit;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_implicit_limit);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_implicit_limit);
  __pyx_cur_scope->__pyx_v_inline_typenames = __pyx_v_inline_typenames;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_inline_typenames);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_inline_typenames);
  __pyx_cur_scope->__pyx_v_inline_typeids = __pyx_v_inline_typeids;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_inline_typeids);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_inline_typeids);
  __pyx_cur_scope->__pyx_v_allow_capabilities = __pyx_v_allow_capabilities;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_allow_capabilities);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_allow_capabilities);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_21generator3, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_parse, __pyx_n_s_SansIOProtocol__parse, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(5, 224, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol._parse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_21generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse *__pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  uint64_t __pyx_t_5;
  int __pyx_t_6;
  uint64_t __pyx_t_7;
  char __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int32_t __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  char const *__pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *(*__pyx_t_23)(PyObject *);
  char const *__pyx_t_24;
  Py_ssize_t __pyx_t_25;
  Py_UCS4 __pyx_t_26;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_parse", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L8_resume_from_await;
    case 2: goto __pyx_L27_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 224, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":240
 *             WriteBuffer buf
 *             char mtype
 *             BaseCodec in_dc = None             # <<<<<<<<<<<<<<
 *             BaseCodec out_dc = None
 *             int16_t type_size
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_cur_scope->__pyx_v_in_dc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)Py_None);

  /* "edgedb/protocol/protocol.pyx":241
 *             char mtype
 *             BaseCodec in_dc = None
 *             BaseCodec out_dc = None             # <<<<<<<<<<<<<<
 *             int16_t type_size
 *             bytes in_type_id
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_cur_scope->__pyx_v_out_dc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)Py_None);

  /* "edgedb/protocol/protocol.pyx":247
 *             bytes cardinality
 * 
 *         if not self.connected:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('not connected')
 * 
 */
  __pyx_t_1 = ((!(__pyx_cur_scope->__pyx_v_self->connected != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "edgedb/protocol/protocol.pyx":248
 * 
 *         if not self.connected:
 *             raise RuntimeError('not connected')             # <<<<<<<<<<<<<<
 * 
 *         buf = WriteBuffer.new_message(PREPARE_MSG)
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__67, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 248, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(5, 248, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":247
 *             bytes cardinality
 * 
 *         if not self.connected:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('not connected')
 * 
 */
  }

  /* "edgedb/protocol/protocol.pyx":250
 *             raise RuntimeError('not connected')
 * 
 *         buf = WriteBuffer.new_message(PREPARE_MSG)             # <<<<<<<<<<<<<<
 *         self.write_execute_headers(
 *             buf, implicit_limit, inline_typenames, inline_typeids,
 */
  __pyx_t_2 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('P')); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_buf = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":252
 *         buf = WriteBuffer.new_message(PREPARE_MSG)
 *         self.write_execute_headers(
 *             buf, implicit_limit, inline_typenames, inline_typeids,             # <<<<<<<<<<<<<<
 *             ALL_CAPABILITIES if allow_capabilities is None
 *             else allow_capabilities)
 */
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_cur_scope->__pyx_v_implicit_limit); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 252, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_inline_typenames); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 252, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_inline_typeids); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 252, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":253
 *         self.write_execute_headers(
 *             buf, implicit_limit, inline_typenames, inline_typeids,
 *             ALL_CAPABILITIES if allow_capabilities is None             # <<<<<<<<<<<<<<
 *             else allow_capabilities)
 *         buf.write_byte(io_format)
 */
  __pyx_t_6 = (__pyx_cur_scope->__pyx_v_allow_capabilities == Py_None);
  if ((__pyx_t_6 != 0)) {
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ALL_CAPABILITIES); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 253, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_PyInt_As_uint64_t(__pyx_t_2); if (unlikely((__pyx_t_7 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(5, 253, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = __pyx_t_7;
  } else {

    /* "edgedb/protocol/protocol.pyx":254
 *             buf, implicit_limit, inline_typenames, inline_typeids,
 *             ALL_CAPABILITIES if allow_capabilities is None
 *             else allow_capabilities)             # <<<<<<<<<<<<<<
 *         buf.write_byte(io_format)
 *         buf.write_byte(CARDINALITY_ONE if expect_one else CARDINALITY_MANY)
 */
    __pyx_t_7 = __Pyx_PyInt_As_uint64_t(__pyx_cur_scope->__pyx_v_allow_capabilities); if (unlikely((__pyx_t_7 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(5, 254, __pyx_L1_error)
    __pyx_t_5 = __pyx_t_7;
  }

  /* "edgedb/protocol/protocol.pyx":251
 * 
 *         buf = WriteBuffer.new_message(PREPARE_MSG)
 *         self.write_execute_headers(             # <<<<<<<<<<<<<<
 *             buf, implicit_limit, inline_typenames, inline_typeids,
 *             ALL_CAPABILITIES if allow_capabilities is None
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write_execute_headers(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_buf, __pyx_t_3, __pyx_t_1, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":255
 *             ALL_CAPABILITIES if allow_capabilities is None
 *             else allow_capabilities)
 *         buf.write_byte(io_format)             # <<<<<<<<<<<<<<
 *         buf.write_byte(CARDINALITY_ONE if expect_one else CARDINALITY_MANY)
 *         buf.write_len_prefixed_bytes(b'')  # stmt_name
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_byte(__pyx_cur_scope->__pyx_v_buf, __pyx_cur_scope->__pyx_v_io_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":256
 *             else allow_capabilities)
 *         buf.write_byte(io_format)
 *         buf.write_byte(CARDINALITY_ONE if expect_one else CARDINALITY_MANY)             # <<<<<<<<<<<<<<
 *         buf.write_len_prefixed_bytes(b'')  # stmt_name
 *         buf.write_len_prefixed_utf8(query)
 */
  if ((__pyx_cur_scope->__pyx_v_expect_one != 0)) {
    __pyx_t_8 = 'o';
  } else {
    __pyx_t_8 = 'm';
  }
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_byte(__pyx_cur_scope->__pyx_v_buf, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":257
 *         buf.write_byte(io_format)
 *         buf.write_byte(CARDINALITY_ONE if expect_one else CARDINALITY_MANY)
 *         buf.write_len_prefixed_bytes(b'')  # stmt_name             # <<<<<<<<<<<<<<
 *         buf.write_len_prefixed_utf8(query)
 *         buf.end_message()
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_len_prefixed_bytes(__pyx_cur_scope->__pyx_v_buf, __pyx_kp_b__61); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":258
 *         buf.write_byte(CARDINALITY_ONE if expect_one else CARDINALITY_MANY)
 *         buf.write_len_prefixed_bytes(b'')  # stmt_name
 *         buf.write_len_prefixed_utf8(query)             # <<<<<<<<<<<<<<
 *         buf.end_message()
 *         buf.write_bytes(SYNC_MESSAGE)
 */
  __pyx_t_2 = __pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_write_len_prefixed_utf8(__pyx_cur_scope->__pyx_v_buf, __pyx_cur_scope->__pyx_v_query); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":259
 *         buf.write_len_prefixed_bytes(b'')  # stmt_name
 *         buf.write_len_prefixed_utf8(query)
 *         buf.end_message()             # <<<<<<<<<<<<<<
 *         buf.write_bytes(SYNC_MESSAGE)
 *         self.write(buf)
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->end_message(__pyx_cur_scope->__pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":260
 *         buf.write_len_prefixed_utf8(query)
 *         buf.end_message()
 *         buf.write_bytes(SYNC_MESSAGE)             # <<<<<<<<<<<<<<
 *         self.write(buf)
 * 
 */
  __pyx_t_2 = __pyx_v_6edgedb_8protocol_8protocol_SYNC_MESSAGE;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_bytes(__pyx_cur_scope->__pyx_v_buf, ((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "edgedb/protocol/protocol.pyx":261
 *         buf.end_message()
 *         buf.write_bytes(SYNC_MESSAGE)
 *         self.write(buf)             # <<<<<<<<<<<<<<
 * 
 *         attrs = None
 */
  __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_buf); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "edgedb/protocol/protocol.pyx":263
 *         self.write(buf)
 * 
 *         attrs = None             # <<<<<<<<<<<<<<
 *         exc = None
 *         while True:
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_cur_scope->__pyx_v_attrs = ((PyObject*)Py_None);

  /* "edgedb/protocol/protocol.pyx":264
 * 
 *         attrs = None
 *         exc = None             # <<<<<<<<<<<<<<
 *         while True:
 *             if not self.buffer.take_message():
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_cur_scope->__pyx_v_exc = Py_None;

  /* "edgedb/protocol/protocol.pyx":265
 *         attrs = None
 *         exc = None
 *         while True:             # <<<<<<<<<<<<<<
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 */
  while (1) {

    /* "edgedb/protocol/protocol.pyx":266
 *         exc = None
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    __pyx_t_10 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_10 == ((int32_t)-1))) __PYX_ERR(5, 266, __pyx_L1_error)
    __pyx_t_4 = ((!(__pyx_t_10 != 0)) != 0);
    if (__pyx_t_4) {

      /* "edgedb/protocol/protocol.pyx":267
 *         while True:
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()             # <<<<<<<<<<<<<<
 *             mtype = self.buffer.get_message_type()
 * 
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_wait_for_message); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 267, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_11 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_9 = (__pyx_t_11) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_11) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 267, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_9);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XGOTREF(__pyx_r);
      if (likely(__pyx_r)) {
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L8_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 267, __pyx_L1_error)
      } else {
        PyObject* exc_type = __Pyx_PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
          else __PYX_ERR(5, 267, __pyx_L1_error)
        }
      }

      /* "edgedb/protocol/protocol.pyx":266
 *         exc = None
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    }

    /* "edgedb/protocol/protocol.pyx":268
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()             # <<<<<<<<<<<<<<
 * 
 *             try:
 */
    __pyx_cur_scope->__pyx_v_mtype = __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_cur_scope->__pyx_v_self->buffer);

    /* "edgedb/protocol/protocol.pyx":270
 *             mtype = self.buffer.get_message_type()
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 if mtype == PREPARE_COMPLETE_MSG:
 *                     attrs = self.parse_headers()
 */
    /*try:*/ {

      /* "edgedb/protocol/protocol.pyx":271
 * 
 *             try:
 *                 if mtype == PREPARE_COMPLETE_MSG:             # <<<<<<<<<<<<<<
 *                     attrs = self.parse_headers()
 *                     cardinality = self.buffer.read_byte()
 */
      switch (__pyx_cur_scope->__pyx_v_mtype) {
        case '1':

        /* "edgedb/protocol/protocol.pyx":272
 *             try:
 *                 if mtype == PREPARE_COMPLETE_MSG:
 *                     attrs = self.parse_headers()             # <<<<<<<<<<<<<<
 *                     cardinality = self.buffer.read_byte()
 *                     in_type_id = self.buffer.read_bytes(16)
 */
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_headers(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 272, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_attrs);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_attrs, ((PyObject*)__pyx_t_9));
        __Pyx_GIVEREF(__pyx_t_9);
        __pyx_t_9 = 0;

        /* "edgedb/protocol/protocol.pyx":273
 *                 if mtype == PREPARE_COMPLETE_MSG:
 *                     attrs = self.parse_headers()
 *                     cardinality = self.buffer.read_byte()             # <<<<<<<<<<<<<<
 *                     in_type_id = self.buffer.read_bytes(16)
 *                     out_type_id = self.buffer.read_bytes(16)
 */
        __pyx_t_8 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->read_byte(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_8 == ((char)-1) && PyErr_Occurred())) __PYX_ERR(5, 273, __pyx_L12_error)
        __pyx_t_9 = PyBytes_FromStringAndSize(&__pyx_t_8, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 273, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_cardinality);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_cardinality, ((PyObject*)__pyx_t_9));
        __Pyx_GIVEREF(__pyx_t_9);
        __pyx_t_9 = 0;

        /* "edgedb/protocol/protocol.pyx":274
 *                     attrs = self.parse_headers()
 *                     cardinality = self.buffer.read_byte()
 *                     in_type_id = self.buffer.read_bytes(16)             # <<<<<<<<<<<<<<
 *                     out_type_id = self.buffer.read_bytes(16)
 * 
 */
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->read_bytes(__pyx_cur_scope->__pyx_v_self->buffer, 16); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 274, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_in_type_id);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_in_type_id, ((PyObject*)__pyx_t_9));
        __Pyx_GIVEREF(__pyx_t_9);
        __pyx_t_9 = 0;

        /* "edgedb/protocol/protocol.pyx":275
 *                     cardinality = self.buffer.read_byte()
 *                     in_type_id = self.buffer.read_bytes(16)
 *                     out_type_id = self.buffer.read_bytes(16)             # <<<<<<<<<<<<<<
 * 
 *                 elif mtype == ERROR_RESPONSE_MSG:
 */
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->read_bytes(__pyx_cur_scope->__pyx_v_self->buffer, 16); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 275, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_out_type_id);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_out_type_id, ((PyObject*)__pyx_t_9));
        __Pyx_GIVEREF(__pyx_t_9);
        __pyx_t_9 = 0;

        /* "edgedb/protocol/protocol.pyx":271
 * 
 *             try:
 *                 if mtype == PREPARE_COMPLETE_MSG:             # <<<<<<<<<<<<<<
 *                     attrs = self.parse_headers()
 *                     cardinality = self.buffer.read_byte()
 */
        break;
        case 'E':

        /* "edgedb/protocol/protocol.pyx":278
 * 
 *                 elif mtype == ERROR_RESPONSE_MSG:
 *                     exc = self.parse_error_message()             # <<<<<<<<<<<<<<
 *                     exc = self._amend_parse_error(
 *                         exc, io_format, expect_one, required_one)
 */
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_error_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 278, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_exc);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_exc, __pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_9);
        __pyx_t_9 = 0;

        /* "edgedb/protocol/protocol.pyx":280
 *                     exc = self.parse_error_message()
 *                     exc = self._amend_parse_error(
 *                         exc, io_format, expect_one, required_one)             # <<<<<<<<<<<<<<
 * 
 *                 elif mtype == READY_FOR_COMMAND_MSG:
 */
        __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_required_one); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 280, __pyx_L12_error)

        /* "edgedb/protocol/protocol.pyx":279
 *                 elif mtype == ERROR_RESPONSE_MSG:
 *                     exc = self.parse_error_message()
 *                     exc = self._amend_parse_error(             # <<<<<<<<<<<<<<
 *                         exc, io_format, expect_one, required_one)
 * 
 */
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->_amend_parse_error(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_exc, __pyx_cur_scope->__pyx_v_io_format, __pyx_cur_scope->__pyx_v_expect_one, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 279, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_exc);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_exc, __pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_9);
        __pyx_t_9 = 0;

        /* "edgedb/protocol/protocol.pyx":277
 *                     out_type_id = self.buffer.read_bytes(16)
 * 
 *                 elif mtype == ERROR_RESPONSE_MSG:             # <<<<<<<<<<<<<<
 *                     exc = self.parse_error_message()
 *                     exc = self._amend_parse_error(
 */
        break;
        case 'Z':

        /* "edgedb/protocol/protocol.pyx":283
 * 
 *                 elif mtype == READY_FOR_COMMAND_MSG:
 *                     self.parse_sync_message()             # <<<<<<<<<<<<<<
 *                     break
 * 
 */
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_sync_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 283, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

        /* "edgedb/protocol/protocol.pyx":284
 *                 elif mtype == READY_FOR_COMMAND_MSG:
 *                     self.parse_sync_message()
 *                     break             # <<<<<<<<<<<<<<
 * 
 *                 else:
 */
        goto __pyx_L10_break;

        /* "edgedb/protocol/protocol.pyx":282
 *                         exc, io_format, expect_one, required_one)
 * 
 *                 elif mtype == READY_FOR_COMMAND_MSG:             # <<<<<<<<<<<<<<
 *                     self.parse_sync_message()
 *                     break
 */
        break;
        default:

        /* "edgedb/protocol/protocol.pyx":287
 * 
 *                 else:
 *                     self.fallthrough()             # <<<<<<<<<<<<<<
 *             finally:
 *                 self.buffer.finish_message()
 */
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->fallthrough(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 287, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        break;
      }
    }

    /* "edgedb/protocol/protocol.pyx":289
 *                     self.fallthrough()
 *             finally:
 *                 self.buffer.finish_message()             # <<<<<<<<<<<<<<
 * 
 *         if exc is not None:
 */
    /*finally:*/ {
      /*normal exit:*/{
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 289, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L13;
      }
      __pyx_L12_error:;
      /*exception exit:*/{
        __Pyx_PyThreadState_assign
        __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
        if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
        __Pyx_XGOTREF(__pyx_t_14);
        __Pyx_XGOTREF(__pyx_t_15);
        __Pyx_XGOTREF(__pyx_t_16);
        __Pyx_XGOTREF(__pyx_t_17);
        __Pyx_XGOTREF(__pyx_t_18);
        __Pyx_XGOTREF(__pyx_t_19);
        __pyx_t_3 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_13 = __pyx_filename;
        {
          __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 289, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
        }
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16);
        __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
        __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_13;
        goto __pyx_L1_error;
        __pyx_L17_error:;
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
        }
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
        goto __pyx_L1_error;
      }
      __pyx_L10_break: {
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 289, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L6_break;
      }
      __pyx_L13:;
    }
  }
  __pyx_L6_break:;

  /* "edgedb/protocol/protocol.pyx":291
 *                 self.buffer.finish_message()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             raise exc
 * 
 */
  __pyx_t_4 = (__pyx_cur_scope->__pyx_v_exc != Py_None);
  __pyx_t_1 = (__pyx_t_4 != 0);
  if (unlikely(__pyx_t_1)) {

    /* "edgedb/protocol/protocol.pyx":292
 * 
 *         if exc is not None:
 *             raise exc             # <<<<<<<<<<<<<<
 * 
 *         if reg.has_codec(in_type_id):
 */
    __Pyx_Raise(__pyx_cur_scope->__pyx_v_exc, 0, 0, 0);
    __PYX_ERR(5, 292, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":291
 *                 self.buffer.finish_message()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             raise exc
 * 
 */
  }

  /* "edgedb/protocol/protocol.pyx":294
 *             raise exc
 * 
 *         if reg.has_codec(in_type_id):             # <<<<<<<<<<<<<<
 *             in_dc = reg.get_codec(in_type_id)
 *         if reg.has_codec(out_type_id):
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_in_type_id)) { __Pyx_RaiseUnboundLocalError("in_type_id"); __PYX_ERR(5, 294, __pyx_L1_error) }
  __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_cur_scope->__pyx_v_reg->__pyx_vtab)->has_codec(__pyx_cur_scope->__pyx_v_reg, __pyx_cur_scope->__pyx_v_in_type_id); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(5, 294, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__pyx_t_1) {

    /* "edgedb/protocol/protocol.pyx":295
 * 
 *         if reg.has_codec(in_type_id):
 *             in_dc = reg.get_codec(in_type_id)             # <<<<<<<<<<<<<<
 *         if reg.has_codec(out_type_id):
 *             out_dc = reg.get_codec(out_type_id)
 */
    if (unlikely(!__pyx_cur_scope->__pyx_v_in_type_id)) { __Pyx_RaiseUnboundLocalError("in_type_id"); __PYX_ERR(5, 295, __pyx_L1_error) }
    __pyx_t_9 = ((PyObject *)((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_cur_scope->__pyx_v_reg->__pyx_vtab)->get_codec(__pyx_cur_scope->__pyx_v_reg, __pyx_cur_scope->__pyx_v_in_type_id)); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 295, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_in_dc));
    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_in_dc, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_9));
    __Pyx_GIVEREF(__pyx_t_9);
    __pyx_t_9 = 0;

    /* "edgedb/protocol/protocol.pyx":294
 *             raise exc
 * 
 *         if reg.has_codec(in_type_id):             # <<<<<<<<<<<<<<
 *             in_dc = reg.get_codec(in_type_id)
 *         if reg.has_codec(out_type_id):
 */
  }

  /* "edgedb/protocol/protocol.pyx":296
 *         if reg.has_codec(in_type_id):
 *             in_dc = reg.get_codec(in_type_id)
 *         if reg.has_codec(out_type_id):             # <<<<<<<<<<<<<<
 *             out_dc = reg.get_codec(out_type_id)
 * 
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_out_type_id)) { __Pyx_RaiseUnboundLocalError("out_type_id"); __PYX_ERR(5, 296, __pyx_L1_error) }
  __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_cur_scope->__pyx_v_reg->__pyx_vtab)->has_codec(__pyx_cur_scope->__pyx_v_reg, __pyx_cur_scope->__pyx_v_out_type_id); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(5, 296, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__pyx_t_1) {

    /* "edgedb/protocol/protocol.pyx":297
 *             in_dc = reg.get_codec(in_type_id)
 *         if reg.has_codec(out_type_id):
 *             out_dc = reg.get_codec(out_type_id)             # <<<<<<<<<<<<<<
 * 
 *         if in_dc is None or out_dc is None:
 */
    if (unlikely(!__pyx_cur_scope->__pyx_v_out_type_id)) { __Pyx_RaiseUnboundLocalError("out_type_id"); __PYX_ERR(5, 297, __pyx_L1_error) }
    __pyx_t_9 = ((PyObject *)((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_cur_scope->__pyx_v_reg->__pyx_vtab)->get_codec(__pyx_cur_scope->__pyx_v_reg, __pyx_cur_scope->__pyx_v_out_type_id)); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 297, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_out_dc));
    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_out_dc, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_9));
    __Pyx_GIVEREF(__pyx_t_9);
    __pyx_t_9 = 0;

    /* "edgedb/protocol/protocol.pyx":296
 *         if reg.has_codec(in_type_id):
 *             in_dc = reg.get_codec(in_type_id)
 *         if reg.has_codec(out_type_id):             # <<<<<<<<<<<<<<
 *             out_dc = reg.get_codec(out_type_id)
 * 
 */
  }

  /* "edgedb/protocol/protocol.pyx":299
 *             out_dc = reg.get_codec(out_type_id)
 * 
 *         if in_dc is None or out_dc is None:             # <<<<<<<<<<<<<<
 *             buf = WriteBuffer.new_message(DESCRIBE_STMT_MSG)
 *             buf.write_int16(0)  # no headers
 */
  __pyx_t_4 = (((PyObject *)__pyx_cur_scope->__pyx_v_in_dc) == Py_None);
  __pyx_t_6 = (__pyx_t_4 != 0);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_1 = __pyx_t_6;
    goto __pyx_L22_bool_binop_done;
  }
  __pyx_t_6 = (((PyObject *)__pyx_cur_scope->__pyx_v_out_dc) == Py_None);
  __pyx_t_4 = (__pyx_t_6 != 0);
  __pyx_t_1 = __pyx_t_4;
  __pyx_L22_bool_binop_done:;
  if (__pyx_t_1) {

    /* "edgedb/protocol/protocol.pyx":300
 * 
 *         if in_dc is None or out_dc is None:
 *             buf = WriteBuffer.new_message(DESCRIBE_STMT_MSG)             # <<<<<<<<<<<<<<
 *             buf.write_int16(0)  # no headers
 *             buf.write_byte(DESCRIBE_ASPECT_DATA)
 */
    __pyx_t_9 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('D')); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 300, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_buf));
    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_buf, ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_9));
    __Pyx_GIVEREF(__pyx_t_9);
    __pyx_t_9 = 0;

    /* "edgedb/protocol/protocol.pyx":301
 *         if in_dc is None or out_dc is None:
 *             buf = WriteBuffer.new_message(DESCRIBE_STMT_MSG)
 *             buf.write_int16(0)  # no headers             # <<<<<<<<<<<<<<
 *             buf.write_byte(DESCRIBE_ASPECT_DATA)
 *             buf.write_len_prefixed_bytes(b'')  # stmt_name
 */
    __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_int16(__pyx_cur_scope->__pyx_v_buf, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "edgedb/protocol/protocol.pyx":302
 *             buf = WriteBuffer.new_message(DESCRIBE_STMT_MSG)
 *             buf.write_int16(0)  # no headers
 *             buf.write_byte(DESCRIBE_ASPECT_DATA)             # <<<<<<<<<<<<<<
 *             buf.write_len_prefixed_bytes(b'')  # stmt_name
 *             buf.end_message()
 */
    __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_byte(__pyx_cur_scope->__pyx_v_buf, 'T'); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 302, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "edgedb/protocol/protocol.pyx":303
 *             buf.write_int16(0)  # no headers
 *             buf.write_byte(DESCRIBE_ASPECT_DATA)
 *             buf.write_len_prefixed_bytes(b'')  # stmt_name             # <<<<<<<<<<<<<<
 *             buf.end_message()
 *             buf.write_bytes(SYNC_MESSAGE)
 */
    __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_len_prefixed_bytes(__pyx_cur_scope->__pyx_v_buf, __pyx_kp_b__61); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 303, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "edgedb/protocol/protocol.pyx":304
 *             buf.write_byte(DESCRIBE_ASPECT_DATA)
 *             buf.write_len_prefixed_bytes(b'')  # stmt_name
 *             buf.end_message()             # <<<<<<<<<<<<<<
 *             buf.write_bytes(SYNC_MESSAGE)
 *             self.write(buf)
 */
    __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->end_message(__pyx_cur_scope->__pyx_v_buf); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 304, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "edgedb/protocol/protocol.pyx":305
 *             buf.write_len_prefixed_bytes(b'')  # stmt_name
 *             buf.end_message()
 *             buf.write_bytes(SYNC_MESSAGE)             # <<<<<<<<<<<<<<
 *             self.write(buf)
 * 
 */
    __pyx_t_9 = __pyx_v_6edgedb_8protocol_8protocol_SYNC_MESSAGE;
    __Pyx_INCREF(__pyx_t_9);
    __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_bytes(__pyx_cur_scope->__pyx_v_buf, ((PyObject*)__pyx_t_9)); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 305, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "edgedb/protocol/protocol.pyx":306
 *             buf.end_message()
 *             buf.write_bytes(SYNC_MESSAGE)
 *             self.write(buf)             # <<<<<<<<<<<<<<
 * 
 *             while True:
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 306, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "edgedb/protocol/protocol.pyx":308
 *             self.write(buf)
 * 
 *             while True:             # <<<<<<<<<<<<<<
 *                 if not self.buffer.take_message():
 *                     await self.wait_for_message()
 */
    while (1) {

      /* "edgedb/protocol/protocol.pyx":309
 * 
 *             while True:
 *                 if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                     await self.wait_for_message()
 *                 mtype = self.buffer.get_message_type()
 */
      __pyx_t_10 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_10 == ((int32_t)-1))) __PYX_ERR(5, 309, __pyx_L1_error)
      __pyx_t_1 = ((!(__pyx_t_10 != 0)) != 0);
      if (__pyx_t_1) {

        /* "edgedb/protocol/protocol.pyx":310
 *             while True:
 *                 if not self.buffer.take_message():
 *                     await self.wait_for_message()             # <<<<<<<<<<<<<<
 *                 mtype = self.buffer.get_message_type()
 * 
 */
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_wait_for_message); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 310, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_11 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
          if (likely(__pyx_t_11)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_11);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_9, function);
          }
        }
        __pyx_t_2 = (__pyx_t_11) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_11) : __Pyx_PyObject_CallNoArg(__pyx_t_9);
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 310, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_r);
        if (likely(__pyx_r)) {
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 2;
          return __pyx_r;
          __pyx_L27_resume_from_await:;
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 310, __pyx_L1_error)
        } else {
          PyObject* exc_type = __Pyx_PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
            else __PYX_ERR(5, 310, __pyx_L1_error)
          }
        }

        /* "edgedb/protocol/protocol.pyx":309
 * 
 *             while True:
 *                 if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                     await self.wait_for_message()
 *                 mtype = self.buffer.get_message_type()
 */
      }

      /* "edgedb/protocol/protocol.pyx":311
 *                 if not self.buffer.take_message():
 *                     await self.wait_for_message()
 *                 mtype = self.buffer.get_message_type()             # <<<<<<<<<<<<<<
 * 
 *                 try:
 */
      __pyx_cur_scope->__pyx_v_mtype = __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_cur_scope->__pyx_v_self->buffer);

      /* "edgedb/protocol/protocol.pyx":313
 *                 mtype = self.buffer.get_message_type()
 * 
 *                 try:             # <<<<<<<<<<<<<<
 *                     if mtype == STMT_DATA_DESC_MSG:
 *                         cardinality, in_dc, out_dc, _ = \
 */
      /*try:*/ {

        /* "edgedb/protocol/protocol.pyx":314
 * 
 *                 try:
 *                     if mtype == STMT_DATA_DESC_MSG:             # <<<<<<<<<<<<<<
 *                         cardinality, in_dc, out_dc, _ = \
 *                             self.parse_describe_type_message(reg)
 */
        switch (__pyx_cur_scope->__pyx_v_mtype) {
          case 'T':

          /* "edgedb/protocol/protocol.pyx":316
 *                     if mtype == STMT_DATA_DESC_MSG:
 *                         cardinality, in_dc, out_dc, _ = \
 *                             self.parse_describe_type_message(reg)             # <<<<<<<<<<<<<<
 * 
 *                     elif mtype == ERROR_RESPONSE_MSG:
 */
          __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_describe_type_message(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_reg); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 316, __pyx_L31_error)
          __Pyx_GOTREF(__pyx_t_2);
          if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
            PyObject* sequence = __pyx_t_2;
            Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
            if (unlikely(size != 4)) {
              if (size > 4) __Pyx_RaiseTooManyValuesError(4);
              else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
              __PYX_ERR(5, 315, __pyx_L31_error)
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            if (likely(PyTuple_CheckExact(sequence))) {
              __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
              __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
              __pyx_t_20 = PyTuple_GET_ITEM(sequence, 2); 
              __pyx_t_21 = PyTuple_GET_ITEM(sequence, 3); 
            } else {
              __pyx_t_9 = PyList_GET_ITEM(sequence, 0); 
              __pyx_t_11 = PyList_GET_ITEM(sequence, 1); 
              __pyx_t_20 = PyList_GET_ITEM(sequence, 2); 
              __pyx_t_21 = PyList_GET_ITEM(sequence, 3); 
            }
            __Pyx_INCREF(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_11);
            __Pyx_INCREF(__pyx_t_20);
            __Pyx_INCREF(__pyx_t_21);
            #else
            {
              Py_ssize_t i;
              PyObject** temps[4] = {&__pyx_t_9,&__pyx_t_11,&__pyx_t_20,&__pyx_t_21};
              for (i=0; i < 4; i++) {
                PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(5, 315, __pyx_L31_error)
                __Pyx_GOTREF(item);
                *(temps[i]) = item;
              }
            }
            #endif
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          } else {
            Py_ssize_t index = -1;
            PyObject** temps[4] = {&__pyx_t_9,&__pyx_t_11,&__pyx_t_20,&__pyx_t_21};
            __pyx_t_22 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_22)) __PYX_ERR(5, 315, __pyx_L31_error)
            __Pyx_GOTREF(__pyx_t_22);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_23 = Py_TYPE(__pyx_t_22)->tp_iternext;
            for (index=0; index < 4; index++) {
              PyObject* item = __pyx_t_23(__pyx_t_22); if (unlikely(!item)) goto __pyx_L33_unpacking_failed;
              __Pyx_GOTREF(item);
              *(temps[index]) = item;
            }
            if (__Pyx_IternextUnpackEndCheck(__pyx_t_23(__pyx_t_22), 4) < 0) __PYX_ERR(5, 315, __pyx_L31_error)
            __pyx_t_23 = NULL;
            __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
            goto __pyx_L34_unpacking_done;
            __pyx_L33_unpacking_failed:;
            __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
            __pyx_t_23 = NULL;
            if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
            __PYX_ERR(5, 315, __pyx_L31_error)
            __pyx_L34_unpacking_done:;
          }

          /* "edgedb/protocol/protocol.pyx":315
 *                 try:
 *                     if mtype == STMT_DATA_DESC_MSG:
 *                         cardinality, in_dc, out_dc, _ = \             # <<<<<<<<<<<<<<
 *                             self.parse_describe_type_message(reg)
 * 
 */
          if (!(likely(PyBytes_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_9)->tp_name), 0))) __PYX_ERR(5, 315, __pyx_L31_error)
          if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec))))) __PYX_ERR(5, 315, __pyx_L31_error)
          if (!(likely(((__pyx_t_20) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_20, __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec))))) __PYX_ERR(5, 315, __pyx_L31_error)
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_cardinality);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_cardinality, ((PyObject*)__pyx_t_9));
          __Pyx_GIVEREF(__pyx_t_9);
          __pyx_t_9 = 0;
          __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_in_dc));
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_in_dc, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_11));
          __Pyx_GIVEREF(__pyx_t_11);
          __pyx_t_11 = 0;
          __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_out_dc));
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_out_dc, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_20));
          __Pyx_GIVEREF(__pyx_t_20);
          __pyx_t_20 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__, __pyx_t_21);
          __Pyx_GIVEREF(__pyx_t_21);
          __pyx_t_21 = 0;

          /* "edgedb/protocol/protocol.pyx":314
 * 
 *                 try:
 *                     if mtype == STMT_DATA_DESC_MSG:             # <<<<<<<<<<<<<<
 *                         cardinality, in_dc, out_dc, _ = \
 *                             self.parse_describe_type_message(reg)
 */
          break;
          case 'E':

          /* "edgedb/protocol/protocol.pyx":319
 * 
 *                     elif mtype == ERROR_RESPONSE_MSG:
 *                         exc = self.parse_error_message()             # <<<<<<<<<<<<<<
 *                         exc = self._amend_parse_error(
 *                             exc, io_format, expect_one, required_one)
 */
          __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_error_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 319, __pyx_L31_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_exc);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_exc, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;

          /* "edgedb/protocol/protocol.pyx":321
 *                         exc = self.parse_error_message()
 *                         exc = self._amend_parse_error(
 *                             exc, io_format, expect_one, required_one)             # <<<<<<<<<<<<<<
 * 
 *                     elif mtype == READY_FOR_COMMAND_MSG:
 */
          __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_required_one); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 321, __pyx_L31_error)

          /* "edgedb/protocol/protocol.pyx":320
 *                     elif mtype == ERROR_RESPONSE_MSG:
 *                         exc = self.parse_error_message()
 *                         exc = self._amend_parse_error(             # <<<<<<<<<<<<<<
 *                             exc, io_format, expect_one, required_one)
 * 
 */
          __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->_amend_parse_error(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_exc, __pyx_cur_scope->__pyx_v_io_format, __pyx_cur_scope->__pyx_v_expect_one, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 320, __pyx_L31_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_exc);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_exc, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;

          /* "edgedb/protocol/protocol.pyx":318
 *                             self.parse_describe_type_message(reg)
 * 
 *                     elif mtype == ERROR_RESPONSE_MSG:             # <<<<<<<<<<<<<<
 *                         exc = self.parse_error_message()
 *                         exc = self._amend_parse_error(
 */
          break;
          case 'Z':

          /* "edgedb/protocol/protocol.pyx":324
 * 
 *                     elif mtype == READY_FOR_COMMAND_MSG:
 *                         self.parse_sync_message()             # <<<<<<<<<<<<<<
 *                         break
 * 
 */
          __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_sync_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 324, __pyx_L31_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "edgedb/protocol/protocol.pyx":325
 *                     elif mtype == READY_FOR_COMMAND_MSG:
 *                         self.parse_sync_message()
 *                         break             # <<<<<<<<<<<<<<
 * 
 *                     else:
 */
          goto __pyx_L29_break;

          /* "edgedb/protocol/protocol.pyx":323
 *                             exc, io_format, expect_one, required_one)
 * 
 *                     elif mtype == READY_FOR_COMMAND_MSG:             # <<<<<<<<<<<<<<
 *                         self.parse_sync_message()
 *                         break
 */
          break;
          default:

          /* "edgedb/protocol/protocol.pyx":328
 * 
 *                     else:
 *                         self.fallthrough()             # <<<<<<<<<<<<<<
 * 
 *                 finally:
 */
          __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->fallthrough(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 328, __pyx_L31_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          break;
        }
      }

      /* "edgedb/protocol/protocol.pyx":331
 * 
 *                 finally:
 *                     self.buffer.finish_message()             # <<<<<<<<<<<<<<
 * 
 *         if exc is not None:
 */
      /*finally:*/ {
        /*normal exit:*/{
          __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 331, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          goto __pyx_L32;
        }
        __pyx_L31_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_15, &__pyx_t_14);
          if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_14);
          __pyx_t_12 = __pyx_lineno; __pyx_t_3 = __pyx_clineno; __pyx_t_24 = __pyx_filename;
          {
            __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 331, __pyx_L38_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          }
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_15, __pyx_t_14);
          }
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_ErrRestore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
          __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0;
          __pyx_lineno = __pyx_t_12; __pyx_clineno = __pyx_t_3; __pyx_filename = __pyx_t_24;
          goto __pyx_L1_error;
          __pyx_L38_error:;
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_15, __pyx_t_14);
          }
          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0;
          goto __pyx_L1_error;
        }
        __pyx_L29_break: {
          __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 331, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          goto __pyx_L25_break;
        }
        __pyx_L32:;
      }
    }
    __pyx_L25_break:;

    /* "edgedb/protocol/protocol.pyx":299
 *             out_dc = reg.get_codec(out_type_id)
 * 
 *         if in_dc is None or out_dc is None:             # <<<<<<<<<<<<<<
 *             buf = WriteBuffer.new_message(DESCRIBE_STMT_MSG)
 *             buf.write_int16(0)  # no headers
 */
  }

  /* "edgedb/protocol/protocol.pyx":333
 *                     self.buffer.finish_message()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             raise exc
 * 
 */
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_exc != Py_None);
  __pyx_t_4 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_4)) {

    /* "edgedb/protocol/protocol.pyx":334
 * 
 *         if exc is not None:
 *             raise exc             # <<<<<<<<<<<<<<
 * 
 *         if required_one and cardinality == CARDINALITY_NOT_APPLICABLE:
 */
    __Pyx_Raise(__pyx_cur_scope->__pyx_v_exc, 0, 0, 0);
    __PYX_ERR(5, 334, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":333
 *                     self.buffer.finish_message()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             raise exc
 * 
 */
  }

  /* "edgedb/protocol/protocol.pyx":336
 *             raise exc
 * 
 *         if required_one and cardinality == CARDINALITY_NOT_APPLICABLE:             # <<<<<<<<<<<<<<
 *             methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *             raise errors.InterfaceError(
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_required_one); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(5, 336, __pyx_L1_error)
  if (__pyx_t_1) {
  } else {
    __pyx_t_4 = __pyx_t_1;
    goto __pyx_L41_bool_binop_done;
  }
  if (unlikely(!__pyx_cur_scope->__pyx_v_cardinality)) { __Pyx_RaiseUnboundLocalError("cardinality"); __PYX_ERR(5, 336, __pyx_L1_error) }
  __pyx_t_1 = (__Pyx_PyBytes_Equals(__pyx_cur_scope->__pyx_v_cardinality, __pyx_n_b_n, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(5, 336, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_1 != 0);
  __pyx_t_4 = __pyx_t_6;
  __pyx_L41_bool_binop_done:;
  if (unlikely(__pyx_t_4)) {

    /* "edgedb/protocol/protocol.pyx":337
 * 
 *         if required_one and cardinality == CARDINALITY_NOT_APPLICABLE:
 *             methname = _QUERY_SINGLE_METHOD[required_one][io_format]             # <<<<<<<<<<<<<<
 *             raise errors.InterfaceError(
 *                 f'query cannot be executed with {methname}() as it '
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_QUERY_SINGLE_METHOD); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 337, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_21 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_cur_scope->__pyx_v_required_one); if (unlikely(!__pyx_t_21)) __PYX_ERR(5, 337, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_cur_scope->__pyx_v_io_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 337, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_20 = __Pyx_PyObject_GetItem(__pyx_t_21, __pyx_t_2); if (unlikely(!__pyx_t_20)) __PYX_ERR(5, 337, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_20);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GIVEREF(__pyx_t_20);
    __pyx_cur_scope->__pyx_v_methname = __pyx_t_20;
    __pyx_t_20 = 0;

    /* "edgedb/protocol/protocol.pyx":338
 *         if required_one and cardinality == CARDINALITY_NOT_APPLICABLE:
 *             methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *             raise errors.InterfaceError(             # <<<<<<<<<<<<<<
 *                 f'query cannot be executed with {methname}() as it '
 *                 f'does not return any data')
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_errors); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_InterfaceError); if (unlikely(!__pyx_t_21)) __PYX_ERR(5, 338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "edgedb/protocol/protocol.pyx":339
 *             methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *             raise errors.InterfaceError(
 *                 f'query cannot be executed with {methname}() as it '             # <<<<<<<<<<<<<<
 *                 f'does not return any data')
 * 
 */
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 339, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_25 = 0;
    __pyx_t_26 = 127;
    __Pyx_INCREF(__pyx_kp_u_query_cannot_be_executed_with);
    __pyx_t_25 += 30;
    __Pyx_GIVEREF(__pyx_kp_u_query_cannot_be_executed_with);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u_query_cannot_be_executed_with);
    __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_methname, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 339, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_26 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_26) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_26;
    __pyx_t_25 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_11);
    __pyx_t_11 = 0;
    __Pyx_INCREF(__pyx_kp_u_as_it_does_not_return_any_data);
    __pyx_t_25 += 33;
    __Pyx_GIVEREF(__pyx_kp_u_as_it_does_not_return_any_data);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u_as_it_does_not_return_any_data);
    __pyx_t_11 = __Pyx_PyUnicode_Join(__pyx_t_2, 3, __pyx_t_25, __pyx_t_26); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 339, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_21))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_21);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_21);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_21, function);
      }
    }
    __pyx_t_20 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_21, __pyx_t_2, __pyx_t_11) : __Pyx_PyObject_CallOneArg(__pyx_t_21, __pyx_t_11);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (unlikely(!__pyx_t_20)) __PYX_ERR(5, 338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_20);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_Raise(__pyx_t_20, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
    __PYX_ERR(5, 338, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":336
 *             raise exc
 * 
 *         if required_one and cardinality == CARDINALITY_NOT_APPLICABLE:             # <<<<<<<<<<<<<<
 *             methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *             raise errors.InterfaceError(
 */
  }

  /* "edgedb/protocol/protocol.pyx":342
 *                 f'does not return any data')
 * 
 *         return cardinality, in_dc, out_dc, attrs             # <<<<<<<<<<<<<<
 * 
 *     cdef ensure_connected(self):
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_v_cardinality)) { __Pyx_RaiseUnboundLocalError("cardinality"); __PYX_ERR(5, 342, __pyx_L1_error) }
  __pyx_t_20 = PyTuple_New(4); if (unlikely(!__pyx_t_20)) __PYX_ERR(5, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_cardinality);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_cardinality);
  PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_cur_scope->__pyx_v_cardinality);
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_in_dc));
  __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_in_dc));
  PyTuple_SET_ITEM(__pyx_t_20, 1, ((PyObject *)__pyx_cur_scope->__pyx_v_in_dc));
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_out_dc));
  __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_out_dc));
  PyTuple_SET_ITEM(__pyx_t_20, 2, ((PyObject *)__pyx_cur_scope->__pyx_v_out_dc));
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_attrs);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_attrs);
  PyTuple_SET_ITEM(__pyx_t_20, 3, __pyx_cur_scope->__pyx_v_attrs);
  __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  goto __pyx_L0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "edgedb/protocol/protocol.pyx":224
 *             buf.write_int16(0)  # no headers
 * 
 *     async def _parse(             # <<<<<<<<<<<<<<
 *         self,
 *         query: str,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_AddTraceback("_parse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":344
 *         return cardinality, in_dc, out_dc, attrs
 * 
 *     cdef ensure_connected(self):             # <<<<<<<<<<<<<<
 *         if self.cancelled:
 *             raise errors.ClientConnectionClosedError(
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_ensure_connected(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ensure_connected", 0);

  /* "edgedb/protocol/protocol.pyx":345
 * 
 *     cdef ensure_connected(self):
 *         if self.cancelled:             # <<<<<<<<<<<<<<
 *             raise errors.ClientConnectionClosedError(
 *                 'the connection has been closed '
 */
  __pyx_t_1 = (__pyx_v_self->cancelled != 0);
  if (unlikely(__pyx_t_1)) {

    /* "edgedb/protocol/protocol.pyx":346
 *     cdef ensure_connected(self):
 *         if self.cancelled:
 *             raise errors.ClientConnectionClosedError(             # <<<<<<<<<<<<<<
 *                 'the connection has been closed '
 *                 'because an operation was cancelled on it')
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_errors); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 346, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ClientConnectionClosedError); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 346, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_kp_u_the_connection_has_been_closed_b) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u_the_connection_has_been_closed_b);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 346, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(5, 346, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":345
 * 
 *     cdef ensure_connected(self):
 *         if self.cancelled:             # <<<<<<<<<<<<<<
 *             raise errors.ClientConnectionClosedError(
 *                 'the connection has been closed '
 */
  }

  /* "edgedb/protocol/protocol.pyx":349
 *                 'the connection has been closed '
 *                 'because an operation was cancelled on it')
 *         if not self.connected:             # <<<<<<<<<<<<<<
 *             raise errors.ClientConnectionClosedError(
 *                 'the connection has been closed')
 */
  __pyx_t_1 = ((!(__pyx_v_self->connected != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "edgedb/protocol/protocol.pyx":350
 *                 'because an operation was cancelled on it')
 *         if not self.connected:
 *             raise errors.ClientConnectionClosedError(             # <<<<<<<<<<<<<<
 *                 'the connection has been closed')
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_errors); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 350, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ClientConnectionClosedError); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 350, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_kp_u_the_connection_has_been_closed) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_the_connection_has_been_closed);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 350, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(5, 350, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":349
 *                 'the connection has been closed '
 *                 'because an operation was cancelled on it')
 *         if not self.connected:             # <<<<<<<<<<<<<<
 *             raise errors.ClientConnectionClosedError(
 *                 'the connection has been closed')
 */
  }

  /* "edgedb/protocol/protocol.pyx":344
 *         return cardinality, in_dc, out_dc, attrs
 * 
 *     cdef ensure_connected(self):             # <<<<<<<<<<<<<<
 *         if self.cancelled:
 *             raise errors.ClientConnectionClosedError(
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.ensure_connected", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_24generator4(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "edgedb/protocol/protocol.pyx":353
 *                 'the connection has been closed')
 * 
 *     async def _execute(self, BaseCodec in_dc, BaseCodec out_dc, args, kwargs):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer packet
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_23_execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_23_execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_in_dc = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_out_dc = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_execute (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_in_dc,&__pyx_n_s_out_dc,&__pyx_n_s_args,&__pyx_n_s_kwargs,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_in_dc)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out_dc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_execute", 1, 4, 4, 1); __PYX_ERR(5, 353, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_execute", 1, 4, 4, 2); __PYX_ERR(5, 353, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_execute", 1, 4, 4, 3); __PYX_ERR(5, 353, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_execute") < 0)) __PYX_ERR(5, 353, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_in_dc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)values[0]);
    __pyx_v_out_dc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)values[1]);
    __pyx_v_args = values[2];
    __pyx_v_kwargs = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_execute", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 353, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol._execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_in_dc), __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec, 1, "in_dc", 0))) __PYX_ERR(5, 353, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out_dc), __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec, 1, "out_dc", 0))) __PYX_ERR(5, 353, __pyx_L1_error)
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_22_execute(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self), __pyx_v_in_dc, __pyx_v_out_dc, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_22_execute(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_in_dc, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_out_dc, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_execute", 0);
  __pyx_cur_scope = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute *)__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute(__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 353, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_in_dc = __pyx_v_in_dc;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_in_dc);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_in_dc);
  __pyx_cur_scope->__pyx_v_out_dc = __pyx_v_out_dc;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_out_dc);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_out_dc);
  __pyx_cur_scope->__pyx_v_args = __pyx_v_args;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_args);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_args);
  __pyx_cur_scope->__pyx_v_kwargs = __pyx_v_kwargs;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_kwargs);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_kwargs);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_24generator4, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_execute, __pyx_n_s_SansIOProtocol__execute, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(5, 353, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol._execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_24generator4(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute *__pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int32_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  char const *__pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  char const *__pyx_t_22;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_execute", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L7_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 353, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":359
 *             char mtype
 * 
 *         self.ensure_connected()             # <<<<<<<<<<<<<<
 *         self.reset_status()
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->ensure_connected(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":360
 * 
 *         self.ensure_connected()
 *         self.reset_status()             # <<<<<<<<<<<<<<
 * 
 *         packet = WriteBuffer.new()
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->reset_status(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":362
 *         self.reset_status()
 * 
 *         packet = WriteBuffer.new()             # <<<<<<<<<<<<<<
 * 
 *         buf = WriteBuffer.new_message(EXECUTE_MSG)
 */
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 362, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_packet = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":364
 *         packet = WriteBuffer.new()
 * 
 *         buf = WriteBuffer.new_message(EXECUTE_MSG)             # <<<<<<<<<<<<<<
 *         buf.write_int16(0)  # no headers
 *         buf.write_len_prefixed_bytes(b'')  # stmt_name
 */
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('E')); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_buf = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":365
 * 
 *         buf = WriteBuffer.new_message(EXECUTE_MSG)
 *         buf.write_int16(0)  # no headers             # <<<<<<<<<<<<<<
 *         buf.write_len_prefixed_bytes(b'')  # stmt_name
 *         self.encode_args(in_dc, buf, args, kwargs)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_int16(__pyx_cur_scope->__pyx_v_buf, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 365, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":366
 *         buf = WriteBuffer.new_message(EXECUTE_MSG)
 *         buf.write_int16(0)  # no headers
 *         buf.write_len_prefixed_bytes(b'')  # stmt_name             # <<<<<<<<<<<<<<
 *         self.encode_args(in_dc, buf, args, kwargs)
 *         packet.write_buffer(buf.end_message())
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_len_prefixed_bytes(__pyx_cur_scope->__pyx_v_buf, __pyx_kp_b__61); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 366, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":367
 *         buf.write_int16(0)  # no headers
 *         buf.write_len_prefixed_bytes(b'')  # stmt_name
 *         self.encode_args(in_dc, buf, args, kwargs)             # <<<<<<<<<<<<<<
 *         packet.write_buffer(buf.end_message())
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->encode_args(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_in_dc, __pyx_cur_scope->__pyx_v_buf, __pyx_cur_scope->__pyx_v_args, __pyx_cur_scope->__pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":368
 *         buf.write_len_prefixed_bytes(b'')  # stmt_name
 *         self.encode_args(in_dc, buf, args, kwargs)
 *         packet.write_buffer(buf.end_message())             # <<<<<<<<<<<<<<
 * 
 *         packet.write_bytes(SYNC_MESSAGE)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->end_message(__pyx_cur_scope->__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 368, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6edgedb_7pgproto_7pgproto_WriteBuffer))))) __PYX_ERR(5, 368, __pyx_L1_error)
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_packet->__pyx_vtab)->write_buffer(__pyx_cur_scope->__pyx_v_packet, ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 368, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":370
 *         packet.write_buffer(buf.end_message())
 * 
 *         packet.write_bytes(SYNC_MESSAGE)             # <<<<<<<<<<<<<<
 *         self.write(packet)
 * 
 */
  __pyx_t_2 = __pyx_v_6edgedb_8protocol_8protocol_SYNC_MESSAGE;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_packet->__pyx_vtab)->write_bytes(__pyx_cur_scope->__pyx_v_packet, ((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":371
 * 
 *         packet.write_bytes(SYNC_MESSAGE)
 *         self.write(packet)             # <<<<<<<<<<<<<<
 * 
 *         result = datatypes.set_new(0)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_packet); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":373
 *         self.write(packet)
 * 
 *         result = datatypes.set_new(0)             # <<<<<<<<<<<<<<
 * 
 *         attrs = None
 */
  __pyx_t_1 = __pyx_f_6edgedb_9datatypes_9datatypes_set_new(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":375
 *         result = datatypes.set_new(0)
 * 
 *         attrs = None             # <<<<<<<<<<<<<<
 *         exc = None
 *         while True:
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_cur_scope->__pyx_v_attrs = Py_None;

  /* "edgedb/protocol/protocol.pyx":376
 * 
 *         attrs = None
 *         exc = None             # <<<<<<<<<<<<<<
 *         while True:
 *             if not self.buffer.take_message():
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_cur_scope->__pyx_v_exc = Py_None;

  /* "edgedb/protocol/protocol.pyx":377
 *         attrs = None
 *         exc = None
 *         while True:             # <<<<<<<<<<<<<<
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 */
  while (1) {

    /* "edgedb/protocol/protocol.pyx":378
 *         exc = None
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_3 == ((int32_t)-1))) __PYX_ERR(5, 378, __pyx_L1_error)
    __pyx_t_4 = ((!(__pyx_t_3 != 0)) != 0);
    if (__pyx_t_4) {

      /* "edgedb/protocol/protocol.pyx":379
 *         while True:
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()             # <<<<<<<<<<<<<<
 *             mtype = self.buffer.get_message_type()
 * 
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_wait_for_message); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 379, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 379, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XGOTREF(__pyx_r);
      if (likely(__pyx_r)) {
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L7_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 379, __pyx_L1_error)
      } else {
        PyObject* exc_type = __Pyx_PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
          else __PYX_ERR(5, 379, __pyx_L1_error)
        }
      }

      /* "edgedb/protocol/protocol.pyx":378
 *         exc = None
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    }

    /* "edgedb/protocol/protocol.pyx":380
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()             # <<<<<<<<<<<<<<
 * 
 *             try:
 */
    __pyx_cur_scope->__pyx_v_mtype = __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_cur_scope->__pyx_v_self->buffer);

    /* "edgedb/protocol/protocol.pyx":382
 *             mtype = self.buffer.get_message_type()
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 if mtype == DATA_MSG:
 *                     if exc is None:
 */
    /*try:*/ {

      /* "edgedb/protocol/protocol.pyx":383
 * 
 *             try:
 *                 if mtype == DATA_MSG:             # <<<<<<<<<<<<<<
 *                     if exc is None:
 *                         try:
 */
      switch (__pyx_cur_scope->__pyx_v_mtype) {
        case 'D':

        /* "edgedb/protocol/protocol.pyx":384
 *             try:
 *                 if mtype == DATA_MSG:
 *                     if exc is None:             # <<<<<<<<<<<<<<
 *                         try:
 *                             self.parse_data_messages(out_dc, result)
 */
        __pyx_t_4 = (__pyx_cur_scope->__pyx_v_exc == Py_None);
        __pyx_t_6 = (__pyx_t_4 != 0);
        if (__pyx_t_6) {

          /* "edgedb/protocol/protocol.pyx":385
 *                 if mtype == DATA_MSG:
 *                     if exc is None:
 *                         try:             # <<<<<<<<<<<<<<
 *                             self.parse_data_messages(out_dc, result)
 *                         except Exception as ex:
 */
          {
            __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
            __Pyx_XGOTREF(__pyx_t_7);
            __Pyx_XGOTREF(__pyx_t_8);
            __Pyx_XGOTREF(__pyx_t_9);
            /*try:*/ {

              /* "edgedb/protocol/protocol.pyx":386
 *                     if exc is None:
 *                         try:
 *                             self.parse_data_messages(out_dc, result)             # <<<<<<<<<<<<<<
 *                         except Exception as ex:
 *                             # An error during data decoding.  We need to
 */
              __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_data_messages(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_out_dc, __pyx_cur_scope->__pyx_v_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 386, __pyx_L14_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "edgedb/protocol/protocol.pyx":385
 *                 if mtype == DATA_MSG:
 *                     if exc is None:
 *                         try:             # <<<<<<<<<<<<<<
 *                             self.parse_data_messages(out_dc, result)
 *                         except Exception as ex:
 */
            }
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            goto __pyx_L21_try_end;
            __pyx_L14_error:;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

            /* "edgedb/protocol/protocol.pyx":387
 *                         try:
 *                             self.parse_data_messages(out_dc, result)
 *                         except Exception as ex:             # <<<<<<<<<<<<<<
 *                             # An error during data decoding.  We need to
 *                             # handle this as gracefully as possible:
 */
            __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
            if (__pyx_t_10) {
              __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol._execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_5) < 0) __PYX_ERR(5, 387, __pyx_L16_except_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_GIVEREF(__pyx_t_2);
              __pyx_cur_scope->__pyx_v_ex = __pyx_t_2;
              /*try:*/ {

                /* "edgedb/protocol/protocol.pyx":393
 *                             #   received;
 *                             # * ignore all 'D' messages for this query.
 *                             exc = errors.ClientError(             # <<<<<<<<<<<<<<
 *                                 'unable to decode data to Python objects')
 *                             exc.__cause__ = ex
 */
                __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_errors); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 393, __pyx_L27_error)
                __Pyx_GOTREF(__pyx_t_12);
                __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_ClientError); if (unlikely(!__pyx_t_13)) __PYX_ERR(5, 393, __pyx_L27_error)
                __Pyx_GOTREF(__pyx_t_13);
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                __pyx_t_12 = NULL;
                if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
                  __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
                  if (likely(__pyx_t_12)) {
                    PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
                    __Pyx_INCREF(__pyx_t_12);
                    __Pyx_INCREF(function);
                    __Pyx_DECREF_SET(__pyx_t_13, function);
                  }
                }
                __pyx_t_11 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_12, __pyx_kp_u_unable_to_decode_data_to_Python) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_u_unable_to_decode_data_to_Python);
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 393, __pyx_L27_error)
                __Pyx_GOTREF(__pyx_t_11);
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_exc);
                __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_exc, __pyx_t_11);
                __Pyx_GIVEREF(__pyx_t_11);
                __pyx_t_11 = 0;

                /* "edgedb/protocol/protocol.pyx":395
 *                             exc = errors.ClientError(
 *                                 'unable to decode data to Python objects')
 *                             exc.__cause__ = ex             # <<<<<<<<<<<<<<
 *                             # Take care of a partially consumed 'D' message
 *                             # and the ones yet unparsed.
 */
                if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_exc, __pyx_n_s_cause, __pyx_cur_scope->__pyx_v_ex) < 0) __PYX_ERR(5, 395, __pyx_L27_error)

                /* "edgedb/protocol/protocol.pyx":398
 *                             # Take care of a partially consumed 'D' message
 *                             # and the ones yet unparsed.
 *                             while self.buffer.take_message_type(DATA_MSG):             # <<<<<<<<<<<<<<
 *                                 self.buffer.discard_message()
 *                     else:
 */
                while (1) {
                  __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message_type(__pyx_cur_scope->__pyx_v_self->buffer, 'D'); if (unlikely(__pyx_t_3 == ((int32_t)-1))) __PYX_ERR(5, 398, __pyx_L27_error)
                  __pyx_t_6 = (__pyx_t_3 != 0);
                  if (!__pyx_t_6) break;

                  /* "edgedb/protocol/protocol.pyx":399
 *                             # and the ones yet unparsed.
 *                             while self.buffer.take_message_type(DATA_MSG):
 *                                 self.buffer.discard_message()             # <<<<<<<<<<<<<<
 *                     else:
 *                         self.buffer.discard_message()
 */
                  __pyx_t_11 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->discard_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 399, __pyx_L27_error)
                  __Pyx_GOTREF(__pyx_t_11);
                  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                }
              }

              /* "edgedb/protocol/protocol.pyx":387
 *                         try:
 *                             self.parse_data_messages(out_dc, result)
 *                         except Exception as ex:             # <<<<<<<<<<<<<<
 *                             # An error during data decoding.  We need to
 *                             # handle this as gracefully as possible:
 */
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
                  __pyx_cur_scope->__pyx_v_ex = NULL;
                  goto __pyx_L28;
                }
                __pyx_L27_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
                  __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
                  if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_t_16);
                  __Pyx_XGOTREF(__pyx_t_17);
                  __Pyx_XGOTREF(__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_t_19);
                  __Pyx_XGOTREF(__pyx_t_20);
                  __Pyx_XGOTREF(__pyx_t_21);
                  __pyx_t_10 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
                    __pyx_cur_scope->__pyx_v_ex = NULL;
                  }
                  if (PY_MAJOR_VERSION >= 3) {
                    __Pyx_XGIVEREF(__pyx_t_19);
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
                  }
                  __Pyx_XGIVEREF(__pyx_t_16);
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
                  __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
                  __pyx_lineno = __pyx_t_10; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
                  goto __pyx_L16_except_error;
                }
                __pyx_L28:;
              }
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              goto __pyx_L15_exception_handled;
            }
            goto __pyx_L16_except_error;
            __pyx_L16_except_error:;

            /* "edgedb/protocol/protocol.pyx":385
 *                 if mtype == DATA_MSG:
 *                     if exc is None:
 *                         try:             # <<<<<<<<<<<<<<
 *                             self.parse_data_messages(out_dc, result)
 *                         except Exception as ex:
 */
            __Pyx_XGIVEREF(__pyx_t_7);
            __Pyx_XGIVEREF(__pyx_t_8);
            __Pyx_XGIVEREF(__pyx_t_9);
            __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
            goto __pyx_L11_error;
            __pyx_L15_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_7);
            __Pyx_XGIVEREF(__pyx_t_8);
            __Pyx_XGIVEREF(__pyx_t_9);
            __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
            __pyx_L21_try_end:;
          }

          /* "edgedb/protocol/protocol.pyx":384
 *             try:
 *                 if mtype == DATA_MSG:
 *                     if exc is None:             # <<<<<<<<<<<<<<
 *                         try:
 *                             self.parse_data_messages(out_dc, result)
 */
          goto __pyx_L13;
        }

        /* "edgedb/protocol/protocol.pyx":401
 *                                 self.buffer.discard_message()
 *                     else:
 *                         self.buffer.discard_message()             # <<<<<<<<<<<<<<
 * 
 *                 elif mtype == COMMAND_COMPLETE_MSG:
 */
        /*else*/ {
          __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->discard_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 401, __pyx_L11_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
        __pyx_L13:;

        /* "edgedb/protocol/protocol.pyx":383
 * 
 *             try:
 *                 if mtype == DATA_MSG:             # <<<<<<<<<<<<<<
 *                     if exc is None:
 *                         try:
 */
        break;
        case 'C':

        /* "edgedb/protocol/protocol.pyx":404
 * 
 *                 elif mtype == COMMAND_COMPLETE_MSG:
 *                     attrs = self.parse_command_complete_message()             # <<<<<<<<<<<<<<
 * 
 *                 elif mtype == ERROR_RESPONSE_MSG:
 */
        __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_command_complete_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 404, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_attrs);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_attrs, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __pyx_t_5 = 0;

        /* "edgedb/protocol/protocol.pyx":403
 *                         self.buffer.discard_message()
 * 
 *                 elif mtype == COMMAND_COMPLETE_MSG:             # <<<<<<<<<<<<<<
 *                     attrs = self.parse_command_complete_message()
 * 
 */
        break;
        case 'E':

        /* "edgedb/protocol/protocol.pyx":407
 * 
 *                 elif mtype == ERROR_RESPONSE_MSG:
 *                     exc = self.parse_error_message()             # <<<<<<<<<<<<<<
 * 
 *                 elif mtype == READY_FOR_COMMAND_MSG:
 */
        __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_error_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 407, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_exc);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_exc, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __pyx_t_5 = 0;

        /* "edgedb/protocol/protocol.pyx":406
 *                     attrs = self.parse_command_complete_message()
 * 
 *                 elif mtype == ERROR_RESPONSE_MSG:             # <<<<<<<<<<<<<<
 *                     exc = self.parse_error_message()
 * 
 */
        break;
        case 'Z':

        /* "edgedb/protocol/protocol.pyx":410
 * 
 *                 elif mtype == READY_FOR_COMMAND_MSG:
 *                     self.parse_sync_message()             # <<<<<<<<<<<<<<
 *                     break
 * 
 */
        __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_sync_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 410, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "edgedb/protocol/protocol.pyx":411
 *                 elif mtype == READY_FOR_COMMAND_MSG:
 *                     self.parse_sync_message()
 *                     break             # <<<<<<<<<<<<<<
 * 
 *                 else:
 */
        goto __pyx_L9_break;

        /* "edgedb/protocol/protocol.pyx":409
 *                     exc = self.parse_error_message()
 * 
 *                 elif mtype == READY_FOR_COMMAND_MSG:             # <<<<<<<<<<<<<<
 *                     self.parse_sync_message()
 *                     break
 */
        break;
        default:

        /* "edgedb/protocol/protocol.pyx":414
 * 
 *                 else:
 *                     self.fallthrough()             # <<<<<<<<<<<<<<
 * 
 *             finally:
 */
        __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->fallthrough(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 414, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        break;
      }
    }

    /* "edgedb/protocol/protocol.pyx":417
 * 
 *             finally:
 *                 self.buffer.finish_message()             # <<<<<<<<<<<<<<
 * 
 *         if exc is not None:
 */
    /*finally:*/ {
      /*normal exit:*/{
        __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 417, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L12;
      }
      __pyx_L11_error:;
      /*exception exit:*/{
        __Pyx_PyThreadState_assign
        __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_20, &__pyx_t_19);
        if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_21);
        __Pyx_XGOTREF(__pyx_t_20);
        __Pyx_XGOTREF(__pyx_t_19);
        __pyx_t_14 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_22 = __pyx_filename;
        {
          __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 417, __pyx_L38_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
        }
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_ErrRestore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
        __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
        __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_22;
        goto __pyx_L1_error;
        __pyx_L38_error:;
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19);
        }
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
        goto __pyx_L1_error;
      }
      __pyx_L9_break: {
        __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 417, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L5_break;
      }
      __pyx_L12:;
    }
  }
  __pyx_L5_break:;

  /* "edgedb/protocol/protocol.pyx":419
 *                 self.buffer.finish_message()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             raise exc
 * 
 */
  __pyx_t_6 = (__pyx_cur_scope->__pyx_v_exc != Py_None);
  __pyx_t_4 = (__pyx_t_6 != 0);
  if (unlikely(__pyx_t_4)) {

    /* "edgedb/protocol/protocol.pyx":420
 * 
 *         if exc is not None:
 *             raise exc             # <<<<<<<<<<<<<<
 * 
 *         return result, attrs
 */
    __Pyx_Raise(__pyx_cur_scope->__pyx_v_exc, 0, 0, 0);
    __PYX_ERR(5, 420, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":419
 *                 self.buffer.finish_message()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             raise exc
 * 
 */
  }

  /* "edgedb/protocol/protocol.pyx":422
 *             raise exc
 * 
 *         return result, attrs             # <<<<<<<<<<<<<<
 * 
 *     async def _optimistic_execute(
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_result);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_result);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_cur_scope->__pyx_v_result);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_attrs);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_attrs);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_cur_scope->__pyx_v_attrs);
  __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  goto __pyx_L0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "edgedb/protocol/protocol.pyx":353
 *                 'the connection has been closed')
 * 
 *     async def _execute(self, BaseCodec in_dc, BaseCodec out_dc, args, kwargs):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer packet
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("_execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_27generator5(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "edgedb/protocol/protocol.pyx":424
 *         return result, attrs
 * 
 *     async def _optimistic_execute(             # <<<<<<<<<<<<<<
 *         self,
 *         *,
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_26_optimistic_execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_26_optimistic_execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_query = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_reg = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_qc = 0;
  PyObject *__pyx_v_io_format = 0;
  int __pyx_v_expect_one;
  int __pyx_v_required_one;
  PyObject *__pyx_v_implicit_limit = 0;
  int __pyx_v_inline_typenames;
  int __pyx_v_inline_typeids;
  PyObject *__pyx_v_allow_capabilities = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_in_dc = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_out_dc = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_optimistic_execute (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_query,&__pyx_n_s_args,&__pyx_n_s_kwargs,&__pyx_n_s_reg,&__pyx_n_s_qc,&__pyx_n_s_io_format,&__pyx_n_s_expect_one,&__pyx_n_s_required_one,&__pyx_n_s_implicit_limit,&__pyx_n_s_inline_typenames,&__pyx_n_s_inline_typeids,&__pyx_n_s_in_dc,&__pyx_n_s_out_dc,&__pyx_n_s_allow_capabilities,0};
    PyObject* values[14] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0};

    /* "edgedb/protocol/protocol.pyx":438
 *         inline_typenames: bint,
 *         inline_typeids: bint,
 *         allow_capabilities: typing.Optional[int] = None,             # <<<<<<<<<<<<<<
 *         in_dc: BaseCodec,
 *         out_dc: BaseCodec,
 */
    values[13] = ((PyObject *)Py_None);
    if (likely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_query)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("_optimistic_execute", __pyx_n_s_query); __PYX_ERR(5, 424, __pyx_L3_error)
      }
      if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("_optimistic_execute", __pyx_n_s_args); __PYX_ERR(5, 424, __pyx_L3_error)
      }
      if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("_optimistic_execute", __pyx_n_s_kwargs); __PYX_ERR(5, 424, __pyx_L3_error)
      }
      if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reg)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("_optimistic_execute", __pyx_n_s_reg); __PYX_ERR(5, 424, __pyx_L3_error)
      }
      if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_qc)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("_optimistic_execute", __pyx_n_s_qc); __PYX_ERR(5, 424, __pyx_L3_error)
      }
      if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_io_format)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("_optimistic_execute", __pyx_n_s_io_format); __PYX_ERR(5, 424, __pyx_L3_error)
      }
      if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_expect_one)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("_optimistic_execute", __pyx_n_s_expect_one); __PYX_ERR(5, 424, __pyx_L3_error)
      }
      if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_required_one)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("_optimistic_execute", __pyx_n_s_required_one); __PYX_ERR(5, 424, __pyx_L3_error)
      }
      if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_implicit_limit)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("_optimistic_execute", __pyx_n_s_implicit_limit); __PYX_ERR(5, 424, __pyx_L3_error)
      }
      if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inline_typenames)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("_optimistic_execute", __pyx_n_s_inline_typenames); __PYX_ERR(5, 424, __pyx_L3_error)
      }
      if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inline_typeids)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("_optimistic_execute", __pyx_n_s_inline_typeids); __PYX_ERR(5, 424, __pyx_L3_error)
      }
      if (likely((values[11] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_in_dc)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("_optimistic_execute", __pyx_n_s_in_dc); __PYX_ERR(5, 424, __pyx_L3_error)
      }
      if (likely((values[12] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out_dc)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("_optimistic_execute", __pyx_n_s_out_dc); __PYX_ERR(5, 424, __pyx_L3_error)
      }
      if (kw_args == 1) {
        const Py_ssize_t index = 13;
        PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
        if (value) { values[index] = value; kw_args--; }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "_optimistic_execute") < 0)) __PYX_ERR(5, 424, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
      goto __pyx_L5_argtuple_error;
    } else {
      __Pyx_RaiseKeywordRequired("_optimistic_execute", __pyx_n_s_query); __PYX_ERR(5, 424, __pyx_L3_error)
    }
    __pyx_v_query = ((PyObject*)values[0]);
    __pyx_v_args = values[1];
    __pyx_v_kwargs = values[2];
    __pyx_v_reg = ((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)values[3]);
    __pyx_v_qc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *)values[4]);
    __pyx_v_io_format = values[5];
    __pyx_v_expect_one = __Pyx_PyObject_IsTrue(values[6]); if (unlikely((__pyx_v_expect_one == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 433, __pyx_L3_error)
    __pyx_v_required_one = __Pyx_PyObject_IsTrue(values[7]); if (unlikely((__pyx_v_required_one == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 434, __pyx_L3_error)
    __pyx_v_implicit_limit = values[8];
    __pyx_v_inline_typenames = __Pyx_PyObject_IsTrue(values[9]); if (unlikely((__pyx_v_inline_typenames == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 436, __pyx_L3_error)
    __pyx_v_inline_typeids = __Pyx_PyObject_IsTrue(values[10]); if (unlikely((__pyx_v_inline_typeids == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 437, __pyx_L3_error)
    __pyx_v_in_dc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)values[11]);
    __pyx_v_out_dc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)values[12]);
    __pyx_v_allow_capabilities = values[13];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_optimistic_execute", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 424, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol._optimistic_execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_query), (&PyUnicode_Type), 1, "query", 1))) __PYX_ERR(5, 427, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reg), __pyx_ptype_6edgedb_8protocol_8protocol_CodecsRegistry, 1, "reg", 0))) __PYX_ERR(5, 430, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_qc), __pyx_ptype_6edgedb_8protocol_8protocol_QueryCodecsCache, 1, "qc", 0))) __PYX_ERR(5, 431, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_in_dc), __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec, 1, "in_dc", 0))) __PYX_ERR(5, 439, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out_dc), __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec, 1, "out_dc", 0))) __PYX_ERR(5, 440, __pyx_L1_error)
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_25_optimistic_execute(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self), __pyx_v_query, __pyx_v_args, __pyx_v_kwargs, __pyx_v_reg, __pyx_v_qc, __pyx_v_io_format, __pyx_v_expect_one, __pyx_v_required_one, __pyx_v_implicit_limit, __pyx_v_inline_typenames, __pyx_v_inline_typeids, __pyx_v_allow_capabilities, __pyx_v_in_dc, __pyx_v_out_dc);

  /* "edgedb/protocol/protocol.pyx":424
 *         return result, attrs
 * 
 *     async def _optimistic_execute(             # <<<<<<<<<<<<<<
 *         self,
 *         *,
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_25_optimistic_execute(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_query, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_reg, struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_qc, PyObject *__pyx_v_io_format, int __pyx_v_expect_one, int __pyx_v_required_one, PyObject *__pyx_v_implicit_limit, int __pyx_v_inline_typenames, int __pyx_v_inline_typeids, PyObject *__pyx_v_allow_capabilities, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_in_dc, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_out_dc) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_optimistic_execute", 0);
  __pyx_cur_scope = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute *)__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute(__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 424, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_query = __pyx_v_query;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_query);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_query);
  __pyx_cur_scope->__pyx_v_args = __pyx_v_args;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_args);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_args);
  __pyx_cur_scope->__pyx_v_kwargs = __pyx_v_kwargs;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_kwargs);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_kwargs);
  __pyx_cur_scope->__pyx_v_reg = __pyx_v_reg;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_reg);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_reg);
  __pyx_cur_scope->__pyx_v_qc = __pyx_v_qc;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_qc);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_qc);
  __pyx_cur_scope->__pyx_v_io_format = __pyx_v_io_format;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_io_format);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_io_format);
  __pyx_cur_scope->__pyx_v_expect_one = __pyx_v_expect_one;
  __pyx_cur_scope->__pyx_v_required_one = __pyx_v_required_one;
  __pyx_cur_scope->__pyx_v_implicit_limit = __pyx_v_implicit_limit;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_implicit_limit);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_implicit_limit);
  __pyx_cur_scope->__pyx_v_inline_typenames = __pyx_v_inline_typenames;
  __pyx_cur_scope->__pyx_v_inline_typeids = __pyx_v_inline_typeids;
  __pyx_cur_scope->__pyx_v_allow_capabilities = __pyx_v_allow_capabilities;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_allow_capabilities);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_allow_capabilities);
  __pyx_cur_scope->__pyx_v_in_dc = __pyx_v_in_dc;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_in_dc);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_in_dc);
  __pyx_cur_scope->__pyx_v_out_dc = __pyx_v_out_dc;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_out_dc);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_out_dc);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_27generator5, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_optimistic_execute, __pyx_n_s_SansIOProtocol__optimistic_execu, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(5, 424, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol._optimistic_execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_27generator5(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute *__pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  uint64_t __pyx_t_3;
  int __pyx_t_4;
  uint64_t __pyx_t_5;
  char __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int32_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  int __pyx_t_14;
  enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __pyx_t_15;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  char const *__pyx_t_20;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  char const *__pyx_t_27;
  int __pyx_t_28;
  Py_ssize_t __pyx_t_29;
  Py_UCS4 __pyx_t_30;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_optimistic_execute", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L7_resume_from_await;
    case 2: goto __pyx_L47_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 424, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":448
 *             bint re_exec
 *             object result
 *             bytes new_cardinality = None             # <<<<<<<<<<<<<<
 * 
 *         buf = WriteBuffer.new_message(OPTIMISTIC_EXECUTE_MSG)
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_cur_scope->__pyx_v_new_cardinality = ((PyObject*)Py_None);

  /* "edgedb/protocol/protocol.pyx":450
 *             bytes new_cardinality = None
 * 
 *         buf = WriteBuffer.new_message(OPTIMISTIC_EXECUTE_MSG)             # <<<<<<<<<<<<<<
 *         self.write_execute_headers(
 *             buf, implicit_limit, inline_typenames, inline_typeids,
 */
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('O')); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 450, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_buf = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":452
 *         buf = WriteBuffer.new_message(OPTIMISTIC_EXECUTE_MSG)
 *         self.write_execute_headers(
 *             buf, implicit_limit, inline_typenames, inline_typeids,             # <<<<<<<<<<<<<<
 *             ALL_CAPABILITIES if allow_capabilities is None
 *             else allow_capabilities)
 */
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_cur_scope->__pyx_v_implicit_limit); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 452, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":453
 *         self.write_execute_headers(
 *             buf, implicit_limit, inline_typenames, inline_typeids,
 *             ALL_CAPABILITIES if allow_capabilities is None             # <<<<<<<<<<<<<<
 *             else allow_capabilities)
 *         buf.write_byte(io_format)
 */
  __pyx_t_4 = (__pyx_cur_scope->__pyx_v_allow_capabilities == Py_None);
  if ((__pyx_t_4 != 0)) {
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ALL_CAPABILITIES); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 453, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_As_uint64_t(__pyx_t_1); if (unlikely((__pyx_t_5 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(5, 453, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = __pyx_t_5;
  } else {

    /* "edgedb/protocol/protocol.pyx":454
 *             buf, implicit_limit, inline_typenames, inline_typeids,
 *             ALL_CAPABILITIES if allow_capabilities is None
 *             else allow_capabilities)             # <<<<<<<<<<<<<<
 *         buf.write_byte(io_format)
 *         buf.write_byte(CARDINALITY_ONE if expect_one else CARDINALITY_MANY)
 */
    __pyx_t_5 = __Pyx_PyInt_As_uint64_t(__pyx_cur_scope->__pyx_v_allow_capabilities); if (unlikely((__pyx_t_5 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(5, 454, __pyx_L1_error)
    __pyx_t_3 = __pyx_t_5;
  }

  /* "edgedb/protocol/protocol.pyx":451
 * 
 *         buf = WriteBuffer.new_message(OPTIMISTIC_EXECUTE_MSG)
 *         self.write_execute_headers(             # <<<<<<<<<<<<<<
 *             buf, implicit_limit, inline_typenames, inline_typeids,
 *             ALL_CAPABILITIES if allow_capabilities is None
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write_execute_headers(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_buf, __pyx_t_2, __pyx_cur_scope->__pyx_v_inline_typenames, __pyx_cur_scope->__pyx_v_inline_typeids, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":455
 *             ALL_CAPABILITIES if allow_capabilities is None
 *             else allow_capabilities)
 *         buf.write_byte(io_format)             # <<<<<<<<<<<<<<
 *         buf.write_byte(CARDINALITY_ONE if expect_one else CARDINALITY_MANY)
 *         buf.write_len_prefixed_utf8(query)
 */
  __pyx_t_6 = __Pyx_PyInt_As_char(__pyx_cur_scope->__pyx_v_io_format); if (unlikely((__pyx_t_6 == (char)-1) && PyErr_Occurred())) __PYX_ERR(5, 455, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_byte(__pyx_cur_scope->__pyx_v_buf, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":456
 *             else allow_capabilities)
 *         buf.write_byte(io_format)
 *         buf.write_byte(CARDINALITY_ONE if expect_one else CARDINALITY_MANY)             # <<<<<<<<<<<<<<
 *         buf.write_len_prefixed_utf8(query)
 *         buf.write_bytes(in_dc.get_tid())
 */
  if ((__pyx_cur_scope->__pyx_v_expect_one != 0)) {
    __pyx_t_6 = 'o';
  } else {
    __pyx_t_6 = 'm';
  }
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_byte(__pyx_cur_scope->__pyx_v_buf, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 456, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":457
 *         buf.write_byte(io_format)
 *         buf.write_byte(CARDINALITY_ONE if expect_one else CARDINALITY_MANY)
 *         buf.write_len_prefixed_utf8(query)             # <<<<<<<<<<<<<<
 *         buf.write_bytes(in_dc.get_tid())
 *         buf.write_bytes(out_dc.get_tid())
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_write_len_prefixed_utf8(__pyx_cur_scope->__pyx_v_buf, __pyx_cur_scope->__pyx_v_query); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":458
 *         buf.write_byte(CARDINALITY_ONE if expect_one else CARDINALITY_MANY)
 *         buf.write_len_prefixed_utf8(query)
 *         buf.write_bytes(in_dc.get_tid())             # <<<<<<<<<<<<<<
 *         buf.write_bytes(out_dc.get_tid())
 *         self.encode_args(in_dc, buf, args, kwargs)
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_9BaseCodec_get_tid(__pyx_cur_scope->__pyx_v_in_dc); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_bytes(__pyx_cur_scope->__pyx_v_buf, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "edgedb/protocol/protocol.pyx":459
 *         buf.write_len_prefixed_utf8(query)
 *         buf.write_bytes(in_dc.get_tid())
 *         buf.write_bytes(out_dc.get_tid())             # <<<<<<<<<<<<<<
 *         self.encode_args(in_dc, buf, args, kwargs)
 *         buf.end_message()
 */
  __pyx_t_7 = __pyx_f_6edgedb_8protocol_8protocol_9BaseCodec_get_tid(__pyx_cur_scope->__pyx_v_out_dc); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_bytes(__pyx_cur_scope->__pyx_v_buf, ((PyObject*)__pyx_t_7)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":460
 *         buf.write_bytes(in_dc.get_tid())
 *         buf.write_bytes(out_dc.get_tid())
 *         self.encode_args(in_dc, buf, args, kwargs)             # <<<<<<<<<<<<<<
 *         buf.end_message()
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->encode_args(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_in_dc, __pyx_cur_scope->__pyx_v_buf, __pyx_cur_scope->__pyx_v_args, __pyx_cur_scope->__pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 460, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":461
 *         buf.write_bytes(out_dc.get_tid())
 *         self.encode_args(in_dc, buf, args, kwargs)
 *         buf.end_message()             # <<<<<<<<<<<<<<
 * 
 *         packet = WriteBuffer.new()
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->end_message(__pyx_cur_scope->__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 461, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":463
 *         buf.end_message()
 * 
 *         packet = WriteBuffer.new()             # <<<<<<<<<<<<<<
 *         packet.write_buffer(buf)
 *         packet.write_bytes(SYNC_MESSAGE)
 */
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_packet = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":464
 * 
 *         packet = WriteBuffer.new()
 *         packet.write_buffer(buf)             # <<<<<<<<<<<<<<
 *         packet.write_bytes(SYNC_MESSAGE)
 *         self.write(packet)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_packet->__pyx_vtab)->write_buffer(__pyx_cur_scope->__pyx_v_packet, __pyx_cur_scope->__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":465
 *         packet = WriteBuffer.new()
 *         packet.write_buffer(buf)
 *         packet.write_bytes(SYNC_MESSAGE)             # <<<<<<<<<<<<<<
 *         self.write(packet)
 * 
 */
  __pyx_t_1 = __pyx_v_6edgedb_8protocol_8protocol_SYNC_MESSAGE;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_7 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_packet->__pyx_vtab)->write_bytes(__pyx_cur_scope->__pyx_v_packet, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 465, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "edgedb/protocol/protocol.pyx":466
 *         packet.write_buffer(buf)
 *         packet.write_bytes(SYNC_MESSAGE)
 *         self.write(packet)             # <<<<<<<<<<<<<<
 * 
 *         result = datatypes.set_new(0)
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_packet); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 466, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "edgedb/protocol/protocol.pyx":468
 *         self.write(packet)
 * 
 *         result = datatypes.set_new(0)             # <<<<<<<<<<<<<<
 *         attrs = None
 *         re_exec = False
 */
  __pyx_t_7 = __pyx_f_6edgedb_9datatypes_9datatypes_set_new(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_cur_scope->__pyx_v_result = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "edgedb/protocol/protocol.pyx":469
 * 
 *         result = datatypes.set_new(0)
 *         attrs = None             # <<<<<<<<<<<<<<
 *         re_exec = False
 *         exc = None
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_cur_scope->__pyx_v_attrs = Py_None;

  /* "edgedb/protocol/protocol.pyx":470
 *         result = datatypes.set_new(0)
 *         attrs = None
 *         re_exec = False             # <<<<<<<<<<<<<<
 *         exc = None
 *         while True:
 */
  __pyx_cur_scope->__pyx_v_re_exec = 0;

  /* "edgedb/protocol/protocol.pyx":471
 *         attrs = None
 *         re_exec = False
 *         exc = None             # <<<<<<<<<<<<<<
 *         while True:
 *             if not self.buffer.take_message():
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_cur_scope->__pyx_v_exc = Py_None;

  /* "edgedb/protocol/protocol.pyx":472
 *         re_exec = False
 *         exc = None
 *         while True:             # <<<<<<<<<<<<<<
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 */
  while (1) {

    /* "edgedb/protocol/protocol.pyx":473
 *         exc = None
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    __pyx_t_8 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_8 == ((int32_t)-1))) __PYX_ERR(5, 473, __pyx_L1_error)
    __pyx_t_4 = ((!(__pyx_t_8 != 0)) != 0);
    if (__pyx_t_4) {

      /* "edgedb/protocol/protocol.pyx":474
 *         while True:
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()             # <<<<<<<<<<<<<<
 *             mtype = self.buffer.get_message_type()
 * 
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_wait_for_message); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 474, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 474, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XGOTREF(__pyx_r);
      if (likely(__pyx_r)) {
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L7_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 474, __pyx_L1_error)
      } else {
        PyObject* exc_type = __Pyx_PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
          else __PYX_ERR(5, 474, __pyx_L1_error)
        }
      }

      /* "edgedb/protocol/protocol.pyx":473
 *         exc = None
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    }

    /* "edgedb/protocol/protocol.pyx":475
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()             # <<<<<<<<<<<<<<
 * 
 *             try:
 */
    __pyx_cur_scope->__pyx_v_mtype = __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_cur_scope->__pyx_v_self->buffer);

    /* "edgedb/protocol/protocol.pyx":477
 *             mtype = self.buffer.get_message_type()
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 if mtype == STMT_DATA_DESC_MSG:
 *                     # our in/out type spec is out-dated
 */
    /*try:*/ {

      /* "edgedb/protocol/protocol.pyx":478
 * 
 *             try:
 *                 if mtype == STMT_DATA_DESC_MSG:             # <<<<<<<<<<<<<<
 *                     # our in/out type spec is out-dated
 *                     new_cardinality, in_dc, out_dc, headers = \
 */
      switch (__pyx_cur_scope->__pyx_v_mtype) {
        case 'T':

        /* "edgedb/protocol/protocol.pyx":481
 *                     # our in/out type spec is out-dated
 *                     new_cardinality, in_dc, out_dc, headers = \
 *                         self.parse_describe_type_message(reg)             # <<<<<<<<<<<<<<
 * 
 *                     capabilities = headers.get(SERVER_HEADER_CAPABILITIES)
 */
        __pyx_t_7 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_describe_type_message(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_reg); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 481, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_7);
        if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) {
          PyObject* sequence = __pyx_t_7;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 4)) {
            if (size > 4) __Pyx_RaiseTooManyValuesError(4);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(5, 480, __pyx_L11_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); 
            __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); 
            __pyx_t_11 = PyTuple_GET_ITEM(sequence, 3); 
          } else {
            __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_9 = PyList_GET_ITEM(sequence, 1); 
            __pyx_t_10 = PyList_GET_ITEM(sequence, 2); 
            __pyx_t_11 = PyList_GET_ITEM(sequence, 3); 
          }
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_11);
          #else
          {
            Py_ssize_t i;
            PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_9,&__pyx_t_10,&__pyx_t_11};
            for (i=0; i < 4; i++) {
              PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(5, 480, __pyx_L11_error)
              __Pyx_GOTREF(item);
              *(temps[i]) = item;
            }
          }
          #endif
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        } else {
          Py_ssize_t index = -1;
          PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_9,&__pyx_t_10,&__pyx_t_11};
          __pyx_t_12 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 480, __pyx_L11_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
          for (index=0; index < 4; index++) {
            PyObject* item = __pyx_t_13(__pyx_t_12); if (unlikely(!item)) goto __pyx_L13_unpacking_failed;
            __Pyx_GOTREF(item);
            *(temps[index]) = item;
          }
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 4) < 0) __PYX_ERR(5, 480, __pyx_L11_error)
          __pyx_t_13 = NULL;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          goto __pyx_L14_unpacking_done;
          __pyx_L13_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_13 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(5, 480, __pyx_L11_error)
          __pyx_L14_unpacking_done:;
        }

        /* "edgedb/protocol/protocol.pyx":480
 *                 if mtype == STMT_DATA_DESC_MSG:
 *                     # our in/out type spec is out-dated
 *                     new_cardinality, in_dc, out_dc, headers = \             # <<<<<<<<<<<<<<
 *                         self.parse_describe_type_message(reg)
 * 
 */
        if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(5, 480, __pyx_L11_error)
        if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec))))) __PYX_ERR(5, 480, __pyx_L11_error)
        if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec))))) __PYX_ERR(5, 480, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_new_cardinality);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_new_cardinality, ((PyObject*)__pyx_t_1));
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_1 = 0;
        __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_in_dc));
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_in_dc, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_9));
        __Pyx_GIVEREF(__pyx_t_9);
        __pyx_t_9 = 0;
        __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_out_dc));
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_out_dc, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_10));
        __Pyx_GIVEREF(__pyx_t_10);
        __pyx_t_10 = 0;
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_headers);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_headers, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_11);
        __pyx_t_11 = 0;

        /* "edgedb/protocol/protocol.pyx":483
 *                         self.parse_describe_type_message(reg)
 * 
 *                     capabilities = headers.get(SERVER_HEADER_CAPABILITIES)             # <<<<<<<<<<<<<<
 *                     if capabilities is not None:
 *                         capabilities = int.from_bytes(capabilities, 'big')
 */
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_headers, __pyx_n_s_get); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 483, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_10 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_11, function);
          }
        }
        __pyx_t_7 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_10, __pyx_int_4097) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_int_4097);
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 483, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_capabilities);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_capabilities, __pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_7);
        __pyx_t_7 = 0;

        /* "edgedb/protocol/protocol.pyx":484
 * 
 *                     capabilities = headers.get(SERVER_HEADER_CAPABILITIES)
 *                     if capabilities is not None:             # <<<<<<<<<<<<<<
 *                         capabilities = int.from_bytes(capabilities, 'big')
 * 
 */
        __pyx_t_4 = (__pyx_cur_scope->__pyx_v_capabilities != Py_None);
        __pyx_t_14 = (__pyx_t_4 != 0);
        if (__pyx_t_14) {

          /* "edgedb/protocol/protocol.pyx":485
 *                     capabilities = headers.get(SERVER_HEADER_CAPABILITIES)
 *                     if capabilities is not None:
 *                         capabilities = int.from_bytes(capabilities, 'big')             # <<<<<<<<<<<<<<
 * 
 *                     qc.set(
 */
          __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyInt_Type)), __pyx_n_s_from_bytes); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 485, __pyx_L11_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_10 = NULL;
          __pyx_t_2 = 0;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
            __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
            if (likely(__pyx_t_10)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
              __Pyx_INCREF(__pyx_t_10);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_11, function);
              __pyx_t_2 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_cur_scope->__pyx_v_capabilities, __pyx_n_u_big};
            __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 485, __pyx_L11_error)
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_GOTREF(__pyx_t_7);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_cur_scope->__pyx_v_capabilities, __pyx_n_u_big};
            __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 485, __pyx_L11_error)
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_GOTREF(__pyx_t_7);
          } else
          #endif
          {
            __pyx_t_9 = PyTuple_New(2+__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 485, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_9);
            if (__pyx_t_10) {
              __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
            }
            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_capabilities);
            __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_capabilities);
            PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_2, __pyx_cur_scope->__pyx_v_capabilities);
            __Pyx_INCREF(__pyx_n_u_big);
            __Pyx_GIVEREF(__pyx_n_u_big);
            PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_2, __pyx_n_u_big);
            __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_9, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 485, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_capabilities);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_capabilities, __pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_7);
          __pyx_t_7 = 0;

          /* "edgedb/protocol/protocol.pyx":484
 * 
 *                     capabilities = headers.get(SERVER_HEADER_CAPABILITIES)
 *                     if capabilities is not None:             # <<<<<<<<<<<<<<
 *                         capabilities = int.from_bytes(capabilities, 'big')
 * 
 */
        }

        /* "edgedb/protocol/protocol.pyx":489
 *                     qc.set(
 *                         query,
 *                         io_format,             # <<<<<<<<<<<<<<
 *                         implicit_limit,
 *                         inline_typenames,
 */
        __pyx_t_15 = ((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)__Pyx_PyInt_As_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_cur_scope->__pyx_v_io_format)); if (unlikely(PyErr_Occurred())) __PYX_ERR(5, 489, __pyx_L11_error)

        /* "edgedb/protocol/protocol.pyx":490
 *                         query,
 *                         io_format,
 *                         implicit_limit,             # <<<<<<<<<<<<<<
 *                         inline_typenames,
 *                         inline_typeids,
 */
        __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_cur_scope->__pyx_v_implicit_limit); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 490, __pyx_L11_error)

        /* "edgedb/protocol/protocol.pyx":494
 *                         inline_typeids,
 *                         expect_one,
 *                         new_cardinality == CARDINALITY_NOT_APPLICABLE,             # <<<<<<<<<<<<<<
 *                         in_dc, out_dc, capabilities)
 *                     re_exec = True
 */
        __pyx_t_14 = (__Pyx_PyBytes_Equals(__pyx_cur_scope->__pyx_v_new_cardinality, __pyx_n_b_n, Py_EQ)); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(5, 494, __pyx_L11_error)

        /* "edgedb/protocol/protocol.pyx":495
 *                         expect_one,
 *                         new_cardinality == CARDINALITY_NOT_APPLICABLE,
 *                         in_dc, out_dc, capabilities)             # <<<<<<<<<<<<<<
 *                     re_exec = True
 * 
 */
        __pyx_t_16 = __Pyx_PyInt_As_int(__pyx_cur_scope->__pyx_v_capabilities); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 495, __pyx_L11_error)

        /* "edgedb/protocol/protocol.pyx":487
 *                         capabilities = int.from_bytes(capabilities, 'big')
 * 
 *                     qc.set(             # <<<<<<<<<<<<<<
 *                         query,
 *                         io_format,
 */
        __pyx_t_7 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_QueryCodecsCache *)__pyx_cur_scope->__pyx_v_qc->__pyx_vtab)->set(__pyx_cur_scope->__pyx_v_qc, __pyx_cur_scope->__pyx_v_query, __pyx_t_15, __pyx_t_2, __pyx_cur_scope->__pyx_v_inline_typenames, __pyx_cur_scope->__pyx_v_inline_typeids, __pyx_cur_scope->__pyx_v_expect_one, __pyx_t_14, __pyx_cur_scope->__pyx_v_in_dc, __pyx_cur_scope->__pyx_v_out_dc, __pyx_t_16); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 487, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "edgedb/protocol/protocol.pyx":496
 *                         new_cardinality == CARDINALITY_NOT_APPLICABLE,
 *                         in_dc, out_dc, capabilities)
 *                     re_exec = True             # <<<<<<<<<<<<<<
 * 
 *                 elif mtype == DATA_MSG:
 */
        __pyx_cur_scope->__pyx_v_re_exec = 1;

        /* "edgedb/protocol/protocol.pyx":478
 * 
 *             try:
 *                 if mtype == STMT_DATA_DESC_MSG:             # <<<<<<<<<<<<<<
 *                     # our in/out type spec is out-dated
 *                     new_cardinality, in_dc, out_dc, headers = \
 */
        break;
        case 'D':

        /* "edgedb/protocol/protocol.pyx":499
 * 
 *                 elif mtype == DATA_MSG:
 *                     assert not re_exec             # <<<<<<<<<<<<<<
 *                     if exc is None:
 *                         try:
 */
        #ifndef CYTHON_WITHOUT_ASSERTIONS
        if (unlikely(!Py_OptimizeFlag)) {
          if (unlikely(!((!(__pyx_cur_scope->__pyx_v_re_exec != 0)) != 0))) {
            PyErr_SetNone(PyExc_AssertionError);
            __PYX_ERR(5, 499, __pyx_L11_error)
          }
        }
        #endif

        /* "edgedb/protocol/protocol.pyx":500
 *                 elif mtype == DATA_MSG:
 *                     assert not re_exec
 *                     if exc is None:             # <<<<<<<<<<<<<<
 *                         try:
 *                             self.parse_data_messages(out_dc, result)
 */
        __pyx_t_14 = (__pyx_cur_scope->__pyx_v_exc == Py_None);
        __pyx_t_4 = (__pyx_t_14 != 0);
        if (__pyx_t_4) {

          /* "edgedb/protocol/protocol.pyx":501
 *                     assert not re_exec
 *                     if exc is None:
 *                         try:             # <<<<<<<<<<<<<<
 *                             self.parse_data_messages(out_dc, result)
 *                         except Exception as ex:
 */
          {
            __Pyx_ExceptionSave(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
            __Pyx_XGOTREF(__pyx_t_17);
            __Pyx_XGOTREF(__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_19);
            /*try:*/ {

              /* "edgedb/protocol/protocol.pyx":502
 *                     if exc is None:
 *                         try:
 *                             self.parse_data_messages(out_dc, result)             # <<<<<<<<<<<<<<
 *                         except Exception as ex:
 *                             # An error during data decoding.  We need to
 */
              __pyx_t_7 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_data_messages(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_out_dc, __pyx_cur_scope->__pyx_v_result); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 502, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

              /* "edgedb/protocol/protocol.pyx":501
 *                     assert not re_exec
 *                     if exc is None:
 *                         try:             # <<<<<<<<<<<<<<
 *                             self.parse_data_messages(out_dc, result)
 *                         except Exception as ex:
 */
            }
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            goto __pyx_L24_try_end;
            __pyx_L17_error:;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

            /* "edgedb/protocol/protocol.pyx":503
 *                         try:
 *                             self.parse_data_messages(out_dc, result)
 *                         except Exception as ex:             # <<<<<<<<<<<<<<
 *                             # An error during data decoding.  We need to
 *                             # handle this as gracefully as possible:
 */
            __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
            if (__pyx_t_16) {
              __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol._optimistic_execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_11, &__pyx_t_9) < 0) __PYX_ERR(5, 503, __pyx_L19_except_error)
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_GOTREF(__pyx_t_11);
              __Pyx_GOTREF(__pyx_t_9);
              __Pyx_INCREF(__pyx_t_11);
              __Pyx_GIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_v_ex = __pyx_t_11;
              /*try:*/ {

                /* "edgedb/protocol/protocol.pyx":509
 *                             #   received;
 *                             # * ignore all 'D' messages for this query.
 *                             exc = errors.ClientError(             # <<<<<<<<<<<<<<
 *                                 'unable to decode data to Python objects')
 *                             exc.__cause__ = ex
 */
                __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_errors); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 509, __pyx_L30_error)
                __Pyx_GOTREF(__pyx_t_1);
                __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ClientError); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 509, __pyx_L30_error)
                __Pyx_GOTREF(__pyx_t_12);
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                __pyx_t_1 = NULL;
                if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
                  __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_12);
                  if (likely(__pyx_t_1)) {
                    PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
                    __Pyx_INCREF(__pyx_t_1);
                    __Pyx_INCREF(function);
                    __Pyx_DECREF_SET(__pyx_t_12, function);
                  }
                }
                __pyx_t_10 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_1, __pyx_kp_u_unable_to_decode_data_to_Python) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_kp_u_unable_to_decode_data_to_Python);
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                if (unlikely(!__pyx_t_10)) __PYX_ERR(5, 509, __pyx_L30_error)
                __Pyx_GOTREF(__pyx_t_10);
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_exc);
                __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_exc, __pyx_t_10);
                __Pyx_GIVEREF(__pyx_t_10);
                __pyx_t_10 = 0;

                /* "edgedb/protocol/protocol.pyx":511
 *                             exc = errors.ClientError(
 *                                 'unable to decode data to Python objects')
 *                             exc.__cause__ = ex             # <<<<<<<<<<<<<<
 *                             # Take care of a partially consumed 'D' message
 *                             # and the ones yet unparsed.
 */
                if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_exc, __pyx_n_s_cause, __pyx_cur_scope->__pyx_v_ex) < 0) __PYX_ERR(5, 511, __pyx_L30_error)

                /* "edgedb/protocol/protocol.pyx":514
 *                             # Take care of a partially consumed 'D' message
 *                             # and the ones yet unparsed.
 *                             while self.buffer.take_message_type(DATA_MSG):             # <<<<<<<<<<<<<<
 *                                 self.buffer.discard_message()
 *                     else:
 */
                while (1) {
                  __pyx_t_8 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message_type(__pyx_cur_scope->__pyx_v_self->buffer, 'D'); if (unlikely(__pyx_t_8 == ((int32_t)-1))) __PYX_ERR(5, 514, __pyx_L30_error)
                  __pyx_t_4 = (__pyx_t_8 != 0);
                  if (!__pyx_t_4) break;

                  /* "edgedb/protocol/protocol.pyx":515
 *                             # and the ones yet unparsed.
 *                             while self.buffer.take_message_type(DATA_MSG):
 *                                 self.buffer.discard_message()             # <<<<<<<<<<<<<<
 *                     else:
 *                         self.buffer.discard_message()
 */
                  __pyx_t_10 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->discard_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_10)) __PYX_ERR(5, 515, __pyx_L30_error)
                  __Pyx_GOTREF(__pyx_t_10);
                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                }
              }

              /* "edgedb/protocol/protocol.pyx":503
 *                         try:
 *                             self.parse_data_messages(out_dc, result)
 *                         except Exception as ex:             # <<<<<<<<<<<<<<
 *                             # An error during data decoding.  We need to
 *                             # handle this as gracefully as possible:
 */
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
                  __pyx_cur_scope->__pyx_v_ex = NULL;
                  goto __pyx_L31;
                }
                __pyx_L30_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                  if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26);
                  if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
                  __Pyx_XGOTREF(__pyx_t_21);
                  __Pyx_XGOTREF(__pyx_t_22);
                  __Pyx_XGOTREF(__pyx_t_23);
                  __Pyx_XGOTREF(__pyx_t_24);
                  __Pyx_XGOTREF(__pyx_t_25);
                  __Pyx_XGOTREF(__pyx_t_26);
                  __pyx_t_16 = __pyx_lineno; __pyx_t_2 = __pyx_clineno; __pyx_t_20 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ex);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_ex);
                    __pyx_cur_scope->__pyx_v_ex = NULL;
                  }
                  if (PY_MAJOR_VERSION >= 3) {
                    __Pyx_XGIVEREF(__pyx_t_24);
                    __Pyx_XGIVEREF(__pyx_t_25);
                    __Pyx_XGIVEREF(__pyx_t_26);
                    __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26);
                  }
                  __Pyx_XGIVEREF(__pyx_t_21);
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __Pyx_ErrRestore(__pyx_t_21, __pyx_t_22, __pyx_t_23);
                  __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
                  __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_2; __pyx_filename = __pyx_t_20;
                  goto __pyx_L19_except_error;
                }
                __pyx_L31:;
              }
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
              __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
              goto __pyx_L18_exception_handled;
            }
            goto __pyx_L19_except_error;
            __pyx_L19_except_error:;

            /* "edgedb/protocol/protocol.pyx":501
 *                     assert not re_exec
 *                     if exc is None:
 *                         try:             # <<<<<<<<<<<<<<
 *                             self.parse_data_messages(out_dc, result)
 *                         except Exception as ex:
 */
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
            goto __pyx_L11_error;
            __pyx_L18_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
            __pyx_L24_try_end:;
          }

          /* "edgedb/protocol/protocol.pyx":500
 *                 elif mtype == DATA_MSG:
 *                     assert not re_exec
 *                     if exc is None:             # <<<<<<<<<<<<<<
 *                         try:
 *                             self.parse_data_messages(out_dc, result)
 */
          goto __pyx_L16;
        }

        /* "edgedb/protocol/protocol.pyx":517
 *                                 self.buffer.discard_message()
 *                     else:
 *                         self.buffer.discard_message()             # <<<<<<<<<<<<<<
 * 
 *                 elif mtype == COMMAND_COMPLETE_MSG:
 */
        /*else*/ {
          __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->discard_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 517, __pyx_L11_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        __pyx_L16:;

        /* "edgedb/protocol/protocol.pyx":498
 *                     re_exec = True
 * 
 *                 elif mtype == DATA_MSG:             # <<<<<<<<<<<<<<
 *                     assert not re_exec
 *                     if exc is None:
 */
        break;
        case 'C':

        /* "edgedb/protocol/protocol.pyx":520
 * 
 *                 elif mtype == COMMAND_COMPLETE_MSG:
 *                     attrs = self.parse_command_complete_message()             # <<<<<<<<<<<<<<
 * 
 *                 elif mtype == ERROR_RESPONSE_MSG:
 */
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_command_complete_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 520, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_attrs);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_attrs, __pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_9);
        __pyx_t_9 = 0;

        /* "edgedb/protocol/protocol.pyx":519
 *                         self.buffer.discard_message()
 * 
 *                 elif mtype == COMMAND_COMPLETE_MSG:             # <<<<<<<<<<<<<<
 *                     attrs = self.parse_command_complete_message()
 * 
 */
        break;
        case 'E':

        /* "edgedb/protocol/protocol.pyx":523
 * 
 *                 elif mtype == ERROR_RESPONSE_MSG:
 *                     exc = self.parse_error_message()             # <<<<<<<<<<<<<<
 *                     exc = self._amend_parse_error(
 *                         exc, io_format, expect_one, required_one)
 */
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_error_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 523, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_exc);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_exc, __pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_9);
        __pyx_t_9 = 0;

        /* "edgedb/protocol/protocol.pyx":525
 *                     exc = self.parse_error_message()
 *                     exc = self._amend_parse_error(
 *                         exc, io_format, expect_one, required_one)             # <<<<<<<<<<<<<<
 * 
 *                 elif mtype == READY_FOR_COMMAND_MSG:
 */
        __pyx_t_15 = ((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)__Pyx_PyInt_As_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_cur_scope->__pyx_v_io_format)); if (unlikely(PyErr_Occurred())) __PYX_ERR(5, 525, __pyx_L11_error)

        /* "edgedb/protocol/protocol.pyx":524
 *                 elif mtype == ERROR_RESPONSE_MSG:
 *                     exc = self.parse_error_message()
 *                     exc = self._amend_parse_error(             # <<<<<<<<<<<<<<
 *                         exc, io_format, expect_one, required_one)
 * 
 */
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->_amend_parse_error(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_exc, __pyx_t_15, __pyx_cur_scope->__pyx_v_expect_one, __pyx_cur_scope->__pyx_v_required_one); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 524, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_exc);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_exc, __pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_9);
        __pyx_t_9 = 0;

        /* "edgedb/protocol/protocol.pyx":522
 *                     attrs = self.parse_command_complete_message()
 * 
 *                 elif mtype == ERROR_RESPONSE_MSG:             # <<<<<<<<<<<<<<
 *                     exc = self.parse_error_message()
 *                     exc = self._amend_parse_error(
 */
        break;
        case 'Z':

        /* "edgedb/protocol/protocol.pyx":528
 * 
 *                 elif mtype == READY_FOR_COMMAND_MSG:
 *                     self.parse_sync_message()             # <<<<<<<<<<<<<<
 *                     break
 * 
 */
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_sync_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 528, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

        /* "edgedb/protocol/protocol.pyx":529
 *                 elif mtype == READY_FOR_COMMAND_MSG:
 *                     self.parse_sync_message()
 *                     break             # <<<<<<<<<<<<<<
 * 
 *                 else:
 */
        goto __pyx_L9_break;

        /* "edgedb/protocol/protocol.pyx":527
 *                         exc, io_format, expect_one, required_one)
 * 
 *                 elif mtype == READY_FOR_COMMAND_MSG:             # <<<<<<<<<<<<<<
 *                     self.parse_sync_message()
 *                     break
 */
        break;
        default:

        /* "edgedb/protocol/protocol.pyx":532
 * 
 *                 else:
 *                     self.fallthrough()             # <<<<<<<<<<<<<<
 * 
 *             finally:
 */
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->fallthrough(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 532, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        break;
      }
    }

    /* "edgedb/protocol/protocol.pyx":535
 * 
 *             finally:
 *                 self.buffer.finish_message()             # <<<<<<<<<<<<<<
 * 
 *         if exc is not None:
 */
    /*finally:*/ {
      /*normal exit:*/{
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 535, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L12;
      }
      __pyx_L11_error:;
      /*exception exit:*/{
        __Pyx_PyThreadState_assign
        __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_26, &__pyx_t_25, &__pyx_t_24);
        if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
        __Pyx_XGOTREF(__pyx_t_19);
        __Pyx_XGOTREF(__pyx_t_18);
        __Pyx_XGOTREF(__pyx_t_17);
        __Pyx_XGOTREF(__pyx_t_26);
        __Pyx_XGOTREF(__pyx_t_25);
        __Pyx_XGOTREF(__pyx_t_24);
        __pyx_t_2 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_27 = __pyx_filename;
        {
          __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 535, __pyx_L41_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_26);
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_25, __pyx_t_24);
        }
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_XGIVEREF(__pyx_t_18);
        __Pyx_XGIVEREF(__pyx_t_17);
        __Pyx_ErrRestore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
        __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0;
        __pyx_lineno = __pyx_t_2; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_27;
        goto __pyx_L1_error;
        __pyx_L41_error:;
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_26);
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_25, __pyx_t_24);
        }
        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0;
        goto __pyx_L1_error;
      }
      __pyx_L9_break: {
        __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 535, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L5_break;
      }
      __pyx_L12:;
    }
  }
  __pyx_L5_break:;

  /* "edgedb/protocol/protocol.pyx":537
 *                 self.buffer.finish_message()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             raise exc
 * 
 */
  __pyx_t_4 = (__pyx_cur_scope->__pyx_v_exc != Py_None);
  __pyx_t_14 = (__pyx_t_4 != 0);
  if (unlikely(__pyx_t_14)) {

    /* "edgedb/protocol/protocol.pyx":538
 * 
 *         if exc is not None:
 *             raise exc             # <<<<<<<<<<<<<<
 * 
 *         if re_exec:
 */
    __Pyx_Raise(__pyx_cur_scope->__pyx_v_exc, 0, 0, 0);
    __PYX_ERR(5, 538, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":537
 *                 self.buffer.finish_message()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             raise exc
 * 
 */
  }

  /* "edgedb/protocol/protocol.pyx":540
 *             raise exc
 * 
 *         if re_exec:             # <<<<<<<<<<<<<<
 *             assert new_cardinality is not None
 *             if required_one and new_cardinality == CARDINALITY_NOT_APPLICABLE:
 */
  __pyx_t_14 = (__pyx_cur_scope->__pyx_v_re_exec != 0);
  if (__pyx_t_14) {

    /* "edgedb/protocol/protocol.pyx":541
 * 
 *         if re_exec:
 *             assert new_cardinality is not None             # <<<<<<<<<<<<<<
 *             if required_one and new_cardinality == CARDINALITY_NOT_APPLICABLE:
 *                 methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_14 = (__pyx_cur_scope->__pyx_v_new_cardinality != ((PyObject*)Py_None));
      if (unlikely(!(__pyx_t_14 != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(5, 541, __pyx_L1_error)
      }
    }
    #endif

    /* "edgedb/protocol/protocol.pyx":542
 *         if re_exec:
 *             assert new_cardinality is not None
 *             if required_one and new_cardinality == CARDINALITY_NOT_APPLICABLE:             # <<<<<<<<<<<<<<
 *                 methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *                 raise errors.InterfaceError(
 */
    __pyx_t_4 = (__pyx_cur_scope->__pyx_v_required_one != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_14 = __pyx_t_4;
      goto __pyx_L45_bool_binop_done;
    }
    __pyx_t_4 = (__Pyx_PyBytes_Equals(__pyx_cur_scope->__pyx_v_new_cardinality, __pyx_n_b_n, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(5, 542, __pyx_L1_error)
    __pyx_t_28 = (__pyx_t_4 != 0);
    __pyx_t_14 = __pyx_t_28;
    __pyx_L45_bool_binop_done:;
    if (unlikely(__pyx_t_14)) {

      /* "edgedb/protocol/protocol.pyx":543
 *             assert new_cardinality is not None
 *             if required_one and new_cardinality == CARDINALITY_NOT_APPLICABLE:
 *                 methname = _QUERY_SINGLE_METHOD[required_one][io_format]             # <<<<<<<<<<<<<<
 *                 raise errors.InterfaceError(
 *                     f'query cannot be executed with {methname}() as it '
 */
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_QUERY_SINGLE_METHOD); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 543, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_11 = __Pyx_GetItemInt(__pyx_t_9, __pyx_cur_scope->__pyx_v_required_one, int, 1, __Pyx_PyBool_FromLong, 0, 1, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 543, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_t_11, __pyx_cur_scope->__pyx_v_io_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 543, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GIVEREF(__pyx_t_9);
      __pyx_cur_scope->__pyx_v_methname = __pyx_t_9;
      __pyx_t_9 = 0;

      /* "edgedb/protocol/protocol.pyx":544
 *             if required_one and new_cardinality == CARDINALITY_NOT_APPLICABLE:
 *                 methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *                 raise errors.InterfaceError(             # <<<<<<<<<<<<<<
 *                     f'query cannot be executed with {methname}() as it '
 *                     f'does not return any data')
 */
      __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_errors); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 544, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_InterfaceError); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 544, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

      /* "edgedb/protocol/protocol.pyx":545
 *                 methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *                 raise errors.InterfaceError(
 *                     f'query cannot be executed with {methname}() as it '             # <<<<<<<<<<<<<<
 *                     f'does not return any data')
 *             return await self._execute(in_dc, out_dc, args, kwargs)
 */
      __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 545, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_29 = 0;
      __pyx_t_30 = 127;
      __Pyx_INCREF(__pyx_kp_u_query_cannot_be_executed_with);
      __pyx_t_29 += 30;
      __Pyx_GIVEREF(__pyx_kp_u_query_cannot_be_executed_with);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_kp_u_query_cannot_be_executed_with);
      __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_methname, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(5, 545, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_30 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_30) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_30;
      __pyx_t_29 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10);
      __pyx_t_10 = 0;
      __Pyx_INCREF(__pyx_kp_u_as_it_does_not_return_any_data);
      __pyx_t_29 += 33;
      __Pyx_GIVEREF(__pyx_kp_u_as_it_does_not_return_any_data);
      PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_kp_u_as_it_does_not_return_any_data);
      __pyx_t_10 = __Pyx_PyUnicode_Join(__pyx_t_11, 3, __pyx_t_29, __pyx_t_30); if (unlikely(!__pyx_t_10)) __PYX_ERR(5, 545, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      __pyx_t_9 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_11, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_10);
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 544, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(5, 544, __pyx_L1_error)

      /* "edgedb/protocol/protocol.pyx":542
 *         if re_exec:
 *             assert new_cardinality is not None
 *             if required_one and new_cardinality == CARDINALITY_NOT_APPLICABLE:             # <<<<<<<<<<<<<<
 *                 methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *                 raise errors.InterfaceError(
 */
    }

    /* "edgedb/protocol/protocol.pyx":547
 *                     f'query cannot be executed with {methname}() as it '
 *                     f'does not return any data')
 *             return await self._execute(in_dc, out_dc, args, kwargs)             # <<<<<<<<<<<<<<
 *         else:
 *             return result, attrs
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_execute); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 547, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_10 = NULL;
    __pyx_t_16 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
        __pyx_t_16 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[5] = {__pyx_t_10, ((PyObject *)__pyx_cur_scope->__pyx_v_in_dc), ((PyObject *)__pyx_cur_scope->__pyx_v_out_dc), __pyx_cur_scope->__pyx_v_args, __pyx_cur_scope->__pyx_v_kwargs};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_16, 4+__pyx_t_16); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 547, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_9);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[5] = {__pyx_t_10, ((PyObject *)__pyx_cur_scope->__pyx_v_in_dc), ((PyObject *)__pyx_cur_scope->__pyx_v_out_dc), __pyx_cur_scope->__pyx_v_args, __pyx_cur_scope->__pyx_v_kwargs};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_16, 4+__pyx_t_16); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 547, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_9);
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(4+__pyx_t_16); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 547, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_in_dc));
      __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_in_dc));
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_16, ((PyObject *)__pyx_cur_scope->__pyx_v_in_dc));
      __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_out_dc));
      __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_out_dc));
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_16, ((PyObject *)__pyx_cur_scope->__pyx_v_out_dc));
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_args);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_args);
      PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_16, __pyx_cur_scope->__pyx_v_args);
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_kwargs);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_kwargs);
      PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_16, __pyx_cur_scope->__pyx_v_kwargs);
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 547, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_9);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XGOTREF(__pyx_r);
    if (likely(__pyx_r)) {
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L47_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 547, __pyx_L1_error)
      __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
    } else {
      __pyx_t_9 = NULL;
      if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_9) < 0) __PYX_ERR(5, 547, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
    }
    __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L0;

    /* "edgedb/protocol/protocol.pyx":540
 *             raise exc
 * 
 *         if re_exec:             # <<<<<<<<<<<<<<
 *             assert new_cardinality is not None
 *             if required_one and new_cardinality == CARDINALITY_NOT_APPLICABLE:
 */
  }

  /* "edgedb/protocol/protocol.pyx":549
 *             return await self._execute(in_dc, out_dc, args, kwargs)
 *         else:
 *             return result, attrs             # <<<<<<<<<<<<<<
 * 
 *     async def simple_query(self, str query, capabilities: enums.Capability):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 549, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_result);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_result);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_cur_scope->__pyx_v_result);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_attrs);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_attrs);
    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_cur_scope->__pyx_v_attrs);
    __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "edgedb/protocol/protocol.pyx":424
 *         return result, attrs
 * 
 *     async def _optimistic_execute(             # <<<<<<<<<<<<<<
 *         self,
 *         *,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("_optimistic_execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_30generator6(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "edgedb/protocol/protocol.pyx":551
 *             return result, attrs
 * 
 *     async def simple_query(self, str query, capabilities: enums.Capability):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer buf
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_29simple_query(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_29simple_query(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_query = 0;
  PyObject *__pyx_v_capabilities = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("simple_query (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_query,&__pyx_n_s_capabilities,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_query)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_capabilities)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("simple_query", 1, 2, 2, 1); __PYX_ERR(5, 551, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "simple_query") < 0)) __PYX_ERR(5, 551, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_query = ((PyObject*)values[0]);
    __pyx_v_capabilities = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("simple_query", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 551, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.simple_query", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_query), (&PyUnicode_Type), 1, "query", 1))) __PYX_ERR(5, 551, __pyx_L1_error)
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_28simple_query(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self), __pyx_v_query, __pyx_v_capabilities);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_28simple_query(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_query, PyObject *__pyx_v_capabilities) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("simple_query", 0);
  __pyx_cur_scope = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query *)__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query(__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 551, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_query = __pyx_v_query;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_query);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_query);
  __pyx_cur_scope->__pyx_v_capabilities = __pyx_v_capabilities;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_capabilities);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_capabilities);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_30generator6, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_simple_query, __pyx_n_s_SansIOProtocol_simple_query, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(5, 551, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.simple_query", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_30generator6(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query *__pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  uint64_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int32_t __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  char const *__pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("simple_query", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L7_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 551, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":556
 *             char mtype
 * 
 *         self.ensure_connected()             # <<<<<<<<<<<<<<
 *         self.reset_status()
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->ensure_connected(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":557
 * 
 *         self.ensure_connected()
 *         self.reset_status()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->reset_status(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":560
 * 
 * 
 *         buf = WriteBuffer.new_message(EXECUTE_SCRIPT_MSG)             # <<<<<<<<<<<<<<
 *         cap_bytes = cpython.PyBytes_FromStringAndSize(NULL, sizeof(uint64_t))
 *         hton.pack_int64(
 */
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('Q')); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_buf = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":561
 * 
 *         buf = WriteBuffer.new_message(EXECUTE_SCRIPT_MSG)
 *         cap_bytes = cpython.PyBytes_FromStringAndSize(NULL, sizeof(uint64_t))             # <<<<<<<<<<<<<<
 *         hton.pack_int64(
 *             cpython.PyBytes_AsString(cap_bytes),
 */
  __pyx_t_1 = PyBytes_FromStringAndSize(NULL, (sizeof(uint64_t))); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 561, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_cap_bytes = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":563
 *         cap_bytes = cpython.PyBytes_FromStringAndSize(NULL, sizeof(uint64_t))
 *         hton.pack_int64(
 *             cpython.PyBytes_AsString(cap_bytes),             # <<<<<<<<<<<<<<
 *             <int64_t><uint64_t>capabilities,
 *         )
 */
  __pyx_t_2 = PyBytes_AsString(__pyx_cur_scope->__pyx_v_cap_bytes); if (unlikely(__pyx_t_2 == ((char *)NULL))) __PYX_ERR(5, 563, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":564
 *         hton.pack_int64(
 *             cpython.PyBytes_AsString(cap_bytes),
 *             <int64_t><uint64_t>capabilities,             # <<<<<<<<<<<<<<
 *         )
 *         self.write_headers(
 */
  __pyx_t_3 = __Pyx_PyInt_As_uint64_t(__pyx_cur_scope->__pyx_v_capabilities); if (unlikely((__pyx_t_3 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(5, 564, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":562
 *         buf = WriteBuffer.new_message(EXECUTE_SCRIPT_MSG)
 *         cap_bytes = cpython.PyBytes_FromStringAndSize(NULL, sizeof(uint64_t))
 *         hton.pack_int64(             # <<<<<<<<<<<<<<
 *             cpython.PyBytes_AsString(cap_bytes),
 *             <int64_t><uint64_t>capabilities,
 */
  pack_int64(__pyx_t_2, ((int64_t)((uint64_t)__pyx_t_3)));

  /* "edgedb/protocol/protocol.pyx":568
 *         self.write_headers(
 *             buf,
 *             {QUERY_OPT_ALLOW_CAPABILITIES: cap_bytes},             # <<<<<<<<<<<<<<
 *         )
 *         buf.write_len_prefixed_utf8(query)
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_65284, __pyx_cur_scope->__pyx_v_cap_bytes) < 0) __PYX_ERR(5, 568, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":566
 *             <int64_t><uint64_t>capabilities,
 *         )
 *         self.write_headers(             # <<<<<<<<<<<<<<
 *             buf,
 *             {QUERY_OPT_ALLOW_CAPABILITIES: cap_bytes},
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write_headers(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_buf, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 566, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "edgedb/protocol/protocol.pyx":570
 *             {QUERY_OPT_ALLOW_CAPABILITIES: cap_bytes},
 *         )
 *         buf.write_len_prefixed_utf8(query)             # <<<<<<<<<<<<<<
 *         self.write(buf.end_message())
 * 
 */
  __pyx_t_4 = __pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_write_len_prefixed_utf8(__pyx_cur_scope->__pyx_v_buf, __pyx_cur_scope->__pyx_v_query); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 570, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "edgedb/protocol/protocol.pyx":571
 *         )
 *         buf.write_len_prefixed_utf8(query)
 *         self.write(buf.end_message())             # <<<<<<<<<<<<<<
 * 
 *         exc = None
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->end_message(__pyx_cur_scope->__pyx_v_buf); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 571, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_6edgedb_7pgproto_7pgproto_WriteBuffer))))) __PYX_ERR(5, 571, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write(__pyx_cur_scope->__pyx_v_self, ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 571, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":573
 *         self.write(buf.end_message())
 * 
 *         exc = None             # <<<<<<<<<<<<<<
 * 
 *         while True:
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_cur_scope->__pyx_v_exc = Py_None;

  /* "edgedb/protocol/protocol.pyx":575
 *         exc = None
 * 
 *         while True:             # <<<<<<<<<<<<<<
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 */
  while (1) {

    /* "edgedb/protocol/protocol.pyx":576
 * 
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_5 == ((int32_t)-1))) __PYX_ERR(5, 576, __pyx_L1_error)
    __pyx_t_6 = ((!(__pyx_t_5 != 0)) != 0);
    if (__pyx_t_6) {

      /* "edgedb/protocol/protocol.pyx":577
 *         while True:
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()             # <<<<<<<<<<<<<<
 *             mtype = self.buffer.get_message_type()
 * 
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_wait_for_message); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 577, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 577, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XGOTREF(__pyx_r);
      if (likely(__pyx_r)) {
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L7_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 577, __pyx_L1_error)
      } else {
        PyObject* exc_type = __Pyx_PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
          else __PYX_ERR(5, 577, __pyx_L1_error)
        }
      }

      /* "edgedb/protocol/protocol.pyx":576
 * 
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    }

    /* "edgedb/protocol/protocol.pyx":578
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()             # <<<<<<<<<<<<<<
 * 
 *             try:
 */
    __pyx_cur_scope->__pyx_v_mtype = __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_cur_scope->__pyx_v_self->buffer);

    /* "edgedb/protocol/protocol.pyx":580
 *             mtype = self.buffer.get_message_type()
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 if mtype == COMMAND_COMPLETE_MSG:
 *                     self.parse_command_complete_message()
 */
    /*try:*/ {

      /* "edgedb/protocol/protocol.pyx":581
 * 
 *             try:
 *                 if mtype == COMMAND_COMPLETE_MSG:             # <<<<<<<<<<<<<<
 *                     self.parse_command_complete_message()
 * 
 */
      switch (__pyx_cur_scope->__pyx_v_mtype) {
        case 'C':

        /* "edgedb/protocol/protocol.pyx":582
 *             try:
 *                 if mtype == COMMAND_COMPLETE_MSG:
 *                     self.parse_command_complete_message()             # <<<<<<<<<<<<<<
 * 
 *                 elif mtype == ERROR_RESPONSE_MSG:
 */
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_command_complete_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 582, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "edgedb/protocol/protocol.pyx":581
 * 
 *             try:
 *                 if mtype == COMMAND_COMPLETE_MSG:             # <<<<<<<<<<<<<<
 *                     self.parse_command_complete_message()
 * 
 */
        break;
        case 'E':

        /* "edgedb/protocol/protocol.pyx":586
 *                 elif mtype == ERROR_RESPONSE_MSG:
 *                     # ErrorResponse
 *                     exc = self.parse_error_message()             # <<<<<<<<<<<<<<
 * 
 *                 elif mtype == READY_FOR_COMMAND_MSG:
 */
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_error_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 586, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_exc);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_exc, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_1 = 0;

        /* "edgedb/protocol/protocol.pyx":584
 *                     self.parse_command_complete_message()
 * 
 *                 elif mtype == ERROR_RESPONSE_MSG:             # <<<<<<<<<<<<<<
 *                     # ErrorResponse
 *                     exc = self.parse_error_message()
 */
        break;
        case 'Z':

        /* "edgedb/protocol/protocol.pyx":589
 * 
 *                 elif mtype == READY_FOR_COMMAND_MSG:
 *                     self.parse_sync_message()             # <<<<<<<<<<<<<<
 *                     break
 * 
 */
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_sync_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 589, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "edgedb/protocol/protocol.pyx":590
 *                 elif mtype == READY_FOR_COMMAND_MSG:
 *                     self.parse_sync_message()
 *                     break             # <<<<<<<<<<<<<<
 * 
 *                 else:
 */
        goto __pyx_L9_break;

        /* "edgedb/protocol/protocol.pyx":588
 *                     exc = self.parse_error_message()
 * 
 *                 elif mtype == READY_FOR_COMMAND_MSG:             # <<<<<<<<<<<<<<
 *                     self.parse_sync_message()
 *                     break
 */
        break;
        default:

        /* "edgedb/protocol/protocol.pyx":593
 * 
 *                 else:
 *                     self.fallthrough()             # <<<<<<<<<<<<<<
 * 
 *             finally:
 */
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->fallthrough(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 593, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        break;
      }
    }

    /* "edgedb/protocol/protocol.pyx":596
 * 
 *             finally:
 *                 self.buffer.finish_message()             # <<<<<<<<<<<<<<
 * 
 *         if exc is not None:
 */
    /*finally:*/ {
      /*normal exit:*/{
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 596, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L12;
      }
      __pyx_L11_error:;
      /*exception exit:*/{
        __Pyx_PyThreadState_assign
        __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
        if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        __Pyx_XGOTREF(__pyx_t_11);
        __Pyx_XGOTREF(__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_13);
        __Pyx_XGOTREF(__pyx_t_14);
        __Pyx_XGOTREF(__pyx_t_15);
        __Pyx_XGOTREF(__pyx_t_16);
        __pyx_t_8 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_10 = __pyx_filename;
        {
          __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 596, __pyx_L16_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        }
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
        }
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ErrRestore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
        __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
        __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_10;
        goto __pyx_L1_error;
        __pyx_L16_error:;
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
        }
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
        goto __pyx_L1_error;
      }
      __pyx_L9_break: {
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 596, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L5_break;
      }
      __pyx_L12:;
    }
  }
  __pyx_L5_break:;

  /* "edgedb/protocol/protocol.pyx":598
 *                 self.buffer.finish_message()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             raise exc
 * 
 */
  __pyx_t_6 = (__pyx_cur_scope->__pyx_v_exc != Py_None);
  __pyx_t_17 = (__pyx_t_6 != 0);
  if (unlikely(__pyx_t_17)) {

    /* "edgedb/protocol/protocol.pyx":599
 * 
 *         if exc is not None:
 *             raise exc             # <<<<<<<<<<<<<<
 * 
 *     async def execute_anonymous(
 */
    __Pyx_Raise(__pyx_cur_scope->__pyx_v_exc, 0, 0, 0);
    __PYX_ERR(5, 599, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":598
 *                 self.buffer.finish_message()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             raise exc
 * 
 */
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "edgedb/protocol/protocol.pyx":551
 *             return result, attrs
 * 
 *     async def simple_query(self, str query, capabilities: enums.Capability):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer buf
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("simple_query", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_33generator7(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "edgedb/protocol/protocol.pyx":601
 *             raise exc
 * 
 *     async def execute_anonymous(             # <<<<<<<<<<<<<<
 *         self,
 *         *,
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_32execute_anonymous(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_32execute_anonymous(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_query = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_reg = 0;
  struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_qc = 0;
  PyObject *__pyx_v_io_format = 0;
  int __pyx_v_expect_one;
  PyObject *__pyx_v_required_one = 0;
  PyObject *__pyx_v_implicit_limit = 0;
  PyObject *__pyx_v_inline_typenames = 0;
  PyObject *__pyx_v_inline_typeids = 0;
  PyObject *__pyx_v_allow_capabilities = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("execute_anonymous (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_query,&__pyx_n_s_args,&__pyx_n_s_kwargs,&__pyx_n_s_reg,&__pyx_n_s_qc,&__pyx_n_s_io_format,&__pyx_n_s_expect_one,&__pyx_n_s_required_one,&__pyx_n_s_implicit_limit,&__pyx_n_s_inline_typenames,&__pyx_n_s_inline_typeids,&__pyx_n_s_allow_capabilities,0};
    PyObject* values[12] = {0,0,0,0,0,0,0,0,0,0,0,0};

    /* "edgedb/protocol/protocol.pyx":611
 *         io_format: object,
 *         expect_one: bint = False,
 *         required_one: bool = False,             # <<<<<<<<<<<<<<
 *         implicit_limit: int = 0,
 *         inline_typenames: bool = False,
 */
    values[7] = ((PyObject *)Py_False);
    values[8] = ((PyObject *)__pyx_int_0);

    /* "edgedb/protocol/protocol.pyx":613
 *         required_one: bool = False,
 *         implicit_limit: int = 0,
 *         inline_typenames: bool = False,             # <<<<<<<<<<<<<<
 *         inline_typeids: bool = False,
 *         allow_capabilities: typing.Optional[int] = None,
 */
    values[9] = ((PyObject *)Py_False);

    /* "edgedb/protocol/protocol.pyx":614
 *         implicit_limit: int = 0,
 *         inline_typenames: bool = False,
 *         inline_typeids: bool = False,             # <<<<<<<<<<<<<<
 *         allow_capabilities: typing.Optional[int] = None,
 *     ):
 */
    values[10] = ((PyObject *)Py_False);

    /* "edgedb/protocol/protocol.pyx":615
 *         inline_typenames: bool = False,
 *         inline_typeids: bool = False,
 *         allow_capabilities: typing.Optional[int] = None,             # <<<<<<<<<<<<<<
 *     ):
 *         cdef:
 */
    values[11] = ((PyObject *)Py_None);
    if (likely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_query)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("execute_anonymous", __pyx_n_s_query); __PYX_ERR(5, 601, __pyx_L3_error)
      }
      if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("execute_anonymous", __pyx_n_s_args); __PYX_ERR(5, 601, __pyx_L3_error)
      }
      if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("execute_anonymous", __pyx_n_s_kwargs); __PYX_ERR(5, 601, __pyx_L3_error)
      }
      if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reg)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("execute_anonymous", __pyx_n_s_reg); __PYX_ERR(5, 601, __pyx_L3_error)
      }
      if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_qc)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("execute_anonymous", __pyx_n_s_qc); __PYX_ERR(5, 601, __pyx_L3_error)
      }
      if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_io_format)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("execute_anonymous", __pyx_n_s_io_format); __PYX_ERR(5, 601, __pyx_L3_error)
      }
      if (kw_args > 0 && likely(kw_args <= 6)) {
        Py_ssize_t index;
        for (index = 6; index < 12 && kw_args > 0; index++) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "execute_anonymous") < 0)) __PYX_ERR(5, 601, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
      goto __pyx_L5_argtuple_error;
    } else {
      __Pyx_RaiseKeywordRequired("execute_anonymous", __pyx_n_s_query); __PYX_ERR(5, 601, __pyx_L3_error)
    }
    __pyx_v_query = ((PyObject*)values[0]);
    __pyx_v_args = values[1];
    __pyx_v_kwargs = values[2];
    __pyx_v_reg = ((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)values[3]);
    __pyx_v_qc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *)values[4]);
    __pyx_v_io_format = values[5];
    if (values[6]) {
      __pyx_v_expect_one = __Pyx_PyObject_IsTrue(values[6]); if (unlikely((__pyx_v_expect_one == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 610, __pyx_L3_error)
    } else {

      /* "edgedb/protocol/protocol.pyx":610
 *         qc: QueryCodecsCache,
 *         io_format: object,
 *         expect_one: bint = False,             # <<<<<<<<<<<<<<
 *         required_one: bool = False,
 *         implicit_limit: int = 0,
 */
      __pyx_v_expect_one = ((int)0);
    }
    __pyx_v_required_one = values[7];
    __pyx_v_implicit_limit = values[8];
    __pyx_v_inline_typenames = values[9];
    __pyx_v_inline_typeids = values[10];
    __pyx_v_allow_capabilities = values[11];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("execute_anonymous", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 601, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.execute_anonymous", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_query), (&PyUnicode_Type), 1, "query", 1))) __PYX_ERR(5, 604, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reg), __pyx_ptype_6edgedb_8protocol_8protocol_CodecsRegistry, 1, "reg", 0))) __PYX_ERR(5, 607, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_qc), __pyx_ptype_6edgedb_8protocol_8protocol_QueryCodecsCache, 1, "qc", 0))) __PYX_ERR(5, 608, __pyx_L1_error)
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_31execute_anonymous(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self), __pyx_v_query, __pyx_v_args, __pyx_v_kwargs, __pyx_v_reg, __pyx_v_qc, __pyx_v_io_format, __pyx_v_expect_one, __pyx_v_required_one, __pyx_v_implicit_limit, __pyx_v_inline_typenames, __pyx_v_inline_typeids, __pyx_v_allow_capabilities);

  /* "edgedb/protocol/protocol.pyx":601
 *             raise exc
 * 
 *     async def execute_anonymous(             # <<<<<<<<<<<<<<
 *         self,
 *         *,
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_31execute_anonymous(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_query, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_reg, struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v_qc, PyObject *__pyx_v_io_format, int __pyx_v_expect_one, PyObject *__pyx_v_required_one, PyObject *__pyx_v_implicit_limit, PyObject *__pyx_v_inline_typenames, PyObject *__pyx_v_inline_typeids, PyObject *__pyx_v_allow_capabilities) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("execute_anonymous", 0);
  __pyx_cur_scope = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous *)__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous(__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 601, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_query = __pyx_v_query;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_query);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_query);
  __pyx_cur_scope->__pyx_v_args = __pyx_v_args;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_args);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_args);
  __pyx_cur_scope->__pyx_v_kwargs = __pyx_v_kwargs;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_kwargs);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_kwargs);
  __pyx_cur_scope->__pyx_v_reg = __pyx_v_reg;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_reg);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_reg);
  __pyx_cur_scope->__pyx_v_qc = __pyx_v_qc;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_qc);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_qc);
  __pyx_cur_scope->__pyx_v_io_format = __pyx_v_io_format;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_io_format);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_io_format);
  __pyx_cur_scope->__pyx_v_expect_one = __pyx_v_expect_one;
  __pyx_cur_scope->__pyx_v_required_one = __pyx_v_required_one;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_required_one);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_required_one);
  __pyx_cur_scope->__pyx_v_implicit_limit = __pyx_v_implicit_limit;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_implicit_limit);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_implicit_limit);
  __pyx_cur_scope->__pyx_v_inline_typenames = __pyx_v_inline_typenames;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_inline_typenames);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_inline_typenames);
  __pyx_cur_scope->__pyx_v_inline_typeids = __pyx_v_inline_typeids;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_inline_typeids);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_inline_typeids);
  __pyx_cur_scope->__pyx_v_allow_capabilities = __pyx_v_allow_capabilities;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_allow_capabilities);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_allow_capabilities);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_33generator7, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_execute_anonymous, __pyx_n_s_SansIOProtocol_execute_anonymous, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(5, 601, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.execute_anonymous", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_33generator7(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous *__pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  PyObject *(*__pyx_t_12)(PyObject *);
  Py_ssize_t __pyx_t_13;
  Py_UCS4 __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("execute_anonymous", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L5_resume_from_await;
    case 2: goto __pyx_L8_resume_from_await;
    case 3: goto __pyx_L14_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 601, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":621
 *             BaseCodec out_dc
 * 
 *         self.ensure_connected()             # <<<<<<<<<<<<<<
 *         self.reset_status()
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->ensure_connected(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 621, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":622
 * 
 *         self.ensure_connected()
 *         self.reset_status()             # <<<<<<<<<<<<<<
 * 
 *         codecs = qc.get(
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->reset_status(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 622, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":624
 *         self.reset_status()
 * 
 *         codecs = qc.get(             # <<<<<<<<<<<<<<
 *             query, io_format, implicit_limit, inline_typenames, inline_typeids,
 *             expect_one)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_qc), __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 624, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "edgedb/protocol/protocol.pyx":626
 *         codecs = qc.get(
 *             query, io_format, implicit_limit, inline_typenames, inline_typeids,
 *             expect_one)             # <<<<<<<<<<<<<<
 *         if codecs is None:
 *             codecs = await self._parse(
 */
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_expect_one); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[7] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_query, __pyx_cur_scope->__pyx_v_io_format, __pyx_cur_scope->__pyx_v_implicit_limit, __pyx_cur_scope->__pyx_v_inline_typenames, __pyx_cur_scope->__pyx_v_inline_typeids, __pyx_t_3};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 6+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 624, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[7] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_query, __pyx_cur_scope->__pyx_v_io_format, __pyx_cur_scope->__pyx_v_implicit_limit, __pyx_cur_scope->__pyx_v_inline_typenames, __pyx_cur_scope->__pyx_v_inline_typeids, __pyx_t_3};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 6+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 624, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(6+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 624, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_query);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_query);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_cur_scope->__pyx_v_query);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_io_format);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_io_format);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_cur_scope->__pyx_v_io_format);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_implicit_limit);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_implicit_limit);
    PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_cur_scope->__pyx_v_implicit_limit);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_inline_typenames);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_inline_typenames);
    PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_cur_scope->__pyx_v_inline_typenames);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_inline_typeids);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_inline_typeids);
    PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_5, __pyx_cur_scope->__pyx_v_inline_typeids);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 5+__pyx_t_5, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 624, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_codecs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":627
 *             query, io_format, implicit_limit, inline_typenames, inline_typeids,
 *             expect_one)
 *         if codecs is None:             # <<<<<<<<<<<<<<
 *             codecs = await self._parse(
 *                 query,
 */
  __pyx_t_7 = (__pyx_cur_scope->__pyx_v_codecs == Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "edgedb/protocol/protocol.pyx":628
 *             expect_one)
 *         if codecs is None:
 *             codecs = await self._parse(             # <<<<<<<<<<<<<<
 *                 query,
 *                 reg=reg,
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_parse); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 628, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "edgedb/protocol/protocol.pyx":629
 *         if codecs is None:
 *             codecs = await self._parse(
 *                 query,             # <<<<<<<<<<<<<<
 *                 reg=reg,
 *                 io_format=io_format,
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 628, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_query);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_query);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_v_query);

    /* "edgedb/protocol/protocol.pyx":630
 *             codecs = await self._parse(
 *                 query,
 *                 reg=reg,             # <<<<<<<<<<<<<<
 *                 io_format=io_format,
 *                 expect_one=expect_one,
 */
    __pyx_t_6 = __Pyx_PyDict_NewPresized(8); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 630, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_reg, ((PyObject *)__pyx_cur_scope->__pyx_v_reg)) < 0) __PYX_ERR(5, 630, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":631
 *                 query,
 *                 reg=reg,
 *                 io_format=io_format,             # <<<<<<<<<<<<<<
 *                 expect_one=expect_one,
 *                 required_one=required_one,
 */
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_io_format, __pyx_cur_scope->__pyx_v_io_format) < 0) __PYX_ERR(5, 630, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":632
 *                 reg=reg,
 *                 io_format=io_format,
 *                 expect_one=expect_one,             # <<<<<<<<<<<<<<
 *                 required_one=required_one,
 *                 implicit_limit=implicit_limit,
 */
    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_expect_one); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_expect_one, __pyx_t_3) < 0) __PYX_ERR(5, 630, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "edgedb/protocol/protocol.pyx":633
 *                 io_format=io_format,
 *                 expect_one=expect_one,
 *                 required_one=required_one,             # <<<<<<<<<<<<<<
 *                 implicit_limit=implicit_limit,
 *                 inline_typenames=inline_typenames,
 */
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_required_one, __pyx_cur_scope->__pyx_v_required_one) < 0) __PYX_ERR(5, 630, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":634
 *                 expect_one=expect_one,
 *                 required_one=required_one,
 *                 implicit_limit=implicit_limit,             # <<<<<<<<<<<<<<
 *                 inline_typenames=inline_typenames,
 *                 inline_typeids=inline_typeids,
 */
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_implicit_limit, __pyx_cur_scope->__pyx_v_implicit_limit) < 0) __PYX_ERR(5, 630, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":635
 *                 required_one=required_one,
 *                 implicit_limit=implicit_limit,
 *                 inline_typenames=inline_typenames,             # <<<<<<<<<<<<<<
 *                 inline_typeids=inline_typeids,
 *                 allow_capabilities=allow_capabilities,
 */
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_inline_typenames, __pyx_cur_scope->__pyx_v_inline_typenames) < 0) __PYX_ERR(5, 630, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":636
 *                 implicit_limit=implicit_limit,
 *                 inline_typenames=inline_typenames,
 *                 inline_typeids=inline_typeids,             # <<<<<<<<<<<<<<
 *                 allow_capabilities=allow_capabilities,
 *             )
 */
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_inline_typeids, __pyx_cur_scope->__pyx_v_inline_typeids) < 0) __PYX_ERR(5, 630, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":637
 *                 inline_typenames=inline_typenames,
 *                 inline_typeids=inline_typeids,
 *                 allow_capabilities=allow_capabilities,             # <<<<<<<<<<<<<<
 *             )
 * 
 */
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_allow_capabilities, __pyx_cur_scope->__pyx_v_allow_capabilities) < 0) __PYX_ERR(5, 630, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":628
 *             expect_one)
 *         if codecs is None:
 *             codecs = await self._parse(             # <<<<<<<<<<<<<<
 *                 query,
 *                 reg=reg,
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 628, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XGOTREF(__pyx_r);
    if (likely(__pyx_r)) {
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L5_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 628, __pyx_L1_error)
      __pyx_t_3 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_3);
    } else {
      __pyx_t_3 = NULL;
      if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_3) < 0) __PYX_ERR(5, 628, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_codecs);
    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_codecs, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;

    /* "edgedb/protocol/protocol.pyx":640
 *             )
 * 
 *             cardinality = codecs[0]             # <<<<<<<<<<<<<<
 *             in_dc = <BaseCodec>codecs[1]
 *             out_dc = <BaseCodec>codecs[2]
 */
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_codecs, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 640, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_cur_scope->__pyx_v_cardinality = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "edgedb/protocol/protocol.pyx":641
 * 
 *             cardinality = codecs[0]
 *             in_dc = <BaseCodec>codecs[1]             # <<<<<<<<<<<<<<
 *             out_dc = <BaseCodec>codecs[2]
 *             headers = <BaseCodec>codecs[3]
 */
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_codecs, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_t_3;
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_cur_scope->__pyx_v_in_dc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "edgedb/protocol/protocol.pyx":642
 *             cardinality = codecs[0]
 *             in_dc = <BaseCodec>codecs[1]
 *             out_dc = <BaseCodec>codecs[2]             # <<<<<<<<<<<<<<
 *             headers = <BaseCodec>codecs[3]
 * 
 */
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_codecs, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 642, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __pyx_t_6;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_cur_scope->__pyx_v_out_dc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "edgedb/protocol/protocol.pyx":643
 *             in_dc = <BaseCodec>codecs[1]
 *             out_dc = <BaseCodec>codecs[2]
 *             headers = <BaseCodec>codecs[3]             # <<<<<<<<<<<<<<
 * 
 *             capabilities = None
 */
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_codecs, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_t_3;
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_cur_scope->__pyx_v_headers = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "edgedb/protocol/protocol.pyx":645
 *             headers = <BaseCodec>codecs[3]
 * 
 *             capabilities = None             # <<<<<<<<<<<<<<
 *             if headers:
 *                 capabilities = headers.get(SERVER_HEADER_CAPABILITIES)
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __pyx_cur_scope->__pyx_v_capabilities = Py_None;

    /* "edgedb/protocol/protocol.pyx":646
 * 
 *             capabilities = None
 *             if headers:             # <<<<<<<<<<<<<<
 *                 capabilities = headers.get(SERVER_HEADER_CAPABILITIES)
 *                 if capabilities is not None:
 */
    __pyx_t_8 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_cur_scope->__pyx_v_headers)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(5, 646, __pyx_L1_error)
    if (__pyx_t_8) {

      /* "edgedb/protocol/protocol.pyx":647
 *             capabilities = None
 *             if headers:
 *                 capabilities = headers.get(SERVER_HEADER_CAPABILITIES)             # <<<<<<<<<<<<<<
 *                 if capabilities is not None:
 *                     capabilities = int.from_bytes(capabilities, 'big')
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_headers), __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 647, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_6 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_int_4097) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_int_4097);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 647, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_capabilities);
      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_capabilities, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_t_6 = 0;

      /* "edgedb/protocol/protocol.pyx":648
 *             if headers:
 *                 capabilities = headers.get(SERVER_HEADER_CAPABILITIES)
 *                 if capabilities is not None:             # <<<<<<<<<<<<<<
 *                     capabilities = int.from_bytes(capabilities, 'big')
 * 
 */
      __pyx_t_8 = (__pyx_cur_scope->__pyx_v_capabilities != Py_None);
      __pyx_t_7 = (__pyx_t_8 != 0);
      if (__pyx_t_7) {

        /* "edgedb/protocol/protocol.pyx":649
 *                 capabilities = headers.get(SERVER_HEADER_CAPABILITIES)
 *                 if capabilities is not None:
 *                     capabilities = int.from_bytes(capabilities, 'big')             # <<<<<<<<<<<<<<
 * 
 *             qc.set(
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyInt_Type)), __pyx_n_s_from_bytes); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 649, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_2)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_capabilities, __pyx_n_u_big};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 649, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_capabilities, __pyx_n_u_big};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 649, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        {
          __pyx_t_1 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 649, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          if (__pyx_t_2) {
            __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
          }
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_capabilities);
          __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_capabilities);
          PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_5, __pyx_cur_scope->__pyx_v_capabilities);
          __Pyx_INCREF(__pyx_n_u_big);
          __Pyx_GIVEREF(__pyx_n_u_big);
          PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_5, __pyx_n_u_big);
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 649, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_capabilities);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_capabilities, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        __pyx_t_6 = 0;

        /* "edgedb/protocol/protocol.pyx":648
 *             if headers:
 *                 capabilities = headers.get(SERVER_HEADER_CAPABILITIES)
 *                 if capabilities is not None:             # <<<<<<<<<<<<<<
 *                     capabilities = int.from_bytes(capabilities, 'big')
 * 
 */
      }

      /* "edgedb/protocol/protocol.pyx":646
 * 
 *             capabilities = None
 *             if headers:             # <<<<<<<<<<<<<<
 *                 capabilities = headers.get(SERVER_HEADER_CAPABILITIES)
 *                 if capabilities is not None:
 */
    }

    /* "edgedb/protocol/protocol.pyx":653
 *             qc.set(
 *                 query,
 *                 io_format,             # <<<<<<<<<<<<<<
 *                 implicit_limit,
 *                 inline_typenames,
 */
    __pyx_t_9 = ((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)__Pyx_PyInt_As_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_cur_scope->__pyx_v_io_format)); if (unlikely(PyErr_Occurred())) __PYX_ERR(5, 653, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":654
 *                 query,
 *                 io_format,
 *                 implicit_limit,             # <<<<<<<<<<<<<<
 *                 inline_typenames,
 *                 inline_typeids,
 */
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_cur_scope->__pyx_v_implicit_limit); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 654, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":655
 *                 io_format,
 *                 implicit_limit,
 *                 inline_typenames,             # <<<<<<<<<<<<<<
 *                 inline_typeids,
 *                 expect_one,
 */
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_inline_typenames); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 655, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":656
 *                 implicit_limit,
 *                 inline_typenames,
 *                 inline_typeids,             # <<<<<<<<<<<<<<
 *                 expect_one,
 *                 cardinality == CARDINALITY_NOT_APPLICABLE,
 */
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_inline_typeids); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 656, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":658
 *                 inline_typeids,
 *                 expect_one,
 *                 cardinality == CARDINALITY_NOT_APPLICABLE,             # <<<<<<<<<<<<<<
 *                 in_dc,
 *                 out_dc,
 */
    __pyx_t_6 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_cardinality, __pyx_n_b_n, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 658, __pyx_L1_error)
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 658, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "edgedb/protocol/protocol.pyx":661
 *                 in_dc,
 *                 out_dc,
 *                 capabilities,             # <<<<<<<<<<<<<<
 *             )
 * 
 */
    __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_cur_scope->__pyx_v_capabilities); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(5, 661, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":651
 *                     capabilities = int.from_bytes(capabilities, 'big')
 * 
 *             qc.set(             # <<<<<<<<<<<<<<
 *                 query,
 *                 io_format,
 */
    __pyx_t_6 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_QueryCodecsCache *)__pyx_cur_scope->__pyx_v_qc->__pyx_vtab)->set(__pyx_cur_scope->__pyx_v_qc, __pyx_cur_scope->__pyx_v_query, __pyx_t_9, __pyx_t_5, __pyx_t_7, __pyx_t_8, __pyx_cur_scope->__pyx_v_expect_one, __pyx_t_10, __pyx_cur_scope->__pyx_v_in_dc, __pyx_cur_scope->__pyx_v_out_dc, __pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 651, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "edgedb/protocol/protocol.pyx":664
 *             )
 * 
 *             ret, attrs = await self._execute(in_dc, out_dc, args, kwargs)             # <<<<<<<<<<<<<<
 * 
 *         else:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_execute); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 664, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[5] = {__pyx_t_1, ((PyObject *)__pyx_cur_scope->__pyx_v_in_dc), ((PyObject *)__pyx_cur_scope->__pyx_v_out_dc), __pyx_cur_scope->__pyx_v_args, __pyx_cur_scope->__pyx_v_kwargs};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 664, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[5] = {__pyx_t_1, ((PyObject *)__pyx_cur_scope->__pyx_v_in_dc), ((PyObject *)__pyx_cur_scope->__pyx_v_out_dc), __pyx_cur_scope->__pyx_v_args, __pyx_cur_scope->__pyx_v_kwargs};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 664, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(4+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 664, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_in_dc));
      __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_in_dc));
      PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_11, ((PyObject *)__pyx_cur_scope->__pyx_v_in_dc));
      __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_out_dc));
      __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_out_dc));
      PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_11, ((PyObject *)__pyx_cur_scope->__pyx_v_out_dc));
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_args);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_args);
      PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_11, __pyx_cur_scope->__pyx_v_args);
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_kwargs);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_kwargs);
      PyTuple_SET_ITEM(__pyx_t_2, 3+__pyx_t_11, __pyx_cur_scope->__pyx_v_kwargs);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 664, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XGOTREF(__pyx_r);
    if (likely(__pyx_r)) {
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L8_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 664, __pyx_L1_error)
      __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
    } else {
      __pyx_t_6 = NULL;
      if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_6) < 0) __PYX_ERR(5, 664, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
      PyObject* sequence = __pyx_t_6;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(5, 664, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 664, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 664, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_1 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 664, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_12 = Py_TYPE(__pyx_t_1)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_12(__pyx_t_1); if (unlikely(!__pyx_t_3)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_2 = __pyx_t_12(__pyx_t_1); if (unlikely(!__pyx_t_2)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_1), 2) < 0) __PYX_ERR(5, 664, __pyx_L1_error)
      __pyx_t_12 = NULL;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L10_unpacking_done;
      __pyx_L9_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_12 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(5, 664, __pyx_L1_error)
      __pyx_L10_unpacking_done:;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_cur_scope->__pyx_v_ret = __pyx_t_3;
    __pyx_t_3 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_cur_scope->__pyx_v_attrs = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "edgedb/protocol/protocol.pyx":627
 *             query, io_format, implicit_limit, inline_typenames, inline_typeids,
 *             expect_one)
 *         if codecs is None:             # <<<<<<<<<<<<<<
 *             codecs = await self._parse(
 *                 query,
 */
    goto __pyx_L4;
  }

  /* "edgedb/protocol/protocol.pyx":667
 * 
 *         else:
 *             has_na_cardinality = codecs[0]             # <<<<<<<<<<<<<<
 *             in_dc = <BaseCodec>codecs[1]
 *             out_dc = <BaseCodec>codecs[2]
 */
  /*else*/ {
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_codecs, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 667, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_cur_scope->__pyx_v_has_na_cardinality = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "edgedb/protocol/protocol.pyx":668
 *         else:
 *             has_na_cardinality = codecs[0]
 *             in_dc = <BaseCodec>codecs[1]             # <<<<<<<<<<<<<<
 *             out_dc = <BaseCodec>codecs[2]
 * 
 */
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_codecs, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 668, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = __pyx_t_6;
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_cur_scope->__pyx_v_in_dc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "edgedb/protocol/protocol.pyx":669
 *             has_na_cardinality = codecs[0]
 *             in_dc = <BaseCodec>codecs[1]
 *             out_dc = <BaseCodec>codecs[2]             # <<<<<<<<<<<<<<
 * 
 *             if required_one and has_na_cardinality:
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_codecs, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 669, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __pyx_t_2;
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_cur_scope->__pyx_v_out_dc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "edgedb/protocol/protocol.pyx":671
 *             out_dc = <BaseCodec>codecs[2]
 * 
 *             if required_one and has_na_cardinality:             # <<<<<<<<<<<<<<
 *                 methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *                 raise errors.InterfaceError(
 */
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_required_one); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(5, 671, __pyx_L1_error)
    if (__pyx_t_8) {
    } else {
      __pyx_t_10 = __pyx_t_8;
      goto __pyx_L12_bool_binop_done;
    }
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_has_na_cardinality); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(5, 671, __pyx_L1_error)
    __pyx_t_10 = __pyx_t_8;
    __pyx_L12_bool_binop_done:;
    if (unlikely(__pyx_t_10)) {

      /* "edgedb/protocol/protocol.pyx":672
 * 
 *             if required_one and has_na_cardinality:
 *                 methname = _QUERY_SINGLE_METHOD[required_one][io_format]             # <<<<<<<<<<<<<<
 *                 raise errors.InterfaceError(
 *                     f'query cannot be executed with {methname}() as it '
 */
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_QUERY_SINGLE_METHOD); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 672, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_6, __pyx_cur_scope->__pyx_v_required_one); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 672, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_cur_scope->__pyx_v_io_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 672, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_v_methname = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "edgedb/protocol/protocol.pyx":673
 *             if required_one and has_na_cardinality:
 *                 methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *                 raise errors.InterfaceError(             # <<<<<<<<<<<<<<
 *                     f'query cannot be executed with {methname}() as it '
 *                     f'does not return any data')
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_errors); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_InterfaceError); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "edgedb/protocol/protocol.pyx":674
 *                 methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *                 raise errors.InterfaceError(
 *                     f'query cannot be executed with {methname}() as it '             # <<<<<<<<<<<<<<
 *                     f'does not return any data')
 * 
 */
      __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 674, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_13 = 0;
      __pyx_t_14 = 127;
      __Pyx_INCREF(__pyx_kp_u_query_cannot_be_executed_with);
      __pyx_t_13 += 30;
      __Pyx_GIVEREF(__pyx_kp_u_query_cannot_be_executed_with);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u_query_cannot_be_executed_with);
      __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_methname, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 674, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_14;
      __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
      __pyx_t_1 = 0;
      __Pyx_INCREF(__pyx_kp_u_as_it_does_not_return_any_data);
      __pyx_t_13 += 33;
      __Pyx_GIVEREF(__pyx_kp_u_as_it_does_not_return_any_data);
      PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u_as_it_does_not_return_any_data);
      __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_2, 3, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 674, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_6 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __PYX_ERR(5, 673, __pyx_L1_error)

      /* "edgedb/protocol/protocol.pyx":671
 *             out_dc = <BaseCodec>codecs[2]
 * 
 *             if required_one and has_na_cardinality:             # <<<<<<<<<<<<<<
 *                 methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *                 raise errors.InterfaceError(
 */
    }

    /* "edgedb/protocol/protocol.pyx":677
 *                     f'does not return any data')
 * 
 *             ret, attrs = await self._optimistic_execute(             # <<<<<<<<<<<<<<
 *                 query=query,
 *                 args=args,
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_optimistic_execute); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 677, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);

    /* "edgedb/protocol/protocol.pyx":678
 * 
 *             ret, attrs = await self._optimistic_execute(
 *                 query=query,             # <<<<<<<<<<<<<<
 *                 args=args,
 *                 kwargs=kwargs,
 */
    __pyx_t_3 = __Pyx_PyDict_NewPresized(14); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 678, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_query, __pyx_cur_scope->__pyx_v_query) < 0) __PYX_ERR(5, 678, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":679
 *             ret, attrs = await self._optimistic_execute(
 *                 query=query,
 *                 args=args,             # <<<<<<<<<<<<<<
 *                 kwargs=kwargs,
 *                 reg=reg,
 */
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_args, __pyx_cur_scope->__pyx_v_args) < 0) __PYX_ERR(5, 678, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":680
 *                 query=query,
 *                 args=args,
 *                 kwargs=kwargs,             # <<<<<<<<<<<<<<
 *                 reg=reg,
 *                 qc=qc,
 */
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_kwargs, __pyx_cur_scope->__pyx_v_kwargs) < 0) __PYX_ERR(5, 678, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":681
 *                 args=args,
 *                 kwargs=kwargs,
 *                 reg=reg,             # <<<<<<<<<<<<<<
 *                 qc=qc,
 *                 io_format=io_format,
 */
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reg, ((PyObject *)__pyx_cur_scope->__pyx_v_reg)) < 0) __PYX_ERR(5, 678, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":682
 *                 kwargs=kwargs,
 *                 reg=reg,
 *                 qc=qc,             # <<<<<<<<<<<<<<
 *                 io_format=io_format,
 *                 expect_one=expect_one,
 */
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_qc, ((PyObject *)__pyx_cur_scope->__pyx_v_qc)) < 0) __PYX_ERR(5, 678, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":683
 *                 reg=reg,
 *                 qc=qc,
 *                 io_format=io_format,             # <<<<<<<<<<<<<<
 *                 expect_one=expect_one,
 *                 required_one=required_one,
 */
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_io_format, __pyx_cur_scope->__pyx_v_io_format) < 0) __PYX_ERR(5, 678, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":684
 *                 qc=qc,
 *                 io_format=io_format,
 *                 expect_one=expect_one,             # <<<<<<<<<<<<<<
 *                 required_one=required_one,
 *                 implicit_limit=implicit_limit,
 */
    __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_expect_one); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 684, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_expect_one, __pyx_t_1) < 0) __PYX_ERR(5, 678, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":685
 *                 io_format=io_format,
 *                 expect_one=expect_one,
 *                 required_one=required_one,             # <<<<<<<<<<<<<<
 *                 implicit_limit=implicit_limit,
 *                 inline_typenames=inline_typenames,
 */
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_required_one, __pyx_cur_scope->__pyx_v_required_one) < 0) __PYX_ERR(5, 678, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":686
 *                 expect_one=expect_one,
 *                 required_one=required_one,
 *                 implicit_limit=implicit_limit,             # <<<<<<<<<<<<<<
 *                 inline_typenames=inline_typenames,
 *                 inline_typeids=inline_typeids,
 */
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_implicit_limit, __pyx_cur_scope->__pyx_v_implicit_limit) < 0) __PYX_ERR(5, 678, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":687
 *                 required_one=required_one,
 *                 implicit_limit=implicit_limit,
 *                 inline_typenames=inline_typenames,             # <<<<<<<<<<<<<<
 *                 inline_typeids=inline_typeids,
 *                 allow_capabilities=allow_capabilities,
 */
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_inline_typenames, __pyx_cur_scope->__pyx_v_inline_typenames) < 0) __PYX_ERR(5, 678, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":688
 *                 implicit_limit=implicit_limit,
 *                 inline_typenames=inline_typenames,
 *                 inline_typeids=inline_typeids,             # <<<<<<<<<<<<<<
 *                 allow_capabilities=allow_capabilities,
 *                 in_dc=in_dc,
 */
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_inline_typeids, __pyx_cur_scope->__pyx_v_inline_typeids) < 0) __PYX_ERR(5, 678, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":689
 *                 inline_typenames=inline_typenames,
 *                 inline_typeids=inline_typeids,
 *                 allow_capabilities=allow_capabilities,             # <<<<<<<<<<<<<<
 *                 in_dc=in_dc,
 *                 out_dc=out_dc,
 */
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allow_capabilities, __pyx_cur_scope->__pyx_v_allow_capabilities) < 0) __PYX_ERR(5, 678, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":690
 *                 inline_typeids=inline_typeids,
 *                 allow_capabilities=allow_capabilities,
 *                 in_dc=in_dc,             # <<<<<<<<<<<<<<
 *                 out_dc=out_dc,
 *             )
 */
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_in_dc, ((PyObject *)__pyx_cur_scope->__pyx_v_in_dc)) < 0) __PYX_ERR(5, 678, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":691
 *                 allow_capabilities=allow_capabilities,
 *                 in_dc=in_dc,
 *                 out_dc=out_dc,             # <<<<<<<<<<<<<<
 *             )
 * 
 */
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_out_dc, ((PyObject *)__pyx_cur_scope->__pyx_v_out_dc)) < 0) __PYX_ERR(5, 678, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":677
 *                     f'does not return any data')
 * 
 *             ret, attrs = await self._optimistic_execute(             # <<<<<<<<<<<<<<
 *                 query=query,
 *                 args=args,
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 677, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XGOTREF(__pyx_r);
    if (likely(__pyx_r)) {
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 3;
      return __pyx_r;
      __pyx_L14_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 677, __pyx_L1_error)
      __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
    } else {
      __pyx_t_1 = NULL;
      if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_1) < 0) __PYX_ERR(5, 677, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(5, 677, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 677, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 677, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 677, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_12 = Py_TYPE(__pyx_t_2)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_12(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L15_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_6 = __pyx_t_12(__pyx_t_2); if (unlikely(!__pyx_t_6)) goto __pyx_L15_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_2), 2) < 0) __PYX_ERR(5, 677, __pyx_L1_error)
      __pyx_t_12 = NULL;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L16_unpacking_done;
      __pyx_L15_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_12 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(5, 677, __pyx_L1_error)
      __pyx_L16_unpacking_done:;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_cur_scope->__pyx_v_ret = __pyx_t_3;
    __pyx_t_3 = 0;
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_cur_scope->__pyx_v_attrs = __pyx_t_6;
    __pyx_t_6 = 0;
  }
  __pyx_L4:;

  /* "edgedb/protocol/protocol.pyx":694
 *             )
 * 
 *         if expect_one:             # <<<<<<<<<<<<<<
 *             if ret or not required_one:
 *                 if ret:
 */
  __pyx_t_10 = (__pyx_cur_scope->__pyx_v_expect_one != 0);
  if (__pyx_t_10) {

    /* "edgedb/protocol/protocol.pyx":695
 * 
 *         if expect_one:
 *             if ret or not required_one:             # <<<<<<<<<<<<<<
 *                 if ret:
 *                     return ret[0], attrs
 */
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_ret); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(5, 695, __pyx_L1_error)
    if (!__pyx_t_8) {
    } else {
      __pyx_t_10 = __pyx_t_8;
      goto __pyx_L19_bool_binop_done;
    }
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_required_one); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(5, 695, __pyx_L1_error)
    __pyx_t_7 = ((!__pyx_t_8) != 0);
    __pyx_t_10 = __pyx_t_7;
    __pyx_L19_bool_binop_done:;
    if (likely(__pyx_t_10)) {

      /* "edgedb/protocol/protocol.pyx":696
 *         if expect_one:
 *             if ret or not required_one:
 *                 if ret:             # <<<<<<<<<<<<<<
 *                     return ret[0], attrs
 *                 else:
 */
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_ret); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(5, 696, __pyx_L1_error)
      if (__pyx_t_10) {

        /* "edgedb/protocol/protocol.pyx":697
 *             if ret or not required_one:
 *                 if ret:
 *                     return ret[0], attrs             # <<<<<<<<<<<<<<
 *                 else:
 *                     if io_format == IoFormat.JSON:
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_ret, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 697, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 697, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_attrs);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_attrs);
        PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_cur_scope->__pyx_v_attrs);
        __pyx_t_1 = 0;
        __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L0;

        /* "edgedb/protocol/protocol.pyx":696
 *         if expect_one:
 *             if ret or not required_one:
 *                 if ret:             # <<<<<<<<<<<<<<
 *                     return ret[0], attrs
 *                 else:
 */
      }

      /* "edgedb/protocol/protocol.pyx":699
 *                     return ret[0], attrs
 *                 else:
 *                     if io_format == IoFormat.JSON:             # <<<<<<<<<<<<<<
 *                         return 'null', attrs
 *                     else:
 */
      /*else*/ {
        __pyx_t_6 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_e_6edgedb_8protocol_8protocol_JSON); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 699, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_1 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_io_format, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 699, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(5, 699, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_10) {

          /* "edgedb/protocol/protocol.pyx":700
 *                 else:
 *                     if io_format == IoFormat.JSON:
 *                         return 'null', attrs             # <<<<<<<<<<<<<<
 *                     else:
 *                         return None, attrs
 */
          __Pyx_XDECREF(__pyx_r);
          __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 700, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_INCREF(__pyx_n_u_null);
          __Pyx_GIVEREF(__pyx_n_u_null);
          PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_n_u_null);
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_attrs);
          __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_attrs);
          PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_cur_scope->__pyx_v_attrs);
          __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L0;

          /* "edgedb/protocol/protocol.pyx":699
 *                     return ret[0], attrs
 *                 else:
 *                     if io_format == IoFormat.JSON:             # <<<<<<<<<<<<<<
 *                         return 'null', attrs
 *                     else:
 */
        }

        /* "edgedb/protocol/protocol.pyx":702
 *                         return 'null', attrs
 *                     else:
 *                         return None, attrs             # <<<<<<<<<<<<<<
 *             else:
 *                 methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 */
        /*else*/ {
          __Pyx_XDECREF(__pyx_r);
          __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 702, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_INCREF(Py_None);
          __Pyx_GIVEREF(Py_None);
          PyTuple_SET_ITEM(__pyx_t_1, 0, Py_None);
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_attrs);
          __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_attrs);
          PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_cur_scope->__pyx_v_attrs);
          __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L0;
        }
      }

      /* "edgedb/protocol/protocol.pyx":695
 * 
 *         if expect_one:
 *             if ret or not required_one:             # <<<<<<<<<<<<<<
 *                 if ret:
 *                     return ret[0], attrs
 */
    }

    /* "edgedb/protocol/protocol.pyx":704
 *                         return None, attrs
 *             else:
 *                 methname = _QUERY_SINGLE_METHOD[required_one][io_format]             # <<<<<<<<<<<<<<
 *                 raise errors.NoDataError(
 *                     f'query executed via {methname}() returned no data')
 */
    /*else*/ {
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_QUERY_SINGLE_METHOD); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 704, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_cur_scope->__pyx_v_required_one); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 704, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_6, __pyx_cur_scope->__pyx_v_io_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 704, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_methname = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "edgedb/protocol/protocol.pyx":705
 *             else:
 *                 methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *                 raise errors.NoDataError(             # <<<<<<<<<<<<<<
 *                     f'query executed via {methname}() returned no data')
 *         else:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_errors); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 705, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_NoDataError); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 705, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "edgedb/protocol/protocol.pyx":706
 *                 methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *                 raise errors.NoDataError(
 *                     f'query executed via {methname}() returned no data')             # <<<<<<<<<<<<<<
 *         else:
 *             if ret:
 */
      __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 706, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_13 = 0;
      __pyx_t_14 = 127;
      __Pyx_INCREF(__pyx_kp_u_query_executed_via);
      __pyx_t_13 += 19;
      __Pyx_GIVEREF(__pyx_kp_u_query_executed_via);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_kp_u_query_executed_via);
      __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_methname, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 706, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_14;
      __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_INCREF(__pyx_kp_u_returned_no_data);
      __pyx_t_13 += 19;
      __Pyx_GIVEREF(__pyx_kp_u_returned_no_data);
      PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_kp_u_returned_no_data);
      __pyx_t_2 = __Pyx_PyUnicode_Join(__pyx_t_6, 3, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 706, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_6, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 705, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(5, 705, __pyx_L1_error)
    }

    /* "edgedb/protocol/protocol.pyx":694
 *             )
 * 
 *         if expect_one:             # <<<<<<<<<<<<<<
 *             if ret or not required_one:
 *                 if ret:
 */
  }

  /* "edgedb/protocol/protocol.pyx":708
 *                     f'query executed via {methname}() returned no data')
 *         else:
 *             if ret:             # <<<<<<<<<<<<<<
 *                 if io_format == IoFormat.JSON:
 *                     return ret[0], attrs
 */
  /*else*/ {
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_ret); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(5, 708, __pyx_L1_error)
    if (__pyx_t_10) {

      /* "edgedb/protocol/protocol.pyx":709
 *         else:
 *             if ret:
 *                 if io_format == IoFormat.JSON:             # <<<<<<<<<<<<<<
 *                     return ret[0], attrs
 *                 else:
 */
      __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_e_6edgedb_8protocol_8protocol_JSON); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 709, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_io_format, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 709, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(5, 709, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_10) {

        /* "edgedb/protocol/protocol.pyx":710
 *             if ret:
 *                 if io_format == IoFormat.JSON:
 *                     return ret[0], attrs             # <<<<<<<<<<<<<<
 *                 else:
 *                     return ret, attrs
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_ret, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 710, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 710, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_attrs);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_attrs);
        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_cur_scope->__pyx_v_attrs);
        __pyx_t_3 = 0;
        __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;

        /* "edgedb/protocol/protocol.pyx":709
 *         else:
 *             if ret:
 *                 if io_format == IoFormat.JSON:             # <<<<<<<<<<<<<<
 *                     return ret[0], attrs
 *                 else:
 */
      }

      /* "edgedb/protocol/protocol.pyx":712
 *                     return ret[0], attrs
 *                 else:
 *                     return ret, attrs             # <<<<<<<<<<<<<<
 *             else:
 *                 if io_format == IoFormat.JSON:
 */
      /*else*/ {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 712, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_ret);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_ret);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_ret);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_attrs);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_attrs);
        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_cur_scope->__pyx_v_attrs);
        __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }

      /* "edgedb/protocol/protocol.pyx":708
 *                     f'query executed via {methname}() returned no data')
 *         else:
 *             if ret:             # <<<<<<<<<<<<<<
 *                 if io_format == IoFormat.JSON:
 *                     return ret[0], attrs
 */
    }

    /* "edgedb/protocol/protocol.pyx":714
 *                     return ret, attrs
 *             else:
 *                 if io_format == IoFormat.JSON:             # <<<<<<<<<<<<<<
 *                     return '[]', attrs
 *                 else:
 */
    /*else*/ {
      __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_e_6edgedb_8protocol_8protocol_JSON); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 714, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_io_format, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 714, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(5, 714, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_10) {

        /* "edgedb/protocol/protocol.pyx":715
 *             else:
 *                 if io_format == IoFormat.JSON:
 *                     return '[]', attrs             # <<<<<<<<<<<<<<
 *                 else:
 *                     return ret, attrs
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 715, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_kp_u__68);
        __Pyx_GIVEREF(__pyx_kp_u__68);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u__68);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_attrs);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_attrs);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_cur_scope->__pyx_v_attrs);
        __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L0;

        /* "edgedb/protocol/protocol.pyx":714
 *                     return ret, attrs
 *             else:
 *                 if io_format == IoFormat.JSON:             # <<<<<<<<<<<<<<
 *                     return '[]', attrs
 *                 else:
 */
      }

      /* "edgedb/protocol/protocol.pyx":717
 *                     return '[]', attrs
 *                 else:
 *                     return ret, attrs             # <<<<<<<<<<<<<<
 * 
 *     async def dump(self, header_callback, block_callback):
 */
      /*else*/ {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 717, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_ret);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_ret);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_cur_scope->__pyx_v_ret);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_attrs);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_attrs);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_cur_scope->__pyx_v_attrs);
        __pyx_r = NULL; __Pyx_ReturnWithStopIteration(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L0;
      }
    }
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "edgedb/protocol/protocol.pyx":601
 *             raise exc
 * 
 *     async def execute_anonymous(             # <<<<<<<<<<<<<<
 *         self,
 *         *,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("execute_anonymous", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_36generator8(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "edgedb/protocol/protocol.pyx":719
 *                     return ret, attrs
 * 
 *     async def dump(self, header_callback, block_callback):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer buf
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_35dump(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_35dump(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_header_callback = 0;
  PyObject *__pyx_v_block_callback = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dump (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_header_callback,&__pyx_n_s_block_callback,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_header_callback)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_block_callback)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("dump", 1, 2, 2, 1); __PYX_ERR(5, 719, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "dump") < 0)) __PYX_ERR(5, 719, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_header_callback = values[0];
    __pyx_v_block_callback = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("dump", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 719, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.dump", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_34dump(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self), __pyx_v_header_callback, __pyx_v_block_callback);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_34dump(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_header_callback, PyObject *__pyx_v_block_callback) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dump", 0);
  __pyx_cur_scope = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump *)__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump(__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 719, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_header_callback = __pyx_v_header_callback;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_header_callback);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_header_callback);
  __pyx_cur_scope->__pyx_v_block_callback = __pyx_v_block_callback;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_block_callback);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_block_callback);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_36generator8, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_dump, __pyx_n_s_SansIOProtocol_dump, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(5, 719, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.dump", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_36generator8(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump *__pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int32_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  char const *__pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dump", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L7_resume_from_await;
    case 2: goto __pyx_L14_resume_from_await;
    case 3: goto __pyx_L17_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 719, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":724
 *             char mtype
 * 
 *         self.ensure_connected()             # <<<<<<<<<<<<<<
 *         self.reset_status()
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->ensure_connected(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 724, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":725
 * 
 *         self.ensure_connected()
 *         self.reset_status()             # <<<<<<<<<<<<<<
 * 
 *         buf = WriteBuffer.new_message(DUMP_MSG)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->reset_status(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 725, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":727
 *         self.reset_status()
 * 
 *         buf = WriteBuffer.new_message(DUMP_MSG)             # <<<<<<<<<<<<<<
 *         buf.write_int16(0)  # no headers
 *         buf.end_message()
 */
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('>')); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 727, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_buf = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":728
 * 
 *         buf = WriteBuffer.new_message(DUMP_MSG)
 *         buf.write_int16(0)  # no headers             # <<<<<<<<<<<<<<
 *         buf.end_message()
 *         buf.write_bytes(SYNC_MESSAGE)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_int16(__pyx_cur_scope->__pyx_v_buf, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":729
 *         buf = WriteBuffer.new_message(DUMP_MSG)
 *         buf.write_int16(0)  # no headers
 *         buf.end_message()             # <<<<<<<<<<<<<<
 *         buf.write_bytes(SYNC_MESSAGE)
 *         self.write(buf)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->end_message(__pyx_cur_scope->__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":730
 *         buf.write_int16(0)  # no headers
 *         buf.end_message()
 *         buf.write_bytes(SYNC_MESSAGE)             # <<<<<<<<<<<<<<
 *         self.write(buf)
 * 
 */
  __pyx_t_1 = __pyx_v_6edgedb_8protocol_8protocol_SYNC_MESSAGE;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_bytes(__pyx_cur_scope->__pyx_v_buf, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":731
 *         buf.end_message()
 *         buf.write_bytes(SYNC_MESSAGE)
 *         self.write(buf)             # <<<<<<<<<<<<<<
 * 
 *         header_received = False
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_buf); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 731, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":733
 *         self.write(buf)
 * 
 *         header_received = False             # <<<<<<<<<<<<<<
 *         data_received = False
 *         exc = None
 */
  __pyx_cur_scope->__pyx_v_header_received = 0;

  /* "edgedb/protocol/protocol.pyx":734
 * 
 *         header_received = False
 *         data_received = False             # <<<<<<<<<<<<<<
 *         exc = None
 *         while True:
 */
  __pyx_cur_scope->__pyx_v_data_received = 0;

  /* "edgedb/protocol/protocol.pyx":735
 *         header_received = False
 *         data_received = False
 *         exc = None             # <<<<<<<<<<<<<<
 *         while True:
 *             if not self.buffer.take_message():
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_cur_scope->__pyx_v_exc = Py_None;

  /* "edgedb/protocol/protocol.pyx":736
 *         data_received = False
 *         exc = None
 *         while True:             # <<<<<<<<<<<<<<
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 */
  while (1) {

    /* "edgedb/protocol/protocol.pyx":737
 *         exc = None
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_3 == ((int32_t)-1))) __PYX_ERR(5, 737, __pyx_L1_error)
    __pyx_t_4 = ((!(__pyx_t_3 != 0)) != 0);
    if (__pyx_t_4) {

      /* "edgedb/protocol/protocol.pyx":738
 *         while True:
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()             # <<<<<<<<<<<<<<
 *             mtype = self.buffer.get_message_type()
 * 
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_wait_for_message); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 738, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 738, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XGOTREF(__pyx_r);
      if (likely(__pyx_r)) {
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L7_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 738, __pyx_L1_error)
      } else {
        PyObject* exc_type = __Pyx_PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
          else __PYX_ERR(5, 738, __pyx_L1_error)
        }
      }

      /* "edgedb/protocol/protocol.pyx":737
 *         exc = None
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    }

    /* "edgedb/protocol/protocol.pyx":739
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()             # <<<<<<<<<<<<<<
 * 
 *             try:
 */
    __pyx_cur_scope->__pyx_v_mtype = __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_cur_scope->__pyx_v_self->buffer);

    /* "edgedb/protocol/protocol.pyx":741
 *             mtype = self.buffer.get_message_type()
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 if mtype == DUMP_BLOCK_MSG:
 *                     if not header_received:
 */
    /*try:*/ {

      /* "edgedb/protocol/protocol.pyx":742
 * 
 *             try:
 *                 if mtype == DUMP_BLOCK_MSG:             # <<<<<<<<<<<<<<
 *                     if not header_received:
 *                         raise RuntimeError('data block before header block')
 */
      switch (__pyx_cur_scope->__pyx_v_mtype) {
        case '=':

        /* "edgedb/protocol/protocol.pyx":743
 *             try:
 *                 if mtype == DUMP_BLOCK_MSG:
 *                     if not header_received:             # <<<<<<<<<<<<<<
 *                         raise RuntimeError('data block before header block')
 *                     data_received = True
 */
        __pyx_t_4 = ((!(__pyx_cur_scope->__pyx_v_header_received != 0)) != 0);
        if (unlikely(__pyx_t_4)) {

          /* "edgedb/protocol/protocol.pyx":744
 *                 if mtype == DUMP_BLOCK_MSG:
 *                     if not header_received:
 *                         raise RuntimeError('data block before header block')             # <<<<<<<<<<<<<<
 *                     data_received = True
 * 
 */
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__69, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 744, __pyx_L11_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_Raise(__pyx_t_2, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __PYX_ERR(5, 744, __pyx_L11_error)

          /* "edgedb/protocol/protocol.pyx":743
 *             try:
 *                 if mtype == DUMP_BLOCK_MSG:
 *                     if not header_received:             # <<<<<<<<<<<<<<
 *                         raise RuntimeError('data block before header block')
 *                     data_received = True
 */
        }

        /* "edgedb/protocol/protocol.pyx":745
 *                     if not header_received:
 *                         raise RuntimeError('data block before header block')
 *                     data_received = True             # <<<<<<<<<<<<<<
 * 
 *                     await block_callback(
 */
        __pyx_cur_scope->__pyx_v_data_received = 1;

        /* "edgedb/protocol/protocol.pyx":748
 * 
 *                     await block_callback(
 *                         self.buffer.consume_message()             # <<<<<<<<<<<<<<
 *                     )
 * 
 */
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->consume_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 748, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_block_callback);
        __pyx_t_5 = __pyx_cur_scope->__pyx_v_block_callback; __pyx_t_6 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_6)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1);
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 747, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_r);
        if (likely(__pyx_r)) {
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 2;
          return __pyx_r;
          __pyx_L14_resume_from_await:;
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 747, __pyx_L11_error)
        } else {
          PyObject* exc_type = __Pyx_PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
            else __PYX_ERR(5, 747, __pyx_L11_error)
          }
        }

        /* "edgedb/protocol/protocol.pyx":742
 * 
 *             try:
 *                 if mtype == DUMP_BLOCK_MSG:             # <<<<<<<<<<<<<<
 *                     if not header_received:
 *                         raise RuntimeError('data block before header block')
 */
        break;
        case '@':

        /* "edgedb/protocol/protocol.pyx":752
 * 
 *                 elif mtype == DUMP_HEADER_BLOCK_MSG:
 *                     if header_received:             # <<<<<<<<<<<<<<
 *                         raise RuntimeError('more than one header block')
 *                     if data_received:
 */
        __pyx_t_4 = (__pyx_cur_scope->__pyx_v_header_received != 0);
        if (unlikely(__pyx_t_4)) {

          /* "edgedb/protocol/protocol.pyx":753
 *                 elif mtype == DUMP_HEADER_BLOCK_MSG:
 *                     if header_received:
 *                         raise RuntimeError('more than one header block')             # <<<<<<<<<<<<<<
 *                     if data_received:
 *                         raise RuntimeError('header block after data block')
 */
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 753, __pyx_L11_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_Raise(__pyx_t_2, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __PYX_ERR(5, 753, __pyx_L11_error)

          /* "edgedb/protocol/protocol.pyx":752
 * 
 *                 elif mtype == DUMP_HEADER_BLOCK_MSG:
 *                     if header_received:             # <<<<<<<<<<<<<<
 *                         raise RuntimeError('more than one header block')
 *                     if data_received:
 */
        }

        /* "edgedb/protocol/protocol.pyx":754
 *                     if header_received:
 *                         raise RuntimeError('more than one header block')
 *                     if data_received:             # <<<<<<<<<<<<<<
 *                         raise RuntimeError('header block after data block')
 * 
 */
        __pyx_t_4 = (__pyx_cur_scope->__pyx_v_data_received != 0);
        if (unlikely(__pyx_t_4)) {

          /* "edgedb/protocol/protocol.pyx":755
 *                         raise RuntimeError('more than one header block')
 *                     if data_received:
 *                         raise RuntimeError('header block after data block')             # <<<<<<<<<<<<<<
 * 
 *                     header_received = True
 */
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__71, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 755, __pyx_L11_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_Raise(__pyx_t_2, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __PYX_ERR(5, 755, __pyx_L11_error)

          /* "edgedb/protocol/protocol.pyx":754
 *                     if header_received:
 *                         raise RuntimeError('more than one header block')
 *                     if data_received:             # <<<<<<<<<<<<<<
 *                         raise RuntimeError('header block after data block')
 * 
 */
        }

        /* "edgedb/protocol/protocol.pyx":757
 *                         raise RuntimeError('header block after data block')
 * 
 *                     header_received = True             # <<<<<<<<<<<<<<
 * 
 *                     await header_callback(
 */
        __pyx_cur_scope->__pyx_v_header_received = 1;

        /* "edgedb/protocol/protocol.pyx":760
 * 
 *                     await header_callback(
 *                         self.buffer.consume_message()             # <<<<<<<<<<<<<<
 *                     )
 * 
 */
        __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->consume_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 760, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_header_callback);
        __pyx_t_1 = __pyx_cur_scope->__pyx_v_header_callback; __pyx_t_6 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
          if (likely(__pyx_t_6)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_1, function);
          }
        }
        __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 759, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_r);
        if (likely(__pyx_r)) {
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 3;
          return __pyx_r;
          __pyx_L17_resume_from_await:;
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 759, __pyx_L11_error)
        } else {
          PyObject* exc_type = __Pyx_PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
            else __PYX_ERR(5, 759, __pyx_L11_error)
          }
        }

        /* "edgedb/protocol/protocol.pyx":751
 *                     )
 * 
 *                 elif mtype == DUMP_HEADER_BLOCK_MSG:             # <<<<<<<<<<<<<<
 *                     if header_received:
 *                         raise RuntimeError('more than one header block')
 */
        break;
        case 'E':

        /* "edgedb/protocol/protocol.pyx":765
 *                 elif mtype == ERROR_RESPONSE_MSG:
 *                     # ErrorResponse
 *                     exc = self.parse_error_message()             # <<<<<<<<<<<<<<
 * 
 *                 elif mtype == COMMAND_COMPLETE_MSG:
 */
        __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_error_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 765, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_exc);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_exc, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;

        /* "edgedb/protocol/protocol.pyx":763
 *                     )
 * 
 *                 elif mtype == ERROR_RESPONSE_MSG:             # <<<<<<<<<<<<<<
 *                     # ErrorResponse
 *                     exc = self.parse_error_message()
 */
        break;
        case 'C':

        /* "edgedb/protocol/protocol.pyx":767
 *                     exc = self.parse_error_message()
 * 
 *                 elif mtype == COMMAND_COMPLETE_MSG:             # <<<<<<<<<<<<<<
 *                     pass
 * 
 */
        break;
        case 'Z':

        /* "edgedb/protocol/protocol.pyx":771
 * 
 *                 elif mtype == READY_FOR_COMMAND_MSG:
 *                     self.parse_sync_message()             # <<<<<<<<<<<<<<
 *                     break
 * 
 */
        __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_sync_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 771, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "edgedb/protocol/protocol.pyx":772
 *                 elif mtype == READY_FOR_COMMAND_MSG:
 *                     self.parse_sync_message()
 *                     break             # <<<<<<<<<<<<<<
 * 
 *                 else:
 */
        goto __pyx_L9_break;

        /* "edgedb/protocol/protocol.pyx":770
 *                     pass
 * 
 *                 elif mtype == READY_FOR_COMMAND_MSG:             # <<<<<<<<<<<<<<
 *                     self.parse_sync_message()
 *                     break
 */
        break;
        default:

        /* "edgedb/protocol/protocol.pyx":775
 * 
 *                 else:
 *                     self.fallthrough()             # <<<<<<<<<<<<<<
 * 
 *             finally:
 */
        __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->fallthrough(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 775, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        break;
      }
    }

    /* "edgedb/protocol/protocol.pyx":778
 * 
 *             finally:
 *                 self.buffer.finish_message()             # <<<<<<<<<<<<<<
 * 
 *         if not header_received:
 */
    /*finally:*/ {
      /*normal exit:*/{
        __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 778, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L12;
      }
      __pyx_L11_error:;
      /*exception exit:*/{
        __Pyx_PyThreadState_assign
        __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
        if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_11);
        __Pyx_XGOTREF(__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_13);
        __Pyx_XGOTREF(__pyx_t_14);
        __Pyx_XGOTREF(__pyx_t_15);
        __pyx_t_7 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_9 = __pyx_filename;
        {
          __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 778, __pyx_L21_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        }
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
        }
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_ErrRestore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
        __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
        __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_9;
        goto __pyx_L1_error;
        __pyx_L21_error:;
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
        }
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
        goto __pyx_L1_error;
      }
      __pyx_L9_break: {
        __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 778, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L5_break;
      }
      __pyx_L12:;
    }
  }
  __pyx_L5_break:;

  /* "edgedb/protocol/protocol.pyx":780
 *                 self.buffer.finish_message()
 * 
 *         if not header_received:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('header block was not received')
 * 
 */
  __pyx_t_4 = ((!(__pyx_cur_scope->__pyx_v_header_received != 0)) != 0);
  if (unlikely(__pyx_t_4)) {

    /* "edgedb/protocol/protocol.pyx":781
 * 
 *         if not header_received:
 *             raise RuntimeError('header block was not received')             # <<<<<<<<<<<<<<
 * 
 *         if exc is not None:
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__72, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 781, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(5, 781, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":780
 *                 self.buffer.finish_message()
 * 
 *         if not header_received:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('header block was not received')
 * 
 */
  }

  /* "edgedb/protocol/protocol.pyx":783
 *             raise RuntimeError('header block was not received')
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             raise exc
 * 
 */
  __pyx_t_4 = (__pyx_cur_scope->__pyx_v_exc != Py_None);
  __pyx_t_16 = (__pyx_t_4 != 0);
  if (unlikely(__pyx_t_16)) {

    /* "edgedb/protocol/protocol.pyx":784
 * 
 *         if exc is not None:
 *             raise exc             # <<<<<<<<<<<<<<
 * 
 *     async def _sync(self):
 */
    __Pyx_Raise(__pyx_cur_scope->__pyx_v_exc, 0, 0, 0);
    __PYX_ERR(5, 784, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":783
 *             raise RuntimeError('header block was not received')
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             raise exc
 * 
 */
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "edgedb/protocol/protocol.pyx":719
 *                     return ret, attrs
 * 
 *     async def dump(self, header_callback, block_callback):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer buf
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("dump", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_39generator9(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "edgedb/protocol/protocol.pyx":786
 *             raise exc
 * 
 *     async def _sync(self):             # <<<<<<<<<<<<<<
 *         cdef char mtype
 *         self.write(WriteBuffer.new_message(SYNC_MSG).end_message())
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_38_sync(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_38_sync(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_sync (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_37_sync(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_37_sync(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_sync", 0);
  __pyx_cur_scope = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync *)__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync(__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 786, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_39generator9, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_sync, __pyx_n_s_SansIOProtocol__sync, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(5, 786, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol._sync", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_39generator9(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync *__pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int32_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_sync", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L7_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 786, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":788
 *     async def _sync(self):
 *         cdef char mtype
 *         self.write(WriteBuffer.new_message(SYNC_MSG).end_message())             # <<<<<<<<<<<<<<
 *         while True:
 *             if not self.buffer.take_message():
 */
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('S')); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1)->__pyx_vtab)->end_message(((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6edgedb_7pgproto_7pgproto_WriteBuffer))))) __PYX_ERR(5, 788, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write(__pyx_cur_scope->__pyx_v_self, ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":789
 *         cdef char mtype
 *         self.write(WriteBuffer.new_message(SYNC_MSG).end_message())
 *         while True:             # <<<<<<<<<<<<<<
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 */
  while (1) {

    /* "edgedb/protocol/protocol.pyx":790
 *         self.write(WriteBuffer.new_message(SYNC_MSG).end_message())
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_3 == ((int32_t)-1))) __PYX_ERR(5, 790, __pyx_L1_error)
    __pyx_t_4 = ((!(__pyx_t_3 != 0)) != 0);
    if (__pyx_t_4) {

      /* "edgedb/protocol/protocol.pyx":791
 *         while True:
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()             # <<<<<<<<<<<<<<
 *             mtype = self.buffer.get_message_type()
 * 
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_wait_for_message); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 791, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 791, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XGOTREF(__pyx_r);
      if (likely(__pyx_r)) {
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L7_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 791, __pyx_L1_error)
      } else {
        PyObject* exc_type = __Pyx_PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
          else __PYX_ERR(5, 791, __pyx_L1_error)
        }
      }

      /* "edgedb/protocol/protocol.pyx":790
 *         self.write(WriteBuffer.new_message(SYNC_MSG).end_message())
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    }

    /* "edgedb/protocol/protocol.pyx":792
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()             # <<<<<<<<<<<<<<
 * 
 *             if mtype == READY_FOR_COMMAND_MSG:
 */
    __pyx_cur_scope->__pyx_v_mtype = __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_cur_scope->__pyx_v_self->buffer);

    /* "edgedb/protocol/protocol.pyx":794
 *             mtype = self.buffer.get_message_type()
 * 
 *             if mtype == READY_FOR_COMMAND_MSG:             # <<<<<<<<<<<<<<
 *                 self.parse_sync_message()
 *                 break
 */
    __pyx_t_4 = ((__pyx_cur_scope->__pyx_v_mtype == 'Z') != 0);
    if (__pyx_t_4) {

      /* "edgedb/protocol/protocol.pyx":795
 * 
 *             if mtype == READY_FOR_COMMAND_MSG:
 *                 self.parse_sync_message()             # <<<<<<<<<<<<<<
 *                 break
 *             else:
 */
      __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_sync_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 795, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "edgedb/protocol/protocol.pyx":796
 *             if mtype == READY_FOR_COMMAND_MSG:
 *                 self.parse_sync_message()
 *                 break             # <<<<<<<<<<<<<<
 *             else:
 *                 self.fallthrough()
 */
      goto __pyx_L5_break;

      /* "edgedb/protocol/protocol.pyx":794
 *             mtype = self.buffer.get_message_type()
 * 
 *             if mtype == READY_FOR_COMMAND_MSG:             # <<<<<<<<<<<<<<
 *                 self.parse_sync_message()
 *                 break
 */
    }

    /* "edgedb/protocol/protocol.pyx":798
 *                 break
 *             else:
 *                 self.fallthrough()             # <<<<<<<<<<<<<<
 * 
 *     async def restore(self, bytes header, data_gen):
 */
    /*else*/ {
      __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->fallthrough(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 798, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  }
  __pyx_L5_break:;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "edgedb/protocol/protocol.pyx":786
 *             raise exc
 * 
 *     async def _sync(self):             # <<<<<<<<<<<<<<
 *         cdef char mtype
 *         self.write(WriteBuffer.new_message(SYNC_MSG).end_message())
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("_sync", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_42generator10(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "edgedb/protocol/protocol.pyx":800
 *                 self.fallthrough()
 * 
 *     async def restore(self, bytes header, data_gen):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer buf
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_41restore(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_41restore(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_header = 0;
  PyObject *__pyx_v_data_gen = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("restore (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_header,&__pyx_n_s_data_gen,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_header)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data_gen)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("restore", 1, 2, 2, 1); __PYX_ERR(5, 800, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "restore") < 0)) __PYX_ERR(5, 800, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_header = ((PyObject*)values[0]);
    __pyx_v_data_gen = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("restore", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(5, 800, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.restore", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_header), (&PyBytes_Type), 1, "header", 1))) __PYX_ERR(5, 800, __pyx_L1_error)
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_40restore(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self), __pyx_v_header, __pyx_v_data_gen);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_40restore(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_header, PyObject *__pyx_v_data_gen) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("restore", 0);
  __pyx_cur_scope = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore *)__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore(__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 800, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_header = __pyx_v_header;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_header);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_header);
  __pyx_cur_scope->__pyx_v_data_gen = __pyx_v_data_gen;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_data_gen);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_data_gen);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_42generator10, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_restore, __pyx_n_s_SansIOProtocol_restore, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(5, 800, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.restore", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_42generator10(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore *__pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int32_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int16_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  char const *__pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  char const *__pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("restore", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L7_resume_from_await;
    case 2: goto __pyx_L18_resume_from_await;
    case 3: goto __pyx_L21_resume_from_await;
    case 4: goto __pyx_L23_resume_from_await;
    case 5: goto __pyx_L27_resume_from_await;
    case 6: goto __pyx_L31_resume_from_await;
    case 7: goto __pyx_L42_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 800, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":805
 *             char mtype
 * 
 *         self.ensure_connected()             # <<<<<<<<<<<<<<
 *         self.reset_status()
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->ensure_connected(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 805, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":806
 * 
 *         self.ensure_connected()
 *         self.reset_status()             # <<<<<<<<<<<<<<
 * 
 *         buf = WriteBuffer.new_message(RESTORE_MSG)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->reset_status(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 806, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":808
 *         self.reset_status()
 * 
 *         buf = WriteBuffer.new_message(RESTORE_MSG)             # <<<<<<<<<<<<<<
 *         buf.write_int16(0)  # no headers
 *         buf.write_int16(1)  # -j level
 */
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('<')); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 808, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_buf = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":809
 * 
 *         buf = WriteBuffer.new_message(RESTORE_MSG)
 *         buf.write_int16(0)  # no headers             # <<<<<<<<<<<<<<
 *         buf.write_int16(1)  # -j level
 *         buf.write_bytes(header)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_int16(__pyx_cur_scope->__pyx_v_buf, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 809, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":810
 *         buf = WriteBuffer.new_message(RESTORE_MSG)
 *         buf.write_int16(0)  # no headers
 *         buf.write_int16(1)  # -j level             # <<<<<<<<<<<<<<
 *         buf.write_bytes(header)
 *         buf.end_message()
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_int16(__pyx_cur_scope->__pyx_v_buf, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 810, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":811
 *         buf.write_int16(0)  # no headers
 *         buf.write_int16(1)  # -j level
 *         buf.write_bytes(header)             # <<<<<<<<<<<<<<
 *         buf.end_message()
 *         self.write(buf)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_bytes(__pyx_cur_scope->__pyx_v_buf, __pyx_cur_scope->__pyx_v_header); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":812
 *         buf.write_int16(1)  # -j level
 *         buf.write_bytes(header)
 *         buf.end_message()             # <<<<<<<<<<<<<<
 *         self.write(buf)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->end_message(__pyx_cur_scope->__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 812, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":813
 *         buf.write_bytes(header)
 *         buf.end_message()
 *         self.write(buf)             # <<<<<<<<<<<<<<
 * 
 *         exc = None
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 813, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":815
 *         self.write(buf)
 * 
 *         exc = None             # <<<<<<<<<<<<<<
 *         while True:
 *             if not self.buffer.take_message():
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_cur_scope->__pyx_v_exc = Py_None;

  /* "edgedb/protocol/protocol.pyx":816
 * 
 *         exc = None
 *         while True:             # <<<<<<<<<<<<<<
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 */
  while (1) {

    /* "edgedb/protocol/protocol.pyx":817
 *         exc = None
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_2 == ((int32_t)-1))) __PYX_ERR(5, 817, __pyx_L1_error)
    __pyx_t_3 = ((!(__pyx_t_2 != 0)) != 0);
    if (__pyx_t_3) {

      /* "edgedb/protocol/protocol.pyx":818
 *         while True:
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()             # <<<<<<<<<<<<<<
 *             mtype = self.buffer.get_message_type()
 * 
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_wait_for_message); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 818, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 818, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XGOTREF(__pyx_r);
      if (likely(__pyx_r)) {
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L7_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 818, __pyx_L1_error)
      } else {
        PyObject* exc_type = __Pyx_PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
          else __PYX_ERR(5, 818, __pyx_L1_error)
        }
      }

      /* "edgedb/protocol/protocol.pyx":817
 *         exc = None
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    }

    /* "edgedb/protocol/protocol.pyx":819
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()             # <<<<<<<<<<<<<<
 * 
 *             try:
 */
    __pyx_cur_scope->__pyx_v_mtype = __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_cur_scope->__pyx_v_self->buffer);

    /* "edgedb/protocol/protocol.pyx":821
 *             mtype = self.buffer.get_message_type()
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 if mtype == RESTORE_READY_MSG:
 *                     self.ignore_headers()
 */
    /*try:*/ {

      /* "edgedb/protocol/protocol.pyx":822
 * 
 *             try:
 *                 if mtype == RESTORE_READY_MSG:             # <<<<<<<<<<<<<<
 *                     self.ignore_headers()
 *                     self.buffer.read_int16()  # discard -j level
 */
      switch (__pyx_cur_scope->__pyx_v_mtype) {
        case '+':

        /* "edgedb/protocol/protocol.pyx":823
 *             try:
 *                 if mtype == RESTORE_READY_MSG:
 *                     self.ignore_headers()             # <<<<<<<<<<<<<<
 *                     self.buffer.read_int16()  # discard -j level
 *                     break
 */
        __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_ignore_headers(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 823, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "edgedb/protocol/protocol.pyx":824
 *                 if mtype == RESTORE_READY_MSG:
 *                     self.ignore_headers()
 *                     self.buffer.read_int16()  # discard -j level             # <<<<<<<<<<<<<<
 *                     break
 *                 elif mtype == ERROR_RESPONSE_MSG:
 */
        __pyx_t_6 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->read_int16(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_6 == ((int16_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 824, __pyx_L11_error)

        /* "edgedb/protocol/protocol.pyx":825
 *                     self.ignore_headers()
 *                     self.buffer.read_int16()  # discard -j level
 *                     break             # <<<<<<<<<<<<<<
 *                 elif mtype == ERROR_RESPONSE_MSG:
 *                     exc = self.parse_error_message()
 */
        goto __pyx_L9_break;

        /* "edgedb/protocol/protocol.pyx":822
 * 
 *             try:
 *                 if mtype == RESTORE_READY_MSG:             # <<<<<<<<<<<<<<
 *                     self.ignore_headers()
 *                     self.buffer.read_int16()  # discard -j level
 */
        break;
        case 'E':

        /* "edgedb/protocol/protocol.pyx":827
 *                     break
 *                 elif mtype == ERROR_RESPONSE_MSG:
 *                     exc = self.parse_error_message()             # <<<<<<<<<<<<<<
 *                     break
 *                 else:
 */
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_error_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 827, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_exc);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_exc, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_1 = 0;

        /* "edgedb/protocol/protocol.pyx":828
 *                 elif mtype == ERROR_RESPONSE_MSG:
 *                     exc = self.parse_error_message()
 *                     break             # <<<<<<<<<<<<<<
 *                 else:
 *                     self.fallthrough()
 */
        goto __pyx_L9_break;

        /* "edgedb/protocol/protocol.pyx":826
 *                     self.buffer.read_int16()  # discard -j level
 *                     break
 *                 elif mtype == ERROR_RESPONSE_MSG:             # <<<<<<<<<<<<<<
 *                     exc = self.parse_error_message()
 *                     break
 */
        break;
        default:

        /* "edgedb/protocol/protocol.pyx":830
 *                     break
 *                 else:
 *                     self.fallthrough()             # <<<<<<<<<<<<<<
 *             finally:
 *                 self.buffer.finish_message()
 */
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->fallthrough(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 830, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        break;
      }
    }

    /* "edgedb/protocol/protocol.pyx":832
 *                     self.fallthrough()
 *             finally:
 *                 self.buffer.finish_message()             # <<<<<<<<<<<<<<
 * 
 *         if exc is not None:
 */
    /*finally:*/ {
      /*normal exit:*/{
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 832, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L12;
      }
      __pyx_L11_error:;
      /*exception exit:*/{
        __Pyx_PyThreadState_assign
        __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
        if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_11);
        __Pyx_XGOTREF(__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_13);
        __Pyx_XGOTREF(__pyx_t_14);
        __Pyx_XGOTREF(__pyx_t_15);
        __pyx_t_7 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_9 = __pyx_filename;
        {
          __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 832, __pyx_L16_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        }
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
        }
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_ErrRestore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
        __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
        __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_9;
        goto __pyx_L1_error;
        __pyx_L16_error:;
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
        }
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
        goto __pyx_L1_error;
      }
      __pyx_L9_break: {
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 832, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L5_break;
      }
      __pyx_L12:;
    }
  }
  __pyx_L5_break:;

  /* "edgedb/protocol/protocol.pyx":834
 *                 self.buffer.finish_message()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             await self._sync()
 *             raise exc
 */
  __pyx_t_3 = (__pyx_cur_scope->__pyx_v_exc != Py_None);
  __pyx_t_16 = (__pyx_t_3 != 0);
  if (unlikely(__pyx_t_16)) {

    /* "edgedb/protocol/protocol.pyx":835
 * 
 *         if exc is not None:
 *             await self._sync()             # <<<<<<<<<<<<<<
 *             raise exc
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_sync); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XGOTREF(__pyx_r);
    if (likely(__pyx_r)) {
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L18_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 835, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(5, 835, __pyx_L1_error)
      }
    }

    /* "edgedb/protocol/protocol.pyx":836
 *         if exc is not None:
 *             await self._sync()
 *             raise exc             # <<<<<<<<<<<<<<
 * 
 *         # TODO: flow-control is missing here. For now this is fine
 */
    __Pyx_Raise(__pyx_cur_scope->__pyx_v_exc, 0, 0, 0);
    __PYX_ERR(5, 836, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":834
 *                 self.buffer.finish_message()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             await self._sync()
 *             raise exc
 */
  }

  /* "edgedb/protocol/protocol.pyx":841
 *         # since this method is only called on a blocking connection.
 * 
 *         async for data in data_gen:             # <<<<<<<<<<<<<<
 *             buf = WriteBuffer.new_message(DUMP_BLOCK_MSG)
 *             buf.write_bytes(data)
 */
  __pyx_t_1 = __Pyx_Coroutine_GetAsyncIter(__pyx_cur_scope->__pyx_v_data_gen); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 841, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  for (;;) {
    __pyx_t_4 = __Pyx_Coroutine_AsyncIterNext(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 841, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XGOTREF(__pyx_r);
    if (likely(__pyx_r)) {
      __Pyx_XGIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 3;
      return __pyx_r;
      __pyx_L21_resume_from_await:;
      __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
      __pyx_cur_scope->__pyx_t_0 = 0;
      __Pyx_XGOTREF(__pyx_t_1);
      if (unlikely(!__pyx_sent_value)) {
        PyObject* exc_type = __Pyx_PyErr_Occurred();
        if (unlikely(exc_type && (exc_type == __Pyx_PyExc_StopAsyncIteration || ( exc_type != PyExc_StopIteration && exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, __Pyx_PyExc_StopAsyncIteration))))) {
          PyErr_Clear();
          break;
        }
        __PYX_ERR(5, 841, __pyx_L1_error)
      }
      __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (unlikely(exc_type && (exc_type == __Pyx_PyExc_StopAsyncIteration || ( exc_type != PyExc_StopIteration && exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, __Pyx_PyExc_StopAsyncIteration))))) {
        PyErr_Clear();
        break;
      }
      __pyx_t_4 = NULL;
      if (__Pyx_PyGen_FetchStopIterationValue(&__pyx_t_4) < 0) __PYX_ERR(5, 841, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_data);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_data, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "edgedb/protocol/protocol.pyx":842
 * 
 *         async for data in data_gen:
 *             buf = WriteBuffer.new_message(DUMP_BLOCK_MSG)             # <<<<<<<<<<<<<<
 *             buf.write_bytes(data)
 *             self.write(buf.end_message())
 */
    __pyx_t_4 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('=')); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 842, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_buf));
    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_buf, ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_4));
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "edgedb/protocol/protocol.pyx":843
 *         async for data in data_gen:
 *             buf = WriteBuffer.new_message(DUMP_BLOCK_MSG)
 *             buf.write_bytes(data)             # <<<<<<<<<<<<<<
 *             self.write(buf.end_message())
 * 
 */
    if (!(likely(PyBytes_CheckExact(__pyx_cur_scope->__pyx_v_data))||((__pyx_cur_scope->__pyx_v_data) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_cur_scope->__pyx_v_data)->tp_name), 0))) __PYX_ERR(5, 843, __pyx_L1_error)
    __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->write_bytes(__pyx_cur_scope->__pyx_v_buf, ((PyObject*)__pyx_cur_scope->__pyx_v_data)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 843, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "edgedb/protocol/protocol.pyx":844
 *             buf = WriteBuffer.new_message(DUMP_BLOCK_MSG)
 *             buf.write_bytes(data)
 *             self.write(buf.end_message())             # <<<<<<<<<<<<<<
 * 
 *             if not self.buffer.take_message():
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_buf->__pyx_vtab)->end_message(__pyx_cur_scope->__pyx_v_buf); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 844, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_6edgedb_7pgproto_7pgproto_WriteBuffer))))) __PYX_ERR(5, 844, __pyx_L1_error)
    __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write(__pyx_cur_scope->__pyx_v_self, ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 844, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "edgedb/protocol/protocol.pyx":846
 *             self.write(buf.end_message())
 * 
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.try_recv_eagerly()
 *             if self.buffer.take_message():
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_2 == ((int32_t)-1))) __PYX_ERR(5, 846, __pyx_L1_error)
    __pyx_t_16 = ((!(__pyx_t_2 != 0)) != 0);
    if (__pyx_t_16) {

      /* "edgedb/protocol/protocol.pyx":847
 * 
 *             if not self.buffer.take_message():
 *                 await self.try_recv_eagerly()             # <<<<<<<<<<<<<<
 *             if self.buffer.take_message():
 *                 # Check if we received an error.
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_try_recv_eagerly); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 847, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_17 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_17)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_17);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_5 = (__pyx_t_17) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_17) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 847, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XGOTREF(__pyx_r);
      if (likely(__pyx_r)) {
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 4;
        return __pyx_r;
        __pyx_L23_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 847, __pyx_L1_error)
      } else {
        PyObject* exc_type = __Pyx_PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
          else __PYX_ERR(5, 847, __pyx_L1_error)
        }
      }

      /* "edgedb/protocol/protocol.pyx":846
 *             self.write(buf.end_message())
 * 
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.try_recv_eagerly()
 *             if self.buffer.take_message():
 */
    }

    /* "edgedb/protocol/protocol.pyx":848
 *             if not self.buffer.take_message():
 *                 await self.try_recv_eagerly()
 *             if self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 # Check if we received an error.
 *                 mtype = self.buffer.get_message_type()
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_2 == ((int32_t)-1))) __PYX_ERR(5, 848, __pyx_L1_error)
    __pyx_t_16 = (__pyx_t_2 != 0);
    if (__pyx_t_16) {

      /* "edgedb/protocol/protocol.pyx":850
 *             if self.buffer.take_message():
 *                 # Check if we received an error.
 *                 mtype = self.buffer.get_message_type()             # <<<<<<<<<<<<<<
 *                 if mtype == ERROR_RESPONSE_MSG:
 *                     exc = self.parse_error_message()
 */
      __pyx_cur_scope->__pyx_v_mtype = __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_cur_scope->__pyx_v_self->buffer);

      /* "edgedb/protocol/protocol.pyx":851
 *                 # Check if we received an error.
 *                 mtype = self.buffer.get_message_type()
 *                 if mtype == ERROR_RESPONSE_MSG:             # <<<<<<<<<<<<<<
 *                     exc = self.parse_error_message()
 *                     self.buffer.finish_message()
 */
      __pyx_t_16 = ((__pyx_cur_scope->__pyx_v_mtype == 'E') != 0);
      if (__pyx_t_16) {

        /* "edgedb/protocol/protocol.pyx":852
 *                 mtype = self.buffer.get_message_type()
 *                 if mtype == ERROR_RESPONSE_MSG:
 *                     exc = self.parse_error_message()             # <<<<<<<<<<<<<<
 *                     self.buffer.finish_message()
 *                     break
 */
        __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_error_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 852, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_exc);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_exc, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __pyx_t_5 = 0;

        /* "edgedb/protocol/protocol.pyx":853
 *                 if mtype == ERROR_RESPONSE_MSG:
 *                     exc = self.parse_error_message()
 *                     self.buffer.finish_message()             # <<<<<<<<<<<<<<
 *                     break
 *                 else:
 */
        __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 853, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "edgedb/protocol/protocol.pyx":854
 *                     exc = self.parse_error_message()
 *                     self.buffer.finish_message()
 *                     break             # <<<<<<<<<<<<<<
 *                 else:
 *                     self.fallthrough()
 */
        goto __pyx_L20_break;

        /* "edgedb/protocol/protocol.pyx":851
 *                 # Check if we received an error.
 *                 mtype = self.buffer.get_message_type()
 *                 if mtype == ERROR_RESPONSE_MSG:             # <<<<<<<<<<<<<<
 *                     exc = self.parse_error_message()
 *                     self.buffer.finish_message()
 */
      }

      /* "edgedb/protocol/protocol.pyx":856
 *                     break
 *                 else:
 *                     self.fallthrough()             # <<<<<<<<<<<<<<
 * 
 *         if exc is not None:
 */
      /*else*/ {
        __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->fallthrough(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 856, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }

      /* "edgedb/protocol/protocol.pyx":848
 *             if not self.buffer.take_message():
 *                 await self.try_recv_eagerly()
 *             if self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 # Check if we received an error.
 *                 mtype = self.buffer.get_message_type()
 */
    }

    /* "edgedb/protocol/protocol.pyx":841
 *         # since this method is only called on a blocking connection.
 * 
 *         async for data in data_gen:             # <<<<<<<<<<<<<<
 *             buf = WriteBuffer.new_message(DUMP_BLOCK_MSG)
 *             buf.write_bytes(data)
 */
  }
  __pyx_L20_break:;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":858
 *                     self.fallthrough()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             await self._sync()
 *             raise exc
 */
  __pyx_t_16 = (__pyx_cur_scope->__pyx_v_exc != Py_None);
  __pyx_t_3 = (__pyx_t_16 != 0);
  if (unlikely(__pyx_t_3)) {

    /* "edgedb/protocol/protocol.pyx":859
 * 
 *         if exc is not None:
 *             await self._sync()             # <<<<<<<<<<<<<<
 *             raise exc
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_sync); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XGOTREF(__pyx_r);
    if (likely(__pyx_r)) {
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 5;
      return __pyx_r;
      __pyx_L27_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 859, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(5, 859, __pyx_L1_error)
      }
    }

    /* "edgedb/protocol/protocol.pyx":860
 *         if exc is not None:
 *             await self._sync()
 *             raise exc             # <<<<<<<<<<<<<<
 * 
 *         self.write(WriteBuffer.new_message(RESTORE_EOF_MSG).end_message())
 */
    __Pyx_Raise(__pyx_cur_scope->__pyx_v_exc, 0, 0, 0);
    __PYX_ERR(5, 860, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":858
 *                     self.fallthrough()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             await self._sync()
 *             raise exc
 */
  }

  /* "edgedb/protocol/protocol.pyx":862
 *             raise exc
 * 
 *         self.write(WriteBuffer.new_message(RESTORE_EOF_MSG).end_message())             # <<<<<<<<<<<<<<
 * 
 *         exc = None
 */
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('.')); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 862, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1)->__pyx_vtab)->end_message(((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 862, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_6edgedb_7pgproto_7pgproto_WriteBuffer))))) __PYX_ERR(5, 862, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write(__pyx_cur_scope->__pyx_v_self, ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_5)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 862, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":864
 *         self.write(WriteBuffer.new_message(RESTORE_EOF_MSG).end_message())
 * 
 *         exc = None             # <<<<<<<<<<<<<<
 *         while True:
 *             if not self.buffer.take_message():
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_exc);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_exc, Py_None);
  __Pyx_GIVEREF(Py_None);

  /* "edgedb/protocol/protocol.pyx":865
 * 
 *         exc = None
 *         while True:             # <<<<<<<<<<<<<<
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 */
  while (1) {

    /* "edgedb/protocol/protocol.pyx":866
 *         exc = None
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_2 == ((int32_t)-1))) __PYX_ERR(5, 866, __pyx_L1_error)
    __pyx_t_3 = ((!(__pyx_t_2 != 0)) != 0);
    if (__pyx_t_3) {

      /* "edgedb/protocol/protocol.pyx":867
 *         while True:
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()             # <<<<<<<<<<<<<<
 *             mtype = self.buffer.get_message_type()
 * 
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_wait_for_message); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 867, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 867, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XGOTREF(__pyx_r);
      if (likely(__pyx_r)) {
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 6;
        return __pyx_r;
        __pyx_L31_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 867, __pyx_L1_error)
      } else {
        PyObject* exc_type = __Pyx_PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
          else __PYX_ERR(5, 867, __pyx_L1_error)
        }
      }

      /* "edgedb/protocol/protocol.pyx":866
 *         exc = None
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    }

    /* "edgedb/protocol/protocol.pyx":868
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()             # <<<<<<<<<<<<<<
 * 
 *             try:
 */
    __pyx_cur_scope->__pyx_v_mtype = __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_cur_scope->__pyx_v_self->buffer);

    /* "edgedb/protocol/protocol.pyx":870
 *             mtype = self.buffer.get_message_type()
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 if mtype == COMMAND_COMPLETE_MSG:
 *                     break
 */
    /*try:*/ {

      /* "edgedb/protocol/protocol.pyx":871
 * 
 *             try:
 *                 if mtype == COMMAND_COMPLETE_MSG:             # <<<<<<<<<<<<<<
 *                     break
 *                 elif mtype == ERROR_RESPONSE_MSG:
 */
      switch (__pyx_cur_scope->__pyx_v_mtype) {
        case 'C':

        /* "edgedb/protocol/protocol.pyx":872
 *             try:
 *                 if mtype == COMMAND_COMPLETE_MSG:
 *                     break             # <<<<<<<<<<<<<<
 *                 elif mtype == ERROR_RESPONSE_MSG:
 *                     exc = self.parse_error_message()
 */
        goto __pyx_L33_break;

        /* "edgedb/protocol/protocol.pyx":871
 * 
 *             try:
 *                 if mtype == COMMAND_COMPLETE_MSG:             # <<<<<<<<<<<<<<
 *                     break
 *                 elif mtype == ERROR_RESPONSE_MSG:
 */
        break;
        case 'E':

        /* "edgedb/protocol/protocol.pyx":874
 *                     break
 *                 elif mtype == ERROR_RESPONSE_MSG:
 *                     exc = self.parse_error_message()             # <<<<<<<<<<<<<<
 *                     break
 *                 else:
 */
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_error_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 874, __pyx_L35_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_exc);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_exc, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_1 = 0;

        /* "edgedb/protocol/protocol.pyx":875
 *                 elif mtype == ERROR_RESPONSE_MSG:
 *                     exc = self.parse_error_message()
 *                     break             # <<<<<<<<<<<<<<
 *                 else:
 *                     self.fallthrough()
 */
        goto __pyx_L33_break;

        /* "edgedb/protocol/protocol.pyx":873
 *                 if mtype == COMMAND_COMPLETE_MSG:
 *                     break
 *                 elif mtype == ERROR_RESPONSE_MSG:             # <<<<<<<<<<<<<<
 *                     exc = self.parse_error_message()
 *                     break
 */
        break;
        default:

        /* "edgedb/protocol/protocol.pyx":877
 *                     break
 *                 else:
 *                     self.fallthrough()             # <<<<<<<<<<<<<<
 *             finally:
 *                 self.buffer.finish_message()
 */
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->fallthrough(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 877, __pyx_L35_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        break;
      }
    }

    /* "edgedb/protocol/protocol.pyx":879
 *                     self.fallthrough()
 *             finally:
 *                 self.buffer.finish_message()             # <<<<<<<<<<<<<<
 * 
 *         if exc is not None:
 */
    /*finally:*/ {
      /*normal exit:*/{
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 879, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L36;
      }
      __pyx_L35_error:;
      /*exception exit:*/{
        __Pyx_PyThreadState_assign
        __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
        if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
        __Pyx_XGOTREF(__pyx_t_15);
        __Pyx_XGOTREF(__pyx_t_14);
        __Pyx_XGOTREF(__pyx_t_13);
        __Pyx_XGOTREF(__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_11);
        __Pyx_XGOTREF(__pyx_t_10);
        __pyx_t_8 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_18 = __pyx_filename;
        {
          __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 879, __pyx_L40_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        }
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_10);
        }
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ErrRestore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
        __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0;
        __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_18;
        goto __pyx_L1_error;
        __pyx_L40_error:;
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_10);
        }
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0;
        goto __pyx_L1_error;
      }
      __pyx_L33_break: {
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 879, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L29_break;
      }
      __pyx_L36:;
    }
  }
  __pyx_L29_break:;

  /* "edgedb/protocol/protocol.pyx":881
 *                 self.buffer.finish_message()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             await self._sync()
 *             raise exc
 */
  __pyx_t_3 = (__pyx_cur_scope->__pyx_v_exc != Py_None);
  __pyx_t_16 = (__pyx_t_3 != 0);
  if (unlikely(__pyx_t_16)) {

    /* "edgedb/protocol/protocol.pyx":882
 * 
 *         if exc is not None:
 *             await self._sync()             # <<<<<<<<<<<<<<
 *             raise exc
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_sync); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 882, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 882, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XGOTREF(__pyx_r);
    if (likely(__pyx_r)) {
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 7;
      return __pyx_r;
      __pyx_L42_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 882, __pyx_L1_error)
    } else {
      PyObject* exc_type = __Pyx_PyErr_Occurred();
      if (exc_type) {
        if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
        else __PYX_ERR(5, 882, __pyx_L1_error)
      }
    }

    /* "edgedb/protocol/protocol.pyx":883
 *         if exc is not None:
 *             await self._sync()
 *             raise exc             # <<<<<<<<<<<<<<
 * 
 *     def terminate(self):
 */
    __Pyx_Raise(__pyx_cur_scope->__pyx_v_exc, 0, 0, 0);
    __PYX_ERR(5, 883, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":881
 *                 self.buffer.finish_message()
 * 
 *         if exc is not None:             # <<<<<<<<<<<<<<
 *             await self._sync()
 *             raise exc
 */
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "edgedb/protocol/protocol.pyx":800
 *                 self.fallthrough()
 * 
 *     async def restore(self, bytes header, data_gen):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer buf
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_AddTraceback("restore", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":885
 *             raise exc
 * 
 *     def terminate(self):             # <<<<<<<<<<<<<<
 *         try:
 *             self.write(WriteBuffer.new_message(TERMINATE_MSG).end_message())
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_44terminate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_44terminate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("terminate (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_43terminate(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_43terminate(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("terminate", 0);

  /* "edgedb/protocol/protocol.pyx":886
 * 
 *     def terminate(self):
 *         try:             # <<<<<<<<<<<<<<
 *             self.write(WriteBuffer.new_message(TERMINATE_MSG).end_message())
 *         except errors.ClientConnectionError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "edgedb/protocol/protocol.pyx":887
 *     def terminate(self):
 *         try:
 *             self.write(WriteBuffer.new_message(TERMINATE_MSG).end_message())             # <<<<<<<<<<<<<<
 *         except errors.ClientConnectionError:
 *             pass
 */
      __pyx_t_4 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('X')); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 887, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_4)->__pyx_vtab)->end_message(((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 887, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_6edgedb_7pgproto_7pgproto_WriteBuffer))))) __PYX_ERR(5, 887, __pyx_L3_error)
      __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self->__pyx_vtab)->write(__pyx_v_self, ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 887, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "edgedb/protocol/protocol.pyx":886
 * 
 *     def terminate(self):
 *         try:             # <<<<<<<<<<<<<<
 *             self.write(WriteBuffer.new_message(TERMINATE_MSG).end_message())
 *         except errors.ClientConnectionError:
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "edgedb/protocol/protocol.pyx":888
 *         try:
 *             self.write(WriteBuffer.new_message(TERMINATE_MSG).end_message())
 *         except errors.ClientConnectionError:             # <<<<<<<<<<<<<<
 *             pass
 * 
 */
    __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_errors); if (unlikely(!__pyx_t_7)) __PYX_ERR(5, 888, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_ClientConnectionError); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 888, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_9 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_4, __pyx_t_8);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_ErrRestore(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0;
    if (__pyx_t_9) {
      __Pyx_ErrRestore(0,0,0);
      goto __pyx_L4_exception_handled;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "edgedb/protocol/protocol.pyx":886
 * 
 *     def terminate(self):
 *         try:             # <<<<<<<<<<<<<<
 *             self.write(WriteBuffer.new_message(TERMINATE_MSG).end_message())
 *         except errors.ClientConnectionError:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L8_try_end:;
  }

  /* "edgedb/protocol/protocol.pyx":885
 *             raise exc
 * 
 *     def terminate(self):             # <<<<<<<<<<<<<<
 *         try:
 *             self.write(WriteBuffer.new_message(TERMINATE_MSG).end_message())
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.terminate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_47generator11(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "edgedb/protocol/protocol.pyx":891
 *             pass
 * 
 *     async def connect(self):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer ver_buf
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_46connect(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_46connect(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("connect (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_45connect(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_45connect(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("connect", 0);
  __pyx_cur_scope = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect *)__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect(__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 891, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_47generator11, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_connect, __pyx_n_s_SansIOProtocol_connect, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(5, 891, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.connect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_47generator11(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect *__pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int32_t __pyx_t_9;
  int16_t __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  Py_UCS4 __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("connect", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L4_resume_from_await;
    case 2: goto __pyx_L11_resume_from_await;
    case 3: goto __pyx_L16_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 891, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":899
 *             int32_t status
 * 
 *         await self.wait_for_connect()             # <<<<<<<<<<<<<<
 * 
 *         if self.connected:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_wait_for_connect); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_XGOTREF(__pyx_r);
  if (likely(__pyx_r)) {
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L4_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 899, __pyx_L1_error)
  } else {
    PyObject* exc_type = __Pyx_PyErr_Occurred();
    if (exc_type) {
      if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
      else __PYX_ERR(5, 899, __pyx_L1_error)
    }
  }

  /* "edgedb/protocol/protocol.pyx":901
 *         await self.wait_for_connect()
 * 
 *         if self.connected:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('already connected')
 * 
 */
  __pyx_t_4 = (__pyx_cur_scope->__pyx_v_self->connected != 0);
  if (unlikely(__pyx_t_4)) {

    /* "edgedb/protocol/protocol.pyx":902
 * 
 *         if self.connected:
 *             raise RuntimeError('already connected')             # <<<<<<<<<<<<<<
 * 
 *         # protocol version
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__73, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 902, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(5, 902, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":901
 *         await self.wait_for_connect()
 * 
 *         if self.connected:             # <<<<<<<<<<<<<<
 *             raise RuntimeError('already connected')
 * 
 */
  }

  /* "edgedb/protocol/protocol.pyx":905
 * 
 *         # protocol version
 *         handshake_buf = WriteBuffer.new_message(CLIENT_HANDSHAKE_MSG)             # <<<<<<<<<<<<<<
 *         handshake_buf.write_int16(PROTO_VER_MAJOR)
 *         handshake_buf.write_int16(PROTO_VER_MINOR)
 */
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('V')); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 905, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_handshake_buf = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":906
 *         # protocol version
 *         handshake_buf = WriteBuffer.new_message(CLIENT_HANDSHAKE_MSG)
 *         handshake_buf.write_int16(PROTO_VER_MAJOR)             # <<<<<<<<<<<<<<
 *         handshake_buf.write_int16(PROTO_VER_MINOR)
 *         self.protocol_version = (PROTO_VER_MAJOR, PROTO_VER_MINOR)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_handshake_buf->__pyx_vtab)->write_int16(__pyx_cur_scope->__pyx_v_handshake_buf, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 906, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":907
 *         handshake_buf = WriteBuffer.new_message(CLIENT_HANDSHAKE_MSG)
 *         handshake_buf.write_int16(PROTO_VER_MAJOR)
 *         handshake_buf.write_int16(PROTO_VER_MINOR)             # <<<<<<<<<<<<<<
 *         self.protocol_version = (PROTO_VER_MAJOR, PROTO_VER_MINOR)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_handshake_buf->__pyx_vtab)->write_int16(__pyx_cur_scope->__pyx_v_handshake_buf, 13); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 907, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":908
 *         handshake_buf.write_int16(PROTO_VER_MAJOR)
 *         handshake_buf.write_int16(PROTO_VER_MINOR)
 *         self.protocol_version = (PROTO_VER_MAJOR, PROTO_VER_MINOR)             # <<<<<<<<<<<<<<
 * 
 *         # params
 */
  __Pyx_INCREF(__pyx_tuple__74);
  __Pyx_GIVEREF(__pyx_tuple__74);
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->protocol_version);
  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->protocol_version);
  __pyx_cur_scope->__pyx_v_self->protocol_version = __pyx_tuple__74;

  /* "edgedb/protocol/protocol.pyx":912
 *         # params
 *         params = {
 *             'user': self.con_params.user,             # <<<<<<<<<<<<<<
 *             'database': self.con_params.database,
 *         }
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->con_params, __pyx_n_s_user); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_user, __pyx_t_2) < 0) __PYX_ERR(5, 912, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":913
 *         params = {
 *             'user': self.con_params.user,
 *             'database': self.con_params.database,             # <<<<<<<<<<<<<<
 *         }
 *         handshake_buf.write_int16(len(params))
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->con_params, __pyx_n_s_database); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 913, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_database, __pyx_t_2) < 0) __PYX_ERR(5, 912, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_params = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":915
 *             'database': self.con_params.database,
 *         }
 *         handshake_buf.write_int16(len(params))             # <<<<<<<<<<<<<<
 *         for k, v in params.items():
 *             handshake_buf.write_len_prefixed_utf8(k)
 */
  __pyx_t_5 = PyDict_Size(__pyx_cur_scope->__pyx_v_params); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(5, 915, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_handshake_buf->__pyx_vtab)->write_int16(__pyx_cur_scope->__pyx_v_handshake_buf, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 915, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":916
 *         }
 *         handshake_buf.write_int16(len(params))
 *         for k, v in params.items():             # <<<<<<<<<<<<<<
 *             handshake_buf.write_len_prefixed_utf8(k)
 *             handshake_buf.write_len_prefixed_utf8(v)
 */
  __pyx_t_5 = 0;
  __pyx_t_2 = __Pyx_dict_iterator(__pyx_cur_scope->__pyx_v_params, 1, __pyx_n_s_items, (&__pyx_t_6), (&__pyx_t_7)); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 916, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_2;
  __pyx_t_2 = 0;
  while (1) {
    __pyx_t_8 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_6, &__pyx_t_5, &__pyx_t_2, &__pyx_t_3, NULL, __pyx_t_7);
    if (unlikely(__pyx_t_8 == 0)) break;
    if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(5, 916, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_k);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_k, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;

    /* "edgedb/protocol/protocol.pyx":917
 *         handshake_buf.write_int16(len(params))
 *         for k, v in params.items():
 *             handshake_buf.write_len_prefixed_utf8(k)             # <<<<<<<<<<<<<<
 *             handshake_buf.write_len_prefixed_utf8(v)
 * 
 */
    if (!(likely(PyUnicode_CheckExact(__pyx_cur_scope->__pyx_v_k))||((__pyx_cur_scope->__pyx_v_k) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_cur_scope->__pyx_v_k)->tp_name), 0))) __PYX_ERR(5, 917, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_write_len_prefixed_utf8(__pyx_cur_scope->__pyx_v_handshake_buf, ((PyObject*)__pyx_cur_scope->__pyx_v_k)); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 917, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "edgedb/protocol/protocol.pyx":918
 *         for k, v in params.items():
 *             handshake_buf.write_len_prefixed_utf8(k)
 *             handshake_buf.write_len_prefixed_utf8(v)             # <<<<<<<<<<<<<<
 * 
 *         # no extensions requested
 */
    if (!(likely(PyUnicode_CheckExact(__pyx_cur_scope->__pyx_v_v))||((__pyx_cur_scope->__pyx_v_v) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_cur_scope->__pyx_v_v)->tp_name), 0))) __PYX_ERR(5, 918, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_write_len_prefixed_utf8(__pyx_cur_scope->__pyx_v_handshake_buf, ((PyObject*)__pyx_cur_scope->__pyx_v_v)); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 918, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":921
 * 
 *         # no extensions requested
 *         handshake_buf.write_int16(0)             # <<<<<<<<<<<<<<
 *         handshake_buf.end_message()
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_handshake_buf->__pyx_vtab)->write_int16(__pyx_cur_scope->__pyx_v_handshake_buf, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 921, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":922
 *         # no extensions requested
 *         handshake_buf.write_int16(0)
 *         handshake_buf.end_message()             # <<<<<<<<<<<<<<
 * 
 *         self.write(handshake_buf)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_handshake_buf->__pyx_vtab)->end_message(__pyx_cur_scope->__pyx_v_handshake_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 922, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":924
 *         handshake_buf.end_message()
 * 
 *         self.write(handshake_buf)             # <<<<<<<<<<<<<<
 * 
 *         while True:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_handshake_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 924, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":926
 *         self.write(handshake_buf)
 * 
 *         while True:             # <<<<<<<<<<<<<<
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 */
  while (1) {

    /* "edgedb/protocol/protocol.pyx":927
 * 
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_9 == ((int32_t)-1))) __PYX_ERR(5, 927, __pyx_L1_error)
    __pyx_t_4 = ((!(__pyx_t_9 != 0)) != 0);
    if (__pyx_t_4) {

      /* "edgedb/protocol/protocol.pyx":928
 *         while True:
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()             # <<<<<<<<<<<<<<
 *             mtype = self.buffer.get_message_type()
 * 
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_wait_for_message); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 928, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 928, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XGOTREF(__pyx_r);
      if (likely(__pyx_r)) {
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 2;
        return __pyx_r;
        __pyx_L11_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 928, __pyx_L1_error)
      } else {
        PyObject* exc_type = __Pyx_PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
          else __PYX_ERR(5, 928, __pyx_L1_error)
        }
      }

      /* "edgedb/protocol/protocol.pyx":927
 * 
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    }

    /* "edgedb/protocol/protocol.pyx":929
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()             # <<<<<<<<<<<<<<
 * 
 *             if mtype == SERVER_HANDSHAKE_MSG:
 */
    __pyx_cur_scope->__pyx_v_mtype = __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_cur_scope->__pyx_v_self->buffer);

    /* "edgedb/protocol/protocol.pyx":931
 *             mtype = self.buffer.get_message_type()
 * 
 *             if mtype == SERVER_HANDSHAKE_MSG:             # <<<<<<<<<<<<<<
 *                 # Server responded with ServerHandshake, this
 *                 # means protocol negotiation.
 */
    switch (__pyx_cur_scope->__pyx_v_mtype) {
      case 'v':

      /* "edgedb/protocol/protocol.pyx":934
 *                 # Server responded with ServerHandshake, this
 *                 # means protocol negotiation.
 *                 major = self.buffer.read_int16()             # <<<<<<<<<<<<<<
 *                 minor = self.buffer.read_int16()
 *                 self.parse_headers()
 */
      __pyx_t_10 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->read_int16(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_10 == ((int16_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 934, __pyx_L1_error)
      __pyx_cur_scope->__pyx_v_major = __pyx_t_10;

      /* "edgedb/protocol/protocol.pyx":935
 *                 # means protocol negotiation.
 *                 major = self.buffer.read_int16()
 *                 minor = self.buffer.read_int16()             # <<<<<<<<<<<<<<
 *                 self.parse_headers()
 *                 self.buffer.finish_message()
 */
      __pyx_t_10 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->read_int16(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_10 == ((int16_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 935, __pyx_L1_error)
      __pyx_cur_scope->__pyx_v_minor = __pyx_t_10;

      /* "edgedb/protocol/protocol.pyx":936
 *                 major = self.buffer.read_int16()
 *                 minor = self.buffer.read_int16()
 *                 self.parse_headers()             # <<<<<<<<<<<<<<
 *                 self.buffer.finish_message()
 * 
 */
      __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_headers(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 936, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "edgedb/protocol/protocol.pyx":937
 *                 minor = self.buffer.read_int16()
 *                 self.parse_headers()
 *                 self.buffer.finish_message()             # <<<<<<<<<<<<<<
 * 
 *                 if (major != PROTO_VER_MAJOR or (major == 0 and
 */
      __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 937, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "edgedb/protocol/protocol.pyx":939
 *                 self.buffer.finish_message()
 * 
 *                 if (major != PROTO_VER_MAJOR or (major == 0 and             # <<<<<<<<<<<<<<
 *                         not PROTO_VER_MINOR_MIN <= minor <= PROTO_VER_MINOR)):
 *                     raise errors.ClientConnectionError(
 */
      __pyx_t_11 = ((__pyx_cur_scope->__pyx_v_major != 0) != 0);
      if (!__pyx_t_11) {
      } else {
        __pyx_t_4 = __pyx_t_11;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_11 = ((__pyx_cur_scope->__pyx_v_major == 0) != 0);
      if (__pyx_t_11) {
      } else {
        __pyx_t_4 = __pyx_t_11;
        goto __pyx_L13_bool_binop_done;
      }

      /* "edgedb/protocol/protocol.pyx":940
 * 
 *                 if (major != PROTO_VER_MAJOR or (major == 0 and
 *                         not PROTO_VER_MINOR_MIN <= minor <= PROTO_VER_MINOR)):             # <<<<<<<<<<<<<<
 *                     raise errors.ClientConnectionError(
 *                         f'the server requested an unsupported version of '
 */
      __pyx_t_11 = (9 <= __pyx_cur_scope->__pyx_v_minor);
      if (__pyx_t_11) {
        __pyx_t_11 = (__pyx_cur_scope->__pyx_v_minor <= 13);
      }
      __pyx_t_12 = ((!(__pyx_t_11 != 0)) != 0);
      __pyx_t_4 = __pyx_t_12;
      __pyx_L13_bool_binop_done:;

      /* "edgedb/protocol/protocol.pyx":939
 *                 self.buffer.finish_message()
 * 
 *                 if (major != PROTO_VER_MAJOR or (major == 0 and             # <<<<<<<<<<<<<<
 *                         not PROTO_VER_MINOR_MIN <= minor <= PROTO_VER_MINOR)):
 *                     raise errors.ClientConnectionError(
 */
      if (unlikely(__pyx_t_4)) {

        /* "edgedb/protocol/protocol.pyx":941
 *                 if (major != PROTO_VER_MAJOR or (major == 0 and
 *                         not PROTO_VER_MINOR_MIN <= minor <= PROTO_VER_MINOR)):
 *                     raise errors.ClientConnectionError(             # <<<<<<<<<<<<<<
 *                         f'the server requested an unsupported version of '
 *                         f'the protocol: {major}.{minor}'
 */
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_errors); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 941, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ClientConnectionError); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 941, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "edgedb/protocol/protocol.pyx":942
 *                         not PROTO_VER_MINOR_MIN <= minor <= PROTO_VER_MINOR)):
 *                     raise errors.ClientConnectionError(
 *                         f'the server requested an unsupported version of '             # <<<<<<<<<<<<<<
 *                         f'the protocol: {major}.{minor}'
 *                     )
 */
        __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 942, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_6 = 0;
        __pyx_t_13 = 127;
        __Pyx_INCREF(__pyx_kp_u_the_server_requested_an_unsuppor);
        __pyx_t_6 += 61;
        __Pyx_GIVEREF(__pyx_kp_u_the_server_requested_an_unsuppor);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_the_server_requested_an_unsuppor);

        /* "edgedb/protocol/protocol.pyx":943
 *                     raise errors.ClientConnectionError(
 *                         f'the server requested an unsupported version of '
 *                         f'the protocol: {major}.{minor}'             # <<<<<<<<<<<<<<
 *                     )
 * 
 */
        __pyx_t_14 = __Pyx_PyInt_From_int16_t(__pyx_cur_scope->__pyx_v_major); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 943, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_15 = __Pyx_PyObject_FormatSimple(__pyx_t_14, __pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 943, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) : __pyx_t_13;
        __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_15);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_15);
        __pyx_t_15 = 0;
        __Pyx_INCREF(__pyx_kp_u__75);
        __pyx_t_6 += 1;
        __Pyx_GIVEREF(__pyx_kp_u__75);
        PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u__75);
        __pyx_t_15 = __Pyx_PyInt_From_int16_t(__pyx_cur_scope->__pyx_v_minor); if (unlikely(!__pyx_t_15)) __PYX_ERR(5, 943, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_t_15, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 943, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13;
        __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14);
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_14);
        __pyx_t_14 = 0;

        /* "edgedb/protocol/protocol.pyx":942
 *                         not PROTO_VER_MINOR_MIN <= minor <= PROTO_VER_MINOR)):
 *                     raise errors.ClientConnectionError(
 *                         f'the server requested an unsupported version of '             # <<<<<<<<<<<<<<
 *                         f'the protocol: {major}.{minor}'
 *                     )
 */
        __pyx_t_14 = __Pyx_PyUnicode_Join(__pyx_t_3, 4, __pyx_t_6, __pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 942, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_14) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_14);
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 941, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(5, 941, __pyx_L1_error)

        /* "edgedb/protocol/protocol.pyx":939
 *                 self.buffer.finish_message()
 * 
 *                 if (major != PROTO_VER_MAJOR or (major == 0 and             # <<<<<<<<<<<<<<
 *                         not PROTO_VER_MINOR_MIN <= minor <= PROTO_VER_MINOR)):
 *                     raise errors.ClientConnectionError(
 */
      }

      /* "edgedb/protocol/protocol.pyx":946
 *                     )
 * 
 *                 self.protocol_version = (major, minor)             # <<<<<<<<<<<<<<
 * 
 *             elif mtype == AUTH_REQUEST_MSG:
 */
      __pyx_t_1 = __Pyx_PyInt_From_int16_t(__pyx_cur_scope->__pyx_v_major); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 946, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyInt_From_int16_t(__pyx_cur_scope->__pyx_v_minor); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 946, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 946, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_2);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __Pyx_GIVEREF(__pyx_t_14);
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->protocol_version);
      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->protocol_version);
      __pyx_cur_scope->__pyx_v_self->protocol_version = ((PyObject*)__pyx_t_14);
      __pyx_t_14 = 0;

      /* "edgedb/protocol/protocol.pyx":931
 *             mtype = self.buffer.get_message_type()
 * 
 *             if mtype == SERVER_HANDSHAKE_MSG:             # <<<<<<<<<<<<<<
 *                 # Server responded with ServerHandshake, this
 *                 # means protocol negotiation.
 */
      break;
      case 'R':

      /* "edgedb/protocol/protocol.pyx":950
 *             elif mtype == AUTH_REQUEST_MSG:
 *                 # Authentication...
 *                 status = self.buffer.read_int32()             # <<<<<<<<<<<<<<
 *                 if status == AuthenticationStatuses.AUTH_OK:
 *                     pass
 */
      __pyx_t_9 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->read_int32(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_9 == ((int32_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 950, __pyx_L1_error)
      __pyx_cur_scope->__pyx_v_status = __pyx_t_9;

      /* "edgedb/protocol/protocol.pyx":951
 *                 # Authentication...
 *                 status = self.buffer.read_int32()
 *                 if status == AuthenticationStatuses.AUTH_OK:             # <<<<<<<<<<<<<<
 *                     pass
 *                 elif status == AuthenticationStatuses.AUTH_SASL:
 */
      switch (__pyx_cur_scope->__pyx_v_status) {
        case __pyx_e_6edgedb_8protocol_8protocol_AUTH_OK:
        break;
        case __pyx_e_6edgedb_8protocol_8protocol_AUTH_SASL:

        /* "edgedb/protocol/protocol.pyx":954
 *                     pass
 *                 elif status == AuthenticationStatuses.AUTH_SASL:
 *                     await self._auth_sasl()             # <<<<<<<<<<<<<<
 *                 else:
 *                     self.abort()
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_auth_sasl); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 954, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        __pyx_t_14 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 954, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_14);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XGOTREF(__pyx_r);
        if (likely(__pyx_r)) {
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 3;
          return __pyx_r;
          __pyx_L16_resume_from_await:;
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 954, __pyx_L1_error)
        } else {
          PyObject* exc_type = __Pyx_PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
            else __PYX_ERR(5, 954, __pyx_L1_error)
          }
        }

        /* "edgedb/protocol/protocol.pyx":953
 *                 if status == AuthenticationStatuses.AUTH_OK:
 *                     pass
 *                 elif status == AuthenticationStatuses.AUTH_SASL:             # <<<<<<<<<<<<<<
 *                     await self._auth_sasl()
 *                 else:
 */
        break;
        default:

        /* "edgedb/protocol/protocol.pyx":956
 *                     await self._auth_sasl()
 *                 else:
 *                     self.abort()             # <<<<<<<<<<<<<<
 *                     raise RuntimeError(
 *                         f'unsupported authentication method requested by the '
 */
        __pyx_t_14 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->abort(__pyx_cur_scope->__pyx_v_self, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 956, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

        /* "edgedb/protocol/protocol.pyx":959
 *                     raise RuntimeError(
 *                         f'unsupported authentication method requested by the '
 *                         f'server: {status}')             # <<<<<<<<<<<<<<
 * 
 *             elif mtype == SERVER_KEY_DATA_MSG:
 */
        __pyx_t_14 = __Pyx_PyInt_From_int32_t(__pyx_cur_scope->__pyx_v_status); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 959, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_t_14, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 959, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

        /* "edgedb/protocol/protocol.pyx":958
 *                     self.abort()
 *                     raise RuntimeError(
 *                         f'unsupported authentication method requested by the '             # <<<<<<<<<<<<<<
 *                         f'server: {status}')
 * 
 */
        __pyx_t_14 = __Pyx_PyUnicode_Concat(__pyx_kp_u_unsupported_authentication_metho, __pyx_t_2); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 958, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "edgedb/protocol/protocol.pyx":957
 *                 else:
 *                     self.abort()
 *                     raise RuntimeError(             # <<<<<<<<<<<<<<
 *                         f'unsupported authentication method requested by the '
 *                         f'server: {status}')
 */
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 957, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __PYX_ERR(5, 957, __pyx_L1_error)
        break;
      }

      /* "edgedb/protocol/protocol.pyx":948
 *                 self.protocol_version = (major, minor)
 * 
 *             elif mtype == AUTH_REQUEST_MSG:             # <<<<<<<<<<<<<<
 *                 # Authentication...
 *                 status = self.buffer.read_int32()
 */
      break;
      case 'K':

      /* "edgedb/protocol/protocol.pyx":962
 * 
 *             elif mtype == SERVER_KEY_DATA_MSG:
 *                 self.backend_secret = self.buffer.read_bytes(32)             # <<<<<<<<<<<<<<
 * 
 *             elif mtype == ERROR_RESPONSE_MSG:
 */
      __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->read_bytes(__pyx_cur_scope->__pyx_v_self->buffer, 32); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 962, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->backend_secret);
      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->backend_secret);
      __pyx_cur_scope->__pyx_v_self->backend_secret = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "edgedb/protocol/protocol.pyx":961
 *                         f'server: {status}')
 * 
 *             elif mtype == SERVER_KEY_DATA_MSG:             # <<<<<<<<<<<<<<
 *                 self.backend_secret = self.buffer.read_bytes(32)
 * 
 */
      break;
      case 'E':

      /* "edgedb/protocol/protocol.pyx":965
 * 
 *             elif mtype == ERROR_RESPONSE_MSG:
 *                 raise self.parse_error_message()             # <<<<<<<<<<<<<<
 * 
 *             elif mtype == READY_FOR_COMMAND_MSG:
 */
      __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_error_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 965, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(5, 965, __pyx_L1_error)

      /* "edgedb/protocol/protocol.pyx":964
 *                 self.backend_secret = self.buffer.read_bytes(32)
 * 
 *             elif mtype == ERROR_RESPONSE_MSG:             # <<<<<<<<<<<<<<
 *                 raise self.parse_error_message()
 * 
 */
      break;
      case 'Z':

      /* "edgedb/protocol/protocol.pyx":969
 *             elif mtype == READY_FOR_COMMAND_MSG:
 *                 # ReadyForQuery
 *                 self.parse_sync_message()             # <<<<<<<<<<<<<<
 *                 if self.xact_status == TRANS_IDLE:
 *                     self.connected = True
 */
      __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_sync_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 969, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "edgedb/protocol/protocol.pyx":970
 *                 # ReadyForQuery
 *                 self.parse_sync_message()
 *                 if self.xact_status == TRANS_IDLE:             # <<<<<<<<<<<<<<
 *                     self.connected = True
 *                     break
 */
      __pyx_t_4 = ((__pyx_cur_scope->__pyx_v_self->xact_status == __pyx_e_6edgedb_8protocol_8protocol_TRANS_IDLE) != 0);
      if (likely(__pyx_t_4)) {

        /* "edgedb/protocol/protocol.pyx":971
 *                 self.parse_sync_message()
 *                 if self.xact_status == TRANS_IDLE:
 *                     self.connected = True             # <<<<<<<<<<<<<<
 *                     break
 *                 else:
 */
        __pyx_cur_scope->__pyx_v_self->connected = 1;

        /* "edgedb/protocol/protocol.pyx":972
 *                 if self.xact_status == TRANS_IDLE:
 *                     self.connected = True
 *                     break             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise RuntimeError('non-idle status after connect')
 */
        goto __pyx_L9_break;

        /* "edgedb/protocol/protocol.pyx":970
 *                 # ReadyForQuery
 *                 self.parse_sync_message()
 *                 if self.xact_status == TRANS_IDLE:             # <<<<<<<<<<<<<<
 *                     self.connected = True
 *                     break
 */
      }

      /* "edgedb/protocol/protocol.pyx":974
 *                     break
 *                 else:
 *                     raise RuntimeError('non-idle status after connect')             # <<<<<<<<<<<<<<
 * 
 *             else:
 */
      /*else*/ {
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 974, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __PYX_ERR(5, 974, __pyx_L1_error)
      }

      /* "edgedb/protocol/protocol.pyx":967
 *                 raise self.parse_error_message()
 * 
 *             elif mtype == READY_FOR_COMMAND_MSG:             # <<<<<<<<<<<<<<
 *                 # ReadyForQuery
 *                 self.parse_sync_message()
 */
      break;
      default:

      /* "edgedb/protocol/protocol.pyx":977
 * 
 *             else:
 *                 self.fallthrough()             # <<<<<<<<<<<<<<
 * 
 *             self.buffer.finish_message()
 */
      __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->fallthrough(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 977, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      break;
    }

    /* "edgedb/protocol/protocol.pyx":979
 *                 self.fallthrough()
 * 
 *             self.buffer.finish_message()             # <<<<<<<<<<<<<<
 * 
 *         if self.tls_compat and \
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 979, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L9_break:;

  /* "edgedb/protocol/protocol.pyx":981
 *             self.buffer.finish_message()
 * 
 *         if self.tls_compat and \             # <<<<<<<<<<<<<<
 *                 self.protocol_version >= PROTO_VER_MIN_TLS:
 *             raise errors.ClientConnectionError(
 */
  __pyx_t_12 = (__pyx_cur_scope->__pyx_v_self->tls_compat != 0);
  if (__pyx_t_12) {
  } else {
    __pyx_t_4 = __pyx_t_12;
    goto __pyx_L19_bool_binop_done;
  }

  /* "edgedb/protocol/protocol.pyx":982
 * 
 *         if self.tls_compat and \
 *                 self.protocol_version >= PROTO_VER_MIN_TLS:             # <<<<<<<<<<<<<<
 *             raise errors.ClientConnectionError(
 *                 'the protocol version requires TLS: {}.{}'.format(
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_self->protocol_version, __pyx_tuple__50, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 982, __pyx_L1_error)
  __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(5, 982, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __pyx_t_12;
  __pyx_L19_bool_binop_done:;

  /* "edgedb/protocol/protocol.pyx":981
 *             self.buffer.finish_message()
 * 
 *         if self.tls_compat and \             # <<<<<<<<<<<<<<
 *                 self.protocol_version >= PROTO_VER_MIN_TLS:
 *             raise errors.ClientConnectionError(
 */
  if (unlikely(__pyx_t_4)) {

    /* "edgedb/protocol/protocol.pyx":983
 *         if self.tls_compat and \
 *                 self.protocol_version >= PROTO_VER_MIN_TLS:
 *             raise errors.ClientConnectionError(             # <<<<<<<<<<<<<<
 *                 'the protocol version requires TLS: {}.{}'.format(
 *                     *self.protocol_version
 */
    __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_errors); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 983, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_ClientConnectionError); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 983, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

    /* "edgedb/protocol/protocol.pyx":984
 *                 self.protocol_version >= PROTO_VER_MIN_TLS:
 *             raise errors.ClientConnectionError(
 *                 'the protocol version requires TLS: {}.{}'.format(             # <<<<<<<<<<<<<<
 *                     *self.protocol_version
 *                 )
 */
    __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_the_protocol_version_requires_TL, __pyx_n_s_format); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 984, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);

    /* "edgedb/protocol/protocol.pyx":985
 *             raise errors.ClientConnectionError(
 *                 'the protocol version requires TLS: {}.{}'.format(
 *                     *self.protocol_version             # <<<<<<<<<<<<<<
 *                 )
 *             )
 */
    if (unlikely(__pyx_cur_scope->__pyx_v_self->protocol_version == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(5, 985, __pyx_L1_error)
    }

    /* "edgedb/protocol/protocol.pyx":984
 *                 self.protocol_version >= PROTO_VER_MIN_TLS:
 *             raise errors.ClientConnectionError(
 *                 'the protocol version requires TLS: {}.{}'.format(             # <<<<<<<<<<<<<<
 *                     *self.protocol_version
 *                 )
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_cur_scope->__pyx_v_self->protocol_version, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 984, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_14 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_14)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_14);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_2 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 983, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(5, 983, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":981
 *             self.buffer.finish_message()
 * 
 *         if self.tls_compat and \             # <<<<<<<<<<<<<<
 *                 self.protocol_version >= PROTO_VER_MIN_TLS:
 *             raise errors.ClientConnectionError(
 */
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "edgedb/protocol/protocol.pyx":891
 *             pass
 * 
 *     async def connect(self):             # <<<<<<<<<<<<<<
 *         cdef:
 *             WriteBuffer ver_buf
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("connect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_50generator12(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "edgedb/protocol/protocol.pyx":989
 *             )
 * 
 *     async def _auth_sasl(self):             # <<<<<<<<<<<<<<
 *         num_methods = self.buffer.read_int32()
 *         if num_methods <= 0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_49_auth_sasl(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_49_auth_sasl(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_auth_sasl (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_48_auth_sasl(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_48_auth_sasl(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_auth_sasl", 0);
  __pyx_cur_scope = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl *)__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl(__pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(5, 989, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_50generator12, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_auth_sasl, __pyx_n_s_SansIOProtocol__auth_sasl, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!gen)) __PYX_ERR(5, 989, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol._auth_sasl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_6edgedb_8protocol_8protocol_14SansIOProtocol_50generator12(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl *__pyx_cur_scope = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int32_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int32_t __pyx_t_4;
  int32_t __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  Py_UCS4 __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyObject *(*__pyx_t_15)(PyObject *);
  PyObject *__pyx_t_16 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_auth_sasl", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L16_resume_from_await;
    case 2: goto __pyx_L27_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 989, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":990
 * 
 *     async def _auth_sasl(self):
 *         num_methods = self.buffer.read_int32()             # <<<<<<<<<<<<<<
 *         if num_methods <= 0:
 *             raise RuntimeError(
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->read_int32(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_1 == ((int32_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 990, __pyx_L1_error)
  __pyx_cur_scope->__pyx_v_num_methods = __pyx_t_1;

  /* "edgedb/protocol/protocol.pyx":991
 *     async def _auth_sasl(self):
 *         num_methods = self.buffer.read_int32()
 *         if num_methods <= 0:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 'the server requested SASL authentication but did not '
 */
  __pyx_t_2 = ((__pyx_cur_scope->__pyx_v_num_methods <= 0) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/protocol.pyx":992
 *         num_methods = self.buffer.read_int32()
 *         if num_methods <= 0:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 'the server requested SASL authentication but did not '
 *                 'offer any methods')
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 992, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(5, 992, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":991
 *     async def _auth_sasl(self):
 *         num_methods = self.buffer.read_int32()
 *         if num_methods <= 0:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 'the server requested SASL authentication but did not '
 */
  }

  /* "edgedb/protocol/protocol.pyx":996
 *                 'offer any methods')
 * 
 *         methods = []             # <<<<<<<<<<<<<<
 *         for i in range(num_methods):
 *             method = self.buffer.read_len_prefixed_bytes()
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 996, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_methods = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "edgedb/protocol/protocol.pyx":997
 * 
 *         methods = []
 *         for i in range(num_methods):             # <<<<<<<<<<<<<<
 *             method = self.buffer.read_len_prefixed_bytes()
 *             methods.append(method)
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_num_methods;
  __pyx_t_4 = __pyx_t_1;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_cur_scope->__pyx_v_i = __pyx_t_5;

    /* "edgedb/protocol/protocol.pyx":998
 *         methods = []
 *         for i in range(num_methods):
 *             method = self.buffer.read_len_prefixed_bytes()             # <<<<<<<<<<<<<<
 *             methods.append(method)
 * 
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->read_len_prefixed_bytes(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 998, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_method);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_method, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;

    /* "edgedb/protocol/protocol.pyx":999
 *         for i in range(num_methods):
 *             method = self.buffer.read_len_prefixed_bytes()
 *             methods.append(method)             # <<<<<<<<<<<<<<
 * 
 *         self.buffer.finish_message()
 */
    __pyx_t_6 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_methods, __pyx_cur_scope->__pyx_v_method); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(5, 999, __pyx_L1_error)
  }

  /* "edgedb/protocol/protocol.pyx":1001
 *             methods.append(method)
 * 
 *         self.buffer.finish_message()             # <<<<<<<<<<<<<<
 * 
 *         for method in methods:
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "edgedb/protocol/protocol.pyx":1003
 *         self.buffer.finish_message()
 * 
 *         for method in methods:             # <<<<<<<<<<<<<<
 *             if method == b'SCRAM-SHA-256':
 *                 break
 */
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_methods; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
  for (;;) {
    if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_8 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_8); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(5, 1003, __pyx_L1_error)
    #else
    __pyx_t_8 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 1003, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    #endif
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_method);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_method, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    __pyx_t_8 = 0;

    /* "edgedb/protocol/protocol.pyx":1004
 * 
 *         for method in methods:
 *             if method == b'SCRAM-SHA-256':             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
    __pyx_t_2 = (__Pyx_PyBytes_Equals(__pyx_cur_scope->__pyx_v_method, __pyx_kp_b_SCRAM_SHA_256, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(5, 1004, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "edgedb/protocol/protocol.pyx":1005
 *         for method in methods:
 *             if method == b'SCRAM-SHA-256':
 *                 break             # <<<<<<<<<<<<<<
 *         else:
 *             raise RuntimeError(
 */
      goto __pyx_L8_break;

      /* "edgedb/protocol/protocol.pyx":1004
 * 
 *         for method in methods:
 *             if method == b'SCRAM-SHA-256':             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
    }

    /* "edgedb/protocol/protocol.pyx":1003
 *         self.buffer.finish_message()
 * 
 *         for method in methods:             # <<<<<<<<<<<<<<
 *             if method == b'SCRAM-SHA-256':
 *                 break
 */
  }
  /*else*/ {

    /* "edgedb/protocol/protocol.pyx":1008
 *         else:
 *             raise RuntimeError(
 *                 f'the server offered the following SASL authentication '             # <<<<<<<<<<<<<<
 *                 f'methods: {", ".join(methods)}, neither are supported.')
 * 
 */
    __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 1008, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = 0;
    __pyx_t_10 = 127;
    __Pyx_INCREF(__pyx_kp_u_the_server_offered_the_following);
    __pyx_t_9 += 62;
    __Pyx_GIVEREF(__pyx_kp_u_the_server_offered_the_following);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_kp_u_the_server_offered_the_following);

    /* "edgedb/protocol/protocol.pyx":1009
 *             raise RuntimeError(
 *                 f'the server offered the following SASL authentication '
 *                 f'methods: {", ".join(methods)}, neither are supported.')             # <<<<<<<<<<<<<<
 * 
 *         client_nonce = scram.generate_nonce()
 */
    __pyx_t_11 = PyUnicode_Join(__pyx_kp_u__78, __pyx_cur_scope->__pyx_v_methods); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 1009, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_10 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_10) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_10;
    __pyx_t_9 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_11);
    __pyx_t_11 = 0;
    __Pyx_INCREF(__pyx_kp_u_neither_are_supported);
    __pyx_t_9 += 24;
    __Pyx_GIVEREF(__pyx_kp_u_neither_are_supported);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_kp_u_neither_are_supported);

    /* "edgedb/protocol/protocol.pyx":1008
 *         else:
 *             raise RuntimeError(
 *                 f'the server offered the following SASL authentication '             # <<<<<<<<<<<<<<
 *                 f'methods: {", ".join(methods)}, neither are supported.')
 * 
 */
    __pyx_t_11 = __Pyx_PyUnicode_Join(__pyx_t_8, 3, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 1008, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "edgedb/protocol/protocol.pyx":1007
 *                 break
 *         else:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 f'the server offered the following SASL authentication '
 *                 f'methods: {", ".join(methods)}, neither are supported.')
 */
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 1007, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_Raise(__pyx_t_8, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __PYX_ERR(5, 1007, __pyx_L1_error)
  }

  /* "edgedb/protocol/protocol.pyx":1003
 *         self.buffer.finish_message()
 * 
 *         for method in methods:             # <<<<<<<<<<<<<<
 *             if method == b'SCRAM-SHA-256':
 *                 break
 */
  __pyx_L8_break:;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "edgedb/protocol/protocol.pyx":1011
 *                 f'methods: {", ".join(methods)}, neither are supported.')
 * 
 *         client_nonce = scram.generate_nonce()             # <<<<<<<<<<<<<<
 *         client_first, client_first_bare = scram.build_client_first_message(
 *             client_nonce, self.con_params.user)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_scram); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 1011, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_generate_nonce); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 1011, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
    }
  }
  __pyx_t_3 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1011, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_client_nonce = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "edgedb/protocol/protocol.pyx":1012
 * 
 *         client_nonce = scram.generate_nonce()
 *         client_first, client_first_bare = scram.build_client_first_message(             # <<<<<<<<<<<<<<
 *             client_nonce, self.con_params.user)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_scram); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 1012, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_build_client_first_message); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 1012, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "edgedb/protocol/protocol.pyx":1013
 *         client_nonce = scram.generate_nonce()
 *         client_first, client_first_bare = scram.build_client_first_message(
 *             client_nonce, self.con_params.user)             # <<<<<<<<<<<<<<
 * 
 *         msg_buf = WriteBuffer.new_message(AUTH_INITIAL_RESPONSE_MSG)
 */
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->con_params, __pyx_n_s_user); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 1013, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = NULL;
  __pyx_t_13 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
      __pyx_t_13 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_client_nonce, __pyx_t_11};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1012, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_client_nonce, __pyx_t_11};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1012, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else
  #endif
  {
    __pyx_t_14 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1012, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    if (__pyx_t_12) {
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __pyx_t_12 = NULL;
    }
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_client_nonce);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_client_nonce);
    PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_13, __pyx_cur_scope->__pyx_v_client_nonce);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_13, __pyx_t_11);
    __pyx_t_11 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1012, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(5, 1012, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_14 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_14 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_14);
    #else
    __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 1012, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_14 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1012, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_11 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 1012, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_15 = Py_TYPE(__pyx_t_11)->tp_iternext;
    index = 0; __pyx_t_8 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_8)) goto __pyx_L11_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_8);
    index = 1; __pyx_t_14 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_14)) goto __pyx_L11_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_14);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_11), 2) < 0) __PYX_ERR(5, 1012, __pyx_L1_error)
    __pyx_t_15 = NULL;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    goto __pyx_L12_unpacking_done;
    __pyx_L11_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_15 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(5, 1012, __pyx_L1_error)
    __pyx_L12_unpacking_done:;
  }

  /* "edgedb/protocol/protocol.pyx":1012
 * 
 *         client_nonce = scram.generate_nonce()
 *         client_first, client_first_bare = scram.build_client_first_message(             # <<<<<<<<<<<<<<
 *             client_nonce, self.con_params.user)
 * 
 */
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_cur_scope->__pyx_v_client_first = __pyx_t_8;
  __pyx_t_8 = 0;
  __Pyx_GIVEREF(__pyx_t_14);
  __pyx_cur_scope->__pyx_v_client_first_bare = __pyx_t_14;
  __pyx_t_14 = 0;

  /* "edgedb/protocol/protocol.pyx":1015
 *             client_nonce, self.con_params.user)
 * 
 *         msg_buf = WriteBuffer.new_message(AUTH_INITIAL_RESPONSE_MSG)             # <<<<<<<<<<<<<<
 *         msg_buf.write_len_prefixed_bytes(b'SCRAM-SHA-256')
 *         msg_buf.write_len_prefixed_utf8(client_first)
 */
  __pyx_t_3 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('p')); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_msg_buf = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "edgedb/protocol/protocol.pyx":1016
 * 
 *         msg_buf = WriteBuffer.new_message(AUTH_INITIAL_RESPONSE_MSG)
 *         msg_buf.write_len_prefixed_bytes(b'SCRAM-SHA-256')             # <<<<<<<<<<<<<<
 *         msg_buf.write_len_prefixed_utf8(client_first)
 *         msg_buf.end_message()
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_msg_buf->__pyx_vtab)->write_len_prefixed_bytes(__pyx_cur_scope->__pyx_v_msg_buf, __pyx_kp_b_SCRAM_SHA_256); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "edgedb/protocol/protocol.pyx":1017
 *         msg_buf = WriteBuffer.new_message(AUTH_INITIAL_RESPONSE_MSG)
 *         msg_buf.write_len_prefixed_bytes(b'SCRAM-SHA-256')
 *         msg_buf.write_len_prefixed_utf8(client_first)             # <<<<<<<<<<<<<<
 *         msg_buf.end_message()
 *         self.write(msg_buf)
 */
  if (!(likely(PyUnicode_CheckExact(__pyx_cur_scope->__pyx_v_client_first))||((__pyx_cur_scope->__pyx_v_client_first) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_cur_scope->__pyx_v_client_first)->tp_name), 0))) __PYX_ERR(5, 1017, __pyx_L1_error)
  __pyx_t_3 = __pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_write_len_prefixed_utf8(__pyx_cur_scope->__pyx_v_msg_buf, ((PyObject*)__pyx_cur_scope->__pyx_v_client_first)); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1017, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "edgedb/protocol/protocol.pyx":1018
 *         msg_buf.write_len_prefixed_bytes(b'SCRAM-SHA-256')
 *         msg_buf.write_len_prefixed_utf8(client_first)
 *         msg_buf.end_message()             # <<<<<<<<<<<<<<
 *         self.write(msg_buf)
 * 
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_msg_buf->__pyx_vtab)->end_message(__pyx_cur_scope->__pyx_v_msg_buf); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1018, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "edgedb/protocol/protocol.pyx":1019
 *         msg_buf.write_len_prefixed_utf8(client_first)
 *         msg_buf.end_message()
 *         self.write(msg_buf)             # <<<<<<<<<<<<<<
 * 
 *         while True:
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_msg_buf); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1019, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "edgedb/protocol/protocol.pyx":1021
 *         self.write(msg_buf)
 * 
 *         while True:             # <<<<<<<<<<<<<<
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 */
  while (1) {

    /* "edgedb/protocol/protocol.pyx":1022
 * 
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_1 == ((int32_t)-1))) __PYX_ERR(5, 1022, __pyx_L1_error)
    __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
    if (__pyx_t_2) {

      /* "edgedb/protocol/protocol.pyx":1023
 *         while True:
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()             # <<<<<<<<<<<<<<
 *             mtype = self.buffer.get_message_type()
 * 
 */
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_wait_for_message); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1023, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_14);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_14, function);
        }
      }
      __pyx_t_3 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_14);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1023, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XGOTREF(__pyx_r);
      if (likely(__pyx_r)) {
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L16_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 1023, __pyx_L1_error)
      } else {
        PyObject* exc_type = __Pyx_PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
          else __PYX_ERR(5, 1023, __pyx_L1_error)
        }
      }

      /* "edgedb/protocol/protocol.pyx":1022
 * 
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    }

    /* "edgedb/protocol/protocol.pyx":1024
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()             # <<<<<<<<<<<<<<
 * 
 *             if mtype == ERROR_RESPONSE_MSG:
 */
    __pyx_cur_scope->__pyx_v_mtype = __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_cur_scope->__pyx_v_self->buffer);

    /* "edgedb/protocol/protocol.pyx":1026
 *             mtype = self.buffer.get_message_type()
 * 
 *             if mtype == ERROR_RESPONSE_MSG:             # <<<<<<<<<<<<<<
 *                 # ErrorResponse
 *                 exc = self.parse_error_message()
 */
    switch (__pyx_cur_scope->__pyx_v_mtype) {
      case 'E':

      /* "edgedb/protocol/protocol.pyx":1028
 *             if mtype == ERROR_RESPONSE_MSG:
 *                 # ErrorResponse
 *                 exc = self.parse_error_message()             # <<<<<<<<<<<<<<
 *                 self.buffer.finish_message()
 *                 raise exc
 */
      __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_error_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1028, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_cur_scope->__pyx_v_exc = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "edgedb/protocol/protocol.pyx":1029
 *                 # ErrorResponse
 *                 exc = self.parse_error_message()
 *                 self.buffer.finish_message()             # <<<<<<<<<<<<<<
 *                 raise exc
 * 
 */
      __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1029, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "edgedb/protocol/protocol.pyx":1030
 *                 exc = self.parse_error_message()
 *                 self.buffer.finish_message()
 *                 raise exc             # <<<<<<<<<<<<<<
 * 
 *             elif mtype == AUTH_REQUEST_MSG:
 */
      __Pyx_Raise(__pyx_cur_scope->__pyx_v_exc, 0, 0, 0);
      __PYX_ERR(5, 1030, __pyx_L1_error)

      /* "edgedb/protocol/protocol.pyx":1026
 *             mtype = self.buffer.get_message_type()
 * 
 *             if mtype == ERROR_RESPONSE_MSG:             # <<<<<<<<<<<<<<
 *                 # ErrorResponse
 *                 exc = self.parse_error_message()
 */
      break;
      case 'R':

      /* "edgedb/protocol/protocol.pyx":1033
 * 
 *             elif mtype == AUTH_REQUEST_MSG:
 *                 break             # <<<<<<<<<<<<<<
 * 
 *             else:
 */
      goto __pyx_L14_break;

      /* "edgedb/protocol/protocol.pyx":1032
 *                 raise exc
 * 
 *             elif mtype == AUTH_REQUEST_MSG:             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
      break;
      default:

      /* "edgedb/protocol/protocol.pyx":1036
 * 
 *             else:
 *                 self.fallthrough()             # <<<<<<<<<<<<<<
 * 
 *         status = self.buffer.read_int32()
 */
      __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->fallthrough(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1036, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      break;
    }
  }
  __pyx_L14_break:;

  /* "edgedb/protocol/protocol.pyx":1038
 *                 self.fallthrough()
 * 
 *         status = self.buffer.read_int32()             # <<<<<<<<<<<<<<
 *         if status != AuthenticationStatuses.AUTH_SASL_CONTINUE:
 *             raise RuntimeError(
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->read_int32(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_1 == ((int32_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 1038, __pyx_L1_error)
  __pyx_cur_scope->__pyx_v_status = __pyx_t_1;

  /* "edgedb/protocol/protocol.pyx":1039
 * 
 *         status = self.buffer.read_int32()
 *         if status != AuthenticationStatuses.AUTH_SASL_CONTINUE:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'expected SASLContinue from the server, received {status}')
 */
  __pyx_t_2 = ((__pyx_cur_scope->__pyx_v_status != __pyx_e_6edgedb_8protocol_8protocol_AUTH_SASL_CONTINUE) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/protocol.pyx":1041
 *         if status != AuthenticationStatuses.AUTH_SASL_CONTINUE:
 *             raise RuntimeError(
 *                 f'expected SASLContinue from the server, received {status}')             # <<<<<<<<<<<<<<
 * 
 *         server_first = self.buffer.read_len_prefixed_bytes()
 */
    __pyx_t_3 = __Pyx_PyInt_From_int32_t(__pyx_cur_scope->__pyx_v_status); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1041, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1041, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_expected_SASLContinue_from_the_s, __pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1041, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

    /* "edgedb/protocol/protocol.pyx":1040
 *         status = self.buffer.read_int32()
 *         if status != AuthenticationStatuses.AUTH_SASL_CONTINUE:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 f'expected SASLContinue from the server, received {status}')
 * 
 */
    __pyx_t_14 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_3); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1040, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_14, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __PYX_ERR(5, 1040, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":1039
 * 
 *         status = self.buffer.read_int32()
 *         if status != AuthenticationStatuses.AUTH_SASL_CONTINUE:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'expected SASLContinue from the server, received {status}')
 */
  }

  /* "edgedb/protocol/protocol.pyx":1043
 *                 f'expected SASLContinue from the server, received {status}')
 * 
 *         server_first = self.buffer.read_len_prefixed_bytes()             # <<<<<<<<<<<<<<
 *         self.buffer.finish_message()
 * 
 */
  __pyx_t_14 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->read_len_prefixed_bytes(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_14);
  __pyx_cur_scope->__pyx_v_server_first = ((PyObject*)__pyx_t_14);
  __pyx_t_14 = 0;

  /* "edgedb/protocol/protocol.pyx":1044
 * 
 *         server_first = self.buffer.read_len_prefixed_bytes()
 *         self.buffer.finish_message()             # <<<<<<<<<<<<<<
 * 
 *         server_nonce, salt, itercount = (
 */
  __pyx_t_14 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1044, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "edgedb/protocol/protocol.pyx":1047
 * 
 *         server_nonce, salt, itercount = (
 *             scram.parse_server_first_message(server_first))             # <<<<<<<<<<<<<<
 * 
 *         client_final, expected_server_sig = scram.build_client_final_message(
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_scram); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1047, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_parse_server_first_message); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 1047, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_14 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_3, __pyx_cur_scope->__pyx_v_server_first) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_cur_scope->__pyx_v_server_first);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1047, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_14))) || (PyList_CheckExact(__pyx_t_14))) {
    PyObject* sequence = __pyx_t_14;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(5, 1046, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_11 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_11 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_11);
    #else
    __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 1046, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1046, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 1046, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    #endif
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_12 = PyObject_GetIter(__pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 1046, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_15 = Py_TYPE(__pyx_t_12)->tp_iternext;
    index = 0; __pyx_t_8 = __pyx_t_15(__pyx_t_12); if (unlikely(!__pyx_t_8)) goto __pyx_L18_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_8);
    index = 1; __pyx_t_3 = __pyx_t_15(__pyx_t_12); if (unlikely(!__pyx_t_3)) goto __pyx_L18_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 2; __pyx_t_11 = __pyx_t_15(__pyx_t_12); if (unlikely(!__pyx_t_11)) goto __pyx_L18_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_11);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_12), 3) < 0) __PYX_ERR(5, 1046, __pyx_L1_error)
    __pyx_t_15 = NULL;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    goto __pyx_L19_unpacking_done;
    __pyx_L18_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_15 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(5, 1046, __pyx_L1_error)
    __pyx_L19_unpacking_done:;
  }

  /* "edgedb/protocol/protocol.pyx":1046
 *         self.buffer.finish_message()
 * 
 *         server_nonce, salt, itercount = (             # <<<<<<<<<<<<<<
 *             scram.parse_server_first_message(server_first))
 * 
 */
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_cur_scope->__pyx_v_server_nonce = __pyx_t_8;
  __pyx_t_8 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_salt = __pyx_t_3;
  __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_11);
  __pyx_cur_scope->__pyx_v_itercount = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "edgedb/protocol/protocol.pyx":1049
 *             scram.parse_server_first_message(server_first))
 * 
 *         client_final, expected_server_sig = scram.build_client_final_message(             # <<<<<<<<<<<<<<
 *             self.con_params.password or '',
 *             salt,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_scram); if (unlikely(!__pyx_t_11)) __PYX_ERR(5, 1049, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_build_client_final_message); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1049, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "edgedb/protocol/protocol.pyx":1050
 * 
 *         client_final, expected_server_sig = scram.build_client_final_message(
 *             self.con_params.password or '',             # <<<<<<<<<<<<<<
 *             salt,
 *             itercount,
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->con_params, __pyx_n_s_password); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 1050, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(5, 1050, __pyx_L1_error)
  if (!__pyx_t_2) {
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    __Pyx_INCREF(__pyx_t_8);
    __pyx_t_11 = __pyx_t_8;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    goto __pyx_L20_bool_binop_done;
  }
  __Pyx_INCREF(__pyx_kp_u__61);
  __pyx_t_11 = __pyx_kp_u__61;
  __pyx_L20_bool_binop_done:;

  /* "edgedb/protocol/protocol.pyx":1053
 *             salt,
 *             itercount,
 *             client_first_bare.encode('utf-8'),             # <<<<<<<<<<<<<<
 *             server_first,
 *             server_nonce)
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_client_first_bare, __pyx_n_s_encode); if (unlikely(!__pyx_t_12)) __PYX_ERR(5, 1053, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_16 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_16)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_16);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
    }
  }
  __pyx_t_8 = (__pyx_t_16) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_16, __pyx_kp_u_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_kp_u_utf_8);
  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
  if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 1053, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "edgedb/protocol/protocol.pyx":1055
 *             client_first_bare.encode('utf-8'),
 *             server_first,
 *             server_nonce)             # <<<<<<<<<<<<<<
 * 
 *         msg_buf = WriteBuffer.new_message(AUTH_RESPONSE_MSG)
 */
  __pyx_t_12 = NULL;
  __pyx_t_13 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_13 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[7] = {__pyx_t_12, __pyx_t_11, __pyx_cur_scope->__pyx_v_salt, __pyx_cur_scope->__pyx_v_itercount, __pyx_t_8, __pyx_cur_scope->__pyx_v_server_first, __pyx_cur_scope->__pyx_v_server_nonce};
    __pyx_t_14 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_13, 6+__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1049, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[7] = {__pyx_t_12, __pyx_t_11, __pyx_cur_scope->__pyx_v_salt, __pyx_cur_scope->__pyx_v_itercount, __pyx_t_8, __pyx_cur_scope->__pyx_v_server_first, __pyx_cur_scope->__pyx_v_server_nonce};
    __pyx_t_14 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_13, 6+__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1049, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  {
    __pyx_t_16 = PyTuple_New(6+__pyx_t_13); if (unlikely(!__pyx_t_16)) __PYX_ERR(5, 1049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    if (__pyx_t_12) {
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_12); __pyx_t_12 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_13, __pyx_t_11);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_salt);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_salt);
    PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_13, __pyx_cur_scope->__pyx_v_salt);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_itercount);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_itercount);
    PyTuple_SET_ITEM(__pyx_t_16, 2+__pyx_t_13, __pyx_cur_scope->__pyx_v_itercount);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_16, 3+__pyx_t_13, __pyx_t_8);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_server_first);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_server_first);
    PyTuple_SET_ITEM(__pyx_t_16, 4+__pyx_t_13, __pyx_cur_scope->__pyx_v_server_first);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_server_nonce);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_server_nonce);
    PyTuple_SET_ITEM(__pyx_t_16, 5+__pyx_t_13, __pyx_cur_scope->__pyx_v_server_nonce);
    __pyx_t_11 = 0;
    __pyx_t_8 = 0;
    __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_16, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_14))) || (PyList_CheckExact(__pyx_t_14))) {
    PyObject* sequence = __pyx_t_14;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(5, 1049, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_16 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_16 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_16);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_16 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_16)) __PYX_ERR(5, 1049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    #endif
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_8 = PyObject_GetIter(__pyx_t_14); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 1049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_15 = Py_TYPE(__pyx_t_8)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_15(__pyx_t_8); if (unlikely(!__pyx_t_3)) goto __pyx_L22_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_16 = __pyx_t_15(__pyx_t_8); if (unlikely(!__pyx_t_16)) goto __pyx_L22_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_16);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_8), 2) < 0) __PYX_ERR(5, 1049, __pyx_L1_error)
    __pyx_t_15 = NULL;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    goto __pyx_L23_unpacking_done;
    __pyx_L22_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_15 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(5, 1049, __pyx_L1_error)
    __pyx_L23_unpacking_done:;
  }

  /* "edgedb/protocol/protocol.pyx":1049
 *             scram.parse_server_first_message(server_first))
 * 
 *         client_final, expected_server_sig = scram.build_client_final_message(             # <<<<<<<<<<<<<<
 *             self.con_params.password or '',
 *             salt,
 */
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_client_final = __pyx_t_3;
  __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_16);
  __pyx_cur_scope->__pyx_v_expected_server_sig = __pyx_t_16;
  __pyx_t_16 = 0;

  /* "edgedb/protocol/protocol.pyx":1057
 *             server_nonce)
 * 
 *         msg_buf = WriteBuffer.new_message(AUTH_RESPONSE_MSG)             # <<<<<<<<<<<<<<
 *         msg_buf.write_len_prefixed_utf8(client_final)
 *         msg_buf.end_message()
 */
  __pyx_t_14 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('r')); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1057, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_msg_buf));
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_msg_buf, ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_14));
  __Pyx_GIVEREF(__pyx_t_14);
  __pyx_t_14 = 0;

  /* "edgedb/protocol/protocol.pyx":1058
 * 
 *         msg_buf = WriteBuffer.new_message(AUTH_RESPONSE_MSG)
 *         msg_buf.write_len_prefixed_utf8(client_final)             # <<<<<<<<<<<<<<
 *         msg_buf.end_message()
 *         self.write(msg_buf)
 */
  if (!(likely(PyUnicode_CheckExact(__pyx_cur_scope->__pyx_v_client_final))||((__pyx_cur_scope->__pyx_v_client_final) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_cur_scope->__pyx_v_client_final)->tp_name), 0))) __PYX_ERR(5, 1058, __pyx_L1_error)
  __pyx_t_14 = __pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_write_len_prefixed_utf8(__pyx_cur_scope->__pyx_v_msg_buf, ((PyObject*)__pyx_cur_scope->__pyx_v_client_final)); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1058, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "edgedb/protocol/protocol.pyx":1059
 *         msg_buf = WriteBuffer.new_message(AUTH_RESPONSE_MSG)
 *         msg_buf.write_len_prefixed_utf8(client_final)
 *         msg_buf.end_message()             # <<<<<<<<<<<<<<
 *         self.write(msg_buf)
 * 
 */
  __pyx_t_14 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_cur_scope->__pyx_v_msg_buf->__pyx_vtab)->end_message(__pyx_cur_scope->__pyx_v_msg_buf); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1059, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "edgedb/protocol/protocol.pyx":1060
 *         msg_buf.write_len_prefixed_utf8(client_final)
 *         msg_buf.end_message()
 *         self.write(msg_buf)             # <<<<<<<<<<<<<<
 * 
 *         while True:
 */
  __pyx_t_14 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->write(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_msg_buf); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "edgedb/protocol/protocol.pyx":1062
 *         self.write(msg_buf)
 * 
 *         while True:             # <<<<<<<<<<<<<<
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 */
  while (1) {

    /* "edgedb/protocol/protocol.pyx":1063
 * 
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->take_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_1 == ((int32_t)-1))) __PYX_ERR(5, 1063, __pyx_L1_error)
    __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
    if (__pyx_t_2) {

      /* "edgedb/protocol/protocol.pyx":1064
 *         while True:
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()             # <<<<<<<<<<<<<<
 *             mtype = self.buffer.get_message_type()
 * 
 */
      __pyx_t_16 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_wait_for_message); if (unlikely(!__pyx_t_16)) __PYX_ERR(5, 1064, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_16))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_16);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_16, function);
        }
      }
      __pyx_t_14 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_16);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1064, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_r = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_14);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_XGOTREF(__pyx_r);
      if (likely(__pyx_r)) {
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 2;
        return __pyx_r;
        __pyx_L27_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(5, 1064, __pyx_L1_error)
      } else {
        PyObject* exc_type = __Pyx_PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();
          else __PYX_ERR(5, 1064, __pyx_L1_error)
        }
      }

      /* "edgedb/protocol/protocol.pyx":1063
 * 
 *         while True:
 *             if not self.buffer.take_message():             # <<<<<<<<<<<<<<
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()
 */
    }

    /* "edgedb/protocol/protocol.pyx":1065
 *             if not self.buffer.take_message():
 *                 await self.wait_for_message()
 *             mtype = self.buffer.get_message_type()             # <<<<<<<<<<<<<<
 * 
 *             if mtype == ERROR_RESPONSE_MSG:
 */
    __pyx_cur_scope->__pyx_v_mtype = __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_cur_scope->__pyx_v_self->buffer);

    /* "edgedb/protocol/protocol.pyx":1067
 *             mtype = self.buffer.get_message_type()
 * 
 *             if mtype == ERROR_RESPONSE_MSG:             # <<<<<<<<<<<<<<
 *                 exc = self.parse_error_message()
 *                 self.buffer.finish_message()
 */
    switch (__pyx_cur_scope->__pyx_v_mtype) {
      case 'E':

      /* "edgedb/protocol/protocol.pyx":1068
 * 
 *             if mtype == ERROR_RESPONSE_MSG:
 *                 exc = self.parse_error_message()             # <<<<<<<<<<<<<<
 *                 self.buffer.finish_message()
 *                 raise exc
 */
      __pyx_t_14 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->parse_error_message(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1068, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_14);
      __pyx_cur_scope->__pyx_v_exc = __pyx_t_14;
      __pyx_t_14 = 0;

      /* "edgedb/protocol/protocol.pyx":1069
 *             if mtype == ERROR_RESPONSE_MSG:
 *                 exc = self.parse_error_message()
 *                 self.buffer.finish_message()             # <<<<<<<<<<<<<<
 *                 raise exc
 * 
 */
      __pyx_t_14 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1069, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "edgedb/protocol/protocol.pyx":1070
 *                 exc = self.parse_error_message()
 *                 self.buffer.finish_message()
 *                 raise exc             # <<<<<<<<<<<<<<
 * 
 *             elif mtype == AUTH_REQUEST_MSG:
 */
      __Pyx_Raise(__pyx_cur_scope->__pyx_v_exc, 0, 0, 0);
      __PYX_ERR(5, 1070, __pyx_L1_error)

      /* "edgedb/protocol/protocol.pyx":1067
 *             mtype = self.buffer.get_message_type()
 * 
 *             if mtype == ERROR_RESPONSE_MSG:             # <<<<<<<<<<<<<<
 *                 exc = self.parse_error_message()
 *                 self.buffer.finish_message()
 */
      break;
      case 'R':

      /* "edgedb/protocol/protocol.pyx":1073
 * 
 *             elif mtype == AUTH_REQUEST_MSG:
 *                 break             # <<<<<<<<<<<<<<
 * 
 *             else:
 */
      goto __pyx_L25_break;

      /* "edgedb/protocol/protocol.pyx":1072
 *                 raise exc
 * 
 *             elif mtype == AUTH_REQUEST_MSG:             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
      break;
      default:

      /* "edgedb/protocol/protocol.pyx":1076
 * 
 *             else:
 *                 self.fallthrough()             # <<<<<<<<<<<<<<
 * 
 *         status = self.buffer.read_int32()
 */
      __pyx_t_14 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->fallthrough(__pyx_cur_scope->__pyx_v_self); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1076, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      break;
    }
  }
  __pyx_L25_break:;

  /* "edgedb/protocol/protocol.pyx":1078
 *                 self.fallthrough()
 * 
 *         status = self.buffer.read_int32()             # <<<<<<<<<<<<<<
 *         if status != AuthenticationStatuses.AUTH_SASL_FINAL:
 *             raise RuntimeError(
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->read_int32(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(__pyx_t_1 == ((int32_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 1078, __pyx_L1_error)
  __pyx_cur_scope->__pyx_v_status = __pyx_t_1;

  /* "edgedb/protocol/protocol.pyx":1079
 * 
 *         status = self.buffer.read_int32()
 *         if status != AuthenticationStatuses.AUTH_SASL_FINAL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'expected SASLFinal from the server, received {status}')
 */
  __pyx_t_2 = ((__pyx_cur_scope->__pyx_v_status != __pyx_e_6edgedb_8protocol_8protocol_AUTH_SASL_FINAL) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/protocol.pyx":1081
 *         if status != AuthenticationStatuses.AUTH_SASL_FINAL:
 *             raise RuntimeError(
 *                 f'expected SASLFinal from the server, received {status}')             # <<<<<<<<<<<<<<
 * 
 *         server_final = self.buffer.read_len_prefixed_bytes()
 */
    __pyx_t_14 = __Pyx_PyInt_From_int32_t(__pyx_cur_scope->__pyx_v_status); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1081, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_16 = __Pyx_PyObject_FormatSimple(__pyx_t_14, __pyx_empty_unicode); if (unlikely(!__pyx_t_16)) __PYX_ERR(5, 1081, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_14 = __Pyx_PyUnicode_Concat(__pyx_kp_u_expected_SASLFinal_from_the_serv, __pyx_t_16); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1081, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

    /* "edgedb/protocol/protocol.pyx":1080
 *         status = self.buffer.read_int32()
 *         if status != AuthenticationStatuses.AUTH_SASL_FINAL:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 f'expected SASLFinal from the server, received {status}')
 * 
 */
    __pyx_t_16 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_14); if (unlikely(!__pyx_t_16)) __PYX_ERR(5, 1080, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_Raise(__pyx_t_16, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __PYX_ERR(5, 1080, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":1079
 * 
 *         status = self.buffer.read_int32()
 *         if status != AuthenticationStatuses.AUTH_SASL_FINAL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'expected SASLFinal from the server, received {status}')
 */
  }

  /* "edgedb/protocol/protocol.pyx":1083
 *                 f'expected SASLFinal from the server, received {status}')
 * 
 *         server_final = self.buffer.read_len_prefixed_bytes()             # <<<<<<<<<<<<<<
 *         self.buffer.finish_message()
 *         server_sig = scram.parse_server_final_message(server_final)
 */
  __pyx_t_16 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->read_len_prefixed_bytes(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_16)) __PYX_ERR(5, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_GIVEREF(__pyx_t_16);
  __pyx_cur_scope->__pyx_v_server_final = ((PyObject*)__pyx_t_16);
  __pyx_t_16 = 0;

  /* "edgedb/protocol/protocol.pyx":1084
 * 
 *         server_final = self.buffer.read_len_prefixed_bytes()
 *         self.buffer.finish_message()             # <<<<<<<<<<<<<<
 *         server_sig = scram.parse_server_final_message(server_final)
 * 
 */
  __pyx_t_16 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_cur_scope->__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_cur_scope->__pyx_v_self->buffer); if (unlikely(!__pyx_t_16)) __PYX_ERR(5, 1084, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

  /* "edgedb/protocol/protocol.pyx":1085
 *         server_final = self.buffer.read_len_prefixed_bytes()
 *         self.buffer.finish_message()
 *         server_sig = scram.parse_server_final_message(server_final)             # <<<<<<<<<<<<<<
 * 
 *         if server_sig != expected_server_sig:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_scram); if (unlikely(!__pyx_t_14)) __PYX_ERR(5, 1085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_parse_server_final_message); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_16 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_14, __pyx_cur_scope->__pyx_v_server_final) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_server_final);
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_16)) __PYX_ERR(5, 1085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_16);
  __pyx_cur_scope->__pyx_v_server_sig = __pyx_t_16;
  __pyx_t_16 = 0;

  /* "edgedb/protocol/protocol.pyx":1087
 *         server_sig = scram.parse_server_final_message(server_final)
 * 
 *         if server_sig != expected_server_sig:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'server SCRAM proof does not match')
 */
  __pyx_t_16 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_server_sig, __pyx_cur_scope->__pyx_v_expected_server_sig, Py_NE); __Pyx_XGOTREF(__pyx_t_16); if (unlikely(!__pyx_t_16)) __PYX_ERR(5, 1087, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_16); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(5, 1087, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/protocol.pyx":1088
 * 
 *         if server_sig != expected_server_sig:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 f'server SCRAM proof does not match')
 * 
 */
    __pyx_t_16 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(5, 1088, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_Raise(__pyx_t_16, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __PYX_ERR(5, 1088, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":1087
 *         server_sig = scram.parse_server_final_message(server_final)
 * 
 *         if server_sig != expected_server_sig:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(
 *                 f'server SCRAM proof does not match')
 */
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "edgedb/protocol/protocol.pyx":989
 *             )
 * 
 *     async def _auth_sasl(self):             # <<<<<<<<<<<<<<
 *         num_methods = self.buffer.read_int32()
 *         if num_methods <= 0:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_AddTraceback("_auth_sasl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":1091
 *                 f'server SCRAM proof does not match')
 * 
 *     cdef parse_system_config(self, BaseCodec codec, bytes data):             # <<<<<<<<<<<<<<
 *         cdef:
 *             decode_row_method decoder = <decode_row_method>codec.decode
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_system_config(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_codec, PyObject *__pyx_v_data) {
  __pyx_t_6edgedb_8protocol_8protocol_decode_row_method __pyx_v_decoder;
  char const *__pyx_v_buf;
  Py_ssize_t __pyx_v_buf_len;
  struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer __pyx_v__rbuf;
  struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_rbuf;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("parse_system_config", 0);

  /* "edgedb/protocol/protocol.pyx":1093
 *     cdef parse_system_config(self, BaseCodec codec, bytes data):
 *         cdef:
 *             decode_row_method decoder = <decode_row_method>codec.decode             # <<<<<<<<<<<<<<
 * 
 *             const char* buf
 */
  __pyx_v_decoder = ((__pyx_t_6edgedb_8protocol_8protocol_decode_row_method)((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_codec->__pyx_vtab)->decode);

  /* "edgedb/protocol/protocol.pyx":1099
 * 
 *             FRBuffer _rbuf
 *             FRBuffer *rbuf = &_rbuf             # <<<<<<<<<<<<<<
 * 
 *         buf = cpython.PyBytes_AS_STRING(data)
 */
  __pyx_v_rbuf = (&__pyx_v__rbuf);

  /* "edgedb/protocol/protocol.pyx":1101
 *             FRBuffer *rbuf = &_rbuf
 * 
 *         buf = cpython.PyBytes_AS_STRING(data)             # <<<<<<<<<<<<<<
 *         buf_len = cpython.PyBytes_GET_SIZE(data)
 * 
 */
  __pyx_v_buf = PyBytes_AS_STRING(__pyx_v_data);

  /* "edgedb/protocol/protocol.pyx":1102
 * 
 *         buf = cpython.PyBytes_AS_STRING(data)
 *         buf_len = cpython.PyBytes_GET_SIZE(data)             # <<<<<<<<<<<<<<
 * 
 *         frb_init(rbuf, buf, buf_len)
 */
  __pyx_v_buf_len = PyBytes_GET_SIZE(__pyx_v_data);

  /* "edgedb/protocol/protocol.pyx":1104
 *         buf_len = cpython.PyBytes_GET_SIZE(data)
 * 
 *         frb_init(rbuf, buf, buf_len)             # <<<<<<<<<<<<<<
 * 
 *         return decoder(codec, rbuf)
 */
  __pyx_f_6edgedb_7pgproto_7pgproto_frb_init(__pyx_v_rbuf, __pyx_v_buf, __pyx_v_buf_len);

  /* "edgedb/protocol/protocol.pyx":1106
 *         frb_init(rbuf, buf, buf_len)
 * 
 *         return decoder(codec, rbuf)             # <<<<<<<<<<<<<<
 * 
 *     cdef parse_server_settings(self, str name, bytes val):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_v_decoder(__pyx_v_codec, __pyx_v_rbuf); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/protocol.pyx":1091
 *                 f'server SCRAM proof does not match')
 * 
 *     cdef parse_system_config(self, BaseCodec codec, bytes data):             # <<<<<<<<<<<<<<
 *         cdef:
 *             decode_row_method decoder = <decode_row_method>codec.decode
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.parse_system_config", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":1108
 *         return decoder(codec, rbuf)
 * 
 *     cdef parse_server_settings(self, str name, bytes val):             # <<<<<<<<<<<<<<
 *         if name == 'suggested_pool_concurrency':
 *             self.server_settings[name] = int(val.decode('utf-8'))
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_server_settings(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_val) {
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *__pyx_v_buf = NULL;
  long __pyx_v_typedesc_len;
  PyObject *__pyx_v_typedesc_id = NULL;
  PyObject *__pyx_v_typedesc = NULL;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_codec = NULL;
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int32_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("parse_server_settings", 0);

  /* "edgedb/protocol/protocol.pyx":1109
 * 
 *     cdef parse_server_settings(self, str name, bytes val):
 *         if name == 'suggested_pool_concurrency':             # <<<<<<<<<<<<<<
 *             self.server_settings[name] = int(val.decode('utf-8'))
 *         elif name == 'system_config':
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_name, __pyx_n_u_suggested_pool_concurrency, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(5, 1109, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "edgedb/protocol/protocol.pyx":1110
 *     cdef parse_server_settings(self, str name, bytes val):
 *         if name == 'suggested_pool_concurrency':
 *             self.server_settings[name] = int(val.decode('utf-8'))             # <<<<<<<<<<<<<<
 *         elif name == 'system_config':
 *             buf = ReadBuffer()
 */
    if (unlikely(__pyx_v_val == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "decode");
      __PYX_ERR(5, 1110, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_decode_bytes(__pyx_v_val, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(__pyx_v_self->server_settings == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(5, 1110, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__pyx_v_self->server_settings, __pyx_v_name, __pyx_t_4) < 0)) __PYX_ERR(5, 1110, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "edgedb/protocol/protocol.pyx":1109
 * 
 *     cdef parse_server_settings(self, str name, bytes val):
 *         if name == 'suggested_pool_concurrency':             # <<<<<<<<<<<<<<
 *             self.server_settings[name] = int(val.decode('utf-8'))
 *         elif name == 'system_config':
 */
    goto __pyx_L3;
  }

  /* "edgedb/protocol/protocol.pyx":1111
 *         if name == 'suggested_pool_concurrency':
 *             self.server_settings[name] = int(val.decode('utf-8'))
 *         elif name == 'system_config':             # <<<<<<<<<<<<<<
 *             buf = ReadBuffer()
 *             buf.feed_data(val)
 */
  __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_name, __pyx_n_u_system_config, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(5, 1111, __pyx_L1_error)
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "edgedb/protocol/protocol.pyx":1112
 *             self.server_settings[name] = int(val.decode('utf-8'))
 *         elif name == 'system_config':
 *             buf = ReadBuffer()             # <<<<<<<<<<<<<<
 *             buf.feed_data(val)
 *             typedesc_len = buf.read_int32() - 16
 */
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6edgedb_7pgproto_7pgproto_ReadBuffer)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_buf = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "edgedb/protocol/protocol.pyx":1113
 *         elif name == 'system_config':
 *             buf = ReadBuffer()
 *             buf.feed_data(val)             # <<<<<<<<<<<<<<
 *             typedesc_len = buf.read_int32() - 16
 *             typedesc_id = buf.read_bytes(16)
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_buf->__pyx_vtab)->feed_data(__pyx_v_buf, __pyx_v_val); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "edgedb/protocol/protocol.pyx":1114
 *             buf = ReadBuffer()
 *             buf.feed_data(val)
 *             typedesc_len = buf.read_int32() - 16             # <<<<<<<<<<<<<<
 *             typedesc_id = buf.read_bytes(16)
 *             typedesc = buf.read_bytes(typedesc_len)
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_buf->__pyx_vtab)->read_int32(__pyx_v_buf); if (unlikely(__pyx_t_5 == ((int32_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 1114, __pyx_L1_error)
    __pyx_v_typedesc_len = (__pyx_t_5 - 16);

    /* "edgedb/protocol/protocol.pyx":1115
 *             buf.feed_data(val)
 *             typedesc_len = buf.read_int32() - 16
 *             typedesc_id = buf.read_bytes(16)             # <<<<<<<<<<<<<<
 *             typedesc = buf.read_bytes(typedesc_len)
 * 
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_buf->__pyx_vtab)->read_bytes(__pyx_v_buf, 16); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1115, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_typedesc_id = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "edgedb/protocol/protocol.pyx":1116
 *             typedesc_len = buf.read_int32() - 16
 *             typedesc_id = buf.read_bytes(16)
 *             typedesc = buf.read_bytes(typedesc_len)             # <<<<<<<<<<<<<<
 * 
 *             if self.internal_reg.has_codec(typedesc_id):
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_buf->__pyx_vtab)->read_bytes(__pyx_v_buf, __pyx_v_typedesc_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1116, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_typedesc = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "edgedb/protocol/protocol.pyx":1118
 *             typedesc = buf.read_bytes(typedesc_len)
 * 
 *             if self.internal_reg.has_codec(typedesc_id):             # <<<<<<<<<<<<<<
 *                 codec = self.internal_reg.get_codec(typedesc_id)
 *             else:
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v_self->internal_reg->__pyx_vtab)->has_codec(__pyx_v_self->internal_reg, __pyx_v_typedesc_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1118, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(5, 1118, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_1) {

      /* "edgedb/protocol/protocol.pyx":1119
 * 
 *             if self.internal_reg.has_codec(typedesc_id):
 *                 codec = self.internal_reg.get_codec(typedesc_id)             # <<<<<<<<<<<<<<
 *             else:
 *                 codec = self.internal_reg.build_codec(
 */
      __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v_self->internal_reg->__pyx_vtab)->get_codec(__pyx_v_self->internal_reg, __pyx_v_typedesc_id)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1119, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "edgedb/protocol/protocol.pyx":1118
 *             typedesc = buf.read_bytes(typedesc_len)
 * 
 *             if self.internal_reg.has_codec(typedesc_id):             # <<<<<<<<<<<<<<
 *                 codec = self.internal_reg.get_codec(typedesc_id)
 *             else:
 */
      goto __pyx_L4;
    }

    /* "edgedb/protocol/protocol.pyx":1121
 *                 codec = self.internal_reg.get_codec(typedesc_id)
 *             else:
 *                 codec = self.internal_reg.build_codec(             # <<<<<<<<<<<<<<
 *                     typedesc, self.protocol_version)
 * 
 */
    /*else*/ {

      /* "edgedb/protocol/protocol.pyx":1122
 *             else:
 *                 codec = self.internal_reg.build_codec(
 *                     typedesc, self.protocol_version)             # <<<<<<<<<<<<<<
 * 
 *             data = buf.read_len_prefixed_bytes()
 */
      __pyx_t_4 = __pyx_v_self->protocol_version;
      __Pyx_INCREF(__pyx_t_4);

      /* "edgedb/protocol/protocol.pyx":1121
 *                 codec = self.internal_reg.get_codec(typedesc_id)
 *             else:
 *                 codec = self.internal_reg.build_codec(             # <<<<<<<<<<<<<<
 *                     typedesc, self.protocol_version)
 * 
 */
      __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v_self->internal_reg->__pyx_vtab)->build_codec(__pyx_v_self->internal_reg, __pyx_v_typedesc, __pyx_t_4)); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1121, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_3);
      __pyx_t_3 = 0;
    }
    __pyx_L4:;

    /* "edgedb/protocol/protocol.pyx":1124
 *                     typedesc, self.protocol_version)
 * 
 *             data = buf.read_len_prefixed_bytes()             # <<<<<<<<<<<<<<
 *             self.server_settings[name] = self.parse_system_config(codec, data)
 *         else:
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_buf->__pyx_vtab)->read_len_prefixed_bytes(__pyx_v_buf); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1124, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_data = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "edgedb/protocol/protocol.pyx":1125
 * 
 *             data = buf.read_len_prefixed_bytes()
 *             self.server_settings[name] = self.parse_system_config(codec, data)             # <<<<<<<<<<<<<<
 *         else:
 *             self.server_settings[name] = val
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self->__pyx_vtab)->parse_system_config(__pyx_v_self, __pyx_v_codec, __pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1125, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__pyx_v_self->server_settings == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(5, 1125, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__pyx_v_self->server_settings, __pyx_v_name, __pyx_t_3) < 0)) __PYX_ERR(5, 1125, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "edgedb/protocol/protocol.pyx":1111
 *         if name == 'suggested_pool_concurrency':
 *             self.server_settings[name] = int(val.decode('utf-8'))
 *         elif name == 'system_config':             # <<<<<<<<<<<<<<
 *             buf = ReadBuffer()
 *             buf.feed_data(val)
 */
    goto __pyx_L3;
  }

  /* "edgedb/protocol/protocol.pyx":1127
 *             self.server_settings[name] = self.parse_system_config(codec, data)
 *         else:
 *             self.server_settings[name] = val             # <<<<<<<<<<<<<<
 * 
 *     cdef fallthrough(self):
 */
  /*else*/ {
    if (unlikely(__pyx_v_self->server_settings == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(5, 1127, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__pyx_v_self->server_settings, __pyx_v_name, __pyx_v_val) < 0)) __PYX_ERR(5, 1127, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "edgedb/protocol/protocol.pyx":1108
 *         return decoder(codec, rbuf)
 * 
 *     cdef parse_server_settings(self, str name, bytes val):             # <<<<<<<<<<<<<<
 *         if name == 'suggested_pool_concurrency':
 *             self.server_settings[name] = int(val.decode('utf-8'))
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.parse_server_settings", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
  __Pyx_XDECREF(__pyx_v_typedesc_id);
  __Pyx_XDECREF(__pyx_v_typedesc);
  __Pyx_XDECREF((PyObject *)__pyx_v_codec);
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":1129
 *             self.server_settings[name] = val
 * 
 *     cdef fallthrough(self):             # <<<<<<<<<<<<<<
 *         cdef:
 *             char mtype = self.buffer.get_message_type()
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_fallthrough(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  char __pyx_v_mtype;
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_val = NULL;
  uint8_t __pyx_v_severity;
  uint32_t __pyx_v_code;
  PyObject *__pyx_v_message = NULL;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_v_con = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char __pyx_t_2;
  int32_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fallthrough", 0);

  /* "edgedb/protocol/protocol.pyx":1131
 *     cdef fallthrough(self):
 *         cdef:
 *             char mtype = self.buffer.get_message_type()             # <<<<<<<<<<<<<<
 * 
 *         if mtype == PARAMETER_STATUS_MSG:
 */
  __pyx_v_mtype = __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_v_self->buffer);

  /* "edgedb/protocol/protocol.pyx":1133
 *             char mtype = self.buffer.get_message_type()
 * 
 *         if mtype == PARAMETER_STATUS_MSG:             # <<<<<<<<<<<<<<
 *             name = self.buffer.read_len_prefixed_utf8()
 *             val = self.buffer.read_len_prefixed_bytes()
 */
  switch (__pyx_v_mtype) {
    case 'S':

    /* "edgedb/protocol/protocol.pyx":1134
 * 
 *         if mtype == PARAMETER_STATUS_MSG:
 *             name = self.buffer.read_len_prefixed_utf8()             # <<<<<<<<<<<<<<
 *             val = self.buffer.read_len_prefixed_bytes()
 *             self.buffer.finish_message()
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_len_prefixed_utf8(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1134, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_name = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":1135
 *         if mtype == PARAMETER_STATUS_MSG:
 *             name = self.buffer.read_len_prefixed_utf8()
 *             val = self.buffer.read_len_prefixed_bytes()             # <<<<<<<<<<<<<<
 *             self.buffer.finish_message()
 *             self.parse_server_settings(name, val)
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_len_prefixed_bytes(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1135, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_val = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":1136
 *             name = self.buffer.read_len_prefixed_utf8()
 *             val = self.buffer.read_len_prefixed_bytes()
 *             self.buffer.finish_message()             # <<<<<<<<<<<<<<
 *             self.parse_server_settings(name, val)
 * 
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1136, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":1137
 *             val = self.buffer.read_len_prefixed_bytes()
 *             self.buffer.finish_message()
 *             self.parse_server_settings(name, val)             # <<<<<<<<<<<<<<
 * 
 *         elif mtype == LOG_MSG:
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self->__pyx_vtab)->parse_server_settings(__pyx_v_self, __pyx_v_name, __pyx_v_val); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1137, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":1133
 *             char mtype = self.buffer.get_message_type()
 * 
 *         if mtype == PARAMETER_STATUS_MSG:             # <<<<<<<<<<<<<<
 *             name = self.buffer.read_len_prefixed_utf8()
 *             val = self.buffer.read_len_prefixed_bytes()
 */
    break;
    case 'L':

    /* "edgedb/protocol/protocol.pyx":1140
 * 
 *         elif mtype == LOG_MSG:
 *             severity = <uint8_t>self.buffer.read_byte()             # <<<<<<<<<<<<<<
 *             code = <uint32_t>self.buffer.read_int32()
 *             message = self.buffer.read_len_prefixed_utf8()
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_byte(__pyx_v_self->buffer); if (unlikely(__pyx_t_2 == ((char)-1) && PyErr_Occurred())) __PYX_ERR(5, 1140, __pyx_L1_error)
    __pyx_v_severity = ((uint8_t)__pyx_t_2);

    /* "edgedb/protocol/protocol.pyx":1141
 *         elif mtype == LOG_MSG:
 *             severity = <uint8_t>self.buffer.read_byte()
 *             code = <uint32_t>self.buffer.read_int32()             # <<<<<<<<<<<<<<
 *             message = self.buffer.read_len_prefixed_utf8()
 *             # Ignore any headers: not yet specified for log messages.
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_int32(__pyx_v_self->buffer); if (unlikely(__pyx_t_3 == ((int32_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 1141, __pyx_L1_error)
    __pyx_v_code = ((uint32_t)__pyx_t_3);

    /* "edgedb/protocol/protocol.pyx":1142
 *             severity = <uint8_t>self.buffer.read_byte()
 *             code = <uint32_t>self.buffer.read_int32()
 *             message = self.buffer.read_len_prefixed_utf8()             # <<<<<<<<<<<<<<
 *             # Ignore any headers: not yet specified for log messages.
 *             self.parse_headers()
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_len_prefixed_utf8(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1142, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_message = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":1144
 *             message = self.buffer.read_len_prefixed_utf8()
 *             # Ignore any headers: not yet specified for log messages.
 *             self.parse_headers()             # <<<<<<<<<<<<<<
 *             self.buffer.finish_message()
 * 
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self->__pyx_vtab)->parse_headers(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":1145
 *             # Ignore any headers: not yet specified for log messages.
 *             self.parse_headers()
 *             self.buffer.finish_message()             # <<<<<<<<<<<<<<
 * 
 *             msg = errors.EdgeDBMessage._from_code(code, severity, message)
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1145, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":1147
 *             self.buffer.finish_message()
 * 
 *             msg = errors.EdgeDBMessage._from_code(code, severity, message)             # <<<<<<<<<<<<<<
 *             if self.con is not None:
 *                 con = self.con()
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_errors); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_EdgeDBMessage); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_from_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_From_uint32_t(__pyx_v_code); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyInt_From_uint8_t(__pyx_v_severity); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 1147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_5, __pyx_t_6, __pyx_v_message};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1147, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_5, __pyx_t_6, __pyx_v_message};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1147, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 1147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
      __Pyx_INCREF(__pyx_v_message);
      __Pyx_GIVEREF(__pyx_v_message);
      PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_v_message);
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_msg = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":1148
 * 
 *             msg = errors.EdgeDBMessage._from_code(code, severity, message)
 *             if self.con is not None:             # <<<<<<<<<<<<<<
 *                 con = self.con()
 *                 if con is not None:
 */
    __pyx_t_10 = (__pyx_v_self->con != Py_None);
    __pyx_t_11 = (__pyx_t_10 != 0);
    if (__pyx_t_11) {

      /* "edgedb/protocol/protocol.pyx":1149
 *             msg = errors.EdgeDBMessage._from_code(code, severity, message)
 *             if self.con is not None:
 *                 con = self.con()             # <<<<<<<<<<<<<<
 *                 if con is not None:
 *                     con._on_log_message(msg)
 */
      __Pyx_INCREF(__pyx_v_self->con);
      __pyx_t_4 = __pyx_v_self->con; __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1149, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_con = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "edgedb/protocol/protocol.pyx":1150
 *             if self.con is not None:
 *                 con = self.con()
 *                 if con is not None:             # <<<<<<<<<<<<<<
 *                     con._on_log_message(msg)
 * 
 */
      __pyx_t_11 = (__pyx_v_con != Py_None);
      __pyx_t_10 = (__pyx_t_11 != 0);
      if (__pyx_t_10) {

        /* "edgedb/protocol/protocol.pyx":1151
 *                 con = self.con()
 *                 if con is not None:
 *                     con._on_log_message(msg)             # <<<<<<<<<<<<<<
 * 
 *         else:
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_con, __pyx_n_s_on_log_message); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1151, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_9 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_9)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_9);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_9, __pyx_v_msg) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_msg);
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1151, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "edgedb/protocol/protocol.pyx":1150
 *             if self.con is not None:
 *                 con = self.con()
 *                 if con is not None:             # <<<<<<<<<<<<<<
 *                     con._on_log_message(msg)
 * 
 */
      }

      /* "edgedb/protocol/protocol.pyx":1148
 * 
 *             msg = errors.EdgeDBMessage._from_code(code, severity, message)
 *             if self.con is not None:             # <<<<<<<<<<<<<<
 *                 con = self.con()
 *                 if con is not None:
 */
    }

    /* "edgedb/protocol/protocol.pyx":1139
 *             self.parse_server_settings(name, val)
 * 
 *         elif mtype == LOG_MSG:             # <<<<<<<<<<<<<<
 *             severity = <uint8_t>self.buffer.read_byte()
 *             code = <uint32_t>self.buffer.read_int32()
 */
    break;
    default:

    /* "edgedb/protocol/protocol.pyx":1154
 * 
 *         else:
 *             self.abort()             # <<<<<<<<<<<<<<
 * 
 *             raise errors.ProtocolError(
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self->__pyx_vtab)->abort(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":1156
 *             self.abort()
 * 
 *             raise errors.ProtocolError(             # <<<<<<<<<<<<<<
 *                 f'unexpected message type {chr(mtype)!r}')
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_errors); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 1156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "edgedb/protocol/protocol.pyx":1157
 * 
 *             raise errors.ProtocolError(
 *                 f'unexpected message type {chr(mtype)!r}')             # <<<<<<<<<<<<<<
 * 
 *     cdef encode_args(self, BaseCodec in_dc, WriteBuffer buf, args, kwargs):
 */
    __pyx_t_4 = __Pyx_PyInt_From_char(__pyx_v_mtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_chr, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 1157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_6), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyUnicode_Concat(__pyx_kp_u_unexpected_message_type, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(5, 1157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_4, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(5, 1156, __pyx_L1_error)
    break;
  }

  /* "edgedb/protocol/protocol.pyx":1129
 *             self.server_settings[name] = val
 * 
 *     cdef fallthrough(self):             # <<<<<<<<<<<<<<
 *         cdef:
 *             char mtype = self.buffer.get_message_type()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.fallthrough", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XDECREF(__pyx_v_message);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF(__pyx_v_con);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":1159
 *                 f'unexpected message type {chr(mtype)!r}')
 * 
 *     cdef encode_args(self, BaseCodec in_dc, WriteBuffer buf, args, kwargs):             # <<<<<<<<<<<<<<
 *         cdef:
 *              WriteBuffer tmp = WriteBuffer.new()
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_encode_args(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_in_dc, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_buf, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  CYTHON_UNUSED struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_tmp = 0;
  PyTypeObject *__pyx_v_in_dc_type = NULL;
  PyObject *__pyx_7genexpr__pyx_v_i = NULL;
  PyObject *__pyx_7genexpr__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyTypeObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("encode_args", 0);
  __Pyx_INCREF(__pyx_v_kwargs);

  /* "edgedb/protocol/protocol.pyx":1161
 *     cdef encode_args(self, BaseCodec in_dc, WriteBuffer buf, args, kwargs):
 *         cdef:
 *              WriteBuffer tmp = WriteBuffer.new()             # <<<<<<<<<<<<<<
 * 
 *         if args and kwargs:
 */
  __pyx_t_1 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new()); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_tmp = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":1163
 *              WriteBuffer tmp = WriteBuffer.new()
 * 
 *         if args and kwargs:             # <<<<<<<<<<<<<<
 *             raise errors.QueryArgumentError(
 *                 'either positional or named arguments are supported; '
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_args); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(5, 1163, __pyx_L1_error)
  if (__pyx_t_3) {
  } else {
    __pyx_t_2 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(5, 1163, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "edgedb/protocol/protocol.pyx":1164
 * 
 *         if args and kwargs:
 *             raise errors.QueryArgumentError(             # <<<<<<<<<<<<<<
 *                 'either positional or named arguments are supported; '
 *                 'not both')
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_errors); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_QueryArgumentError); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_kp_u_either_positional_or_named_argum) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_kp_u_either_positional_or_named_argum);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(5, 1164, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":1163
 *              WriteBuffer tmp = WriteBuffer.new()
 * 
 *         if args and kwargs:             # <<<<<<<<<<<<<<
 *             raise errors.QueryArgumentError(
 *                 'either positional or named arguments are supported; '
 */
  }

  /* "edgedb/protocol/protocol.pyx":1168
 *                 'not both')
 * 
 *         in_dc_type = type(in_dc)             # <<<<<<<<<<<<<<
 * 
 *         if self.protocol_version >= (0, 12):
 */
  __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_in_dc))));
  __pyx_v_in_dc_type = ((PyTypeObject*)((PyObject *)Py_TYPE(((PyObject *)__pyx_v_in_dc))));

  /* "edgedb/protocol/protocol.pyx":1170
 *         in_dc_type = type(in_dc)
 * 
 *         if self.protocol_version >= (0, 12):             # <<<<<<<<<<<<<<
 *             if in_dc_type in {NullCodec, EmptyTupleCodec}:
 *                 # TODO: drop EmptyTupleCodec when 1.0 RC1 is released.
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_self->protocol_version, __pyx_tuple__80, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1170, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(5, 1170, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "edgedb/protocol/protocol.pyx":1171
 * 
 *         if self.protocol_version >= (0, 12):
 *             if in_dc_type in {NullCodec, EmptyTupleCodec}:             # <<<<<<<<<<<<<<
 *                 # TODO: drop EmptyTupleCodec when 1.0 RC1 is released.
 *                 # It's only here because 0.12 protocol is only
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_in_dc_type));
    __pyx_t_6 = __pyx_v_in_dc_type;
    __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_t_6), ((PyObject *)__pyx_ptype_6edgedb_8protocol_8protocol_NullCodec), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1171, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(5, 1171, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_t_6), ((PyObject *)__pyx_ptype_6edgedb_8protocol_8protocol_EmptyTupleCodec), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1171, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(5, 1171, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_2 = __pyx_t_3;
    __pyx_L8_bool_binop_done:;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __pyx_t_3 = (__pyx_t_2 != 0);
    if (__pyx_t_3) {

      /* "edgedb/protocol/protocol.pyx":1175
 *                 # It's only here because 0.12 protocol is only
 *                 # partially implemented in edgedb@master right now.
 *                 if args:             # <<<<<<<<<<<<<<
 *                     raise errors.QueryArgumentError(
 *                         'expected no positional arguments')
 */
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_args); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(5, 1175, __pyx_L1_error)
      if (unlikely(__pyx_t_3)) {

        /* "edgedb/protocol/protocol.pyx":1176
 *                 # partially implemented in edgedb@master right now.
 *                 if args:
 *                     raise errors.QueryArgumentError(             # <<<<<<<<<<<<<<
 *                         'expected no positional arguments')
 *                 if kwargs:
 */
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_errors); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1176, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_QueryArgumentError); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1176, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_5)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_u_expected_no_positional_arguments) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u_expected_no_positional_arguments);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1176, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(5, 1176, __pyx_L1_error)

        /* "edgedb/protocol/protocol.pyx":1175
 *                 # It's only here because 0.12 protocol is only
 *                 # partially implemented in edgedb@master right now.
 *                 if args:             # <<<<<<<<<<<<<<
 *                     raise errors.QueryArgumentError(
 *                         'expected no positional arguments')
 */
      }

      /* "edgedb/protocol/protocol.pyx":1178
 *                     raise errors.QueryArgumentError(
 *                         'expected no positional arguments')
 *                 if kwargs:             # <<<<<<<<<<<<<<
 *                     raise errors.QueryArgumentError(
 *                         'expected no named arguments')
 */
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(5, 1178, __pyx_L1_error)
      if (unlikely(__pyx_t_3)) {

        /* "edgedb/protocol/protocol.pyx":1179
 *                         'expected no positional arguments')
 *                 if kwargs:
 *                     raise errors.QueryArgumentError(             # <<<<<<<<<<<<<<
 *                         'expected no named arguments')
 * 
 */
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_errors); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1179, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_QueryArgumentError); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1179, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_kp_u_expected_no_named_arguments) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_kp_u_expected_no_named_arguments);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1179, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(5, 1179, __pyx_L1_error)

        /* "edgedb/protocol/protocol.pyx":1178
 *                     raise errors.QueryArgumentError(
 *                         'expected no positional arguments')
 *                 if kwargs:             # <<<<<<<<<<<<<<
 *                     raise errors.QueryArgumentError(
 *                         'expected no named arguments')
 */
      }

      /* "edgedb/protocol/protocol.pyx":1182
 *                         'expected no named arguments')
 * 
 *                 if in_dc_type is NullCodec:             # <<<<<<<<<<<<<<
 *                     buf.write_bytes(EMPTY_NULL_DATA)
 *                 else:
 */
      __pyx_t_3 = (__pyx_v_in_dc_type == __pyx_ptype_6edgedb_8protocol_8protocol_NullCodec);
      __pyx_t_2 = (__pyx_t_3 != 0);
      if (__pyx_t_2) {

        /* "edgedb/protocol/protocol.pyx":1183
 * 
 *                 if in_dc_type is NullCodec:
 *                     buf.write_bytes(EMPTY_NULL_DATA)             # <<<<<<<<<<<<<<
 *                 else:
 *                     buf.write_bytes(EMPTY_RECORD_DATA)
 */
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_EMPTY_NULL_DATA); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1183, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(5, 1183, __pyx_L1_error)
        __pyx_t_5 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_bytes(__pyx_v_buf, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1183, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "edgedb/protocol/protocol.pyx":1182
 *                         'expected no named arguments')
 * 
 *                 if in_dc_type is NullCodec:             # <<<<<<<<<<<<<<
 *                     buf.write_bytes(EMPTY_NULL_DATA)
 *                 else:
 */
        goto __pyx_L12;
      }

      /* "edgedb/protocol/protocol.pyx":1185
 *                     buf.write_bytes(EMPTY_NULL_DATA)
 *                 else:
 *                     buf.write_bytes(EMPTY_RECORD_DATA)             # <<<<<<<<<<<<<<
 * 
 *                 return
 */
      /*else*/ {
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_EMPTY_RECORD_DATA); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1185, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (!(likely(PyBytes_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(5, 1185, __pyx_L1_error)
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_bytes(__pyx_v_buf, ((PyObject*)__pyx_t_5)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1185, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __pyx_L12:;

      /* "edgedb/protocol/protocol.pyx":1187
 *                     buf.write_bytes(EMPTY_RECORD_DATA)
 * 
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             if in_dc_type is not ObjectCodec:
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;

      /* "edgedb/protocol/protocol.pyx":1171
 * 
 *         if self.protocol_version >= (0, 12):
 *             if in_dc_type in {NullCodec, EmptyTupleCodec}:             # <<<<<<<<<<<<<<
 *                 # TODO: drop EmptyTupleCodec when 1.0 RC1 is released.
 *                 # It's only here because 0.12 protocol is only
 */
    }

    /* "edgedb/protocol/protocol.pyx":1189
 *                 return
 * 
 *             if in_dc_type is not ObjectCodec:             # <<<<<<<<<<<<<<
 *                 raise errors.QueryArgumentError(
 *                     'unexpected query argument codec')
 */
    __pyx_t_2 = (__pyx_v_in_dc_type != __pyx_ptype_6edgedb_8protocol_8protocol_ObjectCodec);
    __pyx_t_3 = (__pyx_t_2 != 0);
    if (unlikely(__pyx_t_3)) {

      /* "edgedb/protocol/protocol.pyx":1190
 * 
 *             if in_dc_type is not ObjectCodec:
 *                 raise errors.QueryArgumentError(             # <<<<<<<<<<<<<<
 *                     'unexpected query argument codec')
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_errors); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1190, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_QueryArgumentError); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1190, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_u_unexpected_query_argument_codec) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u_unexpected_query_argument_codec);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1190, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(5, 1190, __pyx_L1_error)

      /* "edgedb/protocol/protocol.pyx":1189
 *                 return
 * 
 *             if in_dc_type is not ObjectCodec:             # <<<<<<<<<<<<<<
 *                 raise errors.QueryArgumentError(
 *                     'unexpected query argument codec')
 */
    }

    /* "edgedb/protocol/protocol.pyx":1193
 *                     'unexpected query argument codec')
 * 
 *             if args:             # <<<<<<<<<<<<<<
 *                 kwargs = {str(i): v for i, v in enumerate(args)}
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_args); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(5, 1193, __pyx_L1_error)
    if (__pyx_t_3) {

      /* "edgedb/protocol/protocol.pyx":1194
 * 
 *             if args:
 *                 kwargs = {str(i): v for i, v in enumerate(args)}             # <<<<<<<<<<<<<<
 * 
 *             (<ObjectCodec>in_dc).encode_args(buf, kwargs)
 */
      { /* enter inner scope */
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1194, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_int_0);
        __pyx_t_4 = __pyx_int_0;
        if (likely(PyList_CheckExact(__pyx_v_args)) || PyTuple_CheckExact(__pyx_v_args)) {
          __pyx_t_5 = __pyx_v_args; __Pyx_INCREF(__pyx_t_5); __pyx_t_7 = 0;
          __pyx_t_8 = NULL;
        } else {
          __pyx_t_7 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1194, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 1194, __pyx_L17_error)
        }
        for (;;) {
          if (likely(!__pyx_t_8)) {
            if (likely(PyList_CheckExact(__pyx_t_5))) {
              if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_5)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_9 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(5, 1194, __pyx_L17_error)
              #else
              __pyx_t_9 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 1194, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_9);
              #endif
            } else {
              if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(5, 1194, __pyx_L17_error)
              #else
              __pyx_t_9 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 1194, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_9);
              #endif
            }
          } else {
            __pyx_t_9 = __pyx_t_8(__pyx_t_5);
            if (unlikely(!__pyx_t_9)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(5, 1194, __pyx_L17_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_9);
          }
          __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_v, __pyx_t_9);
          __pyx_t_9 = 0;
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_i, __pyx_t_4);
          __pyx_t_9 = __Pyx_PyInt_AddObjC(__pyx_t_4, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 1194, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_4);
          __pyx_t_4 = __pyx_t_9;
          __pyx_t_9 = 0;
          __pyx_t_9 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_7genexpr__pyx_v_i); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 1194, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_9);
          if (unlikely(PyDict_SetItem(__pyx_t_1, (PyObject*)__pyx_t_9, (PyObject*)__pyx_7genexpr__pyx_v_v))) __PYX_ERR(5, 1194, __pyx_L17_error)
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_7genexpr__pyx_v_i); __pyx_7genexpr__pyx_v_i = 0;
        __Pyx_XDECREF(__pyx_7genexpr__pyx_v_v); __pyx_7genexpr__pyx_v_v = 0;
        goto __pyx_L20_exit_scope;
        __pyx_L17_error:;
        __Pyx_XDECREF(__pyx_7genexpr__pyx_v_i); __pyx_7genexpr__pyx_v_i = 0;
        __Pyx_XDECREF(__pyx_7genexpr__pyx_v_v); __pyx_7genexpr__pyx_v_v = 0;
        goto __pyx_L1_error;
        __pyx_L20_exit_scope:;
      } /* exit inner scope */
      __Pyx_DECREF_SET(__pyx_v_kwargs, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "edgedb/protocol/protocol.pyx":1193
 *                     'unexpected query argument codec')
 * 
 *             if args:             # <<<<<<<<<<<<<<
 *                 kwargs = {str(i): v for i, v in enumerate(args)}
 * 
 */
    }

    /* "edgedb/protocol/protocol.pyx":1196
 *                 kwargs = {str(i): v for i, v in enumerate(args)}
 * 
 *             (<ObjectCodec>in_dc).encode_args(buf, kwargs)             # <<<<<<<<<<<<<<
 *             return
 *         else:
 */
    if (!(likely(PyDict_CheckExact(__pyx_v_kwargs))||((__pyx_v_kwargs) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_kwargs)->tp_name), 0))) __PYX_ERR(5, 1196, __pyx_L1_error)
    __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_encode_args(((struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *)__pyx_v_in_dc), __pyx_v_buf, ((PyObject*)__pyx_v_kwargs)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1196, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":1197
 * 
 *             (<ObjectCodec>in_dc).encode_args(buf, kwargs)
 *             return             # <<<<<<<<<<<<<<
 *         else:
 *             if in_dc_type is EmptyTupleCodec:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "edgedb/protocol/protocol.pyx":1170
 *         in_dc_type = type(in_dc)
 * 
 *         if self.protocol_version >= (0, 12):             # <<<<<<<<<<<<<<
 *             if in_dc_type in {NullCodec, EmptyTupleCodec}:
 *                 # TODO: drop EmptyTupleCodec when 1.0 RC1 is released.
 */
  }

  /* "edgedb/protocol/protocol.pyx":1199
 *             return
 *         else:
 *             if in_dc_type is EmptyTupleCodec:             # <<<<<<<<<<<<<<
 *                 if args:
 *                     raise errors.QueryArgumentError(
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_in_dc_type == __pyx_ptype_6edgedb_8protocol_8protocol_EmptyTupleCodec);
    __pyx_t_2 = (__pyx_t_3 != 0);
    if (__pyx_t_2) {

      /* "edgedb/protocol/protocol.pyx":1200
 *         else:
 *             if in_dc_type is EmptyTupleCodec:
 *                 if args:             # <<<<<<<<<<<<<<
 *                     raise errors.QueryArgumentError(
 *                         'expected no positional arguments')
 */
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_args); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(5, 1200, __pyx_L1_error)
      if (unlikely(__pyx_t_2)) {

        /* "edgedb/protocol/protocol.pyx":1201
 *             if in_dc_type is EmptyTupleCodec:
 *                 if args:
 *                     raise errors.QueryArgumentError(             # <<<<<<<<<<<<<<
 *                         'expected no positional arguments')
 *                 if kwargs:
 */
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_errors); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1201, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_QueryArgumentError); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1201, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_kp_u_expected_no_positional_arguments) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_kp_u_expected_no_positional_arguments);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1201, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(5, 1201, __pyx_L1_error)

        /* "edgedb/protocol/protocol.pyx":1200
 *         else:
 *             if in_dc_type is EmptyTupleCodec:
 *                 if args:             # <<<<<<<<<<<<<<
 *                     raise errors.QueryArgumentError(
 *                         'expected no positional arguments')
 */
      }

      /* "edgedb/protocol/protocol.pyx":1203
 *                     raise errors.QueryArgumentError(
 *                         'expected no positional arguments')
 *                 if kwargs:             # <<<<<<<<<<<<<<
 *                     raise errors.QueryArgumentError(
 *                         'expected no named arguments')
 */
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(5, 1203, __pyx_L1_error)
      if (unlikely(__pyx_t_2)) {

        /* "edgedb/protocol/protocol.pyx":1204
 *                         'expected no positional arguments')
 *                 if kwargs:
 *                     raise errors.QueryArgumentError(             # <<<<<<<<<<<<<<
 *                         'expected no named arguments')
 *                 buf.write_bytes(EMPTY_RECORD_DATA)
 */
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_errors); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1204, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_QueryArgumentError); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1204, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_5)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_u_expected_no_named_arguments) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u_expected_no_named_arguments);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1204, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(5, 1204, __pyx_L1_error)

        /* "edgedb/protocol/protocol.pyx":1203
 *                     raise errors.QueryArgumentError(
 *                         'expected no positional arguments')
 *                 if kwargs:             # <<<<<<<<<<<<<<
 *                     raise errors.QueryArgumentError(
 *                         'expected no named arguments')
 */
      }

      /* "edgedb/protocol/protocol.pyx":1206
 *                     raise errors.QueryArgumentError(
 *                         'expected no named arguments')
 *                 buf.write_bytes(EMPTY_RECORD_DATA)             # <<<<<<<<<<<<<<
 *                 return
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_EMPTY_RECORD_DATA); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1206, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(5, 1206, __pyx_L1_error)
      __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_buf->__pyx_vtab)->write_bytes(__pyx_v_buf, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1206, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "edgedb/protocol/protocol.pyx":1207
 *                         'expected no named arguments')
 *                 buf.write_bytes(EMPTY_RECORD_DATA)
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             if kwargs:
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;

      /* "edgedb/protocol/protocol.pyx":1199
 *             return
 *         else:
 *             if in_dc_type is EmptyTupleCodec:             # <<<<<<<<<<<<<<
 *                 if args:
 *                     raise errors.QueryArgumentError(
 */
    }

    /* "edgedb/protocol/protocol.pyx":1209
 *                 return
 * 
 *             if kwargs:             # <<<<<<<<<<<<<<
 *                 if in_dc_type is not NamedTupleCodec:
 *                     raise errors.QueryArgumentError(
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(5, 1209, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "edgedb/protocol/protocol.pyx":1210
 * 
 *             if kwargs:
 *                 if in_dc_type is not NamedTupleCodec:             # <<<<<<<<<<<<<<
 *                     raise errors.QueryArgumentError(
 *                         'expected positional arguments, got named arguments')
 */
      __pyx_t_2 = (__pyx_v_in_dc_type != __pyx_ptype_6edgedb_8protocol_8protocol_NamedTupleCodec);
      __pyx_t_3 = (__pyx_t_2 != 0);
      if (unlikely(__pyx_t_3)) {

        /* "edgedb/protocol/protocol.pyx":1211
 *             if kwargs:
 *                 if in_dc_type is not NamedTupleCodec:
 *                     raise errors.QueryArgumentError(             # <<<<<<<<<<<<<<
 *                         'expected positional arguments, got named arguments')
 * 
 */
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_errors); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1211, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_QueryArgumentError); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1211, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_1, __pyx_kp_u_expected_positional_arguments_go) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_kp_u_expected_positional_arguments_go);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1211, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(5, 1211, __pyx_L1_error)

        /* "edgedb/protocol/protocol.pyx":1210
 * 
 *             if kwargs:
 *                 if in_dc_type is not NamedTupleCodec:             # <<<<<<<<<<<<<<
 *                     raise errors.QueryArgumentError(
 *                         'expected positional arguments, got named arguments')
 */
      }

      /* "edgedb/protocol/protocol.pyx":1214
 *                         'expected positional arguments, got named arguments')
 * 
 *                 (<NamedTupleCodec>in_dc).encode_kwargs(buf, kwargs)             # <<<<<<<<<<<<<<
 * 
 *             else:
 */
      if (!(likely(PyDict_CheckExact(__pyx_v_kwargs))||((__pyx_v_kwargs) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_kwargs)->tp_name), 0))) __PYX_ERR(5, 1214, __pyx_L1_error)
      __pyx_t_4 = __pyx_f_6edgedb_8protocol_8protocol_15NamedTupleCodec_encode_kwargs(((struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *)__pyx_v_in_dc), __pyx_v_buf, ((PyObject*)__pyx_v_kwargs)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1214, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "edgedb/protocol/protocol.pyx":1209
 *                 return
 * 
 *             if kwargs:             # <<<<<<<<<<<<<<
 *                 if in_dc_type is not NamedTupleCodec:
 *                     raise errors.QueryArgumentError(
 */
      goto __pyx_L24;
    }

    /* "edgedb/protocol/protocol.pyx":1217
 * 
 *             else:
 *                 if in_dc_type is not TupleCodec and args:             # <<<<<<<<<<<<<<
 *                     raise errors.QueryArgumentError(
 *                         'expected named arguments, got positional arguments')
 */
    /*else*/ {
      __pyx_t_2 = (__pyx_v_in_dc_type != __pyx_ptype_6edgedb_8protocol_8protocol_TupleCodec);
      __pyx_t_10 = (__pyx_t_2 != 0);
      if (__pyx_t_10) {
      } else {
        __pyx_t_3 = __pyx_t_10;
        goto __pyx_L27_bool_binop_done;
      }
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_args); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(5, 1217, __pyx_L1_error)
      __pyx_t_3 = __pyx_t_10;
      __pyx_L27_bool_binop_done:;
      if (unlikely(__pyx_t_3)) {

        /* "edgedb/protocol/protocol.pyx":1218
 *             else:
 *                 if in_dc_type is not TupleCodec and args:
 *                     raise errors.QueryArgumentError(             # <<<<<<<<<<<<<<
 *                         'expected named arguments, got positional arguments')
 *                 in_dc.encode(buf, args)
 */
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_errors); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1218, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_QueryArgumentError); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1218, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
          if (likely(__pyx_t_5)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_1, function);
          }
        }
        __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_kp_u_expected_named_arguments_got_pos) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_kp_u_expected_named_arguments_got_pos);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1218, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(5, 1218, __pyx_L1_error)

        /* "edgedb/protocol/protocol.pyx":1217
 * 
 *             else:
 *                 if in_dc_type is not TupleCodec and args:             # <<<<<<<<<<<<<<
 *                     raise errors.QueryArgumentError(
 *                         'expected named arguments, got positional arguments')
 */
      }

      /* "edgedb/protocol/protocol.pyx":1220
 *                     raise errors.QueryArgumentError(
 *                         'expected named arguments, got positional arguments')
 *                 in_dc.encode(buf, args)             # <<<<<<<<<<<<<<
 * 
 *     cdef parse_describe_type_message(self, CodecsRegistry reg):
 */
      __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_in_dc->__pyx_vtab)->encode(__pyx_v_in_dc, __pyx_v_buf, __pyx_v_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1220, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __pyx_L24:;
  }

  /* "edgedb/protocol/protocol.pyx":1159
 *                 f'unexpected message type {chr(mtype)!r}')
 * 
 *     cdef encode_args(self, BaseCodec in_dc, WriteBuffer buf, args, kwargs):             # <<<<<<<<<<<<<<
 *         cdef:
 *              WriteBuffer tmp = WriteBuffer.new()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(((PyObject *)__pyx_t_6));
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.encode_args", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_tmp);
  __Pyx_XDECREF(__pyx_v_in_dc_type);
  __Pyx_XDECREF(__pyx_7genexpr__pyx_v_i);
  __Pyx_XDECREF(__pyx_7genexpr__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":1222
 *                 in_dc.encode(buf, args)
 * 
 *     cdef parse_describe_type_message(self, CodecsRegistry reg):             # <<<<<<<<<<<<<<
 *         assert self.buffer.get_message_type() == COMMAND_DATA_DESC_MSG
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_describe_type_message(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v_reg) {
  PyObject *__pyx_v_type_id = 0;
  PyObject *__pyx_v_cardinality = 0;
  PyObject *__pyx_v_headers = NULL;
  PyObject *__pyx_v_type_data = NULL;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_in_dc = NULL;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_out_dc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  char const *__pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("parse_describe_type_message", 0);

  /* "edgedb/protocol/protocol.pyx":1223
 * 
 *     cdef parse_describe_type_message(self, CodecsRegistry reg):
 *         assert self.buffer.get_message_type() == COMMAND_DATA_DESC_MSG             # <<<<<<<<<<<<<<
 * 
 *         cdef:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_v_self->buffer) == 'T') != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(5, 1223, __pyx_L1_error)
    }
  }
  #endif

  /* "edgedb/protocol/protocol.pyx":1229
 *             bytes cardinality
 * 
 *         headers = self.parse_headers()             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self->__pyx_vtab)->parse_headers(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1229, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_headers = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":1231
 *         headers = self.parse_headers()
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             cardinality = self.buffer.read_byte()
 * 
 */
  /*try:*/ {

    /* "edgedb/protocol/protocol.pyx":1232
 * 
 *         try:
 *             cardinality = self.buffer.read_byte()             # <<<<<<<<<<<<<<
 * 
 *             type_id = self.buffer.read_bytes(16)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_byte(__pyx_v_self->buffer); if (unlikely(__pyx_t_2 == ((char)-1) && PyErr_Occurred())) __PYX_ERR(5, 1232, __pyx_L4_error)
    __pyx_t_1 = PyBytes_FromStringAndSize(&__pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1232, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_cardinality = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":1234
 *             cardinality = self.buffer.read_byte()
 * 
 *             type_id = self.buffer.read_bytes(16)             # <<<<<<<<<<<<<<
 *             type_data = self.buffer.read_len_prefixed_bytes()
 * 
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_bytes(__pyx_v_self->buffer, 16); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1234, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_type_id = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":1235
 * 
 *             type_id = self.buffer.read_bytes(16)
 *             type_data = self.buffer.read_len_prefixed_bytes()             # <<<<<<<<<<<<<<
 * 
 *             if reg.has_codec(type_id):
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_len_prefixed_bytes(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1235, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_type_data = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":1237
 *             type_data = self.buffer.read_len_prefixed_bytes()
 * 
 *             if reg.has_codec(type_id):             # <<<<<<<<<<<<<<
 *                 in_dc = reg.get_codec(type_id)
 *             else:
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v_reg->__pyx_vtab)->has_codec(__pyx_v_reg, __pyx_v_type_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1237, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(5, 1237, __pyx_L4_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {

      /* "edgedb/protocol/protocol.pyx":1238
 * 
 *             if reg.has_codec(type_id):
 *                 in_dc = reg.get_codec(type_id)             # <<<<<<<<<<<<<<
 *             else:
 *                 in_dc = reg.build_codec(type_data, self.protocol_version)
 */
      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v_reg->__pyx_vtab)->get_codec(__pyx_v_reg, __pyx_v_type_id)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1238, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_v_in_dc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "edgedb/protocol/protocol.pyx":1237
 *             type_data = self.buffer.read_len_prefixed_bytes()
 * 
 *             if reg.has_codec(type_id):             # <<<<<<<<<<<<<<
 *                 in_dc = reg.get_codec(type_id)
 *             else:
 */
      goto __pyx_L6;
    }

    /* "edgedb/protocol/protocol.pyx":1240
 *                 in_dc = reg.get_codec(type_id)
 *             else:
 *                 in_dc = reg.build_codec(type_data, self.protocol_version)             # <<<<<<<<<<<<<<
 * 
 *             type_id = self.buffer.read_bytes(16)
 */
    /*else*/ {
      __pyx_t_1 = __pyx_v_self->protocol_version;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v_reg->__pyx_vtab)->build_codec(__pyx_v_reg, __pyx_v_type_data, __pyx_t_1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1240, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_in_dc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_4);
      __pyx_t_4 = 0;
    }
    __pyx_L6:;

    /* "edgedb/protocol/protocol.pyx":1242
 *                 in_dc = reg.build_codec(type_data, self.protocol_version)
 * 
 *             type_id = self.buffer.read_bytes(16)             # <<<<<<<<<<<<<<
 *             type_data = self.buffer.read_len_prefixed_bytes()
 * 
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_bytes(__pyx_v_self->buffer, 16); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1242, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_type_id, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "edgedb/protocol/protocol.pyx":1243
 * 
 *             type_id = self.buffer.read_bytes(16)
 *             type_data = self.buffer.read_len_prefixed_bytes()             # <<<<<<<<<<<<<<
 * 
 *             if reg.has_codec(type_id):
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_len_prefixed_bytes(__pyx_v_self->buffer); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1243, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_type_data, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "edgedb/protocol/protocol.pyx":1245
 *             type_data = self.buffer.read_len_prefixed_bytes()
 * 
 *             if reg.has_codec(type_id):             # <<<<<<<<<<<<<<
 *                 out_dc = reg.get_codec(type_id)
 *             else:
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v_reg->__pyx_vtab)->has_codec(__pyx_v_reg, __pyx_v_type_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1245, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(5, 1245, __pyx_L4_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_3) {

      /* "edgedb/protocol/protocol.pyx":1246
 * 
 *             if reg.has_codec(type_id):
 *                 out_dc = reg.get_codec(type_id)             # <<<<<<<<<<<<<<
 *             else:
 *                 out_dc = reg.build_codec(type_data, self.protocol_version)
 */
      __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v_reg->__pyx_vtab)->get_codec(__pyx_v_reg, __pyx_v_type_id)); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1246, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_out_dc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "edgedb/protocol/protocol.pyx":1245
 *             type_data = self.buffer.read_len_prefixed_bytes()
 * 
 *             if reg.has_codec(type_id):             # <<<<<<<<<<<<<<
 *                 out_dc = reg.get_codec(type_id)
 *             else:
 */
      goto __pyx_L7;
    }

    /* "edgedb/protocol/protocol.pyx":1248
 *                 out_dc = reg.get_codec(type_id)
 *             else:
 *                 out_dc = reg.build_codec(type_data, self.protocol_version)             # <<<<<<<<<<<<<<
 *         finally:
 *             self.buffer.finish_message()
 */
    /*else*/ {
      __pyx_t_4 = __pyx_v_self->protocol_version;
      __Pyx_INCREF(__pyx_t_4);
      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v_reg->__pyx_vtab)->build_codec(__pyx_v_reg, __pyx_v_type_data, __pyx_t_4)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1248, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_out_dc = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_1);
      __pyx_t_1 = 0;
    }
    __pyx_L7:;
  }

  /* "edgedb/protocol/protocol.pyx":1250
 *                 out_dc = reg.build_codec(type_data, self.protocol_version)
 *         finally:
 *             self.buffer.finish_message()             # <<<<<<<<<<<<<<
 * 
 *         return cardinality, in_dc, out_dc, headers
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L5;
    }
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __pyx_t_5 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename;
      {
        __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1250, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ErrRestore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_6; __pyx_filename = __pyx_t_7;
      goto __pyx_L1_error;
      __pyx_L9_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "edgedb/protocol/protocol.pyx":1252
 *             self.buffer.finish_message()
 * 
 *         return cardinality, in_dc, out_dc, headers             # <<<<<<<<<<<<<<
 * 
 *     cdef parse_data_messages(self, BaseCodec out_dc, result):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_cardinality);
  __Pyx_GIVEREF(__pyx_v_cardinality);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_cardinality);
  __Pyx_INCREF(((PyObject *)__pyx_v_in_dc));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_in_dc));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_in_dc));
  __Pyx_INCREF(((PyObject *)__pyx_v_out_dc));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_out_dc));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_out_dc));
  __Pyx_INCREF(__pyx_v_headers);
  __Pyx_GIVEREF(__pyx_v_headers);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_headers);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "edgedb/protocol/protocol.pyx":1222
 *                 in_dc.encode(buf, args)
 * 
 *     cdef parse_describe_type_message(self, CodecsRegistry reg):             # <<<<<<<<<<<<<<
 *         assert self.buffer.get_message_type() == COMMAND_DATA_DESC_MSG
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.parse_describe_type_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_type_id);
  __Pyx_XDECREF(__pyx_v_cardinality);
  __Pyx_XDECREF(__pyx_v_headers);
  __Pyx_XDECREF(__pyx_v_type_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_in_dc);
  __Pyx_XDECREF((PyObject *)__pyx_v_out_dc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":1254
 *         return cardinality, in_dc, out_dc, headers
 * 
 *     cdef parse_data_messages(self, BaseCodec out_dc, result):             # <<<<<<<<<<<<<<
 *         cdef:
 *             ReadBuffer buf = self.buffer
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_data_messages(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_out_dc, PyObject *__pyx_v_result) {
  struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *__pyx_v_buf = 0;
  __pyx_t_6edgedb_8protocol_8protocol_decode_row_method __pyx_v_decoder;
  __pyx_t_6edgedb_7pgproto_7pgproto_try_consume_message_method __pyx_v_try_consume_message;
  __pyx_t_6edgedb_7pgproto_7pgproto_take_message_type_method __pyx_v_take_message_type;
  char const *__pyx_v_cbuf;
  Py_ssize_t __pyx_v_cbuf_len;
  PyObject *__pyx_v_row = 0;
  struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer __pyx_v__rbuf;
  struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_rbuf;
  PyObject *__pyx_v_mem = NULL;
  int16_t __pyx_v_flen;
  int32_t __pyx_v_buflen;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int32_t __pyx_t_4;
  char const *__pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("parse_data_messages", 0);

  /* "edgedb/protocol/protocol.pyx":1256
 *     cdef parse_data_messages(self, BaseCodec out_dc, result):
 *         cdef:
 *             ReadBuffer buf = self.buffer             # <<<<<<<<<<<<<<
 * 
 *             decode_row_method decoder = <decode_row_method>out_dc.decode
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->buffer);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_buf = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":1258
 *             ReadBuffer buf = self.buffer
 * 
 *             decode_row_method decoder = <decode_row_method>out_dc.decode             # <<<<<<<<<<<<<<
 *             pgproto.try_consume_message_method try_consume_message = \
 *                 <pgproto.try_consume_message_method>buf.try_consume_message
 */
  __pyx_v_decoder = ((__pyx_t_6edgedb_8protocol_8protocol_decode_row_method)((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_v_out_dc->__pyx_vtab)->decode);

  /* "edgedb/protocol/protocol.pyx":1260
 *             decode_row_method decoder = <decode_row_method>out_dc.decode
 *             pgproto.try_consume_message_method try_consume_message = \
 *                 <pgproto.try_consume_message_method>buf.try_consume_message             # <<<<<<<<<<<<<<
 *             pgproto.take_message_type_method take_message_type = \
 *                 <pgproto.take_message_type_method>buf.take_message_type
 */
  __pyx_v_try_consume_message = ((__pyx_t_6edgedb_7pgproto_7pgproto_try_consume_message_method)((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_buf->__pyx_vtab)->try_consume_message);

  /* "edgedb/protocol/protocol.pyx":1262
 *                 <pgproto.try_consume_message_method>buf.try_consume_message
 *             pgproto.take_message_type_method take_message_type = \
 *                 <pgproto.take_message_type_method>buf.take_message_type             # <<<<<<<<<<<<<<
 * 
 *             const char* cbuf
 */
  __pyx_v_take_message_type = ((__pyx_t_6edgedb_7pgproto_7pgproto_take_message_type_method)((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_buf->__pyx_vtab)->take_message_type);

  /* "edgedb/protocol/protocol.pyx":1269
 * 
 *             FRBuffer _rbuf
 *             FRBuffer *rbuf = &_rbuf             # <<<<<<<<<<<<<<
 * 
 *         if PG_DEBUG:
 */
  __pyx_v_rbuf = (&__pyx_v__rbuf);

  /* "edgedb/protocol/protocol.pyx":1271
 *             FRBuffer *rbuf = &_rbuf
 * 
 *         if PG_DEBUG:             # <<<<<<<<<<<<<<
 *             if buf.get_message_type() != DATA_MSG:
 *                 raise RuntimeError('first message is not "DataMsg"')
 */
  __pyx_t_2 = (PG_DEBUG != 0);
  if (__pyx_t_2) {

    /* "edgedb/protocol/protocol.pyx":1272
 * 
 *         if PG_DEBUG:
 *             if buf.get_message_type() != DATA_MSG:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError('first message is not "DataMsg"')
 * 
 */
    __pyx_t_2 = ((__pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_v_buf) != 'D') != 0);
    if (unlikely(__pyx_t_2)) {

      /* "edgedb/protocol/protocol.pyx":1273
 *         if PG_DEBUG:
 *             if buf.get_message_type() != DATA_MSG:
 *                 raise RuntimeError('first message is not "DataMsg"')             # <<<<<<<<<<<<<<
 * 
 *             if not datatypes.set_check(result):
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__81, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1273, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(5, 1273, __pyx_L1_error)

      /* "edgedb/protocol/protocol.pyx":1272
 * 
 *         if PG_DEBUG:
 *             if buf.get_message_type() != DATA_MSG:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError('first message is not "DataMsg"')
 * 
 */
    }

    /* "edgedb/protocol/protocol.pyx":1275
 *                 raise RuntimeError('first message is not "DataMsg"')
 * 
 *             if not datatypes.set_check(result):             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     f'result is not an edgedb.Set, but {result!r}')
 */
    __pyx_t_2 = ((!(__pyx_f_6edgedb_9datatypes_9datatypes_set_check(__pyx_v_result) != 0)) != 0);
    if (unlikely(__pyx_t_2)) {

      /* "edgedb/protocol/protocol.pyx":1277
 *             if not datatypes.set_check(result):
 *                 raise RuntimeError(
 *                     f'result is not an edgedb.Set, but {result!r}')             # <<<<<<<<<<<<<<
 * 
 *         while take_message_type(buf, DATA_MSG):
 */
      __pyx_t_1 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_result), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1277, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_result_is_not_an_edgedb_Set_but, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1277, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "edgedb/protocol/protocol.pyx":1276
 * 
 *             if not datatypes.set_check(result):
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     f'result is not an edgedb.Set, but {result!r}')
 * 
 */
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1276, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(5, 1276, __pyx_L1_error)

      /* "edgedb/protocol/protocol.pyx":1275
 *                 raise RuntimeError('first message is not "DataMsg"')
 * 
 *             if not datatypes.set_check(result):             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     f'result is not an edgedb.Set, but {result!r}')
 */
    }

    /* "edgedb/protocol/protocol.pyx":1271
 *             FRBuffer *rbuf = &_rbuf
 * 
 *         if PG_DEBUG:             # <<<<<<<<<<<<<<
 *             if buf.get_message_type() != DATA_MSG:
 *                 raise RuntimeError('first message is not "DataMsg"')
 */
  }

  /* "edgedb/protocol/protocol.pyx":1279
 *                     f'result is not an edgedb.Set, but {result!r}')
 * 
 *         while take_message_type(buf, DATA_MSG):             # <<<<<<<<<<<<<<
 *             cbuf = try_consume_message(buf, &cbuf_len)
 *             if cbuf == NULL:
 */
  while (1) {
    __pyx_t_4 = __pyx_v_take_message_type(((PyObject *)__pyx_v_buf), 'D'); if (unlikely(__pyx_t_4 == ((int32_t)-1))) __PYX_ERR(5, 1279, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_4 != 0);
    if (!__pyx_t_2) break;

    /* "edgedb/protocol/protocol.pyx":1280
 * 
 *         while take_message_type(buf, DATA_MSG):
 *             cbuf = try_consume_message(buf, &cbuf_len)             # <<<<<<<<<<<<<<
 *             if cbuf == NULL:
 *                 mem = buf.consume_message()
 */
    __pyx_v_cbuf = __pyx_v_try_consume_message(((PyObject *)__pyx_v_buf), (&__pyx_v_cbuf_len));

    /* "edgedb/protocol/protocol.pyx":1281
 *         while take_message_type(buf, DATA_MSG):
 *             cbuf = try_consume_message(buf, &cbuf_len)
 *             if cbuf == NULL:             # <<<<<<<<<<<<<<
 *                 mem = buf.consume_message()
 *                 cbuf = cpython.PyBytes_AS_STRING(mem)
 */
    __pyx_t_2 = ((__pyx_v_cbuf == NULL) != 0);
    if (__pyx_t_2) {

      /* "edgedb/protocol/protocol.pyx":1282
 *             cbuf = try_consume_message(buf, &cbuf_len)
 *             if cbuf == NULL:
 *                 mem = buf.consume_message()             # <<<<<<<<<<<<<<
 *                 cbuf = cpython.PyBytes_AS_STRING(mem)
 *                 cbuf_len = cpython.PyBytes_GET_SIZE(mem)
 */
      __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_buf->__pyx_vtab)->consume_message(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1282, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_mem, ((PyObject*)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "edgedb/protocol/protocol.pyx":1283
 *             if cbuf == NULL:
 *                 mem = buf.consume_message()
 *                 cbuf = cpython.PyBytes_AS_STRING(mem)             # <<<<<<<<<<<<<<
 *                 cbuf_len = cpython.PyBytes_GET_SIZE(mem)
 * 
 */
      __pyx_v_cbuf = PyBytes_AS_STRING(__pyx_v_mem);

      /* "edgedb/protocol/protocol.pyx":1284
 *                 mem = buf.consume_message()
 *                 cbuf = cpython.PyBytes_AS_STRING(mem)
 *                 cbuf_len = cpython.PyBytes_GET_SIZE(mem)             # <<<<<<<<<<<<<<
 * 
 *             if PG_DEBUG:
 */
      __pyx_v_cbuf_len = PyBytes_GET_SIZE(__pyx_v_mem);

      /* "edgedb/protocol/protocol.pyx":1281
 *         while take_message_type(buf, DATA_MSG):
 *             cbuf = try_consume_message(buf, &cbuf_len)
 *             if cbuf == NULL:             # <<<<<<<<<<<<<<
 *                 mem = buf.consume_message()
 *                 cbuf = cpython.PyBytes_AS_STRING(mem)
 */
    }

    /* "edgedb/protocol/protocol.pyx":1286
 *                 cbuf_len = cpython.PyBytes_GET_SIZE(mem)
 * 
 *             if PG_DEBUG:             # <<<<<<<<<<<<<<
 *                 frb_init(rbuf, cbuf, cbuf_len)
 * 
 */
    __pyx_t_2 = (PG_DEBUG != 0);
    if (__pyx_t_2) {

      /* "edgedb/protocol/protocol.pyx":1287
 * 
 *             if PG_DEBUG:
 *                 frb_init(rbuf, cbuf, cbuf_len)             # <<<<<<<<<<<<<<
 * 
 *                 flen = hton.unpack_int16(frb_read(rbuf, 2))
 */
      __pyx_f_6edgedb_7pgproto_7pgproto_frb_init(__pyx_v_rbuf, __pyx_v_cbuf, __pyx_v_cbuf_len);

      /* "edgedb/protocol/protocol.pyx":1289
 *                 frb_init(rbuf, cbuf, cbuf_len)
 * 
 *                 flen = hton.unpack_int16(frb_read(rbuf, 2))             # <<<<<<<<<<<<<<
 *                 if flen != 1:
 *                     raise RuntimeError(
 */
      __pyx_t_5 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_rbuf, 2); if (unlikely(__pyx_t_5 == ((char const *)NULL))) __PYX_ERR(5, 1289, __pyx_L1_error)
      __pyx_v_flen = unpack_int16(__pyx_t_5);

      /* "edgedb/protocol/protocol.pyx":1290
 * 
 *                 flen = hton.unpack_int16(frb_read(rbuf, 2))
 *                 if flen != 1:             # <<<<<<<<<<<<<<
 *                     raise RuntimeError(
 *                         f'invalid number of columns: expected 1 got {flen}')
 */
      __pyx_t_2 = ((__pyx_v_flen != 1) != 0);
      if (unlikely(__pyx_t_2)) {

        /* "edgedb/protocol/protocol.pyx":1292
 *                 if flen != 1:
 *                     raise RuntimeError(
 *                         f'invalid number of columns: expected 1 got {flen}')             # <<<<<<<<<<<<<<
 * 
 *                 buflen = hton.unpack_int32(frb_read(rbuf, 4))
 */
        __pyx_t_1 = __Pyx_PyInt_From_int16_t(__pyx_v_flen); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1292, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_t_1, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1292, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_invalid_number_of_columns_expect, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1292, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "edgedb/protocol/protocol.pyx":1291
 *                 flen = hton.unpack_int16(frb_read(rbuf, 2))
 *                 if flen != 1:
 *                     raise RuntimeError(             # <<<<<<<<<<<<<<
 *                         f'invalid number of columns: expected 1 got {flen}')
 * 
 */
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1291, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __PYX_ERR(5, 1291, __pyx_L1_error)

        /* "edgedb/protocol/protocol.pyx":1290
 * 
 *                 flen = hton.unpack_int16(frb_read(rbuf, 2))
 *                 if flen != 1:             # <<<<<<<<<<<<<<
 *                     raise RuntimeError(
 *                         f'invalid number of columns: expected 1 got {flen}')
 */
      }

      /* "edgedb/protocol/protocol.pyx":1294
 *                         f'invalid number of columns: expected 1 got {flen}')
 * 
 *                 buflen = hton.unpack_int32(frb_read(rbuf, 4))             # <<<<<<<<<<<<<<
 *                 if frb_get_len(rbuf) != buflen:
 *                     raise RuntimeError('invalid buffer length')
 */
      __pyx_t_5 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_rbuf, 4); if (unlikely(__pyx_t_5 == ((char const *)NULL))) __PYX_ERR(5, 1294, __pyx_L1_error)
      __pyx_v_buflen = unpack_int32(__pyx_t_5);

      /* "edgedb/protocol/protocol.pyx":1295
 * 
 *                 buflen = hton.unpack_int32(frb_read(rbuf, 4))
 *                 if frb_get_len(rbuf) != buflen:             # <<<<<<<<<<<<<<
 *                     raise RuntimeError('invalid buffer length')
 *             else:
 */
      __pyx_t_2 = ((__pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len(__pyx_v_rbuf) != __pyx_v_buflen) != 0);
      if (unlikely(__pyx_t_2)) {

        /* "edgedb/protocol/protocol.pyx":1296
 *                 buflen = hton.unpack_int32(frb_read(rbuf, 4))
 *                 if frb_get_len(rbuf) != buflen:
 *                     raise RuntimeError('invalid buffer length')             # <<<<<<<<<<<<<<
 *             else:
 *                 # EdgeDB returns rows with one column; Postgres' rows
 */
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1296, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __PYX_ERR(5, 1296, __pyx_L1_error)

        /* "edgedb/protocol/protocol.pyx":1295
 * 
 *                 buflen = hton.unpack_int32(frb_read(rbuf, 4))
 *                 if frb_get_len(rbuf) != buflen:             # <<<<<<<<<<<<<<
 *                     raise RuntimeError('invalid buffer length')
 *             else:
 */
      }

      /* "edgedb/protocol/protocol.pyx":1286
 *                 cbuf_len = cpython.PyBytes_GET_SIZE(mem)
 * 
 *             if PG_DEBUG:             # <<<<<<<<<<<<<<
 *                 frb_init(rbuf, cbuf, cbuf_len)
 * 
 */
      goto __pyx_L9;
    }

    /* "edgedb/protocol/protocol.pyx":1303
 *                 #   4 bytes - int32 - every column is prefixed with its length
 *                 # so we want to skip first 6 bytes:
 *                 frb_init(rbuf, cbuf + 6, cbuf_len - 6)             # <<<<<<<<<<<<<<
 * 
 *             row = decoder(out_dc, rbuf)
 */
    /*else*/ {
      __pyx_f_6edgedb_7pgproto_7pgproto_frb_init(__pyx_v_rbuf, (__pyx_v_cbuf + 6), (__pyx_v_cbuf_len - 6));
    }
    __pyx_L9:;

    /* "edgedb/protocol/protocol.pyx":1305
 *                 frb_init(rbuf, cbuf + 6, cbuf_len - 6)
 * 
 *             row = decoder(out_dc, rbuf)             # <<<<<<<<<<<<<<
 *             datatypes.set_append(result, row)
 * 
 */
    __pyx_t_3 = __pyx_v_decoder(__pyx_v_out_dc, __pyx_v_rbuf); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1305, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_row, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "edgedb/protocol/protocol.pyx":1306
 * 
 *             row = decoder(out_dc, rbuf)
 *             datatypes.set_append(result, row)             # <<<<<<<<<<<<<<
 * 
 *             if frb_get_len(rbuf):
 */
    __pyx_t_3 = __pyx_f_6edgedb_9datatypes_9datatypes_set_append(__pyx_v_result, __pyx_v_row); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1306, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "edgedb/protocol/protocol.pyx":1308
 *             datatypes.set_append(result, row)
 * 
 *             if frb_get_len(rbuf):             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     f'unexpected trailing data in buffer after '
 */
    __pyx_t_2 = (__pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len(__pyx_v_rbuf) != 0);
    if (unlikely(__pyx_t_2)) {

      /* "edgedb/protocol/protocol.pyx":1311
 *                 raise RuntimeError(
 *                     f'unexpected trailing data in buffer after '
 *                     f'data message decoding: {frb_get_len(rbuf)}')             # <<<<<<<<<<<<<<
 * 
 *     cdef parse_command_complete_message(self):
 */
      __pyx_t_3 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len(__pyx_v_rbuf), 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1311, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);

      /* "edgedb/protocol/protocol.pyx":1310
 *             if frb_get_len(rbuf):
 *                 raise RuntimeError(
 *                     f'unexpected trailing data in buffer after '             # <<<<<<<<<<<<<<
 *                     f'data message decoding: {frb_get_len(rbuf)}')
 * 
 */
      __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_unexpected_trailing_data_in_buff_6, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1310, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "edgedb/protocol/protocol.pyx":1309
 * 
 *             if frb_get_len(rbuf):
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     f'unexpected trailing data in buffer after '
 *                     f'data message decoding: {frb_get_len(rbuf)}')
 */
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1309, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(5, 1309, __pyx_L1_error)

      /* "edgedb/protocol/protocol.pyx":1308
 *             datatypes.set_append(result, row)
 * 
 *             if frb_get_len(rbuf):             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     f'unexpected trailing data in buffer after '
 */
    }
  }

  /* "edgedb/protocol/protocol.pyx":1254
 *         return cardinality, in_dc, out_dc, headers
 * 
 *     cdef parse_data_messages(self, BaseCodec out_dc, result):             # <<<<<<<<<<<<<<
 *         cdef:
 *             ReadBuffer buf = self.buffer
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.parse_data_messages", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
  __Pyx_XDECREF(__pyx_v_row);
  __Pyx_XDECREF(__pyx_v_mem);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":1313
 *                     f'data message decoding: {frb_get_len(rbuf)}')
 * 
 *     cdef parse_command_complete_message(self):             # <<<<<<<<<<<<<<
 *         assert self.buffer.get_message_type() == COMMAND_COMPLETE_MSG
 *         attrs = self.parse_headers()
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_command_complete_message(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_v_attrs = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("parse_command_complete_message", 0);

  /* "edgedb/protocol/protocol.pyx":1314
 * 
 *     cdef parse_command_complete_message(self):
 *         assert self.buffer.get_message_type() == COMMAND_COMPLETE_MSG             # <<<<<<<<<<<<<<
 *         attrs = self.parse_headers()
 *         self.last_status = self.buffer.read_len_prefixed_bytes()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_v_self->buffer) == 'C') != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(5, 1314, __pyx_L1_error)
    }
  }
  #endif

  /* "edgedb/protocol/protocol.pyx":1315
 *     cdef parse_command_complete_message(self):
 *         assert self.buffer.get_message_type() == COMMAND_COMPLETE_MSG
 *         attrs = self.parse_headers()             # <<<<<<<<<<<<<<
 *         self.last_status = self.buffer.read_len_prefixed_bytes()
 *         self.buffer.finish_message()
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self->__pyx_vtab)->parse_headers(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_attrs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":1316
 *         assert self.buffer.get_message_type() == COMMAND_COMPLETE_MSG
 *         attrs = self.parse_headers()
 *         self.last_status = self.buffer.read_len_prefixed_bytes()             # <<<<<<<<<<<<<<
 *         self.buffer.finish_message()
 *         return attrs
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_len_prefixed_bytes(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1316, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->last_status);
  __Pyx_DECREF(__pyx_v_self->last_status);
  __pyx_v_self->last_status = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":1317
 *         attrs = self.parse_headers()
 *         self.last_status = self.buffer.read_len_prefixed_bytes()
 *         self.buffer.finish_message()             # <<<<<<<<<<<<<<
 *         return attrs
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1317, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":1318
 *         self.last_status = self.buffer.read_len_prefixed_bytes()
 *         self.buffer.finish_message()
 *         return attrs             # <<<<<<<<<<<<<<
 * 
 *     cdef parse_sync_message(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_attrs);
  __pyx_r = __pyx_v_attrs;
  goto __pyx_L0;

  /* "edgedb/protocol/protocol.pyx":1313
 *                     f'data message decoding: {frb_get_len(rbuf)}')
 * 
 *     cdef parse_command_complete_message(self):             # <<<<<<<<<<<<<<
 *         assert self.buffer.get_message_type() == COMMAND_COMPLETE_MSG
 *         attrs = self.parse_headers()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.parse_command_complete_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_attrs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":1320
 *         return attrs
 * 
 *     cdef parse_sync_message(self):             # <<<<<<<<<<<<<<
 *         cdef char status
 * 
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_sync_message(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  char __pyx_v_status;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("parse_sync_message", 0);

  /* "edgedb/protocol/protocol.pyx":1323
 *         cdef char status
 * 
 *         assert self.buffer.get_message_type() == READY_FOR_COMMAND_MSG             # <<<<<<<<<<<<<<
 * 
 *         self.ignore_headers()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_v_self->buffer) == 'Z') != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(5, 1323, __pyx_L1_error)
    }
  }
  #endif

  /* "edgedb/protocol/protocol.pyx":1325
 *         assert self.buffer.get_message_type() == READY_FOR_COMMAND_MSG
 * 
 *         self.ignore_headers()             # <<<<<<<<<<<<<<
 * 
 *         status = self.buffer.read_byte()
 */
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_ignore_headers(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":1327
 *         self.ignore_headers()
 * 
 *         status = self.buffer.read_byte()             # <<<<<<<<<<<<<<
 * 
 *         if status == TRANS_STATUS_IDLE:
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_byte(__pyx_v_self->buffer); if (unlikely(__pyx_t_2 == ((char)-1) && PyErr_Occurred())) __PYX_ERR(5, 1327, __pyx_L1_error)
  __pyx_v_status = __pyx_t_2;

  /* "edgedb/protocol/protocol.pyx":1329
 *         status = self.buffer.read_byte()
 * 
 *         if status == TRANS_STATUS_IDLE:             # <<<<<<<<<<<<<<
 *             self.xact_status = TRANS_IDLE
 *         elif status == TRANS_STATUS_INTRANS:
 */
  switch (__pyx_v_status) {
    case 'I':

    /* "edgedb/protocol/protocol.pyx":1330
 * 
 *         if status == TRANS_STATUS_IDLE:
 *             self.xact_status = TRANS_IDLE             # <<<<<<<<<<<<<<
 *         elif status == TRANS_STATUS_INTRANS:
 *             self.xact_status = TRANS_INTRANS
 */
    __pyx_v_self->xact_status = __pyx_e_6edgedb_8protocol_8protocol_TRANS_IDLE;

    /* "edgedb/protocol/protocol.pyx":1329
 *         status = self.buffer.read_byte()
 * 
 *         if status == TRANS_STATUS_IDLE:             # <<<<<<<<<<<<<<
 *             self.xact_status = TRANS_IDLE
 *         elif status == TRANS_STATUS_INTRANS:
 */
    break;
    case 'T':

    /* "edgedb/protocol/protocol.pyx":1332
 *             self.xact_status = TRANS_IDLE
 *         elif status == TRANS_STATUS_INTRANS:
 *             self.xact_status = TRANS_INTRANS             # <<<<<<<<<<<<<<
 *         elif status == TRANS_STATUS_ERROR:
 *             self.xact_status = TRANS_INERROR
 */
    __pyx_v_self->xact_status = __pyx_e_6edgedb_8protocol_8protocol_TRANS_INTRANS;

    /* "edgedb/protocol/protocol.pyx":1331
 *         if status == TRANS_STATUS_IDLE:
 *             self.xact_status = TRANS_IDLE
 *         elif status == TRANS_STATUS_INTRANS:             # <<<<<<<<<<<<<<
 *             self.xact_status = TRANS_INTRANS
 *         elif status == TRANS_STATUS_ERROR:
 */
    break;
    case 'E':

    /* "edgedb/protocol/protocol.pyx":1334
 *             self.xact_status = TRANS_INTRANS
 *         elif status == TRANS_STATUS_ERROR:
 *             self.xact_status = TRANS_INERROR             # <<<<<<<<<<<<<<
 *         else:
 *             self.xact_status = TRANS_UNKNOWN
 */
    __pyx_v_self->xact_status = __pyx_e_6edgedb_8protocol_8protocol_TRANS_INERROR;

    /* "edgedb/protocol/protocol.pyx":1333
 *         elif status == TRANS_STATUS_INTRANS:
 *             self.xact_status = TRANS_INTRANS
 *         elif status == TRANS_STATUS_ERROR:             # <<<<<<<<<<<<<<
 *             self.xact_status = TRANS_INERROR
 *         else:
 */
    break;
    default:

    /* "edgedb/protocol/protocol.pyx":1336
 *             self.xact_status = TRANS_INERROR
 *         else:
 *             self.xact_status = TRANS_UNKNOWN             # <<<<<<<<<<<<<<
 * 
 *         self.buffer.finish_message()
 */
    __pyx_v_self->xact_status = __pyx_e_6edgedb_8protocol_8protocol_TRANS_UNKNOWN;
    break;
  }

  /* "edgedb/protocol/protocol.pyx":1338
 *             self.xact_status = TRANS_UNKNOWN
 * 
 *         self.buffer.finish_message()             # <<<<<<<<<<<<<<
 * 
 *     cdef _amend_parse_error(
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->finish_message(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":1320
 *         return attrs
 * 
 *     cdef parse_sync_message(self):             # <<<<<<<<<<<<<<
 *         cdef char status
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.parse_sync_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":1340
 *         self.buffer.finish_message()
 * 
 *     cdef _amend_parse_error(             # <<<<<<<<<<<<<<
 *         self, exc, IoFormat io_format, bint expect_one, bint required_one
 *     ):
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol__amend_parse_error(CYTHON_UNUSED struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v_exc, enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __pyx_v_io_format, int __pyx_v_expect_one, int __pyx_v_required_one) {
  PyObject *__pyx_v_methname = NULL;
  PyObject *__pyx_v_new_exc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  Py_UCS4 __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_amend_parse_error", 0);
  __Pyx_INCREF(__pyx_v_exc);

  /* "edgedb/protocol/protocol.pyx":1343
 *         self, exc, IoFormat io_format, bint expect_one, bint required_one
 *     ):
 *         if expect_one and exc.get_code() == result_cardinality_mismatch_code:             # <<<<<<<<<<<<<<
 *             methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *             new_exc = errors.InterfaceError(
 */
  __pyx_t_2 = (__pyx_v_expect_one != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_exc, __pyx_n_s_get_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_6edgedb_8protocol_8protocol_result_cardinality_mismatch_code, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1343, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(5, 1343, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "edgedb/protocol/protocol.pyx":1344
 *     ):
 *         if expect_one and exc.get_code() == result_cardinality_mismatch_code:
 *             methname = _QUERY_SINGLE_METHOD[required_one][io_format]             # <<<<<<<<<<<<<<
 *             new_exc = errors.InterfaceError(
 *                 f'query cannot be executed with {methname}() as it '
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_QUERY_SINGLE_METHOD); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_4, __pyx_v_required_one, int, 1, __Pyx_PyBool_FromLong, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_v_io_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_methname = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "edgedb/protocol/protocol.pyx":1345
 *         if expect_one and exc.get_code() == result_cardinality_mismatch_code:
 *             methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *             new_exc = errors.InterfaceError(             # <<<<<<<<<<<<<<
 *                 f'query cannot be executed with {methname}() as it '
 *                 f'returns a multiset')
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_errors); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1345, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_InterfaceError); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1345, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "edgedb/protocol/protocol.pyx":1346
 *             methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *             new_exc = errors.InterfaceError(
 *                 f'query cannot be executed with {methname}() as it '             # <<<<<<<<<<<<<<
 *                 f'returns a multiset')
 *             new_exc.__cause__ = exc
 */
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1346, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = 0;
    __pyx_t_7 = 127;
    __Pyx_INCREF(__pyx_kp_u_query_cannot_be_executed_with);
    __pyx_t_6 += 30;
    __Pyx_GIVEREF(__pyx_kp_u_query_cannot_be_executed_with);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_u_query_cannot_be_executed_with);
    __pyx_t_8 = __Pyx_PyObject_FormatSimple(__pyx_v_methname, __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 1346, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_7;
    __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_8);
    __pyx_t_8 = 0;
    __Pyx_INCREF(__pyx_kp_u_as_it_returns_a_multiset);
    __pyx_t_6 += 27;
    __Pyx_GIVEREF(__pyx_kp_u_as_it_returns_a_multiset);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_kp_u_as_it_returns_a_multiset);
    __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_4, 3, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(5, 1346, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_5 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1345, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_new_exc = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "edgedb/protocol/protocol.pyx":1348
 *                 f'query cannot be executed with {methname}() as it '
 *                 f'returns a multiset')
 *             new_exc.__cause__ = exc             # <<<<<<<<<<<<<<
 *             exc = new_exc
 * 
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_new_exc, __pyx_n_s_cause, __pyx_v_exc) < 0) __PYX_ERR(5, 1348, __pyx_L1_error)

    /* "edgedb/protocol/protocol.pyx":1349
 *                 f'returns a multiset')
 *             new_exc.__cause__ = exc
 *             exc = new_exc             # <<<<<<<<<<<<<<
 * 
 *         return exc
 */
    __Pyx_INCREF(__pyx_v_new_exc);
    __Pyx_DECREF_SET(__pyx_v_exc, __pyx_v_new_exc);

    /* "edgedb/protocol/protocol.pyx":1343
 *         self, exc, IoFormat io_format, bint expect_one, bint required_one
 *     ):
 *         if expect_one and exc.get_code() == result_cardinality_mismatch_code:             # <<<<<<<<<<<<<<
 *             methname = _QUERY_SINGLE_METHOD[required_one][io_format]
 *             new_exc = errors.InterfaceError(
 */
  }

  /* "edgedb/protocol/protocol.pyx":1351
 *             exc = new_exc
 * 
 *         return exc             # <<<<<<<<<<<<<<
 * 
 *     cdef dict parse_headers(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_exc);
  __pyx_r = __pyx_v_exc;
  goto __pyx_L0;

  /* "edgedb/protocol/protocol.pyx":1340
 *         self.buffer.finish_message()
 * 
 *     cdef _amend_parse_error(             # <<<<<<<<<<<<<<
 *         self, exc, IoFormat io_format, bint expect_one, bint required_one
 *     ):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol._amend_parse_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_methname);
  __Pyx_XDECREF(__pyx_v_new_exc);
  __Pyx_XDECREF(__pyx_v_exc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":1353
 *         return exc
 * 
 *     cdef dict parse_headers(self):             # <<<<<<<<<<<<<<
 *         cdef:
 *             dict attrs
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_headers(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_v_attrs = 0;
  uint16_t __pyx_v_num_fields;
  uint16_t __pyx_v_key;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int16_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("parse_headers", 0);

  /* "edgedb/protocol/protocol.pyx":1360
 *             bytes value
 * 
 *         attrs = {}             # <<<<<<<<<<<<<<
 *         num_fields = <uint16_t>self.buffer.read_int16()
 *         while num_fields:
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_attrs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":1361
 * 
 *         attrs = {}
 *         num_fields = <uint16_t>self.buffer.read_int16()             # <<<<<<<<<<<<<<
 *         while num_fields:
 *             key = <uint16_t>self.buffer.read_int16()
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_int16(__pyx_v_self->buffer); if (unlikely(__pyx_t_2 == ((int16_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 1361, __pyx_L1_error)
  __pyx_v_num_fields = ((uint16_t)__pyx_t_2);

  /* "edgedb/protocol/protocol.pyx":1362
 *         attrs = {}
 *         num_fields = <uint16_t>self.buffer.read_int16()
 *         while num_fields:             # <<<<<<<<<<<<<<
 *             key = <uint16_t>self.buffer.read_int16()
 *             value = self.buffer.read_len_prefixed_bytes()
 */
  while (1) {
    __pyx_t_3 = (__pyx_v_num_fields != 0);
    if (!__pyx_t_3) break;

    /* "edgedb/protocol/protocol.pyx":1363
 *         num_fields = <uint16_t>self.buffer.read_int16()
 *         while num_fields:
 *             key = <uint16_t>self.buffer.read_int16()             # <<<<<<<<<<<<<<
 *             value = self.buffer.read_len_prefixed_bytes()
 *             attrs[key] = value
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_int16(__pyx_v_self->buffer); if (unlikely(__pyx_t_2 == ((int16_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 1363, __pyx_L1_error)
    __pyx_v_key = ((uint16_t)__pyx_t_2);

    /* "edgedb/protocol/protocol.pyx":1364
 *         while num_fields:
 *             key = <uint16_t>self.buffer.read_int16()
 *             value = self.buffer.read_len_prefixed_bytes()             # <<<<<<<<<<<<<<
 *             attrs[key] = value
 *             num_fields -= 1
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_len_prefixed_bytes(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_value, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":1365
 *             key = <uint16_t>self.buffer.read_int16()
 *             value = self.buffer.read_len_prefixed_bytes()
 *             attrs[key] = value             # <<<<<<<<<<<<<<
 *             num_fields -= 1
 *         return attrs
 */
    __pyx_t_1 = __Pyx_PyInt_From_uint16_t(__pyx_v_key); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(PyDict_SetItem(__pyx_v_attrs, __pyx_t_1, __pyx_v_value) < 0)) __PYX_ERR(5, 1365, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "edgedb/protocol/protocol.pyx":1366
 *             value = self.buffer.read_len_prefixed_bytes()
 *             attrs[key] = value
 *             num_fields -= 1             # <<<<<<<<<<<<<<
 *         return attrs
 * 
 */
    __pyx_v_num_fields = (__pyx_v_num_fields - 1);
  }

  /* "edgedb/protocol/protocol.pyx":1367
 *             attrs[key] = value
 *             num_fields -= 1
 *         return attrs             # <<<<<<<<<<<<<<
 * 
 *     cdef parse_error_message(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_attrs);
  __pyx_r = __pyx_v_attrs;
  goto __pyx_L0;

  /* "edgedb/protocol/protocol.pyx":1353
 *         return exc
 * 
 *     cdef dict parse_headers(self):             # <<<<<<<<<<<<<<
 *         cdef:
 *             dict attrs
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.parse_headers", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_attrs);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pyx":1369
 *         return attrs
 * 
 *     cdef parse_error_message(self):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t code
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_error_message(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  uint32_t __pyx_v_code;
  CYTHON_UNUSED uint8_t __pyx_v_severity;
  PyObject *__pyx_v_msg = 0;
  PyObject *__pyx_v_attrs = NULL;
  PyObject *__pyx_v_exc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char __pyx_t_1;
  int32_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  uint32_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("parse_error_message", 0);

  /* "edgedb/protocol/protocol.pyx":1376
 *             str msg
 * 
 *         assert self.buffer.get_message_type() == ERROR_RESPONSE_MSG             # <<<<<<<<<<<<<<
 * 
 *         severity = <uint8_t>self.buffer.read_byte()
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(__pyx_v_self->buffer) == 'E') != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(5, 1376, __pyx_L1_error)
    }
  }
  #endif

  /* "edgedb/protocol/protocol.pyx":1378
 *         assert self.buffer.get_message_type() == ERROR_RESPONSE_MSG
 * 
 *         severity = <uint8_t>self.buffer.read_byte()             # <<<<<<<<<<<<<<
 *         code = <uint32_t>self.buffer.read_int32()
 *         msg = self.buffer.read_len_prefixed_utf8()
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_byte(__pyx_v_self->buffer); if (unlikely(__pyx_t_1 == ((char)-1) && PyErr_Occurred())) __PYX_ERR(5, 1378, __pyx_L1_error)
  __pyx_v_severity = ((uint8_t)__pyx_t_1);

  /* "edgedb/protocol/protocol.pyx":1379
 * 
 *         severity = <uint8_t>self.buffer.read_byte()
 *         code = <uint32_t>self.buffer.read_int32()             # <<<<<<<<<<<<<<
 *         msg = self.buffer.read_len_prefixed_utf8()
 *         attrs = self.parse_headers()
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_int32(__pyx_v_self->buffer); if (unlikely(__pyx_t_2 == ((int32_t)-1) && PyErr_Occurred())) __PYX_ERR(5, 1379, __pyx_L1_error)
  __pyx_v_code = ((uint32_t)__pyx_t_2);

  /* "edgedb/protocol/protocol.pyx":1380
 *         severity = <uint8_t>self.buffer.read_byte()
 *         code = <uint32_t>self.buffer.read_int32()
 *         msg = self.buffer.read_len_prefixed_utf8()             # <<<<<<<<<<<<<<
 *         attrs = self.parse_headers()
 * 
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_v_self->buffer->__pyx_vtab)->read_len_prefixed_utf8(__pyx_v_self->buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_msg = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "edgedb/protocol/protocol.pyx":1381
 *         code = <uint32_t>self.buffer.read_int32()
 *         msg = self.buffer.read_len_prefixed_utf8()
 *         attrs = self.parse_headers()             # <<<<<<<<<<<<<<
 * 
 *         # It's safe to always map error codes as we don't reuse them
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self->__pyx_vtab)->parse_headers(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_attrs = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "edgedb/protocol/protocol.pyx":1384
 * 
 *         # It's safe to always map error codes as we don't reuse them
 *         code = OLD_ERROR_CODES.get(code, code)             # <<<<<<<<<<<<<<
 * 
 *         exc = errors.EdgeDBError._from_code(code, msg)
 */
  if (unlikely(__pyx_v_6edgedb_8protocol_8protocol_OLD_ERROR_CODES == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get");
    __PYX_ERR(5, 1384, __pyx_L1_error)
  }
  __pyx_t_3 = __Pyx_PyInt_From_uint32_t(__pyx_v_code); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_uint32_t(__pyx_v_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyDict_GetItemDefault(__pyx_v_6edgedb_8protocol_8protocol_OLD_ERROR_CODES, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_uint32_t(__pyx_t_5); if (unlikely((__pyx_t_6 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(5, 1384, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_code = __pyx_t_6;

  /* "edgedb/protocol/protocol.pyx":1386
 *         code = OLD_ERROR_CODES.get(code, code)
 * 
 *         exc = errors.EdgeDBError._from_code(code, msg)             # <<<<<<<<<<<<<<
 *         exc._attrs = attrs
 *         return exc
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_errors); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_EdgeDBError); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_from_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(5, 1386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_uint32_t(__pyx_v_code); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 1386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_3, __pyx_v_msg};
    __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1386, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_3, __pyx_v_msg};
    __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1386, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(5, 1386, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_msg);
    __Pyx_GIVEREF(__pyx_v_msg);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_msg);
    __pyx_t_3 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(5, 1386, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_exc = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "edgedb/protocol/protocol.pyx":1387
 * 
 *         exc = errors.EdgeDBError._from_code(code, msg)
 *         exc._attrs = attrs             # <<<<<<<<<<<<<<
 *         return exc
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_exc, __pyx_n_s_attrs, __pyx_v_attrs) < 0) __PYX_ERR(5, 1387, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":1388
 *         exc = errors.EdgeDBError._from_code(code, msg)
 *         exc._attrs = attrs
 *         return exc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_exc);
  __pyx_r = __pyx_v_exc;
  goto __pyx_L0;

  /* "edgedb/protocol/protocol.pyx":1369
 *         return attrs
 * 
 *     cdef parse_error_message(self):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t code
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.parse_error_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF(__pyx_v_attrs);
  __Pyx_XDECREF(__pyx_v_exc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pxd":85
 *         ReadBuffer buffer
 * 
 *         readonly bint connected             # <<<<<<<<<<<<<<
 *         readonly bint cancelled
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_9connected_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_9connected_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_9connected___get__(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_9connected___get__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->connected); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.connected.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pxd":86
 * 
 *         readonly bint connected
 *         readonly bint cancelled             # <<<<<<<<<<<<<<
 * 
 *         object con
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_9cancelled_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_9cancelled_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_9cancelled___get__(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_9cancelled___get__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->cancelled); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.cancelled.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pxd":89
 * 
 *         object con
 *         readonly object con_params             # <<<<<<<<<<<<<<
 *         readonly bint tls_compat
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_10con_params_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_10con_params_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_10con_params___get__(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_10con_params___get__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->con_params);
  __pyx_r = __pyx_v_self->con_params;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pxd":90
 *         object con
 *         readonly object con_params
 *         readonly bint tls_compat             # <<<<<<<<<<<<<<
 * 
 *         object backend_secret
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_10tls_compat_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_10tls_compat_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_10tls_compat___get__(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_10tls_compat___get__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->tls_compat); if (unlikely(!__pyx_t_1)) __PYX_ERR(12, 90, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.tls_compat.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pxd":99
 *         dict server_settings
 * 
 *         readonly bytes last_status             # <<<<<<<<<<<<<<
 *         readonly bytes last_details
 *         readonly tuple protocol_version
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_11last_status_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_11last_status_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_11last_status___get__(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_11last_status___get__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->last_status);
  __pyx_r = __pyx_v_self->last_status;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pxd":100
 * 
 *         readonly bytes last_status
 *         readonly bytes last_details             # <<<<<<<<<<<<<<
 *         readonly tuple protocol_version
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_12last_details_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_12last_details_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_12last_details___get__(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_12last_details___get__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->last_details);
  __pyx_r = __pyx_v_self->last_details;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/protocol.pxd":101
 *         readonly bytes last_status
 *         readonly bytes last_details
 *         readonly tuple protocol_version             # <<<<<<<<<<<<<<
 * 
 *     cdef encode_args(self, BaseCodec in_dc, WriteBuffer buf, args, kwargs)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_16protocol_version_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_16protocol_version_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_16protocol_version___get__(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_16protocol_version___get__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->protocol_version);
  __pyx_r = __pyx_v_self->protocol_version;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_52__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_52__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_51__reduce_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_51__reduce_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.backend_secret, self.buffer, self.cancelled, self.con, self.con_params, self.connected, self.internal_reg, self.last_details, self.last_status, self.protocol_version, self.server_settings, self.tls_compat, self.xact_status)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->cancelled); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->connected); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_self->tls_compat); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_TransactionStatus(__pyx_v_self->xact_status); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(13); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_self->backend_secret);
  __Pyx_GIVEREF(__pyx_v_self->backend_secret);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self->backend_secret);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->buffer));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->buffer));
  PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_self->buffer));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->con);
  __Pyx_GIVEREF(__pyx_v_self->con);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_self->con);
  __Pyx_INCREF(__pyx_v_self->con_params);
  __Pyx_GIVEREF(__pyx_v_self->con_params);
  PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_v_self->con_params);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 5, __pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->internal_reg));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->internal_reg));
  PyTuple_SET_ITEM(__pyx_t_5, 6, ((PyObject *)__pyx_v_self->internal_reg));
  __Pyx_INCREF(__pyx_v_self->last_details);
  __Pyx_GIVEREF(__pyx_v_self->last_details);
  PyTuple_SET_ITEM(__pyx_t_5, 7, __pyx_v_self->last_details);
  __Pyx_INCREF(__pyx_v_self->last_status);
  __Pyx_GIVEREF(__pyx_v_self->last_status);
  PyTuple_SET_ITEM(__pyx_t_5, 8, __pyx_v_self->last_status);
  __Pyx_INCREF(__pyx_v_self->protocol_version);
  __Pyx_GIVEREF(__pyx_v_self->protocol_version);
  PyTuple_SET_ITEM(__pyx_t_5, 9, __pyx_v_self->protocol_version);
  __Pyx_INCREF(__pyx_v_self->server_settings);
  __Pyx_GIVEREF(__pyx_v_self->server_settings);
  PyTuple_SET_ITEM(__pyx_t_5, 10, __pyx_v_self->server_settings);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 11, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 12, __pyx_t_4);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.backend_secret, self.buffer, self.cancelled, self.con, self.con_params, self.connected, self.internal_reg, self.last_details, self.last_status, self.protocol_version, self.server_settings, self.tls_compat, self.xact_status)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_5 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v__dict = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "(tree fragment)":7
 *     state = (self.backend_secret, self.buffer, self.cancelled, self.con, self.con_params, self.connected, self.internal_reg, self.last_details, self.last_status, self.protocol_version, self.server_settings, self.tls_compat, self.xact_status)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_6 = (__pyx_v__dict != Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.backend_secret is not None or self.buffer is not None or self.con is not None or self.con_params is not None or self.internal_reg is not None or self.last_details is not None or self.last_status is not None or self.protocol_version is not None or self.server_settings is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.backend_secret, self.buffer, self.cancelled, self.con, self.con_params, self.connected, self.internal_reg, self.last_details, self.last_status, self.protocol_version, self.server_settings, self.tls_compat, self.xact_status)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.backend_secret is not None or self.buffer is not None or self.con is not None or self.con_params is not None or self.internal_reg is not None or self.last_details is not None or self.last_status is not None or self.protocol_version is not None or self.server_settings is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_SansIOProtocol, (type(self), 0xadcaa09, None), state
 */
  /*else*/ {
    __pyx_t_6 = (__pyx_v_self->backend_secret != Py_None);
    __pyx_t_8 = (__pyx_t_6 != 0);
    if (!__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_8 = (((PyObject *)__pyx_v_self->buffer) != Py_None);
    __pyx_t_6 = (__pyx_t_8 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_7 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->con != Py_None);
    __pyx_t_8 = (__pyx_t_6 != 0);
    if (!__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_v_self->con_params != Py_None);
    __pyx_t_6 = (__pyx_t_8 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_7 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (((PyObject *)__pyx_v_self->internal_reg) != Py_None);
    __pyx_t_8 = (__pyx_t_6 != 0);
    if (!__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_v_self->last_details != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_8 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_7 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->last_status != ((PyObject*)Py_None));
    __pyx_t_8 = (__pyx_t_6 != 0);
    if (!__pyx_t_8) {
    } else {
      __pyx_t_7 = __pyx_t_8;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_v_self->protocol_version != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_8 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_7 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->server_settings != ((PyObject*)Py_None));
    __pyx_t_8 = (__pyx_t_6 != 0);
    __pyx_t_7 = __pyx_t_8;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_7;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.backend_secret is not None or self.buffer is not None or self.con is not None or self.con_params is not None or self.internal_reg is not None or self.last_details is not None or self.last_status is not None or self.protocol_version is not None or self.server_settings is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_SansIOProtocol, (type(self), 0xadcaa09, None), state
 *     else:
 */
  __pyx_t_7 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_7) {

    /* "(tree fragment)":13
 *         use_setstate = self.backend_secret is not None or self.buffer is not None or self.con is not None or self.con_params is not None or self.internal_reg is not None or self.last_details is not None or self.last_status is not None or self.protocol_version is not None or self.server_settings is not None
 *     if use_setstate:
 *         return __pyx_unpickle_SansIOProtocol, (type(self), 0xadcaa09, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_SansIOProtocol, (type(self), 0xadcaa09, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_SansIOProtocol); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_182233609);
    __Pyx_GIVEREF(__pyx_int_182233609);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_182233609);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_5, 2, Py_None);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.backend_secret is not None or self.buffer is not None or self.con is not None or self.con_params is not None or self.internal_reg is not None or self.last_details is not None or self.last_status is not None or self.protocol_version is not None or self.server_settings is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_SansIOProtocol, (type(self), 0xadcaa09, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_SansIOProtocol, (type(self), 0xadcaa09, None), state
 *     else:
 *         return __pyx_unpickle_SansIOProtocol, (type(self), 0xadcaa09, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_SansIOProtocol__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pyx_unpickle_SansIOProtocol); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_182233609);
    __Pyx_GIVEREF(__pyx_int_182233609);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_182233609);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
    __pyx_t_3 = 0;
    __pyx_t_5 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_SansIOProtocol, (type(self), 0xadcaa09, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_SansIOProtocol__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_54__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_54__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_53__setstate_cython__(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_14SansIOProtocol_53__setstate_cython__(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_SansIOProtocol, (type(self), 0xadcaa09, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_SansIOProtocol__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_SansIOProtocol__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_SansIOProtocol, (type(self), 0xadcaa09, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_SansIOProtocol__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.protocol.protocol.SansIOProtocol.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_LRUMapping(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_1__pyx_unpickle_LRUMapping(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6edgedb_8protocol_8protocol_1__pyx_unpickle_LRUMapping = {"__pyx_unpickle_LRUMapping", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6edgedb_8protocol_8protocol_1__pyx_unpickle_LRUMapping, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_1__pyx_unpickle_LRUMapping(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_LRUMapping (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_LRUMapping", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_LRUMapping", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_LRUMapping") < 0)) __PYX_ERR(2, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_LRUMapping", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.__pyx_unpickle_LRUMapping", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol___pyx_unpickle_LRUMapping(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol___pyx_unpickle_LRUMapping(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_LRUMapping", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x53368d7:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x53368d7 = (_dict, _dict_get, _dict_move_to_end, _maxsize))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x53368d7) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x53368d7:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x53368d7 = (_dict, _dict_get, _dict_move_to_end, _maxsize))" % __pyx_checksum)
 *     __pyx_result = LRUMapping.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x53368d7:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x53368d7 = (_dict, _dict_get, _dict_move_to_end, _maxsize))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = LRUMapping.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x53, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x53368d7:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x53368d7 = (_dict, _dict_get, _dict_move_to_end, _maxsize))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x53368d7 = (_dict, _dict_get, _dict_move_to_end, _maxsize))" % __pyx_checksum)
 *     __pyx_result = LRUMapping.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_LRUMapping__set_state(<LRUMapping> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6edgedb_8protocol_8protocol_LRUMapping), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x53368d7 = (_dict, _dict_get, _dict_move_to_end, _maxsize))" % __pyx_checksum)
 *     __pyx_result = LRUMapping.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_LRUMapping__set_state(<LRUMapping> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = LRUMapping.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_LRUMapping__set_state(<LRUMapping> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_LRUMapping__set_state(LRUMapping __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_LRUMapping__set_state(((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x53368d7 = (_dict, _dict_get, _dict_move_to_end, _maxsize))" % __pyx_checksum)
 *     __pyx_result = LRUMapping.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_LRUMapping__set_state(<LRUMapping> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_LRUMapping__set_state(<LRUMapping> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_LRUMapping__set_state(LRUMapping __pyx_result, tuple __pyx_state):
 *     __pyx_result._dict = __pyx_state[0]; __pyx_result._dict_get = __pyx_state[1]; __pyx_result._dict_move_to_end = __pyx_state[2]; __pyx_result._maxsize = __pyx_state[3]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_LRUMapping(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("edgedb.protocol.protocol.__pyx_unpickle_LRUMapping", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_LRUMapping__set_state(<LRUMapping> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_LRUMapping__set_state(LRUMapping __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._dict = __pyx_state[0]; __pyx_result._dict_get = __pyx_state[1]; __pyx_result._dict_move_to_end = __pyx_state[2]; __pyx_result._maxsize = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_LRUMapping__set_state(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_LRUMapping__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_LRUMapping__set_state(LRUMapping __pyx_result, tuple __pyx_state):
 *     __pyx_result._dict = __pyx_state[0]; __pyx_result._dict_get = __pyx_state[1]; __pyx_result._dict_move_to_end = __pyx_state[2]; __pyx_result._maxsize = __pyx_state[3]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_dict);
  __Pyx_DECREF(__pyx_v___pyx_result->_dict);
  __pyx_v___pyx_result->_dict = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_dict_get);
  __Pyx_DECREF(__pyx_v___pyx_result->_dict_get);
  __pyx_v___pyx_result->_dict_get = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_dict_move_to_end);
  __Pyx_DECREF(__pyx_v___pyx_result->_dict_move_to_end);
  __pyx_v___pyx_result->_dict_move_to_end = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_maxsize = __pyx_t_2;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_LRUMapping__set_state(LRUMapping __pyx_result, tuple __pyx_state):
 *     __pyx_result._dict = __pyx_state[0]; __pyx_result._dict_get = __pyx_state[1]; __pyx_result._dict_move_to_end = __pyx_state[2]; __pyx_result._maxsize = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 13, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 4) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":14
 *     __pyx_result._dict = __pyx_state[0]; __pyx_result._dict_get = __pyx_state[1]; __pyx_result._dict_move_to_end = __pyx_state[2]; __pyx_result._maxsize = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[4])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 14, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_LRUMapping__set_state(LRUMapping __pyx_result, tuple __pyx_state):
 *     __pyx_result._dict = __pyx_state[0]; __pyx_result._dict_get = __pyx_state[1]; __pyx_result._dict_move_to_end = __pyx_state[2]; __pyx_result._maxsize = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_LRUMapping__set_state(<LRUMapping> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_LRUMapping__set_state(LRUMapping __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._dict = __pyx_state[0]; __pyx_result._dict_get = __pyx_state[1]; __pyx_result._dict_move_to_end = __pyx_state[2]; __pyx_result._maxsize = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("edgedb.protocol.protocol.__pyx_unpickle_LRUMapping__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_CodecsRegistry(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_3__pyx_unpickle_CodecsRegistry(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6edgedb_8protocol_8protocol_3__pyx_unpickle_CodecsRegistry = {"__pyx_unpickle_CodecsRegistry", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6edgedb_8protocol_8protocol_3__pyx_unpickle_CodecsRegistry, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_3__pyx_unpickle_CodecsRegistry(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_CodecsRegistry (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_CodecsRegistry", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_CodecsRegistry", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_CodecsRegistry") < 0)) __PYX_ERR(2, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_CodecsRegistry", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.__pyx_unpickle_CodecsRegistry", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_2__pyx_unpickle_CodecsRegistry(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_2__pyx_unpickle_CodecsRegistry(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_CodecsRegistry", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x324635c:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x324635c = (base_codec_overrides, codecs, codecs_build_cache))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x324635c) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x324635c:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x324635c = (base_codec_overrides, codecs, codecs_build_cache))" % __pyx_checksum)
 *     __pyx_result = CodecsRegistry.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x324635c:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x324635c = (base_codec_overrides, codecs, codecs_build_cache))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = CodecsRegistry.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x32, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x324635c:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x324635c = (base_codec_overrides, codecs, codecs_build_cache))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x324635c = (base_codec_overrides, codecs, codecs_build_cache))" % __pyx_checksum)
 *     __pyx_result = CodecsRegistry.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_CodecsRegistry__set_state(<CodecsRegistry> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6edgedb_8protocol_8protocol_CodecsRegistry), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x324635c = (base_codec_overrides, codecs, codecs_build_cache))" % __pyx_checksum)
 *     __pyx_result = CodecsRegistry.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_CodecsRegistry__set_state(<CodecsRegistry> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = CodecsRegistry.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_CodecsRegistry__set_state(<CodecsRegistry> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_CodecsRegistry__set_state(CodecsRegistry __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_CodecsRegistry__set_state(((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x324635c = (base_codec_overrides, codecs, codecs_build_cache))" % __pyx_checksum)
 *     __pyx_result = CodecsRegistry.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_CodecsRegistry__set_state(<CodecsRegistry> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_CodecsRegistry__set_state(<CodecsRegistry> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_CodecsRegistry__set_state(CodecsRegistry __pyx_result, tuple __pyx_state):
 *     __pyx_result.base_codec_overrides = __pyx_state[0]; __pyx_result.codecs = __pyx_state[1]; __pyx_result.codecs_build_cache = __pyx_state[2]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_CodecsRegistry(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("edgedb.protocol.protocol.__pyx_unpickle_CodecsRegistry", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_CodecsRegistry__set_state(<CodecsRegistry> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_CodecsRegistry__set_state(CodecsRegistry __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.base_codec_overrides = __pyx_state[0]; __pyx_result.codecs = __pyx_state[1]; __pyx_result.codecs_build_cache = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_CodecsRegistry__set_state(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_CodecsRegistry__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_CodecsRegistry__set_state(CodecsRegistry __pyx_result, tuple __pyx_state):
 *     __pyx_result.base_codec_overrides = __pyx_state[0]; __pyx_result.codecs = __pyx_state[1]; __pyx_result.codecs_build_cache = __pyx_state[2]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->base_codec_overrides);
  __Pyx_DECREF(__pyx_v___pyx_result->base_codec_overrides);
  __pyx_v___pyx_result->base_codec_overrides = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6edgedb_8protocol_8protocol_LRUMapping))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->codecs);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->codecs));
  __pyx_v___pyx_result->codecs = ((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6edgedb_8protocol_8protocol_LRUMapping))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->codecs_build_cache);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->codecs_build_cache));
  __pyx_v___pyx_result->codecs_build_cache = ((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_CodecsRegistry__set_state(CodecsRegistry __pyx_result, tuple __pyx_state):
 *     __pyx_result.base_codec_overrides = __pyx_state[0]; __pyx_result.codecs = __pyx_state[1]; __pyx_result.codecs_build_cache = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 3) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.base_codec_overrides = __pyx_state[0]; __pyx_result.codecs = __pyx_state[1]; __pyx_result.codecs_build_cache = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[3])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_CodecsRegistry__set_state(CodecsRegistry __pyx_result, tuple __pyx_state):
 *     __pyx_result.base_codec_overrides = __pyx_state[0]; __pyx_result.codecs = __pyx_state[1]; __pyx_result.codecs_build_cache = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_CodecsRegistry__set_state(<CodecsRegistry> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_CodecsRegistry__set_state(CodecsRegistry __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.base_codec_overrides = __pyx_state[0]; __pyx_result.codecs = __pyx_state[1]; __pyx_result.codecs_build_cache = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("edgedb.protocol.protocol.__pyx_unpickle_CodecsRegistry__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_QueryCodecsCache(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_5__pyx_unpickle_QueryCodecsCache(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6edgedb_8protocol_8protocol_5__pyx_unpickle_QueryCodecsCache = {"__pyx_unpickle_QueryCodecsCache", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6edgedb_8protocol_8protocol_5__pyx_unpickle_QueryCodecsCache, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_5__pyx_unpickle_QueryCodecsCache(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_QueryCodecsCache (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_QueryCodecsCache", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_QueryCodecsCache", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_QueryCodecsCache") < 0)) __PYX_ERR(2, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_QueryCodecsCache", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.__pyx_unpickle_QueryCodecsCache", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_4__pyx_unpickle_QueryCodecsCache(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_4__pyx_unpickle_QueryCodecsCache(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_QueryCodecsCache", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x5da7eb4:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x5da7eb4 = (queries))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x5da7eb4) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x5da7eb4:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x5da7eb4 = (queries))" % __pyx_checksum)
 *     __pyx_result = QueryCodecsCache.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x5da7eb4:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x5da7eb4 = (queries))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = QueryCodecsCache.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x5d, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x5da7eb4:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x5da7eb4 = (queries))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x5da7eb4 = (queries))" % __pyx_checksum)
 *     __pyx_result = QueryCodecsCache.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_QueryCodecsCache__set_state(<QueryCodecsCache> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6edgedb_8protocol_8protocol_QueryCodecsCache), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x5da7eb4 = (queries))" % __pyx_checksum)
 *     __pyx_result = QueryCodecsCache.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_QueryCodecsCache__set_state(<QueryCodecsCache> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = QueryCodecsCache.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_QueryCodecsCache__set_state(<QueryCodecsCache> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_QueryCodecsCache__set_state(QueryCodecsCache __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_QueryCodecsCache__set_state(((struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x5da7eb4 = (queries))" % __pyx_checksum)
 *     __pyx_result = QueryCodecsCache.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_QueryCodecsCache__set_state(<QueryCodecsCache> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_QueryCodecsCache__set_state(<QueryCodecsCache> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_QueryCodecsCache__set_state(QueryCodecsCache __pyx_result, tuple __pyx_state):
 *     __pyx_result.queries = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_QueryCodecsCache(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("edgedb.protocol.protocol.__pyx_unpickle_QueryCodecsCache", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_QueryCodecsCache__set_state(<QueryCodecsCache> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_QueryCodecsCache__set_state(QueryCodecsCache __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.queries = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_QueryCodecsCache__set_state(struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_QueryCodecsCache__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_QueryCodecsCache__set_state(QueryCodecsCache __pyx_result, tuple __pyx_state):
 *     __pyx_result.queries = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6edgedb_8protocol_8protocol_LRUMapping))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->queries);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->queries));
  __pyx_v___pyx_result->queries = ((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_QueryCodecsCache__set_state(QueryCodecsCache __pyx_result, tuple __pyx_state):
 *     __pyx_result.queries = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.queries = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_QueryCodecsCache__set_state(QueryCodecsCache __pyx_result, tuple __pyx_state):
 *     __pyx_result.queries = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_QueryCodecsCache__set_state(<QueryCodecsCache> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_QueryCodecsCache__set_state(QueryCodecsCache __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.queries = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("edgedb.protocol.protocol.__pyx_unpickle_QueryCodecsCache__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_SansIOProtocol(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_7__pyx_unpickle_SansIOProtocol(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6edgedb_8protocol_8protocol_7__pyx_unpickle_SansIOProtocol = {"__pyx_unpickle_SansIOProtocol", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6edgedb_8protocol_8protocol_7__pyx_unpickle_SansIOProtocol, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6edgedb_8protocol_8protocol_7__pyx_unpickle_SansIOProtocol(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_SansIOProtocol (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_SansIOProtocol", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_SansIOProtocol", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_SansIOProtocol") < 0)) __PYX_ERR(2, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_SansIOProtocol", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("edgedb.protocol.protocol.__pyx_unpickle_SansIOProtocol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6edgedb_8protocol_8protocol_6__pyx_unpickle_SansIOProtocol(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6edgedb_8protocol_8protocol_6__pyx_unpickle_SansIOProtocol(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_SansIOProtocol", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xadcaa09:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xadcaa09 = (backend_secret, buffer, cancelled, con, con_params, connected, internal_reg, last_details, last_status, protocol_version, server_settings, tls_compat, xact_status))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xadcaa09) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xadcaa09:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xadcaa09 = (backend_secret, buffer, cancelled, con, con_params, connected, internal_reg, last_details, last_status, protocol_version, server_settings, tls_compat, xact_status))" % __pyx_checksum)
 *     __pyx_result = SansIOProtocol.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0xadcaa09:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xadcaa09 = (backend_secret, buffer, cancelled, con, con_params, connected, internal_reg, last_details, last_status, protocol_version, server_settings, tls_compat, xact_status))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = SansIOProtocol.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xad, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xadcaa09:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xadcaa09 = (backend_secret, buffer, cancelled, con, con_params, connected, internal_reg, last_details, last_status, protocol_version, server_settings, tls_compat, xact_status))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xadcaa09 = (backend_secret, buffer, cancelled, con, con_params, connected, internal_reg, last_details, last_status, protocol_version, server_settings, tls_compat, xact_status))" % __pyx_checksum)
 *     __pyx_result = SansIOProtocol.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_SansIOProtocol__set_state(<SansIOProtocol> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6edgedb_8protocol_8protocol_SansIOProtocol), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xadcaa09 = (backend_secret, buffer, cancelled, con, con_params, connected, internal_reg, last_details, last_status, protocol_version, server_settings, tls_compat, xact_status))" % __pyx_checksum)
 *     __pyx_result = SansIOProtocol.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_SansIOProtocol__set_state(<SansIOProtocol> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = SansIOProtocol.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_SansIOProtocol__set_state(<SansIOProtocol> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_SansIOProtocol__set_state(SansIOProtocol __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_SansIOProtocol__set_state(((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xadcaa09 = (backend_secret, buffer, cancelled, con, con_params, connected, internal_reg, last_details, last_status, protocol_version, server_settings, tls_compat, xact_status))" % __pyx_checksum)
 *     __pyx_result = SansIOProtocol.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_SansIOProtocol__set_state(<SansIOProtocol> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_SansIOProtocol__set_state(<SansIOProtocol> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_SansIOProtocol__set_state(SansIOProtocol __pyx_result, tuple __pyx_state):
 *     __pyx_result.backend_secret = __pyx_state[0]; __pyx_result.buffer = __pyx_state[1]; __pyx_result.cancelled = __pyx_state[2]; __pyx_result.con = __pyx_state[3]; __pyx_result.con_params = __pyx_state[4]; __pyx_result.connected = __pyx_state[5]; __pyx_result.internal_reg = __pyx_state[6]; __pyx_result.last_details = __pyx_state[7]; __pyx_result.last_status = __pyx_state[8]; __pyx_result.protocol_version = __pyx_state[9]; __pyx_result.server_settings = __pyx_state[10]; __pyx_result.tls_compat = __pyx_state[11]; __pyx_result.xact_status = __pyx_state[12]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_SansIOProtocol(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("edgedb.protocol.protocol.__pyx_unpickle_SansIOProtocol", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_SansIOProtocol__set_state(<SansIOProtocol> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_SansIOProtocol__set_state(SansIOProtocol __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.backend_secret = __pyx_state[0]; __pyx_result.buffer = __pyx_state[1]; __pyx_result.cancelled = __pyx_state[2]; __pyx_result.con = __pyx_state[3]; __pyx_result.con_params = __pyx_state[4]; __pyx_result.connected = __pyx_state[5]; __pyx_result.internal_reg = __pyx_state[6]; __pyx_result.last_details = __pyx_state[7]; __pyx_result.last_status = __pyx_state[8]; __pyx_result.protocol_version = __pyx_state[9]; __pyx_result.server_settings = __pyx_state[10]; __pyx_result.tls_compat = __pyx_state[11]; __pyx_result.xact_status = __pyx_state[12]
 *     if len(__pyx_state) > 13 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_6edgedb_8protocol_8protocol___pyx_unpickle_SansIOProtocol__set_state(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_SansIOProtocol__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_SansIOProtocol__set_state(SansIOProtocol __pyx_result, tuple __pyx_state):
 *     __pyx_result.backend_secret = __pyx_state[0]; __pyx_result.buffer = __pyx_state[1]; __pyx_result.cancelled = __pyx_state[2]; __pyx_result.con = __pyx_state[3]; __pyx_result.con_params = __pyx_state[4]; __pyx_result.connected = __pyx_state[5]; __pyx_result.internal_reg = __pyx_state[6]; __pyx_result.last_details = __pyx_state[7]; __pyx_result.last_status = __pyx_state[8]; __pyx_result.protocol_version = __pyx_state[9]; __pyx_result.server_settings = __pyx_state[10]; __pyx_result.tls_compat = __pyx_state[11]; __pyx_result.xact_status = __pyx_state[12]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 13 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[13])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->backend_secret);
  __Pyx_DECREF(__pyx_v___pyx_result->backend_secret);
  __pyx_v___pyx_result->backend_secret = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6edgedb_7pgproto_7pgproto_ReadBuffer))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->buffer);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->buffer));
  __pyx_v___pyx_result->buffer = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->cancelled = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->con);
  __Pyx_DECREF(__pyx_v___pyx_result->con);
  __pyx_v___pyx_result->con = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->con_params);
  __Pyx_DECREF(__pyx_v___pyx_result->con_params);
  __pyx_v___pyx_result->con_params = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->connected = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_6edgedb_8protocol_8protocol_CodecsRegistry))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->internal_reg);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->internal_reg));
  __pyx_v___pyx_result->internal_reg = ((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->last_details);
  __Pyx_DECREF(__pyx_v___pyx_result->last_details);
  __pyx_v___pyx_result->last_details = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->last_status);
  __Pyx_DECREF(__pyx_v___pyx_result->last_status);
  __pyx_v___pyx_result->last_status = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->protocol_version);
  __Pyx_DECREF(__pyx_v___pyx_result->protocol_version);
  __pyx_v___pyx_result->protocol_version = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 10, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->server_settings);
  __Pyx_DECREF(__pyx_v___pyx_result->server_settings);
  __pyx_v___pyx_result->server_settings = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 11, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->tls_compat = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 12, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = ((enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)__Pyx_PyInt_As_enum____pyx_t_6edgedb_8protocol_8protocol_TransactionStatus(__pyx_t_1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->xact_status = __pyx_t_3;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_SansIOProtocol__set_state(SansIOProtocol __pyx_result, tuple __pyx_state):
 *     __pyx_result.backend_secret = __pyx_state[0]; __pyx_result.buffer = __pyx_state[1]; __pyx_result.cancelled = __pyx_state[2]; __pyx_result.con = __pyx_state[3]; __pyx_result.con_params = __pyx_state[4]; __pyx_result.connected = __pyx_state[5]; __pyx_result.internal_reg = __pyx_state[6]; __pyx_result.last_details = __pyx_state[7]; __pyx_result.last_status = __pyx_state[8]; __pyx_result.protocol_version = __pyx_state[9]; __pyx_result.server_settings = __pyx_state[10]; __pyx_result.tls_compat = __pyx_state[11]; __pyx_result.xact_status = __pyx_state[12]
 *     if len(__pyx_state) > 13 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[13])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 13, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 13) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_2 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.backend_secret = __pyx_state[0]; __pyx_result.buffer = __pyx_state[1]; __pyx_result.cancelled = __pyx_state[2]; __pyx_result.con = __pyx_state[3]; __pyx_result.con_params = __pyx_state[4]; __pyx_result.connected = __pyx_state[5]; __pyx_result.internal_reg = __pyx_state[6]; __pyx_result.last_details = __pyx_state[7]; __pyx_result.last_status = __pyx_state[8]; __pyx_result.protocol_version = __pyx_state[9]; __pyx_result.server_settings = __pyx_state[10]; __pyx_result.tls_compat = __pyx_state[11]; __pyx_result.xact_status = __pyx_state[12]
 *     if len(__pyx_state) > 13 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[13])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 14, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 13, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_SansIOProtocol__set_state(SansIOProtocol __pyx_result, tuple __pyx_state):
 *     __pyx_result.backend_secret = __pyx_state[0]; __pyx_result.buffer = __pyx_state[1]; __pyx_result.cancelled = __pyx_state[2]; __pyx_result.con = __pyx_state[3]; __pyx_result.con_params = __pyx_state[4]; __pyx_result.connected = __pyx_state[5]; __pyx_result.internal_reg = __pyx_state[6]; __pyx_result.last_details = __pyx_state[7]; __pyx_result.last_status = __pyx_state[8]; __pyx_result.protocol_version = __pyx_state[9]; __pyx_result.server_settings = __pyx_state[10]; __pyx_result.tls_compat = __pyx_state[11]; __pyx_result.xact_status = __pyx_state[12]
 *     if len(__pyx_state) > 13 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[13])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_SansIOProtocol__set_state(<SansIOProtocol> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_SansIOProtocol__set_state(SansIOProtocol __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.backend_secret = __pyx_state[0]; __pyx_result.buffer = __pyx_state[1]; __pyx_result.cancelled = __pyx_state[2]; __pyx_result.con = __pyx_state[3]; __pyx_result.con_params = __pyx_state[4]; __pyx_result.connected = __pyx_state[5]; __pyx_result.internal_reg = __pyx_state[6]; __pyx_result.last_details = __pyx_state[7]; __pyx_result.last_status = __pyx_state[8]; __pyx_result.protocol_version = __pyx_state[9]; __pyx_result.server_settings = __pyx_state[10]; __pyx_result.tls_compat = __pyx_state[11]; __pyx_result.xact_status = __pyx_state[12]
 *     if len(__pyx_state) > 13 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("edgedb.protocol.protocol.__pyx_unpickle_SansIOProtocol__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/pgproto/frb.pxd":14
 *         ssize_t len
 * 
 *     inline ssize_t frb_get_len(FRBuffer *frb):             # <<<<<<<<<<<<<<
 *         return frb.len
 * 
 */

static CYTHON_INLINE Py_ssize_t __pyx_f_6edgedb_7pgproto_7pgproto_frb_get_len(struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_frb) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("frb_get_len", 0);

  /* "edgedb/pgproto/frb.pxd":15
 * 
 *     inline ssize_t frb_get_len(FRBuffer *frb):
 *         return frb.len             # <<<<<<<<<<<<<<
 * 
 *     inline void frb_set_len(FRBuffer *frb, ssize_t new_len):
 */
  __pyx_r = __pyx_v_frb->len;
  goto __pyx_L0;

  /* "edgedb/pgproto/frb.pxd":14
 *         ssize_t len
 * 
 *     inline ssize_t frb_get_len(FRBuffer *frb):             # <<<<<<<<<<<<<<
 *         return frb.len
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/pgproto/frb.pxd":17
 *         return frb.len
 * 
 *     inline void frb_set_len(FRBuffer *frb, ssize_t new_len):             # <<<<<<<<<<<<<<
 *         frb.len = new_len
 * 
 */

static CYTHON_INLINE void __pyx_f_6edgedb_7pgproto_7pgproto_frb_set_len(struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_frb, Py_ssize_t __pyx_v_new_len) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("frb_set_len", 0);

  /* "edgedb/pgproto/frb.pxd":18
 * 
 *     inline void frb_set_len(FRBuffer *frb, ssize_t new_len):
 *         frb.len = new_len             # <<<<<<<<<<<<<<
 * 
 *     inline void frb_init(FRBuffer *frb, const char *buf, ssize_t len):
 */
  __pyx_v_frb->len = __pyx_v_new_len;

  /* "edgedb/pgproto/frb.pxd":17
 *         return frb.len
 * 
 *     inline void frb_set_len(FRBuffer *frb, ssize_t new_len):             # <<<<<<<<<<<<<<
 *         frb.len = new_len
 * 
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "edgedb/pgproto/frb.pxd":20
 *         frb.len = new_len
 * 
 *     inline void frb_init(FRBuffer *frb, const char *buf, ssize_t len):             # <<<<<<<<<<<<<<
 *         frb.buf = buf
 *         frb.len = len
 */

static CYTHON_INLINE void __pyx_f_6edgedb_7pgproto_7pgproto_frb_init(struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_frb, char const *__pyx_v_buf, Py_ssize_t __pyx_v_len) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("frb_init", 0);

  /* "edgedb/pgproto/frb.pxd":21
 * 
 *     inline void frb_init(FRBuffer *frb, const char *buf, ssize_t len):
 *         frb.buf = buf             # <<<<<<<<<<<<<<
 *         frb.len = len
 * 
 */
  __pyx_v_frb->buf = __pyx_v_buf;

  /* "edgedb/pgproto/frb.pxd":22
 *     inline void frb_init(FRBuffer *frb, const char *buf, ssize_t len):
 *         frb.buf = buf
 *         frb.len = len             # <<<<<<<<<<<<<<
 * 
 *     inline const char* frb_read(FRBuffer *frb, ssize_t n) except NULL:
 */
  __pyx_v_frb->len = __pyx_v_len;

  /* "edgedb/pgproto/frb.pxd":20
 *         frb.len = new_len
 * 
 *     inline void frb_init(FRBuffer *frb, const char *buf, ssize_t len):             # <<<<<<<<<<<<<<
 *         frb.buf = buf
 *         frb.len = len
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "edgedb/pgproto/frb.pxd":24
 *         frb.len = len
 * 
 *     inline const char* frb_read(FRBuffer *frb, ssize_t n) except NULL:             # <<<<<<<<<<<<<<
 *         cdef const char *result
 * 
 */

static CYTHON_INLINE char const *__pyx_f_6edgedb_7pgproto_7pgproto_frb_read(struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_frb, Py_ssize_t __pyx_v_n) {
  char const *__pyx_v_result;
  char const *__pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  char const *__pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("frb_read", 0);

  /* "edgedb/pgproto/frb.pxd":27
 *         cdef const char *result
 * 
 *         if n > frb.len:             # <<<<<<<<<<<<<<
 *             frb_check(frb, n)
 * 
 */
  __pyx_t_1 = ((__pyx_v_n > __pyx_v_frb->len) != 0);
  if (__pyx_t_1) {

    /* "edgedb/pgproto/frb.pxd":28
 * 
 *         if n > frb.len:
 *             frb_check(frb, n)             # <<<<<<<<<<<<<<
 * 
 *         result = frb.buf
 */
    __pyx_t_2 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_check(__pyx_v_frb, __pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(13, 28, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "edgedb/pgproto/frb.pxd":27
 *         cdef const char *result
 * 
 *         if n > frb.len:             # <<<<<<<<<<<<<<
 *             frb_check(frb, n)
 * 
 */
  }

  /* "edgedb/pgproto/frb.pxd":30
 *             frb_check(frb, n)
 * 
 *         result = frb.buf             # <<<<<<<<<<<<<<
 *         frb.buf += n
 *         frb.len -= n
 */
  __pyx_t_3 = __pyx_v_frb->buf;
  __pyx_v_result = __pyx_t_3;

  /* "edgedb/pgproto/frb.pxd":31
 * 
 *         result = frb.buf
 *         frb.buf += n             # <<<<<<<<<<<<<<
 *         frb.len -= n
 * 
 */
  __pyx_v_frb->buf = (__pyx_v_frb->buf + __pyx_v_n);

  /* "edgedb/pgproto/frb.pxd":32
 *         result = frb.buf
 *         frb.buf += n
 *         frb.len -= n             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
  __pyx_v_frb->len = (__pyx_v_frb->len - __pyx_v_n);

  /* "edgedb/pgproto/frb.pxd":34
 *         frb.len -= n
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     inline const char* frb_read_all(FRBuffer *frb):
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "edgedb/pgproto/frb.pxd":24
 *         frb.len = len
 * 
 *     inline const char* frb_read(FRBuffer *frb, ssize_t n) except NULL:             # <<<<<<<<<<<<<<
 *         cdef const char *result
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("edgedb.pgproto.pgproto.frb_read", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/pgproto/frb.pxd":36
 *         return result
 * 
 *     inline const char* frb_read_all(FRBuffer *frb):             # <<<<<<<<<<<<<<
 *         cdef const char *result
 *         result = frb.buf
 */

static CYTHON_INLINE char const *__pyx_f_6edgedb_7pgproto_7pgproto_frb_read_all(struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_frb) {
  char const *__pyx_v_result;
  char const *__pyx_r;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  __Pyx_RefNannySetupContext("frb_read_all", 0);

  /* "edgedb/pgproto/frb.pxd":38
 *     inline const char* frb_read_all(FRBuffer *frb):
 *         cdef const char *result
 *         result = frb.buf             # <<<<<<<<<<<<<<
 *         frb.buf += frb.len
 *         frb.len = 0
 */
  __pyx_t_1 = __pyx_v_frb->buf;
  __pyx_v_result = __pyx_t_1;

  /* "edgedb/pgproto/frb.pxd":39
 *         cdef const char *result
 *         result = frb.buf
 *         frb.buf += frb.len             # <<<<<<<<<<<<<<
 *         frb.len = 0
 *         return result
 */
  __pyx_v_frb->buf = (__pyx_v_frb->buf + __pyx_v_frb->len);

  /* "edgedb/pgproto/frb.pxd":40
 *         result = frb.buf
 *         frb.buf += frb.len
 *         frb.len = 0             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
  __pyx_v_frb->len = 0;

  /* "edgedb/pgproto/frb.pxd":41
 *         frb.buf += frb.len
 *         frb.len = 0
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     inline FRBuffer *frb_slice_from(FRBuffer *frb,
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "edgedb/pgproto/frb.pxd":36
 *         return result
 * 
 *     inline const char* frb_read_all(FRBuffer *frb):             # <<<<<<<<<<<<<<
 *         cdef const char *result
 *         result = frb.buf
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/pgproto/frb.pxd":43
 *         return result
 * 
 *     inline FRBuffer *frb_slice_from(FRBuffer *frb,             # <<<<<<<<<<<<<<
 *                                     FRBuffer* source, ssize_t len):
 *         frb.buf = frb_read(source, len)
 */

static CYTHON_INLINE struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_f_6edgedb_7pgproto_7pgproto_frb_slice_from(struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_frb, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_v_source, Py_ssize_t __pyx_v_len) {
  struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *__pyx_r;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("frb_slice_from", 0);

  /* "edgedb/pgproto/frb.pxd":45
 *     inline FRBuffer *frb_slice_from(FRBuffer *frb,
 *                                     FRBuffer* source, ssize_t len):
 *         frb.buf = frb_read(source, len)             # <<<<<<<<<<<<<<
 *         frb.len = len
 *         return frb
 */
  __pyx_t_1 = __pyx_f_6edgedb_7pgproto_7pgproto_frb_read(__pyx_v_source, __pyx_v_len); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(13, 45, __pyx_L1_error)
  __pyx_v_frb->buf = __pyx_t_1;

  /* "edgedb/pgproto/frb.pxd":46
 *                                     FRBuffer* source, ssize_t len):
 *         frb.buf = frb_read(source, len)
 *         frb.len = len             # <<<<<<<<<<<<<<
 *         return frb
 * 
 */
  __pyx_v_frb->len = __pyx_v_len;

  /* "edgedb/pgproto/frb.pxd":47
 *         frb.buf = frb_read(source, len)
 *         frb.len = len
 *         return frb             # <<<<<<<<<<<<<<
 * 
 *     object frb_check(FRBuffer *frb, ssize_t n)
 */
  __pyx_r = __pyx_v_frb;
  goto __pyx_L0;

  /* "edgedb/pgproto/frb.pxd":43
 *         return result
 * 
 *     inline FRBuffer *frb_slice_from(FRBuffer *frb,             # <<<<<<<<<<<<<<
 *                                     FRBuffer* source, ssize_t len):
 *         frb.buf = frb_read(source, len)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("edgedb.pgproto.pgproto.frb_slice_from", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/pgproto/buffer.pxd":28
 *         bint _message_mode
 * 
 *     cdef inline len(self):             # <<<<<<<<<<<<<<
 *         return self._length
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_len(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("len", 0);

  /* "edgedb/pgproto/buffer.pxd":29
 * 
 *     cdef inline len(self):
 *         return self._length             # <<<<<<<<<<<<<<
 * 
 *     cdef inline write_len_prefixed_utf8(self, str s):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "edgedb/pgproto/buffer.pxd":28
 *         bint _message_mode
 * 
 *     cdef inline len(self):             # <<<<<<<<<<<<<<
 *         return self._length
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.pgproto.pgproto.WriteBuffer.len", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/pgproto/buffer.pxd":31
 *         return self._length
 * 
 *     cdef inline write_len_prefixed_utf8(self, str s):             # <<<<<<<<<<<<<<
 *         return self.write_len_prefixed_bytes(s.encode('utf-8'))
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_6edgedb_7pgproto_7pgproto_11WriteBuffer_write_len_prefixed_utf8(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *__pyx_v_self, PyObject *__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("write_len_prefixed_utf8", 0);

  /* "edgedb/pgproto/buffer.pxd":32
 * 
 *     cdef inline write_len_prefixed_utf8(self, str s):
 *         return self.write_len_prefixed_bytes(s.encode('utf-8'))             # <<<<<<<<<<<<<<
 * 
 *     cdef inline _check_readonly(self)
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_s == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(14, 32, __pyx_L1_error)
  }
  __pyx_t_1 = PyUnicode_AsUTF8String(__pyx_v_s); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_v_self->__pyx_vtab)->write_len_prefixed_bytes(__pyx_v_self, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(14, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "edgedb/pgproto/buffer.pxd":31
 *         return self._length
 * 
 *     cdef inline write_len_prefixed_utf8(self, str s):             # <<<<<<<<<<<<<<
 *         return self.write_len_prefixed_bytes(s.encode('utf-8'))
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("edgedb.pgproto.pgproto.WriteBuffer.write_len_prefixed_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/pgproto/buffer.pxd":100
 *         bint _current_message_ready
 * 
 *     cdef inline len(self):             # <<<<<<<<<<<<<<
 *         return self._length
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_len(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("len", 0);

  /* "edgedb/pgproto/buffer.pxd":101
 * 
 *     cdef inline len(self):
 *         return self._length             # <<<<<<<<<<<<<<
 * 
 *     cdef inline char get_message_type(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "edgedb/pgproto/buffer.pxd":100
 *         bint _current_message_ready
 * 
 *     cdef inline len(self):             # <<<<<<<<<<<<<<
 *         return self._length
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("edgedb.pgproto.pgproto.ReadBuffer.len", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/pgproto/buffer.pxd":103
 *         return self._length
 * 
 *     cdef inline char get_message_type(self):             # <<<<<<<<<<<<<<
 *         return self._current_message_type
 * 
 */

static CYTHON_INLINE char __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_type(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *__pyx_v_self) {
  char __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_message_type", 0);

  /* "edgedb/pgproto/buffer.pxd":104
 * 
 *     cdef inline char get_message_type(self):
 *         return self._current_message_type             # <<<<<<<<<<<<<<
 * 
 *     cdef inline int32_t get_message_length(self):
 */
  __pyx_r = __pyx_v_self->_current_message_type;
  goto __pyx_L0;

  /* "edgedb/pgproto/buffer.pxd":103
 *         return self._length
 * 
 *     cdef inline char get_message_type(self):             # <<<<<<<<<<<<<<
 *         return self._current_message_type
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/pgproto/buffer.pxd":106
 *         return self._current_message_type
 * 
 *     cdef inline int32_t get_message_length(self):             # <<<<<<<<<<<<<<
 *         return self._current_message_len
 * 
 */

static CYTHON_INLINE int32_t __pyx_f_6edgedb_7pgproto_7pgproto_10ReadBuffer_get_message_length(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *__pyx_v_self) {
  int32_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_message_length", 0);

  /* "edgedb/pgproto/buffer.pxd":107
 * 
 *     cdef inline int32_t get_message_length(self):
 *         return self._current_message_len             # <<<<<<<<<<<<<<
 * 
 *     cdef feed_data(self, data)
 */
  __pyx_r = __pyx_v_self->_current_message_len;
  goto __pyx_L0;

  /* "edgedb/pgproto/buffer.pxd":106
 *         return self._current_message_type
 * 
 *     cdef inline int32_t get_message_length(self):             # <<<<<<<<<<<<<<
 *         return self._current_message_len
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "edgedb/protocol/codecs/base.pxd":26
 *         str     name
 * 
 *     cdef inline bytes get_tid(self):             # <<<<<<<<<<<<<<
 *         return self.tid
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_6edgedb_8protocol_8protocol_9BaseCodec_get_tid(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_tid", 0);

  /* "edgedb/protocol/codecs/base.pxd":27
 * 
 *     cdef inline bytes get_tid(self):
 *         return self.tid             # <<<<<<<<<<<<<<
 * 
 *     cdef encode(self, WriteBuffer buf, object obj)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->tid);
  __pyx_r = __pyx_v_self->tid;
  goto __pyx_L0;

  /* "edgedb/protocol/codecs/base.pxd":26
 *         str     name
 * 
 *     cdef inline bytes get_tid(self):             # <<<<<<<<<<<<<<
 *         return self.tid
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":104
 * # Datetime C API initialization function.
 * # You have to call it before any usage of DateTime CAPI functions.
 * cdef inline void import_datetime():             # <<<<<<<<<<<<<<
 *     PyDateTime_IMPORT
 * 
 */

static CYTHON_INLINE void __pyx_f_7cpython_8datetime_import_datetime(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("import_datetime", 0);

  /* "cpython/datetime.pxd":105
 * # You have to call it before any usage of DateTime CAPI functions.
 * cdef inline void import_datetime():
 *     PyDateTime_IMPORT             # <<<<<<<<<<<<<<
 * 
 * # Create date object using DateTime CAPI factory function.
 */
  (void)(PyDateTime_IMPORT);

  /* "cpython/datetime.pxd":104
 * # Datetime C API initialization function.
 * # You have to call it before any usage of DateTime CAPI functions.
 * cdef inline void import_datetime():             # <<<<<<<<<<<<<<
 *     PyDateTime_IMPORT
 * 
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "cpython/datetime.pxd":109
 * # Create date object using DateTime CAPI factory function.
 * # Note, there are no range checks for any of the arguments.
 * cdef inline object date_new(int year, int month, int day):             # <<<<<<<<<<<<<<
 *     return PyDateTimeAPI.Date_FromDate(year, month, day, PyDateTimeAPI.DateType)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7cpython_8datetime_date_new(int __pyx_v_year, int __pyx_v_month, int __pyx_v_day) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("date_new", 0);

  /* "cpython/datetime.pxd":110
 * # Note, there are no range checks for any of the arguments.
 * cdef inline object date_new(int year, int month, int day):
 *     return PyDateTimeAPI.Date_FromDate(year, month, day, PyDateTimeAPI.DateType)             # <<<<<<<<<<<<<<
 * 
 * # Create time object using DateTime CAPI factory function
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDateTimeAPI->Date_FromDate(__pyx_v_year, __pyx_v_month, __pyx_v_day, PyDateTimeAPI->DateType); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpython/datetime.pxd":109
 * # Create date object using DateTime CAPI factory function.
 * # Note, there are no range checks for any of the arguments.
 * cdef inline object date_new(int year, int month, int day):             # <<<<<<<<<<<<<<
 *     return PyDateTimeAPI.Date_FromDate(year, month, day, PyDateTimeAPI.DateType)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpython.datetime.date_new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":114
 * # Create time object using DateTime CAPI factory function
 * # Note, there are no range checks for any of the arguments.
 * cdef inline object time_new(int hour, int minute, int second, int microsecond, object tz):             # <<<<<<<<<<<<<<
 *     return PyDateTimeAPI.Time_FromTime(hour, minute, second, microsecond, tz, PyDateTimeAPI.TimeType)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7cpython_8datetime_time_new(int __pyx_v_hour, int __pyx_v_minute, int __pyx_v_second, int __pyx_v_microsecond, PyObject *__pyx_v_tz) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("time_new", 0);

  /* "cpython/datetime.pxd":115
 * # Note, there are no range checks for any of the arguments.
 * cdef inline object time_new(int hour, int minute, int second, int microsecond, object tz):
 *     return PyDateTimeAPI.Time_FromTime(hour, minute, second, microsecond, tz, PyDateTimeAPI.TimeType)             # <<<<<<<<<<<<<<
 * 
 * # Create datetime object using DateTime CAPI factory function.
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDateTimeAPI->Time_FromTime(__pyx_v_hour, __pyx_v_minute, __pyx_v_second, __pyx_v_microsecond, __pyx_v_tz, PyDateTimeAPI->TimeType); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpython/datetime.pxd":114
 * # Create time object using DateTime CAPI factory function
 * # Note, there are no range checks for any of the arguments.
 * cdef inline object time_new(int hour, int minute, int second, int microsecond, object tz):             # <<<<<<<<<<<<<<
 *     return PyDateTimeAPI.Time_FromTime(hour, minute, second, microsecond, tz, PyDateTimeAPI.TimeType)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpython.datetime.time_new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":119
 * # Create datetime object using DateTime CAPI factory function.
 * # Note, there are no range checks for any of the arguments.
 * cdef inline object datetime_new(int year, int month, int day, int hour, int minute, int second, int microsecond, object tz):             # <<<<<<<<<<<<<<
 *     return PyDateTimeAPI.DateTime_FromDateAndTime(year, month, day, hour, minute, second, microsecond, tz, PyDateTimeAPI.DateTimeType)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7cpython_8datetime_datetime_new(int __pyx_v_year, int __pyx_v_month, int __pyx_v_day, int __pyx_v_hour, int __pyx_v_minute, int __pyx_v_second, int __pyx_v_microsecond, PyObject *__pyx_v_tz) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("datetime_new", 0);

  /* "cpython/datetime.pxd":120
 * # Note, there are no range checks for any of the arguments.
 * cdef inline object datetime_new(int year, int month, int day, int hour, int minute, int second, int microsecond, object tz):
 *     return PyDateTimeAPI.DateTime_FromDateAndTime(year, month, day, hour, minute, second, microsecond, tz, PyDateTimeAPI.DateTimeType)             # <<<<<<<<<<<<<<
 * 
 * # Create timedelta object using DateTime CAPI factory function.
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDateTimeAPI->DateTime_FromDateAndTime(__pyx_v_year, __pyx_v_month, __pyx_v_day, __pyx_v_hour, __pyx_v_minute, __pyx_v_second, __pyx_v_microsecond, __pyx_v_tz, PyDateTimeAPI->DateTimeType); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 120, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpython/datetime.pxd":119
 * # Create datetime object using DateTime CAPI factory function.
 * # Note, there are no range checks for any of the arguments.
 * cdef inline object datetime_new(int year, int month, int day, int hour, int minute, int second, int microsecond, object tz):             # <<<<<<<<<<<<<<
 *     return PyDateTimeAPI.DateTime_FromDateAndTime(year, month, day, hour, minute, second, microsecond, tz, PyDateTimeAPI.DateTimeType)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpython.datetime.datetime_new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":124
 * # Create timedelta object using DateTime CAPI factory function.
 * # Note, there are no range checks for any of the arguments.
 * cdef inline object timedelta_new(int days, int seconds, int useconds):             # <<<<<<<<<<<<<<
 *     return PyDateTimeAPI.Delta_FromDelta(days, seconds, useconds, 1, PyDateTimeAPI.DeltaType)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7cpython_8datetime_timedelta_new(int __pyx_v_days, int __pyx_v_seconds, int __pyx_v_useconds) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("timedelta_new", 0);

  /* "cpython/datetime.pxd":125
 * # Note, there are no range checks for any of the arguments.
 * cdef inline object timedelta_new(int days, int seconds, int useconds):
 *     return PyDateTimeAPI.Delta_FromDelta(days, seconds, useconds, 1, PyDateTimeAPI.DeltaType)             # <<<<<<<<<<<<<<
 * 
 * # More recognizable getters for date/time/datetime/timedelta.
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDateTimeAPI->Delta_FromDelta(__pyx_v_days, __pyx_v_seconds, __pyx_v_useconds, 1, PyDateTimeAPI->DeltaType); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cpython/datetime.pxd":124
 * # Create timedelta object using DateTime CAPI factory function.
 * # Note, there are no range checks for any of the arguments.
 * cdef inline object timedelta_new(int days, int seconds, int useconds):             # <<<<<<<<<<<<<<
 *     return PyDateTimeAPI.Delta_FromDelta(days, seconds, useconds, 1, PyDateTimeAPI.DeltaType)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpython.datetime.timedelta_new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":133
 * 
 * # Get tzinfo of time
 * cdef inline object time_tzinfo(object o):             # <<<<<<<<<<<<<<
 *     if (<PyDateTime_Time*>o).hastzinfo:
 *         return <object>(<PyDateTime_Time*>o).tzinfo
 */

static CYTHON_INLINE PyObject *__pyx_f_7cpython_8datetime_time_tzinfo(PyObject *__pyx_v_o) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("time_tzinfo", 0);

  /* "cpython/datetime.pxd":134
 * # Get tzinfo of time
 * cdef inline object time_tzinfo(object o):
 *     if (<PyDateTime_Time*>o).hastzinfo:             # <<<<<<<<<<<<<<
 *         return <object>(<PyDateTime_Time*>o).tzinfo
 *     else:
 */
  __pyx_t_1 = (((PyDateTime_Time *)__pyx_v_o)->hastzinfo != 0);
  if (__pyx_t_1) {

    /* "cpython/datetime.pxd":135
 * cdef inline object time_tzinfo(object o):
 *     if (<PyDateTime_Time*>o).hastzinfo:
 *         return <object>(<PyDateTime_Time*>o).tzinfo             # <<<<<<<<<<<<<<
 *     else:
 *         return None
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)((PyDateTime_Time *)__pyx_v_o)->tzinfo));
    __pyx_r = ((PyObject *)((PyDateTime_Time *)__pyx_v_o)->tzinfo);
    goto __pyx_L0;

    /* "cpython/datetime.pxd":134
 * # Get tzinfo of time
 * cdef inline object time_tzinfo(object o):
 *     if (<PyDateTime_Time*>o).hastzinfo:             # <<<<<<<<<<<<<<
 *         return <object>(<PyDateTime_Time*>o).tzinfo
 *     else:
 */
  }

  /* "cpython/datetime.pxd":137
 *         return <object>(<PyDateTime_Time*>o).tzinfo
 *     else:
 *         return None             # <<<<<<<<<<<<<<
 * 
 * # Get tzinfo of datetime
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "cpython/datetime.pxd":133
 * 
 * # Get tzinfo of time
 * cdef inline object time_tzinfo(object o):             # <<<<<<<<<<<<<<
 *     if (<PyDateTime_Time*>o).hastzinfo:
 *         return <object>(<PyDateTime_Time*>o).tzinfo
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":140
 * 
 * # Get tzinfo of datetime
 * cdef inline object datetime_tzinfo(object o):             # <<<<<<<<<<<<<<
 *     if (<PyDateTime_DateTime*>o).hastzinfo:
 *         return <object>(<PyDateTime_DateTime*>o).tzinfo
 */

static CYTHON_INLINE PyObject *__pyx_f_7cpython_8datetime_datetime_tzinfo(PyObject *__pyx_v_o) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("datetime_tzinfo", 0);

  /* "cpython/datetime.pxd":141
 * # Get tzinfo of datetime
 * cdef inline object datetime_tzinfo(object o):
 *     if (<PyDateTime_DateTime*>o).hastzinfo:             # <<<<<<<<<<<<<<
 *         return <object>(<PyDateTime_DateTime*>o).tzinfo
 *     else:
 */
  __pyx_t_1 = (((PyDateTime_DateTime *)__pyx_v_o)->hastzinfo != 0);
  if (__pyx_t_1) {

    /* "cpython/datetime.pxd":142
 * cdef inline object datetime_tzinfo(object o):
 *     if (<PyDateTime_DateTime*>o).hastzinfo:
 *         return <object>(<PyDateTime_DateTime*>o).tzinfo             # <<<<<<<<<<<<<<
 *     else:
 *         return None
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)((PyDateTime_DateTime *)__pyx_v_o)->tzinfo));
    __pyx_r = ((PyObject *)((PyDateTime_DateTime *)__pyx_v_o)->tzinfo);
    goto __pyx_L0;

    /* "cpython/datetime.pxd":141
 * # Get tzinfo of datetime
 * cdef inline object datetime_tzinfo(object o):
 *     if (<PyDateTime_DateTime*>o).hastzinfo:             # <<<<<<<<<<<<<<
 *         return <object>(<PyDateTime_DateTime*>o).tzinfo
 *     else:
 */
  }

  /* "cpython/datetime.pxd":144
 *         return <object>(<PyDateTime_DateTime*>o).tzinfo
 *     else:
 *         return None             # <<<<<<<<<<<<<<
 * 
 * # Get year of date
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "cpython/datetime.pxd":140
 * 
 * # Get tzinfo of datetime
 * cdef inline object datetime_tzinfo(object o):             # <<<<<<<<<<<<<<
 *     if (<PyDateTime_DateTime*>o).hastzinfo:
 *         return <object>(<PyDateTime_DateTime*>o).tzinfo
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":147
 * 
 * # Get year of date
 * cdef inline int date_year(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_GET_YEAR(o)
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_date_year(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("date_year", 0);

  /* "cpython/datetime.pxd":148
 * # Get year of date
 * cdef inline int date_year(object o):
 *     return PyDateTime_GET_YEAR(o)             # <<<<<<<<<<<<<<
 * 
 * # Get month of date
 */
  __pyx_r = PyDateTime_GET_YEAR(__pyx_v_o);
  goto __pyx_L0;

  /* "cpython/datetime.pxd":147
 * 
 * # Get year of date
 * cdef inline int date_year(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_GET_YEAR(o)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":151
 * 
 * # Get month of date
 * cdef inline int date_month(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_GET_MONTH(o)
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_date_month(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("date_month", 0);

  /* "cpython/datetime.pxd":152
 * # Get month of date
 * cdef inline int date_month(object o):
 *     return PyDateTime_GET_MONTH(o)             # <<<<<<<<<<<<<<
 * 
 * # Get day of date
 */
  __pyx_r = PyDateTime_GET_MONTH(__pyx_v_o);
  goto __pyx_L0;

  /* "cpython/datetime.pxd":151
 * 
 * # Get month of date
 * cdef inline int date_month(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_GET_MONTH(o)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":155
 * 
 * # Get day of date
 * cdef inline int date_day(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_GET_DAY(o)
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_date_day(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("date_day", 0);

  /* "cpython/datetime.pxd":156
 * # Get day of date
 * cdef inline int date_day(object o):
 *     return PyDateTime_GET_DAY(o)             # <<<<<<<<<<<<<<
 * 
 * # Get year of datetime
 */
  __pyx_r = PyDateTime_GET_DAY(__pyx_v_o);
  goto __pyx_L0;

  /* "cpython/datetime.pxd":155
 * 
 * # Get day of date
 * cdef inline int date_day(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_GET_DAY(o)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":159
 * 
 * # Get year of datetime
 * cdef inline int datetime_year(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_GET_YEAR(o)
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_datetime_year(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("datetime_year", 0);

  /* "cpython/datetime.pxd":160
 * # Get year of datetime
 * cdef inline int datetime_year(object o):
 *     return PyDateTime_GET_YEAR(o)             # <<<<<<<<<<<<<<
 * 
 * # Get month of datetime
 */
  __pyx_r = PyDateTime_GET_YEAR(__pyx_v_o);
  goto __pyx_L0;

  /* "cpython/datetime.pxd":159
 * 
 * # Get year of datetime
 * cdef inline int datetime_year(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_GET_YEAR(o)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":163
 * 
 * # Get month of datetime
 * cdef inline int datetime_month(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_GET_MONTH(o)
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_datetime_month(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("datetime_month", 0);

  /* "cpython/datetime.pxd":164
 * # Get month of datetime
 * cdef inline int datetime_month(object o):
 *     return PyDateTime_GET_MONTH(o)             # <<<<<<<<<<<<<<
 * 
 * # Get day of datetime
 */
  __pyx_r = PyDateTime_GET_MONTH(__pyx_v_o);
  goto __pyx_L0;

  /* "cpython/datetime.pxd":163
 * 
 * # Get month of datetime
 * cdef inline int datetime_month(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_GET_MONTH(o)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":167
 * 
 * # Get day of datetime
 * cdef inline int datetime_day(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_GET_DAY(o)
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_datetime_day(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("datetime_day", 0);

  /* "cpython/datetime.pxd":168
 * # Get day of datetime
 * cdef inline int datetime_day(object o):
 *     return PyDateTime_GET_DAY(o)             # <<<<<<<<<<<<<<
 * 
 * # Get hour of time
 */
  __pyx_r = PyDateTime_GET_DAY(__pyx_v_o);
  goto __pyx_L0;

  /* "cpython/datetime.pxd":167
 * 
 * # Get day of datetime
 * cdef inline int datetime_day(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_GET_DAY(o)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":171
 * 
 * # Get hour of time
 * cdef inline int time_hour(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_TIME_GET_HOUR(o)
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_time_hour(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("time_hour", 0);

  /* "cpython/datetime.pxd":172
 * # Get hour of time
 * cdef inline int time_hour(object o):
 *     return PyDateTime_TIME_GET_HOUR(o)             # <<<<<<<<<<<<<<
 * 
 * # Get minute of time
 */
  __pyx_r = PyDateTime_TIME_GET_HOUR(__pyx_v_o);
  goto __pyx_L0;

  /* "cpython/datetime.pxd":171
 * 
 * # Get hour of time
 * cdef inline int time_hour(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_TIME_GET_HOUR(o)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":175
 * 
 * # Get minute of time
 * cdef inline int time_minute(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_TIME_GET_MINUTE(o)
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_time_minute(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("time_minute", 0);

  /* "cpython/datetime.pxd":176
 * # Get minute of time
 * cdef inline int time_minute(object o):
 *     return PyDateTime_TIME_GET_MINUTE(o)             # <<<<<<<<<<<<<<
 * 
 * # Get second of time
 */
  __pyx_r = PyDateTime_TIME_GET_MINUTE(__pyx_v_o);
  goto __pyx_L0;

  /* "cpython/datetime.pxd":175
 * 
 * # Get minute of time
 * cdef inline int time_minute(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_TIME_GET_MINUTE(o)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":179
 * 
 * # Get second of time
 * cdef inline int time_second(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_TIME_GET_SECOND(o)
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_time_second(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("time_second", 0);

  /* "cpython/datetime.pxd":180
 * # Get second of time
 * cdef inline int time_second(object o):
 *     return PyDateTime_TIME_GET_SECOND(o)             # <<<<<<<<<<<<<<
 * 
 * # Get microsecond of time
 */
  __pyx_r = PyDateTime_TIME_GET_SECOND(__pyx_v_o);
  goto __pyx_L0;

  /* "cpython/datetime.pxd":179
 * 
 * # Get second of time
 * cdef inline int time_second(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_TIME_GET_SECOND(o)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":183
 * 
 * # Get microsecond of time
 * cdef inline int time_microsecond(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_TIME_GET_MICROSECOND(o)
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_time_microsecond(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("time_microsecond", 0);

  /* "cpython/datetime.pxd":184
 * # Get microsecond of time
 * cdef inline int time_microsecond(object o):
 *     return PyDateTime_TIME_GET_MICROSECOND(o)             # <<<<<<<<<<<<<<
 * 
 * # Get hour of datetime
 */
  __pyx_r = PyDateTime_TIME_GET_MICROSECOND(__pyx_v_o);
  goto __pyx_L0;

  /* "cpython/datetime.pxd":183
 * 
 * # Get microsecond of time
 * cdef inline int time_microsecond(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_TIME_GET_MICROSECOND(o)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":187
 * 
 * # Get hour of datetime
 * cdef inline int datetime_hour(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_DATE_GET_HOUR(o)
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_datetime_hour(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("datetime_hour", 0);

  /* "cpython/datetime.pxd":188
 * # Get hour of datetime
 * cdef inline int datetime_hour(object o):
 *     return PyDateTime_DATE_GET_HOUR(o)             # <<<<<<<<<<<<<<
 * 
 * # Get minute of datetime
 */
  __pyx_r = PyDateTime_DATE_GET_HOUR(__pyx_v_o);
  goto __pyx_L0;

  /* "cpython/datetime.pxd":187
 * 
 * # Get hour of datetime
 * cdef inline int datetime_hour(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_DATE_GET_HOUR(o)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":191
 * 
 * # Get minute of datetime
 * cdef inline int datetime_minute(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_DATE_GET_MINUTE(o)
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_datetime_minute(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("datetime_minute", 0);

  /* "cpython/datetime.pxd":192
 * # Get minute of datetime
 * cdef inline int datetime_minute(object o):
 *     return PyDateTime_DATE_GET_MINUTE(o)             # <<<<<<<<<<<<<<
 * 
 * # Get second of datetime
 */
  __pyx_r = PyDateTime_DATE_GET_MINUTE(__pyx_v_o);
  goto __pyx_L0;

  /* "cpython/datetime.pxd":191
 * 
 * # Get minute of datetime
 * cdef inline int datetime_minute(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_DATE_GET_MINUTE(o)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":195
 * 
 * # Get second of datetime
 * cdef inline int datetime_second(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_DATE_GET_SECOND(o)
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_datetime_second(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("datetime_second", 0);

  /* "cpython/datetime.pxd":196
 * # Get second of datetime
 * cdef inline int datetime_second(object o):
 *     return PyDateTime_DATE_GET_SECOND(o)             # <<<<<<<<<<<<<<
 * 
 * # Get microsecond of datetime
 */
  __pyx_r = PyDateTime_DATE_GET_SECOND(__pyx_v_o);
  goto __pyx_L0;

  /* "cpython/datetime.pxd":195
 * 
 * # Get second of datetime
 * cdef inline int datetime_second(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_DATE_GET_SECOND(o)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":199
 * 
 * # Get microsecond of datetime
 * cdef inline int datetime_microsecond(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_DATE_GET_MICROSECOND(o)
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_datetime_microsecond(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("datetime_microsecond", 0);

  /* "cpython/datetime.pxd":200
 * # Get microsecond of datetime
 * cdef inline int datetime_microsecond(object o):
 *     return PyDateTime_DATE_GET_MICROSECOND(o)             # <<<<<<<<<<<<<<
 * 
 * # Get days of timedelta
 */
  __pyx_r = PyDateTime_DATE_GET_MICROSECOND(__pyx_v_o);
  goto __pyx_L0;

  /* "cpython/datetime.pxd":199
 * 
 * # Get microsecond of datetime
 * cdef inline int datetime_microsecond(object o):             # <<<<<<<<<<<<<<
 *     return PyDateTime_DATE_GET_MICROSECOND(o)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":203
 * 
 * # Get days of timedelta
 * cdef inline int timedelta_days(object o):             # <<<<<<<<<<<<<<
 *     return (<PyDateTime_Delta*>o).days
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_timedelta_days(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("timedelta_days", 0);

  /* "cpython/datetime.pxd":204
 * # Get days of timedelta
 * cdef inline int timedelta_days(object o):
 *     return (<PyDateTime_Delta*>o).days             # <<<<<<<<<<<<<<
 * 
 * # Get seconds of timedelta
 */
  __pyx_r = ((PyDateTime_Delta *)__pyx_v_o)->days;
  goto __pyx_L0;

  /* "cpython/datetime.pxd":203
 * 
 * # Get days of timedelta
 * cdef inline int timedelta_days(object o):             # <<<<<<<<<<<<<<
 *     return (<PyDateTime_Delta*>o).days
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":207
 * 
 * # Get seconds of timedelta
 * cdef inline int timedelta_seconds(object o):             # <<<<<<<<<<<<<<
 *     return (<PyDateTime_Delta*>o).seconds
 * 
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_timedelta_seconds(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("timedelta_seconds", 0);

  /* "cpython/datetime.pxd":208
 * # Get seconds of timedelta
 * cdef inline int timedelta_seconds(object o):
 *     return (<PyDateTime_Delta*>o).seconds             # <<<<<<<<<<<<<<
 * 
 * # Get microseconds of timedelta
 */
  __pyx_r = ((PyDateTime_Delta *)__pyx_v_o)->seconds;
  goto __pyx_L0;

  /* "cpython/datetime.pxd":207
 * 
 * # Get seconds of timedelta
 * cdef inline int timedelta_seconds(object o):             # <<<<<<<<<<<<<<
 *     return (<PyDateTime_Delta*>o).seconds
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/datetime.pxd":211
 * 
 * # Get microseconds of timedelta
 * cdef inline int timedelta_microseconds(object o):             # <<<<<<<<<<<<<<
 *     return (<PyDateTime_Delta*>o).microseconds
 */

static CYTHON_INLINE int __pyx_f_7cpython_8datetime_timedelta_microseconds(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("timedelta_microseconds", 0);

  /* "cpython/datetime.pxd":212
 * # Get microseconds of timedelta
 * cdef inline int timedelta_microseconds(object o):
 *     return (<PyDateTime_Delta*>o).microseconds             # <<<<<<<<<<<<<<
 */
  __pyx_r = ((PyDateTime_Delta *)__pyx_v_o)->microseconds;
  goto __pyx_L0;

  /* "cpython/datetime.pxd":211
 * 
 * # Get microseconds of timedelta
 * cdef inline int timedelta_microseconds(object o):             # <<<<<<<<<<<<<<
 *     return (<PyDateTime_Delta*>o).microseconds
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "EnumBase":16
 * @cython.internal
 * cdef class __Pyx_EnumMeta(type):
 *     def __init__(cls, name, parents, dct):             # <<<<<<<<<<<<<<
 *         type.__init__(cls, name, parents, dct)
 *         cls.__members__ = __Pyx_OrderedDict()
 */

/* Python wrapper */
static int __pyx_pw_8EnumBase_14__Pyx_EnumMeta_1__init__(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_8EnumBase_14__Pyx_EnumMeta_1__init__(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_parents = 0;
  PyObject *__pyx_v_dct = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name_2,&__pyx_n_s_parents,&__pyx_n_s_dct,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name_2)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_parents)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); __PYX_ERR(2, 16, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dct)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); __PYX_ERR(2, 16, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(2, 16, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_name = values[0];
    __pyx_v_parents = values[1];
    __pyx_v_dct = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 16, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("EnumBase.__Pyx_EnumMeta.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8EnumBase_14__Pyx_EnumMeta___init__(((struct __pyx_obj___Pyx_EnumMeta *)__pyx_v_cls), __pyx_v_name, __pyx_v_parents, __pyx_v_dct);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8EnumBase_14__Pyx_EnumMeta___init__(struct __pyx_obj___Pyx_EnumMeta *__pyx_v_cls, PyObject *__pyx_v_name, PyObject *__pyx_v_parents, PyObject *__pyx_v_dct) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "EnumBase":17
 * cdef class __Pyx_EnumMeta(type):
 *     def __init__(cls, name, parents, dct):
 *         type.__init__(cls, name, parents, dct)             # <<<<<<<<<<<<<<
 *         cls.__members__ = __Pyx_OrderedDict()
 *     def __iter__(cls):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyType_Type)), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_3, ((PyObject *)__pyx_v_cls), __pyx_v_name, __pyx_v_parents, __pyx_v_dct};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 17, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_3, ((PyObject *)__pyx_v_cls), __pyx_v_name, __pyx_v_parents, __pyx_v_dct};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 17, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 17, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_cls));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_cls));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_cls));
    __Pyx_INCREF(__pyx_v_name);
    __Pyx_GIVEREF(__pyx_v_name);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_name);
    __Pyx_INCREF(__pyx_v_parents);
    __Pyx_GIVEREF(__pyx_v_parents);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_parents);
    __Pyx_INCREF(__pyx_v_dct);
    __Pyx_GIVEREF(__pyx_v_dct);
    PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_v_dct);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 17, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "EnumBase":18
 *     def __init__(cls, name, parents, dct):
 *         type.__init__(cls, name, parents, dct)
 *         cls.__members__ = __Pyx_OrderedDict()             # <<<<<<<<<<<<<<
 *     def __iter__(cls):
 *         return iter(cls.__members__.values())
 */
  __Pyx_INCREF(__Pyx_OrderedDict);
  __pyx_t_2 = __Pyx_OrderedDict; __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_cls), __pyx_n_s_members, __pyx_t_1) < 0) __PYX_ERR(2, 18, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "EnumBase":16
 * @cython.internal
 * cdef class __Pyx_EnumMeta(type):
 *     def __init__(cls, name, parents, dct):             # <<<<<<<<<<<<<<
 *         type.__init__(cls, name, parents, dct)
 *         cls.__members__ = __Pyx_OrderedDict()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("EnumBase.__Pyx_EnumMeta.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "EnumBase":19
 *         type.__init__(cls, name, parents, dct)
 *         cls.__members__ = __Pyx_OrderedDict()
 *     def __iter__(cls):             # <<<<<<<<<<<<<<
 *         return iter(cls.__members__.values())
 *     def __getitem__(cls, name):
 */

/* Python wrapper */
static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumMeta_3__iter__(PyObject *__pyx_v_cls); /*proto*/
static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumMeta_3__iter__(PyObject *__pyx_v_cls) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8EnumBase_14__Pyx_EnumMeta_2__iter__(((struct __pyx_obj___Pyx_EnumMeta *)__pyx_v_cls));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumMeta_2__iter__(struct __pyx_obj___Pyx_EnumMeta *__pyx_v_cls) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "EnumBase":20
 *         cls.__members__ = __Pyx_OrderedDict()
 *     def __iter__(cls):
 *         return iter(cls.__members__.values())             # <<<<<<<<<<<<<<
 *     def __getitem__(cls, name):
 *         return cls.__members__[name]
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cls), __pyx_n_s_members); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "EnumBase":19
 *         type.__init__(cls, name, parents, dct)
 *         cls.__members__ = __Pyx_OrderedDict()
 *     def __iter__(cls):             # <<<<<<<<<<<<<<
 *         return iter(cls.__members__.values())
 *     def __getitem__(cls, name):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("EnumBase.__Pyx_EnumMeta.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "EnumBase":21
 *     def __iter__(cls):
 *         return iter(cls.__members__.values())
 *     def __getitem__(cls, name):             # <<<<<<<<<<<<<<
 *         return cls.__members__[name]
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumMeta_5__getitem__(PyObject *__pyx_v_cls, PyObject *__pyx_v_name); /*proto*/
static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumMeta_5__getitem__(PyObject *__pyx_v_cls, PyObject *__pyx_v_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8EnumBase_14__Pyx_EnumMeta_4__getitem__(((struct __pyx_obj___Pyx_EnumMeta *)__pyx_v_cls), ((PyObject *)__pyx_v_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumMeta_4__getitem__(struct __pyx_obj___Pyx_EnumMeta *__pyx_v_cls, PyObject *__pyx_v_name) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "EnumBase":22
 *         return iter(cls.__members__.values())
 *     def __getitem__(cls, name):
 *         return cls.__members__[name]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cls), __pyx_n_s_members); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "EnumBase":21
 *     def __iter__(cls):
 *         return iter(cls.__members__.values())
 *     def __getitem__(cls, name):             # <<<<<<<<<<<<<<
 *         return cls.__members__[name]
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("EnumBase.__Pyx_EnumMeta.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumMeta_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumMeta_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8EnumBase_14__Pyx_EnumMeta_6__reduce_cython__(((struct __pyx_obj___Pyx_EnumMeta *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumMeta_6__reduce_cython__(struct __pyx_obj___Pyx_EnumMeta *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = ()             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __Pyx_INCREF(__pyx_empty_tuple);
  __pyx_v_state = __pyx_empty_tuple;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = ()
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = ()
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = False
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = ()
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = False             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle___Pyx_EnumMeta, (type(self), 0xd41d8cd, None), state
 */
  /*else*/ {
    __pyx_v_use_setstate = 0;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = False
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle___Pyx_EnumMeta, (type(self), 0xd41d8cd, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = False
 *     if use_setstate:
 *         return __pyx_unpickle___Pyx_EnumMeta, (type(self), 0xd41d8cd, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle___Pyx_EnumMeta, (type(self), 0xd41d8cd, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle___Pyx_EnumMeta); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_222419149);
    __Pyx_GIVEREF(__pyx_int_222419149);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_222419149);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = False
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle___Pyx_EnumMeta, (type(self), 0xd41d8cd, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle___Pyx_EnumMeta, (type(self), 0xd41d8cd, None), state
 *     else:
 *         return __pyx_unpickle___Pyx_EnumMeta, (type(self), 0xd41d8cd, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle___Pyx_EnumMeta__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle___Pyx_EnumMeta); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_222419149);
    __Pyx_GIVEREF(__pyx_int_222419149);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_222419149);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("EnumBase.__Pyx_EnumMeta.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle___Pyx_EnumMeta, (type(self), 0xd41d8cd, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle___Pyx_EnumMeta__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumMeta_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumMeta_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8EnumBase_14__Pyx_EnumMeta_8__setstate_cython__(((struct __pyx_obj___Pyx_EnumMeta *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumMeta_8__setstate_cython__(struct __pyx_obj___Pyx_EnumMeta *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle___Pyx_EnumMeta, (type(self), 0xd41d8cd, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle___Pyx_EnumMeta__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_unpickle___Pyx_EnumMeta__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle___Pyx_EnumMeta, (type(self), 0xd41d8cd, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle___Pyx_EnumMeta__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("EnumBase.__Pyx_EnumMeta.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "EnumBase":28
 * class __Pyx_EnumBase(int):
 *     __metaclass__ = __Pyx_EnumMeta
 *     def __new__(cls, value, name=None):             # <<<<<<<<<<<<<<
 *         for v in cls:
 *             if v == value:
 */

/* Python wrapper */
static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumBase_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_8EnumBase_14__Pyx_EnumBase_1__new__ = {"__new__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_8EnumBase_14__Pyx_EnumBase_1__new__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumBase_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_cls = 0;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_v_name = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__new__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,&__pyx_n_s_value,&__pyx_n_s_name_2,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__new__", 0, 2, 3, 1); __PYX_ERR(2, 28, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name_2);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__new__") < 0)) __PYX_ERR(2, 28, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_cls = values[0];
    __pyx_v_value = values[1];
    __pyx_v_name = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__new__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 28, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("EnumBase.__Pyx_EnumBase.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8EnumBase_14__Pyx_EnumBase___new__(__pyx_self, __pyx_v_cls, __pyx_v_value, __pyx_v_name);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumBase___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_value, PyObject *__pyx_v_name) {
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_v_res = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__new__", 0);

  /* "EnumBase":29
 *     __metaclass__ = __Pyx_EnumMeta
 *     def __new__(cls, value, name=None):
 *         for v in cls:             # <<<<<<<<<<<<<<
 *             if v == value:
 *                 return v
 */
  if (likely(PyList_CheckExact(__pyx_v_cls)) || PyTuple_CheckExact(__pyx_v_cls)) {
    __pyx_t_1 = __pyx_v_cls; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_cls); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 29, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 29, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 29, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 29, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 29, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 29, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(2, 29, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "EnumBase":30
 *     def __new__(cls, value, name=None):
 *         for v in cls:
 *             if v == value:             # <<<<<<<<<<<<<<
 *                 return v
 *         if name is None:
 */
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_v, __pyx_v_value, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 30, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 30, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_5) {

      /* "EnumBase":31
 *         for v in cls:
 *             if v == value:
 *                 return v             # <<<<<<<<<<<<<<
 *         if name is None:
 *             raise ValueError("Unknown enum value: '%s'" % value)
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_v);
      __pyx_r = __pyx_v_v;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;

      /* "EnumBase":30
 *     def __new__(cls, value, name=None):
 *         for v in cls:
 *             if v == value:             # <<<<<<<<<<<<<<
 *                 return v
 *         if name is None:
 */
    }

    /* "EnumBase":29
 *     __metaclass__ = __Pyx_EnumMeta
 *     def __new__(cls, value, name=None):
 *         for v in cls:             # <<<<<<<<<<<<<<
 *             if v == value:
 *                 return v
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "EnumBase":32
 *             if v == value:
 *                 return v
 *         if name is None:             # <<<<<<<<<<<<<<
 *             raise ValueError("Unknown enum value: '%s'" % value)
 *         res = int.__new__(cls, value)
 */
  __pyx_t_5 = (__pyx_v_name == Py_None);
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (unlikely(__pyx_t_6)) {

    /* "EnumBase":33
 *                 return v
 *         if name is None:
 *             raise ValueError("Unknown enum value: '%s'" % value)             # <<<<<<<<<<<<<<
 *         res = int.__new__(cls, value)
 *         res.name = name
 */
    __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Unknown_enum_value_s, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 33, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 33, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(2, 33, __pyx_L1_error)

    /* "EnumBase":32
 *             if v == value:
 *                 return v
 *         if name is None:             # <<<<<<<<<<<<<<
 *             raise ValueError("Unknown enum value: '%s'" % value)
 *         res = int.__new__(cls, value)
 */
  }

  /* "EnumBase":34
 *         if name is None:
 *             raise ValueError("Unknown enum value: '%s'" % value)
 *         res = int.__new__(cls, value)             # <<<<<<<<<<<<<<
 *         res.name = name
 *         setattr(cls, name, res)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyInt_Type)), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 34, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_cls, __pyx_v_value};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 34, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_cls, __pyx_v_value};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 34, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 34, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_INCREF(__pyx_v_cls);
    __Pyx_GIVEREF(__pyx_v_cls);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_cls);
    __Pyx_INCREF(__pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_value);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 34, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_res = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "EnumBase":35
 *             raise ValueError("Unknown enum value: '%s'" % value)
 *         res = int.__new__(cls, value)
 *         res.name = name             # <<<<<<<<<<<<<<
 *         setattr(cls, name, res)
 *         cls.__members__[name] = res
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_res, __pyx_n_s_name_2, __pyx_v_name) < 0) __PYX_ERR(2, 35, __pyx_L1_error)

  /* "EnumBase":36
 *         res = int.__new__(cls, value)
 *         res.name = name
 *         setattr(cls, name, res)             # <<<<<<<<<<<<<<
 *         cls.__members__[name] = res
 *         return res
 */
  __pyx_t_10 = PyObject_SetAttr(__pyx_v_cls, __pyx_v_name, __pyx_v_res); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(2, 36, __pyx_L1_error)

  /* "EnumBase":37
 *         res.name = name
 *         setattr(cls, name, res)
 *         cls.__members__[name] = res             # <<<<<<<<<<<<<<
 *         return res
 *     def __repr__(self):
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_cls, __pyx_n_s_members); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 37, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_v_name, __pyx_v_res) < 0)) __PYX_ERR(2, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "EnumBase":38
 *         setattr(cls, name, res)
 *         cls.__members__[name] = res
 *         return res             # <<<<<<<<<<<<<<
 *     def __repr__(self):
 *         return "<%s.%s: %d>" % (self.__class__.__name__, self.name, self)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_res);
  __pyx_r = __pyx_v_res;
  goto __pyx_L0;

  /* "EnumBase":28
 * class __Pyx_EnumBase(int):
 *     __metaclass__ = __Pyx_EnumMeta
 *     def __new__(cls, value, name=None):             # <<<<<<<<<<<<<<
 *         for v in cls:
 *             if v == value:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("EnumBase.__Pyx_EnumBase.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_res);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "EnumBase":39
 *         cls.__members__[name] = res
 *         return res
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<%s.%s: %d>" % (self.__class__.__name__, self.name, self)
 *     def __str__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumBase_3__repr__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_8EnumBase_14__Pyx_EnumBase_3__repr__ = {"__repr__", (PyCFunction)__pyx_pw_8EnumBase_14__Pyx_EnumBase_3__repr__, METH_O, 0};
static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumBase_3__repr__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8EnumBase_14__Pyx_EnumBase_2__repr__(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumBase_2__repr__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "EnumBase":40
 *         return res
 *     def __repr__(self):
 *         return "<%s.%s: %d>" % (self.__class__.__name__, self.name, self)             # <<<<<<<<<<<<<<
 *     def __str__(self):
 *         return "%s.%s" % (self.__class__.__name__, self.name)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_self);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_s_s_d, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "EnumBase":39
 *         cls.__members__[name] = res
 *         return res
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<%s.%s: %d>" % (self.__class__.__name__, self.name, self)
 *     def __str__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("EnumBase.__Pyx_EnumBase.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "EnumBase":41
 *     def __repr__(self):
 *         return "<%s.%s: %d>" % (self.__class__.__name__, self.name, self)
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s.%s" % (self.__class__.__name__, self.name)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumBase_5__str__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_8EnumBase_14__Pyx_EnumBase_5__str__ = {"__str__", (PyCFunction)__pyx_pw_8EnumBase_14__Pyx_EnumBase_5__str__, METH_O, 0};
static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumBase_5__str__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8EnumBase_14__Pyx_EnumBase_4__str__(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumBase_4__str__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "EnumBase":42
 *         return "<%s.%s: %d>" % (self.__class__.__name__, self.name, self)
 *     def __str__(self):
 *         return "%s.%s" % (self.__class__.__name__, self.name)             # <<<<<<<<<<<<<<
 * 
 * if PY_VERSION_HEX >= 0x03040000:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_s_s, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "EnumBase":41
 *     def __repr__(self):
 *         return "<%s.%s: %d>" % (self.__class__.__name__, self.name, self)
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s.%s" % (self.__class__.__name__, self.name)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("EnumBase.__Pyx_EnumBase.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle___Pyx_EnumMeta(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_8EnumBase_1__pyx_unpickle___Pyx_EnumMeta(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_8EnumBase_1__pyx_unpickle___Pyx_EnumMeta = {"__pyx_unpickle___Pyx_EnumMeta", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_8EnumBase_1__pyx_unpickle___Pyx_EnumMeta, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_8EnumBase_1__pyx_unpickle___Pyx_EnumMeta(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle___Pyx_EnumMeta (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle___Pyx_EnumMeta", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle___Pyx_EnumMeta", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle___Pyx_EnumMeta") < 0)) __PYX_ERR(2, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle___Pyx_EnumMeta", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("EnumBase.__pyx_unpickle___Pyx_EnumMeta", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8EnumBase___pyx_unpickle___Pyx_EnumMeta(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8EnumBase___pyx_unpickle___Pyx_EnumMeta(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle___Pyx_EnumMeta", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xd41d8cd:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xd41d8cd) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xd41d8cd:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 *     __pyx_result = __Pyx_EnumMeta.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0xd41d8cd:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = __Pyx_EnumMeta.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xd4, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xd41d8cd:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 *     __pyx_result = __Pyx_EnumMeta.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle___Pyx_EnumMeta__set_state(<__Pyx_EnumMeta> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype___Pyx_EnumMeta), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 *     __pyx_result = __Pyx_EnumMeta.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle___Pyx_EnumMeta__set_state(<__Pyx_EnumMeta> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = __Pyx_EnumMeta.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle___Pyx_EnumMeta__set_state(<__Pyx_EnumMeta> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle___Pyx_EnumMeta__set_state(__Pyx_EnumMeta __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_unpickle___Pyx_EnumMeta__set_state(((struct __pyx_obj___Pyx_EnumMeta *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
 *     __pyx_result = __Pyx_EnumMeta.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle___Pyx_EnumMeta__set_state(<__Pyx_EnumMeta> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle___Pyx_EnumMeta__set_state(<__Pyx_EnumMeta> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle___Pyx_EnumMeta__set_state(__Pyx_EnumMeta __pyx_result, tuple __pyx_state):
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle___Pyx_EnumMeta(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("EnumBase.__pyx_unpickle___Pyx_EnumMeta", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle___Pyx_EnumMeta__set_state(<__Pyx_EnumMeta> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle___Pyx_EnumMeta__set_state(__Pyx_EnumMeta __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[0])
 */

static PyObject *__pyx_unpickle___Pyx_EnumMeta__set_state(struct __pyx_obj___Pyx_EnumMeta *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle___Pyx_EnumMeta__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle___Pyx_EnumMeta__set_state(__Pyx_EnumMeta __pyx_result, tuple __pyx_state):
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[0])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(2, 12, __pyx_L1_error)
  __pyx_t_3 = ((__pyx_t_2 > 0) != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(2, 12, __pyx_L1_error)
  __pyx_t_4 = (__pyx_t_3 != 0);
  __pyx_t_1 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "(tree fragment)":13
 * cdef __pyx_unpickle___Pyx_EnumMeta__set_state(__Pyx_EnumMeta __pyx_result, tuple __pyx_state):
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[0])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 13, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle___Pyx_EnumMeta__set_state(__Pyx_EnumMeta __pyx_result, tuple __pyx_state):
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[0])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle___Pyx_EnumMeta__set_state(<__Pyx_EnumMeta> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle___Pyx_EnumMeta__set_state(__Pyx_EnumMeta __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[0])
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("EnumBase.__pyx_unpickle___Pyx_EnumMeta__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_LRUMapping __pyx_vtable_6edgedb_8protocol_8protocol_LRUMapping;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_LRUMapping(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)o);
  p->__pyx_vtab = __pyx_vtabptr_6edgedb_8protocol_8protocol_LRUMapping;
  p->_dict = Py_None; Py_INCREF(Py_None);
  p->_dict_move_to_end = Py_None; Py_INCREF(Py_None);
  p->_dict_get = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol_LRUMapping(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->_dict);
  Py_CLEAR(p->_dict_move_to_end);
  Py_CLEAR(p->_dict_get);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol_LRUMapping(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)o;
  if (p->_dict) {
    e = (*v)(p->_dict, a); if (e) return e;
  }
  if (p->_dict_move_to_end) {
    e = (*v)(p->_dict_move_to_end, a); if (e) return e;
  }
  if (p->_dict_get) {
    e = (*v)(p->_dict_get, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6edgedb_8protocol_8protocol_LRUMapping(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)o;
  tmp = ((PyObject*)p->_dict);
  p->_dict = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_dict_move_to_end);
  p->_dict_move_to_end = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_dict_get);
  p->_dict_get = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_6edgedb_8protocol_8protocol_LRUMapping(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_6edgedb_8protocol_8protocol_LRUMapping(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_5__setitem__(o, i, v);
  }
  else {
    return __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_7__delitem__(o, i);
  }
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_LRUMapping[] = {
  {"clear", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_15clear, METH_NOARGS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_17__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_19__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PySequenceMethods __pyx_tp_as_sequence_LRUMapping = {
  __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_11__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_6edgedb_8protocol_8protocol_LRUMapping, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_9__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_LRUMapping = {
  __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_11__len__, /*mp_length*/
  __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_3__getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_6edgedb_8protocol_8protocol_LRUMapping, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_LRUMapping = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.LRUMapping", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_LRUMapping, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  &__pyx_tp_as_sequence_LRUMapping, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_LRUMapping, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_LRUMapping, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_LRUMapping, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_13__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_LRUMapping, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_6edgedb_8protocol_8protocol_10LRUMapping_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_LRUMapping, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec __pyx_vtable_6edgedb_8protocol_8protocol_BaseCodec;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_BaseCodec(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)o);
  p->__pyx_vtab = __pyx_vtabptr_6edgedb_8protocol_8protocol_BaseCodec;
  p->tid = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->name = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_3__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseCodec(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  Py_CLEAR(p->tid);
  Py_CLEAR(p->name);
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_BaseCodec[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_5__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_7__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_BaseCodec = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.BaseCodec", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseCodec, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_BaseCodec, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_BaseCodec, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecPythonOverride __pyx_vtable_6edgedb_8protocol_8protocol_CodecPythonOverride;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_CodecPythonOverride(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *p;
  PyObject *o = __pyx_tp_new_6edgedb_8protocol_8protocol_BaseCodec(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec*)__pyx_vtabptr_6edgedb_8protocol_8protocol_CodecPythonOverride;
  p->codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)Py_None); Py_INCREF(Py_None);
  p->encoder = Py_None; Py_INCREF(Py_None);
  p->decoder = Py_None; Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_6edgedb_8protocol_8protocol_19CodecPythonOverride_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol_CodecPythonOverride(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->codec);
  Py_CLEAR(p->encoder);
  Py_CLEAR(p->decoder);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseCodec(o);
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol_CodecPythonOverride(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *)o;
  e = ((likely(__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec)) ? ((__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_traverse) ? __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6edgedb_8protocol_8protocol_CodecPythonOverride)); if (e) return e;
  if (p->codec) {
    e = (*v)(((PyObject *)p->codec), a); if (e) return e;
  }
  if (p->encoder) {
    e = (*v)(p->encoder, a); if (e) return e;
  }
  if (p->decoder) {
    e = (*v)(p->decoder, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6edgedb_8protocol_8protocol_CodecPythonOverride(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride *)o;
  if (likely(__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec)) { if (__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_clear) __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6edgedb_8protocol_8protocol_CodecPythonOverride);
  tmp = ((PyObject*)p->codec);
  p->codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->encoder);
  p->encoder = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->decoder);
  p->decoder = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_CodecPythonOverride[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_19CodecPythonOverride_3__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_19CodecPythonOverride_5__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_CodecPythonOverride = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.CodecPythonOverride", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecPythonOverride), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_CodecPythonOverride, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_CodecPythonOverride, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_CodecPythonOverride, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_CodecPythonOverride, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_CodecPythonOverride, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseRecordCodec __pyx_vtable_6edgedb_8protocol_8protocol_BaseRecordCodec;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_BaseRecordCodec(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *p;
  PyObject *o = __pyx_tp_new_6edgedb_8protocol_8protocol_BaseCodec(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec*)__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseRecordCodec;
  p->fields_codecs = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_6edgedb_8protocol_8protocol_15BaseRecordCodec_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseRecordCodec(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->fields_codecs);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseCodec(o);
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol_BaseRecordCodec(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *)o;
  e = ((likely(__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec)) ? ((__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_traverse) ? __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6edgedb_8protocol_8protocol_BaseRecordCodec)); if (e) return e;
  if (p->fields_codecs) {
    e = (*v)(p->fields_codecs, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6edgedb_8protocol_8protocol_BaseRecordCodec(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *)o;
  if (likely(__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec)) { if (__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_clear) __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6edgedb_8protocol_8protocol_BaseRecordCodec);
  tmp = ((PyObject*)p->fields_codecs);
  p->fields_codecs = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_BaseRecordCodec[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_15BaseRecordCodec_3__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_15BaseRecordCodec_5__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_BaseRecordCodec = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.BaseRecordCodec", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseRecordCodec, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_BaseRecordCodec, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_BaseRecordCodec, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_BaseRecordCodec, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_BaseRecordCodec, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_EmptyTupleCodec __pyx_vtable_6edgedb_8protocol_8protocol_EmptyTupleCodec;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_EmptyTupleCodec(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *p;
  PyObject *o = __pyx_tp_new_6edgedb_8protocol_8protocol_BaseCodec(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec*)__pyx_vtabptr_6edgedb_8protocol_8protocol_EmptyTupleCodec;
  p->empty_tup = Py_None; Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_6edgedb_8protocol_8protocol_15EmptyTupleCodec_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol_EmptyTupleCodec(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->empty_tup);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseCodec(o);
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol_EmptyTupleCodec(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *)o;
  e = ((likely(__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec)) ? ((__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_traverse) ? __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6edgedb_8protocol_8protocol_EmptyTupleCodec)); if (e) return e;
  if (p->empty_tup) {
    e = (*v)(p->empty_tup, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6edgedb_8protocol_8protocol_EmptyTupleCodec(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec *)o;
  if (likely(__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec)) { if (__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_clear) __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6edgedb_8protocol_8protocol_EmptyTupleCodec);
  tmp = ((PyObject*)p->empty_tup);
  p->empty_tup = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_EmptyTupleCodec[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_15EmptyTupleCodec_3__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_15EmptyTupleCodec_5__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_EmptyTupleCodec = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.EmptyTupleCodec", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_EmptyTupleCodec), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_EmptyTupleCodec, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_EmptyTupleCodec, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_EmptyTupleCodec, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_EmptyTupleCodec, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_EmptyTupleCodec, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_NullCodec __pyx_vtable_6edgedb_8protocol_8protocol_NullCodec;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_NullCodec(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_NullCodec *p;
  PyObject *o = __pyx_tp_new_6edgedb_8protocol_8protocol_BaseCodec(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_NullCodec *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec*)__pyx_vtabptr_6edgedb_8protocol_8protocol_NullCodec;
  if (unlikely(__pyx_pw_6edgedb_8protocol_8protocol_9NullCodec_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_NullCodec[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_9NullCodec_3__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_9NullCodec_5__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_NullCodec = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.NullCodec", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_NullCodec), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseCodec, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_NullCodec, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_NullCodec, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseNamedRecordCodec __pyx_vtable_6edgedb_8protocol_8protocol_BaseNamedRecordCodec;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_BaseNamedRecordCodec(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *p;
  PyObject *o = __pyx_tp_new_6edgedb_8protocol_8protocol_BaseRecordCodec(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec*)__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseNamedRecordCodec;
  p->descriptor = Py_None; Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseNamedRecordCodec(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->descriptor);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseRecordCodec(o);
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol_BaseNamedRecordCodec(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *)o;
  e = __pyx_tp_traverse_6edgedb_8protocol_8protocol_BaseRecordCodec(o, v, a); if (e) return e;
  if (p->descriptor) {
    e = (*v)(p->descriptor, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6edgedb_8protocol_8protocol_BaseNamedRecordCodec(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec *)o;
  __pyx_tp_clear_6edgedb_8protocol_8protocol_BaseRecordCodec(o);
  tmp = ((PyObject*)p->descriptor);
  p->descriptor = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_BaseNamedRecordCodec[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_3__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_5__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_BaseNamedRecordCodec = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.BaseNamedRecordCodec", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseNamedRecordCodec), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseNamedRecordCodec, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_BaseNamedRecordCodec, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_BaseNamedRecordCodec, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_BaseNamedRecordCodec, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_BaseNamedRecordCodec, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_EdegDBCodecContext __pyx_vtable_6edgedb_8protocol_8protocol_EdegDBCodecContext;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_EdegDBCodecContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *p;
  PyObject *o = __pyx_ptype_6edgedb_7pgproto_7pgproto_CodecContext->tp_new(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_CodecContext*)__pyx_vtabptr_6edgedb_8protocol_8protocol_EdegDBCodecContext;
  p->_codec = Py_None; Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_6edgedb_8protocol_8protocol_18EdegDBCodecContext_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol_EdegDBCodecContext(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->_codec);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  if (likely(__pyx_ptype_6edgedb_7pgproto_7pgproto_CodecContext)) __pyx_ptype_6edgedb_7pgproto_7pgproto_CodecContext->tp_dealloc(o); else __Pyx_call_next_tp_dealloc(o, __pyx_tp_dealloc_6edgedb_8protocol_8protocol_EdegDBCodecContext);
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol_EdegDBCodecContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *)o;
  e = ((likely(__pyx_ptype_6edgedb_7pgproto_7pgproto_CodecContext)) ? ((__pyx_ptype_6edgedb_7pgproto_7pgproto_CodecContext->tp_traverse) ? __pyx_ptype_6edgedb_7pgproto_7pgproto_CodecContext->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6edgedb_8protocol_8protocol_EdegDBCodecContext)); if (e) return e;
  if (p->_codec) {
    e = (*v)(p->_codec, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6edgedb_8protocol_8protocol_EdegDBCodecContext(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *)o;
  if (likely(__pyx_ptype_6edgedb_7pgproto_7pgproto_CodecContext)) { if (__pyx_ptype_6edgedb_7pgproto_7pgproto_CodecContext->tp_clear) __pyx_ptype_6edgedb_7pgproto_7pgproto_CodecContext->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6edgedb_8protocol_8protocol_EdegDBCodecContext);
  tmp = ((PyObject*)p->_codec);
  p->_codec = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_EdegDBCodecContext[] = {
  {"get_text_codec", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_18EdegDBCodecContext_3get_text_codec, METH_NOARGS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_18EdegDBCodecContext_5__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_18EdegDBCodecContext_7__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_EdegDBCodecContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.EdegDBCodecContext", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_EdegDBCodecContext, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_EdegDBCodecContext, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_EdegDBCodecContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_EdegDBCodecContext, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_EdegDBCodecContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_ScalarCodec __pyx_vtable_6edgedb_8protocol_8protocol_ScalarCodec;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_ScalarCodec(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *p;
  PyObject *o = __pyx_tp_new_6edgedb_8protocol_8protocol_BaseCodec(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec*)__pyx_vtabptr_6edgedb_8protocol_8protocol_ScalarCodec;
  if (unlikely(__pyx_pw_6edgedb_8protocol_8protocol_11ScalarCodec_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_ScalarCodec[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_11ScalarCodec_3__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_11ScalarCodec_5__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_ScalarCodec = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.ScalarCodec", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseCodec, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_ScalarCodec, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_ScalarCodec, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_TupleCodec __pyx_vtable_6edgedb_8protocol_8protocol_TupleCodec;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_TupleCodec(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec *p;
  PyObject *o = __pyx_tp_new_6edgedb_8protocol_8protocol_BaseRecordCodec(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec*)__pyx_vtabptr_6edgedb_8protocol_8protocol_TupleCodec;
  return o;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_TupleCodec[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_10TupleCodec_1__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_10TupleCodec_3__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_TupleCodec = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.TupleCodec", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_TupleCodec), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseRecordCodec, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_BaseRecordCodec, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_BaseRecordCodec, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_TupleCodec, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_TupleCodec, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_NamedTupleCodec __pyx_vtable_6edgedb_8protocol_8protocol_NamedTupleCodec;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_NamedTupleCodec(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *p;
  PyObject *o = __pyx_tp_new_6edgedb_8protocol_8protocol_BaseNamedRecordCodec(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *)o);
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec*)__pyx_vtabptr_6edgedb_8protocol_8protocol_NamedTupleCodec;
  return o;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_NamedTupleCodec[] = {
  {"_make_missing_args_error_message", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_15NamedTupleCodec_1_make_missing_args_error_message, METH_O, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_15NamedTupleCodec_3__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_15NamedTupleCodec_5__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_NamedTupleCodec = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.NamedTupleCodec", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseNamedRecordCodec, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_BaseNamedRecordCodec, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_BaseNamedRecordCodec, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_NamedTupleCodec, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_NamedTupleCodec, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_ObjectCodec __pyx_vtable_6edgedb_8protocol_8protocol_ObjectCodec;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_ObjectCodec(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *p;
  PyObject *o = __pyx_tp_new_6edgedb_8protocol_8protocol_BaseNamedRecordCodec(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *)o);
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec*)__pyx_vtabptr_6edgedb_8protocol_8protocol_ObjectCodec;
  return o;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_ObjectCodec[] = {
  {"_make_missing_args_error_message", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_11ObjectCodec_1_make_missing_args_error_message, METH_O, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_11ObjectCodec_3__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_11ObjectCodec_5__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_ObjectCodec = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.ObjectCodec", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseNamedRecordCodec, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_BaseNamedRecordCodec, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_BaseNamedRecordCodec, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_ObjectCodec, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_ObjectCodec, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseArrayCodec __pyx_vtable_6edgedb_8protocol_8protocol_BaseArrayCodec;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_BaseArrayCodec(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *p;
  PyObject *o = __pyx_tp_new_6edgedb_8protocol_8protocol_BaseCodec(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec*)__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseArrayCodec;
  p->sub_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_6edgedb_8protocol_8protocol_14BaseArrayCodec_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseArrayCodec(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->sub_codec);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseCodec(o);
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol_BaseArrayCodec(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *)o;
  e = ((likely(__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec)) ? ((__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_traverse) ? __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6edgedb_8protocol_8protocol_BaseArrayCodec)); if (e) return e;
  if (p->sub_codec) {
    e = (*v)(((PyObject *)p->sub_codec), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6edgedb_8protocol_8protocol_BaseArrayCodec(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *)o;
  if (likely(__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec)) { if (__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_clear) __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6edgedb_8protocol_8protocol_BaseArrayCodec);
  tmp = ((PyObject*)p->sub_codec);
  p->sub_codec = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_BaseArrayCodec[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14BaseArrayCodec_3__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14BaseArrayCodec_5__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_BaseArrayCodec = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.BaseArrayCodec", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseArrayCodec, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_BaseArrayCodec, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_BaseArrayCodec, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_BaseArrayCodec, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_BaseArrayCodec, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_ArrayCodec __pyx_vtable_6edgedb_8protocol_8protocol_ArrayCodec;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_ArrayCodec(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec *p;
  PyObject *o = __pyx_tp_new_6edgedb_8protocol_8protocol_BaseArrayCodec(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec*)__pyx_vtabptr_6edgedb_8protocol_8protocol_ArrayCodec;
  return o;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_ArrayCodec[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_10ArrayCodec_1__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_10ArrayCodec_3__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_ArrayCodec = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.ArrayCodec", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_ArrayCodec), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseArrayCodec, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_BaseArrayCodec, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_BaseArrayCodec, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_ArrayCodec, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_ArrayCodec, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SetCodec __pyx_vtable_6edgedb_8protocol_8protocol_SetCodec;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_SetCodec(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *p;
  PyObject *o = __pyx_tp_new_6edgedb_8protocol_8protocol_BaseArrayCodec(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec*)__pyx_vtabptr_6edgedb_8protocol_8protocol_SetCodec;
  return o;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_SetCodec[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_8SetCodec_1__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_8SetCodec_3__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_SetCodec = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.SetCodec", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseArrayCodec, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_BaseArrayCodec, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_BaseArrayCodec, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_SetCodec, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_SetCodec, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_EnumCodec __pyx_vtable_6edgedb_8protocol_8protocol_EnumCodec;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_EnumCodec(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *p;
  PyObject *o = __pyx_tp_new_6edgedb_8protocol_8protocol_BaseCodec(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_BaseCodec*)__pyx_vtabptr_6edgedb_8protocol_8protocol_EnumCodec;
  p->descriptor = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol_EnumCodec(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->descriptor);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_BaseCodec(o);
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol_EnumCodec(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *)o;
  e = ((likely(__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec)) ? ((__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_traverse) ? __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6edgedb_8protocol_8protocol_EnumCodec)); if (e) return e;
  if (p->descriptor) {
    e = (*v)(p->descriptor, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6edgedb_8protocol_8protocol_EnumCodec(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec *)o;
  if (likely(__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec)) { if (__pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_clear) __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6edgedb_8protocol_8protocol_EnumCodec);
  tmp = ((PyObject*)p->descriptor);
  p->descriptor = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_EnumCodec[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_9EnumCodec_1__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_9EnumCodec_3__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_EnumCodec = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.EnumCodec", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_EnumCodec), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_EnumCodec, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_EnumCodec, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_EnumCodec, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_EnumCodec, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_6edgedb_8protocol_8protocol_9BaseCodec_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_EnumCodec, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_CodecsRegistry __pyx_vtable_6edgedb_8protocol_8protocol_CodecsRegistry;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_CodecsRegistry(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)o);
  p->__pyx_vtab = __pyx_vtabptr_6edgedb_8protocol_8protocol_CodecsRegistry;
  p->codecs_build_cache = ((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)Py_None); Py_INCREF(Py_None);
  p->codecs = ((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)Py_None); Py_INCREF(Py_None);
  p->base_codec_overrides = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol_CodecsRegistry(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->codecs_build_cache);
  Py_CLEAR(p->codecs);
  Py_CLEAR(p->base_codec_overrides);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol_CodecsRegistry(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)o;
  if (p->codecs_build_cache) {
    e = (*v)(((PyObject *)p->codecs_build_cache), a); if (e) return e;
  }
  if (p->codecs) {
    e = (*v)(((PyObject *)p->codecs), a); if (e) return e;
  }
  if (p->base_codec_overrides) {
    e = (*v)(p->base_codec_overrides, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6edgedb_8protocol_8protocol_CodecsRegistry(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)o;
  tmp = ((PyObject*)p->codecs_build_cache);
  p->codecs_build_cache = ((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->codecs);
  p->codecs = ((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->base_codec_overrides);
  p->base_codec_overrides = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_CodecsRegistry[] = {
  {"clear_cache", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14CodecsRegistry_3clear_cache, METH_NOARGS, 0},
  {"set_type_codec", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6edgedb_8protocol_8protocol_14CodecsRegistry_5set_type_codec, METH_VARARGS|METH_KEYWORDS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14CodecsRegistry_7__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14CodecsRegistry_9__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_CodecsRegistry = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.CodecsRegistry", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_CodecsRegistry, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_CodecsRegistry, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_CodecsRegistry, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_CodecsRegistry, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_6edgedb_8protocol_8protocol_14CodecsRegistry_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_CodecsRegistry, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_QueryCodecsCache __pyx_vtable_6edgedb_8protocol_8protocol_QueryCodecsCache;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_QueryCodecsCache(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *)o);
  p->__pyx_vtab = __pyx_vtabptr_6edgedb_8protocol_8protocol_QueryCodecsCache;
  p->queries = ((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol_QueryCodecsCache(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->queries);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol_QueryCodecsCache(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *)o;
  if (p->queries) {
    e = (*v)(((PyObject *)p->queries), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6edgedb_8protocol_8protocol_QueryCodecsCache(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *)o;
  tmp = ((PyObject*)p->queries);
  p->queries = ((struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_QueryCodecsCache[] = {
  {"get", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6edgedb_8protocol_8protocol_16QueryCodecsCache_3get, METH_VARARGS|METH_KEYWORDS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_16QueryCodecsCache_5__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_16QueryCodecsCache_7__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_QueryCodecsCache = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.QueryCodecsCache", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_QueryCodecsCache, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_QueryCodecsCache, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_QueryCodecsCache, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_QueryCodecsCache, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_6edgedb_8protocol_8protocol_16QueryCodecsCache_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_QueryCodecsCache, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};
static struct __pyx_vtabstruct_6edgedb_8protocol_8protocol_SansIOProtocol __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol_SansIOProtocol(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)o);
  p->__pyx_vtab = __pyx_vtabptr_6edgedb_8protocol_8protocol_SansIOProtocol;
  p->buffer = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *)Py_None); Py_INCREF(Py_None);
  p->con = Py_None; Py_INCREF(Py_None);
  p->con_params = Py_None; Py_INCREF(Py_None);
  p->backend_secret = Py_None; Py_INCREF(Py_None);
  p->internal_reg = ((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)Py_None); Py_INCREF(Py_None);
  p->server_settings = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->last_status = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->last_details = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->protocol_version = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol_SansIOProtocol(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->buffer);
  Py_CLEAR(p->con);
  Py_CLEAR(p->con_params);
  Py_CLEAR(p->backend_secret);
  Py_CLEAR(p->internal_reg);
  Py_CLEAR(p->server_settings);
  Py_CLEAR(p->last_status);
  Py_CLEAR(p->last_details);
  Py_CLEAR(p->protocol_version);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol_SansIOProtocol(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)o;
  if (p->buffer) {
    e = (*v)(((PyObject *)p->buffer), a); if (e) return e;
  }
  if (p->con) {
    e = (*v)(p->con, a); if (e) return e;
  }
  if (p->con_params) {
    e = (*v)(p->con_params, a); if (e) return e;
  }
  if (p->backend_secret) {
    e = (*v)(p->backend_secret, a); if (e) return e;
  }
  if (p->internal_reg) {
    e = (*v)(((PyObject *)p->internal_reg), a); if (e) return e;
  }
  if (p->server_settings) {
    e = (*v)(p->server_settings, a); if (e) return e;
  }
  if (p->protocol_version) {
    e = (*v)(p->protocol_version, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6edgedb_8protocol_8protocol_SansIOProtocol(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *p = (struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *)o;
  tmp = ((PyObject*)p->buffer);
  p->buffer = ((struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->con);
  p->con = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->con_params);
  p->con_params = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->backend_secret);
  p->backend_secret = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->internal_reg);
  p->internal_reg = ((struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->server_settings);
  p->server_settings = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->protocol_version);
  p->protocol_version = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6edgedb_8protocol_8protocol_14SansIOProtocol_connected(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_9connected_1__get__(o);
}

static PyObject *__pyx_getprop_6edgedb_8protocol_8protocol_14SansIOProtocol_cancelled(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_9cancelled_1__get__(o);
}

static PyObject *__pyx_getprop_6edgedb_8protocol_8protocol_14SansIOProtocol_con_params(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_10con_params_1__get__(o);
}

static PyObject *__pyx_getprop_6edgedb_8protocol_8protocol_14SansIOProtocol_tls_compat(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_10tls_compat_1__get__(o);
}

static PyObject *__pyx_getprop_6edgedb_8protocol_8protocol_14SansIOProtocol_last_status(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_11last_status_1__get__(o);
}

static PyObject *__pyx_getprop_6edgedb_8protocol_8protocol_14SansIOProtocol_last_details(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_12last_details_1__get__(o);
}

static PyObject *__pyx_getprop_6edgedb_8protocol_8protocol_14SansIOProtocol_protocol_version(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_16protocol_version_1__get__(o);
}

static PyMethodDef __pyx_methods_6edgedb_8protocol_8protocol_SansIOProtocol[] = {
  {"get_settings", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_3get_settings, METH_NOARGS, 0},
  {"is_in_transaction", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_5is_in_transaction, METH_NOARGS, 0},
  {"set_connection", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_7set_connection, METH_O, 0},
  {"abort", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_9abort, METH_NOARGS, 0},
  {"wait_for_message", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_11wait_for_message, METH_NOARGS, 0},
  {"try_recv_eagerly", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_14try_recv_eagerly, METH_NOARGS, 0},
  {"wait_for_connect", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_17wait_for_connect, METH_NOARGS, 0},
  {"_parse", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_20_parse, METH_VARARGS|METH_KEYWORDS, 0},
  {"_execute", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_23_execute, METH_VARARGS|METH_KEYWORDS, 0},
  {"_optimistic_execute", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_26_optimistic_execute, METH_VARARGS|METH_KEYWORDS, 0},
  {"simple_query", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_29simple_query, METH_VARARGS|METH_KEYWORDS, 0},
  {"execute_anonymous", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_32execute_anonymous, METH_VARARGS|METH_KEYWORDS, 0},
  {"dump", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_35dump, METH_VARARGS|METH_KEYWORDS, 0},
  {"_sync", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_38_sync, METH_NOARGS, 0},
  {"restore", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_41restore, METH_VARARGS|METH_KEYWORDS, 0},
  {"terminate", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_44terminate, METH_NOARGS, 0},
  {"connect", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_46connect, METH_NOARGS, 0},
  {"_auth_sasl", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_49_auth_sasl, METH_NOARGS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_52__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_54__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6edgedb_8protocol_8protocol_SansIOProtocol[] = {
  {(char *)"connected", __pyx_getprop_6edgedb_8protocol_8protocol_14SansIOProtocol_connected, 0, (char *)0, 0},
  {(char *)"cancelled", __pyx_getprop_6edgedb_8protocol_8protocol_14SansIOProtocol_cancelled, 0, (char *)0, 0},
  {(char *)"con_params", __pyx_getprop_6edgedb_8protocol_8protocol_14SansIOProtocol_con_params, 0, (char *)0, 0},
  {(char *)"tls_compat", __pyx_getprop_6edgedb_8protocol_8protocol_14SansIOProtocol_tls_compat, 0, (char *)0, 0},
  {(char *)"last_status", __pyx_getprop_6edgedb_8protocol_8protocol_14SansIOProtocol_last_status, 0, (char *)0, 0},
  {(char *)"last_details", __pyx_getprop_6edgedb_8protocol_8protocol_14SansIOProtocol_last_details, 0, (char *)0, 0},
  {(char *)"protocol_version", __pyx_getprop_6edgedb_8protocol_8protocol_14SansIOProtocol_protocol_version, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol_SansIOProtocol = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.SansIOProtocol", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol_SansIOProtocol, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol_SansIOProtocol, /*tp_traverse*/
  __pyx_tp_clear_6edgedb_8protocol_8protocol_SansIOProtocol, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6edgedb_8protocol_8protocol_SansIOProtocol, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6edgedb_8protocol_8protocol_SansIOProtocol, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_6edgedb_8protocol_8protocol_14SansIOProtocol_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol_SansIOProtocol, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message *__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message[8];
static int __pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message = 0;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message)))) {
    o = (PyObject*)__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message[--__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message];
    memset(o, 0, sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message)))) {
    __pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message[__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message++] = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.__pyx_scope_struct__wait_for_message", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly *__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly[8];
static int __pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly = 0;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly)))) {
    o = (PyObject*)__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly[--__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly];
    memset(o, 0, sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly)))) {
    __pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly[__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly++] = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.__pyx_scope_struct_1_try_recv_eagerly", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect *__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect[8];
static int __pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect = 0;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect)))) {
    o = (PyObject*)__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect[--__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect];
    memset(o, 0, sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect)))) {
    __pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect[__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect++] = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.__pyx_scope_struct_2_wait_for_connect", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse *__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse[8];
static int __pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse = 0;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse)))) {
    o = (PyObject*)__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse[--__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse];
    memset(o, 0, sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v__);
  Py_CLEAR(p->__pyx_v_allow_capabilities);
  Py_CLEAR(p->__pyx_v_attrs);
  Py_CLEAR(p->__pyx_v_buf);
  Py_CLEAR(p->__pyx_v_cardinality);
  Py_CLEAR(p->__pyx_v_exc);
  Py_CLEAR(p->__pyx_v_implicit_limit);
  Py_CLEAR(p->__pyx_v_in_dc);
  Py_CLEAR(p->__pyx_v_in_type_id);
  Py_CLEAR(p->__pyx_v_inline_typeids);
  Py_CLEAR(p->__pyx_v_inline_typenames);
  Py_CLEAR(p->__pyx_v_methname);
  Py_CLEAR(p->__pyx_v_out_dc);
  Py_CLEAR(p->__pyx_v_out_type_id);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_reg);
  Py_CLEAR(p->__pyx_v_required_one);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse)))) {
    __pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse[__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse++] = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse *)o;
  if (p->__pyx_v__) {
    e = (*v)(p->__pyx_v__, a); if (e) return e;
  }
  if (p->__pyx_v_allow_capabilities) {
    e = (*v)(p->__pyx_v_allow_capabilities, a); if (e) return e;
  }
  if (p->__pyx_v_attrs) {
    e = (*v)(p->__pyx_v_attrs, a); if (e) return e;
  }
  if (p->__pyx_v_buf) {
    e = (*v)(((PyObject *)p->__pyx_v_buf), a); if (e) return e;
  }
  if (p->__pyx_v_exc) {
    e = (*v)(p->__pyx_v_exc, a); if (e) return e;
  }
  if (p->__pyx_v_implicit_limit) {
    e = (*v)(p->__pyx_v_implicit_limit, a); if (e) return e;
  }
  if (p->__pyx_v_in_dc) {
    e = (*v)(((PyObject *)p->__pyx_v_in_dc), a); if (e) return e;
  }
  if (p->__pyx_v_inline_typeids) {
    e = (*v)(p->__pyx_v_inline_typeids, a); if (e) return e;
  }
  if (p->__pyx_v_inline_typenames) {
    e = (*v)(p->__pyx_v_inline_typenames, a); if (e) return e;
  }
  if (p->__pyx_v_methname) {
    e = (*v)(p->__pyx_v_methname, a); if (e) return e;
  }
  if (p->__pyx_v_out_dc) {
    e = (*v)(((PyObject *)p->__pyx_v_out_dc), a); if (e) return e;
  }
  if (p->__pyx_v_reg) {
    e = (*v)(((PyObject *)p->__pyx_v_reg), a); if (e) return e;
  }
  if (p->__pyx_v_required_one) {
    e = (*v)(p->__pyx_v_required_one, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.__pyx_scope_struct_3__parse", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute *__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute[8];
static int __pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute = 0;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute)))) {
    o = (PyObject*)__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute[--__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute];
    memset(o, 0, sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_args);
  Py_CLEAR(p->__pyx_v_attrs);
  Py_CLEAR(p->__pyx_v_buf);
  Py_CLEAR(p->__pyx_v_ex);
  Py_CLEAR(p->__pyx_v_exc);
  Py_CLEAR(p->__pyx_v_in_dc);
  Py_CLEAR(p->__pyx_v_kwargs);
  Py_CLEAR(p->__pyx_v_out_dc);
  Py_CLEAR(p->__pyx_v_packet);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute)))) {
    __pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute[__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute++] = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute *)o;
  if (p->__pyx_v_args) {
    e = (*v)(p->__pyx_v_args, a); if (e) return e;
  }
  if (p->__pyx_v_attrs) {
    e = (*v)(p->__pyx_v_attrs, a); if (e) return e;
  }
  if (p->__pyx_v_buf) {
    e = (*v)(((PyObject *)p->__pyx_v_buf), a); if (e) return e;
  }
  if (p->__pyx_v_ex) {
    e = (*v)(p->__pyx_v_ex, a); if (e) return e;
  }
  if (p->__pyx_v_exc) {
    e = (*v)(p->__pyx_v_exc, a); if (e) return e;
  }
  if (p->__pyx_v_in_dc) {
    e = (*v)(((PyObject *)p->__pyx_v_in_dc), a); if (e) return e;
  }
  if (p->__pyx_v_kwargs) {
    e = (*v)(p->__pyx_v_kwargs, a); if (e) return e;
  }
  if (p->__pyx_v_out_dc) {
    e = (*v)(((PyObject *)p->__pyx_v_out_dc), a); if (e) return e;
  }
  if (p->__pyx_v_packet) {
    e = (*v)(((PyObject *)p->__pyx_v_packet), a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.__pyx_scope_struct_4__execute", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute *__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute[8];
static int __pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute = 0;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute)))) {
    o = (PyObject*)__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute[--__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute];
    memset(o, 0, sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_allow_capabilities);
  Py_CLEAR(p->__pyx_v_args);
  Py_CLEAR(p->__pyx_v_attrs);
  Py_CLEAR(p->__pyx_v_buf);
  Py_CLEAR(p->__pyx_v_capabilities);
  Py_CLEAR(p->__pyx_v_ex);
  Py_CLEAR(p->__pyx_v_exc);
  Py_CLEAR(p->__pyx_v_headers);
  Py_CLEAR(p->__pyx_v_implicit_limit);
  Py_CLEAR(p->__pyx_v_in_dc);
  Py_CLEAR(p->__pyx_v_io_format);
  Py_CLEAR(p->__pyx_v_kwargs);
  Py_CLEAR(p->__pyx_v_methname);
  Py_CLEAR(p->__pyx_v_new_cardinality);
  Py_CLEAR(p->__pyx_v_out_dc);
  Py_CLEAR(p->__pyx_v_packet);
  Py_CLEAR(p->__pyx_v_qc);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_reg);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute)))) {
    __pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute[__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute++] = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute *)o;
  if (p->__pyx_v_allow_capabilities) {
    e = (*v)(p->__pyx_v_allow_capabilities, a); if (e) return e;
  }
  if (p->__pyx_v_args) {
    e = (*v)(p->__pyx_v_args, a); if (e) return e;
  }
  if (p->__pyx_v_attrs) {
    e = (*v)(p->__pyx_v_attrs, a); if (e) return e;
  }
  if (p->__pyx_v_buf) {
    e = (*v)(((PyObject *)p->__pyx_v_buf), a); if (e) return e;
  }
  if (p->__pyx_v_capabilities) {
    e = (*v)(p->__pyx_v_capabilities, a); if (e) return e;
  }
  if (p->__pyx_v_ex) {
    e = (*v)(p->__pyx_v_ex, a); if (e) return e;
  }
  if (p->__pyx_v_exc) {
    e = (*v)(p->__pyx_v_exc, a); if (e) return e;
  }
  if (p->__pyx_v_headers) {
    e = (*v)(p->__pyx_v_headers, a); if (e) return e;
  }
  if (p->__pyx_v_implicit_limit) {
    e = (*v)(p->__pyx_v_implicit_limit, a); if (e) return e;
  }
  if (p->__pyx_v_in_dc) {
    e = (*v)(((PyObject *)p->__pyx_v_in_dc), a); if (e) return e;
  }
  if (p->__pyx_v_io_format) {
    e = (*v)(p->__pyx_v_io_format, a); if (e) return e;
  }
  if (p->__pyx_v_kwargs) {
    e = (*v)(p->__pyx_v_kwargs, a); if (e) return e;
  }
  if (p->__pyx_v_methname) {
    e = (*v)(p->__pyx_v_methname, a); if (e) return e;
  }
  if (p->__pyx_v_out_dc) {
    e = (*v)(((PyObject *)p->__pyx_v_out_dc), a); if (e) return e;
  }
  if (p->__pyx_v_packet) {
    e = (*v)(((PyObject *)p->__pyx_v_packet), a); if (e) return e;
  }
  if (p->__pyx_v_qc) {
    e = (*v)(((PyObject *)p->__pyx_v_qc), a); if (e) return e;
  }
  if (p->__pyx_v_reg) {
    e = (*v)(((PyObject *)p->__pyx_v_reg), a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.__pyx_scope_struct_5__optimistic_execute", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query *__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query[8];
static int __pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query = 0;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query)))) {
    o = (PyObject*)__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query[--__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query];
    memset(o, 0, sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_buf);
  Py_CLEAR(p->__pyx_v_cap_bytes);
  Py_CLEAR(p->__pyx_v_capabilities);
  Py_CLEAR(p->__pyx_v_exc);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query)))) {
    __pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query[__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query++] = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query *)o;
  if (p->__pyx_v_buf) {
    e = (*v)(((PyObject *)p->__pyx_v_buf), a); if (e) return e;
  }
  if (p->__pyx_v_capabilities) {
    e = (*v)(p->__pyx_v_capabilities, a); if (e) return e;
  }
  if (p->__pyx_v_exc) {
    e = (*v)(p->__pyx_v_exc, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.__pyx_scope_struct_6_simple_query", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous *__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous[8];
static int __pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous = 0;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous)))) {
    o = (PyObject*)__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous[--__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous];
    memset(o, 0, sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_allow_capabilities);
  Py_CLEAR(p->__pyx_v_args);
  Py_CLEAR(p->__pyx_v_attrs);
  Py_CLEAR(p->__pyx_v_capabilities);
  Py_CLEAR(p->__pyx_v_cardinality);
  Py_CLEAR(p->__pyx_v_codecs);
  Py_CLEAR(p->__pyx_v_has_na_cardinality);
  Py_CLEAR(p->__pyx_v_headers);
  Py_CLEAR(p->__pyx_v_implicit_limit);
  Py_CLEAR(p->__pyx_v_in_dc);
  Py_CLEAR(p->__pyx_v_inline_typeids);
  Py_CLEAR(p->__pyx_v_inline_typenames);
  Py_CLEAR(p->__pyx_v_io_format);
  Py_CLEAR(p->__pyx_v_kwargs);
  Py_CLEAR(p->__pyx_v_methname);
  Py_CLEAR(p->__pyx_v_out_dc);
  Py_CLEAR(p->__pyx_v_qc);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_reg);
  Py_CLEAR(p->__pyx_v_required_one);
  Py_CLEAR(p->__pyx_v_ret);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous)))) {
    __pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous[__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous++] = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous *)o;
  if (p->__pyx_v_allow_capabilities) {
    e = (*v)(p->__pyx_v_allow_capabilities, a); if (e) return e;
  }
  if (p->__pyx_v_args) {
    e = (*v)(p->__pyx_v_args, a); if (e) return e;
  }
  if (p->__pyx_v_attrs) {
    e = (*v)(p->__pyx_v_attrs, a); if (e) return e;
  }
  if (p->__pyx_v_capabilities) {
    e = (*v)(p->__pyx_v_capabilities, a); if (e) return e;
  }
  if (p->__pyx_v_cardinality) {
    e = (*v)(p->__pyx_v_cardinality, a); if (e) return e;
  }
  if (p->__pyx_v_codecs) {
    e = (*v)(p->__pyx_v_codecs, a); if (e) return e;
  }
  if (p->__pyx_v_has_na_cardinality) {
    e = (*v)(p->__pyx_v_has_na_cardinality, a); if (e) return e;
  }
  if (p->__pyx_v_headers) {
    e = (*v)(((PyObject *)p->__pyx_v_headers), a); if (e) return e;
  }
  if (p->__pyx_v_implicit_limit) {
    e = (*v)(p->__pyx_v_implicit_limit, a); if (e) return e;
  }
  if (p->__pyx_v_in_dc) {
    e = (*v)(((PyObject *)p->__pyx_v_in_dc), a); if (e) return e;
  }
  if (p->__pyx_v_inline_typeids) {
    e = (*v)(p->__pyx_v_inline_typeids, a); if (e) return e;
  }
  if (p->__pyx_v_inline_typenames) {
    e = (*v)(p->__pyx_v_inline_typenames, a); if (e) return e;
  }
  if (p->__pyx_v_io_format) {
    e = (*v)(p->__pyx_v_io_format, a); if (e) return e;
  }
  if (p->__pyx_v_kwargs) {
    e = (*v)(p->__pyx_v_kwargs, a); if (e) return e;
  }
  if (p->__pyx_v_methname) {
    e = (*v)(p->__pyx_v_methname, a); if (e) return e;
  }
  if (p->__pyx_v_out_dc) {
    e = (*v)(((PyObject *)p->__pyx_v_out_dc), a); if (e) return e;
  }
  if (p->__pyx_v_qc) {
    e = (*v)(((PyObject *)p->__pyx_v_qc), a); if (e) return e;
  }
  if (p->__pyx_v_reg) {
    e = (*v)(((PyObject *)p->__pyx_v_reg), a); if (e) return e;
  }
  if (p->__pyx_v_required_one) {
    e = (*v)(p->__pyx_v_required_one, a); if (e) return e;
  }
  if (p->__pyx_v_ret) {
    e = (*v)(p->__pyx_v_ret, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.__pyx_scope_struct_7_execute_anonymous", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump *__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump[8];
static int __pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump = 0;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump)))) {
    o = (PyObject*)__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump[--__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump];
    memset(o, 0, sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_block_callback);
  Py_CLEAR(p->__pyx_v_buf);
  Py_CLEAR(p->__pyx_v_exc);
  Py_CLEAR(p->__pyx_v_header_callback);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump)))) {
    __pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump[__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump++] = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump *)o;
  if (p->__pyx_v_block_callback) {
    e = (*v)(p->__pyx_v_block_callback, a); if (e) return e;
  }
  if (p->__pyx_v_buf) {
    e = (*v)(((PyObject *)p->__pyx_v_buf), a); if (e) return e;
  }
  if (p->__pyx_v_exc) {
    e = (*v)(p->__pyx_v_exc, a); if (e) return e;
  }
  if (p->__pyx_v_header_callback) {
    e = (*v)(p->__pyx_v_header_callback, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.__pyx_scope_struct_8_dump", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync *__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync[8];
static int __pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync = 0;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync)))) {
    o = (PyObject*)__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync[--__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync];
    memset(o, 0, sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync)))) {
    __pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync[__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync++] = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.__pyx_scope_struct_9__sync", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore *__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore[8];
static int __pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore = 0;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore)))) {
    o = (PyObject*)__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore[--__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore];
    memset(o, 0, sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_buf);
  Py_CLEAR(p->__pyx_v_data);
  Py_CLEAR(p->__pyx_v_data_gen);
  Py_CLEAR(p->__pyx_v_exc);
  Py_CLEAR(p->__pyx_v_header);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore)))) {
    __pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore[__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore++] = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore *)o;
  if (p->__pyx_v_buf) {
    e = (*v)(((PyObject *)p->__pyx_v_buf), a); if (e) return e;
  }
  if (p->__pyx_v_data) {
    e = (*v)(p->__pyx_v_data, a); if (e) return e;
  }
  if (p->__pyx_v_data_gen) {
    e = (*v)(p->__pyx_v_data_gen, a); if (e) return e;
  }
  if (p->__pyx_v_exc) {
    e = (*v)(p->__pyx_v_exc, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.__pyx_scope_struct_10_restore", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect *__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect[8];
static int __pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect = 0;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect)))) {
    o = (PyObject*)__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect[--__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect];
    memset(o, 0, sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_buf);
  Py_CLEAR(p->__pyx_v_handshake_buf);
  Py_CLEAR(p->__pyx_v_k);
  Py_CLEAR(p->__pyx_v_msg_buf);
  Py_CLEAR(p->__pyx_v_params);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_v);
  Py_CLEAR(p->__pyx_v_ver_buf);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect)))) {
    __pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect[__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect++] = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect *)o;
  if (p->__pyx_v_buf) {
    e = (*v)(((PyObject *)p->__pyx_v_buf), a); if (e) return e;
  }
  if (p->__pyx_v_handshake_buf) {
    e = (*v)(((PyObject *)p->__pyx_v_handshake_buf), a); if (e) return e;
  }
  if (p->__pyx_v_k) {
    e = (*v)(p->__pyx_v_k, a); if (e) return e;
  }
  if (p->__pyx_v_msg_buf) {
    e = (*v)(((PyObject *)p->__pyx_v_msg_buf), a); if (e) return e;
  }
  if (p->__pyx_v_params) {
    e = (*v)(p->__pyx_v_params, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_v_v) {
    e = (*v)(p->__pyx_v_v, a); if (e) return e;
  }
  if (p->__pyx_v_ver_buf) {
    e = (*v)(((PyObject *)p->__pyx_v_ver_buf), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.__pyx_scope_struct_11_connect", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl *__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl[8];
static int __pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl = 0;

static PyObject *__pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl)))) {
    o = (PyObject*)__pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl[--__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl];
    memset(o, 0, sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl(PyObject *o) {
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_client_final);
  Py_CLEAR(p->__pyx_v_client_first);
  Py_CLEAR(p->__pyx_v_client_first_bare);
  Py_CLEAR(p->__pyx_v_client_nonce);
  Py_CLEAR(p->__pyx_v_exc);
  Py_CLEAR(p->__pyx_v_expected_server_sig);
  Py_CLEAR(p->__pyx_v_itercount);
  Py_CLEAR(p->__pyx_v_method);
  Py_CLEAR(p->__pyx_v_methods);
  Py_CLEAR(p->__pyx_v_msg_buf);
  Py_CLEAR(p->__pyx_v_salt);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_server_final);
  Py_CLEAR(p->__pyx_v_server_first);
  Py_CLEAR(p->__pyx_v_server_nonce);
  Py_CLEAR(p->__pyx_v_server_sig);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl)))) {
    __pyx_freelist_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl[__pyx_freecount_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl++] = ((struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl *p = (struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl *)o;
  if (p->__pyx_v_client_final) {
    e = (*v)(p->__pyx_v_client_final, a); if (e) return e;
  }
  if (p->__pyx_v_client_first) {
    e = (*v)(p->__pyx_v_client_first, a); if (e) return e;
  }
  if (p->__pyx_v_client_first_bare) {
    e = (*v)(p->__pyx_v_client_first_bare, a); if (e) return e;
  }
  if (p->__pyx_v_client_nonce) {
    e = (*v)(p->__pyx_v_client_nonce, a); if (e) return e;
  }
  if (p->__pyx_v_exc) {
    e = (*v)(p->__pyx_v_exc, a); if (e) return e;
  }
  if (p->__pyx_v_expected_server_sig) {
    e = (*v)(p->__pyx_v_expected_server_sig, a); if (e) return e;
  }
  if (p->__pyx_v_itercount) {
    e = (*v)(p->__pyx_v_itercount, a); if (e) return e;
  }
  if (p->__pyx_v_method) {
    e = (*v)(p->__pyx_v_method, a); if (e) return e;
  }
  if (p->__pyx_v_methods) {
    e = (*v)(p->__pyx_v_methods, a); if (e) return e;
  }
  if (p->__pyx_v_msg_buf) {
    e = (*v)(((PyObject *)p->__pyx_v_msg_buf), a); if (e) return e;
  }
  if (p->__pyx_v_salt) {
    e = (*v)(p->__pyx_v_salt, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_v_server_nonce) {
    e = (*v)(p->__pyx_v_server_nonce, a); if (e) return e;
  }
  if (p->__pyx_v_server_sig) {
    e = (*v)(p->__pyx_v_server_sig, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.__pyx_scope_struct_12__auth_sasl", /*tp_name*/
  sizeof(struct __pyx_obj_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static PyObject *__pyx_tp_new___Pyx_EnumMeta(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (&PyType_Type)->tp_new(t, a, k);
  if (unlikely(!o)) return 0;
  return o;
}

static void __pyx_tp_dealloc___Pyx_EnumMeta(PyObject *o) {
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  PyObject_GC_Track(o);
  (&PyType_Type)->tp_dealloc(o);
}

static int __pyx_tp_traverse___Pyx_EnumMeta(PyObject *o, visitproc v, void *a) {
  int e;
  if (!(&PyType_Type)->tp_traverse); else { e = (&PyType_Type)->tp_traverse(o,v,a); if (e) return e; }
  return 0;
}

static int __pyx_tp_clear___Pyx_EnumMeta(PyObject *o) {
  if (!(&PyType_Type)->tp_clear); else (&PyType_Type)->tp_clear(o);
  return 0;
}
static PyObject *__pyx_sq_item___Pyx_EnumMeta(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyMethodDef __pyx_methods___Pyx_EnumMeta[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_8EnumBase_14__Pyx_EnumMeta_7__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_8EnumBase_14__Pyx_EnumMeta_9__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PySequenceMethods __pyx_tp_as_sequence___Pyx_EnumMeta = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item___Pyx_EnumMeta, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping___Pyx_EnumMeta = {
  0, /*mp_length*/
  __pyx_pw_8EnumBase_14__Pyx_EnumMeta_5__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __Pyx_EnumMeta = {
  PyVarObject_HEAD_INIT(0, 0)
  "edgedb.protocol.protocol.__Pyx_EnumMeta", /*tp_name*/
  sizeof(struct __pyx_obj___Pyx_EnumMeta), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc___Pyx_EnumMeta, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  &__pyx_tp_as_sequence___Pyx_EnumMeta, /*tp_as_sequence*/
  &__pyx_tp_as_mapping___Pyx_EnumMeta, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse___Pyx_EnumMeta, /*tp_traverse*/
  __pyx_tp_clear___Pyx_EnumMeta, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_8EnumBase_14__Pyx_EnumMeta_3__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods___Pyx_EnumMeta, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_8EnumBase_14__Pyx_EnumMeta_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new___Pyx_EnumMeta, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_protocol(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_protocol},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "protocol",
    0, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
    #define CYTHON_SMALL_CODE __attribute__((cold))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_u_0000, __pyx_k_0000, sizeof(__pyx_k_0000), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000, __pyx_k_00000000_0000_0000_0000_00000000, sizeof(__pyx_k_00000000_0000_0000_0000_00000000), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_10, __pyx_k_00000000_0000_0000_0000_00000000_10, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_10), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_11, __pyx_k_00000000_0000_0000_0000_00000000_11, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_11), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_12, __pyx_k_00000000_0000_0000_0000_00000000_12, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_12), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_13, __pyx_k_00000000_0000_0000_0000_00000000_13, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_13), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_14, __pyx_k_00000000_0000_0000_0000_00000000_14, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_14), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_15, __pyx_k_00000000_0000_0000_0000_00000000_15, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_15), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_16, __pyx_k_00000000_0000_0000_0000_00000000_16, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_16), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_17, __pyx_k_00000000_0000_0000_0000_00000000_17, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_17), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_18, __pyx_k_00000000_0000_0000_0000_00000000_18, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_18), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_19, __pyx_k_00000000_0000_0000_0000_00000000_19, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_19), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_2, __pyx_k_00000000_0000_0000_0000_00000000_2, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_2), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_20, __pyx_k_00000000_0000_0000_0000_00000000_20, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_20), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_21, __pyx_k_00000000_0000_0000_0000_00000000_21, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_21), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_22, __pyx_k_00000000_0000_0000_0000_00000000_22, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_22), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_23, __pyx_k_00000000_0000_0000_0000_00000000_23, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_23), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_3, __pyx_k_00000000_0000_0000_0000_00000000_3, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_3), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_4, __pyx_k_00000000_0000_0000_0000_00000000_4, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_4), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_5, __pyx_k_00000000_0000_0000_0000_00000000_5, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_5), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_6, __pyx_k_00000000_0000_0000_0000_00000000_6, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_6), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_7, __pyx_k_00000000_0000_0000_0000_00000000_7, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_7), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_8, __pyx_k_00000000_0000_0000_0000_00000000_8, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_8), 0, 1, 0, 0},
  {&__pyx_kp_u_00000000_0000_0000_0000_00000000_9, __pyx_k_00000000_0000_0000_0000_00000000_9, sizeof(__pyx_k_00000000_0000_0000_0000_00000000_9), 0, 1, 0, 0},
  {&__pyx_n_s_ALL_CAPABILITIES, __pyx_k_ALL_CAPABILITIES, sizeof(__pyx_k_ALL_CAPABILITIES), 0, 0, 1, 1},
  {&__pyx_n_u_Array, __pyx_k_Array, sizeof(__pyx_k_Array), 0, 1, 0, 1},
  {&__pyx_n_s_ArrayCodec, __pyx_k_ArrayCodec, sizeof(__pyx_k_ArrayCodec), 0, 0, 1, 1},
  {&__pyx_n_s_BINARY, __pyx_k_BINARY, sizeof(__pyx_k_BINARY), 0, 0, 1, 1},
  {&__pyx_n_s_BaseArrayCodec, __pyx_k_BaseArrayCodec, sizeof(__pyx_k_BaseArrayCodec), 0, 0, 1, 1},
  {&__pyx_n_s_BaseCodec, __pyx_k_BaseCodec, sizeof(__pyx_k_BaseCodec), 0, 0, 1, 1},
  {&__pyx_n_s_BaseNamedRecordCodec, __pyx_k_BaseNamedRecordCodec, sizeof(__pyx_k_BaseNamedRecordCodec), 0, 0, 1, 1},
  {&__pyx_n_s_BaseRecordCodec, __pyx_k_BaseRecordCodec, sizeof(__pyx_k_BaseRecordCodec), 0, 0, 1, 1},
  {&__pyx_n_s_ClientConnectionClosedError, __pyx_k_ClientConnectionClosedError, sizeof(__pyx_k_ClientConnectionClosedError), 0, 0, 1, 1},
  {&__pyx_n_s_ClientConnectionError, __pyx_k_ClientConnectionError, sizeof(__pyx_k_ClientConnectionError), 0, 0, 1, 1},
  {&__pyx_n_s_ClientError, __pyx_k_ClientError, sizeof(__pyx_k_ClientError), 0, 0, 1, 1},
  {&__pyx_n_s_CodecPythonOverride, __pyx_k_CodecPythonOverride, sizeof(__pyx_k_CodecPythonOverride), 0, 0, 1, 1},
  {&__pyx_n_s_CodecsRegistry, __pyx_k_CodecsRegistry, sizeof(__pyx_k_CodecsRegistry), 0, 0, 1, 1},
  {&__pyx_n_s_Decimal, __pyx_k_Decimal, sizeof(__pyx_k_Decimal), 0, 0, 1, 1},
  {&__pyx_n_s_EMPTY_NULL_DATA, __pyx_k_EMPTY_NULL_DATA, sizeof(__pyx_k_EMPTY_NULL_DATA), 0, 0, 1, 1},
  {&__pyx_n_s_EMPTY_RECORD_DATA, __pyx_k_EMPTY_RECORD_DATA, sizeof(__pyx_k_EMPTY_RECORD_DATA), 0, 0, 1, 1},
  {&__pyx_n_s_EdegDBCodecContext, __pyx_k_EdegDBCodecContext, sizeof(__pyx_k_EdegDBCodecContext), 0, 0, 1, 1},
  {&__pyx_n_s_EdgeDBError, __pyx_k_EdgeDBError, sizeof(__pyx_k_EdgeDBError), 0, 0, 1, 1},
  {&__pyx_n_s_EdgeDBMessage, __pyx_k_EdgeDBMessage, sizeof(__pyx_k_EdgeDBMessage), 0, 0, 1, 1},
  {&__pyx_n_s_EmptyTupleCodec, __pyx_k_EmptyTupleCodec, sizeof(__pyx_k_EmptyTupleCodec), 0, 0, 1, 1},
  {&__pyx_n_u_Enum, __pyx_k_Enum, sizeof(__pyx_k_Enum), 0, 1, 0, 1},
  {&__pyx_n_s_EnumBase, __pyx_k_EnumBase, sizeof(__pyx_k_EnumBase), 0, 0, 1, 1},
  {&__pyx_n_s_EnumCodec, __pyx_k_EnumCodec, sizeof(__pyx_k_EnumCodec), 0, 0, 1, 1},
  {&__pyx_n_s_EnumType, __pyx_k_EnumType, sizeof(__pyx_k_EnumType), 0, 0, 1, 1},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x32, __pyx_k_Incompatible_checksums_s_vs_0x32, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x32), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x53, __pyx_k_Incompatible_checksums_s_vs_0x53, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x53), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x5d, __pyx_k_Incompatible_checksums_s_vs_0x5d, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x5d), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xad, __pyx_k_Incompatible_checksums_s_vs_0xad, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xad), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xd4, __pyx_k_Incompatible_checksums_s_vs_0xd4, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xd4), 0, 0, 1, 0},
  {&__pyx_n_s_IntEnum, __pyx_k_IntEnum, sizeof(__pyx_k_IntEnum), 0, 0, 1, 1},
  {&__pyx_n_s_InterfaceError, __pyx_k_InterfaceError, sizeof(__pyx_k_InterfaceError), 0, 0, 1, 1},
  {&__pyx_n_s_InvalidArgumentError, __pyx_k_InvalidArgumentError, sizeof(__pyx_k_InvalidArgumentError), 0, 0, 1, 1},
  {&__pyx_n_s_IoFormat, __pyx_k_IoFormat, sizeof(__pyx_k_IoFormat), 0, 0, 1, 1},
  {&__pyx_n_s_Iterable, __pyx_k_Iterable, sizeof(__pyx_k_Iterable), 0, 0, 1, 1},
  {&__pyx_n_s_IterableABC, __pyx_k_IterableABC, sizeof(__pyx_k_IterableABC), 0, 0, 1, 1},
  {&__pyx_n_s_JSON, __pyx_k_JSON, sizeof(__pyx_k_JSON), 0, 0, 1, 1},
  {&__pyx_n_s_JSON_ELEMENTS, __pyx_k_JSON_ELEMENTS, sizeof(__pyx_k_JSON_ELEMENTS), 0, 0, 1, 1},
  {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
  {&__pyx_n_s_LRUMapping, __pyx_k_LRUMapping, sizeof(__pyx_k_LRUMapping), 0, 0, 1, 1},
  {&__pyx_n_s_LookupError, __pyx_k_LookupError, sizeof(__pyx_k_LookupError), 0, 0, 1, 1},
  {&__pyx_n_s_Mapping, __pyx_k_Mapping, sizeof(__pyx_k_Mapping), 0, 0, 1, 1},
  {&__pyx_n_s_MappingABC, __pyx_k_MappingABC, sizeof(__pyx_k_MappingABC), 0, 0, 1, 1},
  {&__pyx_n_s_MappingProxyType, __pyx_k_MappingProxyType, sizeof(__pyx_k_MappingProxyType), 0, 0, 1, 1},
  {&__pyx_n_u_NamedTuple, __pyx_k_NamedTuple, sizeof(__pyx_k_NamedTuple), 0, 1, 0, 1},
  {&__pyx_n_s_NamedTupleCodec, __pyx_k_NamedTupleCodec, sizeof(__pyx_k_NamedTupleCodec), 0, 0, 1, 1},
  {&__pyx_n_s_NoDataError, __pyx_k_NoDataError, sizeof(__pyx_k_NoDataError), 0, 0, 1, 1},
  {&__pyx_kp_u_None, __pyx_k_None, sizeof(__pyx_k_None), 0, 1, 0, 0},
  {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
  {&__pyx_n_s_NullCodec, __pyx_k_NullCodec, sizeof(__pyx_k_NullCodec), 0, 0, 1, 1},
  {&__pyx_n_u_Object, __pyx_k_Object, sizeof(__pyx_k_Object), 0, 1, 0, 1},
  {&__pyx_n_s_ObjectCodec, __pyx_k_ObjectCodec, sizeof(__pyx_k_ObjectCodec), 0, 0, 1, 1},
  {&__pyx_n_s_OrderedDict, __pyx_k_OrderedDict, sizeof(__pyx_k_OrderedDict), 0, 0, 1, 1},
  {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_ProtocolError, __pyx_k_ProtocolError, sizeof(__pyx_k_ProtocolError), 0, 0, 1, 1},
  {&__pyx_kp_u_Python_override, __pyx_k_Python_override, sizeof(__pyx_k_Python_override), 0, 1, 0, 0},
  {&__pyx_n_s_Pyx_EnumBase, __pyx_k_Pyx_EnumBase, sizeof(__pyx_k_Pyx_EnumBase), 0, 0, 1, 1},
  {&__pyx_n_s_Pyx_EnumBase___new, __pyx_k_Pyx_EnumBase___new, sizeof(__pyx_k_Pyx_EnumBase___new), 0, 0, 1, 1},
  {&__pyx_n_s_Pyx_EnumBase___repr, __pyx_k_Pyx_EnumBase___repr, sizeof(__pyx_k_Pyx_EnumBase___repr), 0, 0, 1, 1},
  {&__pyx_n_s_Pyx_EnumBase___str, __pyx_k_Pyx_EnumBase___str, sizeof(__pyx_k_Pyx_EnumBase___str), 0, 0, 1, 1},
  {&__pyx_n_s_QUERY_SINGLE_METHOD, __pyx_k_QUERY_SINGLE_METHOD, sizeof(__pyx_k_QUERY_SINGLE_METHOD), 0, 0, 1, 1},
  {&__pyx_n_s_QueryArgumentError, __pyx_k_QueryArgumentError, sizeof(__pyx_k_QueryArgumentError), 0, 0, 1, 1},
  {&__pyx_n_s_QueryCodecsCache, __pyx_k_QueryCodecsCache, sizeof(__pyx_k_QueryCodecsCache), 0, 0, 1, 1},
  {&__pyx_n_s_ResultCardinalityMismatchError, __pyx_k_ResultCardinalityMismatchError, sizeof(__pyx_k_ResultCardinalityMismatchError), 0, 0, 1, 1},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_kp_b_SCRAM_SHA_256, __pyx_k_SCRAM_SHA_256, sizeof(__pyx_k_SCRAM_SHA_256), 0, 0, 0, 0},
  {&__pyx_n_s_SansIOProtocol, __pyx_k_SansIOProtocol, sizeof(__pyx_k_SansIOProtocol), 0, 0, 1, 1},
  {&__pyx_n_s_SansIOProtocol__auth_sasl, __pyx_k_SansIOProtocol__auth_sasl, sizeof(__pyx_k_SansIOProtocol__auth_sasl), 0, 0, 1, 1},
  {&__pyx_n_s_SansIOProtocol__execute, __pyx_k_SansIOProtocol__execute, sizeof(__pyx_k_SansIOProtocol__execute), 0, 0, 1, 1},
  {&__pyx_n_s_SansIOProtocol__optimistic_execu, __pyx_k_SansIOProtocol__optimistic_execu, sizeof(__pyx_k_SansIOProtocol__optimistic_execu), 0, 0, 1, 1},
  {&__pyx_n_s_SansIOProtocol__parse, __pyx_k_SansIOProtocol__parse, sizeof(__pyx_k_SansIOProtocol__parse), 0, 0, 1, 1},
  {&__pyx_n_s_SansIOProtocol__sync, __pyx_k_SansIOProtocol__sync, sizeof(__pyx_k_SansIOProtocol__sync), 0, 0, 1, 1},
  {&__pyx_n_s_SansIOProtocol_connect, __pyx_k_SansIOProtocol_connect, sizeof(__pyx_k_SansIOProtocol_connect), 0, 0, 1, 1},
  {&__pyx_n_s_SansIOProtocol_dump, __pyx_k_SansIOProtocol_dump, sizeof(__pyx_k_SansIOProtocol_dump), 0, 0, 1, 1},
  {&__pyx_n_s_SansIOProtocol_execute_anonymous, __pyx_k_SansIOProtocol_execute_anonymous, sizeof(__pyx_k_SansIOProtocol_execute_anonymous), 0, 0, 1, 1},
  {&__pyx_n_s_SansIOProtocol_restore, __pyx_k_SansIOProtocol_restore, sizeof(__pyx_k_SansIOProtocol_restore), 0, 0, 1, 1},
  {&__pyx_n_s_SansIOProtocol_simple_query, __pyx_k_SansIOProtocol_simple_query, sizeof(__pyx_k_SansIOProtocol_simple_query), 0, 0, 1, 1},
  {&__pyx_n_s_SansIOProtocol_try_recv_eagerly, __pyx_k_SansIOProtocol_try_recv_eagerly, sizeof(__pyx_k_SansIOProtocol_try_recv_eagerly), 0, 0, 1, 1},
  {&__pyx_n_s_SansIOProtocol_wait_for_connect, __pyx_k_SansIOProtocol_wait_for_connect, sizeof(__pyx_k_SansIOProtocol_wait_for_connect), 0, 0, 1, 1},
  {&__pyx_n_s_SansIOProtocol_wait_for_message, __pyx_k_SansIOProtocol_wait_for_message, sizeof(__pyx_k_SansIOProtocol_wait_for_message), 0, 0, 1, 1},
  {&__pyx_n_s_ScalarCodec, __pyx_k_ScalarCodec, sizeof(__pyx_k_ScalarCodec), 0, 0, 1, 1},
  {&__pyx_n_u_Set, __pyx_k_Set, sizeof(__pyx_k_Set), 0, 1, 0, 1},
  {&__pyx_n_s_SetCodec, __pyx_k_SetCodec, sizeof(__pyx_k_SetCodec), 0, 0, 1, 1},
  {&__pyx_n_s_Sized, __pyx_k_Sized, sizeof(__pyx_k_Sized), 0, 0, 1, 1},
  {&__pyx_n_s_SizedABC, __pyx_k_SizedABC, sizeof(__pyx_k_SizedABC), 0, 0, 1, 1},
  {&__pyx_n_s_TYPE_IDS, __pyx_k_TYPE_IDS, sizeof(__pyx_k_TYPE_IDS), 0, 0, 1, 1},
  {&__pyx_n_u_Tuple, __pyx_k_Tuple, sizeof(__pyx_k_Tuple), 0, 1, 0, 1},
  {&__pyx_n_s_TupleCodec, __pyx_k_TupleCodec, sizeof(__pyx_k_TupleCodec), 0, 0, 1, 1},
  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  {&__pyx_n_s_UUID, __pyx_k_UUID, sizeof(__pyx_k_UUID), 0, 0, 1, 1},
  {&__pyx_kp_s_Unknown_enum_value_s, __pyx_k_Unknown_enum_value_s, sizeof(__pyx_k_Unknown_enum_value_s), 0, 0, 1, 0},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_kp_b__106, __pyx_k__106, sizeof(__pyx_k__106), 0, 0, 0, 0},
  {&__pyx_kp_b__108, __pyx_k__108, sizeof(__pyx_k__108), 0, 0, 0, 0},
  {&__pyx_kp_b__109, __pyx_k__109, sizeof(__pyx_k__109), 0, 0, 0, 0},
  {&__pyx_kp_u__14, __pyx_k__14, sizeof(__pyx_k__14), 0, 1, 0, 0},
  {&__pyx_kp_u__17, __pyx_k__17, sizeof(__pyx_k__17), 0, 1, 0, 0},
  {&__pyx_kp_u__18, __pyx_k__18, sizeof(__pyx_k__18), 0, 1, 0, 0},
  {&__pyx_kp_u__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 1, 0, 0},
  {&__pyx_kp_u__29, __pyx_k__29, sizeof(__pyx_k__29), 0, 1, 0, 0},
  {&__pyx_kp_u__30, __pyx_k__30, sizeof(__pyx_k__30), 0, 1, 0, 0},
  {&__pyx_kp_u__31, __pyx_k__31, sizeof(__pyx_k__31), 0, 1, 0, 0},
  {&__pyx_kp_b__61, __pyx_k__61, sizeof(__pyx_k__61), 0, 0, 0, 0},
  {&__pyx_kp_u__61, __pyx_k__61, sizeof(__pyx_k__61), 0, 1, 0, 0},
  {&__pyx_kp_u__62, __pyx_k__62, sizeof(__pyx_k__62), 0, 1, 0, 0},
  {&__pyx_kp_u__68, __pyx_k__68, sizeof(__pyx_k__68), 0, 1, 0, 0},
  {&__pyx_kp_u__75, __pyx_k__75, sizeof(__pyx_k__75), 0, 1, 0, 0},
  {&__pyx_kp_u__78, __pyx_k__78, sizeof(__pyx_k__78), 0, 1, 0, 0},
  {&__pyx_kp_u_a_datetime_datetime_object_was_e, __pyx_k_a_datetime_datetime_object_was_e, sizeof(__pyx_k_a_datetime_datetime_object_was_e), 0, 1, 0, 0},
  {&__pyx_kp_u_a_datetime_datetime_object_was_e_2, __pyx_k_a_datetime_datetime_object_was_e_2, sizeof(__pyx_k_a_datetime_datetime_object_was_e_2), 0, 1, 0, 0},
  {&__pyx_kp_u_a_naive_date_object_tzinfo_is_No, __pyx_k_a_naive_date_object_tzinfo_is_No, sizeof(__pyx_k_a_naive_date_object_tzinfo_is_No), 0, 1, 0, 0},
  {&__pyx_kp_u_a_naive_datetime_object_tzinfo_i, __pyx_k_a_naive_datetime_object_tzinfo_i, sizeof(__pyx_k_a_naive_datetime_object_tzinfo_i), 0, 1, 0, 0},
  {&__pyx_kp_u_a_naive_time_object_tzinfo_is_No, __pyx_k_a_naive_time_object_tzinfo_is_No, sizeof(__pyx_k_a_naive_time_object_tzinfo_is_No), 0, 1, 0, 0},
  {&__pyx_kp_u_a_scalar_codec_expected_for_base, __pyx_k_a_scalar_codec_expected_for_base, sizeof(__pyx_k_a_scalar_codec_expected_for_base), 0, 1, 0, 0},
  {&__pyx_kp_u_a_sized_iterable_container_expec, __pyx_k_a_sized_iterable_container_expec, sizeof(__pyx_k_a_sized_iterable_container_expec), 0, 1, 0, 0},
  {&__pyx_kp_u_a_str_or_edgedb_EnumValue_is_exp, __pyx_k_a_str_or_edgedb_EnumValue_is_exp, sizeof(__pyx_k_a_str_or_edgedb_EnumValue_is_exp), 0, 1, 0, 0},
  {&__pyx_kp_u_a_timezone_aware_datetime_object, __pyx_k_a_timezone_aware_datetime_object, sizeof(__pyx_k_a_timezone_aware_datetime_object), 0, 1, 0, 0},
  {&__pyx_n_s_abort, __pyx_k_abort, sizeof(__pyx_k_abort), 0, 0, 1, 1},
  {&__pyx_n_s_aiter, __pyx_k_aiter, sizeof(__pyx_k_aiter), 0, 0, 1, 1},
  {&__pyx_n_s_allow_capabilities, __pyx_k_allow_capabilities, sizeof(__pyx_k_allow_capabilities), 0, 0, 1, 1},
  {&__pyx_kp_u_already_connected, __pyx_k_already_connected, sizeof(__pyx_k_already_connected), 0, 1, 0, 0},
  {&__pyx_n_s_anext, __pyx_k_anext, sizeof(__pyx_k_anext), 0, 0, 1, 1},
  {&__pyx_n_u_anytuple, __pyx_k_anytuple, sizeof(__pyx_k_anytuple), 0, 1, 0, 1},
  {&__pyx_n_u_anytype, __pyx_k_anytype, sizeof(__pyx_k_anytype), 0, 1, 0, 1},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  {&__pyx_kp_u_argument, __pyx_k_argument, sizeof(__pyx_k_argument), 0, 1, 0, 0},
  {&__pyx_kp_u_argument_tuples_only_support_sca, __pyx_k_argument_tuples_only_support_sca, sizeof(__pyx_k_argument_tuples_only_support_sca), 0, 1, 0, 0},
  {&__pyx_kp_u_arguments, __pyx_k_arguments, sizeof(__pyx_k_arguments), 0, 1, 0, 0},
  {&__pyx_kp_u_as_it_does_not_return_any_data, __pyx_k_as_it_does_not_return_any_data, sizeof(__pyx_k_as_it_does_not_return_any_data), 0, 1, 0, 0},
  {&__pyx_kp_u_as_it_returns_a_multiset, __pyx_k_as_it_returns_a_multiset, sizeof(__pyx_k_as_it_returns_a_multiset), 0, 1, 0, 0},
  {&__pyx_n_s_asyncio, __pyx_k_asyncio, sizeof(__pyx_k_asyncio), 0, 0, 1, 1},
  {&__pyx_n_s_asyncio_coroutines, __pyx_k_asyncio_coroutines, sizeof(__pyx_k_asyncio_coroutines), 0, 0, 1, 1},
  {&__pyx_n_s_asyncio_tasks, __pyx_k_asyncio_tasks, sizeof(__pyx_k_asyncio_tasks), 0, 0, 1, 1},
  {&__pyx_n_s_attrs, __pyx_k_attrs, sizeof(__pyx_k_attrs), 0, 0, 1, 1},
  {&__pyx_n_s_auth_sasl, __pyx_k_auth_sasl, sizeof(__pyx_k_auth_sasl), 0, 0, 1, 1},
  {&__pyx_n_s_await, __pyx_k_await, sizeof(__pyx_k_await), 0, 0, 1, 1},
  {&__pyx_kp_u_bad_bigint_sign_data, __pyx_k_bad_bigint_sign_data, sizeof(__pyx_k_bad_bigint_sign_data), 0, 1, 0, 0},
  {&__pyx_kp_u_base_scalar_codec_for, __pyx_k_base_scalar_codec_for, sizeof(__pyx_k_base_scalar_codec_for), 0, 1, 0, 0},
  {&__pyx_n_u_big, __pyx_k_big, sizeof(__pyx_k_big), 0, 1, 0, 1},
  {&__pyx_kp_u_bigint_data_has_fractional_part, __pyx_k_bigint_data_has_fractional_part, sizeof(__pyx_k_bigint_data_has_fractional_part), 0, 1, 0, 0},
  {&__pyx_n_s_block_callback, __pyx_k_block_callback, sizeof(__pyx_k_block_callback), 0, 0, 1, 1},
  {&__pyx_n_s_build_client_final_message, __pyx_k_build_client_final_message, sizeof(__pyx_k_build_client_final_message), 0, 0, 1, 1},
  {&__pyx_n_s_build_client_first_message, __pyx_k_build_client_first_message, sizeof(__pyx_k_build_client_first_message), 0, 0, 1, 1},
  {&__pyx_n_s_bytes, __pyx_k_bytes, sizeof(__pyx_k_bytes), 0, 0, 1, 1},
  {&__pyx_n_s_bytes_2, __pyx_k_bytes_2, sizeof(__pyx_k_bytes_2), 0, 0, 1, 1},
  {&__pyx_n_s_cache_size, __pyx_k_cache_size, sizeof(__pyx_k_cache_size), 0, 0, 1, 1},
  {&__pyx_kp_u_cal_local_date, __pyx_k_cal_local_date, sizeof(__pyx_k_cal_local_date), 0, 1, 0, 0},
  {&__pyx_kp_u_cal_local_datetime, __pyx_k_cal_local_datetime, sizeof(__pyx_k_cal_local_datetime), 0, 1, 0, 0},
  {&__pyx_kp_u_cal_local_time, __pyx_k_cal_local_time, sizeof(__pyx_k_cal_local_time), 0, 1, 0, 0},
  {&__pyx_kp_u_cal_relative_duration, __pyx_k_cal_relative_duration, sizeof(__pyx_k_cal_relative_duration), 0, 1, 0, 0},
  {&__pyx_kp_u_cannot_decode_NamedTuple_expecte, __pyx_k_cannot_decode_NamedTuple_expecte, sizeof(__pyx_k_cannot_decode_NamedTuple_expecte), 0, 1, 0, 0},
  {&__pyx_kp_u_cannot_decode_Object_expected, __pyx_k_cannot_decode_Object_expected, sizeof(__pyx_k_cannot_decode_Object_expected), 0, 1, 0, 0},
  {&__pyx_kp_u_cannot_decode_Tuple_expected, __pyx_k_cannot_decode_Tuple_expected, sizeof(__pyx_k_cannot_decode_Tuple_expected), 0, 1, 0, 0},
  {&__pyx_kp_u_cannot_decode_empty_Tuple_expect, __pyx_k_cannot_decode_empty_Tuple_expect, sizeof(__pyx_k_cannot_decode_empty_Tuple_expect), 0, 1, 0, 0},
  {&__pyx_kp_u_cannot_encode_empty_Tuple_expect, __pyx_k_cannot_encode_empty_Tuple_expect, sizeof(__pyx_k_cannot_encode_empty_Tuple_expect), 0, 1, 0, 0},
  {&__pyx_kp_u_cannot_encode_empty_Tuple_expect_2, __pyx_k_cannot_encode_empty_Tuple_expect_2, sizeof(__pyx_k_cannot_encode_empty_Tuple_expect_2), 0, 1, 0, 0},
  {&__pyx_kp_u_cannot_find_known_ID_for_type, __pyx_k_cannot_find_known_ID_for_type, sizeof(__pyx_k_cannot_find_known_ID_for_type), 0, 1, 0, 0},
  {&__pyx_kp_u_cannot_handle_arrays_with_more_t, __pyx_k_cannot_handle_arrays_with_more_t, sizeof(__pyx_k_cannot_handle_arrays_with_more_t), 0, 1, 0, 0},
  {&__pyx_kp_u_cannot_not_build_codec_empty_typ, __pyx_k_cannot_not_build_codec_empty_typ, sizeof(__pyx_k_cannot_not_build_codec_empty_typ), 0, 1, 0, 0},
  {&__pyx_n_s_capabilities, __pyx_k_capabilities, sizeof(__pyx_k_capabilities), 0, 0, 1, 1},
  {&__pyx_n_s_cause, __pyx_k_cause, sizeof(__pyx_k_cause), 0, 0, 1, 1},
  {&__pyx_kp_u_cfg_memory, __pyx_k_cfg_memory, sizeof(__pyx_k_cfg_memory), 0, 1, 0, 0},
  {&__pyx_n_s_chr, __pyx_k_chr, sizeof(__pyx_k_chr), 0, 0, 1, 1},
  {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
  {&__pyx_n_s_clear, __pyx_k_clear, sizeof(__pyx_k_clear), 0, 0, 1, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1},
  {&__pyx_n_s_code, __pyx_k_code, sizeof(__pyx_k_code), 0, 0, 1, 1},
  {&__pyx_n_s_codecs, __pyx_k_codecs, sizeof(__pyx_k_codecs), 0, 0, 1, 1},
  {&__pyx_kp_u_codecs_are_not_supposed_to_be_in, __pyx_k_codecs_are_not_supposed_to_be_in, sizeof(__pyx_k_codecs_are_not_supposed_to_be_in), 0, 1, 0, 0},
  {&__pyx_n_s_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1},
  {&__pyx_n_s_collections_abc, __pyx_k_collections_abc, sizeof(__pyx_k_collections_abc), 0, 0, 1, 1},
  {&__pyx_n_s_con_params, __pyx_k_con_params, sizeof(__pyx_k_con_params), 0, 0, 1, 1},
  {&__pyx_n_s_connect, __pyx_k_connect, sizeof(__pyx_k_connect), 0, 0, 1, 1},
  {&__pyx_kp_u_data_block_before_header_block, __pyx_k_data_block_before_header_block, sizeof(__pyx_k_data_block_before_header_block), 0, 1, 0, 0},
  {&__pyx_n_s_data_gen, __pyx_k_data_gen, sizeof(__pyx_k_data_gen), 0, 0, 1, 1},
  {&__pyx_n_s_database, __pyx_k_database, sizeof(__pyx_k_database), 0, 0, 1, 1},
  {&__pyx_n_u_database, __pyx_k_database, sizeof(__pyx_k_database), 0, 1, 0, 1},
  {&__pyx_n_s_datatypes, __pyx_k_datatypes, sizeof(__pyx_k_datatypes), 0, 0, 1, 1},
  {&__pyx_n_s_datetime, __pyx_k_datetime, sizeof(__pyx_k_datetime), 0, 0, 1, 1},
  {&__pyx_n_s_days, __pyx_k_days, sizeof(__pyx_k_days), 0, 0, 1, 1},
  {&__pyx_n_s_dct, __pyx_k_dct, sizeof(__pyx_k_dct), 0, 0, 1, 1},
  {&__pyx_n_s_decimal, __pyx_k_decimal, sizeof(__pyx_k_decimal), 0, 0, 1, 1},
  {&__pyx_n_s_decoder, __pyx_k_decoder, sizeof(__pyx_k_decoder), 0, 0, 1, 1},
  {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
  {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  {&__pyx_kp_u_does_not_correspond_to_any_know, __pyx_k_does_not_correspond_to_any_know, sizeof(__pyx_k_does_not_correspond_to_any_know), 0, 1, 0, 0},
  {&__pyx_n_s_dump, __pyx_k_dump, sizeof(__pyx_k_dump), 0, 0, 1, 1},
  {&__pyx_n_s_edgedb, __pyx_k_edgedb, sizeof(__pyx_k_edgedb), 0, 0, 1, 1},
  {&__pyx_n_s_edgedb_datatypes, __pyx_k_edgedb_datatypes, sizeof(__pyx_k_edgedb_datatypes), 0, 0, 1, 1},
  {&__pyx_n_s_edgedb_pgproto, __pyx_k_edgedb_pgproto, sizeof(__pyx_k_edgedb_pgproto), 0, 0, 1, 1},
  {&__pyx_n_s_edgedb_pgproto_pgproto, __pyx_k_edgedb_pgproto_pgproto, sizeof(__pyx_k_edgedb_pgproto_pgproto), 0, 0, 1, 1},
  {&__pyx_n_s_edgedb_protocol_protocol, __pyx_k_edgedb_protocol_protocol, sizeof(__pyx_k_edgedb_protocol_protocol), 0, 0, 1, 1},
  {&__pyx_kp_u_either_positional_or_named_argum, __pyx_k_either_positional_or_named_argum, sizeof(__pyx_k_either_positional_or_named_argum), 0, 1, 0, 0},
  {&__pyx_kp_u_elements_got, __pyx_k_elements_got, sizeof(__pyx_k_elements_got), 0, 1, 0, 0},
  {&__pyx_kp_u_elements_in_the_tuple_got, __pyx_k_elements_in_the_tuple_got, sizeof(__pyx_k_elements_in_the_tuple_got), 0, 1, 0, 0},
  {&__pyx_kp_u_empty_tuple, __pyx_k_empty_tuple, sizeof(__pyx_k_empty_tuple), 0, 1, 0, 0},
  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  {&__pyx_n_s_encoder, __pyx_k_encoder, sizeof(__pyx_k_encoder), 0, 0, 1, 1},
  {&__pyx_n_s_enum, __pyx_k_enum, sizeof(__pyx_k_enum), 0, 0, 1, 1},
  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__pyx_n_s_enums, __pyx_k_enums, sizeof(__pyx_k_enums), 0, 0, 1, 1},
  {&__pyx_n_s_errors, __pyx_k_errors, sizeof(__pyx_k_errors), 0, 0, 1, 1},
  {&__pyx_n_s_execute, __pyx_k_execute, sizeof(__pyx_k_execute), 0, 0, 1, 1},
  {&__pyx_n_s_execute_anonymous, __pyx_k_execute_anonymous, sizeof(__pyx_k_execute_anonymous), 0, 0, 1, 1},
  {&__pyx_n_s_expect_one, __pyx_k_expect_one, sizeof(__pyx_k_expect_one), 0, 0, 1, 1},
  {&__pyx_kp_u_expected, __pyx_k_expected, sizeof(__pyx_k_expected), 0, 1, 0, 0},
  {&__pyx_kp_u_expected_2, __pyx_k_expected_2, sizeof(__pyx_k_expected_2), 0, 1, 0, 0},
  {&__pyx_kp_u_expected_SASLContinue_from_the_s, __pyx_k_expected_SASLContinue_from_the_s, sizeof(__pyx_k_expected_SASLContinue_from_the_s), 0, 1, 0, 0},
  {&__pyx_kp_u_expected_SASLFinal_from_the_serv, __pyx_k_expected_SASLFinal_from_the_serv, sizeof(__pyx_k_expected_SASLFinal_from_the_serv), 0, 1, 0, 0},
  {&__pyx_kp_u_expected_a_Decimal_or_an_int, __pyx_k_expected_a_Decimal_or_an_int, sizeof(__pyx_k_expected_a_Decimal_or_an_int), 0, 1, 0, 0},
  {&__pyx_kp_u_expected_a_record_with_a_single, __pyx_k_expected_a_record_with_a_single, sizeof(__pyx_k_expected_a_record_with_a_single), 0, 1, 0, 0},
  {&__pyx_kp_u_expected_a_two_dimensional_array, __pyx_k_expected_a_two_dimensional_array, sizeof(__pyx_k_expected_a_two_dimensional_array), 0, 1, 0, 0},
  {&__pyx_kp_u_expected_an_int, __pyx_k_expected_an_int, sizeof(__pyx_k_expected_an_int), 0, 1, 0, 0},
  {&__pyx_kp_u_expected_named_arguments_got_pos, __pyx_k_expected_named_arguments_got_pos, sizeof(__pyx_k_expected_named_arguments_got_pos), 0, 1, 0, 0},
  {&__pyx_kp_u_expected_no_named_arguments, __pyx_k_expected_no_named_arguments, sizeof(__pyx_k_expected_no_named_arguments), 0, 1, 0, 0},
  {&__pyx_kp_u_expected_no_positional_arguments, __pyx_k_expected_no_positional_arguments, sizeof(__pyx_k_expected_no_positional_arguments), 0, 1, 0, 0},
  {&__pyx_kp_u_expected_positional_arguments_go, __pyx_k_expected_positional_arguments_go, sizeof(__pyx_k_expected_positional_arguments_go), 0, 1, 0, 0},
  {&__pyx_kp_u_extra, __pyx_k_extra, sizeof(__pyx_k_extra), 0, 1, 0, 0},
  {&__pyx_n_u_fetchall_json_elements, __pyx_k_fetchall_json_elements, sizeof(__pyx_k_fetchall_json_elements), 0, 1, 0, 1},
  {&__pyx_kp_u_first_message_is_not_DataMsg, __pyx_k_first_message_is_not_DataMsg, sizeof(__pyx_k_first_message_is_not_DataMsg), 0, 1, 0, 0},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_n_s_from_bytes, __pyx_k_from_bytes, sizeof(__pyx_k_from_bytes), 0, 0, 1, 1},
  {&__pyx_n_s_from_code, __pyx_k_from_code, sizeof(__pyx_k_from_code), 0, 0, 1, 1},
  {&__pyx_n_s_generate_nonce, __pyx_k_generate_nonce, sizeof(__pyx_k_generate_nonce), 0, 0, 1, 1},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_get_code, __pyx_k_get_code, sizeof(__pyx_k_get_code), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  {&__pyx_kp_u_got, __pyx_k_got, sizeof(__pyx_k_got), 0, 1, 0, 0},
  {&__pyx_n_s_header, __pyx_k_header, sizeof(__pyx_k_header), 0, 0, 1, 1},
  {&__pyx_kp_u_header_block_after_data_block, __pyx_k_header_block_after_data_block, sizeof(__pyx_k_header_block_after_data_block), 0, 1, 0, 0},
  {&__pyx_kp_u_header_block_was_not_received, __pyx_k_header_block_was_not_received, sizeof(__pyx_k_header_block_was_not_received), 0, 1, 0, 0},
  {&__pyx_n_s_header_callback, __pyx_k_header_callback, sizeof(__pyx_k_header_callback), 0, 0, 1, 1},
  {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
  {&__pyx_n_s_implicit_limit, __pyx_k_implicit_limit, sizeof(__pyx_k_implicit_limit), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_in_dc, __pyx_k_in_dc, sizeof(__pyx_k_in_dc), 0, 0, 1, 1},
  {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
  {&__pyx_n_s_inline_typeids, __pyx_k_inline_typeids, sizeof(__pyx_k_inline_typeids), 0, 0, 1, 1},
  {&__pyx_n_s_inline_typenames, __pyx_k_inline_typenames, sizeof(__pyx_k_inline_typenames), 0, 0, 1, 1},
  {&__pyx_n_s_inspect, __pyx_k_inspect, sizeof(__pyx_k_inspect), 0, 0, 1, 1},
  {&__pyx_kp_u_invalid_array_element, __pyx_k_invalid_array_element, sizeof(__pyx_k_invalid_array_element), 0, 1, 0, 0},
  {&__pyx_kp_u_invalid_array_size_received, __pyx_k_invalid_array_size_received, sizeof(__pyx_k_invalid_array_size_received), 0, 1, 0, 0},
  {&__pyx_kp_u_invalid_buffer_length, __pyx_k_invalid_buffer_length, sizeof(__pyx_k_invalid_buffer_length), 0, 1, 0, 0},
  {&__pyx_kp_u_invalid_input_for_query_argument, __pyx_k_invalid_input_for_query_argument, sizeof(__pyx_k_invalid_input_for_query_argument), 0, 1, 0, 0},
  {&__pyx_kp_u_invalid_input_for_query_argument_2, __pyx_k_invalid_input_for_query_argument_2, sizeof(__pyx_k_invalid_input_for_query_argument_2), 0, 1, 0, 0},
  {&__pyx_kp_u_invalid_number_of_columns_expect, __pyx_k_invalid_number_of_columns_expect, sizeof(__pyx_k_invalid_number_of_columns_expect), 0, 1, 0, 0},
  {&__pyx_n_s_io_format, __pyx_k_io_format, sizeof(__pyx_k_io_format), 0, 0, 1, 1},
  {&__pyx_kp_u_is_already_registered, __pyx_k_is_already_registered, sizeof(__pyx_k_is_already_registered), 0, 1, 0, 0},
  {&__pyx_kp_u_is_required_but_received_None, __pyx_k_is_required_but_received_None, sizeof(__pyx_k_is_required_but_received_None), 0, 1, 0, 0},
  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
  {&__pyx_n_s_json, __pyx_k_json, sizeof(__pyx_k_json), 0, 0, 1, 1},
  {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1},
  {&__pyx_kp_u_keyword_arguments, __pyx_k_keyword_arguments, sizeof(__pyx_k_keyword_arguments), 0, 1, 0, 0},
  {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
  {&__pyx_n_s_last, __pyx_k_last, sizeof(__pyx_k_last), 0, 0, 1, 1},
  {&__pyx_n_s_lookup, __pyx_k_lookup, sizeof(__pyx_k_lookup), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_make_missing_args_error_message, __pyx_k_make_missing_args_error_message, sizeof(__pyx_k_make_missing_args_error_message), 0, 0, 1, 1},
  {&__pyx_n_s_maxsize, __pyx_k_maxsize, sizeof(__pyx_k_maxsize), 0, 0, 1, 1},
  {&__pyx_kp_u_maxsize_is_expected_to_be_greate, __pyx_k_maxsize_is_expected_to_be_greate, sizeof(__pyx_k_maxsize_is_expected_to_be_greate), 0, 1, 0, 0},
  {&__pyx_n_s_members, __pyx_k_members, sizeof(__pyx_k_members), 0, 0, 1, 1},
  {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  {&__pyx_n_s_microseconds, __pyx_k_microseconds, sizeof(__pyx_k_microseconds), 0, 0, 1, 1},
  {&__pyx_kp_u_missed, __pyx_k_missed, sizeof(__pyx_k_missed), 0, 1, 0, 0},
  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  {&__pyx_n_s_months, __pyx_k_months, sizeof(__pyx_k_months), 0, 0, 1, 1},
  {&__pyx_kp_u_more_than_one_header_block, __pyx_k_more_than_one_header_block, sizeof(__pyx_k_more_than_one_header_block), 0, 1, 0, 0},
  {&__pyx_n_s_move_to_end, __pyx_k_move_to_end, sizeof(__pyx_k_move_to_end), 0, 0, 1, 1},
  {&__pyx_n_s_msg, __pyx_k_msg, sizeof(__pyx_k_msg), 0, 0, 1, 1},
  {&__pyx_n_b_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 0, 1},
  {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
  {&__pyx_kp_u_neither_are_supported, __pyx_k_neither_are_supported, sizeof(__pyx_k_neither_are_supported), 0, 1, 0, 0},
  {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  {&__pyx_kp_u_no_codec_implementation_for_Edge, __pyx_k_no_codec_implementation_for_Edge, sizeof(__pyx_k_no_codec_implementation_for_Edge), 0, 1, 0, 0},
  {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
  {&__pyx_kp_u_no_input, __pyx_k_no_input, sizeof(__pyx_k_no_input), 0, 1, 0, 0},
  {&__pyx_kp_u_non_idle_status_after_connect, __pyx_k_non_idle_status_after_connect, sizeof(__pyx_k_non_idle_status_after_connect), 0, 1, 0, 0},
  {&__pyx_kp_u_non_zero_reserved_bytes_in_durat, __pyx_k_non_zero_reserved_bytes_in_durat, sizeof(__pyx_k_non_zero_reserved_bytes_in_durat), 0, 1, 0, 0},
  {&__pyx_kp_u_not_connected, __pyx_k_not_connected, sizeof(__pyx_k_not_connected), 0, 1, 0, 0},
  {&__pyx_n_u_null, __pyx_k_null, sizeof(__pyx_k_null), 0, 1, 0, 1},
  {&__pyx_kp_u_null_codec, __pyx_k_null_codec, sizeof(__pyx_k_null_codec), 0, 1, 0, 0},
  {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
  {&__pyx_n_s_on_log_message, __pyx_k_on_log_message, sizeof(__pyx_k_on_log_message), 0, 0, 1, 1},
  {&__pyx_kp_u_only_1_dimensional_arrays_are_su, __pyx_k_only_1_dimensional_arrays_are_su, sizeof(__pyx_k_only_1_dimensional_arrays_are_su), 0, 1, 0, 0},
  {&__pyx_kp_u_only_arrays_of_scalars_are_suppo, __pyx_k_only_arrays_of_scalars_are_suppo, sizeof(__pyx_k_only_arrays_of_scalars_are_suppo), 0, 1, 0, 0},
  {&__pyx_n_s_optimistic_execute, __pyx_k_optimistic_execute, sizeof(__pyx_k_optimistic_execute), 0, 0, 1, 1},
  {&__pyx_n_s_out_dc, __pyx_k_out_dc, sizeof(__pyx_k_out_dc), 0, 0, 1, 1},
  {&__pyx_n_s_parents, __pyx_k_parents, sizeof(__pyx_k_parents), 0, 0, 1, 1},
  {&__pyx_n_s_parse, __pyx_k_parse, sizeof(__pyx_k_parse), 0, 0, 1, 1},
  {&__pyx_n_s_parse_server_final_message, __pyx_k_parse_server_final_message, sizeof(__pyx_k_parse_server_final_message), 0, 0, 1, 1},
  {&__pyx_n_s_parse_server_first_message, __pyx_k_parse_server_first_message, sizeof(__pyx_k_parse_server_first_message), 0, 0, 1, 1},
  {&__pyx_n_s_password, __pyx_k_password, sizeof(__pyx_k_password), 0, 0, 1, 1},
  {&__pyx_n_s_pgproto, __pyx_k_pgproto, sizeof(__pyx_k_pgproto), 0, 0, 1, 1},
  {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
  {&__pyx_n_s_popitem, __pyx_k_popitem, sizeof(__pyx_k_popitem), 0, 0, 1, 1},
  {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  {&__pyx_n_u_python, __pyx_k_python, sizeof(__pyx_k_python), 0, 1, 0, 1},
  {&__pyx_kp_u_python_is_the_only_valid_format, __pyx_k_python_is_the_only_valid_format, sizeof(__pyx_k_python_is_the_only_valid_format), 0, 1, 0, 0},
  {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_CodecsRegistry, __pyx_k_pyx_unpickle_CodecsRegistry, sizeof(__pyx_k_pyx_unpickle_CodecsRegistry), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_LRUMapping, __pyx_k_pyx_unpickle_LRUMapping, sizeof(__pyx_k_pyx_unpickle_LRUMapping), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_QueryCodecsCache, __pyx_k_pyx_unpickle_QueryCodecsCache, sizeof(__pyx_k_pyx_unpickle_QueryCodecsCache), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_SansIOProtocol, __pyx_k_pyx_unpickle_SansIOProtocol, sizeof(__pyx_k_pyx_unpickle_SansIOProtocol), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle___Pyx_EnumMeta, __pyx_k_pyx_unpickle___Pyx_EnumMeta, sizeof(__pyx_k_pyx_unpickle___Pyx_EnumMeta), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_qc, __pyx_k_qc, sizeof(__pyx_k_qc), 0, 0, 1, 1},
  {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  {&__pyx_n_s_query, __pyx_k_query, sizeof(__pyx_k_query), 0, 0, 1, 1},
  {&__pyx_kp_u_query_cannot_be_executed_with, __pyx_k_query_cannot_be_executed_with, sizeof(__pyx_k_query_cannot_be_executed_with), 0, 1, 0, 0},
  {&__pyx_kp_u_query_executed_via, __pyx_k_query_executed_via, sizeof(__pyx_k_query_executed_via), 0, 1, 0, 0},
  {&__pyx_n_u_query_required_single, __pyx_k_query_required_single, sizeof(__pyx_k_query_required_single), 0, 1, 0, 1},
  {&__pyx_n_u_query_required_single_json, __pyx_k_query_required_single_json, sizeof(__pyx_k_query_required_single_json), 0, 1, 0, 1},
  {&__pyx_n_u_query_single, __pyx_k_query_single, sizeof(__pyx_k_query_single), 0, 1, 0, 1},
  {&__pyx_n_u_query_single_json, __pyx_k_query_single_json, sizeof(__pyx_k_query_single_json), 0, 1, 0, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  {&__pyx_n_s_ref, __pyx_k_ref, sizeof(__pyx_k_ref), 0, 0, 1, 1},
  {&__pyx_n_s_reg, __pyx_k_reg, sizeof(__pyx_k_reg), 0, 0, 1, 1},
  {&__pyx_n_s_repr, __pyx_k_repr, sizeof(__pyx_k_repr), 0, 0, 1, 1},
  {&__pyx_n_s_required_one, __pyx_k_required_one, sizeof(__pyx_k_required_one), 0, 0, 1, 1},
  {&__pyx_n_s_res, __pyx_k_res, sizeof(__pyx_k_res), 0, 0, 1, 1},
  {&__pyx_n_s_restore, __pyx_k_restore, sizeof(__pyx_k_restore), 0, 0, 1, 1},
  {&__pyx_kp_u_result_is_not_an_edgedb_Set_but, __pyx_k_result_is_not_an_edgedb_Set_but, sizeof(__pyx_k_result_is_not_an_edgedb_Set_but), 0, 1, 0, 0},
  {&__pyx_kp_u_returned_no_data, __pyx_k_returned_no_data, sizeof(__pyx_k_returned_no_data), 0, 1, 0, 0},
  {&__pyx_n_s_reversed, __pyx_k_reversed, sizeof(__pyx_k_reversed), 0, 0, 1, 1},
  {&__pyx_kp_s_s_s, __pyx_k_s_s, sizeof(__pyx_k_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s_d, __pyx_k_s_s_d, sizeof(__pyx_k_s_s_d), 0, 0, 1, 0},
  {&__pyx_n_s_scram, __pyx_k_scram, sizeof(__pyx_k_scram), 0, 0, 1, 1},
  {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  {&__pyx_kp_u_server_SCRAM_proof_does_not_matc, __pyx_k_server_SCRAM_proof_does_not_matc, sizeof(__pyx_k_server_SCRAM_proof_does_not_matc), 0, 1, 0, 0},
  {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_simple_query, __pyx_k_simple_query, sizeof(__pyx_k_simple_query), 0, 0, 1, 1},
  {&__pyx_n_u_std, __pyx_k_std, sizeof(__pyx_k_std), 0, 1, 0, 1},
  {&__pyx_kp_u_std_bigint, __pyx_k_std_bigint, sizeof(__pyx_k_std_bigint), 0, 1, 0, 0},
  {&__pyx_kp_u_std_bool, __pyx_k_std_bool, sizeof(__pyx_k_std_bool), 0, 1, 0, 0},
  {&__pyx_kp_u_std_bytes, __pyx_k_std_bytes, sizeof(__pyx_k_std_bytes), 0, 1, 0, 0},
  {&__pyx_kp_u_std_datetime, __pyx_k_std_datetime, sizeof(__pyx_k_std_datetime), 0, 1, 0, 0},
  {&__pyx_kp_u_std_decimal, __pyx_k_std_decimal, sizeof(__pyx_k_std_decimal), 0, 1, 0, 0},
  {&__pyx_kp_u_std_duration, __pyx_k_std_duration, sizeof(__pyx_k_std_duration), 0, 1, 0, 0},
  {&__pyx_kp_u_std_float32, __pyx_k_std_float32, sizeof(__pyx_k_std_float32), 0, 1, 0, 0},
  {&__pyx_kp_u_std_float64, __pyx_k_std_float64, sizeof(__pyx_k_std_float64), 0, 1, 0, 0},
  {&__pyx_kp_u_std_int16, __pyx_k_std_int16, sizeof(__pyx_k_std_int16), 0, 1, 0, 0},
  {&__pyx_kp_u_std_int32, __pyx_k_std_int32, sizeof(__pyx_k_std_int32), 0, 1, 0, 0},
  {&__pyx_kp_u_std_int64, __pyx_k_std_int64, sizeof(__pyx_k_std_int64), 0, 1, 0, 0},
  {&__pyx_kp_u_std_json, __pyx_k_std_json, sizeof(__pyx_k_std_json), 0, 1, 0, 0},
  {&__pyx_kp_u_std_str, __pyx_k_std_str, sizeof(__pyx_k_std_str), 0, 1, 0, 0},
  {&__pyx_kp_u_std_uuid, __pyx_k_std_uuid, sizeof(__pyx_k_std_uuid), 0, 1, 0, 0},
  {&__pyx_n_s_str, __pyx_k_str, sizeof(__pyx_k_str), 0, 0, 1, 1},
  {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
  {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
  {&__pyx_n_u_suggested_pool_concurrency, __pyx_k_suggested_pool_concurrency, sizeof(__pyx_k_suggested_pool_concurrency), 0, 1, 0, 1},
  {&__pyx_n_s_sync, __pyx_k_sync, sizeof(__pyx_k_sync), 0, 0, 1, 1},
  {&__pyx_n_u_system_config, __pyx_k_system_config, sizeof(__pyx_k_system_config), 0, 1, 0, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_kp_u_the_connection_has_been_closed, __pyx_k_the_connection_has_been_closed, sizeof(__pyx_k_the_connection_has_been_closed), 0, 1, 0, 0},
  {&__pyx_kp_u_the_connection_has_been_closed_b, __pyx_k_the_connection_has_been_closed_b, sizeof(__pyx_k_the_connection_has_been_closed_b), 0, 1, 0, 0},
  {&__pyx_kp_u_the_protocol_version_requires_TL, __pyx_k_the_protocol_version_requires_TL, sizeof(__pyx_k_the_protocol_version_requires_TL), 0, 1, 0, 0},
  {&__pyx_kp_u_the_server_offered_the_following, __pyx_k_the_server_offered_the_following, sizeof(__pyx_k_the_server_offered_the_following), 0, 1, 0, 0},
  {&__pyx_kp_u_the_server_requested_SASL_authen, __pyx_k_the_server_requested_SASL_authen, sizeof(__pyx_k_the_server_requested_SASL_authen), 0, 1, 0, 0},
  {&__pyx_kp_u_the_server_requested_an_unsuppor, __pyx_k_the_server_requested_an_unsuppor, sizeof(__pyx_k_the_server_requested_an_unsuppor), 0, 1, 0, 0},
  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  {&__pyx_n_s_time, __pyx_k_time, sizeof(__pyx_k_time), 0, 0, 1, 1},
  {&__pyx_n_s_timedelta, __pyx_k_timedelta, sizeof(__pyx_k_timedelta), 0, 0, 1, 1},
  {&__pyx_n_s_tls_compat, __pyx_k_tls_compat, sizeof(__pyx_k_tls_compat), 0, 0, 1, 1},
  {&__pyx_kp_u_too_many_elements_for_a_tuple, __pyx_k_too_many_elements_for_a_tuple, sizeof(__pyx_k_too_many_elements_for_a_tuple), 0, 1, 0, 0},
  {&__pyx_kp_u_too_many_elements_in_array_value, __pyx_k_too_many_elements_in_array_value, sizeof(__pyx_k_too_many_elements_in_array_value), 0, 1, 0, 0},
  {&__pyx_n_s_try_recv_eagerly, __pyx_k_try_recv_eagerly, sizeof(__pyx_k_try_recv_eagerly), 0, 0, 1, 1},
  {&__pyx_n_s_typeid, __pyx_k_typeid, sizeof(__pyx_k_typeid), 0, 0, 1, 1},
  {&__pyx_kp_u_typeid_must_be_a_UUID, __pyx_k_typeid_must_be_a_UUID, sizeof(__pyx_k_typeid_must_be_a_UUID), 0, 1, 0, 0},
  {&__pyx_n_s_types, __pyx_k_types, sizeof(__pyx_k_types), 0, 0, 1, 1},
  {&__pyx_n_s_typing, __pyx_k_typing, sizeof(__pyx_k_typing), 0, 0, 1, 1},
  {&__pyx_n_u_tzinfo, __pyx_k_tzinfo, sizeof(__pyx_k_tzinfo), 0, 1, 0, 1},
  {&__pyx_kp_u_unable_to_decode_data_to_Python, __pyx_k_unable_to_decode_data_to_Python, sizeof(__pyx_k_unable_to_decode_data_to_Python), 0, 1, 0, 0},
  {&__pyx_kp_u_unexpected_NULL_value_in_array_s, __pyx_k_unexpected_NULL_value_in_array_s, sizeof(__pyx_k_unexpected_NULL_value_in_array_s), 0, 1, 0, 0},
  {&__pyx_kp_u_unexpected_message_type, __pyx_k_unexpected_message_type, sizeof(__pyx_k_unexpected_message_type), 0, 1, 0, 0},
  {&__pyx_kp_u_unexpected_query_argument_codec, __pyx_k_unexpected_query_argument_codec, sizeof(__pyx_k_unexpected_query_argument_codec), 0, 1, 0, 0},
  {&__pyx_kp_u_unexpected_trailing_data_in_buff, __pyx_k_unexpected_trailing_data_in_buff, sizeof(__pyx_k_unexpected_trailing_data_in_buff), 0, 1, 0, 0},
  {&__pyx_kp_u_unexpected_trailing_data_in_buff_2, __pyx_k_unexpected_trailing_data_in_buff_2, sizeof(__pyx_k_unexpected_trailing_data_in_buff_2), 0, 1, 0, 0},
  {&__pyx_kp_u_unexpected_trailing_data_in_buff_3, __pyx_k_unexpected_trailing_data_in_buff_3, sizeof(__pyx_k_unexpected_trailing_data_in_buff_3), 0, 1, 0, 0},
  {&__pyx_kp_u_unexpected_trailing_data_in_buff_4, __pyx_k_unexpected_trailing_data_in_buff_4, sizeof(__pyx_k_unexpected_trailing_data_in_buff_4), 0, 1, 0, 0},
  {&__pyx_kp_u_unexpected_trailing_data_in_buff_5, __pyx_k_unexpected_trailing_data_in_buff_5, sizeof(__pyx_k_unexpected_trailing_data_in_buff_5), 0, 1, 0, 0},
  {&__pyx_kp_u_unexpected_trailing_data_in_buff_6, __pyx_k_unexpected_trailing_data_in_buff_6, sizeof(__pyx_k_unexpected_trailing_data_in_buff_6), 0, 1, 0, 0},
  {&__pyx_kp_u_unsupported_authentication_metho, __pyx_k_unsupported_authentication_metho, sizeof(__pyx_k_unsupported_authentication_metho), 0, 1, 0, 0},
  {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {&__pyx_n_s_user, __pyx_k_user, sizeof(__pyx_k_user), 0, 0, 1, 1},
  {&__pyx_n_u_user, __pyx_k_user, sizeof(__pyx_k_user), 0, 1, 0, 1},
  {&__pyx_kp_u_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 1, 0, 0},
  {&__pyx_n_s_uuid, __pyx_k_uuid, sizeof(__pyx_k_uuid), 0, 0, 1, 1},
  {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1},
  {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1},
  {&__pyx_n_s_wait_for_connect, __pyx_k_wait_for_connect, sizeof(__pyx_k_wait_for_connect), 0, 0, 1, 1},
  {&__pyx_n_s_wait_for_message, __pyx_k_wait_for_message, sizeof(__pyx_k_wait_for_message), 0, 0, 1, 1},
  {&__pyx_n_s_weakref, __pyx_k_weakref, sizeof(__pyx_k_weakref), 0, 0, 1, 1},
  {&__pyx_n_s_zfill, __pyx_k_zfill, sizeof(__pyx_k_zfill), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 23, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 48, __pyx_L1_error)
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 36, __pyx_L1_error)
  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(1, 44, __pyx_L1_error)
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(2, 2, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(1, 170, __pyx_L1_error)
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(1, 200, __pyx_L1_error)
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(3, 84, __pyx_L1_error)
  __pyx_builtin_LookupError = __Pyx_GetBuiltinName(__pyx_n_s_LookupError); if (!__pyx_builtin_LookupError) __PYX_ERR(4, 299, __pyx_L1_error)
  __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(4, 344, __pyx_L1_error)
  __pyx_builtin_reversed = __Pyx_GetBuiltinName(__pyx_n_s_reversed); if (!__pyx_builtin_reversed) __PYX_ERR(4, 526, __pyx_L1_error)
  __pyx_builtin_chr = __Pyx_GetBuiltinName(__pyx_n_s_chr); if (!__pyx_builtin_chr) __PYX_ERR(5, 1157, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "edgedb/protocol/codecs/base.pyx":36
 * 
 *     def __init__(self):
 *         raise RuntimeError(             # <<<<<<<<<<<<<<
 *             'codecs are not supposed to be instantiated directly')
 * 
 */
  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_codecs_are_not_supposed_to_be_in); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "edgedb/protocol/codecs/base.pyx":139
 * 
 *         if self.encoder_flags & RECORD_ENCODER_INVALID:
 *             raise TypeError(             # <<<<<<<<<<<<<<
 *                 'argument tuples only support scalars and arrays of scalars')
 * 
 */
  __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_u_argument_tuples_only_support_sca); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(1, 139, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "edgedb/protocol/codecs/base.pyx":162
 * 
 *         if objlen > _MAXINT32:
 *             raise ValueError('too many elements for a tuple')             # <<<<<<<<<<<<<<
 * 
 *         if objlen != len(self.fields_codecs):
 */
  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_u_too_many_elements_for_a_tuple); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "edgedb/protocol/codecs/base.pyx":182
 *                     value_repr = repr(item)
 *                     if len(value_repr) > 40:
 *                         value_repr = value_repr[:40] + '...'             # <<<<<<<<<<<<<<
 *                     raise errors.InvalidArgumentError(
 *                         'invalid input for query argument'
 */
  __pyx_slice__13 = PySlice_New(Py_None, __pyx_int_40, Py_None); if (unlikely(!__pyx_slice__13)) __PYX_ERR(1, 182, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__13);
  __Pyx_GIVEREF(__pyx_slice__13);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);

  /* "edgedb/protocol/codecs/array.pyx":48
 * 
 *         if not isinstance(self.sub_codec, ScalarCodec):
 *             raise TypeError('only arrays of scalars are supported')             # <<<<<<<<<<<<<<
 * 
 *         if not _is_array_iterable(obj):
 */
  __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_u_only_arrays_of_scalars_are_suppo); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(9, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);

  /* "edgedb/protocol/codecs/array.pyx":57
 *         objlen = len(obj)
 *         if objlen > _MAXINT32:
 *             raise ValueError('too many elements in array value')             # <<<<<<<<<<<<<<
 * 
 *         elem_data = WriteBuffer.new()
 */
  __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_u_too_many_elements_in_array_value); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(9, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);

  /* "edgedb/protocol/codecs/array.pyx":98
 * 
 *         if ndims > 1:
 *             raise RuntimeError('only 1-dimensional arrays are supported')             # <<<<<<<<<<<<<<
 * 
 *         if ndims == 0:
 */
  __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_u_only_1_dimensional_arrays_are_su); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(9, 98, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);

  /* "edgedb/protocol/codecs/set.pyx":71
 *             return self._new_collection(0)
 *         elif ndims > 1:
 *             raise RuntimeError('expected a two-dimensional array for a '             # <<<<<<<<<<<<<<
 *                                'set of arrays')
 * 
 */
  __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_u_expected_a_two_dimensional_array); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(10, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);

  /* "edgedb/protocol/codecs/set.pyx":83
 *             recsize = <Py_ssize_t><uint32_t>hton.unpack_int32(frb_read(buf, 4))
 *             if recsize != 1:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'expected a record with a single element as an array set '
 *                     'element envelope')
 */
  __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_u_expected_a_record_with_a_single); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(10, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "edgedb/protocol/codecs/set.pyx":91
 *             elem_len = hton.unpack_int32(frb_read(buf, 4))
 *             if elem_len == -1:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'unexpected NULL value in array set element ')
 * 
 */
  __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_u_unexpected_NULL_value_in_array_s); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(10, 91, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);

  /* "edgedb/protocol/codecs/codecs.pyx":71
 *     def set_type_codec(self, typeid, *, encoder, decoder, format):
 *         if format != 'python':
 *             raise ValueError('"python" is the only valid format')             # <<<<<<<<<<<<<<
 *         if not isinstance(typeid, uuid.UUID):
 *             raise TypeError('typeid must be a UUID')
 */
  __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_u_python_is_the_only_valid_format); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(4, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);

  /* "edgedb/protocol/codecs/codecs.pyx":73
 *             raise ValueError('"python" is the only valid format')
 *         if not isinstance(typeid, uuid.UUID):
 *             raise TypeError('typeid must be a UUID')             # <<<<<<<<<<<<<<
 *         basecodec = BASE_SCALAR_CODECS.get(typeid.bytes)
 *         if basecodec is None:
 */
  __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_u_typeid_must_be_a_UUID); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(4, 73, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);

  /* "edgedb/protocol/codecs/codecs.pyx":111
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 for i in range(els):
 *                     if protocol_version >= (0, 11):             # <<<<<<<<<<<<<<
 *                         frb_read(spec, 4)  # flags
 *                         frb_read(spec, 1)  # cardinality
 */
  __pyx_tuple__50 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_11); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(4, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);

  /* "edgedb/protocol/codecs/codecs.pyx":142
 *                 els = <uint16_t>hton.unpack_int16(frb_read(spec, 2))
 *                 if els != 1:
 *                     raise NotImplementedError(             # <<<<<<<<<<<<<<
 *                         'cannot handle arrays with more than one dimension')
 *                 # First dimension length.
 */
  __pyx_tuple__51 = PyTuple_Pack(1, __pyx_kp_u_cannot_handle_arrays_with_more_t); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(4, 142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);

  /* "edgedb/protocol/codecs/codecs.pyx":322
 * 
 *         if not codecs_list:
 *             raise RuntimeError(f'cannot not build codec; empty type desc')             # <<<<<<<<<<<<<<
 * 
 *         return codecs_list[-1]
 */
  __pyx_tuple__52 = PyTuple_Pack(1, __pyx_kp_u_cannot_not_build_codec_empty_typ); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(4, 322, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);

  /* "edgedb/protocol/codecs/codecs.pyx":352
 * cdef time_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     if getattr(obj, 'tzinfo', None) is not None:
 *         raise TypeError(             # <<<<<<<<<<<<<<
 *             f'a naive time object (tzinfo is None) was expected')
 * 
 */
  __pyx_tuple__53 = PyTuple_Pack(1, __pyx_kp_u_a_naive_time_object_tzinfo_is_No); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(4, 352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__53);
  __Pyx_GIVEREF(__pyx_tuple__53);

  /* "edgedb/protocol/codecs/codecs.pyx":363
 *     # let's ensure it doesn't have tzinfo anyways.
 *     if getattr(obj, 'tzinfo', None) is not None:
 *         raise TypeError(             # <<<<<<<<<<<<<<
 *             f'a naive date object (tzinfo is None) was expected')
 * 
 */
  __pyx_tuple__54 = PyTuple_Pack(1, __pyx_kp_u_a_naive_date_object_tzinfo_is_No); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(4, 363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__54);
  __Pyx_GIVEREF(__pyx_tuple__54);

  /* "edgedb/protocol/codecs/codecs.pyx":375
 * 
 *     if getattr(obj, 'tzinfo', None) is not None:
 *         raise TypeError(             # <<<<<<<<<<<<<<
 *             f'a naive datetime object (tzinfo is None) was expected')
 * 
 */
  __pyx_tuple__55 = PyTuple_Pack(1, __pyx_kp_u_a_naive_datetime_object_tzinfo_i); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(4, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);

  /* "edgedb/protocol/codecs/codecs.pyx":383
 * cdef timestamptz_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 *     if not cpython.datetime.PyDateTime_Check(obj):
 *         raise TypeError(             # <<<<<<<<<<<<<<
 *             f'a datetime.datetime object was expected')
 * 
 */
  __pyx_tuple__56 = PyTuple_Pack(1, __pyx_kp_u_a_datetime_datetime_object_was_e_2); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(4, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__56);
  __Pyx_GIVEREF(__pyx_tuple__56);

  /* "edgedb/protocol/codecs/codecs.pyx":387
 * 
 *     if getattr(obj, 'tzinfo', None) is None:
 *         raise TypeError(             # <<<<<<<<<<<<<<
 *             f'a timezone-aware datetime object (tzinfo is not None) '
 *             f'was expected')
 */
  __pyx_tuple__57 = PyTuple_Pack(1, __pyx_kp_u_a_timezone_aware_datetime_object); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(4, 387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_GIVEREF(__pyx_tuple__57);

  /* "edgedb/protocol/codecs/codecs.pyx":415
 *     months = hton.unpack_int32(frb_read(buf, 4))
 *     if days != 0 or months != 0:
 *         raise RuntimeError(f'non-zero reserved bytes in duration')             # <<<<<<<<<<<<<<
 * 
 *     return datetime.timedelta(microseconds=microseconds)
 */
  __pyx_tuple__58 = PyTuple_Pack(1, __pyx_kp_u_non_zero_reserved_bytes_in_durat); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(4, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__58);
  __Pyx_GIVEREF(__pyx_tuple__58);

  /* "edgedb/protocol/codecs/codecs.pyx":471
 * ):
 *     if not isinstance(obj, decimal.Decimal) and not isinstance(obj, int):
 *         raise TypeError('expected a Decimal or an int')             # <<<<<<<<<<<<<<
 *     pgproto.numeric_encode_binary(settings, buf, obj)
 * 
 */
  __pyx_tuple__59 = PyTuple_Pack(1, __pyx_kp_u_expected_a_Decimal_or_an_int); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(4, 471, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);

  /* "edgedb/protocol/codecs/codecs.pyx":481
 * cdef ensure_is_int(obj):
 *     if type(obj) is not int and not isinstance(obj, int):
 *         raise TypeError('expected an int')             # <<<<<<<<<<<<<<
 * 
 * cdef checked_int2_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
 */
  __pyx_tuple__60 = PyTuple_Pack(1, __pyx_kp_u_expected_an_int); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(4, 481, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__60);
  __Pyx_GIVEREF(__pyx_tuple__60);

  /* "edgedb/protocol/codecs/codecs.pyx":543
 *         result = '-'
 *     elif sign != NUMERIC_POS:
 *         raise ValueError("bad bigint sign data")             # <<<<<<<<<<<<<<
 * 
 *     if dscale != 0:
 */
  __pyx_tuple__63 = PyTuple_Pack(1, __pyx_kp_u_bad_bigint_sign_data); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(4, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);

  /* "edgedb/protocol/codecs/codecs.pyx":546
 * 
 *     if dscale != 0:
 *         raise ValueError("bigint data has fractional part")             # <<<<<<<<<<<<<<
 * 
 *     if ndigits == 0:
 */
  __pyx_tuple__64 = PyTuple_Pack(1, __pyx_kp_u_bigint_data_has_fractional_part); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(4, 546, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__64);
  __Pyx_GIVEREF(__pyx_tuple__64);

  /* "edgedb/protocol/protocol.pyx":144
 *         self.server_settings = {}
 *         self.reset_status()
 *         self.protocol_version = (PROTO_VER_MAJOR, 0)             # <<<<<<<<<<<<<<
 * 
 *     cdef reset_status(self):
 */
  __pyx_tuple__65 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_0); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(5, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);

  /* "edgedb/protocol/protocol.pyx":248
 * 
 *         if not self.connected:
 *             raise RuntimeError('not connected')             # <<<<<<<<<<<<<<
 * 
 *         buf = WriteBuffer.new_message(PREPARE_MSG)
 */
  __pyx_tuple__67 = PyTuple_Pack(1, __pyx_kp_u_not_connected); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(5, 248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__67);
  __Pyx_GIVEREF(__pyx_tuple__67);

  /* "edgedb/protocol/protocol.pyx":744
 *                 if mtype == DUMP_BLOCK_MSG:
 *                     if not header_received:
 *                         raise RuntimeError('data block before header block')             # <<<<<<<<<<<<<<
 *                     data_received = True
 * 
 */
  __pyx_tuple__69 = PyTuple_Pack(1, __pyx_kp_u_data_block_before_header_block); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(5, 744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__69);
  __Pyx_GIVEREF(__pyx_tuple__69);

  /* "edgedb/protocol/protocol.pyx":753
 *                 elif mtype == DUMP_HEADER_BLOCK_MSG:
 *                     if header_received:
 *                         raise RuntimeError('more than one header block')             # <<<<<<<<<<<<<<
 *                     if data_received:
 *                         raise RuntimeError('header block after data block')
 */
  __pyx_tuple__70 = PyTuple_Pack(1, __pyx_kp_u_more_than_one_header_block); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(5, 753, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__70);
  __Pyx_GIVEREF(__pyx_tuple__70);

  /* "edgedb/protocol/protocol.pyx":755
 *                         raise RuntimeError('more than one header block')
 *                     if data_received:
 *                         raise RuntimeError('header block after data block')             # <<<<<<<<<<<<<<
 * 
 *                     header_received = True
 */
  __pyx_tuple__71 = PyTuple_Pack(1, __pyx_kp_u_header_block_after_data_block); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(5, 755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__71);
  __Pyx_GIVEREF(__pyx_tuple__71);

  /* "edgedb/protocol/protocol.pyx":781
 * 
 *         if not header_received:
 *             raise RuntimeError('header block was not received')             # <<<<<<<<<<<<<<
 * 
 *         if exc is not None:
 */
  __pyx_tuple__72 = PyTuple_Pack(1, __pyx_kp_u_header_block_was_not_received); if (unlikely(!__pyx_tuple__72)) __PYX_ERR(5, 781, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__72);
  __Pyx_GIVEREF(__pyx_tuple__72);

  /* "edgedb/protocol/protocol.pyx":902
 * 
 *         if self.connected:
 *             raise RuntimeError('already connected')             # <<<<<<<<<<<<<<
 * 
 *         # protocol version
 */
  __pyx_tuple__73 = PyTuple_Pack(1, __pyx_kp_u_already_connected); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(5, 902, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__73);
  __Pyx_GIVEREF(__pyx_tuple__73);

  /* "edgedb/protocol/protocol.pyx":908
 *         handshake_buf.write_int16(PROTO_VER_MAJOR)
 *         handshake_buf.write_int16(PROTO_VER_MINOR)
 *         self.protocol_version = (PROTO_VER_MAJOR, PROTO_VER_MINOR)             # <<<<<<<<<<<<<<
 * 
 *         # params
 */
  __pyx_tuple__74 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_13); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(5, 908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__74);
  __Pyx_GIVEREF(__pyx_tuple__74);

  /* "edgedb/protocol/protocol.pyx":974
 *                     break
 *                 else:
 *                     raise RuntimeError('non-idle status after connect')             # <<<<<<<<<<<<<<
 * 
 *             else:
 */
  __pyx_tuple__76 = PyTuple_Pack(1, __pyx_kp_u_non_idle_status_after_connect); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(5, 974, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__76);
  __Pyx_GIVEREF(__pyx_tuple__76);

  /* "edgedb/protocol/protocol.pyx":992
 *         num_methods = self.buffer.read_int32()
 *         if num_methods <= 0:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 'the server requested SASL authentication but did not '
 *                 'offer any methods')
 */
  __pyx_tuple__77 = PyTuple_Pack(1, __pyx_kp_u_the_server_requested_SASL_authen); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(5, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__77);
  __Pyx_GIVEREF(__pyx_tuple__77);

  /* "edgedb/protocol/protocol.pyx":1088
 * 
 *         if server_sig != expected_server_sig:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 f'server SCRAM proof does not match')
 * 
 */
  __pyx_tuple__79 = PyTuple_Pack(1, __pyx_kp_u_server_SCRAM_proof_does_not_matc); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(5, 1088, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);

  /* "edgedb/protocol/protocol.pyx":1170
 *         in_dc_type = type(in_dc)
 * 
 *         if self.protocol_version >= (0, 12):             # <<<<<<<<<<<<<<
 *             if in_dc_type in {NullCodec, EmptyTupleCodec}:
 *                 # TODO: drop EmptyTupleCodec when 1.0 RC1 is released.
 */
  __pyx_tuple__80 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_12); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(5, 1170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__80);
  __Pyx_GIVEREF(__pyx_tuple__80);

  /* "edgedb/protocol/protocol.pyx":1273
 *         if PG_DEBUG:
 *             if buf.get_message_type() != DATA_MSG:
 *                 raise RuntimeError('first message is not "DataMsg"')             # <<<<<<<<<<<<<<
 * 
 *             if not datatypes.set_check(result):
 */
  __pyx_tuple__81 = PyTuple_Pack(1, __pyx_kp_u_first_message_is_not_DataMsg); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(5, 1273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__81);
  __Pyx_GIVEREF(__pyx_tuple__81);

  /* "edgedb/protocol/protocol.pyx":1296
 *                 buflen = hton.unpack_int32(frb_read(rbuf, 4))
 *                 if frb_get_len(rbuf) != buflen:
 *                     raise RuntimeError('invalid buffer length')             # <<<<<<<<<<<<<<
 *             else:
 *                 # EdgeDB returns rows with one column; Postgres' rows
 */
  __pyx_tuple__82 = PyTuple_Pack(1, __pyx_kp_u_invalid_buffer_length); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(5, 1296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__82);
  __Pyx_GIVEREF(__pyx_tuple__82);

  /* "edgedb/protocol/codecs/edb_types.pxi":9
 * 
 * TYPE_IDS = {
 *     'anytype': uuid.UUID('00000000-0000-0000-0000-000000000001'),             # <<<<<<<<<<<<<<
 *     'anytuple': uuid.UUID('00000000-0000-0000-0000-000000000002'),
 *     'std': uuid.UUID('00000000-0000-0000-0000-0000000000f0'),
 */
  __pyx_tuple__83 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__83);
  __Pyx_GIVEREF(__pyx_tuple__83);

  /* "edgedb/protocol/codecs/edb_types.pxi":10
 * TYPE_IDS = {
 *     'anytype': uuid.UUID('00000000-0000-0000-0000-000000000001'),
 *     'anytuple': uuid.UUID('00000000-0000-0000-0000-000000000002'),             # <<<<<<<<<<<<<<
 *     'std': uuid.UUID('00000000-0000-0000-0000-0000000000f0'),
 *     'empty-tuple': uuid.UUID('00000000-0000-0000-0000-0000000000ff'),
 */
  __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_2); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(22, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__84);
  __Pyx_GIVEREF(__pyx_tuple__84);

  /* "edgedb/protocol/codecs/edb_types.pxi":11
 *     'anytype': uuid.UUID('00000000-0000-0000-0000-000000000001'),
 *     'anytuple': uuid.UUID('00000000-0000-0000-0000-000000000002'),
 *     'std': uuid.UUID('00000000-0000-0000-0000-0000000000f0'),             # <<<<<<<<<<<<<<
 *     'empty-tuple': uuid.UUID('00000000-0000-0000-0000-0000000000ff'),
 *     'std::uuid': uuid.UUID('00000000-0000-0000-0000-000000000100'),
 */
  __pyx_tuple__85 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_3); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(22, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__85);
  __Pyx_GIVEREF(__pyx_tuple__85);

  /* "edgedb/protocol/codecs/edb_types.pxi":12
 *     'anytuple': uuid.UUID('00000000-0000-0000-0000-000000000002'),
 *     'std': uuid.UUID('00000000-0000-0000-0000-0000000000f0'),
 *     'empty-tuple': uuid.UUID('00000000-0000-0000-0000-0000000000ff'),             # <<<<<<<<<<<<<<
 *     'std::uuid': uuid.UUID('00000000-0000-0000-0000-000000000100'),
 *     'std::str': uuid.UUID('00000000-0000-0000-0000-000000000101'),
 */
  __pyx_tuple__86 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_4); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(22, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__86);
  __Pyx_GIVEREF(__pyx_tuple__86);

  /* "edgedb/protocol/codecs/edb_types.pxi":13
 *     'std': uuid.UUID('00000000-0000-0000-0000-0000000000f0'),
 *     'empty-tuple': uuid.UUID('00000000-0000-0000-0000-0000000000ff'),
 *     'std::uuid': uuid.UUID('00000000-0000-0000-0000-000000000100'),             # <<<<<<<<<<<<<<
 *     'std::str': uuid.UUID('00000000-0000-0000-0000-000000000101'),
 *     'std::bytes': uuid.UUID('00000000-0000-0000-0000-000000000102'),
 */
  __pyx_tuple__87 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_5); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(22, 13, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__87);
  __Pyx_GIVEREF(__pyx_tuple__87);

  /* "edgedb/protocol/codecs/edb_types.pxi":14
 *     'empty-tuple': uuid.UUID('00000000-0000-0000-0000-0000000000ff'),
 *     'std::uuid': uuid.UUID('00000000-0000-0000-0000-000000000100'),
 *     'std::str': uuid.UUID('00000000-0000-0000-0000-000000000101'),             # <<<<<<<<<<<<<<
 *     'std::bytes': uuid.UUID('00000000-0000-0000-0000-000000000102'),
 *     'std::int16': uuid.UUID('00000000-0000-0000-0000-000000000103'),
 */
  __pyx_tuple__88 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_6); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(22, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__88);
  __Pyx_GIVEREF(__pyx_tuple__88);

  /* "edgedb/protocol/codecs/edb_types.pxi":15
 *     'std::uuid': uuid.UUID('00000000-0000-0000-0000-000000000100'),
 *     'std::str': uuid.UUID('00000000-0000-0000-0000-000000000101'),
 *     'std::bytes': uuid.UUID('00000000-0000-0000-0000-000000000102'),             # <<<<<<<<<<<<<<
 *     'std::int16': uuid.UUID('00000000-0000-0000-0000-000000000103'),
 *     'std::int32': uuid.UUID('00000000-0000-0000-0000-000000000104'),
 */
  __pyx_tuple__89 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_7); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(22, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__89);
  __Pyx_GIVEREF(__pyx_tuple__89);

  /* "edgedb/protocol/codecs/edb_types.pxi":16
 *     'std::str': uuid.UUID('00000000-0000-0000-0000-000000000101'),
 *     'std::bytes': uuid.UUID('00000000-0000-0000-0000-000000000102'),
 *     'std::int16': uuid.UUID('00000000-0000-0000-0000-000000000103'),             # <<<<<<<<<<<<<<
 *     'std::int32': uuid.UUID('00000000-0000-0000-0000-000000000104'),
 *     'std::int64': uuid.UUID('00000000-0000-0000-0000-000000000105'),
 */
  __pyx_tuple__90 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_8); if (unlikely(!__pyx_tuple__90)) __PYX_ERR(22, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__90);
  __Pyx_GIVEREF(__pyx_tuple__90);

  /* "edgedb/protocol/codecs/edb_types.pxi":17
 *     'std::bytes': uuid.UUID('00000000-0000-0000-0000-000000000102'),
 *     'std::int16': uuid.UUID('00000000-0000-0000-0000-000000000103'),
 *     'std::int32': uuid.UUID('00000000-0000-0000-0000-000000000104'),             # <<<<<<<<<<<<<<
 *     'std::int64': uuid.UUID('00000000-0000-0000-0000-000000000105'),
 *     'std::float32': uuid.UUID('00000000-0000-0000-0000-000000000106'),
 */
  __pyx_tuple__91 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_9); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(22, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__91);
  __Pyx_GIVEREF(__pyx_tuple__91);

  /* "edgedb/protocol/codecs/edb_types.pxi":18
 *     'std::int16': uuid.UUID('00000000-0000-0000-0000-000000000103'),
 *     'std::int32': uuid.UUID('00000000-0000-0000-0000-000000000104'),
 *     'std::int64': uuid.UUID('00000000-0000-0000-0000-000000000105'),             # <<<<<<<<<<<<<<
 *     'std::float32': uuid.UUID('00000000-0000-0000-0000-000000000106'),
 *     'std::float64': uuid.UUID('00000000-0000-0000-0000-000000000107'),
 */
  __pyx_tuple__92 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_10); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(22, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__92);
  __Pyx_GIVEREF(__pyx_tuple__92);

  /* "edgedb/protocol/codecs/edb_types.pxi":19
 *     'std::int32': uuid.UUID('00000000-0000-0000-0000-000000000104'),
 *     'std::int64': uuid.UUID('00000000-0000-0000-0000-000000000105'),
 *     'std::float32': uuid.UUID('00000000-0000-0000-0000-000000000106'),             # <<<<<<<<<<<<<<
 *     'std::float64': uuid.UUID('00000000-0000-0000-0000-000000000107'),
 *     'std::decimal': uuid.UUID('00000000-0000-0000-0000-000000000108'),
 */
  __pyx_tuple__93 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_11); if (unlikely(!__pyx_tuple__93)) __PYX_ERR(22, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__93);
  __Pyx_GIVEREF(__pyx_tuple__93);

  /* "edgedb/protocol/codecs/edb_types.pxi":20
 *     'std::int64': uuid.UUID('00000000-0000-0000-0000-000000000105'),
 *     'std::float32': uuid.UUID('00000000-0000-0000-0000-000000000106'),
 *     'std::float64': uuid.UUID('00000000-0000-0000-0000-000000000107'),             # <<<<<<<<<<<<<<
 *     'std::decimal': uuid.UUID('00000000-0000-0000-0000-000000000108'),
 *     'std::bool': uuid.UUID('00000000-0000-0000-0000-000000000109'),
 */
  __pyx_tuple__94 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_12); if (unlikely(!__pyx_tuple__94)) __PYX_ERR(22, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__94);
  __Pyx_GIVEREF(__pyx_tuple__94);

  /* "edgedb/protocol/codecs/edb_types.pxi":21
 *     'std::float32': uuid.UUID('00000000-0000-0000-0000-000000000106'),
 *     'std::float64': uuid.UUID('00000000-0000-0000-0000-000000000107'),
 *     'std::decimal': uuid.UUID('00000000-0000-0000-0000-000000000108'),             # <<<<<<<<<<<<<<
 *     'std::bool': uuid.UUID('00000000-0000-0000-0000-000000000109'),
 *     'std::datetime': uuid.UUID('00000000-0000-0000-0000-00000000010a'),
 */
  __pyx_tuple__95 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_13); if (unlikely(!__pyx_tuple__95)) __PYX_ERR(22, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__95);
  __Pyx_GIVEREF(__pyx_tuple__95);

  /* "edgedb/protocol/codecs/edb_types.pxi":22
 *     'std::float64': uuid.UUID('00000000-0000-0000-0000-000000000107'),
 *     'std::decimal': uuid.UUID('00000000-0000-0000-0000-000000000108'),
 *     'std::bool': uuid.UUID('00000000-0000-0000-0000-000000000109'),             # <<<<<<<<<<<<<<
 *     'std::datetime': uuid.UUID('00000000-0000-0000-0000-00000000010a'),
 *     'cal::local_datetime': uuid.UUID('00000000-0000-0000-0000-00000000010b'),
 */
  __pyx_tuple__96 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_14); if (unlikely(!__pyx_tuple__96)) __PYX_ERR(22, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__96);
  __Pyx_GIVEREF(__pyx_tuple__96);

  /* "edgedb/protocol/codecs/edb_types.pxi":23
 *     'std::decimal': uuid.UUID('00000000-0000-0000-0000-000000000108'),
 *     'std::bool': uuid.UUID('00000000-0000-0000-0000-000000000109'),
 *     'std::datetime': uuid.UUID('00000000-0000-0000-0000-00000000010a'),             # <<<<<<<<<<<<<<
 *     'cal::local_datetime': uuid.UUID('00000000-0000-0000-0000-00000000010b'),
 *     'cal::local_date': uuid.UUID('00000000-0000-0000-0000-00000000010c'),
 */
  __pyx_tuple__97 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_15); if (unlikely(!__pyx_tuple__97)) __PYX_ERR(22, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__97);
  __Pyx_GIVEREF(__pyx_tuple__97);

  /* "edgedb/protocol/codecs/edb_types.pxi":24
 *     'std::bool': uuid.UUID('00000000-0000-0000-0000-000000000109'),
 *     'std::datetime': uuid.UUID('00000000-0000-0000-0000-00000000010a'),
 *     'cal::local_datetime': uuid.UUID('00000000-0000-0000-0000-00000000010b'),             # <<<<<<<<<<<<<<
 *     'cal::local_date': uuid.UUID('00000000-0000-0000-0000-00000000010c'),
 *     'cal::local_time': uuid.UUID('00000000-0000-0000-0000-00000000010d'),
 */
  __pyx_tuple__98 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_16); if (unlikely(!__pyx_tuple__98)) __PYX_ERR(22, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__98);
  __Pyx_GIVEREF(__pyx_tuple__98);

  /* "edgedb/protocol/codecs/edb_types.pxi":25
 *     'std::datetime': uuid.UUID('00000000-0000-0000-0000-00000000010a'),
 *     'cal::local_datetime': uuid.UUID('00000000-0000-0000-0000-00000000010b'),
 *     'cal::local_date': uuid.UUID('00000000-0000-0000-0000-00000000010c'),             # <<<<<<<<<<<<<<
 *     'cal::local_time': uuid.UUID('00000000-0000-0000-0000-00000000010d'),
 *     'std::duration': uuid.UUID('00000000-0000-0000-0000-00000000010e'),
 */
  __pyx_tuple__99 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_17); if (unlikely(!__pyx_tuple__99)) __PYX_ERR(22, 25, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__99);
  __Pyx_GIVEREF(__pyx_tuple__99);

  /* "edgedb/protocol/codecs/edb_types.pxi":26
 *     'cal::local_datetime': uuid.UUID('00000000-0000-0000-0000-00000000010b'),
 *     'cal::local_date': uuid.UUID('00000000-0000-0000-0000-00000000010c'),
 *     'cal::local_time': uuid.UUID('00000000-0000-0000-0000-00000000010d'),             # <<<<<<<<<<<<<<
 *     'std::duration': uuid.UUID('00000000-0000-0000-0000-00000000010e'),
 *     'std::json': uuid.UUID('00000000-0000-0000-0000-00000000010f'),
 */
  __pyx_tuple__100 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_18); if (unlikely(!__pyx_tuple__100)) __PYX_ERR(22, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__100);
  __Pyx_GIVEREF(__pyx_tuple__100);

  /* "edgedb/protocol/codecs/edb_types.pxi":27
 *     'cal::local_date': uuid.UUID('00000000-0000-0000-0000-00000000010c'),
 *     'cal::local_time': uuid.UUID('00000000-0000-0000-0000-00000000010d'),
 *     'std::duration': uuid.UUID('00000000-0000-0000-0000-00000000010e'),             # <<<<<<<<<<<<<<
 *     'std::json': uuid.UUID('00000000-0000-0000-0000-00000000010f'),
 *     'std::bigint': uuid.UUID('00000000-0000-0000-0000-000000000110'),
 */
  __pyx_tuple__101 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_19); if (unlikely(!__pyx_tuple__101)) __PYX_ERR(22, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__101);
  __Pyx_GIVEREF(__pyx_tuple__101);

  /* "edgedb/protocol/codecs/edb_types.pxi":28
 *     'cal::local_time': uuid.UUID('00000000-0000-0000-0000-00000000010d'),
 *     'std::duration': uuid.UUID('00000000-0000-0000-0000-00000000010e'),
 *     'std::json': uuid.UUID('00000000-0000-0000-0000-00000000010f'),             # <<<<<<<<<<<<<<
 *     'std::bigint': uuid.UUID('00000000-0000-0000-0000-000000000110'),
 *     'cal::relative_duration': uuid.UUID('00000000-0000-0000-0000-000000000111'),
 */
  __pyx_tuple__102 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_20); if (unlikely(!__pyx_tuple__102)) __PYX_ERR(22, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__102);
  __Pyx_GIVEREF(__pyx_tuple__102);

  /* "edgedb/protocol/codecs/edb_types.pxi":29
 *     'std::duration': uuid.UUID('00000000-0000-0000-0000-00000000010e'),
 *     'std::json': uuid.UUID('00000000-0000-0000-0000-00000000010f'),
 *     'std::bigint': uuid.UUID('00000000-0000-0000-0000-000000000110'),             # <<<<<<<<<<<<<<
 *     'cal::relative_duration': uuid.UUID('00000000-0000-0000-0000-000000000111'),
 *     'cfg::memory': uuid.UUID('00000000-0000-0000-0000-000000000130')
 */
  __pyx_tuple__103 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_21); if (unlikely(!__pyx_tuple__103)) __PYX_ERR(22, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__103);
  __Pyx_GIVEREF(__pyx_tuple__103);

  /* "edgedb/protocol/codecs/edb_types.pxi":30
 *     'std::json': uuid.UUID('00000000-0000-0000-0000-00000000010f'),
 *     'std::bigint': uuid.UUID('00000000-0000-0000-0000-000000000110'),
 *     'cal::relative_duration': uuid.UUID('00000000-0000-0000-0000-000000000111'),             # <<<<<<<<<<<<<<
 *     'cfg::memory': uuid.UUID('00000000-0000-0000-0000-000000000130')
 * }
 */
  __pyx_tuple__104 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_22); if (unlikely(!__pyx_tuple__104)) __PYX_ERR(22, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__104);
  __Pyx_GIVEREF(__pyx_tuple__104);

  /* "edgedb/protocol/codecs/edb_types.pxi":31
 *     'std::bigint': uuid.UUID('00000000-0000-0000-0000-000000000110'),
 *     'cal::relative_duration': uuid.UUID('00000000-0000-0000-0000-000000000111'),
 *     'cfg::memory': uuid.UUID('00000000-0000-0000-0000-000000000130')             # <<<<<<<<<<<<<<
 * }
 */
  __pyx_tuple__105 = PyTuple_Pack(1, __pyx_kp_u_00000000_0000_0000_0000_00000000_23); if (unlikely(!__pyx_tuple__105)) __PYX_ERR(22, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__105);
  __Pyx_GIVEREF(__pyx_tuple__105);

  /* "edgedb/protocol/codecs/base.pyx":27
 * 
 * cdef bytes NULL_CODEC_ID = b'\x00' * 16
 * cdef bytes EMPTY_TUPLE_CODEC_ID = TYPE_IDS.get('empty-tuple').bytes             # <<<<<<<<<<<<<<
 * 
 * EMPTY_NULL_DATA = b'\x00\x00\x00\x00'
 */
  __pyx_tuple__107 = PyTuple_Pack(1, __pyx_kp_u_empty_tuple); if (unlikely(!__pyx_tuple__107)) __PYX_ERR(1, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__107);
  __Pyx_GIVEREF(__pyx_tuple__107);

  /* "(tree fragment)":1
 * def __pyx_unpickle_LRUMapping(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_tuple__110 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__110)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__110);
  __Pyx_GIVEREF(__pyx_tuple__110);
  __pyx_codeobj__111 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__110, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_LRUMapping, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__111)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__112 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__112)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__112);
  __Pyx_GIVEREF(__pyx_tuple__112);
  __pyx_codeobj__113 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__112, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_CodecsRegistry, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__113)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__114 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__114)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__114);
  __Pyx_GIVEREF(__pyx_tuple__114);
  __pyx_codeobj__115 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__114, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_QueryCodecsCache, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__115)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__116 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__116)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__116);
  __Pyx_GIVEREF(__pyx_tuple__116);
  __pyx_codeobj__117 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__116, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_SansIOProtocol, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__117)) __PYX_ERR(2, 1, __pyx_L1_error)

  /* "EnumBase":28
 * class __Pyx_EnumBase(int):
 *     __metaclass__ = __Pyx_EnumMeta
 *     def __new__(cls, value, name=None):             # <<<<<<<<<<<<<<
 *         for v in cls:
 *             if v == value:
 */
  __pyx_tuple__118 = PyTuple_Pack(5, __pyx_n_s_cls, __pyx_n_s_value, __pyx_n_s_name_2, __pyx_n_s_v, __pyx_n_s_res); if (unlikely(!__pyx_tuple__118)) __PYX_ERR(2, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__118);
  __Pyx_GIVEREF(__pyx_tuple__118);
  __pyx_codeobj__119 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__118, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_new, 28, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__119)) __PYX_ERR(2, 28, __pyx_L1_error)
  __pyx_tuple__120 = PyTuple_Pack(1, ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__120)) __PYX_ERR(2, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__120);
  __Pyx_GIVEREF(__pyx_tuple__120);

  /* "EnumBase":39
 *         cls.__members__[name] = res
 *         return res
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<%s.%s: %d>" % (self.__class__.__name__, self.name, self)
 *     def __str__(self):
 */
  __pyx_tuple__121 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__121)) __PYX_ERR(2, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__121);
  __Pyx_GIVEREF(__pyx_tuple__121);
  __pyx_codeobj__122 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__121, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_repr, 39, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__122)) __PYX_ERR(2, 39, __pyx_L1_error)

  /* "EnumBase":41
 *     def __repr__(self):
 *         return "<%s.%s: %d>" % (self.__class__.__name__, self.name, self)
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s.%s" % (self.__class__.__name__, self.name)
 * 
 */
  __pyx_tuple__123 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__123)) __PYX_ERR(2, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__123);
  __Pyx_GIVEREF(__pyx_tuple__123);
  __pyx_codeobj__124 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__123, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_str, 41, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__124)) __PYX_ERR(2, 41, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __pyx_unpickle___Pyx_EnumMeta(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_tuple__125 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__125)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__125);
  __Pyx_GIVEREF(__pyx_tuple__125);
  __pyx_codeobj__126 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__125, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle___Pyx_EnumMeta, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__126)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  __pyx_umethod_PyDict_Type_get.type = (PyObject*)&PyDict_Type;
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(5, 1, __pyx_L1_error);
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_11 = PyInt_FromLong(11); if (unlikely(!__pyx_int_11)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_12 = PyInt_FromLong(12); if (unlikely(!__pyx_int_12)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_13 = PyInt_FromLong(13); if (unlikely(!__pyx_int_13)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_40 = PyInt_FromLong(40); if (unlikely(!__pyx_int_40)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_200 = PyInt_FromLong(200); if (unlikely(!__pyx_int_200)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_1000 = PyInt_FromLong(1000); if (unlikely(!__pyx_int_1000)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_4097 = PyInt_FromLong(4097); if (unlikely(!__pyx_int_4097)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_10000 = PyInt_FromLong(10000L); if (unlikely(!__pyx_int_10000)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_65281 = PyInt_FromLong(65281L); if (unlikely(!__pyx_int_65281)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_65282 = PyInt_FromLong(65282L); if (unlikely(!__pyx_int_65282)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_65283 = PyInt_FromLong(65283L); if (unlikely(!__pyx_int_65283)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_65284 = PyInt_FromLong(65284L); if (unlikely(!__pyx_int_65284)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_52716380 = PyInt_FromLong(52716380L); if (unlikely(!__pyx_int_52716380)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_84082689 = PyInt_FromLong(84082689L); if (unlikely(!__pyx_int_84082689)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_84082690 = PyInt_FromLong(84082690L); if (unlikely(!__pyx_int_84082690)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_84082945 = PyInt_FromLong(84082945L); if (unlikely(!__pyx_int_84082945)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_84082946 = PyInt_FromLong(84082946L); if (unlikely(!__pyx_int_84082946)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_87255255 = PyInt_FromLong(87255255L); if (unlikely(!__pyx_int_87255255)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_98205364 = PyInt_FromLong(98205364L); if (unlikely(!__pyx_int_98205364)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_182233609 = PyInt_FromLong(182233609L); if (unlikely(!__pyx_int_182233609)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_222419149 = PyInt_FromLong(222419149L); if (unlikely(!__pyx_int_222419149)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_int_18446744073709551615 = PyInt_FromString((char *)"18446744073709551615", 0, 0); if (unlikely(!__pyx_int_18446744073709551615)) __PYX_ERR(5, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/

static int __Pyx_modinit_global_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __pyx_v_6edgedb_8protocol_8protocol__LRU_MARKER = Py_None; Py_INCREF(Py_None);
  __pyx_v_6edgedb_8protocol_8protocol_NULL_CODEC_ID = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_6edgedb_8protocol_8protocol_EMPTY_TUPLE_CODEC_ID = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_6edgedb_8protocol_8protocol_DEFAULT_CODEC_CONTEXT = ((struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_6edgedb_8protocol_8protocol_NULL_CODEC = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)Py_None); Py_INCREF(Py_None);
  __pyx_v_6edgedb_8protocol_8protocol_EMPTY_TUPLE_CODEC = ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)Py_None); Py_INCREF(Py_None);
  __pyx_v_6edgedb_8protocol_8protocol_BASE_SCALAR_CODECS = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_6edgedb_8protocol_8protocol_OLD_ERROR_CODES = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_6edgedb_8protocol_8protocol_result_cardinality_mismatch_code = Py_None; Py_INCREF(Py_None);
  __pyx_v_6edgedb_8protocol_8protocol_SYNC_MESSAGE = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_6edgedb_8protocol_8protocol_FLUSH_MESSAGE = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __Pyx_OrderedDict = Py_None; Py_INCREF(Py_None);
  __Pyx_EnumBase = Py_None; Py_INCREF(Py_None);
  __Pyx_globals = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  /*--- Variable export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  __pyx_vtabptr_6edgedb_8protocol_8protocol_LRUMapping = &__pyx_vtable_6edgedb_8protocol_8protocol_LRUMapping;
  __pyx_vtable_6edgedb_8protocol_8protocol_LRUMapping.get = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_LRUMapping *, PyObject *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_10LRUMapping_get;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_LRUMapping) < 0) __PYX_ERR(0, 26, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_LRUMapping.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_LRUMapping.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_LRUMapping.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_LRUMapping.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_LRUMapping.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_LRUMapping) < 0) __PYX_ERR(0, 26, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_LRUMapping, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_LRUMapping) < 0) __PYX_ERR(0, 26, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_LRUMapping) < 0) __PYX_ERR(0, 26, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_LRUMapping = &__pyx_type_6edgedb_8protocol_8protocol_LRUMapping;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_BaseCodec = &__pyx_vtable_6edgedb_8protocol_8protocol_BaseCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseCodec.get_tid = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *))__pyx_f_6edgedb_8protocol_8protocol_9BaseCodec_get_tid;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseCodec.encode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_9BaseCodec_encode;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseCodec.decode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *))__pyx_f_6edgedb_8protocol_8protocol_9BaseCodec_decode;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseCodec.dump = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_opt_args_6edgedb_8protocol_8protocol_9BaseCodec_dump *__pyx_optional_args))__pyx_f_6edgedb_8protocol_8protocol_9BaseCodec_dump;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_BaseCodec) < 0) __PYX_ERR(1, 33, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_BaseCodec.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_BaseCodec.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_BaseCodec.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_BaseCodec.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_BaseCodec.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_BaseCodec) < 0) __PYX_ERR(1, 33, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BaseCodec, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_BaseCodec) < 0) __PYX_ERR(1, 33, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_BaseCodec) < 0) __PYX_ERR(1, 33, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec = &__pyx_type_6edgedb_8protocol_8protocol_BaseCodec;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_CodecPythonOverride = &__pyx_vtable_6edgedb_8protocol_8protocol_CodecPythonOverride;
  __pyx_vtable_6edgedb_8protocol_8protocol_CodecPythonOverride.__pyx_base = *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_CodecPythonOverride.__pyx_base.encode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_19CodecPythonOverride_encode;
  __pyx_vtable_6edgedb_8protocol_8protocol_CodecPythonOverride.__pyx_base.decode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *))__pyx_f_6edgedb_8protocol_8protocol_19CodecPythonOverride_decode;
  __pyx_vtable_6edgedb_8protocol_8protocol_CodecPythonOverride.__pyx_base.dump = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_opt_args_6edgedb_8protocol_8protocol_9BaseCodec_dump *__pyx_optional_args))__pyx_f_6edgedb_8protocol_8protocol_19CodecPythonOverride_dump;
  __pyx_vtable_6edgedb_8protocol_8protocol_CodecPythonOverride.new = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*)(PyObject *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, PyObject *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_19CodecPythonOverride_new;
  __pyx_type_6edgedb_8protocol_8protocol_CodecPythonOverride.tp_base = __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_CodecPythonOverride) < 0) __PYX_ERR(1, 53, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_CodecPythonOverride.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_CodecPythonOverride.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_CodecPythonOverride.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_CodecPythonOverride.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_CodecPythonOverride.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_CodecPythonOverride) < 0) __PYX_ERR(1, 53, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_CodecPythonOverride, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_CodecPythonOverride) < 0) __PYX_ERR(1, 53, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_CodecPythonOverride) < 0) __PYX_ERR(1, 53, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_CodecPythonOverride = &__pyx_type_6edgedb_8protocol_8protocol_CodecPythonOverride;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_BaseRecordCodec = &__pyx_vtable_6edgedb_8protocol_8protocol_BaseRecordCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseRecordCodec.__pyx_base = *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseRecordCodec.__pyx_base.encode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_15BaseRecordCodec_encode;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseRecordCodec._check_encoder = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseRecordCodec *))__pyx_f_6edgedb_8protocol_8protocol_15BaseRecordCodec__check_encoder;
  __pyx_type_6edgedb_8protocol_8protocol_BaseRecordCodec.tp_base = __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_BaseRecordCodec) < 0) __PYX_ERR(1, 124, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_BaseRecordCodec.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_BaseRecordCodec.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_BaseRecordCodec.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_BaseRecordCodec.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_BaseRecordCodec.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_BaseRecordCodec) < 0) __PYX_ERR(1, 124, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BaseRecordCodec, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_BaseRecordCodec) < 0) __PYX_ERR(1, 124, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_BaseRecordCodec) < 0) __PYX_ERR(1, 124, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_BaseRecordCodec = &__pyx_type_6edgedb_8protocol_8protocol_BaseRecordCodec;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_EmptyTupleCodec = &__pyx_vtable_6edgedb_8protocol_8protocol_EmptyTupleCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_EmptyTupleCodec.__pyx_base = *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_EmptyTupleCodec.__pyx_base.encode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_15EmptyTupleCodec_encode;
  __pyx_vtable_6edgedb_8protocol_8protocol_EmptyTupleCodec.__pyx_base.decode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *))__pyx_f_6edgedb_8protocol_8protocol_15EmptyTupleCodec_decode;
  __pyx_type_6edgedb_8protocol_8protocol_EmptyTupleCodec.tp_base = __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_EmptyTupleCodec) < 0) __PYX_ERR(1, 87, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_EmptyTupleCodec.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_EmptyTupleCodec.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_EmptyTupleCodec.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_EmptyTupleCodec.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_EmptyTupleCodec.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_EmptyTupleCodec) < 0) __PYX_ERR(1, 87, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_EmptyTupleCodec, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_EmptyTupleCodec) < 0) __PYX_ERR(1, 87, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_EmptyTupleCodec) < 0) __PYX_ERR(1, 87, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_EmptyTupleCodec = &__pyx_type_6edgedb_8protocol_8protocol_EmptyTupleCodec;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_NullCodec = &__pyx_vtable_6edgedb_8protocol_8protocol_NullCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_NullCodec.__pyx_base = *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseCodec;
  __pyx_type_6edgedb_8protocol_8protocol_NullCodec.tp_base = __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_NullCodec) < 0) __PYX_ERR(1, 117, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_NullCodec.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_NullCodec.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_NullCodec.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_NullCodec.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_NullCodec.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_NullCodec) < 0) __PYX_ERR(1, 117, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_NullCodec, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_NullCodec) < 0) __PYX_ERR(1, 117, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_NullCodec) < 0) __PYX_ERR(1, 117, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_NullCodec = &__pyx_type_6edgedb_8protocol_8protocol_NullCodec;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_BaseNamedRecordCodec = &__pyx_vtable_6edgedb_8protocol_8protocol_BaseNamedRecordCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseNamedRecordCodec.__pyx_base = *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseRecordCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseNamedRecordCodec.__pyx_base.__pyx_base.dump = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_opt_args_6edgedb_8protocol_8protocol_9BaseCodec_dump *__pyx_optional_args))__pyx_f_6edgedb_8protocol_8protocol_20BaseNamedRecordCodec_dump;
  __pyx_type_6edgedb_8protocol_8protocol_BaseNamedRecordCodec.tp_base = __pyx_ptype_6edgedb_8protocol_8protocol_BaseRecordCodec;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_BaseNamedRecordCodec) < 0) __PYX_ERR(1, 193, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_BaseNamedRecordCodec.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_BaseNamedRecordCodec.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_BaseNamedRecordCodec.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_BaseNamedRecordCodec.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_BaseNamedRecordCodec.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_BaseNamedRecordCodec) < 0) __PYX_ERR(1, 193, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BaseNamedRecordCodec, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_BaseNamedRecordCodec) < 0) __PYX_ERR(1, 193, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_BaseNamedRecordCodec) < 0) __PYX_ERR(1, 193, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_BaseNamedRecordCodec = &__pyx_type_6edgedb_8protocol_8protocol_BaseNamedRecordCodec;
  __pyx_t_1 = PyImport_ImportModule("edgedb.pgproto.pgproto"); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_6edgedb_7pgproto_7pgproto_CodecContext = __Pyx_ImportType(__pyx_t_1, "edgedb.pgproto.pgproto", "CodecContext", sizeof(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_6edgedb_7pgproto_7pgproto_CodecContext) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_vtabptr_6edgedb_7pgproto_7pgproto_CodecContext = (struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_CodecContext*)__Pyx_GetVtable(__pyx_ptype_6edgedb_7pgproto_7pgproto_CodecContext->tp_dict); if (unlikely(!__pyx_vtabptr_6edgedb_7pgproto_7pgproto_CodecContext)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_vtabptr_6edgedb_8protocol_8protocol_EdegDBCodecContext = &__pyx_vtable_6edgedb_8protocol_8protocol_EdegDBCodecContext;
  __pyx_vtable_6edgedb_8protocol_8protocol_EdegDBCodecContext.__pyx_base = *__pyx_vtabptr_6edgedb_7pgproto_7pgproto_CodecContext;
  __pyx_vtable_6edgedb_8protocol_8protocol_EdegDBCodecContext.__pyx_base.get_text_codec = (PyObject *(*)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, int __pyx_skip_dispatch))__pyx_f_6edgedb_8protocol_8protocol_18EdegDBCodecContext_get_text_codec;
  __pyx_vtable_6edgedb_8protocol_8protocol_EdegDBCodecContext.__pyx_base.is_encoding_utf8 = (PyObject *(*)(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *))__pyx_f_6edgedb_8protocol_8protocol_18EdegDBCodecContext_is_encoding_utf8;
  __pyx_type_6edgedb_8protocol_8protocol_EdegDBCodecContext.tp_base = __pyx_ptype_6edgedb_7pgproto_7pgproto_CodecContext;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_EdegDBCodecContext) < 0) __PYX_ERR(1, 210, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_EdegDBCodecContext.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_EdegDBCodecContext.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_EdegDBCodecContext.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_EdegDBCodecContext.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_EdegDBCodecContext.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_EdegDBCodecContext) < 0) __PYX_ERR(1, 210, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_EdegDBCodecContext, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_EdegDBCodecContext) < 0) __PYX_ERR(1, 210, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_EdegDBCodecContext) < 0) __PYX_ERR(1, 210, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_EdegDBCodecContext = &__pyx_type_6edgedb_8protocol_8protocol_EdegDBCodecContext;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_ScalarCodec = &__pyx_vtable_6edgedb_8protocol_8protocol_ScalarCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_ScalarCodec.__pyx_base = *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_ScalarCodec.__pyx_base.encode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_encode;
  __pyx_vtable_6edgedb_8protocol_8protocol_ScalarCodec.__pyx_base.decode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *))__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_decode;
  __pyx_vtable_6edgedb_8protocol_8protocol_ScalarCodec.derive = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_ScalarCodec *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_derive;
  __pyx_vtable_6edgedb_8protocol_8protocol_ScalarCodec.new = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*)(PyObject *, PyObject *, __pyx_t_6edgedb_7pgproto_7pgproto_encode_func, __pyx_t_6edgedb_7pgproto_7pgproto_decode_func))__pyx_f_6edgedb_8protocol_8protocol_11ScalarCodec_new;
  __pyx_type_6edgedb_8protocol_8protocol_ScalarCodec.tp_base = __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_ScalarCodec) < 0) __PYX_ERR(6, 21, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_ScalarCodec.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_ScalarCodec.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_ScalarCodec.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_ScalarCodec.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_ScalarCodec.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_ScalarCodec) < 0) __PYX_ERR(6, 21, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_ScalarCodec, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_ScalarCodec) < 0) __PYX_ERR(6, 21, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_ScalarCodec) < 0) __PYX_ERR(6, 21, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_ScalarCodec = &__pyx_type_6edgedb_8protocol_8protocol_ScalarCodec;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_TupleCodec = &__pyx_vtable_6edgedb_8protocol_8protocol_TupleCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_TupleCodec.__pyx_base = *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseRecordCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_TupleCodec.__pyx_base.__pyx_base.decode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *))__pyx_f_6edgedb_8protocol_8protocol_10TupleCodec_decode;
  __pyx_vtable_6edgedb_8protocol_8protocol_TupleCodec.__pyx_base.__pyx_base.dump = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_opt_args_6edgedb_8protocol_8protocol_9BaseCodec_dump *__pyx_optional_args))__pyx_f_6edgedb_8protocol_8protocol_10TupleCodec_dump;
  __pyx_vtable_6edgedb_8protocol_8protocol_TupleCodec.new = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*)(PyObject *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_10TupleCodec_new;
  __pyx_type_6edgedb_8protocol_8protocol_TupleCodec.tp_base = __pyx_ptype_6edgedb_8protocol_8protocol_BaseRecordCodec;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_TupleCodec) < 0) __PYX_ERR(7, 21, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_TupleCodec.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_TupleCodec.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_TupleCodec.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_TupleCodec.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_TupleCodec.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_TupleCodec) < 0) __PYX_ERR(7, 21, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_TupleCodec, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_TupleCodec) < 0) __PYX_ERR(7, 21, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_TupleCodec) < 0) __PYX_ERR(7, 21, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_TupleCodec = &__pyx_type_6edgedb_8protocol_8protocol_TupleCodec;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_NamedTupleCodec = &__pyx_vtable_6edgedb_8protocol_8protocol_NamedTupleCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_NamedTupleCodec.__pyx_base = *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseNamedRecordCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_NamedTupleCodec.__pyx_base.__pyx_base.__pyx_base.decode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *))__pyx_f_6edgedb_8protocol_8protocol_15NamedTupleCodec_decode;
  __pyx_vtable_6edgedb_8protocol_8protocol_NamedTupleCodec.encode_kwargs = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_NamedTupleCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_15NamedTupleCodec_encode_kwargs;
  __pyx_vtable_6edgedb_8protocol_8protocol_NamedTupleCodec.new = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*)(PyObject *, PyObject *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_15NamedTupleCodec_new;
  __pyx_type_6edgedb_8protocol_8protocol_NamedTupleCodec.tp_base = __pyx_ptype_6edgedb_8protocol_8protocol_BaseNamedRecordCodec;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_NamedTupleCodec) < 0) __PYX_ERR(3, 24, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_NamedTupleCodec.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_NamedTupleCodec.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_NamedTupleCodec.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_NamedTupleCodec.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_NamedTupleCodec.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_NamedTupleCodec) < 0) __PYX_ERR(3, 24, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_NamedTupleCodec, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_NamedTupleCodec) < 0) __PYX_ERR(3, 24, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_NamedTupleCodec) < 0) __PYX_ERR(3, 24, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_NamedTupleCodec = &__pyx_type_6edgedb_8protocol_8protocol_NamedTupleCodec;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_ObjectCodec = &__pyx_vtable_6edgedb_8protocol_8protocol_ObjectCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_ObjectCodec.__pyx_base = *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseNamedRecordCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_ObjectCodec.__pyx_base.__pyx_base.__pyx_base.encode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_encode;
  __pyx_vtable_6edgedb_8protocol_8protocol_ObjectCodec.__pyx_base.__pyx_base.__pyx_base.decode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *))__pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_decode;
  __pyx_vtable_6edgedb_8protocol_8protocol_ObjectCodec.encode_args = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_ObjectCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_encode_args;
  __pyx_vtable_6edgedb_8protocol_8protocol_ObjectCodec.new = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*)(PyObject *, PyObject *, PyObject *, PyObject *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_11ObjectCodec_new;
  __pyx_type_6edgedb_8protocol_8protocol_ObjectCodec.tp_base = __pyx_ptype_6edgedb_8protocol_8protocol_BaseNamedRecordCodec;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_ObjectCodec) < 0) __PYX_ERR(8, 21, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_ObjectCodec.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_ObjectCodec.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_ObjectCodec.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_ObjectCodec.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_ObjectCodec.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_ObjectCodec) < 0) __PYX_ERR(8, 21, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_ObjectCodec, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_ObjectCodec) < 0) __PYX_ERR(8, 21, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_ObjectCodec) < 0) __PYX_ERR(8, 21, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_ObjectCodec = &__pyx_type_6edgedb_8protocol_8protocol_ObjectCodec;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_BaseArrayCodec = &__pyx_vtable_6edgedb_8protocol_8protocol_BaseArrayCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseArrayCodec.__pyx_base = *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseArrayCodec.__pyx_base.encode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec_encode;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseArrayCodec.__pyx_base.decode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *))__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec_decode;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseArrayCodec.__pyx_base.dump = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_opt_args_6edgedb_8protocol_8protocol_9BaseCodec_dump *__pyx_optional_args))__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec_dump;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseArrayCodec._new_collection = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *, Py_ssize_t))__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec__new_collection;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseArrayCodec._set_collection_item = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *, PyObject *, Py_ssize_t, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec__set_collection_item;
  __pyx_vtable_6edgedb_8protocol_8protocol_BaseArrayCodec._decode_array = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *))__pyx_f_6edgedb_8protocol_8protocol_14BaseArrayCodec__decode_array;
  __pyx_type_6edgedb_8protocol_8protocol_BaseArrayCodec.tp_base = __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_BaseArrayCodec) < 0) __PYX_ERR(9, 25, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_BaseArrayCodec.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_BaseArrayCodec.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_BaseArrayCodec.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_BaseArrayCodec.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_BaseArrayCodec.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_BaseArrayCodec) < 0) __PYX_ERR(9, 25, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BaseArrayCodec, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_BaseArrayCodec) < 0) __PYX_ERR(9, 25, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_BaseArrayCodec) < 0) __PYX_ERR(9, 25, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_BaseArrayCodec = &__pyx_type_6edgedb_8protocol_8protocol_BaseArrayCodec;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_ArrayCodec = &__pyx_vtable_6edgedb_8protocol_8protocol_ArrayCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_ArrayCodec.__pyx_base = *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseArrayCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_ArrayCodec.__pyx_base._new_collection = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *, Py_ssize_t))__pyx_f_6edgedb_8protocol_8protocol_10ArrayCodec__new_collection;
  __pyx_vtable_6edgedb_8protocol_8protocol_ArrayCodec.__pyx_base._set_collection_item = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *, PyObject *, Py_ssize_t, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_10ArrayCodec__set_collection_item;
  __pyx_vtable_6edgedb_8protocol_8protocol_ArrayCodec.new = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*)(PyObject *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, int32_t))__pyx_f_6edgedb_8protocol_8protocol_10ArrayCodec_new;
  __pyx_type_6edgedb_8protocol_8protocol_ArrayCodec.tp_base = __pyx_ptype_6edgedb_8protocol_8protocol_BaseArrayCodec;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_ArrayCodec) < 0) __PYX_ERR(9, 136, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_ArrayCodec.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_ArrayCodec.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_ArrayCodec.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_ArrayCodec.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_ArrayCodec.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_ArrayCodec) < 0) __PYX_ERR(9, 136, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_ArrayCodec, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_ArrayCodec) < 0) __PYX_ERR(9, 136, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_ArrayCodec) < 0) __PYX_ERR(9, 136, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_ArrayCodec = &__pyx_type_6edgedb_8protocol_8protocol_ArrayCodec;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_SetCodec = &__pyx_vtable_6edgedb_8protocol_8protocol_SetCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_SetCodec.__pyx_base = *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseArrayCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_SetCodec.__pyx_base.__pyx_base.decode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *))__pyx_f_6edgedb_8protocol_8protocol_8SetCodec_decode;
  __pyx_vtable_6edgedb_8protocol_8protocol_SetCodec.__pyx_base._new_collection = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *, Py_ssize_t))__pyx_f_6edgedb_8protocol_8protocol_8SetCodec__new_collection;
  __pyx_vtable_6edgedb_8protocol_8protocol_SetCodec.__pyx_base._set_collection_item = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseArrayCodec *, PyObject *, Py_ssize_t, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_8SetCodec__set_collection_item;
  __pyx_vtable_6edgedb_8protocol_8protocol_SetCodec._decode_array_set = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SetCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *))__pyx_f_6edgedb_8protocol_8protocol_8SetCodec__decode_array_set;
  __pyx_vtable_6edgedb_8protocol_8protocol_SetCodec.new = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*)(PyObject *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *))__pyx_f_6edgedb_8protocol_8protocol_8SetCodec_new;
  __pyx_type_6edgedb_8protocol_8protocol_SetCodec.tp_base = __pyx_ptype_6edgedb_8protocol_8protocol_BaseArrayCodec;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_SetCodec) < 0) __PYX_ERR(10, 21, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_SetCodec.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_SetCodec.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_SetCodec.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_SetCodec.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_SetCodec.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_SetCodec) < 0) __PYX_ERR(10, 21, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_SetCodec, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_SetCodec) < 0) __PYX_ERR(10, 21, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_SetCodec) < 0) __PYX_ERR(10, 21, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_SetCodec = &__pyx_type_6edgedb_8protocol_8protocol_SetCodec;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_EnumCodec = &__pyx_vtable_6edgedb_8protocol_8protocol_EnumCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_EnumCodec.__pyx_base = *__pyx_vtabptr_6edgedb_8protocol_8protocol_BaseCodec;
  __pyx_vtable_6edgedb_8protocol_8protocol_EnumCodec.__pyx_base.encode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_9EnumCodec_encode;
  __pyx_vtable_6edgedb_8protocol_8protocol_EnumCodec.__pyx_base.decode = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *))__pyx_f_6edgedb_8protocol_8protocol_9EnumCodec_decode;
  __pyx_vtable_6edgedb_8protocol_8protocol_EnumCodec.new = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*)(PyObject *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_9EnumCodec_new;
  __pyx_type_6edgedb_8protocol_8protocol_EnumCodec.tp_base = __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_EnumCodec) < 0) __PYX_ERR(11, 21, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_EnumCodec.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_EnumCodec.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_EnumCodec.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_EnumCodec.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_EnumCodec.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_EnumCodec) < 0) __PYX_ERR(11, 21, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_EnumCodec, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_EnumCodec) < 0) __PYX_ERR(11, 21, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_EnumCodec) < 0) __PYX_ERR(11, 21, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_EnumCodec = &__pyx_type_6edgedb_8protocol_8protocol_EnumCodec;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_CodecsRegistry = &__pyx_vtable_6edgedb_8protocol_8protocol_CodecsRegistry;
  __pyx_vtable_6edgedb_8protocol_8protocol_CodecsRegistry._build_codec = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *, PyObject *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_14CodecsRegistry__build_codec;
  __pyx_vtable_6edgedb_8protocol_8protocol_CodecsRegistry.build_codec = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *, PyObject *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_14CodecsRegistry_build_codec;
  __pyx_vtable_6edgedb_8protocol_8protocol_CodecsRegistry.has_codec = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_14CodecsRegistry_has_codec;
  __pyx_vtable_6edgedb_8protocol_8protocol_CodecsRegistry.get_codec = (struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_14CodecsRegistry_get_codec;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_CodecsRegistry) < 0) __PYX_ERR(4, 58, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_CodecsRegistry.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_CodecsRegistry.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_CodecsRegistry.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_CodecsRegistry.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_CodecsRegistry.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_CodecsRegistry) < 0) __PYX_ERR(4, 58, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_CodecsRegistry, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_CodecsRegistry) < 0) __PYX_ERR(4, 58, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_CodecsRegistry) < 0) __PYX_ERR(4, 58, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_CodecsRegistry = &__pyx_type_6edgedb_8protocol_8protocol_CodecsRegistry;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_QueryCodecsCache = &__pyx_vtable_6edgedb_8protocol_8protocol_QueryCodecsCache;
  __pyx_vtable_6edgedb_8protocol_8protocol_QueryCodecsCache.set = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_QueryCodecsCache *, PyObject *, enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, int, int, int, int, int, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, int))__pyx_f_6edgedb_8protocol_8protocol_16QueryCodecsCache_set;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_QueryCodecsCache) < 0) __PYX_ERR(5, 94, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_QueryCodecsCache.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_QueryCodecsCache.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_QueryCodecsCache.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_QueryCodecsCache.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_QueryCodecsCache.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_QueryCodecsCache) < 0) __PYX_ERR(5, 94, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_QueryCodecsCache, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_QueryCodecsCache) < 0) __PYX_ERR(5, 94, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_QueryCodecsCache) < 0) __PYX_ERR(5, 94, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_QueryCodecsCache = &__pyx_type_6edgedb_8protocol_8protocol_QueryCodecsCache;
  __pyx_vtabptr_6edgedb_8protocol_8protocol_SansIOProtocol = &__pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.encode_args = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_encode_args;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.parse_data_messages = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_data_messages;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.parse_sync_message = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_sync_message;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.parse_command_complete_message = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_command_complete_message;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.parse_describe_type_message = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, struct __pyx_obj_6edgedb_8protocol_8protocol_CodecsRegistry *))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_describe_type_message;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol._amend_parse_error = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, PyObject *, enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, int, int))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol__amend_parse_error;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.ignore_headers = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_ignore_headers;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.parse_headers = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_headers;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.write_headers = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_write_headers;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.parse_error_message = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_error_message;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.write = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_write;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.abort = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, int __pyx_skip_dispatch))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_abort;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.reset_status = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_reset_status;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.parse_system_config = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_system_config;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.parse_server_settings = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, PyObject *, PyObject *))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_parse_server_settings;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.fallthrough = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_fallthrough;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.write_execute_headers = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, int, int, int, uint64_t))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_write_execute_headers;
  __pyx_vtable_6edgedb_8protocol_8protocol_SansIOProtocol.ensure_connected = (PyObject *(*)(struct __pyx_obj_6edgedb_8protocol_8protocol_SansIOProtocol *))__pyx_f_6edgedb_8protocol_8protocol_14SansIOProtocol_ensure_connected;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol_SansIOProtocol) < 0) __PYX_ERR(5, 127, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol_SansIOProtocol.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol_SansIOProtocol.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol_SansIOProtocol.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol_SansIOProtocol.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_6edgedb_8protocol_8protocol_SansIOProtocol.tp_dict, __pyx_vtabptr_6edgedb_8protocol_8protocol_SansIOProtocol) < 0) __PYX_ERR(5, 127, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_SansIOProtocol, (PyObject *)&__pyx_type_6edgedb_8protocol_8protocol_SansIOProtocol) < 0) __PYX_ERR(5, 127, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6edgedb_8protocol_8protocol_SansIOProtocol) < 0) __PYX_ERR(5, 127, __pyx_L1_error)
  __pyx_ptype_6edgedb_8protocol_8protocol_SansIOProtocol = &__pyx_type_6edgedb_8protocol_8protocol_SansIOProtocol;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message) < 0) __PYX_ERR(5, 165, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message = &__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct__wait_for_message;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly) < 0) __PYX_ERR(5, 168, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly = &__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_1_try_recv_eagerly;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect) < 0) __PYX_ERR(5, 173, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect = &__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_2_wait_for_connect;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse) < 0) __PYX_ERR(5, 224, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse = &__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_3__parse;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute) < 0) __PYX_ERR(5, 353, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute = &__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_4__execute;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute) < 0) __PYX_ERR(5, 424, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute = &__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_5__optimistic_execute;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query) < 0) __PYX_ERR(5, 551, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query = &__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_6_simple_query;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous) < 0) __PYX_ERR(5, 601, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous = &__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_7_execute_anonymous;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump) < 0) __PYX_ERR(5, 719, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump = &__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_8_dump;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync) < 0) __PYX_ERR(5, 786, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync = &__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_9__sync;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore) < 0) __PYX_ERR(5, 800, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore = &__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_10_restore;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect) < 0) __PYX_ERR(5, 891, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect = &__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_11_connect;
  if (PyType_Ready(&__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl) < 0) __PYX_ERR(5, 989, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl.tp_dictoffset && __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl = &__pyx_type_6edgedb_8protocol_8protocol___pyx_scope_struct_12__auth_sasl;
  __Pyx_EnumMeta.tp_base = (&PyType_Type);
  if (PyType_Ready(&__Pyx_EnumMeta) < 0) __PYX_ERR(2, 15, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __Pyx_EnumMeta.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__Pyx_EnumMeta.tp_dictoffset && __Pyx_EnumMeta.tp_getattro == PyObject_GenericGetAttr)) {
    __Pyx_EnumMeta.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_setup_reduce((PyObject*)&__Pyx_EnumMeta) < 0) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_ptype___Pyx_EnumMeta = &__Pyx_EnumMeta;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(16, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", 
  #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(16, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(17, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(17, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(18, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(18, 15, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("datetime"); if (unlikely(!__pyx_t_1)) __PYX_ERR(15, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_8datetime_date = __Pyx_ImportType(__pyx_t_1, "datetime", "date", sizeof(PyDateTime_Date), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_8datetime_date) __PYX_ERR(15, 9, __pyx_L1_error)
  __pyx_ptype_7cpython_8datetime_time = __Pyx_ImportType(__pyx_t_1, "datetime", "time", sizeof(PyDateTime_Time), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_8datetime_time) __PYX_ERR(15, 12, __pyx_L1_error)
  __pyx_ptype_7cpython_8datetime_datetime = __Pyx_ImportType(__pyx_t_1, "datetime", "datetime", sizeof(PyDateTime_DateTime), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_8datetime_datetime) __PYX_ERR(15, 15, __pyx_L1_error)
  __pyx_ptype_7cpython_8datetime_timedelta = __Pyx_ImportType(__pyx_t_1, "datetime", "timedelta", sizeof(PyDateTime_Delta), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_8datetime_timedelta) __PYX_ERR(15, 18, __pyx_L1_error)
  __pyx_ptype_7cpython_8datetime_tzinfo = __Pyx_ImportType(__pyx_t_1, "datetime", "tzinfo", sizeof(PyDateTime_TZInfo), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_8datetime_tzinfo) __PYX_ERR(15, 21, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("edgedb.pgproto.pgproto"); if (unlikely(!__pyx_t_1)) __PYX_ERR(14, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_6edgedb_7pgproto_7pgproto_WriteBuffer = __Pyx_ImportType(__pyx_t_1, "edgedb.pgproto.pgproto", "WriteBuffer", sizeof(struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_6edgedb_7pgproto_7pgproto_WriteBuffer) __PYX_ERR(14, 8, __pyx_L1_error)
  __pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer = (struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer*)__Pyx_GetVtable(__pyx_ptype_6edgedb_7pgproto_7pgproto_WriteBuffer->tp_dict); if (unlikely(!__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer)) __PYX_ERR(14, 8, __pyx_L1_error)
  __pyx_ptype_6edgedb_7pgproto_7pgproto_ReadBuffer = __Pyx_ImportType(__pyx_t_1, "edgedb.pgproto.pgproto", "ReadBuffer", sizeof(struct __pyx_obj_6edgedb_7pgproto_7pgproto_ReadBuffer), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_6edgedb_7pgproto_7pgproto_ReadBuffer) __PYX_ERR(14, 68, __pyx_L1_error)
  __pyx_vtabptr_6edgedb_7pgproto_7pgproto_ReadBuffer = (struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_ReadBuffer*)__Pyx_GetVtable(__pyx_ptype_6edgedb_7pgproto_7pgproto_ReadBuffer->tp_dict); if (unlikely(!__pyx_vtabptr_6edgedb_7pgproto_7pgproto_ReadBuffer)) __PYX_ERR(14, 68, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("edgedb.datatypes.datatypes"); if (unlikely(!__pyx_t_1)) __PYX_ERR(19, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_6edgedb_9datatypes_9datatypes_RelativeDuration = __Pyx_ImportType(__pyx_t_1, "edgedb.datatypes.datatypes", "RelativeDuration", sizeof(struct __pyx_obj_6edgedb_9datatypes_9datatypes_RelativeDuration), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_6edgedb_9datatypes_9datatypes_RelativeDuration) __PYX_ERR(19, 24, __pyx_L1_error)
  __pyx_ptype_6edgedb_9datatypes_9datatypes_EnumDescriptor = __Pyx_ImportType(__pyx_t_1, "edgedb.datatypes.datatypes", "EnumDescriptor", sizeof(struct __pyx_obj_6edgedb_9datatypes_9datatypes_EnumDescriptor), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_6edgedb_9datatypes_9datatypes_EnumDescriptor) __PYX_ERR(20, 20, __pyx_L1_error)
  __pyx_vtabptr_6edgedb_9datatypes_9datatypes_EnumDescriptor = (struct __pyx_vtabstruct_6edgedb_9datatypes_9datatypes_EnumDescriptor*)__Pyx_GetVtable(__pyx_ptype_6edgedb_9datatypes_9datatypes_EnumDescriptor->tp_dict); if (unlikely(!__pyx_vtabptr_6edgedb_9datatypes_9datatypes_EnumDescriptor)) __PYX_ERR(20, 20, __pyx_L1_error)
  __pyx_ptype_6edgedb_9datatypes_9datatypes_EnumValue = __Pyx_ImportType(__pyx_t_1, "edgedb.datatypes.datatypes", "EnumValue", sizeof(struct __pyx_obj_6edgedb_9datatypes_9datatypes_EnumValue), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_6edgedb_9datatypes_9datatypes_EnumValue) __PYX_ERR(20, 29, __pyx_L1_error)
  __pyx_vtabptr_6edgedb_9datatypes_9datatypes_EnumValue = (struct __pyx_vtabstruct_6edgedb_9datatypes_9datatypes_EnumValue*)__Pyx_GetVtable(__pyx_ptype_6edgedb_9datatypes_9datatypes_EnumValue->tp_dict); if (unlikely(!__pyx_vtabptr_6edgedb_9datatypes_9datatypes_EnumValue)) __PYX_ERR(20, 29, __pyx_L1_error)
  __pyx_ptype_6edgedb_9datatypes_9datatypes_ConfigMemory = __Pyx_ImportType(__pyx_t_1, "edgedb.datatypes.datatypes", "ConfigMemory", sizeof(struct __pyx_obj_6edgedb_9datatypes_9datatypes_ConfigMemory), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_6edgedb_9datatypes_9datatypes_ConfigMemory) __PYX_ERR(21, 24, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __pyx_t_1 = PyImport_ImportModule("edgedb.pgproto.pgproto"); if (!__pyx_t_1) __PYX_ERR(5, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_ImportFunction(__pyx_t_1, "frb_check", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_frb_check, "PyObject *(struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *, Py_ssize_t)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "date_encode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_date_encode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "date_decode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_date_decode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "timestamp_encode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_timestamp_encode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "timestamp_decode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_timestamp_decode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "timestamptz_encode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_timestamptz_encode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "timestamptz_decode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_timestamptz_decode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "time_encode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_time_encode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "time_decode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_time_decode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "bool_encode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_bool_encode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "bool_decode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_bool_decode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "int2_encode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_int2_encode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "int2_decode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_int2_decode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "int4_encode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_int4_encode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "int4_decode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_int4_decode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "int8_encode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_int8_encode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "int8_decode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_int8_decode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "float4_encode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_float4_encode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "float4_decode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_float4_decode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "float8_encode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_float8_encode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "float8_decode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_float8_decode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "jsonb_encode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_jsonb_encode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "jsonb_decode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_jsonb_decode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "text_encode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_text_encode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "text_decode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_text_decode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "bytea_encode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_bytea_encode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "bytea_decode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_bytea_decode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "uuid_encode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_uuid_encode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "uuid_decode", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_uuid_decode, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "numeric_encode_binary", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_numeric_encode_binary, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "numeric_decode_binary_ex", (void (**)(void))&__pyx_f_6edgedb_7pgproto_7pgproto_numeric_decode_binary_ex, "PyObject *(struct __pyx_obj_6edgedb_7pgproto_7pgproto_CodecContext *, struct __pyx_t_6edgedb_7pgproto_7pgproto_FRBuffer *, int)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("edgedb.datatypes.datatypes"); if (!__pyx_t_1) __PYX_ERR(5, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_ImportFunction(__pyx_t_1, "record_desc_new", (void (**)(void))&__pyx_f_6edgedb_9datatypes_9datatypes_record_desc_new, "PyObject *(PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "record_desc_pointer_name", (void (**)(void))&__pyx_f_6edgedb_9datatypes_9datatypes_record_desc_pointer_name, "PyObject *(PyObject *, Py_ssize_t)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "record_desc_pointer_card", (void (**)(void))&__pyx_f_6edgedb_9datatypes_9datatypes_record_desc_pointer_card, "PyObject *(PyObject *, Py_ssize_t)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "tuple_new", (void (**)(void))&__pyx_f_6edgedb_9datatypes_9datatypes_tuple_new, "PyObject *(Py_ssize_t)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "tuple_set", (void (**)(void))&__pyx_f_6edgedb_9datatypes_9datatypes_tuple_set, "PyObject *(PyObject *, Py_ssize_t, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "namedtuple_new", (void (**)(void))&__pyx_f_6edgedb_9datatypes_9datatypes_namedtuple_new, "PyObject *(PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "namedtuple_set", (void (**)(void))&__pyx_f_6edgedb_9datatypes_9datatypes_namedtuple_set, "PyObject *(PyObject *, Py_ssize_t, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "object_new", (void (**)(void))&__pyx_f_6edgedb_9datatypes_9datatypes_object_new, "PyObject *(PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "object_set", (void (**)(void))&__pyx_f_6edgedb_9datatypes_9datatypes_object_set, "PyObject *(PyObject *, Py_ssize_t, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "set_check", (void (**)(void))&__pyx_f_6edgedb_9datatypes_9datatypes_set_check, "int (PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "set_new", (void (**)(void))&__pyx_f_6edgedb_9datatypes_9datatypes_set_new, "PyObject *(Py_ssize_t)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "set_set", (void (**)(void))&__pyx_f_6edgedb_9datatypes_9datatypes_set_set, "PyObject *(PyObject *, Py_ssize_t, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "set_append", (void (**)(void))&__pyx_f_6edgedb_9datatypes_9datatypes_set_append, "PyObject *(PyObject *, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "array_new", (void (**)(void))&__pyx_f_6edgedb_9datatypes_9datatypes_array_new, "PyObject *(Py_ssize_t)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "array_set", (void (**)(void))&__pyx_f_6edgedb_9datatypes_9datatypes_array_set, "PyObject *(PyObject *, Py_ssize_t, PyObject *)") < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}


#ifndef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#elif PY_MAJOR_VERSION < 3
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" void
#else
#define __Pyx_PyMODINIT_FUNC void
#endif
#else
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyObject *
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC initprotocol(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initprotocol(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_protocol(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_protocol(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
    #if PY_VERSION_HEX >= 0x030700A1
    static PY_INT64_T main_interpreter_id = -1;
    PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
    if (main_interpreter_id == -1) {
        main_interpreter_id = current_id;
        return (unlikely(current_id == -1)) ? -1 : 0;
    } else if (unlikely(main_interpreter_id != current_id))
    #else
    static PyInterpreterState *main_interpreter = NULL;
    PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
    if (!main_interpreter) {
        main_interpreter = current_interpreter;
    } else if (unlikely(main_interpreter != current_interpreter))
    #endif
    {
        PyErr_SetString(
            PyExc_ImportError,
            "Interpreter change detected - this module can only be loaded into one interpreter per process.");
        return -1;
    }
    return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        if (allow_none || value != Py_None) {
            result = PyDict_SetItemString(moddict, to_name, value);
        }
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__Pyx_check_single_interpreter())
        return NULL;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static CYTHON_SMALL_CODE int __pyx_pymod_exec_protocol(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m) {
    if (__pyx_m == __pyx_pyinit_module) return 0;
    PyErr_SetString(PyExc_RuntimeError, "Module 'protocol' has already been imported. Re-initialisation is not supported.");
    return -1;
  }
  #elif PY_MAJOR_VERSION >= 3
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  #if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
if (!__Pyx_RefNanny) {
  PyErr_Clear();
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  if (!__Pyx_RefNanny)
      Py_FatalError("failed to import 'refnanny' module");
}
#endif
  __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_protocol(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  #ifdef __Pxy_PyFrame_Initialize_Offsets
  __Pxy_PyFrame_Initialize_Offsets();
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(5, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(5, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_AsyncGen_USED
  if (__pyx_AsyncGen_init() < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  PyEval_InitThreads();
  #endif
  /*--- Module creation code ---*/
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("protocol", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(5, 1, __pyx_L1_error)
  #endif
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(5, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(5, 1, __pyx_L1_error)
  Py_INCREF(__pyx_b);
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(5, 1, __pyx_L1_error)
  Py_INCREF(__pyx_cython_runtime);
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(5, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_edgedb__protocol__protocol) {
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(5, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "edgedb.protocol.protocol")) {
      if (unlikely(PyDict_SetItemString(modules, "edgedb.protocol.protocol", __pyx_m) < 0)) __PYX_ERR(5, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  /*--- Global type/function init code ---*/
  (void)__Pyx_modinit_global_init_code();
  (void)__Pyx_modinit_variable_export_code();
  (void)__Pyx_modinit_function_export_code();
  if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(5, 1, __pyx_L1_error)
  if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(5, 1, __pyx_L1_error)
  (void)__Pyx_modinit_variable_import_code();
  if (unlikely(__Pyx_modinit_function_import_code() < 0)) __PYX_ERR(5, 1, __pyx_L1_error)
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  #endif

  /* "edgedb/protocol/protocol.pyx":24
 * cimport cpython.datetime
 * 
 * import asyncio             # <<<<<<<<<<<<<<
 * import collections
 * import datetime
 */
  __pyx_t_1 = __Pyx_patch_asyncio(__Pyx_Import(__pyx_n_s_asyncio, 0, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_asyncio, __pyx_t_1) < 0) __PYX_ERR(5, 24, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":25
 * 
 * import asyncio
 * import collections             # <<<<<<<<<<<<<<
 * import datetime
 * import json
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_collections, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 25, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_collections, __pyx_t_1) < 0) __PYX_ERR(5, 25, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":26
 * import asyncio
 * import collections
 * import datetime             # <<<<<<<<<<<<<<
 * import json
 * import time
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_datetime, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_datetime, __pyx_t_1) < 0) __PYX_ERR(5, 26, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":27
 * import collections
 * import datetime
 * import json             # <<<<<<<<<<<<<<
 * import time
 * import types
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_json, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_json, __pyx_t_1) < 0) __PYX_ERR(5, 27, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":28
 * import datetime
 * import json
 * import time             # <<<<<<<<<<<<<<
 * import types
 * import typing
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_time, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_time, __pyx_t_1) < 0) __PYX_ERR(5, 28, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":29
 * import json
 * import time
 * import types             # <<<<<<<<<<<<<<
 * import typing
 * import weakref
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_types, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_types, __pyx_t_1) < 0) __PYX_ERR(5, 29, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":30
 * import time
 * import types
 * import typing             # <<<<<<<<<<<<<<
 * import weakref
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_typing, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_typing, __pyx_t_1) < 0) __PYX_ERR(5, 30, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":31
 * import types
 * import typing
 * import weakref             # <<<<<<<<<<<<<<
 * 
 * from edgedb.pgproto.pgproto cimport (
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_weakref, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_weakref, __pyx_t_1) < 0) __PYX_ERR(5, 31, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":47
 * )
 * 
 * from edgedb.pgproto import pgproto             # <<<<<<<<<<<<<<
 * from edgedb.pgproto cimport pgproto
 * from edgedb.pgproto cimport hton
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_pgproto);
  __Pyx_GIVEREF(__pyx_n_s_pgproto);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_pgproto);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_edgedb_pgproto, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_pgproto); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pgproto, __pyx_t_1) < 0) __PYX_ERR(5, 47, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":50
 * from edgedb.pgproto cimport pgproto
 * from edgedb.pgproto cimport hton
 * from edgedb.pgproto.pgproto import UUID             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_UUID);
  __Pyx_GIVEREF(__pyx_n_s_UUID);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_UUID);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_edgedb_pgproto_pgproto, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_UUID); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_UUID, __pyx_t_2) < 0) __PYX_ERR(5, 50, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":60
 * from . cimport cpythonx
 * 
 * from edgedb import enums             # <<<<<<<<<<<<<<
 * from edgedb import errors
 * from edgedb import scram
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_enums);
  __Pyx_GIVEREF(__pyx_n_s_enums);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_enums);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_edgedb, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_enums); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_enums, __pyx_t_1) < 0) __PYX_ERR(5, 60, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":61
 * 
 * from edgedb import enums
 * from edgedb import errors             # <<<<<<<<<<<<<<
 * from edgedb import scram
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_errors);
  __Pyx_GIVEREF(__pyx_n_s_errors);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_errors);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_edgedb, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_errors); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_errors, __pyx_t_2) < 0) __PYX_ERR(5, 61, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":62
 * from edgedb import enums
 * from edgedb import errors
 * from edgedb import scram             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_scram);
  __Pyx_GIVEREF(__pyx_n_s_scram);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_scram);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_edgedb, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_scram); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_scram, __pyx_t_1) < 0) __PYX_ERR(5, 62, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/lru.pyx":20
 * 
 * 
 * import collections             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_collections, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_collections, __pyx_t_2) < 0) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/lru.pyx":23
 * 
 * 
 * cdef object _LRU_MARKER = object()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_builtin_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_XGOTREF(__pyx_v_6edgedb_8protocol_8protocol__LRU_MARKER);
  __Pyx_DECREF_SET(__pyx_v_6edgedb_8protocol_8protocol__LRU_MARKER, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":20
 * 
 * 
 * import decimal             # <<<<<<<<<<<<<<
 * import uuid
 * import datetime
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_decimal, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_decimal, __pyx_t_2) < 0) __PYX_ERR(4, 20, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":21
 * 
 * import decimal
 * import uuid             # <<<<<<<<<<<<<<
 * import datetime
 * from edgedb.datatypes import datatypes
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_uuid, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_uuid, __pyx_t_2) < 0) __PYX_ERR(4, 21, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":22
 * import decimal
 * import uuid
 * import datetime             # <<<<<<<<<<<<<<
 * from edgedb.datatypes import datatypes
 * 
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_datetime, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_datetime, __pyx_t_2) < 0) __PYX_ERR(4, 22, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":23
 * import uuid
 * import datetime
 * from edgedb.datatypes import datatypes             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_datatypes);
  __Pyx_GIVEREF(__pyx_n_s_datatypes);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_datatypes);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_edgedb_datatypes, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_datatypes); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_datatypes, __pyx_t_2) < 0) __PYX_ERR(4, 23, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":5
 * 
 * 
 * import uuid             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_uuid, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_uuid, __pyx_t_1) < 0) __PYX_ERR(22, 5, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":9
 * 
 * TYPE_IDS = {
 *     'anytype': uuid.UUID('00000000-0000-0000-0000-000000000001'),             # <<<<<<<<<<<<<<
 *     'anytuple': uuid.UUID('00000000-0000-0000-0000-000000000002'),
 *     'std': uuid.UUID('00000000-0000-0000-0000-0000000000f0'),
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(23); if (unlikely(!__pyx_t_1)) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_anytype, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":10
 * TYPE_IDS = {
 *     'anytype': uuid.UUID('00000000-0000-0000-0000-000000000001'),
 *     'anytuple': uuid.UUID('00000000-0000-0000-0000-000000000002'),             # <<<<<<<<<<<<<<
 *     'std': uuid.UUID('00000000-0000-0000-0000-0000000000f0'),
 *     'empty-tuple': uuid.UUID('00000000-0000-0000-0000-0000000000ff'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_anytuple, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":11
 *     'anytype': uuid.UUID('00000000-0000-0000-0000-000000000001'),
 *     'anytuple': uuid.UUID('00000000-0000-0000-0000-000000000002'),
 *     'std': uuid.UUID('00000000-0000-0000-0000-0000000000f0'),             # <<<<<<<<<<<<<<
 *     'empty-tuple': uuid.UUID('00000000-0000-0000-0000-0000000000ff'),
 *     'std::uuid': uuid.UUID('00000000-0000-0000-0000-000000000100'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__85, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_std, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":12
 *     'anytuple': uuid.UUID('00000000-0000-0000-0000-000000000002'),
 *     'std': uuid.UUID('00000000-0000-0000-0000-0000000000f0'),
 *     'empty-tuple': uuid.UUID('00000000-0000-0000-0000-0000000000ff'),             # <<<<<<<<<<<<<<
 *     'std::uuid': uuid.UUID('00000000-0000-0000-0000-000000000100'),
 *     'std::str': uuid.UUID('00000000-0000-0000-0000-000000000101'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_empty_tuple, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":13
 *     'std': uuid.UUID('00000000-0000-0000-0000-0000000000f0'),
 *     'empty-tuple': uuid.UUID('00000000-0000-0000-0000-0000000000ff'),
 *     'std::uuid': uuid.UUID('00000000-0000-0000-0000-000000000100'),             # <<<<<<<<<<<<<<
 *     'std::str': uuid.UUID('00000000-0000-0000-0000-000000000101'),
 *     'std::bytes': uuid.UUID('00000000-0000-0000-0000-000000000102'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 13, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 13, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__87, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 13, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_std_uuid, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":14
 *     'empty-tuple': uuid.UUID('00000000-0000-0000-0000-0000000000ff'),
 *     'std::uuid': uuid.UUID('00000000-0000-0000-0000-000000000100'),
 *     'std::str': uuid.UUID('00000000-0000-0000-0000-000000000101'),             # <<<<<<<<<<<<<<
 *     'std::bytes': uuid.UUID('00000000-0000-0000-0000-000000000102'),
 *     'std::int16': uuid.UUID('00000000-0000-0000-0000-000000000103'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__88, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_std_str, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":15
 *     'std::uuid': uuid.UUID('00000000-0000-0000-0000-000000000100'),
 *     'std::str': uuid.UUID('00000000-0000-0000-0000-000000000101'),
 *     'std::bytes': uuid.UUID('00000000-0000-0000-0000-000000000102'),             # <<<<<<<<<<<<<<
 *     'std::int16': uuid.UUID('00000000-0000-0000-0000-000000000103'),
 *     'std::int32': uuid.UUID('00000000-0000-0000-0000-000000000104'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__89, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_std_bytes, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":16
 *     'std::str': uuid.UUID('00000000-0000-0000-0000-000000000101'),
 *     'std::bytes': uuid.UUID('00000000-0000-0000-0000-000000000102'),
 *     'std::int16': uuid.UUID('00000000-0000-0000-0000-000000000103'),             # <<<<<<<<<<<<<<
 *     'std::int32': uuid.UUID('00000000-0000-0000-0000-000000000104'),
 *     'std::int64': uuid.UUID('00000000-0000-0000-0000-000000000105'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__90, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_std_int16, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":17
 *     'std::bytes': uuid.UUID('00000000-0000-0000-0000-000000000102'),
 *     'std::int16': uuid.UUID('00000000-0000-0000-0000-000000000103'),
 *     'std::int32': uuid.UUID('00000000-0000-0000-0000-000000000104'),             # <<<<<<<<<<<<<<
 *     'std::int64': uuid.UUID('00000000-0000-0000-0000-000000000105'),
 *     'std::float32': uuid.UUID('00000000-0000-0000-0000-000000000106'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__91, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_std_int32, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":18
 *     'std::int16': uuid.UUID('00000000-0000-0000-0000-000000000103'),
 *     'std::int32': uuid.UUID('00000000-0000-0000-0000-000000000104'),
 *     'std::int64': uuid.UUID('00000000-0000-0000-0000-000000000105'),             # <<<<<<<<<<<<<<
 *     'std::float32': uuid.UUID('00000000-0000-0000-0000-000000000106'),
 *     'std::float64': uuid.UUID('00000000-0000-0000-0000-000000000107'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__92, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_std_int64, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":19
 *     'std::int32': uuid.UUID('00000000-0000-0000-0000-000000000104'),
 *     'std::int64': uuid.UUID('00000000-0000-0000-0000-000000000105'),
 *     'std::float32': uuid.UUID('00000000-0000-0000-0000-000000000106'),             # <<<<<<<<<<<<<<
 *     'std::float64': uuid.UUID('00000000-0000-0000-0000-000000000107'),
 *     'std::decimal': uuid.UUID('00000000-0000-0000-0000-000000000108'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__93, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_std_float32, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":20
 *     'std::int64': uuid.UUID('00000000-0000-0000-0000-000000000105'),
 *     'std::float32': uuid.UUID('00000000-0000-0000-0000-000000000106'),
 *     'std::float64': uuid.UUID('00000000-0000-0000-0000-000000000107'),             # <<<<<<<<<<<<<<
 *     'std::decimal': uuid.UUID('00000000-0000-0000-0000-000000000108'),
 *     'std::bool': uuid.UUID('00000000-0000-0000-0000-000000000109'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__94, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_std_float64, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":21
 *     'std::float32': uuid.UUID('00000000-0000-0000-0000-000000000106'),
 *     'std::float64': uuid.UUID('00000000-0000-0000-0000-000000000107'),
 *     'std::decimal': uuid.UUID('00000000-0000-0000-0000-000000000108'),             # <<<<<<<<<<<<<<
 *     'std::bool': uuid.UUID('00000000-0000-0000-0000-000000000109'),
 *     'std::datetime': uuid.UUID('00000000-0000-0000-0000-00000000010a'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__95, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_std_decimal, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":22
 *     'std::float64': uuid.UUID('00000000-0000-0000-0000-000000000107'),
 *     'std::decimal': uuid.UUID('00000000-0000-0000-0000-000000000108'),
 *     'std::bool': uuid.UUID('00000000-0000-0000-0000-000000000109'),             # <<<<<<<<<<<<<<
 *     'std::datetime': uuid.UUID('00000000-0000-0000-0000-00000000010a'),
 *     'cal::local_datetime': uuid.UUID('00000000-0000-0000-0000-00000000010b'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__96, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_std_bool, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":23
 *     'std::decimal': uuid.UUID('00000000-0000-0000-0000-000000000108'),
 *     'std::bool': uuid.UUID('00000000-0000-0000-0000-000000000109'),
 *     'std::datetime': uuid.UUID('00000000-0000-0000-0000-00000000010a'),             # <<<<<<<<<<<<<<
 *     'cal::local_datetime': uuid.UUID('00000000-0000-0000-0000-00000000010b'),
 *     'cal::local_date': uuid.UUID('00000000-0000-0000-0000-00000000010c'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__97, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_std_datetime, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":24
 *     'std::bool': uuid.UUID('00000000-0000-0000-0000-000000000109'),
 *     'std::datetime': uuid.UUID('00000000-0000-0000-0000-00000000010a'),
 *     'cal::local_datetime': uuid.UUID('00000000-0000-0000-0000-00000000010b'),             # <<<<<<<<<<<<<<
 *     'cal::local_date': uuid.UUID('00000000-0000-0000-0000-00000000010c'),
 *     'cal::local_time': uuid.UUID('00000000-0000-0000-0000-00000000010d'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__98, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_cal_local_datetime, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":25
 *     'std::datetime': uuid.UUID('00000000-0000-0000-0000-00000000010a'),
 *     'cal::local_datetime': uuid.UUID('00000000-0000-0000-0000-00000000010b'),
 *     'cal::local_date': uuid.UUID('00000000-0000-0000-0000-00000000010c'),             # <<<<<<<<<<<<<<
 *     'cal::local_time': uuid.UUID('00000000-0000-0000-0000-00000000010d'),
 *     'std::duration': uuid.UUID('00000000-0000-0000-0000-00000000010e'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 25, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 25, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__99, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 25, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_cal_local_date, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":26
 *     'cal::local_datetime': uuid.UUID('00000000-0000-0000-0000-00000000010b'),
 *     'cal::local_date': uuid.UUID('00000000-0000-0000-0000-00000000010c'),
 *     'cal::local_time': uuid.UUID('00000000-0000-0000-0000-00000000010d'),             # <<<<<<<<<<<<<<
 *     'std::duration': uuid.UUID('00000000-0000-0000-0000-00000000010e'),
 *     'std::json': uuid.UUID('00000000-0000-0000-0000-00000000010f'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__100, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_cal_local_time, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":27
 *     'cal::local_date': uuid.UUID('00000000-0000-0000-0000-00000000010c'),
 *     'cal::local_time': uuid.UUID('00000000-0000-0000-0000-00000000010d'),
 *     'std::duration': uuid.UUID('00000000-0000-0000-0000-00000000010e'),             # <<<<<<<<<<<<<<
 *     'std::json': uuid.UUID('00000000-0000-0000-0000-00000000010f'),
 *     'std::bigint': uuid.UUID('00000000-0000-0000-0000-000000000110'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__101, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_std_duration, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":28
 *     'cal::local_time': uuid.UUID('00000000-0000-0000-0000-00000000010d'),
 *     'std::duration': uuid.UUID('00000000-0000-0000-0000-00000000010e'),
 *     'std::json': uuid.UUID('00000000-0000-0000-0000-00000000010f'),             # <<<<<<<<<<<<<<
 *     'std::bigint': uuid.UUID('00000000-0000-0000-0000-000000000110'),
 *     'cal::relative_duration': uuid.UUID('00000000-0000-0000-0000-000000000111'),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__102, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_std_json, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":29
 *     'std::duration': uuid.UUID('00000000-0000-0000-0000-00000000010e'),
 *     'std::json': uuid.UUID('00000000-0000-0000-0000-00000000010f'),
 *     'std::bigint': uuid.UUID('00000000-0000-0000-0000-000000000110'),             # <<<<<<<<<<<<<<
 *     'cal::relative_duration': uuid.UUID('00000000-0000-0000-0000-000000000111'),
 *     'cfg::memory': uuid.UUID('00000000-0000-0000-0000-000000000130')
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__103, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_std_bigint, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":30
 *     'std::json': uuid.UUID('00000000-0000-0000-0000-00000000010f'),
 *     'std::bigint': uuid.UUID('00000000-0000-0000-0000-000000000110'),
 *     'cal::relative_duration': uuid.UUID('00000000-0000-0000-0000-000000000111'),             # <<<<<<<<<<<<<<
 *     'cfg::memory': uuid.UUID('00000000-0000-0000-0000-000000000130')
 * }
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__104, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_cal_relative_duration, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/edb_types.pxi":31
 *     'std::bigint': uuid.UUID('00000000-0000-0000-0000-000000000110'),
 *     'cal::relative_duration': uuid.UUID('00000000-0000-0000-0000-000000000111'),
 *     'cfg::memory': uuid.UUID('00000000-0000-0000-0000-000000000130')             # <<<<<<<<<<<<<<
 * }
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uuid); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(22, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__105, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(22, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_cfg_memory, __pyx_t_2) < 0) __PYX_ERR(22, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_TYPE_IDS, __pyx_t_1) < 0) __PYX_ERR(22, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/base.pyx":20
 * 
 * 
 * import codecs             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_codecs, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_codecs, __pyx_t_1) < 0) __PYX_ERR(1, 20, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/base.pyx":23
 * 
 * 
 * cdef uint64_t RECORD_ENCODER_CHECKED = 1 << 0             # <<<<<<<<<<<<<<
 * cdef uint64_t RECORD_ENCODER_INVALID = 1 << 1
 * 
 */
  __pyx_v_6edgedb_8protocol_8protocol_RECORD_ENCODER_CHECKED = 1;

  /* "edgedb/protocol/codecs/base.pyx":24
 * 
 * cdef uint64_t RECORD_ENCODER_CHECKED = 1 << 0
 * cdef uint64_t RECORD_ENCODER_INVALID = 1 << 1             # <<<<<<<<<<<<<<
 * 
 * cdef bytes NULL_CODEC_ID = b'\x00' * 16
 */
  __pyx_v_6edgedb_8protocol_8protocol_RECORD_ENCODER_INVALID = 2;

  /* "edgedb/protocol/codecs/base.pyx":26
 * cdef uint64_t RECORD_ENCODER_INVALID = 1 << 1
 * 
 * cdef bytes NULL_CODEC_ID = b'\x00' * 16             # <<<<<<<<<<<<<<
 * cdef bytes EMPTY_TUPLE_CODEC_ID = TYPE_IDS.get('empty-tuple').bytes
 * 
 */
  __Pyx_INCREF(__pyx_kp_b__106);
  __Pyx_XGOTREF(__pyx_v_6edgedb_8protocol_8protocol_NULL_CODEC_ID);
  __Pyx_DECREF_SET(__pyx_v_6edgedb_8protocol_8protocol_NULL_CODEC_ID, __pyx_kp_b__106);
  __Pyx_GIVEREF(__pyx_kp_b__106);

  /* "edgedb/protocol/codecs/base.pyx":27
 * 
 * cdef bytes NULL_CODEC_ID = b'\x00' * 16
 * cdef bytes EMPTY_TUPLE_CODEC_ID = TYPE_IDS.get('empty-tuple').bytes             # <<<<<<<<<<<<<<
 * 
 * EMPTY_NULL_DATA = b'\x00\x00\x00\x00'
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_TYPE_IDS); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__107, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_bytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(1, 27, __pyx_L1_error)
  __Pyx_XGOTREF(__pyx_v_6edgedb_8protocol_8protocol_EMPTY_TUPLE_CODEC_ID);
  __Pyx_DECREF_SET(__pyx_v_6edgedb_8protocol_8protocol_EMPTY_TUPLE_CODEC_ID, ((PyObject*)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/base.pyx":29
 * cdef bytes EMPTY_TUPLE_CODEC_ID = TYPE_IDS.get('empty-tuple').bytes
 * 
 * EMPTY_NULL_DATA = b'\x00\x00\x00\x00'             # <<<<<<<<<<<<<<
 * EMPTY_RECORD_DATA = b'\x00\x00\x00\x04\x00\x00\x00\x00'
 * 
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_EMPTY_NULL_DATA, __pyx_kp_b__108) < 0) __PYX_ERR(1, 29, __pyx_L1_error)

  /* "edgedb/protocol/codecs/base.pyx":30
 * 
 * EMPTY_NULL_DATA = b'\x00\x00\x00\x00'
 * EMPTY_RECORD_DATA = b'\x00\x00\x00\x04\x00\x00\x00\x00'             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_EMPTY_RECORD_DATA, __pyx_kp_b__109) < 0) __PYX_ERR(1, 30, __pyx_L1_error)

  /* "edgedb/protocol/codecs/base.pyx":222
 * 
 * 
 * cdef EdegDBCodecContext DEFAULT_CODEC_CONTEXT = EdegDBCodecContext()             # <<<<<<<<<<<<<<
 */
  __pyx_t_2 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_6edgedb_8protocol_8protocol_EdegDBCodecContext)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_XGOTREF(((PyObject *)__pyx_v_6edgedb_8protocol_8protocol_DEFAULT_CODEC_CONTEXT));
  __Pyx_DECREF_SET(__pyx_v_6edgedb_8protocol_8protocol_DEFAULT_CODEC_CONTEXT, ((struct __pyx_obj_6edgedb_8protocol_8protocol_EdegDBCodecContext *)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/namedtuple.pyx":20
 * 
 * 
 * from edgedb import errors             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_errors);
  __Pyx_GIVEREF(__pyx_n_s_errors);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_errors);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_edgedb, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_errors); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_errors, __pyx_t_2) < 0) __PYX_ERR(3, 20, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/codecs/array.pyx":20
 * 
 * 
 * from collections.abc import (Iterable as IterableABC,             # <<<<<<<<<<<<<<
 *                              Mapping as MappingABC,
 *                              Sized as SizedABC)
 */
  __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_Iterable);
  __Pyx_GIVEREF(__pyx_n_s_Iterable);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Iterable);
  __Pyx_INCREF(__pyx_n_s_Mapping);
  __Pyx_GIVEREF(__pyx_n_s_Mapping);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_Mapping);
  __Pyx_INCREF(__pyx_n_s_Sized);
  __Pyx_GIVEREF(__pyx_n_s_Sized);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_Sized);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_collections_abc, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(9, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_IterableABC, __pyx_t_1) < 0) __PYX_ERR(9, 20, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Mapping); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_MappingABC, __pyx_t_1) < 0) __PYX_ERR(9, 21, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Sized); if (unlikely(!__pyx_t_1)) __PYX_ERR(9, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_SizedABC, __pyx_t_1) < 0) __PYX_ERR(9, 22, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":54
 * DEF NUMERIC_NEG = 0x4000
 * 
 * cdef BaseCodec NULL_CODEC = NullCodec.__new__(NullCodec)             # <<<<<<<<<<<<<<
 * cdef BaseCodec EMPTY_TUPLE_CODEC = EmptyTupleCodec.__new__(EmptyTupleCodec)
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_tp_new_6edgedb_8protocol_8protocol_NullCodec(((PyTypeObject *)__pyx_ptype_6edgedb_8protocol_8protocol_NullCodec), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 54, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (!(likely(__Pyx_TypeTest(((PyObject *)__pyx_t_2), __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec)))) __PYX_ERR(4, 54, __pyx_L1_error)
  __Pyx_XGOTREF(((PyObject *)__pyx_v_6edgedb_8protocol_8protocol_NULL_CODEC));
  __Pyx_DECREF_SET(__pyx_v_6edgedb_8protocol_8protocol_NULL_CODEC, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":55
 * 
 * cdef BaseCodec NULL_CODEC = NullCodec.__new__(NullCodec)
 * cdef BaseCodec EMPTY_TUPLE_CODEC = EmptyTupleCodec.__new__(EmptyTupleCodec)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_tp_new_6edgedb_8protocol_8protocol_EmptyTupleCodec(((PyTypeObject *)__pyx_ptype_6edgedb_8protocol_8protocol_EmptyTupleCodec), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 55, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (!(likely(__Pyx_TypeTest(((PyObject *)__pyx_t_2), __pyx_ptype_6edgedb_8protocol_8protocol_BaseCodec)))) __PYX_ERR(4, 55, __pyx_L1_error)
  __Pyx_XGOTREF(((PyObject *)__pyx_v_6edgedb_8protocol_8protocol_EMPTY_TUPLE_CODEC));
  __Pyx_DECREF_SET(__pyx_v_6edgedb_8protocol_8protocol_EMPTY_TUPLE_CODEC, ((struct __pyx_obj_6edgedb_8protocol_8protocol_BaseCodec *)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":327
 * 
 * 
 * cdef dict BASE_SCALAR_CODECS = {}             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_XGOTREF(__pyx_v_6edgedb_8protocol_8protocol_BASE_SCALAR_CODECS);
  __Pyx_DECREF_SET(__pyx_v_6edgedb_8protocol_8protocol_BASE_SCALAR_CODECS, ((PyObject*)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/codecs/codecs.pyx":660
 * 
 * 
 * register_base_scalar_codecs()             # <<<<<<<<<<<<<<
 */
  __pyx_t_2 = __pyx_f_6edgedb_8protocol_8protocol_register_base_scalar_codecs(); if (unlikely(!__pyx_t_2)) __PYX_ERR(4, 660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":70
 * 
 * 
 * cpython.datetime.import_datetime()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_f_7cpython_8datetime_import_datetime();

  /* "edgedb/protocol/protocol.pyx":74
 * 
 * _QUERY_SINGLE_METHOD = {
 *     True: {             # <<<<<<<<<<<<<<
 *         IoFormat.JSON: 'query_required_single_json',
 *         IoFormat.JSON_ELEMENTS: '_fetchall_json_elements',
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "edgedb/protocol/protocol.pyx":75
 * _QUERY_SINGLE_METHOD = {
 *     True: {
 *         IoFormat.JSON: 'query_required_single_json',             # <<<<<<<<<<<<<<
 *         IoFormat.JSON_ELEMENTS: '_fetchall_json_elements',
 *         IoFormat.BINARY: 'query_required_single',
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_e_6edgedb_8protocol_8protocol_JSON); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_n_u_query_required_single_json) < 0) __PYX_ERR(5, 75, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "edgedb/protocol/protocol.pyx":76
 *     True: {
 *         IoFormat.JSON: 'query_required_single_json',
 *         IoFormat.JSON_ELEMENTS: '_fetchall_json_elements',             # <<<<<<<<<<<<<<
 *         IoFormat.BINARY: 'query_required_single',
 *     },
 */
  __pyx_t_3 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_e_6edgedb_8protocol_8protocol_JSON_ELEMENTS); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_n_u_fetchall_json_elements) < 0) __PYX_ERR(5, 75, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "edgedb/protocol/protocol.pyx":77
 *         IoFormat.JSON: 'query_required_single_json',
 *         IoFormat.JSON_ELEMENTS: '_fetchall_json_elements',
 *         IoFormat.BINARY: 'query_required_single',             # <<<<<<<<<<<<<<
 *     },
 *     False: {
 */
  __pyx_t_3 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_e_6edgedb_8protocol_8protocol_BINARY); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 77, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_n_u_query_required_single) < 0) __PYX_ERR(5, 75, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, Py_True, __pyx_t_1) < 0) __PYX_ERR(5, 74, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "edgedb/protocol/protocol.pyx":80
 *     },
 *     False: {
 *         IoFormat.JSON: 'query_single_json',             # <<<<<<<<<<<<<<
 *         IoFormat.JSON_ELEMENTS: '_fetchall_json_elements',
 *         IoFormat.BINARY: 'query_single',
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 80, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_e_6edgedb_8protocol_8protocol_JSON); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 80, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_n_u_query_single_json) < 0) __PYX_ERR(5, 80, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "edgedb/protocol/protocol.pyx":81
 *     False: {
 *         IoFormat.JSON: 'query_single_json',
 *         IoFormat.JSON_ELEMENTS: '_fetchall_json_elements',             # <<<<<<<<<<<<<<
 *         IoFormat.BINARY: 'query_single',
 *     },
 */
  __pyx_t_3 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_e_6edgedb_8protocol_8protocol_JSON_ELEMENTS); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 81, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_n_u_fetchall_json_elements) < 0) __PYX_ERR(5, 80, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "edgedb/protocol/protocol.pyx":82
 *         IoFormat.JSON: 'query_single_json',
 *         IoFormat.JSON_ELEMENTS: '_fetchall_json_elements',
 *         IoFormat.BINARY: 'query_single',             # <<<<<<<<<<<<<<
 *     },
 * }
 */
  __pyx_t_3 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_e_6edgedb_8protocol_8protocol_BINARY); if (unlikely(!__pyx_t_3)) __PYX_ERR(5, 82, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_n_u_query_single) < 0) __PYX_ERR(5, 80, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, Py_False, __pyx_t_1) < 0) __PYX_ERR(5, 74, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_QUERY_SINGLE_METHOD, __pyx_t_2) < 0) __PYX_ERR(5, 73, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":86
 * }
 * 
 * ALL_CAPABILITIES = 0xFFFFFFFFFFFFFFFF             # <<<<<<<<<<<<<<
 * 
 * cdef dict OLD_ERROR_CODES = {
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ALL_CAPABILITIES, __pyx_int_18446744073709551615) < 0) __PYX_ERR(5, 86, __pyx_L1_error)

  /* "edgedb/protocol/protocol.pyx":89
 * 
 * cdef dict OLD_ERROR_CODES = {
 *     0x05_03_00_01: 0x05_03_01_01,  # TransactionSerializationError #2431             # <<<<<<<<<<<<<<
 *     0x05_03_00_02: 0x05_03_01_02,  # TransactionDeadlockError      #2431
 * }
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_84082689, __pyx_int_84082945) < 0) __PYX_ERR(5, 89, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_84082690, __pyx_int_84082946) < 0) __PYX_ERR(5, 89, __pyx_L1_error)
  __Pyx_XGOTREF(__pyx_v_6edgedb_8protocol_8protocol_OLD_ERROR_CODES);
  __Pyx_DECREF_SET(__pyx_v_6edgedb_8protocol_8protocol_OLD_ERROR_CODES, ((PyObject*)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":229
 *         *,
 *         reg: CodecsRegistry,
 *         io_format: IoFormat=IoFormat.BINARY,             # <<<<<<<<<<<<<<
 *         expect_one: bint=False,
 *         required_one: bool=False,
 */
  __pyx_k__66 = __pyx_e_6edgedb_8protocol_8protocol_BINARY;

  /* "edgedb/protocol/protocol.pyx":1394
 * 
 * cdef result_cardinality_mismatch_code = \
 *     errors.ResultCardinalityMismatchError._code             # <<<<<<<<<<<<<<
 * 
 * cdef bytes SYNC_MESSAGE = bytes(
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_errors); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 1394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ResultCardinalityMismatchError); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_code); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 1394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_XGOTREF(__pyx_v_6edgedb_8protocol_8protocol_result_cardinality_mismatch_code);
  __Pyx_DECREF_SET(__pyx_v_6edgedb_8protocol_8protocol_result_cardinality_mismatch_code, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":1397
 * 
 * cdef bytes SYNC_MESSAGE = bytes(
 *     WriteBuffer.new_message(SYNC_MSG).end_message())             # <<<<<<<<<<<<<<
 * cdef bytes FLUSH_MESSAGE = bytes(
 *     WriteBuffer.new_message(FLUSH_MSG).end_message())
 */
  __pyx_t_2 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('S')); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 1397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_2)->__pyx_vtab)->end_message(((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":1396
 *     errors.ResultCardinalityMismatchError._code
 * 
 * cdef bytes SYNC_MESSAGE = bytes(             # <<<<<<<<<<<<<<
 *     WriteBuffer.new_message(SYNC_MSG).end_message())
 * cdef bytes FLUSH_MESSAGE = bytes(
 */
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 1396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_XGOTREF(__pyx_v_6edgedb_8protocol_8protocol_SYNC_MESSAGE);
  __Pyx_DECREF_SET(__pyx_v_6edgedb_8protocol_8protocol_SYNC_MESSAGE, ((PyObject*)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":1399
 *     WriteBuffer.new_message(SYNC_MSG).end_message())
 * cdef bytes FLUSH_MESSAGE = bytes(
 *     WriteBuffer.new_message(FLUSH_MSG).end_message())             # <<<<<<<<<<<<<<
 */
  __pyx_t_2 = ((PyObject *)__pyx_vtabptr_6edgedb_7pgproto_7pgproto_WriteBuffer->new_message('H')); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 1399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = ((struct __pyx_vtabstruct_6edgedb_7pgproto_7pgproto_WriteBuffer *)((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_2)->__pyx_vtab)->end_message(((struct __pyx_obj_6edgedb_7pgproto_7pgproto_WriteBuffer *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 1399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":1398
 * cdef bytes SYNC_MESSAGE = bytes(
 *     WriteBuffer.new_message(SYNC_MSG).end_message())
 * cdef bytes FLUSH_MESSAGE = bytes(             # <<<<<<<<<<<<<<
 *     WriteBuffer.new_message(FLUSH_MSG).end_message())
 */
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 1398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_XGOTREF(__pyx_v_6edgedb_8protocol_8protocol_FLUSH_MESSAGE);
  __Pyx_DECREF_SET(__pyx_v_6edgedb_8protocol_8protocol_FLUSH_MESSAGE, ((PyObject*)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_LRUMapping(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6edgedb_8protocol_8protocol_1__pyx_unpickle_LRUMapping, NULL, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_LRUMapping, __pyx_t_2) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_LRUMapping__set_state(<LRUMapping> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_LRUMapping__set_state(LRUMapping __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._dict = __pyx_state[0]; __pyx_result._dict_get = __pyx_state[1]; __pyx_result._dict_move_to_end = __pyx_state[2]; __pyx_result._maxsize = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6edgedb_8protocol_8protocol_3__pyx_unpickle_CodecsRegistry, NULL, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_CodecsRegistry, __pyx_t_2) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_QueryCodecsCache(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6edgedb_8protocol_8protocol_5__pyx_unpickle_QueryCodecsCache, NULL, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_QueryCodecsCache, __pyx_t_2) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_QueryCodecsCache__set_state(<QueryCodecsCache> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_QueryCodecsCache__set_state(QueryCodecsCache __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.queries = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6edgedb_8protocol_8protocol_7__pyx_unpickle_SansIOProtocol, NULL, __pyx_n_s_edgedb_protocol_protocol); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_SansIOProtocol, __pyx_t_2) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "edgedb/protocol/protocol.pyx":1
 * #             # <<<<<<<<<<<<<<
 * # This source file is part of the EdgeDB open source project.
 * #
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(5, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(5, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "EnumBase":9
 * 
 * cdef object __Pyx_OrderedDict
 * if PY_VERSION_HEX >= 0x02070000:             # <<<<<<<<<<<<<<
 *     from collections import OrderedDict as __Pyx_OrderedDict
 * else:
 */
  __pyx_t_4 = ((PY_VERSION_HEX >= 0x02070000) != 0);
  if (__pyx_t_4) {

    /* "EnumBase":10
 * cdef object __Pyx_OrderedDict
 * if PY_VERSION_HEX >= 0x02070000:
 *     from collections import OrderedDict as __Pyx_OrderedDict             # <<<<<<<<<<<<<<
 * else:
 *     __Pyx_OrderedDict = dict
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 10, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_OrderedDict);
    __Pyx_GIVEREF(__pyx_n_s_OrderedDict);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_OrderedDict);
    __pyx_t_1 = __Pyx_Import(__pyx_n_s_collections, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 10, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 10, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_XGOTREF(__Pyx_OrderedDict);
    __Pyx_DECREF_SET(__Pyx_OrderedDict, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "EnumBase":9
 * 
 * cdef object __Pyx_OrderedDict
 * if PY_VERSION_HEX >= 0x02070000:             # <<<<<<<<<<<<<<
 *     from collections import OrderedDict as __Pyx_OrderedDict
 * else:
 */
    goto __pyx_L2;
  }

  /* "EnumBase":12
 *     from collections import OrderedDict as __Pyx_OrderedDict
 * else:
 *     __Pyx_OrderedDict = dict             # <<<<<<<<<<<<<<
 * 
 * @cython.internal
 */
  /*else*/ {
    __Pyx_INCREF(((PyObject *)(&PyDict_Type)));
    __Pyx_XGOTREF(__Pyx_OrderedDict);
    __Pyx_DECREF_SET(__Pyx_OrderedDict, ((PyObject *)(&PyDict_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyDict_Type)));
  }
  __pyx_L2:;

  /* "EnumBase":26
 * 
 * cdef object __Pyx_EnumBase
 * class __Pyx_EnumBase(int):             # <<<<<<<<<<<<<<
 *     __metaclass__ = __Pyx_EnumMeta
 *     def __new__(cls, value, name=None):
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)(&PyInt_Type)));
  __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_Pyx_EnumBase, __pyx_n_s_Pyx_EnumBase, (PyObject *) NULL, __pyx_n_s_EnumBase, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "EnumBase":27
 * cdef object __Pyx_EnumBase
 * class __Pyx_EnumBase(int):
 *     __metaclass__ = __Pyx_EnumMeta             # <<<<<<<<<<<<<<
 *     def __new__(cls, value, name=None):
 *         for v in cls:
 */
  if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_metaclass, ((PyObject *)__pyx_ptype___Pyx_EnumMeta)) < 0) __PYX_ERR(2, 27, __pyx_L1_error)

  /* "EnumBase":28
 * class __Pyx_EnumBase(int):
 *     __metaclass__ = __Pyx_EnumMeta
 *     def __new__(cls, value, name=None):             # <<<<<<<<<<<<<<
 *         for v in cls:
 *             if v == value:
 */
  __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_8EnumBase_14__Pyx_EnumBase_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_Pyx_EnumBase___new, NULL, __pyx_n_s_EnumBase, __pyx_d, ((PyObject *)__pyx_codeobj__119)); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__120);
  if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_new, __pyx_t_5) < 0) __PYX_ERR(2, 28, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "EnumBase":39
 *         cls.__members__[name] = res
 *         return res
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<%s.%s: %d>" % (self.__class__.__name__, self.name, self)
 *     def __str__(self):
 */
  __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_8EnumBase_14__Pyx_EnumBase_3__repr__, 0, __pyx_n_s_Pyx_EnumBase___repr, NULL, __pyx_n_s_EnumBase, __pyx_d, ((PyObject *)__pyx_codeobj__122)); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_repr, __pyx_t_5) < 0) __PYX_ERR(2, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "EnumBase":41
 *     def __repr__(self):
 *         return "<%s.%s: %d>" % (self.__class__.__name__, self.name, self)
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s.%s" % (self.__class__.__name__, self.name)
 * 
 */
  __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_8EnumBase_14__Pyx_EnumBase_5__str__, 0, __pyx_n_s_Pyx_EnumBase___str, NULL, __pyx_n_s_EnumBase, __pyx_d, ((PyObject *)__pyx_codeobj__124)); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_str, __pyx_t_5) < 0) __PYX_ERR(2, 41, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "EnumBase":26
 * 
 * cdef object __Pyx_EnumBase
 * class __Pyx_EnumBase(int):             # <<<<<<<<<<<<<<
 *     __metaclass__ = __Pyx_EnumMeta
 *     def __new__(cls, value, name=None):
 */
  __pyx_t_5 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_Pyx_EnumBase, __pyx_t_1, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_XGOTREF(__Pyx_EnumBase);
  __Pyx_DECREF_SET(__Pyx_EnumBase, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "EnumBase":44
 *         return "%s.%s" % (self.__class__.__name__, self.name)
 * 
 * if PY_VERSION_HEX >= 0x03040000:             # <<<<<<<<<<<<<<
 *     from enum import IntEnum as __Pyx_EnumBase
 * 
 */
  __pyx_t_4 = ((PY_VERSION_HEX >= 0x03040000) != 0);
  if (__pyx_t_4) {

    /* "EnumBase":45
 * 
 * if PY_VERSION_HEX >= 0x03040000:
 *     from enum import IntEnum as __Pyx_EnumBase             # <<<<<<<<<<<<<<
 * 
 */
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 45, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_s_IntEnum);
    __Pyx_GIVEREF(__pyx_n_s_IntEnum);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_IntEnum);
    __pyx_t_2 = __Pyx_Import(__pyx_n_s_enum, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 45, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_IntEnum); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 45, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XGOTREF(__Pyx_EnumBase);
    __Pyx_DECREF_SET(__Pyx_EnumBase, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "EnumBase":44
 *         return "%s.%s" % (self.__class__.__name__, self.name)
 * 
 * if PY_VERSION_HEX >= 0x03040000:             # <<<<<<<<<<<<<<
 *     from enum import IntEnum as __Pyx_EnumBase
 * 
 */
  }

  /* "(tree fragment)":1
 * def __pyx_unpickle___Pyx_EnumMeta(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8EnumBase_1__pyx_unpickle___Pyx_EnumMeta, NULL, __pyx_n_s_EnumBase); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle___Pyx_EnumMeta, __pyx_t_2) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "EnumType":50
 * 
 * 
 * cdef dict __Pyx_globals = globals()             # <<<<<<<<<<<<<<
 * if PY_VERSION_HEX >= 0x03040000:
 * 
 */
  __pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(2, 50, __pyx_L1_error)
  __Pyx_XGOTREF(__Pyx_globals);
  __Pyx_DECREF_SET(__Pyx_globals, ((PyObject*)__pyx_t_2));
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "EnumType":51
 * 
 * cdef dict __Pyx_globals = globals()
 * if PY_VERSION_HEX >= 0x03040000:             # <<<<<<<<<<<<<<
 * 
 *     IoFormat = __Pyx_EnumBase('IoFormat', __Pyx_OrderedDict([
 */
  __pyx_t_4 = ((PY_VERSION_HEX >= 0x03040000) != 0);
  if (__pyx_t_4) {

    /* "EnumType":54
 * 
 *     IoFormat = __Pyx_EnumBase('IoFormat', __Pyx_OrderedDict([
 *         ('BINARY', BINARY),             # <<<<<<<<<<<<<<
 *         ('JSON', JSON),
 *         ('JSON_ELEMENTS', JSON_ELEMENTS),
 */
    __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_e_6edgedb_8protocol_8protocol_BINARY); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 54, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 54, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_s_BINARY);
    __Pyx_GIVEREF(__pyx_n_s_BINARY);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_BINARY);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "EnumType":55
 *     IoFormat = __Pyx_EnumBase('IoFormat', __Pyx_OrderedDict([
 *         ('BINARY', BINARY),
 *         ('JSON', JSON),             # <<<<<<<<<<<<<<
 *         ('JSON_ELEMENTS', JSON_ELEMENTS),
 *     ]))
 */
    __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_e_6edgedb_8protocol_8protocol_JSON); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 55, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 55, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_n_s_JSON);
    __Pyx_GIVEREF(__pyx_n_s_JSON);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_JSON);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "EnumType":56
 *         ('BINARY', BINARY),
 *         ('JSON', JSON),
 *         ('JSON_ELEMENTS', JSON_ELEMENTS),             # <<<<<<<<<<<<<<
 *     ]))
 *     __Pyx_globals['BINARY'] = IoFormat.BINARY
 */
    __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_e_6edgedb_8protocol_8protocol_JSON_ELEMENTS); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 56, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 56, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_n_s_JSON_ELEMENTS);
    __Pyx_GIVEREF(__pyx_n_s_JSON_ELEMENTS);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_JSON_ELEMENTS);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "EnumType":53
 * if PY_VERSION_HEX >= 0x03040000:
 * 
 *     IoFormat = __Pyx_EnumBase('IoFormat', __Pyx_OrderedDict([             # <<<<<<<<<<<<<<
 *         ('BINARY', BINARY),
 *         ('JSON', JSON),
 */
    __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 53, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_5);
    PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__Pyx_OrderedDict, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 53, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 53, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_IoFormat);
    __Pyx_GIVEREF(__pyx_n_s_IoFormat);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_IoFormat);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__Pyx_EnumBase, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 53, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_IoFormat, __pyx_t_5) < 0) __PYX_ERR(2, 53, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "EnumType":58
 *         ('JSON_ELEMENTS', JSON_ELEMENTS),
 *     ]))
 *     __Pyx_globals['BINARY'] = IoFormat.BINARY             # <<<<<<<<<<<<<<
 *     __Pyx_globals['JSON'] = IoFormat.JSON
 *     __Pyx_globals['JSON_ELEMENTS'] = IoFormat.JSON_ELEMENTS
 */
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_IoFormat); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 58, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_BINARY); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 58, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(__Pyx_globals == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 58, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__Pyx_globals, __pyx_n_s_BINARY, __pyx_t_2) < 0)) __PYX_ERR(2, 58, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "EnumType":59
 *     ]))
 *     __Pyx_globals['BINARY'] = IoFormat.BINARY
 *     __Pyx_globals['JSON'] = IoFormat.JSON             # <<<<<<<<<<<<<<
 *     __Pyx_globals['JSON_ELEMENTS'] = IoFormat.JSON_ELEMENTS
 * else:
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_IoFormat); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 59, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_JSON); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 59, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(__Pyx_globals == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 59, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__Pyx_globals, __pyx_n_s_JSON, __pyx_t_5) < 0)) __PYX_ERR(2, 59, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "EnumType":60
 *     __Pyx_globals['BINARY'] = IoFormat.BINARY
 *     __Pyx_globals['JSON'] = IoFormat.JSON
 *     __Pyx_globals['JSON_ELEMENTS'] = IoFormat.JSON_ELEMENTS             # <<<<<<<<<<<<<<
 * else:
 *     class IoFormat(__Pyx_EnumBase):
 */
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_IoFormat); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 60, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_JSON_ELEMENTS); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 60, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(__Pyx_globals == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 60, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__Pyx_globals, __pyx_n_s_JSON_ELEMENTS, __pyx_t_2) < 0)) __PYX_ERR(2, 60, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "EnumType":51
 * 
 * cdef dict __Pyx_globals = globals()
 * if PY_VERSION_HEX >= 0x03040000:             # <<<<<<<<<<<<<<
 * 
 *     IoFormat = __Pyx_EnumBase('IoFormat', __Pyx_OrderedDict([
 */
    goto __pyx_L4;
  }

  /* "EnumType":62
 *     __Pyx_globals['JSON_ELEMENTS'] = IoFormat.JSON_ELEMENTS
 * else:
 *     class IoFormat(__Pyx_EnumBase):             # <<<<<<<<<<<<<<
 *         pass
 *     __Pyx_globals['BINARY'] = IoFormat(BINARY, 'BINARY')
 */
  /*else*/ {
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 62, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__Pyx_EnumBase);
    __Pyx_GIVEREF(__Pyx_EnumBase);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __Pyx_EnumBase);
    __pyx_t_5 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 62, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_5, __pyx_t_2, __pyx_n_s_IoFormat, __pyx_n_s_IoFormat, (PyObject *) NULL, __pyx_n_s_EnumType, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 62, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_Py3ClassCreate(__pyx_t_5, __pyx_n_s_IoFormat, __pyx_t_2, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 62, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_IoFormat, __pyx_t_1) < 0) __PYX_ERR(2, 62, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "EnumType":64
 *     class IoFormat(__Pyx_EnumBase):
 *         pass
 *     __Pyx_globals['BINARY'] = IoFormat(BINARY, 'BINARY')             # <<<<<<<<<<<<<<
 *     __Pyx_globals['JSON'] = IoFormat(JSON, 'JSON')
 *     __Pyx_globals['JSON_ELEMENTS'] = IoFormat(JSON_ELEMENTS, 'JSON_ELEMENTS')
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_IoFormat); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 64, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_e_6edgedb_8protocol_8protocol_BINARY); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 64, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 64, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
    __Pyx_INCREF(__pyx_n_s_BINARY);
    __Pyx_GIVEREF(__pyx_n_s_BINARY);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_BINARY);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 64, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(__Pyx_globals == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 64, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__Pyx_globals, __pyx_n_s_BINARY, __pyx_t_5) < 0)) __PYX_ERR(2, 64, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "EnumType":65
 *         pass
 *     __Pyx_globals['BINARY'] = IoFormat(BINARY, 'BINARY')
 *     __Pyx_globals['JSON'] = IoFormat(JSON, 'JSON')             # <<<<<<<<<<<<<<
 *     __Pyx_globals['JSON_ELEMENTS'] = IoFormat(JSON_ELEMENTS, 'JSON_ELEMENTS')
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_IoFormat); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 65, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_e_6edgedb_8protocol_8protocol_JSON); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 65, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 65, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __Pyx_INCREF(__pyx_n_s_JSON);
    __Pyx_GIVEREF(__pyx_n_s_JSON);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_JSON);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 65, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(__Pyx_globals == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 65, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__Pyx_globals, __pyx_n_s_JSON, __pyx_t_3) < 0)) __PYX_ERR(2, 65, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "EnumType":66
 *     __Pyx_globals['BINARY'] = IoFormat(BINARY, 'BINARY')
 *     __Pyx_globals['JSON'] = IoFormat(JSON, 'JSON')
 *     __Pyx_globals['JSON_ELEMENTS'] = IoFormat(JSON_ELEMENTS, 'JSON_ELEMENTS')             # <<<<<<<<<<<<<<
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_IoFormat); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 66, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(__pyx_e_6edgedb_8protocol_8protocol_JSON_ELEMENTS); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 66, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 66, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_JSON_ELEMENTS);
    __Pyx_GIVEREF(__pyx_n_s_JSON_ELEMENTS);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_JSON_ELEMENTS);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 66, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(__Pyx_globals == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 66, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__Pyx_globals, __pyx_n_s_JSON_ELEMENTS, __pyx_t_2) < 0)) __PYX_ERR(2, 66, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L4:;

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init edgedb.protocol.protocol", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_CLEAR(__pyx_m);
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init edgedb.protocol.protocol");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule(modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, "RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#endif

/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

/* RaiseKeywordRequired */
static void __Pyx_RaiseKeywordRequired(const char* func_name, PyObject* kw_name) {
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() needs keyword-only argument %U", func_name, kw_name);
        #else
        "%s() needs keyword-only argument %s", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

/* RaiseDoubleKeywords */
static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

/* ParseKeywords */
static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

/* RaiseArgTupleInvalid */
static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
    }
}
#endif

/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

/* PyObjectCall */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = Py_TYPE(func)->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallMethO */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallOneArg */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
    if (likely(PyCFunction_Check(func))) {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (__Pyx_PyFastCFunction_Check(func)) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* RaiseException */
#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause) {
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = __Pyx_PyThreadState_Current;
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

/* PyDictVersioning */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
    PyObject **dictptr = NULL;
    Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
    if (offset) {
#if CYTHON_COMPILING_IN_CPYTHON
        dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
#else
        dictptr = _PyObject_GetDictPtr(obj);
#endif
    }
    return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
        return 0;
    return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif

/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
    result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    } else if (unlikely(PyErr_Occurred())) {
        return NULL;
    }
#else
    result = PyDict_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
    PyErr_Clear();
#endif
    return __Pyx_GetBuiltinName(name);
}

/* PyObjectCallNoArg */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#else
    if (likely(PyCFunction_Check(func)))
#endif
    {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* PyObjectCall2Args */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
    PyObject *args, *result = NULL;
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyFunction_FastCall(function, args, 2);
    }
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyCFunction_FastCall(function, args, 2);
    }
    #endif
    args = PyTuple_New(2);
    if (unlikely(!args)) goto done;
    Py_INCREF(arg1);
    PyTuple_SET_ITEM(args, 0, arg1);
    Py_INCREF(arg2);
    PyTuple_SET_ITEM(args, 1, arg2);
    Py_INCREF(function);
    result = __Pyx_PyObject_Call(function, args, NULL);
    Py_DECREF(args);
    Py_DECREF(function);
done:
    return result;
}

/* GetItemInt */
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return NULL;
                    PyErr_Clear();
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

/* ObjectGetItem */
#if CYTHON_USE_TYPE_SLOTS
static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
    PyObject *runerr;
    Py_ssize_t key_value;
    PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
    if (unlikely(!(m && m->sq_item))) {
        PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
        return NULL;
    }
    key_value = __Pyx_PyIndex_AsSsize_t(index);
    if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
        return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
    }
    if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
        PyErr_Clear();
        PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
    }
    return NULL;
}
static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
    PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
    if (likely(m && m->mp_subscript)) {
        return m->mp_subscript(obj, key);
    }
    return __Pyx_PyObject_GetIndex(obj, key);
}
#endif

/* PyErrExceptionMatches */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    PyObject *exc_type = tstate->curexc_type;
    if (exc_type == err) return 1;
    if (unlikely(!exc_type)) return 0;
    if (unlikely(PyTuple_Check(err)))
        return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* GetAttr */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

/* GetAttr3 */
static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        return NULL;
    __Pyx_PyErr_Clear();
    Py_INCREF(d);
    return d;
}
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = __Pyx_GetAttr(o, n);
    return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
}

/* KeywordStringCheck */
static int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
#if CYTHON_COMPILING_IN_PYPY
    if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
        goto invalid_keyword;
    return 1;
#else
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_Check(key)))
        #endif
            if (unlikely(!PyUnicode_Check(key)))
                goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    return 0;
#endif
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}

/* PyUnicode_Unicode */
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj) {
    if (unlikely(obj == Py_None))
        obj = __pyx_kp_u_None;
    return __Pyx_NewRef(obj);
}

/* JoinPyUnicode */
static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
                                      CYTHON_UNUSED Py_UCS4 max_char) {
#if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    PyObject *result_uval;
    int result_ukind;
    Py_ssize_t i, char_pos;
    void *result_udata;
#if CYTHON_PEP393_ENABLED
    result_uval = PyUnicode_New(result_ulength, max_char);
    if (unlikely(!result_uval)) return NULL;
    result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND;
    result_udata = PyUnicode_DATA(result_uval);
#else
    result_uval = PyUnicode_FromUnicode(NULL, result_ulength);
    if (unlikely(!result_uval)) return NULL;
    result_ukind = sizeof(Py_UNICODE);
    result_udata = PyUnicode_AS_UNICODE(result_uval);
#endif
    char_pos = 0;
    for (i=0; i < value_count; i++) {
        int ukind;
        Py_ssize_t ulength;
        void *udata;
        PyObject *uval = PyTuple_GET_ITEM(value_tuple, i);
        if (unlikely(__Pyx_PyUnicode_READY(uval)))
            goto bad;
        ulength = __Pyx_PyUnicode_GET_LENGTH(uval);
        if (unlikely(!ulength))
            continue;
        if (unlikely(char_pos + ulength < 0))
            goto overflow;
        ukind = __Pyx_PyUnicode_KIND(uval);
        udata = __Pyx_PyUnicode_DATA(uval);
        if (!CYTHON_PEP393_ENABLED || ukind == result_ukind) {
            memcpy((char *)result_udata + char_pos * result_ukind, udata, (size_t) (ulength * result_ukind));
        } else {
            #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_FastCopyCharacters)
            _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
            #else
            Py_ssize_t j;
            for (j=0; j < ulength; j++) {
                Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j);
                __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar);
            }
            #endif
        }
        char_pos += ulength;
    }
    return result_uval;
overflow:
    PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string");
bad:
    Py_DECREF(result_uval);
    return NULL;
#else
    result_ulength++;
    value_count++;
    return PyUnicode_Join(__pyx_empty_unicode, value_tuple);
#endif
}

/* CIntToDigits */
static const char DIGIT_PAIRS_10[2*10*10+1] = {
    "00010203040506070809"
    "10111213141516171819"
    "20212223242526272829"
    "30313233343536373839"
    "40414243444546474849"
    "50515253545556575859"
    "60616263646566676869"
    "70717273747576777879"
    "80818283848586878889"
    "90919293949596979899"
};
static const char DIGIT_PAIRS_8[2*8*8+1] = {
    "0001020304050607"
    "1011121314151617"
    "2021222324252627"
    "3031323334353637"
    "4041424344454647"
    "5051525354555657"
    "6061626364656667"
    "7071727374757677"
};
static const char DIGITS_HEX[2*16+1] = {
    "0123456789abcdef"
    "0123456789ABCDEF"
};

/* BuildPyUnicode */
static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, char* chars, int clength,
                                                int prepend_sign, char padding_char) {
    PyObject *uval;
    Py_ssize_t uoffset = ulength - clength;
#if CYTHON_USE_UNICODE_INTERNALS
    Py_ssize_t i;
#if CYTHON_PEP393_ENABLED
    void *udata;
    uval = PyUnicode_New(ulength, 127);
    if (unlikely(!uval)) return NULL;
    udata = PyUnicode_DATA(uval);
#else
    Py_UNICODE *udata;
    uval = PyUnicode_FromUnicode(NULL, ulength);
    if (unlikely(!uval)) return NULL;
    udata = PyUnicode_AS_UNICODE(uval);
#endif
    if (uoffset > 0) {
        i = 0;
        if (prepend_sign) {
            __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, 0, '-');
            i++;
        }
        for (; i < uoffset; i++) {
            __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, i, padding_char);
        }
    }
    for (i=0; i < clength; i++) {
        __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, uoffset+i, chars[i]);
    }
#else
    {
        PyObject *sign = NULL, *padding = NULL;
        uval = NULL;
        if (uoffset > 0) {
            prepend_sign = !!prepend_sign;
            if (uoffset > prepend_sign) {
                padding = PyUnicode_FromOrdinal(padding_char);
                if (likely(padding) && uoffset > prepend_sign + 1) {
                    PyObject *tmp;
                    PyObject *repeat = PyInt_FromSize_t(uoffset - prepend_sign);
                    if (unlikely(!repeat)) goto done_or_error;
                    tmp = PyNumber_Multiply(padding, repeat);
                    Py_DECREF(repeat);
                    Py_DECREF(padding);
                    padding = tmp;
                }
                if (unlikely(!padding)) goto done_or_error;
            }
            if (prepend_sign) {
                sign = PyUnicode_FromOrdinal('-');
                if (unlikely(!sign)) goto done_or_error;
            }
        }
        uval = PyUnicode_DecodeASCII(chars, clength, NULL);
        if (likely(uval) && padding) {
            PyObject *tmp = PyNumber_Add(padding, uval);
            Py_DECREF(uval);
            uval = tmp;
        }
        if (likely(uval) && sign) {
            PyObject *tmp = PyNumber_Add(sign, uval);
            Py_DECREF(uval);
            uval = tmp;
        }
done_or_error:
        Py_XDECREF(padding);
        Py_XDECREF(sign);
    }
#endif
    return uval;
}

/* CIntToPyUnicode */
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned short    uint16_t;
        #else
           typedef unsigned __int16  uint16_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_From_Py_ssize_t(Py_ssize_t value, Py_ssize_t width, char padding_char, char format_char) {
    char digits[sizeof(Py_ssize_t)*3+2];
    char *dpos, *end = digits + sizeof(Py_ssize_t)*3+2;
    const char *hex_digits = DIGITS_HEX;
    Py_ssize_t length, ulength;
    int prepend_sign, last_one_off;
    Py_ssize_t remaining;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const Py_ssize_t neg_one = (Py_ssize_t) -1, const_zero = (Py_ssize_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (format_char == 'X') {
        hex_digits += 16;
        format_char = 'x';
    }
    remaining = value;
    last_one_off = 0;
    dpos = end;
    do {
        int digit_pos;
        switch (format_char) {
        case 'o':
            digit_pos = abs((int)(remaining % (8*8)));
            remaining = (Py_ssize_t) (remaining / (8*8));
            dpos -= 2;
            *(uint16_t*)dpos = ((const uint16_t*)DIGIT_PAIRS_8)[digit_pos];
            last_one_off = (digit_pos < 8);
            break;
        case 'd':
            digit_pos = abs((int)(remaining % (10*10)));
            remaining = (Py_ssize_t) (remaining / (10*10));
            dpos -= 2;
            *(uint16_t*)dpos = ((const uint16_t*)DIGIT_PAIRS_10)[digit_pos];
            last_one_off = (digit_pos < 10);
            break;
        case 'x':
            *(--dpos) = hex_digits[abs((int)(remaining % 16))];
            remaining = (Py_ssize_t) (remaining / 16);
            break;
        default:
            assert(0);
            break;
        }
    } while (unlikely(remaining != 0));
    if (last_one_off) {
        assert(*dpos == '0');
        dpos++;
    }
    length = end - dpos;
    ulength = length;
    prepend_sign = 0;
    if (!is_unsigned && value <= neg_one) {
        if (padding_char == ' ' || width <= length + 1) {
            *(--dpos) = '-';
            ++length;
        } else {
            prepend_sign = 1;
        }
        ++ulength;
    }
    if (width > ulength) {
        ulength = width;
    }
    if (ulength == 1) {
        return PyUnicode_FromOrdinal(*dpos);
    }
    return __Pyx_PyUnicode_BuildFromAscii(ulength, dpos, (int) length, prepend_sign, padding_char);
}

/* GetTopmostException */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
{
    _PyErr_StackItem *exc_info = tstate->exc_info;
    while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
           exc_info->previous_item != NULL)
    {
        exc_info = exc_info->previous_item;
    }
    return exc_info;
}
#endif

/* SaveResetException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
    *type = exc_info->exc_type;
    *value = exc_info->exc_value;
    *tb = exc_info->exc_traceback;
    #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    #endif
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = type;
    exc_info->exc_value = value;
    exc_info->exc_traceback = tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* GetException */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
#endif
{
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_FAST_THREAD_STATE
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_FAST_THREAD_STATE
    #if CYTHON_USE_EXC_INFO_STACK
    {
        _PyErr_StackItem *exc_info = tstate->exc_info;
        tmp_type = exc_info->exc_type;
        tmp_value = exc_info->exc_value;
        tmp_tb = exc_info->exc_traceback;
        exc_info->exc_type = local_type;
        exc_info->exc_value = local_value;
        exc_info->exc_traceback = local_tb;
    }
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

/* SliceObject */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_USE_TYPE_SLOTS
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                    goto bad;
                PyErr_Clear();
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_USE_TYPE_SLOTS
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

/* SwapException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = *type;
    exc_info->exc_value = *value;
    exc_info->exc_traceback = *tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
    #endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#endif

/* PyIntBinop */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddCObj(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op2))) {
        const long a = intval;
        long x;
        long b = PyInt_AS_LONG(op2);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op2))) {
        const long a = intval;
        long b, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG lla = intval;
        PY_LONG_LONG llb, llx;
#endif
        const digit* digits = ((PyLongObject*)op2)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op2);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            b = likely(size) ? digits[0] : 0;
            if (size == -1) b = -b;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        b = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        b = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        b = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        b = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        b = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        b = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op2)) {
        const long a = intval;
        double b = PyFloat_AS_DOUBLE(op2);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

/* PyIntBinop */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

/* DictGetItem */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            if (unlikely(PyTuple_Check(key))) {
                PyObject* args = PyTuple_Pack(1, key);
                if (likely(args)) {
                    PyErr_SetObject(PyExc_KeyError, args);
                    Py_DECREF(args);
                }
            } else {
                PyErr_SetObject(PyExc_KeyError, key);
            }
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#endif

/* BytesEquals */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result;
#if CYTHON_USE_UNICODE_INTERNALS
            Py_hash_t hash1, hash2;
            hash1 = ((PyBytesObject*)s1)->ob_shash;
            hash2 = ((PyBytesObject*)s2)->ob_shash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                return (equals == Py_NE);
            }
#endif
            result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

/* UnicodeEquals */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
#if CYTHON_USE_UNICODE_INTERNALS
        {
            Py_hash_t hash1, hash2;
        #if CYTHON_PEP393_ENABLED
            hash1 = ((PyASCIIObject*)s1)->hash;
            hash2 = ((PyASCIIObject*)s2)->hash;
        #else
            hash1 = ((PyUnicodeObject*)s1)->hash;
            hash2 = ((PyUnicodeObject*)s2)->hash;
        #endif
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                goto return_ne;
            }
        }
#endif
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        #if PY_MAJOR_VERSION < 3
        Py_XDECREF(owned_ref);
        #endif
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

/* UnpackUnboundCMethod */
static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
    }
#endif
    return 0;
}

/* CallUnboundCMethod1 */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
    if (likely(cfunc->func)) {
        int flag = cfunc->flag;
        if (flag == METH_O) {
            return (*(cfunc->func))(self, arg);
        } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) {
            if (PY_VERSION_HEX >= 0x030700A0) {
                return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1);
            } else {
                return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
            }
        } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
        }
    }
    return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 0, arg);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 1, arg);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(2, self, arg);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* CallUnboundCMethod2 */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
    if (likely(cfunc->func)) {
        PyObject *args[2] = {arg1, arg2};
        if (cfunc->flag == METH_FASTCALL) {
            #if PY_VERSION_HEX >= 0x030700A0
            return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, args, 2);
            #else
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL);
            #endif
        }
        #if PY_VERSION_HEX >= 0x030700A0
        if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL);
        #endif
    }
    return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 0, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 1, arg2);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(3);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 1, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 2, arg2);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(3, self, arg1, arg2);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* dict_getitem_default */
static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
    PyObject* value;
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (unlikely(PyErr_Occurred()))
            return NULL;
        value = default_value;
    }
    Py_INCREF(value);
    if ((1));
#else
    if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
        value = PyDict_GetItem(d, key);
        if (unlikely(!value)) {
            value = default_value;
        }
        Py_INCREF(value);
    }
#endif
    else {
        if (default_value == Py_None)
            value = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_get, d, key);
        else
            value = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_get, d, key, default_value);
    }
    return value;
}

/* ExtTypeTest */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(__Pyx_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* PyObjectFormatAndDecref */
static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f) {
    if (unlikely(!s)) return NULL;
    if (likely(PyUnicode_CheckExact(s))) return s;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyString_CheckExact(s))) {
        PyObject *result = PyUnicode_FromEncodedObject(s, NULL, "strict");
        Py_DECREF(s);
        return result;
    }
    #endif
    return __Pyx_PyObject_FormatAndDecref(s, f);
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f) {
    PyObject *result = PyObject_Format(s, f);
    Py_DECREF(s);
    return result;
}

/* PyIntCompare */
static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
    if (op1 == op2) {
        Py_RETURN_TRUE;
    }
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
        if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        int unequal;
        unsigned long uintval;
        Py_ssize_t size = Py_SIZE(op1);
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        if (intval == 0) {
            if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
        } else if (intval < 0) {
            if (size >= 0)
                Py_RETURN_FALSE;
            intval = -intval;
            size = -size;
        } else {
            if (size <= 0)
                Py_RETURN_FALSE;
        }
        uintval = (unsigned long) intval;
#if PyLong_SHIFT * 4 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 4)) {
            unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 3 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 3)) {
            unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 2 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 2)) {
            unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 1 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 1)) {
            unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
            unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
        if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
        if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    return (
        PyObject_RichCompare(op1, op2, Py_EQ));
}

/* PyIntBinop */
#if !CYTHON_COMPILING_IN_PYPY
#if PY_MAJOR_VERSION < 3 || CYTHON_USE_PYLONG_INTERNALS
#define __Pyx_PyInt_RemainderObjC_ZeroDivisionError(operand)\
    if (unlikely(zerodivision_check && ((operand) == 0))) {\
        PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");\
        return NULL;\
    }
#endif
static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            __Pyx_PyInt_RemainderObjC_ZeroDivisionError(b)
            x = a % b;
            x += ((x != 0) & ((x ^ b) < 0)) * b;
            return PyInt_FromLong(x);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_remainder(op1, op2);
            }
        }
                __Pyx_PyInt_RemainderObjC_ZeroDivisionError(b)
                x = a % b;
                x += ((x != 0) & ((x ^ b) < 0)) * b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla % llb;
                llx += ((llx != 0) & ((llx ^ llb) < 0)) * llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    return (inplace ? PyNumber_InPlaceRemainder : PyNumber_Remainder)(op1, op2);
}
#endif

/* PyIntBinop */
#if !CYTHON_COMPILING_IN_PYPY
#if PY_MAJOR_VERSION < 3 || CYTHON_USE_PYLONG_INTERNALS
#define __Pyx_PyInt_FloorDivideObjC_ZeroDivisionError(operand)\
    if (unlikely(zerodivision_check && ((operand) == 0))) {\
        PyErr_SetString(PyExc_ZeroDivisionError, "integer division by zero");\
        return NULL;\
    }
#endif
static PyObject* __Pyx_PyInt_FloorDivideObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            __Pyx_PyInt_FloorDivideObjC_ZeroDivisionError(b)
            if (unlikely(b == -1 && ((unsigned long)a) == 0-(unsigned long)a))
                return PyInt_Type.tp_as_number->nb_floor_divide(op1, op2);
            else {
                long q, r;
                q = a / b;
                r = a - q*b;
                q -= ((r != 0) & ((r ^ b) < 0));
                x = q;
            }
            return PyInt_FromLong(x);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_floor_divide(op1, op2);
            }
        }
                __Pyx_PyInt_FloorDivideObjC_ZeroDivisionError(b)
                {
                    long q, r;
                    q = a / b;
                    r = a - q*b;
                    q -= ((r != 0) & ((r ^ b) < 0));
                    x = q;
                }
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                {
                    PY_LONG_LONG q, r;
                    q = lla / llb;
                    r = lla - q*llb;
                    q -= ((r != 0) & ((r ^ llb) < 0));
                    llx = q;
                }
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    return (inplace ? PyNumber_InPlaceFloorDivide : PyNumber_FloorDivide)(op1, op2);
}
#endif

/* ArgTypeTest */
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    else if (exact) {
        #if PY_MAJOR_VERSION == 2
        if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(__Pyx_TypeCheck(obj, type))) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

/* IterFinish */
static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

/* PyObjectGetMethod */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
    PyObject *attr;
#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
    PyTypeObject *tp = Py_TYPE(obj);
    PyObject *descr;
    descrgetfunc f = NULL;
    PyObject **dictptr, *dict;
    int meth_found = 0;
    assert (*method == NULL);
    if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
        attr = __Pyx_PyObject_GetAttrStr(obj, name);
        goto try_unpack;
    }
    if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
        return 0;
    }
    descr = _PyType_Lookup(tp, name);
    if (likely(descr != NULL)) {
        Py_INCREF(descr);
#if PY_MAJOR_VERSION >= 3
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
        #endif
#else
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr)))
        #endif
#endif
        {
            meth_found = 1;
        } else {
            f = Py_TYPE(descr)->tp_descr_get;
            if (f != NULL && PyDescr_IsData(descr)) {
                attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
                Py_DECREF(descr);
                goto try_unpack;
            }
        }
    }
    dictptr = _PyObject_GetDictPtr(obj);
    if (dictptr != NULL && (dict = *dictptr) != NULL) {
        Py_INCREF(dict);
        attr = __Pyx_PyDict_GetItemStr(dict, name);
        if (attr != NULL) {
            Py_INCREF(attr);
            Py_DECREF(dict);
            Py_XDECREF(descr);
            goto try_unpack;
        }
        Py_DECREF(dict);
    }
    if (meth_found) {
        *method = descr;
        return 1;
    }
    if (f != NULL) {
        attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
        Py_DECREF(descr);
        goto try_unpack;
    }
    if (descr != NULL) {
        *method = descr;
        return 0;
    }
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(name));
#endif
    return 0;
#else
    attr = __Pyx_PyObject_GetAttrStr(obj, name);
    goto try_unpack;
#endif
try_unpack:
#if CYTHON_UNPACK_METHODS
    if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
        PyObject *function = PyMethod_GET_FUNCTION(attr);
        Py_INCREF(function);
        Py_DECREF(attr);
        *method = function;
        return 1;
    }
#endif
    *method = attr;
    return 0;
}

/* PyObjectCallMethod0 */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
    PyObject *method = NULL, *result = NULL;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_CallOneArg(method, obj);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) goto bad;
    result = __Pyx_PyObject_CallNoArg(method);
    Py_DECREF(method);
bad:
    return result;
}

/* RaiseNeedMoreValuesToUnpack */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

/* RaiseTooManyValuesToUnpack */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

/* UnpackItemEndCheck */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

/* RaiseNoneIterError */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

/* UnpackTupleError */
static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
    if (t == Py_None) {
      __Pyx_RaiseNoneNotIterableError();
    } else if (PyTuple_GET_SIZE(t) < index) {
      __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
    } else {
      __Pyx_RaiseTooManyValuesError(index);
    }
}

/* UnpackTuple2 */
static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
        PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) {
    PyObject *value1 = NULL, *value2 = NULL;
#if CYTHON_COMPILING_IN_PYPY
    value1 = PySequence_ITEM(tuple, 0);  if (unlikely(!value1)) goto bad;
    value2 = PySequence_ITEM(tuple, 1);  if (unlikely(!value2)) goto bad;
#else
    value1 = PyTuple_GET_ITEM(tuple, 0);  Py_INCREF(value1);
    value2 = PyTuple_GET_ITEM(tuple, 1);  Py_INCREF(value2);
#endif
    if (decref_tuple) {
        Py_DECREF(tuple);
    }
    *pvalue1 = value1;
    *pvalue2 = value2;
    return 0;
#if CYTHON_COMPILING_IN_PYPY
bad:
    Py_XDECREF(value1);
    Py_XDECREF(value2);
    if (decref_tuple) { Py_XDECREF(tuple); }
    return -1;
#endif
}
static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
                                       int has_known_size, int decref_tuple) {
    Py_ssize_t index;
    PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
    iternextfunc iternext;
    iter = PyObject_GetIter(tuple);
    if (unlikely(!iter)) goto bad;
    if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
    iternext = Py_TYPE(iter)->tp_iternext;
    value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
    value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
    if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
    Py_DECREF(iter);
    *pvalue1 = value1;
    *pvalue2 = value2;
    return 0;
unpacking_failed:
    if (!has_known_size && __Pyx_IterFinish() == 0)
        __Pyx_RaiseNeedMoreValuesError(index);
bad:
    Py_XDECREF(iter);
    Py_XDECREF(value1);
    Py_XDECREF(value2);
    if (decref_tuple) { Py_XDECREF(tuple); }
    return -1;
}

/* dict_iter */
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
                                                   Py_ssize_t* p_orig_length, int* p_source_is_dict) {
    is_dict = is_dict || likely(PyDict_CheckExact(iterable));
    *p_source_is_dict = is_dict;
    if (is_dict) {
#if !CYTHON_COMPILING_IN_PYPY
        *p_orig_length = PyDict_Size(iterable);
        Py_INCREF(iterable);
        return iterable;
#elif PY_MAJOR_VERSION >= 3
        static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
        PyObject **pp = NULL;
        if (method_name) {
            const char *name = PyUnicode_AsUTF8(method_name);
            if (strcmp(name, "iteritems") == 0) pp = &py_items;
            else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
            else if (strcmp(name, "itervalues") == 0) pp = &py_values;
            if (pp) {
                if (!*pp) {
                    *pp = PyUnicode_FromString(name + 4);
                    if (!*pp)
                        return NULL;
                }
                method_name = *pp;
            }
        }
#endif
    }
    *p_orig_length = 0;
    if (method_name) {
        PyObject* iter;
        iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
        if (!iterable)
            return NULL;
#if !CYTHON_COMPILING_IN_PYPY
        if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
            return iterable;
#endif
        iter = PyObject_GetIter(iterable);
        Py_DECREF(iterable);
        return iter;
    }
    return PyObject_GetIter(iterable);
}
static CYTHON_INLINE int __Pyx_dict_iter_next(
        PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
        PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
    PyObject* next_item;
#if !CYTHON_COMPILING_IN_PYPY
    if (source_is_dict) {
        PyObject *key, *value;
        if (unlikely(orig_length != PyDict_Size(iter_obj))) {
            PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
            return -1;
        }
        if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
            return 0;
        }
        if (pitem) {
            PyObject* tuple = PyTuple_New(2);
            if (unlikely(!tuple)) {
                return -1;
            }
            Py_INCREF(key);
            Py_INCREF(value);
            PyTuple_SET_ITEM(tuple, 0, key);
            PyTuple_SET_ITEM(tuple, 1, value);
            *pitem = tuple;
        } else {
            if (pkey) {
                Py_INCREF(key);
                *pkey = key;
            }
            if (pvalue) {
                Py_INCREF(value);
                *pvalue = value;
            }
        }
        return 1;
    } else if (PyTuple_CheckExact(iter_obj)) {
        Py_ssize_t pos = *ppos;
        if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
        *ppos = pos + 1;
        next_item = PyTuple_GET_ITEM(iter_obj, pos);
        Py_INCREF(next_item);
    } else if (PyList_CheckExact(iter_obj)) {
        Py_ssize_t pos = *ppos;
        if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
        *ppos = pos + 1;
        next_item = PyList_GET_ITEM(iter_obj, pos);
        Py_INCREF(next_item);
    } else
#endif
    {
        next_item = PyIter_Next(iter_obj);
        if (unlikely(!next_item)) {
            return __Pyx_IterFinish();
        }
    }
    if (pitem) {
        *pitem = next_item;
    } else if (pkey && pvalue) {
        if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
            return -1;
    } else if (pkey) {
        *pkey = next_item;
    } else {
        *pvalue = next_item;
    }
    return 1;
}

/* FetchCommonType */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

/* PyObjectCallMethod1 */
static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
    PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
    Py_DECREF(method);
    return result;
}
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method = NULL, *result;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_Call2Args(method, obj, arg);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) return NULL;
    return __Pyx__PyObject_CallMethod1(method, arg);
}

/* CoroutineBase */
#include <structmember.h>
#include <frameobject.h>
#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
    PyObject *et, *ev, *tb;
    PyObject *value = NULL;
    __Pyx_ErrFetch(&et, &ev, &tb);
    if (!et) {
        Py_XDECREF(tb);
        Py_XDECREF(ev);
        Py_INCREF(Py_None);
        *pvalue = Py_None;
        return 0;
    }
    if (likely(et == PyExc_StopIteration)) {
        if (!ev) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#if PY_VERSION_HEX >= 0x030300A0
        else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
            value = ((PyStopIterationObject *)ev)->value;
            Py_INCREF(value);
            Py_DECREF(ev);
        }
#endif
        else if (unlikely(PyTuple_Check(ev))) {
            if (PyTuple_GET_SIZE(ev) >= 1) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                value = PyTuple_GET_ITEM(ev, 0);
                Py_INCREF(value);
#else
                value = PySequence_ITEM(ev, 0);
#endif
            } else {
                Py_INCREF(Py_None);
                value = Py_None;
            }
            Py_DECREF(ev);
        }
        else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
            value = ev;
        }
        if (likely(value)) {
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = value;
            return 0;
        }
    } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    PyErr_NormalizeException(&et, &ev, &tb);
    if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    Py_XDECREF(tb);
    Py_DECREF(et);
#if PY_VERSION_HEX >= 0x030300A0
    value = ((PyStopIterationObject *)ev)->value;
    Py_INCREF(value);
    Py_DECREF(ev);
#else
    {
        PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
        Py_DECREF(ev);
        if (likely(args)) {
            value = PySequence_GetItem(args, 0);
            Py_DECREF(args);
        }
        if (unlikely(!value)) {
            __Pyx_ErrRestore(NULL, NULL, NULL);
            Py_INCREF(Py_None);
            value = Py_None;
        }
    }
#endif
    *pvalue = value;
    return 0;
}
static CYTHON_INLINE
void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
    PyObject *t, *v, *tb;
    t = exc_state->exc_type;
    v = exc_state->exc_value;
    tb = exc_state->exc_traceback;
    exc_state->exc_type = NULL;
    exc_state->exc_value = NULL;
    exc_state->exc_traceback = NULL;
    Py_XDECREF(t);
    Py_XDECREF(v);
    Py_XDECREF(tb);
}
#define __Pyx_Coroutine_AlreadyRunningError(gen)  (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
    const char *msg;
    if ((0)) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
        msg = "coroutine already executing";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
        msg = "async generator already executing";
    #endif
    } else {
        msg = "generator already executing";
    }
    PyErr_SetString(PyExc_ValueError, msg);
}
#define __Pyx_Coroutine_NotStartedError(gen)  (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
    const char *msg;
    if ((0)) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_Check(gen)) {
        msg = "can't send non-None value to a just-started coroutine";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact(gen)) {
        msg = "can't send non-None value to a just-started async generator";
    #endif
    } else {
        msg = "can't send non-None value to a just-started generator";
    }
    PyErr_SetString(PyExc_TypeError, msg);
}
#define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing)  (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
    #ifdef __Pyx_Coroutine_USED
    if (!closing && __Pyx_Coroutine_Check(gen)) {
        PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
    } else
    #endif
    if (value) {
        #ifdef __Pyx_AsyncGen_USED
        if (__Pyx_AsyncGen_CheckExact(gen))
            PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
        else
        #endif
        PyErr_SetNone(PyExc_StopIteration);
    }
}
static
PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
    __Pyx_PyThreadState_declare
    PyThreadState *tstate;
    __Pyx_ExcInfoStruct *exc_state;
    PyObject *retval;
    assert(!self->is_running);
    if (unlikely(self->resume_label == 0)) {
        if (unlikely(value && value != Py_None)) {
            return __Pyx_Coroutine_NotStartedError((PyObject*)self);
        }
    }
    if (unlikely(self->resume_label == -1)) {
        return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
    }
#if CYTHON_FAST_THREAD_STATE
    __Pyx_PyThreadState_assign
    tstate = __pyx_tstate;
#else
    tstate = __Pyx_PyThreadState_Current;
#endif
    exc_state = &self->gi_exc_state;
    if (exc_state->exc_type) {
        #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
        #else
        if (exc_state->exc_traceback) {
            PyTracebackObject *tb = (PyTracebackObject *) exc_state->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            Py_XINCREF(tstate->frame);
            assert(f->f_back == NULL);
            f->f_back = tstate->frame;
        }
        #endif
    }
#if CYTHON_USE_EXC_INFO_STACK
    exc_state->previous_item = tstate->exc_info;
    tstate->exc_info = exc_state;
#else
    if (exc_state->exc_type) {
        __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
    } else {
        __Pyx_Coroutine_ExceptionClear(exc_state);
        __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
    }
#endif
    self->is_running = 1;
    retval = self->body((PyObject *) self, tstate, value);
    self->is_running = 0;
#if CYTHON_USE_EXC_INFO_STACK
    exc_state = &self->gi_exc_state;
    tstate->exc_info = exc_state->previous_item;
    exc_state->previous_item = NULL;
    __Pyx_Coroutine_ResetFrameBackpointer(exc_state);
#endif
    return retval;
}
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) {
    PyObject *exc_tb = exc_state->exc_traceback;
    if (likely(exc_tb)) {
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
#else
        PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
        PyFrameObject *f = tb->tb_frame;
        Py_CLEAR(f->f_back);
#endif
    }
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
    if (unlikely(!retval)) {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        if (!__Pyx_PyErr_Occurred()) {
            PyObject *exc = PyExc_StopIteration;
            #ifdef __Pyx_AsyncGen_USED
            if (__Pyx_AsyncGen_CheckExact(gen))
                exc = __Pyx_PyExc_StopAsyncIteration;
            #endif
            __Pyx_PyErr_SetNone(exc);
        }
    }
    return retval;
}
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
static CYTHON_INLINE
PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) {
#if PY_VERSION_HEX <= 0x030A00A1
    return _PyGen_Send(gen, arg);
#else
    PyObject *result;
    if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) {
        if (PyAsyncGen_CheckExact(gen)) {
            assert(result == Py_None);
            PyErr_SetNone(PyExc_StopAsyncIteration);
        }
        else if (result == Py_None) {
            PyErr_SetNone(PyExc_StopIteration);
        }
        else {
            _PyGen_SetStopIterationValue(result);
        }
        Py_CLEAR(result);
    }
    return result;
#endif
}
#endif
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
    PyObject *ret;
    PyObject *val = NULL;
    __Pyx_Coroutine_Undelegate(gen);
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
    ret = __Pyx_Coroutine_SendEx(gen, val, 0);
    Py_XDECREF(val);
    return ret;
}
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
    PyObject *retval;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_Check(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_AsyncGen_USED
        if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
            ret = __Pyx_async_gen_asend_send(yf, value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyCoro_CheckExact(yf)) {
            ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        #endif
        {
            if (value == Py_None)
                ret = Py_TYPE(yf)->tp_iternext(yf);
            else
                ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
        }
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        retval = __Pyx_Coroutine_FinishDelegation(gen);
    } else {
        retval = __Pyx_Coroutine_SendEx(gen, value, 0);
    }
    return __Pyx_Coroutine_MethodReturn(self, retval);
}
static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
    PyObject *retval = NULL;
    int err = 0;
    #ifdef __Pyx_Generator_USED
    if (__Pyx_Generator_CheckExact(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_Coroutine_USED
    if (__Pyx_Coroutine_Check(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    if (__Pyx_CoroutineAwait_CheckExact(yf)) {
        retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf, NULL);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_AsyncGen_USED
    if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
        retval = __Pyx_async_gen_asend_close(yf, NULL);
    } else
    if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
        retval = __Pyx_async_gen_athrow_close(yf, NULL);
    } else
    #endif
    {
        PyObject *meth;
        gen->is_running = 1;
        meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
        if (unlikely(!meth)) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                PyErr_WriteUnraisable(yf);
            }
            PyErr_Clear();
        } else {
            retval = PyObject_CallFunction(meth, NULL);
            Py_DECREF(meth);
            if (!retval)
                err = -1;
        }
        gen->is_running = 0;
    }
    Py_XDECREF(retval);
    return err;
}
static PyObject *__Pyx_Generator_Next(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Next(yf);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_Check(yf)) {
            ret = __Pyx_Coroutine_Send(yf, Py_None);
        } else
        #endif
            ret = Py_TYPE(yf)->tp_iternext(yf);
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        return __Pyx_Coroutine_FinishDelegation(gen);
    }
    return __Pyx_Coroutine_SendEx(gen, Py_None, 0);
}
static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, CYTHON_UNUSED PyObject *arg) {
    return __Pyx_Coroutine_Close(self);
}
static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *retval, *raised_exception;
    PyObject *yf = gen->yieldfrom;
    int err = 0;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        Py_INCREF(yf);
        err = __Pyx_Coroutine_CloseIter(gen, yf);
        __Pyx_Coroutine_Undelegate(gen);
        Py_DECREF(yf);
    }
    if (err == 0)
        PyErr_SetNone(PyExc_GeneratorExit);
    retval = __Pyx_Coroutine_SendEx(gen, NULL, 1);
    if (unlikely(retval)) {
        const char *msg;
        Py_DECREF(retval);
        if ((0)) {
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_Coroutine_Check(self)) {
            msg = "coroutine ignored GeneratorExit";
        #endif
        #ifdef __Pyx_AsyncGen_USED
        } else if (__Pyx_AsyncGen_CheckExact(self)) {
#if PY_VERSION_HEX < 0x03060000
            msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
#else
            msg = "async generator ignored GeneratorExit";
#endif
        #endif
        } else {
            msg = "generator ignored GeneratorExit";
        }
        PyErr_SetString(PyExc_RuntimeError, msg);
        return NULL;
    }
    raised_exception = PyErr_Occurred();
    if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
        if (raised_exception) PyErr_Clear();
        Py_INCREF(Py_None);
        return Py_None;
    }
    return NULL;
}
static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
                                        PyObject *args, int close_on_genexit) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        Py_INCREF(yf);
        if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
            int err = __Pyx_Coroutine_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Coroutine_Undelegate(gen);
            if (err < 0)
                return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
            goto throw_here;
        }
        gen->is_running = 1;
        if (0
        #ifdef __Pyx_Generator_USED
            || __Pyx_Generator_CheckExact(yf)
        #endif
        #ifdef __Pyx_Coroutine_USED
            || __Pyx_Coroutine_Check(yf)
        #endif
            ) {
            ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
            ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
        #endif
        } else {
            PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
            if (unlikely(!meth)) {
                Py_DECREF(yf);
                if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                    gen->is_running = 0;
                    return NULL;
                }
                PyErr_Clear();
                __Pyx_Coroutine_Undelegate(gen);
                gen->is_running = 0;
                goto throw_here;
            }
            if (likely(args)) {
                ret = PyObject_CallObject(meth, args);
            } else {
                ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
            }
            Py_DECREF(meth);
        }
        gen->is_running = 0;
        Py_DECREF(yf);
        if (!ret) {
            ret = __Pyx_Coroutine_FinishDelegation(gen);
        }
        return __Pyx_Coroutine_MethodReturn(self, ret);
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
    return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
}
static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
    PyObject *typ;
    PyObject *val = NULL;
    PyObject *tb = NULL;
    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
        return NULL;
    return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
}
static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
    Py_VISIT(exc_state->exc_type);
    Py_VISIT(exc_state->exc_value);
    Py_VISIT(exc_state->exc_traceback);
    return 0;
}
static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
    Py_VISIT(gen->closure);
    Py_VISIT(gen->classobj);
    Py_VISIT(gen->yieldfrom);
    return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg);
}
static int __Pyx_Coroutine_clear(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    Py_CLEAR(gen->closure);
    Py_CLEAR(gen->classobj);
    Py_CLEAR(gen->yieldfrom);
    __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
    }
#endif
    Py_CLEAR(gen->gi_code);
    Py_CLEAR(gen->gi_frame);
    Py_CLEAR(gen->gi_name);
    Py_CLEAR(gen->gi_qualname);
    Py_CLEAR(gen->gi_modulename);
    return 0;
}
static void __Pyx_Coroutine_dealloc(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject_GC_UnTrack(gen);
    if (gen->gi_weakreflist != NULL)
        PyObject_ClearWeakRefs(self);
    if (gen->resume_label >= 0) {
        PyObject_GC_Track(self);
#if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE
        if (PyObject_CallFinalizerFromDealloc(self))
#else
        Py_TYPE(gen)->tp_del(self);
        if (Py_REFCNT(self) > 0)
#endif
        {
            return;
        }
        PyObject_GC_UnTrack(self);
    }
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        /* We have to handle this case for asynchronous generators
           right here, because this code has to be between UNTRACK
           and GC_Del. */
        Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
    }
#endif
    __Pyx_Coroutine_clear(self);
    PyObject_GC_Del(gen);
}
static void __Pyx_Coroutine_del(PyObject *self) {
    PyObject *error_type, *error_value, *error_traceback;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    __Pyx_PyThreadState_declare
    if (gen->resume_label < 0) {
        return;
    }
#if !CYTHON_USE_TP_FINALIZE
    assert(self->ob_refcnt == 0);
    __Pyx_SET_REFCNT(self, 1);
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
        PyObject *finalizer = agen->ag_finalizer;
        if (finalizer && !agen->ag_closed) {
            PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
            if (unlikely(!res)) {
                PyErr_WriteUnraisable(self);
            } else {
                Py_DECREF(res);
            }
            __Pyx_ErrRestore(error_type, error_value, error_traceback);
            return;
        }
    }
#endif
    if (unlikely(gen->resume_label == 0 && !error_value)) {
#ifdef __Pyx_Coroutine_USED
#ifdef __Pyx_Generator_USED
    if (!__Pyx_Generator_CheckExact(self))
#endif
        {
        PyObject_GC_UnTrack(self);
#if PY_MAJOR_VERSION >= 3  || defined(PyErr_WarnFormat)
        if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
            PyErr_WriteUnraisable(self);
#else
        {PyObject *msg;
        char *cmsg;
        #if CYTHON_COMPILING_IN_PYPY
        msg = NULL;
        cmsg = (char*) "coroutine was never awaited";
        #else
        char *cname;
        PyObject *qualname;
        qualname = gen->gi_qualname;
        cname = PyString_AS_STRING(qualname);
        msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
        if (unlikely(!msg)) {
            PyErr_Clear();
            cmsg = (char*) "coroutine was never awaited";
        } else {
            cmsg = PyString_AS_STRING(msg);
        }
        #endif
        if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
            PyErr_WriteUnraisable(self);
        Py_XDECREF(msg);}
#endif
        PyObject_GC_Track(self);
        }
#endif
    } else {
        PyObject *res = __Pyx_Coroutine_Close(self);
        if (unlikely(!res)) {
            if (PyErr_Occurred())
                PyErr_WriteUnraisable(self);
        } else {
            Py_DECREF(res);
        }
    }
    __Pyx_ErrRestore(error_type, error_value, error_traceback);
#if !CYTHON_USE_TP_FINALIZE
    assert(Py_REFCNT(self) > 0);
    if (--self->ob_refcnt == 0) {
        return;
    }
    {
        Py_ssize_t refcnt = Py_REFCNT(self);
        _Py_NewReference(self);
        __Pyx_SET_REFCNT(self, refcnt);
    }
#if CYTHON_COMPILING_IN_CPYTHON
    assert(PyType_IS_GC(Py_TYPE(self)) &&
           _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
    _Py_DEC_REFTOTAL;
#endif
#ifdef COUNT_ALLOCS
    --Py_TYPE(self)->tp_frees;
    --Py_TYPE(self)->tp_allocs;
#endif
#endif
}
static PyObject *
__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
{
    PyObject *name = self->gi_name;
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return name;
}
static int
__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_name;
    Py_INCREF(value);
    self->gi_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
{
    PyObject *name = self->gi_qualname;
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return name;
}
static int
__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_qualname;
    Py_INCREF(value);
    self->gi_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
{
    PyObject *frame = self->gi_frame;
    if (!frame) {
        if (unlikely(!self->gi_code)) {
            Py_RETURN_NONE;
        }
        frame = (PyObject *) PyFrame_New(
            PyThreadState_Get(),            /*PyThreadState *tstate,*/
            (PyCodeObject*) self->gi_code,  /*PyCodeObject *code,*/
            __pyx_d,                 /*PyObject *globals,*/
            0                               /*PyObject *locals*/
        );
        if (unlikely(!frame))
            return NULL;
        self->gi_frame = frame;
    }
    Py_INCREF(frame);
    return frame;
}
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
            PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
    if (unlikely(!gen))
        return NULL;
    return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
}
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    gen->body = body;
    gen->closure = closure;
    Py_XINCREF(closure);
    gen->is_running = 0;
    gen->resume_label = 0;
    gen->classobj = NULL;
    gen->yieldfrom = NULL;
    gen->gi_exc_state.exc_type = NULL;
    gen->gi_exc_state.exc_value = NULL;
    gen->gi_exc_state.exc_traceback = NULL;
#if CYTHON_USE_EXC_INFO_STACK
    gen->gi_exc_state.previous_item = NULL;
#endif
    gen->gi_weakreflist = NULL;
    Py_XINCREF(qualname);
    gen->gi_qualname = qualname;
    Py_XINCREF(name);
    gen->gi_name = name;
    Py_XINCREF(module_name);
    gen->gi_modulename = module_name;
    Py_XINCREF(code);
    gen->gi_code = code;
    gen->gi_frame = NULL;
    PyObject_GC_Track(gen);
    return gen;
}

/* PyObject_GenericGetAttrNoDict */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, attr_name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(attr_name));
#endif
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
    PyObject *descr;
    PyTypeObject *tp = Py_TYPE(obj);
    if (unlikely(!PyString_Check(attr_name))) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    assert(!tp->tp_dictoffset);
    descr = _PyType_Lookup(tp, attr_name);
    if (unlikely(!descr)) {
        return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
    }
    Py_INCREF(descr);
    #if PY_MAJOR_VERSION < 3
    if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
    #endif
    {
        descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
        if (unlikely(f)) {
            PyObject *res = f(descr, obj, (PyObject *)tp);
            Py_DECREF(descr);
            return res;
        }
    }
    return descr;
}
#endif

/* PatchModuleWithCoroutine */
static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    int result;
    PyObject *globals, *result_obj;
    globals = PyDict_New();  if (unlikely(!globals)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_coroutine_type",
    #ifdef __Pyx_Coroutine_USED
        (PyObject*)__pyx_CoroutineType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_generator_type",
    #ifdef __Pyx_Generator_USED
        (PyObject*)__pyx_GeneratorType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
    result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
    if (unlikely(!result_obj)) goto ignore;
    Py_DECREF(result_obj);
    Py_DECREF(globals);
    return module;
ignore:
    Py_XDECREF(globals);
    PyErr_WriteUnraisable(module);
    if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
        Py_DECREF(module);
        module = NULL;
    }
#else
    py_code++;
#endif
    return module;
}

/* PatchGeneratorABC */
#ifndef CYTHON_REGISTER_ABCS
#define CYTHON_REGISTER_ABCS 1
#endif
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
static PyObject* __Pyx_patch_abc_module(PyObject *module);
static PyObject* __Pyx_patch_abc_module(PyObject *module) {
    module = __Pyx_Coroutine_patch_module(
        module, ""
"if _cython_generator_type is not None:\n"
"    try: Generator = _module.Generator\n"
"    except AttributeError: pass\n"
"    else: Generator.register(_cython_generator_type)\n"
"if _cython_coroutine_type is not None:\n"
"    try: Coroutine = _module.Coroutine\n"
"    except AttributeError: pass\n"
"    else: Coroutine.register(_cython_coroutine_type)\n"
    );
    return module;
}
#endif
static int __Pyx_patch_abc(void) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    static int abc_patched = 0;
    if (CYTHON_REGISTER_ABCS && !abc_patched) {
        PyObject *module;
        module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
        if (!module) {
            PyErr_WriteUnraisable(NULL);
            if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
                    ((PY_MAJOR_VERSION >= 3) ?
                        "Cython module failed to register with collections.abc module" :
                        "Cython module failed to register with collections module"), 1) < 0)) {
                return -1;
            }
        } else {
            module = __Pyx_patch_abc_module(module);
            abc_patched = 1;
            if (unlikely(!module))
                return -1;
            Py_DECREF(module);
        }
        module = PyImport_ImportModule("backports_abc");
        if (module) {
            module = __Pyx_patch_abc_module(module);
            Py_XDECREF(module);
        }
        if (!module) {
            PyErr_Clear();
        }
    }
#else
    if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL);
#endif
    return 0;
}

/* Coroutine */
static void __Pyx_CoroutineAwait_dealloc(PyObject *self) {
    PyObject_GC_UnTrack(self);
    Py_CLEAR(((__pyx_CoroutineAwaitObject*)self)->coroutine);
    PyObject_GC_Del(self);
}
static int __Pyx_CoroutineAwait_traverse(__pyx_CoroutineAwaitObject *self, visitproc visit, void *arg) {
    Py_VISIT(self->coroutine);
    return 0;
}
static int __Pyx_CoroutineAwait_clear(__pyx_CoroutineAwaitObject *self) {
    Py_CLEAR(self->coroutine);
    return 0;
}
static PyObject *__Pyx_CoroutineAwait_Next(__pyx_CoroutineAwaitObject *self) {
    return __Pyx_Generator_Next(self->coroutine);
}
static PyObject *__Pyx_CoroutineAwait_Send(__pyx_CoroutineAwaitObject *self, PyObject *value) {
    return __Pyx_Coroutine_Send(self->coroutine, value);
}
static PyObject *__Pyx_CoroutineAwait_Throw(__pyx_CoroutineAwaitObject *self, PyObject *args) {
    return __Pyx_Coroutine_Throw(self->coroutine, args);
}
static PyObject *__Pyx_CoroutineAwait_Close(__pyx_CoroutineAwaitObject *self, CYTHON_UNUSED PyObject *arg) {
    return __Pyx_Coroutine_Close(self->coroutine);
}
static PyObject *__Pyx_CoroutineAwait_self(PyObject *self) {
    Py_INCREF(self);
    return self;
}
#if !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_CoroutineAwait_no_new(CYTHON_UNUSED PyTypeObject *type, CYTHON_UNUSED PyObject *args, CYTHON_UNUSED PyObject *kwargs) {
    PyErr_SetString(PyExc_TypeError, "cannot instantiate type, use 'await coroutine' instead");
    return NULL;
}
#endif
static PyMethodDef __pyx_CoroutineAwait_methods[] = {
    {"send", (PyCFunction) __Pyx_CoroutineAwait_Send, METH_O,
     (char*) PyDoc_STR("send(arg) -> send 'arg' into coroutine,\nreturn next yielded value or raise StopIteration.")},
    {"throw", (PyCFunction) __Pyx_CoroutineAwait_Throw, METH_VARARGS,
     (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in coroutine,\nreturn next yielded value or raise StopIteration.")},
    {"close", (PyCFunction) __Pyx_CoroutineAwait_Close, METH_NOARGS,
     (char*) PyDoc_STR("close() -> raise GeneratorExit inside coroutine.")},
    {0, 0, 0, 0}
};
static PyTypeObject __pyx_CoroutineAwaitType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "coroutine_wrapper",
    sizeof(__pyx_CoroutineAwaitObject),
    0,
    (destructor) __Pyx_CoroutineAwait_dealloc,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
    PyDoc_STR("A wrapper object implementing __await__ for coroutines."),
    (traverseproc) __Pyx_CoroutineAwait_traverse,
    (inquiry) __Pyx_CoroutineAwait_clear,
    0,
    0,
    __Pyx_CoroutineAwait_self,
    (iternextfunc) __Pyx_CoroutineAwait_Next,
    __pyx_CoroutineAwait_methods,
    0                         ,
    0                      ,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if !CYTHON_COMPILING_IN_PYPY
    __Pyx_CoroutineAwait_no_new,
#else
    0,
#endif
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b1
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
    0,
#endif
};
#if PY_VERSION_HEX < 0x030500B1 || defined(__Pyx_IterableCoroutine_USED) || CYTHON_USE_ASYNC_SLOTS
static CYTHON_INLINE PyObject *__Pyx__Coroutine_await(PyObject *coroutine) {
    __pyx_CoroutineAwaitObject *await = PyObject_GC_New(__pyx_CoroutineAwaitObject, __pyx_CoroutineAwaitType);
    if (unlikely(!await)) return NULL;
    Py_INCREF(coroutine);
    await->coroutine = coroutine;
    PyObject_GC_Track(await);
    return (PyObject*)await;
}
#endif
#if PY_VERSION_HEX < 0x030500B1
static PyObject *__Pyx_Coroutine_await_method(PyObject *coroutine, CYTHON_UNUSED PyObject *arg) {
    return __Pyx__Coroutine_await(coroutine);
}
#endif
#if defined(__Pyx_IterableCoroutine_USED) || CYTHON_USE_ASYNC_SLOTS
static PyObject *__Pyx_Coroutine_await(PyObject *coroutine) {
    if (unlikely(!coroutine || !__Pyx_Coroutine_Check(coroutine))) {
        PyErr_SetString(PyExc_TypeError, "invalid input, expected coroutine");
        return NULL;
    }
    return __Pyx__Coroutine_await(coroutine);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1
static PyObject *__Pyx_Coroutine_compare(PyObject *obj, PyObject *other, int op) {
    PyObject* result;
    switch (op) {
        case Py_EQ: result = (other == obj) ? Py_True : Py_False; break;
        case Py_NE: result = (other != obj) ? Py_True : Py_False; break;
        default:
            result = Py_NotImplemented;
    }
    Py_INCREF(result);
    return result;
}
#endif
static PyMethodDef __pyx_Coroutine_methods[] = {
    {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
     (char*) PyDoc_STR("send(arg) -> send 'arg' into coroutine,\nreturn next iterated value or raise StopIteration.")},
    {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
     (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in coroutine,\nreturn next iterated value or raise StopIteration.")},
    {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
     (char*) PyDoc_STR("close() -> raise GeneratorExit inside coroutine.")},
#if PY_VERSION_HEX < 0x030500B1
    {"__await__", (PyCFunction) __Pyx_Coroutine_await_method, METH_NOARGS,
     (char*) PyDoc_STR("__await__() -> return an iterator to be used in await expression.")},
#endif
    {0, 0, 0, 0}
};
static PyMemberDef __pyx_Coroutine_memberlist[] = {
    {(char *) "cr_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
    {(char*) "cr_await", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
     (char*) PyDoc_STR("object being awaited, or None")},
    {(char*) "cr_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
    {(char *) "__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0, 0, 0}
};
static PyGetSetDef __pyx_Coroutine_getsets[] = {
    {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
     (char*) PyDoc_STR("name of the coroutine"), 0},
    {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
     (char*) PyDoc_STR("qualified name of the coroutine"), 0},
    {(char *) "cr_frame", (getter)__Pyx_Coroutine_get_frame, NULL,
     (char*) PyDoc_STR("Frame of the coroutine"), 0},
    {0, 0, 0, 0, 0}
};
#if CYTHON_USE_ASYNC_SLOTS
static __Pyx_PyAsyncMethodsStruct __pyx_Coroutine_as_async = {
    __Pyx_Coroutine_await,
    0,
    0,
};
#endif
static PyTypeObject __pyx_CoroutineType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "coroutine",
    sizeof(__pyx_CoroutineObject),
    0,
    (destructor) __Pyx_Coroutine_dealloc,
    0,
    0,
    0,
#if CYTHON_USE_ASYNC_SLOTS
    &__pyx_Coroutine_as_async,
#else
    0,
#endif
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
    0,
    (traverseproc) __Pyx_Coroutine_traverse,
    0,
#if CYTHON_USE_ASYNC_SLOTS && CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x030500B1
    __Pyx_Coroutine_compare,
#else
    0,
#endif
    offsetof(__pyx_CoroutineObject, gi_weakreflist),
    0,
    0,
    __pyx_Coroutine_methods,
    __pyx_Coroutine_memberlist,
    __pyx_Coroutine_getsets,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if CYTHON_USE_TP_FINALIZE
    0,
#else
    __Pyx_Coroutine_del,
#endif
    0,
#if CYTHON_USE_TP_FINALIZE
    __Pyx_Coroutine_del,
#elif PY_VERSION_HEX >= 0x030400a1
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b1
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
    0,
#endif
};
static int __pyx_Coroutine_init(void) {
    __pyx_CoroutineType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
    __pyx_CoroutineType = __Pyx_FetchCommonType(&__pyx_CoroutineType_type);
    if (unlikely(!__pyx_CoroutineType))
        return -1;
#ifdef __Pyx_IterableCoroutine_USED
    if (unlikely(__pyx_IterableCoroutine_init() == -1))
        return -1;
#endif
    __pyx_CoroutineAwaitType = __Pyx_FetchCommonType(&__pyx_CoroutineAwaitType_type);
    if (unlikely(!__pyx_CoroutineAwaitType))
        return -1;
    return 0;
}

/* GetAwaitIter */
static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o) {
#ifdef __Pyx_Coroutine_USED
    if (__Pyx_Coroutine_Check(o)) {
        return __Pyx_NewRef(o);
    }
#endif
    return __Pyx__Coroutine_GetAwaitableIter(o);
}
static void __Pyx_Coroutine_AwaitableIterError(PyObject *source) {
#if PY_VERSION_HEX >= 0x030600B3 || defined(_PyErr_FormatFromCause)
    _PyErr_FormatFromCause(
        PyExc_TypeError,
        "'async for' received an invalid object "
        "from __anext__: %.100s",
        Py_TYPE(source)->tp_name);
#elif PY_MAJOR_VERSION >= 3
    PyObject *exc, *val, *val2, *tb;
    assert(PyErr_Occurred());
    PyErr_Fetch(&exc, &val, &tb);
    PyErr_NormalizeException(&exc, &val, &tb);
    if (tb != NULL) {
        PyException_SetTraceback(val, tb);
        Py_DECREF(tb);
    }
    Py_DECREF(exc);
    assert(!PyErr_Occurred());
    PyErr_Format(
        PyExc_TypeError,
        "'async for' received an invalid object "
        "from __anext__: %.100s",
        Py_TYPE(source)->tp_name);
    PyErr_Fetch(&exc, &val2, &tb);
    PyErr_NormalizeException(&exc, &val2, &tb);
    Py_INCREF(val);
    PyException_SetCause(val2, val);
    PyException_SetContext(val2, val);
    PyErr_Restore(exc, val2, tb);
#else
    source++;
#endif
}
static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *obj) {
    PyObject *res;
#if CYTHON_USE_ASYNC_SLOTS
    __Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj);
    if (likely(am && am->am_await)) {
        res = (*am->am_await)(obj);
    } else
#endif
#if PY_VERSION_HEX >= 0x030500B2 || defined(PyCoro_CheckExact)
    if (PyCoro_CheckExact(obj)) {
        return __Pyx_NewRef(obj);
    } else
#endif
#if CYTHON_COMPILING_IN_CPYTHON && defined(CO_ITERABLE_COROUTINE)
    if (PyGen_CheckExact(obj) && ((PyGenObject*)obj)->gi_code && ((PyCodeObject *)((PyGenObject*)obj)->gi_code)->co_flags & CO_ITERABLE_COROUTINE) {
        return __Pyx_NewRef(obj);
    } else
#endif
    {
        PyObject *method = NULL;
        int is_method = __Pyx_PyObject_GetMethod(obj, __pyx_n_s_await, &method);
        if (likely(is_method)) {
            res = __Pyx_PyObject_CallOneArg(method, obj);
        } else if (likely(method)) {
            res = __Pyx_PyObject_CallNoArg(method);
        } else
            goto slot_error;
        Py_DECREF(method);
    }
    if (unlikely(!res)) {
        __Pyx_Coroutine_AwaitableIterError(obj);
        goto bad;
    }
    if (unlikely(!PyIter_Check(res))) {
        PyErr_Format(PyExc_TypeError,
                     "__await__() returned non-iterator of type '%.100s'",
                     Py_TYPE(res)->tp_name);
        Py_CLEAR(res);
    } else {
        int is_coroutine = 0;
        #ifdef __Pyx_Coroutine_USED
        is_coroutine |= __Pyx_Coroutine_Check(res);
        #endif
        #if PY_VERSION_HEX >= 0x030500B2 || defined(PyCoro_CheckExact)
        is_coroutine |= PyCoro_CheckExact(res);
        #endif
        if (unlikely(is_coroutine)) {
            /* __await__ must return an *iterator*, not
               a coroutine or another awaitable (see PEP 492) */
            PyErr_SetString(PyExc_TypeError,
                            "__await__() returned a coroutine");
            Py_CLEAR(res);
        }
    }
    return res;
slot_error:
    PyErr_Format(PyExc_TypeError,
                 "object %.100s can't be used in 'await' expression",
                 Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

/* CoroutineYieldFrom */
static PyObject* __Pyx__Coroutine_Yield_From_Generic(__pyx_CoroutineObject *gen, PyObject *source) {
    PyObject *retval;
    PyObject *source_gen = __Pyx__Coroutine_GetAwaitableIter(source);
    if (unlikely(!source_gen)) {
        return NULL;
    }
    if (__Pyx_Coroutine_Check(source_gen)) {
        retval = __Pyx_Generator_Next(source_gen);
    } else {
#if CYTHON_USE_TYPE_SLOTS
        retval = Py_TYPE(source_gen)->tp_iternext(source_gen);
#else
        retval = PyIter_Next(source_gen);
#endif
    }
    if (retval) {
        gen->yieldfrom = source_gen;
        return retval;
    }
    Py_DECREF(source_gen);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_Coroutine_Yield_From(__pyx_CoroutineObject *gen, PyObject *source) {
    PyObject *retval;
    if (__Pyx_Coroutine_Check(source)) {
        if (unlikely(((__pyx_CoroutineObject*)source)->yieldfrom)) {
            PyErr_SetString(
                PyExc_RuntimeError,
                "coroutine is being awaited already");
            return NULL;
        }
        retval = __Pyx_Generator_Next(source);
#ifdef __Pyx_AsyncGen_USED
    } else if (__pyx_PyAsyncGenASend_CheckExact(source)) {
        retval = __Pyx_async_gen_asend_iternext(source);
#endif
    } else {
        return __Pyx__Coroutine_Yield_From_Generic(gen, source);
    }
    if (retval) {
        Py_INCREF(source);
        gen->yieldfrom = source;
    }
    return retval;
}

/* None */
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

/* ReturnWithStopIteration */
static void __Pyx__ReturnWithStopIteration(PyObject* value) {
    PyObject *exc, *args;
#if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_PYSTON
    __Pyx_PyThreadState_declare
    if ((PY_VERSION_HEX >= 0x03030000 && PY_VERSION_HEX < 0x030500B1)
            || unlikely(PyTuple_Check(value) || PyExceptionInstance_Check(value))) {
        args = PyTuple_New(1);
        if (unlikely(!args)) return;
        Py_INCREF(value);
        PyTuple_SET_ITEM(args, 0, value);
        exc = PyType_Type.tp_call(PyExc_StopIteration, args, NULL);
        Py_DECREF(args);
        if (!exc) return;
    } else {
        Py_INCREF(value);
        exc = value;
    }
    #if CYTHON_FAST_THREAD_STATE
    __Pyx_PyThreadState_assign
    #if CYTHON_USE_EXC_INFO_STACK
    if (!__pyx_tstate->exc_info->exc_type)
    #else
    if (!__pyx_tstate->exc_type)
    #endif
    {
        Py_INCREF(PyExc_StopIteration);
        __Pyx_ErrRestore(PyExc_StopIteration, exc, NULL);
        return;
    }
    #endif
#else
    args = PyTuple_Pack(1, value);
    if (unlikely(!args)) return;
    exc = PyObject_Call(PyExc_StopIteration, args, NULL);
    Py_DECREF(args);
    if (unlikely(!exc)) return;
#endif
    PyErr_SetObject(PyExc_StopIteration, exc);
    Py_DECREF(exc);
}

/* PyObjectSetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_setattro))
        return tp->tp_setattro(obj, attr_name, value);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_setattr))
        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
#endif
    return PyObject_SetAttr(obj, attr_name, value);
}
#endif

/* AsyncIter */
static PyObject *__Pyx_Coroutine_GetAsyncIter_Generic(PyObject *obj) {
#if PY_VERSION_HEX < 0x030500B1
    {
        PyObject *iter = __Pyx_PyObject_CallMethod0(obj, __pyx_n_s_aiter);
        if (likely(iter))
            return iter;
        if (!PyErr_ExceptionMatches(PyExc_AttributeError))
            return NULL;
    }
#else
    if ((0)) (void) __Pyx_PyObject_CallMethod0(obj, __pyx_n_s_aiter);
#endif
    PyErr_Format(PyExc_TypeError, "'async for' requires an object with __aiter__ method, got %.100s",
                 Py_TYPE(obj)->tp_name);
    return NULL;
}
static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *obj) {
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(obj)) {
        return __Pyx_NewRef(obj);
    }
#endif
#if CYTHON_USE_ASYNC_SLOTS
    {
        __Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj);
        if (likely(am && am->am_aiter)) {
            return (*am->am_aiter)(obj);
        }
    }
#endif
    return __Pyx_Coroutine_GetAsyncIter_Generic(obj);
}
static PyObject *__Pyx__Coroutine_AsyncIterNext(PyObject *obj) {
#if PY_VERSION_HEX < 0x030500B1
    {
        PyObject *value = __Pyx_PyObject_CallMethod0(obj, __pyx_n_s_anext);
        if (likely(value))
            return value;
    }
    if (PyErr_ExceptionMatches(PyExc_AttributeError))
#endif
        PyErr_Format(PyExc_TypeError, "'async for' requires an object with __anext__ method, got %.100s",
                     Py_TYPE(obj)->tp_name);
    return NULL;
}
static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *obj) {
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(obj)) {
        return __Pyx_async_gen_anext(obj);
    }
#endif
#if CYTHON_USE_ASYNC_SLOTS
    {
        __Pyx_PyAsyncMethodsStruct* am = __Pyx_PyType_AsAsync(obj);
        if (likely(am && am->am_anext)) {
            return (*am->am_anext)(obj);
        }
    }
#endif
    return __Pyx__Coroutine_AsyncIterNext(obj);
}

/* StopAsyncIteration */
#if PY_VERSION_HEX < 0x030500B1
static PyTypeObject __Pyx__PyExc_StopAsyncIteration_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "StopAsyncIteration",
    sizeof(PyBaseExceptionObject),
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
    PyDoc_STR("Signal the end from iterator.__anext__()."),
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#endif
};
#endif
static int __pyx_StopAsyncIteration_init(void) {
#if PY_VERSION_HEX >= 0x030500B1
    __Pyx_PyExc_StopAsyncIteration = PyExc_StopAsyncIteration;
#else
    PyObject *builtins = PyEval_GetBuiltins();
    if (likely(builtins)) {
        PyObject *exc = PyMapping_GetItemString(builtins, (char*) "StopAsyncIteration");
        if (exc) {
            __Pyx_PyExc_StopAsyncIteration = exc;
            return 0;
        }
    }
    PyErr_Clear();
    __Pyx__PyExc_StopAsyncIteration_type.tp_traverse = ((PyTypeObject*)PyExc_BaseException)->tp_traverse;
    __Pyx__PyExc_StopAsyncIteration_type.tp_clear = ((PyTypeObject*)PyExc_BaseException)->tp_clear;
    __Pyx__PyExc_StopAsyncIteration_type.tp_dictoffset = ((PyTypeObject*)PyExc_BaseException)->tp_dictoffset;
    __Pyx__PyExc_StopAsyncIteration_type.tp_base = (PyTypeObject*)PyExc_Exception;
    __Pyx_PyExc_StopAsyncIteration = (PyObject*) __Pyx_FetchCommonType(&__Pyx__PyExc_StopAsyncIteration_type);
    if (unlikely(!__Pyx_PyExc_StopAsyncIteration))
        return -1;
    if (builtins && unlikely(PyMapping_SetItemString(builtins, (char*) "StopAsyncIteration", __Pyx_PyExc_StopAsyncIteration) < 0))
        return -1;
#endif
    return 0;
}

/* FastTypeChecks */
#if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    assert(PyExceptionClass_Check(exc_type));
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        PyObject *t = PyTuple_GET_ITEM(tuple, i);
        #if PY_MAJOR_VERSION < 3
        if (likely(exc_type == t)) return 1;
        #endif
        if (likely(PyExceptionClass_Check(t))) {
            if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
        } else {
        }
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        if (likely(PyExceptionClass_Check(exc_type))) {
            return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
        } else if (likely(PyTuple_Check(exc_type))) {
            return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
        } else {
        }
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    assert(PyExceptionClass_Check(exc_type1));
    assert(PyExceptionClass_Check(exc_type2));
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* decode_c_bytes */
static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
         const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
    if (unlikely((start < 0) | (stop < 0))) {
        if (start < 0) {
            start += length;
            if (start < 0)
                start = 0;
        }
        if (stop < 0)
            stop += length;
    }
    if (stop > length)
        stop = length;
    if (unlikely(stop <= start))
        return __Pyx_NewRef(__pyx_empty_unicode);
    length = stop - start;
    cstring += start;
    if (decode_func) {
        return decode_func(cstring, length, errors);
    } else {
        return PyUnicode_Decode(cstring, length, encoding, errors);
    }
}

/* Import */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* HasAttr */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
    PyObject *r;
    if (unlikely(!__Pyx_PyBaseString_Check(n))) {
        PyErr_SetString(PyExc_TypeError,
                        "hasattr(): attribute name must be string");
        return -1;
    }
    r = __Pyx_GetAttr(o, n);
    if (unlikely(!r)) {
        PyErr_Clear();
        return 0;
    } else {
        Py_DECREF(r);
        return 1;
    }
}

/* WriteUnraisableException */
static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_PyThreadState_declare
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#ifdef _MSC_VER
    else state = (PyGILState_STATE)-1;
#endif
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

/* CallNextTpTraverse */
static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) {
    PyTypeObject* type = Py_TYPE(obj);
    while (type && type->tp_traverse != current_tp_traverse)
        type = type->tp_base;
    while (type && type->tp_traverse == current_tp_traverse)
        type = type->tp_base;
    if (type && type->tp_traverse)
        return type->tp_traverse(obj, v, a);
    return 0;
}

/* CallNextTpClear */
static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) {
    PyTypeObject* type = Py_TYPE(obj);
    while (type && type->tp_clear != current_tp_clear)
        type = type->tp_base;
    while (type && type->tp_clear == current_tp_clear)
        type = type->tp_base;
    if (type && type->tp_clear)
        type->tp_clear(obj);
}

/* CallNextTpDealloc */
static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) {
    PyTypeObject* type = Py_TYPE(obj);
    while (type && type->tp_dealloc != current_tp_dealloc)
        type = type->tp_base;
    while (type && type->tp_dealloc == current_tp_dealloc)
        type = type->tp_base;
    if (type)
        type->tp_dealloc(obj);
}

/* PyObject_GenericGetAttr */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
    if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
}
#endif

/* SetVTable */
static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

/* PyObjectGetAttrStrNoError */
static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        __Pyx_PyErr_Clear();
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
        return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
    }
#endif
    result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
    if (unlikely(!result)) {
        __Pyx_PyObject_GetAttrStr_ClearAttributeError();
    }
    return result;
}

/* SetupReduce */
static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  int ret;
  PyObject *name_attr;
  name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  if (likely(name_attr)) {
      ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  } else {
      ret = -1;
  }
  if (unlikely(ret < 0)) {
      PyErr_Clear();
      ret = 0;
  }
  Py_XDECREF(name_attr);
  return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
    int ret = 0;
    PyObject *object_reduce = NULL;
    PyObject *object_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
#else
    if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
#endif
#if CYTHON_USE_PYTYPE_LOOKUP
    object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#else
    object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#endif
    reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
    if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#else
        object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#endif
        reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
        if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
            reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
            if (likely(reduce_cython)) {
                ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
            } else if (reduce == object_reduce || PyErr_Occurred()) {
                goto __PYX_BAD;
            }
            setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
            if (!setstate) PyErr_Clear();
            if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
                setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
                if (likely(setstate_cython)) {
                    ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                    ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                } else if (!setstate || PyErr_Occurred()) {
                    goto __PYX_BAD;
                }
            }
            PyType_Modified((PyTypeObject*)type_obj);
        }
    }
    goto __PYX_GOOD;
__PYX_BAD:
    if (!PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
    ret = -1;
__PYX_GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
    Py_XDECREF(object_reduce);
    Py_XDECREF(object_reduce_ex);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

/* TypeImport */
#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
    size_t size, enum __Pyx_ImportType_CheckSize check_size)
{
    PyObject *result = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    result = PyObject_GetAttrString(module, class_name);
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if ((size_t)basicsize < size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return NULL;
}
#endif

/* GetVTable */
static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

/* PatchInspect */
static PyObject* __Pyx_patch_inspect(PyObject* module) {
#if defined(__Pyx_Generator_USED) && (!defined(CYTHON_PATCH_INSPECT) || CYTHON_PATCH_INSPECT)
    static int inspect_patched = 0;
    if (unlikely((!inspect_patched) && module)) {
        module = __Pyx_Coroutine_patch_module(
            module, ""
"old_types = getattr(_module.isgenerator, '_cython_generator_types', None)\n"
"if old_types is None or not isinstance(old_types, set):\n"
"    old_types = set()\n"
"    def cy_wrap(orig_func, type=type, cython_generator_types=old_types):\n"
"        def cy_isgenerator(obj): return type(obj) in cython_generator_types or orig_func(obj)\n"
"        cy_isgenerator._cython_generator_types = cython_generator_types\n"
"        return cy_isgenerator\n"
"    _module.isgenerator = cy_wrap(_module.isgenerator)\n"
"old_types.add(_cython_generator_type)\n"
        );
        inspect_patched = 1;
    }
#else
    if ((0)) return __Pyx_Coroutine_patch_module(module, NULL);
#endif
    return module;
}

/* PatchAsyncIO */
static PyObject* __Pyx_patch_asyncio(PyObject* module) {
#if PY_VERSION_HEX < 0x030500B2 &&\
        (defined(__Pyx_Coroutine_USED) || defined(__Pyx_Generator_USED)) &&\
        (!defined(CYTHON_PATCH_ASYNCIO) || CYTHON_PATCH_ASYNCIO)
    PyObject *patch_module = NULL;
    static int asyncio_patched = 0;
    if (unlikely((!asyncio_patched) && module)) {
        PyObject *package;
        package = __Pyx_Import(__pyx_n_s_asyncio_coroutines, NULL, 0);
        if (package) {
            patch_module = __Pyx_Coroutine_patch_module(
                PyObject_GetAttrString(package, "coroutines"), ""
"try:\n"
"    coro_types = _module._COROUTINE_TYPES\n"
"except AttributeError: pass\n"
"else:\n"
"    if _cython_coroutine_type is not None and _cython_coroutine_type not in coro_types:\n"
"        coro_types = tuple(coro_types) + (_cython_coroutine_type,)\n"
"    if _cython_generator_type is not None and _cython_generator_type not in coro_types:\n"
"        coro_types = tuple(coro_types) + (_cython_generator_type,)\n"
"_module._COROUTINE_TYPES = coro_types\n"
            );
        } else {
            PyErr_Clear();
            package = __Pyx_Import(__pyx_n_s_asyncio_tasks, NULL, 0);
            if (unlikely(!package)) goto asyncio_done;
            patch_module = __Pyx_Coroutine_patch_module(
                PyObject_GetAttrString(package, "tasks"), ""
"if hasattr(_module, 'iscoroutine'):\n"
"    old_types = getattr(_module.iscoroutine, '_cython_coroutine_types', None)\n"
"    if old_types is None or not isinstance(old_types, set):\n"
"        old_types = set()\n"
"        def cy_wrap(orig_func, type=type, cython_coroutine_types=old_types):\n"
"            def cy_iscoroutine(obj): return type(obj) in cython_coroutine_types or orig_func(obj)\n"
"            cy_iscoroutine._cython_coroutine_types = cython_coroutine_types\n"
"            return cy_iscoroutine\n"
"        _module.iscoroutine = cy_wrap(_module.iscoroutine)\n"
"    if _cython_coroutine_type is not None:\n"
"        old_types.add(_cython_coroutine_type)\n"
"    if _cython_generator_type is not None:\n"
"        old_types.add(_cython_generator_type)\n"
            );
        }
        Py_DECREF(package);
        if (unlikely(!patch_module)) goto ignore;
asyncio_done:
        PyErr_Clear();
        asyncio_patched = 1;
#ifdef __Pyx_Generator_USED
        {
            PyObject *inspect_module;
            if (patch_module) {
                inspect_module = PyObject_GetAttr(patch_module, __pyx_n_s_inspect);
                Py_DECREF(patch_module);
            } else {
                inspect_module = __Pyx_Import(__pyx_n_s_inspect, NULL, 0);
            }
            if (unlikely(!inspect_module)) goto ignore;
            inspect_module = __Pyx_patch_inspect(inspect_module);
            if (unlikely(!inspect_module)) {
                Py_DECREF(module);
                module = NULL;
            }
            Py_XDECREF(inspect_module);
        }
#else
        if ((0)) return __Pyx_patch_inspect(module);
#endif
    }
    return module;
ignore:
    PyErr_WriteUnraisable(module);
    if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch asyncio package with custom generator type", 1) < 0)) {
        Py_DECREF(module);
        module = NULL;
    }
#else
    if ((0)) return __Pyx_patch_inspect(__Pyx_Coroutine_patch_module(module, NULL));
#endif
    return module;
}

/* CalculateMetaclass */
static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
    Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
    for (i=0; i < nbases; i++) {
        PyTypeObject *tmptype;
        PyObject *tmp = PyTuple_GET_ITEM(bases, i);
        tmptype = Py_TYPE(tmp);
#if PY_MAJOR_VERSION < 3
        if (tmptype == &PyClass_Type)
            continue;
#endif
        if (!metaclass) {
            metaclass = tmptype;
            continue;
        }
        if (PyType_IsSubtype(metaclass, tmptype))
            continue;
        if (PyType_IsSubtype(tmptype, metaclass)) {
            metaclass = tmptype;
            continue;
        }
        PyErr_SetString(PyExc_TypeError,
                        "metaclass conflict: "
                        "the metaclass of a derived class "
                        "must be a (non-strict) subclass "
                        "of the metaclasses of all its bases");
        return NULL;
    }
    if (!metaclass) {
#if PY_MAJOR_VERSION < 3
        metaclass = &PyClass_Type;
#else
        metaclass = &PyType_Type;
#endif
    }
    Py_INCREF((PyObject*) metaclass);
    return (PyObject*) metaclass;
}

/* CythonFunctionShared */
#include <structmember.h>
static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (unlikely(op->func_doc == NULL)) {
        if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
            op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
            op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
            if (unlikely(op->func_doc == NULL))
                return NULL;
        } else {
            Py_INCREF(Py_None);
            return Py_None;
        }
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL) {
        value = Py_None;
    }
    Py_INCREF(value);
    op->func_doc = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
        if (unlikely(op->func_name == NULL))
            return NULL;
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = op->func_qualname;
    Py_INCREF(value);
    op->func_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    if (unlikely(op->func_dict == NULL)) {
        op->func_dict = PyDict_New();
        if (unlikely(op->func_dict == NULL))
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
    if (unlikely(value == NULL)) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (unlikely(!PyDict_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    int result = 0;
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
    Py_INCREF(op->defaults_tuple);
    op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
    Py_INCREF(op->defaults_kwdict);
    #else
    op->defaults_tuple = PySequence_ITEM(res, 0);
    if (unlikely(!op->defaults_tuple)) result = -1;
    else {
        op->defaults_kwdict = PySequence_ITEM(res, 1);
        if (unlikely(!op->defaults_kwdict)) result = -1;
    }
    #endif
    Py_DECREF(res);
    return result;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyTuple_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__defaults__ must be set to a tuple object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_tuple;
    op->defaults_tuple = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->defaults_tuple;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_tuple;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__kwdefaults__ must be set to a dict object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_kwdict;
    op->defaults_kwdict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->defaults_kwdict;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_kwdict;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value || value == Py_None) {
        value = NULL;
    } else if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__annotations__ must be set to a dict object");
        return -1;
    }
    Py_XINCREF(value);
    tmp = op->func_annotations;
    op->func_annotations = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->func_annotations;
    if (unlikely(!result)) {
        result = PyDict_New();
        if (unlikely(!result)) return NULL;
        op->func_annotations = result;
    }
    Py_INCREF(result);
    return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
    {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
    {0, 0, 0, 0, 0}
};
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    Py_INCREF(m->func_qualname);
    return m->func_qualname;
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
#if PY_VERSION_HEX < 0x030500A0
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
#else
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
#endif
static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
                                       PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    if (unlikely(op == NULL))
        return NULL;
    op->flags = flags;
    __Pyx_CyFunction_weakreflist(op) = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    Py_INCREF(qualname);
    op->func_qualname = qualname;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    op->func_globals = globals;
    Py_INCREF(op->func_globals);
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults_size = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_kwdict = NULL;
    op->defaults_getter = NULL;
    op->func_annotations = NULL;
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_qualname);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_globals);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    Py_CLEAR(m->defaults_kwdict);
    Py_CLEAR(m->func_annotations);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyObject_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    if (__Pyx_CyFunction_weakreflist(m) != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    __Pyx__CyFunction_dealloc(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_qualname);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_globals);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    Py_VISIT(m->defaults_kwdict);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
#if PY_MAJOR_VERSION < 3
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
#endif
    return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                op->func_qualname, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(op->func_qualname), (void *)op);
#endif
}
static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = f->m_ml->ml_meth;
    Py_ssize_t size;
    switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
    case METH_VARARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0))
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 0))
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    case METH_O:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 1)) {
                PyObject *result, *arg0;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                arg0 = PyTuple_GET_ITEM(arg, 0);
                #else
                arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
                #endif
                result = (*meth)(self, arg0);
                #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
                Py_DECREF(arg0);
                #endif
                return result;
            }
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    default:
        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
                        "longer supported!");
        return NULL;
    }
    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
                 f->m_ml->ml_name);
    return NULL;
}
static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
}
static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
    PyObject *result;
    __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
    if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
        Py_ssize_t argc;
        PyObject *new_args;
        PyObject *self;
        argc = PyTuple_GET_SIZE(args);
        new_args = PyTuple_GetSlice(args, 1, argc);
        if (unlikely(!new_args))
            return NULL;
        self = PyTuple_GetItem(args, 0);
        if (unlikely(!self)) {
            Py_DECREF(new_args);
            return NULL;
        }
        result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
        Py_DECREF(new_args);
    } else {
        result = __Pyx_CyFunction_Call(func, args, kw);
    }
    return result;
}
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "cython_function_or_method",
    sizeof(__pyx_CyFunctionObject),
    0,
    (destructor) __Pyx_CyFunction_dealloc,
    0,
    0,
    0,
#if PY_MAJOR_VERSION < 3
    0,
#else
    0,
#endif
    (reprfunc) __Pyx_CyFunction_repr,
    0,
    0,
    0,
    0,
    __Pyx_CyFunction_CallAsMethod,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
    0,
    (traverseproc) __Pyx_CyFunction_traverse,
    (inquiry) __Pyx_CyFunction_clear,
    0,
#if PY_VERSION_HEX < 0x030500A0
    offsetof(__pyx_CyFunctionObject, func_weakreflist),
#else
    offsetof(PyCFunctionObject, m_weakreflist),
#endif
    0,
    0,
    __pyx_CyFunction_methods,
    __pyx_CyFunction_members,
    __pyx_CyFunction_getsets,
    0,
    0,
    __Pyx_CyFunction_descr_get,
    0,
    offsetof(__pyx_CyFunctionObject, func_dict),
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b1
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
    0,
#endif
};
static int __pyx_CyFunction_init(void) {
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (unlikely(__pyx_CyFunctionType == NULL)) {
        return -1;
    }
    return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyObject_Malloc(size);
    if (unlikely(!m->defaults))
        return PyErr_NoMemory();
    memset(m->defaults, 0, size);
    m->defaults_pyobjects = pyobjects;
    m->defaults_size = size;
    return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_kwdict = dict;
    Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->func_annotations = dict;
    Py_INCREF(dict);
}

/* CythonFunction */
static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    PyObject *op = __Pyx_CyFunction_Init(
        PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType),
        ml, flags, qualname, closure, module, globals, code
    );
    if (likely(op)) {
        PyObject_GC_Track(op);
    }
    return op;
}

/* Py3ClassCreate */
static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
                                           PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
    PyObject *ns;
    if (metaclass) {
        PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
        if (prep) {
            PyObject *pargs = PyTuple_Pack(2, name, bases);
            if (unlikely(!pargs)) {
                Py_DECREF(prep);
                return NULL;
            }
            ns = PyObject_Call(prep, pargs, mkw);
            Py_DECREF(prep);
            Py_DECREF(pargs);
        } else {
            if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
                return NULL;
            PyErr_Clear();
            ns = PyDict_New();
        }
    } else {
        ns = PyDict_New();
    }
    if (unlikely(!ns))
        return NULL;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
    if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
    return ns;
bad:
    Py_DECREF(ns);
    return NULL;
}
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
                                      PyObject *dict, PyObject *mkw,
                                      int calculate_metaclass, int allow_py2_metaclass) {
    PyObject *result, *margs;
    PyObject *owned_metaclass = NULL;
    if (allow_py2_metaclass) {
        owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
        if (owned_metaclass) {
            metaclass = owned_metaclass;
        } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
            PyErr_Clear();
        } else {
            return NULL;
        }
    }
    if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
        metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
        Py_XDECREF(owned_metaclass);
        if (unlikely(!metaclass))
            return NULL;
        owned_metaclass = metaclass;
    }
    margs = PyTuple_Pack(3, name, bases, dict);
    if (unlikely(!margs)) {
        result = NULL;
    } else {
        result = PyObject_Call(metaclass, margs, mkw);
        Py_DECREF(margs);
    }
    Py_XDECREF(owned_metaclass);
    return result;
}

/* Globals */
static PyObject* __Pyx_Globals(void) {
    Py_ssize_t i;
    PyObject *names;
    PyObject *globals = __pyx_d;
    Py_INCREF(globals);
    names = PyObject_Dir(__pyx_m);
    if (!names)
        goto bad;
    for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject* name = PySequence_ITEM(names, i);
        if (!name)
            goto bad;
#else
        PyObject* name = PyList_GET_ITEM(names, i);
#endif
        if (!PyDict_Contains(globals, name)) {
            PyObject* value = __Pyx_GetAttr(__pyx_m, name);
            if (!value) {
#if CYTHON_COMPILING_IN_PYPY
                Py_DECREF(name);
#endif
                goto bad;
            }
            if (PyDict_SetItem(globals, name, value) < 0) {
#if CYTHON_COMPILING_IN_PYPY
                Py_DECREF(name);
#endif
                Py_DECREF(value);
                goto bad;
            }
        }
#if CYTHON_COMPILING_IN_PYPY
        Py_DECREF(name);
#endif
    }
    Py_DECREF(names);
    return globals;
bad:
    Py_XDECREF(names);
    Py_XDECREF(globals);
    return NULL;
}

/* CLineInTraceback */
#ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
        __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
            use_cline, *cython_runtime_dict,
            __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* CodeObjectCache */
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

/* AddTraceback */
#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        tstate,            /*PyThreadState *tstate,*/
        py_code,           /*PyCodeObject *code,*/
        __pyx_d,    /*PyObject *globals,*/
        0                  /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntFromPyVerify */
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_TransactionStatus(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus neg_one = (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) -1, const_zero = (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus __Pyx_PyInt_As_enum____pyx_t_6edgedb_8protocol_8protocol_TransactionStatus(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus neg_one = (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) -1, const_zero = (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) 0;
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, digit, digits[0])
                case 2:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) >= 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) (((((enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) >= 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) (((((((enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) >= 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) (((((((((enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) 0;
                case -1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) (((enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)-1)*(((((enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) ((((((enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) (((enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)-1)*(((((((enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) ((((((((enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) (((enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)-1)*(((((((((enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) ((((((((((enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) -1;
        }
    } else {
        enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) -1;
        val = __Pyx_PyInt_As_enum____pyx_t_6edgedb_8protocol_8protocol_TransactionStatus(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus");
    return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus");
    return (enum __pyx_t_6edgedb_8protocol_8protocol_TransactionStatus) -1;
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat neg_one = (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) -1, const_zero = (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat __Pyx_PyInt_As_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat neg_one = (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) -1, const_zero = (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) 0;
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, digit, digits[0])
                case 2:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) >= 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) (((((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) >= 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) (((((((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) >= 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) (((((((((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) 0;
                case -1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) (((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)-1)*(((((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) ((((((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) (((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)-1)*(((((((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) ((((((((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) (((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)-1)*(((((((((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) ((((((((((enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) -1;
        }
    } else {
        enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) -1;
        val = __Pyx_PyInt_As_enum____pyx_t_6edgedb_8protocol_8protocol_IoFormat(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat");
    return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat");
    return (enum __pyx_t_6edgedb_8protocol_8protocol_IoFormat) -1;
}

/* CIntFromPy */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

/* CIntFromPy */
static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int32_t neg_one = (int32_t) -1, const_zero = (int32_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int32_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int32_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int32_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int32_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int32_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(int32_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int32_t) >= 2 * PyLong_SHIFT) {
                            return (int32_t) (((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int32_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int32_t) >= 3 * PyLong_SHIFT) {
                            return (int32_t) (((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int32_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int32_t) >= 4 * PyLong_SHIFT) {
                            return (int32_t) (((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int32_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int32_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int32_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int32_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int32_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int32_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int32_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int32_t) (((int32_t)-1)*(((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int32_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int32_t) ((((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int32_t) (((int32_t)-1)*(((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int32_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int32_t) ((((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int32_t) (((int32_t)-1)*(((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int32_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int32_t) ((((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int32_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int32_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int32_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int32_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int32_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int32_t) -1;
        }
    } else {
        int32_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int32_t) -1;
        val = __Pyx_PyInt_As_int32_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int32_t");
    return (int32_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int32_t");
    return (int32_t) -1;
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_EdgeFieldCardinality(EdgeFieldCardinality value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const EdgeFieldCardinality neg_one = (EdgeFieldCardinality) -1, const_zero = (EdgeFieldCardinality) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(EdgeFieldCardinality) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(EdgeFieldCardinality) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(EdgeFieldCardinality) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(EdgeFieldCardinality) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(EdgeFieldCardinality) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(EdgeFieldCardinality),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int32_t(int32_t value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int32_t neg_one = (int32_t) -1, const_zero = (int32_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int32_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int32_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int32_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int32_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int32_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int32_t),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint16_t(uint16_t value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const uint16_t neg_one = (uint16_t) -1, const_zero = (uint16_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(uint16_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(uint16_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint16_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(uint16_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint16_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(uint16_t),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE uint16_t __Pyx_PyInt_As_uint16_t(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const uint16_t neg_one = (uint16_t) -1, const_zero = (uint16_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(uint16_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(uint16_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (uint16_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (uint16_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(uint16_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(uint16_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint16_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint16_t) >= 2 * PyLong_SHIFT) {
                            return (uint16_t) (((((uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint16_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint16_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint16_t) >= 3 * PyLong_SHIFT) {
                            return (uint16_t) (((((((uint16_t)digits[2]) << PyLong_SHIFT) | (uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint16_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint16_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint16_t) >= 4 * PyLong_SHIFT) {
                            return (uint16_t) (((((((((uint16_t)digits[3]) << PyLong_SHIFT) | (uint16_t)digits[2]) << PyLong_SHIFT) | (uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (uint16_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(uint16_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint16_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint16_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint16_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (uint16_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(uint16_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(uint16_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(uint16_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint16_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint16_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint16_t) (((uint16_t)-1)*(((((uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(uint16_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint16_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint16_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint16_t) ((((((uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(uint16_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint16_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint16_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint16_t) (((uint16_t)-1)*(((((((uint16_t)digits[2]) << PyLong_SHIFT) | (uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint16_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint16_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint16_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint16_t) ((((((((uint16_t)digits[2]) << PyLong_SHIFT) | (uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(uint16_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint16_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint16_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint16_t) (((uint16_t)-1)*(((((((((uint16_t)digits[3]) << PyLong_SHIFT) | (uint16_t)digits[2]) << PyLong_SHIFT) | (uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint16_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint16_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint16_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint16_t) ((((((((((uint16_t)digits[3]) << PyLong_SHIFT) | (uint16_t)digits[2]) << PyLong_SHIFT) | (uint16_t)digits[1]) << PyLong_SHIFT) | (uint16_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(uint16_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint16_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint16_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint16_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            uint16_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (uint16_t) -1;
        }
    } else {
        uint16_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (uint16_t) -1;
        val = __Pyx_PyInt_As_uint16_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to uint16_t");
    return (uint16_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to uint16_t");
    return (uint16_t) -1;
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint8_t(uint8_t value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const uint8_t neg_one = (uint8_t) -1, const_zero = (uint8_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(uint8_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(uint8_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint8_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(uint8_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint8_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(uint8_t),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const uint32_t neg_one = (uint32_t) -1, const_zero = (uint32_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(uint32_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(uint32_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint32_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(uint32_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint32_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(uint32_t),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE int64_t __Pyx_PyInt_As_int64_t(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int64_t neg_one = (int64_t) -1, const_zero = (int64_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int64_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int64_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int64_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int64_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int64_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(int64_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) >= 2 * PyLong_SHIFT) {
                            return (int64_t) (((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int64_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) >= 3 * PyLong_SHIFT) {
                            return (int64_t) (((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int64_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) >= 4 * PyLong_SHIFT) {
                            return (int64_t) (((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int64_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int64_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int64_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int64_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int64_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int64_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int64_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int64_t) (((int64_t)-1)*(((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int64_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int64_t) ((((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int64_t) (((int64_t)-1)*(((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int64_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int64_t) ((((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int64_t) (((int64_t)-1)*(((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int64_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int64_t) ((((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int64_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int64_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int64_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int64_t) -1;
        }
    } else {
        int64_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int64_t) -1;
        val = __Pyx_PyInt_As_int64_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int64_t");
    return (int64_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int64_t");
    return (int64_t) -1;
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int64_t(int64_t value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int64_t neg_one = (int64_t) -1, const_zero = (int64_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int64_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int64_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int64_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int64_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int64_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int64_t),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE int16_t __Pyx_PyInt_As_int16_t(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int16_t neg_one = (int16_t) -1, const_zero = (int16_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int16_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int16_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int16_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int16_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int16_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(int16_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int16_t) >= 2 * PyLong_SHIFT) {
                            return (int16_t) (((((int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int16_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int16_t) >= 3 * PyLong_SHIFT) {
                            return (int16_t) (((((((int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int16_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int16_t) >= 4 * PyLong_SHIFT) {
                            return (int16_t) (((((((((int16_t)digits[3]) << PyLong_SHIFT) | (int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int16_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int16_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int16_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int16_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int16_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int16_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int16_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int16_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int16_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int16_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int16_t) (((int16_t)-1)*(((((int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int16_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int16_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int16_t) ((((((int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int16_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int16_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int16_t) (((int16_t)-1)*(((((((int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int16_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int16_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int16_t) ((((((((int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int16_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int16_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int16_t) (((int16_t)-1)*(((((((((int16_t)digits[3]) << PyLong_SHIFT) | (int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int16_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int16_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int16_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int16_t) ((((((((((int16_t)digits[3]) << PyLong_SHIFT) | (int16_t)digits[2]) << PyLong_SHIFT) | (int16_t)digits[1]) << PyLong_SHIFT) | (int16_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int16_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int16_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int16_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int16_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int16_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int16_t) -1;
        }
    } else {
        int16_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int16_t) -1;
        val = __Pyx_PyInt_As_int16_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int16_t");
    return (int16_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int16_t");
    return (int16_t) -1;
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint64_t(uint64_t value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const uint64_t neg_one = (uint64_t) -1, const_zero = (uint64_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(uint64_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(uint64_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint64_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(uint64_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint64_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(uint64_t),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE uint64_t __Pyx_PyInt_As_uint64_t(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const uint64_t neg_one = (uint64_t) -1, const_zero = (uint64_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(uint64_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(uint64_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (uint64_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (uint64_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(uint64_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(uint64_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) >= 2 * PyLong_SHIFT) {
                            return (uint64_t) (((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint64_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) >= 3 * PyLong_SHIFT) {
                            return (uint64_t) (((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint64_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) >= 4 * PyLong_SHIFT) {
                            return (uint64_t) (((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (uint64_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(uint64_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint64_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint64_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint64_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (uint64_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(uint64_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(uint64_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(uint64_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint64_t) (((uint64_t)-1)*(((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(uint64_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint64_t) ((((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint64_t) (((uint64_t)-1)*(((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint64_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint64_t) ((((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint64_t) (((uint64_t)-1)*(((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint64_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint64_t) ((((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(uint64_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint64_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint64_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint64_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            uint64_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (uint64_t) -1;
        }
    } else {
        uint64_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (uint64_t) -1;
        val = __Pyx_PyInt_As_uint64_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to uint64_t");
    return (uint64_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to uint64_t");
    return (uint64_t) -1;
}

/* CIntFromPy */
static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const char neg_one = (char) -1, const_zero = (char) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(char) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (char) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (char) 0;
                case  1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0])
                case 2:
                    if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) {
                            return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) {
                            return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) {
                            return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (char) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(char) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (char) 0;
                case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(char,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
                            return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
                            return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
                            return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
                            return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
                            return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
                            return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(char) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            char val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (char) -1;
        }
    } else {
        char val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (char) -1;
        val = __Pyx_PyInt_As_char(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to char");
    return (char) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to char");
    return (char) -1;
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int16_t(int16_t value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int16_t neg_one = (int16_t) -1, const_zero = (int16_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int16_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int16_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int16_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int16_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int16_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int16_t),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_char(char value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const char neg_one = (char) -1, const_zero = (char) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(char) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(char) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(char) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(char),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE uint32_t __Pyx_PyInt_As_uint32_t(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const uint32_t neg_one = (uint32_t) -1, const_zero = (uint32_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(uint32_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(uint32_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (uint32_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (uint32_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(uint32_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(uint32_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) >= 2 * PyLong_SHIFT) {
                            return (uint32_t) (((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint32_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) >= 3 * PyLong_SHIFT) {
                            return (uint32_t) (((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint32_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) >= 4 * PyLong_SHIFT) {
                            return (uint32_t) (((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (uint32_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(uint32_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint32_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint32_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint32_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (uint32_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(uint32_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(uint32_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(uint32_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint32_t) (((uint32_t)-1)*(((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(uint32_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint32_t) ((((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint32_t) (((uint32_t)-1)*(((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint32_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint32_t) ((((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint32_t) (((uint32_t)-1)*(((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint32_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint32_t) ((((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(uint32_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint32_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint32_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint32_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            uint32_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (uint32_t) -1;
        }
    } else {
        uint32_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (uint32_t) -1;
        val = __Pyx_PyInt_As_uint32_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to uint32_t");
    return (uint32_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to uint32_t");
    return (uint32_t) -1;
}

/* CheckBinaryVersion */
static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

/* FunctionImport */
#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

/* InitStrings */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        if (PyObject_Hash(*t->p) == -1)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    char* defenc_c;
    PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
    if (!defenc) return NULL;
    defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    {
        char* end = defenc_c + PyBytes_GET_SIZE(defenc);
        char* c;
        for (c = defenc_c; c < end; c++) {
            if ((unsigned char) (*c) >= 128) {
                PyUnicode_AsASCIIString(o);
                return NULL;
            }
        }
    }
#endif
    *length = PyBytes_GET_SIZE(defenc);
    return defenc_c;
}
#else
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(PyUnicode_IS_ASCII(o))) {
        *length = PyUnicode_GET_LENGTH(o);
        return PyUnicode_AsUTF8(o);
    } else {
        PyUnicode_AsASCIIString(o);
        return NULL;
    }
#else
    return PyUnicode_AsUTF8AndSize(o, length);
#endif
}
#endif
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
    int retval;
    if (unlikely(!x)) return -1;
    retval = __Pyx_PyObject_IsTrue(x);
    Py_DECREF(x);
    return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(PyLong_Check(x)))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(b);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
