1 /* Generated by Cython 0.29.21 */
2 
3 #define PY_SSIZE_T_CLEAN
4 #include "Python.h"
5 #ifndef Py_PYTHON_H
6     #error Python headers needed to compile C extensions, please install development version of Python.
7 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
8     #error Cython requires Python 2.6+ or Python 3.3+.
9 #else
10 #define CYTHON_ABI "0_29_21"
11 #define CYTHON_HEX_VERSION 0x001D15F0
12 #define CYTHON_FUTURE_DIVISION 1
13 #include <stddef.h>
14 #ifndef offsetof
15   #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
16 #endif
17 #if !defined(WIN32) && !defined(MS_WINDOWS)
18   #ifndef __stdcall
19     #define __stdcall
20   #endif
21   #ifndef __cdecl
22     #define __cdecl
23   #endif
24   #ifndef __fastcall
25     #define __fastcall
26   #endif
27 #endif
28 #ifndef DL_IMPORT
29   #define DL_IMPORT(t) t
30 #endif
31 #ifndef DL_EXPORT
32   #define DL_EXPORT(t) t
33 #endif
34 #define __PYX_COMMA ,
35 #ifndef HAVE_LONG_LONG
36   #if PY_VERSION_HEX >= 0x02070000
37     #define HAVE_LONG_LONG
38   #endif
39 #endif
40 #ifndef PY_LONG_LONG
41   #define PY_LONG_LONG LONG_LONG
42 #endif
43 #ifndef Py_HUGE_VAL
44   #define Py_HUGE_VAL HUGE_VAL
45 #endif
46 #ifdef PYPY_VERSION
47   #define CYTHON_COMPILING_IN_PYPY 1
48   #define CYTHON_COMPILING_IN_PYSTON 0
49   #define CYTHON_COMPILING_IN_CPYTHON 0
50   #undef CYTHON_USE_TYPE_SLOTS
51   #define CYTHON_USE_TYPE_SLOTS 0
52   #undef CYTHON_USE_PYTYPE_LOOKUP
53   #define CYTHON_USE_PYTYPE_LOOKUP 0
54   #if PY_VERSION_HEX < 0x03050000
55     #undef CYTHON_USE_ASYNC_SLOTS
56     #define CYTHON_USE_ASYNC_SLOTS 0
57   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
58     #define CYTHON_USE_ASYNC_SLOTS 1
59   #endif
60   #undef CYTHON_USE_PYLIST_INTERNALS
61   #define CYTHON_USE_PYLIST_INTERNALS 0
62   #undef CYTHON_USE_UNICODE_INTERNALS
63   #define CYTHON_USE_UNICODE_INTERNALS 0
64   #undef CYTHON_USE_UNICODE_WRITER
65   #define CYTHON_USE_UNICODE_WRITER 0
66   #undef CYTHON_USE_PYLONG_INTERNALS
67   #define CYTHON_USE_PYLONG_INTERNALS 0
68   #undef CYTHON_AVOID_BORROWED_REFS
69   #define CYTHON_AVOID_BORROWED_REFS 1
70   #undef CYTHON_ASSUME_SAFE_MACROS
71   #define CYTHON_ASSUME_SAFE_MACROS 0
72   #undef CYTHON_UNPACK_METHODS
73   #define CYTHON_UNPACK_METHODS 0
74   #undef CYTHON_FAST_THREAD_STATE
75   #define CYTHON_FAST_THREAD_STATE 0
76   #undef CYTHON_FAST_PYCALL
77   #define CYTHON_FAST_PYCALL 0
78   #undef CYTHON_PEP489_MULTI_PHASE_INIT
79   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
80   #undef CYTHON_USE_TP_FINALIZE
81   #define CYTHON_USE_TP_FINALIZE 0
82   #undef CYTHON_USE_DICT_VERSIONS
83   #define CYTHON_USE_DICT_VERSIONS 0
84   #undef CYTHON_USE_EXC_INFO_STACK
85   #define CYTHON_USE_EXC_INFO_STACK 0
86 #elif defined(PYSTON_VERSION)
87   #define CYTHON_COMPILING_IN_PYPY 0
88   #define CYTHON_COMPILING_IN_PYSTON 1
89   #define CYTHON_COMPILING_IN_CPYTHON 0
90   #ifndef CYTHON_USE_TYPE_SLOTS
91     #define CYTHON_USE_TYPE_SLOTS 1
92   #endif
93   #undef CYTHON_USE_PYTYPE_LOOKUP
94   #define CYTHON_USE_PYTYPE_LOOKUP 0
95   #undef CYTHON_USE_ASYNC_SLOTS
96   #define CYTHON_USE_ASYNC_SLOTS 0
97   #undef CYTHON_USE_PYLIST_INTERNALS
98   #define CYTHON_USE_PYLIST_INTERNALS 0
99   #ifndef CYTHON_USE_UNICODE_INTERNALS
100     #define CYTHON_USE_UNICODE_INTERNALS 1
101   #endif
102   #undef CYTHON_USE_UNICODE_WRITER
103   #define CYTHON_USE_UNICODE_WRITER 0
104   #undef CYTHON_USE_PYLONG_INTERNALS
105   #define CYTHON_USE_PYLONG_INTERNALS 0
106   #ifndef CYTHON_AVOID_BORROWED_REFS
107     #define CYTHON_AVOID_BORROWED_REFS 0
108   #endif
109   #ifndef CYTHON_ASSUME_SAFE_MACROS
110     #define CYTHON_ASSUME_SAFE_MACROS 1
111   #endif
112   #ifndef CYTHON_UNPACK_METHODS
113     #define CYTHON_UNPACK_METHODS 1
114   #endif
115   #undef CYTHON_FAST_THREAD_STATE
116   #define CYTHON_FAST_THREAD_STATE 0
117   #undef CYTHON_FAST_PYCALL
118   #define CYTHON_FAST_PYCALL 0
119   #undef CYTHON_PEP489_MULTI_PHASE_INIT
120   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
121   #undef CYTHON_USE_TP_FINALIZE
122   #define CYTHON_USE_TP_FINALIZE 0
123   #undef CYTHON_USE_DICT_VERSIONS
124   #define CYTHON_USE_DICT_VERSIONS 0
125   #undef CYTHON_USE_EXC_INFO_STACK
126   #define CYTHON_USE_EXC_INFO_STACK 0
127 #else
128   #define CYTHON_COMPILING_IN_PYPY 0
129   #define CYTHON_COMPILING_IN_PYSTON 0
130   #define CYTHON_COMPILING_IN_CPYTHON 1
131   #ifndef CYTHON_USE_TYPE_SLOTS
132     #define CYTHON_USE_TYPE_SLOTS 1
133   #endif
134   #if PY_VERSION_HEX < 0x02070000
135     #undef CYTHON_USE_PYTYPE_LOOKUP
136     #define CYTHON_USE_PYTYPE_LOOKUP 0
137   #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
138     #define CYTHON_USE_PYTYPE_LOOKUP 1
139   #endif
140   #if PY_MAJOR_VERSION < 3
141     #undef CYTHON_USE_ASYNC_SLOTS
142     #define CYTHON_USE_ASYNC_SLOTS 0
143   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
144     #define CYTHON_USE_ASYNC_SLOTS 1
145   #endif
146   #if PY_VERSION_HEX < 0x02070000
147     #undef CYTHON_USE_PYLONG_INTERNALS
148     #define CYTHON_USE_PYLONG_INTERNALS 0
149   #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
150     #define CYTHON_USE_PYLONG_INTERNALS 1
151   #endif
152   #ifndef CYTHON_USE_PYLIST_INTERNALS
153     #define CYTHON_USE_PYLIST_INTERNALS 1
154   #endif
155   #ifndef CYTHON_USE_UNICODE_INTERNALS
156     #define CYTHON_USE_UNICODE_INTERNALS 1
157   #endif
158   #if PY_VERSION_HEX < 0x030300F0
159     #undef CYTHON_USE_UNICODE_WRITER
160     #define CYTHON_USE_UNICODE_WRITER 0
161   #elif !defined(CYTHON_USE_UNICODE_WRITER)
162     #define CYTHON_USE_UNICODE_WRITER 1
163   #endif
164   #ifndef CYTHON_AVOID_BORROWED_REFS
165     #define CYTHON_AVOID_BORROWED_REFS 0
166   #endif
167   #ifndef CYTHON_ASSUME_SAFE_MACROS
168     #define CYTHON_ASSUME_SAFE_MACROS 1
169   #endif
170   #ifndef CYTHON_UNPACK_METHODS
171     #define CYTHON_UNPACK_METHODS 1
172   #endif
173   #ifndef CYTHON_FAST_THREAD_STATE
174     #define CYTHON_FAST_THREAD_STATE 1
175   #endif
176   #ifndef CYTHON_FAST_PYCALL
177     #define CYTHON_FAST_PYCALL 1
178   #endif
179   #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
180     #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
181   #endif
182   #ifndef CYTHON_USE_TP_FINALIZE
183     #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
184   #endif
185   #ifndef CYTHON_USE_DICT_VERSIONS
186     #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
187   #endif
188   #ifndef CYTHON_USE_EXC_INFO_STACK
189     #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
190   #endif
191 #endif
192 #if !defined(CYTHON_FAST_PYCCALL)
193 #define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
194 #endif
195 #if CYTHON_USE_PYLONG_INTERNALS
196   #include "longintrepr.h"
197   #undef SHIFT
198   #undef BASE
199   #undef MASK
200   #ifdef SIZEOF_VOID_P
201     enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
202   #endif
203 #endif
204 #ifndef __has_attribute
205   #define __has_attribute(x) 0
206 #endif
207 #ifndef __has_cpp_attribute
208   #define __has_cpp_attribute(x) 0
209 #endif
210 #ifndef CYTHON_RESTRICT
211   #if defined(__GNUC__)
212     #define CYTHON_RESTRICT __restrict__
213   #elif defined(_MSC_VER) && _MSC_VER >= 1400
214     #define CYTHON_RESTRICT __restrict
215   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
216     #define CYTHON_RESTRICT restrict
217   #else
218     #define CYTHON_RESTRICT
219   #endif
220 #endif
221 #ifndef CYTHON_UNUSED
222 # if defined(__GNUC__)
223 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
224 #     define CYTHON_UNUSED __attribute__ ((__unused__))
225 #   else
226 #     define CYTHON_UNUSED
227 #   endif
228 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
229 #   define CYTHON_UNUSED __attribute__ ((__unused__))
230 # else
231 #   define CYTHON_UNUSED
232 # endif
233 #endif
234 #ifndef CYTHON_MAYBE_UNUSED_VAR
235 #  if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)236      template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
237 #  else
238 #    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
239 #  endif
240 #endif
241 #ifndef CYTHON_NCP_UNUSED
242 # if CYTHON_COMPILING_IN_CPYTHON
243 #  define CYTHON_NCP_UNUSED
244 # else
245 #  define CYTHON_NCP_UNUSED CYTHON_UNUSED
246 # endif
247 #endif
248 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
249 #ifdef _MSC_VER
250     #ifndef _MSC_STDINT_H_
251         #if _MSC_VER < 1300
252            typedef unsigned char     uint8_t;
253            typedef unsigned int      uint32_t;
254         #else
255            typedef unsigned __int8   uint8_t;
256            typedef unsigned __int32  uint32_t;
257         #endif
258     #endif
259 #else
260    #include <stdint.h>
261 #endif
262 #ifndef CYTHON_FALLTHROUGH
263   #if defined(__cplusplus) && __cplusplus >= 201103L
264     #if __has_cpp_attribute(fallthrough)
265       #define CYTHON_FALLTHROUGH [[fallthrough]]
266     #elif __has_cpp_attribute(clang::fallthrough)
267       #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
268     #elif __has_cpp_attribute(gnu::fallthrough)
269       #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
270     #endif
271   #endif
272   #ifndef CYTHON_FALLTHROUGH
273     #if __has_attribute(fallthrough)
274       #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
275     #else
276       #define CYTHON_FALLTHROUGH
277     #endif
278   #endif
279   #if defined(__clang__ ) && defined(__apple_build_version__)
280     #if __apple_build_version__ < 7000000
281       #undef  CYTHON_FALLTHROUGH
282       #define CYTHON_FALLTHROUGH
283     #endif
284   #endif
285 #endif
286 
287 #ifndef CYTHON_INLINE
288   #if defined(__clang__)
289     #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
290   #elif defined(__GNUC__)
291     #define CYTHON_INLINE __inline__
292   #elif defined(_MSC_VER)
293     #define CYTHON_INLINE __inline
294   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
295     #define CYTHON_INLINE inline
296   #else
297     #define CYTHON_INLINE
298   #endif
299 #endif
300 
301 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
302   #define Py_OptimizeFlag 0
303 #endif
304 #define __PYX_BUILD_PY_SSIZE_T "n"
305 #define CYTHON_FORMAT_SSIZE_T "z"
306 #if PY_MAJOR_VERSION < 3
307   #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
308   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
309           PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
310   #define __Pyx_DefaultClassType PyClass_Type
311 #else
312   #define __Pyx_BUILTIN_MODULE_NAME "builtins"
313 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
314   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
315           PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
316 #else
317   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
318           PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
319 #endif
320   #define __Pyx_DefaultClassType PyType_Type
321 #endif
322 #ifndef Py_TPFLAGS_CHECKTYPES
323   #define Py_TPFLAGS_CHECKTYPES 0
324 #endif
325 #ifndef Py_TPFLAGS_HAVE_INDEX
326   #define Py_TPFLAGS_HAVE_INDEX 0
327 #endif
328 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
329   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
330 #endif
331 #ifndef Py_TPFLAGS_HAVE_FINALIZE
332   #define Py_TPFLAGS_HAVE_FINALIZE 0
333 #endif
334 #ifndef METH_STACKLESS
335   #define METH_STACKLESS 0
336 #endif
337 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
338   #ifndef METH_FASTCALL
339      #define METH_FASTCALL 0x80
340   #endif
341   typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
342   typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
343                                                           Py_ssize_t nargs, PyObject *kwnames);
344 #else
345   #define __Pyx_PyCFunctionFast _PyCFunctionFast
346   #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
347 #endif
348 #if CYTHON_FAST_PYCCALL
349 #define __Pyx_PyFastCFunction_Check(func)\
350     ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
351 #else
352 #define __Pyx_PyFastCFunction_Check(func) 0
353 #endif
354 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
355   #define PyObject_Malloc(s)   PyMem_Malloc(s)
356   #define PyObject_Free(p)     PyMem_Free(p)
357   #define PyObject_Realloc(p)  PyMem_Realloc(p)
358 #endif
359 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
360   #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
361   #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
362   #define PyMem_RawFree(p)             PyMem_Free(p)
363 #endif
364 #if CYTHON_COMPILING_IN_PYSTON
365   #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
366   #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
367 #else
368   #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
369   #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
370 #endif
371 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
372   #define __Pyx_PyThreadState_Current PyThreadState_GET()
373 #elif PY_VERSION_HEX >= 0x03060000
374   #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
375 #elif PY_VERSION_HEX >= 0x03000000
376   #define __Pyx_PyThreadState_Current PyThreadState_GET()
377 #else
378   #define __Pyx_PyThreadState_Current _PyThreadState_Current
379 #endif
380 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
381 #include "pythread.h"
382 #define Py_tss_NEEDS_INIT 0
383 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)384 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
385   *key = PyThread_create_key();
386   return 0;
387 }
PyThread_tss_alloc(void)388 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
389   Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
390   *key = Py_tss_NEEDS_INIT;
391   return key;
392 }
PyThread_tss_free(Py_tss_t * key)393 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
394   PyObject_Free(key);
395 }
PyThread_tss_is_created(Py_tss_t * key)396 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
397   return *key != Py_tss_NEEDS_INIT;
398 }
PyThread_tss_delete(Py_tss_t * key)399 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
400   PyThread_delete_key(*key);
401   *key = Py_tss_NEEDS_INIT;
402 }
PyThread_tss_set(Py_tss_t * key,void * value)403 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
404   return PyThread_set_key_value(*key, value);
405 }
PyThread_tss_get(Py_tss_t * key)406 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
407   return PyThread_get_key_value(*key);
408 }
409 #endif
410 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
411 #define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
412 #else
413 #define __Pyx_PyDict_NewPresized(n)  PyDict_New()
414 #endif
415 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
416   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
417   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
418 #else
419   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
420   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
421 #endif
422 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
423 #define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
424 #else
425 #define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
426 #endif
427 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
428   #define CYTHON_PEP393_ENABLED 1
429   #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
430                                               0 : _PyUnicode_Ready((PyObject *)(op)))
431   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
432   #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
433   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
434   #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
435   #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
436   #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
437   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
438   #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
439   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
440   #else
441   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
442   #endif
443 #else
444   #define CYTHON_PEP393_ENABLED 0
445   #define PyUnicode_1BYTE_KIND  1
446   #define PyUnicode_2BYTE_KIND  2
447   #define PyUnicode_4BYTE_KIND  4
448   #define __Pyx_PyUnicode_READY(op)       (0)
449   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
450   #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
451   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
452   #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
453   #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
454   #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
455   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
456   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
457 #endif
458 #if CYTHON_COMPILING_IN_PYPY
459   #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
460   #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
461 #else
462   #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
463   #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
464       PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
465 #endif
466 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
467   #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
468 #endif
469 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
470   #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
471 #endif
472 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
473   #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
474 #endif
475 #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))
476 #define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
477 #if PY_MAJOR_VERSION >= 3
478   #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
479 #else
480   #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
481 #endif
482 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
483   #define PyObject_ASCII(o)            PyObject_Repr(o)
484 #endif
485 #if PY_MAJOR_VERSION >= 3
486   #define PyBaseString_Type            PyUnicode_Type
487   #define PyStringObject               PyUnicodeObject
488   #define PyString_Type                PyUnicode_Type
489   #define PyString_Check               PyUnicode_Check
490   #define PyString_CheckExact          PyUnicode_CheckExact
491 #ifndef PyObject_Unicode
492   #define PyObject_Unicode             PyObject_Str
493 #endif
494 #endif
495 #if PY_MAJOR_VERSION >= 3
496   #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
497   #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
498 #else
499   #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
500   #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
501 #endif
502 #ifndef PySet_CheckExact
503   #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
504 #endif
505 #if PY_VERSION_HEX >= 0x030900A4
506   #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
507   #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
508 #else
509   #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
510   #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
511 #endif
512 #if CYTHON_ASSUME_SAFE_MACROS
513   #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
514 #else
515   #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
516 #endif
517 #if PY_MAJOR_VERSION >= 3
518   #define PyIntObject                  PyLongObject
519   #define PyInt_Type                   PyLong_Type
520   #define PyInt_Check(op)              PyLong_Check(op)
521   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
522   #define PyInt_FromString             PyLong_FromString
523   #define PyInt_FromUnicode            PyLong_FromUnicode
524   #define PyInt_FromLong               PyLong_FromLong
525   #define PyInt_FromSize_t             PyLong_FromSize_t
526   #define PyInt_FromSsize_t            PyLong_FromSsize_t
527   #define PyInt_AsLong                 PyLong_AsLong
528   #define PyInt_AS_LONG                PyLong_AS_LONG
529   #define PyInt_AsSsize_t              PyLong_AsSsize_t
530   #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
531   #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
532   #define PyNumber_Int                 PyNumber_Long
533 #endif
534 #if PY_MAJOR_VERSION >= 3
535   #define PyBoolObject                 PyLongObject
536 #endif
537 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
538   #ifndef PyUnicode_InternFromString
539     #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
540   #endif
541 #endif
542 #if PY_VERSION_HEX < 0x030200A4
543   typedef long Py_hash_t;
544   #define __Pyx_PyInt_FromHash_t PyInt_FromLong
545   #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
546 #else
547   #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
548   #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
549 #endif
550 #if PY_MAJOR_VERSION >= 3
551   #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
552 #else
553   #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
554 #endif
555 #if CYTHON_USE_ASYNC_SLOTS
556   #if PY_VERSION_HEX >= 0x030500B1
557     #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
558     #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
559   #else
560     #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
561   #endif
562 #else
563   #define __Pyx_PyType_AsAsync(obj) NULL
564 #endif
565 #ifndef __Pyx_PyAsyncMethodsStruct
566     typedef struct {
567         unaryfunc am_await;
568         unaryfunc am_aiter;
569         unaryfunc am_anext;
570     } __Pyx_PyAsyncMethodsStruct;
571 #endif
572 
573 #if defined(WIN32) || defined(MS_WINDOWS)
574   #define _USE_MATH_DEFINES
575 #endif
576 #include <math.h>
577 #ifdef NAN
578 #define __PYX_NAN() ((float) NAN)
579 #else
__PYX_NAN()580 static CYTHON_INLINE float __PYX_NAN() {
581   float value;
582   memset(&value, 0xFF, sizeof(value));
583   return value;
584 }
585 #endif
586 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
587 #define __Pyx_truncl trunc
588 #else
589 #define __Pyx_truncl truncl
590 #endif
591 
592 #define __PYX_MARK_ERR_POS(f_index, lineno) \
593     { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
594 #define __PYX_ERR(f_index, lineno, Ln_error) \
595     { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
596 
597 #ifndef __PYX_EXTERN_C
598   #ifdef __cplusplus
599     #define __PYX_EXTERN_C extern "C"
600   #else
601     #define __PYX_EXTERN_C extern
602   #endif
603 #endif
604 
605 #define __PYX_HAVE__aiohttp___http_writer
606 #define __PYX_HAVE_API__aiohttp___http_writer
607 /* Early includes */
608 #include <string.h>
609 #include <stdio.h>
610 #include <stdint.h>
611 #ifdef _OPENMP
612 #include <omp.h>
613 #endif /* _OPENMP */
614 
615 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
616 #define CYTHON_WITHOUT_ASSERTIONS
617 #endif
618 
619 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
620                 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
621 
622 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
623 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
624 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
625 #define __PYX_DEFAULT_STRING_ENCODING ""
626 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
627 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
628 #define __Pyx_uchar_cast(c) ((unsigned char)c)
629 #define __Pyx_long_cast(x) ((long)x)
630 #define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
631     (sizeof(type) < sizeof(Py_ssize_t))  ||\
632     (sizeof(type) > sizeof(Py_ssize_t) &&\
633           likely(v < (type)PY_SSIZE_T_MAX ||\
634                  v == (type)PY_SSIZE_T_MAX)  &&\
635           (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
636                                 v == (type)PY_SSIZE_T_MIN)))  ||\
637     (sizeof(type) == sizeof(Py_ssize_t) &&\
638           (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
639                                v == (type)PY_SSIZE_T_MAX)))  )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)640 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
641     return (size_t) i < (size_t) limit;
642 }
643 #if defined (__cplusplus) && __cplusplus >= 201103L
644     #include <cstdlib>
645     #define __Pyx_sst_abs(value) std::abs(value)
646 #elif SIZEOF_INT >= SIZEOF_SIZE_T
647     #define __Pyx_sst_abs(value) abs(value)
648 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
649     #define __Pyx_sst_abs(value) labs(value)
650 #elif defined (_MSC_VER)
651     #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
652 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
653     #define __Pyx_sst_abs(value) llabs(value)
654 #elif defined (__GNUC__)
655     #define __Pyx_sst_abs(value) __builtin_llabs(value)
656 #else
657     #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
658 #endif
659 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
660 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
661 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
662 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
663 #define __Pyx_PyBytes_FromString        PyBytes_FromString
664 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
665 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
666 #if PY_MAJOR_VERSION < 3
667     #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
668     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
669 #else
670     #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
671     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
672 #endif
673 #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
674 #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
675 #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
676 #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
677 #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
678 #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
679 #define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
680 #define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
681 #define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
682 #define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
683 #define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
684 #define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
685 #define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
686 #define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
687 #define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
688 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)689 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
690     const Py_UNICODE *u_end = u;
691     while (*u_end++) ;
692     return (size_t)(u_end - u - 1);
693 }
694 #define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
695 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
696 #define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
697 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
698 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
699 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
700 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
701 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
702 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
703 #define __Pyx_PySequence_Tuple(obj)\
704     (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
705 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
706 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
707 #if CYTHON_ASSUME_SAFE_MACROS
708 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
709 #else
710 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
711 #endif
712 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
713 #if PY_MAJOR_VERSION >= 3
714 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
715 #else
716 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
717 #endif
718 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
719 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
720 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)721 static int __Pyx_init_sys_getdefaultencoding_params(void) {
722     PyObject* sys;
723     PyObject* default_encoding = NULL;
724     PyObject* ascii_chars_u = NULL;
725     PyObject* ascii_chars_b = NULL;
726     const char* default_encoding_c;
727     sys = PyImport_ImportModule("sys");
728     if (!sys) goto bad;
729     default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
730     Py_DECREF(sys);
731     if (!default_encoding) goto bad;
732     default_encoding_c = PyBytes_AsString(default_encoding);
733     if (!default_encoding_c) goto bad;
734     if (strcmp(default_encoding_c, "ascii") == 0) {
735         __Pyx_sys_getdefaultencoding_not_ascii = 0;
736     } else {
737         char ascii_chars[128];
738         int c;
739         for (c = 0; c < 128; c++) {
740             ascii_chars[c] = c;
741         }
742         __Pyx_sys_getdefaultencoding_not_ascii = 1;
743         ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
744         if (!ascii_chars_u) goto bad;
745         ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
746         if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
747             PyErr_Format(
748                 PyExc_ValueError,
749                 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
750                 default_encoding_c);
751             goto bad;
752         }
753         Py_DECREF(ascii_chars_u);
754         Py_DECREF(ascii_chars_b);
755     }
756     Py_DECREF(default_encoding);
757     return 0;
758 bad:
759     Py_XDECREF(default_encoding);
760     Py_XDECREF(ascii_chars_u);
761     Py_XDECREF(ascii_chars_b);
762     return -1;
763 }
764 #endif
765 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
766 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
767 #else
768 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
769 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
770 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)771 static int __Pyx_init_sys_getdefaultencoding_params(void) {
772     PyObject* sys;
773     PyObject* default_encoding = NULL;
774     char* default_encoding_c;
775     sys = PyImport_ImportModule("sys");
776     if (!sys) goto bad;
777     default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
778     Py_DECREF(sys);
779     if (!default_encoding) goto bad;
780     default_encoding_c = PyBytes_AsString(default_encoding);
781     if (!default_encoding_c) goto bad;
782     __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
783     if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
784     strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
785     Py_DECREF(default_encoding);
786     return 0;
787 bad:
788     Py_XDECREF(default_encoding);
789     return -1;
790 }
791 #endif
792 #endif
793 
794 
795 /* Test for GCC > 2.95 */
796 #if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
797   #define likely(x)   __builtin_expect(!!(x), 1)
798   #define unlikely(x) __builtin_expect(!!(x), 0)
799 #else /* !__GNUC__ or GCC < 2.95 */
800   #define likely(x)   (x)
801   #define unlikely(x) (x)
802 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)803 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
804 
805 static PyObject *__pyx_m = NULL;
806 static PyObject *__pyx_d;
807 static PyObject *__pyx_b;
808 static PyObject *__pyx_cython_runtime = NULL;
809 static PyObject *__pyx_empty_tuple;
810 static PyObject *__pyx_empty_bytes;
811 static PyObject *__pyx_empty_unicode;
812 static int __pyx_lineno;
813 static int __pyx_clineno = 0;
814 static const char * __pyx_cfilenm= __FILE__;
815 static const char *__pyx_filename;
816 
817 
818 static const char *__pyx_f[] = {
819   "aiohttp/_http_writer.pyx",
820   "type.pxd",
821 };
822 
823 /*--- Type declarations ---*/
824 struct __pyx_t_7aiohttp_12_http_writer_Writer;
825 
826 /* "aiohttp/_http_writer.pyx":18
827  * # ----------------- writer ---------------------------
828  *
829  * cdef struct Writer:             # <<<<<<<<<<<<<<
830  *     char *buf
831  *     Py_ssize_t size
832  */
833 struct __pyx_t_7aiohttp_12_http_writer_Writer {
834   char *buf;
835   Py_ssize_t size;
836   Py_ssize_t pos;
837 };
838 
839 /* --- Runtime support code (head) --- */
840 /* Refnanny.proto */
841 #ifndef CYTHON_REFNANNY
842   #define CYTHON_REFNANNY 0
843 #endif
844 #if CYTHON_REFNANNY
845   typedef struct {
846     void (*INCREF)(void*, PyObject*, int);
847     void (*DECREF)(void*, PyObject*, int);
848     void (*GOTREF)(void*, PyObject*, int);
849     void (*GIVEREF)(void*, PyObject*, int);
850     void* (*SetupContext)(const char*, int, const char*);
851     void (*FinishContext)(void**);
852   } __Pyx_RefNannyAPIStruct;
853   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
854   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
855   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
856 #ifdef WITH_THREAD
857   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
858           if (acquire_gil) {\
859               PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
860               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
861               PyGILState_Release(__pyx_gilstate_save);\
862           } else {\
863               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
864           }
865 #else
866   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
867           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
868 #endif
869   #define __Pyx_RefNannyFinishContext()\
870           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
871   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
872   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
873   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
874   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
875   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
876   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
877   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
878   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
879 #else
880   #define __Pyx_RefNannyDeclarations
881   #define __Pyx_RefNannySetupContext(name, acquire_gil)
882   #define __Pyx_RefNannyFinishContext()
883   #define __Pyx_INCREF(r) Py_INCREF(r)
884   #define __Pyx_DECREF(r) Py_DECREF(r)
885   #define __Pyx_GOTREF(r)
886   #define __Pyx_GIVEREF(r)
887   #define __Pyx_XINCREF(r) Py_XINCREF(r)
888   #define __Pyx_XDECREF(r) Py_XDECREF(r)
889   #define __Pyx_XGOTREF(r)
890   #define __Pyx_XGIVEREF(r)
891 #endif
892 #define __Pyx_XDECREF_SET(r, v) do {\
893         PyObject *tmp = (PyObject *) r;\
894         r = v; __Pyx_XDECREF(tmp);\
895     } while (0)
896 #define __Pyx_DECREF_SET(r, v) do {\
897         PyObject *tmp = (PyObject *) r;\
898         r = v; __Pyx_DECREF(tmp);\
899     } while (0)
900 #define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
901 #define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
902 
903 /* PyObjectGetAttrStr.proto */
904 #if CYTHON_USE_TYPE_SLOTS
905 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
906 #else
907 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
908 #endif
909 
910 /* GetBuiltinName.proto */
911 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
912 
913 /* PyThreadStateGet.proto */
914 #if CYTHON_FAST_THREAD_STATE
915 #define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
916 #define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
917 #define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
918 #else
919 #define __Pyx_PyThreadState_declare
920 #define __Pyx_PyThreadState_assign
921 #define __Pyx_PyErr_Occurred()  PyErr_Occurred()
922 #endif
923 
924 /* PyErrFetchRestore.proto */
925 #if CYTHON_FAST_THREAD_STATE
926 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
927 #define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
928 #define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
929 #define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
930 #define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
931 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
932 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
933 #if CYTHON_COMPILING_IN_CPYTHON
934 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
935 #else
936 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
937 #endif
938 #else
939 #define __Pyx_PyErr_Clear() PyErr_Clear()
940 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
941 #define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
942 #define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
943 #define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
944 #define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
945 #define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
946 #define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
947 #endif
948 
949 /* WriteUnraisableException.proto */
950 static void __Pyx_WriteUnraisable(const char *name, int clineno,
951                                   int lineno, const char *filename,
952                                   int full_traceback, int nogil);
953 
954 /* unicode_iter.proto */
955 static CYTHON_INLINE int __Pyx_init_unicode_iteration(
956     PyObject* ustring, Py_ssize_t *length, void** data, int *kind);
957 
958 /* PyCFunctionFastCall.proto */
959 #if CYTHON_FAST_PYCCALL
960 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
961 #else
962 #define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
963 #endif
964 
965 /* PyFunctionFastCall.proto */
966 #if CYTHON_FAST_PYCALL
967 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
968     __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
969 #if 1 || PY_VERSION_HEX < 0x030600B1
970 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
971 #else
972 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
973 #endif
974 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
975     (sizeof(char [1 - 2*!(cond)]) - 1)
976 #ifndef Py_MEMBER_SIZE
977 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
978 #endif
979   static size_t __pyx_pyframe_localsplus_offset = 0;
980   #include "frameobject.h"
981   #define __Pxy_PyFrame_Initialize_Offsets()\
982     ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
983      (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
984   #define __Pyx_PyFrame_GetLocalsplus(frame)\
985     (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
986 #endif
987 
988 /* PyObjectCall.proto */
989 #if CYTHON_COMPILING_IN_CPYTHON
990 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
991 #else
992 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
993 #endif
994 
995 /* PyObjectCall2Args.proto */
996 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
997 
998 /* PyObjectCallMethO.proto */
999 #if CYTHON_COMPILING_IN_CPYTHON
1000 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1001 #endif
1002 
1003 /* PyObjectCallOneArg.proto */
1004 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1005 
1006 /* RaiseException.proto */
1007 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1008 
1009 /* RaiseArgTupleInvalid.proto */
1010 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1011     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1012 
1013 /* RaiseDoubleKeywords.proto */
1014 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1015 
1016 /* ParseKeywords.proto */
1017 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1018     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1019     const char* function_name);
1020 
1021 /* ArgTypeTest.proto */
1022 #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
1023     ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
1024         __Pyx__ArgTypeTest(obj, type, name, exact))
1025 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
1026 
1027 /* GetTopmostException.proto */
1028 #if CYTHON_USE_EXC_INFO_STACK
1029 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1030 #endif
1031 
1032 /* ReRaiseException.proto */
1033 static CYTHON_INLINE void __Pyx_ReraiseException(void);
1034 
1035 /* IterFinish.proto */
1036 static CYTHON_INLINE int __Pyx_IterFinish(void);
1037 
1038 /* PyObjectCallNoArg.proto */
1039 #if CYTHON_COMPILING_IN_CPYTHON
1040 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1041 #else
1042 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1043 #endif
1044 
1045 /* PyObjectGetMethod.proto */
1046 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
1047 
1048 /* PyObjectCallMethod0.proto */
1049 static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
1050 
1051 /* RaiseNeedMoreValuesToUnpack.proto */
1052 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
1053 
1054 /* RaiseTooManyValuesToUnpack.proto */
1055 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
1056 
1057 /* UnpackItemEndCheck.proto */
1058 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
1059 
1060 /* RaiseNoneIterError.proto */
1061 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
1062 
1063 /* UnpackTupleError.proto */
1064 static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);
1065 
1066 /* UnpackTuple2.proto */
1067 #define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\
1068     (likely(is_tuple || PyTuple_Check(tuple)) ?\
1069         (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\
1070             __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\
1071             (__Pyx_UnpackTupleError(tuple, 2), -1)) :\
1072         __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple))
1073 static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
1074     PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple);
1075 static int __Pyx_unpack_tuple2_generic(
1076     PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple);
1077 
1078 /* dict_iter.proto */
1079 static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
1080                                                    Py_ssize_t* p_orig_length, int* p_is_dict);
1081 static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
1082                                               PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);
1083 
1084 /* GetException.proto */
1085 #if CYTHON_FAST_THREAD_STATE
1086 #define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
1087 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1088 #else
1089 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1090 #endif
1091 
1092 /* SwapException.proto */
1093 #if CYTHON_FAST_THREAD_STATE
1094 #define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
1095 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1096 #else
1097 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
1098 #endif
1099 
1100 /* SaveResetException.proto */
1101 #if CYTHON_FAST_THREAD_STATE
1102 #define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1103 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1104 #define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1105 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1106 #else
1107 #define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
1108 #define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
1109 #endif
1110 
1111 /* TypeImport.proto */
1112 #ifndef __PYX_HAVE_RT_ImportType_proto
1113 #define __PYX_HAVE_RT_ImportType_proto
1114 enum __Pyx_ImportType_CheckSize {
1115    __Pyx_ImportType_CheckSize_Error = 0,
1116    __Pyx_ImportType_CheckSize_Warn = 1,
1117    __Pyx_ImportType_CheckSize_Ignore = 2
1118 };
1119 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
1120 #endif
1121 
1122 /* Import.proto */
1123 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1124 
1125 /* ImportFrom.proto */
1126 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1127 
1128 /* PyDictVersioning.proto */
1129 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1130 #define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
1131 #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
1132 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1133     (version_var) = __PYX_GET_DICT_VERSION(dict);\
1134     (cache_var) = (value);
1135 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1136     static PY_UINT64_T __pyx_dict_version = 0;\
1137     static PyObject *__pyx_dict_cached_value = NULL;\
1138     if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1139         (VAR) = __pyx_dict_cached_value;\
1140     } else {\
1141         (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1142         __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1143     }\
1144 }
1145 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1146 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1147 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1148 #else
1149 #define __PYX_GET_DICT_VERSION(dict)  (0)
1150 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1151 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
1152 #endif
1153 
1154 /* GetModuleGlobalName.proto */
1155 #if CYTHON_USE_DICT_VERSIONS
1156 #define __Pyx_GetModuleGlobalName(var, name)  {\
1157     static PY_UINT64_T __pyx_dict_version = 0;\
1158     static PyObject *__pyx_dict_cached_value = NULL;\
1159     (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1160         (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1161         __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1162 }
1163 #define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
1164     PY_UINT64_T __pyx_dict_version;\
1165     PyObject *__pyx_dict_cached_value;\
1166     (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1167 }
1168 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1169 #else
1170 #define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1171 #define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1172 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1173 #endif
1174 
1175 /* CLineInTraceback.proto */
1176 #ifdef CYTHON_CLINE_IN_TRACEBACK
1177 #define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1178 #else
1179 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1180 #endif
1181 
1182 /* CodeObjectCache.proto */
1183 typedef struct {
1184     PyCodeObject* code_object;
1185     int code_line;
1186 } __Pyx_CodeObjectCacheEntry;
1187 struct __Pyx_CodeObjectCache {
1188     int count;
1189     int max_count;
1190     __Pyx_CodeObjectCacheEntry* entries;
1191 };
1192 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1193 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1194 static PyCodeObject *__pyx_find_code_object(int code_line);
1195 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1196 
1197 /* AddTraceback.proto */
1198 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1199                                int py_line, const char *filename);
1200 
1201 /* CIntToPy.proto */
1202 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1203 
1204 /* CIntFromPy.proto */
1205 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1206 
1207 /* CIntFromPy.proto */
1208 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1209 
1210 /* FastTypeChecks.proto */
1211 #if CYTHON_COMPILING_IN_CPYTHON
1212 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1213 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1214 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1215 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1216 #else
1217 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1218 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1219 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1220 #endif
1221 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1222 
1223 /* CheckBinaryVersion.proto */
1224 static int __Pyx_check_binary_version(void);
1225 
1226 /* InitStrings.proto */
1227 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1228 
1229 
1230 /* Module declarations from 'libc.string' */
1231 
1232 /* Module declarations from 'libc.stdio' */
1233 
1234 /* Module declarations from '__builtin__' */
1235 
1236 /* Module declarations from 'cpython.type' */
1237 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
1238 
1239 /* Module declarations from 'cpython' */
1240 
1241 /* Module declarations from 'cpython.object' */
1242 
1243 /* Module declarations from 'cpython.bytes' */
1244 
1245 /* Module declarations from 'cpython.exc' */
1246 
1247 /* Module declarations from 'cpython.mem' */
1248 
1249 /* Module declarations from 'libc.stdint' */
1250 
1251 /* Module declarations from 'aiohttp._http_writer' */
1252 static char __pyx_v_7aiohttp_12_http_writer_BUFFER[0x4000];
1253 static PyObject *__pyx_v_7aiohttp_12_http_writer__istr = 0;
1254 static CYTHON_INLINE void __pyx_f_7aiohttp_12_http_writer__init_writer(struct __pyx_t_7aiohttp_12_http_writer_Writer *); /*proto*/
1255 static CYTHON_INLINE void __pyx_f_7aiohttp_12_http_writer__release_writer(struct __pyx_t_7aiohttp_12_http_writer_Writer *); /*proto*/
1256 static CYTHON_INLINE int __pyx_f_7aiohttp_12_http_writer__write_byte(struct __pyx_t_7aiohttp_12_http_writer_Writer *, uint8_t); /*proto*/
1257 static CYTHON_INLINE int __pyx_f_7aiohttp_12_http_writer__write_utf8(struct __pyx_t_7aiohttp_12_http_writer_Writer *, Py_UCS4); /*proto*/
1258 static CYTHON_INLINE int __pyx_f_7aiohttp_12_http_writer__write_str(struct __pyx_t_7aiohttp_12_http_writer_Writer *, PyObject *); /*proto*/
1259 static PyObject *__pyx_f_7aiohttp_12_http_writer_to_str(PyObject *); /*proto*/
1260 #define __Pyx_MODULE_NAME "aiohttp._http_writer"
1261 extern int __pyx_module_is_main_aiohttp___http_writer;
1262 int __pyx_module_is_main_aiohttp___http_writer = 0;
1263 
1264 /* Implementation of 'aiohttp._http_writer' */
1265 static PyObject *__pyx_builtin_TypeError;
1266 static const char __pyx_k_key[] = "key";
1267 static const char __pyx_k_ret[] = "ret";
1268 static const char __pyx_k_val[] = "val";
1269 static const char __pyx_k_istr[] = "istr";
1270 static const char __pyx_k_main[] = "__main__";
1271 static const char __pyx_k_name[] = "__name__";
1272 static const char __pyx_k_test[] = "__test__";
1273 static const char __pyx_k_items[] = "items";
1274 static const char __pyx_k_format[] = "format";
1275 static const char __pyx_k_import[] = "__import__";
1276 static const char __pyx_k_writer[] = "writer";
1277 static const char __pyx_k_headers[] = "headers";
1278 static const char __pyx_k_TypeError[] = "TypeError";
1279 static const char __pyx_k_multidict[] = "multidict";
1280 static const char __pyx_k_status_line[] = "status_line";
1281 static const char __pyx_k_serialize_headers[] = "_serialize_headers";
1282 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1283 static const char __pyx_k_aiohttp__http_writer[] = "aiohttp._http_writer";
1284 static const char __pyx_k_aiohttp__http_writer_pyx[] = "aiohttp/_http_writer.pyx";
1285 static const char __pyx_k_Cannot_serialize_non_str_key_r[] = "Cannot serialize non-str key {!r}";
1286 static PyObject *__pyx_kp_u_Cannot_serialize_non_str_key_r;
1287 static PyObject *__pyx_n_s_TypeError;
1288 static PyObject *__pyx_n_s_aiohttp__http_writer;
1289 static PyObject *__pyx_kp_s_aiohttp__http_writer_pyx;
1290 static PyObject *__pyx_n_s_cline_in_traceback;
1291 static PyObject *__pyx_n_s_format;
1292 static PyObject *__pyx_n_s_headers;
1293 static PyObject *__pyx_n_s_import;
1294 static PyObject *__pyx_n_s_istr;
1295 static PyObject *__pyx_n_s_items;
1296 static PyObject *__pyx_n_s_key;
1297 static PyObject *__pyx_n_s_main;
1298 static PyObject *__pyx_n_s_multidict;
1299 static PyObject *__pyx_n_s_name;
1300 static PyObject *__pyx_n_s_ret;
1301 static PyObject *__pyx_n_s_serialize_headers;
1302 static PyObject *__pyx_n_s_status_line;
1303 static PyObject *__pyx_n_s_test;
1304 static PyObject *__pyx_n_s_val;
1305 static PyObject *__pyx_n_s_writer;
1306 static PyObject *__pyx_pf_7aiohttp_12_http_writer__serialize_headers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_status_line, PyObject *__pyx_v_headers); /* proto */
1307 static PyObject *__pyx_tuple_;
1308 static PyObject *__pyx_codeobj__2;
1309 /* Late includes */
1310 
1311 /* "aiohttp/_http_writer.pyx":24
1312  *
1313  *
1314  * cdef inline void _init_writer(Writer* writer):             # <<<<<<<<<<<<<<
1315  *     writer.buf = &BUFFER[0]
1316  *     writer.size = BUF_SIZE
1317  */
1318 
__pyx_f_7aiohttp_12_http_writer__init_writer(struct __pyx_t_7aiohttp_12_http_writer_Writer * __pyx_v_writer)1319 static CYTHON_INLINE void __pyx_f_7aiohttp_12_http_writer__init_writer(struct __pyx_t_7aiohttp_12_http_writer_Writer *__pyx_v_writer) {
1320   __Pyx_RefNannyDeclarations
1321   __Pyx_RefNannySetupContext("_init_writer", 0);
1322 
1323   /* "aiohttp/_http_writer.pyx":25
1324  *
1325  * cdef inline void _init_writer(Writer* writer):
1326  *     writer.buf = &BUFFER[0]             # <<<<<<<<<<<<<<
1327  *     writer.size = BUF_SIZE
1328  *     writer.pos = 0
1329  */
1330   __pyx_v_writer->buf = (&(__pyx_v_7aiohttp_12_http_writer_BUFFER[0]));
1331 
1332   /* "aiohttp/_http_writer.pyx":26
1333  * cdef inline void _init_writer(Writer* writer):
1334  *     writer.buf = &BUFFER[0]
1335  *     writer.size = BUF_SIZE             # <<<<<<<<<<<<<<
1336  *     writer.pos = 0
1337  *
1338  */
1339   __pyx_v_writer->size = 0x4000;
1340 
1341   /* "aiohttp/_http_writer.pyx":27
1342  *     writer.buf = &BUFFER[0]
1343  *     writer.size = BUF_SIZE
1344  *     writer.pos = 0             # <<<<<<<<<<<<<<
1345  *
1346  *
1347  */
1348   __pyx_v_writer->pos = 0;
1349 
1350   /* "aiohttp/_http_writer.pyx":24
1351  *
1352  *
1353  * cdef inline void _init_writer(Writer* writer):             # <<<<<<<<<<<<<<
1354  *     writer.buf = &BUFFER[0]
1355  *     writer.size = BUF_SIZE
1356  */
1357 
1358   /* function exit code */
1359   __Pyx_RefNannyFinishContext();
1360 }
1361 
1362 /* "aiohttp/_http_writer.pyx":30
1363  *
1364  *
1365  * cdef inline void _release_writer(Writer* writer):             # <<<<<<<<<<<<<<
1366  *     if writer.buf != BUFFER:
1367  *         PyMem_Free(writer.buf)
1368  */
1369 
__pyx_f_7aiohttp_12_http_writer__release_writer(struct __pyx_t_7aiohttp_12_http_writer_Writer * __pyx_v_writer)1370 static CYTHON_INLINE void __pyx_f_7aiohttp_12_http_writer__release_writer(struct __pyx_t_7aiohttp_12_http_writer_Writer *__pyx_v_writer) {
1371   __Pyx_RefNannyDeclarations
1372   int __pyx_t_1;
1373   __Pyx_RefNannySetupContext("_release_writer", 0);
1374 
1375   /* "aiohttp/_http_writer.pyx":31
1376  *
1377  * cdef inline void _release_writer(Writer* writer):
1378  *     if writer.buf != BUFFER:             # <<<<<<<<<<<<<<
1379  *         PyMem_Free(writer.buf)
1380  *
1381  */
1382   __pyx_t_1 = ((__pyx_v_writer->buf != __pyx_v_7aiohttp_12_http_writer_BUFFER) != 0);
1383   if (__pyx_t_1) {
1384 
1385     /* "aiohttp/_http_writer.pyx":32
1386  * cdef inline void _release_writer(Writer* writer):
1387  *     if writer.buf != BUFFER:
1388  *         PyMem_Free(writer.buf)             # <<<<<<<<<<<<<<
1389  *
1390  *
1391  */
1392     PyMem_Free(__pyx_v_writer->buf);
1393 
1394     /* "aiohttp/_http_writer.pyx":31
1395  *
1396  * cdef inline void _release_writer(Writer* writer):
1397  *     if writer.buf != BUFFER:             # <<<<<<<<<<<<<<
1398  *         PyMem_Free(writer.buf)
1399  *
1400  */
1401   }
1402 
1403   /* "aiohttp/_http_writer.pyx":30
1404  *
1405  *
1406  * cdef inline void _release_writer(Writer* writer):             # <<<<<<<<<<<<<<
1407  *     if writer.buf != BUFFER:
1408  *         PyMem_Free(writer.buf)
1409  */
1410 
1411   /* function exit code */
1412   __Pyx_RefNannyFinishContext();
1413 }
1414 
1415 /* "aiohttp/_http_writer.pyx":35
1416  *
1417  *
1418  * cdef inline int _write_byte(Writer* writer, uint8_t ch):             # <<<<<<<<<<<<<<
1419  *     cdef char * buf
1420  *     cdef Py_ssize_t size
1421  */
1422 
__pyx_f_7aiohttp_12_http_writer__write_byte(struct __pyx_t_7aiohttp_12_http_writer_Writer * __pyx_v_writer,uint8_t __pyx_v_ch)1423 static CYTHON_INLINE int __pyx_f_7aiohttp_12_http_writer__write_byte(struct __pyx_t_7aiohttp_12_http_writer_Writer *__pyx_v_writer, uint8_t __pyx_v_ch) {
1424   char *__pyx_v_buf;
1425   Py_ssize_t __pyx_v_size;
1426   int __pyx_r;
1427   __Pyx_RefNannyDeclarations
1428   int __pyx_t_1;
1429   PyObject *__pyx_t_2;
1430   int __pyx_lineno = 0;
1431   const char *__pyx_filename = NULL;
1432   int __pyx_clineno = 0;
1433   __Pyx_RefNannySetupContext("_write_byte", 0);
1434 
1435   /* "aiohttp/_http_writer.pyx":39
1436  *     cdef Py_ssize_t size
1437  *
1438  *     if writer.pos == writer.size:             # <<<<<<<<<<<<<<
1439  *         # reallocate
1440  *         size = writer.size + BUF_SIZE
1441  */
1442   __pyx_t_1 = ((__pyx_v_writer->pos == __pyx_v_writer->size) != 0);
1443   if (__pyx_t_1) {
1444 
1445     /* "aiohttp/_http_writer.pyx":41
1446  *     if writer.pos == writer.size:
1447  *         # reallocate
1448  *         size = writer.size + BUF_SIZE             # <<<<<<<<<<<<<<
1449  *         if writer.buf == BUFFER:
1450  *             buf = <char*>PyMem_Malloc(size)
1451  */
1452     __pyx_v_size = (__pyx_v_writer->size + 0x4000);
1453 
1454     /* "aiohttp/_http_writer.pyx":42
1455  *         # reallocate
1456  *         size = writer.size + BUF_SIZE
1457  *         if writer.buf == BUFFER:             # <<<<<<<<<<<<<<
1458  *             buf = <char*>PyMem_Malloc(size)
1459  *             if buf == NULL:
1460  */
1461     __pyx_t_1 = ((__pyx_v_writer->buf == __pyx_v_7aiohttp_12_http_writer_BUFFER) != 0);
1462     if (__pyx_t_1) {
1463 
1464       /* "aiohttp/_http_writer.pyx":43
1465  *         size = writer.size + BUF_SIZE
1466  *         if writer.buf == BUFFER:
1467  *             buf = <char*>PyMem_Malloc(size)             # <<<<<<<<<<<<<<
1468  *             if buf == NULL:
1469  *                 PyErr_NoMemory()
1470  */
1471       __pyx_v_buf = ((char *)PyMem_Malloc(__pyx_v_size));
1472 
1473       /* "aiohttp/_http_writer.pyx":44
1474  *         if writer.buf == BUFFER:
1475  *             buf = <char*>PyMem_Malloc(size)
1476  *             if buf == NULL:             # <<<<<<<<<<<<<<
1477  *                 PyErr_NoMemory()
1478  *                 return -1
1479  */
1480       __pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
1481       if (__pyx_t_1) {
1482 
1483         /* "aiohttp/_http_writer.pyx":45
1484  *             buf = <char*>PyMem_Malloc(size)
1485  *             if buf == NULL:
1486  *                 PyErr_NoMemory()             # <<<<<<<<<<<<<<
1487  *                 return -1
1488  *             memcpy(buf, writer.buf, writer.size)
1489  */
1490         __pyx_t_2 = PyErr_NoMemory(); if (unlikely(__pyx_t_2 == ((PyObject *)NULL))) __PYX_ERR(0, 45, __pyx_L1_error)
1491 
1492         /* "aiohttp/_http_writer.pyx":46
1493  *             if buf == NULL:
1494  *                 PyErr_NoMemory()
1495  *                 return -1             # <<<<<<<<<<<<<<
1496  *             memcpy(buf, writer.buf, writer.size)
1497  *         else:
1498  */
1499         __pyx_r = -1;
1500         goto __pyx_L0;
1501 
1502         /* "aiohttp/_http_writer.pyx":44
1503  *         if writer.buf == BUFFER:
1504  *             buf = <char*>PyMem_Malloc(size)
1505  *             if buf == NULL:             # <<<<<<<<<<<<<<
1506  *                 PyErr_NoMemory()
1507  *                 return -1
1508  */
1509       }
1510 
1511       /* "aiohttp/_http_writer.pyx":47
1512  *                 PyErr_NoMemory()
1513  *                 return -1
1514  *             memcpy(buf, writer.buf, writer.size)             # <<<<<<<<<<<<<<
1515  *         else:
1516  *             buf = <char*>PyMem_Realloc(writer.buf, size)
1517  */
1518       (void)(memcpy(__pyx_v_buf, __pyx_v_writer->buf, __pyx_v_writer->size));
1519 
1520       /* "aiohttp/_http_writer.pyx":42
1521  *         # reallocate
1522  *         size = writer.size + BUF_SIZE
1523  *         if writer.buf == BUFFER:             # <<<<<<<<<<<<<<
1524  *             buf = <char*>PyMem_Malloc(size)
1525  *             if buf == NULL:
1526  */
1527       goto __pyx_L4;
1528     }
1529 
1530     /* "aiohttp/_http_writer.pyx":49
1531  *             memcpy(buf, writer.buf, writer.size)
1532  *         else:
1533  *             buf = <char*>PyMem_Realloc(writer.buf, size)             # <<<<<<<<<<<<<<
1534  *             if buf == NULL:
1535  *                 PyErr_NoMemory()
1536  */
1537     /*else*/ {
1538       __pyx_v_buf = ((char *)PyMem_Realloc(__pyx_v_writer->buf, __pyx_v_size));
1539 
1540       /* "aiohttp/_http_writer.pyx":50
1541  *         else:
1542  *             buf = <char*>PyMem_Realloc(writer.buf, size)
1543  *             if buf == NULL:             # <<<<<<<<<<<<<<
1544  *                 PyErr_NoMemory()
1545  *                 return -1
1546  */
1547       __pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
1548       if (__pyx_t_1) {
1549 
1550         /* "aiohttp/_http_writer.pyx":51
1551  *             buf = <char*>PyMem_Realloc(writer.buf, size)
1552  *             if buf == NULL:
1553  *                 PyErr_NoMemory()             # <<<<<<<<<<<<<<
1554  *                 return -1
1555  *         writer.buf = buf
1556  */
1557         __pyx_t_2 = PyErr_NoMemory(); if (unlikely(__pyx_t_2 == ((PyObject *)NULL))) __PYX_ERR(0, 51, __pyx_L1_error)
1558 
1559         /* "aiohttp/_http_writer.pyx":52
1560  *             if buf == NULL:
1561  *                 PyErr_NoMemory()
1562  *                 return -1             # <<<<<<<<<<<<<<
1563  *         writer.buf = buf
1564  *         writer.size = size
1565  */
1566         __pyx_r = -1;
1567         goto __pyx_L0;
1568 
1569         /* "aiohttp/_http_writer.pyx":50
1570  *         else:
1571  *             buf = <char*>PyMem_Realloc(writer.buf, size)
1572  *             if buf == NULL:             # <<<<<<<<<<<<<<
1573  *                 PyErr_NoMemory()
1574  *                 return -1
1575  */
1576       }
1577     }
1578     __pyx_L4:;
1579 
1580     /* "aiohttp/_http_writer.pyx":53
1581  *                 PyErr_NoMemory()
1582  *                 return -1
1583  *         writer.buf = buf             # <<<<<<<<<<<<<<
1584  *         writer.size = size
1585  *     writer.buf[writer.pos] = <char>ch
1586  */
1587     __pyx_v_writer->buf = __pyx_v_buf;
1588 
1589     /* "aiohttp/_http_writer.pyx":54
1590  *                 return -1
1591  *         writer.buf = buf
1592  *         writer.size = size             # <<<<<<<<<<<<<<
1593  *     writer.buf[writer.pos] = <char>ch
1594  *     writer.pos += 1
1595  */
1596     __pyx_v_writer->size = __pyx_v_size;
1597 
1598     /* "aiohttp/_http_writer.pyx":39
1599  *     cdef Py_ssize_t size
1600  *
1601  *     if writer.pos == writer.size:             # <<<<<<<<<<<<<<
1602  *         # reallocate
1603  *         size = writer.size + BUF_SIZE
1604  */
1605   }
1606 
1607   /* "aiohttp/_http_writer.pyx":55
1608  *         writer.buf = buf
1609  *         writer.size = size
1610  *     writer.buf[writer.pos] = <char>ch             # <<<<<<<<<<<<<<
1611  *     writer.pos += 1
1612  *     return 0
1613  */
1614   (__pyx_v_writer->buf[__pyx_v_writer->pos]) = ((char)__pyx_v_ch);
1615 
1616   /* "aiohttp/_http_writer.pyx":56
1617  *         writer.size = size
1618  *     writer.buf[writer.pos] = <char>ch
1619  *     writer.pos += 1             # <<<<<<<<<<<<<<
1620  *     return 0
1621  *
1622  */
1623   __pyx_v_writer->pos = (__pyx_v_writer->pos + 1);
1624 
1625   /* "aiohttp/_http_writer.pyx":57
1626  *     writer.buf[writer.pos] = <char>ch
1627  *     writer.pos += 1
1628  *     return 0             # <<<<<<<<<<<<<<
1629  *
1630  *
1631  */
1632   __pyx_r = 0;
1633   goto __pyx_L0;
1634 
1635   /* "aiohttp/_http_writer.pyx":35
1636  *
1637  *
1638  * cdef inline int _write_byte(Writer* writer, uint8_t ch):             # <<<<<<<<<<<<<<
1639  *     cdef char * buf
1640  *     cdef Py_ssize_t size
1641  */
1642 
1643   /* function exit code */
1644   __pyx_L1_error:;
1645   __Pyx_WriteUnraisable("aiohttp._http_writer._write_byte", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
1646   __pyx_r = 0;
1647   __pyx_L0:;
1648   __Pyx_RefNannyFinishContext();
1649   return __pyx_r;
1650 }
1651 
1652 /* "aiohttp/_http_writer.pyx":60
1653  *
1654  *
1655  * cdef inline int _write_utf8(Writer* writer, Py_UCS4 symbol):             # <<<<<<<<<<<<<<
1656  *     cdef uint64_t utf = <uint64_t> symbol
1657  *
1658  */
1659 
__pyx_f_7aiohttp_12_http_writer__write_utf8(struct __pyx_t_7aiohttp_12_http_writer_Writer * __pyx_v_writer,Py_UCS4 __pyx_v_symbol)1660 static CYTHON_INLINE int __pyx_f_7aiohttp_12_http_writer__write_utf8(struct __pyx_t_7aiohttp_12_http_writer_Writer *__pyx_v_writer, Py_UCS4 __pyx_v_symbol) {
1661   uint64_t __pyx_v_utf;
1662   int __pyx_r;
1663   __Pyx_RefNannyDeclarations
1664   int __pyx_t_1;
1665   int __pyx_t_2;
1666   __Pyx_RefNannySetupContext("_write_utf8", 0);
1667 
1668   /* "aiohttp/_http_writer.pyx":61
1669  *
1670  * cdef inline int _write_utf8(Writer* writer, Py_UCS4 symbol):
1671  *     cdef uint64_t utf = <uint64_t> symbol             # <<<<<<<<<<<<<<
1672  *
1673  *     if utf < 0x80:
1674  */
1675   __pyx_v_utf = ((uint64_t)__pyx_v_symbol);
1676 
1677   /* "aiohttp/_http_writer.pyx":63
1678  *     cdef uint64_t utf = <uint64_t> symbol
1679  *
1680  *     if utf < 0x80:             # <<<<<<<<<<<<<<
1681  *         return _write_byte(writer, <uint8_t>utf)
1682  *     elif utf < 0x800:
1683  */
1684   __pyx_t_1 = ((__pyx_v_utf < 0x80) != 0);
1685   if (__pyx_t_1) {
1686 
1687     /* "aiohttp/_http_writer.pyx":64
1688  *
1689  *     if utf < 0x80:
1690  *         return _write_byte(writer, <uint8_t>utf)             # <<<<<<<<<<<<<<
1691  *     elif utf < 0x800:
1692  *         if _write_byte(writer, <uint8_t>(0xc0 | (utf >> 6))) < 0:
1693  */
1694     __pyx_r = __pyx_f_7aiohttp_12_http_writer__write_byte(__pyx_v_writer, ((uint8_t)__pyx_v_utf));
1695     goto __pyx_L0;
1696 
1697     /* "aiohttp/_http_writer.pyx":63
1698  *     cdef uint64_t utf = <uint64_t> symbol
1699  *
1700  *     if utf < 0x80:             # <<<<<<<<<<<<<<
1701  *         return _write_byte(writer, <uint8_t>utf)
1702  *     elif utf < 0x800:
1703  */
1704   }
1705 
1706   /* "aiohttp/_http_writer.pyx":65
1707  *     if utf < 0x80:
1708  *         return _write_byte(writer, <uint8_t>utf)
1709  *     elif utf < 0x800:             # <<<<<<<<<<<<<<
1710  *         if _write_byte(writer, <uint8_t>(0xc0 | (utf >> 6))) < 0:
1711  *             return -1
1712  */
1713   __pyx_t_1 = ((__pyx_v_utf < 0x800) != 0);
1714   if (__pyx_t_1) {
1715 
1716     /* "aiohttp/_http_writer.pyx":66
1717  *         return _write_byte(writer, <uint8_t>utf)
1718  *     elif utf < 0x800:
1719  *         if _write_byte(writer, <uint8_t>(0xc0 | (utf >> 6))) < 0:             # <<<<<<<<<<<<<<
1720  *             return -1
1721  *         return _write_byte(writer,  <uint8_t>(0x80 | (utf & 0x3f)))
1722  */
1723     __pyx_t_1 = ((__pyx_f_7aiohttp_12_http_writer__write_byte(__pyx_v_writer, ((uint8_t)(0xc0 | (__pyx_v_utf >> 6)))) < 0) != 0);
1724     if (__pyx_t_1) {
1725 
1726       /* "aiohttp/_http_writer.pyx":67
1727  *     elif utf < 0x800:
1728  *         if _write_byte(writer, <uint8_t>(0xc0 | (utf >> 6))) < 0:
1729  *             return -1             # <<<<<<<<<<<<<<
1730  *         return _write_byte(writer,  <uint8_t>(0x80 | (utf & 0x3f)))
1731  *     elif 0xD800 <= utf <= 0xDFFF:
1732  */
1733       __pyx_r = -1;
1734       goto __pyx_L0;
1735 
1736       /* "aiohttp/_http_writer.pyx":66
1737  *         return _write_byte(writer, <uint8_t>utf)
1738  *     elif utf < 0x800:
1739  *         if _write_byte(writer, <uint8_t>(0xc0 | (utf >> 6))) < 0:             # <<<<<<<<<<<<<<
1740  *             return -1
1741  *         return _write_byte(writer,  <uint8_t>(0x80 | (utf & 0x3f)))
1742  */
1743     }
1744 
1745     /* "aiohttp/_http_writer.pyx":68
1746  *         if _write_byte(writer, <uint8_t>(0xc0 | (utf >> 6))) < 0:
1747  *             return -1
1748  *         return _write_byte(writer,  <uint8_t>(0x80 | (utf & 0x3f)))             # <<<<<<<<<<<<<<
1749  *     elif 0xD800 <= utf <= 0xDFFF:
1750  *         # surogate pair, ignored
1751  */
1752     __pyx_r = __pyx_f_7aiohttp_12_http_writer__write_byte(__pyx_v_writer, ((uint8_t)(0x80 | (__pyx_v_utf & 0x3f))));
1753     goto __pyx_L0;
1754 
1755     /* "aiohttp/_http_writer.pyx":65
1756  *     if utf < 0x80:
1757  *         return _write_byte(writer, <uint8_t>utf)
1758  *     elif utf < 0x800:             # <<<<<<<<<<<<<<
1759  *         if _write_byte(writer, <uint8_t>(0xc0 | (utf >> 6))) < 0:
1760  *             return -1
1761  */
1762   }
1763 
1764   /* "aiohttp/_http_writer.pyx":69
1765  *             return -1
1766  *         return _write_byte(writer,  <uint8_t>(0x80 | (utf & 0x3f)))
1767  *     elif 0xD800 <= utf <= 0xDFFF:             # <<<<<<<<<<<<<<
1768  *         # surogate pair, ignored
1769  *         return 0
1770  */
1771   __pyx_t_1 = (0xD800 <= __pyx_v_utf);
1772   if (__pyx_t_1) {
1773     __pyx_t_1 = (__pyx_v_utf <= 0xDFFF);
1774   }
1775   __pyx_t_2 = (__pyx_t_1 != 0);
1776   if (__pyx_t_2) {
1777 
1778     /* "aiohttp/_http_writer.pyx":71
1779  *     elif 0xD800 <= utf <= 0xDFFF:
1780  *         # surogate pair, ignored
1781  *         return 0             # <<<<<<<<<<<<<<
1782  *     elif utf < 0x10000:
1783  *         if _write_byte(writer, <uint8_t>(0xe0 | (utf >> 12))) < 0:
1784  */
1785     __pyx_r = 0;
1786     goto __pyx_L0;
1787 
1788     /* "aiohttp/_http_writer.pyx":69
1789  *             return -1
1790  *         return _write_byte(writer,  <uint8_t>(0x80 | (utf & 0x3f)))
1791  *     elif 0xD800 <= utf <= 0xDFFF:             # <<<<<<<<<<<<<<
1792  *         # surogate pair, ignored
1793  *         return 0
1794  */
1795   }
1796 
1797   /* "aiohttp/_http_writer.pyx":72
1798  *         # surogate pair, ignored
1799  *         return 0
1800  *     elif utf < 0x10000:             # <<<<<<<<<<<<<<
1801  *         if _write_byte(writer, <uint8_t>(0xe0 | (utf >> 12))) < 0:
1802  *             return -1
1803  */
1804   __pyx_t_2 = ((__pyx_v_utf < 0x10000) != 0);
1805   if (__pyx_t_2) {
1806 
1807     /* "aiohttp/_http_writer.pyx":73
1808  *         return 0
1809  *     elif utf < 0x10000:
1810  *         if _write_byte(writer, <uint8_t>(0xe0 | (utf >> 12))) < 0:             # <<<<<<<<<<<<<<
1811  *             return -1
1812  *         if _write_byte(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f))) < 0:
1813  */
1814     __pyx_t_2 = ((__pyx_f_7aiohttp_12_http_writer__write_byte(__pyx_v_writer, ((uint8_t)(0xe0 | (__pyx_v_utf >> 12)))) < 0) != 0);
1815     if (__pyx_t_2) {
1816 
1817       /* "aiohttp/_http_writer.pyx":74
1818  *     elif utf < 0x10000:
1819  *         if _write_byte(writer, <uint8_t>(0xe0 | (utf >> 12))) < 0:
1820  *             return -1             # <<<<<<<<<<<<<<
1821  *         if _write_byte(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f))) < 0:
1822  *             return -1
1823  */
1824       __pyx_r = -1;
1825       goto __pyx_L0;
1826 
1827       /* "aiohttp/_http_writer.pyx":73
1828  *         return 0
1829  *     elif utf < 0x10000:
1830  *         if _write_byte(writer, <uint8_t>(0xe0 | (utf >> 12))) < 0:             # <<<<<<<<<<<<<<
1831  *             return -1
1832  *         if _write_byte(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f))) < 0:
1833  */
1834     }
1835 
1836     /* "aiohttp/_http_writer.pyx":75
1837  *         if _write_byte(writer, <uint8_t>(0xe0 | (utf >> 12))) < 0:
1838  *             return -1
1839  *         if _write_byte(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f))) < 0:             # <<<<<<<<<<<<<<
1840  *             return -1
1841  *         return _write_byte(writer, <uint8_t>(0x80 | (utf & 0x3f)))
1842  */
1843     __pyx_t_2 = ((__pyx_f_7aiohttp_12_http_writer__write_byte(__pyx_v_writer, ((uint8_t)(0x80 | ((__pyx_v_utf >> 6) & 0x3f)))) < 0) != 0);
1844     if (__pyx_t_2) {
1845 
1846       /* "aiohttp/_http_writer.pyx":76
1847  *             return -1
1848  *         if _write_byte(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f))) < 0:
1849  *             return -1             # <<<<<<<<<<<<<<
1850  *         return _write_byte(writer, <uint8_t>(0x80 | (utf & 0x3f)))
1851  *     elif utf > 0x10FFFF:
1852  */
1853       __pyx_r = -1;
1854       goto __pyx_L0;
1855 
1856       /* "aiohttp/_http_writer.pyx":75
1857  *         if _write_byte(writer, <uint8_t>(0xe0 | (utf >> 12))) < 0:
1858  *             return -1
1859  *         if _write_byte(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f))) < 0:             # <<<<<<<<<<<<<<
1860  *             return -1
1861  *         return _write_byte(writer, <uint8_t>(0x80 | (utf & 0x3f)))
1862  */
1863     }
1864 
1865     /* "aiohttp/_http_writer.pyx":77
1866  *         if _write_byte(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f))) < 0:
1867  *             return -1
1868  *         return _write_byte(writer, <uint8_t>(0x80 | (utf & 0x3f)))             # <<<<<<<<<<<<<<
1869  *     elif utf > 0x10FFFF:
1870  *         # symbol is too large
1871  */
1872     __pyx_r = __pyx_f_7aiohttp_12_http_writer__write_byte(__pyx_v_writer, ((uint8_t)(0x80 | (__pyx_v_utf & 0x3f))));
1873     goto __pyx_L0;
1874 
1875     /* "aiohttp/_http_writer.pyx":72
1876  *         # surogate pair, ignored
1877  *         return 0
1878  *     elif utf < 0x10000:             # <<<<<<<<<<<<<<
1879  *         if _write_byte(writer, <uint8_t>(0xe0 | (utf >> 12))) < 0:
1880  *             return -1
1881  */
1882   }
1883 
1884   /* "aiohttp/_http_writer.pyx":78
1885  *             return -1
1886  *         return _write_byte(writer, <uint8_t>(0x80 | (utf & 0x3f)))
1887  *     elif utf > 0x10FFFF:             # <<<<<<<<<<<<<<
1888  *         # symbol is too large
1889  *         return 0
1890  */
1891   __pyx_t_2 = ((__pyx_v_utf > 0x10FFFF) != 0);
1892   if (__pyx_t_2) {
1893 
1894     /* "aiohttp/_http_writer.pyx":80
1895  *     elif utf > 0x10FFFF:
1896  *         # symbol is too large
1897  *         return 0             # <<<<<<<<<<<<<<
1898  *     else:
1899  *         if _write_byte(writer,  <uint8_t>(0xf0 | (utf >> 18))) < 0:
1900  */
1901     __pyx_r = 0;
1902     goto __pyx_L0;
1903 
1904     /* "aiohttp/_http_writer.pyx":78
1905  *             return -1
1906  *         return _write_byte(writer, <uint8_t>(0x80 | (utf & 0x3f)))
1907  *     elif utf > 0x10FFFF:             # <<<<<<<<<<<<<<
1908  *         # symbol is too large
1909  *         return 0
1910  */
1911   }
1912 
1913   /* "aiohttp/_http_writer.pyx":82
1914  *         return 0
1915  *     else:
1916  *         if _write_byte(writer,  <uint8_t>(0xf0 | (utf >> 18))) < 0:             # <<<<<<<<<<<<<<
1917  *             return -1
1918  *         if _write_byte(writer,
1919  */
1920   /*else*/ {
1921     __pyx_t_2 = ((__pyx_f_7aiohttp_12_http_writer__write_byte(__pyx_v_writer, ((uint8_t)(0xf0 | (__pyx_v_utf >> 18)))) < 0) != 0);
1922     if (__pyx_t_2) {
1923 
1924       /* "aiohttp/_http_writer.pyx":83
1925  *     else:
1926  *         if _write_byte(writer,  <uint8_t>(0xf0 | (utf >> 18))) < 0:
1927  *             return -1             # <<<<<<<<<<<<<<
1928  *         if _write_byte(writer,
1929  *                        <uint8_t>(0x80 | ((utf >> 12) & 0x3f))) < 0:
1930  */
1931       __pyx_r = -1;
1932       goto __pyx_L0;
1933 
1934       /* "aiohttp/_http_writer.pyx":82
1935  *         return 0
1936  *     else:
1937  *         if _write_byte(writer,  <uint8_t>(0xf0 | (utf >> 18))) < 0:             # <<<<<<<<<<<<<<
1938  *             return -1
1939  *         if _write_byte(writer,
1940  */
1941     }
1942 
1943     /* "aiohttp/_http_writer.pyx":85
1944  *             return -1
1945  *         if _write_byte(writer,
1946  *                        <uint8_t>(0x80 | ((utf >> 12) & 0x3f))) < 0:             # <<<<<<<<<<<<<<
1947  *            return -1
1948  *         if _write_byte(writer,
1949  */
1950     __pyx_t_2 = ((__pyx_f_7aiohttp_12_http_writer__write_byte(__pyx_v_writer, ((uint8_t)(0x80 | ((__pyx_v_utf >> 12) & 0x3f)))) < 0) != 0);
1951 
1952     /* "aiohttp/_http_writer.pyx":84
1953  *         if _write_byte(writer,  <uint8_t>(0xf0 | (utf >> 18))) < 0:
1954  *             return -1
1955  *         if _write_byte(writer,             # <<<<<<<<<<<<<<
1956  *                        <uint8_t>(0x80 | ((utf >> 12) & 0x3f))) < 0:
1957  *            return -1
1958  */
1959     if (__pyx_t_2) {
1960 
1961       /* "aiohttp/_http_writer.pyx":86
1962  *         if _write_byte(writer,
1963  *                        <uint8_t>(0x80 | ((utf >> 12) & 0x3f))) < 0:
1964  *            return -1             # <<<<<<<<<<<<<<
1965  *         if _write_byte(writer,
1966  *                        <uint8_t>(0x80 | ((utf >> 6) & 0x3f))) < 0:
1967  */
1968       __pyx_r = -1;
1969       goto __pyx_L0;
1970 
1971       /* "aiohttp/_http_writer.pyx":84
1972  *         if _write_byte(writer,  <uint8_t>(0xf0 | (utf >> 18))) < 0:
1973  *             return -1
1974  *         if _write_byte(writer,             # <<<<<<<<<<<<<<
1975  *                        <uint8_t>(0x80 | ((utf >> 12) & 0x3f))) < 0:
1976  *            return -1
1977  */
1978     }
1979 
1980     /* "aiohttp/_http_writer.pyx":88
1981  *            return -1
1982  *         if _write_byte(writer,
1983  *                        <uint8_t>(0x80 | ((utf >> 6) & 0x3f))) < 0:             # <<<<<<<<<<<<<<
1984  *             return -1
1985  *         return _write_byte(writer, <uint8_t>(0x80 | (utf & 0x3f)))
1986  */
1987     __pyx_t_2 = ((__pyx_f_7aiohttp_12_http_writer__write_byte(__pyx_v_writer, ((uint8_t)(0x80 | ((__pyx_v_utf >> 6) & 0x3f)))) < 0) != 0);
1988 
1989     /* "aiohttp/_http_writer.pyx":87
1990  *                        <uint8_t>(0x80 | ((utf >> 12) & 0x3f))) < 0:
1991  *            return -1
1992  *         if _write_byte(writer,             # <<<<<<<<<<<<<<
1993  *                        <uint8_t>(0x80 | ((utf >> 6) & 0x3f))) < 0:
1994  *             return -1
1995  */
1996     if (__pyx_t_2) {
1997 
1998       /* "aiohttp/_http_writer.pyx":89
1999  *         if _write_byte(writer,
2000  *                        <uint8_t>(0x80 | ((utf >> 6) & 0x3f))) < 0:
2001  *             return -1             # <<<<<<<<<<<<<<
2002  *         return _write_byte(writer, <uint8_t>(0x80 | (utf & 0x3f)))
2003  *
2004  */
2005       __pyx_r = -1;
2006       goto __pyx_L0;
2007 
2008       /* "aiohttp/_http_writer.pyx":87
2009  *                        <uint8_t>(0x80 | ((utf >> 12) & 0x3f))) < 0:
2010  *            return -1
2011  *         if _write_byte(writer,             # <<<<<<<<<<<<<<
2012  *                        <uint8_t>(0x80 | ((utf >> 6) & 0x3f))) < 0:
2013  *             return -1
2014  */
2015     }
2016 
2017     /* "aiohttp/_http_writer.pyx":90
2018  *                        <uint8_t>(0x80 | ((utf >> 6) & 0x3f))) < 0:
2019  *             return -1
2020  *         return _write_byte(writer, <uint8_t>(0x80 | (utf & 0x3f)))             # <<<<<<<<<<<<<<
2021  *
2022  *
2023  */
2024     __pyx_r = __pyx_f_7aiohttp_12_http_writer__write_byte(__pyx_v_writer, ((uint8_t)(0x80 | (__pyx_v_utf & 0x3f))));
2025     goto __pyx_L0;
2026   }
2027 
2028   /* "aiohttp/_http_writer.pyx":60
2029  *
2030  *
2031  * cdef inline int _write_utf8(Writer* writer, Py_UCS4 symbol):             # <<<<<<<<<<<<<<
2032  *     cdef uint64_t utf = <uint64_t> symbol
2033  *
2034  */
2035 
2036   /* function exit code */
2037   __pyx_L0:;
2038   __Pyx_RefNannyFinishContext();
2039   return __pyx_r;
2040 }
2041 
2042 /* "aiohttp/_http_writer.pyx":93
2043  *
2044  *
2045  * cdef inline int _write_str(Writer* writer, str s):             # <<<<<<<<<<<<<<
2046  *     cdef Py_UCS4 ch
2047  *     for ch in s:
2048  */
2049 
__pyx_f_7aiohttp_12_http_writer__write_str(struct __pyx_t_7aiohttp_12_http_writer_Writer * __pyx_v_writer,PyObject * __pyx_v_s)2050 static CYTHON_INLINE int __pyx_f_7aiohttp_12_http_writer__write_str(struct __pyx_t_7aiohttp_12_http_writer_Writer *__pyx_v_writer, PyObject *__pyx_v_s) {
2051   Py_UCS4 __pyx_v_ch;
2052   int __pyx_r;
2053   __Pyx_RefNannyDeclarations
2054   PyObject *__pyx_t_1 = NULL;
2055   Py_ssize_t __pyx_t_2;
2056   Py_ssize_t __pyx_t_3;
2057   void *__pyx_t_4;
2058   int __pyx_t_5;
2059   int __pyx_t_6;
2060   Py_ssize_t __pyx_t_7;
2061   int __pyx_t_8;
2062   int __pyx_lineno = 0;
2063   const char *__pyx_filename = NULL;
2064   int __pyx_clineno = 0;
2065   __Pyx_RefNannySetupContext("_write_str", 0);
2066 
2067   /* "aiohttp/_http_writer.pyx":95
2068  * cdef inline int _write_str(Writer* writer, str s):
2069  *     cdef Py_UCS4 ch
2070  *     for ch in s:             # <<<<<<<<<<<<<<
2071  *         if _write_utf8(writer, ch) < 0:
2072  *             return -1
2073  */
2074   if (unlikely(__pyx_v_s == Py_None)) {
2075     PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
2076     __PYX_ERR(0, 95, __pyx_L1_error)
2077   }
2078   __Pyx_INCREF(__pyx_v_s);
2079   __pyx_t_1 = __pyx_v_s;
2080   __pyx_t_6 = __Pyx_init_unicode_iteration(__pyx_t_1, (&__pyx_t_3), (&__pyx_t_4), (&__pyx_t_5)); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 95, __pyx_L1_error)
2081   for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_3; __pyx_t_7++) {
2082     __pyx_t_2 = __pyx_t_7;
2083     __pyx_v_ch = __Pyx_PyUnicode_READ(__pyx_t_5, __pyx_t_4, __pyx_t_2);
2084 
2085     /* "aiohttp/_http_writer.pyx":96
2086  *     cdef Py_UCS4 ch
2087  *     for ch in s:
2088  *         if _write_utf8(writer, ch) < 0:             # <<<<<<<<<<<<<<
2089  *             return -1
2090  *
2091  */
2092     __pyx_t_8 = ((__pyx_f_7aiohttp_12_http_writer__write_utf8(__pyx_v_writer, __pyx_v_ch) < 0) != 0);
2093     if (__pyx_t_8) {
2094 
2095       /* "aiohttp/_http_writer.pyx":97
2096  *     for ch in s:
2097  *         if _write_utf8(writer, ch) < 0:
2098  *             return -1             # <<<<<<<<<<<<<<
2099  *
2100  *
2101  */
2102       __pyx_r = -1;
2103       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2104       goto __pyx_L0;
2105 
2106       /* "aiohttp/_http_writer.pyx":96
2107  *     cdef Py_UCS4 ch
2108  *     for ch in s:
2109  *         if _write_utf8(writer, ch) < 0:             # <<<<<<<<<<<<<<
2110  *             return -1
2111  *
2112  */
2113     }
2114   }
2115   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2116 
2117   /* "aiohttp/_http_writer.pyx":93
2118  *
2119  *
2120  * cdef inline int _write_str(Writer* writer, str s):             # <<<<<<<<<<<<<<
2121  *     cdef Py_UCS4 ch
2122  *     for ch in s:
2123  */
2124 
2125   /* function exit code */
2126   __pyx_r = 0;
2127   goto __pyx_L0;
2128   __pyx_L1_error:;
2129   __Pyx_XDECREF(__pyx_t_1);
2130   __Pyx_WriteUnraisable("aiohttp._http_writer._write_str", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
2131   __pyx_r = 0;
2132   __pyx_L0:;
2133   __Pyx_RefNannyFinishContext();
2134   return __pyx_r;
2135 }
2136 
2137 /* "aiohttp/_http_writer.pyx":102
2138  * # --------------- _serialize_headers ----------------------
2139  *
2140  * cdef str to_str(object s):             # <<<<<<<<<<<<<<
2141  *     typ = type(s)
2142  *     if typ is str:
2143  */
2144 
__pyx_f_7aiohttp_12_http_writer_to_str(PyObject * __pyx_v_s)2145 static PyObject *__pyx_f_7aiohttp_12_http_writer_to_str(PyObject *__pyx_v_s) {
2146   PyTypeObject *__pyx_v_typ = NULL;
2147   PyObject *__pyx_r = NULL;
2148   __Pyx_RefNannyDeclarations
2149   int __pyx_t_1;
2150   int __pyx_t_2;
2151   PyObject *__pyx_t_3 = NULL;
2152   PyObject *__pyx_t_4 = NULL;
2153   PyObject *__pyx_t_5 = NULL;
2154   int __pyx_lineno = 0;
2155   const char *__pyx_filename = NULL;
2156   int __pyx_clineno = 0;
2157   __Pyx_RefNannySetupContext("to_str", 0);
2158 
2159   /* "aiohttp/_http_writer.pyx":103
2160  *
2161  * cdef str to_str(object s):
2162  *     typ = type(s)             # <<<<<<<<<<<<<<
2163  *     if typ is str:
2164  *         return <str>s
2165  */
2166   __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_s)));
2167   __pyx_v_typ = ((PyTypeObject*)((PyObject *)Py_TYPE(__pyx_v_s)));
2168 
2169   /* "aiohttp/_http_writer.pyx":104
2170  * cdef str to_str(object s):
2171  *     typ = type(s)
2172  *     if typ is str:             # <<<<<<<<<<<<<<
2173  *         return <str>s
2174  *     elif typ is _istr:
2175  */
2176   __pyx_t_1 = (__pyx_v_typ == (&PyUnicode_Type));
2177   __pyx_t_2 = (__pyx_t_1 != 0);
2178   if (__pyx_t_2) {
2179 
2180     /* "aiohttp/_http_writer.pyx":105
2181  *     typ = type(s)
2182  *     if typ is str:
2183  *         return <str>s             # <<<<<<<<<<<<<<
2184  *     elif typ is _istr:
2185  *         return PyObject_Str(s)
2186  */
2187     __Pyx_XDECREF(__pyx_r);
2188     __Pyx_INCREF(((PyObject*)__pyx_v_s));
2189     __pyx_r = ((PyObject*)__pyx_v_s);
2190     goto __pyx_L0;
2191 
2192     /* "aiohttp/_http_writer.pyx":104
2193  * cdef str to_str(object s):
2194  *     typ = type(s)
2195  *     if typ is str:             # <<<<<<<<<<<<<<
2196  *         return <str>s
2197  *     elif typ is _istr:
2198  */
2199   }
2200 
2201   /* "aiohttp/_http_writer.pyx":106
2202  *     if typ is str:
2203  *         return <str>s
2204  *     elif typ is _istr:             # <<<<<<<<<<<<<<
2205  *         return PyObject_Str(s)
2206  *     elif not isinstance(s, str):
2207  */
2208   __pyx_t_2 = (__pyx_v_typ == ((PyTypeObject*)__pyx_v_7aiohttp_12_http_writer__istr));
2209   __pyx_t_1 = (__pyx_t_2 != 0);
2210   if (__pyx_t_1) {
2211 
2212     /* "aiohttp/_http_writer.pyx":107
2213  *         return <str>s
2214  *     elif typ is _istr:
2215  *         return PyObject_Str(s)             # <<<<<<<<<<<<<<
2216  *     elif not isinstance(s, str):
2217  *         raise TypeError("Cannot serialize non-str key {!r}".format(s))
2218  */
2219     __Pyx_XDECREF(__pyx_r);
2220     __pyx_t_3 = PyObject_Str(__pyx_v_s); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 107, __pyx_L1_error)
2221     __Pyx_GOTREF(__pyx_t_3);
2222     if (!(likely(PyUnicode_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 107, __pyx_L1_error)
2223     __pyx_r = ((PyObject*)__pyx_t_3);
2224     __pyx_t_3 = 0;
2225     goto __pyx_L0;
2226 
2227     /* "aiohttp/_http_writer.pyx":106
2228  *     if typ is str:
2229  *         return <str>s
2230  *     elif typ is _istr:             # <<<<<<<<<<<<<<
2231  *         return PyObject_Str(s)
2232  *     elif not isinstance(s, str):
2233  */
2234   }
2235 
2236   /* "aiohttp/_http_writer.pyx":108
2237  *     elif typ is _istr:
2238  *         return PyObject_Str(s)
2239  *     elif not isinstance(s, str):             # <<<<<<<<<<<<<<
2240  *         raise TypeError("Cannot serialize non-str key {!r}".format(s))
2241  *     else:
2242  */
2243   __pyx_t_1 = PyUnicode_Check(__pyx_v_s);
2244   __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
2245   if (unlikely(__pyx_t_2)) {
2246 
2247     /* "aiohttp/_http_writer.pyx":109
2248  *         return PyObject_Str(s)
2249  *     elif not isinstance(s, str):
2250  *         raise TypeError("Cannot serialize non-str key {!r}".format(s))             # <<<<<<<<<<<<<<
2251  *     else:
2252  *         return str(s)
2253  */
2254     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Cannot_serialize_non_str_key_r, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 109, __pyx_L1_error)
2255     __Pyx_GOTREF(__pyx_t_4);
2256     __pyx_t_5 = NULL;
2257     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
2258       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
2259       if (likely(__pyx_t_5)) {
2260         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
2261         __Pyx_INCREF(__pyx_t_5);
2262         __Pyx_INCREF(function);
2263         __Pyx_DECREF_SET(__pyx_t_4, function);
2264       }
2265     }
2266     __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_s) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_s);
2267     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2268     if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 109, __pyx_L1_error)
2269     __Pyx_GOTREF(__pyx_t_3);
2270     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2271     __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 109, __pyx_L1_error)
2272     __Pyx_GOTREF(__pyx_t_4);
2273     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2274     __Pyx_Raise(__pyx_t_4, 0, 0, 0);
2275     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2276     __PYX_ERR(0, 109, __pyx_L1_error)
2277 
2278     /* "aiohttp/_http_writer.pyx":108
2279  *     elif typ is _istr:
2280  *         return PyObject_Str(s)
2281  *     elif not isinstance(s, str):             # <<<<<<<<<<<<<<
2282  *         raise TypeError("Cannot serialize non-str key {!r}".format(s))
2283  *     else:
2284  */
2285   }
2286 
2287   /* "aiohttp/_http_writer.pyx":111
2288  *         raise TypeError("Cannot serialize non-str key {!r}".format(s))
2289  *     else:
2290  *         return str(s)             # <<<<<<<<<<<<<<
2291  *
2292  *
2293  */
2294   /*else*/ {
2295     __Pyx_XDECREF(__pyx_r);
2296     __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_s); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 111, __pyx_L1_error)
2297     __Pyx_GOTREF(__pyx_t_4);
2298     __pyx_r = ((PyObject*)__pyx_t_4);
2299     __pyx_t_4 = 0;
2300     goto __pyx_L0;
2301   }
2302 
2303   /* "aiohttp/_http_writer.pyx":102
2304  * # --------------- _serialize_headers ----------------------
2305  *
2306  * cdef str to_str(object s):             # <<<<<<<<<<<<<<
2307  *     typ = type(s)
2308  *     if typ is str:
2309  */
2310 
2311   /* function exit code */
2312   __pyx_L1_error:;
2313   __Pyx_XDECREF(__pyx_t_3);
2314   __Pyx_XDECREF(__pyx_t_4);
2315   __Pyx_XDECREF(__pyx_t_5);
2316   __Pyx_AddTraceback("aiohttp._http_writer.to_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
2317   __pyx_r = 0;
2318   __pyx_L0:;
2319   __Pyx_XDECREF(__pyx_v_typ);
2320   __Pyx_XGIVEREF(__pyx_r);
2321   __Pyx_RefNannyFinishContext();
2322   return __pyx_r;
2323 }
2324 
2325 /* "aiohttp/_http_writer.pyx":114
2326  *
2327  *
2328  * def _serialize_headers(str status_line, headers):             # <<<<<<<<<<<<<<
2329  *     cdef Writer writer
2330  *     cdef object key
2331  */
2332 
2333 /* Python wrapper */
2334 static PyObject *__pyx_pw_7aiohttp_12_http_writer_1_serialize_headers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2335 static PyMethodDef __pyx_mdef_7aiohttp_12_http_writer_1_serialize_headers = {"_serialize_headers", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7aiohttp_12_http_writer_1_serialize_headers, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_7aiohttp_12_http_writer_1_serialize_headers(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)2336 static PyObject *__pyx_pw_7aiohttp_12_http_writer_1_serialize_headers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2337   PyObject *__pyx_v_status_line = 0;
2338   PyObject *__pyx_v_headers = 0;
2339   int __pyx_lineno = 0;
2340   const char *__pyx_filename = NULL;
2341   int __pyx_clineno = 0;
2342   PyObject *__pyx_r = 0;
2343   __Pyx_RefNannyDeclarations
2344   __Pyx_RefNannySetupContext("_serialize_headers (wrapper)", 0);
2345   {
2346     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_status_line,&__pyx_n_s_headers,0};
2347     PyObject* values[2] = {0,0};
2348     if (unlikely(__pyx_kwds)) {
2349       Py_ssize_t kw_args;
2350       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2351       switch (pos_args) {
2352         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2353         CYTHON_FALLTHROUGH;
2354         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2355         CYTHON_FALLTHROUGH;
2356         case  0: break;
2357         default: goto __pyx_L5_argtuple_error;
2358       }
2359       kw_args = PyDict_Size(__pyx_kwds);
2360       switch (pos_args) {
2361         case  0:
2362         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_status_line)) != 0)) kw_args--;
2363         else goto __pyx_L5_argtuple_error;
2364         CYTHON_FALLTHROUGH;
2365         case  1:
2366         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_headers)) != 0)) kw_args--;
2367         else {
2368           __Pyx_RaiseArgtupleInvalid("_serialize_headers", 1, 2, 2, 1); __PYX_ERR(0, 114, __pyx_L3_error)
2369         }
2370       }
2371       if (unlikely(kw_args > 0)) {
2372         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_serialize_headers") < 0)) __PYX_ERR(0, 114, __pyx_L3_error)
2373       }
2374     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
2375       goto __pyx_L5_argtuple_error;
2376     } else {
2377       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2378       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2379     }
2380     __pyx_v_status_line = ((PyObject*)values[0]);
2381     __pyx_v_headers = values[1];
2382   }
2383   goto __pyx_L4_argument_unpacking_done;
2384   __pyx_L5_argtuple_error:;
2385   __Pyx_RaiseArgtupleInvalid("_serialize_headers", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 114, __pyx_L3_error)
2386   __pyx_L3_error:;
2387   __Pyx_AddTraceback("aiohttp._http_writer._serialize_headers", __pyx_clineno, __pyx_lineno, __pyx_filename);
2388   __Pyx_RefNannyFinishContext();
2389   return NULL;
2390   __pyx_L4_argument_unpacking_done:;
2391   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_status_line), (&PyUnicode_Type), 1, "status_line", 1))) __PYX_ERR(0, 114, __pyx_L1_error)
2392   __pyx_r = __pyx_pf_7aiohttp_12_http_writer__serialize_headers(__pyx_self, __pyx_v_status_line, __pyx_v_headers);
2393 
2394   /* function exit code */
2395   goto __pyx_L0;
2396   __pyx_L1_error:;
2397   __pyx_r = NULL;
2398   __pyx_L0:;
2399   __Pyx_RefNannyFinishContext();
2400   return __pyx_r;
2401 }
2402 
__pyx_pf_7aiohttp_12_http_writer__serialize_headers(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_status_line,PyObject * __pyx_v_headers)2403 static PyObject *__pyx_pf_7aiohttp_12_http_writer__serialize_headers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_status_line, PyObject *__pyx_v_headers) {
2404   struct __pyx_t_7aiohttp_12_http_writer_Writer __pyx_v_writer;
2405   PyObject *__pyx_v_key = 0;
2406   PyObject *__pyx_v_val = 0;
2407   PyObject *__pyx_r = NULL;
2408   __Pyx_RefNannyDeclarations
2409   int __pyx_t_1;
2410   PyObject *__pyx_t_2 = NULL;
2411   Py_ssize_t __pyx_t_3;
2412   Py_ssize_t __pyx_t_4;
2413   int __pyx_t_5;
2414   PyObject *__pyx_t_6 = NULL;
2415   PyObject *__pyx_t_7 = NULL;
2416   int __pyx_t_8;
2417   char const *__pyx_t_9;
2418   PyObject *__pyx_t_10 = NULL;
2419   PyObject *__pyx_t_11 = NULL;
2420   PyObject *__pyx_t_12 = NULL;
2421   PyObject *__pyx_t_13 = NULL;
2422   PyObject *__pyx_t_14 = NULL;
2423   PyObject *__pyx_t_15 = NULL;
2424   int __pyx_lineno = 0;
2425   const char *__pyx_filename = NULL;
2426   int __pyx_clineno = 0;
2427   __Pyx_RefNannySetupContext("_serialize_headers", 0);
2428 
2429   /* "aiohttp/_http_writer.pyx":120
2430  *     cdef bytes ret
2431  *
2432  *     _init_writer(&writer)             # <<<<<<<<<<<<<<
2433  *
2434  *     try:
2435  */
2436   __pyx_f_7aiohttp_12_http_writer__init_writer((&__pyx_v_writer));
2437 
2438   /* "aiohttp/_http_writer.pyx":122
2439  *     _init_writer(&writer)
2440  *
2441  *     try:             # <<<<<<<<<<<<<<
2442  *         if _write_str(&writer, status_line) < 0:
2443  *             raise
2444  */
2445   /*try:*/ {
2446 
2447     /* "aiohttp/_http_writer.pyx":123
2448  *
2449  *     try:
2450  *         if _write_str(&writer, status_line) < 0:             # <<<<<<<<<<<<<<
2451  *             raise
2452  *         if _write_byte(&writer, b'\r') < 0:
2453  */
2454     __pyx_t_1 = ((__pyx_f_7aiohttp_12_http_writer__write_str((&__pyx_v_writer), __pyx_v_status_line) < 0) != 0);
2455     if (unlikely(__pyx_t_1)) {
2456 
2457       /* "aiohttp/_http_writer.pyx":124
2458  *     try:
2459  *         if _write_str(&writer, status_line) < 0:
2460  *             raise             # <<<<<<<<<<<<<<
2461  *         if _write_byte(&writer, b'\r') < 0:
2462  *             raise
2463  */
2464       __Pyx_ReraiseException(); __PYX_ERR(0, 124, __pyx_L4_error)
2465 
2466       /* "aiohttp/_http_writer.pyx":123
2467  *
2468  *     try:
2469  *         if _write_str(&writer, status_line) < 0:             # <<<<<<<<<<<<<<
2470  *             raise
2471  *         if _write_byte(&writer, b'\r') < 0:
2472  */
2473     }
2474 
2475     /* "aiohttp/_http_writer.pyx":125
2476  *         if _write_str(&writer, status_line) < 0:
2477  *             raise
2478  *         if _write_byte(&writer, b'\r') < 0:             # <<<<<<<<<<<<<<
2479  *             raise
2480  *         if _write_byte(&writer, b'\n') < 0:
2481  */
2482     __pyx_t_1 = ((__pyx_f_7aiohttp_12_http_writer__write_byte((&__pyx_v_writer), '\r') < 0) != 0);
2483     if (unlikely(__pyx_t_1)) {
2484 
2485       /* "aiohttp/_http_writer.pyx":126
2486  *             raise
2487  *         if _write_byte(&writer, b'\r') < 0:
2488  *             raise             # <<<<<<<<<<<<<<
2489  *         if _write_byte(&writer, b'\n') < 0:
2490  *             raise
2491  */
2492       __Pyx_ReraiseException(); __PYX_ERR(0, 126, __pyx_L4_error)
2493 
2494       /* "aiohttp/_http_writer.pyx":125
2495  *         if _write_str(&writer, status_line) < 0:
2496  *             raise
2497  *         if _write_byte(&writer, b'\r') < 0:             # <<<<<<<<<<<<<<
2498  *             raise
2499  *         if _write_byte(&writer, b'\n') < 0:
2500  */
2501     }
2502 
2503     /* "aiohttp/_http_writer.pyx":127
2504  *         if _write_byte(&writer, b'\r') < 0:
2505  *             raise
2506  *         if _write_byte(&writer, b'\n') < 0:             # <<<<<<<<<<<<<<
2507  *             raise
2508  *
2509  */
2510     __pyx_t_1 = ((__pyx_f_7aiohttp_12_http_writer__write_byte((&__pyx_v_writer), '\n') < 0) != 0);
2511     if (unlikely(__pyx_t_1)) {
2512 
2513       /* "aiohttp/_http_writer.pyx":128
2514  *             raise
2515  *         if _write_byte(&writer, b'\n') < 0:
2516  *             raise             # <<<<<<<<<<<<<<
2517  *
2518  *         for key, val in headers.items():
2519  */
2520       __Pyx_ReraiseException(); __PYX_ERR(0, 128, __pyx_L4_error)
2521 
2522       /* "aiohttp/_http_writer.pyx":127
2523  *         if _write_byte(&writer, b'\r') < 0:
2524  *             raise
2525  *         if _write_byte(&writer, b'\n') < 0:             # <<<<<<<<<<<<<<
2526  *             raise
2527  *
2528  */
2529     }
2530 
2531     /* "aiohttp/_http_writer.pyx":130
2532  *             raise
2533  *
2534  *         for key, val in headers.items():             # <<<<<<<<<<<<<<
2535  *             if _write_str(&writer, to_str(key)) < 0:
2536  *                 raise
2537  */
2538     __pyx_t_3 = 0;
2539     if (unlikely(__pyx_v_headers == Py_None)) {
2540       PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
2541       __PYX_ERR(0, 130, __pyx_L4_error)
2542     }
2543     __pyx_t_6 = __Pyx_dict_iterator(__pyx_v_headers, 0, __pyx_n_s_items, (&__pyx_t_4), (&__pyx_t_5)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 130, __pyx_L4_error)
2544     __Pyx_GOTREF(__pyx_t_6);
2545     __Pyx_XDECREF(__pyx_t_2);
2546     __pyx_t_2 = __pyx_t_6;
2547     __pyx_t_6 = 0;
2548     while (1) {
2549       __pyx_t_8 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_4, &__pyx_t_3, &__pyx_t_6, &__pyx_t_7, NULL, __pyx_t_5);
2550       if (unlikely(__pyx_t_8 == 0)) break;
2551       if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 130, __pyx_L4_error)
2552       __Pyx_GOTREF(__pyx_t_6);
2553       __Pyx_GOTREF(__pyx_t_7);
2554       __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_6);
2555       __pyx_t_6 = 0;
2556       __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_7);
2557       __pyx_t_7 = 0;
2558 
2559       /* "aiohttp/_http_writer.pyx":131
2560  *
2561  *         for key, val in headers.items():
2562  *             if _write_str(&writer, to_str(key)) < 0:             # <<<<<<<<<<<<<<
2563  *                 raise
2564  *             if _write_byte(&writer, b':') < 0:
2565  */
2566       __pyx_t_7 = __pyx_f_7aiohttp_12_http_writer_to_str(__pyx_v_key); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 131, __pyx_L4_error)
2567       __Pyx_GOTREF(__pyx_t_7);
2568       __pyx_t_1 = ((__pyx_f_7aiohttp_12_http_writer__write_str((&__pyx_v_writer), ((PyObject*)__pyx_t_7)) < 0) != 0);
2569       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2570       if (unlikely(__pyx_t_1)) {
2571 
2572         /* "aiohttp/_http_writer.pyx":132
2573  *         for key, val in headers.items():
2574  *             if _write_str(&writer, to_str(key)) < 0:
2575  *                 raise             # <<<<<<<<<<<<<<
2576  *             if _write_byte(&writer, b':') < 0:
2577  *                 raise
2578  */
2579         __Pyx_ReraiseException(); __PYX_ERR(0, 132, __pyx_L4_error)
2580 
2581         /* "aiohttp/_http_writer.pyx":131
2582  *
2583  *         for key, val in headers.items():
2584  *             if _write_str(&writer, to_str(key)) < 0:             # <<<<<<<<<<<<<<
2585  *                 raise
2586  *             if _write_byte(&writer, b':') < 0:
2587  */
2588       }
2589 
2590       /* "aiohttp/_http_writer.pyx":133
2591  *             if _write_str(&writer, to_str(key)) < 0:
2592  *                 raise
2593  *             if _write_byte(&writer, b':') < 0:             # <<<<<<<<<<<<<<
2594  *                 raise
2595  *             if _write_byte(&writer, b' ') < 0:
2596  */
2597       __pyx_t_1 = ((__pyx_f_7aiohttp_12_http_writer__write_byte((&__pyx_v_writer), ':') < 0) != 0);
2598       if (unlikely(__pyx_t_1)) {
2599 
2600         /* "aiohttp/_http_writer.pyx":134
2601  *                 raise
2602  *             if _write_byte(&writer, b':') < 0:
2603  *                 raise             # <<<<<<<<<<<<<<
2604  *             if _write_byte(&writer, b' ') < 0:
2605  *                 raise
2606  */
2607         __Pyx_ReraiseException(); __PYX_ERR(0, 134, __pyx_L4_error)
2608 
2609         /* "aiohttp/_http_writer.pyx":133
2610  *             if _write_str(&writer, to_str(key)) < 0:
2611  *                 raise
2612  *             if _write_byte(&writer, b':') < 0:             # <<<<<<<<<<<<<<
2613  *                 raise
2614  *             if _write_byte(&writer, b' ') < 0:
2615  */
2616       }
2617 
2618       /* "aiohttp/_http_writer.pyx":135
2619  *             if _write_byte(&writer, b':') < 0:
2620  *                 raise
2621  *             if _write_byte(&writer, b' ') < 0:             # <<<<<<<<<<<<<<
2622  *                 raise
2623  *             if _write_str(&writer, to_str(val)) < 0:
2624  */
2625       __pyx_t_1 = ((__pyx_f_7aiohttp_12_http_writer__write_byte((&__pyx_v_writer), ' ') < 0) != 0);
2626       if (unlikely(__pyx_t_1)) {
2627 
2628         /* "aiohttp/_http_writer.pyx":136
2629  *                 raise
2630  *             if _write_byte(&writer, b' ') < 0:
2631  *                 raise             # <<<<<<<<<<<<<<
2632  *             if _write_str(&writer, to_str(val)) < 0:
2633  *                 raise
2634  */
2635         __Pyx_ReraiseException(); __PYX_ERR(0, 136, __pyx_L4_error)
2636 
2637         /* "aiohttp/_http_writer.pyx":135
2638  *             if _write_byte(&writer, b':') < 0:
2639  *                 raise
2640  *             if _write_byte(&writer, b' ') < 0:             # <<<<<<<<<<<<<<
2641  *                 raise
2642  *             if _write_str(&writer, to_str(val)) < 0:
2643  */
2644       }
2645 
2646       /* "aiohttp/_http_writer.pyx":137
2647  *             if _write_byte(&writer, b' ') < 0:
2648  *                 raise
2649  *             if _write_str(&writer, to_str(val)) < 0:             # <<<<<<<<<<<<<<
2650  *                 raise
2651  *             if _write_byte(&writer, b'\r') < 0:
2652  */
2653       __pyx_t_7 = __pyx_f_7aiohttp_12_http_writer_to_str(__pyx_v_val); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 137, __pyx_L4_error)
2654       __Pyx_GOTREF(__pyx_t_7);
2655       __pyx_t_1 = ((__pyx_f_7aiohttp_12_http_writer__write_str((&__pyx_v_writer), ((PyObject*)__pyx_t_7)) < 0) != 0);
2656       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2657       if (unlikely(__pyx_t_1)) {
2658 
2659         /* "aiohttp/_http_writer.pyx":138
2660  *                 raise
2661  *             if _write_str(&writer, to_str(val)) < 0:
2662  *                 raise             # <<<<<<<<<<<<<<
2663  *             if _write_byte(&writer, b'\r') < 0:
2664  *                 raise
2665  */
2666         __Pyx_ReraiseException(); __PYX_ERR(0, 138, __pyx_L4_error)
2667 
2668         /* "aiohttp/_http_writer.pyx":137
2669  *             if _write_byte(&writer, b' ') < 0:
2670  *                 raise
2671  *             if _write_str(&writer, to_str(val)) < 0:             # <<<<<<<<<<<<<<
2672  *                 raise
2673  *             if _write_byte(&writer, b'\r') < 0:
2674  */
2675       }
2676 
2677       /* "aiohttp/_http_writer.pyx":139
2678  *             if _write_str(&writer, to_str(val)) < 0:
2679  *                 raise
2680  *             if _write_byte(&writer, b'\r') < 0:             # <<<<<<<<<<<<<<
2681  *                 raise
2682  *             if _write_byte(&writer, b'\n') < 0:
2683  */
2684       __pyx_t_1 = ((__pyx_f_7aiohttp_12_http_writer__write_byte((&__pyx_v_writer), '\r') < 0) != 0);
2685       if (unlikely(__pyx_t_1)) {
2686 
2687         /* "aiohttp/_http_writer.pyx":140
2688  *                 raise
2689  *             if _write_byte(&writer, b'\r') < 0:
2690  *                 raise             # <<<<<<<<<<<<<<
2691  *             if _write_byte(&writer, b'\n') < 0:
2692  *                 raise
2693  */
2694         __Pyx_ReraiseException(); __PYX_ERR(0, 140, __pyx_L4_error)
2695 
2696         /* "aiohttp/_http_writer.pyx":139
2697  *             if _write_str(&writer, to_str(val)) < 0:
2698  *                 raise
2699  *             if _write_byte(&writer, b'\r') < 0:             # <<<<<<<<<<<<<<
2700  *                 raise
2701  *             if _write_byte(&writer, b'\n') < 0:
2702  */
2703       }
2704 
2705       /* "aiohttp/_http_writer.pyx":141
2706  *             if _write_byte(&writer, b'\r') < 0:
2707  *                 raise
2708  *             if _write_byte(&writer, b'\n') < 0:             # <<<<<<<<<<<<<<
2709  *                 raise
2710  *
2711  */
2712       __pyx_t_1 = ((__pyx_f_7aiohttp_12_http_writer__write_byte((&__pyx_v_writer), '\n') < 0) != 0);
2713       if (unlikely(__pyx_t_1)) {
2714 
2715         /* "aiohttp/_http_writer.pyx":142
2716  *                 raise
2717  *             if _write_byte(&writer, b'\n') < 0:
2718  *                 raise             # <<<<<<<<<<<<<<
2719  *
2720  *         if _write_byte(&writer, b'\r') < 0:
2721  */
2722         __Pyx_ReraiseException(); __PYX_ERR(0, 142, __pyx_L4_error)
2723 
2724         /* "aiohttp/_http_writer.pyx":141
2725  *             if _write_byte(&writer, b'\r') < 0:
2726  *                 raise
2727  *             if _write_byte(&writer, b'\n') < 0:             # <<<<<<<<<<<<<<
2728  *                 raise
2729  *
2730  */
2731       }
2732     }
2733     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2734 
2735     /* "aiohttp/_http_writer.pyx":144
2736  *                 raise
2737  *
2738  *         if _write_byte(&writer, b'\r') < 0:             # <<<<<<<<<<<<<<
2739  *             raise
2740  *         if _write_byte(&writer, b'\n') < 0:
2741  */
2742     __pyx_t_1 = ((__pyx_f_7aiohttp_12_http_writer__write_byte((&__pyx_v_writer), '\r') < 0) != 0);
2743     if (unlikely(__pyx_t_1)) {
2744 
2745       /* "aiohttp/_http_writer.pyx":145
2746  *
2747  *         if _write_byte(&writer, b'\r') < 0:
2748  *             raise             # <<<<<<<<<<<<<<
2749  *         if _write_byte(&writer, b'\n') < 0:
2750  *             raise
2751  */
2752       __Pyx_ReraiseException(); __PYX_ERR(0, 145, __pyx_L4_error)
2753 
2754       /* "aiohttp/_http_writer.pyx":144
2755  *                 raise
2756  *
2757  *         if _write_byte(&writer, b'\r') < 0:             # <<<<<<<<<<<<<<
2758  *             raise
2759  *         if _write_byte(&writer, b'\n') < 0:
2760  */
2761     }
2762 
2763     /* "aiohttp/_http_writer.pyx":146
2764  *         if _write_byte(&writer, b'\r') < 0:
2765  *             raise
2766  *         if _write_byte(&writer, b'\n') < 0:             # <<<<<<<<<<<<<<
2767  *             raise
2768  *
2769  */
2770     __pyx_t_1 = ((__pyx_f_7aiohttp_12_http_writer__write_byte((&__pyx_v_writer), '\n') < 0) != 0);
2771     if (unlikely(__pyx_t_1)) {
2772 
2773       /* "aiohttp/_http_writer.pyx":147
2774  *             raise
2775  *         if _write_byte(&writer, b'\n') < 0:
2776  *             raise             # <<<<<<<<<<<<<<
2777  *
2778  *         return PyBytes_FromStringAndSize(writer.buf, writer.pos)
2779  */
2780       __Pyx_ReraiseException(); __PYX_ERR(0, 147, __pyx_L4_error)
2781 
2782       /* "aiohttp/_http_writer.pyx":146
2783  *         if _write_byte(&writer, b'\r') < 0:
2784  *             raise
2785  *         if _write_byte(&writer, b'\n') < 0:             # <<<<<<<<<<<<<<
2786  *             raise
2787  *
2788  */
2789     }
2790 
2791     /* "aiohttp/_http_writer.pyx":149
2792  *             raise
2793  *
2794  *         return PyBytes_FromStringAndSize(writer.buf, writer.pos)             # <<<<<<<<<<<<<<
2795  *     finally:
2796  *         _release_writer(&writer)
2797  */
2798     __Pyx_XDECREF(__pyx_r);
2799     __pyx_t_2 = PyBytes_FromStringAndSize(__pyx_v_writer.buf, __pyx_v_writer.pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L4_error)
2800     __Pyx_GOTREF(__pyx_t_2);
2801     __pyx_r = __pyx_t_2;
2802     __pyx_t_2 = 0;
2803     goto __pyx_L3_return;
2804   }
2805 
2806   /* "aiohttp/_http_writer.pyx":151
2807  *         return PyBytes_FromStringAndSize(writer.buf, writer.pos)
2808  *     finally:
2809  *         _release_writer(&writer)             # <<<<<<<<<<<<<<
2810  */
2811   /*finally:*/ {
2812     __pyx_L4_error:;
2813     /*exception exit:*/{
2814       __Pyx_PyThreadState_declare
2815       __Pyx_PyThreadState_assign
2816       __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
2817       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2818       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
2819       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2820       if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
2821       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);
2822       __Pyx_XGOTREF(__pyx_t_10);
2823       __Pyx_XGOTREF(__pyx_t_11);
2824       __Pyx_XGOTREF(__pyx_t_12);
2825       __Pyx_XGOTREF(__pyx_t_13);
2826       __Pyx_XGOTREF(__pyx_t_14);
2827       __Pyx_XGOTREF(__pyx_t_15);
2828       __pyx_t_5 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_9 = __pyx_filename;
2829       {
2830         __pyx_f_7aiohttp_12_http_writer__release_writer((&__pyx_v_writer));
2831       }
2832       if (PY_MAJOR_VERSION >= 3) {
2833         __Pyx_XGIVEREF(__pyx_t_13);
2834         __Pyx_XGIVEREF(__pyx_t_14);
2835         __Pyx_XGIVEREF(__pyx_t_15);
2836         __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
2837       }
2838       __Pyx_XGIVEREF(__pyx_t_10);
2839       __Pyx_XGIVEREF(__pyx_t_11);
2840       __Pyx_XGIVEREF(__pyx_t_12);
2841       __Pyx_ErrRestore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
2842       __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
2843       __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_9;
2844       goto __pyx_L1_error;
2845     }
2846     __pyx_L3_return: {
2847       __pyx_t_15 = __pyx_r;
2848       __pyx_r = 0;
2849       __pyx_f_7aiohttp_12_http_writer__release_writer((&__pyx_v_writer));
2850       __pyx_r = __pyx_t_15;
2851       __pyx_t_15 = 0;
2852       goto __pyx_L0;
2853     }
2854   }
2855 
2856   /* "aiohttp/_http_writer.pyx":114
2857  *
2858  *
2859  * def _serialize_headers(str status_line, headers):             # <<<<<<<<<<<<<<
2860  *     cdef Writer writer
2861  *     cdef object key
2862  */
2863 
2864   /* function exit code */
2865   __pyx_L1_error:;
2866   __Pyx_XDECREF(__pyx_t_2);
2867   __Pyx_XDECREF(__pyx_t_6);
2868   __Pyx_XDECREF(__pyx_t_7);
2869   __Pyx_AddTraceback("aiohttp._http_writer._serialize_headers", __pyx_clineno, __pyx_lineno, __pyx_filename);
2870   __pyx_r = NULL;
2871   __pyx_L0:;
2872   __Pyx_XDECREF(__pyx_v_key);
2873   __Pyx_XDECREF(__pyx_v_val);
2874   __Pyx_XGIVEREF(__pyx_r);
2875   __Pyx_RefNannyFinishContext();
2876   return __pyx_r;
2877 }
2878 
2879 static PyMethodDef __pyx_methods[] = {
2880   {0, 0, 0, 0}
2881 };
2882 
2883 #if PY_MAJOR_VERSION >= 3
2884 #if CYTHON_PEP489_MULTI_PHASE_INIT
2885 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
2886 static int __pyx_pymod_exec__http_writer(PyObject* module); /*proto*/
2887 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
2888   {Py_mod_create, (void*)__pyx_pymod_create},
2889   {Py_mod_exec, (void*)__pyx_pymod_exec__http_writer},
2890   {0, NULL}
2891 };
2892 #endif
2893 
2894 static struct PyModuleDef __pyx_moduledef = {
2895     PyModuleDef_HEAD_INIT,
2896     "_http_writer",
2897     0, /* m_doc */
2898   #if CYTHON_PEP489_MULTI_PHASE_INIT
2899     0, /* m_size */
2900   #else
2901     -1, /* m_size */
2902   #endif
2903     __pyx_methods /* m_methods */,
2904   #if CYTHON_PEP489_MULTI_PHASE_INIT
2905     __pyx_moduledef_slots, /* m_slots */
2906   #else
2907     NULL, /* m_reload */
2908   #endif
2909     NULL, /* m_traverse */
2910     NULL, /* m_clear */
2911     NULL /* m_free */
2912 };
2913 #endif
2914 #ifndef CYTHON_SMALL_CODE
2915 #if defined(__clang__)
2916     #define CYTHON_SMALL_CODE
2917 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
2918     #define CYTHON_SMALL_CODE __attribute__((cold))
2919 #else
2920     #define CYTHON_SMALL_CODE
2921 #endif
2922 #endif
2923 
2924 static __Pyx_StringTabEntry __pyx_string_tab[] = {
2925   {&__pyx_kp_u_Cannot_serialize_non_str_key_r, __pyx_k_Cannot_serialize_non_str_key_r, sizeof(__pyx_k_Cannot_serialize_non_str_key_r), 0, 1, 0, 0},
2926   {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
2927   {&__pyx_n_s_aiohttp__http_writer, __pyx_k_aiohttp__http_writer, sizeof(__pyx_k_aiohttp__http_writer), 0, 0, 1, 1},
2928   {&__pyx_kp_s_aiohttp__http_writer_pyx, __pyx_k_aiohttp__http_writer_pyx, sizeof(__pyx_k_aiohttp__http_writer_pyx), 0, 0, 1, 0},
2929   {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
2930   {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
2931   {&__pyx_n_s_headers, __pyx_k_headers, sizeof(__pyx_k_headers), 0, 0, 1, 1},
2932   {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
2933   {&__pyx_n_s_istr, __pyx_k_istr, sizeof(__pyx_k_istr), 0, 0, 1, 1},
2934   {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
2935   {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1},
2936   {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
2937   {&__pyx_n_s_multidict, __pyx_k_multidict, sizeof(__pyx_k_multidict), 0, 0, 1, 1},
2938   {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
2939   {&__pyx_n_s_ret, __pyx_k_ret, sizeof(__pyx_k_ret), 0, 0, 1, 1},
2940   {&__pyx_n_s_serialize_headers, __pyx_k_serialize_headers, sizeof(__pyx_k_serialize_headers), 0, 0, 1, 1},
2941   {&__pyx_n_s_status_line, __pyx_k_status_line, sizeof(__pyx_k_status_line), 0, 0, 1, 1},
2942   {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
2943   {&__pyx_n_s_val, __pyx_k_val, sizeof(__pyx_k_val), 0, 0, 1, 1},
2944   {&__pyx_n_s_writer, __pyx_k_writer, sizeof(__pyx_k_writer), 0, 0, 1, 1},
2945   {0, 0, 0, 0, 0, 0, 0}
2946 };
__Pyx_InitCachedBuiltins(void)2947 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
2948   __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 109, __pyx_L1_error)
2949   return 0;
2950   __pyx_L1_error:;
2951   return -1;
2952 }
2953 
__Pyx_InitCachedConstants(void)2954 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
2955   __Pyx_RefNannyDeclarations
2956   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
2957 
2958   /* "aiohttp/_http_writer.pyx":114
2959  *
2960  *
2961  * def _serialize_headers(str status_line, headers):             # <<<<<<<<<<<<<<
2962  *     cdef Writer writer
2963  *     cdef object key
2964  */
2965   __pyx_tuple_ = PyTuple_Pack(6, __pyx_n_s_status_line, __pyx_n_s_headers, __pyx_n_s_writer, __pyx_n_s_key, __pyx_n_s_val, __pyx_n_s_ret); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 114, __pyx_L1_error)
2966   __Pyx_GOTREF(__pyx_tuple_);
2967   __Pyx_GIVEREF(__pyx_tuple_);
2968   __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_aiohttp__http_writer_pyx, __pyx_n_s_serialize_headers, 114, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 114, __pyx_L1_error)
2969   __Pyx_RefNannyFinishContext();
2970   return 0;
2971   __pyx_L1_error:;
2972   __Pyx_RefNannyFinishContext();
2973   return -1;
2974 }
2975 
__Pyx_InitGlobals(void)2976 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
2977   if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
2978   return 0;
2979   __pyx_L1_error:;
2980   return -1;
2981 }
2982 
2983 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
2984 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
2985 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
2986 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
2987 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
2988 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
2989 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
2990 
__Pyx_modinit_global_init_code(void)2991 static int __Pyx_modinit_global_init_code(void) {
2992   __Pyx_RefNannyDeclarations
2993   __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
2994   /*--- Global init code ---*/
2995   __pyx_v_7aiohttp_12_http_writer__istr = Py_None; Py_INCREF(Py_None);
2996   __Pyx_RefNannyFinishContext();
2997   return 0;
2998 }
2999 
__Pyx_modinit_variable_export_code(void)3000 static int __Pyx_modinit_variable_export_code(void) {
3001   __Pyx_RefNannyDeclarations
3002   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
3003   /*--- Variable export code ---*/
3004   __Pyx_RefNannyFinishContext();
3005   return 0;
3006 }
3007 
__Pyx_modinit_function_export_code(void)3008 static int __Pyx_modinit_function_export_code(void) {
3009   __Pyx_RefNannyDeclarations
3010   __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
3011   /*--- Function export code ---*/
3012   __Pyx_RefNannyFinishContext();
3013   return 0;
3014 }
3015 
__Pyx_modinit_type_init_code(void)3016 static int __Pyx_modinit_type_init_code(void) {
3017   __Pyx_RefNannyDeclarations
3018   __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
3019   /*--- Type init code ---*/
3020   __Pyx_RefNannyFinishContext();
3021   return 0;
3022 }
3023 
__Pyx_modinit_type_import_code(void)3024 static int __Pyx_modinit_type_import_code(void) {
3025   __Pyx_RefNannyDeclarations
3026   PyObject *__pyx_t_1 = NULL;
3027   int __pyx_lineno = 0;
3028   const char *__pyx_filename = NULL;
3029   int __pyx_clineno = 0;
3030   __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
3031   /*--- Type import code ---*/
3032   __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 9, __pyx_L1_error)
3033   __Pyx_GOTREF(__pyx_t_1);
3034   __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
3035   #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
3036   sizeof(PyTypeObject),
3037   #else
3038   sizeof(PyHeapTypeObject),
3039   #endif
3040   __Pyx_ImportType_CheckSize_Warn);
3041    if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(1, 9, __pyx_L1_error)
3042   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3043   __Pyx_RefNannyFinishContext();
3044   return 0;
3045   __pyx_L1_error:;
3046   __Pyx_XDECREF(__pyx_t_1);
3047   __Pyx_RefNannyFinishContext();
3048   return -1;
3049 }
3050 
__Pyx_modinit_variable_import_code(void)3051 static int __Pyx_modinit_variable_import_code(void) {
3052   __Pyx_RefNannyDeclarations
3053   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
3054   /*--- Variable import code ---*/
3055   __Pyx_RefNannyFinishContext();
3056   return 0;
3057 }
3058 
__Pyx_modinit_function_import_code(void)3059 static int __Pyx_modinit_function_import_code(void) {
3060   __Pyx_RefNannyDeclarations
3061   __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
3062   /*--- Function import code ---*/
3063   __Pyx_RefNannyFinishContext();
3064   return 0;
3065 }
3066 
3067 
3068 #ifndef CYTHON_NO_PYINIT_EXPORT
3069 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
3070 #elif PY_MAJOR_VERSION < 3
3071 #ifdef __cplusplus
3072 #define __Pyx_PyMODINIT_FUNC extern "C" void
3073 #else
3074 #define __Pyx_PyMODINIT_FUNC void
3075 #endif
3076 #else
3077 #ifdef __cplusplus
3078 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
3079 #else
3080 #define __Pyx_PyMODINIT_FUNC PyObject *
3081 #endif
3082 #endif
3083 
3084 
3085 #if PY_MAJOR_VERSION < 3
3086 __Pyx_PyMODINIT_FUNC init_http_writer(void) CYTHON_SMALL_CODE; /*proto*/
init_http_writer(void)3087 __Pyx_PyMODINIT_FUNC init_http_writer(void)
3088 #else
3089 __Pyx_PyMODINIT_FUNC PyInit__http_writer(void) CYTHON_SMALL_CODE; /*proto*/
3090 __Pyx_PyMODINIT_FUNC PyInit__http_writer(void)
3091 #if CYTHON_PEP489_MULTI_PHASE_INIT
3092 {
3093   return PyModuleDef_Init(&__pyx_moduledef);
3094 }
3095 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
3096     #if PY_VERSION_HEX >= 0x030700A1
3097     static PY_INT64_T main_interpreter_id = -1;
3098     PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
3099     if (main_interpreter_id == -1) {
3100         main_interpreter_id = current_id;
3101         return (unlikely(current_id == -1)) ? -1 : 0;
3102     } else if (unlikely(main_interpreter_id != current_id))
3103     #else
3104     static PyInterpreterState *main_interpreter = NULL;
3105     PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
3106     if (!main_interpreter) {
3107         main_interpreter = current_interpreter;
3108     } else if (unlikely(main_interpreter != current_interpreter))
3109     #endif
3110     {
3111         PyErr_SetString(
3112             PyExc_ImportError,
3113             "Interpreter change detected - this module can only be loaded into one interpreter per process.");
3114         return -1;
3115     }
3116     return 0;
3117 }
3118 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) {
3119     PyObject *value = PyObject_GetAttrString(spec, from_name);
3120     int result = 0;
3121     if (likely(value)) {
3122         if (allow_none || value != Py_None) {
3123             result = PyDict_SetItemString(moddict, to_name, value);
3124         }
3125         Py_DECREF(value);
3126     } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
3127         PyErr_Clear();
3128     } else {
3129         result = -1;
3130     }
3131     return result;
3132 }
3133 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
3134     PyObject *module = NULL, *moddict, *modname;
3135     if (__Pyx_check_single_interpreter())
3136         return NULL;
3137     if (__pyx_m)
3138         return __Pyx_NewRef(__pyx_m);
3139     modname = PyObject_GetAttrString(spec, "name");
3140     if (unlikely(!modname)) goto bad;
3141     module = PyModule_NewObject(modname);
3142     Py_DECREF(modname);
3143     if (unlikely(!module)) goto bad;
3144     moddict = PyModule_GetDict(module);
3145     if (unlikely(!moddict)) goto bad;
3146     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
3147     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
3148     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
3149     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
3150     return module;
3151 bad:
3152     Py_XDECREF(module);
3153     return NULL;
3154 }
3155 
3156 
3157 static CYTHON_SMALL_CODE int __pyx_pymod_exec__http_writer(PyObject *__pyx_pyinit_module)
3158 #endif
3159 #endif
3160 {
3161   PyObject *__pyx_t_1 = NULL;
3162   PyObject *__pyx_t_2 = NULL;
3163   int __pyx_lineno = 0;
3164   const char *__pyx_filename = NULL;
3165   int __pyx_clineno = 0;
3166   __Pyx_RefNannyDeclarations
3167   #if CYTHON_PEP489_MULTI_PHASE_INIT
3168   if (__pyx_m) {
3169     if (__pyx_m == __pyx_pyinit_module) return 0;
3170     PyErr_SetString(PyExc_RuntimeError, "Module '_http_writer' has already been imported. Re-initialisation is not supported.");
3171     return -1;
3172   }
3173   #elif PY_MAJOR_VERSION >= 3
3174   if (__pyx_m) return __Pyx_NewRef(__pyx_m);
3175   #endif
3176   #if CYTHON_REFNANNY
3177 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
3178 if (!__Pyx_RefNanny) {
3179   PyErr_Clear();
3180   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
3181   if (!__Pyx_RefNanny)
3182       Py_FatalError("failed to import 'refnanny' module");
3183 }
3184 #endif
3185   __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__http_writer(void)", 0);
3186   if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3187   #ifdef __Pxy_PyFrame_Initialize_Offsets
3188   __Pxy_PyFrame_Initialize_Offsets();
3189   #endif
3190   __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
3191   __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
3192   __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
3193   #ifdef __Pyx_CyFunction_USED
3194   if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3195   #endif
3196   #ifdef __Pyx_FusedFunction_USED
3197   if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3198   #endif
3199   #ifdef __Pyx_Coroutine_USED
3200   if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3201   #endif
3202   #ifdef __Pyx_Generator_USED
3203   if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3204   #endif
3205   #ifdef __Pyx_AsyncGen_USED
3206   if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3207   #endif
3208   #ifdef __Pyx_StopAsyncIteration_USED
3209   if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3210   #endif
3211   /*--- Library function declarations ---*/
3212   /*--- Threads initialization code ---*/
3213   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
3214   #ifdef WITH_THREAD /* Python build with threading support? */
3215   PyEval_InitThreads();
3216   #endif
3217   #endif
3218   /*--- Module creation code ---*/
3219   #if CYTHON_PEP489_MULTI_PHASE_INIT
3220   __pyx_m = __pyx_pyinit_module;
3221   Py_INCREF(__pyx_m);
3222   #else
3223   #if PY_MAJOR_VERSION < 3
3224   __pyx_m = Py_InitModule4("_http_writer", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
3225   #else
3226   __pyx_m = PyModule_Create(&__pyx_moduledef);
3227   #endif
3228   if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
3229   #endif
3230   __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
3231   Py_INCREF(__pyx_d);
3232   __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
3233   Py_INCREF(__pyx_b);
3234   __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
3235   Py_INCREF(__pyx_cython_runtime);
3236   if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
3237   /*--- Initialize various global constants etc. ---*/
3238   if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3239   #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
3240   if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3241   #endif
3242   if (__pyx_module_is_main_aiohttp___http_writer) {
3243     if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3244   }
3245   #if PY_MAJOR_VERSION >= 3
3246   {
3247     PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
3248     if (!PyDict_GetItemString(modules, "aiohttp._http_writer")) {
3249       if (unlikely(PyDict_SetItemString(modules, "aiohttp._http_writer", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
3250     }
3251   }
3252   #endif
3253   /*--- Builtin init code ---*/
3254   if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3255   /*--- Constants init code ---*/
3256   if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3257   /*--- Global type/function init code ---*/
3258   (void)__Pyx_modinit_global_init_code();
3259   (void)__Pyx_modinit_variable_export_code();
3260   (void)__Pyx_modinit_function_export_code();
3261   (void)__Pyx_modinit_type_init_code();
3262   if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
3263   (void)__Pyx_modinit_variable_import_code();
3264   (void)__Pyx_modinit_function_import_code();
3265   /*--- Execution code ---*/
3266   #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
3267   if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3268   #endif
3269 
3270   /* "aiohttp/_http_writer.pyx":8
3271  * from libc.string cimport memcpy
3272  *
3273  * from multidict import istr             # <<<<<<<<<<<<<<
3274  *
3275  * DEF BUF_SIZE = 16 * 1024  # 16KiB
3276  */
3277   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
3278   __Pyx_GOTREF(__pyx_t_1);
3279   __Pyx_INCREF(__pyx_n_s_istr);
3280   __Pyx_GIVEREF(__pyx_n_s_istr);
3281   PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_istr);
3282   __pyx_t_2 = __Pyx_Import(__pyx_n_s_multidict, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
3283   __Pyx_GOTREF(__pyx_t_2);
3284   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3285   __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_istr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
3286   __Pyx_GOTREF(__pyx_t_1);
3287   if (PyDict_SetItem(__pyx_d, __pyx_n_s_istr, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
3288   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3289   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3290 
3291   /* "aiohttp/_http_writer.pyx":13
3292  * cdef char BUFFER[BUF_SIZE]
3293  *
3294  * cdef object _istr = istr             # <<<<<<<<<<<<<<
3295  *
3296  *
3297  */
3298   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_istr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
3299   __Pyx_GOTREF(__pyx_t_2);
3300   __Pyx_XGOTREF(__pyx_v_7aiohttp_12_http_writer__istr);
3301   __Pyx_DECREF_SET(__pyx_v_7aiohttp_12_http_writer__istr, __pyx_t_2);
3302   __Pyx_GIVEREF(__pyx_t_2);
3303   __pyx_t_2 = 0;
3304 
3305   /* "aiohttp/_http_writer.pyx":114
3306  *
3307  *
3308  * def _serialize_headers(str status_line, headers):             # <<<<<<<<<<<<<<
3309  *     cdef Writer writer
3310  *     cdef object key
3311  */
3312   __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7aiohttp_12_http_writer_1_serialize_headers, NULL, __pyx_n_s_aiohttp__http_writer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error)
3313   __Pyx_GOTREF(__pyx_t_2);
3314   if (PyDict_SetItem(__pyx_d, __pyx_n_s_serialize_headers, __pyx_t_2) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
3315   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3316 
3317   /* "aiohttp/_http_writer.pyx":1
3318  * from cpython.bytes cimport PyBytes_FromStringAndSize             # <<<<<<<<<<<<<<
3319  * from cpython.exc cimport PyErr_NoMemory
3320  * from cpython.mem cimport PyMem_Free, PyMem_Malloc, PyMem_Realloc
3321  */
3322   __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
3323   __Pyx_GOTREF(__pyx_t_2);
3324   if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3325   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3326 
3327   /*--- Wrapped vars code ---*/
3328 
3329   goto __pyx_L0;
3330   __pyx_L1_error:;
3331   __Pyx_XDECREF(__pyx_t_1);
3332   __Pyx_XDECREF(__pyx_t_2);
3333   if (__pyx_m) {
3334     if (__pyx_d) {
3335       __Pyx_AddTraceback("init aiohttp._http_writer", __pyx_clineno, __pyx_lineno, __pyx_filename);
3336     }
3337     Py_CLEAR(__pyx_m);
3338   } else if (!PyErr_Occurred()) {
3339     PyErr_SetString(PyExc_ImportError, "init aiohttp._http_writer");
3340   }
3341   __pyx_L0:;
3342   __Pyx_RefNannyFinishContext();
3343   #if CYTHON_PEP489_MULTI_PHASE_INIT
3344   return (__pyx_m != NULL) ? 0 : -1;
3345   #elif PY_MAJOR_VERSION >= 3
3346   return __pyx_m;
3347   #else
3348   return;
3349   #endif
3350 }
3351 
3352 /* --- Runtime support code --- */
3353 /* Refnanny */
3354 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)3355 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
3356     PyObject *m = NULL, *p = NULL;
3357     void *r = NULL;
3358     m = PyImport_ImportModule(modname);
3359     if (!m) goto end;
3360     p = PyObject_GetAttrString(m, "RefNannyAPI");
3361     if (!p) goto end;
3362     r = PyLong_AsVoidPtr(p);
3363 end:
3364     Py_XDECREF(p);
3365     Py_XDECREF(m);
3366     return (__Pyx_RefNannyAPIStruct *)r;
3367 }
3368 #endif
3369 
3370 /* PyObjectGetAttrStr */
3371 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)3372 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
3373     PyTypeObject* tp = Py_TYPE(obj);
3374     if (likely(tp->tp_getattro))
3375         return tp->tp_getattro(obj, attr_name);
3376 #if PY_MAJOR_VERSION < 3
3377     if (likely(tp->tp_getattr))
3378         return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
3379 #endif
3380     return PyObject_GetAttr(obj, attr_name);
3381 }
3382 #endif
3383 
3384 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)3385 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
3386     PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
3387     if (unlikely(!result)) {
3388         PyErr_Format(PyExc_NameError,
3389 #if PY_MAJOR_VERSION >= 3
3390             "name '%U' is not defined", name);
3391 #else
3392             "name '%.200s' is not defined", PyString_AS_STRING(name));
3393 #endif
3394     }
3395     return result;
3396 }
3397 
3398 /* PyErrFetchRestore */
3399 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)3400 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
3401     PyObject *tmp_type, *tmp_value, *tmp_tb;
3402     tmp_type = tstate->curexc_type;
3403     tmp_value = tstate->curexc_value;
3404     tmp_tb = tstate->curexc_traceback;
3405     tstate->curexc_type = type;
3406     tstate->curexc_value = value;
3407     tstate->curexc_traceback = tb;
3408     Py_XDECREF(tmp_type);
3409     Py_XDECREF(tmp_value);
3410     Py_XDECREF(tmp_tb);
3411 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)3412 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
3413     *type = tstate->curexc_type;
3414     *value = tstate->curexc_value;
3415     *tb = tstate->curexc_traceback;
3416     tstate->curexc_type = 0;
3417     tstate->curexc_value = 0;
3418     tstate->curexc_traceback = 0;
3419 }
3420 #endif
3421 
3422 /* WriteUnraisableException */
__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)3423 static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
3424                                   CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
3425                                   int full_traceback, CYTHON_UNUSED int nogil) {
3426     PyObject *old_exc, *old_val, *old_tb;
3427     PyObject *ctx;
3428     __Pyx_PyThreadState_declare
3429 #ifdef WITH_THREAD
3430     PyGILState_STATE state;
3431     if (nogil)
3432         state = PyGILState_Ensure();
3433 #ifdef _MSC_VER
3434     else state = (PyGILState_STATE)-1;
3435 #endif
3436 #endif
3437     __Pyx_PyThreadState_assign
3438     __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
3439     if (full_traceback) {
3440         Py_XINCREF(old_exc);
3441         Py_XINCREF(old_val);
3442         Py_XINCREF(old_tb);
3443         __Pyx_ErrRestore(old_exc, old_val, old_tb);
3444         PyErr_PrintEx(1);
3445     }
3446     #if PY_MAJOR_VERSION < 3
3447     ctx = PyString_FromString(name);
3448     #else
3449     ctx = PyUnicode_FromString(name);
3450     #endif
3451     __Pyx_ErrRestore(old_exc, old_val, old_tb);
3452     if (!ctx) {
3453         PyErr_WriteUnraisable(Py_None);
3454     } else {
3455         PyErr_WriteUnraisable(ctx);
3456         Py_DECREF(ctx);
3457     }
3458 #ifdef WITH_THREAD
3459     if (nogil)
3460         PyGILState_Release(state);
3461 #endif
3462 }
3463 
3464 /* unicode_iter */
__Pyx_init_unicode_iteration(PyObject * ustring,Py_ssize_t * length,void ** data,int * kind)3465 static CYTHON_INLINE int __Pyx_init_unicode_iteration(
3466     PyObject* ustring, Py_ssize_t *length, void** data, int *kind) {
3467 #if CYTHON_PEP393_ENABLED
3468     if (unlikely(__Pyx_PyUnicode_READY(ustring) < 0)) return -1;
3469     *kind   = PyUnicode_KIND(ustring);
3470     *length = PyUnicode_GET_LENGTH(ustring);
3471     *data   = PyUnicode_DATA(ustring);
3472 #else
3473     *kind   = 0;
3474     *length = PyUnicode_GET_SIZE(ustring);
3475     *data   = (void*)PyUnicode_AS_UNICODE(ustring);
3476 #endif
3477     return 0;
3478 }
3479 
3480 /* PyCFunctionFastCall */
3481 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)3482 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
3483     PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
3484     PyCFunction meth = PyCFunction_GET_FUNCTION(func);
3485     PyObject *self = PyCFunction_GET_SELF(func);
3486     int flags = PyCFunction_GET_FLAGS(func);
3487     assert(PyCFunction_Check(func));
3488     assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
3489     assert(nargs >= 0);
3490     assert(nargs == 0 || args != NULL);
3491     /* _PyCFunction_FastCallDict() must not be called with an exception set,
3492        because it may clear it (directly or indirectly) and so the
3493        caller loses its exception */
3494     assert(!PyErr_Occurred());
3495     if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
3496         return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
3497     } else {
3498         return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
3499     }
3500 }
3501 #endif
3502 
3503 /* PyFunctionFastCall */
3504 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)3505 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
3506                                                PyObject *globals) {
3507     PyFrameObject *f;
3508     PyThreadState *tstate = __Pyx_PyThreadState_Current;
3509     PyObject **fastlocals;
3510     Py_ssize_t i;
3511     PyObject *result;
3512     assert(globals != NULL);
3513     /* XXX Perhaps we should create a specialized
3514        PyFrame_New() that doesn't take locals, but does
3515        take builtins without sanity checking them.
3516        */
3517     assert(tstate != NULL);
3518     f = PyFrame_New(tstate, co, globals, NULL);
3519     if (f == NULL) {
3520         return NULL;
3521     }
3522     fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
3523     for (i = 0; i < na; i++) {
3524         Py_INCREF(*args);
3525         fastlocals[i] = *args++;
3526     }
3527     result = PyEval_EvalFrameEx(f,0);
3528     ++tstate->recursion_depth;
3529     Py_DECREF(f);
3530     --tstate->recursion_depth;
3531     return result;
3532 }
3533 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)3534 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
3535     PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
3536     PyObject *globals = PyFunction_GET_GLOBALS(func);
3537     PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
3538     PyObject *closure;
3539 #if PY_MAJOR_VERSION >= 3
3540     PyObject *kwdefs;
3541 #endif
3542     PyObject *kwtuple, **k;
3543     PyObject **d;
3544     Py_ssize_t nd;
3545     Py_ssize_t nk;
3546     PyObject *result;
3547     assert(kwargs == NULL || PyDict_Check(kwargs));
3548     nk = kwargs ? PyDict_Size(kwargs) : 0;
3549     if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
3550         return NULL;
3551     }
3552     if (
3553 #if PY_MAJOR_VERSION >= 3
3554             co->co_kwonlyargcount == 0 &&
3555 #endif
3556             likely(kwargs == NULL || nk == 0) &&
3557             co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
3558         if (argdefs == NULL && co->co_argcount == nargs) {
3559             result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
3560             goto done;
3561         }
3562         else if (nargs == 0 && argdefs != NULL
3563                  && co->co_argcount == Py_SIZE(argdefs)) {
3564             /* function called with no arguments, but all parameters have
3565                a default value: use default values as arguments .*/
3566             args = &PyTuple_GET_ITEM(argdefs, 0);
3567             result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
3568             goto done;
3569         }
3570     }
3571     if (kwargs != NULL) {
3572         Py_ssize_t pos, i;
3573         kwtuple = PyTuple_New(2 * nk);
3574         if (kwtuple == NULL) {
3575             result = NULL;
3576             goto done;
3577         }
3578         k = &PyTuple_GET_ITEM(kwtuple, 0);
3579         pos = i = 0;
3580         while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
3581             Py_INCREF(k[i]);
3582             Py_INCREF(k[i+1]);
3583             i += 2;
3584         }
3585         nk = i / 2;
3586     }
3587     else {
3588         kwtuple = NULL;
3589         k = NULL;
3590     }
3591     closure = PyFunction_GET_CLOSURE(func);
3592 #if PY_MAJOR_VERSION >= 3
3593     kwdefs = PyFunction_GET_KW_DEFAULTS(func);
3594 #endif
3595     if (argdefs != NULL) {
3596         d = &PyTuple_GET_ITEM(argdefs, 0);
3597         nd = Py_SIZE(argdefs);
3598     }
3599     else {
3600         d = NULL;
3601         nd = 0;
3602     }
3603 #if PY_MAJOR_VERSION >= 3
3604     result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
3605                                args, (int)nargs,
3606                                k, (int)nk,
3607                                d, (int)nd, kwdefs, closure);
3608 #else
3609     result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
3610                                args, (int)nargs,
3611                                k, (int)nk,
3612                                d, (int)nd, closure);
3613 #endif
3614     Py_XDECREF(kwtuple);
3615 done:
3616     Py_LeaveRecursiveCall();
3617     return result;
3618 }
3619 #endif
3620 #endif
3621 
3622 /* PyObjectCall */
3623 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)3624 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
3625     PyObject *result;
3626     ternaryfunc call = func->ob_type->tp_call;
3627     if (unlikely(!call))
3628         return PyObject_Call(func, arg, kw);
3629     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
3630         return NULL;
3631     result = (*call)(func, arg, kw);
3632     Py_LeaveRecursiveCall();
3633     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
3634         PyErr_SetString(
3635             PyExc_SystemError,
3636             "NULL result without error in PyObject_Call");
3637     }
3638     return result;
3639 }
3640 #endif
3641 
3642 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)3643 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
3644     PyObject *args, *result = NULL;
3645     #if CYTHON_FAST_PYCALL
3646     if (PyFunction_Check(function)) {
3647         PyObject *args[2] = {arg1, arg2};
3648         return __Pyx_PyFunction_FastCall(function, args, 2);
3649     }
3650     #endif
3651     #if CYTHON_FAST_PYCCALL
3652     if (__Pyx_PyFastCFunction_Check(function)) {
3653         PyObject *args[2] = {arg1, arg2};
3654         return __Pyx_PyCFunction_FastCall(function, args, 2);
3655     }
3656     #endif
3657     args = PyTuple_New(2);
3658     if (unlikely(!args)) goto done;
3659     Py_INCREF(arg1);
3660     PyTuple_SET_ITEM(args, 0, arg1);
3661     Py_INCREF(arg2);
3662     PyTuple_SET_ITEM(args, 1, arg2);
3663     Py_INCREF(function);
3664     result = __Pyx_PyObject_Call(function, args, NULL);
3665     Py_DECREF(args);
3666     Py_DECREF(function);
3667 done:
3668     return result;
3669 }
3670 
3671 /* PyObjectCallMethO */
3672 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)3673 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
3674     PyObject *self, *result;
3675     PyCFunction cfunc;
3676     cfunc = PyCFunction_GET_FUNCTION(func);
3677     self = PyCFunction_GET_SELF(func);
3678     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
3679         return NULL;
3680     result = cfunc(self, arg);
3681     Py_LeaveRecursiveCall();
3682     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
3683         PyErr_SetString(
3684             PyExc_SystemError,
3685             "NULL result without error in PyObject_Call");
3686     }
3687     return result;
3688 }
3689 #endif
3690 
3691 /* PyObjectCallOneArg */
3692 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)3693 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
3694     PyObject *result;
3695     PyObject *args = PyTuple_New(1);
3696     if (unlikely(!args)) return NULL;
3697     Py_INCREF(arg);
3698     PyTuple_SET_ITEM(args, 0, arg);
3699     result = __Pyx_PyObject_Call(func, args, NULL);
3700     Py_DECREF(args);
3701     return result;
3702 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)3703 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
3704 #if CYTHON_FAST_PYCALL
3705     if (PyFunction_Check(func)) {
3706         return __Pyx_PyFunction_FastCall(func, &arg, 1);
3707     }
3708 #endif
3709     if (likely(PyCFunction_Check(func))) {
3710         if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
3711             return __Pyx_PyObject_CallMethO(func, arg);
3712 #if CYTHON_FAST_PYCCALL
3713         } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
3714             return __Pyx_PyCFunction_FastCall(func, &arg, 1);
3715 #endif
3716         }
3717     }
3718     return __Pyx__PyObject_CallOneArg(func, arg);
3719 }
3720 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)3721 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
3722     PyObject *result;
3723     PyObject *args = PyTuple_Pack(1, arg);
3724     if (unlikely(!args)) return NULL;
3725     result = __Pyx_PyObject_Call(func, args, NULL);
3726     Py_DECREF(args);
3727     return result;
3728 }
3729 #endif
3730 
3731 /* RaiseException */
3732 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)3733 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
3734                         CYTHON_UNUSED PyObject *cause) {
3735     __Pyx_PyThreadState_declare
3736     Py_XINCREF(type);
3737     if (!value || value == Py_None)
3738         value = NULL;
3739     else
3740         Py_INCREF(value);
3741     if (!tb || tb == Py_None)
3742         tb = NULL;
3743     else {
3744         Py_INCREF(tb);
3745         if (!PyTraceBack_Check(tb)) {
3746             PyErr_SetString(PyExc_TypeError,
3747                 "raise: arg 3 must be a traceback or None");
3748             goto raise_error;
3749         }
3750     }
3751     if (PyType_Check(type)) {
3752 #if CYTHON_COMPILING_IN_PYPY
3753         if (!value) {
3754             Py_INCREF(Py_None);
3755             value = Py_None;
3756         }
3757 #endif
3758         PyErr_NormalizeException(&type, &value, &tb);
3759     } else {
3760         if (value) {
3761             PyErr_SetString(PyExc_TypeError,
3762                 "instance exception may not have a separate value");
3763             goto raise_error;
3764         }
3765         value = type;
3766         type = (PyObject*) Py_TYPE(type);
3767         Py_INCREF(type);
3768         if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
3769             PyErr_SetString(PyExc_TypeError,
3770                 "raise: exception class must be a subclass of BaseException");
3771             goto raise_error;
3772         }
3773     }
3774     __Pyx_PyThreadState_assign
3775     __Pyx_ErrRestore(type, value, tb);
3776     return;
3777 raise_error:
3778     Py_XDECREF(value);
3779     Py_XDECREF(type);
3780     Py_XDECREF(tb);
3781     return;
3782 }
3783 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)3784 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
3785     PyObject* owned_instance = NULL;
3786     if (tb == Py_None) {
3787         tb = 0;
3788     } else if (tb && !PyTraceBack_Check(tb)) {
3789         PyErr_SetString(PyExc_TypeError,
3790             "raise: arg 3 must be a traceback or None");
3791         goto bad;
3792     }
3793     if (value == Py_None)
3794         value = 0;
3795     if (PyExceptionInstance_Check(type)) {
3796         if (value) {
3797             PyErr_SetString(PyExc_TypeError,
3798                 "instance exception may not have a separate value");
3799             goto bad;
3800         }
3801         value = type;
3802         type = (PyObject*) Py_TYPE(value);
3803     } else if (PyExceptionClass_Check(type)) {
3804         PyObject *instance_class = NULL;
3805         if (value && PyExceptionInstance_Check(value)) {
3806             instance_class = (PyObject*) Py_TYPE(value);
3807             if (instance_class != type) {
3808                 int is_subclass = PyObject_IsSubclass(instance_class, type);
3809                 if (!is_subclass) {
3810                     instance_class = NULL;
3811                 } else if (unlikely(is_subclass == -1)) {
3812                     goto bad;
3813                 } else {
3814                     type = instance_class;
3815                 }
3816             }
3817         }
3818         if (!instance_class) {
3819             PyObject *args;
3820             if (!value)
3821                 args = PyTuple_New(0);
3822             else if (PyTuple_Check(value)) {
3823                 Py_INCREF(value);
3824                 args = value;
3825             } else
3826                 args = PyTuple_Pack(1, value);
3827             if (!args)
3828                 goto bad;
3829             owned_instance = PyObject_Call(type, args, NULL);
3830             Py_DECREF(args);
3831             if (!owned_instance)
3832                 goto bad;
3833             value = owned_instance;
3834             if (!PyExceptionInstance_Check(value)) {
3835                 PyErr_Format(PyExc_TypeError,
3836                              "calling %R should have returned an instance of "
3837                              "BaseException, not %R",
3838                              type, Py_TYPE(value));
3839                 goto bad;
3840             }
3841         }
3842     } else {
3843         PyErr_SetString(PyExc_TypeError,
3844             "raise: exception class must be a subclass of BaseException");
3845         goto bad;
3846     }
3847     if (cause) {
3848         PyObject *fixed_cause;
3849         if (cause == Py_None) {
3850             fixed_cause = NULL;
3851         } else if (PyExceptionClass_Check(cause)) {
3852             fixed_cause = PyObject_CallObject(cause, NULL);
3853             if (fixed_cause == NULL)
3854                 goto bad;
3855         } else if (PyExceptionInstance_Check(cause)) {
3856             fixed_cause = cause;
3857             Py_INCREF(fixed_cause);
3858         } else {
3859             PyErr_SetString(PyExc_TypeError,
3860                             "exception causes must derive from "
3861                             "BaseException");
3862             goto bad;
3863         }
3864         PyException_SetCause(value, fixed_cause);
3865     }
3866     PyErr_SetObject(type, value);
3867     if (tb) {
3868 #if CYTHON_COMPILING_IN_PYPY
3869         PyObject *tmp_type, *tmp_value, *tmp_tb;
3870         PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
3871         Py_INCREF(tb);
3872         PyErr_Restore(tmp_type, tmp_value, tb);
3873         Py_XDECREF(tmp_tb);
3874 #else
3875         PyThreadState *tstate = __Pyx_PyThreadState_Current;
3876         PyObject* tmp_tb = tstate->curexc_traceback;
3877         if (tb != tmp_tb) {
3878             Py_INCREF(tb);
3879             tstate->curexc_traceback = tb;
3880             Py_XDECREF(tmp_tb);
3881         }
3882 #endif
3883     }
3884 bad:
3885     Py_XDECREF(owned_instance);
3886     return;
3887 }
3888 #endif
3889 
3890 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)3891 static void __Pyx_RaiseArgtupleInvalid(
3892     const char* func_name,
3893     int exact,
3894     Py_ssize_t num_min,
3895     Py_ssize_t num_max,
3896     Py_ssize_t num_found)
3897 {
3898     Py_ssize_t num_expected;
3899     const char *more_or_less;
3900     if (num_found < num_min) {
3901         num_expected = num_min;
3902         more_or_less = "at least";
3903     } else {
3904         num_expected = num_max;
3905         more_or_less = "at most";
3906     }
3907     if (exact) {
3908         more_or_less = "exactly";
3909     }
3910     PyErr_Format(PyExc_TypeError,
3911                  "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
3912                  func_name, more_or_less, num_expected,
3913                  (num_expected == 1) ? "" : "s", num_found);
3914 }
3915 
3916 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)3917 static void __Pyx_RaiseDoubleKeywordsError(
3918     const char* func_name,
3919     PyObject* kw_name)
3920 {
3921     PyErr_Format(PyExc_TypeError,
3922         #if PY_MAJOR_VERSION >= 3
3923         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
3924         #else
3925         "%s() got multiple values for keyword argument '%s'", func_name,
3926         PyString_AsString(kw_name));
3927         #endif
3928 }
3929 
3930 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)3931 static int __Pyx_ParseOptionalKeywords(
3932     PyObject *kwds,
3933     PyObject **argnames[],
3934     PyObject *kwds2,
3935     PyObject *values[],
3936     Py_ssize_t num_pos_args,
3937     const char* function_name)
3938 {
3939     PyObject *key = 0, *value = 0;
3940     Py_ssize_t pos = 0;
3941     PyObject*** name;
3942     PyObject*** first_kw_arg = argnames + num_pos_args;
3943     while (PyDict_Next(kwds, &pos, &key, &value)) {
3944         name = first_kw_arg;
3945         while (*name && (**name != key)) name++;
3946         if (*name) {
3947             values[name-argnames] = value;
3948             continue;
3949         }
3950         name = first_kw_arg;
3951         #if PY_MAJOR_VERSION < 3
3952         if (likely(PyString_Check(key))) {
3953             while (*name) {
3954                 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
3955                         && _PyString_Eq(**name, key)) {
3956                     values[name-argnames] = value;
3957                     break;
3958                 }
3959                 name++;
3960             }
3961             if (*name) continue;
3962             else {
3963                 PyObject*** argname = argnames;
3964                 while (argname != first_kw_arg) {
3965                     if ((**argname == key) || (
3966                             (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
3967                              && _PyString_Eq(**argname, key))) {
3968                         goto arg_passed_twice;
3969                     }
3970                     argname++;
3971                 }
3972             }
3973         } else
3974         #endif
3975         if (likely(PyUnicode_Check(key))) {
3976             while (*name) {
3977                 int cmp = (**name == key) ? 0 :
3978                 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
3979                     (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
3980                 #endif
3981                     PyUnicode_Compare(**name, key);
3982                 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
3983                 if (cmp == 0) {
3984                     values[name-argnames] = value;
3985                     break;
3986                 }
3987                 name++;
3988             }
3989             if (*name) continue;
3990             else {
3991                 PyObject*** argname = argnames;
3992                 while (argname != first_kw_arg) {
3993                     int cmp = (**argname == key) ? 0 :
3994                     #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
3995                         (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
3996                     #endif
3997                         PyUnicode_Compare(**argname, key);
3998                     if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
3999                     if (cmp == 0) goto arg_passed_twice;
4000                     argname++;
4001                 }
4002             }
4003         } else
4004             goto invalid_keyword_type;
4005         if (kwds2) {
4006             if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
4007         } else {
4008             goto invalid_keyword;
4009         }
4010     }
4011     return 0;
4012 arg_passed_twice:
4013     __Pyx_RaiseDoubleKeywordsError(function_name, key);
4014     goto bad;
4015 invalid_keyword_type:
4016     PyErr_Format(PyExc_TypeError,
4017         "%.200s() keywords must be strings", function_name);
4018     goto bad;
4019 invalid_keyword:
4020     PyErr_Format(PyExc_TypeError,
4021     #if PY_MAJOR_VERSION < 3
4022         "%.200s() got an unexpected keyword argument '%.200s'",
4023         function_name, PyString_AsString(key));
4024     #else
4025         "%s() got an unexpected keyword argument '%U'",
4026         function_name, key);
4027     #endif
4028 bad:
4029     return -1;
4030 }
4031 
4032 /* ArgTypeTest */
__Pyx__ArgTypeTest(PyObject * obj,PyTypeObject * type,const char * name,int exact)4033 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
4034 {
4035     if (unlikely(!type)) {
4036         PyErr_SetString(PyExc_SystemError, "Missing type object");
4037         return 0;
4038     }
4039     else if (exact) {
4040         #if PY_MAJOR_VERSION == 2
4041         if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
4042         #endif
4043     }
4044     else {
4045         if (likely(__Pyx_TypeCheck(obj, type))) return 1;
4046     }
4047     PyErr_Format(PyExc_TypeError,
4048         "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
4049         name, type->tp_name, Py_TYPE(obj)->tp_name);
4050     return 0;
4051 }
4052 
4053 /* GetTopmostException */
4054 #if CYTHON_USE_EXC_INFO_STACK
4055 static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState * tstate)4056 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
4057 {
4058     _PyErr_StackItem *exc_info = tstate->exc_info;
4059     while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
4060            exc_info->previous_item != NULL)
4061     {
4062         exc_info = exc_info->previous_item;
4063     }
4064     return exc_info;
4065 }
4066 #endif
4067 
4068 /* ReRaiseException */
__Pyx_ReraiseException(void)4069 static CYTHON_INLINE void __Pyx_ReraiseException(void) {
4070     PyObject *type = NULL, *value = NULL, *tb = NULL;
4071 #if CYTHON_FAST_THREAD_STATE
4072     PyThreadState *tstate = PyThreadState_GET();
4073     #if CYTHON_USE_EXC_INFO_STACK
4074     _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
4075     type = exc_info->exc_type;
4076     value = exc_info->exc_value;
4077     tb = exc_info->exc_traceback;
4078     #else
4079     type = tstate->exc_type;
4080     value = tstate->exc_value;
4081     tb = tstate->exc_traceback;
4082     #endif
4083 #else
4084     PyErr_GetExcInfo(&type, &value, &tb);
4085 #endif
4086     if (!type || type == Py_None) {
4087 #if !CYTHON_FAST_THREAD_STATE
4088         Py_XDECREF(type);
4089         Py_XDECREF(value);
4090         Py_XDECREF(tb);
4091 #endif
4092         PyErr_SetString(PyExc_RuntimeError,
4093             "No active exception to reraise");
4094     } else {
4095 #if CYTHON_FAST_THREAD_STATE
4096         Py_INCREF(type);
4097         Py_XINCREF(value);
4098         Py_XINCREF(tb);
4099 #endif
4100         PyErr_Restore(type, value, tb);
4101     }
4102 }
4103 
4104 /* IterFinish */
__Pyx_IterFinish(void)4105 static CYTHON_INLINE int __Pyx_IterFinish(void) {
4106 #if CYTHON_FAST_THREAD_STATE
4107     PyThreadState *tstate = __Pyx_PyThreadState_Current;
4108     PyObject* exc_type = tstate->curexc_type;
4109     if (unlikely(exc_type)) {
4110         if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
4111             PyObject *exc_value, *exc_tb;
4112             exc_value = tstate->curexc_value;
4113             exc_tb = tstate->curexc_traceback;
4114             tstate->curexc_type = 0;
4115             tstate->curexc_value = 0;
4116             tstate->curexc_traceback = 0;
4117             Py_DECREF(exc_type);
4118             Py_XDECREF(exc_value);
4119             Py_XDECREF(exc_tb);
4120             return 0;
4121         } else {
4122             return -1;
4123         }
4124     }
4125     return 0;
4126 #else
4127     if (unlikely(PyErr_Occurred())) {
4128         if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
4129             PyErr_Clear();
4130             return 0;
4131         } else {
4132             return -1;
4133         }
4134     }
4135     return 0;
4136 #endif
4137 }
4138 
4139 /* PyObjectCallNoArg */
4140 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallNoArg(PyObject * func)4141 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
4142 #if CYTHON_FAST_PYCALL
4143     if (PyFunction_Check(func)) {
4144         return __Pyx_PyFunction_FastCall(func, NULL, 0);
4145     }
4146 #endif
4147 #ifdef __Pyx_CyFunction_USED
4148     if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
4149 #else
4150     if (likely(PyCFunction_Check(func)))
4151 #endif
4152     {
4153         if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
4154             return __Pyx_PyObject_CallMethO(func, NULL);
4155         }
4156     }
4157     return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
4158 }
4159 #endif
4160 
4161 /* PyObjectGetMethod */
__Pyx_PyObject_GetMethod(PyObject * obj,PyObject * name,PyObject ** method)4162 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
4163     PyObject *attr;
4164 #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
4165     PyTypeObject *tp = Py_TYPE(obj);
4166     PyObject *descr;
4167     descrgetfunc f = NULL;
4168     PyObject **dictptr, *dict;
4169     int meth_found = 0;
4170     assert (*method == NULL);
4171     if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
4172         attr = __Pyx_PyObject_GetAttrStr(obj, name);
4173         goto try_unpack;
4174     }
4175     if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
4176         return 0;
4177     }
4178     descr = _PyType_Lookup(tp, name);
4179     if (likely(descr != NULL)) {
4180         Py_INCREF(descr);
4181 #if PY_MAJOR_VERSION >= 3
4182         #ifdef __Pyx_CyFunction_USED
4183         if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
4184         #else
4185         if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
4186         #endif
4187 #else
4188         #ifdef __Pyx_CyFunction_USED
4189         if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
4190         #else
4191         if (likely(PyFunction_Check(descr)))
4192         #endif
4193 #endif
4194         {
4195             meth_found = 1;
4196         } else {
4197             f = Py_TYPE(descr)->tp_descr_get;
4198             if (f != NULL && PyDescr_IsData(descr)) {
4199                 attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
4200                 Py_DECREF(descr);
4201                 goto try_unpack;
4202             }
4203         }
4204     }
4205     dictptr = _PyObject_GetDictPtr(obj);
4206     if (dictptr != NULL && (dict = *dictptr) != NULL) {
4207         Py_INCREF(dict);
4208         attr = __Pyx_PyDict_GetItemStr(dict, name);
4209         if (attr != NULL) {
4210             Py_INCREF(attr);
4211             Py_DECREF(dict);
4212             Py_XDECREF(descr);
4213             goto try_unpack;
4214         }
4215         Py_DECREF(dict);
4216     }
4217     if (meth_found) {
4218         *method = descr;
4219         return 1;
4220     }
4221     if (f != NULL) {
4222         attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
4223         Py_DECREF(descr);
4224         goto try_unpack;
4225     }
4226     if (descr != NULL) {
4227         *method = descr;
4228         return 0;
4229     }
4230     PyErr_Format(PyExc_AttributeError,
4231 #if PY_MAJOR_VERSION >= 3
4232                  "'%.50s' object has no attribute '%U'",
4233                  tp->tp_name, name);
4234 #else
4235                  "'%.50s' object has no attribute '%.400s'",
4236                  tp->tp_name, PyString_AS_STRING(name));
4237 #endif
4238     return 0;
4239 #else
4240     attr = __Pyx_PyObject_GetAttrStr(obj, name);
4241     goto try_unpack;
4242 #endif
4243 try_unpack:
4244 #if CYTHON_UNPACK_METHODS
4245     if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
4246         PyObject *function = PyMethod_GET_FUNCTION(attr);
4247         Py_INCREF(function);
4248         Py_DECREF(attr);
4249         *method = function;
4250         return 1;
4251     }
4252 #endif
4253     *method = attr;
4254     return 0;
4255 }
4256 
4257 /* PyObjectCallMethod0 */
__Pyx_PyObject_CallMethod0(PyObject * obj,PyObject * method_name)4258 static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
4259     PyObject *method = NULL, *result = NULL;
4260     int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
4261     if (likely(is_method)) {
4262         result = __Pyx_PyObject_CallOneArg(method, obj);
4263         Py_DECREF(method);
4264         return result;
4265     }
4266     if (unlikely(!method)) goto bad;
4267     result = __Pyx_PyObject_CallNoArg(method);
4268     Py_DECREF(method);
4269 bad:
4270     return result;
4271 }
4272 
4273 /* RaiseNeedMoreValuesToUnpack */
__Pyx_RaiseNeedMoreValuesError(Py_ssize_t index)4274 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
4275     PyErr_Format(PyExc_ValueError,
4276                  "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
4277                  index, (index == 1) ? "" : "s");
4278 }
4279 
4280 /* RaiseTooManyValuesToUnpack */
__Pyx_RaiseTooManyValuesError(Py_ssize_t expected)4281 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
4282     PyErr_Format(PyExc_ValueError,
4283                  "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
4284 }
4285 
4286 /* UnpackItemEndCheck */
__Pyx_IternextUnpackEndCheck(PyObject * retval,Py_ssize_t expected)4287 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
4288     if (unlikely(retval)) {
4289         Py_DECREF(retval);
4290         __Pyx_RaiseTooManyValuesError(expected);
4291         return -1;
4292     } else {
4293         return __Pyx_IterFinish();
4294     }
4295     return 0;
4296 }
4297 
4298 /* RaiseNoneIterError */
__Pyx_RaiseNoneNotIterableError(void)4299 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
4300     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
4301 }
4302 
4303 /* UnpackTupleError */
__Pyx_UnpackTupleError(PyObject * t,Py_ssize_t index)4304 static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
4305     if (t == Py_None) {
4306       __Pyx_RaiseNoneNotIterableError();
4307     } else if (PyTuple_GET_SIZE(t) < index) {
4308       __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
4309     } else {
4310       __Pyx_RaiseTooManyValuesError(index);
4311     }
4312 }
4313 
4314 /* UnpackTuple2 */
__Pyx_unpack_tuple2_exact(PyObject * tuple,PyObject ** pvalue1,PyObject ** pvalue2,int decref_tuple)4315 static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
4316         PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) {
4317     PyObject *value1 = NULL, *value2 = NULL;
4318 #if CYTHON_COMPILING_IN_PYPY
4319     value1 = PySequence_ITEM(tuple, 0);  if (unlikely(!value1)) goto bad;
4320     value2 = PySequence_ITEM(tuple, 1);  if (unlikely(!value2)) goto bad;
4321 #else
4322     value1 = PyTuple_GET_ITEM(tuple, 0);  Py_INCREF(value1);
4323     value2 = PyTuple_GET_ITEM(tuple, 1);  Py_INCREF(value2);
4324 #endif
4325     if (decref_tuple) {
4326         Py_DECREF(tuple);
4327     }
4328     *pvalue1 = value1;
4329     *pvalue2 = value2;
4330     return 0;
4331 #if CYTHON_COMPILING_IN_PYPY
4332 bad:
4333     Py_XDECREF(value1);
4334     Py_XDECREF(value2);
4335     if (decref_tuple) { Py_XDECREF(tuple); }
4336     return -1;
4337 #endif
4338 }
__Pyx_unpack_tuple2_generic(PyObject * tuple,PyObject ** pvalue1,PyObject ** pvalue2,int has_known_size,int decref_tuple)4339 static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
4340                                        int has_known_size, int decref_tuple) {
4341     Py_ssize_t index;
4342     PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
4343     iternextfunc iternext;
4344     iter = PyObject_GetIter(tuple);
4345     if (unlikely(!iter)) goto bad;
4346     if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
4347     iternext = Py_TYPE(iter)->tp_iternext;
4348     value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
4349     value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
4350     if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
4351     Py_DECREF(iter);
4352     *pvalue1 = value1;
4353     *pvalue2 = value2;
4354     return 0;
4355 unpacking_failed:
4356     if (!has_known_size && __Pyx_IterFinish() == 0)
4357         __Pyx_RaiseNeedMoreValuesError(index);
4358 bad:
4359     Py_XDECREF(iter);
4360     Py_XDECREF(value1);
4361     Py_XDECREF(value2);
4362     if (decref_tuple) { Py_XDECREF(tuple); }
4363     return -1;
4364 }
4365 
4366 /* dict_iter */
__Pyx_dict_iterator(PyObject * iterable,int is_dict,PyObject * method_name,Py_ssize_t * p_orig_length,int * p_source_is_dict)4367 static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
4368                                                    Py_ssize_t* p_orig_length, int* p_source_is_dict) {
4369     is_dict = is_dict || likely(PyDict_CheckExact(iterable));
4370     *p_source_is_dict = is_dict;
4371     if (is_dict) {
4372 #if !CYTHON_COMPILING_IN_PYPY
4373         *p_orig_length = PyDict_Size(iterable);
4374         Py_INCREF(iterable);
4375         return iterable;
4376 #elif PY_MAJOR_VERSION >= 3
4377         static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
4378         PyObject **pp = NULL;
4379         if (method_name) {
4380             const char *name = PyUnicode_AsUTF8(method_name);
4381             if (strcmp(name, "iteritems") == 0) pp = &py_items;
4382             else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
4383             else if (strcmp(name, "itervalues") == 0) pp = &py_values;
4384             if (pp) {
4385                 if (!*pp) {
4386                     *pp = PyUnicode_FromString(name + 4);
4387                     if (!*pp)
4388                         return NULL;
4389                 }
4390                 method_name = *pp;
4391             }
4392         }
4393 #endif
4394     }
4395     *p_orig_length = 0;
4396     if (method_name) {
4397         PyObject* iter;
4398         iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
4399         if (!iterable)
4400             return NULL;
4401 #if !CYTHON_COMPILING_IN_PYPY
4402         if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
4403             return iterable;
4404 #endif
4405         iter = PyObject_GetIter(iterable);
4406         Py_DECREF(iterable);
4407         return iter;
4408     }
4409     return PyObject_GetIter(iterable);
4410 }
__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)4411 static CYTHON_INLINE int __Pyx_dict_iter_next(
4412         PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
4413         PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
4414     PyObject* next_item;
4415 #if !CYTHON_COMPILING_IN_PYPY
4416     if (source_is_dict) {
4417         PyObject *key, *value;
4418         if (unlikely(orig_length != PyDict_Size(iter_obj))) {
4419             PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
4420             return -1;
4421         }
4422         if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
4423             return 0;
4424         }
4425         if (pitem) {
4426             PyObject* tuple = PyTuple_New(2);
4427             if (unlikely(!tuple)) {
4428                 return -1;
4429             }
4430             Py_INCREF(key);
4431             Py_INCREF(value);
4432             PyTuple_SET_ITEM(tuple, 0, key);
4433             PyTuple_SET_ITEM(tuple, 1, value);
4434             *pitem = tuple;
4435         } else {
4436             if (pkey) {
4437                 Py_INCREF(key);
4438                 *pkey = key;
4439             }
4440             if (pvalue) {
4441                 Py_INCREF(value);
4442                 *pvalue = value;
4443             }
4444         }
4445         return 1;
4446     } else if (PyTuple_CheckExact(iter_obj)) {
4447         Py_ssize_t pos = *ppos;
4448         if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
4449         *ppos = pos + 1;
4450         next_item = PyTuple_GET_ITEM(iter_obj, pos);
4451         Py_INCREF(next_item);
4452     } else if (PyList_CheckExact(iter_obj)) {
4453         Py_ssize_t pos = *ppos;
4454         if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
4455         *ppos = pos + 1;
4456         next_item = PyList_GET_ITEM(iter_obj, pos);
4457         Py_INCREF(next_item);
4458     } else
4459 #endif
4460     {
4461         next_item = PyIter_Next(iter_obj);
4462         if (unlikely(!next_item)) {
4463             return __Pyx_IterFinish();
4464         }
4465     }
4466     if (pitem) {
4467         *pitem = next_item;
4468     } else if (pkey && pvalue) {
4469         if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
4470             return -1;
4471     } else if (pkey) {
4472         *pkey = next_item;
4473     } else {
4474         *pvalue = next_item;
4475     }
4476     return 1;
4477 }
4478 
4479 /* GetException */
4480 #if CYTHON_FAST_THREAD_STATE
__Pyx__GetException(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)4481 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
4482 #else
4483 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
4484 #endif
4485 {
4486     PyObject *local_type, *local_value, *local_tb;
4487 #if CYTHON_FAST_THREAD_STATE
4488     PyObject *tmp_type, *tmp_value, *tmp_tb;
4489     local_type = tstate->curexc_type;
4490     local_value = tstate->curexc_value;
4491     local_tb = tstate->curexc_traceback;
4492     tstate->curexc_type = 0;
4493     tstate->curexc_value = 0;
4494     tstate->curexc_traceback = 0;
4495 #else
4496     PyErr_Fetch(&local_type, &local_value, &local_tb);
4497 #endif
4498     PyErr_NormalizeException(&local_type, &local_value, &local_tb);
4499 #if CYTHON_FAST_THREAD_STATE
4500     if (unlikely(tstate->curexc_type))
4501 #else
4502     if (unlikely(PyErr_Occurred()))
4503 #endif
4504         goto bad;
4505     #if PY_MAJOR_VERSION >= 3
4506     if (local_tb) {
4507         if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
4508             goto bad;
4509     }
4510     #endif
4511     Py_XINCREF(local_tb);
4512     Py_XINCREF(local_type);
4513     Py_XINCREF(local_value);
4514     *type = local_type;
4515     *value = local_value;
4516     *tb = local_tb;
4517 #if CYTHON_FAST_THREAD_STATE
4518     #if CYTHON_USE_EXC_INFO_STACK
4519     {
4520         _PyErr_StackItem *exc_info = tstate->exc_info;
4521         tmp_type = exc_info->exc_type;
4522         tmp_value = exc_info->exc_value;
4523         tmp_tb = exc_info->exc_traceback;
4524         exc_info->exc_type = local_type;
4525         exc_info->exc_value = local_value;
4526         exc_info->exc_traceback = local_tb;
4527     }
4528     #else
4529     tmp_type = tstate->exc_type;
4530     tmp_value = tstate->exc_value;
4531     tmp_tb = tstate->exc_traceback;
4532     tstate->exc_type = local_type;
4533     tstate->exc_value = local_value;
4534     tstate->exc_traceback = local_tb;
4535     #endif
4536     Py_XDECREF(tmp_type);
4537     Py_XDECREF(tmp_value);
4538     Py_XDECREF(tmp_tb);
4539 #else
4540     PyErr_SetExcInfo(local_type, local_value, local_tb);
4541 #endif
4542     return 0;
4543 bad:
4544     *type = 0;
4545     *value = 0;
4546     *tb = 0;
4547     Py_XDECREF(local_type);
4548     Py_XDECREF(local_value);
4549     Py_XDECREF(local_tb);
4550     return -1;
4551 }
4552 
4553 /* SwapException */
4554 #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSwap(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)4555 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
4556     PyObject *tmp_type, *tmp_value, *tmp_tb;
4557     #if CYTHON_USE_EXC_INFO_STACK
4558     _PyErr_StackItem *exc_info = tstate->exc_info;
4559     tmp_type = exc_info->exc_type;
4560     tmp_value = exc_info->exc_value;
4561     tmp_tb = exc_info->exc_traceback;
4562     exc_info->exc_type = *type;
4563     exc_info->exc_value = *value;
4564     exc_info->exc_traceback = *tb;
4565     #else
4566     tmp_type = tstate->exc_type;
4567     tmp_value = tstate->exc_value;
4568     tmp_tb = tstate->exc_traceback;
4569     tstate->exc_type = *type;
4570     tstate->exc_value = *value;
4571     tstate->exc_traceback = *tb;
4572     #endif
4573     *type = tmp_type;
4574     *value = tmp_value;
4575     *tb = tmp_tb;
4576 }
4577 #else
__Pyx_ExceptionSwap(PyObject ** type,PyObject ** value,PyObject ** tb)4578 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
4579     PyObject *tmp_type, *tmp_value, *tmp_tb;
4580     PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
4581     PyErr_SetExcInfo(*type, *value, *tb);
4582     *type = tmp_type;
4583     *value = tmp_value;
4584     *tb = tmp_tb;
4585 }
4586 #endif
4587 
4588 /* SaveResetException */
4589 #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSave(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)4590 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
4591     #if CYTHON_USE_EXC_INFO_STACK
4592     _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
4593     *type = exc_info->exc_type;
4594     *value = exc_info->exc_value;
4595     *tb = exc_info->exc_traceback;
4596     #else
4597     *type = tstate->exc_type;
4598     *value = tstate->exc_value;
4599     *tb = tstate->exc_traceback;
4600     #endif
4601     Py_XINCREF(*type);
4602     Py_XINCREF(*value);
4603     Py_XINCREF(*tb);
4604 }
__Pyx__ExceptionReset(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)4605 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
4606     PyObject *tmp_type, *tmp_value, *tmp_tb;
4607     #if CYTHON_USE_EXC_INFO_STACK
4608     _PyErr_StackItem *exc_info = tstate->exc_info;
4609     tmp_type = exc_info->exc_type;
4610     tmp_value = exc_info->exc_value;
4611     tmp_tb = exc_info->exc_traceback;
4612     exc_info->exc_type = type;
4613     exc_info->exc_value = value;
4614     exc_info->exc_traceback = tb;
4615     #else
4616     tmp_type = tstate->exc_type;
4617     tmp_value = tstate->exc_value;
4618     tmp_tb = tstate->exc_traceback;
4619     tstate->exc_type = type;
4620     tstate->exc_value = value;
4621     tstate->exc_traceback = tb;
4622     #endif
4623     Py_XDECREF(tmp_type);
4624     Py_XDECREF(tmp_value);
4625     Py_XDECREF(tmp_tb);
4626 }
4627 #endif
4628 
4629 /* TypeImport */
4630 #ifndef __PYX_HAVE_RT_ImportType
4631 #define __PYX_HAVE_RT_ImportType
__Pyx_ImportType(PyObject * module,const char * module_name,const char * class_name,size_t size,enum __Pyx_ImportType_CheckSize check_size)4632 static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
4633     size_t size, enum __Pyx_ImportType_CheckSize check_size)
4634 {
4635     PyObject *result = 0;
4636     char warning[200];
4637     Py_ssize_t basicsize;
4638 #ifdef Py_LIMITED_API
4639     PyObject *py_basicsize;
4640 #endif
4641     result = PyObject_GetAttrString(module, class_name);
4642     if (!result)
4643         goto bad;
4644     if (!PyType_Check(result)) {
4645         PyErr_Format(PyExc_TypeError,
4646             "%.200s.%.200s is not a type object",
4647             module_name, class_name);
4648         goto bad;
4649     }
4650 #ifndef Py_LIMITED_API
4651     basicsize = ((PyTypeObject *)result)->tp_basicsize;
4652 #else
4653     py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
4654     if (!py_basicsize)
4655         goto bad;
4656     basicsize = PyLong_AsSsize_t(py_basicsize);
4657     Py_DECREF(py_basicsize);
4658     py_basicsize = 0;
4659     if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
4660         goto bad;
4661 #endif
4662     if ((size_t)basicsize < size) {
4663         PyErr_Format(PyExc_ValueError,
4664             "%.200s.%.200s size changed, may indicate binary incompatibility. "
4665             "Expected %zd from C header, got %zd from PyObject",
4666             module_name, class_name, size, basicsize);
4667         goto bad;
4668     }
4669     if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
4670         PyErr_Format(PyExc_ValueError,
4671             "%.200s.%.200s size changed, may indicate binary incompatibility. "
4672             "Expected %zd from C header, got %zd from PyObject",
4673             module_name, class_name, size, basicsize);
4674         goto bad;
4675     }
4676     else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
4677         PyOS_snprintf(warning, sizeof(warning),
4678             "%s.%s size changed, may indicate binary incompatibility. "
4679             "Expected %zd from C header, got %zd from PyObject",
4680             module_name, class_name, size, basicsize);
4681         if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
4682     }
4683     return (PyTypeObject *)result;
4684 bad:
4685     Py_XDECREF(result);
4686     return NULL;
4687 }
4688 #endif
4689 
4690 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)4691 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
4692     PyObject *empty_list = 0;
4693     PyObject *module = 0;
4694     PyObject *global_dict = 0;
4695     PyObject *empty_dict = 0;
4696     PyObject *list;
4697     #if PY_MAJOR_VERSION < 3
4698     PyObject *py_import;
4699     py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
4700     if (!py_import)
4701         goto bad;
4702     #endif
4703     if (from_list)
4704         list = from_list;
4705     else {
4706         empty_list = PyList_New(0);
4707         if (!empty_list)
4708             goto bad;
4709         list = empty_list;
4710     }
4711     global_dict = PyModule_GetDict(__pyx_m);
4712     if (!global_dict)
4713         goto bad;
4714     empty_dict = PyDict_New();
4715     if (!empty_dict)
4716         goto bad;
4717     {
4718         #if PY_MAJOR_VERSION >= 3
4719         if (level == -1) {
4720             if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
4721                 module = PyImport_ImportModuleLevelObject(
4722                     name, global_dict, empty_dict, list, 1);
4723                 if (!module) {
4724                     if (!PyErr_ExceptionMatches(PyExc_ImportError))
4725                         goto bad;
4726                     PyErr_Clear();
4727                 }
4728             }
4729             level = 0;
4730         }
4731         #endif
4732         if (!module) {
4733             #if PY_MAJOR_VERSION < 3
4734             PyObject *py_level = PyInt_FromLong(level);
4735             if (!py_level)
4736                 goto bad;
4737             module = PyObject_CallFunctionObjArgs(py_import,
4738                 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
4739             Py_DECREF(py_level);
4740             #else
4741             module = PyImport_ImportModuleLevelObject(
4742                 name, global_dict, empty_dict, list, level);
4743             #endif
4744         }
4745     }
4746 bad:
4747     #if PY_MAJOR_VERSION < 3
4748     Py_XDECREF(py_import);
4749     #endif
4750     Py_XDECREF(empty_list);
4751     Py_XDECREF(empty_dict);
4752     return module;
4753 }
4754 
4755 /* ImportFrom */
__Pyx_ImportFrom(PyObject * module,PyObject * name)4756 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
4757     PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
4758     if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
4759         PyErr_Format(PyExc_ImportError,
4760         #if PY_MAJOR_VERSION < 3
4761             "cannot import name %.230s", PyString_AS_STRING(name));
4762         #else
4763             "cannot import name %S", name);
4764         #endif
4765     }
4766     return value;
4767 }
4768 
4769 /* PyDictVersioning */
4770 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)4771 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
4772     PyObject *dict = Py_TYPE(obj)->tp_dict;
4773     return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
4774 }
__Pyx_get_object_dict_version(PyObject * obj)4775 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
4776     PyObject **dictptr = NULL;
4777     Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
4778     if (offset) {
4779 #if CYTHON_COMPILING_IN_CPYTHON
4780         dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
4781 #else
4782         dictptr = _PyObject_GetDictPtr(obj);
4783 #endif
4784     }
4785     return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
4786 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)4787 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
4788     PyObject *dict = Py_TYPE(obj)->tp_dict;
4789     if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
4790         return 0;
4791     return obj_dict_version == __Pyx_get_object_dict_version(obj);
4792 }
4793 #endif
4794 
4795 /* GetModuleGlobalName */
4796 #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)4797 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
4798 #else
4799 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
4800 #endif
4801 {
4802     PyObject *result;
4803 #if !CYTHON_AVOID_BORROWED_REFS
4804 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
4805     result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
4806     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
4807     if (likely(result)) {
4808         return __Pyx_NewRef(result);
4809     } else if (unlikely(PyErr_Occurred())) {
4810         return NULL;
4811     }
4812 #else
4813     result = PyDict_GetItem(__pyx_d, name);
4814     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
4815     if (likely(result)) {
4816         return __Pyx_NewRef(result);
4817     }
4818 #endif
4819 #else
4820     result = PyObject_GetItem(__pyx_d, name);
4821     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
4822     if (likely(result)) {
4823         return __Pyx_NewRef(result);
4824     }
4825     PyErr_Clear();
4826 #endif
4827     return __Pyx_GetBuiltinName(name);
4828 }
4829 
4830 /* CLineInTraceback */
4831 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)4832 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
4833     PyObject *use_cline;
4834     PyObject *ptype, *pvalue, *ptraceback;
4835 #if CYTHON_COMPILING_IN_CPYTHON
4836     PyObject **cython_runtime_dict;
4837 #endif
4838     if (unlikely(!__pyx_cython_runtime)) {
4839         return c_line;
4840     }
4841     __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
4842 #if CYTHON_COMPILING_IN_CPYTHON
4843     cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
4844     if (likely(cython_runtime_dict)) {
4845         __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
4846             use_cline, *cython_runtime_dict,
4847             __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
4848     } else
4849 #endif
4850     {
4851       PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
4852       if (use_cline_obj) {
4853         use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
4854         Py_DECREF(use_cline_obj);
4855       } else {
4856         PyErr_Clear();
4857         use_cline = NULL;
4858       }
4859     }
4860     if (!use_cline) {
4861         c_line = 0;
4862         PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
4863     }
4864     else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
4865         c_line = 0;
4866     }
4867     __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
4868     return c_line;
4869 }
4870 #endif
4871 
4872 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)4873 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
4874     int start = 0, mid = 0, end = count - 1;
4875     if (end >= 0 && code_line > entries[end].code_line) {
4876         return count;
4877     }
4878     while (start < end) {
4879         mid = start + (end - start) / 2;
4880         if (code_line < entries[mid].code_line) {
4881             end = mid;
4882         } else if (code_line > entries[mid].code_line) {
4883              start = mid + 1;
4884         } else {
4885             return mid;
4886         }
4887     }
4888     if (code_line <= entries[mid].code_line) {
4889         return mid;
4890     } else {
4891         return mid + 1;
4892     }
4893 }
__pyx_find_code_object(int code_line)4894 static PyCodeObject *__pyx_find_code_object(int code_line) {
4895     PyCodeObject* code_object;
4896     int pos;
4897     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
4898         return NULL;
4899     }
4900     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
4901     if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
4902         return NULL;
4903     }
4904     code_object = __pyx_code_cache.entries[pos].code_object;
4905     Py_INCREF(code_object);
4906     return code_object;
4907 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)4908 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
4909     int pos, i;
4910     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
4911     if (unlikely(!code_line)) {
4912         return;
4913     }
4914     if (unlikely(!entries)) {
4915         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
4916         if (likely(entries)) {
4917             __pyx_code_cache.entries = entries;
4918             __pyx_code_cache.max_count = 64;
4919             __pyx_code_cache.count = 1;
4920             entries[0].code_line = code_line;
4921             entries[0].code_object = code_object;
4922             Py_INCREF(code_object);
4923         }
4924         return;
4925     }
4926     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
4927     if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
4928         PyCodeObject* tmp = entries[pos].code_object;
4929         entries[pos].code_object = code_object;
4930         Py_DECREF(tmp);
4931         return;
4932     }
4933     if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
4934         int new_max = __pyx_code_cache.max_count + 64;
4935         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
4936             __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
4937         if (unlikely(!entries)) {
4938             return;
4939         }
4940         __pyx_code_cache.entries = entries;
4941         __pyx_code_cache.max_count = new_max;
4942     }
4943     for (i=__pyx_code_cache.count; i>pos; i--) {
4944         entries[i] = entries[i-1];
4945     }
4946     entries[pos].code_line = code_line;
4947     entries[pos].code_object = code_object;
4948     __pyx_code_cache.count++;
4949     Py_INCREF(code_object);
4950 }
4951 
4952 /* AddTraceback */
4953 #include "compile.h"
4954 #include "frameobject.h"
4955 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)4956 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
4957             const char *funcname, int c_line,
4958             int py_line, const char *filename) {
4959     PyCodeObject *py_code = 0;
4960     PyObject *py_srcfile = 0;
4961     PyObject *py_funcname = 0;
4962     #if PY_MAJOR_VERSION < 3
4963     py_srcfile = PyString_FromString(filename);
4964     #else
4965     py_srcfile = PyUnicode_FromString(filename);
4966     #endif
4967     if (!py_srcfile) goto bad;
4968     if (c_line) {
4969         #if PY_MAJOR_VERSION < 3
4970         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
4971         #else
4972         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
4973         #endif
4974     }
4975     else {
4976         #if PY_MAJOR_VERSION < 3
4977         py_funcname = PyString_FromString(funcname);
4978         #else
4979         py_funcname = PyUnicode_FromString(funcname);
4980         #endif
4981     }
4982     if (!py_funcname) goto bad;
4983     py_code = __Pyx_PyCode_New(
4984         0,
4985         0,
4986         0,
4987         0,
4988         0,
4989         __pyx_empty_bytes, /*PyObject *code,*/
4990         __pyx_empty_tuple, /*PyObject *consts,*/
4991         __pyx_empty_tuple, /*PyObject *names,*/
4992         __pyx_empty_tuple, /*PyObject *varnames,*/
4993         __pyx_empty_tuple, /*PyObject *freevars,*/
4994         __pyx_empty_tuple, /*PyObject *cellvars,*/
4995         py_srcfile,   /*PyObject *filename,*/
4996         py_funcname,  /*PyObject *name,*/
4997         py_line,
4998         __pyx_empty_bytes  /*PyObject *lnotab*/
4999     );
5000     Py_DECREF(py_srcfile);
5001     Py_DECREF(py_funcname);
5002     return py_code;
5003 bad:
5004     Py_XDECREF(py_srcfile);
5005     Py_XDECREF(py_funcname);
5006     return NULL;
5007 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)5008 static void __Pyx_AddTraceback(const char *funcname, int c_line,
5009                                int py_line, const char *filename) {
5010     PyCodeObject *py_code = 0;
5011     PyFrameObject *py_frame = 0;
5012     PyThreadState *tstate = __Pyx_PyThreadState_Current;
5013     if (c_line) {
5014         c_line = __Pyx_CLineForTraceback(tstate, c_line);
5015     }
5016     py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
5017     if (!py_code) {
5018         py_code = __Pyx_CreateCodeObjectForTraceback(
5019             funcname, c_line, py_line, filename);
5020         if (!py_code) goto bad;
5021         __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
5022     }
5023     py_frame = PyFrame_New(
5024         tstate,            /*PyThreadState *tstate,*/
5025         py_code,           /*PyCodeObject *code,*/
5026         __pyx_d,    /*PyObject *globals,*/
5027         0                  /*PyObject *locals*/
5028     );
5029     if (!py_frame) goto bad;
5030     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
5031     PyTraceBack_Here(py_frame);
5032 bad:
5033     Py_XDECREF(py_code);
5034     Py_XDECREF(py_frame);
5035 }
5036 
5037 /* CIntToPy */
__Pyx_PyInt_From_long(long value)5038 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
5039     const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
5040     const int is_unsigned = neg_one > const_zero;
5041     if (is_unsigned) {
5042         if (sizeof(long) < sizeof(long)) {
5043             return PyInt_FromLong((long) value);
5044         } else if (sizeof(long) <= sizeof(unsigned long)) {
5045             return PyLong_FromUnsignedLong((unsigned long) value);
5046 #ifdef HAVE_LONG_LONG
5047         } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
5048             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
5049 #endif
5050         }
5051     } else {
5052         if (sizeof(long) <= sizeof(long)) {
5053             return PyInt_FromLong((long) value);
5054 #ifdef HAVE_LONG_LONG
5055         } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
5056             return PyLong_FromLongLong((PY_LONG_LONG) value);
5057 #endif
5058         }
5059     }
5060     {
5061         int one = 1; int little = (int)*(unsigned char *)&one;
5062         unsigned char *bytes = (unsigned char *)&value;
5063         return _PyLong_FromByteArray(bytes, sizeof(long),
5064                                      little, !is_unsigned);
5065     }
5066 }
5067 
5068 /* CIntFromPyVerify */
5069 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
5070     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
5071 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
5072     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
5073 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
5074     {\
5075         func_type value = func_value;\
5076         if (sizeof(target_type) < sizeof(func_type)) {\
5077             if (unlikely(value != (func_type) (target_type) value)) {\
5078                 func_type zero = 0;\
5079                 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
5080                     return (target_type) -1;\
5081                 if (is_unsigned && unlikely(value < zero))\
5082                     goto raise_neg_overflow;\
5083                 else\
5084                     goto raise_overflow;\
5085             }\
5086         }\
5087         return (target_type) value;\
5088     }
5089 
5090 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)5091 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
5092     const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
5093     const int is_unsigned = neg_one > const_zero;
5094 #if PY_MAJOR_VERSION < 3
5095     if (likely(PyInt_Check(x))) {
5096         if (sizeof(long) < sizeof(long)) {
5097             __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
5098         } else {
5099             long val = PyInt_AS_LONG(x);
5100             if (is_unsigned && unlikely(val < 0)) {
5101                 goto raise_neg_overflow;
5102             }
5103             return (long) val;
5104         }
5105     } else
5106 #endif
5107     if (likely(PyLong_Check(x))) {
5108         if (is_unsigned) {
5109 #if CYTHON_USE_PYLONG_INTERNALS
5110             const digit* digits = ((PyLongObject*)x)->ob_digit;
5111             switch (Py_SIZE(x)) {
5112                 case  0: return (long) 0;
5113                 case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
5114                 case 2:
5115                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
5116                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5117                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5118                         } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
5119                             return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
5120                         }
5121                     }
5122                     break;
5123                 case 3:
5124                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
5125                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5126                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5127                         } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
5128                             return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
5129                         }
5130                     }
5131                     break;
5132                 case 4:
5133                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
5134                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5135                             __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])))
5136                         } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
5137                             return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
5138                         }
5139                     }
5140                     break;
5141             }
5142 #endif
5143 #if CYTHON_COMPILING_IN_CPYTHON
5144             if (unlikely(Py_SIZE(x) < 0)) {
5145                 goto raise_neg_overflow;
5146             }
5147 #else
5148             {
5149                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
5150                 if (unlikely(result < 0))
5151                     return (long) -1;
5152                 if (unlikely(result == 1))
5153                     goto raise_neg_overflow;
5154             }
5155 #endif
5156             if (sizeof(long) <= sizeof(unsigned long)) {
5157                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
5158 #ifdef HAVE_LONG_LONG
5159             } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
5160                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
5161 #endif
5162             }
5163         } else {
5164 #if CYTHON_USE_PYLONG_INTERNALS
5165             const digit* digits = ((PyLongObject*)x)->ob_digit;
5166             switch (Py_SIZE(x)) {
5167                 case  0: return (long) 0;
5168                 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
5169                 case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
5170                 case -2:
5171                     if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
5172                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5173                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5174                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
5175                             return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5176                         }
5177                     }
5178                     break;
5179                 case 2:
5180                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
5181                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5182                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5183                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
5184                             return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5185                         }
5186                     }
5187                     break;
5188                 case -3:
5189                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
5190                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5191                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5192                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5193                             return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5194                         }
5195                     }
5196                     break;
5197                 case 3:
5198                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
5199                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5200                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5201                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5202                             return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5203                         }
5204                     }
5205                     break;
5206                 case -4:
5207                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5208                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5209                             __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])))
5210                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
5211                             return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5212                         }
5213                     }
5214                     break;
5215                 case 4:
5216                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
5217                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5218                             __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])))
5219                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
5220                             return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5221                         }
5222                     }
5223                     break;
5224             }
5225 #endif
5226             if (sizeof(long) <= sizeof(long)) {
5227                 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
5228 #ifdef HAVE_LONG_LONG
5229             } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
5230                 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
5231 #endif
5232             }
5233         }
5234         {
5235 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
5236             PyErr_SetString(PyExc_RuntimeError,
5237                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
5238 #else
5239             long val;
5240             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
5241  #if PY_MAJOR_VERSION < 3
5242             if (likely(v) && !PyLong_Check(v)) {
5243                 PyObject *tmp = v;
5244                 v = PyNumber_Long(tmp);
5245                 Py_DECREF(tmp);
5246             }
5247  #endif
5248             if (likely(v)) {
5249                 int one = 1; int is_little = (int)*(unsigned char *)&one;
5250                 unsigned char *bytes = (unsigned char *)&val;
5251                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
5252                                               bytes, sizeof(val),
5253                                               is_little, !is_unsigned);
5254                 Py_DECREF(v);
5255                 if (likely(!ret))
5256                     return val;
5257             }
5258 #endif
5259             return (long) -1;
5260         }
5261     } else {
5262         long val;
5263         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
5264         if (!tmp) return (long) -1;
5265         val = __Pyx_PyInt_As_long(tmp);
5266         Py_DECREF(tmp);
5267         return val;
5268     }
5269 raise_overflow:
5270     PyErr_SetString(PyExc_OverflowError,
5271         "value too large to convert to long");
5272     return (long) -1;
5273 raise_neg_overflow:
5274     PyErr_SetString(PyExc_OverflowError,
5275         "can't convert negative value to long");
5276     return (long) -1;
5277 }
5278 
5279 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)5280 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
5281     const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
5282     const int is_unsigned = neg_one > const_zero;
5283 #if PY_MAJOR_VERSION < 3
5284     if (likely(PyInt_Check(x))) {
5285         if (sizeof(int) < sizeof(long)) {
5286             __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
5287         } else {
5288             long val = PyInt_AS_LONG(x);
5289             if (is_unsigned && unlikely(val < 0)) {
5290                 goto raise_neg_overflow;
5291             }
5292             return (int) val;
5293         }
5294     } else
5295 #endif
5296     if (likely(PyLong_Check(x))) {
5297         if (is_unsigned) {
5298 #if CYTHON_USE_PYLONG_INTERNALS
5299             const digit* digits = ((PyLongObject*)x)->ob_digit;
5300             switch (Py_SIZE(x)) {
5301                 case  0: return (int) 0;
5302                 case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
5303                 case 2:
5304                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
5305                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5306                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5307                         } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
5308                             return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
5309                         }
5310                     }
5311                     break;
5312                 case 3:
5313                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
5314                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5315                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5316                         } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
5317                             return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
5318                         }
5319                     }
5320                     break;
5321                 case 4:
5322                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
5323                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5324                             __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])))
5325                         } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
5326                             return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
5327                         }
5328                     }
5329                     break;
5330             }
5331 #endif
5332 #if CYTHON_COMPILING_IN_CPYTHON
5333             if (unlikely(Py_SIZE(x) < 0)) {
5334                 goto raise_neg_overflow;
5335             }
5336 #else
5337             {
5338                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
5339                 if (unlikely(result < 0))
5340                     return (int) -1;
5341                 if (unlikely(result == 1))
5342                     goto raise_neg_overflow;
5343             }
5344 #endif
5345             if (sizeof(int) <= sizeof(unsigned long)) {
5346                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
5347 #ifdef HAVE_LONG_LONG
5348             } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
5349                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
5350 #endif
5351             }
5352         } else {
5353 #if CYTHON_USE_PYLONG_INTERNALS
5354             const digit* digits = ((PyLongObject*)x)->ob_digit;
5355             switch (Py_SIZE(x)) {
5356                 case  0: return (int) 0;
5357                 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
5358                 case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
5359                 case -2:
5360                     if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
5361                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5362                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5363                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
5364                             return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
5365                         }
5366                     }
5367                     break;
5368                 case 2:
5369                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
5370                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5371                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5372                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
5373                             return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
5374                         }
5375                     }
5376                     break;
5377                 case -3:
5378                     if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
5379                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5380                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5381                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
5382                             return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
5383                         }
5384                     }
5385                     break;
5386                 case 3:
5387                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
5388                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5389                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5390                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
5391                             return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
5392                         }
5393                     }
5394                     break;
5395                 case -4:
5396                     if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
5397                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5398                             __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])))
5399                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
5400                             return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
5401                         }
5402                     }
5403                     break;
5404                 case 4:
5405                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
5406                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5407                             __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])))
5408                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
5409                             return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
5410                         }
5411                     }
5412                     break;
5413             }
5414 #endif
5415             if (sizeof(int) <= sizeof(long)) {
5416                 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
5417 #ifdef HAVE_LONG_LONG
5418             } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
5419                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
5420 #endif
5421             }
5422         }
5423         {
5424 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
5425             PyErr_SetString(PyExc_RuntimeError,
5426                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
5427 #else
5428             int val;
5429             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
5430  #if PY_MAJOR_VERSION < 3
5431             if (likely(v) && !PyLong_Check(v)) {
5432                 PyObject *tmp = v;
5433                 v = PyNumber_Long(tmp);
5434                 Py_DECREF(tmp);
5435             }
5436  #endif
5437             if (likely(v)) {
5438                 int one = 1; int is_little = (int)*(unsigned char *)&one;
5439                 unsigned char *bytes = (unsigned char *)&val;
5440                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
5441                                               bytes, sizeof(val),
5442                                               is_little, !is_unsigned);
5443                 Py_DECREF(v);
5444                 if (likely(!ret))
5445                     return val;
5446             }
5447 #endif
5448             return (int) -1;
5449         }
5450     } else {
5451         int val;
5452         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
5453         if (!tmp) return (int) -1;
5454         val = __Pyx_PyInt_As_int(tmp);
5455         Py_DECREF(tmp);
5456         return val;
5457     }
5458 raise_overflow:
5459     PyErr_SetString(PyExc_OverflowError,
5460         "value too large to convert to int");
5461     return (int) -1;
5462 raise_neg_overflow:
5463     PyErr_SetString(PyExc_OverflowError,
5464         "can't convert negative value to int");
5465     return (int) -1;
5466 }
5467 
5468 /* FastTypeChecks */
5469 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)5470 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
5471     while (a) {
5472         a = a->tp_base;
5473         if (a == b)
5474             return 1;
5475     }
5476     return b == &PyBaseObject_Type;
5477 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)5478 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
5479     PyObject *mro;
5480     if (a == b) return 1;
5481     mro = a->tp_mro;
5482     if (likely(mro)) {
5483         Py_ssize_t i, n;
5484         n = PyTuple_GET_SIZE(mro);
5485         for (i = 0; i < n; i++) {
5486             if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
5487                 return 1;
5488         }
5489         return 0;
5490     }
5491     return __Pyx_InBases(a, b);
5492 }
5493 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)5494 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
5495     PyObject *exception, *value, *tb;
5496     int res;
5497     __Pyx_PyThreadState_declare
5498     __Pyx_PyThreadState_assign
5499     __Pyx_ErrFetch(&exception, &value, &tb);
5500     res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
5501     if (unlikely(res == -1)) {
5502         PyErr_WriteUnraisable(err);
5503         res = 0;
5504     }
5505     if (!res) {
5506         res = PyObject_IsSubclass(err, exc_type2);
5507         if (unlikely(res == -1)) {
5508             PyErr_WriteUnraisable(err);
5509             res = 0;
5510         }
5511     }
5512     __Pyx_ErrRestore(exception, value, tb);
5513     return res;
5514 }
5515 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)5516 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
5517     int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
5518     if (!res) {
5519         res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
5520     }
5521     return res;
5522 }
5523 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)5524 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
5525     Py_ssize_t i, n;
5526     assert(PyExceptionClass_Check(exc_type));
5527     n = PyTuple_GET_SIZE(tuple);
5528 #if PY_MAJOR_VERSION >= 3
5529     for (i=0; i<n; i++) {
5530         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
5531     }
5532 #endif
5533     for (i=0; i<n; i++) {
5534         PyObject *t = PyTuple_GET_ITEM(tuple, i);
5535         #if PY_MAJOR_VERSION < 3
5536         if (likely(exc_type == t)) return 1;
5537         #endif
5538         if (likely(PyExceptionClass_Check(t))) {
5539             if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
5540         } else {
5541         }
5542     }
5543     return 0;
5544 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)5545 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
5546     if (likely(err == exc_type)) return 1;
5547     if (likely(PyExceptionClass_Check(err))) {
5548         if (likely(PyExceptionClass_Check(exc_type))) {
5549             return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
5550         } else if (likely(PyTuple_Check(exc_type))) {
5551             return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
5552         } else {
5553         }
5554     }
5555     return PyErr_GivenExceptionMatches(err, exc_type);
5556 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)5557 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
5558     assert(PyExceptionClass_Check(exc_type1));
5559     assert(PyExceptionClass_Check(exc_type2));
5560     if (likely(err == exc_type1 || err == exc_type2)) return 1;
5561     if (likely(PyExceptionClass_Check(err))) {
5562         return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
5563     }
5564     return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
5565 }
5566 #endif
5567 
5568 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)5569 static int __Pyx_check_binary_version(void) {
5570     char ctversion[4], rtversion[4];
5571     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
5572     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
5573     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
5574         char message[200];
5575         PyOS_snprintf(message, sizeof(message),
5576                       "compiletime version %s of module '%.100s' "
5577                       "does not match runtime version %s",
5578                       ctversion, __Pyx_MODULE_NAME, rtversion);
5579         return PyErr_WarnEx(NULL, message, 1);
5580     }
5581     return 0;
5582 }
5583 
5584 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)5585 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
5586     while (t->p) {
5587         #if PY_MAJOR_VERSION < 3
5588         if (t->is_unicode) {
5589             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
5590         } else if (t->intern) {
5591             *t->p = PyString_InternFromString(t->s);
5592         } else {
5593             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
5594         }
5595         #else
5596         if (t->is_unicode | t->is_str) {
5597             if (t->intern) {
5598                 *t->p = PyUnicode_InternFromString(t->s);
5599             } else if (t->encoding) {
5600                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
5601             } else {
5602                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
5603             }
5604         } else {
5605             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
5606         }
5607         #endif
5608         if (!*t->p)
5609             return -1;
5610         if (PyObject_Hash(*t->p) == -1)
5611             return -1;
5612         ++t;
5613     }
5614     return 0;
5615 }
5616 
__Pyx_PyUnicode_FromString(const char * c_str)5617 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
5618     return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
5619 }
__Pyx_PyObject_AsString(PyObject * o)5620 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
5621     Py_ssize_t ignore;
5622     return __Pyx_PyObject_AsStringAndSize(o, &ignore);
5623 }
5624 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
5625 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)5626 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
5627     char* defenc_c;
5628     PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
5629     if (!defenc) return NULL;
5630     defenc_c = PyBytes_AS_STRING(defenc);
5631 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
5632     {
5633         char* end = defenc_c + PyBytes_GET_SIZE(defenc);
5634         char* c;
5635         for (c = defenc_c; c < end; c++) {
5636             if ((unsigned char) (*c) >= 128) {
5637                 PyUnicode_AsASCIIString(o);
5638                 return NULL;
5639             }
5640         }
5641     }
5642 #endif
5643     *length = PyBytes_GET_SIZE(defenc);
5644     return defenc_c;
5645 }
5646 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)5647 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
5648     if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
5649 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
5650     if (likely(PyUnicode_IS_ASCII(o))) {
5651         *length = PyUnicode_GET_LENGTH(o);
5652         return PyUnicode_AsUTF8(o);
5653     } else {
5654         PyUnicode_AsASCIIString(o);
5655         return NULL;
5656     }
5657 #else
5658     return PyUnicode_AsUTF8AndSize(o, length);
5659 #endif
5660 }
5661 #endif
5662 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)5663 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
5664 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
5665     if (
5666 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
5667             __Pyx_sys_getdefaultencoding_not_ascii &&
5668 #endif
5669             PyUnicode_Check(o)) {
5670         return __Pyx_PyUnicode_AsStringAndSize(o, length);
5671     } else
5672 #endif
5673 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
5674     if (PyByteArray_Check(o)) {
5675         *length = PyByteArray_GET_SIZE(o);
5676         return PyByteArray_AS_STRING(o);
5677     } else
5678 #endif
5679     {
5680         char* result;
5681         int r = PyBytes_AsStringAndSize(o, &result, length);
5682         if (unlikely(r < 0)) {
5683             return NULL;
5684         } else {
5685             return result;
5686         }
5687     }
5688 }
__Pyx_PyObject_IsTrue(PyObject * x)5689 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
5690    int is_true = x == Py_True;
5691    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
5692    else return PyObject_IsTrue(x);
5693 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)5694 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
5695     int retval;
5696     if (unlikely(!x)) return -1;
5697     retval = __Pyx_PyObject_IsTrue(x);
5698     Py_DECREF(x);
5699     return retval;
5700 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)5701 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
5702 #if PY_MAJOR_VERSION >= 3
5703     if (PyLong_Check(result)) {
5704         if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
5705                 "__int__ returned non-int (type %.200s).  "
5706                 "The ability to return an instance of a strict subclass of int "
5707                 "is deprecated, and may be removed in a future version of Python.",
5708                 Py_TYPE(result)->tp_name)) {
5709             Py_DECREF(result);
5710             return NULL;
5711         }
5712         return result;
5713     }
5714 #endif
5715     PyErr_Format(PyExc_TypeError,
5716                  "__%.4s__ returned non-%.4s (type %.200s)",
5717                  type_name, type_name, Py_TYPE(result)->tp_name);
5718     Py_DECREF(result);
5719     return NULL;
5720 }
__Pyx_PyNumber_IntOrLong(PyObject * x)5721 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
5722 #if CYTHON_USE_TYPE_SLOTS
5723   PyNumberMethods *m;
5724 #endif
5725   const char *name = NULL;
5726   PyObject *res = NULL;
5727 #if PY_MAJOR_VERSION < 3
5728   if (likely(PyInt_Check(x) || PyLong_Check(x)))
5729 #else
5730   if (likely(PyLong_Check(x)))
5731 #endif
5732     return __Pyx_NewRef(x);
5733 #if CYTHON_USE_TYPE_SLOTS
5734   m = Py_TYPE(x)->tp_as_number;
5735   #if PY_MAJOR_VERSION < 3
5736   if (m && m->nb_int) {
5737     name = "int";
5738     res = m->nb_int(x);
5739   }
5740   else if (m && m->nb_long) {
5741     name = "long";
5742     res = m->nb_long(x);
5743   }
5744   #else
5745   if (likely(m && m->nb_int)) {
5746     name = "int";
5747     res = m->nb_int(x);
5748   }
5749   #endif
5750 #else
5751   if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
5752     res = PyNumber_Int(x);
5753   }
5754 #endif
5755   if (likely(res)) {
5756 #if PY_MAJOR_VERSION < 3
5757     if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
5758 #else
5759     if (unlikely(!PyLong_CheckExact(res))) {
5760 #endif
5761         return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
5762     }
5763   }
5764   else if (!PyErr_Occurred()) {
5765     PyErr_SetString(PyExc_TypeError,
5766                     "an integer is required");
5767   }
5768   return res;
5769 }
5770 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
5771   Py_ssize_t ival;
5772   PyObject *x;
5773 #if PY_MAJOR_VERSION < 3
5774   if (likely(PyInt_CheckExact(b))) {
5775     if (sizeof(Py_ssize_t) >= sizeof(long))
5776         return PyInt_AS_LONG(b);
5777     else
5778         return PyInt_AsSsize_t(b);
5779   }
5780 #endif
5781   if (likely(PyLong_CheckExact(b))) {
5782     #if CYTHON_USE_PYLONG_INTERNALS
5783     const digit* digits = ((PyLongObject*)b)->ob_digit;
5784     const Py_ssize_t size = Py_SIZE(b);
5785     if (likely(__Pyx_sst_abs(size) <= 1)) {
5786         ival = likely(size) ? digits[0] : 0;
5787         if (size == -1) ival = -ival;
5788         return ival;
5789     } else {
5790       switch (size) {
5791          case 2:
5792            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
5793              return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5794            }
5795            break;
5796          case -2:
5797            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
5798              return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5799            }
5800            break;
5801          case 3:
5802            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
5803              return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5804            }
5805            break;
5806          case -3:
5807            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
5808              return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5809            }
5810            break;
5811          case 4:
5812            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
5813              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]));
5814            }
5815            break;
5816          case -4:
5817            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
5818              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]));
5819            }
5820            break;
5821       }
5822     }
5823     #endif
5824     return PyLong_AsSsize_t(b);
5825   }
5826   x = PyNumber_Index(b);
5827   if (!x) return -1;
5828   ival = PyInt_AsSsize_t(x);
5829   Py_DECREF(x);
5830   return ival;
5831 }
5832 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
5833   return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
5834 }
5835 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
5836     return PyInt_FromSize_t(ival);
5837 }
5838 
5839 
5840 #endif /* Py_PYTHON_H */
5841