You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

11800 line
449 KiB

  1. /* Generated by Cython 0.29 */
  2. #define PY_SSIZE_T_CLEAN
  3. #include "Python.h"
  4. #ifndef Py_PYTHON_H
  5. #error Python headers needed to compile C extensions, please install development version of Python.
  6. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
  7. #error Cython requires Python 2.6+ or Python 3.3+.
  8. #else
  9. #define CYTHON_ABI "0_29"
  10. #define CYTHON_HEX_VERSION 0x001D00F0
  11. #define CYTHON_FUTURE_DIVISION 1
  12. #include <stddef.h>
  13. #ifndef offsetof
  14. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  15. #endif
  16. #if !defined(WIN32) && !defined(MS_WINDOWS)
  17. #ifndef __stdcall
  18. #define __stdcall
  19. #endif
  20. #ifndef __cdecl
  21. #define __cdecl
  22. #endif
  23. #ifndef __fastcall
  24. #define __fastcall
  25. #endif
  26. #endif
  27. #ifndef DL_IMPORT
  28. #define DL_IMPORT(t) t
  29. #endif
  30. #ifndef DL_EXPORT
  31. #define DL_EXPORT(t) t
  32. #endif
  33. #define __PYX_COMMA ,
  34. #ifndef HAVE_LONG_LONG
  35. #if PY_VERSION_HEX >= 0x02070000
  36. #define HAVE_LONG_LONG
  37. #endif
  38. #endif
  39. #ifndef PY_LONG_LONG
  40. #define PY_LONG_LONG LONG_LONG
  41. #endif
  42. #ifndef Py_HUGE_VAL
  43. #define Py_HUGE_VAL HUGE_VAL
  44. #endif
  45. #ifdef PYPY_VERSION
  46. #define CYTHON_COMPILING_IN_PYPY 1
  47. #define CYTHON_COMPILING_IN_PYSTON 0
  48. #define CYTHON_COMPILING_IN_CPYTHON 0
  49. #undef CYTHON_USE_TYPE_SLOTS
  50. #define CYTHON_USE_TYPE_SLOTS 0
  51. #undef CYTHON_USE_PYTYPE_LOOKUP
  52. #define CYTHON_USE_PYTYPE_LOOKUP 0
  53. #if PY_VERSION_HEX < 0x03050000
  54. #undef CYTHON_USE_ASYNC_SLOTS
  55. #define CYTHON_USE_ASYNC_SLOTS 0
  56. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  57. #define CYTHON_USE_ASYNC_SLOTS 1
  58. #endif
  59. #undef CYTHON_USE_PYLIST_INTERNALS
  60. #define CYTHON_USE_PYLIST_INTERNALS 0
  61. #undef CYTHON_USE_UNICODE_INTERNALS
  62. #define CYTHON_USE_UNICODE_INTERNALS 0
  63. #undef CYTHON_USE_UNICODE_WRITER
  64. #define CYTHON_USE_UNICODE_WRITER 0
  65. #undef CYTHON_USE_PYLONG_INTERNALS
  66. #define CYTHON_USE_PYLONG_INTERNALS 0
  67. #undef CYTHON_AVOID_BORROWED_REFS
  68. #define CYTHON_AVOID_BORROWED_REFS 1
  69. #undef CYTHON_ASSUME_SAFE_MACROS
  70. #define CYTHON_ASSUME_SAFE_MACROS 0
  71. #undef CYTHON_UNPACK_METHODS
  72. #define CYTHON_UNPACK_METHODS 0
  73. #undef CYTHON_FAST_THREAD_STATE
  74. #define CYTHON_FAST_THREAD_STATE 0
  75. #undef CYTHON_FAST_PYCALL
  76. #define CYTHON_FAST_PYCALL 0
  77. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  78. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  79. #undef CYTHON_USE_TP_FINALIZE
  80. #define CYTHON_USE_TP_FINALIZE 0
  81. #undef CYTHON_USE_DICT_VERSIONS
  82. #define CYTHON_USE_DICT_VERSIONS 0
  83. #undef CYTHON_USE_EXC_INFO_STACK
  84. #define CYTHON_USE_EXC_INFO_STACK 0
  85. #elif defined(PYSTON_VERSION)
  86. #define CYTHON_COMPILING_IN_PYPY 0
  87. #define CYTHON_COMPILING_IN_PYSTON 1
  88. #define CYTHON_COMPILING_IN_CPYTHON 0
  89. #ifndef CYTHON_USE_TYPE_SLOTS
  90. #define CYTHON_USE_TYPE_SLOTS 1
  91. #endif
  92. #undef CYTHON_USE_PYTYPE_LOOKUP
  93. #define CYTHON_USE_PYTYPE_LOOKUP 0
  94. #undef CYTHON_USE_ASYNC_SLOTS
  95. #define CYTHON_USE_ASYNC_SLOTS 0
  96. #undef CYTHON_USE_PYLIST_INTERNALS
  97. #define CYTHON_USE_PYLIST_INTERNALS 0
  98. #ifndef CYTHON_USE_UNICODE_INTERNALS
  99. #define CYTHON_USE_UNICODE_INTERNALS 1
  100. #endif
  101. #undef CYTHON_USE_UNICODE_WRITER
  102. #define CYTHON_USE_UNICODE_WRITER 0
  103. #undef CYTHON_USE_PYLONG_INTERNALS
  104. #define CYTHON_USE_PYLONG_INTERNALS 0
  105. #ifndef CYTHON_AVOID_BORROWED_REFS
  106. #define CYTHON_AVOID_BORROWED_REFS 0
  107. #endif
  108. #ifndef CYTHON_ASSUME_SAFE_MACROS
  109. #define CYTHON_ASSUME_SAFE_MACROS 1
  110. #endif
  111. #ifndef CYTHON_UNPACK_METHODS
  112. #define CYTHON_UNPACK_METHODS 1
  113. #endif
  114. #undef CYTHON_FAST_THREAD_STATE
  115. #define CYTHON_FAST_THREAD_STATE 0
  116. #undef CYTHON_FAST_PYCALL
  117. #define CYTHON_FAST_PYCALL 0
  118. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  119. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  120. #undef CYTHON_USE_TP_FINALIZE
  121. #define CYTHON_USE_TP_FINALIZE 0
  122. #undef CYTHON_USE_DICT_VERSIONS
  123. #define CYTHON_USE_DICT_VERSIONS 0
  124. #undef CYTHON_USE_EXC_INFO_STACK
  125. #define CYTHON_USE_EXC_INFO_STACK 0
  126. #else
  127. #define CYTHON_COMPILING_IN_PYPY 0
  128. #define CYTHON_COMPILING_IN_PYSTON 0
  129. #define CYTHON_COMPILING_IN_CPYTHON 1
  130. #ifndef CYTHON_USE_TYPE_SLOTS
  131. #define CYTHON_USE_TYPE_SLOTS 1
  132. #endif
  133. #if PY_VERSION_HEX < 0x02070000
  134. #undef CYTHON_USE_PYTYPE_LOOKUP
  135. #define CYTHON_USE_PYTYPE_LOOKUP 0
  136. #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
  137. #define CYTHON_USE_PYTYPE_LOOKUP 1
  138. #endif
  139. #if PY_MAJOR_VERSION < 3
  140. #undef CYTHON_USE_ASYNC_SLOTS
  141. #define CYTHON_USE_ASYNC_SLOTS 0
  142. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  143. #define CYTHON_USE_ASYNC_SLOTS 1
  144. #endif
  145. #if PY_VERSION_HEX < 0x02070000
  146. #undef CYTHON_USE_PYLONG_INTERNALS
  147. #define CYTHON_USE_PYLONG_INTERNALS 0
  148. #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
  149. #define CYTHON_USE_PYLONG_INTERNALS 1
  150. #endif
  151. #ifndef CYTHON_USE_PYLIST_INTERNALS
  152. #define CYTHON_USE_PYLIST_INTERNALS 1
  153. #endif
  154. #ifndef CYTHON_USE_UNICODE_INTERNALS
  155. #define CYTHON_USE_UNICODE_INTERNALS 1
  156. #endif
  157. #if PY_VERSION_HEX < 0x030300F0
  158. #undef CYTHON_USE_UNICODE_WRITER
  159. #define CYTHON_USE_UNICODE_WRITER 0
  160. #elif !defined(CYTHON_USE_UNICODE_WRITER)
  161. #define CYTHON_USE_UNICODE_WRITER 1
  162. #endif
  163. #ifndef CYTHON_AVOID_BORROWED_REFS
  164. #define CYTHON_AVOID_BORROWED_REFS 0
  165. #endif
  166. #ifndef CYTHON_ASSUME_SAFE_MACROS
  167. #define CYTHON_ASSUME_SAFE_MACROS 1
  168. #endif
  169. #ifndef CYTHON_UNPACK_METHODS
  170. #define CYTHON_UNPACK_METHODS 1
  171. #endif
  172. #ifndef CYTHON_FAST_THREAD_STATE
  173. #define CYTHON_FAST_THREAD_STATE 1
  174. #endif
  175. #ifndef CYTHON_FAST_PYCALL
  176. #define CYTHON_FAST_PYCALL 1
  177. #endif
  178. #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
  179. #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  180. #endif
  181. #ifndef CYTHON_USE_TP_FINALIZE
  182. #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  183. #endif
  184. #ifndef CYTHON_USE_DICT_VERSIONS
  185. #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  186. #endif
  187. #ifndef CYTHON_USE_EXC_INFO_STACK
  188. #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  189. #endif
  190. #endif
  191. #if !defined(CYTHON_FAST_PYCCALL)
  192. #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
  193. #endif
  194. #if CYTHON_USE_PYLONG_INTERNALS
  195. #include "longintrepr.h"
  196. #undef SHIFT
  197. #undef BASE
  198. #undef MASK
  199. #endif
  200. #ifndef __has_attribute
  201. #define __has_attribute(x) 0
  202. #endif
  203. #ifndef __has_cpp_attribute
  204. #define __has_cpp_attribute(x) 0
  205. #endif
  206. #ifndef CYTHON_RESTRICT
  207. #if defined(__GNUC__)
  208. #define CYTHON_RESTRICT __restrict__
  209. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  210. #define CYTHON_RESTRICT __restrict
  211. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  212. #define CYTHON_RESTRICT restrict
  213. #else
  214. #define CYTHON_RESTRICT
  215. #endif
  216. #endif
  217. #ifndef CYTHON_UNUSED
  218. # if defined(__GNUC__)
  219. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  220. # define CYTHON_UNUSED __attribute__ ((__unused__))
  221. # else
  222. # define CYTHON_UNUSED
  223. # endif
  224. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  225. # define CYTHON_UNUSED __attribute__ ((__unused__))
  226. # else
  227. # define CYTHON_UNUSED
  228. # endif
  229. #endif
  230. #ifndef CYTHON_MAYBE_UNUSED_VAR
  231. # if defined(__cplusplus)
  232. template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
  233. # else
  234. # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
  235. # endif
  236. #endif
  237. #ifndef CYTHON_NCP_UNUSED
  238. # if CYTHON_COMPILING_IN_CPYTHON
  239. # define CYTHON_NCP_UNUSED
  240. # else
  241. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  242. # endif
  243. #endif
  244. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  245. #ifdef _MSC_VER
  246. #ifndef _MSC_STDINT_H_
  247. #if _MSC_VER < 1300
  248. typedef unsigned char uint8_t;
  249. typedef unsigned int uint32_t;
  250. #else
  251. typedef unsigned __int8 uint8_t;
  252. typedef unsigned __int32 uint32_t;
  253. #endif
  254. #endif
  255. #else
  256. #include <stdint.h>
  257. #endif
  258. #ifndef CYTHON_FALLTHROUGH
  259. #if defined(__cplusplus) && __cplusplus >= 201103L
  260. #if __has_cpp_attribute(fallthrough)
  261. #define CYTHON_FALLTHROUGH [[fallthrough]]
  262. #elif __has_cpp_attribute(clang::fallthrough)
  263. #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
  264. #elif __has_cpp_attribute(gnu::fallthrough)
  265. #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
  266. #endif
  267. #endif
  268. #ifndef CYTHON_FALLTHROUGH
  269. #if __has_attribute(fallthrough)
  270. #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
  271. #else
  272. #define CYTHON_FALLTHROUGH
  273. #endif
  274. #endif
  275. #if defined(__clang__ ) && defined(__apple_build_version__)
  276. #if __apple_build_version__ < 7000000
  277. #undef CYTHON_FALLTHROUGH
  278. #define CYTHON_FALLTHROUGH
  279. #endif
  280. #endif
  281. #endif
  282. #ifndef CYTHON_INLINE
  283. #if defined(__clang__)
  284. #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  285. #elif defined(__GNUC__)
  286. #define CYTHON_INLINE __inline__
  287. #elif defined(_MSC_VER)
  288. #define CYTHON_INLINE __inline
  289. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  290. #define CYTHON_INLINE inline
  291. #else
  292. #define CYTHON_INLINE
  293. #endif
  294. #endif
  295. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  296. #define Py_OptimizeFlag 0
  297. #endif
  298. #define __PYX_BUILD_PY_SSIZE_T "n"
  299. #define CYTHON_FORMAT_SSIZE_T "z"
  300. #if PY_MAJOR_VERSION < 3
  301. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  302. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  303. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  304. #define __Pyx_DefaultClassType PyClass_Type
  305. #else
  306. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  307. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  308. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  309. #define __Pyx_DefaultClassType PyType_Type
  310. #endif
  311. #ifndef Py_TPFLAGS_CHECKTYPES
  312. #define Py_TPFLAGS_CHECKTYPES 0
  313. #endif
  314. #ifndef Py_TPFLAGS_HAVE_INDEX
  315. #define Py_TPFLAGS_HAVE_INDEX 0
  316. #endif
  317. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  318. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  319. #endif
  320. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  321. #define Py_TPFLAGS_HAVE_FINALIZE 0
  322. #endif
  323. #ifndef METH_STACKLESS
  324. #define METH_STACKLESS 0
  325. #endif
  326. #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  327. #ifndef METH_FASTCALL
  328. #define METH_FASTCALL 0x80
  329. #endif
  330. typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  331. typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
  332. Py_ssize_t nargs, PyObject *kwnames);
  333. #else
  334. #define __Pyx_PyCFunctionFast _PyCFunctionFast
  335. #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
  336. #endif
  337. #if CYTHON_FAST_PYCCALL
  338. #define __Pyx_PyFastCFunction_Check(func)\
  339. ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
  340. #else
  341. #define __Pyx_PyFastCFunction_Check(func) 0
  342. #endif
  343. #if CYTHON_USE_DICT_VERSIONS
  344. #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
  345. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
  346. (version_var) = __PYX_GET_DICT_VERSION(dict);\
  347. (cache_var) = (value);
  348. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
  349. static PY_UINT64_T __pyx_dict_version = 0;\
  350. static PyObject *__pyx_dict_cached_value = NULL;\
  351. if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
  352. (VAR) = __pyx_dict_cached_value;\
  353. } else {\
  354. (VAR) = __pyx_dict_cached_value = (LOOKUP);\
  355. __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
  356. }\
  357. }
  358. #else
  359. #define __PYX_GET_DICT_VERSION(dict) (0)
  360. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
  361. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
  362. #endif
  363. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  364. #define PyObject_Malloc(s) PyMem_Malloc(s)
  365. #define PyObject_Free(p) PyMem_Free(p)
  366. #define PyObject_Realloc(p) PyMem_Realloc(p)
  367. #endif
  368. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  369. #define PyMem_RawMalloc(n) PyMem_Malloc(n)
  370. #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
  371. #define PyMem_RawFree(p) PyMem_Free(p)
  372. #endif
  373. #if CYTHON_COMPILING_IN_PYSTON
  374. #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
  375. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
  376. #else
  377. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  378. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
  379. #endif
  380. #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  381. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  382. #elif PY_VERSION_HEX >= 0x03060000
  383. #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
  384. #elif PY_VERSION_HEX >= 0x03000000
  385. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  386. #else
  387. #define __Pyx_PyThreadState_Current _PyThreadState_Current
  388. #endif
  389. #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
  390. #include "pythread.h"
  391. #define Py_tss_NEEDS_INIT 0
  392. typedef int Py_tss_t;
  393. static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  394. *key = PyThread_create_key();
  395. return 0; // PyThread_create_key reports success always
  396. }
  397. static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  398. Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  399. *key = Py_tss_NEEDS_INIT;
  400. return key;
  401. }
  402. static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  403. PyObject_Free(key);
  404. }
  405. static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  406. return *key != Py_tss_NEEDS_INIT;
  407. }
  408. static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  409. PyThread_delete_key(*key);
  410. *key = Py_tss_NEEDS_INIT;
  411. }
  412. static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  413. return PyThread_set_key_value(*key, value);
  414. }
  415. static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  416. return PyThread_get_key_value(*key);
  417. }
  418. #endif // TSS (Thread Specific Storage) API
  419. #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
  420. #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
  421. #else
  422. #define __Pyx_PyDict_NewPresized(n) PyDict_New()
  423. #endif
  424. #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  425. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  426. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  427. #else
  428. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  429. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  430. #endif
  431. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
  432. #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
  433. #else
  434. #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
  435. #endif
  436. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  437. #define CYTHON_PEP393_ENABLED 1
  438. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  439. 0 : _PyUnicode_Ready((PyObject *)(op)))
  440. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  441. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  442. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
  443. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  444. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  445. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  446. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
  447. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  448. #else
  449. #define CYTHON_PEP393_ENABLED 0
  450. #define PyUnicode_1BYTE_KIND 1
  451. #define PyUnicode_2BYTE_KIND 2
  452. #define PyUnicode_4BYTE_KIND 4
  453. #define __Pyx_PyUnicode_READY(op) (0)
  454. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  455. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  456. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  457. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  458. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  459. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  460. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  461. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
  462. #endif
  463. #if CYTHON_COMPILING_IN_PYPY
  464. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  465. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  466. #else
  467. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  468. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  469. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  470. #endif
  471. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  472. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  473. #endif
  474. #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  475. #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
  476. #endif
  477. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  478. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  479. #endif
  480. #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))
  481. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  482. #if PY_MAJOR_VERSION >= 3
  483. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  484. #else
  485. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  486. #endif
  487. #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  488. #define PyObject_ASCII(o) PyObject_Repr(o)
  489. #endif
  490. #if PY_MAJOR_VERSION >= 3
  491. #define PyBaseString_Type PyUnicode_Type
  492. #define PyStringObject PyUnicodeObject
  493. #define PyString_Type PyUnicode_Type
  494. #define PyString_Check PyUnicode_Check
  495. #define PyString_CheckExact PyUnicode_CheckExact
  496. #define PyObject_Unicode PyObject_Str
  497. #endif
  498. #if PY_MAJOR_VERSION >= 3
  499. #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  500. #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
  501. #else
  502. #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  503. #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
  504. #endif
  505. #ifndef PySet_CheckExact
  506. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  507. #endif
  508. #if CYTHON_ASSUME_SAFE_MACROS
  509. #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
  510. #else
  511. #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
  512. #endif
  513. #if PY_MAJOR_VERSION >= 3
  514. #define PyIntObject PyLongObject
  515. #define PyInt_Type PyLong_Type
  516. #define PyInt_Check(op) PyLong_Check(op)
  517. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  518. #define PyInt_FromString PyLong_FromString
  519. #define PyInt_FromUnicode PyLong_FromUnicode
  520. #define PyInt_FromLong PyLong_FromLong
  521. #define PyInt_FromSize_t PyLong_FromSize_t
  522. #define PyInt_FromSsize_t PyLong_FromSsize_t
  523. #define PyInt_AsLong PyLong_AsLong
  524. #define PyInt_AS_LONG PyLong_AS_LONG
  525. #define PyInt_AsSsize_t PyLong_AsSsize_t
  526. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  527. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  528. #define PyNumber_Int PyNumber_Long
  529. #endif
  530. #if PY_MAJOR_VERSION >= 3
  531. #define PyBoolObject PyLongObject
  532. #endif
  533. #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  534. #ifndef PyUnicode_InternFromString
  535. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  536. #endif
  537. #endif
  538. #if PY_VERSION_HEX < 0x030200A4
  539. typedef long Py_hash_t;
  540. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  541. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  542. #else
  543. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  544. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  545. #endif
  546. #if PY_MAJOR_VERSION >= 3
  547. #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
  548. #else
  549. #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
  550. #endif
  551. #if CYTHON_USE_ASYNC_SLOTS
  552. #if PY_VERSION_HEX >= 0x030500B1
  553. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  554. #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  555. #else
  556. #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  557. #endif
  558. #else
  559. #define __Pyx_PyType_AsAsync(obj) NULL
  560. #endif
  561. #ifndef __Pyx_PyAsyncMethodsStruct
  562. typedef struct {
  563. unaryfunc am_await;
  564. unaryfunc am_aiter;
  565. unaryfunc am_anext;
  566. } __Pyx_PyAsyncMethodsStruct;
  567. #endif
  568. #if defined(WIN32) || defined(MS_WINDOWS)
  569. #define _USE_MATH_DEFINES
  570. #endif
  571. #include <math.h>
  572. #ifdef NAN
  573. #define __PYX_NAN() ((float) NAN)
  574. #else
  575. static CYTHON_INLINE float __PYX_NAN() {
  576. float value;
  577. memset(&value, 0xFF, sizeof(value));
  578. return value;
  579. }
  580. #endif
  581. #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
  582. #define __Pyx_truncl trunc
  583. #else
  584. #define __Pyx_truncl truncl
  585. #endif
  586. #define __PYX_ERR(f_index, lineno, Ln_error) \
  587. { \
  588. __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
  589. }
  590. #ifndef __PYX_EXTERN_C
  591. #ifdef __cplusplus
  592. #define __PYX_EXTERN_C extern "C"
  593. #else
  594. #define __PYX_EXTERN_C extern
  595. #endif
  596. #endif
  597. #define __PYX_HAVE__httptools__parser__parser
  598. #define __PYX_HAVE_API__httptools__parser__parser
  599. /* Early includes */
  600. #include <string.h>
  601. #include <stdio.h>
  602. #include "pythread.h"
  603. #include <stdint.h>
  604. #include "../../vendor/http-parser/http_parser.h"
  605. #ifdef _OPENMP
  606. #include <omp.h>
  607. #endif /* _OPENMP */
  608. #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
  609. #define CYTHON_WITHOUT_ASSERTIONS
  610. #endif
  611. typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
  612. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
  613. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  614. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
  615. #define __PYX_DEFAULT_STRING_ENCODING ""
  616. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  617. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  618. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  619. #define __Pyx_long_cast(x) ((long)x)
  620. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  621. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  622. (sizeof(type) > sizeof(Py_ssize_t) &&\
  623. likely(v < (type)PY_SSIZE_T_MAX ||\
  624. v == (type)PY_SSIZE_T_MAX) &&\
  625. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  626. v == (type)PY_SSIZE_T_MIN))) ||\
  627. (sizeof(type) == sizeof(Py_ssize_t) &&\
  628. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  629. v == (type)PY_SSIZE_T_MAX))) )
  630. static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
  631. return (size_t) i < (size_t) limit;
  632. }
  633. #if defined (__cplusplus) && __cplusplus >= 201103L
  634. #include <cstdlib>
  635. #define __Pyx_sst_abs(value) std::abs(value)
  636. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  637. #define __Pyx_sst_abs(value) abs(value)
  638. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  639. #define __Pyx_sst_abs(value) labs(value)
  640. #elif defined (_MSC_VER)
  641. #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
  642. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  643. #define __Pyx_sst_abs(value) llabs(value)
  644. #elif defined (__GNUC__)
  645. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  646. #else
  647. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  648. #endif
  649. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
  650. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  651. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  652. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  653. #define __Pyx_PyBytes_FromString PyBytes_FromString
  654. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  655. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  656. #if PY_MAJOR_VERSION < 3
  657. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  658. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  659. #else
  660. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  661. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  662. #endif
  663. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
  664. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
  665. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
  666. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
  667. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
  668. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
  669. #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
  670. #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  671. #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  672. #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
  673. #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
  674. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  675. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  676. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  677. #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
  678. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  679. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
  680. const Py_UNICODE *u_end = u;
  681. while (*u_end++) ;
  682. return (size_t)(u_end - u - 1);
  683. }
  684. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  685. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  686. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  687. #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
  688. #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
  689. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
  690. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  691. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
  692. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
  693. #define __Pyx_PySequence_Tuple(obj)\
  694. (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
  695. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  696. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  697. #if CYTHON_ASSUME_SAFE_MACROS
  698. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  699. #else
  700. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  701. #endif
  702. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  703. #if PY_MAJOR_VERSION >= 3
  704. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  705. #else
  706. #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
  707. #endif
  708. #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
  709. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  710. static int __Pyx_sys_getdefaultencoding_not_ascii;
  711. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  712. PyObject* sys;
  713. PyObject* default_encoding = NULL;
  714. PyObject* ascii_chars_u = NULL;
  715. PyObject* ascii_chars_b = NULL;
  716. const char* default_encoding_c;
  717. sys = PyImport_ImportModule("sys");
  718. if (!sys) goto bad;
  719. default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
  720. Py_DECREF(sys);
  721. if (!default_encoding) goto bad;
  722. default_encoding_c = PyBytes_AsString(default_encoding);
  723. if (!default_encoding_c) goto bad;
  724. if (strcmp(default_encoding_c, "ascii") == 0) {
  725. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  726. } else {
  727. char ascii_chars[128];
  728. int c;
  729. for (c = 0; c < 128; c++) {
  730. ascii_chars[c] = c;
  731. }
  732. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  733. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  734. if (!ascii_chars_u) goto bad;
  735. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  736. if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  737. PyErr_Format(
  738. PyExc_ValueError,
  739. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  740. default_encoding_c);
  741. goto bad;
  742. }
  743. Py_DECREF(ascii_chars_u);
  744. Py_DECREF(ascii_chars_b);
  745. }
  746. Py_DECREF(default_encoding);
  747. return 0;
  748. bad:
  749. Py_XDECREF(default_encoding);
  750. Py_XDECREF(ascii_chars_u);
  751. Py_XDECREF(ascii_chars_b);
  752. return -1;
  753. }
  754. #endif
  755. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  756. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  757. #else
  758. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  759. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  760. static char* __PYX_DEFAULT_STRING_ENCODING;
  761. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  762. PyObject* sys;
  763. PyObject* default_encoding = NULL;
  764. char* default_encoding_c;
  765. sys = PyImport_ImportModule("sys");
  766. if (!sys) goto bad;
  767. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  768. Py_DECREF(sys);
  769. if (!default_encoding) goto bad;
  770. default_encoding_c = PyBytes_AsString(default_encoding);
  771. if (!default_encoding_c) goto bad;
  772. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
  773. if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
  774. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  775. Py_DECREF(default_encoding);
  776. return 0;
  777. bad:
  778. Py_XDECREF(default_encoding);
  779. return -1;
  780. }
  781. #endif
  782. #endif
  783. /* Test for GCC > 2.95 */
  784. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  785. #define likely(x) __builtin_expect(!!(x), 1)
  786. #define unlikely(x) __builtin_expect(!!(x), 0)
  787. #else /* !__GNUC__ or GCC < 2.95 */
  788. #define likely(x) (x)
  789. #define unlikely(x) (x)
  790. #endif /* __GNUC__ */
  791. static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
  792. static PyObject *__pyx_m = NULL;
  793. static PyObject *__pyx_d;
  794. static PyObject *__pyx_b;
  795. static PyObject *__pyx_cython_runtime = NULL;
  796. static PyObject *__pyx_empty_tuple;
  797. static PyObject *__pyx_empty_bytes;
  798. static PyObject *__pyx_empty_unicode;
  799. static int __pyx_lineno;
  800. static int __pyx_clineno = 0;
  801. static const char * __pyx_cfilenm= __FILE__;
  802. static const char *__pyx_filename;
  803. static const char *__pyx_f[] = {
  804. "httptools/parser/parser.pyx",
  805. "stringsource",
  806. "type.pxd",
  807. "bool.pxd",
  808. "complex.pxd",
  809. };
  810. /*--- Type declarations ---*/
  811. struct __pyx_obj_9httptools_6parser_6parser_HttpParser;
  812. struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser;
  813. struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser;
  814. struct __pyx_obj_9httptools_6parser_6parser_URL;
  815. /* "httptools/parser/parser.pyx":26
  816. *
  817. * @cython.internal
  818. * cdef class HttpParser: # <<<<<<<<<<<<<<
  819. *
  820. * cdef:
  821. */
  822. struct __pyx_obj_9httptools_6parser_6parser_HttpParser {
  823. PyObject_HEAD
  824. struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser *__pyx_vtab;
  825. struct http_parser *_cparser;
  826. struct http_parser_settings *_csettings;
  827. PyObject *_current_header_name;
  828. PyObject *_current_header_value;
  829. PyObject *_proto_on_url;
  830. PyObject *_proto_on_status;
  831. PyObject *_proto_on_body;
  832. PyObject *_proto_on_header;
  833. PyObject *_proto_on_headers_complete;
  834. PyObject *_proto_on_message_complete;
  835. PyObject *_proto_on_chunk_header;
  836. PyObject *_proto_on_chunk_complete;
  837. PyObject *_proto_on_message_begin;
  838. PyObject *_last_error;
  839. Py_buffer py_buf;
  840. };
  841. /* "httptools/parser/parser.pyx":202
  842. *
  843. *
  844. * cdef class HttpRequestParser(HttpParser): # <<<<<<<<<<<<<<
  845. *
  846. * def __init__(self, protocol):
  847. */
  848. struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser {
  849. struct __pyx_obj_9httptools_6parser_6parser_HttpParser __pyx_base;
  850. };
  851. /* "httptools/parser/parser.pyx":216
  852. *
  853. *
  854. * cdef class HttpResponseParser(HttpParser): # <<<<<<<<<<<<<<
  855. *
  856. * def __init__(self, protocol):
  857. */
  858. struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser {
  859. struct __pyx_obj_9httptools_6parser_6parser_HttpParser __pyx_base;
  860. };
  861. /* "httptools/parser/parser.pyx":379
  862. *
  863. * @cython.freelist(250)
  864. * cdef class URL: # <<<<<<<<<<<<<<
  865. * cdef readonly bytes schema
  866. * cdef readonly bytes host
  867. */
  868. struct __pyx_obj_9httptools_6parser_6parser_URL {
  869. PyObject_HEAD
  870. PyObject *schema;
  871. PyObject *host;
  872. PyObject *port;
  873. PyObject *path;
  874. PyObject *query;
  875. PyObject *fragment;
  876. PyObject *userinfo;
  877. };
  878. /* "httptools/parser/parser.pyx":26
  879. *
  880. * @cython.internal
  881. * cdef class HttpParser: # <<<<<<<<<<<<<<
  882. *
  883. * cdef:
  884. */
  885. struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser {
  886. PyObject *(*_init)(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *, PyObject *, enum http_parser_type);
  887. PyObject *(*_maybe_call_on_header)(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *);
  888. PyObject *(*_on_header_field)(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *, PyObject *);
  889. PyObject *(*_on_header_value)(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *, PyObject *);
  890. PyObject *(*_on_headers_complete)(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *);
  891. PyObject *(*_on_chunk_header)(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *);
  892. PyObject *(*_on_chunk_complete)(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *);
  893. };
  894. static struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser *__pyx_vtabptr_9httptools_6parser_6parser_HttpParser;
  895. /* "httptools/parser/parser.pyx":202
  896. *
  897. *
  898. * cdef class HttpRequestParser(HttpParser): # <<<<<<<<<<<<<<
  899. *
  900. * def __init__(self, protocol):
  901. */
  902. struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpRequestParser {
  903. struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser __pyx_base;
  904. };
  905. static struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpRequestParser *__pyx_vtabptr_9httptools_6parser_6parser_HttpRequestParser;
  906. /* "httptools/parser/parser.pyx":216
  907. *
  908. *
  909. * cdef class HttpResponseParser(HttpParser): # <<<<<<<<<<<<<<
  910. *
  911. * def __init__(self, protocol):
  912. */
  913. struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpResponseParser {
  914. struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser __pyx_base;
  915. };
  916. static struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpResponseParser *__pyx_vtabptr_9httptools_6parser_6parser_HttpResponseParser;
  917. /* --- Runtime support code (head) --- */
  918. /* Refnanny.proto */
  919. #ifndef CYTHON_REFNANNY
  920. #define CYTHON_REFNANNY 0
  921. #endif
  922. #if CYTHON_REFNANNY
  923. typedef struct {
  924. void (*INCREF)(void*, PyObject*, int);
  925. void (*DECREF)(void*, PyObject*, int);
  926. void (*GOTREF)(void*, PyObject*, int);
  927. void (*GIVEREF)(void*, PyObject*, int);
  928. void* (*SetupContext)(const char*, int, const char*);
  929. void (*FinishContext)(void**);
  930. } __Pyx_RefNannyAPIStruct;
  931. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  932. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  933. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  934. #ifdef WITH_THREAD
  935. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  936. if (acquire_gil) {\
  937. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  938. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  939. PyGILState_Release(__pyx_gilstate_save);\
  940. } else {\
  941. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  942. }
  943. #else
  944. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  945. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  946. #endif
  947. #define __Pyx_RefNannyFinishContext()\
  948. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  949. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  950. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  951. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  952. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  953. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  954. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  955. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  956. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  957. #else
  958. #define __Pyx_RefNannyDeclarations
  959. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  960. #define __Pyx_RefNannyFinishContext()
  961. #define __Pyx_INCREF(r) Py_INCREF(r)
  962. #define __Pyx_DECREF(r) Py_DECREF(r)
  963. #define __Pyx_GOTREF(r)
  964. #define __Pyx_GIVEREF(r)
  965. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  966. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  967. #define __Pyx_XGOTREF(r)
  968. #define __Pyx_XGIVEREF(r)
  969. #endif
  970. #define __Pyx_XDECREF_SET(r, v) do {\
  971. PyObject *tmp = (PyObject *) r;\
  972. r = v; __Pyx_XDECREF(tmp);\
  973. } while (0)
  974. #define __Pyx_DECREF_SET(r, v) do {\
  975. PyObject *tmp = (PyObject *) r;\
  976. r = v; __Pyx_DECREF(tmp);\
  977. } while (0)
  978. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  979. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  980. /* PyObjectGetAttrStr.proto */
  981. #if CYTHON_USE_TYPE_SLOTS
  982. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
  983. #else
  984. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  985. #endif
  986. /* GetBuiltinName.proto */
  987. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  988. /* RaiseArgTupleInvalid.proto */
  989. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  990. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
  991. /* KeywordStringCheck.proto */
  992. static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);
  993. /* PyErrExceptionMatches.proto */
  994. #if CYTHON_FAST_THREAD_STATE
  995. #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
  996. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
  997. #else
  998. #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
  999. #endif
  1000. /* PyThreadStateGet.proto */
  1001. #if CYTHON_FAST_THREAD_STATE
  1002. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  1003. #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
  1004. #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
  1005. #else
  1006. #define __Pyx_PyThreadState_declare
  1007. #define __Pyx_PyThreadState_assign
  1008. #define __Pyx_PyErr_Occurred() PyErr_Occurred()
  1009. #endif
  1010. /* PyErrFetchRestore.proto */
  1011. #if CYTHON_FAST_THREAD_STATE
  1012. #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
  1013. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  1014. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  1015. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  1016. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  1017. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1018. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1019. #if CYTHON_COMPILING_IN_CPYTHON
  1020. #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
  1021. #else
  1022. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1023. #endif
  1024. #else
  1025. #define __Pyx_PyErr_Clear() PyErr_Clear()
  1026. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1027. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  1028. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  1029. #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
  1030. #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
  1031. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  1032. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  1033. #endif
  1034. /* GetAttr.proto */
  1035. static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
  1036. /* GetAttr3.proto */
  1037. static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
  1038. /* PyFunctionFastCall.proto */
  1039. #if CYTHON_FAST_PYCALL
  1040. #define __Pyx_PyFunction_FastCall(func, args, nargs)\
  1041. __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
  1042. #if 1 || PY_VERSION_HEX < 0x030600B1
  1043. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
  1044. #else
  1045. #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
  1046. #endif
  1047. #define __Pyx_BUILD_ASSERT_EXPR(cond)\
  1048. (sizeof(char [1 - 2*!(cond)]) - 1)
  1049. #ifndef Py_MEMBER_SIZE
  1050. #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
  1051. #endif
  1052. static size_t __pyx_pyframe_localsplus_offset = 0;
  1053. #include "frameobject.h"
  1054. #define __Pxy_PyFrame_Initialize_Offsets()\
  1055. ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
  1056. (void)(__pyx_pyframe_localsplus_offset = PyFrame_Type.tp_basicsize - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  1057. #define __Pyx_PyFrame_GetLocalsplus(frame)\
  1058. (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
  1059. #endif
  1060. /* PyCFunctionFastCall.proto */
  1061. #if CYTHON_FAST_PYCCALL
  1062. static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
  1063. #else
  1064. #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
  1065. #endif
  1066. /* PyObjectCall.proto */
  1067. #if CYTHON_COMPILING_IN_CPYTHON
  1068. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  1069. #else
  1070. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  1071. #endif
  1072. /* PyObjectCallMethO.proto */
  1073. #if CYTHON_COMPILING_IN_CPYTHON
  1074. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
  1075. #endif
  1076. /* PyObjectCallNoArg.proto */
  1077. #if CYTHON_COMPILING_IN_CPYTHON
  1078. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
  1079. #else
  1080. #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
  1081. #endif
  1082. /* PyObjectCallOneArg.proto */
  1083. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
  1084. /* GetModuleGlobalName.proto */
  1085. #if CYTHON_USE_DICT_VERSIONS
  1086. #define __Pyx_GetModuleGlobalName(var, name) {\
  1087. static PY_UINT64_T __pyx_dict_version = 0;\
  1088. static PyObject *__pyx_dict_cached_value = NULL;\
  1089. (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
  1090. (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
  1091. __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
  1092. }
  1093. #define __Pyx_GetModuleGlobalNameUncached(var, name) {\
  1094. PY_UINT64_T __pyx_dict_version;\
  1095. PyObject *__pyx_dict_cached_value;\
  1096. (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
  1097. }
  1098. static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
  1099. #else
  1100. #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
  1101. #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
  1102. static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
  1103. #endif
  1104. /* PyObjectCall2Args.proto */
  1105. static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
  1106. /* RaiseException.proto */
  1107. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
  1108. /* PyObjectSetAttrStr.proto */
  1109. #if CYTHON_USE_TYPE_SLOTS
  1110. #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
  1111. static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
  1112. #else
  1113. #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
  1114. #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
  1115. #endif
  1116. /* RaiseDoubleKeywords.proto */
  1117. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
  1118. /* ParseKeywords.proto */
  1119. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
  1120. PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
  1121. const char* function_name);
  1122. /* GetTopmostException.proto */
  1123. #if CYTHON_USE_EXC_INFO_STACK
  1124. static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
  1125. #endif
  1126. /* SaveResetException.proto */
  1127. #if CYTHON_FAST_THREAD_STATE
  1128. #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
  1129. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1130. #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
  1131. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1132. #else
  1133. #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
  1134. #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
  1135. #endif
  1136. /* GetException.proto */
  1137. #if CYTHON_FAST_THREAD_STATE
  1138. #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
  1139. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1140. #else
  1141. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
  1142. #endif
  1143. /* decode_c_string_utf16.proto */
  1144. static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
  1145. int byteorder = 0;
  1146. return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
  1147. }
  1148. static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
  1149. int byteorder = -1;
  1150. return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
  1151. }
  1152. static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
  1153. int byteorder = 1;
  1154. return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
  1155. }
  1156. /* decode_c_bytes.proto */
  1157. static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
  1158. const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
  1159. const char* encoding, const char* errors,
  1160. PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
  1161. /* decode_bytes.proto */
  1162. static CYTHON_INLINE PyObject* __Pyx_decode_bytes(
  1163. PyObject* string, Py_ssize_t start, Py_ssize_t stop,
  1164. const char* encoding, const char* errors,
  1165. PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
  1166. return __Pyx_decode_c_bytes(
  1167. PyBytes_AS_STRING(string), PyBytes_GET_SIZE(string),
  1168. start, stop, encoding, errors, decode_func);
  1169. }
  1170. /* ArgTypeTest.proto */
  1171. #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
  1172. ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
  1173. __Pyx__ArgTypeTest(obj, type, name, exact))
  1174. static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
  1175. /* SwapException.proto */
  1176. #if CYTHON_FAST_THREAD_STATE
  1177. #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
  1178. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1179. #else
  1180. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
  1181. #endif
  1182. /* IncludeStringH.proto */
  1183. #include <string.h>
  1184. /* PyObject_GenericGetAttrNoDict.proto */
  1185. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1186. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
  1187. #else
  1188. #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
  1189. #endif
  1190. /* PyObject_GenericGetAttr.proto */
  1191. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1192. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
  1193. #else
  1194. #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
  1195. #endif
  1196. /* SetVTable.proto */
  1197. static int __Pyx_SetVtable(PyObject *dict, void *vtable);
  1198. /* SetupReduce.proto */
  1199. static int __Pyx_setup_reduce(PyObject* type_obj);
  1200. /* TypeImport.proto */
  1201. #ifndef __PYX_HAVE_RT_ImportType_proto
  1202. #define __PYX_HAVE_RT_ImportType_proto
  1203. enum __Pyx_ImportType_CheckSize {
  1204. __Pyx_ImportType_CheckSize_Error = 0,
  1205. __Pyx_ImportType_CheckSize_Warn = 1,
  1206. __Pyx_ImportType_CheckSize_Ignore = 2
  1207. };
  1208. static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
  1209. #endif
  1210. /* Import.proto */
  1211. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
  1212. /* ImportFrom.proto */
  1213. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
  1214. /* CLineInTraceback.proto */
  1215. #ifdef CYTHON_CLINE_IN_TRACEBACK
  1216. #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
  1217. #else
  1218. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
  1219. #endif
  1220. /* CodeObjectCache.proto */
  1221. typedef struct {
  1222. PyCodeObject* code_object;
  1223. int code_line;
  1224. } __Pyx_CodeObjectCacheEntry;
  1225. struct __Pyx_CodeObjectCache {
  1226. int count;
  1227. int max_count;
  1228. __Pyx_CodeObjectCacheEntry* entries;
  1229. };
  1230. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  1231. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  1232. static PyCodeObject *__pyx_find_code_object(int code_line);
  1233. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  1234. /* AddTraceback.proto */
  1235. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  1236. int py_line, const char *filename);
  1237. /* CIntToPy.proto */
  1238. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_short(unsigned short value);
  1239. /* CIntToPy.proto */
  1240. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
  1241. /* CIntToPy.proto */
  1242. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value);
  1243. /* CIntToPy.proto */
  1244. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint16_t(uint16_t value);
  1245. /* CIntToPy.proto */
  1246. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  1247. /* CIntFromPy.proto */
  1248. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  1249. /* CIntFromPy.proto */
  1250. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  1251. /* FastTypeChecks.proto */
  1252. #if CYTHON_COMPILING_IN_CPYTHON
  1253. #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
  1254. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
  1255. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
  1256. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
  1257. #else
  1258. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  1259. #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
  1260. #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
  1261. #endif
  1262. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  1263. /* CheckBinaryVersion.proto */
  1264. static int __Pyx_check_binary_version(void);
  1265. /* InitStrings.proto */
  1266. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
  1267. static PyObject *__pyx_f_9httptools_6parser_6parser_10HttpParser__init(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self, PyObject *__pyx_v_protocol, enum http_parser_type __pyx_v_mode); /* proto*/
  1268. static PyObject *__pyx_f_9httptools_6parser_6parser_10HttpParser__maybe_call_on_header(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self); /* proto*/
  1269. static PyObject *__pyx_f_9httptools_6parser_6parser_10HttpParser__on_header_field(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self, PyObject *__pyx_v_field); /* proto*/
  1270. static PyObject *__pyx_f_9httptools_6parser_6parser_10HttpParser__on_header_value(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self, PyObject *__pyx_v_val); /* proto*/
  1271. static PyObject *__pyx_f_9httptools_6parser_6parser_10HttpParser__on_headers_complete(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self); /* proto*/
  1272. static PyObject *__pyx_f_9httptools_6parser_6parser_10HttpParser__on_chunk_header(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self); /* proto*/
  1273. static PyObject *__pyx_f_9httptools_6parser_6parser_10HttpParser__on_chunk_complete(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self); /* proto*/
  1274. /* Module declarations from 'cpython.mem' */
  1275. /* Module declarations from 'cpython.version' */
  1276. /* Module declarations from '__builtin__' */
  1277. /* Module declarations from 'cpython.type' */
  1278. static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
  1279. /* Module declarations from 'libc.string' */
  1280. /* Module declarations from 'libc.stdio' */
  1281. /* Module declarations from 'cpython.object' */
  1282. /* Module declarations from 'cpython.ref' */
  1283. /* Module declarations from 'cpython.exc' */
  1284. /* Module declarations from 'cpython.module' */
  1285. /* Module declarations from 'cpython.tuple' */
  1286. /* Module declarations from 'cpython.list' */
  1287. /* Module declarations from 'cpython.sequence' */
  1288. /* Module declarations from 'cpython.mapping' */
  1289. /* Module declarations from 'cpython.iterator' */
  1290. /* Module declarations from 'cpython.number' */
  1291. /* Module declarations from 'cpython.int' */
  1292. /* Module declarations from '__builtin__' */
  1293. /* Module declarations from 'cpython.bool' */
  1294. static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
  1295. /* Module declarations from 'cpython.long' */
  1296. /* Module declarations from 'cpython.float' */
  1297. /* Module declarations from '__builtin__' */
  1298. /* Module declarations from 'cpython.complex' */
  1299. static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
  1300. /* Module declarations from 'cpython.string' */
  1301. /* Module declarations from 'cpython.unicode' */
  1302. /* Module declarations from 'cpython.dict' */
  1303. /* Module declarations from 'cpython.instance' */
  1304. /* Module declarations from 'cpython.function' */
  1305. /* Module declarations from 'cpython.method' */
  1306. /* Module declarations from 'cpython.weakref' */
  1307. /* Module declarations from 'cpython.getargs' */
  1308. /* Module declarations from 'cpython.pythread' */
  1309. /* Module declarations from 'cpython.pystate' */
  1310. /* Module declarations from 'cpython.cobject' */
  1311. /* Module declarations from 'cpython.oldbuffer' */
  1312. /* Module declarations from 'cpython.set' */
  1313. /* Module declarations from 'cpython.buffer' */
  1314. /* Module declarations from 'cpython.bytes' */
  1315. /* Module declarations from 'cpython.pycapsule' */
  1316. /* Module declarations from 'cpython' */
  1317. /* Module declarations from 'httptools.parser.python' */
  1318. /* Module declarations from 'cython' */
  1319. /* Module declarations from 'httptools.parser' */
  1320. /* Module declarations from 'libc.stdint' */
  1321. /* Module declarations from 'httptools.parser.cparser' */
  1322. /* Module declarations from 'httptools.parser.parser' */
  1323. static PyTypeObject *__pyx_ptype_9httptools_6parser_6parser_HttpParser = 0;
  1324. static PyTypeObject *__pyx_ptype_9httptools_6parser_6parser_HttpRequestParser = 0;
  1325. static PyTypeObject *__pyx_ptype_9httptools_6parser_6parser_HttpResponseParser = 0;
  1326. static PyTypeObject *__pyx_ptype_9httptools_6parser_6parser_URL = 0;
  1327. static int __pyx_f_9httptools_6parser_6parser_cb_on_message_begin(struct http_parser *); /*proto*/
  1328. static int __pyx_f_9httptools_6parser_6parser_cb_on_url(struct http_parser *, char const *, size_t); /*proto*/
  1329. static int __pyx_f_9httptools_6parser_6parser_cb_on_status(struct http_parser *, char const *, size_t); /*proto*/
  1330. static int __pyx_f_9httptools_6parser_6parser_cb_on_header_field(struct http_parser *, char const *, size_t); /*proto*/
  1331. static int __pyx_f_9httptools_6parser_6parser_cb_on_header_value(struct http_parser *, char const *, size_t); /*proto*/
  1332. static int __pyx_f_9httptools_6parser_6parser_cb_on_headers_complete(struct http_parser *); /*proto*/
  1333. static int __pyx_f_9httptools_6parser_6parser_cb_on_body(struct http_parser *, char const *, size_t); /*proto*/
  1334. static int __pyx_f_9httptools_6parser_6parser_cb_on_message_complete(struct http_parser *); /*proto*/
  1335. static int __pyx_f_9httptools_6parser_6parser_cb_on_chunk_header(struct http_parser *); /*proto*/
  1336. static int __pyx_f_9httptools_6parser_6parser_cb_on_chunk_complete(struct http_parser *); /*proto*/
  1337. static PyObject *__pyx_f_9httptools_6parser_6parser_parser_error_from_errno(enum http_errno); /*proto*/
  1338. #define __Pyx_MODULE_NAME "httptools.parser.parser"
  1339. extern int __pyx_module_is_main_httptools__parser__parser;
  1340. int __pyx_module_is_main_httptools__parser__parser = 0;
  1341. /* Implementation of 'httptools.parser.parser' */
  1342. static PyObject *__pyx_builtin_MemoryError;
  1343. static PyObject *__pyx_builtin_TypeError;
  1344. static PyObject *__pyx_builtin_BaseException;
  1345. static const char __pyx_k_[] = "{}.{}";
  1346. static const char __pyx_k_ln[] = "ln";
  1347. static const char __pyx_k_URL[] = "URL";
  1348. static const char __pyx_k_all[] = "__all__";
  1349. static const char __pyx_k_off[] = "off";
  1350. static const char __pyx_k_res[] = "res";
  1351. static const char __pyx_k_url[] = "url";
  1352. static const char __pyx_k_host[] = "host";
  1353. static const char __pyx_k_main[] = "__main__";
  1354. static const char __pyx_k_name[] = "__name__";
  1355. static const char __pyx_k_path[] = "path";
  1356. static const char __pyx_k_port[] = "port";
  1357. static const char __pyx_k_test[] = "__test__";
  1358. static const char __pyx_k_query[] = "query";
  1359. static const char __pyx_k_errors[] = "errors";
  1360. static const char __pyx_k_format[] = "format";
  1361. static const char __pyx_k_import[] = "__import__";
  1362. static const char __pyx_k_on_url[] = "on_url";
  1363. static const char __pyx_k_parsed[] = "parsed";
  1364. static const char __pyx_k_py_buf[] = "py_buf";
  1365. static const char __pyx_k_reduce[] = "__reduce__";
  1366. static const char __pyx_k_result[] = "result";
  1367. static const char __pyx_k_schema[] = "schema";
  1368. static const char __pyx_k_context[] = "__context__";
  1369. static const char __pyx_k_on_body[] = "on_body";
  1370. static const char __pyx_k_buf_data[] = "buf_data";
  1371. static const char __pyx_k_fragment[] = "fragment";
  1372. static const char __pyx_k_getstate[] = "__getstate__";
  1373. static const char __pyx_k_protocol[] = "protocol";
  1374. static const char __pyx_k_setstate[] = "__setstate__";
  1375. static const char __pyx_k_userinfo[] = "userinfo";
  1376. static const char __pyx_k_TypeError[] = "TypeError";
  1377. static const char __pyx_k_on_header[] = "on_header";
  1378. static const char __pyx_k_on_status[] = "on_status";
  1379. static const char __pyx_k_parse_url[] = "parse_url";
  1380. static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
  1381. static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
  1382. static const char __pyx_k_MemoryError[] = "MemoryError";
  1383. static const char __pyx_k_BaseException[] = "BaseException";
  1384. static const char __pyx_k_invalid_url_r[] = "invalid url {!r}";
  1385. static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
  1386. static const char __pyx_k_HttpParserError[] = "HttpParserError";
  1387. static const char __pyx_k_on_chunk_header[] = "on_chunk_header";
  1388. static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
  1389. static const char __pyx_k_on_message_begin[] = "on_message_begin";
  1390. static const char __pyx_k_HttpParserUpgrade[] = "HttpParserUpgrade";
  1391. static const char __pyx_k_HttpRequestParser[] = "HttpRequestParser";
  1392. static const char __pyx_k_on_chunk_complete[] = "on_chunk_complete";
  1393. static const char __pyx_k_HttpResponseParser[] = "HttpResponseParser";
  1394. static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
  1395. static const char __pyx_k_on_headers_complete[] = "on_headers_complete";
  1396. static const char __pyx_k_on_message_complete[] = "on_message_complete";
  1397. static const char __pyx_k_invalid_headers_state[] = "invalid headers state";
  1398. static const char __pyx_k_HttpParserCallbackError[] = "HttpParserCallbackError";
  1399. static const char __pyx_k_httptools_parser_parser[] = "httptools.parser.parser";
  1400. static const char __pyx_k_HttpParserInvalidURLError[] = "HttpParserInvalidURLError";
  1401. static const char __pyx_k_httptools_parser_parser_pyx[] = "httptools/parser/parser.pyx";
  1402. static const char __pyx_k_HttpParserInvalidMethodError[] = "HttpParserInvalidMethodError";
  1403. static const char __pyx_k_HttpParserInvalidStatusError[] = "HttpParserInvalidStatusError";
  1404. static const char __pyx_k_not_all_of_the_data_was_parsed[] = "not all of the data was parsed";
  1405. static const char __pyx_k_URL_schema_r_host_r_port_r_path[] = "<URL schema: {!r}, host: {!r}, port: {!r}, path: {!r}, query: {!r}, fragment: {!r}, userinfo: {!r}>";
  1406. static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
  1407. static PyObject *__pyx_kp_u_;
  1408. static PyObject *__pyx_n_s_BaseException;
  1409. static PyObject *__pyx_n_s_HttpParserCallbackError;
  1410. static PyObject *__pyx_n_s_HttpParserError;
  1411. static PyObject *__pyx_n_s_HttpParserInvalidMethodError;
  1412. static PyObject *__pyx_n_s_HttpParserInvalidStatusError;
  1413. static PyObject *__pyx_n_s_HttpParserInvalidURLError;
  1414. static PyObject *__pyx_n_s_HttpParserUpgrade;
  1415. static PyObject *__pyx_n_s_HttpRequestParser;
  1416. static PyObject *__pyx_n_u_HttpRequestParser;
  1417. static PyObject *__pyx_n_s_HttpResponseParser;
  1418. static PyObject *__pyx_n_u_HttpResponseParser;
  1419. static PyObject *__pyx_n_s_MemoryError;
  1420. static PyObject *__pyx_n_s_TypeError;
  1421. static PyObject *__pyx_n_s_URL;
  1422. static PyObject *__pyx_kp_u_URL_schema_r_host_r_port_r_path;
  1423. static PyObject *__pyx_n_s_all;
  1424. static PyObject *__pyx_n_s_buf_data;
  1425. static PyObject *__pyx_n_s_cline_in_traceback;
  1426. static PyObject *__pyx_n_s_context;
  1427. static PyObject *__pyx_n_s_errors;
  1428. static PyObject *__pyx_n_s_format;
  1429. static PyObject *__pyx_n_s_fragment;
  1430. static PyObject *__pyx_n_s_getstate;
  1431. static PyObject *__pyx_n_s_host;
  1432. static PyObject *__pyx_n_s_httptools_parser_parser;
  1433. static PyObject *__pyx_kp_s_httptools_parser_parser_pyx;
  1434. static PyObject *__pyx_n_s_import;
  1435. static PyObject *__pyx_kp_u_invalid_headers_state;
  1436. static PyObject *__pyx_kp_u_invalid_url_r;
  1437. static PyObject *__pyx_n_s_ln;
  1438. static PyObject *__pyx_n_s_main;
  1439. static PyObject *__pyx_n_s_name;
  1440. static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
  1441. static PyObject *__pyx_kp_u_not_all_of_the_data_was_parsed;
  1442. static PyObject *__pyx_n_s_off;
  1443. static PyObject *__pyx_n_u_on_body;
  1444. static PyObject *__pyx_n_u_on_chunk_complete;
  1445. static PyObject *__pyx_n_u_on_chunk_header;
  1446. static PyObject *__pyx_n_u_on_header;
  1447. static PyObject *__pyx_n_u_on_headers_complete;
  1448. static PyObject *__pyx_n_u_on_message_begin;
  1449. static PyObject *__pyx_n_u_on_message_complete;
  1450. static PyObject *__pyx_n_u_on_status;
  1451. static PyObject *__pyx_n_u_on_url;
  1452. static PyObject *__pyx_n_s_parse_url;
  1453. static PyObject *__pyx_n_u_parse_url;
  1454. static PyObject *__pyx_n_s_parsed;
  1455. static PyObject *__pyx_n_s_path;
  1456. static PyObject *__pyx_n_s_port;
  1457. static PyObject *__pyx_n_s_protocol;
  1458. static PyObject *__pyx_n_s_py_buf;
  1459. static PyObject *__pyx_n_s_pyx_vtable;
  1460. static PyObject *__pyx_n_s_query;
  1461. static PyObject *__pyx_n_s_reduce;
  1462. static PyObject *__pyx_n_s_reduce_cython;
  1463. static PyObject *__pyx_n_s_reduce_ex;
  1464. static PyObject *__pyx_n_s_res;
  1465. static PyObject *__pyx_n_s_result;
  1466. static PyObject *__pyx_n_s_schema;
  1467. static PyObject *__pyx_n_s_setstate;
  1468. static PyObject *__pyx_n_s_setstate_cython;
  1469. static PyObject *__pyx_n_s_test;
  1470. static PyObject *__pyx_n_s_url;
  1471. static PyObject *__pyx_n_s_userinfo;
  1472. static int __pyx_pf_9httptools_6parser_6parser_10HttpParser___cinit__(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self); /* proto */
  1473. static void __pyx_pf_9httptools_6parser_6parser_10HttpParser_2__dealloc__(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self); /* proto */
  1474. static PyObject *__pyx_pf_9httptools_6parser_6parser_10HttpParser_4get_http_version(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self); /* proto */
  1475. static PyObject *__pyx_pf_9httptools_6parser_6parser_10HttpParser_6should_keep_alive(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self); /* proto */
  1476. static PyObject *__pyx_pf_9httptools_6parser_6parser_10HttpParser_8should_upgrade(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self); /* proto */
  1477. static PyObject *__pyx_pf_9httptools_6parser_6parser_10HttpParser_10feed_data(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self, PyObject *__pyx_v_data); /* proto */
  1478. static PyObject *__pyx_pf_9httptools_6parser_6parser_10HttpParser_12__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self); /* proto */
  1479. static PyObject *__pyx_pf_9httptools_6parser_6parser_10HttpParser_14__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
  1480. static int __pyx_pf_9httptools_6parser_6parser_17HttpRequestParser___init__(struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser *__pyx_v_self, PyObject *__pyx_v_protocol); /* proto */
  1481. static PyObject *__pyx_pf_9httptools_6parser_6parser_17HttpRequestParser_2get_method(struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser *__pyx_v_self); /* proto */
  1482. static PyObject *__pyx_pf_9httptools_6parser_6parser_17HttpRequestParser_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser *__pyx_v_self); /* proto */
  1483. static PyObject *__pyx_pf_9httptools_6parser_6parser_17HttpRequestParser_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
  1484. static int __pyx_pf_9httptools_6parser_6parser_18HttpResponseParser___init__(struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser *__pyx_v_self, PyObject *__pyx_v_protocol); /* proto */
  1485. static PyObject *__pyx_pf_9httptools_6parser_6parser_18HttpResponseParser_2get_status_code(struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser *__pyx_v_self); /* proto */
  1486. static PyObject *__pyx_pf_9httptools_6parser_6parser_18HttpResponseParser_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser *__pyx_v_self); /* proto */
  1487. static PyObject *__pyx_pf_9httptools_6parser_6parser_18HttpResponseParser_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
  1488. static int __pyx_pf_9httptools_6parser_6parser_3URL___cinit__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self, PyObject *__pyx_v_schema, PyObject *__pyx_v_host, PyObject *__pyx_v_port, PyObject *__pyx_v_path, PyObject *__pyx_v_query, PyObject *__pyx_v_fragment, PyObject *__pyx_v_userinfo); /* proto */
  1489. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_2__repr__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self); /* proto */
  1490. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_6schema___get__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self); /* proto */
  1491. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_4host___get__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self); /* proto */
  1492. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_4port___get__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self); /* proto */
  1493. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_4path___get__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self); /* proto */
  1494. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_5query___get__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self); /* proto */
  1495. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_8fragment___get__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self); /* proto */
  1496. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_8userinfo___get__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self); /* proto */
  1497. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self); /* proto */
  1498. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
  1499. static PyObject *__pyx_pf_9httptools_6parser_6parser_parse_url(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url); /* proto */
  1500. static PyObject *__pyx_tp_new_9httptools_6parser_6parser_HttpParser(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1501. static PyObject *__pyx_tp_new_9httptools_6parser_6parser_HttpRequestParser(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1502. static PyObject *__pyx_tp_new_9httptools_6parser_6parser_HttpResponseParser(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1503. static PyObject *__pyx_tp_new_9httptools_6parser_6parser_URL(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1504. static PyObject *__pyx_tuple__2;
  1505. static PyObject *__pyx_tuple__3;
  1506. static PyObject *__pyx_tuple__4;
  1507. static PyObject *__pyx_tuple__5;
  1508. static PyObject *__pyx_tuple__6;
  1509. static PyObject *__pyx_tuple__7;
  1510. static PyObject *__pyx_tuple__8;
  1511. static PyObject *__pyx_tuple__9;
  1512. static PyObject *__pyx_tuple__10;
  1513. static PyObject *__pyx_tuple__11;
  1514. static PyObject *__pyx_tuple__12;
  1515. static PyObject *__pyx_codeobj__13;
  1516. /* Late includes */
  1517. /* "httptools/parser/parser.pyx":44
  1518. * Py_buffer py_buf
  1519. *
  1520. * def __cinit__(self): # <<<<<<<<<<<<<<
  1521. * self._cparser = <cparser.http_parser*> \
  1522. * PyMem_Malloc(sizeof(cparser.http_parser))
  1523. */
  1524. /* Python wrapper */
  1525. static int __pyx_pw_9httptools_6parser_6parser_10HttpParser_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1526. static int __pyx_pw_9httptools_6parser_6parser_10HttpParser_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1527. int __pyx_r;
  1528. __Pyx_RefNannyDeclarations
  1529. __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  1530. if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
  1531. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  1532. if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  1533. __pyx_r = __pyx_pf_9httptools_6parser_6parser_10HttpParser___cinit__(((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_v_self));
  1534. /* function exit code */
  1535. __Pyx_RefNannyFinishContext();
  1536. return __pyx_r;
  1537. }
  1538. static int __pyx_pf_9httptools_6parser_6parser_10HttpParser___cinit__(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self) {
  1539. int __pyx_r;
  1540. __Pyx_RefNannyDeclarations
  1541. int __pyx_t_1;
  1542. __Pyx_RefNannySetupContext("__cinit__", 0);
  1543. /* "httptools/parser/parser.pyx":45
  1544. *
  1545. * def __cinit__(self):
  1546. * self._cparser = <cparser.http_parser*> \ # <<<<<<<<<<<<<<
  1547. * PyMem_Malloc(sizeof(cparser.http_parser))
  1548. * if self._cparser is NULL:
  1549. */
  1550. __pyx_v_self->_cparser = ((struct http_parser *)PyMem_Malloc((sizeof(struct http_parser))));
  1551. /* "httptools/parser/parser.pyx":47
  1552. * self._cparser = <cparser.http_parser*> \
  1553. * PyMem_Malloc(sizeof(cparser.http_parser))
  1554. * if self._cparser is NULL: # <<<<<<<<<<<<<<
  1555. * raise MemoryError()
  1556. *
  1557. */
  1558. __pyx_t_1 = ((__pyx_v_self->_cparser == NULL) != 0);
  1559. if (unlikely(__pyx_t_1)) {
  1560. /* "httptools/parser/parser.pyx":48
  1561. * PyMem_Malloc(sizeof(cparser.http_parser))
  1562. * if self._cparser is NULL:
  1563. * raise MemoryError() # <<<<<<<<<<<<<<
  1564. *
  1565. * self._csettings = <cparser.http_parser_settings*> \
  1566. */
  1567. PyErr_NoMemory(); __PYX_ERR(0, 48, __pyx_L1_error)
  1568. /* "httptools/parser/parser.pyx":47
  1569. * self._cparser = <cparser.http_parser*> \
  1570. * PyMem_Malloc(sizeof(cparser.http_parser))
  1571. * if self._cparser is NULL: # <<<<<<<<<<<<<<
  1572. * raise MemoryError()
  1573. *
  1574. */
  1575. }
  1576. /* "httptools/parser/parser.pyx":50
  1577. * raise MemoryError()
  1578. *
  1579. * self._csettings = <cparser.http_parser_settings*> \ # <<<<<<<<<<<<<<
  1580. * PyMem_Malloc(sizeof(cparser.http_parser_settings))
  1581. * if self._csettings is NULL:
  1582. */
  1583. __pyx_v_self->_csettings = ((struct http_parser_settings *)PyMem_Malloc((sizeof(struct http_parser_settings))));
  1584. /* "httptools/parser/parser.pyx":52
  1585. * self._csettings = <cparser.http_parser_settings*> \
  1586. * PyMem_Malloc(sizeof(cparser.http_parser_settings))
  1587. * if self._csettings is NULL: # <<<<<<<<<<<<<<
  1588. * raise MemoryError()
  1589. *
  1590. */
  1591. __pyx_t_1 = ((__pyx_v_self->_csettings == NULL) != 0);
  1592. if (unlikely(__pyx_t_1)) {
  1593. /* "httptools/parser/parser.pyx":53
  1594. * PyMem_Malloc(sizeof(cparser.http_parser_settings))
  1595. * if self._csettings is NULL:
  1596. * raise MemoryError() # <<<<<<<<<<<<<<
  1597. *
  1598. * def __dealloc__(self):
  1599. */
  1600. PyErr_NoMemory(); __PYX_ERR(0, 53, __pyx_L1_error)
  1601. /* "httptools/parser/parser.pyx":52
  1602. * self._csettings = <cparser.http_parser_settings*> \
  1603. * PyMem_Malloc(sizeof(cparser.http_parser_settings))
  1604. * if self._csettings is NULL: # <<<<<<<<<<<<<<
  1605. * raise MemoryError()
  1606. *
  1607. */
  1608. }
  1609. /* "httptools/parser/parser.pyx":44
  1610. * Py_buffer py_buf
  1611. *
  1612. * def __cinit__(self): # <<<<<<<<<<<<<<
  1613. * self._cparser = <cparser.http_parser*> \
  1614. * PyMem_Malloc(sizeof(cparser.http_parser))
  1615. */
  1616. /* function exit code */
  1617. __pyx_r = 0;
  1618. goto __pyx_L0;
  1619. __pyx_L1_error:;
  1620. __Pyx_AddTraceback("httptools.parser.parser.HttpParser.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1621. __pyx_r = -1;
  1622. __pyx_L0:;
  1623. __Pyx_RefNannyFinishContext();
  1624. return __pyx_r;
  1625. }
  1626. /* "httptools/parser/parser.pyx":55
  1627. * raise MemoryError()
  1628. *
  1629. * def __dealloc__(self): # <<<<<<<<<<<<<<
  1630. * PyMem_Free(self._cparser)
  1631. * PyMem_Free(self._csettings)
  1632. */
  1633. /* Python wrapper */
  1634. static void __pyx_pw_9httptools_6parser_6parser_10HttpParser_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
  1635. static void __pyx_pw_9httptools_6parser_6parser_10HttpParser_3__dealloc__(PyObject *__pyx_v_self) {
  1636. __Pyx_RefNannyDeclarations
  1637. __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  1638. __pyx_pf_9httptools_6parser_6parser_10HttpParser_2__dealloc__(((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_v_self));
  1639. /* function exit code */
  1640. __Pyx_RefNannyFinishContext();
  1641. }
  1642. static void __pyx_pf_9httptools_6parser_6parser_10HttpParser_2__dealloc__(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self) {
  1643. __Pyx_RefNannyDeclarations
  1644. __Pyx_RefNannySetupContext("__dealloc__", 0);
  1645. /* "httptools/parser/parser.pyx":56
  1646. *
  1647. * def __dealloc__(self):
  1648. * PyMem_Free(self._cparser) # <<<<<<<<<<<<<<
  1649. * PyMem_Free(self._csettings)
  1650. *
  1651. */
  1652. PyMem_Free(__pyx_v_self->_cparser);
  1653. /* "httptools/parser/parser.pyx":57
  1654. * def __dealloc__(self):
  1655. * PyMem_Free(self._cparser)
  1656. * PyMem_Free(self._csettings) # <<<<<<<<<<<<<<
  1657. *
  1658. * cdef _init(self, protocol, cparser.http_parser_type mode):
  1659. */
  1660. PyMem_Free(__pyx_v_self->_csettings);
  1661. /* "httptools/parser/parser.pyx":55
  1662. * raise MemoryError()
  1663. *
  1664. * def __dealloc__(self): # <<<<<<<<<<<<<<
  1665. * PyMem_Free(self._cparser)
  1666. * PyMem_Free(self._csettings)
  1667. */
  1668. /* function exit code */
  1669. __Pyx_RefNannyFinishContext();
  1670. }
  1671. /* "httptools/parser/parser.pyx":59
  1672. * PyMem_Free(self._csettings)
  1673. *
  1674. * cdef _init(self, protocol, cparser.http_parser_type mode): # <<<<<<<<<<<<<<
  1675. * cparser.http_parser_init(self._cparser, mode)
  1676. * self._cparser.data = <void*>self
  1677. */
  1678. static PyObject *__pyx_f_9httptools_6parser_6parser_10HttpParser__init(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self, PyObject *__pyx_v_protocol, enum http_parser_type __pyx_v_mode) {
  1679. PyObject *__pyx_r = NULL;
  1680. __Pyx_RefNannyDeclarations
  1681. PyObject *__pyx_t_1 = NULL;
  1682. int __pyx_t_2;
  1683. int __pyx_t_3;
  1684. __Pyx_RefNannySetupContext("_init", 0);
  1685. /* "httptools/parser/parser.pyx":60
  1686. *
  1687. * cdef _init(self, protocol, cparser.http_parser_type mode):
  1688. * cparser.http_parser_init(self._cparser, mode) # <<<<<<<<<<<<<<
  1689. * self._cparser.data = <void*>self
  1690. *
  1691. */
  1692. http_parser_init(__pyx_v_self->_cparser, __pyx_v_mode);
  1693. /* "httptools/parser/parser.pyx":61
  1694. * cdef _init(self, protocol, cparser.http_parser_type mode):
  1695. * cparser.http_parser_init(self._cparser, mode)
  1696. * self._cparser.data = <void*>self # <<<<<<<<<<<<<<
  1697. *
  1698. * cparser.http_parser_settings_init(self._csettings)
  1699. */
  1700. __pyx_v_self->_cparser->data = ((void *)__pyx_v_self);
  1701. /* "httptools/parser/parser.pyx":63
  1702. * self._cparser.data = <void*>self
  1703. *
  1704. * cparser.http_parser_settings_init(self._csettings) # <<<<<<<<<<<<<<
  1705. *
  1706. * self._current_header_name = None
  1707. */
  1708. http_parser_settings_init(__pyx_v_self->_csettings);
  1709. /* "httptools/parser/parser.pyx":65
  1710. * cparser.http_parser_settings_init(self._csettings)
  1711. *
  1712. * self._current_header_name = None # <<<<<<<<<<<<<<
  1713. * self._current_header_value = None
  1714. *
  1715. */
  1716. __Pyx_INCREF(Py_None);
  1717. __Pyx_GIVEREF(Py_None);
  1718. __Pyx_GOTREF(__pyx_v_self->_current_header_name);
  1719. __Pyx_DECREF(__pyx_v_self->_current_header_name);
  1720. __pyx_v_self->_current_header_name = ((PyObject*)Py_None);
  1721. /* "httptools/parser/parser.pyx":66
  1722. *
  1723. * self._current_header_name = None
  1724. * self._current_header_value = None # <<<<<<<<<<<<<<
  1725. *
  1726. * self._proto_on_header = getattr(protocol, 'on_header', None)
  1727. */
  1728. __Pyx_INCREF(Py_None);
  1729. __Pyx_GIVEREF(Py_None);
  1730. __Pyx_GOTREF(__pyx_v_self->_current_header_value);
  1731. __Pyx_DECREF(__pyx_v_self->_current_header_value);
  1732. __pyx_v_self->_current_header_value = ((PyObject*)Py_None);
  1733. /* "httptools/parser/parser.pyx":68
  1734. * self._current_header_value = None
  1735. *
  1736. * self._proto_on_header = getattr(protocol, 'on_header', None) # <<<<<<<<<<<<<<
  1737. * if self._proto_on_header is not None:
  1738. * self._csettings.on_header_field = cb_on_header_field
  1739. */
  1740. __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_protocol, __pyx_n_u_on_header, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
  1741. __Pyx_GOTREF(__pyx_t_1);
  1742. __Pyx_GIVEREF(__pyx_t_1);
  1743. __Pyx_GOTREF(__pyx_v_self->_proto_on_header);
  1744. __Pyx_DECREF(__pyx_v_self->_proto_on_header);
  1745. __pyx_v_self->_proto_on_header = __pyx_t_1;
  1746. __pyx_t_1 = 0;
  1747. /* "httptools/parser/parser.pyx":69
  1748. *
  1749. * self._proto_on_header = getattr(protocol, 'on_header', None)
  1750. * if self._proto_on_header is not None: # <<<<<<<<<<<<<<
  1751. * self._csettings.on_header_field = cb_on_header_field
  1752. * self._csettings.on_header_value = cb_on_header_value
  1753. */
  1754. __pyx_t_2 = (__pyx_v_self->_proto_on_header != Py_None);
  1755. __pyx_t_3 = (__pyx_t_2 != 0);
  1756. if (__pyx_t_3) {
  1757. /* "httptools/parser/parser.pyx":70
  1758. * self._proto_on_header = getattr(protocol, 'on_header', None)
  1759. * if self._proto_on_header is not None:
  1760. * self._csettings.on_header_field = cb_on_header_field # <<<<<<<<<<<<<<
  1761. * self._csettings.on_header_value = cb_on_header_value
  1762. * self._proto_on_headers_complete = getattr(
  1763. */
  1764. __pyx_v_self->_csettings->on_header_field = __pyx_f_9httptools_6parser_6parser_cb_on_header_field;
  1765. /* "httptools/parser/parser.pyx":71
  1766. * if self._proto_on_header is not None:
  1767. * self._csettings.on_header_field = cb_on_header_field
  1768. * self._csettings.on_header_value = cb_on_header_value # <<<<<<<<<<<<<<
  1769. * self._proto_on_headers_complete = getattr(
  1770. * protocol, 'on_headers_complete', None)
  1771. */
  1772. __pyx_v_self->_csettings->on_header_value = __pyx_f_9httptools_6parser_6parser_cb_on_header_value;
  1773. /* "httptools/parser/parser.pyx":69
  1774. *
  1775. * self._proto_on_header = getattr(protocol, 'on_header', None)
  1776. * if self._proto_on_header is not None: # <<<<<<<<<<<<<<
  1777. * self._csettings.on_header_field = cb_on_header_field
  1778. * self._csettings.on_header_value = cb_on_header_value
  1779. */
  1780. }
  1781. /* "httptools/parser/parser.pyx":72
  1782. * self._csettings.on_header_field = cb_on_header_field
  1783. * self._csettings.on_header_value = cb_on_header_value
  1784. * self._proto_on_headers_complete = getattr( # <<<<<<<<<<<<<<
  1785. * protocol, 'on_headers_complete', None)
  1786. * self._csettings.on_headers_complete = cb_on_headers_complete
  1787. */
  1788. __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_protocol, __pyx_n_u_on_headers_complete, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
  1789. __Pyx_GOTREF(__pyx_t_1);
  1790. __Pyx_GIVEREF(__pyx_t_1);
  1791. __Pyx_GOTREF(__pyx_v_self->_proto_on_headers_complete);
  1792. __Pyx_DECREF(__pyx_v_self->_proto_on_headers_complete);
  1793. __pyx_v_self->_proto_on_headers_complete = __pyx_t_1;
  1794. __pyx_t_1 = 0;
  1795. /* "httptools/parser/parser.pyx":74
  1796. * self._proto_on_headers_complete = getattr(
  1797. * protocol, 'on_headers_complete', None)
  1798. * self._csettings.on_headers_complete = cb_on_headers_complete # <<<<<<<<<<<<<<
  1799. *
  1800. * self._proto_on_body = getattr(protocol, 'on_body', None)
  1801. */
  1802. __pyx_v_self->_csettings->on_headers_complete = __pyx_f_9httptools_6parser_6parser_cb_on_headers_complete;
  1803. /* "httptools/parser/parser.pyx":76
  1804. * self._csettings.on_headers_complete = cb_on_headers_complete
  1805. *
  1806. * self._proto_on_body = getattr(protocol, 'on_body', None) # <<<<<<<<<<<<<<
  1807. * if self._proto_on_body is not None:
  1808. * self._csettings.on_body = cb_on_body
  1809. */
  1810. __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_protocol, __pyx_n_u_on_body, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
  1811. __Pyx_GOTREF(__pyx_t_1);
  1812. __Pyx_GIVEREF(__pyx_t_1);
  1813. __Pyx_GOTREF(__pyx_v_self->_proto_on_body);
  1814. __Pyx_DECREF(__pyx_v_self->_proto_on_body);
  1815. __pyx_v_self->_proto_on_body = __pyx_t_1;
  1816. __pyx_t_1 = 0;
  1817. /* "httptools/parser/parser.pyx":77
  1818. *
  1819. * self._proto_on_body = getattr(protocol, 'on_body', None)
  1820. * if self._proto_on_body is not None: # <<<<<<<<<<<<<<
  1821. * self._csettings.on_body = cb_on_body
  1822. *
  1823. */
  1824. __pyx_t_3 = (__pyx_v_self->_proto_on_body != Py_None);
  1825. __pyx_t_2 = (__pyx_t_3 != 0);
  1826. if (__pyx_t_2) {
  1827. /* "httptools/parser/parser.pyx":78
  1828. * self._proto_on_body = getattr(protocol, 'on_body', None)
  1829. * if self._proto_on_body is not None:
  1830. * self._csettings.on_body = cb_on_body # <<<<<<<<<<<<<<
  1831. *
  1832. * self._proto_on_message_begin = getattr(
  1833. */
  1834. __pyx_v_self->_csettings->on_body = __pyx_f_9httptools_6parser_6parser_cb_on_body;
  1835. /* "httptools/parser/parser.pyx":77
  1836. *
  1837. * self._proto_on_body = getattr(protocol, 'on_body', None)
  1838. * if self._proto_on_body is not None: # <<<<<<<<<<<<<<
  1839. * self._csettings.on_body = cb_on_body
  1840. *
  1841. */
  1842. }
  1843. /* "httptools/parser/parser.pyx":80
  1844. * self._csettings.on_body = cb_on_body
  1845. *
  1846. * self._proto_on_message_begin = getattr( # <<<<<<<<<<<<<<
  1847. * protocol, 'on_message_begin', None)
  1848. * if self._proto_on_message_begin is not None:
  1849. */
  1850. __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_protocol, __pyx_n_u_on_message_begin, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error)
  1851. __Pyx_GOTREF(__pyx_t_1);
  1852. __Pyx_GIVEREF(__pyx_t_1);
  1853. __Pyx_GOTREF(__pyx_v_self->_proto_on_message_begin);
  1854. __Pyx_DECREF(__pyx_v_self->_proto_on_message_begin);
  1855. __pyx_v_self->_proto_on_message_begin = __pyx_t_1;
  1856. __pyx_t_1 = 0;
  1857. /* "httptools/parser/parser.pyx":82
  1858. * self._proto_on_message_begin = getattr(
  1859. * protocol, 'on_message_begin', None)
  1860. * if self._proto_on_message_begin is not None: # <<<<<<<<<<<<<<
  1861. * self._csettings.on_message_begin = cb_on_message_begin
  1862. *
  1863. */
  1864. __pyx_t_2 = (__pyx_v_self->_proto_on_message_begin != Py_None);
  1865. __pyx_t_3 = (__pyx_t_2 != 0);
  1866. if (__pyx_t_3) {
  1867. /* "httptools/parser/parser.pyx":83
  1868. * protocol, 'on_message_begin', None)
  1869. * if self._proto_on_message_begin is not None:
  1870. * self._csettings.on_message_begin = cb_on_message_begin # <<<<<<<<<<<<<<
  1871. *
  1872. * self._proto_on_message_complete = getattr(
  1873. */
  1874. __pyx_v_self->_csettings->on_message_begin = __pyx_f_9httptools_6parser_6parser_cb_on_message_begin;
  1875. /* "httptools/parser/parser.pyx":82
  1876. * self._proto_on_message_begin = getattr(
  1877. * protocol, 'on_message_begin', None)
  1878. * if self._proto_on_message_begin is not None: # <<<<<<<<<<<<<<
  1879. * self._csettings.on_message_begin = cb_on_message_begin
  1880. *
  1881. */
  1882. }
  1883. /* "httptools/parser/parser.pyx":85
  1884. * self._csettings.on_message_begin = cb_on_message_begin
  1885. *
  1886. * self._proto_on_message_complete = getattr( # <<<<<<<<<<<<<<
  1887. * protocol, 'on_message_complete', None)
  1888. * if self._proto_on_message_complete is not None:
  1889. */
  1890. __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_protocol, __pyx_n_u_on_message_complete, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error)
  1891. __Pyx_GOTREF(__pyx_t_1);
  1892. __Pyx_GIVEREF(__pyx_t_1);
  1893. __Pyx_GOTREF(__pyx_v_self->_proto_on_message_complete);
  1894. __Pyx_DECREF(__pyx_v_self->_proto_on_message_complete);
  1895. __pyx_v_self->_proto_on_message_complete = __pyx_t_1;
  1896. __pyx_t_1 = 0;
  1897. /* "httptools/parser/parser.pyx":87
  1898. * self._proto_on_message_complete = getattr(
  1899. * protocol, 'on_message_complete', None)
  1900. * if self._proto_on_message_complete is not None: # <<<<<<<<<<<<<<
  1901. * self._csettings.on_message_complete = cb_on_message_complete
  1902. *
  1903. */
  1904. __pyx_t_3 = (__pyx_v_self->_proto_on_message_complete != Py_None);
  1905. __pyx_t_2 = (__pyx_t_3 != 0);
  1906. if (__pyx_t_2) {
  1907. /* "httptools/parser/parser.pyx":88
  1908. * protocol, 'on_message_complete', None)
  1909. * if self._proto_on_message_complete is not None:
  1910. * self._csettings.on_message_complete = cb_on_message_complete # <<<<<<<<<<<<<<
  1911. *
  1912. * self._proto_on_chunk_header = getattr(
  1913. */
  1914. __pyx_v_self->_csettings->on_message_complete = __pyx_f_9httptools_6parser_6parser_cb_on_message_complete;
  1915. /* "httptools/parser/parser.pyx":87
  1916. * self._proto_on_message_complete = getattr(
  1917. * protocol, 'on_message_complete', None)
  1918. * if self._proto_on_message_complete is not None: # <<<<<<<<<<<<<<
  1919. * self._csettings.on_message_complete = cb_on_message_complete
  1920. *
  1921. */
  1922. }
  1923. /* "httptools/parser/parser.pyx":90
  1924. * self._csettings.on_message_complete = cb_on_message_complete
  1925. *
  1926. * self._proto_on_chunk_header = getattr( # <<<<<<<<<<<<<<
  1927. * protocol, 'on_chunk_header', None)
  1928. * self._csettings.on_chunk_header = cb_on_chunk_header
  1929. */
  1930. __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_protocol, __pyx_n_u_on_chunk_header, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
  1931. __Pyx_GOTREF(__pyx_t_1);
  1932. __Pyx_GIVEREF(__pyx_t_1);
  1933. __Pyx_GOTREF(__pyx_v_self->_proto_on_chunk_header);
  1934. __Pyx_DECREF(__pyx_v_self->_proto_on_chunk_header);
  1935. __pyx_v_self->_proto_on_chunk_header = __pyx_t_1;
  1936. __pyx_t_1 = 0;
  1937. /* "httptools/parser/parser.pyx":92
  1938. * self._proto_on_chunk_header = getattr(
  1939. * protocol, 'on_chunk_header', None)
  1940. * self._csettings.on_chunk_header = cb_on_chunk_header # <<<<<<<<<<<<<<
  1941. *
  1942. * self._proto_on_chunk_complete = getattr(
  1943. */
  1944. __pyx_v_self->_csettings->on_chunk_header = __pyx_f_9httptools_6parser_6parser_cb_on_chunk_header;
  1945. /* "httptools/parser/parser.pyx":94
  1946. * self._csettings.on_chunk_header = cb_on_chunk_header
  1947. *
  1948. * self._proto_on_chunk_complete = getattr( # <<<<<<<<<<<<<<
  1949. * protocol, 'on_chunk_complete', None)
  1950. * self._csettings.on_chunk_complete = cb_on_chunk_complete
  1951. */
  1952. __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_protocol, __pyx_n_u_on_chunk_complete, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error)
  1953. __Pyx_GOTREF(__pyx_t_1);
  1954. __Pyx_GIVEREF(__pyx_t_1);
  1955. __Pyx_GOTREF(__pyx_v_self->_proto_on_chunk_complete);
  1956. __Pyx_DECREF(__pyx_v_self->_proto_on_chunk_complete);
  1957. __pyx_v_self->_proto_on_chunk_complete = __pyx_t_1;
  1958. __pyx_t_1 = 0;
  1959. /* "httptools/parser/parser.pyx":96
  1960. * self._proto_on_chunk_complete = getattr(
  1961. * protocol, 'on_chunk_complete', None)
  1962. * self._csettings.on_chunk_complete = cb_on_chunk_complete # <<<<<<<<<<<<<<
  1963. *
  1964. * self._last_error = None
  1965. */
  1966. __pyx_v_self->_csettings->on_chunk_complete = __pyx_f_9httptools_6parser_6parser_cb_on_chunk_complete;
  1967. /* "httptools/parser/parser.pyx":98
  1968. * self._csettings.on_chunk_complete = cb_on_chunk_complete
  1969. *
  1970. * self._last_error = None # <<<<<<<<<<<<<<
  1971. *
  1972. * cdef _maybe_call_on_header(self):
  1973. */
  1974. __Pyx_INCREF(Py_None);
  1975. __Pyx_GIVEREF(Py_None);
  1976. __Pyx_GOTREF(__pyx_v_self->_last_error);
  1977. __Pyx_DECREF(__pyx_v_self->_last_error);
  1978. __pyx_v_self->_last_error = Py_None;
  1979. /* "httptools/parser/parser.pyx":59
  1980. * PyMem_Free(self._csettings)
  1981. *
  1982. * cdef _init(self, protocol, cparser.http_parser_type mode): # <<<<<<<<<<<<<<
  1983. * cparser.http_parser_init(self._cparser, mode)
  1984. * self._cparser.data = <void*>self
  1985. */
  1986. /* function exit code */
  1987. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  1988. goto __pyx_L0;
  1989. __pyx_L1_error:;
  1990. __Pyx_XDECREF(__pyx_t_1);
  1991. __Pyx_AddTraceback("httptools.parser.parser.HttpParser._init", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1992. __pyx_r = 0;
  1993. __pyx_L0:;
  1994. __Pyx_XGIVEREF(__pyx_r);
  1995. __Pyx_RefNannyFinishContext();
  1996. return __pyx_r;
  1997. }
  1998. /* "httptools/parser/parser.pyx":100
  1999. * self._last_error = None
  2000. *
  2001. * cdef _maybe_call_on_header(self): # <<<<<<<<<<<<<<
  2002. * if self._current_header_value is not None:
  2003. * current_header_name = self._current_header_name
  2004. */
  2005. static PyObject *__pyx_f_9httptools_6parser_6parser_10HttpParser__maybe_call_on_header(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self) {
  2006. PyObject *__pyx_v_current_header_name = NULL;
  2007. PyObject *__pyx_v_current_header_value = NULL;
  2008. PyObject *__pyx_r = NULL;
  2009. __Pyx_RefNannyDeclarations
  2010. int __pyx_t_1;
  2011. int __pyx_t_2;
  2012. PyObject *__pyx_t_3 = NULL;
  2013. PyObject *__pyx_t_4 = NULL;
  2014. PyObject *__pyx_t_5 = NULL;
  2015. int __pyx_t_6;
  2016. PyObject *__pyx_t_7 = NULL;
  2017. __Pyx_RefNannySetupContext("_maybe_call_on_header", 0);
  2018. /* "httptools/parser/parser.pyx":101
  2019. *
  2020. * cdef _maybe_call_on_header(self):
  2021. * if self._current_header_value is not None: # <<<<<<<<<<<<<<
  2022. * current_header_name = self._current_header_name
  2023. * current_header_value = self._current_header_value
  2024. */
  2025. __pyx_t_1 = (__pyx_v_self->_current_header_value != ((PyObject*)Py_None));
  2026. __pyx_t_2 = (__pyx_t_1 != 0);
  2027. if (__pyx_t_2) {
  2028. /* "httptools/parser/parser.pyx":102
  2029. * cdef _maybe_call_on_header(self):
  2030. * if self._current_header_value is not None:
  2031. * current_header_name = self._current_header_name # <<<<<<<<<<<<<<
  2032. * current_header_value = self._current_header_value
  2033. *
  2034. */
  2035. __pyx_t_3 = __pyx_v_self->_current_header_name;
  2036. __Pyx_INCREF(__pyx_t_3);
  2037. __pyx_v_current_header_name = ((PyObject*)__pyx_t_3);
  2038. __pyx_t_3 = 0;
  2039. /* "httptools/parser/parser.pyx":103
  2040. * if self._current_header_value is not None:
  2041. * current_header_name = self._current_header_name
  2042. * current_header_value = self._current_header_value # <<<<<<<<<<<<<<
  2043. *
  2044. * self._current_header_name = self._current_header_value = None
  2045. */
  2046. __pyx_t_3 = __pyx_v_self->_current_header_value;
  2047. __Pyx_INCREF(__pyx_t_3);
  2048. __pyx_v_current_header_value = ((PyObject*)__pyx_t_3);
  2049. __pyx_t_3 = 0;
  2050. /* "httptools/parser/parser.pyx":105
  2051. * current_header_value = self._current_header_value
  2052. *
  2053. * self._current_header_name = self._current_header_value = None # <<<<<<<<<<<<<<
  2054. *
  2055. * if self._proto_on_header is not None:
  2056. */
  2057. __Pyx_INCREF(Py_None);
  2058. __Pyx_GIVEREF(Py_None);
  2059. __Pyx_GOTREF(__pyx_v_self->_current_header_name);
  2060. __Pyx_DECREF(__pyx_v_self->_current_header_name);
  2061. __pyx_v_self->_current_header_name = ((PyObject*)Py_None);
  2062. __Pyx_INCREF(Py_None);
  2063. __Pyx_GIVEREF(Py_None);
  2064. __Pyx_GOTREF(__pyx_v_self->_current_header_value);
  2065. __Pyx_DECREF(__pyx_v_self->_current_header_value);
  2066. __pyx_v_self->_current_header_value = ((PyObject*)Py_None);
  2067. /* "httptools/parser/parser.pyx":107
  2068. * self._current_header_name = self._current_header_value = None
  2069. *
  2070. * if self._proto_on_header is not None: # <<<<<<<<<<<<<<
  2071. * self._proto_on_header(current_header_name,
  2072. * current_header_value)
  2073. */
  2074. __pyx_t_2 = (__pyx_v_self->_proto_on_header != Py_None);
  2075. __pyx_t_1 = (__pyx_t_2 != 0);
  2076. if (__pyx_t_1) {
  2077. /* "httptools/parser/parser.pyx":109
  2078. * if self._proto_on_header is not None:
  2079. * self._proto_on_header(current_header_name,
  2080. * current_header_value) # <<<<<<<<<<<<<<
  2081. *
  2082. * cdef _on_header_field(self, bytes field):
  2083. */
  2084. __Pyx_INCREF(__pyx_v_self->_proto_on_header);
  2085. __pyx_t_4 = __pyx_v_self->_proto_on_header; __pyx_t_5 = NULL;
  2086. __pyx_t_6 = 0;
  2087. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  2088. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  2089. if (likely(__pyx_t_5)) {
  2090. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  2091. __Pyx_INCREF(__pyx_t_5);
  2092. __Pyx_INCREF(function);
  2093. __Pyx_DECREF_SET(__pyx_t_4, function);
  2094. __pyx_t_6 = 1;
  2095. }
  2096. }
  2097. #if CYTHON_FAST_PYCALL
  2098. if (PyFunction_Check(__pyx_t_4)) {
  2099. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_current_header_name, __pyx_v_current_header_value};
  2100. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 108, __pyx_L1_error)
  2101. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2102. __Pyx_GOTREF(__pyx_t_3);
  2103. } else
  2104. #endif
  2105. #if CYTHON_FAST_PYCCALL
  2106. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  2107. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_current_header_name, __pyx_v_current_header_value};
  2108. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 108, __pyx_L1_error)
  2109. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2110. __Pyx_GOTREF(__pyx_t_3);
  2111. } else
  2112. #endif
  2113. {
  2114. __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 108, __pyx_L1_error)
  2115. __Pyx_GOTREF(__pyx_t_7);
  2116. if (__pyx_t_5) {
  2117. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  2118. }
  2119. __Pyx_INCREF(__pyx_v_current_header_name);
  2120. __Pyx_GIVEREF(__pyx_v_current_header_name);
  2121. PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_current_header_name);
  2122. __Pyx_INCREF(__pyx_v_current_header_value);
  2123. __Pyx_GIVEREF(__pyx_v_current_header_value);
  2124. PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_current_header_value);
  2125. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 108, __pyx_L1_error)
  2126. __Pyx_GOTREF(__pyx_t_3);
  2127. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2128. }
  2129. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2130. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2131. /* "httptools/parser/parser.pyx":107
  2132. * self._current_header_name = self._current_header_value = None
  2133. *
  2134. * if self._proto_on_header is not None: # <<<<<<<<<<<<<<
  2135. * self._proto_on_header(current_header_name,
  2136. * current_header_value)
  2137. */
  2138. }
  2139. /* "httptools/parser/parser.pyx":101
  2140. *
  2141. * cdef _maybe_call_on_header(self):
  2142. * if self._current_header_value is not None: # <<<<<<<<<<<<<<
  2143. * current_header_name = self._current_header_name
  2144. * current_header_value = self._current_header_value
  2145. */
  2146. }
  2147. /* "httptools/parser/parser.pyx":100
  2148. * self._last_error = None
  2149. *
  2150. * cdef _maybe_call_on_header(self): # <<<<<<<<<<<<<<
  2151. * if self._current_header_value is not None:
  2152. * current_header_name = self._current_header_name
  2153. */
  2154. /* function exit code */
  2155. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  2156. goto __pyx_L0;
  2157. __pyx_L1_error:;
  2158. __Pyx_XDECREF(__pyx_t_3);
  2159. __Pyx_XDECREF(__pyx_t_4);
  2160. __Pyx_XDECREF(__pyx_t_5);
  2161. __Pyx_XDECREF(__pyx_t_7);
  2162. __Pyx_AddTraceback("httptools.parser.parser.HttpParser._maybe_call_on_header", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2163. __pyx_r = 0;
  2164. __pyx_L0:;
  2165. __Pyx_XDECREF(__pyx_v_current_header_name);
  2166. __Pyx_XDECREF(__pyx_v_current_header_value);
  2167. __Pyx_XGIVEREF(__pyx_r);
  2168. __Pyx_RefNannyFinishContext();
  2169. return __pyx_r;
  2170. }
  2171. /* "httptools/parser/parser.pyx":111
  2172. * current_header_value)
  2173. *
  2174. * cdef _on_header_field(self, bytes field): # <<<<<<<<<<<<<<
  2175. * self._maybe_call_on_header()
  2176. * if self._current_header_name is None:
  2177. */
  2178. static PyObject *__pyx_f_9httptools_6parser_6parser_10HttpParser__on_header_field(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self, PyObject *__pyx_v_field) {
  2179. PyObject *__pyx_r = NULL;
  2180. __Pyx_RefNannyDeclarations
  2181. PyObject *__pyx_t_1 = NULL;
  2182. int __pyx_t_2;
  2183. int __pyx_t_3;
  2184. __Pyx_RefNannySetupContext("_on_header_field", 0);
  2185. /* "httptools/parser/parser.pyx":112
  2186. *
  2187. * cdef _on_header_field(self, bytes field):
  2188. * self._maybe_call_on_header() # <<<<<<<<<<<<<<
  2189. * if self._current_header_name is None:
  2190. * self._current_header_name = field
  2191. */
  2192. __pyx_t_1 = ((struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser *)__pyx_v_self->__pyx_vtab)->_maybe_call_on_header(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error)
  2193. __Pyx_GOTREF(__pyx_t_1);
  2194. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2195. /* "httptools/parser/parser.pyx":113
  2196. * cdef _on_header_field(self, bytes field):
  2197. * self._maybe_call_on_header()
  2198. * if self._current_header_name is None: # <<<<<<<<<<<<<<
  2199. * self._current_header_name = field
  2200. * else:
  2201. */
  2202. __pyx_t_2 = (__pyx_v_self->_current_header_name == ((PyObject*)Py_None));
  2203. __pyx_t_3 = (__pyx_t_2 != 0);
  2204. if (__pyx_t_3) {
  2205. /* "httptools/parser/parser.pyx":114
  2206. * self._maybe_call_on_header()
  2207. * if self._current_header_name is None:
  2208. * self._current_header_name = field # <<<<<<<<<<<<<<
  2209. * else:
  2210. * self._current_header_name += field
  2211. */
  2212. __Pyx_INCREF(__pyx_v_field);
  2213. __Pyx_GIVEREF(__pyx_v_field);
  2214. __Pyx_GOTREF(__pyx_v_self->_current_header_name);
  2215. __Pyx_DECREF(__pyx_v_self->_current_header_name);
  2216. __pyx_v_self->_current_header_name = __pyx_v_field;
  2217. /* "httptools/parser/parser.pyx":113
  2218. * cdef _on_header_field(self, bytes field):
  2219. * self._maybe_call_on_header()
  2220. * if self._current_header_name is None: # <<<<<<<<<<<<<<
  2221. * self._current_header_name = field
  2222. * else:
  2223. */
  2224. goto __pyx_L3;
  2225. }
  2226. /* "httptools/parser/parser.pyx":116
  2227. * self._current_header_name = field
  2228. * else:
  2229. * self._current_header_name += field # <<<<<<<<<<<<<<
  2230. *
  2231. * cdef _on_header_value(self, bytes val):
  2232. */
  2233. /*else*/ {
  2234. __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_self->_current_header_name, __pyx_v_field); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error)
  2235. __Pyx_GOTREF(__pyx_t_1);
  2236. __Pyx_GIVEREF(__pyx_t_1);
  2237. __Pyx_GOTREF(__pyx_v_self->_current_header_name);
  2238. __Pyx_DECREF(__pyx_v_self->_current_header_name);
  2239. __pyx_v_self->_current_header_name = ((PyObject*)__pyx_t_1);
  2240. __pyx_t_1 = 0;
  2241. }
  2242. __pyx_L3:;
  2243. /* "httptools/parser/parser.pyx":111
  2244. * current_header_value)
  2245. *
  2246. * cdef _on_header_field(self, bytes field): # <<<<<<<<<<<<<<
  2247. * self._maybe_call_on_header()
  2248. * if self._current_header_name is None:
  2249. */
  2250. /* function exit code */
  2251. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  2252. goto __pyx_L0;
  2253. __pyx_L1_error:;
  2254. __Pyx_XDECREF(__pyx_t_1);
  2255. __Pyx_AddTraceback("httptools.parser.parser.HttpParser._on_header_field", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2256. __pyx_r = 0;
  2257. __pyx_L0:;
  2258. __Pyx_XGIVEREF(__pyx_r);
  2259. __Pyx_RefNannyFinishContext();
  2260. return __pyx_r;
  2261. }
  2262. /* "httptools/parser/parser.pyx":118
  2263. * self._current_header_name += field
  2264. *
  2265. * cdef _on_header_value(self, bytes val): # <<<<<<<<<<<<<<
  2266. * if self._current_header_value is None:
  2267. * self._current_header_value = val
  2268. */
  2269. static PyObject *__pyx_f_9httptools_6parser_6parser_10HttpParser__on_header_value(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self, PyObject *__pyx_v_val) {
  2270. PyObject *__pyx_r = NULL;
  2271. __Pyx_RefNannyDeclarations
  2272. int __pyx_t_1;
  2273. int __pyx_t_2;
  2274. PyObject *__pyx_t_3 = NULL;
  2275. __Pyx_RefNannySetupContext("_on_header_value", 0);
  2276. /* "httptools/parser/parser.pyx":119
  2277. *
  2278. * cdef _on_header_value(self, bytes val):
  2279. * if self._current_header_value is None: # <<<<<<<<<<<<<<
  2280. * self._current_header_value = val
  2281. * else:
  2282. */
  2283. __pyx_t_1 = (__pyx_v_self->_current_header_value == ((PyObject*)Py_None));
  2284. __pyx_t_2 = (__pyx_t_1 != 0);
  2285. if (__pyx_t_2) {
  2286. /* "httptools/parser/parser.pyx":120
  2287. * cdef _on_header_value(self, bytes val):
  2288. * if self._current_header_value is None:
  2289. * self._current_header_value = val # <<<<<<<<<<<<<<
  2290. * else:
  2291. * # This is unlikely, as mostly HTTP headers are one-line
  2292. */
  2293. __Pyx_INCREF(__pyx_v_val);
  2294. __Pyx_GIVEREF(__pyx_v_val);
  2295. __Pyx_GOTREF(__pyx_v_self->_current_header_value);
  2296. __Pyx_DECREF(__pyx_v_self->_current_header_value);
  2297. __pyx_v_self->_current_header_value = __pyx_v_val;
  2298. /* "httptools/parser/parser.pyx":119
  2299. *
  2300. * cdef _on_header_value(self, bytes val):
  2301. * if self._current_header_value is None: # <<<<<<<<<<<<<<
  2302. * self._current_header_value = val
  2303. * else:
  2304. */
  2305. goto __pyx_L3;
  2306. }
  2307. /* "httptools/parser/parser.pyx":123
  2308. * else:
  2309. * # This is unlikely, as mostly HTTP headers are one-line
  2310. * self._current_header_value += val # <<<<<<<<<<<<<<
  2311. *
  2312. * cdef _on_headers_complete(self):
  2313. */
  2314. /*else*/ {
  2315. __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_self->_current_header_value, __pyx_v_val); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 123, __pyx_L1_error)
  2316. __Pyx_GOTREF(__pyx_t_3);
  2317. __Pyx_GIVEREF(__pyx_t_3);
  2318. __Pyx_GOTREF(__pyx_v_self->_current_header_value);
  2319. __Pyx_DECREF(__pyx_v_self->_current_header_value);
  2320. __pyx_v_self->_current_header_value = ((PyObject*)__pyx_t_3);
  2321. __pyx_t_3 = 0;
  2322. }
  2323. __pyx_L3:;
  2324. /* "httptools/parser/parser.pyx":118
  2325. * self._current_header_name += field
  2326. *
  2327. * cdef _on_header_value(self, bytes val): # <<<<<<<<<<<<<<
  2328. * if self._current_header_value is None:
  2329. * self._current_header_value = val
  2330. */
  2331. /* function exit code */
  2332. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  2333. goto __pyx_L0;
  2334. __pyx_L1_error:;
  2335. __Pyx_XDECREF(__pyx_t_3);
  2336. __Pyx_AddTraceback("httptools.parser.parser.HttpParser._on_header_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2337. __pyx_r = 0;
  2338. __pyx_L0:;
  2339. __Pyx_XGIVEREF(__pyx_r);
  2340. __Pyx_RefNannyFinishContext();
  2341. return __pyx_r;
  2342. }
  2343. /* "httptools/parser/parser.pyx":125
  2344. * self._current_header_value += val
  2345. *
  2346. * cdef _on_headers_complete(self): # <<<<<<<<<<<<<<
  2347. * self._maybe_call_on_header()
  2348. *
  2349. */
  2350. static PyObject *__pyx_f_9httptools_6parser_6parser_10HttpParser__on_headers_complete(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self) {
  2351. PyObject *__pyx_r = NULL;
  2352. __Pyx_RefNannyDeclarations
  2353. PyObject *__pyx_t_1 = NULL;
  2354. int __pyx_t_2;
  2355. int __pyx_t_3;
  2356. PyObject *__pyx_t_4 = NULL;
  2357. PyObject *__pyx_t_5 = NULL;
  2358. __Pyx_RefNannySetupContext("_on_headers_complete", 0);
  2359. /* "httptools/parser/parser.pyx":126
  2360. *
  2361. * cdef _on_headers_complete(self):
  2362. * self._maybe_call_on_header() # <<<<<<<<<<<<<<
  2363. *
  2364. * if self._proto_on_headers_complete is not None:
  2365. */
  2366. __pyx_t_1 = ((struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser *)__pyx_v_self->__pyx_vtab)->_maybe_call_on_header(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error)
  2367. __Pyx_GOTREF(__pyx_t_1);
  2368. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2369. /* "httptools/parser/parser.pyx":128
  2370. * self._maybe_call_on_header()
  2371. *
  2372. * if self._proto_on_headers_complete is not None: # <<<<<<<<<<<<<<
  2373. * self._proto_on_headers_complete()
  2374. *
  2375. */
  2376. __pyx_t_2 = (__pyx_v_self->_proto_on_headers_complete != Py_None);
  2377. __pyx_t_3 = (__pyx_t_2 != 0);
  2378. if (__pyx_t_3) {
  2379. /* "httptools/parser/parser.pyx":129
  2380. *
  2381. * if self._proto_on_headers_complete is not None:
  2382. * self._proto_on_headers_complete() # <<<<<<<<<<<<<<
  2383. *
  2384. * cdef _on_chunk_header(self):
  2385. */
  2386. __Pyx_INCREF(__pyx_v_self->_proto_on_headers_complete);
  2387. __pyx_t_4 = __pyx_v_self->_proto_on_headers_complete; __pyx_t_5 = NULL;
  2388. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  2389. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  2390. if (likely(__pyx_t_5)) {
  2391. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  2392. __Pyx_INCREF(__pyx_t_5);
  2393. __Pyx_INCREF(function);
  2394. __Pyx_DECREF_SET(__pyx_t_4, function);
  2395. }
  2396. }
  2397. __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  2398. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2399. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error)
  2400. __Pyx_GOTREF(__pyx_t_1);
  2401. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2402. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2403. /* "httptools/parser/parser.pyx":128
  2404. * self._maybe_call_on_header()
  2405. *
  2406. * if self._proto_on_headers_complete is not None: # <<<<<<<<<<<<<<
  2407. * self._proto_on_headers_complete()
  2408. *
  2409. */
  2410. }
  2411. /* "httptools/parser/parser.pyx":125
  2412. * self._current_header_value += val
  2413. *
  2414. * cdef _on_headers_complete(self): # <<<<<<<<<<<<<<
  2415. * self._maybe_call_on_header()
  2416. *
  2417. */
  2418. /* function exit code */
  2419. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  2420. goto __pyx_L0;
  2421. __pyx_L1_error:;
  2422. __Pyx_XDECREF(__pyx_t_1);
  2423. __Pyx_XDECREF(__pyx_t_4);
  2424. __Pyx_XDECREF(__pyx_t_5);
  2425. __Pyx_AddTraceback("httptools.parser.parser.HttpParser._on_headers_complete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2426. __pyx_r = 0;
  2427. __pyx_L0:;
  2428. __Pyx_XGIVEREF(__pyx_r);
  2429. __Pyx_RefNannyFinishContext();
  2430. return __pyx_r;
  2431. }
  2432. /* "httptools/parser/parser.pyx":131
  2433. * self._proto_on_headers_complete()
  2434. *
  2435. * cdef _on_chunk_header(self): # <<<<<<<<<<<<<<
  2436. * if (self._current_header_value is not None or
  2437. * self._current_header_name is not None):
  2438. */
  2439. static PyObject *__pyx_f_9httptools_6parser_6parser_10HttpParser__on_chunk_header(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self) {
  2440. PyObject *__pyx_r = NULL;
  2441. __Pyx_RefNannyDeclarations
  2442. int __pyx_t_1;
  2443. int __pyx_t_2;
  2444. int __pyx_t_3;
  2445. PyObject *__pyx_t_4 = NULL;
  2446. PyObject *__pyx_t_5 = NULL;
  2447. PyObject *__pyx_t_6 = NULL;
  2448. __Pyx_RefNannySetupContext("_on_chunk_header", 0);
  2449. /* "httptools/parser/parser.pyx":132
  2450. *
  2451. * cdef _on_chunk_header(self):
  2452. * if (self._current_header_value is not None or # <<<<<<<<<<<<<<
  2453. * self._current_header_name is not None):
  2454. * raise HttpParserError('invalid headers state')
  2455. */
  2456. __pyx_t_2 = (__pyx_v_self->_current_header_value != ((PyObject*)Py_None));
  2457. __pyx_t_3 = (__pyx_t_2 != 0);
  2458. if (!__pyx_t_3) {
  2459. } else {
  2460. __pyx_t_1 = __pyx_t_3;
  2461. goto __pyx_L4_bool_binop_done;
  2462. }
  2463. /* "httptools/parser/parser.pyx":133
  2464. * cdef _on_chunk_header(self):
  2465. * if (self._current_header_value is not None or
  2466. * self._current_header_name is not None): # <<<<<<<<<<<<<<
  2467. * raise HttpParserError('invalid headers state')
  2468. *
  2469. */
  2470. __pyx_t_3 = (__pyx_v_self->_current_header_name != ((PyObject*)Py_None));
  2471. __pyx_t_2 = (__pyx_t_3 != 0);
  2472. __pyx_t_1 = __pyx_t_2;
  2473. __pyx_L4_bool_binop_done:;
  2474. /* "httptools/parser/parser.pyx":132
  2475. *
  2476. * cdef _on_chunk_header(self):
  2477. * if (self._current_header_value is not None or # <<<<<<<<<<<<<<
  2478. * self._current_header_name is not None):
  2479. * raise HttpParserError('invalid headers state')
  2480. */
  2481. if (unlikely(__pyx_t_1)) {
  2482. /* "httptools/parser/parser.pyx":134
  2483. * if (self._current_header_value is not None or
  2484. * self._current_header_name is not None):
  2485. * raise HttpParserError('invalid headers state') # <<<<<<<<<<<<<<
  2486. *
  2487. * if self._proto_on_chunk_header is not None:
  2488. */
  2489. __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_HttpParserError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 134, __pyx_L1_error)
  2490. __Pyx_GOTREF(__pyx_t_5);
  2491. __pyx_t_6 = NULL;
  2492. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  2493. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
  2494. if (likely(__pyx_t_6)) {
  2495. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  2496. __Pyx_INCREF(__pyx_t_6);
  2497. __Pyx_INCREF(function);
  2498. __Pyx_DECREF_SET(__pyx_t_5, function);
  2499. }
  2500. }
  2501. __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_kp_u_invalid_headers_state) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_kp_u_invalid_headers_state);
  2502. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2503. if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 134, __pyx_L1_error)
  2504. __Pyx_GOTREF(__pyx_t_4);
  2505. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2506. __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  2507. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2508. __PYX_ERR(0, 134, __pyx_L1_error)
  2509. /* "httptools/parser/parser.pyx":132
  2510. *
  2511. * cdef _on_chunk_header(self):
  2512. * if (self._current_header_value is not None or # <<<<<<<<<<<<<<
  2513. * self._current_header_name is not None):
  2514. * raise HttpParserError('invalid headers state')
  2515. */
  2516. }
  2517. /* "httptools/parser/parser.pyx":136
  2518. * raise HttpParserError('invalid headers state')
  2519. *
  2520. * if self._proto_on_chunk_header is not None: # <<<<<<<<<<<<<<
  2521. * self._proto_on_chunk_header()
  2522. *
  2523. */
  2524. __pyx_t_1 = (__pyx_v_self->_proto_on_chunk_header != Py_None);
  2525. __pyx_t_2 = (__pyx_t_1 != 0);
  2526. if (__pyx_t_2) {
  2527. /* "httptools/parser/parser.pyx":137
  2528. *
  2529. * if self._proto_on_chunk_header is not None:
  2530. * self._proto_on_chunk_header() # <<<<<<<<<<<<<<
  2531. *
  2532. * cdef _on_chunk_complete(self):
  2533. */
  2534. __Pyx_INCREF(__pyx_v_self->_proto_on_chunk_header);
  2535. __pyx_t_5 = __pyx_v_self->_proto_on_chunk_header; __pyx_t_6 = NULL;
  2536. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  2537. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
  2538. if (likely(__pyx_t_6)) {
  2539. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  2540. __Pyx_INCREF(__pyx_t_6);
  2541. __Pyx_INCREF(function);
  2542. __Pyx_DECREF_SET(__pyx_t_5, function);
  2543. }
  2544. }
  2545. __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
  2546. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2547. if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 137, __pyx_L1_error)
  2548. __Pyx_GOTREF(__pyx_t_4);
  2549. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2550. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2551. /* "httptools/parser/parser.pyx":136
  2552. * raise HttpParserError('invalid headers state')
  2553. *
  2554. * if self._proto_on_chunk_header is not None: # <<<<<<<<<<<<<<
  2555. * self._proto_on_chunk_header()
  2556. *
  2557. */
  2558. }
  2559. /* "httptools/parser/parser.pyx":131
  2560. * self._proto_on_headers_complete()
  2561. *
  2562. * cdef _on_chunk_header(self): # <<<<<<<<<<<<<<
  2563. * if (self._current_header_value is not None or
  2564. * self._current_header_name is not None):
  2565. */
  2566. /* function exit code */
  2567. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  2568. goto __pyx_L0;
  2569. __pyx_L1_error:;
  2570. __Pyx_XDECREF(__pyx_t_4);
  2571. __Pyx_XDECREF(__pyx_t_5);
  2572. __Pyx_XDECREF(__pyx_t_6);
  2573. __Pyx_AddTraceback("httptools.parser.parser.HttpParser._on_chunk_header", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2574. __pyx_r = 0;
  2575. __pyx_L0:;
  2576. __Pyx_XGIVEREF(__pyx_r);
  2577. __Pyx_RefNannyFinishContext();
  2578. return __pyx_r;
  2579. }
  2580. /* "httptools/parser/parser.pyx":139
  2581. * self._proto_on_chunk_header()
  2582. *
  2583. * cdef _on_chunk_complete(self): # <<<<<<<<<<<<<<
  2584. * self._maybe_call_on_header()
  2585. *
  2586. */
  2587. static PyObject *__pyx_f_9httptools_6parser_6parser_10HttpParser__on_chunk_complete(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self) {
  2588. PyObject *__pyx_r = NULL;
  2589. __Pyx_RefNannyDeclarations
  2590. PyObject *__pyx_t_1 = NULL;
  2591. int __pyx_t_2;
  2592. int __pyx_t_3;
  2593. PyObject *__pyx_t_4 = NULL;
  2594. PyObject *__pyx_t_5 = NULL;
  2595. __Pyx_RefNannySetupContext("_on_chunk_complete", 0);
  2596. /* "httptools/parser/parser.pyx":140
  2597. *
  2598. * cdef _on_chunk_complete(self):
  2599. * self._maybe_call_on_header() # <<<<<<<<<<<<<<
  2600. *
  2601. * if self._proto_on_chunk_complete is not None:
  2602. */
  2603. __pyx_t_1 = ((struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser *)__pyx_v_self->__pyx_vtab)->_maybe_call_on_header(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
  2604. __Pyx_GOTREF(__pyx_t_1);
  2605. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2606. /* "httptools/parser/parser.pyx":142
  2607. * self._maybe_call_on_header()
  2608. *
  2609. * if self._proto_on_chunk_complete is not None: # <<<<<<<<<<<<<<
  2610. * self._proto_on_chunk_complete()
  2611. *
  2612. */
  2613. __pyx_t_2 = (__pyx_v_self->_proto_on_chunk_complete != Py_None);
  2614. __pyx_t_3 = (__pyx_t_2 != 0);
  2615. if (__pyx_t_3) {
  2616. /* "httptools/parser/parser.pyx":143
  2617. *
  2618. * if self._proto_on_chunk_complete is not None:
  2619. * self._proto_on_chunk_complete() # <<<<<<<<<<<<<<
  2620. *
  2621. * ### Public API ###
  2622. */
  2623. __Pyx_INCREF(__pyx_v_self->_proto_on_chunk_complete);
  2624. __pyx_t_4 = __pyx_v_self->_proto_on_chunk_complete; __pyx_t_5 = NULL;
  2625. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  2626. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  2627. if (likely(__pyx_t_5)) {
  2628. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  2629. __Pyx_INCREF(__pyx_t_5);
  2630. __Pyx_INCREF(function);
  2631. __Pyx_DECREF_SET(__pyx_t_4, function);
  2632. }
  2633. }
  2634. __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  2635. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2636. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
  2637. __Pyx_GOTREF(__pyx_t_1);
  2638. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2639. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2640. /* "httptools/parser/parser.pyx":142
  2641. * self._maybe_call_on_header()
  2642. *
  2643. * if self._proto_on_chunk_complete is not None: # <<<<<<<<<<<<<<
  2644. * self._proto_on_chunk_complete()
  2645. *
  2646. */
  2647. }
  2648. /* "httptools/parser/parser.pyx":139
  2649. * self._proto_on_chunk_header()
  2650. *
  2651. * cdef _on_chunk_complete(self): # <<<<<<<<<<<<<<
  2652. * self._maybe_call_on_header()
  2653. *
  2654. */
  2655. /* function exit code */
  2656. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  2657. goto __pyx_L0;
  2658. __pyx_L1_error:;
  2659. __Pyx_XDECREF(__pyx_t_1);
  2660. __Pyx_XDECREF(__pyx_t_4);
  2661. __Pyx_XDECREF(__pyx_t_5);
  2662. __Pyx_AddTraceback("httptools.parser.parser.HttpParser._on_chunk_complete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2663. __pyx_r = 0;
  2664. __pyx_L0:;
  2665. __Pyx_XGIVEREF(__pyx_r);
  2666. __Pyx_RefNannyFinishContext();
  2667. return __pyx_r;
  2668. }
  2669. /* "httptools/parser/parser.pyx":147
  2670. * ### Public API ###
  2671. *
  2672. * def get_http_version(self): # <<<<<<<<<<<<<<
  2673. * cdef cparser.http_parser* parser = self._cparser
  2674. * return '{}.{}'.format(parser.http_major, parser.http_minor)
  2675. */
  2676. /* Python wrapper */
  2677. static PyObject *__pyx_pw_9httptools_6parser_6parser_10HttpParser_5get_http_version(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  2678. static PyObject *__pyx_pw_9httptools_6parser_6parser_10HttpParser_5get_http_version(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  2679. PyObject *__pyx_r = 0;
  2680. __Pyx_RefNannyDeclarations
  2681. __Pyx_RefNannySetupContext("get_http_version (wrapper)", 0);
  2682. __pyx_r = __pyx_pf_9httptools_6parser_6parser_10HttpParser_4get_http_version(((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_v_self));
  2683. /* function exit code */
  2684. __Pyx_RefNannyFinishContext();
  2685. return __pyx_r;
  2686. }
  2687. static PyObject *__pyx_pf_9httptools_6parser_6parser_10HttpParser_4get_http_version(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self) {
  2688. struct http_parser *__pyx_v_parser;
  2689. PyObject *__pyx_r = NULL;
  2690. __Pyx_RefNannyDeclarations
  2691. struct http_parser *__pyx_t_1;
  2692. PyObject *__pyx_t_2 = NULL;
  2693. PyObject *__pyx_t_3 = NULL;
  2694. PyObject *__pyx_t_4 = NULL;
  2695. PyObject *__pyx_t_5 = NULL;
  2696. PyObject *__pyx_t_6 = NULL;
  2697. int __pyx_t_7;
  2698. PyObject *__pyx_t_8 = NULL;
  2699. __Pyx_RefNannySetupContext("get_http_version", 0);
  2700. /* "httptools/parser/parser.pyx":148
  2701. *
  2702. * def get_http_version(self):
  2703. * cdef cparser.http_parser* parser = self._cparser # <<<<<<<<<<<<<<
  2704. * return '{}.{}'.format(parser.http_major, parser.http_minor)
  2705. *
  2706. */
  2707. __pyx_t_1 = __pyx_v_self->_cparser;
  2708. __pyx_v_parser = __pyx_t_1;
  2709. /* "httptools/parser/parser.pyx":149
  2710. * def get_http_version(self):
  2711. * cdef cparser.http_parser* parser = self._cparser
  2712. * return '{}.{}'.format(parser.http_major, parser.http_minor) # <<<<<<<<<<<<<<
  2713. *
  2714. * def should_keep_alive(self):
  2715. */
  2716. __Pyx_XDECREF(__pyx_r);
  2717. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 149, __pyx_L1_error)
  2718. __Pyx_GOTREF(__pyx_t_3);
  2719. __pyx_t_4 = __Pyx_PyInt_From_unsigned_short(__pyx_v_parser->http_major); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 149, __pyx_L1_error)
  2720. __Pyx_GOTREF(__pyx_t_4);
  2721. __pyx_t_5 = __Pyx_PyInt_From_unsigned_short(__pyx_v_parser->http_minor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 149, __pyx_L1_error)
  2722. __Pyx_GOTREF(__pyx_t_5);
  2723. __pyx_t_6 = NULL;
  2724. __pyx_t_7 = 0;
  2725. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  2726. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
  2727. if (likely(__pyx_t_6)) {
  2728. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  2729. __Pyx_INCREF(__pyx_t_6);
  2730. __Pyx_INCREF(function);
  2731. __Pyx_DECREF_SET(__pyx_t_3, function);
  2732. __pyx_t_7 = 1;
  2733. }
  2734. }
  2735. #if CYTHON_FAST_PYCALL
  2736. if (PyFunction_Check(__pyx_t_3)) {
  2737. PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_t_5};
  2738. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error)
  2739. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2740. __Pyx_GOTREF(__pyx_t_2);
  2741. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2742. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2743. } else
  2744. #endif
  2745. #if CYTHON_FAST_PYCCALL
  2746. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  2747. PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_t_5};
  2748. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error)
  2749. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2750. __Pyx_GOTREF(__pyx_t_2);
  2751. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2752. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2753. } else
  2754. #endif
  2755. {
  2756. __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 149, __pyx_L1_error)
  2757. __Pyx_GOTREF(__pyx_t_8);
  2758. if (__pyx_t_6) {
  2759. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
  2760. }
  2761. __Pyx_GIVEREF(__pyx_t_4);
  2762. PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_4);
  2763. __Pyx_GIVEREF(__pyx_t_5);
  2764. PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5);
  2765. __pyx_t_4 = 0;
  2766. __pyx_t_5 = 0;
  2767. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error)
  2768. __Pyx_GOTREF(__pyx_t_2);
  2769. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2770. }
  2771. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2772. __pyx_r = __pyx_t_2;
  2773. __pyx_t_2 = 0;
  2774. goto __pyx_L0;
  2775. /* "httptools/parser/parser.pyx":147
  2776. * ### Public API ###
  2777. *
  2778. * def get_http_version(self): # <<<<<<<<<<<<<<
  2779. * cdef cparser.http_parser* parser = self._cparser
  2780. * return '{}.{}'.format(parser.http_major, parser.http_minor)
  2781. */
  2782. /* function exit code */
  2783. __pyx_L1_error:;
  2784. __Pyx_XDECREF(__pyx_t_2);
  2785. __Pyx_XDECREF(__pyx_t_3);
  2786. __Pyx_XDECREF(__pyx_t_4);
  2787. __Pyx_XDECREF(__pyx_t_5);
  2788. __Pyx_XDECREF(__pyx_t_6);
  2789. __Pyx_XDECREF(__pyx_t_8);
  2790. __Pyx_AddTraceback("httptools.parser.parser.HttpParser.get_http_version", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2791. __pyx_r = NULL;
  2792. __pyx_L0:;
  2793. __Pyx_XGIVEREF(__pyx_r);
  2794. __Pyx_RefNannyFinishContext();
  2795. return __pyx_r;
  2796. }
  2797. /* "httptools/parser/parser.pyx":151
  2798. * return '{}.{}'.format(parser.http_major, parser.http_minor)
  2799. *
  2800. * def should_keep_alive(self): # <<<<<<<<<<<<<<
  2801. * return bool(cparser.http_should_keep_alive(self._cparser))
  2802. *
  2803. */
  2804. /* Python wrapper */
  2805. static PyObject *__pyx_pw_9httptools_6parser_6parser_10HttpParser_7should_keep_alive(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  2806. static PyObject *__pyx_pw_9httptools_6parser_6parser_10HttpParser_7should_keep_alive(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  2807. PyObject *__pyx_r = 0;
  2808. __Pyx_RefNannyDeclarations
  2809. __Pyx_RefNannySetupContext("should_keep_alive (wrapper)", 0);
  2810. __pyx_r = __pyx_pf_9httptools_6parser_6parser_10HttpParser_6should_keep_alive(((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_v_self));
  2811. /* function exit code */
  2812. __Pyx_RefNannyFinishContext();
  2813. return __pyx_r;
  2814. }
  2815. static PyObject *__pyx_pf_9httptools_6parser_6parser_10HttpParser_6should_keep_alive(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self) {
  2816. PyObject *__pyx_r = NULL;
  2817. __Pyx_RefNannyDeclarations
  2818. PyObject *__pyx_t_1 = NULL;
  2819. int __pyx_t_2;
  2820. __Pyx_RefNannySetupContext("should_keep_alive", 0);
  2821. /* "httptools/parser/parser.pyx":152
  2822. *
  2823. * def should_keep_alive(self):
  2824. * return bool(cparser.http_should_keep_alive(self._cparser)) # <<<<<<<<<<<<<<
  2825. *
  2826. * def should_upgrade(self):
  2827. */
  2828. __Pyx_XDECREF(__pyx_r);
  2829. __pyx_t_1 = __Pyx_PyInt_From_int(http_should_keep_alive(__pyx_v_self->_cparser)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error)
  2830. __Pyx_GOTREF(__pyx_t_1);
  2831. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 152, __pyx_L1_error)
  2832. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2833. __pyx_t_1 = __Pyx_PyBool_FromLong((!(!__pyx_t_2))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error)
  2834. __Pyx_GOTREF(__pyx_t_1);
  2835. __pyx_r = __pyx_t_1;
  2836. __pyx_t_1 = 0;
  2837. goto __pyx_L0;
  2838. /* "httptools/parser/parser.pyx":151
  2839. * return '{}.{}'.format(parser.http_major, parser.http_minor)
  2840. *
  2841. * def should_keep_alive(self): # <<<<<<<<<<<<<<
  2842. * return bool(cparser.http_should_keep_alive(self._cparser))
  2843. *
  2844. */
  2845. /* function exit code */
  2846. __pyx_L1_error:;
  2847. __Pyx_XDECREF(__pyx_t_1);
  2848. __Pyx_AddTraceback("httptools.parser.parser.HttpParser.should_keep_alive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2849. __pyx_r = NULL;
  2850. __pyx_L0:;
  2851. __Pyx_XGIVEREF(__pyx_r);
  2852. __Pyx_RefNannyFinishContext();
  2853. return __pyx_r;
  2854. }
  2855. /* "httptools/parser/parser.pyx":154
  2856. * return bool(cparser.http_should_keep_alive(self._cparser))
  2857. *
  2858. * def should_upgrade(self): # <<<<<<<<<<<<<<
  2859. * cdef cparser.http_parser* parser = self._cparser
  2860. * return bool(parser.upgrade)
  2861. */
  2862. /* Python wrapper */
  2863. static PyObject *__pyx_pw_9httptools_6parser_6parser_10HttpParser_9should_upgrade(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  2864. static PyObject *__pyx_pw_9httptools_6parser_6parser_10HttpParser_9should_upgrade(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  2865. PyObject *__pyx_r = 0;
  2866. __Pyx_RefNannyDeclarations
  2867. __Pyx_RefNannySetupContext("should_upgrade (wrapper)", 0);
  2868. __pyx_r = __pyx_pf_9httptools_6parser_6parser_10HttpParser_8should_upgrade(((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_v_self));
  2869. /* function exit code */
  2870. __Pyx_RefNannyFinishContext();
  2871. return __pyx_r;
  2872. }
  2873. static PyObject *__pyx_pf_9httptools_6parser_6parser_10HttpParser_8should_upgrade(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self) {
  2874. struct http_parser *__pyx_v_parser;
  2875. PyObject *__pyx_r = NULL;
  2876. __Pyx_RefNannyDeclarations
  2877. struct http_parser *__pyx_t_1;
  2878. PyObject *__pyx_t_2 = NULL;
  2879. int __pyx_t_3;
  2880. __Pyx_RefNannySetupContext("should_upgrade", 0);
  2881. /* "httptools/parser/parser.pyx":155
  2882. *
  2883. * def should_upgrade(self):
  2884. * cdef cparser.http_parser* parser = self._cparser # <<<<<<<<<<<<<<
  2885. * return bool(parser.upgrade)
  2886. *
  2887. */
  2888. __pyx_t_1 = __pyx_v_self->_cparser;
  2889. __pyx_v_parser = __pyx_t_1;
  2890. /* "httptools/parser/parser.pyx":156
  2891. * def should_upgrade(self):
  2892. * cdef cparser.http_parser* parser = self._cparser
  2893. * return bool(parser.upgrade) # <<<<<<<<<<<<<<
  2894. *
  2895. * def feed_data(self, data):
  2896. */
  2897. __Pyx_XDECREF(__pyx_r);
  2898. __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_parser->upgrade); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error)
  2899. __Pyx_GOTREF(__pyx_t_2);
  2900. __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 156, __pyx_L1_error)
  2901. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2902. __pyx_t_2 = __Pyx_PyBool_FromLong((!(!__pyx_t_3))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error)
  2903. __Pyx_GOTREF(__pyx_t_2);
  2904. __pyx_r = __pyx_t_2;
  2905. __pyx_t_2 = 0;
  2906. goto __pyx_L0;
  2907. /* "httptools/parser/parser.pyx":154
  2908. * return bool(cparser.http_should_keep_alive(self._cparser))
  2909. *
  2910. * def should_upgrade(self): # <<<<<<<<<<<<<<
  2911. * cdef cparser.http_parser* parser = self._cparser
  2912. * return bool(parser.upgrade)
  2913. */
  2914. /* function exit code */
  2915. __pyx_L1_error:;
  2916. __Pyx_XDECREF(__pyx_t_2);
  2917. __Pyx_AddTraceback("httptools.parser.parser.HttpParser.should_upgrade", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2918. __pyx_r = NULL;
  2919. __pyx_L0:;
  2920. __Pyx_XGIVEREF(__pyx_r);
  2921. __Pyx_RefNannyFinishContext();
  2922. return __pyx_r;
  2923. }
  2924. /* "httptools/parser/parser.pyx":158
  2925. * return bool(parser.upgrade)
  2926. *
  2927. * def feed_data(self, data): # <<<<<<<<<<<<<<
  2928. * cdef:
  2929. * size_t data_len
  2930. */
  2931. /* Python wrapper */
  2932. static PyObject *__pyx_pw_9httptools_6parser_6parser_10HttpParser_11feed_data(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/
  2933. static PyObject *__pyx_pw_9httptools_6parser_6parser_10HttpParser_11feed_data(PyObject *__pyx_v_self, PyObject *__pyx_v_data) {
  2934. PyObject *__pyx_r = 0;
  2935. __Pyx_RefNannyDeclarations
  2936. __Pyx_RefNannySetupContext("feed_data (wrapper)", 0);
  2937. __pyx_r = __pyx_pf_9httptools_6parser_6parser_10HttpParser_10feed_data(((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_v_self), ((PyObject *)__pyx_v_data));
  2938. /* function exit code */
  2939. __Pyx_RefNannyFinishContext();
  2940. return __pyx_r;
  2941. }
  2942. static PyObject *__pyx_pf_9httptools_6parser_6parser_10HttpParser_10feed_data(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self, PyObject *__pyx_v_data) {
  2943. size_t __pyx_v_data_len;
  2944. size_t __pyx_v_nb;
  2945. Py_buffer *__pyx_v_buf;
  2946. PyObject *__pyx_v_ex = NULL;
  2947. PyObject *__pyx_r = NULL;
  2948. __Pyx_RefNannyDeclarations
  2949. int __pyx_t_1;
  2950. int __pyx_t_2;
  2951. PyObject *__pyx_t_3 = NULL;
  2952. int __pyx_t_4;
  2953. PyObject *__pyx_t_5 = NULL;
  2954. PyObject *__pyx_t_6 = NULL;
  2955. PyObject *__pyx_t_7 = NULL;
  2956. __Pyx_RefNannySetupContext("feed_data", 0);
  2957. /* "httptools/parser/parser.pyx":164
  2958. * Py_buffer *buf
  2959. *
  2960. * if PyMemoryView_Check(data): # <<<<<<<<<<<<<<
  2961. * buf = PyMemoryView_GET_BUFFER(data)
  2962. * data_len = <size_t>buf.len
  2963. */
  2964. __pyx_t_1 = (PyMemoryView_Check(__pyx_v_data) != 0);
  2965. if (__pyx_t_1) {
  2966. /* "httptools/parser/parser.pyx":165
  2967. *
  2968. * if PyMemoryView_Check(data):
  2969. * buf = PyMemoryView_GET_BUFFER(data) # <<<<<<<<<<<<<<
  2970. * data_len = <size_t>buf.len
  2971. * nb = cparser.http_parser_execute(
  2972. */
  2973. __pyx_v_buf = PyMemoryView_GET_BUFFER(__pyx_v_data);
  2974. /* "httptools/parser/parser.pyx":166
  2975. * if PyMemoryView_Check(data):
  2976. * buf = PyMemoryView_GET_BUFFER(data)
  2977. * data_len = <size_t>buf.len # <<<<<<<<<<<<<<
  2978. * nb = cparser.http_parser_execute(
  2979. * self._cparser,
  2980. */
  2981. __pyx_v_data_len = ((size_t)__pyx_v_buf->len);
  2982. /* "httptools/parser/parser.pyx":167
  2983. * buf = PyMemoryView_GET_BUFFER(data)
  2984. * data_len = <size_t>buf.len
  2985. * nb = cparser.http_parser_execute( # <<<<<<<<<<<<<<
  2986. * self._cparser,
  2987. * self._csettings,
  2988. */
  2989. __pyx_v_nb = http_parser_execute(__pyx_v_self->_cparser, __pyx_v_self->_csettings, ((char *)__pyx_v_buf->buf), __pyx_v_data_len);
  2990. /* "httptools/parser/parser.pyx":164
  2991. * Py_buffer *buf
  2992. *
  2993. * if PyMemoryView_Check(data): # <<<<<<<<<<<<<<
  2994. * buf = PyMemoryView_GET_BUFFER(data)
  2995. * data_len = <size_t>buf.len
  2996. */
  2997. goto __pyx_L3;
  2998. }
  2999. /* "httptools/parser/parser.pyx":174
  3000. *
  3001. * else:
  3002. * buf = &self.py_buf # <<<<<<<<<<<<<<
  3003. * PyObject_GetBuffer(data, buf, PyBUF_SIMPLE)
  3004. * data_len = <size_t>buf.len
  3005. */
  3006. /*else*/ {
  3007. __pyx_v_buf = (&__pyx_v_self->py_buf);
  3008. /* "httptools/parser/parser.pyx":175
  3009. * else:
  3010. * buf = &self.py_buf
  3011. * PyObject_GetBuffer(data, buf, PyBUF_SIMPLE) # <<<<<<<<<<<<<<
  3012. * data_len = <size_t>buf.len
  3013. *
  3014. */
  3015. __pyx_t_2 = PyObject_GetBuffer(__pyx_v_data, __pyx_v_buf, PyBUF_SIMPLE); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 175, __pyx_L1_error)
  3016. /* "httptools/parser/parser.pyx":176
  3017. * buf = &self.py_buf
  3018. * PyObject_GetBuffer(data, buf, PyBUF_SIMPLE)
  3019. * data_len = <size_t>buf.len # <<<<<<<<<<<<<<
  3020. *
  3021. * nb = cparser.http_parser_execute(
  3022. */
  3023. __pyx_v_data_len = ((size_t)__pyx_v_buf->len);
  3024. /* "httptools/parser/parser.pyx":178
  3025. * data_len = <size_t>buf.len
  3026. *
  3027. * nb = cparser.http_parser_execute( # <<<<<<<<<<<<<<
  3028. * self._cparser,
  3029. * self._csettings,
  3030. */
  3031. __pyx_v_nb = http_parser_execute(__pyx_v_self->_cparser, __pyx_v_self->_csettings, ((char *)__pyx_v_buf->buf), __pyx_v_data_len);
  3032. /* "httptools/parser/parser.pyx":184
  3033. * data_len)
  3034. *
  3035. * PyBuffer_Release(buf) # <<<<<<<<<<<<<<
  3036. *
  3037. * if self._cparser.http_errno != cparser.HPE_OK:
  3038. */
  3039. PyBuffer_Release(__pyx_v_buf);
  3040. }
  3041. __pyx_L3:;
  3042. /* "httptools/parser/parser.pyx":186
  3043. * PyBuffer_Release(buf)
  3044. *
  3045. * if self._cparser.http_errno != cparser.HPE_OK: # <<<<<<<<<<<<<<
  3046. * ex = parser_error_from_errno(
  3047. * <cparser.http_errno> self._cparser.http_errno)
  3048. */
  3049. __pyx_t_1 = ((__pyx_v_self->_cparser->http_errno != HPE_OK) != 0);
  3050. if (__pyx_t_1) {
  3051. /* "httptools/parser/parser.pyx":187
  3052. *
  3053. * if self._cparser.http_errno != cparser.HPE_OK:
  3054. * ex = parser_error_from_errno( # <<<<<<<<<<<<<<
  3055. * <cparser.http_errno> self._cparser.http_errno)
  3056. * if isinstance(ex, HttpParserCallbackError):
  3057. */
  3058. __pyx_t_3 = __pyx_f_9httptools_6parser_6parser_parser_error_from_errno(((enum http_errno)__pyx_v_self->_cparser->http_errno)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 187, __pyx_L1_error)
  3059. __Pyx_GOTREF(__pyx_t_3);
  3060. __pyx_v_ex = __pyx_t_3;
  3061. __pyx_t_3 = 0;
  3062. /* "httptools/parser/parser.pyx":189
  3063. * ex = parser_error_from_errno(
  3064. * <cparser.http_errno> self._cparser.http_errno)
  3065. * if isinstance(ex, HttpParserCallbackError): # <<<<<<<<<<<<<<
  3066. * if self._last_error is not None:
  3067. * ex.__context__ = self._last_error
  3068. */
  3069. __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_HttpParserCallbackError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 189, __pyx_L1_error)
  3070. __Pyx_GOTREF(__pyx_t_3);
  3071. __pyx_t_1 = PyObject_IsInstance(__pyx_v_ex, __pyx_t_3); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 189, __pyx_L1_error)
  3072. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3073. __pyx_t_4 = (__pyx_t_1 != 0);
  3074. if (__pyx_t_4) {
  3075. /* "httptools/parser/parser.pyx":190
  3076. * <cparser.http_errno> self._cparser.http_errno)
  3077. * if isinstance(ex, HttpParserCallbackError):
  3078. * if self._last_error is not None: # <<<<<<<<<<<<<<
  3079. * ex.__context__ = self._last_error
  3080. * self._last_error = None
  3081. */
  3082. __pyx_t_4 = (__pyx_v_self->_last_error != Py_None);
  3083. __pyx_t_1 = (__pyx_t_4 != 0);
  3084. if (__pyx_t_1) {
  3085. /* "httptools/parser/parser.pyx":191
  3086. * if isinstance(ex, HttpParserCallbackError):
  3087. * if self._last_error is not None:
  3088. * ex.__context__ = self._last_error # <<<<<<<<<<<<<<
  3089. * self._last_error = None
  3090. * raise ex
  3091. */
  3092. __pyx_t_3 = __pyx_v_self->_last_error;
  3093. __Pyx_INCREF(__pyx_t_3);
  3094. if (__Pyx_PyObject_SetAttrStr(__pyx_v_ex, __pyx_n_s_context, __pyx_t_3) < 0) __PYX_ERR(0, 191, __pyx_L1_error)
  3095. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3096. /* "httptools/parser/parser.pyx":192
  3097. * if self._last_error is not None:
  3098. * ex.__context__ = self._last_error
  3099. * self._last_error = None # <<<<<<<<<<<<<<
  3100. * raise ex
  3101. *
  3102. */
  3103. __Pyx_INCREF(Py_None);
  3104. __Pyx_GIVEREF(Py_None);
  3105. __Pyx_GOTREF(__pyx_v_self->_last_error);
  3106. __Pyx_DECREF(__pyx_v_self->_last_error);
  3107. __pyx_v_self->_last_error = Py_None;
  3108. /* "httptools/parser/parser.pyx":190
  3109. * <cparser.http_errno> self._cparser.http_errno)
  3110. * if isinstance(ex, HttpParserCallbackError):
  3111. * if self._last_error is not None: # <<<<<<<<<<<<<<
  3112. * ex.__context__ = self._last_error
  3113. * self._last_error = None
  3114. */
  3115. }
  3116. /* "httptools/parser/parser.pyx":189
  3117. * ex = parser_error_from_errno(
  3118. * <cparser.http_errno> self._cparser.http_errno)
  3119. * if isinstance(ex, HttpParserCallbackError): # <<<<<<<<<<<<<<
  3120. * if self._last_error is not None:
  3121. * ex.__context__ = self._last_error
  3122. */
  3123. }
  3124. /* "httptools/parser/parser.pyx":193
  3125. * ex.__context__ = self._last_error
  3126. * self._last_error = None
  3127. * raise ex # <<<<<<<<<<<<<<
  3128. *
  3129. * if self._cparser.upgrade:
  3130. */
  3131. __Pyx_Raise(__pyx_v_ex, 0, 0, 0);
  3132. __PYX_ERR(0, 193, __pyx_L1_error)
  3133. /* "httptools/parser/parser.pyx":186
  3134. * PyBuffer_Release(buf)
  3135. *
  3136. * if self._cparser.http_errno != cparser.HPE_OK: # <<<<<<<<<<<<<<
  3137. * ex = parser_error_from_errno(
  3138. * <cparser.http_errno> self._cparser.http_errno)
  3139. */
  3140. }
  3141. /* "httptools/parser/parser.pyx":195
  3142. * raise ex
  3143. *
  3144. * if self._cparser.upgrade: # <<<<<<<<<<<<<<
  3145. * raise HttpParserUpgrade(nb)
  3146. *
  3147. */
  3148. __pyx_t_1 = (__pyx_v_self->_cparser->upgrade != 0);
  3149. if (unlikely(__pyx_t_1)) {
  3150. /* "httptools/parser/parser.pyx":196
  3151. *
  3152. * if self._cparser.upgrade:
  3153. * raise HttpParserUpgrade(nb) # <<<<<<<<<<<<<<
  3154. *
  3155. * if nb != data_len:
  3156. */
  3157. __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_HttpParserUpgrade); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 196, __pyx_L1_error)
  3158. __Pyx_GOTREF(__pyx_t_5);
  3159. __pyx_t_6 = __Pyx_PyInt_FromSize_t(__pyx_v_nb); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 196, __pyx_L1_error)
  3160. __Pyx_GOTREF(__pyx_t_6);
  3161. __pyx_t_7 = NULL;
  3162. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  3163. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
  3164. if (likely(__pyx_t_7)) {
  3165. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  3166. __Pyx_INCREF(__pyx_t_7);
  3167. __Pyx_INCREF(function);
  3168. __Pyx_DECREF_SET(__pyx_t_5, function);
  3169. }
  3170. }
  3171. __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6);
  3172. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3173. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3174. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 196, __pyx_L1_error)
  3175. __Pyx_GOTREF(__pyx_t_3);
  3176. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3177. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  3178. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3179. __PYX_ERR(0, 196, __pyx_L1_error)
  3180. /* "httptools/parser/parser.pyx":195
  3181. * raise ex
  3182. *
  3183. * if self._cparser.upgrade: # <<<<<<<<<<<<<<
  3184. * raise HttpParserUpgrade(nb)
  3185. *
  3186. */
  3187. }
  3188. /* "httptools/parser/parser.pyx":198
  3189. * raise HttpParserUpgrade(nb)
  3190. *
  3191. * if nb != data_len: # <<<<<<<<<<<<<<
  3192. * raise HttpParserError('not all of the data was parsed')
  3193. *
  3194. */
  3195. __pyx_t_1 = ((__pyx_v_nb != __pyx_v_data_len) != 0);
  3196. if (unlikely(__pyx_t_1)) {
  3197. /* "httptools/parser/parser.pyx":199
  3198. *
  3199. * if nb != data_len:
  3200. * raise HttpParserError('not all of the data was parsed') # <<<<<<<<<<<<<<
  3201. *
  3202. *
  3203. */
  3204. __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_HttpParserError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 199, __pyx_L1_error)
  3205. __Pyx_GOTREF(__pyx_t_5);
  3206. __pyx_t_6 = NULL;
  3207. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  3208. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
  3209. if (likely(__pyx_t_6)) {
  3210. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  3211. __Pyx_INCREF(__pyx_t_6);
  3212. __Pyx_INCREF(function);
  3213. __Pyx_DECREF_SET(__pyx_t_5, function);
  3214. }
  3215. }
  3216. __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_kp_u_not_all_of_the_data_was_parsed) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_kp_u_not_all_of_the_data_was_parsed);
  3217. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3218. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error)
  3219. __Pyx_GOTREF(__pyx_t_3);
  3220. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3221. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  3222. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3223. __PYX_ERR(0, 199, __pyx_L1_error)
  3224. /* "httptools/parser/parser.pyx":198
  3225. * raise HttpParserUpgrade(nb)
  3226. *
  3227. * if nb != data_len: # <<<<<<<<<<<<<<
  3228. * raise HttpParserError('not all of the data was parsed')
  3229. *
  3230. */
  3231. }
  3232. /* "httptools/parser/parser.pyx":158
  3233. * return bool(parser.upgrade)
  3234. *
  3235. * def feed_data(self, data): # <<<<<<<<<<<<<<
  3236. * cdef:
  3237. * size_t data_len
  3238. */
  3239. /* function exit code */
  3240. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  3241. goto __pyx_L0;
  3242. __pyx_L1_error:;
  3243. __Pyx_XDECREF(__pyx_t_3);
  3244. __Pyx_XDECREF(__pyx_t_5);
  3245. __Pyx_XDECREF(__pyx_t_6);
  3246. __Pyx_XDECREF(__pyx_t_7);
  3247. __Pyx_AddTraceback("httptools.parser.parser.HttpParser.feed_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3248. __pyx_r = NULL;
  3249. __pyx_L0:;
  3250. __Pyx_XDECREF(__pyx_v_ex);
  3251. __Pyx_XGIVEREF(__pyx_r);
  3252. __Pyx_RefNannyFinishContext();
  3253. return __pyx_r;
  3254. }
  3255. /* "(tree fragment)":1
  3256. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  3257. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3258. * def __setstate_cython__(self, __pyx_state):
  3259. */
  3260. /* Python wrapper */
  3261. static PyObject *__pyx_pw_9httptools_6parser_6parser_10HttpParser_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  3262. static PyObject *__pyx_pw_9httptools_6parser_6parser_10HttpParser_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  3263. PyObject *__pyx_r = 0;
  3264. __Pyx_RefNannyDeclarations
  3265. __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  3266. __pyx_r = __pyx_pf_9httptools_6parser_6parser_10HttpParser_12__reduce_cython__(((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_v_self));
  3267. /* function exit code */
  3268. __Pyx_RefNannyFinishContext();
  3269. return __pyx_r;
  3270. }
  3271. static PyObject *__pyx_pf_9httptools_6parser_6parser_10HttpParser_12__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self) {
  3272. PyObject *__pyx_r = NULL;
  3273. __Pyx_RefNannyDeclarations
  3274. PyObject *__pyx_t_1 = NULL;
  3275. __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  3276. /* "(tree fragment)":2
  3277. * def __reduce_cython__(self):
  3278. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  3279. * def __setstate_cython__(self, __pyx_state):
  3280. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3281. */
  3282. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
  3283. __Pyx_GOTREF(__pyx_t_1);
  3284. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  3285. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3286. __PYX_ERR(1, 2, __pyx_L1_error)
  3287. /* "(tree fragment)":1
  3288. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  3289. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3290. * def __setstate_cython__(self, __pyx_state):
  3291. */
  3292. /* function exit code */
  3293. __pyx_L1_error:;
  3294. __Pyx_XDECREF(__pyx_t_1);
  3295. __Pyx_AddTraceback("httptools.parser.parser.HttpParser.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3296. __pyx_r = NULL;
  3297. __Pyx_XGIVEREF(__pyx_r);
  3298. __Pyx_RefNannyFinishContext();
  3299. return __pyx_r;
  3300. }
  3301. /* "(tree fragment)":3
  3302. * def __reduce_cython__(self):
  3303. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3304. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  3305. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3306. */
  3307. /* Python wrapper */
  3308. static PyObject *__pyx_pw_9httptools_6parser_6parser_10HttpParser_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
  3309. static PyObject *__pyx_pw_9httptools_6parser_6parser_10HttpParser_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  3310. PyObject *__pyx_r = 0;
  3311. __Pyx_RefNannyDeclarations
  3312. __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  3313. __pyx_r = __pyx_pf_9httptools_6parser_6parser_10HttpParser_14__setstate_cython__(((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
  3314. /* function exit code */
  3315. __Pyx_RefNannyFinishContext();
  3316. return __pyx_r;
  3317. }
  3318. static PyObject *__pyx_pf_9httptools_6parser_6parser_10HttpParser_14__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  3319. PyObject *__pyx_r = NULL;
  3320. __Pyx_RefNannyDeclarations
  3321. PyObject *__pyx_t_1 = NULL;
  3322. __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  3323. /* "(tree fragment)":4
  3324. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3325. * def __setstate_cython__(self, __pyx_state):
  3326. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  3327. */
  3328. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  3329. __Pyx_GOTREF(__pyx_t_1);
  3330. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  3331. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3332. __PYX_ERR(1, 4, __pyx_L1_error)
  3333. /* "(tree fragment)":3
  3334. * def __reduce_cython__(self):
  3335. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3336. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  3337. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3338. */
  3339. /* function exit code */
  3340. __pyx_L1_error:;
  3341. __Pyx_XDECREF(__pyx_t_1);
  3342. __Pyx_AddTraceback("httptools.parser.parser.HttpParser.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3343. __pyx_r = NULL;
  3344. __Pyx_XGIVEREF(__pyx_r);
  3345. __Pyx_RefNannyFinishContext();
  3346. return __pyx_r;
  3347. }
  3348. /* "httptools/parser/parser.pyx":204
  3349. * cdef class HttpRequestParser(HttpParser):
  3350. *
  3351. * def __init__(self, protocol): # <<<<<<<<<<<<<<
  3352. * self._init(protocol, cparser.HTTP_REQUEST)
  3353. *
  3354. */
  3355. /* Python wrapper */
  3356. static int __pyx_pw_9httptools_6parser_6parser_17HttpRequestParser_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  3357. static int __pyx_pw_9httptools_6parser_6parser_17HttpRequestParser_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  3358. PyObject *__pyx_v_protocol = 0;
  3359. int __pyx_r;
  3360. __Pyx_RefNannyDeclarations
  3361. __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  3362. {
  3363. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_protocol,0};
  3364. PyObject* values[1] = {0};
  3365. if (unlikely(__pyx_kwds)) {
  3366. Py_ssize_t kw_args;
  3367. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  3368. switch (pos_args) {
  3369. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3370. CYTHON_FALLTHROUGH;
  3371. case 0: break;
  3372. default: goto __pyx_L5_argtuple_error;
  3373. }
  3374. kw_args = PyDict_Size(__pyx_kwds);
  3375. switch (pos_args) {
  3376. case 0:
  3377. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_protocol)) != 0)) kw_args--;
  3378. else goto __pyx_L5_argtuple_error;
  3379. }
  3380. if (unlikely(kw_args > 0)) {
  3381. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 204, __pyx_L3_error)
  3382. }
  3383. } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
  3384. goto __pyx_L5_argtuple_error;
  3385. } else {
  3386. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3387. }
  3388. __pyx_v_protocol = values[0];
  3389. }
  3390. goto __pyx_L4_argument_unpacking_done;
  3391. __pyx_L5_argtuple_error:;
  3392. __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 204, __pyx_L3_error)
  3393. __pyx_L3_error:;
  3394. __Pyx_AddTraceback("httptools.parser.parser.HttpRequestParser.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3395. __Pyx_RefNannyFinishContext();
  3396. return -1;
  3397. __pyx_L4_argument_unpacking_done:;
  3398. __pyx_r = __pyx_pf_9httptools_6parser_6parser_17HttpRequestParser___init__(((struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser *)__pyx_v_self), __pyx_v_protocol);
  3399. /* function exit code */
  3400. __Pyx_RefNannyFinishContext();
  3401. return __pyx_r;
  3402. }
  3403. static int __pyx_pf_9httptools_6parser_6parser_17HttpRequestParser___init__(struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser *__pyx_v_self, PyObject *__pyx_v_protocol) {
  3404. int __pyx_r;
  3405. __Pyx_RefNannyDeclarations
  3406. PyObject *__pyx_t_1 = NULL;
  3407. int __pyx_t_2;
  3408. int __pyx_t_3;
  3409. __Pyx_RefNannySetupContext("__init__", 0);
  3410. /* "httptools/parser/parser.pyx":205
  3411. *
  3412. * def __init__(self, protocol):
  3413. * self._init(protocol, cparser.HTTP_REQUEST) # <<<<<<<<<<<<<<
  3414. *
  3415. * self._proto_on_url = getattr(protocol, 'on_url', None)
  3416. */
  3417. __pyx_t_1 = ((struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpRequestParser *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._init(((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_v_self), __pyx_v_protocol, HTTP_REQUEST); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error)
  3418. __Pyx_GOTREF(__pyx_t_1);
  3419. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3420. /* "httptools/parser/parser.pyx":207
  3421. * self._init(protocol, cparser.HTTP_REQUEST)
  3422. *
  3423. * self._proto_on_url = getattr(protocol, 'on_url', None) # <<<<<<<<<<<<<<
  3424. * if self._proto_on_url is not None:
  3425. * self._csettings.on_url = cb_on_url
  3426. */
  3427. __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_protocol, __pyx_n_u_on_url, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error)
  3428. __Pyx_GOTREF(__pyx_t_1);
  3429. __Pyx_GIVEREF(__pyx_t_1);
  3430. __Pyx_GOTREF(__pyx_v_self->__pyx_base._proto_on_url);
  3431. __Pyx_DECREF(__pyx_v_self->__pyx_base._proto_on_url);
  3432. __pyx_v_self->__pyx_base._proto_on_url = __pyx_t_1;
  3433. __pyx_t_1 = 0;
  3434. /* "httptools/parser/parser.pyx":208
  3435. *
  3436. * self._proto_on_url = getattr(protocol, 'on_url', None)
  3437. * if self._proto_on_url is not None: # <<<<<<<<<<<<<<
  3438. * self._csettings.on_url = cb_on_url
  3439. *
  3440. */
  3441. __pyx_t_2 = (__pyx_v_self->__pyx_base._proto_on_url != Py_None);
  3442. __pyx_t_3 = (__pyx_t_2 != 0);
  3443. if (__pyx_t_3) {
  3444. /* "httptools/parser/parser.pyx":209
  3445. * self._proto_on_url = getattr(protocol, 'on_url', None)
  3446. * if self._proto_on_url is not None:
  3447. * self._csettings.on_url = cb_on_url # <<<<<<<<<<<<<<
  3448. *
  3449. * def get_method(self):
  3450. */
  3451. __pyx_v_self->__pyx_base._csettings->on_url = __pyx_f_9httptools_6parser_6parser_cb_on_url;
  3452. /* "httptools/parser/parser.pyx":208
  3453. *
  3454. * self._proto_on_url = getattr(protocol, 'on_url', None)
  3455. * if self._proto_on_url is not None: # <<<<<<<<<<<<<<
  3456. * self._csettings.on_url = cb_on_url
  3457. *
  3458. */
  3459. }
  3460. /* "httptools/parser/parser.pyx":204
  3461. * cdef class HttpRequestParser(HttpParser):
  3462. *
  3463. * def __init__(self, protocol): # <<<<<<<<<<<<<<
  3464. * self._init(protocol, cparser.HTTP_REQUEST)
  3465. *
  3466. */
  3467. /* function exit code */
  3468. __pyx_r = 0;
  3469. goto __pyx_L0;
  3470. __pyx_L1_error:;
  3471. __Pyx_XDECREF(__pyx_t_1);
  3472. __Pyx_AddTraceback("httptools.parser.parser.HttpRequestParser.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3473. __pyx_r = -1;
  3474. __pyx_L0:;
  3475. __Pyx_RefNannyFinishContext();
  3476. return __pyx_r;
  3477. }
  3478. /* "httptools/parser/parser.pyx":211
  3479. * self._csettings.on_url = cb_on_url
  3480. *
  3481. * def get_method(self): # <<<<<<<<<<<<<<
  3482. * cdef cparser.http_parser* parser = self._cparser
  3483. * return cparser.http_method_str(<cparser.http_method> parser.method)
  3484. */
  3485. /* Python wrapper */
  3486. static PyObject *__pyx_pw_9httptools_6parser_6parser_17HttpRequestParser_3get_method(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  3487. static PyObject *__pyx_pw_9httptools_6parser_6parser_17HttpRequestParser_3get_method(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  3488. PyObject *__pyx_r = 0;
  3489. __Pyx_RefNannyDeclarations
  3490. __Pyx_RefNannySetupContext("get_method (wrapper)", 0);
  3491. __pyx_r = __pyx_pf_9httptools_6parser_6parser_17HttpRequestParser_2get_method(((struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser *)__pyx_v_self));
  3492. /* function exit code */
  3493. __Pyx_RefNannyFinishContext();
  3494. return __pyx_r;
  3495. }
  3496. static PyObject *__pyx_pf_9httptools_6parser_6parser_17HttpRequestParser_2get_method(struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser *__pyx_v_self) {
  3497. struct http_parser *__pyx_v_parser;
  3498. PyObject *__pyx_r = NULL;
  3499. __Pyx_RefNannyDeclarations
  3500. struct http_parser *__pyx_t_1;
  3501. PyObject *__pyx_t_2 = NULL;
  3502. __Pyx_RefNannySetupContext("get_method", 0);
  3503. /* "httptools/parser/parser.pyx":212
  3504. *
  3505. * def get_method(self):
  3506. * cdef cparser.http_parser* parser = self._cparser # <<<<<<<<<<<<<<
  3507. * return cparser.http_method_str(<cparser.http_method> parser.method)
  3508. *
  3509. */
  3510. __pyx_t_1 = __pyx_v_self->__pyx_base._cparser;
  3511. __pyx_v_parser = __pyx_t_1;
  3512. /* "httptools/parser/parser.pyx":213
  3513. * def get_method(self):
  3514. * cdef cparser.http_parser* parser = self._cparser
  3515. * return cparser.http_method_str(<cparser.http_method> parser.method) # <<<<<<<<<<<<<<
  3516. *
  3517. *
  3518. */
  3519. __Pyx_XDECREF(__pyx_r);
  3520. __pyx_t_2 = __Pyx_PyBytes_FromString(http_method_str(((enum http_method)__pyx_v_parser->method))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L1_error)
  3521. __Pyx_GOTREF(__pyx_t_2);
  3522. __pyx_r = __pyx_t_2;
  3523. __pyx_t_2 = 0;
  3524. goto __pyx_L0;
  3525. /* "httptools/parser/parser.pyx":211
  3526. * self._csettings.on_url = cb_on_url
  3527. *
  3528. * def get_method(self): # <<<<<<<<<<<<<<
  3529. * cdef cparser.http_parser* parser = self._cparser
  3530. * return cparser.http_method_str(<cparser.http_method> parser.method)
  3531. */
  3532. /* function exit code */
  3533. __pyx_L1_error:;
  3534. __Pyx_XDECREF(__pyx_t_2);
  3535. __Pyx_AddTraceback("httptools.parser.parser.HttpRequestParser.get_method", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3536. __pyx_r = NULL;
  3537. __pyx_L0:;
  3538. __Pyx_XGIVEREF(__pyx_r);
  3539. __Pyx_RefNannyFinishContext();
  3540. return __pyx_r;
  3541. }
  3542. /* "(tree fragment)":1
  3543. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  3544. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3545. * def __setstate_cython__(self, __pyx_state):
  3546. */
  3547. /* Python wrapper */
  3548. static PyObject *__pyx_pw_9httptools_6parser_6parser_17HttpRequestParser_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  3549. static PyObject *__pyx_pw_9httptools_6parser_6parser_17HttpRequestParser_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  3550. PyObject *__pyx_r = 0;
  3551. __Pyx_RefNannyDeclarations
  3552. __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  3553. __pyx_r = __pyx_pf_9httptools_6parser_6parser_17HttpRequestParser_4__reduce_cython__(((struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser *)__pyx_v_self));
  3554. /* function exit code */
  3555. __Pyx_RefNannyFinishContext();
  3556. return __pyx_r;
  3557. }
  3558. static PyObject *__pyx_pf_9httptools_6parser_6parser_17HttpRequestParser_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser *__pyx_v_self) {
  3559. PyObject *__pyx_r = NULL;
  3560. __Pyx_RefNannyDeclarations
  3561. PyObject *__pyx_t_1 = NULL;
  3562. __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  3563. /* "(tree fragment)":2
  3564. * def __reduce_cython__(self):
  3565. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  3566. * def __setstate_cython__(self, __pyx_state):
  3567. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3568. */
  3569. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
  3570. __Pyx_GOTREF(__pyx_t_1);
  3571. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  3572. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3573. __PYX_ERR(1, 2, __pyx_L1_error)
  3574. /* "(tree fragment)":1
  3575. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  3576. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3577. * def __setstate_cython__(self, __pyx_state):
  3578. */
  3579. /* function exit code */
  3580. __pyx_L1_error:;
  3581. __Pyx_XDECREF(__pyx_t_1);
  3582. __Pyx_AddTraceback("httptools.parser.parser.HttpRequestParser.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3583. __pyx_r = NULL;
  3584. __Pyx_XGIVEREF(__pyx_r);
  3585. __Pyx_RefNannyFinishContext();
  3586. return __pyx_r;
  3587. }
  3588. /* "(tree fragment)":3
  3589. * def __reduce_cython__(self):
  3590. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3591. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  3592. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3593. */
  3594. /* Python wrapper */
  3595. static PyObject *__pyx_pw_9httptools_6parser_6parser_17HttpRequestParser_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
  3596. static PyObject *__pyx_pw_9httptools_6parser_6parser_17HttpRequestParser_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  3597. PyObject *__pyx_r = 0;
  3598. __Pyx_RefNannyDeclarations
  3599. __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  3600. __pyx_r = __pyx_pf_9httptools_6parser_6parser_17HttpRequestParser_6__setstate_cython__(((struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
  3601. /* function exit code */
  3602. __Pyx_RefNannyFinishContext();
  3603. return __pyx_r;
  3604. }
  3605. static PyObject *__pyx_pf_9httptools_6parser_6parser_17HttpRequestParser_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  3606. PyObject *__pyx_r = NULL;
  3607. __Pyx_RefNannyDeclarations
  3608. PyObject *__pyx_t_1 = NULL;
  3609. __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  3610. /* "(tree fragment)":4
  3611. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3612. * def __setstate_cython__(self, __pyx_state):
  3613. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  3614. */
  3615. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  3616. __Pyx_GOTREF(__pyx_t_1);
  3617. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  3618. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3619. __PYX_ERR(1, 4, __pyx_L1_error)
  3620. /* "(tree fragment)":3
  3621. * def __reduce_cython__(self):
  3622. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3623. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  3624. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3625. */
  3626. /* function exit code */
  3627. __pyx_L1_error:;
  3628. __Pyx_XDECREF(__pyx_t_1);
  3629. __Pyx_AddTraceback("httptools.parser.parser.HttpRequestParser.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3630. __pyx_r = NULL;
  3631. __Pyx_XGIVEREF(__pyx_r);
  3632. __Pyx_RefNannyFinishContext();
  3633. return __pyx_r;
  3634. }
  3635. /* "httptools/parser/parser.pyx":218
  3636. * cdef class HttpResponseParser(HttpParser):
  3637. *
  3638. * def __init__(self, protocol): # <<<<<<<<<<<<<<
  3639. * self._init(protocol, cparser.HTTP_RESPONSE)
  3640. *
  3641. */
  3642. /* Python wrapper */
  3643. static int __pyx_pw_9httptools_6parser_6parser_18HttpResponseParser_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  3644. static int __pyx_pw_9httptools_6parser_6parser_18HttpResponseParser_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  3645. PyObject *__pyx_v_protocol = 0;
  3646. int __pyx_r;
  3647. __Pyx_RefNannyDeclarations
  3648. __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  3649. {
  3650. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_protocol,0};
  3651. PyObject* values[1] = {0};
  3652. if (unlikely(__pyx_kwds)) {
  3653. Py_ssize_t kw_args;
  3654. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  3655. switch (pos_args) {
  3656. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3657. CYTHON_FALLTHROUGH;
  3658. case 0: break;
  3659. default: goto __pyx_L5_argtuple_error;
  3660. }
  3661. kw_args = PyDict_Size(__pyx_kwds);
  3662. switch (pos_args) {
  3663. case 0:
  3664. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_protocol)) != 0)) kw_args--;
  3665. else goto __pyx_L5_argtuple_error;
  3666. }
  3667. if (unlikely(kw_args > 0)) {
  3668. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 218, __pyx_L3_error)
  3669. }
  3670. } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
  3671. goto __pyx_L5_argtuple_error;
  3672. } else {
  3673. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3674. }
  3675. __pyx_v_protocol = values[0];
  3676. }
  3677. goto __pyx_L4_argument_unpacking_done;
  3678. __pyx_L5_argtuple_error:;
  3679. __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 218, __pyx_L3_error)
  3680. __pyx_L3_error:;
  3681. __Pyx_AddTraceback("httptools.parser.parser.HttpResponseParser.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3682. __Pyx_RefNannyFinishContext();
  3683. return -1;
  3684. __pyx_L4_argument_unpacking_done:;
  3685. __pyx_r = __pyx_pf_9httptools_6parser_6parser_18HttpResponseParser___init__(((struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser *)__pyx_v_self), __pyx_v_protocol);
  3686. /* function exit code */
  3687. __Pyx_RefNannyFinishContext();
  3688. return __pyx_r;
  3689. }
  3690. static int __pyx_pf_9httptools_6parser_6parser_18HttpResponseParser___init__(struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser *__pyx_v_self, PyObject *__pyx_v_protocol) {
  3691. int __pyx_r;
  3692. __Pyx_RefNannyDeclarations
  3693. PyObject *__pyx_t_1 = NULL;
  3694. int __pyx_t_2;
  3695. int __pyx_t_3;
  3696. __Pyx_RefNannySetupContext("__init__", 0);
  3697. /* "httptools/parser/parser.pyx":219
  3698. *
  3699. * def __init__(self, protocol):
  3700. * self._init(protocol, cparser.HTTP_RESPONSE) # <<<<<<<<<<<<<<
  3701. *
  3702. * self._proto_on_status = getattr(protocol, 'on_status', None)
  3703. */
  3704. __pyx_t_1 = ((struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpResponseParser *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._init(((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_v_self), __pyx_v_protocol, HTTP_RESPONSE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 219, __pyx_L1_error)
  3705. __Pyx_GOTREF(__pyx_t_1);
  3706. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3707. /* "httptools/parser/parser.pyx":221
  3708. * self._init(protocol, cparser.HTTP_RESPONSE)
  3709. *
  3710. * self._proto_on_status = getattr(protocol, 'on_status', None) # <<<<<<<<<<<<<<
  3711. * if self._proto_on_status is not None:
  3712. * self._csettings.on_status = cb_on_status
  3713. */
  3714. __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_protocol, __pyx_n_u_on_status, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error)
  3715. __Pyx_GOTREF(__pyx_t_1);
  3716. __Pyx_GIVEREF(__pyx_t_1);
  3717. __Pyx_GOTREF(__pyx_v_self->__pyx_base._proto_on_status);
  3718. __Pyx_DECREF(__pyx_v_self->__pyx_base._proto_on_status);
  3719. __pyx_v_self->__pyx_base._proto_on_status = __pyx_t_1;
  3720. __pyx_t_1 = 0;
  3721. /* "httptools/parser/parser.pyx":222
  3722. *
  3723. * self._proto_on_status = getattr(protocol, 'on_status', None)
  3724. * if self._proto_on_status is not None: # <<<<<<<<<<<<<<
  3725. * self._csettings.on_status = cb_on_status
  3726. *
  3727. */
  3728. __pyx_t_2 = (__pyx_v_self->__pyx_base._proto_on_status != Py_None);
  3729. __pyx_t_3 = (__pyx_t_2 != 0);
  3730. if (__pyx_t_3) {
  3731. /* "httptools/parser/parser.pyx":223
  3732. * self._proto_on_status = getattr(protocol, 'on_status', None)
  3733. * if self._proto_on_status is not None:
  3734. * self._csettings.on_status = cb_on_status # <<<<<<<<<<<<<<
  3735. *
  3736. * def get_status_code(self):
  3737. */
  3738. __pyx_v_self->__pyx_base._csettings->on_status = __pyx_f_9httptools_6parser_6parser_cb_on_status;
  3739. /* "httptools/parser/parser.pyx":222
  3740. *
  3741. * self._proto_on_status = getattr(protocol, 'on_status', None)
  3742. * if self._proto_on_status is not None: # <<<<<<<<<<<<<<
  3743. * self._csettings.on_status = cb_on_status
  3744. *
  3745. */
  3746. }
  3747. /* "httptools/parser/parser.pyx":218
  3748. * cdef class HttpResponseParser(HttpParser):
  3749. *
  3750. * def __init__(self, protocol): # <<<<<<<<<<<<<<
  3751. * self._init(protocol, cparser.HTTP_RESPONSE)
  3752. *
  3753. */
  3754. /* function exit code */
  3755. __pyx_r = 0;
  3756. goto __pyx_L0;
  3757. __pyx_L1_error:;
  3758. __Pyx_XDECREF(__pyx_t_1);
  3759. __Pyx_AddTraceback("httptools.parser.parser.HttpResponseParser.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3760. __pyx_r = -1;
  3761. __pyx_L0:;
  3762. __Pyx_RefNannyFinishContext();
  3763. return __pyx_r;
  3764. }
  3765. /* "httptools/parser/parser.pyx":225
  3766. * self._csettings.on_status = cb_on_status
  3767. *
  3768. * def get_status_code(self): # <<<<<<<<<<<<<<
  3769. * cdef cparser.http_parser* parser = self._cparser
  3770. * return parser.status_code
  3771. */
  3772. /* Python wrapper */
  3773. static PyObject *__pyx_pw_9httptools_6parser_6parser_18HttpResponseParser_3get_status_code(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  3774. static PyObject *__pyx_pw_9httptools_6parser_6parser_18HttpResponseParser_3get_status_code(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  3775. PyObject *__pyx_r = 0;
  3776. __Pyx_RefNannyDeclarations
  3777. __Pyx_RefNannySetupContext("get_status_code (wrapper)", 0);
  3778. __pyx_r = __pyx_pf_9httptools_6parser_6parser_18HttpResponseParser_2get_status_code(((struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser *)__pyx_v_self));
  3779. /* function exit code */
  3780. __Pyx_RefNannyFinishContext();
  3781. return __pyx_r;
  3782. }
  3783. static PyObject *__pyx_pf_9httptools_6parser_6parser_18HttpResponseParser_2get_status_code(struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser *__pyx_v_self) {
  3784. struct http_parser *__pyx_v_parser;
  3785. PyObject *__pyx_r = NULL;
  3786. __Pyx_RefNannyDeclarations
  3787. struct http_parser *__pyx_t_1;
  3788. PyObject *__pyx_t_2 = NULL;
  3789. __Pyx_RefNannySetupContext("get_status_code", 0);
  3790. /* "httptools/parser/parser.pyx":226
  3791. *
  3792. * def get_status_code(self):
  3793. * cdef cparser.http_parser* parser = self._cparser # <<<<<<<<<<<<<<
  3794. * return parser.status_code
  3795. *
  3796. */
  3797. __pyx_t_1 = __pyx_v_self->__pyx_base._cparser;
  3798. __pyx_v_parser = __pyx_t_1;
  3799. /* "httptools/parser/parser.pyx":227
  3800. * def get_status_code(self):
  3801. * cdef cparser.http_parser* parser = self._cparser
  3802. * return parser.status_code # <<<<<<<<<<<<<<
  3803. *
  3804. *
  3805. */
  3806. __Pyx_XDECREF(__pyx_r);
  3807. __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_parser->status_code); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 227, __pyx_L1_error)
  3808. __Pyx_GOTREF(__pyx_t_2);
  3809. __pyx_r = __pyx_t_2;
  3810. __pyx_t_2 = 0;
  3811. goto __pyx_L0;
  3812. /* "httptools/parser/parser.pyx":225
  3813. * self._csettings.on_status = cb_on_status
  3814. *
  3815. * def get_status_code(self): # <<<<<<<<<<<<<<
  3816. * cdef cparser.http_parser* parser = self._cparser
  3817. * return parser.status_code
  3818. */
  3819. /* function exit code */
  3820. __pyx_L1_error:;
  3821. __Pyx_XDECREF(__pyx_t_2);
  3822. __Pyx_AddTraceback("httptools.parser.parser.HttpResponseParser.get_status_code", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3823. __pyx_r = NULL;
  3824. __pyx_L0:;
  3825. __Pyx_XGIVEREF(__pyx_r);
  3826. __Pyx_RefNannyFinishContext();
  3827. return __pyx_r;
  3828. }
  3829. /* "(tree fragment)":1
  3830. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  3831. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3832. * def __setstate_cython__(self, __pyx_state):
  3833. */
  3834. /* Python wrapper */
  3835. static PyObject *__pyx_pw_9httptools_6parser_6parser_18HttpResponseParser_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  3836. static PyObject *__pyx_pw_9httptools_6parser_6parser_18HttpResponseParser_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  3837. PyObject *__pyx_r = 0;
  3838. __Pyx_RefNannyDeclarations
  3839. __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  3840. __pyx_r = __pyx_pf_9httptools_6parser_6parser_18HttpResponseParser_4__reduce_cython__(((struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser *)__pyx_v_self));
  3841. /* function exit code */
  3842. __Pyx_RefNannyFinishContext();
  3843. return __pyx_r;
  3844. }
  3845. static PyObject *__pyx_pf_9httptools_6parser_6parser_18HttpResponseParser_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser *__pyx_v_self) {
  3846. PyObject *__pyx_r = NULL;
  3847. __Pyx_RefNannyDeclarations
  3848. PyObject *__pyx_t_1 = NULL;
  3849. __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  3850. /* "(tree fragment)":2
  3851. * def __reduce_cython__(self):
  3852. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  3853. * def __setstate_cython__(self, __pyx_state):
  3854. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3855. */
  3856. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
  3857. __Pyx_GOTREF(__pyx_t_1);
  3858. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  3859. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3860. __PYX_ERR(1, 2, __pyx_L1_error)
  3861. /* "(tree fragment)":1
  3862. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  3863. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3864. * def __setstate_cython__(self, __pyx_state):
  3865. */
  3866. /* function exit code */
  3867. __pyx_L1_error:;
  3868. __Pyx_XDECREF(__pyx_t_1);
  3869. __Pyx_AddTraceback("httptools.parser.parser.HttpResponseParser.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3870. __pyx_r = NULL;
  3871. __Pyx_XGIVEREF(__pyx_r);
  3872. __Pyx_RefNannyFinishContext();
  3873. return __pyx_r;
  3874. }
  3875. /* "(tree fragment)":3
  3876. * def __reduce_cython__(self):
  3877. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3878. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  3879. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3880. */
  3881. /* Python wrapper */
  3882. static PyObject *__pyx_pw_9httptools_6parser_6parser_18HttpResponseParser_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
  3883. static PyObject *__pyx_pw_9httptools_6parser_6parser_18HttpResponseParser_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  3884. PyObject *__pyx_r = 0;
  3885. __Pyx_RefNannyDeclarations
  3886. __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  3887. __pyx_r = __pyx_pf_9httptools_6parser_6parser_18HttpResponseParser_6__setstate_cython__(((struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
  3888. /* function exit code */
  3889. __Pyx_RefNannyFinishContext();
  3890. return __pyx_r;
  3891. }
  3892. static PyObject *__pyx_pf_9httptools_6parser_6parser_18HttpResponseParser_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  3893. PyObject *__pyx_r = NULL;
  3894. __Pyx_RefNannyDeclarations
  3895. PyObject *__pyx_t_1 = NULL;
  3896. __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  3897. /* "(tree fragment)":4
  3898. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3899. * def __setstate_cython__(self, __pyx_state):
  3900. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  3901. */
  3902. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  3903. __Pyx_GOTREF(__pyx_t_1);
  3904. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  3905. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3906. __PYX_ERR(1, 4, __pyx_L1_error)
  3907. /* "(tree fragment)":3
  3908. * def __reduce_cython__(self):
  3909. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3910. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  3911. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3912. */
  3913. /* function exit code */
  3914. __pyx_L1_error:;
  3915. __Pyx_XDECREF(__pyx_t_1);
  3916. __Pyx_AddTraceback("httptools.parser.parser.HttpResponseParser.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3917. __pyx_r = NULL;
  3918. __Pyx_XGIVEREF(__pyx_r);
  3919. __Pyx_RefNannyFinishContext();
  3920. return __pyx_r;
  3921. }
  3922. /* "httptools/parser/parser.pyx":230
  3923. *
  3924. *
  3925. * cdef int cb_on_message_begin(cparser.http_parser* parser) except -1: # <<<<<<<<<<<<<<
  3926. * cdef HttpParser pyparser = <HttpParser>parser.data
  3927. * try:
  3928. */
  3929. static int __pyx_f_9httptools_6parser_6parser_cb_on_message_begin(struct http_parser *__pyx_v_parser) {
  3930. struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_pyparser = 0;
  3931. PyObject *__pyx_v_ex = NULL;
  3932. int __pyx_r;
  3933. __Pyx_RefNannyDeclarations
  3934. PyObject *__pyx_t_1 = NULL;
  3935. PyObject *__pyx_t_2 = NULL;
  3936. PyObject *__pyx_t_3 = NULL;
  3937. PyObject *__pyx_t_4 = NULL;
  3938. PyObject *__pyx_t_5 = NULL;
  3939. PyObject *__pyx_t_6 = NULL;
  3940. int __pyx_t_7;
  3941. __Pyx_RefNannySetupContext("cb_on_message_begin", 0);
  3942. /* "httptools/parser/parser.pyx":231
  3943. *
  3944. * cdef int cb_on_message_begin(cparser.http_parser* parser) except -1:
  3945. * cdef HttpParser pyparser = <HttpParser>parser.data # <<<<<<<<<<<<<<
  3946. * try:
  3947. * pyparser._proto_on_message_begin()
  3948. */
  3949. __pyx_t_1 = ((PyObject *)__pyx_v_parser->data);
  3950. __Pyx_INCREF(__pyx_t_1);
  3951. __pyx_v_pyparser = ((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_t_1);
  3952. __pyx_t_1 = 0;
  3953. /* "httptools/parser/parser.pyx":232
  3954. * cdef int cb_on_message_begin(cparser.http_parser* parser) except -1:
  3955. * cdef HttpParser pyparser = <HttpParser>parser.data
  3956. * try: # <<<<<<<<<<<<<<
  3957. * pyparser._proto_on_message_begin()
  3958. * except BaseException as ex:
  3959. */
  3960. {
  3961. __Pyx_PyThreadState_declare
  3962. __Pyx_PyThreadState_assign
  3963. __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
  3964. __Pyx_XGOTREF(__pyx_t_2);
  3965. __Pyx_XGOTREF(__pyx_t_3);
  3966. __Pyx_XGOTREF(__pyx_t_4);
  3967. /*try:*/ {
  3968. /* "httptools/parser/parser.pyx":233
  3969. * cdef HttpParser pyparser = <HttpParser>parser.data
  3970. * try:
  3971. * pyparser._proto_on_message_begin() # <<<<<<<<<<<<<<
  3972. * except BaseException as ex:
  3973. * pyparser._last_error = ex
  3974. */
  3975. __Pyx_INCREF(__pyx_v_pyparser->_proto_on_message_begin);
  3976. __pyx_t_5 = __pyx_v_pyparser->_proto_on_message_begin; __pyx_t_6 = NULL;
  3977. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  3978. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
  3979. if (likely(__pyx_t_6)) {
  3980. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  3981. __Pyx_INCREF(__pyx_t_6);
  3982. __Pyx_INCREF(function);
  3983. __Pyx_DECREF_SET(__pyx_t_5, function);
  3984. }
  3985. }
  3986. __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
  3987. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3988. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 233, __pyx_L3_error)
  3989. __Pyx_GOTREF(__pyx_t_1);
  3990. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3991. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3992. /* "httptools/parser/parser.pyx":232
  3993. * cdef int cb_on_message_begin(cparser.http_parser* parser) except -1:
  3994. * cdef HttpParser pyparser = <HttpParser>parser.data
  3995. * try: # <<<<<<<<<<<<<<
  3996. * pyparser._proto_on_message_begin()
  3997. * except BaseException as ex:
  3998. */
  3999. }
  4000. /* "httptools/parser/parser.pyx":238
  4001. * return -1
  4002. * else:
  4003. * return 0 # <<<<<<<<<<<<<<
  4004. *
  4005. *
  4006. */
  4007. /*else:*/ {
  4008. __pyx_r = 0;
  4009. goto __pyx_L6_except_return;
  4010. }
  4011. __pyx_L3_error:;
  4012. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  4013. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4014. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  4015. /* "httptools/parser/parser.pyx":234
  4016. * try:
  4017. * pyparser._proto_on_message_begin()
  4018. * except BaseException as ex: # <<<<<<<<<<<<<<
  4019. * pyparser._last_error = ex
  4020. * return -1
  4021. */
  4022. __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_BaseException);
  4023. if (__pyx_t_7) {
  4024. __Pyx_AddTraceback("httptools.parser.parser.cb_on_message_begin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4025. if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 234, __pyx_L5_except_error)
  4026. __Pyx_GOTREF(__pyx_t_1);
  4027. __Pyx_GOTREF(__pyx_t_5);
  4028. __Pyx_GOTREF(__pyx_t_6);
  4029. __Pyx_INCREF(__pyx_t_5);
  4030. __pyx_v_ex = __pyx_t_5;
  4031. /*try:*/ {
  4032. /* "httptools/parser/parser.pyx":235
  4033. * pyparser._proto_on_message_begin()
  4034. * except BaseException as ex:
  4035. * pyparser._last_error = ex # <<<<<<<<<<<<<<
  4036. * return -1
  4037. * else:
  4038. */
  4039. __Pyx_INCREF(__pyx_v_ex);
  4040. __Pyx_GIVEREF(__pyx_v_ex);
  4041. __Pyx_GOTREF(__pyx_v_pyparser->_last_error);
  4042. __Pyx_DECREF(__pyx_v_pyparser->_last_error);
  4043. __pyx_v_pyparser->_last_error = __pyx_v_ex;
  4044. /* "httptools/parser/parser.pyx":236
  4045. * except BaseException as ex:
  4046. * pyparser._last_error = ex
  4047. * return -1 # <<<<<<<<<<<<<<
  4048. * else:
  4049. * return 0
  4050. */
  4051. __pyx_r = -1;
  4052. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4053. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4054. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4055. goto __pyx_L13_return;
  4056. }
  4057. /* "httptools/parser/parser.pyx":234
  4058. * try:
  4059. * pyparser._proto_on_message_begin()
  4060. * except BaseException as ex: # <<<<<<<<<<<<<<
  4061. * pyparser._last_error = ex
  4062. * return -1
  4063. */
  4064. /*finally:*/ {
  4065. __pyx_L13_return: {
  4066. __pyx_t_7 = __pyx_r;
  4067. __Pyx_DECREF(__pyx_v_ex);
  4068. __pyx_v_ex = NULL;
  4069. __pyx_r = __pyx_t_7;
  4070. goto __pyx_L6_except_return;
  4071. }
  4072. }
  4073. }
  4074. goto __pyx_L5_except_error;
  4075. __pyx_L5_except_error:;
  4076. /* "httptools/parser/parser.pyx":232
  4077. * cdef int cb_on_message_begin(cparser.http_parser* parser) except -1:
  4078. * cdef HttpParser pyparser = <HttpParser>parser.data
  4079. * try: # <<<<<<<<<<<<<<
  4080. * pyparser._proto_on_message_begin()
  4081. * except BaseException as ex:
  4082. */
  4083. __Pyx_XGIVEREF(__pyx_t_2);
  4084. __Pyx_XGIVEREF(__pyx_t_3);
  4085. __Pyx_XGIVEREF(__pyx_t_4);
  4086. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  4087. goto __pyx_L1_error;
  4088. __pyx_L6_except_return:;
  4089. __Pyx_XGIVEREF(__pyx_t_2);
  4090. __Pyx_XGIVEREF(__pyx_t_3);
  4091. __Pyx_XGIVEREF(__pyx_t_4);
  4092. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  4093. goto __pyx_L0;
  4094. }
  4095. /* "httptools/parser/parser.pyx":230
  4096. *
  4097. *
  4098. * cdef int cb_on_message_begin(cparser.http_parser* parser) except -1: # <<<<<<<<<<<<<<
  4099. * cdef HttpParser pyparser = <HttpParser>parser.data
  4100. * try:
  4101. */
  4102. /* function exit code */
  4103. __pyx_L1_error:;
  4104. __Pyx_XDECREF(__pyx_t_1);
  4105. __Pyx_XDECREF(__pyx_t_5);
  4106. __Pyx_XDECREF(__pyx_t_6);
  4107. __Pyx_AddTraceback("httptools.parser.parser.cb_on_message_begin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4108. __pyx_r = -1;
  4109. __pyx_L0:;
  4110. __Pyx_XDECREF((PyObject *)__pyx_v_pyparser);
  4111. __Pyx_XDECREF(__pyx_v_ex);
  4112. __Pyx_RefNannyFinishContext();
  4113. return __pyx_r;
  4114. }
  4115. /* "httptools/parser/parser.pyx":241
  4116. *
  4117. *
  4118. * cdef int cb_on_url(cparser.http_parser* parser, # <<<<<<<<<<<<<<
  4119. * const char *at, size_t length) except -1:
  4120. * cdef HttpParser pyparser = <HttpParser>parser.data
  4121. */
  4122. static int __pyx_f_9httptools_6parser_6parser_cb_on_url(struct http_parser *__pyx_v_parser, char const *__pyx_v_at, size_t __pyx_v_length) {
  4123. struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_pyparser = 0;
  4124. PyObject *__pyx_v_ex = NULL;
  4125. int __pyx_r;
  4126. __Pyx_RefNannyDeclarations
  4127. PyObject *__pyx_t_1 = NULL;
  4128. PyObject *__pyx_t_2 = NULL;
  4129. PyObject *__pyx_t_3 = NULL;
  4130. PyObject *__pyx_t_4 = NULL;
  4131. PyObject *__pyx_t_5 = NULL;
  4132. PyObject *__pyx_t_6 = NULL;
  4133. PyObject *__pyx_t_7 = NULL;
  4134. int __pyx_t_8;
  4135. __Pyx_RefNannySetupContext("cb_on_url", 0);
  4136. /* "httptools/parser/parser.pyx":243
  4137. * cdef int cb_on_url(cparser.http_parser* parser,
  4138. * const char *at, size_t length) except -1:
  4139. * cdef HttpParser pyparser = <HttpParser>parser.data # <<<<<<<<<<<<<<
  4140. * try:
  4141. * pyparser._proto_on_url(at[:length])
  4142. */
  4143. __pyx_t_1 = ((PyObject *)__pyx_v_parser->data);
  4144. __Pyx_INCREF(__pyx_t_1);
  4145. __pyx_v_pyparser = ((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_t_1);
  4146. __pyx_t_1 = 0;
  4147. /* "httptools/parser/parser.pyx":244
  4148. * const char *at, size_t length) except -1:
  4149. * cdef HttpParser pyparser = <HttpParser>parser.data
  4150. * try: # <<<<<<<<<<<<<<
  4151. * pyparser._proto_on_url(at[:length])
  4152. * except BaseException as ex:
  4153. */
  4154. {
  4155. __Pyx_PyThreadState_declare
  4156. __Pyx_PyThreadState_assign
  4157. __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
  4158. __Pyx_XGOTREF(__pyx_t_2);
  4159. __Pyx_XGOTREF(__pyx_t_3);
  4160. __Pyx_XGOTREF(__pyx_t_4);
  4161. /*try:*/ {
  4162. /* "httptools/parser/parser.pyx":245
  4163. * cdef HttpParser pyparser = <HttpParser>parser.data
  4164. * try:
  4165. * pyparser._proto_on_url(at[:length]) # <<<<<<<<<<<<<<
  4166. * except BaseException as ex:
  4167. * pyparser._last_error = ex
  4168. */
  4169. __pyx_t_5 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_at + 0, __pyx_v_length - 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 245, __pyx_L3_error)
  4170. __Pyx_GOTREF(__pyx_t_5);
  4171. __Pyx_INCREF(__pyx_v_pyparser->_proto_on_url);
  4172. __pyx_t_6 = __pyx_v_pyparser->_proto_on_url; __pyx_t_7 = NULL;
  4173. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  4174. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
  4175. if (likely(__pyx_t_7)) {
  4176. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  4177. __Pyx_INCREF(__pyx_t_7);
  4178. __Pyx_INCREF(function);
  4179. __Pyx_DECREF_SET(__pyx_t_6, function);
  4180. }
  4181. }
  4182. __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5);
  4183. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4184. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4185. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L3_error)
  4186. __Pyx_GOTREF(__pyx_t_1);
  4187. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4188. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4189. /* "httptools/parser/parser.pyx":244
  4190. * const char *at, size_t length) except -1:
  4191. * cdef HttpParser pyparser = <HttpParser>parser.data
  4192. * try: # <<<<<<<<<<<<<<
  4193. * pyparser._proto_on_url(at[:length])
  4194. * except BaseException as ex:
  4195. */
  4196. }
  4197. /* "httptools/parser/parser.pyx":250
  4198. * return -1
  4199. * else:
  4200. * return 0 # <<<<<<<<<<<<<<
  4201. *
  4202. *
  4203. */
  4204. /*else:*/ {
  4205. __pyx_r = 0;
  4206. goto __pyx_L6_except_return;
  4207. }
  4208. __pyx_L3_error:;
  4209. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4210. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4211. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  4212. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  4213. /* "httptools/parser/parser.pyx":246
  4214. * try:
  4215. * pyparser._proto_on_url(at[:length])
  4216. * except BaseException as ex: # <<<<<<<<<<<<<<
  4217. * pyparser._last_error = ex
  4218. * return -1
  4219. */
  4220. __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_BaseException);
  4221. if (__pyx_t_8) {
  4222. __Pyx_AddTraceback("httptools.parser.parser.cb_on_url", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4223. if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_6, &__pyx_t_5) < 0) __PYX_ERR(0, 246, __pyx_L5_except_error)
  4224. __Pyx_GOTREF(__pyx_t_1);
  4225. __Pyx_GOTREF(__pyx_t_6);
  4226. __Pyx_GOTREF(__pyx_t_5);
  4227. __Pyx_INCREF(__pyx_t_6);
  4228. __pyx_v_ex = __pyx_t_6;
  4229. /*try:*/ {
  4230. /* "httptools/parser/parser.pyx":247
  4231. * pyparser._proto_on_url(at[:length])
  4232. * except BaseException as ex:
  4233. * pyparser._last_error = ex # <<<<<<<<<<<<<<
  4234. * return -1
  4235. * else:
  4236. */
  4237. __Pyx_INCREF(__pyx_v_ex);
  4238. __Pyx_GIVEREF(__pyx_v_ex);
  4239. __Pyx_GOTREF(__pyx_v_pyparser->_last_error);
  4240. __Pyx_DECREF(__pyx_v_pyparser->_last_error);
  4241. __pyx_v_pyparser->_last_error = __pyx_v_ex;
  4242. /* "httptools/parser/parser.pyx":248
  4243. * except BaseException as ex:
  4244. * pyparser._last_error = ex
  4245. * return -1 # <<<<<<<<<<<<<<
  4246. * else:
  4247. * return 0
  4248. */
  4249. __pyx_r = -1;
  4250. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4251. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4252. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4253. goto __pyx_L13_return;
  4254. }
  4255. /* "httptools/parser/parser.pyx":246
  4256. * try:
  4257. * pyparser._proto_on_url(at[:length])
  4258. * except BaseException as ex: # <<<<<<<<<<<<<<
  4259. * pyparser._last_error = ex
  4260. * return -1
  4261. */
  4262. /*finally:*/ {
  4263. __pyx_L13_return: {
  4264. __pyx_t_8 = __pyx_r;
  4265. __Pyx_DECREF(__pyx_v_ex);
  4266. __pyx_v_ex = NULL;
  4267. __pyx_r = __pyx_t_8;
  4268. goto __pyx_L6_except_return;
  4269. }
  4270. }
  4271. }
  4272. goto __pyx_L5_except_error;
  4273. __pyx_L5_except_error:;
  4274. /* "httptools/parser/parser.pyx":244
  4275. * const char *at, size_t length) except -1:
  4276. * cdef HttpParser pyparser = <HttpParser>parser.data
  4277. * try: # <<<<<<<<<<<<<<
  4278. * pyparser._proto_on_url(at[:length])
  4279. * except BaseException as ex:
  4280. */
  4281. __Pyx_XGIVEREF(__pyx_t_2);
  4282. __Pyx_XGIVEREF(__pyx_t_3);
  4283. __Pyx_XGIVEREF(__pyx_t_4);
  4284. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  4285. goto __pyx_L1_error;
  4286. __pyx_L6_except_return:;
  4287. __Pyx_XGIVEREF(__pyx_t_2);
  4288. __Pyx_XGIVEREF(__pyx_t_3);
  4289. __Pyx_XGIVEREF(__pyx_t_4);
  4290. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  4291. goto __pyx_L0;
  4292. }
  4293. /* "httptools/parser/parser.pyx":241
  4294. *
  4295. *
  4296. * cdef int cb_on_url(cparser.http_parser* parser, # <<<<<<<<<<<<<<
  4297. * const char *at, size_t length) except -1:
  4298. * cdef HttpParser pyparser = <HttpParser>parser.data
  4299. */
  4300. /* function exit code */
  4301. __pyx_L1_error:;
  4302. __Pyx_XDECREF(__pyx_t_1);
  4303. __Pyx_XDECREF(__pyx_t_5);
  4304. __Pyx_XDECREF(__pyx_t_6);
  4305. __Pyx_XDECREF(__pyx_t_7);
  4306. __Pyx_AddTraceback("httptools.parser.parser.cb_on_url", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4307. __pyx_r = -1;
  4308. __pyx_L0:;
  4309. __Pyx_XDECREF((PyObject *)__pyx_v_pyparser);
  4310. __Pyx_XDECREF(__pyx_v_ex);
  4311. __Pyx_RefNannyFinishContext();
  4312. return __pyx_r;
  4313. }
  4314. /* "httptools/parser/parser.pyx":253
  4315. *
  4316. *
  4317. * cdef int cb_on_status(cparser.http_parser* parser, # <<<<<<<<<<<<<<
  4318. * const char *at, size_t length) except -1:
  4319. * cdef HttpParser pyparser = <HttpParser>parser.data
  4320. */
  4321. static int __pyx_f_9httptools_6parser_6parser_cb_on_status(struct http_parser *__pyx_v_parser, char const *__pyx_v_at, size_t __pyx_v_length) {
  4322. struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_pyparser = 0;
  4323. PyObject *__pyx_v_ex = NULL;
  4324. int __pyx_r;
  4325. __Pyx_RefNannyDeclarations
  4326. PyObject *__pyx_t_1 = NULL;
  4327. PyObject *__pyx_t_2 = NULL;
  4328. PyObject *__pyx_t_3 = NULL;
  4329. PyObject *__pyx_t_4 = NULL;
  4330. PyObject *__pyx_t_5 = NULL;
  4331. PyObject *__pyx_t_6 = NULL;
  4332. PyObject *__pyx_t_7 = NULL;
  4333. int __pyx_t_8;
  4334. __Pyx_RefNannySetupContext("cb_on_status", 0);
  4335. /* "httptools/parser/parser.pyx":255
  4336. * cdef int cb_on_status(cparser.http_parser* parser,
  4337. * const char *at, size_t length) except -1:
  4338. * cdef HttpParser pyparser = <HttpParser>parser.data # <<<<<<<<<<<<<<
  4339. * try:
  4340. * pyparser._proto_on_status(at[:length])
  4341. */
  4342. __pyx_t_1 = ((PyObject *)__pyx_v_parser->data);
  4343. __Pyx_INCREF(__pyx_t_1);
  4344. __pyx_v_pyparser = ((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_t_1);
  4345. __pyx_t_1 = 0;
  4346. /* "httptools/parser/parser.pyx":256
  4347. * const char *at, size_t length) except -1:
  4348. * cdef HttpParser pyparser = <HttpParser>parser.data
  4349. * try: # <<<<<<<<<<<<<<
  4350. * pyparser._proto_on_status(at[:length])
  4351. * except BaseException as ex:
  4352. */
  4353. {
  4354. __Pyx_PyThreadState_declare
  4355. __Pyx_PyThreadState_assign
  4356. __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
  4357. __Pyx_XGOTREF(__pyx_t_2);
  4358. __Pyx_XGOTREF(__pyx_t_3);
  4359. __Pyx_XGOTREF(__pyx_t_4);
  4360. /*try:*/ {
  4361. /* "httptools/parser/parser.pyx":257
  4362. * cdef HttpParser pyparser = <HttpParser>parser.data
  4363. * try:
  4364. * pyparser._proto_on_status(at[:length]) # <<<<<<<<<<<<<<
  4365. * except BaseException as ex:
  4366. * pyparser._last_error = ex
  4367. */
  4368. __pyx_t_5 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_at + 0, __pyx_v_length - 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 257, __pyx_L3_error)
  4369. __Pyx_GOTREF(__pyx_t_5);
  4370. __Pyx_INCREF(__pyx_v_pyparser->_proto_on_status);
  4371. __pyx_t_6 = __pyx_v_pyparser->_proto_on_status; __pyx_t_7 = NULL;
  4372. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  4373. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
  4374. if (likely(__pyx_t_7)) {
  4375. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  4376. __Pyx_INCREF(__pyx_t_7);
  4377. __Pyx_INCREF(function);
  4378. __Pyx_DECREF_SET(__pyx_t_6, function);
  4379. }
  4380. }
  4381. __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5);
  4382. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4383. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4384. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 257, __pyx_L3_error)
  4385. __Pyx_GOTREF(__pyx_t_1);
  4386. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4387. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4388. /* "httptools/parser/parser.pyx":256
  4389. * const char *at, size_t length) except -1:
  4390. * cdef HttpParser pyparser = <HttpParser>parser.data
  4391. * try: # <<<<<<<<<<<<<<
  4392. * pyparser._proto_on_status(at[:length])
  4393. * except BaseException as ex:
  4394. */
  4395. }
  4396. /* "httptools/parser/parser.pyx":262
  4397. * return -1
  4398. * else:
  4399. * return 0 # <<<<<<<<<<<<<<
  4400. *
  4401. *
  4402. */
  4403. /*else:*/ {
  4404. __pyx_r = 0;
  4405. goto __pyx_L6_except_return;
  4406. }
  4407. __pyx_L3_error:;
  4408. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4409. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4410. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  4411. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  4412. /* "httptools/parser/parser.pyx":258
  4413. * try:
  4414. * pyparser._proto_on_status(at[:length])
  4415. * except BaseException as ex: # <<<<<<<<<<<<<<
  4416. * pyparser._last_error = ex
  4417. * return -1
  4418. */
  4419. __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_BaseException);
  4420. if (__pyx_t_8) {
  4421. __Pyx_AddTraceback("httptools.parser.parser.cb_on_status", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4422. if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_6, &__pyx_t_5) < 0) __PYX_ERR(0, 258, __pyx_L5_except_error)
  4423. __Pyx_GOTREF(__pyx_t_1);
  4424. __Pyx_GOTREF(__pyx_t_6);
  4425. __Pyx_GOTREF(__pyx_t_5);
  4426. __Pyx_INCREF(__pyx_t_6);
  4427. __pyx_v_ex = __pyx_t_6;
  4428. /*try:*/ {
  4429. /* "httptools/parser/parser.pyx":259
  4430. * pyparser._proto_on_status(at[:length])
  4431. * except BaseException as ex:
  4432. * pyparser._last_error = ex # <<<<<<<<<<<<<<
  4433. * return -1
  4434. * else:
  4435. */
  4436. __Pyx_INCREF(__pyx_v_ex);
  4437. __Pyx_GIVEREF(__pyx_v_ex);
  4438. __Pyx_GOTREF(__pyx_v_pyparser->_last_error);
  4439. __Pyx_DECREF(__pyx_v_pyparser->_last_error);
  4440. __pyx_v_pyparser->_last_error = __pyx_v_ex;
  4441. /* "httptools/parser/parser.pyx":260
  4442. * except BaseException as ex:
  4443. * pyparser._last_error = ex
  4444. * return -1 # <<<<<<<<<<<<<<
  4445. * else:
  4446. * return 0
  4447. */
  4448. __pyx_r = -1;
  4449. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4450. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4451. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4452. goto __pyx_L13_return;
  4453. }
  4454. /* "httptools/parser/parser.pyx":258
  4455. * try:
  4456. * pyparser._proto_on_status(at[:length])
  4457. * except BaseException as ex: # <<<<<<<<<<<<<<
  4458. * pyparser._last_error = ex
  4459. * return -1
  4460. */
  4461. /*finally:*/ {
  4462. __pyx_L13_return: {
  4463. __pyx_t_8 = __pyx_r;
  4464. __Pyx_DECREF(__pyx_v_ex);
  4465. __pyx_v_ex = NULL;
  4466. __pyx_r = __pyx_t_8;
  4467. goto __pyx_L6_except_return;
  4468. }
  4469. }
  4470. }
  4471. goto __pyx_L5_except_error;
  4472. __pyx_L5_except_error:;
  4473. /* "httptools/parser/parser.pyx":256
  4474. * const char *at, size_t length) except -1:
  4475. * cdef HttpParser pyparser = <HttpParser>parser.data
  4476. * try: # <<<<<<<<<<<<<<
  4477. * pyparser._proto_on_status(at[:length])
  4478. * except BaseException as ex:
  4479. */
  4480. __Pyx_XGIVEREF(__pyx_t_2);
  4481. __Pyx_XGIVEREF(__pyx_t_3);
  4482. __Pyx_XGIVEREF(__pyx_t_4);
  4483. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  4484. goto __pyx_L1_error;
  4485. __pyx_L6_except_return:;
  4486. __Pyx_XGIVEREF(__pyx_t_2);
  4487. __Pyx_XGIVEREF(__pyx_t_3);
  4488. __Pyx_XGIVEREF(__pyx_t_4);
  4489. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  4490. goto __pyx_L0;
  4491. }
  4492. /* "httptools/parser/parser.pyx":253
  4493. *
  4494. *
  4495. * cdef int cb_on_status(cparser.http_parser* parser, # <<<<<<<<<<<<<<
  4496. * const char *at, size_t length) except -1:
  4497. * cdef HttpParser pyparser = <HttpParser>parser.data
  4498. */
  4499. /* function exit code */
  4500. __pyx_L1_error:;
  4501. __Pyx_XDECREF(__pyx_t_1);
  4502. __Pyx_XDECREF(__pyx_t_5);
  4503. __Pyx_XDECREF(__pyx_t_6);
  4504. __Pyx_XDECREF(__pyx_t_7);
  4505. __Pyx_AddTraceback("httptools.parser.parser.cb_on_status", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4506. __pyx_r = -1;
  4507. __pyx_L0:;
  4508. __Pyx_XDECREF((PyObject *)__pyx_v_pyparser);
  4509. __Pyx_XDECREF(__pyx_v_ex);
  4510. __Pyx_RefNannyFinishContext();
  4511. return __pyx_r;
  4512. }
  4513. /* "httptools/parser/parser.pyx":265
  4514. *
  4515. *
  4516. * cdef int cb_on_header_field(cparser.http_parser* parser, # <<<<<<<<<<<<<<
  4517. * const char *at, size_t length) except -1:
  4518. * cdef HttpParser pyparser = <HttpParser>parser.data
  4519. */
  4520. static int __pyx_f_9httptools_6parser_6parser_cb_on_header_field(struct http_parser *__pyx_v_parser, char const *__pyx_v_at, size_t __pyx_v_length) {
  4521. struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_pyparser = 0;
  4522. PyObject *__pyx_v_ex = NULL;
  4523. int __pyx_r;
  4524. __Pyx_RefNannyDeclarations
  4525. PyObject *__pyx_t_1 = NULL;
  4526. PyObject *__pyx_t_2 = NULL;
  4527. PyObject *__pyx_t_3 = NULL;
  4528. PyObject *__pyx_t_4 = NULL;
  4529. PyObject *__pyx_t_5 = NULL;
  4530. int __pyx_t_6;
  4531. PyObject *__pyx_t_7 = NULL;
  4532. __Pyx_RefNannySetupContext("cb_on_header_field", 0);
  4533. /* "httptools/parser/parser.pyx":267
  4534. * cdef int cb_on_header_field(cparser.http_parser* parser,
  4535. * const char *at, size_t length) except -1:
  4536. * cdef HttpParser pyparser = <HttpParser>parser.data # <<<<<<<<<<<<<<
  4537. * try:
  4538. * pyparser._on_header_field(at[:length])
  4539. */
  4540. __pyx_t_1 = ((PyObject *)__pyx_v_parser->data);
  4541. __Pyx_INCREF(__pyx_t_1);
  4542. __pyx_v_pyparser = ((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_t_1);
  4543. __pyx_t_1 = 0;
  4544. /* "httptools/parser/parser.pyx":268
  4545. * const char *at, size_t length) except -1:
  4546. * cdef HttpParser pyparser = <HttpParser>parser.data
  4547. * try: # <<<<<<<<<<<<<<
  4548. * pyparser._on_header_field(at[:length])
  4549. * except BaseException as ex:
  4550. */
  4551. {
  4552. __Pyx_PyThreadState_declare
  4553. __Pyx_PyThreadState_assign
  4554. __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
  4555. __Pyx_XGOTREF(__pyx_t_2);
  4556. __Pyx_XGOTREF(__pyx_t_3);
  4557. __Pyx_XGOTREF(__pyx_t_4);
  4558. /*try:*/ {
  4559. /* "httptools/parser/parser.pyx":269
  4560. * cdef HttpParser pyparser = <HttpParser>parser.data
  4561. * try:
  4562. * pyparser._on_header_field(at[:length]) # <<<<<<<<<<<<<<
  4563. * except BaseException as ex:
  4564. * pyparser._last_error = ex
  4565. */
  4566. __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_at + 0, __pyx_v_length - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L3_error)
  4567. __Pyx_GOTREF(__pyx_t_1);
  4568. __pyx_t_5 = ((struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser *)__pyx_v_pyparser->__pyx_vtab)->_on_header_field(__pyx_v_pyparser, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 269, __pyx_L3_error)
  4569. __Pyx_GOTREF(__pyx_t_5);
  4570. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4571. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4572. /* "httptools/parser/parser.pyx":268
  4573. * const char *at, size_t length) except -1:
  4574. * cdef HttpParser pyparser = <HttpParser>parser.data
  4575. * try: # <<<<<<<<<<<<<<
  4576. * pyparser._on_header_field(at[:length])
  4577. * except BaseException as ex:
  4578. */
  4579. }
  4580. /* "httptools/parser/parser.pyx":274
  4581. * return -1
  4582. * else:
  4583. * return 0 # <<<<<<<<<<<<<<
  4584. *
  4585. *
  4586. */
  4587. /*else:*/ {
  4588. __pyx_r = 0;
  4589. goto __pyx_L6_except_return;
  4590. }
  4591. __pyx_L3_error:;
  4592. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  4593. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4594. /* "httptools/parser/parser.pyx":270
  4595. * try:
  4596. * pyparser._on_header_field(at[:length])
  4597. * except BaseException as ex: # <<<<<<<<<<<<<<
  4598. * pyparser._last_error = ex
  4599. * return -1
  4600. */
  4601. __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_BaseException);
  4602. if (__pyx_t_6) {
  4603. __Pyx_AddTraceback("httptools.parser.parser.cb_on_header_field", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4604. if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_1, &__pyx_t_7) < 0) __PYX_ERR(0, 270, __pyx_L5_except_error)
  4605. __Pyx_GOTREF(__pyx_t_5);
  4606. __Pyx_GOTREF(__pyx_t_1);
  4607. __Pyx_GOTREF(__pyx_t_7);
  4608. __Pyx_INCREF(__pyx_t_1);
  4609. __pyx_v_ex = __pyx_t_1;
  4610. /*try:*/ {
  4611. /* "httptools/parser/parser.pyx":271
  4612. * pyparser._on_header_field(at[:length])
  4613. * except BaseException as ex:
  4614. * pyparser._last_error = ex # <<<<<<<<<<<<<<
  4615. * return -1
  4616. * else:
  4617. */
  4618. __Pyx_INCREF(__pyx_v_ex);
  4619. __Pyx_GIVEREF(__pyx_v_ex);
  4620. __Pyx_GOTREF(__pyx_v_pyparser->_last_error);
  4621. __Pyx_DECREF(__pyx_v_pyparser->_last_error);
  4622. __pyx_v_pyparser->_last_error = __pyx_v_ex;
  4623. /* "httptools/parser/parser.pyx":272
  4624. * except BaseException as ex:
  4625. * pyparser._last_error = ex
  4626. * return -1 # <<<<<<<<<<<<<<
  4627. * else:
  4628. * return 0
  4629. */
  4630. __pyx_r = -1;
  4631. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4632. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4633. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4634. goto __pyx_L13_return;
  4635. }
  4636. /* "httptools/parser/parser.pyx":270
  4637. * try:
  4638. * pyparser._on_header_field(at[:length])
  4639. * except BaseException as ex: # <<<<<<<<<<<<<<
  4640. * pyparser._last_error = ex
  4641. * return -1
  4642. */
  4643. /*finally:*/ {
  4644. __pyx_L13_return: {
  4645. __pyx_t_6 = __pyx_r;
  4646. __Pyx_DECREF(__pyx_v_ex);
  4647. __pyx_v_ex = NULL;
  4648. __pyx_r = __pyx_t_6;
  4649. goto __pyx_L6_except_return;
  4650. }
  4651. }
  4652. }
  4653. goto __pyx_L5_except_error;
  4654. __pyx_L5_except_error:;
  4655. /* "httptools/parser/parser.pyx":268
  4656. * const char *at, size_t length) except -1:
  4657. * cdef HttpParser pyparser = <HttpParser>parser.data
  4658. * try: # <<<<<<<<<<<<<<
  4659. * pyparser._on_header_field(at[:length])
  4660. * except BaseException as ex:
  4661. */
  4662. __Pyx_XGIVEREF(__pyx_t_2);
  4663. __Pyx_XGIVEREF(__pyx_t_3);
  4664. __Pyx_XGIVEREF(__pyx_t_4);
  4665. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  4666. goto __pyx_L1_error;
  4667. __pyx_L6_except_return:;
  4668. __Pyx_XGIVEREF(__pyx_t_2);
  4669. __Pyx_XGIVEREF(__pyx_t_3);
  4670. __Pyx_XGIVEREF(__pyx_t_4);
  4671. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  4672. goto __pyx_L0;
  4673. }
  4674. /* "httptools/parser/parser.pyx":265
  4675. *
  4676. *
  4677. * cdef int cb_on_header_field(cparser.http_parser* parser, # <<<<<<<<<<<<<<
  4678. * const char *at, size_t length) except -1:
  4679. * cdef HttpParser pyparser = <HttpParser>parser.data
  4680. */
  4681. /* function exit code */
  4682. __pyx_L1_error:;
  4683. __Pyx_XDECREF(__pyx_t_1);
  4684. __Pyx_XDECREF(__pyx_t_5);
  4685. __Pyx_XDECREF(__pyx_t_7);
  4686. __Pyx_AddTraceback("httptools.parser.parser.cb_on_header_field", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4687. __pyx_r = -1;
  4688. __pyx_L0:;
  4689. __Pyx_XDECREF((PyObject *)__pyx_v_pyparser);
  4690. __Pyx_XDECREF(__pyx_v_ex);
  4691. __Pyx_RefNannyFinishContext();
  4692. return __pyx_r;
  4693. }
  4694. /* "httptools/parser/parser.pyx":277
  4695. *
  4696. *
  4697. * cdef int cb_on_header_value(cparser.http_parser* parser, # <<<<<<<<<<<<<<
  4698. * const char *at, size_t length) except -1:
  4699. * cdef HttpParser pyparser = <HttpParser>parser.data
  4700. */
  4701. static int __pyx_f_9httptools_6parser_6parser_cb_on_header_value(struct http_parser *__pyx_v_parser, char const *__pyx_v_at, size_t __pyx_v_length) {
  4702. struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_pyparser = 0;
  4703. PyObject *__pyx_v_ex = NULL;
  4704. int __pyx_r;
  4705. __Pyx_RefNannyDeclarations
  4706. PyObject *__pyx_t_1 = NULL;
  4707. PyObject *__pyx_t_2 = NULL;
  4708. PyObject *__pyx_t_3 = NULL;
  4709. PyObject *__pyx_t_4 = NULL;
  4710. PyObject *__pyx_t_5 = NULL;
  4711. int __pyx_t_6;
  4712. PyObject *__pyx_t_7 = NULL;
  4713. __Pyx_RefNannySetupContext("cb_on_header_value", 0);
  4714. /* "httptools/parser/parser.pyx":279
  4715. * cdef int cb_on_header_value(cparser.http_parser* parser,
  4716. * const char *at, size_t length) except -1:
  4717. * cdef HttpParser pyparser = <HttpParser>parser.data # <<<<<<<<<<<<<<
  4718. * try:
  4719. * pyparser._on_header_value(at[:length])
  4720. */
  4721. __pyx_t_1 = ((PyObject *)__pyx_v_parser->data);
  4722. __Pyx_INCREF(__pyx_t_1);
  4723. __pyx_v_pyparser = ((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_t_1);
  4724. __pyx_t_1 = 0;
  4725. /* "httptools/parser/parser.pyx":280
  4726. * const char *at, size_t length) except -1:
  4727. * cdef HttpParser pyparser = <HttpParser>parser.data
  4728. * try: # <<<<<<<<<<<<<<
  4729. * pyparser._on_header_value(at[:length])
  4730. * except BaseException as ex:
  4731. */
  4732. {
  4733. __Pyx_PyThreadState_declare
  4734. __Pyx_PyThreadState_assign
  4735. __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
  4736. __Pyx_XGOTREF(__pyx_t_2);
  4737. __Pyx_XGOTREF(__pyx_t_3);
  4738. __Pyx_XGOTREF(__pyx_t_4);
  4739. /*try:*/ {
  4740. /* "httptools/parser/parser.pyx":281
  4741. * cdef HttpParser pyparser = <HttpParser>parser.data
  4742. * try:
  4743. * pyparser._on_header_value(at[:length]) # <<<<<<<<<<<<<<
  4744. * except BaseException as ex:
  4745. * pyparser._last_error = ex
  4746. */
  4747. __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_at + 0, __pyx_v_length - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L3_error)
  4748. __Pyx_GOTREF(__pyx_t_1);
  4749. __pyx_t_5 = ((struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser *)__pyx_v_pyparser->__pyx_vtab)->_on_header_value(__pyx_v_pyparser, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 281, __pyx_L3_error)
  4750. __Pyx_GOTREF(__pyx_t_5);
  4751. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4752. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4753. /* "httptools/parser/parser.pyx":280
  4754. * const char *at, size_t length) except -1:
  4755. * cdef HttpParser pyparser = <HttpParser>parser.data
  4756. * try: # <<<<<<<<<<<<<<
  4757. * pyparser._on_header_value(at[:length])
  4758. * except BaseException as ex:
  4759. */
  4760. }
  4761. /* "httptools/parser/parser.pyx":286
  4762. * return -1
  4763. * else:
  4764. * return 0 # <<<<<<<<<<<<<<
  4765. *
  4766. *
  4767. */
  4768. /*else:*/ {
  4769. __pyx_r = 0;
  4770. goto __pyx_L6_except_return;
  4771. }
  4772. __pyx_L3_error:;
  4773. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  4774. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4775. /* "httptools/parser/parser.pyx":282
  4776. * try:
  4777. * pyparser._on_header_value(at[:length])
  4778. * except BaseException as ex: # <<<<<<<<<<<<<<
  4779. * pyparser._last_error = ex
  4780. * return -1
  4781. */
  4782. __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_BaseException);
  4783. if (__pyx_t_6) {
  4784. __Pyx_AddTraceback("httptools.parser.parser.cb_on_header_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4785. if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_1, &__pyx_t_7) < 0) __PYX_ERR(0, 282, __pyx_L5_except_error)
  4786. __Pyx_GOTREF(__pyx_t_5);
  4787. __Pyx_GOTREF(__pyx_t_1);
  4788. __Pyx_GOTREF(__pyx_t_7);
  4789. __Pyx_INCREF(__pyx_t_1);
  4790. __pyx_v_ex = __pyx_t_1;
  4791. /*try:*/ {
  4792. /* "httptools/parser/parser.pyx":283
  4793. * pyparser._on_header_value(at[:length])
  4794. * except BaseException as ex:
  4795. * pyparser._last_error = ex # <<<<<<<<<<<<<<
  4796. * return -1
  4797. * else:
  4798. */
  4799. __Pyx_INCREF(__pyx_v_ex);
  4800. __Pyx_GIVEREF(__pyx_v_ex);
  4801. __Pyx_GOTREF(__pyx_v_pyparser->_last_error);
  4802. __Pyx_DECREF(__pyx_v_pyparser->_last_error);
  4803. __pyx_v_pyparser->_last_error = __pyx_v_ex;
  4804. /* "httptools/parser/parser.pyx":284
  4805. * except BaseException as ex:
  4806. * pyparser._last_error = ex
  4807. * return -1 # <<<<<<<<<<<<<<
  4808. * else:
  4809. * return 0
  4810. */
  4811. __pyx_r = -1;
  4812. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4813. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4814. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4815. goto __pyx_L13_return;
  4816. }
  4817. /* "httptools/parser/parser.pyx":282
  4818. * try:
  4819. * pyparser._on_header_value(at[:length])
  4820. * except BaseException as ex: # <<<<<<<<<<<<<<
  4821. * pyparser._last_error = ex
  4822. * return -1
  4823. */
  4824. /*finally:*/ {
  4825. __pyx_L13_return: {
  4826. __pyx_t_6 = __pyx_r;
  4827. __Pyx_DECREF(__pyx_v_ex);
  4828. __pyx_v_ex = NULL;
  4829. __pyx_r = __pyx_t_6;
  4830. goto __pyx_L6_except_return;
  4831. }
  4832. }
  4833. }
  4834. goto __pyx_L5_except_error;
  4835. __pyx_L5_except_error:;
  4836. /* "httptools/parser/parser.pyx":280
  4837. * const char *at, size_t length) except -1:
  4838. * cdef HttpParser pyparser = <HttpParser>parser.data
  4839. * try: # <<<<<<<<<<<<<<
  4840. * pyparser._on_header_value(at[:length])
  4841. * except BaseException as ex:
  4842. */
  4843. __Pyx_XGIVEREF(__pyx_t_2);
  4844. __Pyx_XGIVEREF(__pyx_t_3);
  4845. __Pyx_XGIVEREF(__pyx_t_4);
  4846. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  4847. goto __pyx_L1_error;
  4848. __pyx_L6_except_return:;
  4849. __Pyx_XGIVEREF(__pyx_t_2);
  4850. __Pyx_XGIVEREF(__pyx_t_3);
  4851. __Pyx_XGIVEREF(__pyx_t_4);
  4852. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  4853. goto __pyx_L0;
  4854. }
  4855. /* "httptools/parser/parser.pyx":277
  4856. *
  4857. *
  4858. * cdef int cb_on_header_value(cparser.http_parser* parser, # <<<<<<<<<<<<<<
  4859. * const char *at, size_t length) except -1:
  4860. * cdef HttpParser pyparser = <HttpParser>parser.data
  4861. */
  4862. /* function exit code */
  4863. __pyx_L1_error:;
  4864. __Pyx_XDECREF(__pyx_t_1);
  4865. __Pyx_XDECREF(__pyx_t_5);
  4866. __Pyx_XDECREF(__pyx_t_7);
  4867. __Pyx_AddTraceback("httptools.parser.parser.cb_on_header_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4868. __pyx_r = -1;
  4869. __pyx_L0:;
  4870. __Pyx_XDECREF((PyObject *)__pyx_v_pyparser);
  4871. __Pyx_XDECREF(__pyx_v_ex);
  4872. __Pyx_RefNannyFinishContext();
  4873. return __pyx_r;
  4874. }
  4875. /* "httptools/parser/parser.pyx":289
  4876. *
  4877. *
  4878. * cdef int cb_on_headers_complete(cparser.http_parser* parser) except -1: # <<<<<<<<<<<<<<
  4879. * cdef HttpParser pyparser = <HttpParser>parser.data
  4880. * try:
  4881. */
  4882. static int __pyx_f_9httptools_6parser_6parser_cb_on_headers_complete(struct http_parser *__pyx_v_parser) {
  4883. struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_pyparser = 0;
  4884. PyObject *__pyx_v_ex = NULL;
  4885. int __pyx_r;
  4886. __Pyx_RefNannyDeclarations
  4887. PyObject *__pyx_t_1 = NULL;
  4888. PyObject *__pyx_t_2 = NULL;
  4889. PyObject *__pyx_t_3 = NULL;
  4890. PyObject *__pyx_t_4 = NULL;
  4891. int __pyx_t_5;
  4892. int __pyx_t_6;
  4893. PyObject *__pyx_t_7 = NULL;
  4894. PyObject *__pyx_t_8 = NULL;
  4895. __Pyx_RefNannySetupContext("cb_on_headers_complete", 0);
  4896. /* "httptools/parser/parser.pyx":290
  4897. *
  4898. * cdef int cb_on_headers_complete(cparser.http_parser* parser) except -1:
  4899. * cdef HttpParser pyparser = <HttpParser>parser.data # <<<<<<<<<<<<<<
  4900. * try:
  4901. * pyparser._on_headers_complete()
  4902. */
  4903. __pyx_t_1 = ((PyObject *)__pyx_v_parser->data);
  4904. __Pyx_INCREF(__pyx_t_1);
  4905. __pyx_v_pyparser = ((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_t_1);
  4906. __pyx_t_1 = 0;
  4907. /* "httptools/parser/parser.pyx":291
  4908. * cdef int cb_on_headers_complete(cparser.http_parser* parser) except -1:
  4909. * cdef HttpParser pyparser = <HttpParser>parser.data
  4910. * try: # <<<<<<<<<<<<<<
  4911. * pyparser._on_headers_complete()
  4912. * except BaseException as ex:
  4913. */
  4914. {
  4915. __Pyx_PyThreadState_declare
  4916. __Pyx_PyThreadState_assign
  4917. __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
  4918. __Pyx_XGOTREF(__pyx_t_2);
  4919. __Pyx_XGOTREF(__pyx_t_3);
  4920. __Pyx_XGOTREF(__pyx_t_4);
  4921. /*try:*/ {
  4922. /* "httptools/parser/parser.pyx":292
  4923. * cdef HttpParser pyparser = <HttpParser>parser.data
  4924. * try:
  4925. * pyparser._on_headers_complete() # <<<<<<<<<<<<<<
  4926. * except BaseException as ex:
  4927. * pyparser._last_error = ex
  4928. */
  4929. __pyx_t_1 = ((struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser *)__pyx_v_pyparser->__pyx_vtab)->_on_headers_complete(__pyx_v_pyparser); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 292, __pyx_L3_error)
  4930. __Pyx_GOTREF(__pyx_t_1);
  4931. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4932. /* "httptools/parser/parser.pyx":291
  4933. * cdef int cb_on_headers_complete(cparser.http_parser* parser) except -1:
  4934. * cdef HttpParser pyparser = <HttpParser>parser.data
  4935. * try: # <<<<<<<<<<<<<<
  4936. * pyparser._on_headers_complete()
  4937. * except BaseException as ex:
  4938. */
  4939. }
  4940. /* "httptools/parser/parser.pyx":297
  4941. * return -1
  4942. * else:
  4943. * if pyparser._cparser.upgrade: # <<<<<<<<<<<<<<
  4944. * return 1
  4945. * else:
  4946. */
  4947. /*else:*/ {
  4948. __pyx_t_5 = (__pyx_v_pyparser->_cparser->upgrade != 0);
  4949. if (__pyx_t_5) {
  4950. /* "httptools/parser/parser.pyx":298
  4951. * else:
  4952. * if pyparser._cparser.upgrade:
  4953. * return 1 # <<<<<<<<<<<<<<
  4954. * else:
  4955. * return 0
  4956. */
  4957. __pyx_r = 1;
  4958. goto __pyx_L6_except_return;
  4959. /* "httptools/parser/parser.pyx":297
  4960. * return -1
  4961. * else:
  4962. * if pyparser._cparser.upgrade: # <<<<<<<<<<<<<<
  4963. * return 1
  4964. * else:
  4965. */
  4966. }
  4967. /* "httptools/parser/parser.pyx":300
  4968. * return 1
  4969. * else:
  4970. * return 0 # <<<<<<<<<<<<<<
  4971. *
  4972. *
  4973. */
  4974. /*else*/ {
  4975. __pyx_r = 0;
  4976. goto __pyx_L6_except_return;
  4977. }
  4978. }
  4979. __pyx_L3_error:;
  4980. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  4981. /* "httptools/parser/parser.pyx":293
  4982. * try:
  4983. * pyparser._on_headers_complete()
  4984. * except BaseException as ex: # <<<<<<<<<<<<<<
  4985. * pyparser._last_error = ex
  4986. * return -1
  4987. */
  4988. __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_BaseException);
  4989. if (__pyx_t_6) {
  4990. __Pyx_AddTraceback("httptools.parser.parser.cb_on_headers_complete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4991. if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(0, 293, __pyx_L5_except_error)
  4992. __Pyx_GOTREF(__pyx_t_1);
  4993. __Pyx_GOTREF(__pyx_t_7);
  4994. __Pyx_GOTREF(__pyx_t_8);
  4995. __Pyx_INCREF(__pyx_t_7);
  4996. __pyx_v_ex = __pyx_t_7;
  4997. /*try:*/ {
  4998. /* "httptools/parser/parser.pyx":294
  4999. * pyparser._on_headers_complete()
  5000. * except BaseException as ex:
  5001. * pyparser._last_error = ex # <<<<<<<<<<<<<<
  5002. * return -1
  5003. * else:
  5004. */
  5005. __Pyx_INCREF(__pyx_v_ex);
  5006. __Pyx_GIVEREF(__pyx_v_ex);
  5007. __Pyx_GOTREF(__pyx_v_pyparser->_last_error);
  5008. __Pyx_DECREF(__pyx_v_pyparser->_last_error);
  5009. __pyx_v_pyparser->_last_error = __pyx_v_ex;
  5010. /* "httptools/parser/parser.pyx":295
  5011. * except BaseException as ex:
  5012. * pyparser._last_error = ex
  5013. * return -1 # <<<<<<<<<<<<<<
  5014. * else:
  5015. * if pyparser._cparser.upgrade:
  5016. */
  5017. __pyx_r = -1;
  5018. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5019. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5020. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5021. goto __pyx_L14_return;
  5022. }
  5023. /* "httptools/parser/parser.pyx":293
  5024. * try:
  5025. * pyparser._on_headers_complete()
  5026. * except BaseException as ex: # <<<<<<<<<<<<<<
  5027. * pyparser._last_error = ex
  5028. * return -1
  5029. */
  5030. /*finally:*/ {
  5031. __pyx_L14_return: {
  5032. __pyx_t_6 = __pyx_r;
  5033. __Pyx_DECREF(__pyx_v_ex);
  5034. __pyx_v_ex = NULL;
  5035. __pyx_r = __pyx_t_6;
  5036. goto __pyx_L6_except_return;
  5037. }
  5038. }
  5039. }
  5040. goto __pyx_L5_except_error;
  5041. __pyx_L5_except_error:;
  5042. /* "httptools/parser/parser.pyx":291
  5043. * cdef int cb_on_headers_complete(cparser.http_parser* parser) except -1:
  5044. * cdef HttpParser pyparser = <HttpParser>parser.data
  5045. * try: # <<<<<<<<<<<<<<
  5046. * pyparser._on_headers_complete()
  5047. * except BaseException as ex:
  5048. */
  5049. __Pyx_XGIVEREF(__pyx_t_2);
  5050. __Pyx_XGIVEREF(__pyx_t_3);
  5051. __Pyx_XGIVEREF(__pyx_t_4);
  5052. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  5053. goto __pyx_L1_error;
  5054. __pyx_L6_except_return:;
  5055. __Pyx_XGIVEREF(__pyx_t_2);
  5056. __Pyx_XGIVEREF(__pyx_t_3);
  5057. __Pyx_XGIVEREF(__pyx_t_4);
  5058. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  5059. goto __pyx_L0;
  5060. }
  5061. /* "httptools/parser/parser.pyx":289
  5062. *
  5063. *
  5064. * cdef int cb_on_headers_complete(cparser.http_parser* parser) except -1: # <<<<<<<<<<<<<<
  5065. * cdef HttpParser pyparser = <HttpParser>parser.data
  5066. * try:
  5067. */
  5068. /* function exit code */
  5069. __pyx_L1_error:;
  5070. __Pyx_XDECREF(__pyx_t_1);
  5071. __Pyx_XDECREF(__pyx_t_7);
  5072. __Pyx_XDECREF(__pyx_t_8);
  5073. __Pyx_AddTraceback("httptools.parser.parser.cb_on_headers_complete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5074. __pyx_r = -1;
  5075. __pyx_L0:;
  5076. __Pyx_XDECREF((PyObject *)__pyx_v_pyparser);
  5077. __Pyx_XDECREF(__pyx_v_ex);
  5078. __Pyx_RefNannyFinishContext();
  5079. return __pyx_r;
  5080. }
  5081. /* "httptools/parser/parser.pyx":303
  5082. *
  5083. *
  5084. * cdef int cb_on_body(cparser.http_parser* parser, # <<<<<<<<<<<<<<
  5085. * const char *at, size_t length) except -1:
  5086. * cdef HttpParser pyparser = <HttpParser>parser.data
  5087. */
  5088. static int __pyx_f_9httptools_6parser_6parser_cb_on_body(struct http_parser *__pyx_v_parser, char const *__pyx_v_at, size_t __pyx_v_length) {
  5089. struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_pyparser = 0;
  5090. PyObject *__pyx_v_ex = NULL;
  5091. int __pyx_r;
  5092. __Pyx_RefNannyDeclarations
  5093. PyObject *__pyx_t_1 = NULL;
  5094. PyObject *__pyx_t_2 = NULL;
  5095. PyObject *__pyx_t_3 = NULL;
  5096. PyObject *__pyx_t_4 = NULL;
  5097. PyObject *__pyx_t_5 = NULL;
  5098. PyObject *__pyx_t_6 = NULL;
  5099. PyObject *__pyx_t_7 = NULL;
  5100. int __pyx_t_8;
  5101. __Pyx_RefNannySetupContext("cb_on_body", 0);
  5102. /* "httptools/parser/parser.pyx":305
  5103. * cdef int cb_on_body(cparser.http_parser* parser,
  5104. * const char *at, size_t length) except -1:
  5105. * cdef HttpParser pyparser = <HttpParser>parser.data # <<<<<<<<<<<<<<
  5106. * try:
  5107. * pyparser._proto_on_body(at[:length])
  5108. */
  5109. __pyx_t_1 = ((PyObject *)__pyx_v_parser->data);
  5110. __Pyx_INCREF(__pyx_t_1);
  5111. __pyx_v_pyparser = ((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_t_1);
  5112. __pyx_t_1 = 0;
  5113. /* "httptools/parser/parser.pyx":306
  5114. * const char *at, size_t length) except -1:
  5115. * cdef HttpParser pyparser = <HttpParser>parser.data
  5116. * try: # <<<<<<<<<<<<<<
  5117. * pyparser._proto_on_body(at[:length])
  5118. * except BaseException as ex:
  5119. */
  5120. {
  5121. __Pyx_PyThreadState_declare
  5122. __Pyx_PyThreadState_assign
  5123. __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
  5124. __Pyx_XGOTREF(__pyx_t_2);
  5125. __Pyx_XGOTREF(__pyx_t_3);
  5126. __Pyx_XGOTREF(__pyx_t_4);
  5127. /*try:*/ {
  5128. /* "httptools/parser/parser.pyx":307
  5129. * cdef HttpParser pyparser = <HttpParser>parser.data
  5130. * try:
  5131. * pyparser._proto_on_body(at[:length]) # <<<<<<<<<<<<<<
  5132. * except BaseException as ex:
  5133. * pyparser._last_error = ex
  5134. */
  5135. __pyx_t_5 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_at + 0, __pyx_v_length - 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 307, __pyx_L3_error)
  5136. __Pyx_GOTREF(__pyx_t_5);
  5137. __Pyx_INCREF(__pyx_v_pyparser->_proto_on_body);
  5138. __pyx_t_6 = __pyx_v_pyparser->_proto_on_body; __pyx_t_7 = NULL;
  5139. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
  5140. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
  5141. if (likely(__pyx_t_7)) {
  5142. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  5143. __Pyx_INCREF(__pyx_t_7);
  5144. __Pyx_INCREF(function);
  5145. __Pyx_DECREF_SET(__pyx_t_6, function);
  5146. }
  5147. }
  5148. __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5);
  5149. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5150. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5151. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L3_error)
  5152. __Pyx_GOTREF(__pyx_t_1);
  5153. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5154. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5155. /* "httptools/parser/parser.pyx":306
  5156. * const char *at, size_t length) except -1:
  5157. * cdef HttpParser pyparser = <HttpParser>parser.data
  5158. * try: # <<<<<<<<<<<<<<
  5159. * pyparser._proto_on_body(at[:length])
  5160. * except BaseException as ex:
  5161. */
  5162. }
  5163. /* "httptools/parser/parser.pyx":312
  5164. * return -1
  5165. * else:
  5166. * return 0 # <<<<<<<<<<<<<<
  5167. *
  5168. *
  5169. */
  5170. /*else:*/ {
  5171. __pyx_r = 0;
  5172. goto __pyx_L6_except_return;
  5173. }
  5174. __pyx_L3_error:;
  5175. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5176. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  5177. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  5178. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  5179. /* "httptools/parser/parser.pyx":308
  5180. * try:
  5181. * pyparser._proto_on_body(at[:length])
  5182. * except BaseException as ex: # <<<<<<<<<<<<<<
  5183. * pyparser._last_error = ex
  5184. * return -1
  5185. */
  5186. __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_BaseException);
  5187. if (__pyx_t_8) {
  5188. __Pyx_AddTraceback("httptools.parser.parser.cb_on_body", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5189. if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_6, &__pyx_t_5) < 0) __PYX_ERR(0, 308, __pyx_L5_except_error)
  5190. __Pyx_GOTREF(__pyx_t_1);
  5191. __Pyx_GOTREF(__pyx_t_6);
  5192. __Pyx_GOTREF(__pyx_t_5);
  5193. __Pyx_INCREF(__pyx_t_6);
  5194. __pyx_v_ex = __pyx_t_6;
  5195. /*try:*/ {
  5196. /* "httptools/parser/parser.pyx":309
  5197. * pyparser._proto_on_body(at[:length])
  5198. * except BaseException as ex:
  5199. * pyparser._last_error = ex # <<<<<<<<<<<<<<
  5200. * return -1
  5201. * else:
  5202. */
  5203. __Pyx_INCREF(__pyx_v_ex);
  5204. __Pyx_GIVEREF(__pyx_v_ex);
  5205. __Pyx_GOTREF(__pyx_v_pyparser->_last_error);
  5206. __Pyx_DECREF(__pyx_v_pyparser->_last_error);
  5207. __pyx_v_pyparser->_last_error = __pyx_v_ex;
  5208. /* "httptools/parser/parser.pyx":310
  5209. * except BaseException as ex:
  5210. * pyparser._last_error = ex
  5211. * return -1 # <<<<<<<<<<<<<<
  5212. * else:
  5213. * return 0
  5214. */
  5215. __pyx_r = -1;
  5216. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5217. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5218. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5219. goto __pyx_L13_return;
  5220. }
  5221. /* "httptools/parser/parser.pyx":308
  5222. * try:
  5223. * pyparser._proto_on_body(at[:length])
  5224. * except BaseException as ex: # <<<<<<<<<<<<<<
  5225. * pyparser._last_error = ex
  5226. * return -1
  5227. */
  5228. /*finally:*/ {
  5229. __pyx_L13_return: {
  5230. __pyx_t_8 = __pyx_r;
  5231. __Pyx_DECREF(__pyx_v_ex);
  5232. __pyx_v_ex = NULL;
  5233. __pyx_r = __pyx_t_8;
  5234. goto __pyx_L6_except_return;
  5235. }
  5236. }
  5237. }
  5238. goto __pyx_L5_except_error;
  5239. __pyx_L5_except_error:;
  5240. /* "httptools/parser/parser.pyx":306
  5241. * const char *at, size_t length) except -1:
  5242. * cdef HttpParser pyparser = <HttpParser>parser.data
  5243. * try: # <<<<<<<<<<<<<<
  5244. * pyparser._proto_on_body(at[:length])
  5245. * except BaseException as ex:
  5246. */
  5247. __Pyx_XGIVEREF(__pyx_t_2);
  5248. __Pyx_XGIVEREF(__pyx_t_3);
  5249. __Pyx_XGIVEREF(__pyx_t_4);
  5250. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  5251. goto __pyx_L1_error;
  5252. __pyx_L6_except_return:;
  5253. __Pyx_XGIVEREF(__pyx_t_2);
  5254. __Pyx_XGIVEREF(__pyx_t_3);
  5255. __Pyx_XGIVEREF(__pyx_t_4);
  5256. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  5257. goto __pyx_L0;
  5258. }
  5259. /* "httptools/parser/parser.pyx":303
  5260. *
  5261. *
  5262. * cdef int cb_on_body(cparser.http_parser* parser, # <<<<<<<<<<<<<<
  5263. * const char *at, size_t length) except -1:
  5264. * cdef HttpParser pyparser = <HttpParser>parser.data
  5265. */
  5266. /* function exit code */
  5267. __pyx_L1_error:;
  5268. __Pyx_XDECREF(__pyx_t_1);
  5269. __Pyx_XDECREF(__pyx_t_5);
  5270. __Pyx_XDECREF(__pyx_t_6);
  5271. __Pyx_XDECREF(__pyx_t_7);
  5272. __Pyx_AddTraceback("httptools.parser.parser.cb_on_body", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5273. __pyx_r = -1;
  5274. __pyx_L0:;
  5275. __Pyx_XDECREF((PyObject *)__pyx_v_pyparser);
  5276. __Pyx_XDECREF(__pyx_v_ex);
  5277. __Pyx_RefNannyFinishContext();
  5278. return __pyx_r;
  5279. }
  5280. /* "httptools/parser/parser.pyx":315
  5281. *
  5282. *
  5283. * cdef int cb_on_message_complete(cparser.http_parser* parser) except -1: # <<<<<<<<<<<<<<
  5284. * cdef HttpParser pyparser = <HttpParser>parser.data
  5285. * try:
  5286. */
  5287. static int __pyx_f_9httptools_6parser_6parser_cb_on_message_complete(struct http_parser *__pyx_v_parser) {
  5288. struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_pyparser = 0;
  5289. PyObject *__pyx_v_ex = NULL;
  5290. int __pyx_r;
  5291. __Pyx_RefNannyDeclarations
  5292. PyObject *__pyx_t_1 = NULL;
  5293. PyObject *__pyx_t_2 = NULL;
  5294. PyObject *__pyx_t_3 = NULL;
  5295. PyObject *__pyx_t_4 = NULL;
  5296. PyObject *__pyx_t_5 = NULL;
  5297. PyObject *__pyx_t_6 = NULL;
  5298. int __pyx_t_7;
  5299. __Pyx_RefNannySetupContext("cb_on_message_complete", 0);
  5300. /* "httptools/parser/parser.pyx":316
  5301. *
  5302. * cdef int cb_on_message_complete(cparser.http_parser* parser) except -1:
  5303. * cdef HttpParser pyparser = <HttpParser>parser.data # <<<<<<<<<<<<<<
  5304. * try:
  5305. * pyparser._proto_on_message_complete()
  5306. */
  5307. __pyx_t_1 = ((PyObject *)__pyx_v_parser->data);
  5308. __Pyx_INCREF(__pyx_t_1);
  5309. __pyx_v_pyparser = ((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_t_1);
  5310. __pyx_t_1 = 0;
  5311. /* "httptools/parser/parser.pyx":317
  5312. * cdef int cb_on_message_complete(cparser.http_parser* parser) except -1:
  5313. * cdef HttpParser pyparser = <HttpParser>parser.data
  5314. * try: # <<<<<<<<<<<<<<
  5315. * pyparser._proto_on_message_complete()
  5316. * except BaseException as ex:
  5317. */
  5318. {
  5319. __Pyx_PyThreadState_declare
  5320. __Pyx_PyThreadState_assign
  5321. __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
  5322. __Pyx_XGOTREF(__pyx_t_2);
  5323. __Pyx_XGOTREF(__pyx_t_3);
  5324. __Pyx_XGOTREF(__pyx_t_4);
  5325. /*try:*/ {
  5326. /* "httptools/parser/parser.pyx":318
  5327. * cdef HttpParser pyparser = <HttpParser>parser.data
  5328. * try:
  5329. * pyparser._proto_on_message_complete() # <<<<<<<<<<<<<<
  5330. * except BaseException as ex:
  5331. * pyparser._last_error = ex
  5332. */
  5333. __Pyx_INCREF(__pyx_v_pyparser->_proto_on_message_complete);
  5334. __pyx_t_5 = __pyx_v_pyparser->_proto_on_message_complete; __pyx_t_6 = NULL;
  5335. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  5336. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
  5337. if (likely(__pyx_t_6)) {
  5338. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  5339. __Pyx_INCREF(__pyx_t_6);
  5340. __Pyx_INCREF(function);
  5341. __Pyx_DECREF_SET(__pyx_t_5, function);
  5342. }
  5343. }
  5344. __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
  5345. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  5346. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L3_error)
  5347. __Pyx_GOTREF(__pyx_t_1);
  5348. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5349. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5350. /* "httptools/parser/parser.pyx":317
  5351. * cdef int cb_on_message_complete(cparser.http_parser* parser) except -1:
  5352. * cdef HttpParser pyparser = <HttpParser>parser.data
  5353. * try: # <<<<<<<<<<<<<<
  5354. * pyparser._proto_on_message_complete()
  5355. * except BaseException as ex:
  5356. */
  5357. }
  5358. /* "httptools/parser/parser.pyx":323
  5359. * return -1
  5360. * else:
  5361. * return 0 # <<<<<<<<<<<<<<
  5362. *
  5363. *
  5364. */
  5365. /*else:*/ {
  5366. __pyx_r = 0;
  5367. goto __pyx_L6_except_return;
  5368. }
  5369. __pyx_L3_error:;
  5370. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  5371. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  5372. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  5373. /* "httptools/parser/parser.pyx":319
  5374. * try:
  5375. * pyparser._proto_on_message_complete()
  5376. * except BaseException as ex: # <<<<<<<<<<<<<<
  5377. * pyparser._last_error = ex
  5378. * return -1
  5379. */
  5380. __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_BaseException);
  5381. if (__pyx_t_7) {
  5382. __Pyx_AddTraceback("httptools.parser.parser.cb_on_message_complete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5383. if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 319, __pyx_L5_except_error)
  5384. __Pyx_GOTREF(__pyx_t_1);
  5385. __Pyx_GOTREF(__pyx_t_5);
  5386. __Pyx_GOTREF(__pyx_t_6);
  5387. __Pyx_INCREF(__pyx_t_5);
  5388. __pyx_v_ex = __pyx_t_5;
  5389. /*try:*/ {
  5390. /* "httptools/parser/parser.pyx":320
  5391. * pyparser._proto_on_message_complete()
  5392. * except BaseException as ex:
  5393. * pyparser._last_error = ex # <<<<<<<<<<<<<<
  5394. * return -1
  5395. * else:
  5396. */
  5397. __Pyx_INCREF(__pyx_v_ex);
  5398. __Pyx_GIVEREF(__pyx_v_ex);
  5399. __Pyx_GOTREF(__pyx_v_pyparser->_last_error);
  5400. __Pyx_DECREF(__pyx_v_pyparser->_last_error);
  5401. __pyx_v_pyparser->_last_error = __pyx_v_ex;
  5402. /* "httptools/parser/parser.pyx":321
  5403. * except BaseException as ex:
  5404. * pyparser._last_error = ex
  5405. * return -1 # <<<<<<<<<<<<<<
  5406. * else:
  5407. * return 0
  5408. */
  5409. __pyx_r = -1;
  5410. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5411. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5412. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5413. goto __pyx_L13_return;
  5414. }
  5415. /* "httptools/parser/parser.pyx":319
  5416. * try:
  5417. * pyparser._proto_on_message_complete()
  5418. * except BaseException as ex: # <<<<<<<<<<<<<<
  5419. * pyparser._last_error = ex
  5420. * return -1
  5421. */
  5422. /*finally:*/ {
  5423. __pyx_L13_return: {
  5424. __pyx_t_7 = __pyx_r;
  5425. __Pyx_DECREF(__pyx_v_ex);
  5426. __pyx_v_ex = NULL;
  5427. __pyx_r = __pyx_t_7;
  5428. goto __pyx_L6_except_return;
  5429. }
  5430. }
  5431. }
  5432. goto __pyx_L5_except_error;
  5433. __pyx_L5_except_error:;
  5434. /* "httptools/parser/parser.pyx":317
  5435. * cdef int cb_on_message_complete(cparser.http_parser* parser) except -1:
  5436. * cdef HttpParser pyparser = <HttpParser>parser.data
  5437. * try: # <<<<<<<<<<<<<<
  5438. * pyparser._proto_on_message_complete()
  5439. * except BaseException as ex:
  5440. */
  5441. __Pyx_XGIVEREF(__pyx_t_2);
  5442. __Pyx_XGIVEREF(__pyx_t_3);
  5443. __Pyx_XGIVEREF(__pyx_t_4);
  5444. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  5445. goto __pyx_L1_error;
  5446. __pyx_L6_except_return:;
  5447. __Pyx_XGIVEREF(__pyx_t_2);
  5448. __Pyx_XGIVEREF(__pyx_t_3);
  5449. __Pyx_XGIVEREF(__pyx_t_4);
  5450. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  5451. goto __pyx_L0;
  5452. }
  5453. /* "httptools/parser/parser.pyx":315
  5454. *
  5455. *
  5456. * cdef int cb_on_message_complete(cparser.http_parser* parser) except -1: # <<<<<<<<<<<<<<
  5457. * cdef HttpParser pyparser = <HttpParser>parser.data
  5458. * try:
  5459. */
  5460. /* function exit code */
  5461. __pyx_L1_error:;
  5462. __Pyx_XDECREF(__pyx_t_1);
  5463. __Pyx_XDECREF(__pyx_t_5);
  5464. __Pyx_XDECREF(__pyx_t_6);
  5465. __Pyx_AddTraceback("httptools.parser.parser.cb_on_message_complete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5466. __pyx_r = -1;
  5467. __pyx_L0:;
  5468. __Pyx_XDECREF((PyObject *)__pyx_v_pyparser);
  5469. __Pyx_XDECREF(__pyx_v_ex);
  5470. __Pyx_RefNannyFinishContext();
  5471. return __pyx_r;
  5472. }
  5473. /* "httptools/parser/parser.pyx":326
  5474. *
  5475. *
  5476. * cdef int cb_on_chunk_header(cparser.http_parser* parser) except -1: # <<<<<<<<<<<<<<
  5477. * cdef HttpParser pyparser = <HttpParser>parser.data
  5478. * try:
  5479. */
  5480. static int __pyx_f_9httptools_6parser_6parser_cb_on_chunk_header(struct http_parser *__pyx_v_parser) {
  5481. struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_pyparser = 0;
  5482. PyObject *__pyx_v_ex = NULL;
  5483. int __pyx_r;
  5484. __Pyx_RefNannyDeclarations
  5485. PyObject *__pyx_t_1 = NULL;
  5486. PyObject *__pyx_t_2 = NULL;
  5487. PyObject *__pyx_t_3 = NULL;
  5488. PyObject *__pyx_t_4 = NULL;
  5489. int __pyx_t_5;
  5490. PyObject *__pyx_t_6 = NULL;
  5491. PyObject *__pyx_t_7 = NULL;
  5492. __Pyx_RefNannySetupContext("cb_on_chunk_header", 0);
  5493. /* "httptools/parser/parser.pyx":327
  5494. *
  5495. * cdef int cb_on_chunk_header(cparser.http_parser* parser) except -1:
  5496. * cdef HttpParser pyparser = <HttpParser>parser.data # <<<<<<<<<<<<<<
  5497. * try:
  5498. * pyparser._on_chunk_header()
  5499. */
  5500. __pyx_t_1 = ((PyObject *)__pyx_v_parser->data);
  5501. __Pyx_INCREF(__pyx_t_1);
  5502. __pyx_v_pyparser = ((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_t_1);
  5503. __pyx_t_1 = 0;
  5504. /* "httptools/parser/parser.pyx":328
  5505. * cdef int cb_on_chunk_header(cparser.http_parser* parser) except -1:
  5506. * cdef HttpParser pyparser = <HttpParser>parser.data
  5507. * try: # <<<<<<<<<<<<<<
  5508. * pyparser._on_chunk_header()
  5509. * except BaseException as ex:
  5510. */
  5511. {
  5512. __Pyx_PyThreadState_declare
  5513. __Pyx_PyThreadState_assign
  5514. __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
  5515. __Pyx_XGOTREF(__pyx_t_2);
  5516. __Pyx_XGOTREF(__pyx_t_3);
  5517. __Pyx_XGOTREF(__pyx_t_4);
  5518. /*try:*/ {
  5519. /* "httptools/parser/parser.pyx":329
  5520. * cdef HttpParser pyparser = <HttpParser>parser.data
  5521. * try:
  5522. * pyparser._on_chunk_header() # <<<<<<<<<<<<<<
  5523. * except BaseException as ex:
  5524. * pyparser._last_error = ex
  5525. */
  5526. __pyx_t_1 = ((struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser *)__pyx_v_pyparser->__pyx_vtab)->_on_chunk_header(__pyx_v_pyparser); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 329, __pyx_L3_error)
  5527. __Pyx_GOTREF(__pyx_t_1);
  5528. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5529. /* "httptools/parser/parser.pyx":328
  5530. * cdef int cb_on_chunk_header(cparser.http_parser* parser) except -1:
  5531. * cdef HttpParser pyparser = <HttpParser>parser.data
  5532. * try: # <<<<<<<<<<<<<<
  5533. * pyparser._on_chunk_header()
  5534. * except BaseException as ex:
  5535. */
  5536. }
  5537. /* "httptools/parser/parser.pyx":334
  5538. * return -1
  5539. * else:
  5540. * return 0 # <<<<<<<<<<<<<<
  5541. *
  5542. *
  5543. */
  5544. /*else:*/ {
  5545. __pyx_r = 0;
  5546. goto __pyx_L6_except_return;
  5547. }
  5548. __pyx_L3_error:;
  5549. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  5550. /* "httptools/parser/parser.pyx":330
  5551. * try:
  5552. * pyparser._on_chunk_header()
  5553. * except BaseException as ex: # <<<<<<<<<<<<<<
  5554. * pyparser._last_error = ex
  5555. * return -1
  5556. */
  5557. __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_BaseException);
  5558. if (__pyx_t_5) {
  5559. __Pyx_AddTraceback("httptools.parser.parser.cb_on_chunk_header", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5560. if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 330, __pyx_L5_except_error)
  5561. __Pyx_GOTREF(__pyx_t_1);
  5562. __Pyx_GOTREF(__pyx_t_6);
  5563. __Pyx_GOTREF(__pyx_t_7);
  5564. __Pyx_INCREF(__pyx_t_6);
  5565. __pyx_v_ex = __pyx_t_6;
  5566. /*try:*/ {
  5567. /* "httptools/parser/parser.pyx":331
  5568. * pyparser._on_chunk_header()
  5569. * except BaseException as ex:
  5570. * pyparser._last_error = ex # <<<<<<<<<<<<<<
  5571. * return -1
  5572. * else:
  5573. */
  5574. __Pyx_INCREF(__pyx_v_ex);
  5575. __Pyx_GIVEREF(__pyx_v_ex);
  5576. __Pyx_GOTREF(__pyx_v_pyparser->_last_error);
  5577. __Pyx_DECREF(__pyx_v_pyparser->_last_error);
  5578. __pyx_v_pyparser->_last_error = __pyx_v_ex;
  5579. /* "httptools/parser/parser.pyx":332
  5580. * except BaseException as ex:
  5581. * pyparser._last_error = ex
  5582. * return -1 # <<<<<<<<<<<<<<
  5583. * else:
  5584. * return 0
  5585. */
  5586. __pyx_r = -1;
  5587. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5588. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5589. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5590. goto __pyx_L13_return;
  5591. }
  5592. /* "httptools/parser/parser.pyx":330
  5593. * try:
  5594. * pyparser._on_chunk_header()
  5595. * except BaseException as ex: # <<<<<<<<<<<<<<
  5596. * pyparser._last_error = ex
  5597. * return -1
  5598. */
  5599. /*finally:*/ {
  5600. __pyx_L13_return: {
  5601. __pyx_t_5 = __pyx_r;
  5602. __Pyx_DECREF(__pyx_v_ex);
  5603. __pyx_v_ex = NULL;
  5604. __pyx_r = __pyx_t_5;
  5605. goto __pyx_L6_except_return;
  5606. }
  5607. }
  5608. }
  5609. goto __pyx_L5_except_error;
  5610. __pyx_L5_except_error:;
  5611. /* "httptools/parser/parser.pyx":328
  5612. * cdef int cb_on_chunk_header(cparser.http_parser* parser) except -1:
  5613. * cdef HttpParser pyparser = <HttpParser>parser.data
  5614. * try: # <<<<<<<<<<<<<<
  5615. * pyparser._on_chunk_header()
  5616. * except BaseException as ex:
  5617. */
  5618. __Pyx_XGIVEREF(__pyx_t_2);
  5619. __Pyx_XGIVEREF(__pyx_t_3);
  5620. __Pyx_XGIVEREF(__pyx_t_4);
  5621. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  5622. goto __pyx_L1_error;
  5623. __pyx_L6_except_return:;
  5624. __Pyx_XGIVEREF(__pyx_t_2);
  5625. __Pyx_XGIVEREF(__pyx_t_3);
  5626. __Pyx_XGIVEREF(__pyx_t_4);
  5627. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  5628. goto __pyx_L0;
  5629. }
  5630. /* "httptools/parser/parser.pyx":326
  5631. *
  5632. *
  5633. * cdef int cb_on_chunk_header(cparser.http_parser* parser) except -1: # <<<<<<<<<<<<<<
  5634. * cdef HttpParser pyparser = <HttpParser>parser.data
  5635. * try:
  5636. */
  5637. /* function exit code */
  5638. __pyx_L1_error:;
  5639. __Pyx_XDECREF(__pyx_t_1);
  5640. __Pyx_XDECREF(__pyx_t_6);
  5641. __Pyx_XDECREF(__pyx_t_7);
  5642. __Pyx_AddTraceback("httptools.parser.parser.cb_on_chunk_header", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5643. __pyx_r = -1;
  5644. __pyx_L0:;
  5645. __Pyx_XDECREF((PyObject *)__pyx_v_pyparser);
  5646. __Pyx_XDECREF(__pyx_v_ex);
  5647. __Pyx_RefNannyFinishContext();
  5648. return __pyx_r;
  5649. }
  5650. /* "httptools/parser/parser.pyx":337
  5651. *
  5652. *
  5653. * cdef int cb_on_chunk_complete(cparser.http_parser* parser) except -1: # <<<<<<<<<<<<<<
  5654. * cdef HttpParser pyparser = <HttpParser>parser.data
  5655. * try:
  5656. */
  5657. static int __pyx_f_9httptools_6parser_6parser_cb_on_chunk_complete(struct http_parser *__pyx_v_parser) {
  5658. struct __pyx_obj_9httptools_6parser_6parser_HttpParser *__pyx_v_pyparser = 0;
  5659. PyObject *__pyx_v_ex = NULL;
  5660. int __pyx_r;
  5661. __Pyx_RefNannyDeclarations
  5662. PyObject *__pyx_t_1 = NULL;
  5663. PyObject *__pyx_t_2 = NULL;
  5664. PyObject *__pyx_t_3 = NULL;
  5665. PyObject *__pyx_t_4 = NULL;
  5666. int __pyx_t_5;
  5667. PyObject *__pyx_t_6 = NULL;
  5668. PyObject *__pyx_t_7 = NULL;
  5669. __Pyx_RefNannySetupContext("cb_on_chunk_complete", 0);
  5670. /* "httptools/parser/parser.pyx":338
  5671. *
  5672. * cdef int cb_on_chunk_complete(cparser.http_parser* parser) except -1:
  5673. * cdef HttpParser pyparser = <HttpParser>parser.data # <<<<<<<<<<<<<<
  5674. * try:
  5675. * pyparser._on_chunk_complete()
  5676. */
  5677. __pyx_t_1 = ((PyObject *)__pyx_v_parser->data);
  5678. __Pyx_INCREF(__pyx_t_1);
  5679. __pyx_v_pyparser = ((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)__pyx_t_1);
  5680. __pyx_t_1 = 0;
  5681. /* "httptools/parser/parser.pyx":339
  5682. * cdef int cb_on_chunk_complete(cparser.http_parser* parser) except -1:
  5683. * cdef HttpParser pyparser = <HttpParser>parser.data
  5684. * try: # <<<<<<<<<<<<<<
  5685. * pyparser._on_chunk_complete()
  5686. * except BaseException as ex:
  5687. */
  5688. {
  5689. __Pyx_PyThreadState_declare
  5690. __Pyx_PyThreadState_assign
  5691. __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
  5692. __Pyx_XGOTREF(__pyx_t_2);
  5693. __Pyx_XGOTREF(__pyx_t_3);
  5694. __Pyx_XGOTREF(__pyx_t_4);
  5695. /*try:*/ {
  5696. /* "httptools/parser/parser.pyx":340
  5697. * cdef HttpParser pyparser = <HttpParser>parser.data
  5698. * try:
  5699. * pyparser._on_chunk_complete() # <<<<<<<<<<<<<<
  5700. * except BaseException as ex:
  5701. * pyparser._last_error = ex
  5702. */
  5703. __pyx_t_1 = ((struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser *)__pyx_v_pyparser->__pyx_vtab)->_on_chunk_complete(__pyx_v_pyparser); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L3_error)
  5704. __Pyx_GOTREF(__pyx_t_1);
  5705. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5706. /* "httptools/parser/parser.pyx":339
  5707. * cdef int cb_on_chunk_complete(cparser.http_parser* parser) except -1:
  5708. * cdef HttpParser pyparser = <HttpParser>parser.data
  5709. * try: # <<<<<<<<<<<<<<
  5710. * pyparser._on_chunk_complete()
  5711. * except BaseException as ex:
  5712. */
  5713. }
  5714. /* "httptools/parser/parser.pyx":345
  5715. * return -1
  5716. * else:
  5717. * return 0 # <<<<<<<<<<<<<<
  5718. *
  5719. *
  5720. */
  5721. /*else:*/ {
  5722. __pyx_r = 0;
  5723. goto __pyx_L6_except_return;
  5724. }
  5725. __pyx_L3_error:;
  5726. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  5727. /* "httptools/parser/parser.pyx":341
  5728. * try:
  5729. * pyparser._on_chunk_complete()
  5730. * except BaseException as ex: # <<<<<<<<<<<<<<
  5731. * pyparser._last_error = ex
  5732. * return -1
  5733. */
  5734. __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_BaseException);
  5735. if (__pyx_t_5) {
  5736. __Pyx_AddTraceback("httptools.parser.parser.cb_on_chunk_complete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5737. if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 341, __pyx_L5_except_error)
  5738. __Pyx_GOTREF(__pyx_t_1);
  5739. __Pyx_GOTREF(__pyx_t_6);
  5740. __Pyx_GOTREF(__pyx_t_7);
  5741. __Pyx_INCREF(__pyx_t_6);
  5742. __pyx_v_ex = __pyx_t_6;
  5743. /*try:*/ {
  5744. /* "httptools/parser/parser.pyx":342
  5745. * pyparser._on_chunk_complete()
  5746. * except BaseException as ex:
  5747. * pyparser._last_error = ex # <<<<<<<<<<<<<<
  5748. * return -1
  5749. * else:
  5750. */
  5751. __Pyx_INCREF(__pyx_v_ex);
  5752. __Pyx_GIVEREF(__pyx_v_ex);
  5753. __Pyx_GOTREF(__pyx_v_pyparser->_last_error);
  5754. __Pyx_DECREF(__pyx_v_pyparser->_last_error);
  5755. __pyx_v_pyparser->_last_error = __pyx_v_ex;
  5756. /* "httptools/parser/parser.pyx":343
  5757. * except BaseException as ex:
  5758. * pyparser._last_error = ex
  5759. * return -1 # <<<<<<<<<<<<<<
  5760. * else:
  5761. * return 0
  5762. */
  5763. __pyx_r = -1;
  5764. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5765. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5766. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5767. goto __pyx_L13_return;
  5768. }
  5769. /* "httptools/parser/parser.pyx":341
  5770. * try:
  5771. * pyparser._on_chunk_complete()
  5772. * except BaseException as ex: # <<<<<<<<<<<<<<
  5773. * pyparser._last_error = ex
  5774. * return -1
  5775. */
  5776. /*finally:*/ {
  5777. __pyx_L13_return: {
  5778. __pyx_t_5 = __pyx_r;
  5779. __Pyx_DECREF(__pyx_v_ex);
  5780. __pyx_v_ex = NULL;
  5781. __pyx_r = __pyx_t_5;
  5782. goto __pyx_L6_except_return;
  5783. }
  5784. }
  5785. }
  5786. goto __pyx_L5_except_error;
  5787. __pyx_L5_except_error:;
  5788. /* "httptools/parser/parser.pyx":339
  5789. * cdef int cb_on_chunk_complete(cparser.http_parser* parser) except -1:
  5790. * cdef HttpParser pyparser = <HttpParser>parser.data
  5791. * try: # <<<<<<<<<<<<<<
  5792. * pyparser._on_chunk_complete()
  5793. * except BaseException as ex:
  5794. */
  5795. __Pyx_XGIVEREF(__pyx_t_2);
  5796. __Pyx_XGIVEREF(__pyx_t_3);
  5797. __Pyx_XGIVEREF(__pyx_t_4);
  5798. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  5799. goto __pyx_L1_error;
  5800. __pyx_L6_except_return:;
  5801. __Pyx_XGIVEREF(__pyx_t_2);
  5802. __Pyx_XGIVEREF(__pyx_t_3);
  5803. __Pyx_XGIVEREF(__pyx_t_4);
  5804. __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
  5805. goto __pyx_L0;
  5806. }
  5807. /* "httptools/parser/parser.pyx":337
  5808. *
  5809. *
  5810. * cdef int cb_on_chunk_complete(cparser.http_parser* parser) except -1: # <<<<<<<<<<<<<<
  5811. * cdef HttpParser pyparser = <HttpParser>parser.data
  5812. * try:
  5813. */
  5814. /* function exit code */
  5815. __pyx_L1_error:;
  5816. __Pyx_XDECREF(__pyx_t_1);
  5817. __Pyx_XDECREF(__pyx_t_6);
  5818. __Pyx_XDECREF(__pyx_t_7);
  5819. __Pyx_AddTraceback("httptools.parser.parser.cb_on_chunk_complete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5820. __pyx_r = -1;
  5821. __pyx_L0:;
  5822. __Pyx_XDECREF((PyObject *)__pyx_v_pyparser);
  5823. __Pyx_XDECREF(__pyx_v_ex);
  5824. __Pyx_RefNannyFinishContext();
  5825. return __pyx_r;
  5826. }
  5827. /* "httptools/parser/parser.pyx":348
  5828. *
  5829. *
  5830. * cdef parser_error_from_errno(cparser.http_errno errno): # <<<<<<<<<<<<<<
  5831. * cdef bytes desc = cparser.http_errno_description(errno)
  5832. *
  5833. */
  5834. static PyObject *__pyx_f_9httptools_6parser_6parser_parser_error_from_errno(enum http_errno __pyx_v_errno) {
  5835. PyObject *__pyx_v_desc = 0;
  5836. PyObject *__pyx_v_cls = NULL;
  5837. PyObject *__pyx_r = NULL;
  5838. __Pyx_RefNannyDeclarations
  5839. PyObject *__pyx_t_1 = NULL;
  5840. PyObject *__pyx_t_2 = NULL;
  5841. PyObject *__pyx_t_3 = NULL;
  5842. PyObject *__pyx_t_4 = NULL;
  5843. __Pyx_RefNannySetupContext("parser_error_from_errno", 0);
  5844. /* "httptools/parser/parser.pyx":349
  5845. *
  5846. * cdef parser_error_from_errno(cparser.http_errno errno):
  5847. * cdef bytes desc = cparser.http_errno_description(errno) # <<<<<<<<<<<<<<
  5848. *
  5849. * if errno in (cparser.HPE_CB_message_begin,
  5850. */
  5851. __pyx_t_1 = __Pyx_PyBytes_FromString(http_errno_description(__pyx_v_errno)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error)
  5852. __Pyx_GOTREF(__pyx_t_1);
  5853. __pyx_v_desc = ((PyObject*)__pyx_t_1);
  5854. __pyx_t_1 = 0;
  5855. /* "httptools/parser/parser.pyx":351
  5856. * cdef bytes desc = cparser.http_errno_description(errno)
  5857. *
  5858. * if errno in (cparser.HPE_CB_message_begin, # <<<<<<<<<<<<<<
  5859. * cparser.HPE_CB_url,
  5860. * cparser.HPE_CB_header_field,
  5861. */
  5862. switch (__pyx_v_errno) {
  5863. case HPE_CB_message_begin:
  5864. case HPE_CB_url:
  5865. /* "httptools/parser/parser.pyx":352
  5866. *
  5867. * if errno in (cparser.HPE_CB_message_begin,
  5868. * cparser.HPE_CB_url, # <<<<<<<<<<<<<<
  5869. * cparser.HPE_CB_header_field,
  5870. * cparser.HPE_CB_header_value,
  5871. */
  5872. case HPE_CB_header_field:
  5873. /* "httptools/parser/parser.pyx":353
  5874. * if errno in (cparser.HPE_CB_message_begin,
  5875. * cparser.HPE_CB_url,
  5876. * cparser.HPE_CB_header_field, # <<<<<<<<<<<<<<
  5877. * cparser.HPE_CB_header_value,
  5878. * cparser.HPE_CB_headers_complete,
  5879. */
  5880. case HPE_CB_header_value:
  5881. /* "httptools/parser/parser.pyx":354
  5882. * cparser.HPE_CB_url,
  5883. * cparser.HPE_CB_header_field,
  5884. * cparser.HPE_CB_header_value, # <<<<<<<<<<<<<<
  5885. * cparser.HPE_CB_headers_complete,
  5886. * cparser.HPE_CB_body,
  5887. */
  5888. case HPE_CB_headers_complete:
  5889. /* "httptools/parser/parser.pyx":355
  5890. * cparser.HPE_CB_header_field,
  5891. * cparser.HPE_CB_header_value,
  5892. * cparser.HPE_CB_headers_complete, # <<<<<<<<<<<<<<
  5893. * cparser.HPE_CB_body,
  5894. * cparser.HPE_CB_message_complete,
  5895. */
  5896. case HPE_CB_body:
  5897. /* "httptools/parser/parser.pyx":356
  5898. * cparser.HPE_CB_header_value,
  5899. * cparser.HPE_CB_headers_complete,
  5900. * cparser.HPE_CB_body, # <<<<<<<<<<<<<<
  5901. * cparser.HPE_CB_message_complete,
  5902. * cparser.HPE_CB_status,
  5903. */
  5904. case HPE_CB_message_complete:
  5905. /* "httptools/parser/parser.pyx":357
  5906. * cparser.HPE_CB_headers_complete,
  5907. * cparser.HPE_CB_body,
  5908. * cparser.HPE_CB_message_complete, # <<<<<<<<<<<<<<
  5909. * cparser.HPE_CB_status,
  5910. * cparser.HPE_CB_chunk_header,
  5911. */
  5912. case HPE_CB_status:
  5913. /* "httptools/parser/parser.pyx":358
  5914. * cparser.HPE_CB_body,
  5915. * cparser.HPE_CB_message_complete,
  5916. * cparser.HPE_CB_status, # <<<<<<<<<<<<<<
  5917. * cparser.HPE_CB_chunk_header,
  5918. * cparser.HPE_CB_chunk_complete):
  5919. */
  5920. case HPE_CB_chunk_header:
  5921. /* "httptools/parser/parser.pyx":359
  5922. * cparser.HPE_CB_message_complete,
  5923. * cparser.HPE_CB_status,
  5924. * cparser.HPE_CB_chunk_header, # <<<<<<<<<<<<<<
  5925. * cparser.HPE_CB_chunk_complete):
  5926. * cls = HttpParserCallbackError
  5927. */
  5928. case HPE_CB_chunk_complete:
  5929. /* "httptools/parser/parser.pyx":361
  5930. * cparser.HPE_CB_chunk_header,
  5931. * cparser.HPE_CB_chunk_complete):
  5932. * cls = HttpParserCallbackError # <<<<<<<<<<<<<<
  5933. *
  5934. * elif errno == cparser.HPE_INVALID_STATUS:
  5935. */
  5936. __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_HttpParserCallbackError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error)
  5937. __Pyx_GOTREF(__pyx_t_1);
  5938. __pyx_v_cls = __pyx_t_1;
  5939. __pyx_t_1 = 0;
  5940. /* "httptools/parser/parser.pyx":351
  5941. * cdef bytes desc = cparser.http_errno_description(errno)
  5942. *
  5943. * if errno in (cparser.HPE_CB_message_begin, # <<<<<<<<<<<<<<
  5944. * cparser.HPE_CB_url,
  5945. * cparser.HPE_CB_header_field,
  5946. */
  5947. break;
  5948. case HPE_INVALID_STATUS:
  5949. /* "httptools/parser/parser.pyx":364
  5950. *
  5951. * elif errno == cparser.HPE_INVALID_STATUS:
  5952. * cls = HttpParserInvalidStatusError # <<<<<<<<<<<<<<
  5953. *
  5954. * elif errno == cparser.HPE_INVALID_METHOD:
  5955. */
  5956. __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_HttpParserInvalidStatusError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 364, __pyx_L1_error)
  5957. __Pyx_GOTREF(__pyx_t_1);
  5958. __pyx_v_cls = __pyx_t_1;
  5959. __pyx_t_1 = 0;
  5960. /* "httptools/parser/parser.pyx":363
  5961. * cls = HttpParserCallbackError
  5962. *
  5963. * elif errno == cparser.HPE_INVALID_STATUS: # <<<<<<<<<<<<<<
  5964. * cls = HttpParserInvalidStatusError
  5965. *
  5966. */
  5967. break;
  5968. case HPE_INVALID_METHOD:
  5969. /* "httptools/parser/parser.pyx":367
  5970. *
  5971. * elif errno == cparser.HPE_INVALID_METHOD:
  5972. * cls = HttpParserInvalidMethodError # <<<<<<<<<<<<<<
  5973. *
  5974. * elif errno == cparser.HPE_INVALID_URL:
  5975. */
  5976. __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_HttpParserInvalidMethodError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error)
  5977. __Pyx_GOTREF(__pyx_t_1);
  5978. __pyx_v_cls = __pyx_t_1;
  5979. __pyx_t_1 = 0;
  5980. /* "httptools/parser/parser.pyx":366
  5981. * cls = HttpParserInvalidStatusError
  5982. *
  5983. * elif errno == cparser.HPE_INVALID_METHOD: # <<<<<<<<<<<<<<
  5984. * cls = HttpParserInvalidMethodError
  5985. *
  5986. */
  5987. break;
  5988. case HPE_INVALID_URL:
  5989. /* "httptools/parser/parser.pyx":370
  5990. *
  5991. * elif errno == cparser.HPE_INVALID_URL:
  5992. * cls = HttpParserInvalidURLError # <<<<<<<<<<<<<<
  5993. *
  5994. * else:
  5995. */
  5996. __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_HttpParserInvalidURLError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 370, __pyx_L1_error)
  5997. __Pyx_GOTREF(__pyx_t_1);
  5998. __pyx_v_cls = __pyx_t_1;
  5999. __pyx_t_1 = 0;
  6000. /* "httptools/parser/parser.pyx":369
  6001. * cls = HttpParserInvalidMethodError
  6002. *
  6003. * elif errno == cparser.HPE_INVALID_URL: # <<<<<<<<<<<<<<
  6004. * cls = HttpParserInvalidURLError
  6005. *
  6006. */
  6007. break;
  6008. default:
  6009. /* "httptools/parser/parser.pyx":373
  6010. *
  6011. * else:
  6012. * cls = HttpParserError # <<<<<<<<<<<<<<
  6013. *
  6014. * return cls(desc.decode('latin-1'))
  6015. */
  6016. __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_HttpParserError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 373, __pyx_L1_error)
  6017. __Pyx_GOTREF(__pyx_t_1);
  6018. __pyx_v_cls = __pyx_t_1;
  6019. __pyx_t_1 = 0;
  6020. break;
  6021. }
  6022. /* "httptools/parser/parser.pyx":375
  6023. * cls = HttpParserError
  6024. *
  6025. * return cls(desc.decode('latin-1')) # <<<<<<<<<<<<<<
  6026. *
  6027. *
  6028. */
  6029. __Pyx_XDECREF(__pyx_r);
  6030. __pyx_t_2 = __Pyx_decode_bytes(__pyx_v_desc, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeLatin1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 375, __pyx_L1_error)
  6031. __Pyx_GOTREF(__pyx_t_2);
  6032. __Pyx_INCREF(__pyx_v_cls);
  6033. __pyx_t_3 = __pyx_v_cls; __pyx_t_4 = NULL;
  6034. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  6035. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  6036. if (likely(__pyx_t_4)) {
  6037. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  6038. __Pyx_INCREF(__pyx_t_4);
  6039. __Pyx_INCREF(function);
  6040. __Pyx_DECREF_SET(__pyx_t_3, function);
  6041. }
  6042. }
  6043. __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
  6044. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  6045. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6046. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 375, __pyx_L1_error)
  6047. __Pyx_GOTREF(__pyx_t_1);
  6048. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6049. __pyx_r = __pyx_t_1;
  6050. __pyx_t_1 = 0;
  6051. goto __pyx_L0;
  6052. /* "httptools/parser/parser.pyx":348
  6053. *
  6054. *
  6055. * cdef parser_error_from_errno(cparser.http_errno errno): # <<<<<<<<<<<<<<
  6056. * cdef bytes desc = cparser.http_errno_description(errno)
  6057. *
  6058. */
  6059. /* function exit code */
  6060. __pyx_L1_error:;
  6061. __Pyx_XDECREF(__pyx_t_1);
  6062. __Pyx_XDECREF(__pyx_t_2);
  6063. __Pyx_XDECREF(__pyx_t_3);
  6064. __Pyx_XDECREF(__pyx_t_4);
  6065. __Pyx_AddTraceback("httptools.parser.parser.parser_error_from_errno", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6066. __pyx_r = 0;
  6067. __pyx_L0:;
  6068. __Pyx_XDECREF(__pyx_v_desc);
  6069. __Pyx_XDECREF(__pyx_v_cls);
  6070. __Pyx_XGIVEREF(__pyx_r);
  6071. __Pyx_RefNannyFinishContext();
  6072. return __pyx_r;
  6073. }
  6074. /* "httptools/parser/parser.pyx":388
  6075. * cdef readonly bytes userinfo
  6076. *
  6077. * def __cinit__(self, bytes schema, bytes host, object port, bytes path, # <<<<<<<<<<<<<<
  6078. * bytes query, bytes fragment, bytes userinfo):
  6079. *
  6080. */
  6081. /* Python wrapper */
  6082. static int __pyx_pw_9httptools_6parser_6parser_3URL_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  6083. static int __pyx_pw_9httptools_6parser_6parser_3URL_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  6084. PyObject *__pyx_v_schema = 0;
  6085. PyObject *__pyx_v_host = 0;
  6086. PyObject *__pyx_v_port = 0;
  6087. PyObject *__pyx_v_path = 0;
  6088. PyObject *__pyx_v_query = 0;
  6089. PyObject *__pyx_v_fragment = 0;
  6090. PyObject *__pyx_v_userinfo = 0;
  6091. int __pyx_r;
  6092. __Pyx_RefNannyDeclarations
  6093. __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  6094. {
  6095. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_schema,&__pyx_n_s_host,&__pyx_n_s_port,&__pyx_n_s_path,&__pyx_n_s_query,&__pyx_n_s_fragment,&__pyx_n_s_userinfo,0};
  6096. PyObject* values[7] = {0,0,0,0,0,0,0};
  6097. if (unlikely(__pyx_kwds)) {
  6098. Py_ssize_t kw_args;
  6099. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  6100. switch (pos_args) {
  6101. case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
  6102. CYTHON_FALLTHROUGH;
  6103. case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
  6104. CYTHON_FALLTHROUGH;
  6105. case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
  6106. CYTHON_FALLTHROUGH;
  6107. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  6108. CYTHON_FALLTHROUGH;
  6109. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6110. CYTHON_FALLTHROUGH;
  6111. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6112. CYTHON_FALLTHROUGH;
  6113. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6114. CYTHON_FALLTHROUGH;
  6115. case 0: break;
  6116. default: goto __pyx_L5_argtuple_error;
  6117. }
  6118. kw_args = PyDict_Size(__pyx_kwds);
  6119. switch (pos_args) {
  6120. case 0:
  6121. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_schema)) != 0)) kw_args--;
  6122. else goto __pyx_L5_argtuple_error;
  6123. CYTHON_FALLTHROUGH;
  6124. case 1:
  6125. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_host)) != 0)) kw_args--;
  6126. else {
  6127. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 1); __PYX_ERR(0, 388, __pyx_L3_error)
  6128. }
  6129. CYTHON_FALLTHROUGH;
  6130. case 2:
  6131. if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_port)) != 0)) kw_args--;
  6132. else {
  6133. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 2); __PYX_ERR(0, 388, __pyx_L3_error)
  6134. }
  6135. CYTHON_FALLTHROUGH;
  6136. case 3:
  6137. if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--;
  6138. else {
  6139. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 3); __PYX_ERR(0, 388, __pyx_L3_error)
  6140. }
  6141. CYTHON_FALLTHROUGH;
  6142. case 4:
  6143. if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_query)) != 0)) kw_args--;
  6144. else {
  6145. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 4); __PYX_ERR(0, 388, __pyx_L3_error)
  6146. }
  6147. CYTHON_FALLTHROUGH;
  6148. case 5:
  6149. if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fragment)) != 0)) kw_args--;
  6150. else {
  6151. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 5); __PYX_ERR(0, 388, __pyx_L3_error)
  6152. }
  6153. CYTHON_FALLTHROUGH;
  6154. case 6:
  6155. if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_userinfo)) != 0)) kw_args--;
  6156. else {
  6157. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 6); __PYX_ERR(0, 388, __pyx_L3_error)
  6158. }
  6159. }
  6160. if (unlikely(kw_args > 0)) {
  6161. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 388, __pyx_L3_error)
  6162. }
  6163. } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
  6164. goto __pyx_L5_argtuple_error;
  6165. } else {
  6166. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6167. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6168. values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6169. values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  6170. values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
  6171. values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
  6172. values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
  6173. }
  6174. __pyx_v_schema = ((PyObject*)values[0]);
  6175. __pyx_v_host = ((PyObject*)values[1]);
  6176. __pyx_v_port = values[2];
  6177. __pyx_v_path = ((PyObject*)values[3]);
  6178. __pyx_v_query = ((PyObject*)values[4]);
  6179. __pyx_v_fragment = ((PyObject*)values[5]);
  6180. __pyx_v_userinfo = ((PyObject*)values[6]);
  6181. }
  6182. goto __pyx_L4_argument_unpacking_done;
  6183. __pyx_L5_argtuple_error:;
  6184. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 388, __pyx_L3_error)
  6185. __pyx_L3_error:;
  6186. __Pyx_AddTraceback("httptools.parser.parser.URL.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6187. __Pyx_RefNannyFinishContext();
  6188. return -1;
  6189. __pyx_L4_argument_unpacking_done:;
  6190. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_schema), (&PyBytes_Type), 1, "schema", 1))) __PYX_ERR(0, 388, __pyx_L1_error)
  6191. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_host), (&PyBytes_Type), 1, "host", 1))) __PYX_ERR(0, 388, __pyx_L1_error)
  6192. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_path), (&PyBytes_Type), 1, "path", 1))) __PYX_ERR(0, 388, __pyx_L1_error)
  6193. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_query), (&PyBytes_Type), 1, "query", 1))) __PYX_ERR(0, 389, __pyx_L1_error)
  6194. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fragment), (&PyBytes_Type), 1, "fragment", 1))) __PYX_ERR(0, 389, __pyx_L1_error)
  6195. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_userinfo), (&PyBytes_Type), 1, "userinfo", 1))) __PYX_ERR(0, 389, __pyx_L1_error)
  6196. __pyx_r = __pyx_pf_9httptools_6parser_6parser_3URL___cinit__(((struct __pyx_obj_9httptools_6parser_6parser_URL *)__pyx_v_self), __pyx_v_schema, __pyx_v_host, __pyx_v_port, __pyx_v_path, __pyx_v_query, __pyx_v_fragment, __pyx_v_userinfo);
  6197. /* function exit code */
  6198. goto __pyx_L0;
  6199. __pyx_L1_error:;
  6200. __pyx_r = -1;
  6201. __pyx_L0:;
  6202. __Pyx_RefNannyFinishContext();
  6203. return __pyx_r;
  6204. }
  6205. static int __pyx_pf_9httptools_6parser_6parser_3URL___cinit__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self, PyObject *__pyx_v_schema, PyObject *__pyx_v_host, PyObject *__pyx_v_port, PyObject *__pyx_v_path, PyObject *__pyx_v_query, PyObject *__pyx_v_fragment, PyObject *__pyx_v_userinfo) {
  6206. int __pyx_r;
  6207. __Pyx_RefNannyDeclarations
  6208. __Pyx_RefNannySetupContext("__cinit__", 0);
  6209. /* "httptools/parser/parser.pyx":391
  6210. * bytes query, bytes fragment, bytes userinfo):
  6211. *
  6212. * self.schema = schema # <<<<<<<<<<<<<<
  6213. * self.host = host
  6214. * self.port = port
  6215. */
  6216. __Pyx_INCREF(__pyx_v_schema);
  6217. __Pyx_GIVEREF(__pyx_v_schema);
  6218. __Pyx_GOTREF(__pyx_v_self->schema);
  6219. __Pyx_DECREF(__pyx_v_self->schema);
  6220. __pyx_v_self->schema = __pyx_v_schema;
  6221. /* "httptools/parser/parser.pyx":392
  6222. *
  6223. * self.schema = schema
  6224. * self.host = host # <<<<<<<<<<<<<<
  6225. * self.port = port
  6226. * self.path = path
  6227. */
  6228. __Pyx_INCREF(__pyx_v_host);
  6229. __Pyx_GIVEREF(__pyx_v_host);
  6230. __Pyx_GOTREF(__pyx_v_self->host);
  6231. __Pyx_DECREF(__pyx_v_self->host);
  6232. __pyx_v_self->host = __pyx_v_host;
  6233. /* "httptools/parser/parser.pyx":393
  6234. * self.schema = schema
  6235. * self.host = host
  6236. * self.port = port # <<<<<<<<<<<<<<
  6237. * self.path = path
  6238. * self.query = query
  6239. */
  6240. __Pyx_INCREF(__pyx_v_port);
  6241. __Pyx_GIVEREF(__pyx_v_port);
  6242. __Pyx_GOTREF(__pyx_v_self->port);
  6243. __Pyx_DECREF(__pyx_v_self->port);
  6244. __pyx_v_self->port = __pyx_v_port;
  6245. /* "httptools/parser/parser.pyx":394
  6246. * self.host = host
  6247. * self.port = port
  6248. * self.path = path # <<<<<<<<<<<<<<
  6249. * self.query = query
  6250. * self.fragment = fragment
  6251. */
  6252. __Pyx_INCREF(__pyx_v_path);
  6253. __Pyx_GIVEREF(__pyx_v_path);
  6254. __Pyx_GOTREF(__pyx_v_self->path);
  6255. __Pyx_DECREF(__pyx_v_self->path);
  6256. __pyx_v_self->path = __pyx_v_path;
  6257. /* "httptools/parser/parser.pyx":395
  6258. * self.port = port
  6259. * self.path = path
  6260. * self.query = query # <<<<<<<<<<<<<<
  6261. * self.fragment = fragment
  6262. * self.userinfo = userinfo
  6263. */
  6264. __Pyx_INCREF(__pyx_v_query);
  6265. __Pyx_GIVEREF(__pyx_v_query);
  6266. __Pyx_GOTREF(__pyx_v_self->query);
  6267. __Pyx_DECREF(__pyx_v_self->query);
  6268. __pyx_v_self->query = __pyx_v_query;
  6269. /* "httptools/parser/parser.pyx":396
  6270. * self.path = path
  6271. * self.query = query
  6272. * self.fragment = fragment # <<<<<<<<<<<<<<
  6273. * self.userinfo = userinfo
  6274. *
  6275. */
  6276. __Pyx_INCREF(__pyx_v_fragment);
  6277. __Pyx_GIVEREF(__pyx_v_fragment);
  6278. __Pyx_GOTREF(__pyx_v_self->fragment);
  6279. __Pyx_DECREF(__pyx_v_self->fragment);
  6280. __pyx_v_self->fragment = __pyx_v_fragment;
  6281. /* "httptools/parser/parser.pyx":397
  6282. * self.query = query
  6283. * self.fragment = fragment
  6284. * self.userinfo = userinfo # <<<<<<<<<<<<<<
  6285. *
  6286. * def __repr__(self):
  6287. */
  6288. __Pyx_INCREF(__pyx_v_userinfo);
  6289. __Pyx_GIVEREF(__pyx_v_userinfo);
  6290. __Pyx_GOTREF(__pyx_v_self->userinfo);
  6291. __Pyx_DECREF(__pyx_v_self->userinfo);
  6292. __pyx_v_self->userinfo = __pyx_v_userinfo;
  6293. /* "httptools/parser/parser.pyx":388
  6294. * cdef readonly bytes userinfo
  6295. *
  6296. * def __cinit__(self, bytes schema, bytes host, object port, bytes path, # <<<<<<<<<<<<<<
  6297. * bytes query, bytes fragment, bytes userinfo):
  6298. *
  6299. */
  6300. /* function exit code */
  6301. __pyx_r = 0;
  6302. __Pyx_RefNannyFinishContext();
  6303. return __pyx_r;
  6304. }
  6305. /* "httptools/parser/parser.pyx":399
  6306. * self.userinfo = userinfo
  6307. *
  6308. * def __repr__(self): # <<<<<<<<<<<<<<
  6309. * return ('<URL schema: {!r}, host: {!r}, port: {!r}, path: {!r}, '
  6310. * 'query: {!r}, fragment: {!r}, userinfo: {!r}>'
  6311. */
  6312. /* Python wrapper */
  6313. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_3__repr__(PyObject *__pyx_v_self); /*proto*/
  6314. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_3__repr__(PyObject *__pyx_v_self) {
  6315. PyObject *__pyx_r = 0;
  6316. __Pyx_RefNannyDeclarations
  6317. __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  6318. __pyx_r = __pyx_pf_9httptools_6parser_6parser_3URL_2__repr__(((struct __pyx_obj_9httptools_6parser_6parser_URL *)__pyx_v_self));
  6319. /* function exit code */
  6320. __Pyx_RefNannyFinishContext();
  6321. return __pyx_r;
  6322. }
  6323. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_2__repr__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self) {
  6324. PyObject *__pyx_r = NULL;
  6325. __Pyx_RefNannyDeclarations
  6326. PyObject *__pyx_t_1 = NULL;
  6327. PyObject *__pyx_t_2 = NULL;
  6328. PyObject *__pyx_t_3 = NULL;
  6329. int __pyx_t_4;
  6330. PyObject *__pyx_t_5 = NULL;
  6331. __Pyx_RefNannySetupContext("__repr__", 0);
  6332. /* "httptools/parser/parser.pyx":400
  6333. *
  6334. * def __repr__(self):
  6335. * return ('<URL schema: {!r}, host: {!r}, port: {!r}, path: {!r}, ' # <<<<<<<<<<<<<<
  6336. * 'query: {!r}, fragment: {!r}, userinfo: {!r}>'
  6337. * .format(self.schema, self.host, self.port, self.path,
  6338. */
  6339. __Pyx_XDECREF(__pyx_r);
  6340. /* "httptools/parser/parser.pyx":402
  6341. * return ('<URL schema: {!r}, host: {!r}, port: {!r}, path: {!r}, '
  6342. * 'query: {!r}, fragment: {!r}, userinfo: {!r}>'
  6343. * .format(self.schema, self.host, self.port, self.path, # <<<<<<<<<<<<<<
  6344. * self.query, self.fragment, self.userinfo))
  6345. *
  6346. */
  6347. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_URL_schema_r_host_r_port_r_path, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __pyx_L1_error)
  6348. __Pyx_GOTREF(__pyx_t_2);
  6349. /* "httptools/parser/parser.pyx":403
  6350. * 'query: {!r}, fragment: {!r}, userinfo: {!r}>'
  6351. * .format(self.schema, self.host, self.port, self.path,
  6352. * self.query, self.fragment, self.userinfo)) # <<<<<<<<<<<<<<
  6353. *
  6354. *
  6355. */
  6356. __pyx_t_3 = NULL;
  6357. __pyx_t_4 = 0;
  6358. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  6359. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  6360. if (likely(__pyx_t_3)) {
  6361. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  6362. __Pyx_INCREF(__pyx_t_3);
  6363. __Pyx_INCREF(function);
  6364. __Pyx_DECREF_SET(__pyx_t_2, function);
  6365. __pyx_t_4 = 1;
  6366. }
  6367. }
  6368. #if CYTHON_FAST_PYCALL
  6369. if (PyFunction_Check(__pyx_t_2)) {
  6370. PyObject *__pyx_temp[8] = {__pyx_t_3, __pyx_v_self->schema, __pyx_v_self->host, __pyx_v_self->port, __pyx_v_self->path, __pyx_v_self->query, __pyx_v_self->fragment, __pyx_v_self->userinfo};
  6371. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 7+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __pyx_L1_error)
  6372. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  6373. __Pyx_GOTREF(__pyx_t_1);
  6374. } else
  6375. #endif
  6376. #if CYTHON_FAST_PYCCALL
  6377. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  6378. PyObject *__pyx_temp[8] = {__pyx_t_3, __pyx_v_self->schema, __pyx_v_self->host, __pyx_v_self->port, __pyx_v_self->path, __pyx_v_self->query, __pyx_v_self->fragment, __pyx_v_self->userinfo};
  6379. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 7+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __pyx_L1_error)
  6380. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  6381. __Pyx_GOTREF(__pyx_t_1);
  6382. } else
  6383. #endif
  6384. {
  6385. __pyx_t_5 = PyTuple_New(7+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 402, __pyx_L1_error)
  6386. __Pyx_GOTREF(__pyx_t_5);
  6387. if (__pyx_t_3) {
  6388. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  6389. }
  6390. __Pyx_INCREF(__pyx_v_self->schema);
  6391. __Pyx_GIVEREF(__pyx_v_self->schema);
  6392. PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_self->schema);
  6393. __Pyx_INCREF(__pyx_v_self->host);
  6394. __Pyx_GIVEREF(__pyx_v_self->host);
  6395. PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_self->host);
  6396. __Pyx_INCREF(__pyx_v_self->port);
  6397. __Pyx_GIVEREF(__pyx_v_self->port);
  6398. PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_self->port);
  6399. __Pyx_INCREF(__pyx_v_self->path);
  6400. __Pyx_GIVEREF(__pyx_v_self->path);
  6401. PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_v_self->path);
  6402. __Pyx_INCREF(__pyx_v_self->query);
  6403. __Pyx_GIVEREF(__pyx_v_self->query);
  6404. PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_4, __pyx_v_self->query);
  6405. __Pyx_INCREF(__pyx_v_self->fragment);
  6406. __Pyx_GIVEREF(__pyx_v_self->fragment);
  6407. PyTuple_SET_ITEM(__pyx_t_5, 5+__pyx_t_4, __pyx_v_self->fragment);
  6408. __Pyx_INCREF(__pyx_v_self->userinfo);
  6409. __Pyx_GIVEREF(__pyx_v_self->userinfo);
  6410. PyTuple_SET_ITEM(__pyx_t_5, 6+__pyx_t_4, __pyx_v_self->userinfo);
  6411. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __pyx_L1_error)
  6412. __Pyx_GOTREF(__pyx_t_1);
  6413. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6414. }
  6415. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6416. __pyx_r = __pyx_t_1;
  6417. __pyx_t_1 = 0;
  6418. goto __pyx_L0;
  6419. /* "httptools/parser/parser.pyx":399
  6420. * self.userinfo = userinfo
  6421. *
  6422. * def __repr__(self): # <<<<<<<<<<<<<<
  6423. * return ('<URL schema: {!r}, host: {!r}, port: {!r}, path: {!r}, '
  6424. * 'query: {!r}, fragment: {!r}, userinfo: {!r}>'
  6425. */
  6426. /* function exit code */
  6427. __pyx_L1_error:;
  6428. __Pyx_XDECREF(__pyx_t_1);
  6429. __Pyx_XDECREF(__pyx_t_2);
  6430. __Pyx_XDECREF(__pyx_t_3);
  6431. __Pyx_XDECREF(__pyx_t_5);
  6432. __Pyx_AddTraceback("httptools.parser.parser.URL.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6433. __pyx_r = NULL;
  6434. __pyx_L0:;
  6435. __Pyx_XGIVEREF(__pyx_r);
  6436. __Pyx_RefNannyFinishContext();
  6437. return __pyx_r;
  6438. }
  6439. /* "httptools/parser/parser.pyx":380
  6440. * @cython.freelist(250)
  6441. * cdef class URL:
  6442. * cdef readonly bytes schema # <<<<<<<<<<<<<<
  6443. * cdef readonly bytes host
  6444. * cdef readonly object port
  6445. */
  6446. /* Python wrapper */
  6447. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_6schema_1__get__(PyObject *__pyx_v_self); /*proto*/
  6448. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_6schema_1__get__(PyObject *__pyx_v_self) {
  6449. PyObject *__pyx_r = 0;
  6450. __Pyx_RefNannyDeclarations
  6451. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  6452. __pyx_r = __pyx_pf_9httptools_6parser_6parser_3URL_6schema___get__(((struct __pyx_obj_9httptools_6parser_6parser_URL *)__pyx_v_self));
  6453. /* function exit code */
  6454. __Pyx_RefNannyFinishContext();
  6455. return __pyx_r;
  6456. }
  6457. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_6schema___get__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self) {
  6458. PyObject *__pyx_r = NULL;
  6459. __Pyx_RefNannyDeclarations
  6460. __Pyx_RefNannySetupContext("__get__", 0);
  6461. __Pyx_XDECREF(__pyx_r);
  6462. __Pyx_INCREF(__pyx_v_self->schema);
  6463. __pyx_r = __pyx_v_self->schema;
  6464. goto __pyx_L0;
  6465. /* function exit code */
  6466. __pyx_L0:;
  6467. __Pyx_XGIVEREF(__pyx_r);
  6468. __Pyx_RefNannyFinishContext();
  6469. return __pyx_r;
  6470. }
  6471. /* "httptools/parser/parser.pyx":381
  6472. * cdef class URL:
  6473. * cdef readonly bytes schema
  6474. * cdef readonly bytes host # <<<<<<<<<<<<<<
  6475. * cdef readonly object port
  6476. * cdef readonly bytes path
  6477. */
  6478. /* Python wrapper */
  6479. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_4host_1__get__(PyObject *__pyx_v_self); /*proto*/
  6480. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_4host_1__get__(PyObject *__pyx_v_self) {
  6481. PyObject *__pyx_r = 0;
  6482. __Pyx_RefNannyDeclarations
  6483. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  6484. __pyx_r = __pyx_pf_9httptools_6parser_6parser_3URL_4host___get__(((struct __pyx_obj_9httptools_6parser_6parser_URL *)__pyx_v_self));
  6485. /* function exit code */
  6486. __Pyx_RefNannyFinishContext();
  6487. return __pyx_r;
  6488. }
  6489. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_4host___get__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self) {
  6490. PyObject *__pyx_r = NULL;
  6491. __Pyx_RefNannyDeclarations
  6492. __Pyx_RefNannySetupContext("__get__", 0);
  6493. __Pyx_XDECREF(__pyx_r);
  6494. __Pyx_INCREF(__pyx_v_self->host);
  6495. __pyx_r = __pyx_v_self->host;
  6496. goto __pyx_L0;
  6497. /* function exit code */
  6498. __pyx_L0:;
  6499. __Pyx_XGIVEREF(__pyx_r);
  6500. __Pyx_RefNannyFinishContext();
  6501. return __pyx_r;
  6502. }
  6503. /* "httptools/parser/parser.pyx":382
  6504. * cdef readonly bytes schema
  6505. * cdef readonly bytes host
  6506. * cdef readonly object port # <<<<<<<<<<<<<<
  6507. * cdef readonly bytes path
  6508. * cdef readonly bytes query
  6509. */
  6510. /* Python wrapper */
  6511. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_4port_1__get__(PyObject *__pyx_v_self); /*proto*/
  6512. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_4port_1__get__(PyObject *__pyx_v_self) {
  6513. PyObject *__pyx_r = 0;
  6514. __Pyx_RefNannyDeclarations
  6515. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  6516. __pyx_r = __pyx_pf_9httptools_6parser_6parser_3URL_4port___get__(((struct __pyx_obj_9httptools_6parser_6parser_URL *)__pyx_v_self));
  6517. /* function exit code */
  6518. __Pyx_RefNannyFinishContext();
  6519. return __pyx_r;
  6520. }
  6521. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_4port___get__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self) {
  6522. PyObject *__pyx_r = NULL;
  6523. __Pyx_RefNannyDeclarations
  6524. __Pyx_RefNannySetupContext("__get__", 0);
  6525. __Pyx_XDECREF(__pyx_r);
  6526. __Pyx_INCREF(__pyx_v_self->port);
  6527. __pyx_r = __pyx_v_self->port;
  6528. goto __pyx_L0;
  6529. /* function exit code */
  6530. __pyx_L0:;
  6531. __Pyx_XGIVEREF(__pyx_r);
  6532. __Pyx_RefNannyFinishContext();
  6533. return __pyx_r;
  6534. }
  6535. /* "httptools/parser/parser.pyx":383
  6536. * cdef readonly bytes host
  6537. * cdef readonly object port
  6538. * cdef readonly bytes path # <<<<<<<<<<<<<<
  6539. * cdef readonly bytes query
  6540. * cdef readonly bytes fragment
  6541. */
  6542. /* Python wrapper */
  6543. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_4path_1__get__(PyObject *__pyx_v_self); /*proto*/
  6544. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_4path_1__get__(PyObject *__pyx_v_self) {
  6545. PyObject *__pyx_r = 0;
  6546. __Pyx_RefNannyDeclarations
  6547. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  6548. __pyx_r = __pyx_pf_9httptools_6parser_6parser_3URL_4path___get__(((struct __pyx_obj_9httptools_6parser_6parser_URL *)__pyx_v_self));
  6549. /* function exit code */
  6550. __Pyx_RefNannyFinishContext();
  6551. return __pyx_r;
  6552. }
  6553. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_4path___get__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self) {
  6554. PyObject *__pyx_r = NULL;
  6555. __Pyx_RefNannyDeclarations
  6556. __Pyx_RefNannySetupContext("__get__", 0);
  6557. __Pyx_XDECREF(__pyx_r);
  6558. __Pyx_INCREF(__pyx_v_self->path);
  6559. __pyx_r = __pyx_v_self->path;
  6560. goto __pyx_L0;
  6561. /* function exit code */
  6562. __pyx_L0:;
  6563. __Pyx_XGIVEREF(__pyx_r);
  6564. __Pyx_RefNannyFinishContext();
  6565. return __pyx_r;
  6566. }
  6567. /* "httptools/parser/parser.pyx":384
  6568. * cdef readonly object port
  6569. * cdef readonly bytes path
  6570. * cdef readonly bytes query # <<<<<<<<<<<<<<
  6571. * cdef readonly bytes fragment
  6572. * cdef readonly bytes userinfo
  6573. */
  6574. /* Python wrapper */
  6575. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_5query_1__get__(PyObject *__pyx_v_self); /*proto*/
  6576. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_5query_1__get__(PyObject *__pyx_v_self) {
  6577. PyObject *__pyx_r = 0;
  6578. __Pyx_RefNannyDeclarations
  6579. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  6580. __pyx_r = __pyx_pf_9httptools_6parser_6parser_3URL_5query___get__(((struct __pyx_obj_9httptools_6parser_6parser_URL *)__pyx_v_self));
  6581. /* function exit code */
  6582. __Pyx_RefNannyFinishContext();
  6583. return __pyx_r;
  6584. }
  6585. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_5query___get__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self) {
  6586. PyObject *__pyx_r = NULL;
  6587. __Pyx_RefNannyDeclarations
  6588. __Pyx_RefNannySetupContext("__get__", 0);
  6589. __Pyx_XDECREF(__pyx_r);
  6590. __Pyx_INCREF(__pyx_v_self->query);
  6591. __pyx_r = __pyx_v_self->query;
  6592. goto __pyx_L0;
  6593. /* function exit code */
  6594. __pyx_L0:;
  6595. __Pyx_XGIVEREF(__pyx_r);
  6596. __Pyx_RefNannyFinishContext();
  6597. return __pyx_r;
  6598. }
  6599. /* "httptools/parser/parser.pyx":385
  6600. * cdef readonly bytes path
  6601. * cdef readonly bytes query
  6602. * cdef readonly bytes fragment # <<<<<<<<<<<<<<
  6603. * cdef readonly bytes userinfo
  6604. *
  6605. */
  6606. /* Python wrapper */
  6607. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_8fragment_1__get__(PyObject *__pyx_v_self); /*proto*/
  6608. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_8fragment_1__get__(PyObject *__pyx_v_self) {
  6609. PyObject *__pyx_r = 0;
  6610. __Pyx_RefNannyDeclarations
  6611. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  6612. __pyx_r = __pyx_pf_9httptools_6parser_6parser_3URL_8fragment___get__(((struct __pyx_obj_9httptools_6parser_6parser_URL *)__pyx_v_self));
  6613. /* function exit code */
  6614. __Pyx_RefNannyFinishContext();
  6615. return __pyx_r;
  6616. }
  6617. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_8fragment___get__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self) {
  6618. PyObject *__pyx_r = NULL;
  6619. __Pyx_RefNannyDeclarations
  6620. __Pyx_RefNannySetupContext("__get__", 0);
  6621. __Pyx_XDECREF(__pyx_r);
  6622. __Pyx_INCREF(__pyx_v_self->fragment);
  6623. __pyx_r = __pyx_v_self->fragment;
  6624. goto __pyx_L0;
  6625. /* function exit code */
  6626. __pyx_L0:;
  6627. __Pyx_XGIVEREF(__pyx_r);
  6628. __Pyx_RefNannyFinishContext();
  6629. return __pyx_r;
  6630. }
  6631. /* "httptools/parser/parser.pyx":386
  6632. * cdef readonly bytes query
  6633. * cdef readonly bytes fragment
  6634. * cdef readonly bytes userinfo # <<<<<<<<<<<<<<
  6635. *
  6636. * def __cinit__(self, bytes schema, bytes host, object port, bytes path,
  6637. */
  6638. /* Python wrapper */
  6639. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_8userinfo_1__get__(PyObject *__pyx_v_self); /*proto*/
  6640. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_8userinfo_1__get__(PyObject *__pyx_v_self) {
  6641. PyObject *__pyx_r = 0;
  6642. __Pyx_RefNannyDeclarations
  6643. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  6644. __pyx_r = __pyx_pf_9httptools_6parser_6parser_3URL_8userinfo___get__(((struct __pyx_obj_9httptools_6parser_6parser_URL *)__pyx_v_self));
  6645. /* function exit code */
  6646. __Pyx_RefNannyFinishContext();
  6647. return __pyx_r;
  6648. }
  6649. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_8userinfo___get__(struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self) {
  6650. PyObject *__pyx_r = NULL;
  6651. __Pyx_RefNannyDeclarations
  6652. __Pyx_RefNannySetupContext("__get__", 0);
  6653. __Pyx_XDECREF(__pyx_r);
  6654. __Pyx_INCREF(__pyx_v_self->userinfo);
  6655. __pyx_r = __pyx_v_self->userinfo;
  6656. goto __pyx_L0;
  6657. /* function exit code */
  6658. __pyx_L0:;
  6659. __Pyx_XGIVEREF(__pyx_r);
  6660. __Pyx_RefNannyFinishContext();
  6661. return __pyx_r;
  6662. }
  6663. /* "(tree fragment)":1
  6664. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  6665. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  6666. * def __setstate_cython__(self, __pyx_state):
  6667. */
  6668. /* Python wrapper */
  6669. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  6670. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  6671. PyObject *__pyx_r = 0;
  6672. __Pyx_RefNannyDeclarations
  6673. __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  6674. __pyx_r = __pyx_pf_9httptools_6parser_6parser_3URL_4__reduce_cython__(((struct __pyx_obj_9httptools_6parser_6parser_URL *)__pyx_v_self));
  6675. /* function exit code */
  6676. __Pyx_RefNannyFinishContext();
  6677. return __pyx_r;
  6678. }
  6679. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self) {
  6680. PyObject *__pyx_r = NULL;
  6681. __Pyx_RefNannyDeclarations
  6682. PyObject *__pyx_t_1 = NULL;
  6683. __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  6684. /* "(tree fragment)":2
  6685. * def __reduce_cython__(self):
  6686. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  6687. * def __setstate_cython__(self, __pyx_state):
  6688. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  6689. */
  6690. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
  6691. __Pyx_GOTREF(__pyx_t_1);
  6692. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  6693. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6694. __PYX_ERR(1, 2, __pyx_L1_error)
  6695. /* "(tree fragment)":1
  6696. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  6697. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  6698. * def __setstate_cython__(self, __pyx_state):
  6699. */
  6700. /* function exit code */
  6701. __pyx_L1_error:;
  6702. __Pyx_XDECREF(__pyx_t_1);
  6703. __Pyx_AddTraceback("httptools.parser.parser.URL.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6704. __pyx_r = NULL;
  6705. __Pyx_XGIVEREF(__pyx_r);
  6706. __Pyx_RefNannyFinishContext();
  6707. return __pyx_r;
  6708. }
  6709. /* "(tree fragment)":3
  6710. * def __reduce_cython__(self):
  6711. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  6712. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  6713. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  6714. */
  6715. /* Python wrapper */
  6716. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
  6717. static PyObject *__pyx_pw_9httptools_6parser_6parser_3URL_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  6718. PyObject *__pyx_r = 0;
  6719. __Pyx_RefNannyDeclarations
  6720. __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  6721. __pyx_r = __pyx_pf_9httptools_6parser_6parser_3URL_6__setstate_cython__(((struct __pyx_obj_9httptools_6parser_6parser_URL *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
  6722. /* function exit code */
  6723. __Pyx_RefNannyFinishContext();
  6724. return __pyx_r;
  6725. }
  6726. static PyObject *__pyx_pf_9httptools_6parser_6parser_3URL_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  6727. PyObject *__pyx_r = NULL;
  6728. __Pyx_RefNannyDeclarations
  6729. PyObject *__pyx_t_1 = NULL;
  6730. __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  6731. /* "(tree fragment)":4
  6732. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  6733. * def __setstate_cython__(self, __pyx_state):
  6734. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  6735. */
  6736. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  6737. __Pyx_GOTREF(__pyx_t_1);
  6738. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  6739. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6740. __PYX_ERR(1, 4, __pyx_L1_error)
  6741. /* "(tree fragment)":3
  6742. * def __reduce_cython__(self):
  6743. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  6744. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  6745. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  6746. */
  6747. /* function exit code */
  6748. __pyx_L1_error:;
  6749. __Pyx_XDECREF(__pyx_t_1);
  6750. __Pyx_AddTraceback("httptools.parser.parser.URL.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6751. __pyx_r = NULL;
  6752. __Pyx_XGIVEREF(__pyx_r);
  6753. __Pyx_RefNannyFinishContext();
  6754. return __pyx_r;
  6755. }
  6756. /* "httptools/parser/parser.pyx":406
  6757. *
  6758. *
  6759. * def parse_url(url): # <<<<<<<<<<<<<<
  6760. * cdef:
  6761. * Py_buffer py_buf
  6762. */
  6763. /* Python wrapper */
  6764. static PyObject *__pyx_pw_9httptools_6parser_6parser_1parse_url(PyObject *__pyx_self, PyObject *__pyx_v_url); /*proto*/
  6765. static PyMethodDef __pyx_mdef_9httptools_6parser_6parser_1parse_url = {"parse_url", (PyCFunction)__pyx_pw_9httptools_6parser_6parser_1parse_url, METH_O, 0};
  6766. static PyObject *__pyx_pw_9httptools_6parser_6parser_1parse_url(PyObject *__pyx_self, PyObject *__pyx_v_url) {
  6767. PyObject *__pyx_r = 0;
  6768. __Pyx_RefNannyDeclarations
  6769. __Pyx_RefNannySetupContext("parse_url (wrapper)", 0);
  6770. __pyx_r = __pyx_pf_9httptools_6parser_6parser_parse_url(__pyx_self, ((PyObject *)__pyx_v_url));
  6771. /* function exit code */
  6772. __Pyx_RefNannyFinishContext();
  6773. return __pyx_r;
  6774. }
  6775. static PyObject *__pyx_pf_9httptools_6parser_6parser_parse_url(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url) {
  6776. Py_buffer __pyx_v_py_buf;
  6777. char *__pyx_v_buf_data;
  6778. struct http_parser_url *__pyx_v_parsed;
  6779. int __pyx_v_res;
  6780. PyObject *__pyx_v_schema = 0;
  6781. PyObject *__pyx_v_host = 0;
  6782. PyObject *__pyx_v_port = 0;
  6783. PyObject *__pyx_v_path = 0;
  6784. PyObject *__pyx_v_query = 0;
  6785. PyObject *__pyx_v_fragment = 0;
  6786. PyObject *__pyx_v_userinfo = 0;
  6787. CYTHON_UNUSED PyObject *__pyx_v_result = 0;
  6788. int __pyx_v_off;
  6789. int __pyx_v_ln;
  6790. PyObject *__pyx_r = NULL;
  6791. __Pyx_RefNannyDeclarations
  6792. int __pyx_t_1;
  6793. int __pyx_t_2;
  6794. PyObject *__pyx_t_3 = NULL;
  6795. int __pyx_t_4;
  6796. uint16_t __pyx_t_5;
  6797. PyObject *__pyx_t_6 = NULL;
  6798. PyObject *__pyx_t_7 = NULL;
  6799. PyObject *__pyx_t_8 = NULL;
  6800. PyObject *__pyx_t_9 = NULL;
  6801. int __pyx_t_10;
  6802. char const *__pyx_t_11;
  6803. PyObject *__pyx_t_12 = NULL;
  6804. PyObject *__pyx_t_13 = NULL;
  6805. PyObject *__pyx_t_14 = NULL;
  6806. PyObject *__pyx_t_15 = NULL;
  6807. PyObject *__pyx_t_16 = NULL;
  6808. PyObject *__pyx_t_17 = NULL;
  6809. __Pyx_RefNannySetupContext("parse_url", 0);
  6810. /* "httptools/parser/parser.pyx":412
  6811. * cparser.http_parser_url* parsed
  6812. * int res
  6813. * bytes schema = None # <<<<<<<<<<<<<<
  6814. * bytes host = None
  6815. * object port = None
  6816. */
  6817. __Pyx_INCREF(Py_None);
  6818. __pyx_v_schema = ((PyObject*)Py_None);
  6819. /* "httptools/parser/parser.pyx":413
  6820. * int res
  6821. * bytes schema = None
  6822. * bytes host = None # <<<<<<<<<<<<<<
  6823. * object port = None
  6824. * bytes path = None
  6825. */
  6826. __Pyx_INCREF(Py_None);
  6827. __pyx_v_host = ((PyObject*)Py_None);
  6828. /* "httptools/parser/parser.pyx":414
  6829. * bytes schema = None
  6830. * bytes host = None
  6831. * object port = None # <<<<<<<<<<<<<<
  6832. * bytes path = None
  6833. * bytes query = None
  6834. */
  6835. __Pyx_INCREF(Py_None);
  6836. __pyx_v_port = Py_None;
  6837. /* "httptools/parser/parser.pyx":415
  6838. * bytes host = None
  6839. * object port = None
  6840. * bytes path = None # <<<<<<<<<<<<<<
  6841. * bytes query = None
  6842. * bytes fragment = None
  6843. */
  6844. __Pyx_INCREF(Py_None);
  6845. __pyx_v_path = ((PyObject*)Py_None);
  6846. /* "httptools/parser/parser.pyx":416
  6847. * object port = None
  6848. * bytes path = None
  6849. * bytes query = None # <<<<<<<<<<<<<<
  6850. * bytes fragment = None
  6851. * bytes userinfo = None
  6852. */
  6853. __Pyx_INCREF(Py_None);
  6854. __pyx_v_query = ((PyObject*)Py_None);
  6855. /* "httptools/parser/parser.pyx":417
  6856. * bytes path = None
  6857. * bytes query = None
  6858. * bytes fragment = None # <<<<<<<<<<<<<<
  6859. * bytes userinfo = None
  6860. * object result = None
  6861. */
  6862. __Pyx_INCREF(Py_None);
  6863. __pyx_v_fragment = ((PyObject*)Py_None);
  6864. /* "httptools/parser/parser.pyx":418
  6865. * bytes query = None
  6866. * bytes fragment = None
  6867. * bytes userinfo = None # <<<<<<<<<<<<<<
  6868. * object result = None
  6869. * int off
  6870. */
  6871. __Pyx_INCREF(Py_None);
  6872. __pyx_v_userinfo = ((PyObject*)Py_None);
  6873. /* "httptools/parser/parser.pyx":419
  6874. * bytes fragment = None
  6875. * bytes userinfo = None
  6876. * object result = None # <<<<<<<<<<<<<<
  6877. * int off
  6878. * int ln
  6879. */
  6880. __Pyx_INCREF(Py_None);
  6881. __pyx_v_result = Py_None;
  6882. /* "httptools/parser/parser.pyx":423
  6883. * int ln
  6884. *
  6885. * if not url: # <<<<<<<<<<<<<<
  6886. * return URL(None, None, None, None, None, None, None)
  6887. *
  6888. */
  6889. __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_url); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 423, __pyx_L1_error)
  6890. __pyx_t_2 = ((!__pyx_t_1) != 0);
  6891. if (__pyx_t_2) {
  6892. /* "httptools/parser/parser.pyx":424
  6893. *
  6894. * if not url:
  6895. * return URL(None, None, None, None, None, None, None) # <<<<<<<<<<<<<<
  6896. *
  6897. * parsed = <cparser.http_parser_url*> \
  6898. */
  6899. __Pyx_XDECREF(__pyx_r);
  6900. __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9httptools_6parser_6parser_URL), __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 424, __pyx_L1_error)
  6901. __Pyx_GOTREF(__pyx_t_3);
  6902. __pyx_r = __pyx_t_3;
  6903. __pyx_t_3 = 0;
  6904. goto __pyx_L0;
  6905. /* "httptools/parser/parser.pyx":423
  6906. * int ln
  6907. *
  6908. * if not url: # <<<<<<<<<<<<<<
  6909. * return URL(None, None, None, None, None, None, None)
  6910. *
  6911. */
  6912. }
  6913. /* "httptools/parser/parser.pyx":426
  6914. * return URL(None, None, None, None, None, None, None)
  6915. *
  6916. * parsed = <cparser.http_parser_url*> \ # <<<<<<<<<<<<<<
  6917. * PyMem_Malloc(sizeof(cparser.http_parser_url))
  6918. * cparser.http_parser_url_init(parsed)
  6919. */
  6920. __pyx_v_parsed = ((struct http_parser_url *)PyMem_Malloc((sizeof(struct http_parser_url))));
  6921. /* "httptools/parser/parser.pyx":428
  6922. * parsed = <cparser.http_parser_url*> \
  6923. * PyMem_Malloc(sizeof(cparser.http_parser_url))
  6924. * cparser.http_parser_url_init(parsed) # <<<<<<<<<<<<<<
  6925. *
  6926. * PyObject_GetBuffer(url, &py_buf, PyBUF_SIMPLE)
  6927. */
  6928. http_parser_url_init(__pyx_v_parsed);
  6929. /* "httptools/parser/parser.pyx":430
  6930. * cparser.http_parser_url_init(parsed)
  6931. *
  6932. * PyObject_GetBuffer(url, &py_buf, PyBUF_SIMPLE) # <<<<<<<<<<<<<<
  6933. * try:
  6934. * buf_data = <char*>py_buf.buf
  6935. */
  6936. __pyx_t_4 = PyObject_GetBuffer(__pyx_v_url, (&__pyx_v_py_buf), PyBUF_SIMPLE); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 430, __pyx_L1_error)
  6937. /* "httptools/parser/parser.pyx":431
  6938. *
  6939. * PyObject_GetBuffer(url, &py_buf, PyBUF_SIMPLE)
  6940. * try: # <<<<<<<<<<<<<<
  6941. * buf_data = <char*>py_buf.buf
  6942. * res = cparser.http_parser_parse_url(buf_data, py_buf.len, 0, parsed)
  6943. */
  6944. /*try:*/ {
  6945. /* "httptools/parser/parser.pyx":432
  6946. * PyObject_GetBuffer(url, &py_buf, PyBUF_SIMPLE)
  6947. * try:
  6948. * buf_data = <char*>py_buf.buf # <<<<<<<<<<<<<<
  6949. * res = cparser.http_parser_parse_url(buf_data, py_buf.len, 0, parsed)
  6950. *
  6951. */
  6952. __pyx_v_buf_data = ((char *)__pyx_v_py_buf.buf);
  6953. /* "httptools/parser/parser.pyx":433
  6954. * try:
  6955. * buf_data = <char*>py_buf.buf
  6956. * res = cparser.http_parser_parse_url(buf_data, py_buf.len, 0, parsed) # <<<<<<<<<<<<<<
  6957. *
  6958. * if res == 0:
  6959. */
  6960. __pyx_v_res = http_parser_parse_url(__pyx_v_buf_data, __pyx_v_py_buf.len, 0, __pyx_v_parsed);
  6961. /* "httptools/parser/parser.pyx":435
  6962. * res = cparser.http_parser_parse_url(buf_data, py_buf.len, 0, parsed)
  6963. *
  6964. * if res == 0: # <<<<<<<<<<<<<<
  6965. * if parsed.field_set & (1 << cparser.UF_SCHEMA):
  6966. * off = parsed.field_data[<int>cparser.UF_SCHEMA].off
  6967. */
  6968. __pyx_t_2 = ((__pyx_v_res == 0) != 0);
  6969. if (likely(__pyx_t_2)) {
  6970. /* "httptools/parser/parser.pyx":436
  6971. *
  6972. * if res == 0:
  6973. * if parsed.field_set & (1 << cparser.UF_SCHEMA): # <<<<<<<<<<<<<<
  6974. * off = parsed.field_data[<int>cparser.UF_SCHEMA].off
  6975. * ln = parsed.field_data[<int>cparser.UF_SCHEMA].len
  6976. */
  6977. __pyx_t_2 = ((__pyx_v_parsed->field_set & (1 << UF_SCHEMA)) != 0);
  6978. if (__pyx_t_2) {
  6979. /* "httptools/parser/parser.pyx":437
  6980. * if res == 0:
  6981. * if parsed.field_set & (1 << cparser.UF_SCHEMA):
  6982. * off = parsed.field_data[<int>cparser.UF_SCHEMA].off # <<<<<<<<<<<<<<
  6983. * ln = parsed.field_data[<int>cparser.UF_SCHEMA].len
  6984. * schema = buf_data[off:off+ln]
  6985. */
  6986. __pyx_t_5 = (__pyx_v_parsed->field_data[((int)UF_SCHEMA)]).off;
  6987. __pyx_v_off = __pyx_t_5;
  6988. /* "httptools/parser/parser.pyx":438
  6989. * if parsed.field_set & (1 << cparser.UF_SCHEMA):
  6990. * off = parsed.field_data[<int>cparser.UF_SCHEMA].off
  6991. * ln = parsed.field_data[<int>cparser.UF_SCHEMA].len # <<<<<<<<<<<<<<
  6992. * schema = buf_data[off:off+ln]
  6993. *
  6994. */
  6995. __pyx_t_5 = (__pyx_v_parsed->field_data[((int)UF_SCHEMA)]).len;
  6996. __pyx_v_ln = __pyx_t_5;
  6997. /* "httptools/parser/parser.pyx":439
  6998. * off = parsed.field_data[<int>cparser.UF_SCHEMA].off
  6999. * ln = parsed.field_data[<int>cparser.UF_SCHEMA].len
  7000. * schema = buf_data[off:off+ln] # <<<<<<<<<<<<<<
  7001. *
  7002. * if parsed.field_set & (1 << cparser.UF_HOST):
  7003. */
  7004. __pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_buf_data + __pyx_v_off, (__pyx_v_off + __pyx_v_ln) - __pyx_v_off); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 439, __pyx_L5_error)
  7005. __Pyx_GOTREF(__pyx_t_3);
  7006. __Pyx_DECREF_SET(__pyx_v_schema, ((PyObject*)__pyx_t_3));
  7007. __pyx_t_3 = 0;
  7008. /* "httptools/parser/parser.pyx":436
  7009. *
  7010. * if res == 0:
  7011. * if parsed.field_set & (1 << cparser.UF_SCHEMA): # <<<<<<<<<<<<<<
  7012. * off = parsed.field_data[<int>cparser.UF_SCHEMA].off
  7013. * ln = parsed.field_data[<int>cparser.UF_SCHEMA].len
  7014. */
  7015. }
  7016. /* "httptools/parser/parser.pyx":441
  7017. * schema = buf_data[off:off+ln]
  7018. *
  7019. * if parsed.field_set & (1 << cparser.UF_HOST): # <<<<<<<<<<<<<<
  7020. * off = parsed.field_data[<int>cparser.UF_HOST].off
  7021. * ln = parsed.field_data[<int>cparser.UF_HOST].len
  7022. */
  7023. __pyx_t_2 = ((__pyx_v_parsed->field_set & (1 << UF_HOST)) != 0);
  7024. if (__pyx_t_2) {
  7025. /* "httptools/parser/parser.pyx":442
  7026. *
  7027. * if parsed.field_set & (1 << cparser.UF_HOST):
  7028. * off = parsed.field_data[<int>cparser.UF_HOST].off # <<<<<<<<<<<<<<
  7029. * ln = parsed.field_data[<int>cparser.UF_HOST].len
  7030. * host = buf_data[off:off+ln]
  7031. */
  7032. __pyx_t_5 = (__pyx_v_parsed->field_data[((int)UF_HOST)]).off;
  7033. __pyx_v_off = __pyx_t_5;
  7034. /* "httptools/parser/parser.pyx":443
  7035. * if parsed.field_set & (1 << cparser.UF_HOST):
  7036. * off = parsed.field_data[<int>cparser.UF_HOST].off
  7037. * ln = parsed.field_data[<int>cparser.UF_HOST].len # <<<<<<<<<<<<<<
  7038. * host = buf_data[off:off+ln]
  7039. *
  7040. */
  7041. __pyx_t_5 = (__pyx_v_parsed->field_data[((int)UF_HOST)]).len;
  7042. __pyx_v_ln = __pyx_t_5;
  7043. /* "httptools/parser/parser.pyx":444
  7044. * off = parsed.field_data[<int>cparser.UF_HOST].off
  7045. * ln = parsed.field_data[<int>cparser.UF_HOST].len
  7046. * host = buf_data[off:off+ln] # <<<<<<<<<<<<<<
  7047. *
  7048. * if parsed.field_set & (1 << cparser.UF_PORT):
  7049. */
  7050. __pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_buf_data + __pyx_v_off, (__pyx_v_off + __pyx_v_ln) - __pyx_v_off); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 444, __pyx_L5_error)
  7051. __Pyx_GOTREF(__pyx_t_3);
  7052. __Pyx_DECREF_SET(__pyx_v_host, ((PyObject*)__pyx_t_3));
  7053. __pyx_t_3 = 0;
  7054. /* "httptools/parser/parser.pyx":441
  7055. * schema = buf_data[off:off+ln]
  7056. *
  7057. * if parsed.field_set & (1 << cparser.UF_HOST): # <<<<<<<<<<<<<<
  7058. * off = parsed.field_data[<int>cparser.UF_HOST].off
  7059. * ln = parsed.field_data[<int>cparser.UF_HOST].len
  7060. */
  7061. }
  7062. /* "httptools/parser/parser.pyx":446
  7063. * host = buf_data[off:off+ln]
  7064. *
  7065. * if parsed.field_set & (1 << cparser.UF_PORT): # <<<<<<<<<<<<<<
  7066. * port = parsed.port
  7067. *
  7068. */
  7069. __pyx_t_2 = ((__pyx_v_parsed->field_set & (1 << UF_PORT)) != 0);
  7070. if (__pyx_t_2) {
  7071. /* "httptools/parser/parser.pyx":447
  7072. *
  7073. * if parsed.field_set & (1 << cparser.UF_PORT):
  7074. * port = parsed.port # <<<<<<<<<<<<<<
  7075. *
  7076. * if parsed.field_set & (1 << cparser.UF_PATH):
  7077. */
  7078. __pyx_t_3 = __Pyx_PyInt_From_uint16_t(__pyx_v_parsed->port); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 447, __pyx_L5_error)
  7079. __Pyx_GOTREF(__pyx_t_3);
  7080. __Pyx_DECREF_SET(__pyx_v_port, __pyx_t_3);
  7081. __pyx_t_3 = 0;
  7082. /* "httptools/parser/parser.pyx":446
  7083. * host = buf_data[off:off+ln]
  7084. *
  7085. * if parsed.field_set & (1 << cparser.UF_PORT): # <<<<<<<<<<<<<<
  7086. * port = parsed.port
  7087. *
  7088. */
  7089. }
  7090. /* "httptools/parser/parser.pyx":449
  7091. * port = parsed.port
  7092. *
  7093. * if parsed.field_set & (1 << cparser.UF_PATH): # <<<<<<<<<<<<<<
  7094. * off = parsed.field_data[<int>cparser.UF_PATH].off
  7095. * ln = parsed.field_data[<int>cparser.UF_PATH].len
  7096. */
  7097. __pyx_t_2 = ((__pyx_v_parsed->field_set & (1 << UF_PATH)) != 0);
  7098. if (__pyx_t_2) {
  7099. /* "httptools/parser/parser.pyx":450
  7100. *
  7101. * if parsed.field_set & (1 << cparser.UF_PATH):
  7102. * off = parsed.field_data[<int>cparser.UF_PATH].off # <<<<<<<<<<<<<<
  7103. * ln = parsed.field_data[<int>cparser.UF_PATH].len
  7104. * path = buf_data[off:off+ln]
  7105. */
  7106. __pyx_t_5 = (__pyx_v_parsed->field_data[((int)UF_PATH)]).off;
  7107. __pyx_v_off = __pyx_t_5;
  7108. /* "httptools/parser/parser.pyx":451
  7109. * if parsed.field_set & (1 << cparser.UF_PATH):
  7110. * off = parsed.field_data[<int>cparser.UF_PATH].off
  7111. * ln = parsed.field_data[<int>cparser.UF_PATH].len # <<<<<<<<<<<<<<
  7112. * path = buf_data[off:off+ln]
  7113. *
  7114. */
  7115. __pyx_t_5 = (__pyx_v_parsed->field_data[((int)UF_PATH)]).len;
  7116. __pyx_v_ln = __pyx_t_5;
  7117. /* "httptools/parser/parser.pyx":452
  7118. * off = parsed.field_data[<int>cparser.UF_PATH].off
  7119. * ln = parsed.field_data[<int>cparser.UF_PATH].len
  7120. * path = buf_data[off:off+ln] # <<<<<<<<<<<<<<
  7121. *
  7122. * if parsed.field_set & (1 << cparser.UF_QUERY):
  7123. */
  7124. __pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_buf_data + __pyx_v_off, (__pyx_v_off + __pyx_v_ln) - __pyx_v_off); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 452, __pyx_L5_error)
  7125. __Pyx_GOTREF(__pyx_t_3);
  7126. __Pyx_DECREF_SET(__pyx_v_path, ((PyObject*)__pyx_t_3));
  7127. __pyx_t_3 = 0;
  7128. /* "httptools/parser/parser.pyx":449
  7129. * port = parsed.port
  7130. *
  7131. * if parsed.field_set & (1 << cparser.UF_PATH): # <<<<<<<<<<<<<<
  7132. * off = parsed.field_data[<int>cparser.UF_PATH].off
  7133. * ln = parsed.field_data[<int>cparser.UF_PATH].len
  7134. */
  7135. }
  7136. /* "httptools/parser/parser.pyx":454
  7137. * path = buf_data[off:off+ln]
  7138. *
  7139. * if parsed.field_set & (1 << cparser.UF_QUERY): # <<<<<<<<<<<<<<
  7140. * off = parsed.field_data[<int>cparser.UF_QUERY].off
  7141. * ln = parsed.field_data[<int>cparser.UF_QUERY].len
  7142. */
  7143. __pyx_t_2 = ((__pyx_v_parsed->field_set & (1 << UF_QUERY)) != 0);
  7144. if (__pyx_t_2) {
  7145. /* "httptools/parser/parser.pyx":455
  7146. *
  7147. * if parsed.field_set & (1 << cparser.UF_QUERY):
  7148. * off = parsed.field_data[<int>cparser.UF_QUERY].off # <<<<<<<<<<<<<<
  7149. * ln = parsed.field_data[<int>cparser.UF_QUERY].len
  7150. * query = buf_data[off:off+ln]
  7151. */
  7152. __pyx_t_5 = (__pyx_v_parsed->field_data[((int)UF_QUERY)]).off;
  7153. __pyx_v_off = __pyx_t_5;
  7154. /* "httptools/parser/parser.pyx":456
  7155. * if parsed.field_set & (1 << cparser.UF_QUERY):
  7156. * off = parsed.field_data[<int>cparser.UF_QUERY].off
  7157. * ln = parsed.field_data[<int>cparser.UF_QUERY].len # <<<<<<<<<<<<<<
  7158. * query = buf_data[off:off+ln]
  7159. *
  7160. */
  7161. __pyx_t_5 = (__pyx_v_parsed->field_data[((int)UF_QUERY)]).len;
  7162. __pyx_v_ln = __pyx_t_5;
  7163. /* "httptools/parser/parser.pyx":457
  7164. * off = parsed.field_data[<int>cparser.UF_QUERY].off
  7165. * ln = parsed.field_data[<int>cparser.UF_QUERY].len
  7166. * query = buf_data[off:off+ln] # <<<<<<<<<<<<<<
  7167. *
  7168. * if parsed.field_set & (1 << cparser.UF_FRAGMENT):
  7169. */
  7170. __pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_buf_data + __pyx_v_off, (__pyx_v_off + __pyx_v_ln) - __pyx_v_off); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 457, __pyx_L5_error)
  7171. __Pyx_GOTREF(__pyx_t_3);
  7172. __Pyx_DECREF_SET(__pyx_v_query, ((PyObject*)__pyx_t_3));
  7173. __pyx_t_3 = 0;
  7174. /* "httptools/parser/parser.pyx":454
  7175. * path = buf_data[off:off+ln]
  7176. *
  7177. * if parsed.field_set & (1 << cparser.UF_QUERY): # <<<<<<<<<<<<<<
  7178. * off = parsed.field_data[<int>cparser.UF_QUERY].off
  7179. * ln = parsed.field_data[<int>cparser.UF_QUERY].len
  7180. */
  7181. }
  7182. /* "httptools/parser/parser.pyx":459
  7183. * query = buf_data[off:off+ln]
  7184. *
  7185. * if parsed.field_set & (1 << cparser.UF_FRAGMENT): # <<<<<<<<<<<<<<
  7186. * off = parsed.field_data[<int>cparser.UF_FRAGMENT].off
  7187. * ln = parsed.field_data[<int>cparser.UF_FRAGMENT].len
  7188. */
  7189. __pyx_t_2 = ((__pyx_v_parsed->field_set & (1 << UF_FRAGMENT)) != 0);
  7190. if (__pyx_t_2) {
  7191. /* "httptools/parser/parser.pyx":460
  7192. *
  7193. * if parsed.field_set & (1 << cparser.UF_FRAGMENT):
  7194. * off = parsed.field_data[<int>cparser.UF_FRAGMENT].off # <<<<<<<<<<<<<<
  7195. * ln = parsed.field_data[<int>cparser.UF_FRAGMENT].len
  7196. * fragment = buf_data[off:off+ln]
  7197. */
  7198. __pyx_t_5 = (__pyx_v_parsed->field_data[((int)UF_FRAGMENT)]).off;
  7199. __pyx_v_off = __pyx_t_5;
  7200. /* "httptools/parser/parser.pyx":461
  7201. * if parsed.field_set & (1 << cparser.UF_FRAGMENT):
  7202. * off = parsed.field_data[<int>cparser.UF_FRAGMENT].off
  7203. * ln = parsed.field_data[<int>cparser.UF_FRAGMENT].len # <<<<<<<<<<<<<<
  7204. * fragment = buf_data[off:off+ln]
  7205. *
  7206. */
  7207. __pyx_t_5 = (__pyx_v_parsed->field_data[((int)UF_FRAGMENT)]).len;
  7208. __pyx_v_ln = __pyx_t_5;
  7209. /* "httptools/parser/parser.pyx":462
  7210. * off = parsed.field_data[<int>cparser.UF_FRAGMENT].off
  7211. * ln = parsed.field_data[<int>cparser.UF_FRAGMENT].len
  7212. * fragment = buf_data[off:off+ln] # <<<<<<<<<<<<<<
  7213. *
  7214. * if parsed.field_set & (1 << cparser.UF_USERINFO):
  7215. */
  7216. __pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_buf_data + __pyx_v_off, (__pyx_v_off + __pyx_v_ln) - __pyx_v_off); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 462, __pyx_L5_error)
  7217. __Pyx_GOTREF(__pyx_t_3);
  7218. __Pyx_DECREF_SET(__pyx_v_fragment, ((PyObject*)__pyx_t_3));
  7219. __pyx_t_3 = 0;
  7220. /* "httptools/parser/parser.pyx":459
  7221. * query = buf_data[off:off+ln]
  7222. *
  7223. * if parsed.field_set & (1 << cparser.UF_FRAGMENT): # <<<<<<<<<<<<<<
  7224. * off = parsed.field_data[<int>cparser.UF_FRAGMENT].off
  7225. * ln = parsed.field_data[<int>cparser.UF_FRAGMENT].len
  7226. */
  7227. }
  7228. /* "httptools/parser/parser.pyx":464
  7229. * fragment = buf_data[off:off+ln]
  7230. *
  7231. * if parsed.field_set & (1 << cparser.UF_USERINFO): # <<<<<<<<<<<<<<
  7232. * off = parsed.field_data[<int>cparser.UF_USERINFO].off
  7233. * ln = parsed.field_data[<int>cparser.UF_USERINFO].len
  7234. */
  7235. __pyx_t_2 = ((__pyx_v_parsed->field_set & (1 << UF_USERINFO)) != 0);
  7236. if (__pyx_t_2) {
  7237. /* "httptools/parser/parser.pyx":465
  7238. *
  7239. * if parsed.field_set & (1 << cparser.UF_USERINFO):
  7240. * off = parsed.field_data[<int>cparser.UF_USERINFO].off # <<<<<<<<<<<<<<
  7241. * ln = parsed.field_data[<int>cparser.UF_USERINFO].len
  7242. * userinfo = buf_data[off:off+ln]
  7243. */
  7244. __pyx_t_5 = (__pyx_v_parsed->field_data[((int)UF_USERINFO)]).off;
  7245. __pyx_v_off = __pyx_t_5;
  7246. /* "httptools/parser/parser.pyx":466
  7247. * if parsed.field_set & (1 << cparser.UF_USERINFO):
  7248. * off = parsed.field_data[<int>cparser.UF_USERINFO].off
  7249. * ln = parsed.field_data[<int>cparser.UF_USERINFO].len # <<<<<<<<<<<<<<
  7250. * userinfo = buf_data[off:off+ln]
  7251. *
  7252. */
  7253. __pyx_t_5 = (__pyx_v_parsed->field_data[((int)UF_USERINFO)]).len;
  7254. __pyx_v_ln = __pyx_t_5;
  7255. /* "httptools/parser/parser.pyx":467
  7256. * off = parsed.field_data[<int>cparser.UF_USERINFO].off
  7257. * ln = parsed.field_data[<int>cparser.UF_USERINFO].len
  7258. * userinfo = buf_data[off:off+ln] # <<<<<<<<<<<<<<
  7259. *
  7260. * return URL(schema, host, port, path, query, fragment, userinfo)
  7261. */
  7262. __pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_buf_data + __pyx_v_off, (__pyx_v_off + __pyx_v_ln) - __pyx_v_off); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 467, __pyx_L5_error)
  7263. __Pyx_GOTREF(__pyx_t_3);
  7264. __Pyx_DECREF_SET(__pyx_v_userinfo, ((PyObject*)__pyx_t_3));
  7265. __pyx_t_3 = 0;
  7266. /* "httptools/parser/parser.pyx":464
  7267. * fragment = buf_data[off:off+ln]
  7268. *
  7269. * if parsed.field_set & (1 << cparser.UF_USERINFO): # <<<<<<<<<<<<<<
  7270. * off = parsed.field_data[<int>cparser.UF_USERINFO].off
  7271. * ln = parsed.field_data[<int>cparser.UF_USERINFO].len
  7272. */
  7273. }
  7274. /* "httptools/parser/parser.pyx":469
  7275. * userinfo = buf_data[off:off+ln]
  7276. *
  7277. * return URL(schema, host, port, path, query, fragment, userinfo) # <<<<<<<<<<<<<<
  7278. * else:
  7279. * raise HttpParserInvalidURLError("invalid url {!r}".format(url))
  7280. */
  7281. __Pyx_XDECREF(__pyx_r);
  7282. __pyx_t_3 = PyTuple_New(7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 469, __pyx_L5_error)
  7283. __Pyx_GOTREF(__pyx_t_3);
  7284. __Pyx_INCREF(__pyx_v_schema);
  7285. __Pyx_GIVEREF(__pyx_v_schema);
  7286. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_schema);
  7287. __Pyx_INCREF(__pyx_v_host);
  7288. __Pyx_GIVEREF(__pyx_v_host);
  7289. PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_host);
  7290. __Pyx_INCREF(__pyx_v_port);
  7291. __Pyx_GIVEREF(__pyx_v_port);
  7292. PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_port);
  7293. __Pyx_INCREF(__pyx_v_path);
  7294. __Pyx_GIVEREF(__pyx_v_path);
  7295. PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_path);
  7296. __Pyx_INCREF(__pyx_v_query);
  7297. __Pyx_GIVEREF(__pyx_v_query);
  7298. PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_v_query);
  7299. __Pyx_INCREF(__pyx_v_fragment);
  7300. __Pyx_GIVEREF(__pyx_v_fragment);
  7301. PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_v_fragment);
  7302. __Pyx_INCREF(__pyx_v_userinfo);
  7303. __Pyx_GIVEREF(__pyx_v_userinfo);
  7304. PyTuple_SET_ITEM(__pyx_t_3, 6, __pyx_v_userinfo);
  7305. __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9httptools_6parser_6parser_URL), __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 469, __pyx_L5_error)
  7306. __Pyx_GOTREF(__pyx_t_6);
  7307. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7308. __pyx_r = __pyx_t_6;
  7309. __pyx_t_6 = 0;
  7310. goto __pyx_L4_return;
  7311. /* "httptools/parser/parser.pyx":435
  7312. * res = cparser.http_parser_parse_url(buf_data, py_buf.len, 0, parsed)
  7313. *
  7314. * if res == 0: # <<<<<<<<<<<<<<
  7315. * if parsed.field_set & (1 << cparser.UF_SCHEMA):
  7316. * off = parsed.field_data[<int>cparser.UF_SCHEMA].off
  7317. */
  7318. }
  7319. /* "httptools/parser/parser.pyx":471
  7320. * return URL(schema, host, port, path, query, fragment, userinfo)
  7321. * else:
  7322. * raise HttpParserInvalidURLError("invalid url {!r}".format(url)) # <<<<<<<<<<<<<<
  7323. * finally:
  7324. * PyBuffer_Release(&py_buf)
  7325. */
  7326. /*else*/ {
  7327. __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_HttpParserInvalidURLError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 471, __pyx_L5_error)
  7328. __Pyx_GOTREF(__pyx_t_3);
  7329. __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_invalid_url_r, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 471, __pyx_L5_error)
  7330. __Pyx_GOTREF(__pyx_t_8);
  7331. __pyx_t_9 = NULL;
  7332. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
  7333. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
  7334. if (likely(__pyx_t_9)) {
  7335. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
  7336. __Pyx_INCREF(__pyx_t_9);
  7337. __Pyx_INCREF(function);
  7338. __Pyx_DECREF_SET(__pyx_t_8, function);
  7339. }
  7340. }
  7341. __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_v_url) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_url);
  7342. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  7343. if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 471, __pyx_L5_error)
  7344. __Pyx_GOTREF(__pyx_t_7);
  7345. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7346. __pyx_t_8 = NULL;
  7347. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  7348. __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
  7349. if (likely(__pyx_t_8)) {
  7350. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  7351. __Pyx_INCREF(__pyx_t_8);
  7352. __Pyx_INCREF(function);
  7353. __Pyx_DECREF_SET(__pyx_t_3, function);
  7354. }
  7355. }
  7356. __pyx_t_6 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7);
  7357. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  7358. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7359. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 471, __pyx_L5_error)
  7360. __Pyx_GOTREF(__pyx_t_6);
  7361. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7362. __Pyx_Raise(__pyx_t_6, 0, 0, 0);
  7363. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7364. __PYX_ERR(0, 471, __pyx_L5_error)
  7365. }
  7366. }
  7367. /* "httptools/parser/parser.pyx":473
  7368. * raise HttpParserInvalidURLError("invalid url {!r}".format(url))
  7369. * finally:
  7370. * PyBuffer_Release(&py_buf) # <<<<<<<<<<<<<<
  7371. * PyMem_Free(parsed)
  7372. */
  7373. /*finally:*/ {
  7374. __pyx_L5_error:;
  7375. /*exception exit:*/{
  7376. __Pyx_PyThreadState_declare
  7377. __Pyx_PyThreadState_assign
  7378. __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
  7379. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  7380. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  7381. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7382. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  7383. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  7384. if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
  7385. if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
  7386. __Pyx_XGOTREF(__pyx_t_12);
  7387. __Pyx_XGOTREF(__pyx_t_13);
  7388. __Pyx_XGOTREF(__pyx_t_14);
  7389. __Pyx_XGOTREF(__pyx_t_15);
  7390. __Pyx_XGOTREF(__pyx_t_16);
  7391. __Pyx_XGOTREF(__pyx_t_17);
  7392. __pyx_t_4 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
  7393. {
  7394. PyBuffer_Release((&__pyx_v_py_buf));
  7395. /* "httptools/parser/parser.pyx":474
  7396. * finally:
  7397. * PyBuffer_Release(&py_buf)
  7398. * PyMem_Free(parsed) # <<<<<<<<<<<<<<
  7399. */
  7400. PyMem_Free(__pyx_v_parsed);
  7401. }
  7402. if (PY_MAJOR_VERSION >= 3) {
  7403. __Pyx_XGIVEREF(__pyx_t_15);
  7404. __Pyx_XGIVEREF(__pyx_t_16);
  7405. __Pyx_XGIVEREF(__pyx_t_17);
  7406. __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
  7407. }
  7408. __Pyx_XGIVEREF(__pyx_t_12);
  7409. __Pyx_XGIVEREF(__pyx_t_13);
  7410. __Pyx_XGIVEREF(__pyx_t_14);
  7411. __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
  7412. __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
  7413. __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
  7414. goto __pyx_L1_error;
  7415. }
  7416. __pyx_L4_return: {
  7417. __pyx_t_17 = __pyx_r;
  7418. __pyx_r = 0;
  7419. /* "httptools/parser/parser.pyx":473
  7420. * raise HttpParserInvalidURLError("invalid url {!r}".format(url))
  7421. * finally:
  7422. * PyBuffer_Release(&py_buf) # <<<<<<<<<<<<<<
  7423. * PyMem_Free(parsed)
  7424. */
  7425. PyBuffer_Release((&__pyx_v_py_buf));
  7426. /* "httptools/parser/parser.pyx":474
  7427. * finally:
  7428. * PyBuffer_Release(&py_buf)
  7429. * PyMem_Free(parsed) # <<<<<<<<<<<<<<
  7430. */
  7431. PyMem_Free(__pyx_v_parsed);
  7432. __pyx_r = __pyx_t_17;
  7433. __pyx_t_17 = 0;
  7434. goto __pyx_L0;
  7435. }
  7436. }
  7437. /* "httptools/parser/parser.pyx":406
  7438. *
  7439. *
  7440. * def parse_url(url): # <<<<<<<<<<<<<<
  7441. * cdef:
  7442. * Py_buffer py_buf
  7443. */
  7444. /* function exit code */
  7445. __pyx_L1_error:;
  7446. __Pyx_XDECREF(__pyx_t_3);
  7447. __Pyx_XDECREF(__pyx_t_6);
  7448. __Pyx_XDECREF(__pyx_t_7);
  7449. __Pyx_XDECREF(__pyx_t_8);
  7450. __Pyx_XDECREF(__pyx_t_9);
  7451. __Pyx_AddTraceback("httptools.parser.parser.parse_url", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7452. __pyx_r = NULL;
  7453. __pyx_L0:;
  7454. __Pyx_XDECREF(__pyx_v_schema);
  7455. __Pyx_XDECREF(__pyx_v_host);
  7456. __Pyx_XDECREF(__pyx_v_port);
  7457. __Pyx_XDECREF(__pyx_v_path);
  7458. __Pyx_XDECREF(__pyx_v_query);
  7459. __Pyx_XDECREF(__pyx_v_fragment);
  7460. __Pyx_XDECREF(__pyx_v_userinfo);
  7461. __Pyx_XDECREF(__pyx_v_result);
  7462. __Pyx_XGIVEREF(__pyx_r);
  7463. __Pyx_RefNannyFinishContext();
  7464. return __pyx_r;
  7465. }
  7466. static struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser __pyx_vtable_9httptools_6parser_6parser_HttpParser;
  7467. static PyObject *__pyx_tp_new_9httptools_6parser_6parser_HttpParser(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  7468. struct __pyx_obj_9httptools_6parser_6parser_HttpParser *p;
  7469. PyObject *o;
  7470. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  7471. o = (*t->tp_alloc)(t, 0);
  7472. } else {
  7473. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  7474. }
  7475. if (unlikely(!o)) return 0;
  7476. p = ((struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)o);
  7477. p->__pyx_vtab = __pyx_vtabptr_9httptools_6parser_6parser_HttpParser;
  7478. p->_current_header_name = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7479. p->_current_header_value = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7480. p->_proto_on_url = Py_None; Py_INCREF(Py_None);
  7481. p->_proto_on_status = Py_None; Py_INCREF(Py_None);
  7482. p->_proto_on_body = Py_None; Py_INCREF(Py_None);
  7483. p->_proto_on_header = Py_None; Py_INCREF(Py_None);
  7484. p->_proto_on_headers_complete = Py_None; Py_INCREF(Py_None);
  7485. p->_proto_on_message_complete = Py_None; Py_INCREF(Py_None);
  7486. p->_proto_on_chunk_header = Py_None; Py_INCREF(Py_None);
  7487. p->_proto_on_chunk_complete = Py_None; Py_INCREF(Py_None);
  7488. p->_proto_on_message_begin = Py_None; Py_INCREF(Py_None);
  7489. p->_last_error = Py_None; Py_INCREF(Py_None);
  7490. p->py_buf.obj = NULL;
  7491. if (unlikely(__pyx_pw_9httptools_6parser_6parser_10HttpParser_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
  7492. return o;
  7493. bad:
  7494. Py_DECREF(o); o = 0;
  7495. return NULL;
  7496. }
  7497. static void __pyx_tp_dealloc_9httptools_6parser_6parser_HttpParser(PyObject *o) {
  7498. struct __pyx_obj_9httptools_6parser_6parser_HttpParser *p = (struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)o;
  7499. #if CYTHON_USE_TP_FINALIZE
  7500. if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
  7501. if (PyObject_CallFinalizerFromDealloc(o)) return;
  7502. }
  7503. #endif
  7504. PyObject_GC_UnTrack(o);
  7505. {
  7506. PyObject *etype, *eval, *etb;
  7507. PyErr_Fetch(&etype, &eval, &etb);
  7508. ++Py_REFCNT(o);
  7509. __pyx_pw_9httptools_6parser_6parser_10HttpParser_3__dealloc__(o);
  7510. --Py_REFCNT(o);
  7511. PyErr_Restore(etype, eval, etb);
  7512. }
  7513. Py_CLEAR(p->_current_header_name);
  7514. Py_CLEAR(p->_current_header_value);
  7515. Py_CLEAR(p->_proto_on_url);
  7516. Py_CLEAR(p->_proto_on_status);
  7517. Py_CLEAR(p->_proto_on_body);
  7518. Py_CLEAR(p->_proto_on_header);
  7519. Py_CLEAR(p->_proto_on_headers_complete);
  7520. Py_CLEAR(p->_proto_on_message_complete);
  7521. Py_CLEAR(p->_proto_on_chunk_header);
  7522. Py_CLEAR(p->_proto_on_chunk_complete);
  7523. Py_CLEAR(p->_proto_on_message_begin);
  7524. Py_CLEAR(p->_last_error);
  7525. (*Py_TYPE(o)->tp_free)(o);
  7526. }
  7527. static int __pyx_tp_traverse_9httptools_6parser_6parser_HttpParser(PyObject *o, visitproc v, void *a) {
  7528. int e;
  7529. struct __pyx_obj_9httptools_6parser_6parser_HttpParser *p = (struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)o;
  7530. if (p->_proto_on_url) {
  7531. e = (*v)(p->_proto_on_url, a); if (e) return e;
  7532. }
  7533. if (p->_proto_on_status) {
  7534. e = (*v)(p->_proto_on_status, a); if (e) return e;
  7535. }
  7536. if (p->_proto_on_body) {
  7537. e = (*v)(p->_proto_on_body, a); if (e) return e;
  7538. }
  7539. if (p->_proto_on_header) {
  7540. e = (*v)(p->_proto_on_header, a); if (e) return e;
  7541. }
  7542. if (p->_proto_on_headers_complete) {
  7543. e = (*v)(p->_proto_on_headers_complete, a); if (e) return e;
  7544. }
  7545. if (p->_proto_on_message_complete) {
  7546. e = (*v)(p->_proto_on_message_complete, a); if (e) return e;
  7547. }
  7548. if (p->_proto_on_chunk_header) {
  7549. e = (*v)(p->_proto_on_chunk_header, a); if (e) return e;
  7550. }
  7551. if (p->_proto_on_chunk_complete) {
  7552. e = (*v)(p->_proto_on_chunk_complete, a); if (e) return e;
  7553. }
  7554. if (p->_proto_on_message_begin) {
  7555. e = (*v)(p->_proto_on_message_begin, a); if (e) return e;
  7556. }
  7557. if (p->_last_error) {
  7558. e = (*v)(p->_last_error, a); if (e) return e;
  7559. }
  7560. if (p->py_buf.obj) {
  7561. e = (*v)(p->py_buf.obj, a); if (e) return e;
  7562. }
  7563. return 0;
  7564. }
  7565. static int __pyx_tp_clear_9httptools_6parser_6parser_HttpParser(PyObject *o) {
  7566. PyObject* tmp;
  7567. struct __pyx_obj_9httptools_6parser_6parser_HttpParser *p = (struct __pyx_obj_9httptools_6parser_6parser_HttpParser *)o;
  7568. tmp = ((PyObject*)p->_proto_on_url);
  7569. p->_proto_on_url = Py_None; Py_INCREF(Py_None);
  7570. Py_XDECREF(tmp);
  7571. tmp = ((PyObject*)p->_proto_on_status);
  7572. p->_proto_on_status = Py_None; Py_INCREF(Py_None);
  7573. Py_XDECREF(tmp);
  7574. tmp = ((PyObject*)p->_proto_on_body);
  7575. p->_proto_on_body = Py_None; Py_INCREF(Py_None);
  7576. Py_XDECREF(tmp);
  7577. tmp = ((PyObject*)p->_proto_on_header);
  7578. p->_proto_on_header = Py_None; Py_INCREF(Py_None);
  7579. Py_XDECREF(tmp);
  7580. tmp = ((PyObject*)p->_proto_on_headers_complete);
  7581. p->_proto_on_headers_complete = Py_None; Py_INCREF(Py_None);
  7582. Py_XDECREF(tmp);
  7583. tmp = ((PyObject*)p->_proto_on_message_complete);
  7584. p->_proto_on_message_complete = Py_None; Py_INCREF(Py_None);
  7585. Py_XDECREF(tmp);
  7586. tmp = ((PyObject*)p->_proto_on_chunk_header);
  7587. p->_proto_on_chunk_header = Py_None; Py_INCREF(Py_None);
  7588. Py_XDECREF(tmp);
  7589. tmp = ((PyObject*)p->_proto_on_chunk_complete);
  7590. p->_proto_on_chunk_complete = Py_None; Py_INCREF(Py_None);
  7591. Py_XDECREF(tmp);
  7592. tmp = ((PyObject*)p->_proto_on_message_begin);
  7593. p->_proto_on_message_begin = Py_None; Py_INCREF(Py_None);
  7594. Py_XDECREF(tmp);
  7595. tmp = ((PyObject*)p->_last_error);
  7596. p->_last_error = Py_None; Py_INCREF(Py_None);
  7597. Py_XDECREF(tmp);
  7598. Py_CLEAR(p->py_buf.obj);
  7599. return 0;
  7600. }
  7601. static PyMethodDef __pyx_methods_9httptools_6parser_6parser_HttpParser[] = {
  7602. {"get_http_version", (PyCFunction)__pyx_pw_9httptools_6parser_6parser_10HttpParser_5get_http_version, METH_NOARGS, 0},
  7603. {"should_keep_alive", (PyCFunction)__pyx_pw_9httptools_6parser_6parser_10HttpParser_7should_keep_alive, METH_NOARGS, 0},
  7604. {"should_upgrade", (PyCFunction)__pyx_pw_9httptools_6parser_6parser_10HttpParser_9should_upgrade, METH_NOARGS, 0},
  7605. {"feed_data", (PyCFunction)__pyx_pw_9httptools_6parser_6parser_10HttpParser_11feed_data, METH_O, 0},
  7606. {"__reduce_cython__", (PyCFunction)__pyx_pw_9httptools_6parser_6parser_10HttpParser_13__reduce_cython__, METH_NOARGS, 0},
  7607. {"__setstate_cython__", (PyCFunction)__pyx_pw_9httptools_6parser_6parser_10HttpParser_15__setstate_cython__, METH_O, 0},
  7608. {0, 0, 0, 0}
  7609. };
  7610. static PyTypeObject __pyx_type_9httptools_6parser_6parser_HttpParser = {
  7611. PyVarObject_HEAD_INIT(0, 0)
  7612. "httptools.parser.parser.HttpParser", /*tp_name*/
  7613. sizeof(struct __pyx_obj_9httptools_6parser_6parser_HttpParser), /*tp_basicsize*/
  7614. 0, /*tp_itemsize*/
  7615. __pyx_tp_dealloc_9httptools_6parser_6parser_HttpParser, /*tp_dealloc*/
  7616. 0, /*tp_print*/
  7617. 0, /*tp_getattr*/
  7618. 0, /*tp_setattr*/
  7619. #if PY_MAJOR_VERSION < 3
  7620. 0, /*tp_compare*/
  7621. #endif
  7622. #if PY_MAJOR_VERSION >= 3
  7623. 0, /*tp_as_async*/
  7624. #endif
  7625. 0, /*tp_repr*/
  7626. 0, /*tp_as_number*/
  7627. 0, /*tp_as_sequence*/
  7628. 0, /*tp_as_mapping*/
  7629. 0, /*tp_hash*/
  7630. 0, /*tp_call*/
  7631. 0, /*tp_str*/
  7632. 0, /*tp_getattro*/
  7633. 0, /*tp_setattro*/
  7634. 0, /*tp_as_buffer*/
  7635. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  7636. 0, /*tp_doc*/
  7637. __pyx_tp_traverse_9httptools_6parser_6parser_HttpParser, /*tp_traverse*/
  7638. __pyx_tp_clear_9httptools_6parser_6parser_HttpParser, /*tp_clear*/
  7639. 0, /*tp_richcompare*/
  7640. 0, /*tp_weaklistoffset*/
  7641. 0, /*tp_iter*/
  7642. 0, /*tp_iternext*/
  7643. __pyx_methods_9httptools_6parser_6parser_HttpParser, /*tp_methods*/
  7644. 0, /*tp_members*/
  7645. 0, /*tp_getset*/
  7646. 0, /*tp_base*/
  7647. 0, /*tp_dict*/
  7648. 0, /*tp_descr_get*/
  7649. 0, /*tp_descr_set*/
  7650. 0, /*tp_dictoffset*/
  7651. 0, /*tp_init*/
  7652. 0, /*tp_alloc*/
  7653. __pyx_tp_new_9httptools_6parser_6parser_HttpParser, /*tp_new*/
  7654. 0, /*tp_free*/
  7655. 0, /*tp_is_gc*/
  7656. 0, /*tp_bases*/
  7657. 0, /*tp_mro*/
  7658. 0, /*tp_cache*/
  7659. 0, /*tp_subclasses*/
  7660. 0, /*tp_weaklist*/
  7661. 0, /*tp_del*/
  7662. 0, /*tp_version_tag*/
  7663. #if PY_VERSION_HEX >= 0x030400a1
  7664. 0, /*tp_finalize*/
  7665. #endif
  7666. };
  7667. static struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpRequestParser __pyx_vtable_9httptools_6parser_6parser_HttpRequestParser;
  7668. static PyObject *__pyx_tp_new_9httptools_6parser_6parser_HttpRequestParser(PyTypeObject *t, PyObject *a, PyObject *k) {
  7669. struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser *p;
  7670. PyObject *o = __pyx_tp_new_9httptools_6parser_6parser_HttpParser(t, a, k);
  7671. if (unlikely(!o)) return 0;
  7672. p = ((struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser *)o);
  7673. p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser*)__pyx_vtabptr_9httptools_6parser_6parser_HttpRequestParser;
  7674. return o;
  7675. }
  7676. static PyMethodDef __pyx_methods_9httptools_6parser_6parser_HttpRequestParser[] = {
  7677. {"get_method", (PyCFunction)__pyx_pw_9httptools_6parser_6parser_17HttpRequestParser_3get_method, METH_NOARGS, 0},
  7678. {"__reduce_cython__", (PyCFunction)__pyx_pw_9httptools_6parser_6parser_17HttpRequestParser_5__reduce_cython__, METH_NOARGS, 0},
  7679. {"__setstate_cython__", (PyCFunction)__pyx_pw_9httptools_6parser_6parser_17HttpRequestParser_7__setstate_cython__, METH_O, 0},
  7680. {0, 0, 0, 0}
  7681. };
  7682. static PyTypeObject __pyx_type_9httptools_6parser_6parser_HttpRequestParser = {
  7683. PyVarObject_HEAD_INIT(0, 0)
  7684. "httptools.parser.parser.HttpRequestParser", /*tp_name*/
  7685. sizeof(struct __pyx_obj_9httptools_6parser_6parser_HttpRequestParser), /*tp_basicsize*/
  7686. 0, /*tp_itemsize*/
  7687. __pyx_tp_dealloc_9httptools_6parser_6parser_HttpParser, /*tp_dealloc*/
  7688. 0, /*tp_print*/
  7689. 0, /*tp_getattr*/
  7690. 0, /*tp_setattr*/
  7691. #if PY_MAJOR_VERSION < 3
  7692. 0, /*tp_compare*/
  7693. #endif
  7694. #if PY_MAJOR_VERSION >= 3
  7695. 0, /*tp_as_async*/
  7696. #endif
  7697. 0, /*tp_repr*/
  7698. 0, /*tp_as_number*/
  7699. 0, /*tp_as_sequence*/
  7700. 0, /*tp_as_mapping*/
  7701. 0, /*tp_hash*/
  7702. 0, /*tp_call*/
  7703. 0, /*tp_str*/
  7704. 0, /*tp_getattro*/
  7705. 0, /*tp_setattro*/
  7706. 0, /*tp_as_buffer*/
  7707. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  7708. 0, /*tp_doc*/
  7709. __pyx_tp_traverse_9httptools_6parser_6parser_HttpParser, /*tp_traverse*/
  7710. __pyx_tp_clear_9httptools_6parser_6parser_HttpParser, /*tp_clear*/
  7711. 0, /*tp_richcompare*/
  7712. 0, /*tp_weaklistoffset*/
  7713. 0, /*tp_iter*/
  7714. 0, /*tp_iternext*/
  7715. __pyx_methods_9httptools_6parser_6parser_HttpRequestParser, /*tp_methods*/
  7716. 0, /*tp_members*/
  7717. 0, /*tp_getset*/
  7718. 0, /*tp_base*/
  7719. 0, /*tp_dict*/
  7720. 0, /*tp_descr_get*/
  7721. 0, /*tp_descr_set*/
  7722. 0, /*tp_dictoffset*/
  7723. __pyx_pw_9httptools_6parser_6parser_17HttpRequestParser_1__init__, /*tp_init*/
  7724. 0, /*tp_alloc*/
  7725. __pyx_tp_new_9httptools_6parser_6parser_HttpRequestParser, /*tp_new*/
  7726. 0, /*tp_free*/
  7727. 0, /*tp_is_gc*/
  7728. 0, /*tp_bases*/
  7729. 0, /*tp_mro*/
  7730. 0, /*tp_cache*/
  7731. 0, /*tp_subclasses*/
  7732. 0, /*tp_weaklist*/
  7733. 0, /*tp_del*/
  7734. 0, /*tp_version_tag*/
  7735. #if PY_VERSION_HEX >= 0x030400a1
  7736. 0, /*tp_finalize*/
  7737. #endif
  7738. };
  7739. static struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpResponseParser __pyx_vtable_9httptools_6parser_6parser_HttpResponseParser;
  7740. static PyObject *__pyx_tp_new_9httptools_6parser_6parser_HttpResponseParser(PyTypeObject *t, PyObject *a, PyObject *k) {
  7741. struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser *p;
  7742. PyObject *o = __pyx_tp_new_9httptools_6parser_6parser_HttpParser(t, a, k);
  7743. if (unlikely(!o)) return 0;
  7744. p = ((struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser *)o);
  7745. p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9httptools_6parser_6parser_HttpParser*)__pyx_vtabptr_9httptools_6parser_6parser_HttpResponseParser;
  7746. return o;
  7747. }
  7748. static PyMethodDef __pyx_methods_9httptools_6parser_6parser_HttpResponseParser[] = {
  7749. {"get_status_code", (PyCFunction)__pyx_pw_9httptools_6parser_6parser_18HttpResponseParser_3get_status_code, METH_NOARGS, 0},
  7750. {"__reduce_cython__", (PyCFunction)__pyx_pw_9httptools_6parser_6parser_18HttpResponseParser_5__reduce_cython__, METH_NOARGS, 0},
  7751. {"__setstate_cython__", (PyCFunction)__pyx_pw_9httptools_6parser_6parser_18HttpResponseParser_7__setstate_cython__, METH_O, 0},
  7752. {0, 0, 0, 0}
  7753. };
  7754. static PyTypeObject __pyx_type_9httptools_6parser_6parser_HttpResponseParser = {
  7755. PyVarObject_HEAD_INIT(0, 0)
  7756. "httptools.parser.parser.HttpResponseParser", /*tp_name*/
  7757. sizeof(struct __pyx_obj_9httptools_6parser_6parser_HttpResponseParser), /*tp_basicsize*/
  7758. 0, /*tp_itemsize*/
  7759. __pyx_tp_dealloc_9httptools_6parser_6parser_HttpParser, /*tp_dealloc*/
  7760. 0, /*tp_print*/
  7761. 0, /*tp_getattr*/
  7762. 0, /*tp_setattr*/
  7763. #if PY_MAJOR_VERSION < 3
  7764. 0, /*tp_compare*/
  7765. #endif
  7766. #if PY_MAJOR_VERSION >= 3
  7767. 0, /*tp_as_async*/
  7768. #endif
  7769. 0, /*tp_repr*/
  7770. 0, /*tp_as_number*/
  7771. 0, /*tp_as_sequence*/
  7772. 0, /*tp_as_mapping*/
  7773. 0, /*tp_hash*/
  7774. 0, /*tp_call*/
  7775. 0, /*tp_str*/
  7776. 0, /*tp_getattro*/
  7777. 0, /*tp_setattro*/
  7778. 0, /*tp_as_buffer*/
  7779. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  7780. 0, /*tp_doc*/
  7781. __pyx_tp_traverse_9httptools_6parser_6parser_HttpParser, /*tp_traverse*/
  7782. __pyx_tp_clear_9httptools_6parser_6parser_HttpParser, /*tp_clear*/
  7783. 0, /*tp_richcompare*/
  7784. 0, /*tp_weaklistoffset*/
  7785. 0, /*tp_iter*/
  7786. 0, /*tp_iternext*/
  7787. __pyx_methods_9httptools_6parser_6parser_HttpResponseParser, /*tp_methods*/
  7788. 0, /*tp_members*/
  7789. 0, /*tp_getset*/
  7790. 0, /*tp_base*/
  7791. 0, /*tp_dict*/
  7792. 0, /*tp_descr_get*/
  7793. 0, /*tp_descr_set*/
  7794. 0, /*tp_dictoffset*/
  7795. __pyx_pw_9httptools_6parser_6parser_18HttpResponseParser_1__init__, /*tp_init*/
  7796. 0, /*tp_alloc*/
  7797. __pyx_tp_new_9httptools_6parser_6parser_HttpResponseParser, /*tp_new*/
  7798. 0, /*tp_free*/
  7799. 0, /*tp_is_gc*/
  7800. 0, /*tp_bases*/
  7801. 0, /*tp_mro*/
  7802. 0, /*tp_cache*/
  7803. 0, /*tp_subclasses*/
  7804. 0, /*tp_weaklist*/
  7805. 0, /*tp_del*/
  7806. 0, /*tp_version_tag*/
  7807. #if PY_VERSION_HEX >= 0x030400a1
  7808. 0, /*tp_finalize*/
  7809. #endif
  7810. };
  7811. static struct __pyx_obj_9httptools_6parser_6parser_URL *__pyx_freelist_9httptools_6parser_6parser_URL[250];
  7812. static int __pyx_freecount_9httptools_6parser_6parser_URL = 0;
  7813. static PyObject *__pyx_tp_new_9httptools_6parser_6parser_URL(PyTypeObject *t, PyObject *a, PyObject *k) {
  7814. struct __pyx_obj_9httptools_6parser_6parser_URL *p;
  7815. PyObject *o;
  7816. if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9httptools_6parser_6parser_URL > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9httptools_6parser_6parser_URL)) & ((t->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)) == 0))) {
  7817. o = (PyObject*)__pyx_freelist_9httptools_6parser_6parser_URL[--__pyx_freecount_9httptools_6parser_6parser_URL];
  7818. memset(o, 0, sizeof(struct __pyx_obj_9httptools_6parser_6parser_URL));
  7819. (void) PyObject_INIT(o, t);
  7820. PyObject_GC_Track(o);
  7821. } else {
  7822. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  7823. o = (*t->tp_alloc)(t, 0);
  7824. } else {
  7825. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  7826. }
  7827. if (unlikely(!o)) return 0;
  7828. }
  7829. p = ((struct __pyx_obj_9httptools_6parser_6parser_URL *)o);
  7830. p->schema = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7831. p->host = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7832. p->port = Py_None; Py_INCREF(Py_None);
  7833. p->path = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7834. p->query = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7835. p->fragment = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7836. p->userinfo = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7837. if (unlikely(__pyx_pw_9httptools_6parser_6parser_3URL_1__cinit__(o, a, k) < 0)) goto bad;
  7838. return o;
  7839. bad:
  7840. Py_DECREF(o); o = 0;
  7841. return NULL;
  7842. }
  7843. static void __pyx_tp_dealloc_9httptools_6parser_6parser_URL(PyObject *o) {
  7844. struct __pyx_obj_9httptools_6parser_6parser_URL *p = (struct __pyx_obj_9httptools_6parser_6parser_URL *)o;
  7845. #if CYTHON_USE_TP_FINALIZE
  7846. if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
  7847. if (PyObject_CallFinalizerFromDealloc(o)) return;
  7848. }
  7849. #endif
  7850. PyObject_GC_UnTrack(o);
  7851. Py_CLEAR(p->schema);
  7852. Py_CLEAR(p->host);
  7853. Py_CLEAR(p->port);
  7854. Py_CLEAR(p->path);
  7855. Py_CLEAR(p->query);
  7856. Py_CLEAR(p->fragment);
  7857. Py_CLEAR(p->userinfo);
  7858. if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9httptools_6parser_6parser_URL < 250) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9httptools_6parser_6parser_URL)) & ((Py_TYPE(o)->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)) == 0))) {
  7859. __pyx_freelist_9httptools_6parser_6parser_URL[__pyx_freecount_9httptools_6parser_6parser_URL++] = ((struct __pyx_obj_9httptools_6parser_6parser_URL *)o);
  7860. } else {
  7861. (*Py_TYPE(o)->tp_free)(o);
  7862. }
  7863. }
  7864. static int __pyx_tp_traverse_9httptools_6parser_6parser_URL(PyObject *o, visitproc v, void *a) {
  7865. int e;
  7866. struct __pyx_obj_9httptools_6parser_6parser_URL *p = (struct __pyx_obj_9httptools_6parser_6parser_URL *)o;
  7867. if (p->port) {
  7868. e = (*v)(p->port, a); if (e) return e;
  7869. }
  7870. return 0;
  7871. }
  7872. static int __pyx_tp_clear_9httptools_6parser_6parser_URL(PyObject *o) {
  7873. PyObject* tmp;
  7874. struct __pyx_obj_9httptools_6parser_6parser_URL *p = (struct __pyx_obj_9httptools_6parser_6parser_URL *)o;
  7875. tmp = ((PyObject*)p->port);
  7876. p->port = Py_None; Py_INCREF(Py_None);
  7877. Py_XDECREF(tmp);
  7878. return 0;
  7879. }
  7880. static PyObject *__pyx_getprop_9httptools_6parser_6parser_3URL_schema(PyObject *o, CYTHON_UNUSED void *x) {
  7881. return __pyx_pw_9httptools_6parser_6parser_3URL_6schema_1__get__(o);
  7882. }
  7883. static PyObject *__pyx_getprop_9httptools_6parser_6parser_3URL_host(PyObject *o, CYTHON_UNUSED void *x) {
  7884. return __pyx_pw_9httptools_6parser_6parser_3URL_4host_1__get__(o);
  7885. }
  7886. static PyObject *__pyx_getprop_9httptools_6parser_6parser_3URL_port(PyObject *o, CYTHON_UNUSED void *x) {
  7887. return __pyx_pw_9httptools_6parser_6parser_3URL_4port_1__get__(o);
  7888. }
  7889. static PyObject *__pyx_getprop_9httptools_6parser_6parser_3URL_path(PyObject *o, CYTHON_UNUSED void *x) {
  7890. return __pyx_pw_9httptools_6parser_6parser_3URL_4path_1__get__(o);
  7891. }
  7892. static PyObject *__pyx_getprop_9httptools_6parser_6parser_3URL_query(PyObject *o, CYTHON_UNUSED void *x) {
  7893. return __pyx_pw_9httptools_6parser_6parser_3URL_5query_1__get__(o);
  7894. }
  7895. static PyObject *__pyx_getprop_9httptools_6parser_6parser_3URL_fragment(PyObject *o, CYTHON_UNUSED void *x) {
  7896. return __pyx_pw_9httptools_6parser_6parser_3URL_8fragment_1__get__(o);
  7897. }
  7898. static PyObject *__pyx_getprop_9httptools_6parser_6parser_3URL_userinfo(PyObject *o, CYTHON_UNUSED void *x) {
  7899. return __pyx_pw_9httptools_6parser_6parser_3URL_8userinfo_1__get__(o);
  7900. }
  7901. static PyMethodDef __pyx_methods_9httptools_6parser_6parser_URL[] = {
  7902. {"__reduce_cython__", (PyCFunction)__pyx_pw_9httptools_6parser_6parser_3URL_5__reduce_cython__, METH_NOARGS, 0},
  7903. {"__setstate_cython__", (PyCFunction)__pyx_pw_9httptools_6parser_6parser_3URL_7__setstate_cython__, METH_O, 0},
  7904. {0, 0, 0, 0}
  7905. };
  7906. static struct PyGetSetDef __pyx_getsets_9httptools_6parser_6parser_URL[] = {
  7907. {(char *)"schema", __pyx_getprop_9httptools_6parser_6parser_3URL_schema, 0, (char *)0, 0},
  7908. {(char *)"host", __pyx_getprop_9httptools_6parser_6parser_3URL_host, 0, (char *)0, 0},
  7909. {(char *)"port", __pyx_getprop_9httptools_6parser_6parser_3URL_port, 0, (char *)0, 0},
  7910. {(char *)"path", __pyx_getprop_9httptools_6parser_6parser_3URL_path, 0, (char *)0, 0},
  7911. {(char *)"query", __pyx_getprop_9httptools_6parser_6parser_3URL_query, 0, (char *)0, 0},
  7912. {(char *)"fragment", __pyx_getprop_9httptools_6parser_6parser_3URL_fragment, 0, (char *)0, 0},
  7913. {(char *)"userinfo", __pyx_getprop_9httptools_6parser_6parser_3URL_userinfo, 0, (char *)0, 0},
  7914. {0, 0, 0, 0, 0}
  7915. };
  7916. static PyTypeObject __pyx_type_9httptools_6parser_6parser_URL = {
  7917. PyVarObject_HEAD_INIT(0, 0)
  7918. "httptools.parser.parser.URL", /*tp_name*/
  7919. sizeof(struct __pyx_obj_9httptools_6parser_6parser_URL), /*tp_basicsize*/
  7920. 0, /*tp_itemsize*/
  7921. __pyx_tp_dealloc_9httptools_6parser_6parser_URL, /*tp_dealloc*/
  7922. 0, /*tp_print*/
  7923. 0, /*tp_getattr*/
  7924. 0, /*tp_setattr*/
  7925. #if PY_MAJOR_VERSION < 3
  7926. 0, /*tp_compare*/
  7927. #endif
  7928. #if PY_MAJOR_VERSION >= 3
  7929. 0, /*tp_as_async*/
  7930. #endif
  7931. __pyx_pw_9httptools_6parser_6parser_3URL_3__repr__, /*tp_repr*/
  7932. 0, /*tp_as_number*/
  7933. 0, /*tp_as_sequence*/
  7934. 0, /*tp_as_mapping*/
  7935. 0, /*tp_hash*/
  7936. 0, /*tp_call*/
  7937. 0, /*tp_str*/
  7938. 0, /*tp_getattro*/
  7939. 0, /*tp_setattro*/
  7940. 0, /*tp_as_buffer*/
  7941. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  7942. 0, /*tp_doc*/
  7943. __pyx_tp_traverse_9httptools_6parser_6parser_URL, /*tp_traverse*/
  7944. __pyx_tp_clear_9httptools_6parser_6parser_URL, /*tp_clear*/
  7945. 0, /*tp_richcompare*/
  7946. 0, /*tp_weaklistoffset*/
  7947. 0, /*tp_iter*/
  7948. 0, /*tp_iternext*/
  7949. __pyx_methods_9httptools_6parser_6parser_URL, /*tp_methods*/
  7950. 0, /*tp_members*/
  7951. __pyx_getsets_9httptools_6parser_6parser_URL, /*tp_getset*/
  7952. 0, /*tp_base*/
  7953. 0, /*tp_dict*/
  7954. 0, /*tp_descr_get*/
  7955. 0, /*tp_descr_set*/
  7956. 0, /*tp_dictoffset*/
  7957. 0, /*tp_init*/
  7958. 0, /*tp_alloc*/
  7959. __pyx_tp_new_9httptools_6parser_6parser_URL, /*tp_new*/
  7960. 0, /*tp_free*/
  7961. 0, /*tp_is_gc*/
  7962. 0, /*tp_bases*/
  7963. 0, /*tp_mro*/
  7964. 0, /*tp_cache*/
  7965. 0, /*tp_subclasses*/
  7966. 0, /*tp_weaklist*/
  7967. 0, /*tp_del*/
  7968. 0, /*tp_version_tag*/
  7969. #if PY_VERSION_HEX >= 0x030400a1
  7970. 0, /*tp_finalize*/
  7971. #endif
  7972. };
  7973. static PyMethodDef __pyx_methods[] = {
  7974. {0, 0, 0, 0}
  7975. };
  7976. #if PY_MAJOR_VERSION >= 3
  7977. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7978. static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
  7979. static int __pyx_pymod_exec_parser(PyObject* module); /*proto*/
  7980. static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  7981. {Py_mod_create, (void*)__pyx_pymod_create},
  7982. {Py_mod_exec, (void*)__pyx_pymod_exec_parser},
  7983. {0, NULL}
  7984. };
  7985. #endif
  7986. static struct PyModuleDef __pyx_moduledef = {
  7987. PyModuleDef_HEAD_INIT,
  7988. "parser",
  7989. 0, /* m_doc */
  7990. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7991. 0, /* m_size */
  7992. #else
  7993. -1, /* m_size */
  7994. #endif
  7995. __pyx_methods /* m_methods */,
  7996. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7997. __pyx_moduledef_slots, /* m_slots */
  7998. #else
  7999. NULL, /* m_reload */
  8000. #endif
  8001. NULL, /* m_traverse */
  8002. NULL, /* m_clear */
  8003. NULL /* m_free */
  8004. };
  8005. #endif
  8006. #ifndef CYTHON_SMALL_CODE
  8007. #if defined(__clang__)
  8008. #define CYTHON_SMALL_CODE
  8009. #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
  8010. #define CYTHON_SMALL_CODE __attribute__((cold))
  8011. #else
  8012. #define CYTHON_SMALL_CODE
  8013. #endif
  8014. #endif
  8015. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  8016. {&__pyx_kp_u_, __pyx_k_, sizeof(__pyx_k_), 0, 1, 0, 0},
  8017. {&__pyx_n_s_BaseException, __pyx_k_BaseException, sizeof(__pyx_k_BaseException), 0, 0, 1, 1},
  8018. {&__pyx_n_s_HttpParserCallbackError, __pyx_k_HttpParserCallbackError, sizeof(__pyx_k_HttpParserCallbackError), 0, 0, 1, 1},
  8019. {&__pyx_n_s_HttpParserError, __pyx_k_HttpParserError, sizeof(__pyx_k_HttpParserError), 0, 0, 1, 1},
  8020. {&__pyx_n_s_HttpParserInvalidMethodError, __pyx_k_HttpParserInvalidMethodError, sizeof(__pyx_k_HttpParserInvalidMethodError), 0, 0, 1, 1},
  8021. {&__pyx_n_s_HttpParserInvalidStatusError, __pyx_k_HttpParserInvalidStatusError, sizeof(__pyx_k_HttpParserInvalidStatusError), 0, 0, 1, 1},
  8022. {&__pyx_n_s_HttpParserInvalidURLError, __pyx_k_HttpParserInvalidURLError, sizeof(__pyx_k_HttpParserInvalidURLError), 0, 0, 1, 1},
  8023. {&__pyx_n_s_HttpParserUpgrade, __pyx_k_HttpParserUpgrade, sizeof(__pyx_k_HttpParserUpgrade), 0, 0, 1, 1},
  8024. {&__pyx_n_s_HttpRequestParser, __pyx_k_HttpRequestParser, sizeof(__pyx_k_HttpRequestParser), 0, 0, 1, 1},
  8025. {&__pyx_n_u_HttpRequestParser, __pyx_k_HttpRequestParser, sizeof(__pyx_k_HttpRequestParser), 0, 1, 0, 1},
  8026. {&__pyx_n_s_HttpResponseParser, __pyx_k_HttpResponseParser, sizeof(__pyx_k_HttpResponseParser), 0, 0, 1, 1},
  8027. {&__pyx_n_u_HttpResponseParser, __pyx_k_HttpResponseParser, sizeof(__pyx_k_HttpResponseParser), 0, 1, 0, 1},
  8028. {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
  8029. {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  8030. {&__pyx_n_s_URL, __pyx_k_URL, sizeof(__pyx_k_URL), 0, 0, 1, 1},
  8031. {&__pyx_kp_u_URL_schema_r_host_r_port_r_path, __pyx_k_URL_schema_r_host_r_port_r_path, sizeof(__pyx_k_URL_schema_r_host_r_port_r_path), 0, 1, 0, 0},
  8032. {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
  8033. {&__pyx_n_s_buf_data, __pyx_k_buf_data, sizeof(__pyx_k_buf_data), 0, 0, 1, 1},
  8034. {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  8035. {&__pyx_n_s_context, __pyx_k_context, sizeof(__pyx_k_context), 0, 0, 1, 1},
  8036. {&__pyx_n_s_errors, __pyx_k_errors, sizeof(__pyx_k_errors), 0, 0, 1, 1},
  8037. {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  8038. {&__pyx_n_s_fragment, __pyx_k_fragment, sizeof(__pyx_k_fragment), 0, 0, 1, 1},
  8039. {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  8040. {&__pyx_n_s_host, __pyx_k_host, sizeof(__pyx_k_host), 0, 0, 1, 1},
  8041. {&__pyx_n_s_httptools_parser_parser, __pyx_k_httptools_parser_parser, sizeof(__pyx_k_httptools_parser_parser), 0, 0, 1, 1},
  8042. {&__pyx_kp_s_httptools_parser_parser_pyx, __pyx_k_httptools_parser_parser_pyx, sizeof(__pyx_k_httptools_parser_parser_pyx), 0, 0, 1, 0},
  8043. {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  8044. {&__pyx_kp_u_invalid_headers_state, __pyx_k_invalid_headers_state, sizeof(__pyx_k_invalid_headers_state), 0, 1, 0, 0},
  8045. {&__pyx_kp_u_invalid_url_r, __pyx_k_invalid_url_r, sizeof(__pyx_k_invalid_url_r), 0, 1, 0, 0},
  8046. {&__pyx_n_s_ln, __pyx_k_ln, sizeof(__pyx_k_ln), 0, 0, 1, 1},
  8047. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  8048. {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  8049. {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
  8050. {&__pyx_kp_u_not_all_of_the_data_was_parsed, __pyx_k_not_all_of_the_data_was_parsed, sizeof(__pyx_k_not_all_of_the_data_was_parsed), 0, 1, 0, 0},
  8051. {&__pyx_n_s_off, __pyx_k_off, sizeof(__pyx_k_off), 0, 0, 1, 1},
  8052. {&__pyx_n_u_on_body, __pyx_k_on_body, sizeof(__pyx_k_on_body), 0, 1, 0, 1},
  8053. {&__pyx_n_u_on_chunk_complete, __pyx_k_on_chunk_complete, sizeof(__pyx_k_on_chunk_complete), 0, 1, 0, 1},
  8054. {&__pyx_n_u_on_chunk_header, __pyx_k_on_chunk_header, sizeof(__pyx_k_on_chunk_header), 0, 1, 0, 1},
  8055. {&__pyx_n_u_on_header, __pyx_k_on_header, sizeof(__pyx_k_on_header), 0, 1, 0, 1},
  8056. {&__pyx_n_u_on_headers_complete, __pyx_k_on_headers_complete, sizeof(__pyx_k_on_headers_complete), 0, 1, 0, 1},
  8057. {&__pyx_n_u_on_message_begin, __pyx_k_on_message_begin, sizeof(__pyx_k_on_message_begin), 0, 1, 0, 1},
  8058. {&__pyx_n_u_on_message_complete, __pyx_k_on_message_complete, sizeof(__pyx_k_on_message_complete), 0, 1, 0, 1},
  8059. {&__pyx_n_u_on_status, __pyx_k_on_status, sizeof(__pyx_k_on_status), 0, 1, 0, 1},
  8060. {&__pyx_n_u_on_url, __pyx_k_on_url, sizeof(__pyx_k_on_url), 0, 1, 0, 1},
  8061. {&__pyx_n_s_parse_url, __pyx_k_parse_url, sizeof(__pyx_k_parse_url), 0, 0, 1, 1},
  8062. {&__pyx_n_u_parse_url, __pyx_k_parse_url, sizeof(__pyx_k_parse_url), 0, 1, 0, 1},
  8063. {&__pyx_n_s_parsed, __pyx_k_parsed, sizeof(__pyx_k_parsed), 0, 0, 1, 1},
  8064. {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1},
  8065. {&__pyx_n_s_port, __pyx_k_port, sizeof(__pyx_k_port), 0, 0, 1, 1},
  8066. {&__pyx_n_s_protocol, __pyx_k_protocol, sizeof(__pyx_k_protocol), 0, 0, 1, 1},
  8067. {&__pyx_n_s_py_buf, __pyx_k_py_buf, sizeof(__pyx_k_py_buf), 0, 0, 1, 1},
  8068. {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  8069. {&__pyx_n_s_query, __pyx_k_query, sizeof(__pyx_k_query), 0, 0, 1, 1},
  8070. {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  8071. {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  8072. {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  8073. {&__pyx_n_s_res, __pyx_k_res, sizeof(__pyx_k_res), 0, 0, 1, 1},
  8074. {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1},
  8075. {&__pyx_n_s_schema, __pyx_k_schema, sizeof(__pyx_k_schema), 0, 0, 1, 1},
  8076. {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  8077. {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  8078. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  8079. {&__pyx_n_s_url, __pyx_k_url, sizeof(__pyx_k_url), 0, 0, 1, 1},
  8080. {&__pyx_n_s_userinfo, __pyx_k_userinfo, sizeof(__pyx_k_userinfo), 0, 0, 1, 1},
  8081. {0, 0, 0, 0, 0, 0, 0}
  8082. };
  8083. static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  8084. __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 48, __pyx_L1_error)
  8085. __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error)
  8086. __pyx_builtin_BaseException = __Pyx_GetBuiltinName(__pyx_n_s_BaseException); if (!__pyx_builtin_BaseException) __PYX_ERR(0, 234, __pyx_L1_error)
  8087. return 0;
  8088. __pyx_L1_error:;
  8089. return -1;
  8090. }
  8091. static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  8092. __Pyx_RefNannyDeclarations
  8093. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  8094. /* "(tree fragment)":2
  8095. * def __reduce_cython__(self):
  8096. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  8097. * def __setstate_cython__(self, __pyx_state):
  8098. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  8099. */
  8100. __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 2, __pyx_L1_error)
  8101. __Pyx_GOTREF(__pyx_tuple__2);
  8102. __Pyx_GIVEREF(__pyx_tuple__2);
  8103. /* "(tree fragment)":4
  8104. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  8105. * def __setstate_cython__(self, __pyx_state):
  8106. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  8107. */
  8108. __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 4, __pyx_L1_error)
  8109. __Pyx_GOTREF(__pyx_tuple__3);
  8110. __Pyx_GIVEREF(__pyx_tuple__3);
  8111. /* "(tree fragment)":2
  8112. * def __reduce_cython__(self):
  8113. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  8114. * def __setstate_cython__(self, __pyx_state):
  8115. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  8116. */
  8117. __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 2, __pyx_L1_error)
  8118. __Pyx_GOTREF(__pyx_tuple__4);
  8119. __Pyx_GIVEREF(__pyx_tuple__4);
  8120. /* "(tree fragment)":4
  8121. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  8122. * def __setstate_cython__(self, __pyx_state):
  8123. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  8124. */
  8125. __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 4, __pyx_L1_error)
  8126. __Pyx_GOTREF(__pyx_tuple__5);
  8127. __Pyx_GIVEREF(__pyx_tuple__5);
  8128. /* "(tree fragment)":2
  8129. * def __reduce_cython__(self):
  8130. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  8131. * def __setstate_cython__(self, __pyx_state):
  8132. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  8133. */
  8134. __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 2, __pyx_L1_error)
  8135. __Pyx_GOTREF(__pyx_tuple__6);
  8136. __Pyx_GIVEREF(__pyx_tuple__6);
  8137. /* "(tree fragment)":4
  8138. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  8139. * def __setstate_cython__(self, __pyx_state):
  8140. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  8141. */
  8142. __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 4, __pyx_L1_error)
  8143. __Pyx_GOTREF(__pyx_tuple__7);
  8144. __Pyx_GIVEREF(__pyx_tuple__7);
  8145. /* "(tree fragment)":2
  8146. * def __reduce_cython__(self):
  8147. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  8148. * def __setstate_cython__(self, __pyx_state):
  8149. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  8150. */
  8151. __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 2, __pyx_L1_error)
  8152. __Pyx_GOTREF(__pyx_tuple__8);
  8153. __Pyx_GIVEREF(__pyx_tuple__8);
  8154. /* "(tree fragment)":4
  8155. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  8156. * def __setstate_cython__(self, __pyx_state):
  8157. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  8158. */
  8159. __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 4, __pyx_L1_error)
  8160. __Pyx_GOTREF(__pyx_tuple__9);
  8161. __Pyx_GIVEREF(__pyx_tuple__9);
  8162. /* "httptools/parser/parser.pyx":424
  8163. *
  8164. * if not url:
  8165. * return URL(None, None, None, None, None, None, None) # <<<<<<<<<<<<<<
  8166. *
  8167. * parsed = <cparser.http_parser_url*> \
  8168. */
  8169. __pyx_tuple__10 = PyTuple_Pack(7, Py_None, Py_None, Py_None, Py_None, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 424, __pyx_L1_error)
  8170. __Pyx_GOTREF(__pyx_tuple__10);
  8171. __Pyx_GIVEREF(__pyx_tuple__10);
  8172. /* "httptools/parser/parser.pyx":22
  8173. *
  8174. *
  8175. * __all__ = ('HttpRequestParser', 'HttpResponseParser', 'parse_url') # <<<<<<<<<<<<<<
  8176. *
  8177. *
  8178. */
  8179. __pyx_tuple__11 = PyTuple_Pack(3, __pyx_n_u_HttpRequestParser, __pyx_n_u_HttpResponseParser, __pyx_n_u_parse_url); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 22, __pyx_L1_error)
  8180. __Pyx_GOTREF(__pyx_tuple__11);
  8181. __Pyx_GIVEREF(__pyx_tuple__11);
  8182. /* "httptools/parser/parser.pyx":406
  8183. *
  8184. *
  8185. * def parse_url(url): # <<<<<<<<<<<<<<
  8186. * cdef:
  8187. * Py_buffer py_buf
  8188. */
  8189. __pyx_tuple__12 = PyTuple_Pack(15, __pyx_n_s_url, __pyx_n_s_py_buf, __pyx_n_s_buf_data, __pyx_n_s_parsed, __pyx_n_s_res, __pyx_n_s_schema, __pyx_n_s_host, __pyx_n_s_port, __pyx_n_s_path, __pyx_n_s_query, __pyx_n_s_fragment, __pyx_n_s_userinfo, __pyx_n_s_result, __pyx_n_s_off, __pyx_n_s_ln); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 406, __pyx_L1_error)
  8190. __Pyx_GOTREF(__pyx_tuple__12);
  8191. __Pyx_GIVEREF(__pyx_tuple__12);
  8192. __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(1, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__12, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_httptools_parser_parser_pyx, __pyx_n_s_parse_url, 406, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 406, __pyx_L1_error)
  8193. __Pyx_RefNannyFinishContext();
  8194. return 0;
  8195. __pyx_L1_error:;
  8196. __Pyx_RefNannyFinishContext();
  8197. return -1;
  8198. }
  8199. static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  8200. if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  8201. return 0;
  8202. __pyx_L1_error:;
  8203. return -1;
  8204. }
  8205. static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
  8206. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
  8207. static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
  8208. static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
  8209. static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
  8210. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
  8211. static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
  8212. static int __Pyx_modinit_global_init_code(void) {
  8213. __Pyx_RefNannyDeclarations
  8214. __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  8215. /*--- Global init code ---*/
  8216. __Pyx_RefNannyFinishContext();
  8217. return 0;
  8218. }
  8219. static int __Pyx_modinit_variable_export_code(void) {
  8220. __Pyx_RefNannyDeclarations
  8221. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  8222. /*--- Variable export code ---*/
  8223. __Pyx_RefNannyFinishContext();
  8224. return 0;
  8225. }
  8226. static int __Pyx_modinit_function_export_code(void) {
  8227. __Pyx_RefNannyDeclarations
  8228. __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  8229. /*--- Function export code ---*/
  8230. __Pyx_RefNannyFinishContext();
  8231. return 0;
  8232. }
  8233. static int __Pyx_modinit_type_init_code(void) {
  8234. __Pyx_RefNannyDeclarations
  8235. __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  8236. /*--- Type init code ---*/
  8237. __pyx_vtabptr_9httptools_6parser_6parser_HttpParser = &__pyx_vtable_9httptools_6parser_6parser_HttpParser;
  8238. __pyx_vtable_9httptools_6parser_6parser_HttpParser._init = (PyObject *(*)(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *, PyObject *, enum http_parser_type))__pyx_f_9httptools_6parser_6parser_10HttpParser__init;
  8239. __pyx_vtable_9httptools_6parser_6parser_HttpParser._maybe_call_on_header = (PyObject *(*)(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *))__pyx_f_9httptools_6parser_6parser_10HttpParser__maybe_call_on_header;
  8240. __pyx_vtable_9httptools_6parser_6parser_HttpParser._on_header_field = (PyObject *(*)(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *, PyObject *))__pyx_f_9httptools_6parser_6parser_10HttpParser__on_header_field;
  8241. __pyx_vtable_9httptools_6parser_6parser_HttpParser._on_header_value = (PyObject *(*)(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *, PyObject *))__pyx_f_9httptools_6parser_6parser_10HttpParser__on_header_value;
  8242. __pyx_vtable_9httptools_6parser_6parser_HttpParser._on_headers_complete = (PyObject *(*)(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *))__pyx_f_9httptools_6parser_6parser_10HttpParser__on_headers_complete;
  8243. __pyx_vtable_9httptools_6parser_6parser_HttpParser._on_chunk_header = (PyObject *(*)(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *))__pyx_f_9httptools_6parser_6parser_10HttpParser__on_chunk_header;
  8244. __pyx_vtable_9httptools_6parser_6parser_HttpParser._on_chunk_complete = (PyObject *(*)(struct __pyx_obj_9httptools_6parser_6parser_HttpParser *))__pyx_f_9httptools_6parser_6parser_10HttpParser__on_chunk_complete;
  8245. if (PyType_Ready(&__pyx_type_9httptools_6parser_6parser_HttpParser) < 0) __PYX_ERR(0, 26, __pyx_L1_error)
  8246. __pyx_type_9httptools_6parser_6parser_HttpParser.tp_print = 0;
  8247. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9httptools_6parser_6parser_HttpParser.tp_dictoffset && __pyx_type_9httptools_6parser_6parser_HttpParser.tp_getattro == PyObject_GenericGetAttr)) {
  8248. __pyx_type_9httptools_6parser_6parser_HttpParser.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  8249. }
  8250. if (__Pyx_SetVtable(__pyx_type_9httptools_6parser_6parser_HttpParser.tp_dict, __pyx_vtabptr_9httptools_6parser_6parser_HttpParser) < 0) __PYX_ERR(0, 26, __pyx_L1_error)
  8251. if (__Pyx_setup_reduce((PyObject*)&__pyx_type_9httptools_6parser_6parser_HttpParser) < 0) __PYX_ERR(0, 26, __pyx_L1_error)
  8252. __pyx_ptype_9httptools_6parser_6parser_HttpParser = &__pyx_type_9httptools_6parser_6parser_HttpParser;
  8253. __pyx_vtabptr_9httptools_6parser_6parser_HttpRequestParser = &__pyx_vtable_9httptools_6parser_6parser_HttpRequestParser;
  8254. __pyx_vtable_9httptools_6parser_6parser_HttpRequestParser.__pyx_base = *__pyx_vtabptr_9httptools_6parser_6parser_HttpParser;
  8255. __pyx_type_9httptools_6parser_6parser_HttpRequestParser.tp_base = __pyx_ptype_9httptools_6parser_6parser_HttpParser;
  8256. if (PyType_Ready(&__pyx_type_9httptools_6parser_6parser_HttpRequestParser) < 0) __PYX_ERR(0, 202, __pyx_L1_error)
  8257. __pyx_type_9httptools_6parser_6parser_HttpRequestParser.tp_print = 0;
  8258. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9httptools_6parser_6parser_HttpRequestParser.tp_dictoffset && __pyx_type_9httptools_6parser_6parser_HttpRequestParser.tp_getattro == PyObject_GenericGetAttr)) {
  8259. __pyx_type_9httptools_6parser_6parser_HttpRequestParser.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  8260. }
  8261. if (__Pyx_SetVtable(__pyx_type_9httptools_6parser_6parser_HttpRequestParser.tp_dict, __pyx_vtabptr_9httptools_6parser_6parser_HttpRequestParser) < 0) __PYX_ERR(0, 202, __pyx_L1_error)
  8262. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_HttpRequestParser, (PyObject *)&__pyx_type_9httptools_6parser_6parser_HttpRequestParser) < 0) __PYX_ERR(0, 202, __pyx_L1_error)
  8263. if (__Pyx_setup_reduce((PyObject*)&__pyx_type_9httptools_6parser_6parser_HttpRequestParser) < 0) __PYX_ERR(0, 202, __pyx_L1_error)
  8264. __pyx_ptype_9httptools_6parser_6parser_HttpRequestParser = &__pyx_type_9httptools_6parser_6parser_HttpRequestParser;
  8265. __pyx_vtabptr_9httptools_6parser_6parser_HttpResponseParser = &__pyx_vtable_9httptools_6parser_6parser_HttpResponseParser;
  8266. __pyx_vtable_9httptools_6parser_6parser_HttpResponseParser.__pyx_base = *__pyx_vtabptr_9httptools_6parser_6parser_HttpParser;
  8267. __pyx_type_9httptools_6parser_6parser_HttpResponseParser.tp_base = __pyx_ptype_9httptools_6parser_6parser_HttpParser;
  8268. if (PyType_Ready(&__pyx_type_9httptools_6parser_6parser_HttpResponseParser) < 0) __PYX_ERR(0, 216, __pyx_L1_error)
  8269. __pyx_type_9httptools_6parser_6parser_HttpResponseParser.tp_print = 0;
  8270. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9httptools_6parser_6parser_HttpResponseParser.tp_dictoffset && __pyx_type_9httptools_6parser_6parser_HttpResponseParser.tp_getattro == PyObject_GenericGetAttr)) {
  8271. __pyx_type_9httptools_6parser_6parser_HttpResponseParser.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  8272. }
  8273. if (__Pyx_SetVtable(__pyx_type_9httptools_6parser_6parser_HttpResponseParser.tp_dict, __pyx_vtabptr_9httptools_6parser_6parser_HttpResponseParser) < 0) __PYX_ERR(0, 216, __pyx_L1_error)
  8274. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_HttpResponseParser, (PyObject *)&__pyx_type_9httptools_6parser_6parser_HttpResponseParser) < 0) __PYX_ERR(0, 216, __pyx_L1_error)
  8275. if (__Pyx_setup_reduce((PyObject*)&__pyx_type_9httptools_6parser_6parser_HttpResponseParser) < 0) __PYX_ERR(0, 216, __pyx_L1_error)
  8276. __pyx_ptype_9httptools_6parser_6parser_HttpResponseParser = &__pyx_type_9httptools_6parser_6parser_HttpResponseParser;
  8277. if (PyType_Ready(&__pyx_type_9httptools_6parser_6parser_URL) < 0) __PYX_ERR(0, 379, __pyx_L1_error)
  8278. __pyx_type_9httptools_6parser_6parser_URL.tp_print = 0;
  8279. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9httptools_6parser_6parser_URL.tp_dictoffset && __pyx_type_9httptools_6parser_6parser_URL.tp_getattro == PyObject_GenericGetAttr)) {
  8280. __pyx_type_9httptools_6parser_6parser_URL.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  8281. }
  8282. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_URL, (PyObject *)&__pyx_type_9httptools_6parser_6parser_URL) < 0) __PYX_ERR(0, 379, __pyx_L1_error)
  8283. if (__Pyx_setup_reduce((PyObject*)&__pyx_type_9httptools_6parser_6parser_URL) < 0) __PYX_ERR(0, 379, __pyx_L1_error)
  8284. __pyx_ptype_9httptools_6parser_6parser_URL = &__pyx_type_9httptools_6parser_6parser_URL;
  8285. __Pyx_RefNannyFinishContext();
  8286. return 0;
  8287. __pyx_L1_error:;
  8288. __Pyx_RefNannyFinishContext();
  8289. return -1;
  8290. }
  8291. static int __Pyx_modinit_type_import_code(void) {
  8292. __Pyx_RefNannyDeclarations
  8293. PyObject *__pyx_t_1 = NULL;
  8294. __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  8295. /*--- Type import code ---*/
  8296. __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 9, __pyx_L1_error)
  8297. __Pyx_GOTREF(__pyx_t_1);
  8298. __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
  8299. #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
  8300. sizeof(PyTypeObject),
  8301. #else
  8302. sizeof(PyHeapTypeObject),
  8303. #endif
  8304. __Pyx_ImportType_CheckSize_Warn);
  8305. if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(2, 9, __pyx_L1_error)
  8306. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8307. __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 8, __pyx_L1_error)
  8308. __Pyx_GOTREF(__pyx_t_1);
  8309. __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), __Pyx_ImportType_CheckSize_Warn);
  8310. if (!__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(3, 8, __pyx_L1_error)
  8311. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8312. __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 15, __pyx_L1_error)
  8313. __Pyx_GOTREF(__pyx_t_1);
  8314. __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), __Pyx_ImportType_CheckSize_Warn);
  8315. if (!__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(4, 15, __pyx_L1_error)
  8316. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8317. __Pyx_RefNannyFinishContext();
  8318. return 0;
  8319. __pyx_L1_error:;
  8320. __Pyx_XDECREF(__pyx_t_1);
  8321. __Pyx_RefNannyFinishContext();
  8322. return -1;
  8323. }
  8324. static int __Pyx_modinit_variable_import_code(void) {
  8325. __Pyx_RefNannyDeclarations
  8326. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  8327. /*--- Variable import code ---*/
  8328. __Pyx_RefNannyFinishContext();
  8329. return 0;
  8330. }
  8331. static int __Pyx_modinit_function_import_code(void) {
  8332. __Pyx_RefNannyDeclarations
  8333. __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  8334. /*--- Function import code ---*/
  8335. __Pyx_RefNannyFinishContext();
  8336. return 0;
  8337. }
  8338. #if PY_MAJOR_VERSION < 3
  8339. #ifdef CYTHON_NO_PYINIT_EXPORT
  8340. #define __Pyx_PyMODINIT_FUNC void
  8341. #else
  8342. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  8343. #endif
  8344. #else
  8345. #ifdef CYTHON_NO_PYINIT_EXPORT
  8346. #define __Pyx_PyMODINIT_FUNC PyObject *
  8347. #else
  8348. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  8349. #endif
  8350. #endif
  8351. #if PY_MAJOR_VERSION < 3
  8352. __Pyx_PyMODINIT_FUNC initparser(void) CYTHON_SMALL_CODE; /*proto*/
  8353. __Pyx_PyMODINIT_FUNC initparser(void)
  8354. #else
  8355. __Pyx_PyMODINIT_FUNC PyInit_parser(void) CYTHON_SMALL_CODE; /*proto*/
  8356. __Pyx_PyMODINIT_FUNC PyInit_parser(void)
  8357. #if CYTHON_PEP489_MULTI_PHASE_INIT
  8358. {
  8359. return PyModuleDef_Init(&__pyx_moduledef);
  8360. }
  8361. static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
  8362. #if PY_VERSION_HEX >= 0x030700A1
  8363. static PY_INT64_T main_interpreter_id = -1;
  8364. PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
  8365. if (main_interpreter_id == -1) {
  8366. main_interpreter_id = current_id;
  8367. return (unlikely(current_id == -1)) ? -1 : 0;
  8368. } else if (unlikely(main_interpreter_id != current_id))
  8369. #else
  8370. static PyInterpreterState *main_interpreter = NULL;
  8371. PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
  8372. if (!main_interpreter) {
  8373. main_interpreter = current_interpreter;
  8374. } else if (unlikely(main_interpreter != current_interpreter))
  8375. #endif
  8376. {
  8377. PyErr_SetString(
  8378. PyExc_ImportError,
  8379. "Interpreter change detected - this module can only be loaded into one interpreter per process.");
  8380. return -1;
  8381. }
  8382. return 0;
  8383. }
  8384. static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
  8385. PyObject *value = PyObject_GetAttrString(spec, from_name);
  8386. int result = 0;
  8387. if (likely(value)) {
  8388. result = PyDict_SetItemString(moddict, to_name, value);
  8389. Py_DECREF(value);
  8390. } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
  8391. PyErr_Clear();
  8392. } else {
  8393. result = -1;
  8394. }
  8395. return result;
  8396. }
  8397. static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
  8398. PyObject *module = NULL, *moddict, *modname;
  8399. if (__Pyx_check_single_interpreter())
  8400. return NULL;
  8401. if (__pyx_m)
  8402. return __Pyx_NewRef(__pyx_m);
  8403. modname = PyObject_GetAttrString(spec, "name");
  8404. if (unlikely(!modname)) goto bad;
  8405. module = PyModule_NewObject(modname);
  8406. Py_DECREF(modname);
  8407. if (unlikely(!module)) goto bad;
  8408. moddict = PyModule_GetDict(module);
  8409. if (unlikely(!moddict)) goto bad;
  8410. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
  8411. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
  8412. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
  8413. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
  8414. return module;
  8415. bad:
  8416. Py_XDECREF(module);
  8417. return NULL;
  8418. }
  8419. static CYTHON_SMALL_CODE int __pyx_pymod_exec_parser(PyObject *__pyx_pyinit_module)
  8420. #endif
  8421. #endif
  8422. {
  8423. PyObject *__pyx_t_1 = NULL;
  8424. PyObject *__pyx_t_2 = NULL;
  8425. __Pyx_RefNannyDeclarations
  8426. #if CYTHON_PEP489_MULTI_PHASE_INIT
  8427. if (__pyx_m) {
  8428. if (__pyx_m == __pyx_pyinit_module) return 0;
  8429. PyErr_SetString(PyExc_RuntimeError, "Module 'parser' has already been imported. Re-initialisation is not supported.");
  8430. return -1;
  8431. }
  8432. #elif PY_MAJOR_VERSION >= 3
  8433. if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  8434. #endif
  8435. #if CYTHON_REFNANNY
  8436. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  8437. if (!__Pyx_RefNanny) {
  8438. PyErr_Clear();
  8439. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  8440. if (!__Pyx_RefNanny)
  8441. Py_FatalError("failed to import 'refnanny' module");
  8442. }
  8443. #endif
  8444. __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_parser(void)", 0);
  8445. if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8446. #ifdef __Pxy_PyFrame_Initialize_Offsets
  8447. __Pxy_PyFrame_Initialize_Offsets();
  8448. #endif
  8449. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  8450. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  8451. __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  8452. #ifdef __Pyx_CyFunction_USED
  8453. if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8454. #endif
  8455. #ifdef __Pyx_FusedFunction_USED
  8456. if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8457. #endif
  8458. #ifdef __Pyx_Coroutine_USED
  8459. if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8460. #endif
  8461. #ifdef __Pyx_Generator_USED
  8462. if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8463. #endif
  8464. #ifdef __Pyx_AsyncGen_USED
  8465. if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8466. #endif
  8467. #ifdef __Pyx_StopAsyncIteration_USED
  8468. if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8469. #endif
  8470. /*--- Library function declarations ---*/
  8471. /*--- Threads initialization code ---*/
  8472. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  8473. #ifdef WITH_THREAD /* Python build with threading support? */
  8474. PyEval_InitThreads();
  8475. #endif
  8476. #endif
  8477. /*--- Module creation code ---*/
  8478. #if CYTHON_PEP489_MULTI_PHASE_INIT
  8479. __pyx_m = __pyx_pyinit_module;
  8480. Py_INCREF(__pyx_m);
  8481. #else
  8482. #if PY_MAJOR_VERSION < 3
  8483. __pyx_m = Py_InitModule4("parser", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  8484. #else
  8485. __pyx_m = PyModule_Create(&__pyx_moduledef);
  8486. #endif
  8487. if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  8488. #endif
  8489. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  8490. Py_INCREF(__pyx_d);
  8491. __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  8492. __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  8493. #if CYTHON_COMPILING_IN_PYPY
  8494. Py_INCREF(__pyx_b);
  8495. #endif
  8496. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  8497. /*--- Initialize various global constants etc. ---*/
  8498. if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8499. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  8500. if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8501. #endif
  8502. if (__pyx_module_is_main_httptools__parser__parser) {
  8503. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8504. }
  8505. #if PY_MAJOR_VERSION >= 3
  8506. {
  8507. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  8508. if (!PyDict_GetItemString(modules, "httptools.parser.parser")) {
  8509. if (unlikely(PyDict_SetItemString(modules, "httptools.parser.parser", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  8510. }
  8511. }
  8512. #endif
  8513. /*--- Builtin init code ---*/
  8514. if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8515. /*--- Constants init code ---*/
  8516. if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8517. /*--- Global type/function init code ---*/
  8518. (void)__Pyx_modinit_global_init_code();
  8519. (void)__Pyx_modinit_variable_export_code();
  8520. (void)__Pyx_modinit_function_export_code();
  8521. if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
  8522. if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
  8523. (void)__Pyx_modinit_variable_import_code();
  8524. (void)__Pyx_modinit_function_import_code();
  8525. /*--- Execution code ---*/
  8526. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  8527. if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8528. #endif
  8529. /* "httptools/parser/parser.pyx":11
  8530. *
  8531. *
  8532. * from .errors import (HttpParserError, # <<<<<<<<<<<<<<
  8533. * HttpParserCallbackError,
  8534. * HttpParserInvalidStatusError,
  8535. */
  8536. __pyx_t_1 = PyList_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
  8537. __Pyx_GOTREF(__pyx_t_1);
  8538. __Pyx_INCREF(__pyx_n_s_HttpParserError);
  8539. __Pyx_GIVEREF(__pyx_n_s_HttpParserError);
  8540. PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_HttpParserError);
  8541. __Pyx_INCREF(__pyx_n_s_HttpParserCallbackError);
  8542. __Pyx_GIVEREF(__pyx_n_s_HttpParserCallbackError);
  8543. PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_HttpParserCallbackError);
  8544. __Pyx_INCREF(__pyx_n_s_HttpParserInvalidStatusError);
  8545. __Pyx_GIVEREF(__pyx_n_s_HttpParserInvalidStatusError);
  8546. PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_HttpParserInvalidStatusError);
  8547. __Pyx_INCREF(__pyx_n_s_HttpParserInvalidMethodError);
  8548. __Pyx_GIVEREF(__pyx_n_s_HttpParserInvalidMethodError);
  8549. PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_HttpParserInvalidMethodError);
  8550. __Pyx_INCREF(__pyx_n_s_HttpParserInvalidURLError);
  8551. __Pyx_GIVEREF(__pyx_n_s_HttpParserInvalidURLError);
  8552. PyList_SET_ITEM(__pyx_t_1, 4, __pyx_n_s_HttpParserInvalidURLError);
  8553. __Pyx_INCREF(__pyx_n_s_HttpParserUpgrade);
  8554. __Pyx_GIVEREF(__pyx_n_s_HttpParserUpgrade);
  8555. PyList_SET_ITEM(__pyx_t_1, 5, __pyx_n_s_HttpParserUpgrade);
  8556. __pyx_t_2 = __Pyx_Import(__pyx_n_s_errors, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
  8557. __Pyx_GOTREF(__pyx_t_2);
  8558. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8559. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_HttpParserError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
  8560. __Pyx_GOTREF(__pyx_t_1);
  8561. if (PyDict_SetItem(__pyx_d, __pyx_n_s_HttpParserError, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
  8562. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8563. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_HttpParserCallbackError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
  8564. __Pyx_GOTREF(__pyx_t_1);
  8565. if (PyDict_SetItem(__pyx_d, __pyx_n_s_HttpParserCallbackError, __pyx_t_1) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
  8566. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8567. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_HttpParserInvalidStatusError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
  8568. __Pyx_GOTREF(__pyx_t_1);
  8569. if (PyDict_SetItem(__pyx_d, __pyx_n_s_HttpParserInvalidStatusError, __pyx_t_1) < 0) __PYX_ERR(0, 13, __pyx_L1_error)
  8570. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8571. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_HttpParserInvalidMethodError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
  8572. __Pyx_GOTREF(__pyx_t_1);
  8573. if (PyDict_SetItem(__pyx_d, __pyx_n_s_HttpParserInvalidMethodError, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
  8574. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8575. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_HttpParserInvalidURLError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
  8576. __Pyx_GOTREF(__pyx_t_1);
  8577. if (PyDict_SetItem(__pyx_d, __pyx_n_s_HttpParserInvalidURLError, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
  8578. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8579. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_HttpParserUpgrade); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
  8580. __Pyx_GOTREF(__pyx_t_1);
  8581. if (PyDict_SetItem(__pyx_d, __pyx_n_s_HttpParserUpgrade, __pyx_t_1) < 0) __PYX_ERR(0, 16, __pyx_L1_error)
  8582. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8583. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8584. /* "httptools/parser/parser.pyx":22
  8585. *
  8586. *
  8587. * __all__ = ('HttpRequestParser', 'HttpResponseParser', 'parse_url') # <<<<<<<<<<<<<<
  8588. *
  8589. *
  8590. */
  8591. if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_tuple__11) < 0) __PYX_ERR(0, 22, __pyx_L1_error)
  8592. /* "httptools/parser/parser.pyx":406
  8593. *
  8594. *
  8595. * def parse_url(url): # <<<<<<<<<<<<<<
  8596. * cdef:
  8597. * Py_buffer py_buf
  8598. */
  8599. __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_9httptools_6parser_6parser_1parse_url, NULL, __pyx_n_s_httptools_parser_parser); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 406, __pyx_L1_error)
  8600. __Pyx_GOTREF(__pyx_t_2);
  8601. if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_url, __pyx_t_2) < 0) __PYX_ERR(0, 406, __pyx_L1_error)
  8602. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8603. /* "httptools/parser/parser.pyx":1
  8604. * #cython: language_level=3 # <<<<<<<<<<<<<<
  8605. *
  8606. * from __future__ import print_function
  8607. */
  8608. __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  8609. __Pyx_GOTREF(__pyx_t_2);
  8610. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8611. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8612. /*--- Wrapped vars code ---*/
  8613. goto __pyx_L0;
  8614. __pyx_L1_error:;
  8615. __Pyx_XDECREF(__pyx_t_1);
  8616. __Pyx_XDECREF(__pyx_t_2);
  8617. if (__pyx_m) {
  8618. if (__pyx_d) {
  8619. __Pyx_AddTraceback("init httptools.parser.parser", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8620. }
  8621. Py_CLEAR(__pyx_m);
  8622. } else if (!PyErr_Occurred()) {
  8623. PyErr_SetString(PyExc_ImportError, "init httptools.parser.parser");
  8624. }
  8625. __pyx_L0:;
  8626. __Pyx_RefNannyFinishContext();
  8627. #if CYTHON_PEP489_MULTI_PHASE_INIT
  8628. return (__pyx_m != NULL) ? 0 : -1;
  8629. #elif PY_MAJOR_VERSION >= 3
  8630. return __pyx_m;
  8631. #else
  8632. return;
  8633. #endif
  8634. }
  8635. /* --- Runtime support code --- */
  8636. /* Refnanny */
  8637. #if CYTHON_REFNANNY
  8638. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  8639. PyObject *m = NULL, *p = NULL;
  8640. void *r = NULL;
  8641. m = PyImport_ImportModule(modname);
  8642. if (!m) goto end;
  8643. p = PyObject_GetAttrString(m, "RefNannyAPI");
  8644. if (!p) goto end;
  8645. r = PyLong_AsVoidPtr(p);
  8646. end:
  8647. Py_XDECREF(p);
  8648. Py_XDECREF(m);
  8649. return (__Pyx_RefNannyAPIStruct *)r;
  8650. }
  8651. #endif
  8652. /* PyObjectGetAttrStr */
  8653. #if CYTHON_USE_TYPE_SLOTS
  8654. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  8655. PyTypeObject* tp = Py_TYPE(obj);
  8656. if (likely(tp->tp_getattro))
  8657. return tp->tp_getattro(obj, attr_name);
  8658. #if PY_MAJOR_VERSION < 3
  8659. if (likely(tp->tp_getattr))
  8660. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  8661. #endif
  8662. return PyObject_GetAttr(obj, attr_name);
  8663. }
  8664. #endif
  8665. /* GetBuiltinName */
  8666. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  8667. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  8668. if (unlikely(!result)) {
  8669. PyErr_Format(PyExc_NameError,
  8670. #if PY_MAJOR_VERSION >= 3
  8671. "name '%U' is not defined", name);
  8672. #else
  8673. "name '%.200s' is not defined", PyString_AS_STRING(name));
  8674. #endif
  8675. }
  8676. return result;
  8677. }
  8678. /* RaiseArgTupleInvalid */
  8679. static void __Pyx_RaiseArgtupleInvalid(
  8680. const char* func_name,
  8681. int exact,
  8682. Py_ssize_t num_min,
  8683. Py_ssize_t num_max,
  8684. Py_ssize_t num_found)
  8685. {
  8686. Py_ssize_t num_expected;
  8687. const char *more_or_less;
  8688. if (num_found < num_min) {
  8689. num_expected = num_min;
  8690. more_or_less = "at least";
  8691. } else {
  8692. num_expected = num_max;
  8693. more_or_less = "at most";
  8694. }
  8695. if (exact) {
  8696. more_or_less = "exactly";
  8697. }
  8698. PyErr_Format(PyExc_TypeError,
  8699. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  8700. func_name, more_or_less, num_expected,
  8701. (num_expected == 1) ? "" : "s", num_found);
  8702. }
  8703. /* KeywordStringCheck */
  8704. static int __Pyx_CheckKeywordStrings(
  8705. PyObject *kwdict,
  8706. const char* function_name,
  8707. int kw_allowed)
  8708. {
  8709. PyObject* key = 0;
  8710. Py_ssize_t pos = 0;
  8711. #if CYTHON_COMPILING_IN_PYPY
  8712. if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
  8713. goto invalid_keyword;
  8714. return 1;
  8715. #else
  8716. while (PyDict_Next(kwdict, &pos, &key, 0)) {
  8717. #if PY_MAJOR_VERSION < 3
  8718. if (unlikely(!PyString_Check(key)))
  8719. #endif
  8720. if (unlikely(!PyUnicode_Check(key)))
  8721. goto invalid_keyword_type;
  8722. }
  8723. if ((!kw_allowed) && unlikely(key))
  8724. goto invalid_keyword;
  8725. return 1;
  8726. invalid_keyword_type:
  8727. PyErr_Format(PyExc_TypeError,
  8728. "%.200s() keywords must be strings", function_name);
  8729. return 0;
  8730. #endif
  8731. invalid_keyword:
  8732. PyErr_Format(PyExc_TypeError,
  8733. #if PY_MAJOR_VERSION < 3
  8734. "%.200s() got an unexpected keyword argument '%.200s'",
  8735. function_name, PyString_AsString(key));
  8736. #else
  8737. "%s() got an unexpected keyword argument '%U'",
  8738. function_name, key);
  8739. #endif
  8740. return 0;
  8741. }
  8742. /* PyErrExceptionMatches */
  8743. #if CYTHON_FAST_THREAD_STATE
  8744. static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  8745. Py_ssize_t i, n;
  8746. n = PyTuple_GET_SIZE(tuple);
  8747. #if PY_MAJOR_VERSION >= 3
  8748. for (i=0; i<n; i++) {
  8749. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  8750. }
  8751. #endif
  8752. for (i=0; i<n; i++) {
  8753. if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
  8754. }
  8755. return 0;
  8756. }
  8757. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
  8758. PyObject *exc_type = tstate->curexc_type;
  8759. if (exc_type == err) return 1;
  8760. if (unlikely(!exc_type)) return 0;
  8761. if (unlikely(PyTuple_Check(err)))
  8762. return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
  8763. return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
  8764. }
  8765. #endif
  8766. /* PyErrFetchRestore */
  8767. #if CYTHON_FAST_THREAD_STATE
  8768. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  8769. PyObject *tmp_type, *tmp_value, *tmp_tb;
  8770. tmp_type = tstate->curexc_type;
  8771. tmp_value = tstate->curexc_value;
  8772. tmp_tb = tstate->curexc_traceback;
  8773. tstate->curexc_type = type;
  8774. tstate->curexc_value = value;
  8775. tstate->curexc_traceback = tb;
  8776. Py_XDECREF(tmp_type);
  8777. Py_XDECREF(tmp_value);
  8778. Py_XDECREF(tmp_tb);
  8779. }
  8780. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  8781. *type = tstate->curexc_type;
  8782. *value = tstate->curexc_value;
  8783. *tb = tstate->curexc_traceback;
  8784. tstate->curexc_type = 0;
  8785. tstate->curexc_value = 0;
  8786. tstate->curexc_traceback = 0;
  8787. }
  8788. #endif
  8789. /* GetAttr */
  8790. static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
  8791. #if CYTHON_USE_TYPE_SLOTS
  8792. #if PY_MAJOR_VERSION >= 3
  8793. if (likely(PyUnicode_Check(n)))
  8794. #else
  8795. if (likely(PyString_Check(n)))
  8796. #endif
  8797. return __Pyx_PyObject_GetAttrStr(o, n);
  8798. #endif
  8799. return PyObject_GetAttr(o, n);
  8800. }
  8801. /* GetAttr3 */
  8802. static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
  8803. __Pyx_PyThreadState_declare
  8804. __Pyx_PyThreadState_assign
  8805. if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
  8806. return NULL;
  8807. __Pyx_PyErr_Clear();
  8808. Py_INCREF(d);
  8809. return d;
  8810. }
  8811. static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
  8812. PyObject *r = __Pyx_GetAttr(o, n);
  8813. return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
  8814. }
  8815. /* PyFunctionFastCall */
  8816. #if CYTHON_FAST_PYCALL
  8817. static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
  8818. PyObject *globals) {
  8819. PyFrameObject *f;
  8820. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  8821. PyObject **fastlocals;
  8822. Py_ssize_t i;
  8823. PyObject *result;
  8824. assert(globals != NULL);
  8825. /* XXX Perhaps we should create a specialized
  8826. PyFrame_New() that doesn't take locals, but does
  8827. take builtins without sanity checking them.
  8828. */
  8829. assert(tstate != NULL);
  8830. f = PyFrame_New(tstate, co, globals, NULL);
  8831. if (f == NULL) {
  8832. return NULL;
  8833. }
  8834. fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
  8835. for (i = 0; i < na; i++) {
  8836. Py_INCREF(*args);
  8837. fastlocals[i] = *args++;
  8838. }
  8839. result = PyEval_EvalFrameEx(f,0);
  8840. ++tstate->recursion_depth;
  8841. Py_DECREF(f);
  8842. --tstate->recursion_depth;
  8843. return result;
  8844. }
  8845. #if 1 || PY_VERSION_HEX < 0x030600B1
  8846. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
  8847. PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
  8848. PyObject *globals = PyFunction_GET_GLOBALS(func);
  8849. PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
  8850. PyObject *closure;
  8851. #if PY_MAJOR_VERSION >= 3
  8852. PyObject *kwdefs;
  8853. #endif
  8854. PyObject *kwtuple, **k;
  8855. PyObject **d;
  8856. Py_ssize_t nd;
  8857. Py_ssize_t nk;
  8858. PyObject *result;
  8859. assert(kwargs == NULL || PyDict_Check(kwargs));
  8860. nk = kwargs ? PyDict_Size(kwargs) : 0;
  8861. if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
  8862. return NULL;
  8863. }
  8864. if (
  8865. #if PY_MAJOR_VERSION >= 3
  8866. co->co_kwonlyargcount == 0 &&
  8867. #endif
  8868. likely(kwargs == NULL || nk == 0) &&
  8869. co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
  8870. if (argdefs == NULL && co->co_argcount == nargs) {
  8871. result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
  8872. goto done;
  8873. }
  8874. else if (nargs == 0 && argdefs != NULL
  8875. && co->co_argcount == Py_SIZE(argdefs)) {
  8876. /* function called with no arguments, but all parameters have
  8877. a default value: use default values as arguments .*/
  8878. args = &PyTuple_GET_ITEM(argdefs, 0);
  8879. result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
  8880. goto done;
  8881. }
  8882. }
  8883. if (kwargs != NULL) {
  8884. Py_ssize_t pos, i;
  8885. kwtuple = PyTuple_New(2 * nk);
  8886. if (kwtuple == NULL) {
  8887. result = NULL;
  8888. goto done;
  8889. }
  8890. k = &PyTuple_GET_ITEM(kwtuple, 0);
  8891. pos = i = 0;
  8892. while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
  8893. Py_INCREF(k[i]);
  8894. Py_INCREF(k[i+1]);
  8895. i += 2;
  8896. }
  8897. nk = i / 2;
  8898. }
  8899. else {
  8900. kwtuple = NULL;
  8901. k = NULL;
  8902. }
  8903. closure = PyFunction_GET_CLOSURE(func);
  8904. #if PY_MAJOR_VERSION >= 3
  8905. kwdefs = PyFunction_GET_KW_DEFAULTS(func);
  8906. #endif
  8907. if (argdefs != NULL) {
  8908. d = &PyTuple_GET_ITEM(argdefs, 0);
  8909. nd = Py_SIZE(argdefs);
  8910. }
  8911. else {
  8912. d = NULL;
  8913. nd = 0;
  8914. }
  8915. #if PY_MAJOR_VERSION >= 3
  8916. result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
  8917. args, nargs,
  8918. k, (int)nk,
  8919. d, (int)nd, kwdefs, closure);
  8920. #else
  8921. result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
  8922. args, nargs,
  8923. k, (int)nk,
  8924. d, (int)nd, closure);
  8925. #endif
  8926. Py_XDECREF(kwtuple);
  8927. done:
  8928. Py_LeaveRecursiveCall();
  8929. return result;
  8930. }
  8931. #endif
  8932. #endif
  8933. /* PyCFunctionFastCall */
  8934. #if CYTHON_FAST_PYCCALL
  8935. static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
  8936. PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
  8937. PyCFunction meth = PyCFunction_GET_FUNCTION(func);
  8938. PyObject *self = PyCFunction_GET_SELF(func);
  8939. int flags = PyCFunction_GET_FLAGS(func);
  8940. assert(PyCFunction_Check(func));
  8941. assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
  8942. assert(nargs >= 0);
  8943. assert(nargs == 0 || args != NULL);
  8944. /* _PyCFunction_FastCallDict() must not be called with an exception set,
  8945. because it may clear it (directly or indirectly) and so the
  8946. caller loses its exception */
  8947. assert(!PyErr_Occurred());
  8948. if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
  8949. return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
  8950. } else {
  8951. return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
  8952. }
  8953. }
  8954. #endif
  8955. /* PyObjectCall */
  8956. #if CYTHON_COMPILING_IN_CPYTHON
  8957. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  8958. PyObject *result;
  8959. ternaryfunc call = func->ob_type->tp_call;
  8960. if (unlikely(!call))
  8961. return PyObject_Call(func, arg, kw);
  8962. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  8963. return NULL;
  8964. result = (*call)(func, arg, kw);
  8965. Py_LeaveRecursiveCall();
  8966. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  8967. PyErr_SetString(
  8968. PyExc_SystemError,
  8969. "NULL result without error in PyObject_Call");
  8970. }
  8971. return result;
  8972. }
  8973. #endif
  8974. /* PyObjectCallMethO */
  8975. #if CYTHON_COMPILING_IN_CPYTHON
  8976. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
  8977. PyObject *self, *result;
  8978. PyCFunction cfunc;
  8979. cfunc = PyCFunction_GET_FUNCTION(func);
  8980. self = PyCFunction_GET_SELF(func);
  8981. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  8982. return NULL;
  8983. result = cfunc(self, arg);
  8984. Py_LeaveRecursiveCall();
  8985. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  8986. PyErr_SetString(
  8987. PyExc_SystemError,
  8988. "NULL result without error in PyObject_Call");
  8989. }
  8990. return result;
  8991. }
  8992. #endif
  8993. /* PyObjectCallNoArg */
  8994. #if CYTHON_COMPILING_IN_CPYTHON
  8995. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
  8996. #if CYTHON_FAST_PYCALL
  8997. if (PyFunction_Check(func)) {
  8998. return __Pyx_PyFunction_FastCall(func, NULL, 0);
  8999. }
  9000. #endif
  9001. #ifdef __Pyx_CyFunction_USED
  9002. if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
  9003. #else
  9004. if (likely(PyCFunction_Check(func)))
  9005. #endif
  9006. {
  9007. if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
  9008. return __Pyx_PyObject_CallMethO(func, NULL);
  9009. }
  9010. }
  9011. return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
  9012. }
  9013. #endif
  9014. /* PyObjectCallOneArg */
  9015. #if CYTHON_COMPILING_IN_CPYTHON
  9016. static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  9017. PyObject *result;
  9018. PyObject *args = PyTuple_New(1);
  9019. if (unlikely(!args)) return NULL;
  9020. Py_INCREF(arg);
  9021. PyTuple_SET_ITEM(args, 0, arg);
  9022. result = __Pyx_PyObject_Call(func, args, NULL);
  9023. Py_DECREF(args);
  9024. return result;
  9025. }
  9026. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  9027. #if CYTHON_FAST_PYCALL
  9028. if (PyFunction_Check(func)) {
  9029. return __Pyx_PyFunction_FastCall(func, &arg, 1);
  9030. }
  9031. #endif
  9032. if (likely(PyCFunction_Check(func))) {
  9033. if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
  9034. return __Pyx_PyObject_CallMethO(func, arg);
  9035. #if CYTHON_FAST_PYCCALL
  9036. } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
  9037. return __Pyx_PyCFunction_FastCall(func, &arg, 1);
  9038. #endif
  9039. }
  9040. }
  9041. return __Pyx__PyObject_CallOneArg(func, arg);
  9042. }
  9043. #else
  9044. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  9045. PyObject *result;
  9046. PyObject *args = PyTuple_Pack(1, arg);
  9047. if (unlikely(!args)) return NULL;
  9048. result = __Pyx_PyObject_Call(func, args, NULL);
  9049. Py_DECREF(args);
  9050. return result;
  9051. }
  9052. #endif
  9053. /* GetModuleGlobalName */
  9054. #if CYTHON_USE_DICT_VERSIONS
  9055. static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
  9056. #else
  9057. static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
  9058. #endif
  9059. {
  9060. PyObject *result;
  9061. #if !CYTHON_AVOID_BORROWED_REFS
  9062. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
  9063. result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
  9064. __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
  9065. if (likely(result)) {
  9066. return __Pyx_NewRef(result);
  9067. } else if (unlikely(PyErr_Occurred())) {
  9068. return NULL;
  9069. }
  9070. #else
  9071. result = PyDict_GetItem(__pyx_d, name);
  9072. __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
  9073. if (likely(result)) {
  9074. return __Pyx_NewRef(result);
  9075. }
  9076. #endif
  9077. #else
  9078. result = PyObject_GetItem(__pyx_d, name);
  9079. __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
  9080. if (likely(result)) {
  9081. return __Pyx_NewRef(result);
  9082. }
  9083. PyErr_Clear();
  9084. #endif
  9085. return __Pyx_GetBuiltinName(name);
  9086. }
  9087. /* PyObjectCall2Args */
  9088. static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
  9089. PyObject *args, *result = NULL;
  9090. #if CYTHON_FAST_PYCALL
  9091. if (PyFunction_Check(function)) {
  9092. PyObject *args[2] = {arg1, arg2};
  9093. return __Pyx_PyFunction_FastCall(function, args, 2);
  9094. }
  9095. #endif
  9096. #if CYTHON_FAST_PYCCALL
  9097. if (__Pyx_PyFastCFunction_Check(function)) {
  9098. PyObject *args[2] = {arg1, arg2};
  9099. return __Pyx_PyCFunction_FastCall(function, args, 2);
  9100. }
  9101. #endif
  9102. args = PyTuple_New(2);
  9103. if (unlikely(!args)) goto done;
  9104. Py_INCREF(arg1);
  9105. PyTuple_SET_ITEM(args, 0, arg1);
  9106. Py_INCREF(arg2);
  9107. PyTuple_SET_ITEM(args, 1, arg2);
  9108. Py_INCREF(function);
  9109. result = __Pyx_PyObject_Call(function, args, NULL);
  9110. Py_DECREF(args);
  9111. Py_DECREF(function);
  9112. done:
  9113. return result;
  9114. }
  9115. /* RaiseException */
  9116. #if PY_MAJOR_VERSION < 3
  9117. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
  9118. CYTHON_UNUSED PyObject *cause) {
  9119. __Pyx_PyThreadState_declare
  9120. Py_XINCREF(type);
  9121. if (!value || value == Py_None)
  9122. value = NULL;
  9123. else
  9124. Py_INCREF(value);
  9125. if (!tb || tb == Py_None)
  9126. tb = NULL;
  9127. else {
  9128. Py_INCREF(tb);
  9129. if (!PyTraceBack_Check(tb)) {
  9130. PyErr_SetString(PyExc_TypeError,
  9131. "raise: arg 3 must be a traceback or None");
  9132. goto raise_error;
  9133. }
  9134. }
  9135. if (PyType_Check(type)) {
  9136. #if CYTHON_COMPILING_IN_PYPY
  9137. if (!value) {
  9138. Py_INCREF(Py_None);
  9139. value = Py_None;
  9140. }
  9141. #endif
  9142. PyErr_NormalizeException(&type, &value, &tb);
  9143. } else {
  9144. if (value) {
  9145. PyErr_SetString(PyExc_TypeError,
  9146. "instance exception may not have a separate value");
  9147. goto raise_error;
  9148. }
  9149. value = type;
  9150. type = (PyObject*) Py_TYPE(type);
  9151. Py_INCREF(type);
  9152. if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
  9153. PyErr_SetString(PyExc_TypeError,
  9154. "raise: exception class must be a subclass of BaseException");
  9155. goto raise_error;
  9156. }
  9157. }
  9158. __Pyx_PyThreadState_assign
  9159. __Pyx_ErrRestore(type, value, tb);
  9160. return;
  9161. raise_error:
  9162. Py_XDECREF(value);
  9163. Py_XDECREF(type);
  9164. Py_XDECREF(tb);
  9165. return;
  9166. }
  9167. #else
  9168. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  9169. PyObject* owned_instance = NULL;
  9170. if (tb == Py_None) {
  9171. tb = 0;
  9172. } else if (tb && !PyTraceBack_Check(tb)) {
  9173. PyErr_SetString(PyExc_TypeError,
  9174. "raise: arg 3 must be a traceback or None");
  9175. goto bad;
  9176. }
  9177. if (value == Py_None)
  9178. value = 0;
  9179. if (PyExceptionInstance_Check(type)) {
  9180. if (value) {
  9181. PyErr_SetString(PyExc_TypeError,
  9182. "instance exception may not have a separate value");
  9183. goto bad;
  9184. }
  9185. value = type;
  9186. type = (PyObject*) Py_TYPE(value);
  9187. } else if (PyExceptionClass_Check(type)) {
  9188. PyObject *instance_class = NULL;
  9189. if (value && PyExceptionInstance_Check(value)) {
  9190. instance_class = (PyObject*) Py_TYPE(value);
  9191. if (instance_class != type) {
  9192. int is_subclass = PyObject_IsSubclass(instance_class, type);
  9193. if (!is_subclass) {
  9194. instance_class = NULL;
  9195. } else if (unlikely(is_subclass == -1)) {
  9196. goto bad;
  9197. } else {
  9198. type = instance_class;
  9199. }
  9200. }
  9201. }
  9202. if (!instance_class) {
  9203. PyObject *args;
  9204. if (!value)
  9205. args = PyTuple_New(0);
  9206. else if (PyTuple_Check(value)) {
  9207. Py_INCREF(value);
  9208. args = value;
  9209. } else
  9210. args = PyTuple_Pack(1, value);
  9211. if (!args)
  9212. goto bad;
  9213. owned_instance = PyObject_Call(type, args, NULL);
  9214. Py_DECREF(args);
  9215. if (!owned_instance)
  9216. goto bad;
  9217. value = owned_instance;
  9218. if (!PyExceptionInstance_Check(value)) {
  9219. PyErr_Format(PyExc_TypeError,
  9220. "calling %R should have returned an instance of "
  9221. "BaseException, not %R",
  9222. type, Py_TYPE(value));
  9223. goto bad;
  9224. }
  9225. }
  9226. } else {
  9227. PyErr_SetString(PyExc_TypeError,
  9228. "raise: exception class must be a subclass of BaseException");
  9229. goto bad;
  9230. }
  9231. if (cause) {
  9232. PyObject *fixed_cause;
  9233. if (cause == Py_None) {
  9234. fixed_cause = NULL;
  9235. } else if (PyExceptionClass_Check(cause)) {
  9236. fixed_cause = PyObject_CallObject(cause, NULL);
  9237. if (fixed_cause == NULL)
  9238. goto bad;
  9239. } else if (PyExceptionInstance_Check(cause)) {
  9240. fixed_cause = cause;
  9241. Py_INCREF(fixed_cause);
  9242. } else {
  9243. PyErr_SetString(PyExc_TypeError,
  9244. "exception causes must derive from "
  9245. "BaseException");
  9246. goto bad;
  9247. }
  9248. PyException_SetCause(value, fixed_cause);
  9249. }
  9250. PyErr_SetObject(type, value);
  9251. if (tb) {
  9252. #if CYTHON_COMPILING_IN_PYPY
  9253. PyObject *tmp_type, *tmp_value, *tmp_tb;
  9254. PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
  9255. Py_INCREF(tb);
  9256. PyErr_Restore(tmp_type, tmp_value, tb);
  9257. Py_XDECREF(tmp_tb);
  9258. #else
  9259. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  9260. PyObject* tmp_tb = tstate->curexc_traceback;
  9261. if (tb != tmp_tb) {
  9262. Py_INCREF(tb);
  9263. tstate->curexc_traceback = tb;
  9264. Py_XDECREF(tmp_tb);
  9265. }
  9266. #endif
  9267. }
  9268. bad:
  9269. Py_XDECREF(owned_instance);
  9270. return;
  9271. }
  9272. #endif
  9273. /* PyObjectSetAttrStr */
  9274. #if CYTHON_USE_TYPE_SLOTS
  9275. static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
  9276. PyTypeObject* tp = Py_TYPE(obj);
  9277. if (likely(tp->tp_setattro))
  9278. return tp->tp_setattro(obj, attr_name, value);
  9279. #if PY_MAJOR_VERSION < 3
  9280. if (likely(tp->tp_setattr))
  9281. return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
  9282. #endif
  9283. return PyObject_SetAttr(obj, attr_name, value);
  9284. }
  9285. #endif
  9286. /* RaiseDoubleKeywords */
  9287. static void __Pyx_RaiseDoubleKeywordsError(
  9288. const char* func_name,
  9289. PyObject* kw_name)
  9290. {
  9291. PyErr_Format(PyExc_TypeError,
  9292. #if PY_MAJOR_VERSION >= 3
  9293. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  9294. #else
  9295. "%s() got multiple values for keyword argument '%s'", func_name,
  9296. PyString_AsString(kw_name));
  9297. #endif
  9298. }
  9299. /* ParseKeywords */
  9300. static int __Pyx_ParseOptionalKeywords(
  9301. PyObject *kwds,
  9302. PyObject **argnames[],
  9303. PyObject *kwds2,
  9304. PyObject *values[],
  9305. Py_ssize_t num_pos_args,
  9306. const char* function_name)
  9307. {
  9308. PyObject *key = 0, *value = 0;
  9309. Py_ssize_t pos = 0;
  9310. PyObject*** name;
  9311. PyObject*** first_kw_arg = argnames + num_pos_args;
  9312. while (PyDict_Next(kwds, &pos, &key, &value)) {
  9313. name = first_kw_arg;
  9314. while (*name && (**name != key)) name++;
  9315. if (*name) {
  9316. values[name-argnames] = value;
  9317. continue;
  9318. }
  9319. name = first_kw_arg;
  9320. #if PY_MAJOR_VERSION < 3
  9321. if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
  9322. while (*name) {
  9323. if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
  9324. && _PyString_Eq(**name, key)) {
  9325. values[name-argnames] = value;
  9326. break;
  9327. }
  9328. name++;
  9329. }
  9330. if (*name) continue;
  9331. else {
  9332. PyObject*** argname = argnames;
  9333. while (argname != first_kw_arg) {
  9334. if ((**argname == key) || (
  9335. (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
  9336. && _PyString_Eq(**argname, key))) {
  9337. goto arg_passed_twice;
  9338. }
  9339. argname++;
  9340. }
  9341. }
  9342. } else
  9343. #endif
  9344. if (likely(PyUnicode_Check(key))) {
  9345. while (*name) {
  9346. int cmp = (**name == key) ? 0 :
  9347. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  9348. (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
  9349. #endif
  9350. PyUnicode_Compare(**name, key);
  9351. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  9352. if (cmp == 0) {
  9353. values[name-argnames] = value;
  9354. break;
  9355. }
  9356. name++;
  9357. }
  9358. if (*name) continue;
  9359. else {
  9360. PyObject*** argname = argnames;
  9361. while (argname != first_kw_arg) {
  9362. int cmp = (**argname == key) ? 0 :
  9363. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  9364. (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
  9365. #endif
  9366. PyUnicode_Compare(**argname, key);
  9367. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  9368. if (cmp == 0) goto arg_passed_twice;
  9369. argname++;
  9370. }
  9371. }
  9372. } else
  9373. goto invalid_keyword_type;
  9374. if (kwds2) {
  9375. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  9376. } else {
  9377. goto invalid_keyword;
  9378. }
  9379. }
  9380. return 0;
  9381. arg_passed_twice:
  9382. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  9383. goto bad;
  9384. invalid_keyword_type:
  9385. PyErr_Format(PyExc_TypeError,
  9386. "%.200s() keywords must be strings", function_name);
  9387. goto bad;
  9388. invalid_keyword:
  9389. PyErr_Format(PyExc_TypeError,
  9390. #if PY_MAJOR_VERSION < 3
  9391. "%.200s() got an unexpected keyword argument '%.200s'",
  9392. function_name, PyString_AsString(key));
  9393. #else
  9394. "%s() got an unexpected keyword argument '%U'",
  9395. function_name, key);
  9396. #endif
  9397. bad:
  9398. return -1;
  9399. }
  9400. /* GetTopmostException */
  9401. #if CYTHON_USE_EXC_INFO_STACK
  9402. static _PyErr_StackItem *
  9403. __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
  9404. {
  9405. _PyErr_StackItem *exc_info = tstate->exc_info;
  9406. while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
  9407. exc_info->previous_item != NULL)
  9408. {
  9409. exc_info = exc_info->previous_item;
  9410. }
  9411. return exc_info;
  9412. }
  9413. #endif
  9414. /* SaveResetException */
  9415. #if CYTHON_FAST_THREAD_STATE
  9416. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  9417. #if CYTHON_USE_EXC_INFO_STACK
  9418. _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
  9419. *type = exc_info->exc_type;
  9420. *value = exc_info->exc_value;
  9421. *tb = exc_info->exc_traceback;
  9422. #else
  9423. *type = tstate->exc_type;
  9424. *value = tstate->exc_value;
  9425. *tb = tstate->exc_traceback;
  9426. #endif
  9427. Py_XINCREF(*type);
  9428. Py_XINCREF(*value);
  9429. Py_XINCREF(*tb);
  9430. }
  9431. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  9432. PyObject *tmp_type, *tmp_value, *tmp_tb;
  9433. #if CYTHON_USE_EXC_INFO_STACK
  9434. _PyErr_StackItem *exc_info = tstate->exc_info;
  9435. tmp_type = exc_info->exc_type;
  9436. tmp_value = exc_info->exc_value;
  9437. tmp_tb = exc_info->exc_traceback;
  9438. exc_info->exc_type = type;
  9439. exc_info->exc_value = value;
  9440. exc_info->exc_traceback = tb;
  9441. #else
  9442. tmp_type = tstate->exc_type;
  9443. tmp_value = tstate->exc_value;
  9444. tmp_tb = tstate->exc_traceback;
  9445. tstate->exc_type = type;
  9446. tstate->exc_value = value;
  9447. tstate->exc_traceback = tb;
  9448. #endif
  9449. Py_XDECREF(tmp_type);
  9450. Py_XDECREF(tmp_value);
  9451. Py_XDECREF(tmp_tb);
  9452. }
  9453. #endif
  9454. /* GetException */
  9455. #if CYTHON_FAST_THREAD_STATE
  9456. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
  9457. #else
  9458. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
  9459. #endif
  9460. {
  9461. PyObject *local_type, *local_value, *local_tb;
  9462. #if CYTHON_FAST_THREAD_STATE
  9463. PyObject *tmp_type, *tmp_value, *tmp_tb;
  9464. local_type = tstate->curexc_type;
  9465. local_value = tstate->curexc_value;
  9466. local_tb = tstate->curexc_traceback;
  9467. tstate->curexc_type = 0;
  9468. tstate->curexc_value = 0;
  9469. tstate->curexc_traceback = 0;
  9470. #else
  9471. PyErr_Fetch(&local_type, &local_value, &local_tb);
  9472. #endif
  9473. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  9474. #if CYTHON_FAST_THREAD_STATE
  9475. if (unlikely(tstate->curexc_type))
  9476. #else
  9477. if (unlikely(PyErr_Occurred()))
  9478. #endif
  9479. goto bad;
  9480. #if PY_MAJOR_VERSION >= 3
  9481. if (local_tb) {
  9482. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  9483. goto bad;
  9484. }
  9485. #endif
  9486. Py_XINCREF(local_tb);
  9487. Py_XINCREF(local_type);
  9488. Py_XINCREF(local_value);
  9489. *type = local_type;
  9490. *value = local_value;
  9491. *tb = local_tb;
  9492. #if CYTHON_FAST_THREAD_STATE
  9493. #if CYTHON_USE_EXC_INFO_STACK
  9494. {
  9495. _PyErr_StackItem *exc_info = tstate->exc_info;
  9496. tmp_type = exc_info->exc_type;
  9497. tmp_value = exc_info->exc_value;
  9498. tmp_tb = exc_info->exc_traceback;
  9499. exc_info->exc_type = local_type;
  9500. exc_info->exc_value = local_value;
  9501. exc_info->exc_traceback = local_tb;
  9502. }
  9503. #else
  9504. tmp_type = tstate->exc_type;
  9505. tmp_value = tstate->exc_value;
  9506. tmp_tb = tstate->exc_traceback;
  9507. tstate->exc_type = local_type;
  9508. tstate->exc_value = local_value;
  9509. tstate->exc_traceback = local_tb;
  9510. #endif
  9511. Py_XDECREF(tmp_type);
  9512. Py_XDECREF(tmp_value);
  9513. Py_XDECREF(tmp_tb);
  9514. #else
  9515. PyErr_SetExcInfo(local_type, local_value, local_tb);
  9516. #endif
  9517. return 0;
  9518. bad:
  9519. *type = 0;
  9520. *value = 0;
  9521. *tb = 0;
  9522. Py_XDECREF(local_type);
  9523. Py_XDECREF(local_value);
  9524. Py_XDECREF(local_tb);
  9525. return -1;
  9526. }
  9527. /* decode_c_bytes */
  9528. static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
  9529. const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
  9530. const char* encoding, const char* errors,
  9531. PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
  9532. if (unlikely((start < 0) | (stop < 0))) {
  9533. if (start < 0) {
  9534. start += length;
  9535. if (start < 0)
  9536. start = 0;
  9537. }
  9538. if (stop < 0)
  9539. stop += length;
  9540. }
  9541. if (stop > length)
  9542. stop = length;
  9543. length = stop - start;
  9544. if (unlikely(length <= 0))
  9545. return PyUnicode_FromUnicode(NULL, 0);
  9546. cstring += start;
  9547. if (decode_func) {
  9548. return decode_func(cstring, length, errors);
  9549. } else {
  9550. return PyUnicode_Decode(cstring, length, encoding, errors);
  9551. }
  9552. }
  9553. /* ArgTypeTest */
  9554. static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
  9555. {
  9556. if (unlikely(!type)) {
  9557. PyErr_SetString(PyExc_SystemError, "Missing type object");
  9558. return 0;
  9559. }
  9560. else if (exact) {
  9561. #if PY_MAJOR_VERSION == 2
  9562. if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
  9563. #endif
  9564. }
  9565. else {
  9566. if (likely(__Pyx_TypeCheck(obj, type))) return 1;
  9567. }
  9568. PyErr_Format(PyExc_TypeError,
  9569. "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
  9570. name, type->tp_name, Py_TYPE(obj)->tp_name);
  9571. return 0;
  9572. }
  9573. /* SwapException */
  9574. #if CYTHON_FAST_THREAD_STATE
  9575. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  9576. PyObject *tmp_type, *tmp_value, *tmp_tb;
  9577. #if CYTHON_USE_EXC_INFO_STACK
  9578. _PyErr_StackItem *exc_info = tstate->exc_info;
  9579. tmp_type = exc_info->exc_type;
  9580. tmp_value = exc_info->exc_value;
  9581. tmp_tb = exc_info->exc_traceback;
  9582. exc_info->exc_type = *type;
  9583. exc_info->exc_value = *value;
  9584. exc_info->exc_traceback = *tb;
  9585. #else
  9586. tmp_type = tstate->exc_type;
  9587. tmp_value = tstate->exc_value;
  9588. tmp_tb = tstate->exc_traceback;
  9589. tstate->exc_type = *type;
  9590. tstate->exc_value = *value;
  9591. tstate->exc_traceback = *tb;
  9592. #endif
  9593. *type = tmp_type;
  9594. *value = tmp_value;
  9595. *tb = tmp_tb;
  9596. }
  9597. #else
  9598. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
  9599. PyObject *tmp_type, *tmp_value, *tmp_tb;
  9600. PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
  9601. PyErr_SetExcInfo(*type, *value, *tb);
  9602. *type = tmp_type;
  9603. *value = tmp_value;
  9604. *tb = tmp_tb;
  9605. }
  9606. #endif
  9607. /* PyObject_GenericGetAttrNoDict */
  9608. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  9609. static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
  9610. PyErr_Format(PyExc_AttributeError,
  9611. #if PY_MAJOR_VERSION >= 3
  9612. "'%.50s' object has no attribute '%U'",
  9613. tp->tp_name, attr_name);
  9614. #else
  9615. "'%.50s' object has no attribute '%.400s'",
  9616. tp->tp_name, PyString_AS_STRING(attr_name));
  9617. #endif
  9618. return NULL;
  9619. }
  9620. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
  9621. PyObject *descr;
  9622. PyTypeObject *tp = Py_TYPE(obj);
  9623. if (unlikely(!PyString_Check(attr_name))) {
  9624. return PyObject_GenericGetAttr(obj, attr_name);
  9625. }
  9626. assert(!tp->tp_dictoffset);
  9627. descr = _PyType_Lookup(tp, attr_name);
  9628. if (unlikely(!descr)) {
  9629. return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
  9630. }
  9631. Py_INCREF(descr);
  9632. #if PY_MAJOR_VERSION < 3
  9633. if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
  9634. #endif
  9635. {
  9636. descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
  9637. if (unlikely(f)) {
  9638. PyObject *res = f(descr, obj, (PyObject *)tp);
  9639. Py_DECREF(descr);
  9640. return res;
  9641. }
  9642. }
  9643. return descr;
  9644. }
  9645. #endif
  9646. /* PyObject_GenericGetAttr */
  9647. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  9648. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
  9649. if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
  9650. return PyObject_GenericGetAttr(obj, attr_name);
  9651. }
  9652. return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
  9653. }
  9654. #endif
  9655. /* SetVTable */
  9656. static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
  9657. #if PY_VERSION_HEX >= 0x02070000
  9658. PyObject *ob = PyCapsule_New(vtable, 0, 0);
  9659. #else
  9660. PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
  9661. #endif
  9662. if (!ob)
  9663. goto bad;
  9664. if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
  9665. goto bad;
  9666. Py_DECREF(ob);
  9667. return 0;
  9668. bad:
  9669. Py_XDECREF(ob);
  9670. return -1;
  9671. }
  9672. /* SetupReduce */
  9673. static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  9674. int ret;
  9675. PyObject *name_attr;
  9676. name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  9677. if (likely(name_attr)) {
  9678. ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  9679. } else {
  9680. ret = -1;
  9681. }
  9682. if (unlikely(ret < 0)) {
  9683. PyErr_Clear();
  9684. ret = 0;
  9685. }
  9686. Py_XDECREF(name_attr);
  9687. return ret;
  9688. }
  9689. static int __Pyx_setup_reduce(PyObject* type_obj) {
  9690. int ret = 0;
  9691. PyObject *object_reduce = NULL;
  9692. PyObject *object_reduce_ex = NULL;
  9693. PyObject *reduce = NULL;
  9694. PyObject *reduce_ex = NULL;
  9695. PyObject *reduce_cython = NULL;
  9696. PyObject *setstate = NULL;
  9697. PyObject *setstate_cython = NULL;
  9698. #if CYTHON_USE_PYTYPE_LOOKUP
  9699. if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD;
  9700. #else
  9701. if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD;
  9702. #endif
  9703. #if CYTHON_USE_PYTYPE_LOOKUP
  9704. object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
  9705. #else
  9706. object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
  9707. #endif
  9708. reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD;
  9709. if (reduce_ex == object_reduce_ex) {
  9710. #if CYTHON_USE_PYTYPE_LOOKUP
  9711. object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
  9712. #else
  9713. object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
  9714. #endif
  9715. reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD;
  9716. if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
  9717. reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD;
  9718. ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD;
  9719. ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD;
  9720. setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
  9721. if (!setstate) PyErr_Clear();
  9722. if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
  9723. setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD;
  9724. ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD;
  9725. ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD;
  9726. }
  9727. PyType_Modified((PyTypeObject*)type_obj);
  9728. }
  9729. }
  9730. goto GOOD;
  9731. BAD:
  9732. if (!PyErr_Occurred())
  9733. PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
  9734. ret = -1;
  9735. GOOD:
  9736. #if !CYTHON_USE_PYTYPE_LOOKUP
  9737. Py_XDECREF(object_reduce);
  9738. Py_XDECREF(object_reduce_ex);
  9739. #endif
  9740. Py_XDECREF(reduce);
  9741. Py_XDECREF(reduce_ex);
  9742. Py_XDECREF(reduce_cython);
  9743. Py_XDECREF(setstate);
  9744. Py_XDECREF(setstate_cython);
  9745. return ret;
  9746. }
  9747. /* TypeImport */
  9748. #ifndef __PYX_HAVE_RT_ImportType
  9749. #define __PYX_HAVE_RT_ImportType
  9750. static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
  9751. size_t size, enum __Pyx_ImportType_CheckSize check_size)
  9752. {
  9753. PyObject *result = 0;
  9754. char warning[200];
  9755. Py_ssize_t basicsize;
  9756. #ifdef Py_LIMITED_API
  9757. PyObject *py_basicsize;
  9758. #endif
  9759. result = PyObject_GetAttrString(module, class_name);
  9760. if (!result)
  9761. goto bad;
  9762. if (!PyType_Check(result)) {
  9763. PyErr_Format(PyExc_TypeError,
  9764. "%.200s.%.200s is not a type object",
  9765. module_name, class_name);
  9766. goto bad;
  9767. }
  9768. #ifndef Py_LIMITED_API
  9769. basicsize = ((PyTypeObject *)result)->tp_basicsize;
  9770. #else
  9771. py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
  9772. if (!py_basicsize)
  9773. goto bad;
  9774. basicsize = PyLong_AsSsize_t(py_basicsize);
  9775. Py_DECREF(py_basicsize);
  9776. py_basicsize = 0;
  9777. if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
  9778. goto bad;
  9779. #endif
  9780. if ((size_t)basicsize < size) {
  9781. PyErr_Format(PyExc_ValueError,
  9782. "%.200s.%.200s size changed, may indicate binary incompatibility. "
  9783. "Expected %zd from C header, got %zd from PyObject",
  9784. module_name, class_name, size, basicsize);
  9785. goto bad;
  9786. }
  9787. if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
  9788. PyErr_Format(PyExc_ValueError,
  9789. "%.200s.%.200s size changed, may indicate binary incompatibility. "
  9790. "Expected %zd from C header, got %zd from PyObject",
  9791. module_name, class_name, size, basicsize);
  9792. goto bad;
  9793. }
  9794. else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
  9795. PyOS_snprintf(warning, sizeof(warning),
  9796. "%s.%s size changed, may indicate binary incompatibility. "
  9797. "Expected %zd from C header, got %zd from PyObject",
  9798. module_name, class_name, size, basicsize);
  9799. if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
  9800. }
  9801. return (PyTypeObject *)result;
  9802. bad:
  9803. Py_XDECREF(result);
  9804. return NULL;
  9805. }
  9806. #endif
  9807. /* Import */
  9808. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
  9809. PyObject *empty_list = 0;
  9810. PyObject *module = 0;
  9811. PyObject *global_dict = 0;
  9812. PyObject *empty_dict = 0;
  9813. PyObject *list;
  9814. #if PY_MAJOR_VERSION < 3
  9815. PyObject *py_import;
  9816. py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
  9817. if (!py_import)
  9818. goto bad;
  9819. #endif
  9820. if (from_list)
  9821. list = from_list;
  9822. else {
  9823. empty_list = PyList_New(0);
  9824. if (!empty_list)
  9825. goto bad;
  9826. list = empty_list;
  9827. }
  9828. global_dict = PyModule_GetDict(__pyx_m);
  9829. if (!global_dict)
  9830. goto bad;
  9831. empty_dict = PyDict_New();
  9832. if (!empty_dict)
  9833. goto bad;
  9834. {
  9835. #if PY_MAJOR_VERSION >= 3
  9836. if (level == -1) {
  9837. if (strchr(__Pyx_MODULE_NAME, '.')) {
  9838. module = PyImport_ImportModuleLevelObject(
  9839. name, global_dict, empty_dict, list, 1);
  9840. if (!module) {
  9841. if (!PyErr_ExceptionMatches(PyExc_ImportError))
  9842. goto bad;
  9843. PyErr_Clear();
  9844. }
  9845. }
  9846. level = 0;
  9847. }
  9848. #endif
  9849. if (!module) {
  9850. #if PY_MAJOR_VERSION < 3
  9851. PyObject *py_level = PyInt_FromLong(level);
  9852. if (!py_level)
  9853. goto bad;
  9854. module = PyObject_CallFunctionObjArgs(py_import,
  9855. name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
  9856. Py_DECREF(py_level);
  9857. #else
  9858. module = PyImport_ImportModuleLevelObject(
  9859. name, global_dict, empty_dict, list, level);
  9860. #endif
  9861. }
  9862. }
  9863. bad:
  9864. #if PY_MAJOR_VERSION < 3
  9865. Py_XDECREF(py_import);
  9866. #endif
  9867. Py_XDECREF(empty_list);
  9868. Py_XDECREF(empty_dict);
  9869. return module;
  9870. }
  9871. /* ImportFrom */
  9872. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  9873. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  9874. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  9875. PyErr_Format(PyExc_ImportError,
  9876. #if PY_MAJOR_VERSION < 3
  9877. "cannot import name %.230s", PyString_AS_STRING(name));
  9878. #else
  9879. "cannot import name %S", name);
  9880. #endif
  9881. }
  9882. return value;
  9883. }
  9884. /* CLineInTraceback */
  9885. #ifndef CYTHON_CLINE_IN_TRACEBACK
  9886. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
  9887. PyObject *use_cline;
  9888. PyObject *ptype, *pvalue, *ptraceback;
  9889. #if CYTHON_COMPILING_IN_CPYTHON
  9890. PyObject **cython_runtime_dict;
  9891. #endif
  9892. if (unlikely(!__pyx_cython_runtime)) {
  9893. return c_line;
  9894. }
  9895. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  9896. #if CYTHON_COMPILING_IN_CPYTHON
  9897. cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
  9898. if (likely(cython_runtime_dict)) {
  9899. __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
  9900. use_cline, *cython_runtime_dict,
  9901. __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
  9902. } else
  9903. #endif
  9904. {
  9905. PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
  9906. if (use_cline_obj) {
  9907. use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
  9908. Py_DECREF(use_cline_obj);
  9909. } else {
  9910. PyErr_Clear();
  9911. use_cline = NULL;
  9912. }
  9913. }
  9914. if (!use_cline) {
  9915. c_line = 0;
  9916. PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
  9917. }
  9918. else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
  9919. c_line = 0;
  9920. }
  9921. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  9922. return c_line;
  9923. }
  9924. #endif
  9925. /* CodeObjectCache */
  9926. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  9927. int start = 0, mid = 0, end = count - 1;
  9928. if (end >= 0 && code_line > entries[end].code_line) {
  9929. return count;
  9930. }
  9931. while (start < end) {
  9932. mid = start + (end - start) / 2;
  9933. if (code_line < entries[mid].code_line) {
  9934. end = mid;
  9935. } else if (code_line > entries[mid].code_line) {
  9936. start = mid + 1;
  9937. } else {
  9938. return mid;
  9939. }
  9940. }
  9941. if (code_line <= entries[mid].code_line) {
  9942. return mid;
  9943. } else {
  9944. return mid + 1;
  9945. }
  9946. }
  9947. static PyCodeObject *__pyx_find_code_object(int code_line) {
  9948. PyCodeObject* code_object;
  9949. int pos;
  9950. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  9951. return NULL;
  9952. }
  9953. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  9954. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  9955. return NULL;
  9956. }
  9957. code_object = __pyx_code_cache.entries[pos].code_object;
  9958. Py_INCREF(code_object);
  9959. return code_object;
  9960. }
  9961. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  9962. int pos, i;
  9963. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  9964. if (unlikely(!code_line)) {
  9965. return;
  9966. }
  9967. if (unlikely(!entries)) {
  9968. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  9969. if (likely(entries)) {
  9970. __pyx_code_cache.entries = entries;
  9971. __pyx_code_cache.max_count = 64;
  9972. __pyx_code_cache.count = 1;
  9973. entries[0].code_line = code_line;
  9974. entries[0].code_object = code_object;
  9975. Py_INCREF(code_object);
  9976. }
  9977. return;
  9978. }
  9979. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  9980. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  9981. PyCodeObject* tmp = entries[pos].code_object;
  9982. entries[pos].code_object = code_object;
  9983. Py_DECREF(tmp);
  9984. return;
  9985. }
  9986. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  9987. int new_max = __pyx_code_cache.max_count + 64;
  9988. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  9989. __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  9990. if (unlikely(!entries)) {
  9991. return;
  9992. }
  9993. __pyx_code_cache.entries = entries;
  9994. __pyx_code_cache.max_count = new_max;
  9995. }
  9996. for (i=__pyx_code_cache.count; i>pos; i--) {
  9997. entries[i] = entries[i-1];
  9998. }
  9999. entries[pos].code_line = code_line;
  10000. entries[pos].code_object = code_object;
  10001. __pyx_code_cache.count++;
  10002. Py_INCREF(code_object);
  10003. }
  10004. /* AddTraceback */
  10005. #include "compile.h"
  10006. #include "frameobject.h"
  10007. #include "traceback.h"
  10008. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  10009. const char *funcname, int c_line,
  10010. int py_line, const char *filename) {
  10011. PyCodeObject *py_code = 0;
  10012. PyObject *py_srcfile = 0;
  10013. PyObject *py_funcname = 0;
  10014. #if PY_MAJOR_VERSION < 3
  10015. py_srcfile = PyString_FromString(filename);
  10016. #else
  10017. py_srcfile = PyUnicode_FromString(filename);
  10018. #endif
  10019. if (!py_srcfile) goto bad;
  10020. if (c_line) {
  10021. #if PY_MAJOR_VERSION < 3
  10022. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  10023. #else
  10024. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  10025. #endif
  10026. }
  10027. else {
  10028. #if PY_MAJOR_VERSION < 3
  10029. py_funcname = PyString_FromString(funcname);
  10030. #else
  10031. py_funcname = PyUnicode_FromString(funcname);
  10032. #endif
  10033. }
  10034. if (!py_funcname) goto bad;
  10035. py_code = __Pyx_PyCode_New(
  10036. 0,
  10037. 0,
  10038. 0,
  10039. 0,
  10040. 0,
  10041. __pyx_empty_bytes, /*PyObject *code,*/
  10042. __pyx_empty_tuple, /*PyObject *consts,*/
  10043. __pyx_empty_tuple, /*PyObject *names,*/
  10044. __pyx_empty_tuple, /*PyObject *varnames,*/
  10045. __pyx_empty_tuple, /*PyObject *freevars,*/
  10046. __pyx_empty_tuple, /*PyObject *cellvars,*/
  10047. py_srcfile, /*PyObject *filename,*/
  10048. py_funcname, /*PyObject *name,*/
  10049. py_line,
  10050. __pyx_empty_bytes /*PyObject *lnotab*/
  10051. );
  10052. Py_DECREF(py_srcfile);
  10053. Py_DECREF(py_funcname);
  10054. return py_code;
  10055. bad:
  10056. Py_XDECREF(py_srcfile);
  10057. Py_XDECREF(py_funcname);
  10058. return NULL;
  10059. }
  10060. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  10061. int py_line, const char *filename) {
  10062. PyCodeObject *py_code = 0;
  10063. PyFrameObject *py_frame = 0;
  10064. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  10065. if (c_line) {
  10066. c_line = __Pyx_CLineForTraceback(tstate, c_line);
  10067. }
  10068. py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
  10069. if (!py_code) {
  10070. py_code = __Pyx_CreateCodeObjectForTraceback(
  10071. funcname, c_line, py_line, filename);
  10072. if (!py_code) goto bad;
  10073. __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
  10074. }
  10075. py_frame = PyFrame_New(
  10076. tstate, /*PyThreadState *tstate,*/
  10077. py_code, /*PyCodeObject *code,*/
  10078. __pyx_d, /*PyObject *globals,*/
  10079. 0 /*PyObject *locals*/
  10080. );
  10081. if (!py_frame) goto bad;
  10082. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  10083. PyTraceBack_Here(py_frame);
  10084. bad:
  10085. Py_XDECREF(py_code);
  10086. Py_XDECREF(py_frame);
  10087. }
  10088. /* CIntToPy */
  10089. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_short(unsigned short value) {
  10090. const unsigned short neg_one = (unsigned short) ((unsigned short) 0 - (unsigned short) 1), const_zero = (unsigned short) 0;
  10091. const int is_unsigned = neg_one > const_zero;
  10092. if (is_unsigned) {
  10093. if (sizeof(unsigned short) < sizeof(long)) {
  10094. return PyInt_FromLong((long) value);
  10095. } else if (sizeof(unsigned short) <= sizeof(unsigned long)) {
  10096. return PyLong_FromUnsignedLong((unsigned long) value);
  10097. #ifdef HAVE_LONG_LONG
  10098. } else if (sizeof(unsigned short) <= sizeof(unsigned PY_LONG_LONG)) {
  10099. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  10100. #endif
  10101. }
  10102. } else {
  10103. if (sizeof(unsigned short) <= sizeof(long)) {
  10104. return PyInt_FromLong((long) value);
  10105. #ifdef HAVE_LONG_LONG
  10106. } else if (sizeof(unsigned short) <= sizeof(PY_LONG_LONG)) {
  10107. return PyLong_FromLongLong((PY_LONG_LONG) value);
  10108. #endif
  10109. }
  10110. }
  10111. {
  10112. int one = 1; int little = (int)*(unsigned char *)&one;
  10113. unsigned char *bytes = (unsigned char *)&value;
  10114. return _PyLong_FromByteArray(bytes, sizeof(unsigned short),
  10115. little, !is_unsigned);
  10116. }
  10117. }
  10118. /* CIntToPy */
  10119. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
  10120. const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
  10121. const int is_unsigned = neg_one > const_zero;
  10122. if (is_unsigned) {
  10123. if (sizeof(int) < sizeof(long)) {
  10124. return PyInt_FromLong((long) value);
  10125. } else if (sizeof(int) <= sizeof(unsigned long)) {
  10126. return PyLong_FromUnsignedLong((unsigned long) value);
  10127. #ifdef HAVE_LONG_LONG
  10128. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  10129. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  10130. #endif
  10131. }
  10132. } else {
  10133. if (sizeof(int) <= sizeof(long)) {
  10134. return PyInt_FromLong((long) value);
  10135. #ifdef HAVE_LONG_LONG
  10136. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  10137. return PyLong_FromLongLong((PY_LONG_LONG) value);
  10138. #endif
  10139. }
  10140. }
  10141. {
  10142. int one = 1; int little = (int)*(unsigned char *)&one;
  10143. unsigned char *bytes = (unsigned char *)&value;
  10144. return _PyLong_FromByteArray(bytes, sizeof(int),
  10145. little, !is_unsigned);
  10146. }
  10147. }
  10148. /* CIntToPy */
  10149. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) {
  10150. const unsigned int neg_one = (unsigned int) ((unsigned int) 0 - (unsigned int) 1), const_zero = (unsigned int) 0;
  10151. const int is_unsigned = neg_one > const_zero;
  10152. if (is_unsigned) {
  10153. if (sizeof(unsigned int) < sizeof(long)) {
  10154. return PyInt_FromLong((long) value);
  10155. } else if (sizeof(unsigned int) <= sizeof(unsigned long)) {
  10156. return PyLong_FromUnsignedLong((unsigned long) value);
  10157. #ifdef HAVE_LONG_LONG
  10158. } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
  10159. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  10160. #endif
  10161. }
  10162. } else {
  10163. if (sizeof(unsigned int) <= sizeof(long)) {
  10164. return PyInt_FromLong((long) value);
  10165. #ifdef HAVE_LONG_LONG
  10166. } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
  10167. return PyLong_FromLongLong((PY_LONG_LONG) value);
  10168. #endif
  10169. }
  10170. }
  10171. {
  10172. int one = 1; int little = (int)*(unsigned char *)&one;
  10173. unsigned char *bytes = (unsigned char *)&value;
  10174. return _PyLong_FromByteArray(bytes, sizeof(unsigned int),
  10175. little, !is_unsigned);
  10176. }
  10177. }
  10178. /* CIntToPy */
  10179. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint16_t(uint16_t value) {
  10180. const uint16_t neg_one = (uint16_t) ((uint16_t) 0 - (uint16_t) 1), const_zero = (uint16_t) 0;
  10181. const int is_unsigned = neg_one > const_zero;
  10182. if (is_unsigned) {
  10183. if (sizeof(uint16_t) < sizeof(long)) {
  10184. return PyInt_FromLong((long) value);
  10185. } else if (sizeof(uint16_t) <= sizeof(unsigned long)) {
  10186. return PyLong_FromUnsignedLong((unsigned long) value);
  10187. #ifdef HAVE_LONG_LONG
  10188. } else if (sizeof(uint16_t) <= sizeof(unsigned PY_LONG_LONG)) {
  10189. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  10190. #endif
  10191. }
  10192. } else {
  10193. if (sizeof(uint16_t) <= sizeof(long)) {
  10194. return PyInt_FromLong((long) value);
  10195. #ifdef HAVE_LONG_LONG
  10196. } else if (sizeof(uint16_t) <= sizeof(PY_LONG_LONG)) {
  10197. return PyLong_FromLongLong((PY_LONG_LONG) value);
  10198. #endif
  10199. }
  10200. }
  10201. {
  10202. int one = 1; int little = (int)*(unsigned char *)&one;
  10203. unsigned char *bytes = (unsigned char *)&value;
  10204. return _PyLong_FromByteArray(bytes, sizeof(uint16_t),
  10205. little, !is_unsigned);
  10206. }
  10207. }
  10208. /* CIntToPy */
  10209. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  10210. const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
  10211. const int is_unsigned = neg_one > const_zero;
  10212. if (is_unsigned) {
  10213. if (sizeof(long) < sizeof(long)) {
  10214. return PyInt_FromLong((long) value);
  10215. } else if (sizeof(long) <= sizeof(unsigned long)) {
  10216. return PyLong_FromUnsignedLong((unsigned long) value);
  10217. #ifdef HAVE_LONG_LONG
  10218. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  10219. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  10220. #endif
  10221. }
  10222. } else {
  10223. if (sizeof(long) <= sizeof(long)) {
  10224. return PyInt_FromLong((long) value);
  10225. #ifdef HAVE_LONG_LONG
  10226. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  10227. return PyLong_FromLongLong((PY_LONG_LONG) value);
  10228. #endif
  10229. }
  10230. }
  10231. {
  10232. int one = 1; int little = (int)*(unsigned char *)&one;
  10233. unsigned char *bytes = (unsigned char *)&value;
  10234. return _PyLong_FromByteArray(bytes, sizeof(long),
  10235. little, !is_unsigned);
  10236. }
  10237. }
  10238. /* CIntFromPyVerify */
  10239. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  10240. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  10241. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  10242. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  10243. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  10244. {\
  10245. func_type value = func_value;\
  10246. if (sizeof(target_type) < sizeof(func_type)) {\
  10247. if (unlikely(value != (func_type) (target_type) value)) {\
  10248. func_type zero = 0;\
  10249. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  10250. return (target_type) -1;\
  10251. if (is_unsigned && unlikely(value < zero))\
  10252. goto raise_neg_overflow;\
  10253. else\
  10254. goto raise_overflow;\
  10255. }\
  10256. }\
  10257. return (target_type) value;\
  10258. }
  10259. /* CIntFromPy */
  10260. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  10261. const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
  10262. const int is_unsigned = neg_one > const_zero;
  10263. #if PY_MAJOR_VERSION < 3
  10264. if (likely(PyInt_Check(x))) {
  10265. if (sizeof(long) < sizeof(long)) {
  10266. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
  10267. } else {
  10268. long val = PyInt_AS_LONG(x);
  10269. if (is_unsigned && unlikely(val < 0)) {
  10270. goto raise_neg_overflow;
  10271. }
  10272. return (long) val;
  10273. }
  10274. } else
  10275. #endif
  10276. if (likely(PyLong_Check(x))) {
  10277. if (is_unsigned) {
  10278. #if CYTHON_USE_PYLONG_INTERNALS
  10279. const digit* digits = ((PyLongObject*)x)->ob_digit;
  10280. switch (Py_SIZE(x)) {
  10281. case 0: return (long) 0;
  10282. case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
  10283. case 2:
  10284. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  10285. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10286. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10287. } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
  10288. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  10289. }
  10290. }
  10291. break;
  10292. case 3:
  10293. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  10294. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10295. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10296. } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
  10297. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  10298. }
  10299. }
  10300. break;
  10301. case 4:
  10302. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  10303. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10304. __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])))
  10305. } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
  10306. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  10307. }
  10308. }
  10309. break;
  10310. }
  10311. #endif
  10312. #if CYTHON_COMPILING_IN_CPYTHON
  10313. if (unlikely(Py_SIZE(x) < 0)) {
  10314. goto raise_neg_overflow;
  10315. }
  10316. #else
  10317. {
  10318. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  10319. if (unlikely(result < 0))
  10320. return (long) -1;
  10321. if (unlikely(result == 1))
  10322. goto raise_neg_overflow;
  10323. }
  10324. #endif
  10325. if (sizeof(long) <= sizeof(unsigned long)) {
  10326. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  10327. #ifdef HAVE_LONG_LONG
  10328. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  10329. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  10330. #endif
  10331. }
  10332. } else {
  10333. #if CYTHON_USE_PYLONG_INTERNALS
  10334. const digit* digits = ((PyLongObject*)x)->ob_digit;
  10335. switch (Py_SIZE(x)) {
  10336. case 0: return (long) 0;
  10337. case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
  10338. case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
  10339. case -2:
  10340. if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
  10341. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10342. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10343. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  10344. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  10345. }
  10346. }
  10347. break;
  10348. case 2:
  10349. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  10350. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10351. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10352. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  10353. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  10354. }
  10355. }
  10356. break;
  10357. case -3:
  10358. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  10359. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10360. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10361. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  10362. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  10363. }
  10364. }
  10365. break;
  10366. case 3:
  10367. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  10368. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10369. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10370. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  10371. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  10372. }
  10373. }
  10374. break;
  10375. case -4:
  10376. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  10377. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10378. __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])))
  10379. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  10380. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  10381. }
  10382. }
  10383. break;
  10384. case 4:
  10385. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  10386. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10387. __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])))
  10388. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  10389. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  10390. }
  10391. }
  10392. break;
  10393. }
  10394. #endif
  10395. if (sizeof(long) <= sizeof(long)) {
  10396. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  10397. #ifdef HAVE_LONG_LONG
  10398. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  10399. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  10400. #endif
  10401. }
  10402. }
  10403. {
  10404. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  10405. PyErr_SetString(PyExc_RuntimeError,
  10406. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  10407. #else
  10408. long val;
  10409. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  10410. #if PY_MAJOR_VERSION < 3
  10411. if (likely(v) && !PyLong_Check(v)) {
  10412. PyObject *tmp = v;
  10413. v = PyNumber_Long(tmp);
  10414. Py_DECREF(tmp);
  10415. }
  10416. #endif
  10417. if (likely(v)) {
  10418. int one = 1; int is_little = (int)*(unsigned char *)&one;
  10419. unsigned char *bytes = (unsigned char *)&val;
  10420. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  10421. bytes, sizeof(val),
  10422. is_little, !is_unsigned);
  10423. Py_DECREF(v);
  10424. if (likely(!ret))
  10425. return val;
  10426. }
  10427. #endif
  10428. return (long) -1;
  10429. }
  10430. } else {
  10431. long val;
  10432. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  10433. if (!tmp) return (long) -1;
  10434. val = __Pyx_PyInt_As_long(tmp);
  10435. Py_DECREF(tmp);
  10436. return val;
  10437. }
  10438. raise_overflow:
  10439. PyErr_SetString(PyExc_OverflowError,
  10440. "value too large to convert to long");
  10441. return (long) -1;
  10442. raise_neg_overflow:
  10443. PyErr_SetString(PyExc_OverflowError,
  10444. "can't convert negative value to long");
  10445. return (long) -1;
  10446. }
  10447. /* CIntFromPy */
  10448. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  10449. const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
  10450. const int is_unsigned = neg_one > const_zero;
  10451. #if PY_MAJOR_VERSION < 3
  10452. if (likely(PyInt_Check(x))) {
  10453. if (sizeof(int) < sizeof(long)) {
  10454. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
  10455. } else {
  10456. long val = PyInt_AS_LONG(x);
  10457. if (is_unsigned && unlikely(val < 0)) {
  10458. goto raise_neg_overflow;
  10459. }
  10460. return (int) val;
  10461. }
  10462. } else
  10463. #endif
  10464. if (likely(PyLong_Check(x))) {
  10465. if (is_unsigned) {
  10466. #if CYTHON_USE_PYLONG_INTERNALS
  10467. const digit* digits = ((PyLongObject*)x)->ob_digit;
  10468. switch (Py_SIZE(x)) {
  10469. case 0: return (int) 0;
  10470. case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
  10471. case 2:
  10472. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  10473. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10474. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10475. } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
  10476. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  10477. }
  10478. }
  10479. break;
  10480. case 3:
  10481. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  10482. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10483. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10484. } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
  10485. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  10486. }
  10487. }
  10488. break;
  10489. case 4:
  10490. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  10491. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10492. __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])))
  10493. } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
  10494. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  10495. }
  10496. }
  10497. break;
  10498. }
  10499. #endif
  10500. #if CYTHON_COMPILING_IN_CPYTHON
  10501. if (unlikely(Py_SIZE(x) < 0)) {
  10502. goto raise_neg_overflow;
  10503. }
  10504. #else
  10505. {
  10506. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  10507. if (unlikely(result < 0))
  10508. return (int) -1;
  10509. if (unlikely(result == 1))
  10510. goto raise_neg_overflow;
  10511. }
  10512. #endif
  10513. if (sizeof(int) <= sizeof(unsigned long)) {
  10514. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  10515. #ifdef HAVE_LONG_LONG
  10516. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  10517. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  10518. #endif
  10519. }
  10520. } else {
  10521. #if CYTHON_USE_PYLONG_INTERNALS
  10522. const digit* digits = ((PyLongObject*)x)->ob_digit;
  10523. switch (Py_SIZE(x)) {
  10524. case 0: return (int) 0;
  10525. case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
  10526. case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
  10527. case -2:
  10528. if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
  10529. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10530. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10531. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  10532. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  10533. }
  10534. }
  10535. break;
  10536. case 2:
  10537. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  10538. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10539. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10540. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  10541. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  10542. }
  10543. }
  10544. break;
  10545. case -3:
  10546. if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  10547. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10548. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10549. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  10550. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  10551. }
  10552. }
  10553. break;
  10554. case 3:
  10555. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  10556. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10557. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10558. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  10559. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  10560. }
  10561. }
  10562. break;
  10563. case -4:
  10564. if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  10565. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10566. __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])))
  10567. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  10568. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  10569. }
  10570. }
  10571. break;
  10572. case 4:
  10573. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  10574. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10575. __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])))
  10576. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  10577. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  10578. }
  10579. }
  10580. break;
  10581. }
  10582. #endif
  10583. if (sizeof(int) <= sizeof(long)) {
  10584. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  10585. #ifdef HAVE_LONG_LONG
  10586. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  10587. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  10588. #endif
  10589. }
  10590. }
  10591. {
  10592. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  10593. PyErr_SetString(PyExc_RuntimeError,
  10594. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  10595. #else
  10596. int val;
  10597. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  10598. #if PY_MAJOR_VERSION < 3
  10599. if (likely(v) && !PyLong_Check(v)) {
  10600. PyObject *tmp = v;
  10601. v = PyNumber_Long(tmp);
  10602. Py_DECREF(tmp);
  10603. }
  10604. #endif
  10605. if (likely(v)) {
  10606. int one = 1; int is_little = (int)*(unsigned char *)&one;
  10607. unsigned char *bytes = (unsigned char *)&val;
  10608. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  10609. bytes, sizeof(val),
  10610. is_little, !is_unsigned);
  10611. Py_DECREF(v);
  10612. if (likely(!ret))
  10613. return val;
  10614. }
  10615. #endif
  10616. return (int) -1;
  10617. }
  10618. } else {
  10619. int val;
  10620. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  10621. if (!tmp) return (int) -1;
  10622. val = __Pyx_PyInt_As_int(tmp);
  10623. Py_DECREF(tmp);
  10624. return val;
  10625. }
  10626. raise_overflow:
  10627. PyErr_SetString(PyExc_OverflowError,
  10628. "value too large to convert to int");
  10629. return (int) -1;
  10630. raise_neg_overflow:
  10631. PyErr_SetString(PyExc_OverflowError,
  10632. "can't convert negative value to int");
  10633. return (int) -1;
  10634. }
  10635. /* FastTypeChecks */
  10636. #if CYTHON_COMPILING_IN_CPYTHON
  10637. static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
  10638. while (a) {
  10639. a = a->tp_base;
  10640. if (a == b)
  10641. return 1;
  10642. }
  10643. return b == &PyBaseObject_Type;
  10644. }
  10645. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
  10646. PyObject *mro;
  10647. if (a == b) return 1;
  10648. mro = a->tp_mro;
  10649. if (likely(mro)) {
  10650. Py_ssize_t i, n;
  10651. n = PyTuple_GET_SIZE(mro);
  10652. for (i = 0; i < n; i++) {
  10653. if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
  10654. return 1;
  10655. }
  10656. return 0;
  10657. }
  10658. return __Pyx_InBases(a, b);
  10659. }
  10660. #if PY_MAJOR_VERSION == 2
  10661. static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
  10662. PyObject *exception, *value, *tb;
  10663. int res;
  10664. __Pyx_PyThreadState_declare
  10665. __Pyx_PyThreadState_assign
  10666. __Pyx_ErrFetch(&exception, &value, &tb);
  10667. res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
  10668. if (unlikely(res == -1)) {
  10669. PyErr_WriteUnraisable(err);
  10670. res = 0;
  10671. }
  10672. if (!res) {
  10673. res = PyObject_IsSubclass(err, exc_type2);
  10674. if (unlikely(res == -1)) {
  10675. PyErr_WriteUnraisable(err);
  10676. res = 0;
  10677. }
  10678. }
  10679. __Pyx_ErrRestore(exception, value, tb);
  10680. return res;
  10681. }
  10682. #else
  10683. static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
  10684. int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
  10685. if (!res) {
  10686. res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
  10687. }
  10688. return res;
  10689. }
  10690. #endif
  10691. static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  10692. Py_ssize_t i, n;
  10693. assert(PyExceptionClass_Check(exc_type));
  10694. n = PyTuple_GET_SIZE(tuple);
  10695. #if PY_MAJOR_VERSION >= 3
  10696. for (i=0; i<n; i++) {
  10697. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  10698. }
  10699. #endif
  10700. for (i=0; i<n; i++) {
  10701. PyObject *t = PyTuple_GET_ITEM(tuple, i);
  10702. #if PY_MAJOR_VERSION < 3
  10703. if (likely(exc_type == t)) return 1;
  10704. #endif
  10705. if (likely(PyExceptionClass_Check(t))) {
  10706. if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
  10707. } else {
  10708. }
  10709. }
  10710. return 0;
  10711. }
  10712. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
  10713. if (likely(err == exc_type)) return 1;
  10714. if (likely(PyExceptionClass_Check(err))) {
  10715. if (likely(PyExceptionClass_Check(exc_type))) {
  10716. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
  10717. } else if (likely(PyTuple_Check(exc_type))) {
  10718. return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
  10719. } else {
  10720. }
  10721. }
  10722. return PyErr_GivenExceptionMatches(err, exc_type);
  10723. }
  10724. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
  10725. assert(PyExceptionClass_Check(exc_type1));
  10726. assert(PyExceptionClass_Check(exc_type2));
  10727. if (likely(err == exc_type1 || err == exc_type2)) return 1;
  10728. if (likely(PyExceptionClass_Check(err))) {
  10729. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
  10730. }
  10731. return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
  10732. }
  10733. #endif
  10734. /* CheckBinaryVersion */
  10735. static int __Pyx_check_binary_version(void) {
  10736. char ctversion[4], rtversion[4];
  10737. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  10738. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  10739. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  10740. char message[200];
  10741. PyOS_snprintf(message, sizeof(message),
  10742. "compiletime version %s of module '%.100s' "
  10743. "does not match runtime version %s",
  10744. ctversion, __Pyx_MODULE_NAME, rtversion);
  10745. return PyErr_WarnEx(NULL, message, 1);
  10746. }
  10747. return 0;
  10748. }
  10749. /* InitStrings */
  10750. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  10751. while (t->p) {
  10752. #if PY_MAJOR_VERSION < 3
  10753. if (t->is_unicode) {
  10754. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  10755. } else if (t->intern) {
  10756. *t->p = PyString_InternFromString(t->s);
  10757. } else {
  10758. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  10759. }
  10760. #else
  10761. if (t->is_unicode | t->is_str) {
  10762. if (t->intern) {
  10763. *t->p = PyUnicode_InternFromString(t->s);
  10764. } else if (t->encoding) {
  10765. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  10766. } else {
  10767. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  10768. }
  10769. } else {
  10770. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  10771. }
  10772. #endif
  10773. if (!*t->p)
  10774. return -1;
  10775. if (PyObject_Hash(*t->p) == -1)
  10776. return -1;
  10777. ++t;
  10778. }
  10779. return 0;
  10780. }
  10781. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  10782. return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
  10783. }
  10784. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
  10785. Py_ssize_t ignore;
  10786. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  10787. }
  10788. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  10789. #if !CYTHON_PEP393_ENABLED
  10790. static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  10791. char* defenc_c;
  10792. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  10793. if (!defenc) return NULL;
  10794. defenc_c = PyBytes_AS_STRING(defenc);
  10795. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  10796. {
  10797. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  10798. char* c;
  10799. for (c = defenc_c; c < end; c++) {
  10800. if ((unsigned char) (*c) >= 128) {
  10801. PyUnicode_AsASCIIString(o);
  10802. return NULL;
  10803. }
  10804. }
  10805. }
  10806. #endif
  10807. *length = PyBytes_GET_SIZE(defenc);
  10808. return defenc_c;
  10809. }
  10810. #else
  10811. static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  10812. if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
  10813. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  10814. if (likely(PyUnicode_IS_ASCII(o))) {
  10815. *length = PyUnicode_GET_LENGTH(o);
  10816. return PyUnicode_AsUTF8(o);
  10817. } else {
  10818. PyUnicode_AsASCIIString(o);
  10819. return NULL;
  10820. }
  10821. #else
  10822. return PyUnicode_AsUTF8AndSize(o, length);
  10823. #endif
  10824. }
  10825. #endif
  10826. #endif
  10827. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  10828. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  10829. if (
  10830. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  10831. __Pyx_sys_getdefaultencoding_not_ascii &&
  10832. #endif
  10833. PyUnicode_Check(o)) {
  10834. return __Pyx_PyUnicode_AsStringAndSize(o, length);
  10835. } else
  10836. #endif
  10837. #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
  10838. if (PyByteArray_Check(o)) {
  10839. *length = PyByteArray_GET_SIZE(o);
  10840. return PyByteArray_AS_STRING(o);
  10841. } else
  10842. #endif
  10843. {
  10844. char* result;
  10845. int r = PyBytes_AsStringAndSize(o, &result, length);
  10846. if (unlikely(r < 0)) {
  10847. return NULL;
  10848. } else {
  10849. return result;
  10850. }
  10851. }
  10852. }
  10853. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  10854. int is_true = x == Py_True;
  10855. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  10856. else return PyObject_IsTrue(x);
  10857. }
  10858. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
  10859. int retval;
  10860. if (unlikely(!x)) return -1;
  10861. retval = __Pyx_PyObject_IsTrue(x);
  10862. Py_DECREF(x);
  10863. return retval;
  10864. }
  10865. static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
  10866. #if PY_MAJOR_VERSION >= 3
  10867. if (PyLong_Check(result)) {
  10868. if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
  10869. "__int__ returned non-int (type %.200s). "
  10870. "The ability to return an instance of a strict subclass of int "
  10871. "is deprecated, and may be removed in a future version of Python.",
  10872. Py_TYPE(result)->tp_name)) {
  10873. Py_DECREF(result);
  10874. return NULL;
  10875. }
  10876. return result;
  10877. }
  10878. #endif
  10879. PyErr_Format(PyExc_TypeError,
  10880. "__%.4s__ returned non-%.4s (type %.200s)",
  10881. type_name, type_name, Py_TYPE(result)->tp_name);
  10882. Py_DECREF(result);
  10883. return NULL;
  10884. }
  10885. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  10886. #if CYTHON_USE_TYPE_SLOTS
  10887. PyNumberMethods *m;
  10888. #endif
  10889. const char *name = NULL;
  10890. PyObject *res = NULL;
  10891. #if PY_MAJOR_VERSION < 3
  10892. if (likely(PyInt_Check(x) || PyLong_Check(x)))
  10893. #else
  10894. if (likely(PyLong_Check(x)))
  10895. #endif
  10896. return __Pyx_NewRef(x);
  10897. #if CYTHON_USE_TYPE_SLOTS
  10898. m = Py_TYPE(x)->tp_as_number;
  10899. #if PY_MAJOR_VERSION < 3
  10900. if (m && m->nb_int) {
  10901. name = "int";
  10902. res = m->nb_int(x);
  10903. }
  10904. else if (m && m->nb_long) {
  10905. name = "long";
  10906. res = m->nb_long(x);
  10907. }
  10908. #else
  10909. if (likely(m && m->nb_int)) {
  10910. name = "int";
  10911. res = m->nb_int(x);
  10912. }
  10913. #endif
  10914. #else
  10915. if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
  10916. res = PyNumber_Int(x);
  10917. }
  10918. #endif
  10919. if (likely(res)) {
  10920. #if PY_MAJOR_VERSION < 3
  10921. if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
  10922. #else
  10923. if (unlikely(!PyLong_CheckExact(res))) {
  10924. #endif
  10925. return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
  10926. }
  10927. }
  10928. else if (!PyErr_Occurred()) {
  10929. PyErr_SetString(PyExc_TypeError,
  10930. "an integer is required");
  10931. }
  10932. return res;
  10933. }
  10934. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  10935. Py_ssize_t ival;
  10936. PyObject *x;
  10937. #if PY_MAJOR_VERSION < 3
  10938. if (likely(PyInt_CheckExact(b))) {
  10939. if (sizeof(Py_ssize_t) >= sizeof(long))
  10940. return PyInt_AS_LONG(b);
  10941. else
  10942. return PyInt_AsSsize_t(b);
  10943. }
  10944. #endif
  10945. if (likely(PyLong_CheckExact(b))) {
  10946. #if CYTHON_USE_PYLONG_INTERNALS
  10947. const digit* digits = ((PyLongObject*)b)->ob_digit;
  10948. const Py_ssize_t size = Py_SIZE(b);
  10949. if (likely(__Pyx_sst_abs(size) <= 1)) {
  10950. ival = likely(size) ? digits[0] : 0;
  10951. if (size == -1) ival = -ival;
  10952. return ival;
  10953. } else {
  10954. switch (size) {
  10955. case 2:
  10956. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  10957. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  10958. }
  10959. break;
  10960. case -2:
  10961. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  10962. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  10963. }
  10964. break;
  10965. case 3:
  10966. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  10967. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  10968. }
  10969. break;
  10970. case -3:
  10971. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  10972. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  10973. }
  10974. break;
  10975. case 4:
  10976. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  10977. 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]));
  10978. }
  10979. break;
  10980. case -4:
  10981. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  10982. 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]));
  10983. }
  10984. break;
  10985. }
  10986. }
  10987. #endif
  10988. return PyLong_AsSsize_t(b);
  10989. }
  10990. x = PyNumber_Index(b);
  10991. if (!x) return -1;
  10992. ival = PyInt_AsSsize_t(x);
  10993. Py_DECREF(x);
  10994. return ival;
  10995. }
  10996. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  10997. return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
  10998. }
  10999. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  11000. return PyInt_FromSize_t(ival);
  11001. }
  11002. #endif /* Py_PYTHON_H */