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.

12195 lines
459 KiB

4 years ago
  1. /* Generated by Cython 0.28.3 */
  2. /* BEGIN: Cython Metadata
  3. {
  4. "distutils": {
  5. "depends": [],
  6. "name": "yarl._quoting",
  7. "sources": [
  8. "yarl/_quoting.pyx"
  9. ]
  10. },
  11. "module_name": "yarl._quoting"
  12. }
  13. END: Cython Metadata */
  14. #define PY_SSIZE_T_CLEAN
  15. #include "Python.h"
  16. #ifndef Py_PYTHON_H
  17. #error Python headers needed to compile C extensions, please install development version of Python.
  18. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
  19. #error Cython requires Python 2.6+ or Python 3.3+.
  20. #else
  21. #define CYTHON_ABI "0_28_3"
  22. #define CYTHON_FUTURE_DIVISION 1
  23. #include <stddef.h>
  24. #ifndef offsetof
  25. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  26. #endif
  27. #if !defined(WIN32) && !defined(MS_WINDOWS)
  28. #ifndef __stdcall
  29. #define __stdcall
  30. #endif
  31. #ifndef __cdecl
  32. #define __cdecl
  33. #endif
  34. #ifndef __fastcall
  35. #define __fastcall
  36. #endif
  37. #endif
  38. #ifndef DL_IMPORT
  39. #define DL_IMPORT(t) t
  40. #endif
  41. #ifndef DL_EXPORT
  42. #define DL_EXPORT(t) t
  43. #endif
  44. #define __PYX_COMMA ,
  45. #ifndef HAVE_LONG_LONG
  46. #if PY_VERSION_HEX >= 0x02070000
  47. #define HAVE_LONG_LONG
  48. #endif
  49. #endif
  50. #ifndef PY_LONG_LONG
  51. #define PY_LONG_LONG LONG_LONG
  52. #endif
  53. #ifndef Py_HUGE_VAL
  54. #define Py_HUGE_VAL HUGE_VAL
  55. #endif
  56. #ifdef PYPY_VERSION
  57. #define CYTHON_COMPILING_IN_PYPY 1
  58. #define CYTHON_COMPILING_IN_PYSTON 0
  59. #define CYTHON_COMPILING_IN_CPYTHON 0
  60. #undef CYTHON_USE_TYPE_SLOTS
  61. #define CYTHON_USE_TYPE_SLOTS 0
  62. #undef CYTHON_USE_PYTYPE_LOOKUP
  63. #define CYTHON_USE_PYTYPE_LOOKUP 0
  64. #if PY_VERSION_HEX < 0x03050000
  65. #undef CYTHON_USE_ASYNC_SLOTS
  66. #define CYTHON_USE_ASYNC_SLOTS 0
  67. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  68. #define CYTHON_USE_ASYNC_SLOTS 1
  69. #endif
  70. #undef CYTHON_USE_PYLIST_INTERNALS
  71. #define CYTHON_USE_PYLIST_INTERNALS 0
  72. #undef CYTHON_USE_UNICODE_INTERNALS
  73. #define CYTHON_USE_UNICODE_INTERNALS 0
  74. #undef CYTHON_USE_UNICODE_WRITER
  75. #define CYTHON_USE_UNICODE_WRITER 0
  76. #undef CYTHON_USE_PYLONG_INTERNALS
  77. #define CYTHON_USE_PYLONG_INTERNALS 0
  78. #undef CYTHON_AVOID_BORROWED_REFS
  79. #define CYTHON_AVOID_BORROWED_REFS 1
  80. #undef CYTHON_ASSUME_SAFE_MACROS
  81. #define CYTHON_ASSUME_SAFE_MACROS 0
  82. #undef CYTHON_UNPACK_METHODS
  83. #define CYTHON_UNPACK_METHODS 0
  84. #undef CYTHON_FAST_THREAD_STATE
  85. #define CYTHON_FAST_THREAD_STATE 0
  86. #undef CYTHON_FAST_PYCALL
  87. #define CYTHON_FAST_PYCALL 0
  88. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  89. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  90. #undef CYTHON_USE_TP_FINALIZE
  91. #define CYTHON_USE_TP_FINALIZE 0
  92. #elif defined(PYSTON_VERSION)
  93. #define CYTHON_COMPILING_IN_PYPY 0
  94. #define CYTHON_COMPILING_IN_PYSTON 1
  95. #define CYTHON_COMPILING_IN_CPYTHON 0
  96. #ifndef CYTHON_USE_TYPE_SLOTS
  97. #define CYTHON_USE_TYPE_SLOTS 1
  98. #endif
  99. #undef CYTHON_USE_PYTYPE_LOOKUP
  100. #define CYTHON_USE_PYTYPE_LOOKUP 0
  101. #undef CYTHON_USE_ASYNC_SLOTS
  102. #define CYTHON_USE_ASYNC_SLOTS 0
  103. #undef CYTHON_USE_PYLIST_INTERNALS
  104. #define CYTHON_USE_PYLIST_INTERNALS 0
  105. #ifndef CYTHON_USE_UNICODE_INTERNALS
  106. #define CYTHON_USE_UNICODE_INTERNALS 1
  107. #endif
  108. #undef CYTHON_USE_UNICODE_WRITER
  109. #define CYTHON_USE_UNICODE_WRITER 0
  110. #undef CYTHON_USE_PYLONG_INTERNALS
  111. #define CYTHON_USE_PYLONG_INTERNALS 0
  112. #ifndef CYTHON_AVOID_BORROWED_REFS
  113. #define CYTHON_AVOID_BORROWED_REFS 0
  114. #endif
  115. #ifndef CYTHON_ASSUME_SAFE_MACROS
  116. #define CYTHON_ASSUME_SAFE_MACROS 1
  117. #endif
  118. #ifndef CYTHON_UNPACK_METHODS
  119. #define CYTHON_UNPACK_METHODS 1
  120. #endif
  121. #undef CYTHON_FAST_THREAD_STATE
  122. #define CYTHON_FAST_THREAD_STATE 0
  123. #undef CYTHON_FAST_PYCALL
  124. #define CYTHON_FAST_PYCALL 0
  125. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  126. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  127. #undef CYTHON_USE_TP_FINALIZE
  128. #define CYTHON_USE_TP_FINALIZE 0
  129. #else
  130. #define CYTHON_COMPILING_IN_PYPY 0
  131. #define CYTHON_COMPILING_IN_PYSTON 0
  132. #define CYTHON_COMPILING_IN_CPYTHON 1
  133. #ifndef CYTHON_USE_TYPE_SLOTS
  134. #define CYTHON_USE_TYPE_SLOTS 1
  135. #endif
  136. #if PY_VERSION_HEX < 0x02070000
  137. #undef CYTHON_USE_PYTYPE_LOOKUP
  138. #define CYTHON_USE_PYTYPE_LOOKUP 0
  139. #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
  140. #define CYTHON_USE_PYTYPE_LOOKUP 1
  141. #endif
  142. #if PY_MAJOR_VERSION < 3
  143. #undef CYTHON_USE_ASYNC_SLOTS
  144. #define CYTHON_USE_ASYNC_SLOTS 0
  145. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  146. #define CYTHON_USE_ASYNC_SLOTS 1
  147. #endif
  148. #if PY_VERSION_HEX < 0x02070000
  149. #undef CYTHON_USE_PYLONG_INTERNALS
  150. #define CYTHON_USE_PYLONG_INTERNALS 0
  151. #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
  152. #define CYTHON_USE_PYLONG_INTERNALS 1
  153. #endif
  154. #ifndef CYTHON_USE_PYLIST_INTERNALS
  155. #define CYTHON_USE_PYLIST_INTERNALS 1
  156. #endif
  157. #ifndef CYTHON_USE_UNICODE_INTERNALS
  158. #define CYTHON_USE_UNICODE_INTERNALS 1
  159. #endif
  160. #if PY_VERSION_HEX < 0x030300F0
  161. #undef CYTHON_USE_UNICODE_WRITER
  162. #define CYTHON_USE_UNICODE_WRITER 0
  163. #elif !defined(CYTHON_USE_UNICODE_WRITER)
  164. #define CYTHON_USE_UNICODE_WRITER 1
  165. #endif
  166. #ifndef CYTHON_AVOID_BORROWED_REFS
  167. #define CYTHON_AVOID_BORROWED_REFS 0
  168. #endif
  169. #ifndef CYTHON_ASSUME_SAFE_MACROS
  170. #define CYTHON_ASSUME_SAFE_MACROS 1
  171. #endif
  172. #ifndef CYTHON_UNPACK_METHODS
  173. #define CYTHON_UNPACK_METHODS 1
  174. #endif
  175. #ifndef CYTHON_FAST_THREAD_STATE
  176. #define CYTHON_FAST_THREAD_STATE 1
  177. #endif
  178. #ifndef CYTHON_FAST_PYCALL
  179. #define CYTHON_FAST_PYCALL 1
  180. #endif
  181. #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
  182. #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
  183. #endif
  184. #ifndef CYTHON_USE_TP_FINALIZE
  185. #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  186. #endif
  187. #endif
  188. #if !defined(CYTHON_FAST_PYCCALL)
  189. #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
  190. #endif
  191. #if CYTHON_USE_PYLONG_INTERNALS
  192. #include "longintrepr.h"
  193. #undef SHIFT
  194. #undef BASE
  195. #undef MASK
  196. #endif
  197. #ifndef __has_attribute
  198. #define __has_attribute(x) 0
  199. #endif
  200. #ifndef __has_cpp_attribute
  201. #define __has_cpp_attribute(x) 0
  202. #endif
  203. #ifndef CYTHON_RESTRICT
  204. #if defined(__GNUC__)
  205. #define CYTHON_RESTRICT __restrict__
  206. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  207. #define CYTHON_RESTRICT __restrict
  208. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  209. #define CYTHON_RESTRICT restrict
  210. #else
  211. #define CYTHON_RESTRICT
  212. #endif
  213. #endif
  214. #ifndef CYTHON_UNUSED
  215. # if defined(__GNUC__)
  216. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  217. # define CYTHON_UNUSED __attribute__ ((__unused__))
  218. # else
  219. # define CYTHON_UNUSED
  220. # endif
  221. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  222. # define CYTHON_UNUSED __attribute__ ((__unused__))
  223. # else
  224. # define CYTHON_UNUSED
  225. # endif
  226. #endif
  227. #ifndef CYTHON_MAYBE_UNUSED_VAR
  228. # if defined(__cplusplus)
  229. template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
  230. # else
  231. # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
  232. # endif
  233. #endif
  234. #ifndef CYTHON_NCP_UNUSED
  235. # if CYTHON_COMPILING_IN_CPYTHON
  236. # define CYTHON_NCP_UNUSED
  237. # else
  238. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  239. # endif
  240. #endif
  241. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  242. #ifdef _MSC_VER
  243. #ifndef _MSC_STDINT_H_
  244. #if _MSC_VER < 1300
  245. typedef unsigned char uint8_t;
  246. typedef unsigned int uint32_t;
  247. #else
  248. typedef unsigned __int8 uint8_t;
  249. typedef unsigned __int32 uint32_t;
  250. #endif
  251. #endif
  252. #else
  253. #include <stdint.h>
  254. #endif
  255. #ifndef CYTHON_FALLTHROUGH
  256. #if defined(__cplusplus) && __cplusplus >= 201103L
  257. #if __has_cpp_attribute(fallthrough)
  258. #define CYTHON_FALLTHROUGH [[fallthrough]]
  259. #elif __has_cpp_attribute(clang::fallthrough)
  260. #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
  261. #elif __has_cpp_attribute(gnu::fallthrough)
  262. #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
  263. #endif
  264. #endif
  265. #ifndef CYTHON_FALLTHROUGH
  266. #if __has_attribute(fallthrough)
  267. #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
  268. #else
  269. #define CYTHON_FALLTHROUGH
  270. #endif
  271. #endif
  272. #if defined(__clang__ ) && defined(__apple_build_version__)
  273. #if __apple_build_version__ < 7000000
  274. #undef CYTHON_FALLTHROUGH
  275. #define CYTHON_FALLTHROUGH
  276. #endif
  277. #endif
  278. #endif
  279. #ifndef CYTHON_INLINE
  280. #if defined(__clang__)
  281. #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  282. #elif defined(__GNUC__)
  283. #define CYTHON_INLINE __inline__
  284. #elif defined(_MSC_VER)
  285. #define CYTHON_INLINE __inline
  286. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  287. #define CYTHON_INLINE inline
  288. #else
  289. #define CYTHON_INLINE
  290. #endif
  291. #endif
  292. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  293. #define Py_OptimizeFlag 0
  294. #endif
  295. #define __PYX_BUILD_PY_SSIZE_T "n"
  296. #define CYTHON_FORMAT_SSIZE_T "z"
  297. #if PY_MAJOR_VERSION < 3
  298. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  299. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  300. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  301. #define __Pyx_DefaultClassType PyClass_Type
  302. #else
  303. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  304. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  305. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  306. #define __Pyx_DefaultClassType PyType_Type
  307. #endif
  308. #ifndef Py_TPFLAGS_CHECKTYPES
  309. #define Py_TPFLAGS_CHECKTYPES 0
  310. #endif
  311. #ifndef Py_TPFLAGS_HAVE_INDEX
  312. #define Py_TPFLAGS_HAVE_INDEX 0
  313. #endif
  314. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  315. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  316. #endif
  317. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  318. #define Py_TPFLAGS_HAVE_FINALIZE 0
  319. #endif
  320. #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  321. #ifndef METH_FASTCALL
  322. #define METH_FASTCALL 0x80
  323. #endif
  324. typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  325. typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
  326. Py_ssize_t nargs, PyObject *kwnames);
  327. #else
  328. #define __Pyx_PyCFunctionFast _PyCFunctionFast
  329. #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
  330. #endif
  331. #if CYTHON_FAST_PYCCALL
  332. #define __Pyx_PyFastCFunction_Check(func)\
  333. ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
  334. #else
  335. #define __Pyx_PyFastCFunction_Check(func) 0
  336. #endif
  337. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  338. #define PyObject_Malloc(s) PyMem_Malloc(s)
  339. #define PyObject_Free(p) PyMem_Free(p)
  340. #define PyObject_Realloc(p) PyMem_Realloc(p)
  341. #endif
  342. #if CYTHON_COMPILING_IN_PYSTON
  343. #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
  344. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
  345. #else
  346. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  347. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
  348. #endif
  349. #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  350. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  351. #elif PY_VERSION_HEX >= 0x03060000
  352. #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
  353. #elif PY_VERSION_HEX >= 0x03000000
  354. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  355. #else
  356. #define __Pyx_PyThreadState_Current _PyThreadState_Current
  357. #endif
  358. #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
  359. #include "pythread.h"
  360. #define Py_tss_NEEDS_INIT 0
  361. typedef int Py_tss_t;
  362. static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  363. *key = PyThread_create_key();
  364. return 0; // PyThread_create_key reports success always
  365. }
  366. static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  367. Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  368. *key = Py_tss_NEEDS_INIT;
  369. return key;
  370. }
  371. static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  372. PyObject_Free(key);
  373. }
  374. static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  375. return *key != Py_tss_NEEDS_INIT;
  376. }
  377. static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  378. PyThread_delete_key(*key);
  379. *key = Py_tss_NEEDS_INIT;
  380. }
  381. static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  382. return PyThread_set_key_value(*key, value);
  383. }
  384. static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  385. return PyThread_get_key_value(*key);
  386. }
  387. #endif // TSS (Thread Specific Storage) API
  388. #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
  389. #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
  390. #else
  391. #define __Pyx_PyDict_NewPresized(n) PyDict_New()
  392. #endif
  393. #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  394. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  395. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  396. #else
  397. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  398. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  399. #endif
  400. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
  401. #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
  402. #else
  403. #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
  404. #endif
  405. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  406. #define CYTHON_PEP393_ENABLED 1
  407. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  408. 0 : _PyUnicode_Ready((PyObject *)(op)))
  409. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  410. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  411. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
  412. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  413. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  414. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  415. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
  416. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  417. #else
  418. #define CYTHON_PEP393_ENABLED 0
  419. #define PyUnicode_1BYTE_KIND 1
  420. #define PyUnicode_2BYTE_KIND 2
  421. #define PyUnicode_4BYTE_KIND 4
  422. #define __Pyx_PyUnicode_READY(op) (0)
  423. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  424. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  425. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  426. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  427. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  428. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  429. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  430. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
  431. #endif
  432. #if CYTHON_COMPILING_IN_PYPY
  433. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  434. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  435. #else
  436. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  437. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  438. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  439. #endif
  440. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  441. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  442. #endif
  443. #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  444. #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
  445. #endif
  446. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  447. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  448. #endif
  449. #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
  450. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  451. #if PY_MAJOR_VERSION >= 3
  452. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  453. #else
  454. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  455. #endif
  456. #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  457. #define PyObject_ASCII(o) PyObject_Repr(o)
  458. #endif
  459. #if PY_MAJOR_VERSION >= 3
  460. #define PyBaseString_Type PyUnicode_Type
  461. #define PyStringObject PyUnicodeObject
  462. #define PyString_Type PyUnicode_Type
  463. #define PyString_Check PyUnicode_Check
  464. #define PyString_CheckExact PyUnicode_CheckExact
  465. #define PyObject_Unicode PyObject_Str
  466. #endif
  467. #if PY_MAJOR_VERSION >= 3
  468. #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  469. #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
  470. #else
  471. #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  472. #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
  473. #endif
  474. #ifndef PySet_CheckExact
  475. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  476. #endif
  477. #if CYTHON_ASSUME_SAFE_MACROS
  478. #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
  479. #else
  480. #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
  481. #endif
  482. #if PY_MAJOR_VERSION >= 3
  483. #define PyIntObject PyLongObject
  484. #define PyInt_Type PyLong_Type
  485. #define PyInt_Check(op) PyLong_Check(op)
  486. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  487. #define PyInt_FromString PyLong_FromString
  488. #define PyInt_FromUnicode PyLong_FromUnicode
  489. #define PyInt_FromLong PyLong_FromLong
  490. #define PyInt_FromSize_t PyLong_FromSize_t
  491. #define PyInt_FromSsize_t PyLong_FromSsize_t
  492. #define PyInt_AsLong PyLong_AsLong
  493. #define PyInt_AS_LONG PyLong_AS_LONG
  494. #define PyInt_AsSsize_t PyLong_AsSsize_t
  495. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  496. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  497. #define PyNumber_Int PyNumber_Long
  498. #endif
  499. #if PY_MAJOR_VERSION >= 3
  500. #define PyBoolObject PyLongObject
  501. #endif
  502. #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  503. #ifndef PyUnicode_InternFromString
  504. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  505. #endif
  506. #endif
  507. #if PY_VERSION_HEX < 0x030200A4
  508. typedef long Py_hash_t;
  509. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  510. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  511. #else
  512. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  513. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  514. #endif
  515. #if PY_MAJOR_VERSION >= 3
  516. #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
  517. #else
  518. #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
  519. #endif
  520. #if CYTHON_USE_ASYNC_SLOTS
  521. #if PY_VERSION_HEX >= 0x030500B1
  522. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  523. #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  524. #else
  525. #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  526. #endif
  527. #else
  528. #define __Pyx_PyType_AsAsync(obj) NULL
  529. #endif
  530. #ifndef __Pyx_PyAsyncMethodsStruct
  531. typedef struct {
  532. unaryfunc am_await;
  533. unaryfunc am_aiter;
  534. unaryfunc am_anext;
  535. } __Pyx_PyAsyncMethodsStruct;
  536. #endif
  537. #if defined(WIN32) || defined(MS_WINDOWS)
  538. #define _USE_MATH_DEFINES
  539. #endif
  540. #include <math.h>
  541. #ifdef NAN
  542. #define __PYX_NAN() ((float) NAN)
  543. #else
  544. static CYTHON_INLINE float __PYX_NAN() {
  545. float value;
  546. memset(&value, 0xFF, sizeof(value));
  547. return value;
  548. }
  549. #endif
  550. #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
  551. #define __Pyx_truncl trunc
  552. #else
  553. #define __Pyx_truncl truncl
  554. #endif
  555. #define __PYX_ERR(f_index, lineno, Ln_error) \
  556. { \
  557. __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
  558. }
  559. #ifndef __PYX_EXTERN_C
  560. #ifdef __cplusplus
  561. #define __PYX_EXTERN_C extern "C"
  562. #else
  563. #define __PYX_EXTERN_C extern
  564. #endif
  565. #endif
  566. #define __PYX_HAVE__yarl___quoting
  567. #define __PYX_HAVE_API__yarl___quoting
  568. /* Early includes */
  569. #include <stdint.h>
  570. #include <string.h>
  571. #include <stdio.h>
  572. #ifdef _OPENMP
  573. #include <omp.h>
  574. #endif /* _OPENMP */
  575. #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
  576. #define CYTHON_WITHOUT_ASSERTIONS
  577. #endif
  578. typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
  579. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
  580. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  581. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
  582. #define __PYX_DEFAULT_STRING_ENCODING ""
  583. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  584. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  585. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  586. #define __Pyx_long_cast(x) ((long)x)
  587. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  588. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  589. (sizeof(type) > sizeof(Py_ssize_t) &&\
  590. likely(v < (type)PY_SSIZE_T_MAX ||\
  591. v == (type)PY_SSIZE_T_MAX) &&\
  592. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  593. v == (type)PY_SSIZE_T_MIN))) ||\
  594. (sizeof(type) == sizeof(Py_ssize_t) &&\
  595. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  596. v == (type)PY_SSIZE_T_MAX))) )
  597. #if defined (__cplusplus) && __cplusplus >= 201103L
  598. #include <cstdlib>
  599. #define __Pyx_sst_abs(value) std::abs(value)
  600. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  601. #define __Pyx_sst_abs(value) abs(value)
  602. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  603. #define __Pyx_sst_abs(value) labs(value)
  604. #elif defined (_MSC_VER)
  605. #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
  606. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  607. #define __Pyx_sst_abs(value) llabs(value)
  608. #elif defined (__GNUC__)
  609. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  610. #else
  611. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  612. #endif
  613. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
  614. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  615. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  616. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  617. #define __Pyx_PyBytes_FromString PyBytes_FromString
  618. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  619. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  620. #if PY_MAJOR_VERSION < 3
  621. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  622. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  623. #else
  624. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  625. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  626. #endif
  627. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
  628. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
  629. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
  630. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
  631. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
  632. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
  633. #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
  634. #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  635. #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  636. #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
  637. #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
  638. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  639. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  640. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  641. #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
  642. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  643. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
  644. const Py_UNICODE *u_end = u;
  645. while (*u_end++) ;
  646. return (size_t)(u_end - u - 1);
  647. }
  648. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  649. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  650. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  651. #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
  652. #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
  653. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
  654. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  655. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
  656. #define __Pyx_PySequence_Tuple(obj)\
  657. (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
  658. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  659. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  660. #if CYTHON_ASSUME_SAFE_MACROS
  661. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  662. #else
  663. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  664. #endif
  665. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  666. #if PY_MAJOR_VERSION >= 3
  667. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  668. #else
  669. #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
  670. #endif
  671. #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
  672. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  673. static int __Pyx_sys_getdefaultencoding_not_ascii;
  674. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  675. PyObject* sys;
  676. PyObject* default_encoding = NULL;
  677. PyObject* ascii_chars_u = NULL;
  678. PyObject* ascii_chars_b = NULL;
  679. const char* default_encoding_c;
  680. sys = PyImport_ImportModule("sys");
  681. if (!sys) goto bad;
  682. default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
  683. Py_DECREF(sys);
  684. if (!default_encoding) goto bad;
  685. default_encoding_c = PyBytes_AsString(default_encoding);
  686. if (!default_encoding_c) goto bad;
  687. if (strcmp(default_encoding_c, "ascii") == 0) {
  688. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  689. } else {
  690. char ascii_chars[128];
  691. int c;
  692. for (c = 0; c < 128; c++) {
  693. ascii_chars[c] = c;
  694. }
  695. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  696. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  697. if (!ascii_chars_u) goto bad;
  698. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  699. if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  700. PyErr_Format(
  701. PyExc_ValueError,
  702. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  703. default_encoding_c);
  704. goto bad;
  705. }
  706. Py_DECREF(ascii_chars_u);
  707. Py_DECREF(ascii_chars_b);
  708. }
  709. Py_DECREF(default_encoding);
  710. return 0;
  711. bad:
  712. Py_XDECREF(default_encoding);
  713. Py_XDECREF(ascii_chars_u);
  714. Py_XDECREF(ascii_chars_b);
  715. return -1;
  716. }
  717. #endif
  718. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  719. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  720. #else
  721. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  722. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  723. static char* __PYX_DEFAULT_STRING_ENCODING;
  724. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  725. PyObject* sys;
  726. PyObject* default_encoding = NULL;
  727. char* default_encoding_c;
  728. sys = PyImport_ImportModule("sys");
  729. if (!sys) goto bad;
  730. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  731. Py_DECREF(sys);
  732. if (!default_encoding) goto bad;
  733. default_encoding_c = PyBytes_AsString(default_encoding);
  734. if (!default_encoding_c) goto bad;
  735. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
  736. if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
  737. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  738. Py_DECREF(default_encoding);
  739. return 0;
  740. bad:
  741. Py_XDECREF(default_encoding);
  742. return -1;
  743. }
  744. #endif
  745. #endif
  746. /* Test for GCC > 2.95 */
  747. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  748. #define likely(x) __builtin_expect(!!(x), 1)
  749. #define unlikely(x) __builtin_expect(!!(x), 0)
  750. #else /* !__GNUC__ or GCC < 2.95 */
  751. #define likely(x) (x)
  752. #define unlikely(x) (x)
  753. #endif /* __GNUC__ */
  754. static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
  755. static PyObject *__pyx_m = NULL;
  756. static PyObject *__pyx_d;
  757. static PyObject *__pyx_b;
  758. static PyObject *__pyx_cython_runtime = NULL;
  759. static PyObject *__pyx_empty_tuple;
  760. static PyObject *__pyx_empty_bytes;
  761. static PyObject *__pyx_empty_unicode;
  762. static int __pyx_lineno;
  763. static int __pyx_clineno = 0;
  764. static const char * __pyx_cfilenm= __FILE__;
  765. static const char *__pyx_filename;
  766. static const char *__pyx_f[] = {
  767. "yarl/_quoting.pyx",
  768. "stringsource",
  769. "type.pxd",
  770. };
  771. /*--- Type declarations ---*/
  772. struct __pyx_obj_4yarl_8_quoting__Quoter;
  773. struct __pyx_obj_4yarl_8_quoting__Unquoter;
  774. struct __pyx_t_4yarl_8_quoting_Writer;
  775. /* "yarl/_quoting.pyx":76
  776. * # ----------------- writer ---------------------------
  777. *
  778. * cdef struct Writer: # <<<<<<<<<<<<<<
  779. * char *buf
  780. * Py_ssize_t size
  781. */
  782. struct __pyx_t_4yarl_8_quoting_Writer {
  783. char *buf;
  784. Py_ssize_t size;
  785. Py_ssize_t pos;
  786. int changed;
  787. };
  788. /* "yarl/_quoting.pyx":186
  789. *
  790. *
  791. * cdef class _Quoter: # <<<<<<<<<<<<<<
  792. * cdef bint _qs
  793. *
  794. */
  795. struct __pyx_obj_4yarl_8_quoting__Quoter {
  796. PyObject_HEAD
  797. struct __pyx_vtabstruct_4yarl_8_quoting__Quoter *__pyx_vtab;
  798. int _qs;
  799. uint8_t _safe_table[16];
  800. uint8_t _protected_table[16];
  801. };
  802. /* "yarl/_quoting.pyx":301
  803. *
  804. *
  805. * cdef class _Unquoter: # <<<<<<<<<<<<<<
  806. * cdef str _unsafe
  807. * cdef bint _qs
  808. */
  809. struct __pyx_obj_4yarl_8_quoting__Unquoter {
  810. PyObject_HEAD
  811. struct __pyx_vtabstruct_4yarl_8_quoting__Unquoter *__pyx_vtab;
  812. PyObject *_unsafe;
  813. int _qs;
  814. struct __pyx_obj_4yarl_8_quoting__Quoter *_quoter;
  815. struct __pyx_obj_4yarl_8_quoting__Quoter *_qs_quoter;
  816. };
  817. /* "yarl/_quoting.pyx":186
  818. *
  819. *
  820. * cdef class _Quoter: # <<<<<<<<<<<<<<
  821. * cdef bint _qs
  822. *
  823. */
  824. struct __pyx_vtabstruct_4yarl_8_quoting__Quoter {
  825. PyObject *(*_do_quote)(struct __pyx_obj_4yarl_8_quoting__Quoter *, PyObject *, struct __pyx_t_4yarl_8_quoting_Writer *);
  826. int (*_write)(struct __pyx_obj_4yarl_8_quoting__Quoter *, struct __pyx_t_4yarl_8_quoting_Writer *, Py_UCS4);
  827. };
  828. static struct __pyx_vtabstruct_4yarl_8_quoting__Quoter *__pyx_vtabptr_4yarl_8_quoting__Quoter;
  829. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting_7_Quoter__write(struct __pyx_obj_4yarl_8_quoting__Quoter *, struct __pyx_t_4yarl_8_quoting_Writer *, Py_UCS4);
  830. /* "yarl/_quoting.pyx":301
  831. *
  832. *
  833. * cdef class _Unquoter: # <<<<<<<<<<<<<<
  834. * cdef str _unsafe
  835. * cdef bint _qs
  836. */
  837. struct __pyx_vtabstruct_4yarl_8_quoting__Unquoter {
  838. PyObject *(*_do_unquote)(struct __pyx_obj_4yarl_8_quoting__Unquoter *, PyObject *);
  839. };
  840. static struct __pyx_vtabstruct_4yarl_8_quoting__Unquoter *__pyx_vtabptr_4yarl_8_quoting__Unquoter;
  841. /* --- Runtime support code (head) --- */
  842. /* Refnanny.proto */
  843. #ifndef CYTHON_REFNANNY
  844. #define CYTHON_REFNANNY 0
  845. #endif
  846. #if CYTHON_REFNANNY
  847. typedef struct {
  848. void (*INCREF)(void*, PyObject*, int);
  849. void (*DECREF)(void*, PyObject*, int);
  850. void (*GOTREF)(void*, PyObject*, int);
  851. void (*GIVEREF)(void*, PyObject*, int);
  852. void* (*SetupContext)(const char*, int, const char*);
  853. void (*FinishContext)(void**);
  854. } __Pyx_RefNannyAPIStruct;
  855. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  856. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  857. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  858. #ifdef WITH_THREAD
  859. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  860. if (acquire_gil) {\
  861. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  862. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  863. PyGILState_Release(__pyx_gilstate_save);\
  864. } else {\
  865. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  866. }
  867. #else
  868. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  869. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  870. #endif
  871. #define __Pyx_RefNannyFinishContext()\
  872. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  873. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  874. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  875. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  876. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  877. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  878. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  879. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  880. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  881. #else
  882. #define __Pyx_RefNannyDeclarations
  883. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  884. #define __Pyx_RefNannyFinishContext()
  885. #define __Pyx_INCREF(r) Py_INCREF(r)
  886. #define __Pyx_DECREF(r) Py_DECREF(r)
  887. #define __Pyx_GOTREF(r)
  888. #define __Pyx_GIVEREF(r)
  889. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  890. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  891. #define __Pyx_XGOTREF(r)
  892. #define __Pyx_XGIVEREF(r)
  893. #endif
  894. #define __Pyx_XDECREF_SET(r, v) do {\
  895. PyObject *tmp = (PyObject *) r;\
  896. r = v; __Pyx_XDECREF(tmp);\
  897. } while (0)
  898. #define __Pyx_DECREF_SET(r, v) do {\
  899. PyObject *tmp = (PyObject *) r;\
  900. r = v; __Pyx_DECREF(tmp);\
  901. } while (0)
  902. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  903. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  904. /* PyObjectGetAttrStr.proto */
  905. #if CYTHON_USE_TYPE_SLOTS
  906. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
  907. #else
  908. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  909. #endif
  910. /* GetBuiltinName.proto */
  911. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  912. /* PyThreadStateGet.proto */
  913. #if CYTHON_FAST_THREAD_STATE
  914. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  915. #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
  916. #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
  917. #else
  918. #define __Pyx_PyThreadState_declare
  919. #define __Pyx_PyThreadState_assign
  920. #define __Pyx_PyErr_Occurred() PyErr_Occurred()
  921. #endif
  922. /* PyErrFetchRestore.proto */
  923. #if CYTHON_FAST_THREAD_STATE
  924. #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
  925. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  926. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  927. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  928. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  929. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  930. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  931. #if CYTHON_COMPILING_IN_CPYTHON
  932. #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
  933. #else
  934. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  935. #endif
  936. #else
  937. #define __Pyx_PyErr_Clear() PyErr_Clear()
  938. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  939. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  940. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  941. #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
  942. #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
  943. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  944. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  945. #endif
  946. /* WriteUnraisableException.proto */
  947. static void __Pyx_WriteUnraisable(const char *name, int clineno,
  948. int lineno, const char *filename,
  949. int full_traceback, int nogil);
  950. /* RaiseDoubleKeywords.proto */
  951. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
  952. /* ParseKeywords.proto */
  953. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
  954. PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
  955. const char* function_name);
  956. /* RaiseArgTupleInvalid.proto */
  957. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  958. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
  959. /* ArgTypeTest.proto */
  960. #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
  961. ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
  962. __Pyx__ArgTypeTest(obj, type, name, exact))
  963. static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
  964. /* unicode_iter.proto */
  965. static CYTHON_INLINE int __Pyx_init_unicode_iteration(
  966. PyObject* ustring, Py_ssize_t *length, void** data, int *kind);
  967. /* PyObjectCall.proto */
  968. #if CYTHON_COMPILING_IN_CPYTHON
  969. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  970. #else
  971. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  972. #endif
  973. /* RaiseException.proto */
  974. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
  975. /* PyCFunctionFastCall.proto */
  976. #if CYTHON_FAST_PYCCALL
  977. static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
  978. #else
  979. #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
  980. #endif
  981. /* PyFunctionFastCall.proto */
  982. #if CYTHON_FAST_PYCALL
  983. #define __Pyx_PyFunction_FastCall(func, args, nargs)\
  984. __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
  985. #if 1 || PY_VERSION_HEX < 0x030600B1
  986. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
  987. #else
  988. #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
  989. #endif
  990. #endif
  991. /* PyObjectCallMethO.proto */
  992. #if CYTHON_COMPILING_IN_CPYTHON
  993. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
  994. #endif
  995. /* PyObjectCallOneArg.proto */
  996. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
  997. /* GetException.proto */
  998. #if CYTHON_FAST_THREAD_STATE
  999. #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
  1000. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1001. #else
  1002. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
  1003. #endif
  1004. /* SwapException.proto */
  1005. #if CYTHON_FAST_THREAD_STATE
  1006. #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
  1007. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1008. #else
  1009. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
  1010. #endif
  1011. /* SaveResetException.proto */
  1012. #if CYTHON_FAST_THREAD_STATE
  1013. #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
  1014. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1015. #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
  1016. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1017. #else
  1018. #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
  1019. #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
  1020. #endif
  1021. /* ReRaiseException.proto */
  1022. static CYTHON_INLINE void __Pyx_ReraiseException(void) {
  1023. PyObject *type = NULL, *value = NULL, *tb = NULL;
  1024. #if CYTHON_FAST_THREAD_STATE
  1025. PyThreadState *tstate = PyThreadState_GET();
  1026. #if PY_VERSION_HEX >= 0x030700A2
  1027. type = tstate->exc_state.exc_type;
  1028. value = tstate->exc_state.exc_value;
  1029. tb = tstate->exc_state.exc_traceback;
  1030. #else
  1031. type = tstate->exc_type;
  1032. value = tstate->exc_value;
  1033. tb = tstate->exc_traceback;
  1034. #endif
  1035. #else
  1036. PyErr_GetExcInfo(&type, &value, &tb);
  1037. #endif
  1038. if (!type || type == Py_None) {
  1039. #if !CYTHON_FAST_THREAD_STATE
  1040. Py_XDECREF(type);
  1041. Py_XDECREF(value);
  1042. Py_XDECREF(tb);
  1043. #endif
  1044. PyErr_SetString(PyExc_RuntimeError,
  1045. "No active exception to reraise");
  1046. } else {
  1047. #if CYTHON_FAST_THREAD_STATE
  1048. Py_INCREF(type);
  1049. Py_XINCREF(value);
  1050. Py_XINCREF(tb);
  1051. #endif
  1052. PyErr_Restore(type, value, tb);
  1053. }
  1054. }
  1055. /* PyErrExceptionMatches.proto */
  1056. #if CYTHON_FAST_THREAD_STATE
  1057. #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
  1058. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
  1059. #else
  1060. #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
  1061. #endif
  1062. /* GetAttr.proto */
  1063. static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
  1064. /* GetAttr3.proto */
  1065. static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
  1066. /* GetModuleGlobalName.proto */
  1067. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
  1068. /* PyObjectCallNoArg.proto */
  1069. #if CYTHON_COMPILING_IN_CPYTHON
  1070. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
  1071. #else
  1072. #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
  1073. #endif
  1074. /* PyObjectCallMethod1.proto */
  1075. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
  1076. static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg);
  1077. /* ByteArrayAppend.proto */
  1078. static CYTHON_INLINE int __Pyx_PyByteArray_Append(PyObject* bytearray, int value);
  1079. /* ByteArrayAppendObject.proto */
  1080. static CYTHON_INLINE int __Pyx_PyByteArray_AppendObject(PyObject* bytearray, PyObject* value);
  1081. /* PyUnicode_Substring.proto */
  1082. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring(
  1083. PyObject* text, Py_ssize_t start, Py_ssize_t stop);
  1084. /* decode_c_string_utf16.proto */
  1085. static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
  1086. int byteorder = 0;
  1087. return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
  1088. }
  1089. static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
  1090. int byteorder = -1;
  1091. return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
  1092. }
  1093. static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
  1094. int byteorder = 1;
  1095. return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
  1096. }
  1097. /* decode_c_bytes.proto */
  1098. static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
  1099. const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
  1100. const char* encoding, const char* errors,
  1101. PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
  1102. /* decode_bytearray.proto */
  1103. static CYTHON_INLINE PyObject* __Pyx_decode_bytearray(
  1104. PyObject* string, Py_ssize_t start, Py_ssize_t stop,
  1105. const char* encoding, const char* errors,
  1106. PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
  1107. return __Pyx_decode_c_bytes(
  1108. PyByteArray_AS_STRING(string), PyByteArray_GET_SIZE(string),
  1109. start, stop, encoding, errors, decode_func);
  1110. }
  1111. /* PyUnicodeContains.proto */
  1112. static CYTHON_INLINE int __Pyx_PyUnicode_ContainsTF(PyObject* substring, PyObject* text, int eq) {
  1113. int result = PyUnicode_Contains(text, substring);
  1114. return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
  1115. }
  1116. /* ListAppend.proto */
  1117. #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
  1118. static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
  1119. PyListObject* L = (PyListObject*) list;
  1120. Py_ssize_t len = Py_SIZE(list);
  1121. if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
  1122. Py_INCREF(x);
  1123. PyList_SET_ITEM(list, len, x);
  1124. Py_SIZE(list) = len+1;
  1125. return 0;
  1126. }
  1127. return PyList_Append(list, x);
  1128. }
  1129. #else
  1130. #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
  1131. #endif
  1132. /* SliceObject.proto */
  1133. #define __Pyx_PyObject_DelSlice(obj, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound)\
  1134. __Pyx_PyObject_SetSlice(obj, (PyObject*)NULL, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound)
  1135. static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
  1136. PyObject* obj, PyObject* value, Py_ssize_t cstart, Py_ssize_t cstop,
  1137. PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
  1138. int has_cstart, int has_cstop, int wraparound);
  1139. /* IncludeStringH.proto */
  1140. #include <string.h>
  1141. /* BytesEquals.proto */
  1142. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
  1143. /* UnicodeEquals.proto */
  1144. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
  1145. /* UnicodeAsUCS4.proto */
  1146. static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject*);
  1147. /* object_ord.proto */
  1148. #if PY_MAJOR_VERSION >= 3
  1149. #define __Pyx_PyObject_Ord(c)\
  1150. (likely(PyUnicode_Check(c)) ? (long)__Pyx_PyUnicode_AsPy_UCS4(c) : __Pyx__PyObject_Ord(c))
  1151. #else
  1152. #define __Pyx_PyObject_Ord(c) __Pyx__PyObject_Ord(c)
  1153. #endif
  1154. static long __Pyx__PyObject_Ord(PyObject* c);
  1155. /* SliceObject.proto */
  1156. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
  1157. PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
  1158. PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
  1159. int has_cstart, int has_cstop, int wraparound);
  1160. /* Import.proto */
  1161. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
  1162. /* ImportFrom.proto */
  1163. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
  1164. /* GetItemInt.proto */
  1165. #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
  1166. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1167. __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
  1168. (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
  1169. __Pyx_GetItemInt_Generic(o, to_py_func(i))))
  1170. #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
  1171. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1172. __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
  1173. (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
  1174. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  1175. int wraparound, int boundscheck);
  1176. #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
  1177. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1178. __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
  1179. (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
  1180. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  1181. int wraparound, int boundscheck);
  1182. static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
  1183. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
  1184. int is_list, int wraparound, int boundscheck);
  1185. /* HasAttr.proto */
  1186. static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
  1187. /* ExtTypeTest.proto */
  1188. static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
  1189. /* PyObject_GenericGetAttrNoDict.proto */
  1190. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1191. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
  1192. #else
  1193. #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
  1194. #endif
  1195. /* PyObject_GenericGetAttr.proto */
  1196. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1197. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
  1198. #else
  1199. #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
  1200. #endif
  1201. /* SetVTable.proto */
  1202. static int __Pyx_SetVtable(PyObject *dict, void *vtable);
  1203. /* SetupReduce.proto */
  1204. static int __Pyx_setup_reduce(PyObject* type_obj);
  1205. /* CLineInTraceback.proto */
  1206. #ifdef CYTHON_CLINE_IN_TRACEBACK
  1207. #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
  1208. #else
  1209. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
  1210. #endif
  1211. /* CodeObjectCache.proto */
  1212. typedef struct {
  1213. PyCodeObject* code_object;
  1214. int code_line;
  1215. } __Pyx_CodeObjectCacheEntry;
  1216. struct __Pyx_CodeObjectCache {
  1217. int count;
  1218. int max_count;
  1219. __Pyx_CodeObjectCacheEntry* entries;
  1220. };
  1221. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  1222. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  1223. static PyCodeObject *__pyx_find_code_object(int code_line);
  1224. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  1225. /* AddTraceback.proto */
  1226. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  1227. int py_line, const char *filename);
  1228. /* CIntToPy.proto */
  1229. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  1230. /* CIntFromPy.proto */
  1231. static CYTHON_INLINE uint8_t __Pyx_PyInt_As_uint8_t(PyObject *);
  1232. /* CIntFromPy.proto */
  1233. static CYTHON_INLINE uint64_t __Pyx_PyInt_As_uint64_t(PyObject *);
  1234. /* CIntFromPy.proto */
  1235. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  1236. /* CIntFromPy.proto */
  1237. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  1238. /* FastTypeChecks.proto */
  1239. #if CYTHON_COMPILING_IN_CPYTHON
  1240. #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
  1241. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
  1242. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
  1243. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
  1244. #else
  1245. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  1246. #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
  1247. #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
  1248. #endif
  1249. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  1250. /* CheckBinaryVersion.proto */
  1251. static int __Pyx_check_binary_version(void);
  1252. /* PyIdentifierFromString.proto */
  1253. #if !defined(__Pyx_PyIdentifier_FromString)
  1254. #if PY_MAJOR_VERSION < 3
  1255. #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
  1256. #else
  1257. #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
  1258. #endif
  1259. #endif
  1260. /* ModuleImport.proto */
  1261. static PyObject *__Pyx_ImportModule(const char *name);
  1262. /* TypeImport.proto */
  1263. static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
  1264. /* InitStrings.proto */
  1265. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
  1266. static PyObject *__pyx_f_4yarl_8_quoting_7_Quoter__do_quote(struct __pyx_obj_4yarl_8_quoting__Quoter *__pyx_v_self, PyObject *__pyx_v_val, struct __pyx_t_4yarl_8_quoting_Writer *__pyx_v_writer); /* proto*/
  1267. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting_7_Quoter__write(struct __pyx_obj_4yarl_8_quoting__Quoter *__pyx_v_self, struct __pyx_t_4yarl_8_quoting_Writer *__pyx_v_writer, Py_UCS4 __pyx_v_ch); /* proto*/
  1268. static PyObject *__pyx_f_4yarl_8_quoting_9_Unquoter__do_unquote(struct __pyx_obj_4yarl_8_quoting__Unquoter *__pyx_v_self, PyObject *__pyx_v_val); /* proto*/
  1269. /* Module declarations from 'libc.stdint' */
  1270. /* Module declarations from 'libc.string' */
  1271. /* Module declarations from 'libc.stdio' */
  1272. /* Module declarations from '__builtin__' */
  1273. /* Module declarations from 'cpython.type' */
  1274. static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
  1275. /* Module declarations from 'cpython' */
  1276. /* Module declarations from 'cpython.object' */
  1277. /* Module declarations from 'cpython.exc' */
  1278. /* Module declarations from 'cpython.mem' */
  1279. /* Module declarations from 'cpython.unicode' */
  1280. /* Module declarations from 'yarl._quoting' */
  1281. static PyTypeObject *__pyx_ptype_4yarl_8_quoting__Quoter = 0;
  1282. static PyTypeObject *__pyx_ptype_4yarl_8_quoting__Unquoter = 0;
  1283. static PyObject *__pyx_v_4yarl_8_quoting_GEN_DELIMS = 0;
  1284. static PyObject *__pyx_v_4yarl_8_quoting_SUB_DELIMS_WITHOUT_QS = 0;
  1285. static PyObject *__pyx_v_4yarl_8_quoting_SUB_DELIMS = 0;
  1286. static PyObject *__pyx_v_4yarl_8_quoting_RESERVED = 0;
  1287. static PyObject *__pyx_v_4yarl_8_quoting_UNRESERVED = 0;
  1288. static PyObject *__pyx_v_4yarl_8_quoting_ALLOWED = 0;
  1289. static PyObject *__pyx_v_4yarl_8_quoting_QS = 0;
  1290. static char __pyx_v_4yarl_8_quoting_BUFFER[0x2000];
  1291. static uint8_t __pyx_v_4yarl_8_quoting_ALLOWED_TABLE[16];
  1292. static uint8_t __pyx_v_4yarl_8_quoting_ALLOWED_NOTQS_TABLE[16];
  1293. static CYTHON_INLINE Py_UCS4 __pyx_f_4yarl_8_quoting__to_hex(uint8_t); /*proto*/
  1294. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting__from_hex(Py_UCS4); /*proto*/
  1295. static CYTHON_INLINE Py_UCS4 __pyx_f_4yarl_8_quoting__restore_ch(Py_UCS4, Py_UCS4); /*proto*/
  1296. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting_bit_at(uint8_t *, uint64_t); /*proto*/
  1297. static CYTHON_INLINE void __pyx_f_4yarl_8_quoting_set_bit(uint8_t *, uint64_t); /*proto*/
  1298. static CYTHON_INLINE void __pyx_f_4yarl_8_quoting__init_writer(struct __pyx_t_4yarl_8_quoting_Writer *); /*proto*/
  1299. static CYTHON_INLINE void __pyx_f_4yarl_8_quoting__release_writer(struct __pyx_t_4yarl_8_quoting_Writer *); /*proto*/
  1300. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting__write_char(struct __pyx_t_4yarl_8_quoting_Writer *, Py_UCS4, int); /*proto*/
  1301. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting__write_pct(struct __pyx_t_4yarl_8_quoting_Writer *, uint8_t, int); /*proto*/
  1302. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting__write_percent(struct __pyx_t_4yarl_8_quoting_Writer *); /*proto*/
  1303. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting__write_pct_check(struct __pyx_t_4yarl_8_quoting_Writer *, Py_UCS4, Py_UCS4 *); /*proto*/
  1304. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting__write_utf8(struct __pyx_t_4yarl_8_quoting_Writer *, Py_UCS4); /*proto*/
  1305. static PyObject *__pyx_f_4yarl_8_quoting___pyx_unpickle__Quoter__set_state(struct __pyx_obj_4yarl_8_quoting__Quoter *, PyObject *); /*proto*/
  1306. static PyObject *__pyx_f_4yarl_8_quoting___pyx_unpickle__Unquoter__set_state(struct __pyx_obj_4yarl_8_quoting__Unquoter *, PyObject *); /*proto*/
  1307. static int __Pyx_carray_from_py_uint8_t(PyObject *, uint8_t *, Py_ssize_t); /*proto*/
  1308. #define __Pyx_MODULE_NAME "yarl._quoting"
  1309. extern int __pyx_module_is_main_yarl___quoting;
  1310. int __pyx_module_is_main_yarl___quoting = 0;
  1311. /* Implementation of 'yarl._quoting' */
  1312. static PyObject *__pyx_builtin_range;
  1313. static PyObject *__pyx_builtin_chr;
  1314. static PyObject *__pyx_builtin_ValueError;
  1315. static PyObject *__pyx_builtin_TypeError;
  1316. static PyObject *__pyx_builtin_UnicodeDecodeError;
  1317. static PyObject *__pyx_builtin_hex;
  1318. static PyObject *__pyx_builtin_OverflowError;
  1319. static PyObject *__pyx_builtin_enumerate;
  1320. static PyObject *__pyx_builtin_IndexError;
  1321. static const char __pyx_k_[] = "";
  1322. static const char __pyx_k_i[] = "i";
  1323. static const char __pyx_k__6[] = "+=&;";
  1324. static const char __pyx_k__7[] = "%";
  1325. static const char __pyx_k__8[] = "+";
  1326. static const char __pyx_k__9[] = " ";
  1327. static const char __pyx_k_qs[] = "qs";
  1328. static const char __pyx_k__11[] = ":/?#[]@";
  1329. static const char __pyx_k__12[] = "!$'()*,";
  1330. static const char __pyx_k__13[] = "+?=;";
  1331. static const char __pyx_k__14[] = "-._~";
  1332. static const char __pyx_k__15[] = "+&=;";
  1333. static const char __pyx_k_chr[] = "chr";
  1334. static const char __pyx_k_hex[] = "hex";
  1335. static const char __pyx_k_new[] = "__new__";
  1336. static const char __pyx_k_val[] = "val";
  1337. static const char __pyx_k_base[] = "base";
  1338. static const char __pyx_k_dict[] = "__dict__";
  1339. static const char __pyx_k_main[] = "__main__";
  1340. static const char __pyx_k_name[] = "__name__";
  1341. static const char __pyx_k_safe[] = "safe";
  1342. static const char __pyx_k_test[] = "__test__";
  1343. static const char __pyx_k_range[] = "range";
  1344. static const char __pyx_k_upper[] = "upper";
  1345. static const char __pyx_k_append[] = "append";
  1346. static const char __pyx_k_digits[] = "digits";
  1347. static const char __pyx_k_import[] = "__import__";
  1348. static const char __pyx_k_pickle[] = "pickle";
  1349. static const char __pyx_k_reduce[] = "__reduce__";
  1350. static const char __pyx_k_string[] = "string";
  1351. static const char __pyx_k_unsafe[] = "unsafe";
  1352. static const char __pyx_k_update[] = "update";
  1353. static const char __pyx_k_getstate[] = "__getstate__";
  1354. static const char __pyx_k_pyx_type[] = "__pyx_type";
  1355. static const char __pyx_k_setstate[] = "__setstate__";
  1356. static const char __pyx_k_TypeError[] = "TypeError";
  1357. static const char __pyx_k_enumerate[] = "enumerate";
  1358. static const char __pyx_k_protected[] = "protected";
  1359. static const char __pyx_k_pyx_state[] = "__pyx_state";
  1360. static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
  1361. static const char __pyx_k_IndexError[] = "IndexError";
  1362. static const char __pyx_k_ValueError[] = "ValueError";
  1363. static const char __pyx_k_pyx_result[] = "__pyx_result";
  1364. static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
  1365. static const char __pyx_k_PickleError[] = "PickleError";
  1366. static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
  1367. static const char __pyx_k_stringsource[] = "stringsource";
  1368. static const char __pyx_k_OverflowError[] = "OverflowError";
  1369. static const char __pyx_k_ascii_letters[] = "ascii_letters";
  1370. static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
  1371. static const char __pyx_k_yarl__quoting[] = "yarl._quoting";
  1372. static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
  1373. static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
  1374. static const char __pyx_k_UnicodeDecodeError[] = "UnicodeDecodeError";
  1375. static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
  1376. static const char __pyx_k_pyx_unpickle__Quoter[] = "__pyx_unpickle__Quoter";
  1377. static const char __pyx_k_Argument_should_be_str[] = "Argument should be str";
  1378. static const char __pyx_k_pyx_unpickle__Unquoter[] = "__pyx_unpickle__Unquoter";
  1379. static const char __pyx_k_Incompatible_checksums_s_vs_0x27[] = "Incompatible checksums (%s vs 0x276577d = (_qs, _qs_quoter, _quoter, _unsafe))";
  1380. static const char __pyx_k_Incompatible_checksums_s_vs_0x8f[] = "Incompatible checksums (%s vs 0x8f193a6 = (_protected_table, _qs, _safe_table))";
  1381. static const char __pyx_k_Only_safe_symbols_with_ORD_128_a[] = "Only safe symbols with ORD < 128 are allowed";
  1382. static PyObject *__pyx_kp_u_;
  1383. static PyObject *__pyx_kp_u_Argument_should_be_str;
  1384. static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x27;
  1385. static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x8f;
  1386. static PyObject *__pyx_n_s_IndexError;
  1387. static PyObject *__pyx_kp_u_Only_safe_symbols_with_ORD_128_a;
  1388. static PyObject *__pyx_n_s_OverflowError;
  1389. static PyObject *__pyx_n_s_PickleError;
  1390. static PyObject *__pyx_n_s_TypeError;
  1391. static PyObject *__pyx_n_s_UnicodeDecodeError;
  1392. static PyObject *__pyx_n_s_ValueError;
  1393. static PyObject *__pyx_kp_u__11;
  1394. static PyObject *__pyx_kp_u__12;
  1395. static PyObject *__pyx_kp_u__13;
  1396. static PyObject *__pyx_kp_u__14;
  1397. static PyObject *__pyx_kp_u__15;
  1398. static PyObject *__pyx_kp_u__6;
  1399. static PyObject *__pyx_kp_u__7;
  1400. static PyObject *__pyx_kp_u__8;
  1401. static PyObject *__pyx_kp_u__9;
  1402. static PyObject *__pyx_n_s_append;
  1403. static PyObject *__pyx_n_s_ascii_letters;
  1404. static PyObject *__pyx_n_s_base;
  1405. static PyObject *__pyx_n_s_chr;
  1406. static PyObject *__pyx_n_s_cline_in_traceback;
  1407. static PyObject *__pyx_n_s_dict;
  1408. static PyObject *__pyx_n_s_digits;
  1409. static PyObject *__pyx_n_s_enumerate;
  1410. static PyObject *__pyx_n_s_getstate;
  1411. static PyObject *__pyx_n_s_hex;
  1412. static PyObject *__pyx_n_s_i;
  1413. static PyObject *__pyx_n_s_import;
  1414. static PyObject *__pyx_n_s_main;
  1415. static PyObject *__pyx_n_s_name;
  1416. static PyObject *__pyx_n_s_new;
  1417. static PyObject *__pyx_n_s_pickle;
  1418. static PyObject *__pyx_n_s_protected;
  1419. static PyObject *__pyx_n_s_pyx_PickleError;
  1420. static PyObject *__pyx_n_s_pyx_checksum;
  1421. static PyObject *__pyx_n_s_pyx_result;
  1422. static PyObject *__pyx_n_s_pyx_state;
  1423. static PyObject *__pyx_n_s_pyx_type;
  1424. static PyObject *__pyx_n_s_pyx_unpickle__Quoter;
  1425. static PyObject *__pyx_n_s_pyx_unpickle__Unquoter;
  1426. static PyObject *__pyx_n_s_pyx_vtable;
  1427. static PyObject *__pyx_n_s_qs;
  1428. static PyObject *__pyx_n_s_range;
  1429. static PyObject *__pyx_n_s_reduce;
  1430. static PyObject *__pyx_n_s_reduce_cython;
  1431. static PyObject *__pyx_n_s_reduce_ex;
  1432. static PyObject *__pyx_n_s_safe;
  1433. static PyObject *__pyx_n_s_setstate;
  1434. static PyObject *__pyx_n_s_setstate_cython;
  1435. static PyObject *__pyx_n_s_string;
  1436. static PyObject *__pyx_kp_s_stringsource;
  1437. static PyObject *__pyx_n_s_test;
  1438. static PyObject *__pyx_n_s_unsafe;
  1439. static PyObject *__pyx_n_s_update;
  1440. static PyObject *__pyx_n_s_upper;
  1441. static PyObject *__pyx_n_s_val;
  1442. static PyObject *__pyx_n_s_yarl__quoting;
  1443. static int __pyx_pf_4yarl_8_quoting_7_Quoter___init__(struct __pyx_obj_4yarl_8_quoting__Quoter *__pyx_v_self, PyObject *__pyx_v_safe, PyObject *__pyx_v_protected, int __pyx_v_qs); /* proto */
  1444. static PyObject *__pyx_pf_4yarl_8_quoting_7_Quoter_2__call__(struct __pyx_obj_4yarl_8_quoting__Quoter *__pyx_v_self, PyObject *__pyx_v_val); /* proto */
  1445. static PyObject *__pyx_pf_4yarl_8_quoting_7_Quoter_4__reduce_cython__(struct __pyx_obj_4yarl_8_quoting__Quoter *__pyx_v_self); /* proto */
  1446. static PyObject *__pyx_pf_4yarl_8_quoting_7_Quoter_6__setstate_cython__(struct __pyx_obj_4yarl_8_quoting__Quoter *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
  1447. static int __pyx_pf_4yarl_8_quoting_9_Unquoter___init__(struct __pyx_obj_4yarl_8_quoting__Unquoter *__pyx_v_self, PyObject *__pyx_v_unsafe, PyObject *__pyx_v_qs); /* proto */
  1448. static PyObject *__pyx_pf_4yarl_8_quoting_9_Unquoter_2__call__(struct __pyx_obj_4yarl_8_quoting__Unquoter *__pyx_v_self, PyObject *__pyx_v_val); /* proto */
  1449. static PyObject *__pyx_pf_4yarl_8_quoting_9_Unquoter_4__reduce_cython__(struct __pyx_obj_4yarl_8_quoting__Unquoter *__pyx_v_self); /* proto */
  1450. static PyObject *__pyx_pf_4yarl_8_quoting_9_Unquoter_6__setstate_cython__(struct __pyx_obj_4yarl_8_quoting__Unquoter *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
  1451. static PyObject *__pyx_pf_4yarl_8_quoting___pyx_unpickle__Quoter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
  1452. static PyObject *__pyx_pf_4yarl_8_quoting_2__pyx_unpickle__Unquoter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
  1453. static PyObject *__pyx_tp_new_4yarl_8_quoting__Quoter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1454. static PyObject *__pyx_tp_new_4yarl_8_quoting__Unquoter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1455. static PyObject *__pyx_int_2;
  1456. static PyObject *__pyx_int_16;
  1457. static PyObject *__pyx_int_41310077;
  1458. static PyObject *__pyx_int_150049702;
  1459. static PyObject *__pyx_tuple__2;
  1460. static PyObject *__pyx_tuple__3;
  1461. static PyObject *__pyx_tuple__4;
  1462. static PyObject *__pyx_tuple__5;
  1463. static PyObject *__pyx_slice__10;
  1464. static PyObject *__pyx_tuple__16;
  1465. static PyObject *__pyx_tuple__18;
  1466. static PyObject *__pyx_codeobj__17;
  1467. static PyObject *__pyx_codeobj__19;
  1468. /* Late includes */
  1469. /* "yarl/_quoting.pyx":24
  1470. *
  1471. *
  1472. * cdef inline Py_UCS4 _to_hex(uint8_t v): # <<<<<<<<<<<<<<
  1473. * if v < 10:
  1474. * return <Py_UCS4>(v+0x30) # ord('0') == 0x30
  1475. */
  1476. static CYTHON_INLINE Py_UCS4 __pyx_f_4yarl_8_quoting__to_hex(uint8_t __pyx_v_v) {
  1477. Py_UCS4 __pyx_r;
  1478. __Pyx_RefNannyDeclarations
  1479. int __pyx_t_1;
  1480. __Pyx_RefNannySetupContext("_to_hex", 0);
  1481. /* "yarl/_quoting.pyx":25
  1482. *
  1483. * cdef inline Py_UCS4 _to_hex(uint8_t v):
  1484. * if v < 10: # <<<<<<<<<<<<<<
  1485. * return <Py_UCS4>(v+0x30) # ord('0') == 0x30
  1486. * else:
  1487. */
  1488. __pyx_t_1 = ((__pyx_v_v < 10) != 0);
  1489. if (__pyx_t_1) {
  1490. /* "yarl/_quoting.pyx":26
  1491. * cdef inline Py_UCS4 _to_hex(uint8_t v):
  1492. * if v < 10:
  1493. * return <Py_UCS4>(v+0x30) # ord('0') == 0x30 # <<<<<<<<<<<<<<
  1494. * else:
  1495. * return <Py_UCS4>(v+0x41-10) # ord('A') == 0x41
  1496. */
  1497. __pyx_r = ((Py_UCS4)(__pyx_v_v + 0x30));
  1498. goto __pyx_L0;
  1499. /* "yarl/_quoting.pyx":25
  1500. *
  1501. * cdef inline Py_UCS4 _to_hex(uint8_t v):
  1502. * if v < 10: # <<<<<<<<<<<<<<
  1503. * return <Py_UCS4>(v+0x30) # ord('0') == 0x30
  1504. * else:
  1505. */
  1506. }
  1507. /* "yarl/_quoting.pyx":28
  1508. * return <Py_UCS4>(v+0x30) # ord('0') == 0x30
  1509. * else:
  1510. * return <Py_UCS4>(v+0x41-10) # ord('A') == 0x41 # <<<<<<<<<<<<<<
  1511. *
  1512. *
  1513. */
  1514. /*else*/ {
  1515. __pyx_r = ((Py_UCS4)((__pyx_v_v + 0x41) - 10));
  1516. goto __pyx_L0;
  1517. }
  1518. /* "yarl/_quoting.pyx":24
  1519. *
  1520. *
  1521. * cdef inline Py_UCS4 _to_hex(uint8_t v): # <<<<<<<<<<<<<<
  1522. * if v < 10:
  1523. * return <Py_UCS4>(v+0x30) # ord('0') == 0x30
  1524. */
  1525. /* function exit code */
  1526. __pyx_L0:;
  1527. __Pyx_RefNannyFinishContext();
  1528. return __pyx_r;
  1529. }
  1530. /* "yarl/_quoting.pyx":31
  1531. *
  1532. *
  1533. * cdef inline int _from_hex(Py_UCS4 v): # <<<<<<<<<<<<<<
  1534. * if '0' <= v <= '9':
  1535. * return <int>(v) - 0x30 # ord('0') == 0x30
  1536. */
  1537. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting__from_hex(Py_UCS4 __pyx_v_v) {
  1538. int __pyx_r;
  1539. __Pyx_RefNannyDeclarations
  1540. int __pyx_t_1;
  1541. int __pyx_t_2;
  1542. __Pyx_RefNannySetupContext("_from_hex", 0);
  1543. /* "yarl/_quoting.pyx":32
  1544. *
  1545. * cdef inline int _from_hex(Py_UCS4 v):
  1546. * if '0' <= v <= '9': # <<<<<<<<<<<<<<
  1547. * return <int>(v) - 0x30 # ord('0') == 0x30
  1548. * elif 'A' <= v <= 'F':
  1549. */
  1550. __pyx_t_1 = (48 <= __pyx_v_v);
  1551. if (__pyx_t_1) {
  1552. __pyx_t_1 = (__pyx_v_v <= 57);
  1553. }
  1554. __pyx_t_2 = (__pyx_t_1 != 0);
  1555. if (__pyx_t_2) {
  1556. /* "yarl/_quoting.pyx":33
  1557. * cdef inline int _from_hex(Py_UCS4 v):
  1558. * if '0' <= v <= '9':
  1559. * return <int>(v) - 0x30 # ord('0') == 0x30 # <<<<<<<<<<<<<<
  1560. * elif 'A' <= v <= 'F':
  1561. * return <int>(v) - 0x41 + 10 # ord('A') == 0x41
  1562. */
  1563. __pyx_r = (((int)__pyx_v_v) - 0x30);
  1564. goto __pyx_L0;
  1565. /* "yarl/_quoting.pyx":32
  1566. *
  1567. * cdef inline int _from_hex(Py_UCS4 v):
  1568. * if '0' <= v <= '9': # <<<<<<<<<<<<<<
  1569. * return <int>(v) - 0x30 # ord('0') == 0x30
  1570. * elif 'A' <= v <= 'F':
  1571. */
  1572. }
  1573. /* "yarl/_quoting.pyx":34
  1574. * if '0' <= v <= '9':
  1575. * return <int>(v) - 0x30 # ord('0') == 0x30
  1576. * elif 'A' <= v <= 'F': # <<<<<<<<<<<<<<
  1577. * return <int>(v) - 0x41 + 10 # ord('A') == 0x41
  1578. * elif 'a' <= v <= 'f':
  1579. */
  1580. __pyx_t_2 = (65 <= __pyx_v_v);
  1581. if (__pyx_t_2) {
  1582. __pyx_t_2 = (__pyx_v_v <= 70);
  1583. }
  1584. __pyx_t_1 = (__pyx_t_2 != 0);
  1585. if (__pyx_t_1) {
  1586. /* "yarl/_quoting.pyx":35
  1587. * return <int>(v) - 0x30 # ord('0') == 0x30
  1588. * elif 'A' <= v <= 'F':
  1589. * return <int>(v) - 0x41 + 10 # ord('A') == 0x41 # <<<<<<<<<<<<<<
  1590. * elif 'a' <= v <= 'f':
  1591. * return <int>(v) - 0x61 + 10 # ord('a') == 0x61
  1592. */
  1593. __pyx_r = ((((int)__pyx_v_v) - 0x41) + 10);
  1594. goto __pyx_L0;
  1595. /* "yarl/_quoting.pyx":34
  1596. * if '0' <= v <= '9':
  1597. * return <int>(v) - 0x30 # ord('0') == 0x30
  1598. * elif 'A' <= v <= 'F': # <<<<<<<<<<<<<<
  1599. * return <int>(v) - 0x41 + 10 # ord('A') == 0x41
  1600. * elif 'a' <= v <= 'f':
  1601. */
  1602. }
  1603. /* "yarl/_quoting.pyx":36
  1604. * elif 'A' <= v <= 'F':
  1605. * return <int>(v) - 0x41 + 10 # ord('A') == 0x41
  1606. * elif 'a' <= v <= 'f': # <<<<<<<<<<<<<<
  1607. * return <int>(v) - 0x61 + 10 # ord('a') == 0x61
  1608. * else:
  1609. */
  1610. __pyx_t_1 = (97 <= __pyx_v_v);
  1611. if (__pyx_t_1) {
  1612. __pyx_t_1 = (__pyx_v_v <= 0x66);
  1613. }
  1614. __pyx_t_2 = (__pyx_t_1 != 0);
  1615. if (__pyx_t_2) {
  1616. /* "yarl/_quoting.pyx":37
  1617. * return <int>(v) - 0x41 + 10 # ord('A') == 0x41
  1618. * elif 'a' <= v <= 'f':
  1619. * return <int>(v) - 0x61 + 10 # ord('a') == 0x61 # <<<<<<<<<<<<<<
  1620. * else:
  1621. * return -1
  1622. */
  1623. __pyx_r = ((((int)__pyx_v_v) - 0x61) + 10);
  1624. goto __pyx_L0;
  1625. /* "yarl/_quoting.pyx":36
  1626. * elif 'A' <= v <= 'F':
  1627. * return <int>(v) - 0x41 + 10 # ord('A') == 0x41
  1628. * elif 'a' <= v <= 'f': # <<<<<<<<<<<<<<
  1629. * return <int>(v) - 0x61 + 10 # ord('a') == 0x61
  1630. * else:
  1631. */
  1632. }
  1633. /* "yarl/_quoting.pyx":39
  1634. * return <int>(v) - 0x61 + 10 # ord('a') == 0x61
  1635. * else:
  1636. * return -1 # <<<<<<<<<<<<<<
  1637. *
  1638. *
  1639. */
  1640. /*else*/ {
  1641. __pyx_r = -1;
  1642. goto __pyx_L0;
  1643. }
  1644. /* "yarl/_quoting.pyx":31
  1645. *
  1646. *
  1647. * cdef inline int _from_hex(Py_UCS4 v): # <<<<<<<<<<<<<<
  1648. * if '0' <= v <= '9':
  1649. * return <int>(v) - 0x30 # ord('0') == 0x30
  1650. */
  1651. /* function exit code */
  1652. __pyx_L0:;
  1653. __Pyx_RefNannyFinishContext();
  1654. return __pyx_r;
  1655. }
  1656. /* "yarl/_quoting.pyx":42
  1657. *
  1658. *
  1659. * cdef inline Py_UCS4 _restore_ch(Py_UCS4 d1, Py_UCS4 d2): # <<<<<<<<<<<<<<
  1660. * cdef int digit1 = _from_hex(d1)
  1661. * if digit1 < 0:
  1662. */
  1663. static CYTHON_INLINE Py_UCS4 __pyx_f_4yarl_8_quoting__restore_ch(Py_UCS4 __pyx_v_d1, Py_UCS4 __pyx_v_d2) {
  1664. int __pyx_v_digit1;
  1665. int __pyx_v_digit2;
  1666. Py_UCS4 __pyx_r;
  1667. __Pyx_RefNannyDeclarations
  1668. int __pyx_t_1;
  1669. __Pyx_RefNannySetupContext("_restore_ch", 0);
  1670. /* "yarl/_quoting.pyx":43
  1671. *
  1672. * cdef inline Py_UCS4 _restore_ch(Py_UCS4 d1, Py_UCS4 d2):
  1673. * cdef int digit1 = _from_hex(d1) # <<<<<<<<<<<<<<
  1674. * if digit1 < 0:
  1675. * return <Py_UCS4>-1
  1676. */
  1677. __pyx_v_digit1 = __pyx_f_4yarl_8_quoting__from_hex(__pyx_v_d1);
  1678. /* "yarl/_quoting.pyx":44
  1679. * cdef inline Py_UCS4 _restore_ch(Py_UCS4 d1, Py_UCS4 d2):
  1680. * cdef int digit1 = _from_hex(d1)
  1681. * if digit1 < 0: # <<<<<<<<<<<<<<
  1682. * return <Py_UCS4>-1
  1683. * cdef int digit2 = _from_hex(d2)
  1684. */
  1685. __pyx_t_1 = ((__pyx_v_digit1 < 0) != 0);
  1686. if (__pyx_t_1) {
  1687. /* "yarl/_quoting.pyx":45
  1688. * cdef int digit1 = _from_hex(d1)
  1689. * if digit1 < 0:
  1690. * return <Py_UCS4>-1 # <<<<<<<<<<<<<<
  1691. * cdef int digit2 = _from_hex(d2)
  1692. * if digit2 < 0:
  1693. */
  1694. __pyx_r = ((Py_UCS4)-1L);
  1695. goto __pyx_L0;
  1696. /* "yarl/_quoting.pyx":44
  1697. * cdef inline Py_UCS4 _restore_ch(Py_UCS4 d1, Py_UCS4 d2):
  1698. * cdef int digit1 = _from_hex(d1)
  1699. * if digit1 < 0: # <<<<<<<<<<<<<<
  1700. * return <Py_UCS4>-1
  1701. * cdef int digit2 = _from_hex(d2)
  1702. */
  1703. }
  1704. /* "yarl/_quoting.pyx":46
  1705. * if digit1 < 0:
  1706. * return <Py_UCS4>-1
  1707. * cdef int digit2 = _from_hex(d2) # <<<<<<<<<<<<<<
  1708. * if digit2 < 0:
  1709. * return <Py_UCS4>-1
  1710. */
  1711. __pyx_v_digit2 = __pyx_f_4yarl_8_quoting__from_hex(__pyx_v_d2);
  1712. /* "yarl/_quoting.pyx":47
  1713. * return <Py_UCS4>-1
  1714. * cdef int digit2 = _from_hex(d2)
  1715. * if digit2 < 0: # <<<<<<<<<<<<<<
  1716. * return <Py_UCS4>-1
  1717. * return <Py_UCS4>(digit1 << 4 | digit2)
  1718. */
  1719. __pyx_t_1 = ((__pyx_v_digit2 < 0) != 0);
  1720. if (__pyx_t_1) {
  1721. /* "yarl/_quoting.pyx":48
  1722. * cdef int digit2 = _from_hex(d2)
  1723. * if digit2 < 0:
  1724. * return <Py_UCS4>-1 # <<<<<<<<<<<<<<
  1725. * return <Py_UCS4>(digit1 << 4 | digit2)
  1726. *
  1727. */
  1728. __pyx_r = ((Py_UCS4)-1L);
  1729. goto __pyx_L0;
  1730. /* "yarl/_quoting.pyx":47
  1731. * return <Py_UCS4>-1
  1732. * cdef int digit2 = _from_hex(d2)
  1733. * if digit2 < 0: # <<<<<<<<<<<<<<
  1734. * return <Py_UCS4>-1
  1735. * return <Py_UCS4>(digit1 << 4 | digit2)
  1736. */
  1737. }
  1738. /* "yarl/_quoting.pyx":49
  1739. * if digit2 < 0:
  1740. * return <Py_UCS4>-1
  1741. * return <Py_UCS4>(digit1 << 4 | digit2) # <<<<<<<<<<<<<<
  1742. *
  1743. *
  1744. */
  1745. __pyx_r = ((Py_UCS4)((__pyx_v_digit1 << 4) | __pyx_v_digit2));
  1746. goto __pyx_L0;
  1747. /* "yarl/_quoting.pyx":42
  1748. *
  1749. *
  1750. * cdef inline Py_UCS4 _restore_ch(Py_UCS4 d1, Py_UCS4 d2): # <<<<<<<<<<<<<<
  1751. * cdef int digit1 = _from_hex(d1)
  1752. * if digit1 < 0:
  1753. */
  1754. /* function exit code */
  1755. __pyx_L0:;
  1756. __Pyx_RefNannyFinishContext();
  1757. return __pyx_r;
  1758. }
  1759. /* "yarl/_quoting.pyx":56
  1760. *
  1761. *
  1762. * cdef inline bint bit_at(uint8_t array[], uint64_t ch): # <<<<<<<<<<<<<<
  1763. * return array[ch >> 3] & (1 << (ch & 7))
  1764. *
  1765. */
  1766. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting_bit_at(uint8_t *__pyx_v_array, uint64_t __pyx_v_ch) {
  1767. int __pyx_r;
  1768. __Pyx_RefNannyDeclarations
  1769. __Pyx_RefNannySetupContext("bit_at", 0);
  1770. /* "yarl/_quoting.pyx":57
  1771. *
  1772. * cdef inline bint bit_at(uint8_t array[], uint64_t ch):
  1773. * return array[ch >> 3] & (1 << (ch & 7)) # <<<<<<<<<<<<<<
  1774. *
  1775. *
  1776. */
  1777. __pyx_r = ((__pyx_v_array[(__pyx_v_ch >> 3)]) & (1 << (__pyx_v_ch & 7)));
  1778. goto __pyx_L0;
  1779. /* "yarl/_quoting.pyx":56
  1780. *
  1781. *
  1782. * cdef inline bint bit_at(uint8_t array[], uint64_t ch): # <<<<<<<<<<<<<<
  1783. * return array[ch >> 3] & (1 << (ch & 7))
  1784. *
  1785. */
  1786. /* function exit code */
  1787. __pyx_L0:;
  1788. __Pyx_RefNannyFinishContext();
  1789. return __pyx_r;
  1790. }
  1791. /* "yarl/_quoting.pyx":60
  1792. *
  1793. *
  1794. * cdef inline void set_bit(uint8_t array[], uint64_t ch): # <<<<<<<<<<<<<<
  1795. * array[ch >> 3] |= (1 << (ch & 7))
  1796. *
  1797. */
  1798. static CYTHON_INLINE void __pyx_f_4yarl_8_quoting_set_bit(uint8_t *__pyx_v_array, uint64_t __pyx_v_ch) {
  1799. __Pyx_RefNannyDeclarations
  1800. uint64_t __pyx_t_1;
  1801. __Pyx_RefNannySetupContext("set_bit", 0);
  1802. /* "yarl/_quoting.pyx":61
  1803. *
  1804. * cdef inline void set_bit(uint8_t array[], uint64_t ch):
  1805. * array[ch >> 3] |= (1 << (ch & 7)) # <<<<<<<<<<<<<<
  1806. *
  1807. *
  1808. */
  1809. __pyx_t_1 = (__pyx_v_ch >> 3);
  1810. (__pyx_v_array[__pyx_t_1]) = ((__pyx_v_array[__pyx_t_1]) | (1 << (__pyx_v_ch & 7)));
  1811. /* "yarl/_quoting.pyx":60
  1812. *
  1813. *
  1814. * cdef inline void set_bit(uint8_t array[], uint64_t ch): # <<<<<<<<<<<<<<
  1815. * array[ch >> 3] |= (1 << (ch & 7))
  1816. *
  1817. */
  1818. /* function exit code */
  1819. __Pyx_RefNannyFinishContext();
  1820. }
  1821. /* "yarl/_quoting.pyx":83
  1822. *
  1823. *
  1824. * cdef inline void _init_writer(Writer* writer): # <<<<<<<<<<<<<<
  1825. * writer.buf = &BUFFER[0]
  1826. * writer.size = BUF_SIZE
  1827. */
  1828. static CYTHON_INLINE void __pyx_f_4yarl_8_quoting__init_writer(struct __pyx_t_4yarl_8_quoting_Writer *__pyx_v_writer) {
  1829. __Pyx_RefNannyDeclarations
  1830. __Pyx_RefNannySetupContext("_init_writer", 0);
  1831. /* "yarl/_quoting.pyx":84
  1832. *
  1833. * cdef inline void _init_writer(Writer* writer):
  1834. * writer.buf = &BUFFER[0] # <<<<<<<<<<<<<<
  1835. * writer.size = BUF_SIZE
  1836. * writer.pos = 0
  1837. */
  1838. __pyx_v_writer->buf = (&(__pyx_v_4yarl_8_quoting_BUFFER[0]));
  1839. /* "yarl/_quoting.pyx":85
  1840. * cdef inline void _init_writer(Writer* writer):
  1841. * writer.buf = &BUFFER[0]
  1842. * writer.size = BUF_SIZE # <<<<<<<<<<<<<<
  1843. * writer.pos = 0
  1844. * writer.changed = 0
  1845. */
  1846. __pyx_v_writer->size = 0x2000;
  1847. /* "yarl/_quoting.pyx":86
  1848. * writer.buf = &BUFFER[0]
  1849. * writer.size = BUF_SIZE
  1850. * writer.pos = 0 # <<<<<<<<<<<<<<
  1851. * writer.changed = 0
  1852. *
  1853. */
  1854. __pyx_v_writer->pos = 0;
  1855. /* "yarl/_quoting.pyx":87
  1856. * writer.size = BUF_SIZE
  1857. * writer.pos = 0
  1858. * writer.changed = 0 # <<<<<<<<<<<<<<
  1859. *
  1860. *
  1861. */
  1862. __pyx_v_writer->changed = 0;
  1863. /* "yarl/_quoting.pyx":83
  1864. *
  1865. *
  1866. * cdef inline void _init_writer(Writer* writer): # <<<<<<<<<<<<<<
  1867. * writer.buf = &BUFFER[0]
  1868. * writer.size = BUF_SIZE
  1869. */
  1870. /* function exit code */
  1871. __Pyx_RefNannyFinishContext();
  1872. }
  1873. /* "yarl/_quoting.pyx":90
  1874. *
  1875. *
  1876. * cdef inline void _release_writer(Writer* writer): # <<<<<<<<<<<<<<
  1877. * if writer.buf != BUFFER:
  1878. * PyMem_Free(writer.buf)
  1879. */
  1880. static CYTHON_INLINE void __pyx_f_4yarl_8_quoting__release_writer(struct __pyx_t_4yarl_8_quoting_Writer *__pyx_v_writer) {
  1881. __Pyx_RefNannyDeclarations
  1882. int __pyx_t_1;
  1883. __Pyx_RefNannySetupContext("_release_writer", 0);
  1884. /* "yarl/_quoting.pyx":91
  1885. *
  1886. * cdef inline void _release_writer(Writer* writer):
  1887. * if writer.buf != BUFFER: # <<<<<<<<<<<<<<
  1888. * PyMem_Free(writer.buf)
  1889. *
  1890. */
  1891. __pyx_t_1 = ((__pyx_v_writer->buf != __pyx_v_4yarl_8_quoting_BUFFER) != 0);
  1892. if (__pyx_t_1) {
  1893. /* "yarl/_quoting.pyx":92
  1894. * cdef inline void _release_writer(Writer* writer):
  1895. * if writer.buf != BUFFER:
  1896. * PyMem_Free(writer.buf) # <<<<<<<<<<<<<<
  1897. *
  1898. *
  1899. */
  1900. PyMem_Free(__pyx_v_writer->buf);
  1901. /* "yarl/_quoting.pyx":91
  1902. *
  1903. * cdef inline void _release_writer(Writer* writer):
  1904. * if writer.buf != BUFFER: # <<<<<<<<<<<<<<
  1905. * PyMem_Free(writer.buf)
  1906. *
  1907. */
  1908. }
  1909. /* "yarl/_quoting.pyx":90
  1910. *
  1911. *
  1912. * cdef inline void _release_writer(Writer* writer): # <<<<<<<<<<<<<<
  1913. * if writer.buf != BUFFER:
  1914. * PyMem_Free(writer.buf)
  1915. */
  1916. /* function exit code */
  1917. __Pyx_RefNannyFinishContext();
  1918. }
  1919. /* "yarl/_quoting.pyx":95
  1920. *
  1921. *
  1922. * cdef inline int _write_char(Writer* writer, Py_UCS4 ch, bint changed): # <<<<<<<<<<<<<<
  1923. * cdef char * buf
  1924. * cdef Py_ssize_t size
  1925. */
  1926. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting__write_char(struct __pyx_t_4yarl_8_quoting_Writer *__pyx_v_writer, Py_UCS4 __pyx_v_ch, int __pyx_v_changed) {
  1927. char *__pyx_v_buf;
  1928. Py_ssize_t __pyx_v_size;
  1929. int __pyx_r;
  1930. __Pyx_RefNannyDeclarations
  1931. int __pyx_t_1;
  1932. PyObject *__pyx_t_2;
  1933. __Pyx_RefNannySetupContext("_write_char", 0);
  1934. /* "yarl/_quoting.pyx":99
  1935. * cdef Py_ssize_t size
  1936. *
  1937. * if writer.pos == writer.size: # <<<<<<<<<<<<<<
  1938. * # reallocate
  1939. * size = writer.size + BUF_SIZE
  1940. */
  1941. __pyx_t_1 = ((__pyx_v_writer->pos == __pyx_v_writer->size) != 0);
  1942. if (__pyx_t_1) {
  1943. /* "yarl/_quoting.pyx":101
  1944. * if writer.pos == writer.size:
  1945. * # reallocate
  1946. * size = writer.size + BUF_SIZE # <<<<<<<<<<<<<<
  1947. * if writer.buf == BUFFER:
  1948. * buf = <char*>PyMem_Malloc(size)
  1949. */
  1950. __pyx_v_size = (__pyx_v_writer->size + 0x2000);
  1951. /* "yarl/_quoting.pyx":102
  1952. * # reallocate
  1953. * size = writer.size + BUF_SIZE
  1954. * if writer.buf == BUFFER: # <<<<<<<<<<<<<<
  1955. * buf = <char*>PyMem_Malloc(size)
  1956. * if buf == NULL:
  1957. */
  1958. __pyx_t_1 = ((__pyx_v_writer->buf == __pyx_v_4yarl_8_quoting_BUFFER) != 0);
  1959. if (__pyx_t_1) {
  1960. /* "yarl/_quoting.pyx":103
  1961. * size = writer.size + BUF_SIZE
  1962. * if writer.buf == BUFFER:
  1963. * buf = <char*>PyMem_Malloc(size) # <<<<<<<<<<<<<<
  1964. * if buf == NULL:
  1965. * PyErr_NoMemory()
  1966. */
  1967. __pyx_v_buf = ((char *)PyMem_Malloc(__pyx_v_size));
  1968. /* "yarl/_quoting.pyx":104
  1969. * if writer.buf == BUFFER:
  1970. * buf = <char*>PyMem_Malloc(size)
  1971. * if buf == NULL: # <<<<<<<<<<<<<<
  1972. * PyErr_NoMemory()
  1973. * return -1
  1974. */
  1975. __pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
  1976. if (__pyx_t_1) {
  1977. /* "yarl/_quoting.pyx":105
  1978. * buf = <char*>PyMem_Malloc(size)
  1979. * if buf == NULL:
  1980. * PyErr_NoMemory() # <<<<<<<<<<<<<<
  1981. * return -1
  1982. * memcpy(buf, writer.buf, writer.size)
  1983. */
  1984. __pyx_t_2 = PyErr_NoMemory(); if (unlikely(__pyx_t_2 == ((PyObject *)NULL))) __PYX_ERR(0, 105, __pyx_L1_error)
  1985. /* "yarl/_quoting.pyx":106
  1986. * if buf == NULL:
  1987. * PyErr_NoMemory()
  1988. * return -1 # <<<<<<<<<<<<<<
  1989. * memcpy(buf, writer.buf, writer.size)
  1990. * else:
  1991. */
  1992. __pyx_r = -1;
  1993. goto __pyx_L0;
  1994. /* "yarl/_quoting.pyx":104
  1995. * if writer.buf == BUFFER:
  1996. * buf = <char*>PyMem_Malloc(size)
  1997. * if buf == NULL: # <<<<<<<<<<<<<<
  1998. * PyErr_NoMemory()
  1999. * return -1
  2000. */
  2001. }
  2002. /* "yarl/_quoting.pyx":107
  2003. * PyErr_NoMemory()
  2004. * return -1
  2005. * memcpy(buf, writer.buf, writer.size) # <<<<<<<<<<<<<<
  2006. * else:
  2007. * buf = <char*>PyMem_Realloc(writer.buf, size)
  2008. */
  2009. (void)(memcpy(__pyx_v_buf, __pyx_v_writer->buf, __pyx_v_writer->size));
  2010. /* "yarl/_quoting.pyx":102
  2011. * # reallocate
  2012. * size = writer.size + BUF_SIZE
  2013. * if writer.buf == BUFFER: # <<<<<<<<<<<<<<
  2014. * buf = <char*>PyMem_Malloc(size)
  2015. * if buf == NULL:
  2016. */
  2017. goto __pyx_L4;
  2018. }
  2019. /* "yarl/_quoting.pyx":109
  2020. * memcpy(buf, writer.buf, writer.size)
  2021. * else:
  2022. * buf = <char*>PyMem_Realloc(writer.buf, size) # <<<<<<<<<<<<<<
  2023. * if buf == NULL:
  2024. * PyErr_NoMemory()
  2025. */
  2026. /*else*/ {
  2027. __pyx_v_buf = ((char *)PyMem_Realloc(__pyx_v_writer->buf, __pyx_v_size));
  2028. /* "yarl/_quoting.pyx":110
  2029. * else:
  2030. * buf = <char*>PyMem_Realloc(writer.buf, size)
  2031. * if buf == NULL: # <<<<<<<<<<<<<<
  2032. * PyErr_NoMemory()
  2033. * return -1
  2034. */
  2035. __pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
  2036. if (__pyx_t_1) {
  2037. /* "yarl/_quoting.pyx":111
  2038. * buf = <char*>PyMem_Realloc(writer.buf, size)
  2039. * if buf == NULL:
  2040. * PyErr_NoMemory() # <<<<<<<<<<<<<<
  2041. * return -1
  2042. * writer.buf = buf
  2043. */
  2044. __pyx_t_2 = PyErr_NoMemory(); if (unlikely(__pyx_t_2 == ((PyObject *)NULL))) __PYX_ERR(0, 111, __pyx_L1_error)
  2045. /* "yarl/_quoting.pyx":112
  2046. * if buf == NULL:
  2047. * PyErr_NoMemory()
  2048. * return -1 # <<<<<<<<<<<<<<
  2049. * writer.buf = buf
  2050. * writer.size = size
  2051. */
  2052. __pyx_r = -1;
  2053. goto __pyx_L0;
  2054. /* "yarl/_quoting.pyx":110
  2055. * else:
  2056. * buf = <char*>PyMem_Realloc(writer.buf, size)
  2057. * if buf == NULL: # <<<<<<<<<<<<<<
  2058. * PyErr_NoMemory()
  2059. * return -1
  2060. */
  2061. }
  2062. }
  2063. __pyx_L4:;
  2064. /* "yarl/_quoting.pyx":113
  2065. * PyErr_NoMemory()
  2066. * return -1
  2067. * writer.buf = buf # <<<<<<<<<<<<<<
  2068. * writer.size = size
  2069. * writer.buf[writer.pos] = <char>ch
  2070. */
  2071. __pyx_v_writer->buf = __pyx_v_buf;
  2072. /* "yarl/_quoting.pyx":114
  2073. * return -1
  2074. * writer.buf = buf
  2075. * writer.size = size # <<<<<<<<<<<<<<
  2076. * writer.buf[writer.pos] = <char>ch
  2077. * writer.pos += 1
  2078. */
  2079. __pyx_v_writer->size = __pyx_v_size;
  2080. /* "yarl/_quoting.pyx":99
  2081. * cdef Py_ssize_t size
  2082. *
  2083. * if writer.pos == writer.size: # <<<<<<<<<<<<<<
  2084. * # reallocate
  2085. * size = writer.size + BUF_SIZE
  2086. */
  2087. }
  2088. /* "yarl/_quoting.pyx":115
  2089. * writer.buf = buf
  2090. * writer.size = size
  2091. * writer.buf[writer.pos] = <char>ch # <<<<<<<<<<<<<<
  2092. * writer.pos += 1
  2093. * writer.changed |= changed
  2094. */
  2095. (__pyx_v_writer->buf[__pyx_v_writer->pos]) = ((char)__pyx_v_ch);
  2096. /* "yarl/_quoting.pyx":116
  2097. * writer.size = size
  2098. * writer.buf[writer.pos] = <char>ch
  2099. * writer.pos += 1 # <<<<<<<<<<<<<<
  2100. * writer.changed |= changed
  2101. * return 0
  2102. */
  2103. __pyx_v_writer->pos = (__pyx_v_writer->pos + 1);
  2104. /* "yarl/_quoting.pyx":117
  2105. * writer.buf[writer.pos] = <char>ch
  2106. * writer.pos += 1
  2107. * writer.changed |= changed # <<<<<<<<<<<<<<
  2108. * return 0
  2109. *
  2110. */
  2111. __pyx_v_writer->changed = (__pyx_v_writer->changed | __pyx_v_changed);
  2112. /* "yarl/_quoting.pyx":118
  2113. * writer.pos += 1
  2114. * writer.changed |= changed
  2115. * return 0 # <<<<<<<<<<<<<<
  2116. *
  2117. *
  2118. */
  2119. __pyx_r = 0;
  2120. goto __pyx_L0;
  2121. /* "yarl/_quoting.pyx":95
  2122. *
  2123. *
  2124. * cdef inline int _write_char(Writer* writer, Py_UCS4 ch, bint changed): # <<<<<<<<<<<<<<
  2125. * cdef char * buf
  2126. * cdef Py_ssize_t size
  2127. */
  2128. /* function exit code */
  2129. __pyx_L1_error:;
  2130. __Pyx_WriteUnraisable("yarl._quoting._write_char", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  2131. __pyx_r = 0;
  2132. __pyx_L0:;
  2133. __Pyx_RefNannyFinishContext();
  2134. return __pyx_r;
  2135. }
  2136. /* "yarl/_quoting.pyx":121
  2137. *
  2138. *
  2139. * cdef inline int _write_pct(Writer* writer, uint8_t ch, bint changed): # <<<<<<<<<<<<<<
  2140. * if _write_char(writer, '%', changed) < 0:
  2141. * return -1
  2142. */
  2143. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting__write_pct(struct __pyx_t_4yarl_8_quoting_Writer *__pyx_v_writer, uint8_t __pyx_v_ch, int __pyx_v_changed) {
  2144. int __pyx_r;
  2145. __Pyx_RefNannyDeclarations
  2146. int __pyx_t_1;
  2147. __Pyx_RefNannySetupContext("_write_pct", 0);
  2148. /* "yarl/_quoting.pyx":122
  2149. *
  2150. * cdef inline int _write_pct(Writer* writer, uint8_t ch, bint changed):
  2151. * if _write_char(writer, '%', changed) < 0: # <<<<<<<<<<<<<<
  2152. * return -1
  2153. * if _write_char(writer, _to_hex(<uint8_t>ch >> 4), changed) < 0:
  2154. */
  2155. __pyx_t_1 = ((__pyx_f_4yarl_8_quoting__write_char(__pyx_v_writer, 37, __pyx_v_changed) < 0) != 0);
  2156. if (__pyx_t_1) {
  2157. /* "yarl/_quoting.pyx":123
  2158. * cdef inline int _write_pct(Writer* writer, uint8_t ch, bint changed):
  2159. * if _write_char(writer, '%', changed) < 0:
  2160. * return -1 # <<<<<<<<<<<<<<
  2161. * if _write_char(writer, _to_hex(<uint8_t>ch >> 4), changed) < 0:
  2162. * return -1
  2163. */
  2164. __pyx_r = -1;
  2165. goto __pyx_L0;
  2166. /* "yarl/_quoting.pyx":122
  2167. *
  2168. * cdef inline int _write_pct(Writer* writer, uint8_t ch, bint changed):
  2169. * if _write_char(writer, '%', changed) < 0: # <<<<<<<<<<<<<<
  2170. * return -1
  2171. * if _write_char(writer, _to_hex(<uint8_t>ch >> 4), changed) < 0:
  2172. */
  2173. }
  2174. /* "yarl/_quoting.pyx":124
  2175. * if _write_char(writer, '%', changed) < 0:
  2176. * return -1
  2177. * if _write_char(writer, _to_hex(<uint8_t>ch >> 4), changed) < 0: # <<<<<<<<<<<<<<
  2178. * return -1
  2179. * return _write_char(writer, _to_hex(<uint8_t>ch & 0x0f), changed)
  2180. */
  2181. __pyx_t_1 = ((__pyx_f_4yarl_8_quoting__write_char(__pyx_v_writer, __pyx_f_4yarl_8_quoting__to_hex((((uint8_t)__pyx_v_ch) >> 4)), __pyx_v_changed) < 0) != 0);
  2182. if (__pyx_t_1) {
  2183. /* "yarl/_quoting.pyx":125
  2184. * return -1
  2185. * if _write_char(writer, _to_hex(<uint8_t>ch >> 4), changed) < 0:
  2186. * return -1 # <<<<<<<<<<<<<<
  2187. * return _write_char(writer, _to_hex(<uint8_t>ch & 0x0f), changed)
  2188. *
  2189. */
  2190. __pyx_r = -1;
  2191. goto __pyx_L0;
  2192. /* "yarl/_quoting.pyx":124
  2193. * if _write_char(writer, '%', changed) < 0:
  2194. * return -1
  2195. * if _write_char(writer, _to_hex(<uint8_t>ch >> 4), changed) < 0: # <<<<<<<<<<<<<<
  2196. * return -1
  2197. * return _write_char(writer, _to_hex(<uint8_t>ch & 0x0f), changed)
  2198. */
  2199. }
  2200. /* "yarl/_quoting.pyx":126
  2201. * if _write_char(writer, _to_hex(<uint8_t>ch >> 4), changed) < 0:
  2202. * return -1
  2203. * return _write_char(writer, _to_hex(<uint8_t>ch & 0x0f), changed) # <<<<<<<<<<<<<<
  2204. *
  2205. *
  2206. */
  2207. __pyx_r = __pyx_f_4yarl_8_quoting__write_char(__pyx_v_writer, __pyx_f_4yarl_8_quoting__to_hex((((uint8_t)__pyx_v_ch) & 0x0f)), __pyx_v_changed);
  2208. goto __pyx_L0;
  2209. /* "yarl/_quoting.pyx":121
  2210. *
  2211. *
  2212. * cdef inline int _write_pct(Writer* writer, uint8_t ch, bint changed): # <<<<<<<<<<<<<<
  2213. * if _write_char(writer, '%', changed) < 0:
  2214. * return -1
  2215. */
  2216. /* function exit code */
  2217. __pyx_L0:;
  2218. __Pyx_RefNannyFinishContext();
  2219. return __pyx_r;
  2220. }
  2221. /* "yarl/_quoting.pyx":129
  2222. *
  2223. *
  2224. * cdef inline int _write_percent(Writer* writer): # <<<<<<<<<<<<<<
  2225. * if _write_char(writer, '%', True) < 0:
  2226. * return -1
  2227. */
  2228. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting__write_percent(struct __pyx_t_4yarl_8_quoting_Writer *__pyx_v_writer) {
  2229. int __pyx_r;
  2230. __Pyx_RefNannyDeclarations
  2231. int __pyx_t_1;
  2232. __Pyx_RefNannySetupContext("_write_percent", 0);
  2233. /* "yarl/_quoting.pyx":130
  2234. *
  2235. * cdef inline int _write_percent(Writer* writer):
  2236. * if _write_char(writer, '%', True) < 0: # <<<<<<<<<<<<<<
  2237. * return -1
  2238. * if _write_char(writer, '2', True) < 0:
  2239. */
  2240. __pyx_t_1 = ((__pyx_f_4yarl_8_quoting__write_char(__pyx_v_writer, 37, 1) < 0) != 0);
  2241. if (__pyx_t_1) {
  2242. /* "yarl/_quoting.pyx":131
  2243. * cdef inline int _write_percent(Writer* writer):
  2244. * if _write_char(writer, '%', True) < 0:
  2245. * return -1 # <<<<<<<<<<<<<<
  2246. * if _write_char(writer, '2', True) < 0:
  2247. * return -1
  2248. */
  2249. __pyx_r = -1;
  2250. goto __pyx_L0;
  2251. /* "yarl/_quoting.pyx":130
  2252. *
  2253. * cdef inline int _write_percent(Writer* writer):
  2254. * if _write_char(writer, '%', True) < 0: # <<<<<<<<<<<<<<
  2255. * return -1
  2256. * if _write_char(writer, '2', True) < 0:
  2257. */
  2258. }
  2259. /* "yarl/_quoting.pyx":132
  2260. * if _write_char(writer, '%', True) < 0:
  2261. * return -1
  2262. * if _write_char(writer, '2', True) < 0: # <<<<<<<<<<<<<<
  2263. * return -1
  2264. * return _write_char(writer, '5', True)
  2265. */
  2266. __pyx_t_1 = ((__pyx_f_4yarl_8_quoting__write_char(__pyx_v_writer, 50, 1) < 0) != 0);
  2267. if (__pyx_t_1) {
  2268. /* "yarl/_quoting.pyx":133
  2269. * return -1
  2270. * if _write_char(writer, '2', True) < 0:
  2271. * return -1 # <<<<<<<<<<<<<<
  2272. * return _write_char(writer, '5', True)
  2273. *
  2274. */
  2275. __pyx_r = -1;
  2276. goto __pyx_L0;
  2277. /* "yarl/_quoting.pyx":132
  2278. * if _write_char(writer, '%', True) < 0:
  2279. * return -1
  2280. * if _write_char(writer, '2', True) < 0: # <<<<<<<<<<<<<<
  2281. * return -1
  2282. * return _write_char(writer, '5', True)
  2283. */
  2284. }
  2285. /* "yarl/_quoting.pyx":134
  2286. * if _write_char(writer, '2', True) < 0:
  2287. * return -1
  2288. * return _write_char(writer, '5', True) # <<<<<<<<<<<<<<
  2289. *
  2290. *
  2291. */
  2292. __pyx_r = __pyx_f_4yarl_8_quoting__write_char(__pyx_v_writer, 53, 1);
  2293. goto __pyx_L0;
  2294. /* "yarl/_quoting.pyx":129
  2295. *
  2296. *
  2297. * cdef inline int _write_percent(Writer* writer): # <<<<<<<<<<<<<<
  2298. * if _write_char(writer, '%', True) < 0:
  2299. * return -1
  2300. */
  2301. /* function exit code */
  2302. __pyx_L0:;
  2303. __Pyx_RefNannyFinishContext();
  2304. return __pyx_r;
  2305. }
  2306. /* "yarl/_quoting.pyx":137
  2307. *
  2308. *
  2309. * cdef inline int _write_pct_check(Writer* writer, Py_UCS4 ch, Py_UCS4 pct[]): # <<<<<<<<<<<<<<
  2310. * cdef Py_UCS4 pct1 = _to_hex(<uint8_t>ch >> 4)
  2311. * cdef Py_UCS4 pct2 = _to_hex(<uint8_t>ch & 0x0f)
  2312. */
  2313. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting__write_pct_check(struct __pyx_t_4yarl_8_quoting_Writer *__pyx_v_writer, Py_UCS4 __pyx_v_ch, Py_UCS4 *__pyx_v_pct) {
  2314. Py_UCS4 __pyx_v_pct1;
  2315. Py_UCS4 __pyx_v_pct2;
  2316. int __pyx_v_changed;
  2317. int __pyx_r;
  2318. __Pyx_RefNannyDeclarations
  2319. int __pyx_t_1;
  2320. int __pyx_t_2;
  2321. __Pyx_RefNannySetupContext("_write_pct_check", 0);
  2322. /* "yarl/_quoting.pyx":138
  2323. *
  2324. * cdef inline int _write_pct_check(Writer* writer, Py_UCS4 ch, Py_UCS4 pct[]):
  2325. * cdef Py_UCS4 pct1 = _to_hex(<uint8_t>ch >> 4) # <<<<<<<<<<<<<<
  2326. * cdef Py_UCS4 pct2 = _to_hex(<uint8_t>ch & 0x0f)
  2327. * cdef bint changed = pct[0] != pct1 or pct[1] != pct2
  2328. */
  2329. __pyx_v_pct1 = __pyx_f_4yarl_8_quoting__to_hex((((uint8_t)__pyx_v_ch) >> 4));
  2330. /* "yarl/_quoting.pyx":139
  2331. * cdef inline int _write_pct_check(Writer* writer, Py_UCS4 ch, Py_UCS4 pct[]):
  2332. * cdef Py_UCS4 pct1 = _to_hex(<uint8_t>ch >> 4)
  2333. * cdef Py_UCS4 pct2 = _to_hex(<uint8_t>ch & 0x0f) # <<<<<<<<<<<<<<
  2334. * cdef bint changed = pct[0] != pct1 or pct[1] != pct2
  2335. *
  2336. */
  2337. __pyx_v_pct2 = __pyx_f_4yarl_8_quoting__to_hex((((uint8_t)__pyx_v_ch) & 0x0f));
  2338. /* "yarl/_quoting.pyx":140
  2339. * cdef Py_UCS4 pct1 = _to_hex(<uint8_t>ch >> 4)
  2340. * cdef Py_UCS4 pct2 = _to_hex(<uint8_t>ch & 0x0f)
  2341. * cdef bint changed = pct[0] != pct1 or pct[1] != pct2 # <<<<<<<<<<<<<<
  2342. *
  2343. * if _write_char(writer, '%', changed) < 0:
  2344. */
  2345. __pyx_t_2 = (((__pyx_v_pct[0]) != __pyx_v_pct1) != 0);
  2346. if (!__pyx_t_2) {
  2347. } else {
  2348. __pyx_t_1 = __pyx_t_2;
  2349. goto __pyx_L3_bool_binop_done;
  2350. }
  2351. __pyx_t_2 = (((__pyx_v_pct[1]) != __pyx_v_pct2) != 0);
  2352. __pyx_t_1 = __pyx_t_2;
  2353. __pyx_L3_bool_binop_done:;
  2354. __pyx_v_changed = __pyx_t_1;
  2355. /* "yarl/_quoting.pyx":142
  2356. * cdef bint changed = pct[0] != pct1 or pct[1] != pct2
  2357. *
  2358. * if _write_char(writer, '%', changed) < 0: # <<<<<<<<<<<<<<
  2359. * return -1
  2360. * if _write_char(writer, pct1, changed) < 0:
  2361. */
  2362. __pyx_t_1 = ((__pyx_f_4yarl_8_quoting__write_char(__pyx_v_writer, 37, __pyx_v_changed) < 0) != 0);
  2363. if (__pyx_t_1) {
  2364. /* "yarl/_quoting.pyx":143
  2365. *
  2366. * if _write_char(writer, '%', changed) < 0:
  2367. * return -1 # <<<<<<<<<<<<<<
  2368. * if _write_char(writer, pct1, changed) < 0:
  2369. * return -1
  2370. */
  2371. __pyx_r = -1;
  2372. goto __pyx_L0;
  2373. /* "yarl/_quoting.pyx":142
  2374. * cdef bint changed = pct[0] != pct1 or pct[1] != pct2
  2375. *
  2376. * if _write_char(writer, '%', changed) < 0: # <<<<<<<<<<<<<<
  2377. * return -1
  2378. * if _write_char(writer, pct1, changed) < 0:
  2379. */
  2380. }
  2381. /* "yarl/_quoting.pyx":144
  2382. * if _write_char(writer, '%', changed) < 0:
  2383. * return -1
  2384. * if _write_char(writer, pct1, changed) < 0: # <<<<<<<<<<<<<<
  2385. * return -1
  2386. * return _write_char(writer, pct2, changed)
  2387. */
  2388. __pyx_t_1 = ((__pyx_f_4yarl_8_quoting__write_char(__pyx_v_writer, __pyx_v_pct1, __pyx_v_changed) < 0) != 0);
  2389. if (__pyx_t_1) {
  2390. /* "yarl/_quoting.pyx":145
  2391. * return -1
  2392. * if _write_char(writer, pct1, changed) < 0:
  2393. * return -1 # <<<<<<<<<<<<<<
  2394. * return _write_char(writer, pct2, changed)
  2395. *
  2396. */
  2397. __pyx_r = -1;
  2398. goto __pyx_L0;
  2399. /* "yarl/_quoting.pyx":144
  2400. * if _write_char(writer, '%', changed) < 0:
  2401. * return -1
  2402. * if _write_char(writer, pct1, changed) < 0: # <<<<<<<<<<<<<<
  2403. * return -1
  2404. * return _write_char(writer, pct2, changed)
  2405. */
  2406. }
  2407. /* "yarl/_quoting.pyx":146
  2408. * if _write_char(writer, pct1, changed) < 0:
  2409. * return -1
  2410. * return _write_char(writer, pct2, changed) # <<<<<<<<<<<<<<
  2411. *
  2412. *
  2413. */
  2414. __pyx_r = __pyx_f_4yarl_8_quoting__write_char(__pyx_v_writer, __pyx_v_pct2, __pyx_v_changed);
  2415. goto __pyx_L0;
  2416. /* "yarl/_quoting.pyx":137
  2417. *
  2418. *
  2419. * cdef inline int _write_pct_check(Writer* writer, Py_UCS4 ch, Py_UCS4 pct[]): # <<<<<<<<<<<<<<
  2420. * cdef Py_UCS4 pct1 = _to_hex(<uint8_t>ch >> 4)
  2421. * cdef Py_UCS4 pct2 = _to_hex(<uint8_t>ch & 0x0f)
  2422. */
  2423. /* function exit code */
  2424. __pyx_L0:;
  2425. __Pyx_RefNannyFinishContext();
  2426. return __pyx_r;
  2427. }
  2428. /* "yarl/_quoting.pyx":149
  2429. *
  2430. *
  2431. * cdef inline int _write_utf8(Writer* writer, Py_UCS4 symbol): # <<<<<<<<<<<<<<
  2432. * cdef uint64_t utf = <uint64_t> symbol
  2433. *
  2434. */
  2435. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting__write_utf8(struct __pyx_t_4yarl_8_quoting_Writer *__pyx_v_writer, Py_UCS4 __pyx_v_symbol) {
  2436. uint64_t __pyx_v_utf;
  2437. int __pyx_r;
  2438. __Pyx_RefNannyDeclarations
  2439. int __pyx_t_1;
  2440. int __pyx_t_2;
  2441. __Pyx_RefNannySetupContext("_write_utf8", 0);
  2442. /* "yarl/_quoting.pyx":150
  2443. *
  2444. * cdef inline int _write_utf8(Writer* writer, Py_UCS4 symbol):
  2445. * cdef uint64_t utf = <uint64_t> symbol # <<<<<<<<<<<<<<
  2446. *
  2447. * if utf < 0x80:
  2448. */
  2449. __pyx_v_utf = ((uint64_t)__pyx_v_symbol);
  2450. /* "yarl/_quoting.pyx":152
  2451. * cdef uint64_t utf = <uint64_t> symbol
  2452. *
  2453. * if utf < 0x80: # <<<<<<<<<<<<<<
  2454. * return _write_pct(writer, <uint8_t>utf, True)
  2455. * elif utf < 0x800:
  2456. */
  2457. __pyx_t_1 = ((__pyx_v_utf < 0x80) != 0);
  2458. if (__pyx_t_1) {
  2459. /* "yarl/_quoting.pyx":153
  2460. *
  2461. * if utf < 0x80:
  2462. * return _write_pct(writer, <uint8_t>utf, True) # <<<<<<<<<<<<<<
  2463. * elif utf < 0x800:
  2464. * if _write_pct(writer, <uint8_t>(0xc0 | (utf >> 6)), True) < 0:
  2465. */
  2466. __pyx_r = __pyx_f_4yarl_8_quoting__write_pct(__pyx_v_writer, ((uint8_t)__pyx_v_utf), 1);
  2467. goto __pyx_L0;
  2468. /* "yarl/_quoting.pyx":152
  2469. * cdef uint64_t utf = <uint64_t> symbol
  2470. *
  2471. * if utf < 0x80: # <<<<<<<<<<<<<<
  2472. * return _write_pct(writer, <uint8_t>utf, True)
  2473. * elif utf < 0x800:
  2474. */
  2475. }
  2476. /* "yarl/_quoting.pyx":154
  2477. * if utf < 0x80:
  2478. * return _write_pct(writer, <uint8_t>utf, True)
  2479. * elif utf < 0x800: # <<<<<<<<<<<<<<
  2480. * if _write_pct(writer, <uint8_t>(0xc0 | (utf >> 6)), True) < 0:
  2481. * return -1
  2482. */
  2483. __pyx_t_1 = ((__pyx_v_utf < 0x800) != 0);
  2484. if (__pyx_t_1) {
  2485. /* "yarl/_quoting.pyx":155
  2486. * return _write_pct(writer, <uint8_t>utf, True)
  2487. * elif utf < 0x800:
  2488. * if _write_pct(writer, <uint8_t>(0xc0 | (utf >> 6)), True) < 0: # <<<<<<<<<<<<<<
  2489. * return -1
  2490. * return _write_pct(writer, <uint8_t>(0x80 | (utf & 0x3f)), True)
  2491. */
  2492. __pyx_t_1 = ((__pyx_f_4yarl_8_quoting__write_pct(__pyx_v_writer, ((uint8_t)(0xc0 | (__pyx_v_utf >> 6))), 1) < 0) != 0);
  2493. if (__pyx_t_1) {
  2494. /* "yarl/_quoting.pyx":156
  2495. * elif utf < 0x800:
  2496. * if _write_pct(writer, <uint8_t>(0xc0 | (utf >> 6)), True) < 0:
  2497. * return -1 # <<<<<<<<<<<<<<
  2498. * return _write_pct(writer, <uint8_t>(0x80 | (utf & 0x3f)), True)
  2499. * elif 0xD800 <= utf <= 0xDFFF:
  2500. */
  2501. __pyx_r = -1;
  2502. goto __pyx_L0;
  2503. /* "yarl/_quoting.pyx":155
  2504. * return _write_pct(writer, <uint8_t>utf, True)
  2505. * elif utf < 0x800:
  2506. * if _write_pct(writer, <uint8_t>(0xc0 | (utf >> 6)), True) < 0: # <<<<<<<<<<<<<<
  2507. * return -1
  2508. * return _write_pct(writer, <uint8_t>(0x80 | (utf & 0x3f)), True)
  2509. */
  2510. }
  2511. /* "yarl/_quoting.pyx":157
  2512. * if _write_pct(writer, <uint8_t>(0xc0 | (utf >> 6)), True) < 0:
  2513. * return -1
  2514. * return _write_pct(writer, <uint8_t>(0x80 | (utf & 0x3f)), True) # <<<<<<<<<<<<<<
  2515. * elif 0xD800 <= utf <= 0xDFFF:
  2516. * # surogate pair, ignored
  2517. */
  2518. __pyx_r = __pyx_f_4yarl_8_quoting__write_pct(__pyx_v_writer, ((uint8_t)(0x80 | (__pyx_v_utf & 0x3f))), 1);
  2519. goto __pyx_L0;
  2520. /* "yarl/_quoting.pyx":154
  2521. * if utf < 0x80:
  2522. * return _write_pct(writer, <uint8_t>utf, True)
  2523. * elif utf < 0x800: # <<<<<<<<<<<<<<
  2524. * if _write_pct(writer, <uint8_t>(0xc0 | (utf >> 6)), True) < 0:
  2525. * return -1
  2526. */
  2527. }
  2528. /* "yarl/_quoting.pyx":158
  2529. * return -1
  2530. * return _write_pct(writer, <uint8_t>(0x80 | (utf & 0x3f)), True)
  2531. * elif 0xD800 <= utf <= 0xDFFF: # <<<<<<<<<<<<<<
  2532. * # surogate pair, ignored
  2533. * return 0
  2534. */
  2535. __pyx_t_1 = (0xD800 <= __pyx_v_utf);
  2536. if (__pyx_t_1) {
  2537. __pyx_t_1 = (__pyx_v_utf <= 0xDFFF);
  2538. }
  2539. __pyx_t_2 = (__pyx_t_1 != 0);
  2540. if (__pyx_t_2) {
  2541. /* "yarl/_quoting.pyx":160
  2542. * elif 0xD800 <= utf <= 0xDFFF:
  2543. * # surogate pair, ignored
  2544. * return 0 # <<<<<<<<<<<<<<
  2545. * elif utf < 0x10000:
  2546. * if _write_pct(writer, <uint8_t>(0xe0 | (utf >> 12)), True) < 0:
  2547. */
  2548. __pyx_r = 0;
  2549. goto __pyx_L0;
  2550. /* "yarl/_quoting.pyx":158
  2551. * return -1
  2552. * return _write_pct(writer, <uint8_t>(0x80 | (utf & 0x3f)), True)
  2553. * elif 0xD800 <= utf <= 0xDFFF: # <<<<<<<<<<<<<<
  2554. * # surogate pair, ignored
  2555. * return 0
  2556. */
  2557. }
  2558. /* "yarl/_quoting.pyx":161
  2559. * # surogate pair, ignored
  2560. * return 0
  2561. * elif utf < 0x10000: # <<<<<<<<<<<<<<
  2562. * if _write_pct(writer, <uint8_t>(0xe0 | (utf >> 12)), True) < 0:
  2563. * return -1
  2564. */
  2565. __pyx_t_2 = ((__pyx_v_utf < 0x10000) != 0);
  2566. if (__pyx_t_2) {
  2567. /* "yarl/_quoting.pyx":162
  2568. * return 0
  2569. * elif utf < 0x10000:
  2570. * if _write_pct(writer, <uint8_t>(0xe0 | (utf >> 12)), True) < 0: # <<<<<<<<<<<<<<
  2571. * return -1
  2572. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f)),
  2573. */
  2574. __pyx_t_2 = ((__pyx_f_4yarl_8_quoting__write_pct(__pyx_v_writer, ((uint8_t)(0xe0 | (__pyx_v_utf >> 12))), 1) < 0) != 0);
  2575. if (__pyx_t_2) {
  2576. /* "yarl/_quoting.pyx":163
  2577. * elif utf < 0x10000:
  2578. * if _write_pct(writer, <uint8_t>(0xe0 | (utf >> 12)), True) < 0:
  2579. * return -1 # <<<<<<<<<<<<<<
  2580. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f)),
  2581. * True) < 0:
  2582. */
  2583. __pyx_r = -1;
  2584. goto __pyx_L0;
  2585. /* "yarl/_quoting.pyx":162
  2586. * return 0
  2587. * elif utf < 0x10000:
  2588. * if _write_pct(writer, <uint8_t>(0xe0 | (utf >> 12)), True) < 0: # <<<<<<<<<<<<<<
  2589. * return -1
  2590. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f)),
  2591. */
  2592. }
  2593. /* "yarl/_quoting.pyx":165
  2594. * return -1
  2595. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f)),
  2596. * True) < 0: # <<<<<<<<<<<<<<
  2597. * return -1
  2598. * return _write_pct(writer, <uint8_t>(0x80 | (utf & 0x3f)), True)
  2599. */
  2600. __pyx_t_2 = ((__pyx_f_4yarl_8_quoting__write_pct(__pyx_v_writer, ((uint8_t)(0x80 | ((__pyx_v_utf >> 6) & 0x3f))), 1) < 0) != 0);
  2601. /* "yarl/_quoting.pyx":164
  2602. * if _write_pct(writer, <uint8_t>(0xe0 | (utf >> 12)), True) < 0:
  2603. * return -1
  2604. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f)), # <<<<<<<<<<<<<<
  2605. * True) < 0:
  2606. * return -1
  2607. */
  2608. if (__pyx_t_2) {
  2609. /* "yarl/_quoting.pyx":166
  2610. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f)),
  2611. * True) < 0:
  2612. * return -1 # <<<<<<<<<<<<<<
  2613. * return _write_pct(writer, <uint8_t>(0x80 | (utf & 0x3f)), True)
  2614. * elif utf > 0x10FFFF:
  2615. */
  2616. __pyx_r = -1;
  2617. goto __pyx_L0;
  2618. /* "yarl/_quoting.pyx":164
  2619. * if _write_pct(writer, <uint8_t>(0xe0 | (utf >> 12)), True) < 0:
  2620. * return -1
  2621. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f)), # <<<<<<<<<<<<<<
  2622. * True) < 0:
  2623. * return -1
  2624. */
  2625. }
  2626. /* "yarl/_quoting.pyx":167
  2627. * True) < 0:
  2628. * return -1
  2629. * return _write_pct(writer, <uint8_t>(0x80 | (utf & 0x3f)), True) # <<<<<<<<<<<<<<
  2630. * elif utf > 0x10FFFF:
  2631. * # symbol is too large
  2632. */
  2633. __pyx_r = __pyx_f_4yarl_8_quoting__write_pct(__pyx_v_writer, ((uint8_t)(0x80 | (__pyx_v_utf & 0x3f))), 1);
  2634. goto __pyx_L0;
  2635. /* "yarl/_quoting.pyx":161
  2636. * # surogate pair, ignored
  2637. * return 0
  2638. * elif utf < 0x10000: # <<<<<<<<<<<<<<
  2639. * if _write_pct(writer, <uint8_t>(0xe0 | (utf >> 12)), True) < 0:
  2640. * return -1
  2641. */
  2642. }
  2643. /* "yarl/_quoting.pyx":168
  2644. * return -1
  2645. * return _write_pct(writer, <uint8_t>(0x80 | (utf & 0x3f)), True)
  2646. * elif utf > 0x10FFFF: # <<<<<<<<<<<<<<
  2647. * # symbol is too large
  2648. * return 0
  2649. */
  2650. __pyx_t_2 = ((__pyx_v_utf > 0x10FFFF) != 0);
  2651. if (__pyx_t_2) {
  2652. /* "yarl/_quoting.pyx":170
  2653. * elif utf > 0x10FFFF:
  2654. * # symbol is too large
  2655. * return 0 # <<<<<<<<<<<<<<
  2656. * else:
  2657. * if _write_pct(writer, <uint8_t>(0xf0 | (utf >> 18)), True) < 0:
  2658. */
  2659. __pyx_r = 0;
  2660. goto __pyx_L0;
  2661. /* "yarl/_quoting.pyx":168
  2662. * return -1
  2663. * return _write_pct(writer, <uint8_t>(0x80 | (utf & 0x3f)), True)
  2664. * elif utf > 0x10FFFF: # <<<<<<<<<<<<<<
  2665. * # symbol is too large
  2666. * return 0
  2667. */
  2668. }
  2669. /* "yarl/_quoting.pyx":172
  2670. * return 0
  2671. * else:
  2672. * if _write_pct(writer, <uint8_t>(0xf0 | (utf >> 18)), True) < 0: # <<<<<<<<<<<<<<
  2673. * return -1
  2674. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 12) & 0x3f)),
  2675. */
  2676. /*else*/ {
  2677. __pyx_t_2 = ((__pyx_f_4yarl_8_quoting__write_pct(__pyx_v_writer, ((uint8_t)(0xf0 | (__pyx_v_utf >> 18))), 1) < 0) != 0);
  2678. if (__pyx_t_2) {
  2679. /* "yarl/_quoting.pyx":173
  2680. * else:
  2681. * if _write_pct(writer, <uint8_t>(0xf0 | (utf >> 18)), True) < 0:
  2682. * return -1 # <<<<<<<<<<<<<<
  2683. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 12) & 0x3f)),
  2684. * True) < 0:
  2685. */
  2686. __pyx_r = -1;
  2687. goto __pyx_L0;
  2688. /* "yarl/_quoting.pyx":172
  2689. * return 0
  2690. * else:
  2691. * if _write_pct(writer, <uint8_t>(0xf0 | (utf >> 18)), True) < 0: # <<<<<<<<<<<<<<
  2692. * return -1
  2693. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 12) & 0x3f)),
  2694. */
  2695. }
  2696. /* "yarl/_quoting.pyx":175
  2697. * return -1
  2698. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 12) & 0x3f)),
  2699. * True) < 0: # <<<<<<<<<<<<<<
  2700. * return -1
  2701. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f)),
  2702. */
  2703. __pyx_t_2 = ((__pyx_f_4yarl_8_quoting__write_pct(__pyx_v_writer, ((uint8_t)(0x80 | ((__pyx_v_utf >> 12) & 0x3f))), 1) < 0) != 0);
  2704. /* "yarl/_quoting.pyx":174
  2705. * if _write_pct(writer, <uint8_t>(0xf0 | (utf >> 18)), True) < 0:
  2706. * return -1
  2707. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 12) & 0x3f)), # <<<<<<<<<<<<<<
  2708. * True) < 0:
  2709. * return -1
  2710. */
  2711. if (__pyx_t_2) {
  2712. /* "yarl/_quoting.pyx":176
  2713. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 12) & 0x3f)),
  2714. * True) < 0:
  2715. * return -1 # <<<<<<<<<<<<<<
  2716. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f)),
  2717. * True) < 0:
  2718. */
  2719. __pyx_r = -1;
  2720. goto __pyx_L0;
  2721. /* "yarl/_quoting.pyx":174
  2722. * if _write_pct(writer, <uint8_t>(0xf0 | (utf >> 18)), True) < 0:
  2723. * return -1
  2724. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 12) & 0x3f)), # <<<<<<<<<<<<<<
  2725. * True) < 0:
  2726. * return -1
  2727. */
  2728. }
  2729. /* "yarl/_quoting.pyx":178
  2730. * return -1
  2731. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f)),
  2732. * True) < 0: # <<<<<<<<<<<<<<
  2733. * return -1
  2734. * return _write_pct(writer, <uint8_t>(0x80 | (utf & 0x3f)), True)
  2735. */
  2736. __pyx_t_2 = ((__pyx_f_4yarl_8_quoting__write_pct(__pyx_v_writer, ((uint8_t)(0x80 | ((__pyx_v_utf >> 6) & 0x3f))), 1) < 0) != 0);
  2737. /* "yarl/_quoting.pyx":177
  2738. * True) < 0:
  2739. * return -1
  2740. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f)), # <<<<<<<<<<<<<<
  2741. * True) < 0:
  2742. * return -1
  2743. */
  2744. if (__pyx_t_2) {
  2745. /* "yarl/_quoting.pyx":179
  2746. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f)),
  2747. * True) < 0:
  2748. * return -1 # <<<<<<<<<<<<<<
  2749. * return _write_pct(writer, <uint8_t>(0x80 | (utf & 0x3f)), True)
  2750. *
  2751. */
  2752. __pyx_r = -1;
  2753. goto __pyx_L0;
  2754. /* "yarl/_quoting.pyx":177
  2755. * True) < 0:
  2756. * return -1
  2757. * if _write_pct(writer, <uint8_t>(0x80 | ((utf >> 6) & 0x3f)), # <<<<<<<<<<<<<<
  2758. * True) < 0:
  2759. * return -1
  2760. */
  2761. }
  2762. /* "yarl/_quoting.pyx":180
  2763. * True) < 0:
  2764. * return -1
  2765. * return _write_pct(writer, <uint8_t>(0x80 | (utf & 0x3f)), True) # <<<<<<<<<<<<<<
  2766. *
  2767. *
  2768. */
  2769. __pyx_r = __pyx_f_4yarl_8_quoting__write_pct(__pyx_v_writer, ((uint8_t)(0x80 | (__pyx_v_utf & 0x3f))), 1);
  2770. goto __pyx_L0;
  2771. }
  2772. /* "yarl/_quoting.pyx":149
  2773. *
  2774. *
  2775. * cdef inline int _write_utf8(Writer* writer, Py_UCS4 symbol): # <<<<<<<<<<<<<<
  2776. * cdef uint64_t utf = <uint64_t> symbol
  2777. *
  2778. */
  2779. /* function exit code */
  2780. __pyx_L0:;
  2781. __Pyx_RefNannyFinishContext();
  2782. return __pyx_r;
  2783. }
  2784. /* "yarl/_quoting.pyx":192
  2785. * cdef uint8_t _protected_table[16]
  2786. *
  2787. * def __init__(self, *, str safe='', str protected='', bint qs=False): # <<<<<<<<<<<<<<
  2788. * cdef Py_UCS4 ch
  2789. *
  2790. */
  2791. /* Python wrapper */
  2792. static int __pyx_pw_4yarl_8_quoting_7_Quoter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2793. static int __pyx_pw_4yarl_8_quoting_7_Quoter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2794. PyObject *__pyx_v_safe = 0;
  2795. PyObject *__pyx_v_protected = 0;
  2796. int __pyx_v_qs;
  2797. int __pyx_r;
  2798. __Pyx_RefNannyDeclarations
  2799. __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  2800. {
  2801. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_safe,&__pyx_n_s_protected,&__pyx_n_s_qs,0};
  2802. PyObject* values[3] = {0,0,0};
  2803. values[0] = ((PyObject*)__pyx_kp_u_);
  2804. values[1] = ((PyObject*)__pyx_kp_u_);
  2805. if (unlikely(__pyx_kwds)) {
  2806. Py_ssize_t kw_args;
  2807. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  2808. switch (pos_args) {
  2809. case 0: break;
  2810. default: goto __pyx_L5_argtuple_error;
  2811. }
  2812. kw_args = PyDict_Size(__pyx_kwds);
  2813. if (kw_args > 0 && likely(kw_args <= 3)) {
  2814. Py_ssize_t index;
  2815. for (index = 0; index < 3 && kw_args > 0; index++) {
  2816. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
  2817. if (value) { values[index] = value; kw_args--; }
  2818. }
  2819. }
  2820. if (unlikely(kw_args > 0)) {
  2821. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "__init__") < 0)) __PYX_ERR(0, 192, __pyx_L3_error)
  2822. }
  2823. } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
  2824. goto __pyx_L5_argtuple_error;
  2825. } else {
  2826. }
  2827. __pyx_v_safe = ((PyObject*)values[0]);
  2828. __pyx_v_protected = ((PyObject*)values[1]);
  2829. if (values[2]) {
  2830. __pyx_v_qs = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_qs == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 192, __pyx_L3_error)
  2831. } else {
  2832. __pyx_v_qs = ((int)0);
  2833. }
  2834. }
  2835. goto __pyx_L4_argument_unpacking_done;
  2836. __pyx_L5_argtuple_error:;
  2837. __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 192, __pyx_L3_error)
  2838. __pyx_L3_error:;
  2839. __Pyx_AddTraceback("yarl._quoting._Quoter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2840. __Pyx_RefNannyFinishContext();
  2841. return -1;
  2842. __pyx_L4_argument_unpacking_done:;
  2843. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_safe), (&PyUnicode_Type), 1, "safe", 1))) __PYX_ERR(0, 192, __pyx_L1_error)
  2844. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_protected), (&PyUnicode_Type), 1, "protected", 1))) __PYX_ERR(0, 192, __pyx_L1_error)
  2845. __pyx_r = __pyx_pf_4yarl_8_quoting_7_Quoter___init__(((struct __pyx_obj_4yarl_8_quoting__Quoter *)__pyx_v_self), __pyx_v_safe, __pyx_v_protected, __pyx_v_qs);
  2846. /* function exit code */
  2847. goto __pyx_L0;
  2848. __pyx_L1_error:;
  2849. __pyx_r = -1;
  2850. __pyx_L0:;
  2851. __Pyx_RefNannyFinishContext();
  2852. return __pyx_r;
  2853. }
  2854. static int __pyx_pf_4yarl_8_quoting_7_Quoter___init__(struct __pyx_obj_4yarl_8_quoting__Quoter *__pyx_v_self, PyObject *__pyx_v_safe, PyObject *__pyx_v_protected, int __pyx_v_qs) {
  2855. Py_UCS4 __pyx_v_ch;
  2856. int __pyx_r;
  2857. __Pyx_RefNannyDeclarations
  2858. int __pyx_t_1;
  2859. PyObject *__pyx_t_2 = NULL;
  2860. Py_ssize_t __pyx_t_3;
  2861. Py_ssize_t __pyx_t_4;
  2862. void *__pyx_t_5;
  2863. int __pyx_t_6;
  2864. int __pyx_t_7;
  2865. Py_ssize_t __pyx_t_8;
  2866. PyObject *__pyx_t_9 = NULL;
  2867. __Pyx_RefNannySetupContext("__init__", 0);
  2868. /* "yarl/_quoting.pyx":195
  2869. * cdef Py_UCS4 ch
  2870. *
  2871. * self._qs = qs # <<<<<<<<<<<<<<
  2872. *
  2873. * if not self._qs:
  2874. */
  2875. __pyx_v_self->_qs = __pyx_v_qs;
  2876. /* "yarl/_quoting.pyx":197
  2877. * self._qs = qs
  2878. *
  2879. * if not self._qs: # <<<<<<<<<<<<<<
  2880. * memcpy(self._safe_table,
  2881. * ALLOWED_NOTQS_TABLE,
  2882. */
  2883. __pyx_t_1 = ((!(__pyx_v_self->_qs != 0)) != 0);
  2884. if (__pyx_t_1) {
  2885. /* "yarl/_quoting.pyx":198
  2886. *
  2887. * if not self._qs:
  2888. * memcpy(self._safe_table, # <<<<<<<<<<<<<<
  2889. * ALLOWED_NOTQS_TABLE,
  2890. * sizeof(self._safe_table))
  2891. */
  2892. (void)(memcpy(__pyx_v_self->_safe_table, __pyx_v_4yarl_8_quoting_ALLOWED_NOTQS_TABLE, (sizeof(__pyx_v_self->_safe_table))));
  2893. /* "yarl/_quoting.pyx":197
  2894. * self._qs = qs
  2895. *
  2896. * if not self._qs: # <<<<<<<<<<<<<<
  2897. * memcpy(self._safe_table,
  2898. * ALLOWED_NOTQS_TABLE,
  2899. */
  2900. goto __pyx_L3;
  2901. }
  2902. /* "yarl/_quoting.pyx":202
  2903. * sizeof(self._safe_table))
  2904. * else:
  2905. * memcpy(self._safe_table, # <<<<<<<<<<<<<<
  2906. * ALLOWED_TABLE,
  2907. * sizeof(self._safe_table))
  2908. */
  2909. /*else*/ {
  2910. /* "yarl/_quoting.pyx":204
  2911. * memcpy(self._safe_table,
  2912. * ALLOWED_TABLE,
  2913. * sizeof(self._safe_table)) # <<<<<<<<<<<<<<
  2914. * for ch in safe:
  2915. * if ord(ch) > 127:
  2916. */
  2917. (void)(memcpy(__pyx_v_self->_safe_table, __pyx_v_4yarl_8_quoting_ALLOWED_TABLE, (sizeof(__pyx_v_self->_safe_table))));
  2918. }
  2919. __pyx_L3:;
  2920. /* "yarl/_quoting.pyx":205
  2921. * ALLOWED_TABLE,
  2922. * sizeof(self._safe_table))
  2923. * for ch in safe: # <<<<<<<<<<<<<<
  2924. * if ord(ch) > 127:
  2925. * raise ValueError("Only safe symbols with ORD < 128 are allowed")
  2926. */
  2927. if (unlikely(__pyx_v_safe == Py_None)) {
  2928. PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
  2929. __PYX_ERR(0, 205, __pyx_L1_error)
  2930. }
  2931. __Pyx_INCREF(__pyx_v_safe);
  2932. __pyx_t_2 = __pyx_v_safe;
  2933. __pyx_t_7 = __Pyx_init_unicode_iteration(__pyx_t_2, (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 205, __pyx_L1_error)
  2934. for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_4; __pyx_t_8++) {
  2935. __pyx_t_3 = __pyx_t_8;
  2936. __pyx_v_ch = __Pyx_PyUnicode_READ(__pyx_t_6, __pyx_t_5, __pyx_t_3);
  2937. /* "yarl/_quoting.pyx":206
  2938. * sizeof(self._safe_table))
  2939. * for ch in safe:
  2940. * if ord(ch) > 127: # <<<<<<<<<<<<<<
  2941. * raise ValueError("Only safe symbols with ORD < 128 are allowed")
  2942. * set_bit(self._safe_table, ch)
  2943. */
  2944. __pyx_t_1 = ((((long)__pyx_v_ch) > 0x7F) != 0);
  2945. if (unlikely(__pyx_t_1)) {
  2946. /* "yarl/_quoting.pyx":207
  2947. * for ch in safe:
  2948. * if ord(ch) > 127:
  2949. * raise ValueError("Only safe symbols with ORD < 128 are allowed") # <<<<<<<<<<<<<<
  2950. * set_bit(self._safe_table, ch)
  2951. *
  2952. */
  2953. __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 207, __pyx_L1_error)
  2954. __Pyx_GOTREF(__pyx_t_9);
  2955. __Pyx_Raise(__pyx_t_9, 0, 0, 0);
  2956. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  2957. __PYX_ERR(0, 207, __pyx_L1_error)
  2958. /* "yarl/_quoting.pyx":206
  2959. * sizeof(self._safe_table))
  2960. * for ch in safe:
  2961. * if ord(ch) > 127: # <<<<<<<<<<<<<<
  2962. * raise ValueError("Only safe symbols with ORD < 128 are allowed")
  2963. * set_bit(self._safe_table, ch)
  2964. */
  2965. }
  2966. /* "yarl/_quoting.pyx":208
  2967. * if ord(ch) > 127:
  2968. * raise ValueError("Only safe symbols with ORD < 128 are allowed")
  2969. * set_bit(self._safe_table, ch) # <<<<<<<<<<<<<<
  2970. *
  2971. * memset(self._protected_table, 0, sizeof(self._protected_table))
  2972. */
  2973. __pyx_f_4yarl_8_quoting_set_bit(__pyx_v_self->_safe_table, __pyx_v_ch);
  2974. }
  2975. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2976. /* "yarl/_quoting.pyx":210
  2977. * set_bit(self._safe_table, ch)
  2978. *
  2979. * memset(self._protected_table, 0, sizeof(self._protected_table)) # <<<<<<<<<<<<<<
  2980. * for ch in protected:
  2981. * if ord(ch) > 127:
  2982. */
  2983. (void)(memset(__pyx_v_self->_protected_table, 0, (sizeof(__pyx_v_self->_protected_table))));
  2984. /* "yarl/_quoting.pyx":211
  2985. *
  2986. * memset(self._protected_table, 0, sizeof(self._protected_table))
  2987. * for ch in protected: # <<<<<<<<<<<<<<
  2988. * if ord(ch) > 127:
  2989. * raise ValueError("Only safe symbols with ORD < 128 are allowed")
  2990. */
  2991. if (unlikely(__pyx_v_protected == Py_None)) {
  2992. PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
  2993. __PYX_ERR(0, 211, __pyx_L1_error)
  2994. }
  2995. __Pyx_INCREF(__pyx_v_protected);
  2996. __pyx_t_2 = __pyx_v_protected;
  2997. __pyx_t_7 = __Pyx_init_unicode_iteration(__pyx_t_2, (&__pyx_t_3), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 211, __pyx_L1_error)
  2998. for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_3; __pyx_t_8++) {
  2999. __pyx_t_4 = __pyx_t_8;
  3000. __pyx_v_ch = __Pyx_PyUnicode_READ(__pyx_t_6, __pyx_t_5, __pyx_t_4);
  3001. /* "yarl/_quoting.pyx":212
  3002. * memset(self._protected_table, 0, sizeof(self._protected_table))
  3003. * for ch in protected:
  3004. * if ord(ch) > 127: # <<<<<<<<<<<<<<
  3005. * raise ValueError("Only safe symbols with ORD < 128 are allowed")
  3006. * set_bit(self._safe_table, ch)
  3007. */
  3008. __pyx_t_1 = ((((long)__pyx_v_ch) > 0x7F) != 0);
  3009. if (unlikely(__pyx_t_1)) {
  3010. /* "yarl/_quoting.pyx":213
  3011. * for ch in protected:
  3012. * if ord(ch) > 127:
  3013. * raise ValueError("Only safe symbols with ORD < 128 are allowed") # <<<<<<<<<<<<<<
  3014. * set_bit(self._safe_table, ch)
  3015. * set_bit(self._protected_table, ch)
  3016. */
  3017. __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 213, __pyx_L1_error)
  3018. __Pyx_GOTREF(__pyx_t_9);
  3019. __Pyx_Raise(__pyx_t_9, 0, 0, 0);
  3020. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  3021. __PYX_ERR(0, 213, __pyx_L1_error)
  3022. /* "yarl/_quoting.pyx":212
  3023. * memset(self._protected_table, 0, sizeof(self._protected_table))
  3024. * for ch in protected:
  3025. * if ord(ch) > 127: # <<<<<<<<<<<<<<
  3026. * raise ValueError("Only safe symbols with ORD < 128 are allowed")
  3027. * set_bit(self._safe_table, ch)
  3028. */
  3029. }
  3030. /* "yarl/_quoting.pyx":214
  3031. * if ord(ch) > 127:
  3032. * raise ValueError("Only safe symbols with ORD < 128 are allowed")
  3033. * set_bit(self._safe_table, ch) # <<<<<<<<<<<<<<
  3034. * set_bit(self._protected_table, ch)
  3035. *
  3036. */
  3037. __pyx_f_4yarl_8_quoting_set_bit(__pyx_v_self->_safe_table, __pyx_v_ch);
  3038. /* "yarl/_quoting.pyx":215
  3039. * raise ValueError("Only safe symbols with ORD < 128 are allowed")
  3040. * set_bit(self._safe_table, ch)
  3041. * set_bit(self._protected_table, ch) # <<<<<<<<<<<<<<
  3042. *
  3043. * def __call__(self, val):
  3044. */
  3045. __pyx_f_4yarl_8_quoting_set_bit(__pyx_v_self->_protected_table, __pyx_v_ch);
  3046. }
  3047. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3048. /* "yarl/_quoting.pyx":192
  3049. * cdef uint8_t _protected_table[16]
  3050. *
  3051. * def __init__(self, *, str safe='', str protected='', bint qs=False): # <<<<<<<<<<<<<<
  3052. * cdef Py_UCS4 ch
  3053. *
  3054. */
  3055. /* function exit code */
  3056. __pyx_r = 0;
  3057. goto __pyx_L0;
  3058. __pyx_L1_error:;
  3059. __Pyx_XDECREF(__pyx_t_2);
  3060. __Pyx_XDECREF(__pyx_t_9);
  3061. __Pyx_AddTraceback("yarl._quoting._Quoter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3062. __pyx_r = -1;
  3063. __pyx_L0:;
  3064. __Pyx_RefNannyFinishContext();
  3065. return __pyx_r;
  3066. }
  3067. /* "yarl/_quoting.pyx":217
  3068. * set_bit(self._protected_table, ch)
  3069. *
  3070. * def __call__(self, val): # <<<<<<<<<<<<<<
  3071. * cdef Writer writer
  3072. * if val is None:
  3073. */
  3074. /* Python wrapper */
  3075. static PyObject *__pyx_pw_4yarl_8_quoting_7_Quoter_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  3076. static PyObject *__pyx_pw_4yarl_8_quoting_7_Quoter_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  3077. PyObject *__pyx_v_val = 0;
  3078. PyObject *__pyx_r = 0;
  3079. __Pyx_RefNannyDeclarations
  3080. __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  3081. {
  3082. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_val,0};
  3083. PyObject* values[1] = {0};
  3084. if (unlikely(__pyx_kwds)) {
  3085. Py_ssize_t kw_args;
  3086. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  3087. switch (pos_args) {
  3088. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3089. CYTHON_FALLTHROUGH;
  3090. case 0: break;
  3091. default: goto __pyx_L5_argtuple_error;
  3092. }
  3093. kw_args = PyDict_Size(__pyx_kwds);
  3094. switch (pos_args) {
  3095. case 0:
  3096. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_val)) != 0)) kw_args--;
  3097. else goto __pyx_L5_argtuple_error;
  3098. }
  3099. if (unlikely(kw_args > 0)) {
  3100. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) __PYX_ERR(0, 217, __pyx_L3_error)
  3101. }
  3102. } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
  3103. goto __pyx_L5_argtuple_error;
  3104. } else {
  3105. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3106. }
  3107. __pyx_v_val = values[0];
  3108. }
  3109. goto __pyx_L4_argument_unpacking_done;
  3110. __pyx_L5_argtuple_error:;
  3111. __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 217, __pyx_L3_error)
  3112. __pyx_L3_error:;
  3113. __Pyx_AddTraceback("yarl._quoting._Quoter.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3114. __Pyx_RefNannyFinishContext();
  3115. return NULL;
  3116. __pyx_L4_argument_unpacking_done:;
  3117. __pyx_r = __pyx_pf_4yarl_8_quoting_7_Quoter_2__call__(((struct __pyx_obj_4yarl_8_quoting__Quoter *)__pyx_v_self), __pyx_v_val);
  3118. /* function exit code */
  3119. __Pyx_RefNannyFinishContext();
  3120. return __pyx_r;
  3121. }
  3122. static PyObject *__pyx_pf_4yarl_8_quoting_7_Quoter_2__call__(struct __pyx_obj_4yarl_8_quoting__Quoter *__pyx_v_self, PyObject *__pyx_v_val) {
  3123. struct __pyx_t_4yarl_8_quoting_Writer __pyx_v_writer;
  3124. PyObject *__pyx_r = NULL;
  3125. __Pyx_RefNannyDeclarations
  3126. int __pyx_t_1;
  3127. int __pyx_t_2;
  3128. PyObject *__pyx_t_3 = NULL;
  3129. int __pyx_t_4;
  3130. int __pyx_t_5;
  3131. char const *__pyx_t_6;
  3132. PyObject *__pyx_t_7 = NULL;
  3133. PyObject *__pyx_t_8 = NULL;
  3134. PyObject *__pyx_t_9 = NULL;
  3135. PyObject *__pyx_t_10 = NULL;
  3136. PyObject *__pyx_t_11 = NULL;
  3137. PyObject *__pyx_t_12 = NULL;
  3138. __Pyx_RefNannySetupContext("__call__", 0);
  3139. __Pyx_INCREF(__pyx_v_val);
  3140. /* "yarl/_quoting.pyx":219
  3141. * def __call__(self, val):
  3142. * cdef Writer writer
  3143. * if val is None: # <<<<<<<<<<<<<<
  3144. * return None
  3145. * if type(val) is not str:
  3146. */
  3147. __pyx_t_1 = (__pyx_v_val == Py_None);
  3148. __pyx_t_2 = (__pyx_t_1 != 0);
  3149. if (__pyx_t_2) {
  3150. /* "yarl/_quoting.pyx":220
  3151. * cdef Writer writer
  3152. * if val is None:
  3153. * return None # <<<<<<<<<<<<<<
  3154. * if type(val) is not str:
  3155. * if isinstance(val, str):
  3156. */
  3157. __Pyx_XDECREF(__pyx_r);
  3158. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  3159. goto __pyx_L0;
  3160. /* "yarl/_quoting.pyx":219
  3161. * def __call__(self, val):
  3162. * cdef Writer writer
  3163. * if val is None: # <<<<<<<<<<<<<<
  3164. * return None
  3165. * if type(val) is not str:
  3166. */
  3167. }
  3168. /* "yarl/_quoting.pyx":221
  3169. * if val is None:
  3170. * return None
  3171. * if type(val) is not str: # <<<<<<<<<<<<<<
  3172. * if isinstance(val, str):
  3173. * # derived from str
  3174. */
  3175. __pyx_t_2 = (((PyObject *)Py_TYPE(__pyx_v_val)) != ((PyObject *)(&PyUnicode_Type)));
  3176. __pyx_t_1 = (__pyx_t_2 != 0);
  3177. if (__pyx_t_1) {
  3178. /* "yarl/_quoting.pyx":222
  3179. * return None
  3180. * if type(val) is not str:
  3181. * if isinstance(val, str): # <<<<<<<<<<<<<<
  3182. * # derived from str
  3183. * val = str(val)
  3184. */
  3185. __pyx_t_1 = PyUnicode_Check(__pyx_v_val);
  3186. __pyx_t_2 = (__pyx_t_1 != 0);
  3187. if (likely(__pyx_t_2)) {
  3188. /* "yarl/_quoting.pyx":224
  3189. * if isinstance(val, str):
  3190. * # derived from str
  3191. * val = str(val) # <<<<<<<<<<<<<<
  3192. * else:
  3193. * raise TypeError("Argument should be str")
  3194. */
  3195. __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_val); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 224, __pyx_L1_error)
  3196. __Pyx_GOTREF(__pyx_t_3);
  3197. __Pyx_DECREF_SET(__pyx_v_val, __pyx_t_3);
  3198. __pyx_t_3 = 0;
  3199. /* "yarl/_quoting.pyx":222
  3200. * return None
  3201. * if type(val) is not str:
  3202. * if isinstance(val, str): # <<<<<<<<<<<<<<
  3203. * # derived from str
  3204. * val = str(val)
  3205. */
  3206. goto __pyx_L5;
  3207. }
  3208. /* "yarl/_quoting.pyx":226
  3209. * val = str(val)
  3210. * else:
  3211. * raise TypeError("Argument should be str") # <<<<<<<<<<<<<<
  3212. * _init_writer(&writer)
  3213. * try:
  3214. */
  3215. /*else*/ {
  3216. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 226, __pyx_L1_error)
  3217. __Pyx_GOTREF(__pyx_t_3);
  3218. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  3219. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3220. __PYX_ERR(0, 226, __pyx_L1_error)
  3221. }
  3222. __pyx_L5:;
  3223. /* "yarl/_quoting.pyx":221
  3224. * if val is None:
  3225. * return None
  3226. * if type(val) is not str: # <<<<<<<<<<<<<<
  3227. * if isinstance(val, str):
  3228. * # derived from str
  3229. */
  3230. }
  3231. /* "yarl/_quoting.pyx":227
  3232. * else:
  3233. * raise TypeError("Argument should be str")
  3234. * _init_writer(&writer) # <<<<<<<<<<<<<<
  3235. * try:
  3236. * return self._do_quote(<str>val, &writer)
  3237. */
  3238. __pyx_f_4yarl_8_quoting__init_writer((&__pyx_v_writer));
  3239. /* "yarl/_quoting.pyx":228
  3240. * raise TypeError("Argument should be str")
  3241. * _init_writer(&writer)
  3242. * try: # <<<<<<<<<<<<<<
  3243. * return self._do_quote(<str>val, &writer)
  3244. * finally:
  3245. */
  3246. /*try:*/ {
  3247. /* "yarl/_quoting.pyx":229
  3248. * _init_writer(&writer)
  3249. * try:
  3250. * return self._do_quote(<str>val, &writer) # <<<<<<<<<<<<<<
  3251. * finally:
  3252. * _release_writer(&writer)
  3253. */
  3254. __Pyx_XDECREF(__pyx_r);
  3255. __pyx_t_3 = ((struct __pyx_vtabstruct_4yarl_8_quoting__Quoter *)__pyx_v_self->__pyx_vtab)->_do_quote(__pyx_v_self, ((PyObject*)__pyx_v_val), (&__pyx_v_writer)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 229, __pyx_L7_error)
  3256. __Pyx_GOTREF(__pyx_t_3);
  3257. __pyx_r = __pyx_t_3;
  3258. __pyx_t_3 = 0;
  3259. goto __pyx_L6_return;
  3260. }
  3261. /* "yarl/_quoting.pyx":231
  3262. * return self._do_quote(<str>val, &writer)
  3263. * finally:
  3264. * _release_writer(&writer) # <<<<<<<<<<<<<<
  3265. *
  3266. * cdef str _do_quote(self, str val, Writer *writer):
  3267. */
  3268. /*finally:*/ {
  3269. __pyx_L7_error:;
  3270. /*exception exit:*/{
  3271. __Pyx_PyThreadState_declare
  3272. __Pyx_PyThreadState_assign
  3273. __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
  3274. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3275. if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
  3276. if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
  3277. __Pyx_XGOTREF(__pyx_t_7);
  3278. __Pyx_XGOTREF(__pyx_t_8);
  3279. __Pyx_XGOTREF(__pyx_t_9);
  3280. __Pyx_XGOTREF(__pyx_t_10);
  3281. __Pyx_XGOTREF(__pyx_t_11);
  3282. __Pyx_XGOTREF(__pyx_t_12);
  3283. __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
  3284. {
  3285. __pyx_f_4yarl_8_quoting__release_writer((&__pyx_v_writer));
  3286. }
  3287. if (PY_MAJOR_VERSION >= 3) {
  3288. __Pyx_XGIVEREF(__pyx_t_10);
  3289. __Pyx_XGIVEREF(__pyx_t_11);
  3290. __Pyx_XGIVEREF(__pyx_t_12);
  3291. __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
  3292. }
  3293. __Pyx_XGIVEREF(__pyx_t_7);
  3294. __Pyx_XGIVEREF(__pyx_t_8);
  3295. __Pyx_XGIVEREF(__pyx_t_9);
  3296. __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
  3297. __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
  3298. __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
  3299. goto __pyx_L1_error;
  3300. }
  3301. __pyx_L6_return: {
  3302. __pyx_t_12 = __pyx_r;
  3303. __pyx_r = 0;
  3304. __pyx_f_4yarl_8_quoting__release_writer((&__pyx_v_writer));
  3305. __pyx_r = __pyx_t_12;
  3306. __pyx_t_12 = 0;
  3307. goto __pyx_L0;
  3308. }
  3309. }
  3310. /* "yarl/_quoting.pyx":217
  3311. * set_bit(self._protected_table, ch)
  3312. *
  3313. * def __call__(self, val): # <<<<<<<<<<<<<<
  3314. * cdef Writer writer
  3315. * if val is None:
  3316. */
  3317. /* function exit code */
  3318. __pyx_L1_error:;
  3319. __Pyx_XDECREF(__pyx_t_3);
  3320. __Pyx_AddTraceback("yarl._quoting._Quoter.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3321. __pyx_r = NULL;
  3322. __pyx_L0:;
  3323. __Pyx_XDECREF(__pyx_v_val);
  3324. __Pyx_XGIVEREF(__pyx_r);
  3325. __Pyx_RefNannyFinishContext();
  3326. return __pyx_r;
  3327. }
  3328. /* "yarl/_quoting.pyx":233
  3329. * _release_writer(&writer)
  3330. *
  3331. * cdef str _do_quote(self, str val, Writer *writer): # <<<<<<<<<<<<<<
  3332. * cdef Py_UCS4 ch
  3333. * cdef int has_pct = 0
  3334. */
  3335. static PyObject *__pyx_f_4yarl_8_quoting_7_Quoter__do_quote(struct __pyx_obj_4yarl_8_quoting__Quoter *__pyx_v_self, PyObject *__pyx_v_val, struct __pyx_t_4yarl_8_quoting_Writer *__pyx_v_writer) {
  3336. Py_UCS4 __pyx_v_ch;
  3337. int __pyx_v_has_pct;
  3338. Py_UCS4 __pyx_v_pct[2];
  3339. CYTHON_UNUSED int __pyx_v_idx;
  3340. PyObject *__pyx_r = NULL;
  3341. __Pyx_RefNannyDeclarations
  3342. PyObject *__pyx_t_1 = NULL;
  3343. Py_ssize_t __pyx_t_2;
  3344. Py_ssize_t __pyx_t_3;
  3345. void *__pyx_t_4;
  3346. int __pyx_t_5;
  3347. int __pyx_t_6;
  3348. Py_ssize_t __pyx_t_7;
  3349. int __pyx_t_8;
  3350. PyObject *__pyx_t_9 = NULL;
  3351. __Pyx_RefNannySetupContext("_do_quote", 0);
  3352. /* "yarl/_quoting.pyx":235
  3353. * cdef str _do_quote(self, str val, Writer *writer):
  3354. * cdef Py_UCS4 ch
  3355. * cdef int has_pct = 0 # <<<<<<<<<<<<<<
  3356. * cdef Py_UCS4 pct[2]
  3357. * cdef int idx = 0
  3358. */
  3359. __pyx_v_has_pct = 0;
  3360. /* "yarl/_quoting.pyx":237
  3361. * cdef int has_pct = 0
  3362. * cdef Py_UCS4 pct[2]
  3363. * cdef int idx = 0 # <<<<<<<<<<<<<<
  3364. *
  3365. * for ch in val:
  3366. */
  3367. __pyx_v_idx = 0;
  3368. /* "yarl/_quoting.pyx":239
  3369. * cdef int idx = 0
  3370. *
  3371. * for ch in val: # <<<<<<<<<<<<<<
  3372. * if has_pct:
  3373. * pct[has_pct-1] = ch
  3374. */
  3375. if (unlikely(__pyx_v_val == Py_None)) {
  3376. PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
  3377. __PYX_ERR(0, 239, __pyx_L1_error)
  3378. }
  3379. __Pyx_INCREF(__pyx_v_val);
  3380. __pyx_t_1 = __pyx_v_val;
  3381. __pyx_t_6 = __Pyx_init_unicode_iteration(__pyx_t_1, (&__pyx_t_3), (&__pyx_t_4), (&__pyx_t_5)); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 239, __pyx_L1_error)
  3382. for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_3; __pyx_t_7++) {
  3383. __pyx_t_2 = __pyx_t_7;
  3384. __pyx_v_ch = __Pyx_PyUnicode_READ(__pyx_t_5, __pyx_t_4, __pyx_t_2);
  3385. /* "yarl/_quoting.pyx":240
  3386. *
  3387. * for ch in val:
  3388. * if has_pct: # <<<<<<<<<<<<<<
  3389. * pct[has_pct-1] = ch
  3390. * has_pct += 1
  3391. */
  3392. __pyx_t_8 = (__pyx_v_has_pct != 0);
  3393. if (__pyx_t_8) {
  3394. /* "yarl/_quoting.pyx":241
  3395. * for ch in val:
  3396. * if has_pct:
  3397. * pct[has_pct-1] = ch # <<<<<<<<<<<<<<
  3398. * has_pct += 1
  3399. * if has_pct == 3:
  3400. */
  3401. (__pyx_v_pct[(__pyx_v_has_pct - 1)]) = __pyx_v_ch;
  3402. /* "yarl/_quoting.pyx":242
  3403. * if has_pct:
  3404. * pct[has_pct-1] = ch
  3405. * has_pct += 1 # <<<<<<<<<<<<<<
  3406. * if has_pct == 3:
  3407. * ch = _restore_ch(pct[0], pct[1])
  3408. */
  3409. __pyx_v_has_pct = (__pyx_v_has_pct + 1);
  3410. /* "yarl/_quoting.pyx":243
  3411. * pct[has_pct-1] = ch
  3412. * has_pct += 1
  3413. * if has_pct == 3: # <<<<<<<<<<<<<<
  3414. * ch = _restore_ch(pct[0], pct[1])
  3415. * has_pct = 0
  3416. */
  3417. __pyx_t_8 = ((__pyx_v_has_pct == 3) != 0);
  3418. if (__pyx_t_8) {
  3419. /* "yarl/_quoting.pyx":244
  3420. * has_pct += 1
  3421. * if has_pct == 3:
  3422. * ch = _restore_ch(pct[0], pct[1]) # <<<<<<<<<<<<<<
  3423. * has_pct = 0
  3424. *
  3425. */
  3426. __pyx_v_ch = __pyx_f_4yarl_8_quoting__restore_ch((__pyx_v_pct[0]), (__pyx_v_pct[1]));
  3427. /* "yarl/_quoting.pyx":245
  3428. * if has_pct == 3:
  3429. * ch = _restore_ch(pct[0], pct[1])
  3430. * has_pct = 0 # <<<<<<<<<<<<<<
  3431. *
  3432. * if ch == <Py_UCS4>-1:
  3433. */
  3434. __pyx_v_has_pct = 0;
  3435. /* "yarl/_quoting.pyx":247
  3436. * has_pct = 0
  3437. *
  3438. * if ch == <Py_UCS4>-1: # <<<<<<<<<<<<<<
  3439. * if _write_percent(writer) < 0:
  3440. * raise
  3441. */
  3442. __pyx_t_8 = ((__pyx_v_ch == ((Py_UCS4)-1L)) != 0);
  3443. if (__pyx_t_8) {
  3444. /* "yarl/_quoting.pyx":248
  3445. *
  3446. * if ch == <Py_UCS4>-1:
  3447. * if _write_percent(writer) < 0: # <<<<<<<<<<<<<<
  3448. * raise
  3449. * if self._write(writer, pct[0]) < 0:
  3450. */
  3451. __pyx_t_8 = ((__pyx_f_4yarl_8_quoting__write_percent(__pyx_v_writer) < 0) != 0);
  3452. if (unlikely(__pyx_t_8)) {
  3453. /* "yarl/_quoting.pyx":249
  3454. * if ch == <Py_UCS4>-1:
  3455. * if _write_percent(writer) < 0:
  3456. * raise # <<<<<<<<<<<<<<
  3457. * if self._write(writer, pct[0]) < 0:
  3458. * raise
  3459. */
  3460. __Pyx_ReraiseException(); __PYX_ERR(0, 249, __pyx_L1_error)
  3461. /* "yarl/_quoting.pyx":248
  3462. *
  3463. * if ch == <Py_UCS4>-1:
  3464. * if _write_percent(writer) < 0: # <<<<<<<<<<<<<<
  3465. * raise
  3466. * if self._write(writer, pct[0]) < 0:
  3467. */
  3468. }
  3469. /* "yarl/_quoting.pyx":250
  3470. * if _write_percent(writer) < 0:
  3471. * raise
  3472. * if self._write(writer, pct[0]) < 0: # <<<<<<<<<<<<<<
  3473. * raise
  3474. * if self._write(writer, pct[1]) < 0:
  3475. */
  3476. __pyx_t_8 = ((__pyx_f_4yarl_8_quoting_7_Quoter__write(__pyx_v_self, __pyx_v_writer, (__pyx_v_pct[0])) < 0) != 0);
  3477. if (unlikely(__pyx_t_8)) {
  3478. /* "yarl/_quoting.pyx":251
  3479. * raise
  3480. * if self._write(writer, pct[0]) < 0:
  3481. * raise # <<<<<<<<<<<<<<
  3482. * if self._write(writer, pct[1]) < 0:
  3483. * raise
  3484. */
  3485. __Pyx_ReraiseException(); __PYX_ERR(0, 251, __pyx_L1_error)
  3486. /* "yarl/_quoting.pyx":250
  3487. * if _write_percent(writer) < 0:
  3488. * raise
  3489. * if self._write(writer, pct[0]) < 0: # <<<<<<<<<<<<<<
  3490. * raise
  3491. * if self._write(writer, pct[1]) < 0:
  3492. */
  3493. }
  3494. /* "yarl/_quoting.pyx":252
  3495. * if self._write(writer, pct[0]) < 0:
  3496. * raise
  3497. * if self._write(writer, pct[1]) < 0: # <<<<<<<<<<<<<<
  3498. * raise
  3499. * continue
  3500. */
  3501. __pyx_t_8 = ((__pyx_f_4yarl_8_quoting_7_Quoter__write(__pyx_v_self, __pyx_v_writer, (__pyx_v_pct[1])) < 0) != 0);
  3502. if (unlikely(__pyx_t_8)) {
  3503. /* "yarl/_quoting.pyx":253
  3504. * raise
  3505. * if self._write(writer, pct[1]) < 0:
  3506. * raise # <<<<<<<<<<<<<<
  3507. * continue
  3508. *
  3509. */
  3510. __Pyx_ReraiseException(); __PYX_ERR(0, 253, __pyx_L1_error)
  3511. /* "yarl/_quoting.pyx":252
  3512. * if self._write(writer, pct[0]) < 0:
  3513. * raise
  3514. * if self._write(writer, pct[1]) < 0: # <<<<<<<<<<<<<<
  3515. * raise
  3516. * continue
  3517. */
  3518. }
  3519. /* "yarl/_quoting.pyx":254
  3520. * if self._write(writer, pct[1]) < 0:
  3521. * raise
  3522. * continue # <<<<<<<<<<<<<<
  3523. *
  3524. * if ch < 128:
  3525. */
  3526. goto __pyx_L3_continue;
  3527. /* "yarl/_quoting.pyx":247
  3528. * has_pct = 0
  3529. *
  3530. * if ch == <Py_UCS4>-1: # <<<<<<<<<<<<<<
  3531. * if _write_percent(writer) < 0:
  3532. * raise
  3533. */
  3534. }
  3535. /* "yarl/_quoting.pyx":256
  3536. * continue
  3537. *
  3538. * if ch < 128: # <<<<<<<<<<<<<<
  3539. * if bit_at(self._protected_table, ch):
  3540. * if _write_pct(writer, ch, True) < 0:
  3541. */
  3542. __pyx_t_8 = ((__pyx_v_ch < 0x80) != 0);
  3543. if (__pyx_t_8) {
  3544. /* "yarl/_quoting.pyx":257
  3545. *
  3546. * if ch < 128:
  3547. * if bit_at(self._protected_table, ch): # <<<<<<<<<<<<<<
  3548. * if _write_pct(writer, ch, True) < 0:
  3549. * raise
  3550. */
  3551. __pyx_t_8 = (__pyx_f_4yarl_8_quoting_bit_at(__pyx_v_self->_protected_table, __pyx_v_ch) != 0);
  3552. if (__pyx_t_8) {
  3553. /* "yarl/_quoting.pyx":258
  3554. * if ch < 128:
  3555. * if bit_at(self._protected_table, ch):
  3556. * if _write_pct(writer, ch, True) < 0: # <<<<<<<<<<<<<<
  3557. * raise
  3558. * continue
  3559. */
  3560. __pyx_t_8 = ((__pyx_f_4yarl_8_quoting__write_pct(__pyx_v_writer, __pyx_v_ch, 1) < 0) != 0);
  3561. if (unlikely(__pyx_t_8)) {
  3562. /* "yarl/_quoting.pyx":259
  3563. * if bit_at(self._protected_table, ch):
  3564. * if _write_pct(writer, ch, True) < 0:
  3565. * raise # <<<<<<<<<<<<<<
  3566. * continue
  3567. *
  3568. */
  3569. __Pyx_ReraiseException(); __PYX_ERR(0, 259, __pyx_L1_error)
  3570. /* "yarl/_quoting.pyx":258
  3571. * if ch < 128:
  3572. * if bit_at(self._protected_table, ch):
  3573. * if _write_pct(writer, ch, True) < 0: # <<<<<<<<<<<<<<
  3574. * raise
  3575. * continue
  3576. */
  3577. }
  3578. /* "yarl/_quoting.pyx":260
  3579. * if _write_pct(writer, ch, True) < 0:
  3580. * raise
  3581. * continue # <<<<<<<<<<<<<<
  3582. *
  3583. * if bit_at(self._safe_table, ch):
  3584. */
  3585. goto __pyx_L3_continue;
  3586. /* "yarl/_quoting.pyx":257
  3587. *
  3588. * if ch < 128:
  3589. * if bit_at(self._protected_table, ch): # <<<<<<<<<<<<<<
  3590. * if _write_pct(writer, ch, True) < 0:
  3591. * raise
  3592. */
  3593. }
  3594. /* "yarl/_quoting.pyx":262
  3595. * continue
  3596. *
  3597. * if bit_at(self._safe_table, ch): # <<<<<<<<<<<<<<
  3598. * if _write_char(writer, ch, True) < 0:
  3599. * raise
  3600. */
  3601. __pyx_t_8 = (__pyx_f_4yarl_8_quoting_bit_at(__pyx_v_self->_safe_table, __pyx_v_ch) != 0);
  3602. if (__pyx_t_8) {
  3603. /* "yarl/_quoting.pyx":263
  3604. *
  3605. * if bit_at(self._safe_table, ch):
  3606. * if _write_char(writer, ch, True) < 0: # <<<<<<<<<<<<<<
  3607. * raise
  3608. * continue
  3609. */
  3610. __pyx_t_8 = ((__pyx_f_4yarl_8_quoting__write_char(__pyx_v_writer, __pyx_v_ch, 1) < 0) != 0);
  3611. if (unlikely(__pyx_t_8)) {
  3612. /* "yarl/_quoting.pyx":264
  3613. * if bit_at(self._safe_table, ch):
  3614. * if _write_char(writer, ch, True) < 0:
  3615. * raise # <<<<<<<<<<<<<<
  3616. * continue
  3617. *
  3618. */
  3619. __Pyx_ReraiseException(); __PYX_ERR(0, 264, __pyx_L1_error)
  3620. /* "yarl/_quoting.pyx":263
  3621. *
  3622. * if bit_at(self._safe_table, ch):
  3623. * if _write_char(writer, ch, True) < 0: # <<<<<<<<<<<<<<
  3624. * raise
  3625. * continue
  3626. */
  3627. }
  3628. /* "yarl/_quoting.pyx":265
  3629. * if _write_char(writer, ch, True) < 0:
  3630. * raise
  3631. * continue # <<<<<<<<<<<<<<
  3632. *
  3633. * if _write_pct_check(writer, ch, pct) < 0:
  3634. */
  3635. goto __pyx_L3_continue;
  3636. /* "yarl/_quoting.pyx":262
  3637. * continue
  3638. *
  3639. * if bit_at(self._safe_table, ch): # <<<<<<<<<<<<<<
  3640. * if _write_char(writer, ch, True) < 0:
  3641. * raise
  3642. */
  3643. }
  3644. /* "yarl/_quoting.pyx":256
  3645. * continue
  3646. *
  3647. * if ch < 128: # <<<<<<<<<<<<<<
  3648. * if bit_at(self._protected_table, ch):
  3649. * if _write_pct(writer, ch, True) < 0:
  3650. */
  3651. }
  3652. /* "yarl/_quoting.pyx":267
  3653. * continue
  3654. *
  3655. * if _write_pct_check(writer, ch, pct) < 0: # <<<<<<<<<<<<<<
  3656. * raise
  3657. * continue
  3658. */
  3659. __pyx_t_8 = ((__pyx_f_4yarl_8_quoting__write_pct_check(__pyx_v_writer, __pyx_v_ch, __pyx_v_pct) < 0) != 0);
  3660. if (unlikely(__pyx_t_8)) {
  3661. /* "yarl/_quoting.pyx":268
  3662. *
  3663. * if _write_pct_check(writer, ch, pct) < 0:
  3664. * raise # <<<<<<<<<<<<<<
  3665. * continue
  3666. *
  3667. */
  3668. __Pyx_ReraiseException(); __PYX_ERR(0, 268, __pyx_L1_error)
  3669. /* "yarl/_quoting.pyx":267
  3670. * continue
  3671. *
  3672. * if _write_pct_check(writer, ch, pct) < 0: # <<<<<<<<<<<<<<
  3673. * raise
  3674. * continue
  3675. */
  3676. }
  3677. /* "yarl/_quoting.pyx":243
  3678. * pct[has_pct-1] = ch
  3679. * has_pct += 1
  3680. * if has_pct == 3: # <<<<<<<<<<<<<<
  3681. * ch = _restore_ch(pct[0], pct[1])
  3682. * has_pct = 0
  3683. */
  3684. }
  3685. /* "yarl/_quoting.pyx":269
  3686. * if _write_pct_check(writer, ch, pct) < 0:
  3687. * raise
  3688. * continue # <<<<<<<<<<<<<<
  3689. *
  3690. * elif ch == '%':
  3691. */
  3692. goto __pyx_L3_continue;
  3693. /* "yarl/_quoting.pyx":240
  3694. *
  3695. * for ch in val:
  3696. * if has_pct: # <<<<<<<<<<<<<<
  3697. * pct[has_pct-1] = ch
  3698. * has_pct += 1
  3699. */
  3700. }
  3701. /* "yarl/_quoting.pyx":271
  3702. * continue
  3703. *
  3704. * elif ch == '%': # <<<<<<<<<<<<<<
  3705. * has_pct = 1
  3706. * continue
  3707. */
  3708. __pyx_t_8 = ((__pyx_v_ch == 37) != 0);
  3709. if (__pyx_t_8) {
  3710. /* "yarl/_quoting.pyx":272
  3711. *
  3712. * elif ch == '%':
  3713. * has_pct = 1 # <<<<<<<<<<<<<<
  3714. * continue
  3715. *
  3716. */
  3717. __pyx_v_has_pct = 1;
  3718. /* "yarl/_quoting.pyx":273
  3719. * elif ch == '%':
  3720. * has_pct = 1
  3721. * continue # <<<<<<<<<<<<<<
  3722. *
  3723. * if self._write(writer, ch) < 0:
  3724. */
  3725. goto __pyx_L3_continue;
  3726. /* "yarl/_quoting.pyx":271
  3727. * continue
  3728. *
  3729. * elif ch == '%': # <<<<<<<<<<<<<<
  3730. * has_pct = 1
  3731. * continue
  3732. */
  3733. }
  3734. /* "yarl/_quoting.pyx":275
  3735. * continue
  3736. *
  3737. * if self._write(writer, ch) < 0: # <<<<<<<<<<<<<<
  3738. * raise
  3739. *
  3740. */
  3741. __pyx_t_8 = ((__pyx_f_4yarl_8_quoting_7_Quoter__write(__pyx_v_self, __pyx_v_writer, __pyx_v_ch) < 0) != 0);
  3742. if (unlikely(__pyx_t_8)) {
  3743. /* "yarl/_quoting.pyx":276
  3744. *
  3745. * if self._write(writer, ch) < 0:
  3746. * raise # <<<<<<<<<<<<<<
  3747. *
  3748. * if has_pct:
  3749. */
  3750. __Pyx_ReraiseException(); __PYX_ERR(0, 276, __pyx_L1_error)
  3751. /* "yarl/_quoting.pyx":275
  3752. * continue
  3753. *
  3754. * if self._write(writer, ch) < 0: # <<<<<<<<<<<<<<
  3755. * raise
  3756. *
  3757. */
  3758. }
  3759. __pyx_L3_continue:;
  3760. }
  3761. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3762. /* "yarl/_quoting.pyx":278
  3763. * raise
  3764. *
  3765. * if has_pct: # <<<<<<<<<<<<<<
  3766. * if _write_percent(writer) < 0:
  3767. * raise
  3768. */
  3769. __pyx_t_8 = (__pyx_v_has_pct != 0);
  3770. if (__pyx_t_8) {
  3771. /* "yarl/_quoting.pyx":279
  3772. *
  3773. * if has_pct:
  3774. * if _write_percent(writer) < 0: # <<<<<<<<<<<<<<
  3775. * raise
  3776. * if has_pct > 1: # the value is 2
  3777. */
  3778. __pyx_t_8 = ((__pyx_f_4yarl_8_quoting__write_percent(__pyx_v_writer) < 0) != 0);
  3779. if (unlikely(__pyx_t_8)) {
  3780. /* "yarl/_quoting.pyx":280
  3781. * if has_pct:
  3782. * if _write_percent(writer) < 0:
  3783. * raise # <<<<<<<<<<<<<<
  3784. * if has_pct > 1: # the value is 2
  3785. * if self._write(writer, ch) < 0:
  3786. */
  3787. __Pyx_ReraiseException(); __PYX_ERR(0, 280, __pyx_L1_error)
  3788. /* "yarl/_quoting.pyx":279
  3789. *
  3790. * if has_pct:
  3791. * if _write_percent(writer) < 0: # <<<<<<<<<<<<<<
  3792. * raise
  3793. * if has_pct > 1: # the value is 2
  3794. */
  3795. }
  3796. /* "yarl/_quoting.pyx":281
  3797. * if _write_percent(writer) < 0:
  3798. * raise
  3799. * if has_pct > 1: # the value is 2 # <<<<<<<<<<<<<<
  3800. * if self._write(writer, ch) < 0:
  3801. * raise
  3802. */
  3803. __pyx_t_8 = ((__pyx_v_has_pct > 1) != 0);
  3804. if (__pyx_t_8) {
  3805. /* "yarl/_quoting.pyx":282
  3806. * raise
  3807. * if has_pct > 1: # the value is 2
  3808. * if self._write(writer, ch) < 0: # <<<<<<<<<<<<<<
  3809. * raise
  3810. *
  3811. */
  3812. __pyx_t_8 = ((__pyx_f_4yarl_8_quoting_7_Quoter__write(__pyx_v_self, __pyx_v_writer, __pyx_v_ch) < 0) != 0);
  3813. if (unlikely(__pyx_t_8)) {
  3814. /* "yarl/_quoting.pyx":283
  3815. * if has_pct > 1: # the value is 2
  3816. * if self._write(writer, ch) < 0:
  3817. * raise # <<<<<<<<<<<<<<
  3818. *
  3819. * if not writer.changed:
  3820. */
  3821. __Pyx_ReraiseException(); __PYX_ERR(0, 283, __pyx_L1_error)
  3822. /* "yarl/_quoting.pyx":282
  3823. * raise
  3824. * if has_pct > 1: # the value is 2
  3825. * if self._write(writer, ch) < 0: # <<<<<<<<<<<<<<
  3826. * raise
  3827. *
  3828. */
  3829. }
  3830. /* "yarl/_quoting.pyx":281
  3831. * if _write_percent(writer) < 0:
  3832. * raise
  3833. * if has_pct > 1: # the value is 2 # <<<<<<<<<<<<<<
  3834. * if self._write(writer, ch) < 0:
  3835. * raise
  3836. */
  3837. }
  3838. /* "yarl/_quoting.pyx":278
  3839. * raise
  3840. *
  3841. * if has_pct: # <<<<<<<<<<<<<<
  3842. * if _write_percent(writer) < 0:
  3843. * raise
  3844. */
  3845. }
  3846. /* "yarl/_quoting.pyx":285
  3847. * raise
  3848. *
  3849. * if not writer.changed: # <<<<<<<<<<<<<<
  3850. * return val
  3851. * else:
  3852. */
  3853. __pyx_t_8 = ((!(__pyx_v_writer->changed != 0)) != 0);
  3854. if (__pyx_t_8) {
  3855. /* "yarl/_quoting.pyx":286
  3856. *
  3857. * if not writer.changed:
  3858. * return val # <<<<<<<<<<<<<<
  3859. * else:
  3860. * return PyUnicode_DecodeASCII(writer.buf, writer.pos, "strict")
  3861. */
  3862. __Pyx_XDECREF(__pyx_r);
  3863. __Pyx_INCREF(__pyx_v_val);
  3864. __pyx_r = __pyx_v_val;
  3865. goto __pyx_L0;
  3866. /* "yarl/_quoting.pyx":285
  3867. * raise
  3868. *
  3869. * if not writer.changed: # <<<<<<<<<<<<<<
  3870. * return val
  3871. * else:
  3872. */
  3873. }
  3874. /* "yarl/_quoting.pyx":288
  3875. * return val
  3876. * else:
  3877. * return PyUnicode_DecodeASCII(writer.buf, writer.pos, "strict") # <<<<<<<<<<<<<<
  3878. *
  3879. * cdef inline int _write(self, Writer *writer, Py_UCS4 ch):
  3880. */
  3881. /*else*/ {
  3882. __Pyx_XDECREF(__pyx_r);
  3883. __pyx_t_9 = PyUnicode_DecodeASCII(__pyx_v_writer->buf, __pyx_v_writer->pos, ((char *)"strict")); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 288, __pyx_L1_error)
  3884. __Pyx_GOTREF(__pyx_t_9);
  3885. __pyx_r = ((PyObject*)__pyx_t_9);
  3886. __pyx_t_9 = 0;
  3887. goto __pyx_L0;
  3888. }
  3889. /* "yarl/_quoting.pyx":233
  3890. * _release_writer(&writer)
  3891. *
  3892. * cdef str _do_quote(self, str val, Writer *writer): # <<<<<<<<<<<<<<
  3893. * cdef Py_UCS4 ch
  3894. * cdef int has_pct = 0
  3895. */
  3896. /* function exit code */
  3897. __pyx_L1_error:;
  3898. __Pyx_XDECREF(__pyx_t_1);
  3899. __Pyx_XDECREF(__pyx_t_9);
  3900. __Pyx_AddTraceback("yarl._quoting._Quoter._do_quote", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3901. __pyx_r = 0;
  3902. __pyx_L0:;
  3903. __Pyx_XGIVEREF(__pyx_r);
  3904. __Pyx_RefNannyFinishContext();
  3905. return __pyx_r;
  3906. }
  3907. /* "yarl/_quoting.pyx":290
  3908. * return PyUnicode_DecodeASCII(writer.buf, writer.pos, "strict")
  3909. *
  3910. * cdef inline int _write(self, Writer *writer, Py_UCS4 ch): # <<<<<<<<<<<<<<
  3911. * if self._qs:
  3912. * if ch == ' ':
  3913. */
  3914. static CYTHON_INLINE int __pyx_f_4yarl_8_quoting_7_Quoter__write(struct __pyx_obj_4yarl_8_quoting__Quoter *__pyx_v_self, struct __pyx_t_4yarl_8_quoting_Writer *__pyx_v_writer, Py_UCS4 __pyx_v_ch) {
  3915. int __pyx_r;
  3916. __Pyx_RefNannyDeclarations
  3917. int __pyx_t_1;
  3918. int __pyx_t_2;
  3919. __Pyx_RefNannySetupContext("_write", 0);
  3920. /* "yarl/_quoting.pyx":291
  3921. *
  3922. * cdef inline int _write(self, Writer *writer, Py_UCS4 ch):
  3923. * if self._qs: # <<<<<<<<<<<<<<
  3924. * if ch == ' ':
  3925. * return _write_char(writer, '+', True)
  3926. */
  3927. __pyx_t_1 = (__pyx_v_self->_qs != 0);
  3928. if (__pyx_t_1) {
  3929. /* "yarl/_quoting.pyx":292
  3930. * cdef inline int _write(self, Writer *writer, Py_UCS4 ch):
  3931. * if self._qs:
  3932. * if ch == ' ': # <<<<<<<<<<<<<<
  3933. * return _write_char(writer, '+', True)
  3934. *
  3935. */
  3936. __pyx_t_1 = ((__pyx_v_ch == 32) != 0);
  3937. if (__pyx_t_1) {
  3938. /* "yarl/_quoting.pyx":293
  3939. * if self._qs:
  3940. * if ch == ' ':
  3941. * return _write_char(writer, '+', True) # <<<<<<<<<<<<<<
  3942. *
  3943. * if ch < 128 and bit_at(self._safe_table, ch):
  3944. */
  3945. __pyx_r = __pyx_f_4yarl_8_quoting__write_char(__pyx_v_writer, 43, 1);
  3946. goto __pyx_L0;
  3947. /* "yarl/_quoting.pyx":292
  3948. * cdef inline int _write(self, Writer *writer, Py_UCS4 ch):
  3949. * if self._qs:
  3950. * if ch == ' ': # <<<<<<<<<<<<<<
  3951. * return _write_char(writer, '+', True)
  3952. *
  3953. */
  3954. }
  3955. /* "yarl/_quoting.pyx":291
  3956. *
  3957. * cdef inline int _write(self, Writer *writer, Py_UCS4 ch):
  3958. * if self._qs: # <<<<<<<<<<<<<<
  3959. * if ch == ' ':
  3960. * return _write_char(writer, '+', True)
  3961. */
  3962. }
  3963. /* "yarl/_quoting.pyx":295
  3964. * return _write_char(writer, '+', True)
  3965. *
  3966. * if ch < 128 and bit_at(self._safe_table, ch): # <<<<<<<<<<<<<<
  3967. * return _write_char(writer, ch, False)
  3968. *
  3969. */
  3970. __pyx_t_2 = ((__pyx_v_ch < 0x80) != 0);
  3971. if (__pyx_t_2) {
  3972. } else {
  3973. __pyx_t_1 = __pyx_t_2;
  3974. goto __pyx_L6_bool_binop_done;
  3975. }
  3976. __pyx_t_2 = (__pyx_f_4yarl_8_quoting_bit_at(__pyx_v_self->_safe_table, __pyx_v_ch) != 0);
  3977. __pyx_t_1 = __pyx_t_2;
  3978. __pyx_L6_bool_binop_done:;
  3979. if (__pyx_t_1) {
  3980. /* "yarl/_quoting.pyx":296
  3981. *
  3982. * if ch < 128 and bit_at(self._safe_table, ch):
  3983. * return _write_char(writer, ch, False) # <<<<<<<<<<<<<<
  3984. *
  3985. * return _write_utf8(writer, ch)
  3986. */
  3987. __pyx_r = __pyx_f_4yarl_8_quoting__write_char(__pyx_v_writer, __pyx_v_ch, 0);
  3988. goto __pyx_L0;
  3989. /* "yarl/_quoting.pyx":295
  3990. * return _write_char(writer, '+', True)
  3991. *
  3992. * if ch < 128 and bit_at(self._safe_table, ch): # <<<<<<<<<<<<<<
  3993. * return _write_char(writer, ch, False)
  3994. *
  3995. */
  3996. }
  3997. /* "yarl/_quoting.pyx":298
  3998. * return _write_char(writer, ch, False)
  3999. *
  4000. * return _write_utf8(writer, ch) # <<<<<<<<<<<<<<
  4001. *
  4002. *
  4003. */
  4004. __pyx_r = __pyx_f_4yarl_8_quoting__write_utf8(__pyx_v_writer, __pyx_v_ch);
  4005. goto __pyx_L0;
  4006. /* "yarl/_quoting.pyx":290
  4007. * return PyUnicode_DecodeASCII(writer.buf, writer.pos, "strict")
  4008. *
  4009. * cdef inline int _write(self, Writer *writer, Py_UCS4 ch): # <<<<<<<<<<<<<<
  4010. * if self._qs:
  4011. * if ch == ' ':
  4012. */
  4013. /* function exit code */
  4014. __pyx_L0:;
  4015. __Pyx_RefNannyFinishContext();
  4016. return __pyx_r;
  4017. }
  4018. /* "(tree fragment)":1
  4019. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  4020. * cdef bint use_setstate
  4021. * state = (self._protected_table, self._qs, self._safe_table)
  4022. */
  4023. /* Python wrapper */
  4024. static PyObject *__pyx_pw_4yarl_8_quoting_7_Quoter_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  4025. static PyObject *__pyx_pw_4yarl_8_quoting_7_Quoter_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  4026. PyObject *__pyx_r = 0;
  4027. __Pyx_RefNannyDeclarations
  4028. __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  4029. __pyx_r = __pyx_pf_4yarl_8_quoting_7_Quoter_4__reduce_cython__(((struct __pyx_obj_4yarl_8_quoting__Quoter *)__pyx_v_self));
  4030. /* function exit code */
  4031. __Pyx_RefNannyFinishContext();
  4032. return __pyx_r;
  4033. }
  4034. static PyObject *__pyx_pf_4yarl_8_quoting_7_Quoter_4__reduce_cython__(struct __pyx_obj_4yarl_8_quoting__Quoter *__pyx_v_self) {
  4035. int __pyx_v_use_setstate;
  4036. PyObject *__pyx_v_state = NULL;
  4037. PyObject *__pyx_v__dict = NULL;
  4038. PyObject *__pyx_r = NULL;
  4039. __Pyx_RefNannyDeclarations
  4040. PyObject *__pyx_t_1 = NULL;
  4041. PyObject *__pyx_t_2 = NULL;
  4042. PyObject *__pyx_t_3 = NULL;
  4043. PyObject *__pyx_t_4 = NULL;
  4044. int __pyx_t_5;
  4045. int __pyx_t_6;
  4046. __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  4047. /* "(tree fragment)":3
  4048. * def __reduce_cython__(self):
  4049. * cdef bint use_setstate
  4050. * state = (self._protected_table, self._qs, self._safe_table) # <<<<<<<<<<<<<<
  4051. * _dict = getattr(self, '__dict__', None)
  4052. * if _dict is not None:
  4053. */
  4054. __pyx_t_1 = __Pyx_PyObject_FromCString(__pyx_v_self->_protected_table); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3, __pyx_L1_error)
  4055. __Pyx_GOTREF(__pyx_t_1);
  4056. __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->_qs); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3, __pyx_L1_error)
  4057. __Pyx_GOTREF(__pyx_t_2);
  4058. __pyx_t_3 = __Pyx_PyObject_FromCString(__pyx_v_self->_safe_table); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 3, __pyx_L1_error)
  4059. __Pyx_GOTREF(__pyx_t_3);
  4060. __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3, __pyx_L1_error)
  4061. __Pyx_GOTREF(__pyx_t_4);
  4062. __Pyx_GIVEREF(__pyx_t_1);
  4063. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  4064. __Pyx_GIVEREF(__pyx_t_2);
  4065. PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  4066. __Pyx_GIVEREF(__pyx_t_3);
  4067. PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  4068. __pyx_t_1 = 0;
  4069. __pyx_t_2 = 0;
  4070. __pyx_t_3 = 0;
  4071. __pyx_v_state = __pyx_t_4;
  4072. __pyx_t_4 = 0;
  4073. /* "(tree fragment)":4
  4074. * cdef bint use_setstate
  4075. * state = (self._protected_table, self._qs, self._safe_table)
  4076. * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<<
  4077. * if _dict is not None:
  4078. * state += (_dict,)
  4079. */
  4080. __pyx_t_4 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4, __pyx_L1_error)
  4081. __Pyx_GOTREF(__pyx_t_4);
  4082. __pyx_v__dict = __pyx_t_4;
  4083. __pyx_t_4 = 0;
  4084. /* "(tree fragment)":5
  4085. * state = (self._protected_table, self._qs, self._safe_table)
  4086. * _dict = getattr(self, '__dict__', None)
  4087. * if _dict is not None: # <<<<<<<<<<<<<<
  4088. * state += (_dict,)
  4089. * use_setstate = True
  4090. */
  4091. __pyx_t_5 = (__pyx_v__dict != Py_None);
  4092. __pyx_t_6 = (__pyx_t_5 != 0);
  4093. if (__pyx_t_6) {
  4094. /* "(tree fragment)":6
  4095. * _dict = getattr(self, '__dict__', None)
  4096. * if _dict is not None:
  4097. * state += (_dict,) # <<<<<<<<<<<<<<
  4098. * use_setstate = True
  4099. * else:
  4100. */
  4101. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
  4102. __Pyx_GOTREF(__pyx_t_4);
  4103. __Pyx_INCREF(__pyx_v__dict);
  4104. __Pyx_GIVEREF(__pyx_v__dict);
  4105. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v__dict);
  4106. __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
  4107. __Pyx_GOTREF(__pyx_t_3);
  4108. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4109. __Pyx_DECREF_SET(__pyx_v_state, __pyx_t_3);
  4110. __pyx_t_3 = 0;
  4111. /* "(tree fragment)":7
  4112. * if _dict is not None:
  4113. * state += (_dict,)
  4114. * use_setstate = True # <<<<<<<<<<<<<<
  4115. * else:
  4116. * use_setstate = False
  4117. */
  4118. __pyx_v_use_setstate = 1;
  4119. /* "(tree fragment)":5
  4120. * state = (self._protected_table, self._qs, self._safe_table)
  4121. * _dict = getattr(self, '__dict__', None)
  4122. * if _dict is not None: # <<<<<<<<<<<<<<
  4123. * state += (_dict,)
  4124. * use_setstate = True
  4125. */
  4126. goto __pyx_L3;
  4127. }
  4128. /* "(tree fragment)":9
  4129. * use_setstate = True
  4130. * else:
  4131. * use_setstate = False # <<<<<<<<<<<<<<
  4132. * if use_setstate:
  4133. * return __pyx_unpickle__Quoter, (type(self), 0x8f193a6, None), state
  4134. */
  4135. /*else*/ {
  4136. __pyx_v_use_setstate = 0;
  4137. }
  4138. __pyx_L3:;
  4139. /* "(tree fragment)":10
  4140. * else:
  4141. * use_setstate = False
  4142. * if use_setstate: # <<<<<<<<<<<<<<
  4143. * return __pyx_unpickle__Quoter, (type(self), 0x8f193a6, None), state
  4144. * else:
  4145. */
  4146. __pyx_t_6 = (__pyx_v_use_setstate != 0);
  4147. if (__pyx_t_6) {
  4148. /* "(tree fragment)":11
  4149. * use_setstate = False
  4150. * if use_setstate:
  4151. * return __pyx_unpickle__Quoter, (type(self), 0x8f193a6, None), state # <<<<<<<<<<<<<<
  4152. * else:
  4153. * return __pyx_unpickle__Quoter, (type(self), 0x8f193a6, state)
  4154. */
  4155. __Pyx_XDECREF(__pyx_r);
  4156. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle__Quoter); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 11, __pyx_L1_error)
  4157. __Pyx_GOTREF(__pyx_t_3);
  4158. __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 11, __pyx_L1_error)
  4159. __Pyx_GOTREF(__pyx_t_4);
  4160. __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
  4161. __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
  4162. PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
  4163. __Pyx_INCREF(__pyx_int_150049702);
  4164. __Pyx_GIVEREF(__pyx_int_150049702);
  4165. PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_150049702);
  4166. __Pyx_INCREF(Py_None);
  4167. __Pyx_GIVEREF(Py_None);
  4168. PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None);
  4169. __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 11, __pyx_L1_error)
  4170. __Pyx_GOTREF(__pyx_t_2);
  4171. __Pyx_GIVEREF(__pyx_t_3);
  4172. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  4173. __Pyx_GIVEREF(__pyx_t_4);
  4174. PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
  4175. __Pyx_INCREF(__pyx_v_state);
  4176. __Pyx_GIVEREF(__pyx_v_state);
  4177. PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
  4178. __pyx_t_3 = 0;
  4179. __pyx_t_4 = 0;
  4180. __pyx_r = __pyx_t_2;
  4181. __pyx_t_2 = 0;
  4182. goto __pyx_L0;
  4183. /* "(tree fragment)":10
  4184. * else:
  4185. * use_setstate = False
  4186. * if use_setstate: # <<<<<<<<<<<<<<
  4187. * return __pyx_unpickle__Quoter, (type(self), 0x8f193a6, None), state
  4188. * else:
  4189. */
  4190. }
  4191. /* "(tree fragment)":13
  4192. * return __pyx_unpickle__Quoter, (type(self), 0x8f193a6, None), state
  4193. * else:
  4194. * return __pyx_unpickle__Quoter, (type(self), 0x8f193a6, state) # <<<<<<<<<<<<<<
  4195. * def __setstate_cython__(self, __pyx_state):
  4196. * __pyx_unpickle__Quoter__set_state(self, __pyx_state)
  4197. */
  4198. /*else*/ {
  4199. __Pyx_XDECREF(__pyx_r);
  4200. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle__Quoter); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
  4201. __Pyx_GOTREF(__pyx_t_2);
  4202. __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
  4203. __Pyx_GOTREF(__pyx_t_4);
  4204. __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
  4205. __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
  4206. PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
  4207. __Pyx_INCREF(__pyx_int_150049702);
  4208. __Pyx_GIVEREF(__pyx_int_150049702);
  4209. PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_150049702);
  4210. __Pyx_INCREF(__pyx_v_state);
  4211. __Pyx_GIVEREF(__pyx_v_state);
  4212. PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_state);
  4213. __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 13, __pyx_L1_error)
  4214. __Pyx_GOTREF(__pyx_t_3);
  4215. __Pyx_GIVEREF(__pyx_t_2);
  4216. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  4217. __Pyx_GIVEREF(__pyx_t_4);
  4218. PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  4219. __pyx_t_2 = 0;
  4220. __pyx_t_4 = 0;
  4221. __pyx_r = __pyx_t_3;
  4222. __pyx_t_3 = 0;
  4223. goto __pyx_L0;
  4224. }
  4225. /* "(tree fragment)":1
  4226. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  4227. * cdef bint use_setstate
  4228. * state = (self._protected_table, self._qs, self._safe_table)
  4229. */
  4230. /* function exit code */
  4231. __pyx_L1_error:;
  4232. __Pyx_XDECREF(__pyx_t_1);
  4233. __Pyx_XDECREF(__pyx_t_2);
  4234. __Pyx_XDECREF(__pyx_t_3);
  4235. __Pyx_XDECREF(__pyx_t_4);
  4236. __Pyx_AddTraceback("yarl._quoting._Quoter.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4237. __pyx_r = NULL;
  4238. __pyx_L0:;
  4239. __Pyx_XDECREF(__pyx_v_state);
  4240. __Pyx_XDECREF(__pyx_v__dict);
  4241. __Pyx_XGIVEREF(__pyx_r);
  4242. __Pyx_RefNannyFinishContext();
  4243. return __pyx_r;
  4244. }
  4245. /* "(tree fragment)":14
  4246. * else:
  4247. * return __pyx_unpickle__Quoter, (type(self), 0x8f193a6, state)
  4248. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  4249. * __pyx_unpickle__Quoter__set_state(self, __pyx_state)
  4250. */
  4251. /* Python wrapper */
  4252. static PyObject *__pyx_pw_4yarl_8_quoting_7_Quoter_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
  4253. static PyObject *__pyx_pw_4yarl_8_quoting_7_Quoter_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  4254. PyObject *__pyx_r = 0;
  4255. __Pyx_RefNannyDeclarations
  4256. __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  4257. __pyx_r = __pyx_pf_4yarl_8_quoting_7_Quoter_6__setstate_cython__(((struct __pyx_obj_4yarl_8_quoting__Quoter *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
  4258. /* function exit code */
  4259. __Pyx_RefNannyFinishContext();
  4260. return __pyx_r;
  4261. }
  4262. static PyObject *__pyx_pf_4yarl_8_quoting_7_Quoter_6__setstate_cython__(struct __pyx_obj_4yarl_8_quoting__Quoter *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  4263. PyObject *__pyx_r = NULL;
  4264. __Pyx_RefNannyDeclarations
  4265. PyObject *__pyx_t_1 = NULL;
  4266. __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  4267. /* "(tree fragment)":15
  4268. * return __pyx_unpickle__Quoter, (type(self), 0x8f193a6, state)
  4269. * def __setstate_cython__(self, __pyx_state):
  4270. * __pyx_unpickle__Quoter__set_state(self, __pyx_state) # <<<<<<<<<<<<<<
  4271. */
  4272. if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 15, __pyx_L1_error)
  4273. __pyx_t_1 = __pyx_f_4yarl_8_quoting___pyx_unpickle__Quoter__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
  4274. __Pyx_GOTREF(__pyx_t_1);
  4275. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4276. /* "(tree fragment)":14
  4277. * else:
  4278. * return __pyx_unpickle__Quoter, (type(self), 0x8f193a6, state)
  4279. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  4280. * __pyx_unpickle__Quoter__set_state(self, __pyx_state)
  4281. */
  4282. /* function exit code */
  4283. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4284. goto __pyx_L0;
  4285. __pyx_L1_error:;
  4286. __Pyx_XDECREF(__pyx_t_1);
  4287. __Pyx_AddTraceback("yarl._quoting._Quoter.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4288. __pyx_r = NULL;
  4289. __pyx_L0:;
  4290. __Pyx_XGIVEREF(__pyx_r);
  4291. __Pyx_RefNannyFinishContext();
  4292. return __pyx_r;
  4293. }
  4294. /* "yarl/_quoting.pyx":307
  4295. * cdef _Quoter _qs_quoter
  4296. *
  4297. * def __init__(self, *, unsafe='', qs=False): # <<<<<<<<<<<<<<
  4298. * self._unsafe = unsafe
  4299. * self._qs = qs
  4300. */
  4301. /* Python wrapper */
  4302. static int __pyx_pw_4yarl_8_quoting_9_Unquoter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4303. static int __pyx_pw_4yarl_8_quoting_9_Unquoter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  4304. PyObject *__pyx_v_unsafe = 0;
  4305. PyObject *__pyx_v_qs = 0;
  4306. int __pyx_r;
  4307. __Pyx_RefNannyDeclarations
  4308. __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  4309. {
  4310. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_unsafe,&__pyx_n_s_qs,0};
  4311. PyObject* values[2] = {0,0};
  4312. values[0] = ((PyObject *)__pyx_kp_u_);
  4313. values[1] = ((PyObject *)Py_False);
  4314. if (unlikely(__pyx_kwds)) {
  4315. Py_ssize_t kw_args;
  4316. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  4317. switch (pos_args) {
  4318. case 0: break;
  4319. default: goto __pyx_L5_argtuple_error;
  4320. }
  4321. kw_args = PyDict_Size(__pyx_kwds);
  4322. if (kw_args > 0 && likely(kw_args <= 2)) {
  4323. Py_ssize_t index;
  4324. for (index = 0; index < 2 && kw_args > 0; index++) {
  4325. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
  4326. if (value) { values[index] = value; kw_args--; }
  4327. }
  4328. }
  4329. if (unlikely(kw_args > 0)) {
  4330. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "__init__") < 0)) __PYX_ERR(0, 307, __pyx_L3_error)
  4331. }
  4332. } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
  4333. goto __pyx_L5_argtuple_error;
  4334. } else {
  4335. }
  4336. __pyx_v_unsafe = values[0];
  4337. __pyx_v_qs = values[1];
  4338. }
  4339. goto __pyx_L4_argument_unpacking_done;
  4340. __pyx_L5_argtuple_error:;
  4341. __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 307, __pyx_L3_error)
  4342. __pyx_L3_error:;
  4343. __Pyx_AddTraceback("yarl._quoting._Unquoter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4344. __Pyx_RefNannyFinishContext();
  4345. return -1;
  4346. __pyx_L4_argument_unpacking_done:;
  4347. __pyx_r = __pyx_pf_4yarl_8_quoting_9_Unquoter___init__(((struct __pyx_obj_4yarl_8_quoting__Unquoter *)__pyx_v_self), __pyx_v_unsafe, __pyx_v_qs);
  4348. /* function exit code */
  4349. __Pyx_RefNannyFinishContext();
  4350. return __pyx_r;
  4351. }
  4352. static int __pyx_pf_4yarl_8_quoting_9_Unquoter___init__(struct __pyx_obj_4yarl_8_quoting__Unquoter *__pyx_v_self, PyObject *__pyx_v_unsafe, PyObject *__pyx_v_qs) {
  4353. int __pyx_r;
  4354. __Pyx_RefNannyDeclarations
  4355. PyObject *__pyx_t_1 = NULL;
  4356. int __pyx_t_2;
  4357. PyObject *__pyx_t_3 = NULL;
  4358. __Pyx_RefNannySetupContext("__init__", 0);
  4359. /* "yarl/_quoting.pyx":308
  4360. *
  4361. * def __init__(self, *, unsafe='', qs=False):
  4362. * self._unsafe = unsafe # <<<<<<<<<<<<<<
  4363. * self._qs = qs
  4364. * self._quoter = _Quoter()
  4365. */
  4366. if (!(likely(PyUnicode_CheckExact(__pyx_v_unsafe))||((__pyx_v_unsafe) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_unsafe)->tp_name), 0))) __PYX_ERR(0, 308, __pyx_L1_error)
  4367. __pyx_t_1 = __pyx_v_unsafe;
  4368. __Pyx_INCREF(__pyx_t_1);
  4369. __Pyx_GIVEREF(__pyx_t_1);
  4370. __Pyx_GOTREF(__pyx_v_self->_unsafe);
  4371. __Pyx_DECREF(__pyx_v_self->_unsafe);
  4372. __pyx_v_self->_unsafe = ((PyObject*)__pyx_t_1);
  4373. __pyx_t_1 = 0;
  4374. /* "yarl/_quoting.pyx":309
  4375. * def __init__(self, *, unsafe='', qs=False):
  4376. * self._unsafe = unsafe
  4377. * self._qs = qs # <<<<<<<<<<<<<<
  4378. * self._quoter = _Quoter()
  4379. * self._qs_quoter = _Quoter(qs=True)
  4380. */
  4381. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_qs); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 309, __pyx_L1_error)
  4382. __pyx_v_self->_qs = __pyx_t_2;
  4383. /* "yarl/_quoting.pyx":310
  4384. * self._unsafe = unsafe
  4385. * self._qs = qs
  4386. * self._quoter = _Quoter() # <<<<<<<<<<<<<<
  4387. * self._qs_quoter = _Quoter(qs=True)
  4388. *
  4389. */
  4390. __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_4yarl_8_quoting__Quoter)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
  4391. __Pyx_GOTREF(__pyx_t_1);
  4392. __Pyx_GIVEREF(__pyx_t_1);
  4393. __Pyx_GOTREF(__pyx_v_self->_quoter);
  4394. __Pyx_DECREF(((PyObject *)__pyx_v_self->_quoter));
  4395. __pyx_v_self->_quoter = ((struct __pyx_obj_4yarl_8_quoting__Quoter *)__pyx_t_1);
  4396. __pyx_t_1 = 0;
  4397. /* "yarl/_quoting.pyx":311
  4398. * self._qs = qs
  4399. * self._quoter = _Quoter()
  4400. * self._qs_quoter = _Quoter(qs=True) # <<<<<<<<<<<<<<
  4401. *
  4402. * def __call__(self, val):
  4403. */
  4404. __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 311, __pyx_L1_error)
  4405. __Pyx_GOTREF(__pyx_t_1);
  4406. if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_qs, Py_True) < 0) __PYX_ERR(0, 311, __pyx_L1_error)
  4407. __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4yarl_8_quoting__Quoter), __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 311, __pyx_L1_error)
  4408. __Pyx_GOTREF(__pyx_t_3);
  4409. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4410. __Pyx_GIVEREF(__pyx_t_3);
  4411. __Pyx_GOTREF(__pyx_v_self->_qs_quoter);
  4412. __Pyx_DECREF(((PyObject *)__pyx_v_self->_qs_quoter));
  4413. __pyx_v_self->_qs_quoter = ((struct __pyx_obj_4yarl_8_quoting__Quoter *)__pyx_t_3);
  4414. __pyx_t_3 = 0;
  4415. /* "yarl/_quoting.pyx":307
  4416. * cdef _Quoter _qs_quoter
  4417. *
  4418. * def __init__(self, *, unsafe='', qs=False): # <<<<<<<<<<<<<<
  4419. * self._unsafe = unsafe
  4420. * self._qs = qs
  4421. */
  4422. /* function exit code */
  4423. __pyx_r = 0;
  4424. goto __pyx_L0;
  4425. __pyx_L1_error:;
  4426. __Pyx_XDECREF(__pyx_t_1);
  4427. __Pyx_XDECREF(__pyx_t_3);
  4428. __Pyx_AddTraceback("yarl._quoting._Unquoter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4429. __pyx_r = -1;
  4430. __pyx_L0:;
  4431. __Pyx_RefNannyFinishContext();
  4432. return __pyx_r;
  4433. }
  4434. /* "yarl/_quoting.pyx":313
  4435. * self._qs_quoter = _Quoter(qs=True)
  4436. *
  4437. * def __call__(self, val): # <<<<<<<<<<<<<<
  4438. * if val is None:
  4439. * return None
  4440. */
  4441. /* Python wrapper */
  4442. static PyObject *__pyx_pw_4yarl_8_quoting_9_Unquoter_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4443. static PyObject *__pyx_pw_4yarl_8_quoting_9_Unquoter_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  4444. PyObject *__pyx_v_val = 0;
  4445. PyObject *__pyx_r = 0;
  4446. __Pyx_RefNannyDeclarations
  4447. __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  4448. {
  4449. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_val,0};
  4450. PyObject* values[1] = {0};
  4451. if (unlikely(__pyx_kwds)) {
  4452. Py_ssize_t kw_args;
  4453. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  4454. switch (pos_args) {
  4455. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4456. CYTHON_FALLTHROUGH;
  4457. case 0: break;
  4458. default: goto __pyx_L5_argtuple_error;
  4459. }
  4460. kw_args = PyDict_Size(__pyx_kwds);
  4461. switch (pos_args) {
  4462. case 0:
  4463. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_val)) != 0)) kw_args--;
  4464. else goto __pyx_L5_argtuple_error;
  4465. }
  4466. if (unlikely(kw_args > 0)) {
  4467. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) __PYX_ERR(0, 313, __pyx_L3_error)
  4468. }
  4469. } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
  4470. goto __pyx_L5_argtuple_error;
  4471. } else {
  4472. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4473. }
  4474. __pyx_v_val = values[0];
  4475. }
  4476. goto __pyx_L4_argument_unpacking_done;
  4477. __pyx_L5_argtuple_error:;
  4478. __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 313, __pyx_L3_error)
  4479. __pyx_L3_error:;
  4480. __Pyx_AddTraceback("yarl._quoting._Unquoter.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4481. __Pyx_RefNannyFinishContext();
  4482. return NULL;
  4483. __pyx_L4_argument_unpacking_done:;
  4484. __pyx_r = __pyx_pf_4yarl_8_quoting_9_Unquoter_2__call__(((struct __pyx_obj_4yarl_8_quoting__Unquoter *)__pyx_v_self), __pyx_v_val);
  4485. /* function exit code */
  4486. __Pyx_RefNannyFinishContext();
  4487. return __pyx_r;
  4488. }
  4489. static PyObject *__pyx_pf_4yarl_8_quoting_9_Unquoter_2__call__(struct __pyx_obj_4yarl_8_quoting__Unquoter *__pyx_v_self, PyObject *__pyx_v_val) {
  4490. PyObject *__pyx_r = NULL;
  4491. __Pyx_RefNannyDeclarations
  4492. int __pyx_t_1;
  4493. int __pyx_t_2;
  4494. PyObject *__pyx_t_3 = NULL;
  4495. __Pyx_RefNannySetupContext("__call__", 0);
  4496. __Pyx_INCREF(__pyx_v_val);
  4497. /* "yarl/_quoting.pyx":314
  4498. *
  4499. * def __call__(self, val):
  4500. * if val is None: # <<<<<<<<<<<<<<
  4501. * return None
  4502. * if type(val) is not str:
  4503. */
  4504. __pyx_t_1 = (__pyx_v_val == Py_None);
  4505. __pyx_t_2 = (__pyx_t_1 != 0);
  4506. if (__pyx_t_2) {
  4507. /* "yarl/_quoting.pyx":315
  4508. * def __call__(self, val):
  4509. * if val is None:
  4510. * return None # <<<<<<<<<<<<<<
  4511. * if type(val) is not str:
  4512. * if isinstance(val, str):
  4513. */
  4514. __Pyx_XDECREF(__pyx_r);
  4515. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4516. goto __pyx_L0;
  4517. /* "yarl/_quoting.pyx":314
  4518. *
  4519. * def __call__(self, val):
  4520. * if val is None: # <<<<<<<<<<<<<<
  4521. * return None
  4522. * if type(val) is not str:
  4523. */
  4524. }
  4525. /* "yarl/_quoting.pyx":316
  4526. * if val is None:
  4527. * return None
  4528. * if type(val) is not str: # <<<<<<<<<<<<<<
  4529. * if isinstance(val, str):
  4530. * # derived from str
  4531. */
  4532. __pyx_t_2 = (((PyObject *)Py_TYPE(__pyx_v_val)) != ((PyObject *)(&PyUnicode_Type)));
  4533. __pyx_t_1 = (__pyx_t_2 != 0);
  4534. if (__pyx_t_1) {
  4535. /* "yarl/_quoting.pyx":317
  4536. * return None
  4537. * if type(val) is not str:
  4538. * if isinstance(val, str): # <<<<<<<<<<<<<<
  4539. * # derived from str
  4540. * val = str(val)
  4541. */
  4542. __pyx_t_1 = PyUnicode_Check(__pyx_v_val);
  4543. __pyx_t_2 = (__pyx_t_1 != 0);
  4544. if (likely(__pyx_t_2)) {
  4545. /* "yarl/_quoting.pyx":319
  4546. * if isinstance(val, str):
  4547. * # derived from str
  4548. * val = str(val) # <<<<<<<<<<<<<<
  4549. * else:
  4550. * raise TypeError("Argument should be str")
  4551. */
  4552. __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_val); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 319, __pyx_L1_error)
  4553. __Pyx_GOTREF(__pyx_t_3);
  4554. __Pyx_DECREF_SET(__pyx_v_val, __pyx_t_3);
  4555. __pyx_t_3 = 0;
  4556. /* "yarl/_quoting.pyx":317
  4557. * return None
  4558. * if type(val) is not str:
  4559. * if isinstance(val, str): # <<<<<<<<<<<<<<
  4560. * # derived from str
  4561. * val = str(val)
  4562. */
  4563. goto __pyx_L5;
  4564. }
  4565. /* "yarl/_quoting.pyx":321
  4566. * val = str(val)
  4567. * else:
  4568. * raise TypeError("Argument should be str") # <<<<<<<<<<<<<<
  4569. * return self._do_unquote(<str>val)
  4570. *
  4571. */
  4572. /*else*/ {
  4573. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __pyx_L1_error)
  4574. __Pyx_GOTREF(__pyx_t_3);
  4575. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  4576. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4577. __PYX_ERR(0, 321, __pyx_L1_error)
  4578. }
  4579. __pyx_L5:;
  4580. /* "yarl/_quoting.pyx":316
  4581. * if val is None:
  4582. * return None
  4583. * if type(val) is not str: # <<<<<<<<<<<<<<
  4584. * if isinstance(val, str):
  4585. * # derived from str
  4586. */
  4587. }
  4588. /* "yarl/_quoting.pyx":322
  4589. * else:
  4590. * raise TypeError("Argument should be str")
  4591. * return self._do_unquote(<str>val) # <<<<<<<<<<<<<<
  4592. *
  4593. * cdef str _do_unquote(self, str val):
  4594. */
  4595. __Pyx_XDECREF(__pyx_r);
  4596. __pyx_t_3 = ((struct __pyx_vtabstruct_4yarl_8_quoting__Unquoter *)__pyx_v_self->__pyx_vtab)->_do_unquote(__pyx_v_self, ((PyObject*)__pyx_v_val)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 322, __pyx_L1_error)
  4597. __Pyx_GOTREF(__pyx_t_3);
  4598. __pyx_r = __pyx_t_3;
  4599. __pyx_t_3 = 0;
  4600. goto __pyx_L0;
  4601. /* "yarl/_quoting.pyx":313
  4602. * self._qs_quoter = _Quoter(qs=True)
  4603. *
  4604. * def __call__(self, val): # <<<<<<<<<<<<<<
  4605. * if val is None:
  4606. * return None
  4607. */
  4608. /* function exit code */
  4609. __pyx_L1_error:;
  4610. __Pyx_XDECREF(__pyx_t_3);
  4611. __Pyx_AddTraceback("yarl._quoting._Unquoter.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4612. __pyx_r = NULL;
  4613. __pyx_L0:;
  4614. __Pyx_XDECREF(__pyx_v_val);
  4615. __Pyx_XGIVEREF(__pyx_r);
  4616. __Pyx_RefNannyFinishContext();
  4617. return __pyx_r;
  4618. }
  4619. /* "yarl/_quoting.pyx":324
  4620. * return self._do_unquote(<str>val)
  4621. *
  4622. * cdef str _do_unquote(self, str val): # <<<<<<<<<<<<<<
  4623. * if len(val) == 0:
  4624. * return val
  4625. */
  4626. static PyObject *__pyx_f_4yarl_8_quoting_9_Unquoter__do_unquote(struct __pyx_obj_4yarl_8_quoting__Unquoter *__pyx_v_self, PyObject *__pyx_v_val) {
  4627. PyObject *__pyx_v_pct = 0;
  4628. PyObject *__pyx_v_last_pct = 0;
  4629. PyObject *__pyx_v_pcts = 0;
  4630. PyObject *__pyx_v_ret = 0;
  4631. PyObject *__pyx_v_unquoted = 0;
  4632. PyObject *__pyx_v_ch = NULL;
  4633. PyObject *__pyx_v_h = NULL;
  4634. PyObject *__pyx_r = NULL;
  4635. __Pyx_RefNannyDeclarations
  4636. Py_ssize_t __pyx_t_1;
  4637. int __pyx_t_2;
  4638. PyObject *__pyx_t_3 = NULL;
  4639. PyObject *__pyx_t_4 = NULL;
  4640. Py_ssize_t __pyx_t_5;
  4641. void *__pyx_t_6;
  4642. int __pyx_t_7;
  4643. int __pyx_t_8;
  4644. Py_ssize_t __pyx_t_9;
  4645. Py_ssize_t __pyx_t_10;
  4646. PyObject *__pyx_t_11 = NULL;
  4647. PyObject *__pyx_t_12 = NULL;
  4648. int __pyx_t_13;
  4649. PyObject *__pyx_t_14 = NULL;
  4650. PyObject *__pyx_t_15 = NULL;
  4651. PyObject *__pyx_t_16 = NULL;
  4652. int __pyx_t_17;
  4653. int __pyx_t_18;
  4654. PyObject *__pyx_t_19 = NULL;
  4655. long __pyx_t_20;
  4656. PyObject *(*__pyx_t_21)(PyObject *);
  4657. __Pyx_RefNannySetupContext("_do_unquote", 0);
  4658. /* "yarl/_quoting.pyx":325
  4659. *
  4660. * cdef str _do_unquote(self, str val):
  4661. * if len(val) == 0: # <<<<<<<<<<<<<<
  4662. * return val
  4663. * cdef str pct = ''
  4664. */
  4665. if (unlikely(__pyx_v_val == Py_None)) {
  4666. PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
  4667. __PYX_ERR(0, 325, __pyx_L1_error)
  4668. }
  4669. __pyx_t_1 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_val); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 325, __pyx_L1_error)
  4670. __pyx_t_2 = ((__pyx_t_1 == 0) != 0);
  4671. if (__pyx_t_2) {
  4672. /* "yarl/_quoting.pyx":326
  4673. * cdef str _do_unquote(self, str val):
  4674. * if len(val) == 0:
  4675. * return val # <<<<<<<<<<<<<<
  4676. * cdef str pct = ''
  4677. * cdef str last_pct = ''
  4678. */
  4679. __Pyx_XDECREF(__pyx_r);
  4680. __Pyx_INCREF(__pyx_v_val);
  4681. __pyx_r = __pyx_v_val;
  4682. goto __pyx_L0;
  4683. /* "yarl/_quoting.pyx":325
  4684. *
  4685. * cdef str _do_unquote(self, str val):
  4686. * if len(val) == 0: # <<<<<<<<<<<<<<
  4687. * return val
  4688. * cdef str pct = ''
  4689. */
  4690. }
  4691. /* "yarl/_quoting.pyx":327
  4692. * if len(val) == 0:
  4693. * return val
  4694. * cdef str pct = '' # <<<<<<<<<<<<<<
  4695. * cdef str last_pct = ''
  4696. * cdef bytearray pcts = bytearray()
  4697. */
  4698. __Pyx_INCREF(__pyx_kp_u_);
  4699. __pyx_v_pct = __pyx_kp_u_;
  4700. /* "yarl/_quoting.pyx":328
  4701. * return val
  4702. * cdef str pct = ''
  4703. * cdef str last_pct = '' # <<<<<<<<<<<<<<
  4704. * cdef bytearray pcts = bytearray()
  4705. * cdef list ret = []
  4706. */
  4707. __Pyx_INCREF(__pyx_kp_u_);
  4708. __pyx_v_last_pct = __pyx_kp_u_;
  4709. /* "yarl/_quoting.pyx":329
  4710. * cdef str pct = ''
  4711. * cdef str last_pct = ''
  4712. * cdef bytearray pcts = bytearray() # <<<<<<<<<<<<<<
  4713. * cdef list ret = []
  4714. * cdef str unquoted
  4715. */
  4716. __pyx_t_3 = __Pyx_PyObject_CallNoArg(((PyObject *)(&PyByteArray_Type))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 329, __pyx_L1_error)
  4717. __Pyx_GOTREF(__pyx_t_3);
  4718. __pyx_v_pcts = ((PyObject*)__pyx_t_3);
  4719. __pyx_t_3 = 0;
  4720. /* "yarl/_quoting.pyx":330
  4721. * cdef str last_pct = ''
  4722. * cdef bytearray pcts = bytearray()
  4723. * cdef list ret = [] # <<<<<<<<<<<<<<
  4724. * cdef str unquoted
  4725. * for ch in val:
  4726. */
  4727. __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 330, __pyx_L1_error)
  4728. __Pyx_GOTREF(__pyx_t_3);
  4729. __pyx_v_ret = ((PyObject*)__pyx_t_3);
  4730. __pyx_t_3 = 0;
  4731. /* "yarl/_quoting.pyx":332
  4732. * cdef list ret = []
  4733. * cdef str unquoted
  4734. * for ch in val: # <<<<<<<<<<<<<<
  4735. * if pct:
  4736. * pct += ch
  4737. */
  4738. if (unlikely(__pyx_v_val == Py_None)) {
  4739. PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
  4740. __PYX_ERR(0, 332, __pyx_L1_error)
  4741. }
  4742. __Pyx_INCREF(__pyx_v_val);
  4743. __pyx_t_4 = __pyx_v_val;
  4744. __pyx_t_8 = __Pyx_init_unicode_iteration(__pyx_t_4, (&__pyx_t_5), (&__pyx_t_6), (&__pyx_t_7)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 332, __pyx_L1_error)
  4745. for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_5; __pyx_t_9++) {
  4746. __pyx_t_1 = __pyx_t_9;
  4747. __pyx_t_3 = PyUnicode_FromOrdinal(__Pyx_PyUnicode_READ(__pyx_t_7, __pyx_t_6, __pyx_t_1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 332, __pyx_L1_error)
  4748. __Pyx_GOTREF(__pyx_t_3);
  4749. __Pyx_XDECREF_SET(__pyx_v_ch, __pyx_t_3);
  4750. __pyx_t_3 = 0;
  4751. /* "yarl/_quoting.pyx":333
  4752. * cdef str unquoted
  4753. * for ch in val:
  4754. * if pct: # <<<<<<<<<<<<<<
  4755. * pct += ch
  4756. * if len(pct) == 3: # pragma: no branch # peephole optimizer
  4757. */
  4758. __pyx_t_2 = (__pyx_v_pct != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_pct) != 0);
  4759. if (__pyx_t_2) {
  4760. /* "yarl/_quoting.pyx":334
  4761. * for ch in val:
  4762. * if pct:
  4763. * pct += ch # <<<<<<<<<<<<<<
  4764. * if len(pct) == 3: # pragma: no branch # peephole optimizer
  4765. * pcts.append(int(pct[1:], base=16))
  4766. */
  4767. __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_pct, __pyx_v_ch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 334, __pyx_L1_error)
  4768. __Pyx_GOTREF(__pyx_t_3);
  4769. if (!(likely(PyUnicode_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 334, __pyx_L1_error)
  4770. __Pyx_DECREF_SET(__pyx_v_pct, ((PyObject*)__pyx_t_3));
  4771. __pyx_t_3 = 0;
  4772. /* "yarl/_quoting.pyx":335
  4773. * if pct:
  4774. * pct += ch
  4775. * if len(pct) == 3: # pragma: no branch # peephole optimizer # <<<<<<<<<<<<<<
  4776. * pcts.append(int(pct[1:], base=16))
  4777. * last_pct = pct
  4778. */
  4779. if (unlikely(__pyx_v_pct == Py_None)) {
  4780. PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
  4781. __PYX_ERR(0, 335, __pyx_L1_error)
  4782. }
  4783. __pyx_t_10 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_pct); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 335, __pyx_L1_error)
  4784. __pyx_t_2 = ((__pyx_t_10 == 3) != 0);
  4785. if (__pyx_t_2) {
  4786. /* "yarl/_quoting.pyx":336
  4787. * pct += ch
  4788. * if len(pct) == 3: # pragma: no branch # peephole optimizer
  4789. * pcts.append(int(pct[1:], base=16)) # <<<<<<<<<<<<<<
  4790. * last_pct = pct
  4791. * pct = ''
  4792. */
  4793. if (unlikely(__pyx_v_pct == Py_None)) {
  4794. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
  4795. __PYX_ERR(0, 336, __pyx_L1_error)
  4796. }
  4797. __pyx_t_3 = __Pyx_PyUnicode_Substring(__pyx_v_pct, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 336, __pyx_L1_error)
  4798. __Pyx_GOTREF(__pyx_t_3);
  4799. __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 336, __pyx_L1_error)
  4800. __Pyx_GOTREF(__pyx_t_11);
  4801. __Pyx_GIVEREF(__pyx_t_3);
  4802. PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3);
  4803. __pyx_t_3 = 0;
  4804. __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 336, __pyx_L1_error)
  4805. __Pyx_GOTREF(__pyx_t_3);
  4806. if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_base, __pyx_int_16) < 0) __PYX_ERR(0, 336, __pyx_L1_error)
  4807. __pyx_t_12 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_11, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 336, __pyx_L1_error)
  4808. __Pyx_GOTREF(__pyx_t_12);
  4809. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  4810. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4811. __pyx_t_13 = __Pyx_PyByteArray_AppendObject(__pyx_v_pcts, __pyx_t_12); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 336, __pyx_L1_error)
  4812. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4813. /* "yarl/_quoting.pyx":337
  4814. * if len(pct) == 3: # pragma: no branch # peephole optimizer
  4815. * pcts.append(int(pct[1:], base=16))
  4816. * last_pct = pct # <<<<<<<<<<<<<<
  4817. * pct = ''
  4818. * continue
  4819. */
  4820. __Pyx_INCREF(__pyx_v_pct);
  4821. __Pyx_DECREF_SET(__pyx_v_last_pct, __pyx_v_pct);
  4822. /* "yarl/_quoting.pyx":338
  4823. * pcts.append(int(pct[1:], base=16))
  4824. * last_pct = pct
  4825. * pct = '' # <<<<<<<<<<<<<<
  4826. * continue
  4827. * if pcts:
  4828. */
  4829. __Pyx_INCREF(__pyx_kp_u_);
  4830. __Pyx_DECREF_SET(__pyx_v_pct, __pyx_kp_u_);
  4831. /* "yarl/_quoting.pyx":335
  4832. * if pct:
  4833. * pct += ch
  4834. * if len(pct) == 3: # pragma: no branch # peephole optimizer # <<<<<<<<<<<<<<
  4835. * pcts.append(int(pct[1:], base=16))
  4836. * last_pct = pct
  4837. */
  4838. }
  4839. /* "yarl/_quoting.pyx":339
  4840. * last_pct = pct
  4841. * pct = ''
  4842. * continue # <<<<<<<<<<<<<<
  4843. * if pcts:
  4844. * try:
  4845. */
  4846. goto __pyx_L4_continue;
  4847. /* "yarl/_quoting.pyx":333
  4848. * cdef str unquoted
  4849. * for ch in val:
  4850. * if pct: # <<<<<<<<<<<<<<
  4851. * pct += ch
  4852. * if len(pct) == 3: # pragma: no branch # peephole optimizer
  4853. */
  4854. }
  4855. /* "yarl/_quoting.pyx":340
  4856. * pct = ''
  4857. * continue
  4858. * if pcts: # <<<<<<<<<<<<<<
  4859. * try:
  4860. * unquoted = pcts.decode('utf8')
  4861. */
  4862. __pyx_t_2 = (PyByteArray_GET_SIZE(__pyx_v_pcts) != 0);
  4863. if (__pyx_t_2) {
  4864. /* "yarl/_quoting.pyx":341
  4865. * continue
  4866. * if pcts:
  4867. * try: # <<<<<<<<<<<<<<
  4868. * unquoted = pcts.decode('utf8')
  4869. * except UnicodeDecodeError:
  4870. */
  4871. {
  4872. __Pyx_PyThreadState_declare
  4873. __Pyx_PyThreadState_assign
  4874. __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
  4875. __Pyx_XGOTREF(__pyx_t_14);
  4876. __Pyx_XGOTREF(__pyx_t_15);
  4877. __Pyx_XGOTREF(__pyx_t_16);
  4878. /*try:*/ {
  4879. /* "yarl/_quoting.pyx":342
  4880. * if pcts:
  4881. * try:
  4882. * unquoted = pcts.decode('utf8') # <<<<<<<<<<<<<<
  4883. * except UnicodeDecodeError:
  4884. * pass
  4885. */
  4886. __pyx_t_12 = __Pyx_decode_bytearray(__pyx_v_pcts, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 342, __pyx_L9_error)
  4887. __Pyx_GOTREF(__pyx_t_12);
  4888. __Pyx_XDECREF_SET(__pyx_v_unquoted, ((PyObject*)__pyx_t_12));
  4889. __pyx_t_12 = 0;
  4890. /* "yarl/_quoting.pyx":341
  4891. * continue
  4892. * if pcts:
  4893. * try: # <<<<<<<<<<<<<<
  4894. * unquoted = pcts.decode('utf8')
  4895. * except UnicodeDecodeError:
  4896. */
  4897. }
  4898. /* "yarl/_quoting.pyx":346
  4899. * pass
  4900. * else:
  4901. * if self._qs and unquoted in '+=&;': # <<<<<<<<<<<<<<
  4902. * ret.append(self._qs_quoter(unquoted))
  4903. * elif unquoted in self._unsafe:
  4904. */
  4905. /*else:*/ {
  4906. __pyx_t_17 = (__pyx_v_self->_qs != 0);
  4907. if (__pyx_t_17) {
  4908. } else {
  4909. __pyx_t_2 = __pyx_t_17;
  4910. goto __pyx_L18_bool_binop_done;
  4911. }
  4912. __pyx_t_17 = (__Pyx_PyUnicode_ContainsTF(__pyx_v_unquoted, __pyx_kp_u__6, Py_EQ)); if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 346, __pyx_L11_except_error)
  4913. __pyx_t_18 = (__pyx_t_17 != 0);
  4914. __pyx_t_2 = __pyx_t_18;
  4915. __pyx_L18_bool_binop_done:;
  4916. if (__pyx_t_2) {
  4917. /* "yarl/_quoting.pyx":347
  4918. * else:
  4919. * if self._qs and unquoted in '+=&;':
  4920. * ret.append(self._qs_quoter(unquoted)) # <<<<<<<<<<<<<<
  4921. * elif unquoted in self._unsafe:
  4922. * ret.append(self._quoter(unquoted))
  4923. */
  4924. __Pyx_INCREF(((PyObject *)__pyx_v_self->_qs_quoter));
  4925. __pyx_t_3 = ((PyObject *)__pyx_v_self->_qs_quoter); __pyx_t_11 = NULL;
  4926. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  4927. __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
  4928. if (likely(__pyx_t_11)) {
  4929. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  4930. __Pyx_INCREF(__pyx_t_11);
  4931. __Pyx_INCREF(function);
  4932. __Pyx_DECREF_SET(__pyx_t_3, function);
  4933. }
  4934. }
  4935. if (!__pyx_t_11) {
  4936. __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_unquoted); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 347, __pyx_L11_except_error)
  4937. __Pyx_GOTREF(__pyx_t_12);
  4938. } else {
  4939. #if CYTHON_FAST_PYCALL
  4940. if (PyFunction_Check(__pyx_t_3)) {
  4941. PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_unquoted};
  4942. __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 347, __pyx_L11_except_error)
  4943. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  4944. __Pyx_GOTREF(__pyx_t_12);
  4945. } else
  4946. #endif
  4947. #if CYTHON_FAST_PYCCALL
  4948. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  4949. PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_unquoted};
  4950. __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 347, __pyx_L11_except_error)
  4951. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  4952. __Pyx_GOTREF(__pyx_t_12);
  4953. } else
  4954. #endif
  4955. {
  4956. __pyx_t_19 = PyTuple_New(1+1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 347, __pyx_L11_except_error)
  4957. __Pyx_GOTREF(__pyx_t_19);
  4958. __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_11); __pyx_t_11 = NULL;
  4959. __Pyx_INCREF(__pyx_v_unquoted);
  4960. __Pyx_GIVEREF(__pyx_v_unquoted);
  4961. PyTuple_SET_ITEM(__pyx_t_19, 0+1, __pyx_v_unquoted);
  4962. __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_19, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 347, __pyx_L11_except_error)
  4963. __Pyx_GOTREF(__pyx_t_12);
  4964. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  4965. }
  4966. }
  4967. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4968. __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_t_12); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 347, __pyx_L11_except_error)
  4969. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4970. /* "yarl/_quoting.pyx":346
  4971. * pass
  4972. * else:
  4973. * if self._qs and unquoted in '+=&;': # <<<<<<<<<<<<<<
  4974. * ret.append(self._qs_quoter(unquoted))
  4975. * elif unquoted in self._unsafe:
  4976. */
  4977. goto __pyx_L17;
  4978. }
  4979. /* "yarl/_quoting.pyx":348
  4980. * if self._qs and unquoted in '+=&;':
  4981. * ret.append(self._qs_quoter(unquoted))
  4982. * elif unquoted in self._unsafe: # <<<<<<<<<<<<<<
  4983. * ret.append(self._quoter(unquoted))
  4984. * else:
  4985. */
  4986. if (unlikely(__pyx_v_self->_unsafe == Py_None)) {
  4987. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
  4988. __PYX_ERR(0, 348, __pyx_L11_except_error)
  4989. }
  4990. __pyx_t_2 = (__Pyx_PyUnicode_ContainsTF(__pyx_v_unquoted, __pyx_v_self->_unsafe, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 348, __pyx_L11_except_error)
  4991. __pyx_t_18 = (__pyx_t_2 != 0);
  4992. if (__pyx_t_18) {
  4993. /* "yarl/_quoting.pyx":349
  4994. * ret.append(self._qs_quoter(unquoted))
  4995. * elif unquoted in self._unsafe:
  4996. * ret.append(self._quoter(unquoted)) # <<<<<<<<<<<<<<
  4997. * else:
  4998. * ret.append(unquoted)
  4999. */
  5000. __Pyx_INCREF(((PyObject *)__pyx_v_self->_quoter));
  5001. __pyx_t_3 = ((PyObject *)__pyx_v_self->_quoter); __pyx_t_19 = NULL;
  5002. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  5003. __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_3);
  5004. if (likely(__pyx_t_19)) {
  5005. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  5006. __Pyx_INCREF(__pyx_t_19);
  5007. __Pyx_INCREF(function);
  5008. __Pyx_DECREF_SET(__pyx_t_3, function);
  5009. }
  5010. }
  5011. if (!__pyx_t_19) {
  5012. __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_unquoted); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 349, __pyx_L11_except_error)
  5013. __Pyx_GOTREF(__pyx_t_12);
  5014. } else {
  5015. #if CYTHON_FAST_PYCALL
  5016. if (PyFunction_Check(__pyx_t_3)) {
  5017. PyObject *__pyx_temp[2] = {__pyx_t_19, __pyx_v_unquoted};
  5018. __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 349, __pyx_L11_except_error)
  5019. __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
  5020. __Pyx_GOTREF(__pyx_t_12);
  5021. } else
  5022. #endif
  5023. #if CYTHON_FAST_PYCCALL
  5024. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  5025. PyObject *__pyx_temp[2] = {__pyx_t_19, __pyx_v_unquoted};
  5026. __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 349, __pyx_L11_except_error)
  5027. __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
  5028. __Pyx_GOTREF(__pyx_t_12);
  5029. } else
  5030. #endif
  5031. {
  5032. __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 349, __pyx_L11_except_error)
  5033. __Pyx_GOTREF(__pyx_t_11);
  5034. __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_19); __pyx_t_19 = NULL;
  5035. __Pyx_INCREF(__pyx_v_unquoted);
  5036. __Pyx_GIVEREF(__pyx_v_unquoted);
  5037. PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_unquoted);
  5038. __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 349, __pyx_L11_except_error)
  5039. __Pyx_GOTREF(__pyx_t_12);
  5040. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  5041. }
  5042. }
  5043. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5044. __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_t_12); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 349, __pyx_L11_except_error)
  5045. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  5046. /* "yarl/_quoting.pyx":348
  5047. * if self._qs and unquoted in '+=&;':
  5048. * ret.append(self._qs_quoter(unquoted))
  5049. * elif unquoted in self._unsafe: # <<<<<<<<<<<<<<
  5050. * ret.append(self._quoter(unquoted))
  5051. * else:
  5052. */
  5053. goto __pyx_L17;
  5054. }
  5055. /* "yarl/_quoting.pyx":351
  5056. * ret.append(self._quoter(unquoted))
  5057. * else:
  5058. * ret.append(unquoted) # <<<<<<<<<<<<<<
  5059. * del pcts[:]
  5060. *
  5061. */
  5062. /*else*/ {
  5063. __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_unquoted); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 351, __pyx_L11_except_error)
  5064. }
  5065. __pyx_L17:;
  5066. /* "yarl/_quoting.pyx":352
  5067. * else:
  5068. * ret.append(unquoted)
  5069. * del pcts[:] # <<<<<<<<<<<<<<
  5070. *
  5071. * if ch == '%':
  5072. */
  5073. if (__Pyx_PyObject_DelSlice(__pyx_v_pcts, 0, 0, NULL, NULL, NULL, 0, 0, 1) < 0) __PYX_ERR(0, 352, __pyx_L11_except_error)
  5074. }
  5075. __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  5076. __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  5077. __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
  5078. goto __pyx_L16_try_end;
  5079. __pyx_L9_error:;
  5080. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  5081. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5082. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  5083. /* "yarl/_quoting.pyx":343
  5084. * try:
  5085. * unquoted = pcts.decode('utf8')
  5086. * except UnicodeDecodeError: # <<<<<<<<<<<<<<
  5087. * pass
  5088. * else:
  5089. */
  5090. __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
  5091. if (__pyx_t_8) {
  5092. __Pyx_ErrRestore(0,0,0);
  5093. goto __pyx_L10_exception_handled;
  5094. }
  5095. goto __pyx_L11_except_error;
  5096. __pyx_L11_except_error:;
  5097. /* "yarl/_quoting.pyx":341
  5098. * continue
  5099. * if pcts:
  5100. * try: # <<<<<<<<<<<<<<
  5101. * unquoted = pcts.decode('utf8')
  5102. * except UnicodeDecodeError:
  5103. */
  5104. __Pyx_XGIVEREF(__pyx_t_14);
  5105. __Pyx_XGIVEREF(__pyx_t_15);
  5106. __Pyx_XGIVEREF(__pyx_t_16);
  5107. __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
  5108. goto __pyx_L1_error;
  5109. __pyx_L10_exception_handled:;
  5110. __Pyx_XGIVEREF(__pyx_t_14);
  5111. __Pyx_XGIVEREF(__pyx_t_15);
  5112. __Pyx_XGIVEREF(__pyx_t_16);
  5113. __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
  5114. __pyx_L16_try_end:;
  5115. }
  5116. /* "yarl/_quoting.pyx":340
  5117. * pct = ''
  5118. * continue
  5119. * if pcts: # <<<<<<<<<<<<<<
  5120. * try:
  5121. * unquoted = pcts.decode('utf8')
  5122. */
  5123. }
  5124. /* "yarl/_quoting.pyx":354
  5125. * del pcts[:]
  5126. *
  5127. * if ch == '%': # <<<<<<<<<<<<<<
  5128. * pct = ch
  5129. * continue
  5130. */
  5131. __pyx_t_18 = (__Pyx_PyUnicode_Equals(__pyx_v_ch, __pyx_kp_u__7, Py_EQ)); if (unlikely(__pyx_t_18 < 0)) __PYX_ERR(0, 354, __pyx_L1_error)
  5132. if (__pyx_t_18) {
  5133. /* "yarl/_quoting.pyx":355
  5134. *
  5135. * if ch == '%':
  5136. * pct = ch # <<<<<<<<<<<<<<
  5137. * continue
  5138. *
  5139. */
  5140. if (!(likely(PyUnicode_CheckExact(__pyx_v_ch))||((__pyx_v_ch) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_ch)->tp_name), 0))) __PYX_ERR(0, 355, __pyx_L1_error)
  5141. __pyx_t_12 = __pyx_v_ch;
  5142. __Pyx_INCREF(__pyx_t_12);
  5143. __Pyx_DECREF_SET(__pyx_v_pct, ((PyObject*)__pyx_t_12));
  5144. __pyx_t_12 = 0;
  5145. /* "yarl/_quoting.pyx":356
  5146. * if ch == '%':
  5147. * pct = ch
  5148. * continue # <<<<<<<<<<<<<<
  5149. *
  5150. * if pcts:
  5151. */
  5152. goto __pyx_L4_continue;
  5153. /* "yarl/_quoting.pyx":354
  5154. * del pcts[:]
  5155. *
  5156. * if ch == '%': # <<<<<<<<<<<<<<
  5157. * pct = ch
  5158. * continue
  5159. */
  5160. }
  5161. /* "yarl/_quoting.pyx":358
  5162. * continue
  5163. *
  5164. * if pcts: # <<<<<<<<<<<<<<
  5165. * ret.append(last_pct) # %F8ab
  5166. * last_pct = ''
  5167. */
  5168. __pyx_t_18 = (PyByteArray_GET_SIZE(__pyx_v_pcts) != 0);
  5169. if (__pyx_t_18) {
  5170. /* "yarl/_quoting.pyx":359
  5171. *
  5172. * if pcts:
  5173. * ret.append(last_pct) # %F8ab # <<<<<<<<<<<<<<
  5174. * last_pct = ''
  5175. *
  5176. */
  5177. __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_last_pct); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 359, __pyx_L1_error)
  5178. /* "yarl/_quoting.pyx":360
  5179. * if pcts:
  5180. * ret.append(last_pct) # %F8ab
  5181. * last_pct = '' # <<<<<<<<<<<<<<
  5182. *
  5183. * if ch == '+':
  5184. */
  5185. __Pyx_INCREF(__pyx_kp_u_);
  5186. __Pyx_DECREF_SET(__pyx_v_last_pct, __pyx_kp_u_);
  5187. /* "yarl/_quoting.pyx":358
  5188. * continue
  5189. *
  5190. * if pcts: # <<<<<<<<<<<<<<
  5191. * ret.append(last_pct) # %F8ab
  5192. * last_pct = ''
  5193. */
  5194. }
  5195. /* "yarl/_quoting.pyx":362
  5196. * last_pct = ''
  5197. *
  5198. * if ch == '+': # <<<<<<<<<<<<<<
  5199. * if not self._qs or ch in self._unsafe:
  5200. * ret.append('+')
  5201. */
  5202. __pyx_t_18 = (__Pyx_PyUnicode_Equals(__pyx_v_ch, __pyx_kp_u__8, Py_EQ)); if (unlikely(__pyx_t_18 < 0)) __PYX_ERR(0, 362, __pyx_L1_error)
  5203. if (__pyx_t_18) {
  5204. /* "yarl/_quoting.pyx":363
  5205. *
  5206. * if ch == '+':
  5207. * if not self._qs or ch in self._unsafe: # <<<<<<<<<<<<<<
  5208. * ret.append('+')
  5209. * else:
  5210. */
  5211. __pyx_t_2 = ((!(__pyx_v_self->_qs != 0)) != 0);
  5212. if (!__pyx_t_2) {
  5213. } else {
  5214. __pyx_t_18 = __pyx_t_2;
  5215. goto __pyx_L24_bool_binop_done;
  5216. }
  5217. if (unlikely(__pyx_v_self->_unsafe == Py_None)) {
  5218. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
  5219. __PYX_ERR(0, 363, __pyx_L1_error)
  5220. }
  5221. __pyx_t_2 = (__Pyx_PyUnicode_ContainsTF(__pyx_v_ch, __pyx_v_self->_unsafe, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 363, __pyx_L1_error)
  5222. __pyx_t_17 = (__pyx_t_2 != 0);
  5223. __pyx_t_18 = __pyx_t_17;
  5224. __pyx_L24_bool_binop_done:;
  5225. if (__pyx_t_18) {
  5226. /* "yarl/_quoting.pyx":364
  5227. * if ch == '+':
  5228. * if not self._qs or ch in self._unsafe:
  5229. * ret.append('+') # <<<<<<<<<<<<<<
  5230. * else:
  5231. * ret.append(' ')
  5232. */
  5233. __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_kp_u__8); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 364, __pyx_L1_error)
  5234. /* "yarl/_quoting.pyx":363
  5235. *
  5236. * if ch == '+':
  5237. * if not self._qs or ch in self._unsafe: # <<<<<<<<<<<<<<
  5238. * ret.append('+')
  5239. * else:
  5240. */
  5241. goto __pyx_L23;
  5242. }
  5243. /* "yarl/_quoting.pyx":366
  5244. * ret.append('+')
  5245. * else:
  5246. * ret.append(' ') # <<<<<<<<<<<<<<
  5247. * continue
  5248. *
  5249. */
  5250. /*else*/ {
  5251. __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_kp_u__9); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 366, __pyx_L1_error)
  5252. }
  5253. __pyx_L23:;
  5254. /* "yarl/_quoting.pyx":367
  5255. * else:
  5256. * ret.append(' ')
  5257. * continue # <<<<<<<<<<<<<<
  5258. *
  5259. * if ch in self._unsafe:
  5260. */
  5261. goto __pyx_L4_continue;
  5262. /* "yarl/_quoting.pyx":362
  5263. * last_pct = ''
  5264. *
  5265. * if ch == '+': # <<<<<<<<<<<<<<
  5266. * if not self._qs or ch in self._unsafe:
  5267. * ret.append('+')
  5268. */
  5269. }
  5270. /* "yarl/_quoting.pyx":369
  5271. * continue
  5272. *
  5273. * if ch in self._unsafe: # <<<<<<<<<<<<<<
  5274. * ret.append('%')
  5275. * h = hex(ord(ch)).upper()[2:]
  5276. */
  5277. if (unlikely(__pyx_v_self->_unsafe == Py_None)) {
  5278. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
  5279. __PYX_ERR(0, 369, __pyx_L1_error)
  5280. }
  5281. __pyx_t_18 = (__Pyx_PyUnicode_ContainsTF(__pyx_v_ch, __pyx_v_self->_unsafe, Py_EQ)); if (unlikely(__pyx_t_18 < 0)) __PYX_ERR(0, 369, __pyx_L1_error)
  5282. __pyx_t_17 = (__pyx_t_18 != 0);
  5283. if (__pyx_t_17) {
  5284. /* "yarl/_quoting.pyx":370
  5285. *
  5286. * if ch in self._unsafe:
  5287. * ret.append('%') # <<<<<<<<<<<<<<
  5288. * h = hex(ord(ch)).upper()[2:]
  5289. * for ch in h:
  5290. */
  5291. __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_kp_u__7); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 370, __pyx_L1_error)
  5292. /* "yarl/_quoting.pyx":371
  5293. * if ch in self._unsafe:
  5294. * ret.append('%')
  5295. * h = hex(ord(ch)).upper()[2:] # <<<<<<<<<<<<<<
  5296. * for ch in h:
  5297. * ret.append(ch)
  5298. */
  5299. __pyx_t_20 = __Pyx_PyObject_Ord(__pyx_v_ch); if (unlikely(__pyx_t_20 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 371, __pyx_L1_error)
  5300. __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_t_20); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L1_error)
  5301. __Pyx_GOTREF(__pyx_t_3);
  5302. __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_hex, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 371, __pyx_L1_error)
  5303. __Pyx_GOTREF(__pyx_t_11);
  5304. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5305. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_upper); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L1_error)
  5306. __Pyx_GOTREF(__pyx_t_3);
  5307. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  5308. __pyx_t_11 = NULL;
  5309. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
  5310. __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
  5311. if (likely(__pyx_t_11)) {
  5312. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  5313. __Pyx_INCREF(__pyx_t_11);
  5314. __Pyx_INCREF(function);
  5315. __Pyx_DECREF_SET(__pyx_t_3, function);
  5316. }
  5317. }
  5318. if (__pyx_t_11) {
  5319. __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 371, __pyx_L1_error)
  5320. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  5321. } else {
  5322. __pyx_t_12 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 371, __pyx_L1_error)
  5323. }
  5324. __Pyx_GOTREF(__pyx_t_12);
  5325. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5326. __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_t_12, 2, 0, NULL, NULL, &__pyx_slice__10, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L1_error)
  5327. __Pyx_GOTREF(__pyx_t_3);
  5328. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  5329. __Pyx_XDECREF_SET(__pyx_v_h, __pyx_t_3);
  5330. __pyx_t_3 = 0;
  5331. /* "yarl/_quoting.pyx":372
  5332. * ret.append('%')
  5333. * h = hex(ord(ch)).upper()[2:]
  5334. * for ch in h: # <<<<<<<<<<<<<<
  5335. * ret.append(ch)
  5336. * continue
  5337. */
  5338. if (likely(PyList_CheckExact(__pyx_v_h)) || PyTuple_CheckExact(__pyx_v_h)) {
  5339. __pyx_t_3 = __pyx_v_h; __Pyx_INCREF(__pyx_t_3); __pyx_t_10 = 0;
  5340. __pyx_t_21 = NULL;
  5341. } else {
  5342. __pyx_t_10 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_h); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 372, __pyx_L1_error)
  5343. __Pyx_GOTREF(__pyx_t_3);
  5344. __pyx_t_21 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 372, __pyx_L1_error)
  5345. }
  5346. for (;;) {
  5347. if (likely(!__pyx_t_21)) {
  5348. if (likely(PyList_CheckExact(__pyx_t_3))) {
  5349. if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_3)) break;
  5350. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  5351. __pyx_t_12 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_12); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 372, __pyx_L1_error)
  5352. #else
  5353. __pyx_t_12 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 372, __pyx_L1_error)
  5354. __Pyx_GOTREF(__pyx_t_12);
  5355. #endif
  5356. } else {
  5357. if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
  5358. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  5359. __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_12); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 372, __pyx_L1_error)
  5360. #else
  5361. __pyx_t_12 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 372, __pyx_L1_error)
  5362. __Pyx_GOTREF(__pyx_t_12);
  5363. #endif
  5364. }
  5365. } else {
  5366. __pyx_t_12 = __pyx_t_21(__pyx_t_3);
  5367. if (unlikely(!__pyx_t_12)) {
  5368. PyObject* exc_type = PyErr_Occurred();
  5369. if (exc_type) {
  5370. if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  5371. else __PYX_ERR(0, 372, __pyx_L1_error)
  5372. }
  5373. break;
  5374. }
  5375. __Pyx_GOTREF(__pyx_t_12);
  5376. }
  5377. __Pyx_DECREF_SET(__pyx_v_ch, __pyx_t_12);
  5378. __pyx_t_12 = 0;
  5379. /* "yarl/_quoting.pyx":373
  5380. * h = hex(ord(ch)).upper()[2:]
  5381. * for ch in h:
  5382. * ret.append(ch) # <<<<<<<<<<<<<<
  5383. * continue
  5384. *
  5385. */
  5386. __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_ch); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 373, __pyx_L1_error)
  5387. /* "yarl/_quoting.pyx":372
  5388. * ret.append('%')
  5389. * h = hex(ord(ch)).upper()[2:]
  5390. * for ch in h: # <<<<<<<<<<<<<<
  5391. * ret.append(ch)
  5392. * continue
  5393. */
  5394. }
  5395. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5396. /* "yarl/_quoting.pyx":374
  5397. * for ch in h:
  5398. * ret.append(ch)
  5399. * continue # <<<<<<<<<<<<<<
  5400. *
  5401. * ret.append(ch)
  5402. */
  5403. goto __pyx_L4_continue;
  5404. /* "yarl/_quoting.pyx":369
  5405. * continue
  5406. *
  5407. * if ch in self._unsafe: # <<<<<<<<<<<<<<
  5408. * ret.append('%')
  5409. * h = hex(ord(ch)).upper()[2:]
  5410. */
  5411. }
  5412. /* "yarl/_quoting.pyx":376
  5413. * continue
  5414. *
  5415. * ret.append(ch) # <<<<<<<<<<<<<<
  5416. *
  5417. * if pcts:
  5418. */
  5419. __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_ch); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 376, __pyx_L1_error)
  5420. __pyx_L4_continue:;
  5421. }
  5422. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5423. /* "yarl/_quoting.pyx":378
  5424. * ret.append(ch)
  5425. *
  5426. * if pcts: # <<<<<<<<<<<<<<
  5427. * try:
  5428. * unquoted = pcts.decode('utf8')
  5429. */
  5430. __pyx_t_17 = (PyByteArray_GET_SIZE(__pyx_v_pcts) != 0);
  5431. if (__pyx_t_17) {
  5432. /* "yarl/_quoting.pyx":379
  5433. *
  5434. * if pcts:
  5435. * try: # <<<<<<<<<<<<<<
  5436. * unquoted = pcts.decode('utf8')
  5437. * except UnicodeDecodeError:
  5438. */
  5439. {
  5440. __Pyx_PyThreadState_declare
  5441. __Pyx_PyThreadState_assign
  5442. __Pyx_ExceptionSave(&__pyx_t_16, &__pyx_t_15, &__pyx_t_14);
  5443. __Pyx_XGOTREF(__pyx_t_16);
  5444. __Pyx_XGOTREF(__pyx_t_15);
  5445. __Pyx_XGOTREF(__pyx_t_14);
  5446. /*try:*/ {
  5447. /* "yarl/_quoting.pyx":380
  5448. * if pcts:
  5449. * try:
  5450. * unquoted = pcts.decode('utf8') # <<<<<<<<<<<<<<
  5451. * except UnicodeDecodeError:
  5452. * ret.append(last_pct) # %F8
  5453. */
  5454. __pyx_t_3 = __Pyx_decode_bytearray(__pyx_v_pcts, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 380, __pyx_L30_error)
  5455. __Pyx_GOTREF(__pyx_t_3);
  5456. __Pyx_XDECREF_SET(__pyx_v_unquoted, ((PyObject*)__pyx_t_3));
  5457. __pyx_t_3 = 0;
  5458. /* "yarl/_quoting.pyx":379
  5459. *
  5460. * if pcts:
  5461. * try: # <<<<<<<<<<<<<<
  5462. * unquoted = pcts.decode('utf8')
  5463. * except UnicodeDecodeError:
  5464. */
  5465. }
  5466. /* "yarl/_quoting.pyx":384
  5467. * ret.append(last_pct) # %F8
  5468. * else:
  5469. * if self._qs and unquoted in '+=&;': # <<<<<<<<<<<<<<
  5470. * ret.append(self._qs_quoter(unquoted))
  5471. * elif unquoted in self._unsafe:
  5472. */
  5473. /*else:*/ {
  5474. __pyx_t_18 = (__pyx_v_self->_qs != 0);
  5475. if (__pyx_t_18) {
  5476. } else {
  5477. __pyx_t_17 = __pyx_t_18;
  5478. goto __pyx_L37_bool_binop_done;
  5479. }
  5480. __pyx_t_18 = (__Pyx_PyUnicode_ContainsTF(__pyx_v_unquoted, __pyx_kp_u__6, Py_EQ)); if (unlikely(__pyx_t_18 < 0)) __PYX_ERR(0, 384, __pyx_L32_except_error)
  5481. __pyx_t_2 = (__pyx_t_18 != 0);
  5482. __pyx_t_17 = __pyx_t_2;
  5483. __pyx_L37_bool_binop_done:;
  5484. if (__pyx_t_17) {
  5485. /* "yarl/_quoting.pyx":385
  5486. * else:
  5487. * if self._qs and unquoted in '+=&;':
  5488. * ret.append(self._qs_quoter(unquoted)) # <<<<<<<<<<<<<<
  5489. * elif unquoted in self._unsafe:
  5490. * ret.append(self._quoter(unquoted))
  5491. */
  5492. __Pyx_INCREF(((PyObject *)__pyx_v_self->_qs_quoter));
  5493. __pyx_t_12 = ((PyObject *)__pyx_v_self->_qs_quoter); __pyx_t_11 = NULL;
  5494. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
  5495. __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12);
  5496. if (likely(__pyx_t_11)) {
  5497. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
  5498. __Pyx_INCREF(__pyx_t_11);
  5499. __Pyx_INCREF(function);
  5500. __Pyx_DECREF_SET(__pyx_t_12, function);
  5501. }
  5502. }
  5503. if (!__pyx_t_11) {
  5504. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_unquoted); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 385, __pyx_L32_except_error)
  5505. __Pyx_GOTREF(__pyx_t_3);
  5506. } else {
  5507. #if CYTHON_FAST_PYCALL
  5508. if (PyFunction_Check(__pyx_t_12)) {
  5509. PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_unquoted};
  5510. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 385, __pyx_L32_except_error)
  5511. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  5512. __Pyx_GOTREF(__pyx_t_3);
  5513. } else
  5514. #endif
  5515. #if CYTHON_FAST_PYCCALL
  5516. if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
  5517. PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_unquoted};
  5518. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 385, __pyx_L32_except_error)
  5519. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  5520. __Pyx_GOTREF(__pyx_t_3);
  5521. } else
  5522. #endif
  5523. {
  5524. __pyx_t_19 = PyTuple_New(1+1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 385, __pyx_L32_except_error)
  5525. __Pyx_GOTREF(__pyx_t_19);
  5526. __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_11); __pyx_t_11 = NULL;
  5527. __Pyx_INCREF(__pyx_v_unquoted);
  5528. __Pyx_GIVEREF(__pyx_v_unquoted);
  5529. PyTuple_SET_ITEM(__pyx_t_19, 0+1, __pyx_v_unquoted);
  5530. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_19, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 385, __pyx_L32_except_error)
  5531. __Pyx_GOTREF(__pyx_t_3);
  5532. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  5533. }
  5534. }
  5535. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  5536. __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_t_3); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 385, __pyx_L32_except_error)
  5537. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5538. /* "yarl/_quoting.pyx":384
  5539. * ret.append(last_pct) # %F8
  5540. * else:
  5541. * if self._qs and unquoted in '+=&;': # <<<<<<<<<<<<<<
  5542. * ret.append(self._qs_quoter(unquoted))
  5543. * elif unquoted in self._unsafe:
  5544. */
  5545. goto __pyx_L36;
  5546. }
  5547. /* "yarl/_quoting.pyx":386
  5548. * if self._qs and unquoted in '+=&;':
  5549. * ret.append(self._qs_quoter(unquoted))
  5550. * elif unquoted in self._unsafe: # <<<<<<<<<<<<<<
  5551. * ret.append(self._quoter(unquoted))
  5552. * else:
  5553. */
  5554. if (unlikely(__pyx_v_self->_unsafe == Py_None)) {
  5555. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
  5556. __PYX_ERR(0, 386, __pyx_L32_except_error)
  5557. }
  5558. __pyx_t_17 = (__Pyx_PyUnicode_ContainsTF(__pyx_v_unquoted, __pyx_v_self->_unsafe, Py_EQ)); if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 386, __pyx_L32_except_error)
  5559. __pyx_t_2 = (__pyx_t_17 != 0);
  5560. if (__pyx_t_2) {
  5561. /* "yarl/_quoting.pyx":387
  5562. * ret.append(self._qs_quoter(unquoted))
  5563. * elif unquoted in self._unsafe:
  5564. * ret.append(self._quoter(unquoted)) # <<<<<<<<<<<<<<
  5565. * else:
  5566. * ret.append(unquoted)
  5567. */
  5568. __Pyx_INCREF(((PyObject *)__pyx_v_self->_quoter));
  5569. __pyx_t_12 = ((PyObject *)__pyx_v_self->_quoter); __pyx_t_19 = NULL;
  5570. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
  5571. __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_12);
  5572. if (likely(__pyx_t_19)) {
  5573. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
  5574. __Pyx_INCREF(__pyx_t_19);
  5575. __Pyx_INCREF(function);
  5576. __Pyx_DECREF_SET(__pyx_t_12, function);
  5577. }
  5578. }
  5579. if (!__pyx_t_19) {
  5580. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_unquoted); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 387, __pyx_L32_except_error)
  5581. __Pyx_GOTREF(__pyx_t_3);
  5582. } else {
  5583. #if CYTHON_FAST_PYCALL
  5584. if (PyFunction_Check(__pyx_t_12)) {
  5585. PyObject *__pyx_temp[2] = {__pyx_t_19, __pyx_v_unquoted};
  5586. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 387, __pyx_L32_except_error)
  5587. __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
  5588. __Pyx_GOTREF(__pyx_t_3);
  5589. } else
  5590. #endif
  5591. #if CYTHON_FAST_PYCCALL
  5592. if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
  5593. PyObject *__pyx_temp[2] = {__pyx_t_19, __pyx_v_unquoted};
  5594. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 387, __pyx_L32_except_error)
  5595. __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
  5596. __Pyx_GOTREF(__pyx_t_3);
  5597. } else
  5598. #endif
  5599. {
  5600. __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 387, __pyx_L32_except_error)
  5601. __Pyx_GOTREF(__pyx_t_11);
  5602. __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_19); __pyx_t_19 = NULL;
  5603. __Pyx_INCREF(__pyx_v_unquoted);
  5604. __Pyx_GIVEREF(__pyx_v_unquoted);
  5605. PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_unquoted);
  5606. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 387, __pyx_L32_except_error)
  5607. __Pyx_GOTREF(__pyx_t_3);
  5608. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  5609. }
  5610. }
  5611. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  5612. __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_t_3); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 387, __pyx_L32_except_error)
  5613. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5614. /* "yarl/_quoting.pyx":386
  5615. * if self._qs and unquoted in '+=&;':
  5616. * ret.append(self._qs_quoter(unquoted))
  5617. * elif unquoted in self._unsafe: # <<<<<<<<<<<<<<
  5618. * ret.append(self._quoter(unquoted))
  5619. * else:
  5620. */
  5621. goto __pyx_L36;
  5622. }
  5623. /* "yarl/_quoting.pyx":389
  5624. * ret.append(self._quoter(unquoted))
  5625. * else:
  5626. * ret.append(unquoted) # <<<<<<<<<<<<<<
  5627. * return ''.join(ret)
  5628. */
  5629. /*else*/ {
  5630. __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_unquoted); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 389, __pyx_L32_except_error)
  5631. }
  5632. __pyx_L36:;
  5633. }
  5634. __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
  5635. __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  5636. __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  5637. goto __pyx_L35_try_end;
  5638. __pyx_L30_error:;
  5639. __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
  5640. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  5641. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  5642. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5643. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5644. /* "yarl/_quoting.pyx":381
  5645. * try:
  5646. * unquoted = pcts.decode('utf8')
  5647. * except UnicodeDecodeError: # <<<<<<<<<<<<<<
  5648. * ret.append(last_pct) # %F8
  5649. * else:
  5650. */
  5651. __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
  5652. if (__pyx_t_7) {
  5653. __Pyx_AddTraceback("yarl._quoting._Unquoter._do_unquote", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5654. if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_12, &__pyx_t_11) < 0) __PYX_ERR(0, 381, __pyx_L32_except_error)
  5655. __Pyx_GOTREF(__pyx_t_3);
  5656. __Pyx_GOTREF(__pyx_t_12);
  5657. __Pyx_GOTREF(__pyx_t_11);
  5658. /* "yarl/_quoting.pyx":382
  5659. * unquoted = pcts.decode('utf8')
  5660. * except UnicodeDecodeError:
  5661. * ret.append(last_pct) # %F8 # <<<<<<<<<<<<<<
  5662. * else:
  5663. * if self._qs and unquoted in '+=&;':
  5664. */
  5665. __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_last_pct); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 382, __pyx_L32_except_error)
  5666. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5667. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  5668. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  5669. goto __pyx_L31_exception_handled;
  5670. }
  5671. goto __pyx_L32_except_error;
  5672. __pyx_L32_except_error:;
  5673. /* "yarl/_quoting.pyx":379
  5674. *
  5675. * if pcts:
  5676. * try: # <<<<<<<<<<<<<<
  5677. * unquoted = pcts.decode('utf8')
  5678. * except UnicodeDecodeError:
  5679. */
  5680. __Pyx_XGIVEREF(__pyx_t_16);
  5681. __Pyx_XGIVEREF(__pyx_t_15);
  5682. __Pyx_XGIVEREF(__pyx_t_14);
  5683. __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_15, __pyx_t_14);
  5684. goto __pyx_L1_error;
  5685. __pyx_L31_exception_handled:;
  5686. __Pyx_XGIVEREF(__pyx_t_16);
  5687. __Pyx_XGIVEREF(__pyx_t_15);
  5688. __Pyx_XGIVEREF(__pyx_t_14);
  5689. __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_15, __pyx_t_14);
  5690. __pyx_L35_try_end:;
  5691. }
  5692. /* "yarl/_quoting.pyx":378
  5693. * ret.append(ch)
  5694. *
  5695. * if pcts: # <<<<<<<<<<<<<<
  5696. * try:
  5697. * unquoted = pcts.decode('utf8')
  5698. */
  5699. }
  5700. /* "yarl/_quoting.pyx":390
  5701. * else:
  5702. * ret.append(unquoted)
  5703. * return ''.join(ret) # <<<<<<<<<<<<<<
  5704. */
  5705. __Pyx_XDECREF(__pyx_r);
  5706. __pyx_t_11 = PyUnicode_Join(__pyx_kp_u_, __pyx_v_ret); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 390, __pyx_L1_error)
  5707. __Pyx_GOTREF(__pyx_t_11);
  5708. __pyx_r = ((PyObject*)__pyx_t_11);
  5709. __pyx_t_11 = 0;
  5710. goto __pyx_L0;
  5711. /* "yarl/_quoting.pyx":324
  5712. * return self._do_unquote(<str>val)
  5713. *
  5714. * cdef str _do_unquote(self, str val): # <<<<<<<<<<<<<<
  5715. * if len(val) == 0:
  5716. * return val
  5717. */
  5718. /* function exit code */
  5719. __pyx_L1_error:;
  5720. __Pyx_XDECREF(__pyx_t_3);
  5721. __Pyx_XDECREF(__pyx_t_4);
  5722. __Pyx_XDECREF(__pyx_t_11);
  5723. __Pyx_XDECREF(__pyx_t_12);
  5724. __Pyx_XDECREF(__pyx_t_19);
  5725. __Pyx_AddTraceback("yarl._quoting._Unquoter._do_unquote", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5726. __pyx_r = 0;
  5727. __pyx_L0:;
  5728. __Pyx_XDECREF(__pyx_v_pct);
  5729. __Pyx_XDECREF(__pyx_v_last_pct);
  5730. __Pyx_XDECREF(__pyx_v_pcts);
  5731. __Pyx_XDECREF(__pyx_v_ret);
  5732. __Pyx_XDECREF(__pyx_v_unquoted);
  5733. __Pyx_XDECREF(__pyx_v_ch);
  5734. __Pyx_XDECREF(__pyx_v_h);
  5735. __Pyx_XGIVEREF(__pyx_r);
  5736. __Pyx_RefNannyFinishContext();
  5737. return __pyx_r;
  5738. }
  5739. /* "(tree fragment)":1
  5740. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  5741. * cdef bint use_setstate
  5742. * state = (self._qs, self._qs_quoter, self._quoter, self._unsafe)
  5743. */
  5744. /* Python wrapper */
  5745. static PyObject *__pyx_pw_4yarl_8_quoting_9_Unquoter_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  5746. static PyObject *__pyx_pw_4yarl_8_quoting_9_Unquoter_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  5747. PyObject *__pyx_r = 0;
  5748. __Pyx_RefNannyDeclarations
  5749. __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  5750. __pyx_r = __pyx_pf_4yarl_8_quoting_9_Unquoter_4__reduce_cython__(((struct __pyx_obj_4yarl_8_quoting__Unquoter *)__pyx_v_self));
  5751. /* function exit code */
  5752. __Pyx_RefNannyFinishContext();
  5753. return __pyx_r;
  5754. }
  5755. static PyObject *__pyx_pf_4yarl_8_quoting_9_Unquoter_4__reduce_cython__(struct __pyx_obj_4yarl_8_quoting__Unquoter *__pyx_v_self) {
  5756. int __pyx_v_use_setstate;
  5757. PyObject *__pyx_v_state = NULL;
  5758. PyObject *__pyx_v__dict = NULL;
  5759. PyObject *__pyx_r = NULL;
  5760. __Pyx_RefNannyDeclarations
  5761. PyObject *__pyx_t_1 = NULL;
  5762. PyObject *__pyx_t_2 = NULL;
  5763. int __pyx_t_3;
  5764. int __pyx_t_4;
  5765. int __pyx_t_5;
  5766. PyObject *__pyx_t_6 = NULL;
  5767. __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  5768. /* "(tree fragment)":3
  5769. * def __reduce_cython__(self):
  5770. * cdef bint use_setstate
  5771. * state = (self._qs, self._qs_quoter, self._quoter, self._unsafe) # <<<<<<<<<<<<<<
  5772. * _dict = getattr(self, '__dict__', None)
  5773. * if _dict is not None:
  5774. */
  5775. __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_qs); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3, __pyx_L1_error)
  5776. __Pyx_GOTREF(__pyx_t_1);
  5777. __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3, __pyx_L1_error)
  5778. __Pyx_GOTREF(__pyx_t_2);
  5779. __Pyx_GIVEREF(__pyx_t_1);
  5780. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  5781. __Pyx_INCREF(((PyObject *)__pyx_v_self->_qs_quoter));
  5782. __Pyx_GIVEREF(((PyObject *)__pyx_v_self->_qs_quoter));
  5783. PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self->_qs_quoter));
  5784. __Pyx_INCREF(((PyObject *)__pyx_v_self->_quoter));
  5785. __Pyx_GIVEREF(((PyObject *)__pyx_v_self->_quoter));
  5786. PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_self->_quoter));
  5787. __Pyx_INCREF(__pyx_v_self->_unsafe);
  5788. __Pyx_GIVEREF(__pyx_v_self->_unsafe);
  5789. PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_self->_unsafe);
  5790. __pyx_t_1 = 0;
  5791. __pyx_v_state = ((PyObject*)__pyx_t_2);
  5792. __pyx_t_2 = 0;
  5793. /* "(tree fragment)":4
  5794. * cdef bint use_setstate
  5795. * state = (self._qs, self._qs_quoter, self._quoter, self._unsafe)
  5796. * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<<
  5797. * if _dict is not None:
  5798. * state += (_dict,)
  5799. */
  5800. __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4, __pyx_L1_error)
  5801. __Pyx_GOTREF(__pyx_t_2);
  5802. __pyx_v__dict = __pyx_t_2;
  5803. __pyx_t_2 = 0;
  5804. /* "(tree fragment)":5
  5805. * state = (self._qs, self._qs_quoter, self._quoter, self._unsafe)
  5806. * _dict = getattr(self, '__dict__', None)
  5807. * if _dict is not None: # <<<<<<<<<<<<<<
  5808. * state += (_dict,)
  5809. * use_setstate = True
  5810. */
  5811. __pyx_t_3 = (__pyx_v__dict != Py_None);
  5812. __pyx_t_4 = (__pyx_t_3 != 0);
  5813. if (__pyx_t_4) {
  5814. /* "(tree fragment)":6
  5815. * _dict = getattr(self, '__dict__', None)
  5816. * if _dict is not None:
  5817. * state += (_dict,) # <<<<<<<<<<<<<<
  5818. * use_setstate = True
  5819. * else:
  5820. */
  5821. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
  5822. __Pyx_GOTREF(__pyx_t_2);
  5823. __Pyx_INCREF(__pyx_v__dict);
  5824. __Pyx_GIVEREF(__pyx_v__dict);
  5825. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
  5826. __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  5827. __Pyx_GOTREF(__pyx_t_1);
  5828. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5829. __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
  5830. __pyx_t_1 = 0;
  5831. /* "(tree fragment)":7
  5832. * if _dict is not None:
  5833. * state += (_dict,)
  5834. * use_setstate = True # <<<<<<<<<<<<<<
  5835. * else:
  5836. * use_setstate = self._qs_quoter is not None or self._quoter is not None or self._unsafe is not None
  5837. */
  5838. __pyx_v_use_setstate = 1;
  5839. /* "(tree fragment)":5
  5840. * state = (self._qs, self._qs_quoter, self._quoter, self._unsafe)
  5841. * _dict = getattr(self, '__dict__', None)
  5842. * if _dict is not None: # <<<<<<<<<<<<<<
  5843. * state += (_dict,)
  5844. * use_setstate = True
  5845. */
  5846. goto __pyx_L3;
  5847. }
  5848. /* "(tree fragment)":9
  5849. * use_setstate = True
  5850. * else:
  5851. * use_setstate = self._qs_quoter is not None or self._quoter is not None or self._unsafe is not None # <<<<<<<<<<<<<<
  5852. * if use_setstate:
  5853. * return __pyx_unpickle__Unquoter, (type(self), 0x276577d, None), state
  5854. */
  5855. /*else*/ {
  5856. __pyx_t_3 = (((PyObject *)__pyx_v_self->_qs_quoter) != Py_None);
  5857. __pyx_t_5 = (__pyx_t_3 != 0);
  5858. if (!__pyx_t_5) {
  5859. } else {
  5860. __pyx_t_4 = __pyx_t_5;
  5861. goto __pyx_L4_bool_binop_done;
  5862. }
  5863. __pyx_t_5 = (((PyObject *)__pyx_v_self->_quoter) != Py_None);
  5864. __pyx_t_3 = (__pyx_t_5 != 0);
  5865. if (!__pyx_t_3) {
  5866. } else {
  5867. __pyx_t_4 = __pyx_t_3;
  5868. goto __pyx_L4_bool_binop_done;
  5869. }
  5870. __pyx_t_3 = (__pyx_v_self->_unsafe != ((PyObject*)Py_None));
  5871. __pyx_t_5 = (__pyx_t_3 != 0);
  5872. __pyx_t_4 = __pyx_t_5;
  5873. __pyx_L4_bool_binop_done:;
  5874. __pyx_v_use_setstate = __pyx_t_4;
  5875. }
  5876. __pyx_L3:;
  5877. /* "(tree fragment)":10
  5878. * else:
  5879. * use_setstate = self._qs_quoter is not None or self._quoter is not None or self._unsafe is not None
  5880. * if use_setstate: # <<<<<<<<<<<<<<
  5881. * return __pyx_unpickle__Unquoter, (type(self), 0x276577d, None), state
  5882. * else:
  5883. */
  5884. __pyx_t_4 = (__pyx_v_use_setstate != 0);
  5885. if (__pyx_t_4) {
  5886. /* "(tree fragment)":11
  5887. * use_setstate = self._qs_quoter is not None or self._quoter is not None or self._unsafe is not None
  5888. * if use_setstate:
  5889. * return __pyx_unpickle__Unquoter, (type(self), 0x276577d, None), state # <<<<<<<<<<<<<<
  5890. * else:
  5891. * return __pyx_unpickle__Unquoter, (type(self), 0x276577d, state)
  5892. */
  5893. __Pyx_XDECREF(__pyx_r);
  5894. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle__Unquoter); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 11, __pyx_L1_error)
  5895. __Pyx_GOTREF(__pyx_t_1);
  5896. __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 11, __pyx_L1_error)
  5897. __Pyx_GOTREF(__pyx_t_2);
  5898. __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
  5899. __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
  5900. PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
  5901. __Pyx_INCREF(__pyx_int_41310077);
  5902. __Pyx_GIVEREF(__pyx_int_41310077);
  5903. PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_41310077);
  5904. __Pyx_INCREF(Py_None);
  5905. __Pyx_GIVEREF(Py_None);
  5906. PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
  5907. __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 11, __pyx_L1_error)
  5908. __Pyx_GOTREF(__pyx_t_6);
  5909. __Pyx_GIVEREF(__pyx_t_1);
  5910. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
  5911. __Pyx_GIVEREF(__pyx_t_2);
  5912. PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
  5913. __Pyx_INCREF(__pyx_v_state);
  5914. __Pyx_GIVEREF(__pyx_v_state);
  5915. PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
  5916. __pyx_t_1 = 0;
  5917. __pyx_t_2 = 0;
  5918. __pyx_r = __pyx_t_6;
  5919. __pyx_t_6 = 0;
  5920. goto __pyx_L0;
  5921. /* "(tree fragment)":10
  5922. * else:
  5923. * use_setstate = self._qs_quoter is not None or self._quoter is not None or self._unsafe is not None
  5924. * if use_setstate: # <<<<<<<<<<<<<<
  5925. * return __pyx_unpickle__Unquoter, (type(self), 0x276577d, None), state
  5926. * else:
  5927. */
  5928. }
  5929. /* "(tree fragment)":13
  5930. * return __pyx_unpickle__Unquoter, (type(self), 0x276577d, None), state
  5931. * else:
  5932. * return __pyx_unpickle__Unquoter, (type(self), 0x276577d, state) # <<<<<<<<<<<<<<
  5933. * def __setstate_cython__(self, __pyx_state):
  5934. * __pyx_unpickle__Unquoter__set_state(self, __pyx_state)
  5935. */
  5936. /*else*/ {
  5937. __Pyx_XDECREF(__pyx_r);
  5938. __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_pyx_unpickle__Unquoter); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
  5939. __Pyx_GOTREF(__pyx_t_6);
  5940. __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
  5941. __Pyx_GOTREF(__pyx_t_2);
  5942. __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
  5943. __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
  5944. PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
  5945. __Pyx_INCREF(__pyx_int_41310077);
  5946. __Pyx_GIVEREF(__pyx_int_41310077);
  5947. PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_41310077);
  5948. __Pyx_INCREF(__pyx_v_state);
  5949. __Pyx_GIVEREF(__pyx_v_state);
  5950. PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
  5951. __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
  5952. __Pyx_GOTREF(__pyx_t_1);
  5953. __Pyx_GIVEREF(__pyx_t_6);
  5954. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
  5955. __Pyx_GIVEREF(__pyx_t_2);
  5956. PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
  5957. __pyx_t_6 = 0;
  5958. __pyx_t_2 = 0;
  5959. __pyx_r = __pyx_t_1;
  5960. __pyx_t_1 = 0;
  5961. goto __pyx_L0;
  5962. }
  5963. /* "(tree fragment)":1
  5964. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  5965. * cdef bint use_setstate
  5966. * state = (self._qs, self._qs_quoter, self._quoter, self._unsafe)
  5967. */
  5968. /* function exit code */
  5969. __pyx_L1_error:;
  5970. __Pyx_XDECREF(__pyx_t_1);
  5971. __Pyx_XDECREF(__pyx_t_2);
  5972. __Pyx_XDECREF(__pyx_t_6);
  5973. __Pyx_AddTraceback("yarl._quoting._Unquoter.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5974. __pyx_r = NULL;
  5975. __pyx_L0:;
  5976. __Pyx_XDECREF(__pyx_v_state);
  5977. __Pyx_XDECREF(__pyx_v__dict);
  5978. __Pyx_XGIVEREF(__pyx_r);
  5979. __Pyx_RefNannyFinishContext();
  5980. return __pyx_r;
  5981. }
  5982. /* "(tree fragment)":14
  5983. * else:
  5984. * return __pyx_unpickle__Unquoter, (type(self), 0x276577d, state)
  5985. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  5986. * __pyx_unpickle__Unquoter__set_state(self, __pyx_state)
  5987. */
  5988. /* Python wrapper */
  5989. static PyObject *__pyx_pw_4yarl_8_quoting_9_Unquoter_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
  5990. static PyObject *__pyx_pw_4yarl_8_quoting_9_Unquoter_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  5991. PyObject *__pyx_r = 0;
  5992. __Pyx_RefNannyDeclarations
  5993. __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  5994. __pyx_r = __pyx_pf_4yarl_8_quoting_9_Unquoter_6__setstate_cython__(((struct __pyx_obj_4yarl_8_quoting__Unquoter *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
  5995. /* function exit code */
  5996. __Pyx_RefNannyFinishContext();
  5997. return __pyx_r;
  5998. }
  5999. static PyObject *__pyx_pf_4yarl_8_quoting_9_Unquoter_6__setstate_cython__(struct __pyx_obj_4yarl_8_quoting__Unquoter *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  6000. PyObject *__pyx_r = NULL;
  6001. __Pyx_RefNannyDeclarations
  6002. PyObject *__pyx_t_1 = NULL;
  6003. __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  6004. /* "(tree fragment)":15
  6005. * return __pyx_unpickle__Unquoter, (type(self), 0x276577d, state)
  6006. * def __setstate_cython__(self, __pyx_state):
  6007. * __pyx_unpickle__Unquoter__set_state(self, __pyx_state) # <<<<<<<<<<<<<<
  6008. */
  6009. if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 15, __pyx_L1_error)
  6010. __pyx_t_1 = __pyx_f_4yarl_8_quoting___pyx_unpickle__Unquoter__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
  6011. __Pyx_GOTREF(__pyx_t_1);
  6012. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6013. /* "(tree fragment)":14
  6014. * else:
  6015. * return __pyx_unpickle__Unquoter, (type(self), 0x276577d, state)
  6016. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  6017. * __pyx_unpickle__Unquoter__set_state(self, __pyx_state)
  6018. */
  6019. /* function exit code */
  6020. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6021. goto __pyx_L0;
  6022. __pyx_L1_error:;
  6023. __Pyx_XDECREF(__pyx_t_1);
  6024. __Pyx_AddTraceback("yarl._quoting._Unquoter.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6025. __pyx_r = NULL;
  6026. __pyx_L0:;
  6027. __Pyx_XGIVEREF(__pyx_r);
  6028. __Pyx_RefNannyFinishContext();
  6029. return __pyx_r;
  6030. }
  6031. /* "(tree fragment)":1
  6032. * def __pyx_unpickle__Quoter(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
  6033. * if __pyx_checksum != 0x8f193a6:
  6034. * from pickle import PickleError as __pyx_PickleError
  6035. */
  6036. /* Python wrapper */
  6037. static PyObject *__pyx_pw_4yarl_8_quoting_1__pyx_unpickle__Quoter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  6038. static PyMethodDef __pyx_mdef_4yarl_8_quoting_1__pyx_unpickle__Quoter = {"__pyx_unpickle__Quoter", (PyCFunction)__pyx_pw_4yarl_8_quoting_1__pyx_unpickle__Quoter, METH_VARARGS|METH_KEYWORDS, 0};
  6039. static PyObject *__pyx_pw_4yarl_8_quoting_1__pyx_unpickle__Quoter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  6040. PyObject *__pyx_v___pyx_type = 0;
  6041. long __pyx_v___pyx_checksum;
  6042. PyObject *__pyx_v___pyx_state = 0;
  6043. PyObject *__pyx_r = 0;
  6044. __Pyx_RefNannyDeclarations
  6045. __Pyx_RefNannySetupContext("__pyx_unpickle__Quoter (wrapper)", 0);
  6046. {
  6047. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
  6048. PyObject* values[3] = {0,0,0};
  6049. if (unlikely(__pyx_kwds)) {
  6050. Py_ssize_t kw_args;
  6051. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  6052. switch (pos_args) {
  6053. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6054. CYTHON_FALLTHROUGH;
  6055. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6056. CYTHON_FALLTHROUGH;
  6057. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6058. CYTHON_FALLTHROUGH;
  6059. case 0: break;
  6060. default: goto __pyx_L5_argtuple_error;
  6061. }
  6062. kw_args = PyDict_Size(__pyx_kwds);
  6063. switch (pos_args) {
  6064. case 0:
  6065. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
  6066. else goto __pyx_L5_argtuple_error;
  6067. CYTHON_FALLTHROUGH;
  6068. case 1:
  6069. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
  6070. else {
  6071. __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__Quoter", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
  6072. }
  6073. CYTHON_FALLTHROUGH;
  6074. case 2:
  6075. if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
  6076. else {
  6077. __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__Quoter", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
  6078. }
  6079. }
  6080. if (unlikely(kw_args > 0)) {
  6081. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle__Quoter") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
  6082. }
  6083. } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
  6084. goto __pyx_L5_argtuple_error;
  6085. } else {
  6086. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6087. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6088. values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6089. }
  6090. __pyx_v___pyx_type = values[0];
  6091. __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
  6092. __pyx_v___pyx_state = values[2];
  6093. }
  6094. goto __pyx_L4_argument_unpacking_done;
  6095. __pyx_L5_argtuple_error:;
  6096. __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__Quoter", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  6097. __pyx_L3_error:;
  6098. __Pyx_AddTraceback("yarl._quoting.__pyx_unpickle__Quoter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6099. __Pyx_RefNannyFinishContext();
  6100. return NULL;
  6101. __pyx_L4_argument_unpacking_done:;
  6102. __pyx_r = __pyx_pf_4yarl_8_quoting___pyx_unpickle__Quoter(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
  6103. /* function exit code */
  6104. __Pyx_RefNannyFinishContext();
  6105. return __pyx_r;
  6106. }
  6107. static PyObject *__pyx_pf_4yarl_8_quoting___pyx_unpickle__Quoter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  6108. PyObject *__pyx_v___pyx_PickleError = NULL;
  6109. PyObject *__pyx_v___pyx_result = NULL;
  6110. PyObject *__pyx_r = NULL;
  6111. __Pyx_RefNannyDeclarations
  6112. int __pyx_t_1;
  6113. PyObject *__pyx_t_2 = NULL;
  6114. PyObject *__pyx_t_3 = NULL;
  6115. PyObject *__pyx_t_4 = NULL;
  6116. PyObject *__pyx_t_5 = NULL;
  6117. PyObject *__pyx_t_6 = NULL;
  6118. int __pyx_t_7;
  6119. __Pyx_RefNannySetupContext("__pyx_unpickle__Quoter", 0);
  6120. /* "(tree fragment)":2
  6121. * def __pyx_unpickle__Quoter(__pyx_type, long __pyx_checksum, __pyx_state):
  6122. * if __pyx_checksum != 0x8f193a6: # <<<<<<<<<<<<<<
  6123. * from pickle import PickleError as __pyx_PickleError
  6124. * raise __pyx_PickleError("Incompatible checksums (%s vs 0x8f193a6 = (_protected_table, _qs, _safe_table))" % __pyx_checksum)
  6125. */
  6126. __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x8f193a6) != 0);
  6127. if (__pyx_t_1) {
  6128. /* "(tree fragment)":3
  6129. * def __pyx_unpickle__Quoter(__pyx_type, long __pyx_checksum, __pyx_state):
  6130. * if __pyx_checksum != 0x8f193a6:
  6131. * from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<<
  6132. * raise __pyx_PickleError("Incompatible checksums (%s vs 0x8f193a6 = (_protected_table, _qs, _safe_table))" % __pyx_checksum)
  6133. * __pyx_result = _Quoter.__new__(__pyx_type)
  6134. */
  6135. __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3, __pyx_L1_error)
  6136. __Pyx_GOTREF(__pyx_t_2);
  6137. __Pyx_INCREF(__pyx_n_s_PickleError);
  6138. __Pyx_GIVEREF(__pyx_n_s_PickleError);
  6139. PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
  6140. __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 3, __pyx_L1_error)
  6141. __Pyx_GOTREF(__pyx_t_3);
  6142. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6143. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3, __pyx_L1_error)
  6144. __Pyx_GOTREF(__pyx_t_2);
  6145. __Pyx_INCREF(__pyx_t_2);
  6146. __pyx_v___pyx_PickleError = __pyx_t_2;
  6147. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6148. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6149. /* "(tree fragment)":4
  6150. * if __pyx_checksum != 0x8f193a6:
  6151. * from pickle import PickleError as __pyx_PickleError
  6152. * raise __pyx_PickleError("Incompatible checksums (%s vs 0x8f193a6 = (_protected_table, _qs, _safe_table))" % __pyx_checksum) # <<<<<<<<<<<<<<
  6153. * __pyx_result = _Quoter.__new__(__pyx_type)
  6154. * if __pyx_state is not None:
  6155. */
  6156. __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4, __pyx_L1_error)
  6157. __Pyx_GOTREF(__pyx_t_2);
  6158. __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x8f, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4, __pyx_L1_error)
  6159. __Pyx_GOTREF(__pyx_t_4);
  6160. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6161. __Pyx_INCREF(__pyx_v___pyx_PickleError);
  6162. __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
  6163. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  6164. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
  6165. if (likely(__pyx_t_5)) {
  6166. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  6167. __Pyx_INCREF(__pyx_t_5);
  6168. __Pyx_INCREF(function);
  6169. __Pyx_DECREF_SET(__pyx_t_2, function);
  6170. }
  6171. }
  6172. if (!__pyx_t_5) {
  6173. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4, __pyx_L1_error)
  6174. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6175. __Pyx_GOTREF(__pyx_t_3);
  6176. } else {
  6177. #if CYTHON_FAST_PYCALL
  6178. if (PyFunction_Check(__pyx_t_2)) {
  6179. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
  6180. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4, __pyx_L1_error)
  6181. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6182. __Pyx_GOTREF(__pyx_t_3);
  6183. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6184. } else
  6185. #endif
  6186. #if CYTHON_FAST_PYCCALL
  6187. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  6188. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
  6189. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4, __pyx_L1_error)
  6190. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6191. __Pyx_GOTREF(__pyx_t_3);
  6192. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6193. } else
  6194. #endif
  6195. {
  6196. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 4, __pyx_L1_error)
  6197. __Pyx_GOTREF(__pyx_t_6);
  6198. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
  6199. __Pyx_GIVEREF(__pyx_t_4);
  6200. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
  6201. __pyx_t_4 = 0;
  6202. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4, __pyx_L1_error)
  6203. __Pyx_GOTREF(__pyx_t_3);
  6204. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6205. }
  6206. }
  6207. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6208. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  6209. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6210. __PYX_ERR(1, 4, __pyx_L1_error)
  6211. /* "(tree fragment)":2
  6212. * def __pyx_unpickle__Quoter(__pyx_type, long __pyx_checksum, __pyx_state):
  6213. * if __pyx_checksum != 0x8f193a6: # <<<<<<<<<<<<<<
  6214. * from pickle import PickleError as __pyx_PickleError
  6215. * raise __pyx_PickleError("Incompatible checksums (%s vs 0x8f193a6 = (_protected_table, _qs, _safe_table))" % __pyx_checksum)
  6216. */
  6217. }
  6218. /* "(tree fragment)":5
  6219. * from pickle import PickleError as __pyx_PickleError
  6220. * raise __pyx_PickleError("Incompatible checksums (%s vs 0x8f193a6 = (_protected_table, _qs, _safe_table))" % __pyx_checksum)
  6221. * __pyx_result = _Quoter.__new__(__pyx_type) # <<<<<<<<<<<<<<
  6222. * if __pyx_state is not None:
  6223. * __pyx_unpickle__Quoter__set_state(<_Quoter> __pyx_result, __pyx_state)
  6224. */
  6225. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4yarl_8_quoting__Quoter), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  6226. __Pyx_GOTREF(__pyx_t_2);
  6227. __pyx_t_6 = NULL;
  6228. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  6229. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
  6230. if (likely(__pyx_t_6)) {
  6231. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  6232. __Pyx_INCREF(__pyx_t_6);
  6233. __Pyx_INCREF(function);
  6234. __Pyx_DECREF_SET(__pyx_t_2, function);
  6235. }
  6236. }
  6237. if (!__pyx_t_6) {
  6238. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  6239. __Pyx_GOTREF(__pyx_t_3);
  6240. } else {
  6241. #if CYTHON_FAST_PYCALL
  6242. if (PyFunction_Check(__pyx_t_2)) {
  6243. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
  6244. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  6245. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  6246. __Pyx_GOTREF(__pyx_t_3);
  6247. } else
  6248. #endif
  6249. #if CYTHON_FAST_PYCCALL
  6250. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  6251. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
  6252. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  6253. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  6254. __Pyx_GOTREF(__pyx_t_3);
  6255. } else
  6256. #endif
  6257. {
  6258. __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
  6259. __Pyx_GOTREF(__pyx_t_4);
  6260. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
  6261. __Pyx_INCREF(__pyx_v___pyx_type);
  6262. __Pyx_GIVEREF(__pyx_v___pyx_type);
  6263. PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
  6264. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  6265. __Pyx_GOTREF(__pyx_t_3);
  6266. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6267. }
  6268. }
  6269. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6270. __pyx_v___pyx_result = __pyx_t_3;
  6271. __pyx_t_3 = 0;
  6272. /* "(tree fragment)":6
  6273. * raise __pyx_PickleError("Incompatible checksums (%s vs 0x8f193a6 = (_protected_table, _qs, _safe_table))" % __pyx_checksum)
  6274. * __pyx_result = _Quoter.__new__(__pyx_type)
  6275. * if __pyx_state is not None: # <<<<<<<<<<<<<<
  6276. * __pyx_unpickle__Quoter__set_state(<_Quoter> __pyx_result, __pyx_state)
  6277. * return __pyx_result
  6278. */
  6279. __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  6280. __pyx_t_7 = (__pyx_t_1 != 0);
  6281. if (__pyx_t_7) {
  6282. /* "(tree fragment)":7
  6283. * __pyx_result = _Quoter.__new__(__pyx_type)
  6284. * if __pyx_state is not None:
  6285. * __pyx_unpickle__Quoter__set_state(<_Quoter> __pyx_result, __pyx_state) # <<<<<<<<<<<<<<
  6286. * return __pyx_result
  6287. * cdef __pyx_unpickle__Quoter__set_state(_Quoter __pyx_result, tuple __pyx_state):
  6288. */
  6289. if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 7, __pyx_L1_error)
  6290. __pyx_t_3 = __pyx_f_4yarl_8_quoting___pyx_unpickle__Quoter__set_state(((struct __pyx_obj_4yarl_8_quoting__Quoter *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  6291. __Pyx_GOTREF(__pyx_t_3);
  6292. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6293. /* "(tree fragment)":6
  6294. * raise __pyx_PickleError("Incompatible checksums (%s vs 0x8f193a6 = (_protected_table, _qs, _safe_table))" % __pyx_checksum)
  6295. * __pyx_result = _Quoter.__new__(__pyx_type)
  6296. * if __pyx_state is not None: # <<<<<<<<<<<<<<
  6297. * __pyx_unpickle__Quoter__set_state(<_Quoter> __pyx_result, __pyx_state)
  6298. * return __pyx_result
  6299. */
  6300. }
  6301. /* "(tree fragment)":8
  6302. * if __pyx_state is not None:
  6303. * __pyx_unpickle__Quoter__set_state(<_Quoter> __pyx_result, __pyx_state)
  6304. * return __pyx_result # <<<<<<<<<<<<<<
  6305. * cdef __pyx_unpickle__Quoter__set_state(_Quoter __pyx_result, tuple __pyx_state):
  6306. * __pyx_result._protected_table = __pyx_state[0]; __pyx_result._qs = __pyx_state[1]; __pyx_result._safe_table = __pyx_state[2]
  6307. */
  6308. __Pyx_XDECREF(__pyx_r);
  6309. __Pyx_INCREF(__pyx_v___pyx_result);
  6310. __pyx_r = __pyx_v___pyx_result;
  6311. goto __pyx_L0;
  6312. /* "(tree fragment)":1
  6313. * def __pyx_unpickle__Quoter(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
  6314. * if __pyx_checksum != 0x8f193a6:
  6315. * from pickle import PickleError as __pyx_PickleError
  6316. */
  6317. /* function exit code */
  6318. __pyx_L1_error:;
  6319. __Pyx_XDECREF(__pyx_t_2);
  6320. __Pyx_XDECREF(__pyx_t_3);
  6321. __Pyx_XDECREF(__pyx_t_4);
  6322. __Pyx_XDECREF(__pyx_t_5);
  6323. __Pyx_XDECREF(__pyx_t_6);
  6324. __Pyx_AddTraceback("yarl._quoting.__pyx_unpickle__Quoter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6325. __pyx_r = NULL;
  6326. __pyx_L0:;
  6327. __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  6328. __Pyx_XDECREF(__pyx_v___pyx_result);
  6329. __Pyx_XGIVEREF(__pyx_r);
  6330. __Pyx_RefNannyFinishContext();
  6331. return __pyx_r;
  6332. }
  6333. /* "(tree fragment)":9
  6334. * __pyx_unpickle__Quoter__set_state(<_Quoter> __pyx_result, __pyx_state)
  6335. * return __pyx_result
  6336. * cdef __pyx_unpickle__Quoter__set_state(_Quoter __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
  6337. * __pyx_result._protected_table = __pyx_state[0]; __pyx_result._qs = __pyx_state[1]; __pyx_result._safe_table = __pyx_state[2]
  6338. * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
  6339. */
  6340. static PyObject *__pyx_f_4yarl_8_quoting___pyx_unpickle__Quoter__set_state(struct __pyx_obj_4yarl_8_quoting__Quoter *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  6341. PyObject *__pyx_r = NULL;
  6342. __Pyx_RefNannyDeclarations
  6343. PyObject *__pyx_t_1 = NULL;
  6344. uint8_t __pyx_t_2[16];
  6345. int __pyx_t_3;
  6346. Py_ssize_t __pyx_t_4;
  6347. int __pyx_t_5;
  6348. int __pyx_t_6;
  6349. PyObject *__pyx_t_7 = NULL;
  6350. PyObject *__pyx_t_8 = NULL;
  6351. PyObject *__pyx_t_9 = NULL;
  6352. PyObject *__pyx_t_10 = NULL;
  6353. __Pyx_RefNannySetupContext("__pyx_unpickle__Quoter__set_state", 0);
  6354. /* "(tree fragment)":10
  6355. * return __pyx_result
  6356. * cdef __pyx_unpickle__Quoter__set_state(_Quoter __pyx_result, tuple __pyx_state):
  6357. * __pyx_result._protected_table = __pyx_state[0]; __pyx_result._qs = __pyx_state[1]; __pyx_result._safe_table = __pyx_state[2] # <<<<<<<<<<<<<<
  6358. * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
  6359. * __pyx_result.__dict__.update(__pyx_state[3])
  6360. */
  6361. if (unlikely(__pyx_v___pyx_state == Py_None)) {
  6362. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
  6363. __PYX_ERR(1, 10, __pyx_L1_error)
  6364. }
  6365. __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 10, __pyx_L1_error)
  6366. __Pyx_GOTREF(__pyx_t_1);
  6367. if (unlikely(__Pyx_carray_from_py_uint8_t(__pyx_t_1, __pyx_t_2, 16) < 0)) __PYX_ERR(1, 10, __pyx_L1_error)
  6368. memcpy(&(__pyx_v___pyx_result->_protected_table[0]), __pyx_t_2, sizeof(__pyx_v___pyx_result->_protected_table[0]) * (16));
  6369. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6370. if (unlikely(__pyx_v___pyx_state == Py_None)) {
  6371. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
  6372. __PYX_ERR(1, 10, __pyx_L1_error)
  6373. }
  6374. __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 10, __pyx_L1_error)
  6375. __Pyx_GOTREF(__pyx_t_1);
  6376. __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 10, __pyx_L1_error)
  6377. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6378. __pyx_v___pyx_result->_qs = __pyx_t_3;
  6379. if (unlikely(__pyx_v___pyx_state == Py_None)) {
  6380. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
  6381. __PYX_ERR(1, 10, __pyx_L1_error)
  6382. }
  6383. __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 10, __pyx_L1_error)
  6384. __Pyx_GOTREF(__pyx_t_1);
  6385. if (unlikely(__Pyx_carray_from_py_uint8_t(__pyx_t_1, __pyx_t_2, 16) < 0)) __PYX_ERR(1, 10, __pyx_L1_error)
  6386. memcpy(&(__pyx_v___pyx_result->_safe_table[0]), __pyx_t_2, sizeof(__pyx_v___pyx_result->_safe_table[0]) * (16));
  6387. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6388. /* "(tree fragment)":11
  6389. * cdef __pyx_unpickle__Quoter__set_state(_Quoter __pyx_result, tuple __pyx_state):
  6390. * __pyx_result._protected_table = __pyx_state[0]; __pyx_result._qs = __pyx_state[1]; __pyx_result._safe_table = __pyx_state[2]
  6391. * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
  6392. * __pyx_result.__dict__.update(__pyx_state[3])
  6393. */
  6394. if (unlikely(__pyx_v___pyx_state == Py_None)) {
  6395. PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
  6396. __PYX_ERR(1, 11, __pyx_L1_error)
  6397. }
  6398. __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 11, __pyx_L1_error)
  6399. __pyx_t_5 = ((__pyx_t_4 > 3) != 0);
  6400. if (__pyx_t_5) {
  6401. } else {
  6402. __pyx_t_3 = __pyx_t_5;
  6403. goto __pyx_L4_bool_binop_done;
  6404. }
  6405. __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 11, __pyx_L1_error)
  6406. __pyx_t_6 = (__pyx_t_5 != 0);
  6407. __pyx_t_3 = __pyx_t_6;
  6408. __pyx_L4_bool_binop_done:;
  6409. if (__pyx_t_3) {
  6410. /* "(tree fragment)":12
  6411. * __pyx_result._protected_table = __pyx_state[0]; __pyx_result._qs = __pyx_state[1]; __pyx_result._safe_table = __pyx_state[2]
  6412. * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
  6413. * __pyx_result.__dict__.update(__pyx_state[3]) # <<<<<<<<<<<<<<
  6414. */
  6415. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 12, __pyx_L1_error)
  6416. __Pyx_GOTREF(__pyx_t_7);
  6417. __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 12, __pyx_L1_error)
  6418. __Pyx_GOTREF(__pyx_t_8);
  6419. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6420. if (unlikely(__pyx_v___pyx_state == Py_None)) {
  6421. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
  6422. __PYX_ERR(1, 12, __pyx_L1_error)
  6423. }
  6424. __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 12, __pyx_L1_error)
  6425. __Pyx_GOTREF(__pyx_t_7);
  6426. __pyx_t_9 = NULL;
  6427. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
  6428. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
  6429. if (likely(__pyx_t_9)) {
  6430. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
  6431. __Pyx_INCREF(__pyx_t_9);
  6432. __Pyx_INCREF(function);
  6433. __Pyx_DECREF_SET(__pyx_t_8, function);
  6434. }
  6435. }
  6436. if (!__pyx_t_9) {
  6437. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  6438. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6439. __Pyx_GOTREF(__pyx_t_1);
  6440. } else {
  6441. #if CYTHON_FAST_PYCALL
  6442. if (PyFunction_Check(__pyx_t_8)) {
  6443. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
  6444. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  6445. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  6446. __Pyx_GOTREF(__pyx_t_1);
  6447. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6448. } else
  6449. #endif
  6450. #if CYTHON_FAST_PYCCALL
  6451. if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
  6452. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_7};
  6453. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  6454. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  6455. __Pyx_GOTREF(__pyx_t_1);
  6456. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6457. } else
  6458. #endif
  6459. {
  6460. __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 12, __pyx_L1_error)
  6461. __Pyx_GOTREF(__pyx_t_10);
  6462. __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
  6463. __Pyx_GIVEREF(__pyx_t_7);
  6464. PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_7);
  6465. __pyx_t_7 = 0;
  6466. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  6467. __Pyx_GOTREF(__pyx_t_1);
  6468. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  6469. }
  6470. }
  6471. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6472. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6473. /* "(tree fragment)":11
  6474. * cdef __pyx_unpickle__Quoter__set_state(_Quoter __pyx_result, tuple __pyx_state):
  6475. * __pyx_result._protected_table = __pyx_state[0]; __pyx_result._qs = __pyx_state[1]; __pyx_result._safe_table = __pyx_state[2]
  6476. * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
  6477. * __pyx_result.__dict__.update(__pyx_state[3])
  6478. */
  6479. }
  6480. /* "(tree fragment)":9
  6481. * __pyx_unpickle__Quoter__set_state(<_Quoter> __pyx_result, __pyx_state)
  6482. * return __pyx_result
  6483. * cdef __pyx_unpickle__Quoter__set_state(_Quoter __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
  6484. * __pyx_result._protected_table = __pyx_state[0]; __pyx_result._qs = __pyx_state[1]; __pyx_result._safe_table = __pyx_state[2]
  6485. * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
  6486. */
  6487. /* function exit code */
  6488. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6489. goto __pyx_L0;
  6490. __pyx_L1_error:;
  6491. __Pyx_XDECREF(__pyx_t_1);
  6492. __Pyx_XDECREF(__pyx_t_7);
  6493. __Pyx_XDECREF(__pyx_t_8);
  6494. __Pyx_XDECREF(__pyx_t_9);
  6495. __Pyx_XDECREF(__pyx_t_10);
  6496. __Pyx_AddTraceback("yarl._quoting.__pyx_unpickle__Quoter__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6497. __pyx_r = 0;
  6498. __pyx_L0:;
  6499. __Pyx_XGIVEREF(__pyx_r);
  6500. __Pyx_RefNannyFinishContext();
  6501. return __pyx_r;
  6502. }
  6503. /* "(tree fragment)":1
  6504. * def __pyx_unpickle__Unquoter(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
  6505. * if __pyx_checksum != 0x276577d:
  6506. * from pickle import PickleError as __pyx_PickleError
  6507. */
  6508. /* Python wrapper */
  6509. static PyObject *__pyx_pw_4yarl_8_quoting_3__pyx_unpickle__Unquoter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  6510. static PyMethodDef __pyx_mdef_4yarl_8_quoting_3__pyx_unpickle__Unquoter = {"__pyx_unpickle__Unquoter", (PyCFunction)__pyx_pw_4yarl_8_quoting_3__pyx_unpickle__Unquoter, METH_VARARGS|METH_KEYWORDS, 0};
  6511. static PyObject *__pyx_pw_4yarl_8_quoting_3__pyx_unpickle__Unquoter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  6512. PyObject *__pyx_v___pyx_type = 0;
  6513. long __pyx_v___pyx_checksum;
  6514. PyObject *__pyx_v___pyx_state = 0;
  6515. PyObject *__pyx_r = 0;
  6516. __Pyx_RefNannyDeclarations
  6517. __Pyx_RefNannySetupContext("__pyx_unpickle__Unquoter (wrapper)", 0);
  6518. {
  6519. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
  6520. PyObject* values[3] = {0,0,0};
  6521. if (unlikely(__pyx_kwds)) {
  6522. Py_ssize_t kw_args;
  6523. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  6524. switch (pos_args) {
  6525. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6526. CYTHON_FALLTHROUGH;
  6527. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6528. CYTHON_FALLTHROUGH;
  6529. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6530. CYTHON_FALLTHROUGH;
  6531. case 0: break;
  6532. default: goto __pyx_L5_argtuple_error;
  6533. }
  6534. kw_args = PyDict_Size(__pyx_kwds);
  6535. switch (pos_args) {
  6536. case 0:
  6537. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
  6538. else goto __pyx_L5_argtuple_error;
  6539. CYTHON_FALLTHROUGH;
  6540. case 1:
  6541. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
  6542. else {
  6543. __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__Unquoter", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
  6544. }
  6545. CYTHON_FALLTHROUGH;
  6546. case 2:
  6547. if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
  6548. else {
  6549. __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__Unquoter", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
  6550. }
  6551. }
  6552. if (unlikely(kw_args > 0)) {
  6553. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle__Unquoter") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
  6554. }
  6555. } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
  6556. goto __pyx_L5_argtuple_error;
  6557. } else {
  6558. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6559. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6560. values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6561. }
  6562. __pyx_v___pyx_type = values[0];
  6563. __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
  6564. __pyx_v___pyx_state = values[2];
  6565. }
  6566. goto __pyx_L4_argument_unpacking_done;
  6567. __pyx_L5_argtuple_error:;
  6568. __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__Unquoter", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  6569. __pyx_L3_error:;
  6570. __Pyx_AddTraceback("yarl._quoting.__pyx_unpickle__Unquoter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6571. __Pyx_RefNannyFinishContext();
  6572. return NULL;
  6573. __pyx_L4_argument_unpacking_done:;
  6574. __pyx_r = __pyx_pf_4yarl_8_quoting_2__pyx_unpickle__Unquoter(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
  6575. /* function exit code */
  6576. __Pyx_RefNannyFinishContext();
  6577. return __pyx_r;
  6578. }
  6579. static PyObject *__pyx_pf_4yarl_8_quoting_2__pyx_unpickle__Unquoter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  6580. PyObject *__pyx_v___pyx_PickleError = NULL;
  6581. PyObject *__pyx_v___pyx_result = NULL;
  6582. PyObject *__pyx_r = NULL;
  6583. __Pyx_RefNannyDeclarations
  6584. int __pyx_t_1;
  6585. PyObject *__pyx_t_2 = NULL;
  6586. PyObject *__pyx_t_3 = NULL;
  6587. PyObject *__pyx_t_4 = NULL;
  6588. PyObject *__pyx_t_5 = NULL;
  6589. PyObject *__pyx_t_6 = NULL;
  6590. int __pyx_t_7;
  6591. __Pyx_RefNannySetupContext("__pyx_unpickle__Unquoter", 0);
  6592. /* "(tree fragment)":2
  6593. * def __pyx_unpickle__Unquoter(__pyx_type, long __pyx_checksum, __pyx_state):
  6594. * if __pyx_checksum != 0x276577d: # <<<<<<<<<<<<<<
  6595. * from pickle import PickleError as __pyx_PickleError
  6596. * raise __pyx_PickleError("Incompatible checksums (%s vs 0x276577d = (_qs, _qs_quoter, _quoter, _unsafe))" % __pyx_checksum)
  6597. */
  6598. __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x276577d) != 0);
  6599. if (__pyx_t_1) {
  6600. /* "(tree fragment)":3
  6601. * def __pyx_unpickle__Unquoter(__pyx_type, long __pyx_checksum, __pyx_state):
  6602. * if __pyx_checksum != 0x276577d:
  6603. * from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<<
  6604. * raise __pyx_PickleError("Incompatible checksums (%s vs 0x276577d = (_qs, _qs_quoter, _quoter, _unsafe))" % __pyx_checksum)
  6605. * __pyx_result = _Unquoter.__new__(__pyx_type)
  6606. */
  6607. __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3, __pyx_L1_error)
  6608. __Pyx_GOTREF(__pyx_t_2);
  6609. __Pyx_INCREF(__pyx_n_s_PickleError);
  6610. __Pyx_GIVEREF(__pyx_n_s_PickleError);
  6611. PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
  6612. __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 3, __pyx_L1_error)
  6613. __Pyx_GOTREF(__pyx_t_3);
  6614. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6615. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3, __pyx_L1_error)
  6616. __Pyx_GOTREF(__pyx_t_2);
  6617. __Pyx_INCREF(__pyx_t_2);
  6618. __pyx_v___pyx_PickleError = __pyx_t_2;
  6619. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6620. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6621. /* "(tree fragment)":4
  6622. * if __pyx_checksum != 0x276577d:
  6623. * from pickle import PickleError as __pyx_PickleError
  6624. * raise __pyx_PickleError("Incompatible checksums (%s vs 0x276577d = (_qs, _qs_quoter, _quoter, _unsafe))" % __pyx_checksum) # <<<<<<<<<<<<<<
  6625. * __pyx_result = _Unquoter.__new__(__pyx_type)
  6626. * if __pyx_state is not None:
  6627. */
  6628. __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4, __pyx_L1_error)
  6629. __Pyx_GOTREF(__pyx_t_2);
  6630. __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x27, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4, __pyx_L1_error)
  6631. __Pyx_GOTREF(__pyx_t_4);
  6632. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6633. __Pyx_INCREF(__pyx_v___pyx_PickleError);
  6634. __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
  6635. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  6636. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
  6637. if (likely(__pyx_t_5)) {
  6638. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  6639. __Pyx_INCREF(__pyx_t_5);
  6640. __Pyx_INCREF(function);
  6641. __Pyx_DECREF_SET(__pyx_t_2, function);
  6642. }
  6643. }
  6644. if (!__pyx_t_5) {
  6645. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4, __pyx_L1_error)
  6646. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6647. __Pyx_GOTREF(__pyx_t_3);
  6648. } else {
  6649. #if CYTHON_FAST_PYCALL
  6650. if (PyFunction_Check(__pyx_t_2)) {
  6651. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
  6652. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4, __pyx_L1_error)
  6653. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6654. __Pyx_GOTREF(__pyx_t_3);
  6655. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6656. } else
  6657. #endif
  6658. #if CYTHON_FAST_PYCCALL
  6659. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  6660. PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
  6661. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4, __pyx_L1_error)
  6662. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6663. __Pyx_GOTREF(__pyx_t_3);
  6664. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6665. } else
  6666. #endif
  6667. {
  6668. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 4, __pyx_L1_error)
  6669. __Pyx_GOTREF(__pyx_t_6);
  6670. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
  6671. __Pyx_GIVEREF(__pyx_t_4);
  6672. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
  6673. __pyx_t_4 = 0;
  6674. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4, __pyx_L1_error)
  6675. __Pyx_GOTREF(__pyx_t_3);
  6676. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6677. }
  6678. }
  6679. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6680. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  6681. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6682. __PYX_ERR(1, 4, __pyx_L1_error)
  6683. /* "(tree fragment)":2
  6684. * def __pyx_unpickle__Unquoter(__pyx_type, long __pyx_checksum, __pyx_state):
  6685. * if __pyx_checksum != 0x276577d: # <<<<<<<<<<<<<<
  6686. * from pickle import PickleError as __pyx_PickleError
  6687. * raise __pyx_PickleError("Incompatible checksums (%s vs 0x276577d = (_qs, _qs_quoter, _quoter, _unsafe))" % __pyx_checksum)
  6688. */
  6689. }
  6690. /* "(tree fragment)":5
  6691. * from pickle import PickleError as __pyx_PickleError
  6692. * raise __pyx_PickleError("Incompatible checksums (%s vs 0x276577d = (_qs, _qs_quoter, _quoter, _unsafe))" % __pyx_checksum)
  6693. * __pyx_result = _Unquoter.__new__(__pyx_type) # <<<<<<<<<<<<<<
  6694. * if __pyx_state is not None:
  6695. * __pyx_unpickle__Unquoter__set_state(<_Unquoter> __pyx_result, __pyx_state)
  6696. */
  6697. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4yarl_8_quoting__Unquoter), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  6698. __Pyx_GOTREF(__pyx_t_2);
  6699. __pyx_t_6 = NULL;
  6700. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  6701. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
  6702. if (likely(__pyx_t_6)) {
  6703. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  6704. __Pyx_INCREF(__pyx_t_6);
  6705. __Pyx_INCREF(function);
  6706. __Pyx_DECREF_SET(__pyx_t_2, function);
  6707. }
  6708. }
  6709. if (!__pyx_t_6) {
  6710. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  6711. __Pyx_GOTREF(__pyx_t_3);
  6712. } else {
  6713. #if CYTHON_FAST_PYCALL
  6714. if (PyFunction_Check(__pyx_t_2)) {
  6715. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
  6716. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  6717. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  6718. __Pyx_GOTREF(__pyx_t_3);
  6719. } else
  6720. #endif
  6721. #if CYTHON_FAST_PYCCALL
  6722. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  6723. PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v___pyx_type};
  6724. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  6725. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  6726. __Pyx_GOTREF(__pyx_t_3);
  6727. } else
  6728. #endif
  6729. {
  6730. __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
  6731. __Pyx_GOTREF(__pyx_t_4);
  6732. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
  6733. __Pyx_INCREF(__pyx_v___pyx_type);
  6734. __Pyx_GIVEREF(__pyx_v___pyx_type);
  6735. PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v___pyx_type);
  6736. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  6737. __Pyx_GOTREF(__pyx_t_3);
  6738. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6739. }
  6740. }
  6741. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6742. __pyx_v___pyx_result = __pyx_t_3;
  6743. __pyx_t_3 = 0;
  6744. /* "(tree fragment)":6
  6745. * raise __pyx_PickleError("Incompatible checksums (%s vs 0x276577d = (_qs, _qs_quoter, _quoter, _unsafe))" % __pyx_checksum)
  6746. * __pyx_result = _Unquoter.__new__(__pyx_type)
  6747. * if __pyx_state is not None: # <<<<<<<<<<<<<<
  6748. * __pyx_unpickle__Unquoter__set_state(<_Unquoter> __pyx_result, __pyx_state)
  6749. * return __pyx_result
  6750. */
  6751. __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  6752. __pyx_t_7 = (__pyx_t_1 != 0);
  6753. if (__pyx_t_7) {
  6754. /* "(tree fragment)":7
  6755. * __pyx_result = _Unquoter.__new__(__pyx_type)
  6756. * if __pyx_state is not None:
  6757. * __pyx_unpickle__Unquoter__set_state(<_Unquoter> __pyx_result, __pyx_state) # <<<<<<<<<<<<<<
  6758. * return __pyx_result
  6759. * cdef __pyx_unpickle__Unquoter__set_state(_Unquoter __pyx_result, tuple __pyx_state):
  6760. */
  6761. if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 7, __pyx_L1_error)
  6762. __pyx_t_3 = __pyx_f_4yarl_8_quoting___pyx_unpickle__Unquoter__set_state(((struct __pyx_obj_4yarl_8_quoting__Unquoter *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  6763. __Pyx_GOTREF(__pyx_t_3);
  6764. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6765. /* "(tree fragment)":6
  6766. * raise __pyx_PickleError("Incompatible checksums (%s vs 0x276577d = (_qs, _qs_quoter, _quoter, _unsafe))" % __pyx_checksum)
  6767. * __pyx_result = _Unquoter.__new__(__pyx_type)
  6768. * if __pyx_state is not None: # <<<<<<<<<<<<<<
  6769. * __pyx_unpickle__Unquoter__set_state(<_Unquoter> __pyx_result, __pyx_state)
  6770. * return __pyx_result
  6771. */
  6772. }
  6773. /* "(tree fragment)":8
  6774. * if __pyx_state is not None:
  6775. * __pyx_unpickle__Unquoter__set_state(<_Unquoter> __pyx_result, __pyx_state)
  6776. * return __pyx_result # <<<<<<<<<<<<<<
  6777. * cdef __pyx_unpickle__Unquoter__set_state(_Unquoter __pyx_result, tuple __pyx_state):
  6778. * __pyx_result._qs = __pyx_state[0]; __pyx_result._qs_quoter = __pyx_state[1]; __pyx_result._quoter = __pyx_state[2]; __pyx_result._unsafe = __pyx_state[3]
  6779. */
  6780. __Pyx_XDECREF(__pyx_r);
  6781. __Pyx_INCREF(__pyx_v___pyx_result);
  6782. __pyx_r = __pyx_v___pyx_result;
  6783. goto __pyx_L0;
  6784. /* "(tree fragment)":1
  6785. * def __pyx_unpickle__Unquoter(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
  6786. * if __pyx_checksum != 0x276577d:
  6787. * from pickle import PickleError as __pyx_PickleError
  6788. */
  6789. /* function exit code */
  6790. __pyx_L1_error:;
  6791. __Pyx_XDECREF(__pyx_t_2);
  6792. __Pyx_XDECREF(__pyx_t_3);
  6793. __Pyx_XDECREF(__pyx_t_4);
  6794. __Pyx_XDECREF(__pyx_t_5);
  6795. __Pyx_XDECREF(__pyx_t_6);
  6796. __Pyx_AddTraceback("yarl._quoting.__pyx_unpickle__Unquoter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6797. __pyx_r = NULL;
  6798. __pyx_L0:;
  6799. __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  6800. __Pyx_XDECREF(__pyx_v___pyx_result);
  6801. __Pyx_XGIVEREF(__pyx_r);
  6802. __Pyx_RefNannyFinishContext();
  6803. return __pyx_r;
  6804. }
  6805. /* "(tree fragment)":9
  6806. * __pyx_unpickle__Unquoter__set_state(<_Unquoter> __pyx_result, __pyx_state)
  6807. * return __pyx_result
  6808. * cdef __pyx_unpickle__Unquoter__set_state(_Unquoter __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
  6809. * __pyx_result._qs = __pyx_state[0]; __pyx_result._qs_quoter = __pyx_state[1]; __pyx_result._quoter = __pyx_state[2]; __pyx_result._unsafe = __pyx_state[3]
  6810. * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
  6811. */
  6812. static PyObject *__pyx_f_4yarl_8_quoting___pyx_unpickle__Unquoter__set_state(struct __pyx_obj_4yarl_8_quoting__Unquoter *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  6813. PyObject *__pyx_r = NULL;
  6814. __Pyx_RefNannyDeclarations
  6815. PyObject *__pyx_t_1 = NULL;
  6816. int __pyx_t_2;
  6817. Py_ssize_t __pyx_t_3;
  6818. int __pyx_t_4;
  6819. int __pyx_t_5;
  6820. PyObject *__pyx_t_6 = NULL;
  6821. PyObject *__pyx_t_7 = NULL;
  6822. PyObject *__pyx_t_8 = NULL;
  6823. PyObject *__pyx_t_9 = NULL;
  6824. __Pyx_RefNannySetupContext("__pyx_unpickle__Unquoter__set_state", 0);
  6825. /* "(tree fragment)":10
  6826. * return __pyx_result
  6827. * cdef __pyx_unpickle__Unquoter__set_state(_Unquoter __pyx_result, tuple __pyx_state):
  6828. * __pyx_result._qs = __pyx_state[0]; __pyx_result._qs_quoter = __pyx_state[1]; __pyx_result._quoter = __pyx_state[2]; __pyx_result._unsafe = __pyx_state[3] # <<<<<<<<<<<<<<
  6829. * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
  6830. * __pyx_result.__dict__.update(__pyx_state[4])
  6831. */
  6832. if (unlikely(__pyx_v___pyx_state == Py_None)) {
  6833. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
  6834. __PYX_ERR(1, 10, __pyx_L1_error)
  6835. }
  6836. __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 10, __pyx_L1_error)
  6837. __Pyx_GOTREF(__pyx_t_1);
  6838. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 10, __pyx_L1_error)
  6839. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6840. __pyx_v___pyx_result->_qs = __pyx_t_2;
  6841. if (unlikely(__pyx_v___pyx_state == Py_None)) {
  6842. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
  6843. __PYX_ERR(1, 10, __pyx_L1_error)
  6844. }
  6845. __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 10, __pyx_L1_error)
  6846. __Pyx_GOTREF(__pyx_t_1);
  6847. if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4yarl_8_quoting__Quoter))))) __PYX_ERR(1, 10, __pyx_L1_error)
  6848. __Pyx_GIVEREF(__pyx_t_1);
  6849. __Pyx_GOTREF(__pyx_v___pyx_result->_qs_quoter);
  6850. __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->_qs_quoter));
  6851. __pyx_v___pyx_result->_qs_quoter = ((struct __pyx_obj_4yarl_8_quoting__Quoter *)__pyx_t_1);
  6852. __pyx_t_1 = 0;
  6853. if (unlikely(__pyx_v___pyx_state == Py_None)) {
  6854. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
  6855. __PYX_ERR(1, 10, __pyx_L1_error)
  6856. }
  6857. __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 10, __pyx_L1_error)
  6858. __Pyx_GOTREF(__pyx_t_1);
  6859. if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4yarl_8_quoting__Quoter))))) __PYX_ERR(1, 10, __pyx_L1_error)
  6860. __Pyx_GIVEREF(__pyx_t_1);
  6861. __Pyx_GOTREF(__pyx_v___pyx_result->_quoter);
  6862. __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->_quoter));
  6863. __pyx_v___pyx_result->_quoter = ((struct __pyx_obj_4yarl_8_quoting__Quoter *)__pyx_t_1);
  6864. __pyx_t_1 = 0;
  6865. if (unlikely(__pyx_v___pyx_state == Py_None)) {
  6866. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
  6867. __PYX_ERR(1, 10, __pyx_L1_error)
  6868. }
  6869. __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 10, __pyx_L1_error)
  6870. __Pyx_GOTREF(__pyx_t_1);
  6871. if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 10, __pyx_L1_error)
  6872. __Pyx_GIVEREF(__pyx_t_1);
  6873. __Pyx_GOTREF(__pyx_v___pyx_result->_unsafe);
  6874. __Pyx_DECREF(__pyx_v___pyx_result->_unsafe);
  6875. __pyx_v___pyx_result->_unsafe = ((PyObject*)__pyx_t_1);
  6876. __pyx_t_1 = 0;
  6877. /* "(tree fragment)":11
  6878. * cdef __pyx_unpickle__Unquoter__set_state(_Unquoter __pyx_result, tuple __pyx_state):
  6879. * __pyx_result._qs = __pyx_state[0]; __pyx_result._qs_quoter = __pyx_state[1]; __pyx_result._quoter = __pyx_state[2]; __pyx_result._unsafe = __pyx_state[3]
  6880. * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
  6881. * __pyx_result.__dict__.update(__pyx_state[4])
  6882. */
  6883. if (unlikely(__pyx_v___pyx_state == Py_None)) {
  6884. PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
  6885. __PYX_ERR(1, 11, __pyx_L1_error)
  6886. }
  6887. __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 11, __pyx_L1_error)
  6888. __pyx_t_4 = ((__pyx_t_3 > 4) != 0);
  6889. if (__pyx_t_4) {
  6890. } else {
  6891. __pyx_t_2 = __pyx_t_4;
  6892. goto __pyx_L4_bool_binop_done;
  6893. }
  6894. __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 11, __pyx_L1_error)
  6895. __pyx_t_5 = (__pyx_t_4 != 0);
  6896. __pyx_t_2 = __pyx_t_5;
  6897. __pyx_L4_bool_binop_done:;
  6898. if (__pyx_t_2) {
  6899. /* "(tree fragment)":12
  6900. * __pyx_result._qs = __pyx_state[0]; __pyx_result._qs_quoter = __pyx_state[1]; __pyx_result._quoter = __pyx_state[2]; __pyx_result._unsafe = __pyx_state[3]
  6901. * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
  6902. * __pyx_result.__dict__.update(__pyx_state[4]) # <<<<<<<<<<<<<<
  6903. */
  6904. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 12, __pyx_L1_error)
  6905. __Pyx_GOTREF(__pyx_t_6);
  6906. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 12, __pyx_L1_error)
  6907. __Pyx_GOTREF(__pyx_t_7);
  6908. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6909. if (unlikely(__pyx_v___pyx_state == Py_None)) {
  6910. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
  6911. __PYX_ERR(1, 12, __pyx_L1_error)
  6912. }
  6913. __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 12, __pyx_L1_error)
  6914. __Pyx_GOTREF(__pyx_t_6);
  6915. __pyx_t_8 = NULL;
  6916. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
  6917. __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
  6918. if (likely(__pyx_t_8)) {
  6919. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  6920. __Pyx_INCREF(__pyx_t_8);
  6921. __Pyx_INCREF(function);
  6922. __Pyx_DECREF_SET(__pyx_t_7, function);
  6923. }
  6924. }
  6925. if (!__pyx_t_8) {
  6926. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  6927. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6928. __Pyx_GOTREF(__pyx_t_1);
  6929. } else {
  6930. #if CYTHON_FAST_PYCALL
  6931. if (PyFunction_Check(__pyx_t_7)) {
  6932. PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
  6933. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  6934. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  6935. __Pyx_GOTREF(__pyx_t_1);
  6936. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6937. } else
  6938. #endif
  6939. #if CYTHON_FAST_PYCCALL
  6940. if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
  6941. PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6};
  6942. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  6943. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  6944. __Pyx_GOTREF(__pyx_t_1);
  6945. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6946. } else
  6947. #endif
  6948. {
  6949. __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 12, __pyx_L1_error)
  6950. __Pyx_GOTREF(__pyx_t_9);
  6951. __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
  6952. __Pyx_GIVEREF(__pyx_t_6);
  6953. PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6);
  6954. __pyx_t_6 = 0;
  6955. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  6956. __Pyx_GOTREF(__pyx_t_1);
  6957. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6958. }
  6959. }
  6960. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6961. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6962. /* "(tree fragment)":11
  6963. * cdef __pyx_unpickle__Unquoter__set_state(_Unquoter __pyx_result, tuple __pyx_state):
  6964. * __pyx_result._qs = __pyx_state[0]; __pyx_result._qs_quoter = __pyx_state[1]; __pyx_result._quoter = __pyx_state[2]; __pyx_result._unsafe = __pyx_state[3]
  6965. * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
  6966. * __pyx_result.__dict__.update(__pyx_state[4])
  6967. */
  6968. }
  6969. /* "(tree fragment)":9
  6970. * __pyx_unpickle__Unquoter__set_state(<_Unquoter> __pyx_result, __pyx_state)
  6971. * return __pyx_result
  6972. * cdef __pyx_unpickle__Unquoter__set_state(_Unquoter __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
  6973. * __pyx_result._qs = __pyx_state[0]; __pyx_result._qs_quoter = __pyx_state[1]; __pyx_result._quoter = __pyx_state[2]; __pyx_result._unsafe = __pyx_state[3]
  6974. * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
  6975. */
  6976. /* function exit code */
  6977. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6978. goto __pyx_L0;
  6979. __pyx_L1_error:;
  6980. __Pyx_XDECREF(__pyx_t_1);
  6981. __Pyx_XDECREF(__pyx_t_6);
  6982. __Pyx_XDECREF(__pyx_t_7);
  6983. __Pyx_XDECREF(__pyx_t_8);
  6984. __Pyx_XDECREF(__pyx_t_9);
  6985. __Pyx_AddTraceback("yarl._quoting.__pyx_unpickle__Unquoter__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6986. __pyx_r = 0;
  6987. __pyx_L0:;
  6988. __Pyx_XGIVEREF(__pyx_r);
  6989. __Pyx_RefNannyFinishContext();
  6990. return __pyx_r;
  6991. }
  6992. /* "carray.from_py":77
  6993. *
  6994. * @cname("__Pyx_carray_from_py_uint8_t")
  6995. * cdef int __Pyx_carray_from_py_uint8_t(object o, base_type *v, Py_ssize_t length) except -1: # <<<<<<<<<<<<<<
  6996. * cdef Py_ssize_t i = length
  6997. * try:
  6998. */
  6999. static int __Pyx_carray_from_py_uint8_t(PyObject *__pyx_v_o, uint8_t *__pyx_v_v, Py_ssize_t __pyx_v_length) {
  7000. Py_ssize_t __pyx_v_i;
  7001. PyObject *__pyx_v_item = NULL;
  7002. int __pyx_r;
  7003. __Pyx_RefNannyDeclarations
  7004. PyObject *__pyx_t_1 = NULL;
  7005. PyObject *__pyx_t_2 = NULL;
  7006. PyObject *__pyx_t_3 = NULL;
  7007. Py_ssize_t __pyx_t_4;
  7008. int __pyx_t_5;
  7009. int __pyx_t_6;
  7010. PyObject *__pyx_t_7 = NULL;
  7011. Py_ssize_t __pyx_t_8;
  7012. PyObject *(*__pyx_t_9)(PyObject *);
  7013. PyObject *__pyx_t_10 = NULL;
  7014. uint8_t __pyx_t_11;
  7015. char const *__pyx_t_12;
  7016. __Pyx_RefNannySetupContext("__Pyx_carray_from_py_uint8_t", 0);
  7017. /* "carray.from_py":78
  7018. * @cname("__Pyx_carray_from_py_uint8_t")
  7019. * cdef int __Pyx_carray_from_py_uint8_t(object o, base_type *v, Py_ssize_t length) except -1:
  7020. * cdef Py_ssize_t i = length # <<<<<<<<<<<<<<
  7021. * try:
  7022. * i = len(o)
  7023. */
  7024. __pyx_v_i = __pyx_v_length;
  7025. /* "carray.from_py":79
  7026. * cdef int __Pyx_carray_from_py_uint8_t(object o, base_type *v, Py_ssize_t length) except -1:
  7027. * cdef Py_ssize_t i = length
  7028. * try: # <<<<<<<<<<<<<<
  7029. * i = len(o)
  7030. * except (TypeError, OverflowError):
  7031. */
  7032. {
  7033. __Pyx_PyThreadState_declare
  7034. __Pyx_PyThreadState_assign
  7035. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  7036. __Pyx_XGOTREF(__pyx_t_1);
  7037. __Pyx_XGOTREF(__pyx_t_2);
  7038. __Pyx_XGOTREF(__pyx_t_3);
  7039. /*try:*/ {
  7040. /* "carray.from_py":80
  7041. * cdef Py_ssize_t i = length
  7042. * try:
  7043. * i = len(o) # <<<<<<<<<<<<<<
  7044. * except (TypeError, OverflowError):
  7045. * pass
  7046. */
  7047. __pyx_t_4 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 80, __pyx_L3_error)
  7048. __pyx_v_i = __pyx_t_4;
  7049. /* "carray.from_py":79
  7050. * cdef int __Pyx_carray_from_py_uint8_t(object o, base_type *v, Py_ssize_t length) except -1:
  7051. * cdef Py_ssize_t i = length
  7052. * try: # <<<<<<<<<<<<<<
  7053. * i = len(o)
  7054. * except (TypeError, OverflowError):
  7055. */
  7056. }
  7057. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  7058. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  7059. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  7060. goto __pyx_L8_try_end;
  7061. __pyx_L3_error:;
  7062. /* "carray.from_py":81
  7063. * try:
  7064. * i = len(o)
  7065. * except (TypeError, OverflowError): # <<<<<<<<<<<<<<
  7066. * pass
  7067. * if i == length:
  7068. */
  7069. __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_OverflowError);
  7070. if (__pyx_t_5) {
  7071. __Pyx_ErrRestore(0,0,0);
  7072. goto __pyx_L4_exception_handled;
  7073. }
  7074. goto __pyx_L5_except_error;
  7075. __pyx_L5_except_error:;
  7076. /* "carray.from_py":79
  7077. * cdef int __Pyx_carray_from_py_uint8_t(object o, base_type *v, Py_ssize_t length) except -1:
  7078. * cdef Py_ssize_t i = length
  7079. * try: # <<<<<<<<<<<<<<
  7080. * i = len(o)
  7081. * except (TypeError, OverflowError):
  7082. */
  7083. __Pyx_XGIVEREF(__pyx_t_1);
  7084. __Pyx_XGIVEREF(__pyx_t_2);
  7085. __Pyx_XGIVEREF(__pyx_t_3);
  7086. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7087. goto __pyx_L1_error;
  7088. __pyx_L4_exception_handled:;
  7089. __Pyx_XGIVEREF(__pyx_t_1);
  7090. __Pyx_XGIVEREF(__pyx_t_2);
  7091. __Pyx_XGIVEREF(__pyx_t_3);
  7092. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7093. __pyx_L8_try_end:;
  7094. }
  7095. /* "carray.from_py":83
  7096. * except (TypeError, OverflowError):
  7097. * pass
  7098. * if i == length: # <<<<<<<<<<<<<<
  7099. * for i, item in enumerate(o):
  7100. * if i >= length:
  7101. */
  7102. __pyx_t_6 = ((__pyx_v_i == __pyx_v_length) != 0);
  7103. if (__pyx_t_6) {
  7104. /* "carray.from_py":84
  7105. * pass
  7106. * if i == length:
  7107. * for i, item in enumerate(o): # <<<<<<<<<<<<<<
  7108. * if i >= length:
  7109. * break
  7110. */
  7111. __pyx_t_4 = 0;
  7112. if (likely(PyList_CheckExact(__pyx_v_o)) || PyTuple_CheckExact(__pyx_v_o)) {
  7113. __pyx_t_7 = __pyx_v_o; __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = 0;
  7114. __pyx_t_9 = NULL;
  7115. } else {
  7116. __pyx_t_8 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 84, __pyx_L1_error)
  7117. __Pyx_GOTREF(__pyx_t_7);
  7118. __pyx_t_9 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 84, __pyx_L1_error)
  7119. }
  7120. for (;;) {
  7121. if (likely(!__pyx_t_9)) {
  7122. if (likely(PyList_CheckExact(__pyx_t_7))) {
  7123. if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_7)) break;
  7124. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  7125. __pyx_t_10 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_10); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 84, __pyx_L1_error)
  7126. #else
  7127. __pyx_t_10 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 84, __pyx_L1_error)
  7128. __Pyx_GOTREF(__pyx_t_10);
  7129. #endif
  7130. } else {
  7131. if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
  7132. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  7133. __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_10); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 84, __pyx_L1_error)
  7134. #else
  7135. __pyx_t_10 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 84, __pyx_L1_error)
  7136. __Pyx_GOTREF(__pyx_t_10);
  7137. #endif
  7138. }
  7139. } else {
  7140. __pyx_t_10 = __pyx_t_9(__pyx_t_7);
  7141. if (unlikely(!__pyx_t_10)) {
  7142. PyObject* exc_type = PyErr_Occurred();
  7143. if (exc_type) {
  7144. if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  7145. else __PYX_ERR(1, 84, __pyx_L1_error)
  7146. }
  7147. break;
  7148. }
  7149. __Pyx_GOTREF(__pyx_t_10);
  7150. }
  7151. __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_10);
  7152. __pyx_t_10 = 0;
  7153. __pyx_v_i = __pyx_t_4;
  7154. __pyx_t_4 = (__pyx_t_4 + 1);
  7155. /* "carray.from_py":85
  7156. * if i == length:
  7157. * for i, item in enumerate(o):
  7158. * if i >= length: # <<<<<<<<<<<<<<
  7159. * break
  7160. * v[i] = item
  7161. */
  7162. __pyx_t_6 = ((__pyx_v_i >= __pyx_v_length) != 0);
  7163. if (__pyx_t_6) {
  7164. /* "carray.from_py":86
  7165. * for i, item in enumerate(o):
  7166. * if i >= length:
  7167. * break # <<<<<<<<<<<<<<
  7168. * v[i] = item
  7169. * else:
  7170. */
  7171. goto __pyx_L11_break;
  7172. /* "carray.from_py":85
  7173. * if i == length:
  7174. * for i, item in enumerate(o):
  7175. * if i >= length: # <<<<<<<<<<<<<<
  7176. * break
  7177. * v[i] = item
  7178. */
  7179. }
  7180. /* "carray.from_py":87
  7181. * if i >= length:
  7182. * break
  7183. * v[i] = item # <<<<<<<<<<<<<<
  7184. * else:
  7185. * i += 1 # convert index to length
  7186. */
  7187. __pyx_t_11 = __Pyx_PyInt_As_uint8_t(__pyx_v_item); if (unlikely((__pyx_t_11 == ((uint8_t)-1)) && PyErr_Occurred())) __PYX_ERR(1, 87, __pyx_L1_error)
  7188. (__pyx_v_v[__pyx_v_i]) = __pyx_t_11;
  7189. /* "carray.from_py":84
  7190. * pass
  7191. * if i == length:
  7192. * for i, item in enumerate(o): # <<<<<<<<<<<<<<
  7193. * if i >= length:
  7194. * break
  7195. */
  7196. }
  7197. /*else*/ {
  7198. /* "carray.from_py":89
  7199. * v[i] = item
  7200. * else:
  7201. * i += 1 # convert index to length # <<<<<<<<<<<<<<
  7202. * if i == length:
  7203. * return 0
  7204. */
  7205. __pyx_v_i = (__pyx_v_i + 1);
  7206. /* "carray.from_py":90
  7207. * else:
  7208. * i += 1 # convert index to length
  7209. * if i == length: # <<<<<<<<<<<<<<
  7210. * return 0
  7211. *
  7212. */
  7213. __pyx_t_6 = ((__pyx_v_i == __pyx_v_length) != 0);
  7214. if (__pyx_t_6) {
  7215. /* "carray.from_py":91
  7216. * i += 1 # convert index to length
  7217. * if i == length:
  7218. * return 0 # <<<<<<<<<<<<<<
  7219. *
  7220. * PyErr_Format(
  7221. */
  7222. __pyx_r = 0;
  7223. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7224. goto __pyx_L0;
  7225. /* "carray.from_py":90
  7226. * else:
  7227. * i += 1 # convert index to length
  7228. * if i == length: # <<<<<<<<<<<<<<
  7229. * return 0
  7230. *
  7231. */
  7232. }
  7233. }
  7234. /* "carray.from_py":84
  7235. * pass
  7236. * if i == length:
  7237. * for i, item in enumerate(o): # <<<<<<<<<<<<<<
  7238. * if i >= length:
  7239. * break
  7240. */
  7241. __pyx_L11_break:;
  7242. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7243. /* "carray.from_py":83
  7244. * except (TypeError, OverflowError):
  7245. * pass
  7246. * if i == length: # <<<<<<<<<<<<<<
  7247. * for i, item in enumerate(o):
  7248. * if i >= length:
  7249. */
  7250. }
  7251. /* "carray.from_py":96
  7252. * IndexError,
  7253. * ("too many values found during array assignment, expected %zd"
  7254. * if i >= length else # <<<<<<<<<<<<<<
  7255. * "not enough values found during array assignment, expected %zd, got %zd"),
  7256. * length, i)
  7257. */
  7258. if (((__pyx_v_i >= __pyx_v_length) != 0)) {
  7259. __pyx_t_12 = ((char const *)"too many values found during array assignment, expected %zd");
  7260. } else {
  7261. __pyx_t_12 = ((char const *)"not enough values found during array assignment, expected %zd, got %zd");
  7262. }
  7263. /* "carray.from_py":93
  7264. * return 0
  7265. *
  7266. * PyErr_Format( # <<<<<<<<<<<<<<
  7267. * IndexError,
  7268. * ("too many values found during array assignment, expected %zd"
  7269. */
  7270. __pyx_t_7 = PyErr_Format(__pyx_builtin_IndexError, __pyx_t_12, __pyx_v_length, __pyx_v_i); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 93, __pyx_L1_error)
  7271. __Pyx_GOTREF(__pyx_t_7);
  7272. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7273. /* "carray.from_py":77
  7274. *
  7275. * @cname("__Pyx_carray_from_py_uint8_t")
  7276. * cdef int __Pyx_carray_from_py_uint8_t(object o, base_type *v, Py_ssize_t length) except -1: # <<<<<<<<<<<<<<
  7277. * cdef Py_ssize_t i = length
  7278. * try:
  7279. */
  7280. /* function exit code */
  7281. __pyx_r = 0;
  7282. goto __pyx_L0;
  7283. __pyx_L1_error:;
  7284. __Pyx_XDECREF(__pyx_t_7);
  7285. __Pyx_XDECREF(__pyx_t_10);
  7286. __Pyx_AddTraceback("carray.from_py.__Pyx_carray_from_py_uint8_t", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7287. __pyx_r = -1;
  7288. __pyx_L0:;
  7289. __Pyx_XDECREF(__pyx_v_item);
  7290. __Pyx_RefNannyFinishContext();
  7291. return __pyx_r;
  7292. }
  7293. static struct __pyx_vtabstruct_4yarl_8_quoting__Quoter __pyx_vtable_4yarl_8_quoting__Quoter;
  7294. static PyObject *__pyx_tp_new_4yarl_8_quoting__Quoter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  7295. struct __pyx_obj_4yarl_8_quoting__Quoter *p;
  7296. PyObject *o;
  7297. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  7298. o = (*t->tp_alloc)(t, 0);
  7299. } else {
  7300. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  7301. }
  7302. if (unlikely(!o)) return 0;
  7303. p = ((struct __pyx_obj_4yarl_8_quoting__Quoter *)o);
  7304. p->__pyx_vtab = __pyx_vtabptr_4yarl_8_quoting__Quoter;
  7305. return o;
  7306. }
  7307. static void __pyx_tp_dealloc_4yarl_8_quoting__Quoter(PyObject *o) {
  7308. #if CYTHON_USE_TP_FINALIZE
  7309. if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
  7310. if (PyObject_CallFinalizerFromDealloc(o)) return;
  7311. }
  7312. #endif
  7313. (*Py_TYPE(o)->tp_free)(o);
  7314. }
  7315. static PyMethodDef __pyx_methods_4yarl_8_quoting__Quoter[] = {
  7316. {"__reduce_cython__", (PyCFunction)__pyx_pw_4yarl_8_quoting_7_Quoter_5__reduce_cython__, METH_NOARGS, 0},
  7317. {"__setstate_cython__", (PyCFunction)__pyx_pw_4yarl_8_quoting_7_Quoter_7__setstate_cython__, METH_O, 0},
  7318. {0, 0, 0, 0}
  7319. };
  7320. static PyTypeObject __pyx_type_4yarl_8_quoting__Quoter = {
  7321. PyVarObject_HEAD_INIT(0, 0)
  7322. "yarl._quoting._Quoter", /*tp_name*/
  7323. sizeof(struct __pyx_obj_4yarl_8_quoting__Quoter), /*tp_basicsize*/
  7324. 0, /*tp_itemsize*/
  7325. __pyx_tp_dealloc_4yarl_8_quoting__Quoter, /*tp_dealloc*/
  7326. 0, /*tp_print*/
  7327. 0, /*tp_getattr*/
  7328. 0, /*tp_setattr*/
  7329. #if PY_MAJOR_VERSION < 3
  7330. 0, /*tp_compare*/
  7331. #endif
  7332. #if PY_MAJOR_VERSION >= 3
  7333. 0, /*tp_as_async*/
  7334. #endif
  7335. 0, /*tp_repr*/
  7336. 0, /*tp_as_number*/
  7337. 0, /*tp_as_sequence*/
  7338. 0, /*tp_as_mapping*/
  7339. 0, /*tp_hash*/
  7340. __pyx_pw_4yarl_8_quoting_7_Quoter_3__call__, /*tp_call*/
  7341. 0, /*tp_str*/
  7342. 0, /*tp_getattro*/
  7343. 0, /*tp_setattro*/
  7344. 0, /*tp_as_buffer*/
  7345. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  7346. 0, /*tp_doc*/
  7347. 0, /*tp_traverse*/
  7348. 0, /*tp_clear*/
  7349. 0, /*tp_richcompare*/
  7350. 0, /*tp_weaklistoffset*/
  7351. 0, /*tp_iter*/
  7352. 0, /*tp_iternext*/
  7353. __pyx_methods_4yarl_8_quoting__Quoter, /*tp_methods*/
  7354. 0, /*tp_members*/
  7355. 0, /*tp_getset*/
  7356. 0, /*tp_base*/
  7357. 0, /*tp_dict*/
  7358. 0, /*tp_descr_get*/
  7359. 0, /*tp_descr_set*/
  7360. 0, /*tp_dictoffset*/
  7361. __pyx_pw_4yarl_8_quoting_7_Quoter_1__init__, /*tp_init*/
  7362. 0, /*tp_alloc*/
  7363. __pyx_tp_new_4yarl_8_quoting__Quoter, /*tp_new*/
  7364. 0, /*tp_free*/
  7365. 0, /*tp_is_gc*/
  7366. 0, /*tp_bases*/
  7367. 0, /*tp_mro*/
  7368. 0, /*tp_cache*/
  7369. 0, /*tp_subclasses*/
  7370. 0, /*tp_weaklist*/
  7371. 0, /*tp_del*/
  7372. 0, /*tp_version_tag*/
  7373. #if PY_VERSION_HEX >= 0x030400a1
  7374. 0, /*tp_finalize*/
  7375. #endif
  7376. };
  7377. static struct __pyx_vtabstruct_4yarl_8_quoting__Unquoter __pyx_vtable_4yarl_8_quoting__Unquoter;
  7378. static PyObject *__pyx_tp_new_4yarl_8_quoting__Unquoter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  7379. struct __pyx_obj_4yarl_8_quoting__Unquoter *p;
  7380. PyObject *o;
  7381. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  7382. o = (*t->tp_alloc)(t, 0);
  7383. } else {
  7384. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  7385. }
  7386. if (unlikely(!o)) return 0;
  7387. p = ((struct __pyx_obj_4yarl_8_quoting__Unquoter *)o);
  7388. p->__pyx_vtab = __pyx_vtabptr_4yarl_8_quoting__Unquoter;
  7389. p->_unsafe = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7390. p->_quoter = ((struct __pyx_obj_4yarl_8_quoting__Quoter *)Py_None); Py_INCREF(Py_None);
  7391. p->_qs_quoter = ((struct __pyx_obj_4yarl_8_quoting__Quoter *)Py_None); Py_INCREF(Py_None);
  7392. return o;
  7393. }
  7394. static void __pyx_tp_dealloc_4yarl_8_quoting__Unquoter(PyObject *o) {
  7395. struct __pyx_obj_4yarl_8_quoting__Unquoter *p = (struct __pyx_obj_4yarl_8_quoting__Unquoter *)o;
  7396. #if CYTHON_USE_TP_FINALIZE
  7397. if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
  7398. if (PyObject_CallFinalizerFromDealloc(o)) return;
  7399. }
  7400. #endif
  7401. PyObject_GC_UnTrack(o);
  7402. Py_CLEAR(p->_unsafe);
  7403. Py_CLEAR(p->_quoter);
  7404. Py_CLEAR(p->_qs_quoter);
  7405. (*Py_TYPE(o)->tp_free)(o);
  7406. }
  7407. static int __pyx_tp_traverse_4yarl_8_quoting__Unquoter(PyObject *o, visitproc v, void *a) {
  7408. int e;
  7409. struct __pyx_obj_4yarl_8_quoting__Unquoter *p = (struct __pyx_obj_4yarl_8_quoting__Unquoter *)o;
  7410. if (p->_quoter) {
  7411. e = (*v)(((PyObject *)p->_quoter), a); if (e) return e;
  7412. }
  7413. if (p->_qs_quoter) {
  7414. e = (*v)(((PyObject *)p->_qs_quoter), a); if (e) return e;
  7415. }
  7416. return 0;
  7417. }
  7418. static int __pyx_tp_clear_4yarl_8_quoting__Unquoter(PyObject *o) {
  7419. PyObject* tmp;
  7420. struct __pyx_obj_4yarl_8_quoting__Unquoter *p = (struct __pyx_obj_4yarl_8_quoting__Unquoter *)o;
  7421. tmp = ((PyObject*)p->_quoter);
  7422. p->_quoter = ((struct __pyx_obj_4yarl_8_quoting__Quoter *)Py_None); Py_INCREF(Py_None);
  7423. Py_XDECREF(tmp);
  7424. tmp = ((PyObject*)p->_qs_quoter);
  7425. p->_qs_quoter = ((struct __pyx_obj_4yarl_8_quoting__Quoter *)Py_None); Py_INCREF(Py_None);
  7426. Py_XDECREF(tmp);
  7427. return 0;
  7428. }
  7429. static PyMethodDef __pyx_methods_4yarl_8_quoting__Unquoter[] = {
  7430. {"__reduce_cython__", (PyCFunction)__pyx_pw_4yarl_8_quoting_9_Unquoter_5__reduce_cython__, METH_NOARGS, 0},
  7431. {"__setstate_cython__", (PyCFunction)__pyx_pw_4yarl_8_quoting_9_Unquoter_7__setstate_cython__, METH_O, 0},
  7432. {0, 0, 0, 0}
  7433. };
  7434. static PyTypeObject __pyx_type_4yarl_8_quoting__Unquoter = {
  7435. PyVarObject_HEAD_INIT(0, 0)
  7436. "yarl._quoting._Unquoter", /*tp_name*/
  7437. sizeof(struct __pyx_obj_4yarl_8_quoting__Unquoter), /*tp_basicsize*/
  7438. 0, /*tp_itemsize*/
  7439. __pyx_tp_dealloc_4yarl_8_quoting__Unquoter, /*tp_dealloc*/
  7440. 0, /*tp_print*/
  7441. 0, /*tp_getattr*/
  7442. 0, /*tp_setattr*/
  7443. #if PY_MAJOR_VERSION < 3
  7444. 0, /*tp_compare*/
  7445. #endif
  7446. #if PY_MAJOR_VERSION >= 3
  7447. 0, /*tp_as_async*/
  7448. #endif
  7449. 0, /*tp_repr*/
  7450. 0, /*tp_as_number*/
  7451. 0, /*tp_as_sequence*/
  7452. 0, /*tp_as_mapping*/
  7453. 0, /*tp_hash*/
  7454. __pyx_pw_4yarl_8_quoting_9_Unquoter_3__call__, /*tp_call*/
  7455. 0, /*tp_str*/
  7456. 0, /*tp_getattro*/
  7457. 0, /*tp_setattro*/
  7458. 0, /*tp_as_buffer*/
  7459. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  7460. 0, /*tp_doc*/
  7461. __pyx_tp_traverse_4yarl_8_quoting__Unquoter, /*tp_traverse*/
  7462. __pyx_tp_clear_4yarl_8_quoting__Unquoter, /*tp_clear*/
  7463. 0, /*tp_richcompare*/
  7464. 0, /*tp_weaklistoffset*/
  7465. 0, /*tp_iter*/
  7466. 0, /*tp_iternext*/
  7467. __pyx_methods_4yarl_8_quoting__Unquoter, /*tp_methods*/
  7468. 0, /*tp_members*/
  7469. 0, /*tp_getset*/
  7470. 0, /*tp_base*/
  7471. 0, /*tp_dict*/
  7472. 0, /*tp_descr_get*/
  7473. 0, /*tp_descr_set*/
  7474. 0, /*tp_dictoffset*/
  7475. __pyx_pw_4yarl_8_quoting_9_Unquoter_1__init__, /*tp_init*/
  7476. 0, /*tp_alloc*/
  7477. __pyx_tp_new_4yarl_8_quoting__Unquoter, /*tp_new*/
  7478. 0, /*tp_free*/
  7479. 0, /*tp_is_gc*/
  7480. 0, /*tp_bases*/
  7481. 0, /*tp_mro*/
  7482. 0, /*tp_cache*/
  7483. 0, /*tp_subclasses*/
  7484. 0, /*tp_weaklist*/
  7485. 0, /*tp_del*/
  7486. 0, /*tp_version_tag*/
  7487. #if PY_VERSION_HEX >= 0x030400a1
  7488. 0, /*tp_finalize*/
  7489. #endif
  7490. };
  7491. static PyMethodDef __pyx_methods[] = {
  7492. {0, 0, 0, 0}
  7493. };
  7494. #if PY_MAJOR_VERSION >= 3
  7495. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7496. static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
  7497. static int __pyx_pymod_exec__quoting(PyObject* module); /*proto*/
  7498. static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  7499. {Py_mod_create, (void*)__pyx_pymod_create},
  7500. {Py_mod_exec, (void*)__pyx_pymod_exec__quoting},
  7501. {0, NULL}
  7502. };
  7503. #endif
  7504. static struct PyModuleDef __pyx_moduledef = {
  7505. PyModuleDef_HEAD_INIT,
  7506. "_quoting",
  7507. 0, /* m_doc */
  7508. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7509. 0, /* m_size */
  7510. #else
  7511. -1, /* m_size */
  7512. #endif
  7513. __pyx_methods /* m_methods */,
  7514. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7515. __pyx_moduledef_slots, /* m_slots */
  7516. #else
  7517. NULL, /* m_reload */
  7518. #endif
  7519. NULL, /* m_traverse */
  7520. NULL, /* m_clear */
  7521. NULL /* m_free */
  7522. };
  7523. #endif
  7524. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  7525. {&__pyx_kp_u_, __pyx_k_, sizeof(__pyx_k_), 0, 1, 0, 0},
  7526. {&__pyx_kp_u_Argument_should_be_str, __pyx_k_Argument_should_be_str, sizeof(__pyx_k_Argument_should_be_str), 0, 1, 0, 0},
  7527. {&__pyx_kp_s_Incompatible_checksums_s_vs_0x27, __pyx_k_Incompatible_checksums_s_vs_0x27, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x27), 0, 0, 1, 0},
  7528. {&__pyx_kp_s_Incompatible_checksums_s_vs_0x8f, __pyx_k_Incompatible_checksums_s_vs_0x8f, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x8f), 0, 0, 1, 0},
  7529. {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
  7530. {&__pyx_kp_u_Only_safe_symbols_with_ORD_128_a, __pyx_k_Only_safe_symbols_with_ORD_128_a, sizeof(__pyx_k_Only_safe_symbols_with_ORD_128_a), 0, 1, 0, 0},
  7531. {&__pyx_n_s_OverflowError, __pyx_k_OverflowError, sizeof(__pyx_k_OverflowError), 0, 0, 1, 1},
  7532. {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
  7533. {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  7534. {&__pyx_n_s_UnicodeDecodeError, __pyx_k_UnicodeDecodeError, sizeof(__pyx_k_UnicodeDecodeError), 0, 0, 1, 1},
  7535. {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  7536. {&__pyx_kp_u__11, __pyx_k__11, sizeof(__pyx_k__11), 0, 1, 0, 0},
  7537. {&__pyx_kp_u__12, __pyx_k__12, sizeof(__pyx_k__12), 0, 1, 0, 0},
  7538. {&__pyx_kp_u__13, __pyx_k__13, sizeof(__pyx_k__13), 0, 1, 0, 0},
  7539. {&__pyx_kp_u__14, __pyx_k__14, sizeof(__pyx_k__14), 0, 1, 0, 0},
  7540. {&__pyx_kp_u__15, __pyx_k__15, sizeof(__pyx_k__15), 0, 1, 0, 0},
  7541. {&__pyx_kp_u__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 1, 0, 0},
  7542. {&__pyx_kp_u__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 1, 0, 0},
  7543. {&__pyx_kp_u__8, __pyx_k__8, sizeof(__pyx_k__8), 0, 1, 0, 0},
  7544. {&__pyx_kp_u__9, __pyx_k__9, sizeof(__pyx_k__9), 0, 1, 0, 0},
  7545. {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  7546. {&__pyx_n_s_ascii_letters, __pyx_k_ascii_letters, sizeof(__pyx_k_ascii_letters), 0, 0, 1, 1},
  7547. {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
  7548. {&__pyx_n_s_chr, __pyx_k_chr, sizeof(__pyx_k_chr), 0, 0, 1, 1},
  7549. {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  7550. {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
  7551. {&__pyx_n_s_digits, __pyx_k_digits, sizeof(__pyx_k_digits), 0, 0, 1, 1},
  7552. {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  7553. {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  7554. {&__pyx_n_s_hex, __pyx_k_hex, sizeof(__pyx_k_hex), 0, 0, 1, 1},
  7555. {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  7556. {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  7557. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  7558. {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  7559. {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  7560. {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
  7561. {&__pyx_n_s_protected, __pyx_k_protected, sizeof(__pyx_k_protected), 0, 0, 1, 1},
  7562. {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
  7563. {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
  7564. {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
  7565. {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
  7566. {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
  7567. {&__pyx_n_s_pyx_unpickle__Quoter, __pyx_k_pyx_unpickle__Quoter, sizeof(__pyx_k_pyx_unpickle__Quoter), 0, 0, 1, 1},
  7568. {&__pyx_n_s_pyx_unpickle__Unquoter, __pyx_k_pyx_unpickle__Unquoter, sizeof(__pyx_k_pyx_unpickle__Unquoter), 0, 0, 1, 1},
  7569. {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  7570. {&__pyx_n_s_qs, __pyx_k_qs, sizeof(__pyx_k_qs), 0, 0, 1, 1},
  7571. {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  7572. {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  7573. {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  7574. {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  7575. {&__pyx_n_s_safe, __pyx_k_safe, sizeof(__pyx_k_safe), 0, 0, 1, 1},
  7576. {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  7577. {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  7578. {&__pyx_n_s_string, __pyx_k_string, sizeof(__pyx_k_string), 0, 0, 1, 1},
  7579. {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
  7580. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  7581. {&__pyx_n_s_unsafe, __pyx_k_unsafe, sizeof(__pyx_k_unsafe), 0, 0, 1, 1},
  7582. {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  7583. {&__pyx_n_s_upper, __pyx_k_upper, sizeof(__pyx_k_upper), 0, 0, 1, 1},
  7584. {&__pyx_n_s_val, __pyx_k_val, sizeof(__pyx_k_val), 0, 0, 1, 1},
  7585. {&__pyx_n_s_yarl__quoting, __pyx_k_yarl__quoting, sizeof(__pyx_k_yarl__quoting), 0, 0, 1, 1},
  7586. {0, 0, 0, 0, 0, 0, 0}
  7587. };
  7588. static int __Pyx_InitCachedBuiltins(void) {
  7589. __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 67, __pyx_L1_error)
  7590. __pyx_builtin_chr = __Pyx_GetBuiltinName(__pyx_n_s_chr); if (!__pyx_builtin_chr) __PYX_ERR(0, 68, __pyx_L1_error)
  7591. __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 207, __pyx_L1_error)
  7592. __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 226, __pyx_L1_error)
  7593. __pyx_builtin_UnicodeDecodeError = __Pyx_GetBuiltinName(__pyx_n_s_UnicodeDecodeError); if (!__pyx_builtin_UnicodeDecodeError) __PYX_ERR(0, 343, __pyx_L1_error)
  7594. __pyx_builtin_hex = __Pyx_GetBuiltinName(__pyx_n_s_hex); if (!__pyx_builtin_hex) __PYX_ERR(0, 371, __pyx_L1_error)
  7595. __pyx_builtin_OverflowError = __Pyx_GetBuiltinName(__pyx_n_s_OverflowError); if (!__pyx_builtin_OverflowError) __PYX_ERR(1, 81, __pyx_L1_error)
  7596. __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(1, 84, __pyx_L1_error)
  7597. __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(1, 94, __pyx_L1_error)
  7598. return 0;
  7599. __pyx_L1_error:;
  7600. return -1;
  7601. }
  7602. static int __Pyx_InitCachedConstants(void) {
  7603. __Pyx_RefNannyDeclarations
  7604. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  7605. /* "yarl/_quoting.pyx":207
  7606. * for ch in safe:
  7607. * if ord(ch) > 127:
  7608. * raise ValueError("Only safe symbols with ORD < 128 are allowed") # <<<<<<<<<<<<<<
  7609. * set_bit(self._safe_table, ch)
  7610. *
  7611. */
  7612. __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_Only_safe_symbols_with_ORD_128_a); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 207, __pyx_L1_error)
  7613. __Pyx_GOTREF(__pyx_tuple__2);
  7614. __Pyx_GIVEREF(__pyx_tuple__2);
  7615. /* "yarl/_quoting.pyx":213
  7616. * for ch in protected:
  7617. * if ord(ch) > 127:
  7618. * raise ValueError("Only safe symbols with ORD < 128 are allowed") # <<<<<<<<<<<<<<
  7619. * set_bit(self._safe_table, ch)
  7620. * set_bit(self._protected_table, ch)
  7621. */
  7622. __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_Only_safe_symbols_with_ORD_128_a); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 213, __pyx_L1_error)
  7623. __Pyx_GOTREF(__pyx_tuple__3);
  7624. __Pyx_GIVEREF(__pyx_tuple__3);
  7625. /* "yarl/_quoting.pyx":226
  7626. * val = str(val)
  7627. * else:
  7628. * raise TypeError("Argument should be str") # <<<<<<<<<<<<<<
  7629. * _init_writer(&writer)
  7630. * try:
  7631. */
  7632. __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Argument_should_be_str); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 226, __pyx_L1_error)
  7633. __Pyx_GOTREF(__pyx_tuple__4);
  7634. __Pyx_GIVEREF(__pyx_tuple__4);
  7635. /* "yarl/_quoting.pyx":321
  7636. * val = str(val)
  7637. * else:
  7638. * raise TypeError("Argument should be str") # <<<<<<<<<<<<<<
  7639. * return self._do_unquote(<str>val)
  7640. *
  7641. */
  7642. __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Argument_should_be_str); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 321, __pyx_L1_error)
  7643. __Pyx_GOTREF(__pyx_tuple__5);
  7644. __Pyx_GIVEREF(__pyx_tuple__5);
  7645. /* "yarl/_quoting.pyx":371
  7646. * if ch in self._unsafe:
  7647. * ret.append('%')
  7648. * h = hex(ord(ch)).upper()[2:] # <<<<<<<<<<<<<<
  7649. * for ch in h:
  7650. * ret.append(ch)
  7651. */
  7652. __pyx_slice__10 = PySlice_New(__pyx_int_2, Py_None, Py_None); if (unlikely(!__pyx_slice__10)) __PYX_ERR(0, 371, __pyx_L1_error)
  7653. __Pyx_GOTREF(__pyx_slice__10);
  7654. __Pyx_GIVEREF(__pyx_slice__10);
  7655. /* "(tree fragment)":1
  7656. * def __pyx_unpickle__Quoter(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
  7657. * if __pyx_checksum != 0x8f193a6:
  7658. * from pickle import PickleError as __pyx_PickleError
  7659. */
  7660. __pyx_tuple__16 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 1, __pyx_L1_error)
  7661. __Pyx_GOTREF(__pyx_tuple__16);
  7662. __Pyx_GIVEREF(__pyx_tuple__16);
  7663. __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle__Quoter, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(1, 1, __pyx_L1_error)
  7664. __pyx_tuple__18 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(1, 1, __pyx_L1_error)
  7665. __Pyx_GOTREF(__pyx_tuple__18);
  7666. __Pyx_GIVEREF(__pyx_tuple__18);
  7667. __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle__Unquoter, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(1, 1, __pyx_L1_error)
  7668. __Pyx_RefNannyFinishContext();
  7669. return 0;
  7670. __pyx_L1_error:;
  7671. __Pyx_RefNannyFinishContext();
  7672. return -1;
  7673. }
  7674. static int __Pyx_InitGlobals(void) {
  7675. if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  7676. __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  7677. __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) __PYX_ERR(0, 1, __pyx_L1_error)
  7678. __pyx_int_41310077 = PyInt_FromLong(41310077L); if (unlikely(!__pyx_int_41310077)) __PYX_ERR(0, 1, __pyx_L1_error)
  7679. __pyx_int_150049702 = PyInt_FromLong(150049702L); if (unlikely(!__pyx_int_150049702)) __PYX_ERR(0, 1, __pyx_L1_error)
  7680. return 0;
  7681. __pyx_L1_error:;
  7682. return -1;
  7683. }
  7684. static int __Pyx_modinit_global_init_code(void); /*proto*/
  7685. static int __Pyx_modinit_variable_export_code(void); /*proto*/
  7686. static int __Pyx_modinit_function_export_code(void); /*proto*/
  7687. static int __Pyx_modinit_type_init_code(void); /*proto*/
  7688. static int __Pyx_modinit_type_import_code(void); /*proto*/
  7689. static int __Pyx_modinit_variable_import_code(void); /*proto*/
  7690. static int __Pyx_modinit_function_import_code(void); /*proto*/
  7691. static int __Pyx_modinit_global_init_code(void) {
  7692. __Pyx_RefNannyDeclarations
  7693. __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  7694. /*--- Global init code ---*/
  7695. __pyx_v_4yarl_8_quoting_GEN_DELIMS = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7696. __pyx_v_4yarl_8_quoting_SUB_DELIMS_WITHOUT_QS = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7697. __pyx_v_4yarl_8_quoting_SUB_DELIMS = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7698. __pyx_v_4yarl_8_quoting_RESERVED = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7699. __pyx_v_4yarl_8_quoting_UNRESERVED = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7700. __pyx_v_4yarl_8_quoting_ALLOWED = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7701. __pyx_v_4yarl_8_quoting_QS = ((PyObject*)Py_None); Py_INCREF(Py_None);
  7702. __Pyx_RefNannyFinishContext();
  7703. return 0;
  7704. }
  7705. static int __Pyx_modinit_variable_export_code(void) {
  7706. __Pyx_RefNannyDeclarations
  7707. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  7708. /*--- Variable export code ---*/
  7709. __Pyx_RefNannyFinishContext();
  7710. return 0;
  7711. }
  7712. static int __Pyx_modinit_function_export_code(void) {
  7713. __Pyx_RefNannyDeclarations
  7714. __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  7715. /*--- Function export code ---*/
  7716. __Pyx_RefNannyFinishContext();
  7717. return 0;
  7718. }
  7719. static int __Pyx_modinit_type_init_code(void) {
  7720. __Pyx_RefNannyDeclarations
  7721. __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  7722. /*--- Type init code ---*/
  7723. __pyx_vtabptr_4yarl_8_quoting__Quoter = &__pyx_vtable_4yarl_8_quoting__Quoter;
  7724. __pyx_vtable_4yarl_8_quoting__Quoter._do_quote = (PyObject *(*)(struct __pyx_obj_4yarl_8_quoting__Quoter *, PyObject *, struct __pyx_t_4yarl_8_quoting_Writer *))__pyx_f_4yarl_8_quoting_7_Quoter__do_quote;
  7725. __pyx_vtable_4yarl_8_quoting__Quoter._write = (int (*)(struct __pyx_obj_4yarl_8_quoting__Quoter *, struct __pyx_t_4yarl_8_quoting_Writer *, Py_UCS4))__pyx_f_4yarl_8_quoting_7_Quoter__write;
  7726. if (PyType_Ready(&__pyx_type_4yarl_8_quoting__Quoter) < 0) __PYX_ERR(0, 186, __pyx_L1_error)
  7727. __pyx_type_4yarl_8_quoting__Quoter.tp_print = 0;
  7728. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4yarl_8_quoting__Quoter.tp_dictoffset && __pyx_type_4yarl_8_quoting__Quoter.tp_getattro == PyObject_GenericGetAttr)) {
  7729. __pyx_type_4yarl_8_quoting__Quoter.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  7730. }
  7731. if (__Pyx_SetVtable(__pyx_type_4yarl_8_quoting__Quoter.tp_dict, __pyx_vtabptr_4yarl_8_quoting__Quoter) < 0) __PYX_ERR(0, 186, __pyx_L1_error)
  7732. if (PyObject_SetAttrString(__pyx_m, "_Quoter", (PyObject *)&__pyx_type_4yarl_8_quoting__Quoter) < 0) __PYX_ERR(0, 186, __pyx_L1_error)
  7733. if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4yarl_8_quoting__Quoter) < 0) __PYX_ERR(0, 186, __pyx_L1_error)
  7734. __pyx_ptype_4yarl_8_quoting__Quoter = &__pyx_type_4yarl_8_quoting__Quoter;
  7735. __pyx_vtabptr_4yarl_8_quoting__Unquoter = &__pyx_vtable_4yarl_8_quoting__Unquoter;
  7736. __pyx_vtable_4yarl_8_quoting__Unquoter._do_unquote = (PyObject *(*)(struct __pyx_obj_4yarl_8_quoting__Unquoter *, PyObject *))__pyx_f_4yarl_8_quoting_9_Unquoter__do_unquote;
  7737. if (PyType_Ready(&__pyx_type_4yarl_8_quoting__Unquoter) < 0) __PYX_ERR(0, 301, __pyx_L1_error)
  7738. __pyx_type_4yarl_8_quoting__Unquoter.tp_print = 0;
  7739. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4yarl_8_quoting__Unquoter.tp_dictoffset && __pyx_type_4yarl_8_quoting__Unquoter.tp_getattro == PyObject_GenericGetAttr)) {
  7740. __pyx_type_4yarl_8_quoting__Unquoter.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  7741. }
  7742. if (__Pyx_SetVtable(__pyx_type_4yarl_8_quoting__Unquoter.tp_dict, __pyx_vtabptr_4yarl_8_quoting__Unquoter) < 0) __PYX_ERR(0, 301, __pyx_L1_error)
  7743. if (PyObject_SetAttrString(__pyx_m, "_Unquoter", (PyObject *)&__pyx_type_4yarl_8_quoting__Unquoter) < 0) __PYX_ERR(0, 301, __pyx_L1_error)
  7744. if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4yarl_8_quoting__Unquoter) < 0) __PYX_ERR(0, 301, __pyx_L1_error)
  7745. __pyx_ptype_4yarl_8_quoting__Unquoter = &__pyx_type_4yarl_8_quoting__Unquoter;
  7746. __Pyx_RefNannyFinishContext();
  7747. return 0;
  7748. __pyx_L1_error:;
  7749. __Pyx_RefNannyFinishContext();
  7750. return -1;
  7751. }
  7752. static int __Pyx_modinit_type_import_code(void) {
  7753. __Pyx_RefNannyDeclarations
  7754. __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  7755. /*--- Type import code ---*/
  7756. __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type",
  7757. #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
  7758. sizeof(PyTypeObject),
  7759. #else
  7760. sizeof(PyHeapTypeObject),
  7761. #endif
  7762. 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(2, 9, __pyx_L1_error)
  7763. __Pyx_RefNannyFinishContext();
  7764. return 0;
  7765. __pyx_L1_error:;
  7766. __Pyx_RefNannyFinishContext();
  7767. return -1;
  7768. }
  7769. static int __Pyx_modinit_variable_import_code(void) {
  7770. __Pyx_RefNannyDeclarations
  7771. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  7772. /*--- Variable import code ---*/
  7773. __Pyx_RefNannyFinishContext();
  7774. return 0;
  7775. }
  7776. static int __Pyx_modinit_function_import_code(void) {
  7777. __Pyx_RefNannyDeclarations
  7778. __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  7779. /*--- Function import code ---*/
  7780. __Pyx_RefNannyFinishContext();
  7781. return 0;
  7782. }
  7783. #if PY_MAJOR_VERSION < 3
  7784. #ifdef CYTHON_NO_PYINIT_EXPORT
  7785. #define __Pyx_PyMODINIT_FUNC void
  7786. #else
  7787. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  7788. #endif
  7789. #else
  7790. #ifdef CYTHON_NO_PYINIT_EXPORT
  7791. #define __Pyx_PyMODINIT_FUNC PyObject *
  7792. #else
  7793. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  7794. #endif
  7795. #endif
  7796. #ifndef CYTHON_SMALL_CODE
  7797. #if defined(__clang__)
  7798. #define CYTHON_SMALL_CODE
  7799. #elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
  7800. #define CYTHON_SMALL_CODE __attribute__((optimize("Os")))
  7801. #else
  7802. #define CYTHON_SMALL_CODE
  7803. #endif
  7804. #endif
  7805. #if PY_MAJOR_VERSION < 3
  7806. __Pyx_PyMODINIT_FUNC init_quoting(void) CYTHON_SMALL_CODE; /*proto*/
  7807. __Pyx_PyMODINIT_FUNC init_quoting(void)
  7808. #else
  7809. __Pyx_PyMODINIT_FUNC PyInit__quoting(void) CYTHON_SMALL_CODE; /*proto*/
  7810. __Pyx_PyMODINIT_FUNC PyInit__quoting(void)
  7811. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7812. {
  7813. return PyModuleDef_Init(&__pyx_moduledef);
  7814. }
  7815. static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
  7816. PyObject *value = PyObject_GetAttrString(spec, from_name);
  7817. int result = 0;
  7818. if (likely(value)) {
  7819. result = PyDict_SetItemString(moddict, to_name, value);
  7820. Py_DECREF(value);
  7821. } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
  7822. PyErr_Clear();
  7823. } else {
  7824. result = -1;
  7825. }
  7826. return result;
  7827. }
  7828. static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
  7829. PyObject *module = NULL, *moddict, *modname;
  7830. if (__pyx_m)
  7831. return __Pyx_NewRef(__pyx_m);
  7832. modname = PyObject_GetAttrString(spec, "name");
  7833. if (unlikely(!modname)) goto bad;
  7834. module = PyModule_NewObject(modname);
  7835. Py_DECREF(modname);
  7836. if (unlikely(!module)) goto bad;
  7837. moddict = PyModule_GetDict(module);
  7838. if (unlikely(!moddict)) goto bad;
  7839. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
  7840. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
  7841. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
  7842. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
  7843. return module;
  7844. bad:
  7845. Py_XDECREF(module);
  7846. return NULL;
  7847. }
  7848. static int __pyx_pymod_exec__quoting(PyObject *__pyx_pyinit_module)
  7849. #endif
  7850. #endif
  7851. {
  7852. PyObject *__pyx_t_1 = NULL;
  7853. PyObject *__pyx_t_2 = NULL;
  7854. PyObject *__pyx_t_3 = NULL;
  7855. long __pyx_t_4;
  7856. int __pyx_t_5;
  7857. int __pyx_t_6;
  7858. uint64_t __pyx_t_7;
  7859. __Pyx_RefNannyDeclarations
  7860. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7861. if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
  7862. #elif PY_MAJOR_VERSION >= 3
  7863. if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  7864. #endif
  7865. #if CYTHON_REFNANNY
  7866. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  7867. if (!__Pyx_RefNanny) {
  7868. PyErr_Clear();
  7869. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  7870. if (!__Pyx_RefNanny)
  7871. Py_FatalError("failed to import 'refnanny' module");
  7872. }
  7873. #endif
  7874. __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__quoting(void)", 0);
  7875. if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7876. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  7877. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  7878. __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  7879. #ifdef __Pyx_CyFunction_USED
  7880. if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7881. #endif
  7882. #ifdef __Pyx_FusedFunction_USED
  7883. if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7884. #endif
  7885. #ifdef __Pyx_Coroutine_USED
  7886. if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7887. #endif
  7888. #ifdef __Pyx_Generator_USED
  7889. if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7890. #endif
  7891. #ifdef __Pyx_AsyncGen_USED
  7892. if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7893. #endif
  7894. #ifdef __Pyx_StopAsyncIteration_USED
  7895. if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7896. #endif
  7897. /*--- Library function declarations ---*/
  7898. /*--- Threads initialization code ---*/
  7899. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  7900. #ifdef WITH_THREAD /* Python build with threading support? */
  7901. PyEval_InitThreads();
  7902. #endif
  7903. #endif
  7904. /*--- Module creation code ---*/
  7905. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7906. __pyx_m = __pyx_pyinit_module;
  7907. Py_INCREF(__pyx_m);
  7908. #else
  7909. #if PY_MAJOR_VERSION < 3
  7910. __pyx_m = Py_InitModule4("_quoting", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  7911. #else
  7912. __pyx_m = PyModule_Create(&__pyx_moduledef);
  7913. #endif
  7914. if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  7915. #endif
  7916. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  7917. Py_INCREF(__pyx_d);
  7918. __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  7919. __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  7920. #if CYTHON_COMPILING_IN_PYPY
  7921. Py_INCREF(__pyx_b);
  7922. #endif
  7923. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  7924. /*--- Initialize various global constants etc. ---*/
  7925. if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7926. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  7927. if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7928. #endif
  7929. if (__pyx_module_is_main_yarl___quoting) {
  7930. if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7931. }
  7932. #if PY_MAJOR_VERSION >= 3
  7933. {
  7934. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  7935. if (!PyDict_GetItemString(modules, "yarl._quoting")) {
  7936. if (unlikely(PyDict_SetItemString(modules, "yarl._quoting", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7937. }
  7938. }
  7939. #endif
  7940. /*--- Builtin init code ---*/
  7941. if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7942. /*--- Constants init code ---*/
  7943. if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7944. /*--- Global type/function init code ---*/
  7945. (void)__Pyx_modinit_global_init_code();
  7946. (void)__Pyx_modinit_variable_export_code();
  7947. (void)__Pyx_modinit_function_export_code();
  7948. if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
  7949. if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
  7950. (void)__Pyx_modinit_variable_import_code();
  7951. (void)__Pyx_modinit_function_import_code();
  7952. /*--- Execution code ---*/
  7953. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  7954. if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7955. #endif
  7956. /* "yarl/_quoting.pyx":10
  7957. * from cpython.unicode cimport PyUnicode_DecodeASCII
  7958. *
  7959. * from string import ascii_letters, digits # <<<<<<<<<<<<<<
  7960. *
  7961. * cdef str GEN_DELIMS = ":/?#[]@"
  7962. */
  7963. __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
  7964. __Pyx_GOTREF(__pyx_t_1);
  7965. __Pyx_INCREF(__pyx_n_s_ascii_letters);
  7966. __Pyx_GIVEREF(__pyx_n_s_ascii_letters);
  7967. PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_ascii_letters);
  7968. __Pyx_INCREF(__pyx_n_s_digits);
  7969. __Pyx_GIVEREF(__pyx_n_s_digits);
  7970. PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_digits);
  7971. __pyx_t_2 = __Pyx_Import(__pyx_n_s_string, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
  7972. __Pyx_GOTREF(__pyx_t_2);
  7973. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7974. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ascii_letters); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
  7975. __Pyx_GOTREF(__pyx_t_1);
  7976. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ascii_letters, __pyx_t_1) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  7977. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7978. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_digits); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
  7979. __Pyx_GOTREF(__pyx_t_1);
  7980. if (PyDict_SetItem(__pyx_d, __pyx_n_s_digits, __pyx_t_1) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  7981. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7982. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7983. /* "yarl/_quoting.pyx":12
  7984. * from string import ascii_letters, digits
  7985. *
  7986. * cdef str GEN_DELIMS = ":/?#[]@" # <<<<<<<<<<<<<<
  7987. * cdef str SUB_DELIMS_WITHOUT_QS = "!$'()*,"
  7988. * cdef str SUB_DELIMS = SUB_DELIMS_WITHOUT_QS + '+?=;'
  7989. */
  7990. __Pyx_INCREF(__pyx_kp_u__11);
  7991. __Pyx_XGOTREF(__pyx_v_4yarl_8_quoting_GEN_DELIMS);
  7992. __Pyx_DECREF_SET(__pyx_v_4yarl_8_quoting_GEN_DELIMS, __pyx_kp_u__11);
  7993. __Pyx_GIVEREF(__pyx_kp_u__11);
  7994. /* "yarl/_quoting.pyx":13
  7995. *
  7996. * cdef str GEN_DELIMS = ":/?#[]@"
  7997. * cdef str SUB_DELIMS_WITHOUT_QS = "!$'()*," # <<<<<<<<<<<<<<
  7998. * cdef str SUB_DELIMS = SUB_DELIMS_WITHOUT_QS + '+?=;'
  7999. * cdef str RESERVED = GEN_DELIMS + SUB_DELIMS
  8000. */
  8001. __Pyx_INCREF(__pyx_kp_u__12);
  8002. __Pyx_XGOTREF(__pyx_v_4yarl_8_quoting_SUB_DELIMS_WITHOUT_QS);
  8003. __Pyx_DECREF_SET(__pyx_v_4yarl_8_quoting_SUB_DELIMS_WITHOUT_QS, __pyx_kp_u__12);
  8004. __Pyx_GIVEREF(__pyx_kp_u__12);
  8005. /* "yarl/_quoting.pyx":14
  8006. * cdef str GEN_DELIMS = ":/?#[]@"
  8007. * cdef str SUB_DELIMS_WITHOUT_QS = "!$'()*,"
  8008. * cdef str SUB_DELIMS = SUB_DELIMS_WITHOUT_QS + '+?=;' # <<<<<<<<<<<<<<
  8009. * cdef str RESERVED = GEN_DELIMS + SUB_DELIMS
  8010. * cdef str UNRESERVED = ascii_letters + digits + '-._~'
  8011. */
  8012. __pyx_t_2 = __Pyx_PyUnicode_ConcatSafe(__pyx_v_4yarl_8_quoting_SUB_DELIMS_WITHOUT_QS, __pyx_kp_u__13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
  8013. __Pyx_GOTREF(__pyx_t_2);
  8014. __Pyx_XGOTREF(__pyx_v_4yarl_8_quoting_SUB_DELIMS);
  8015. __Pyx_DECREF_SET(__pyx_v_4yarl_8_quoting_SUB_DELIMS, ((PyObject*)__pyx_t_2));
  8016. __Pyx_GIVEREF(__pyx_t_2);
  8017. __pyx_t_2 = 0;
  8018. /* "yarl/_quoting.pyx":15
  8019. * cdef str SUB_DELIMS_WITHOUT_QS = "!$'()*,"
  8020. * cdef str SUB_DELIMS = SUB_DELIMS_WITHOUT_QS + '+?=;'
  8021. * cdef str RESERVED = GEN_DELIMS + SUB_DELIMS # <<<<<<<<<<<<<<
  8022. * cdef str UNRESERVED = ascii_letters + digits + '-._~'
  8023. * cdef str ALLOWED = UNRESERVED + SUB_DELIMS_WITHOUT_QS
  8024. */
  8025. __pyx_t_2 = __Pyx_PyUnicode_ConcatSafe(__pyx_v_4yarl_8_quoting_GEN_DELIMS, __pyx_v_4yarl_8_quoting_SUB_DELIMS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
  8026. __Pyx_GOTREF(__pyx_t_2);
  8027. __Pyx_XGOTREF(__pyx_v_4yarl_8_quoting_RESERVED);
  8028. __Pyx_DECREF_SET(__pyx_v_4yarl_8_quoting_RESERVED, ((PyObject*)__pyx_t_2));
  8029. __Pyx_GIVEREF(__pyx_t_2);
  8030. __pyx_t_2 = 0;
  8031. /* "yarl/_quoting.pyx":16
  8032. * cdef str SUB_DELIMS = SUB_DELIMS_WITHOUT_QS + '+?=;'
  8033. * cdef str RESERVED = GEN_DELIMS + SUB_DELIMS
  8034. * cdef str UNRESERVED = ascii_letters + digits + '-._~' # <<<<<<<<<<<<<<
  8035. * cdef str ALLOWED = UNRESERVED + SUB_DELIMS_WITHOUT_QS
  8036. * cdef str QS = '+&=;'
  8037. */
  8038. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ascii_letters); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
  8039. __Pyx_GOTREF(__pyx_t_2);
  8040. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_digits); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
  8041. __Pyx_GOTREF(__pyx_t_1);
  8042. __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 16, __pyx_L1_error)
  8043. __Pyx_GOTREF(__pyx_t_3);
  8044. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8045. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8046. __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_kp_u__14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
  8047. __Pyx_GOTREF(__pyx_t_1);
  8048. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8049. if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 16, __pyx_L1_error)
  8050. __Pyx_XGOTREF(__pyx_v_4yarl_8_quoting_UNRESERVED);
  8051. __Pyx_DECREF_SET(__pyx_v_4yarl_8_quoting_UNRESERVED, ((PyObject*)__pyx_t_1));
  8052. __Pyx_GIVEREF(__pyx_t_1);
  8053. __pyx_t_1 = 0;
  8054. /* "yarl/_quoting.pyx":17
  8055. * cdef str RESERVED = GEN_DELIMS + SUB_DELIMS
  8056. * cdef str UNRESERVED = ascii_letters + digits + '-._~'
  8057. * cdef str ALLOWED = UNRESERVED + SUB_DELIMS_WITHOUT_QS # <<<<<<<<<<<<<<
  8058. * cdef str QS = '+&=;'
  8059. *
  8060. */
  8061. __pyx_t_1 = __Pyx_PyUnicode_ConcatSafe(__pyx_v_4yarl_8_quoting_UNRESERVED, __pyx_v_4yarl_8_quoting_SUB_DELIMS_WITHOUT_QS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  8062. __Pyx_GOTREF(__pyx_t_1);
  8063. __Pyx_XGOTREF(__pyx_v_4yarl_8_quoting_ALLOWED);
  8064. __Pyx_DECREF_SET(__pyx_v_4yarl_8_quoting_ALLOWED, ((PyObject*)__pyx_t_1));
  8065. __Pyx_GIVEREF(__pyx_t_1);
  8066. __pyx_t_1 = 0;
  8067. /* "yarl/_quoting.pyx":18
  8068. * cdef str UNRESERVED = ascii_letters + digits + '-._~'
  8069. * cdef str ALLOWED = UNRESERVED + SUB_DELIMS_WITHOUT_QS
  8070. * cdef str QS = '+&=;' # <<<<<<<<<<<<<<
  8071. *
  8072. * DEF BUF_SIZE = 8 * 1024 # 8KiB
  8073. */
  8074. __Pyx_INCREF(__pyx_kp_u__15);
  8075. __Pyx_XGOTREF(__pyx_v_4yarl_8_quoting_QS);
  8076. __Pyx_DECREF_SET(__pyx_v_4yarl_8_quoting_QS, __pyx_kp_u__15);
  8077. __Pyx_GIVEREF(__pyx_kp_u__15);
  8078. /* "yarl/_quoting.pyx":64
  8079. *
  8080. *
  8081. * memset(ALLOWED_TABLE, 0, sizeof(ALLOWED_TABLE)) # <<<<<<<<<<<<<<
  8082. * memset(ALLOWED_NOTQS_TABLE, 0, sizeof(ALLOWED_NOTQS_TABLE))
  8083. *
  8084. */
  8085. (void)(memset(__pyx_v_4yarl_8_quoting_ALLOWED_TABLE, 0, (sizeof(__pyx_v_4yarl_8_quoting_ALLOWED_TABLE))));
  8086. /* "yarl/_quoting.pyx":65
  8087. *
  8088. * memset(ALLOWED_TABLE, 0, sizeof(ALLOWED_TABLE))
  8089. * memset(ALLOWED_NOTQS_TABLE, 0, sizeof(ALLOWED_NOTQS_TABLE)) # <<<<<<<<<<<<<<
  8090. *
  8091. * for i in range(128):
  8092. */
  8093. (void)(memset(__pyx_v_4yarl_8_quoting_ALLOWED_NOTQS_TABLE, 0, (sizeof(__pyx_v_4yarl_8_quoting_ALLOWED_NOTQS_TABLE))));
  8094. /* "yarl/_quoting.pyx":67
  8095. * memset(ALLOWED_NOTQS_TABLE, 0, sizeof(ALLOWED_NOTQS_TABLE))
  8096. *
  8097. * for i in range(128): # <<<<<<<<<<<<<<
  8098. * if chr(i) in ALLOWED:
  8099. * set_bit(ALLOWED_TABLE, i)
  8100. */
  8101. for (__pyx_t_4 = 0; __pyx_t_4 < 0x80; __pyx_t_4+=1) {
  8102. __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error)
  8103. __Pyx_GOTREF(__pyx_t_1);
  8104. if (PyDict_SetItem(__pyx_d, __pyx_n_s_i, __pyx_t_1) < 0) __PYX_ERR(0, 67, __pyx_L1_error)
  8105. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8106. /* "yarl/_quoting.pyx":68
  8107. *
  8108. * for i in range(128):
  8109. * if chr(i) in ALLOWED: # <<<<<<<<<<<<<<
  8110. * set_bit(ALLOWED_TABLE, i)
  8111. * set_bit(ALLOWED_NOTQS_TABLE, i)
  8112. */
  8113. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
  8114. __Pyx_GOTREF(__pyx_t_1);
  8115. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_chr, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 68, __pyx_L1_error)
  8116. __Pyx_GOTREF(__pyx_t_3);
  8117. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8118. if (unlikely(__pyx_v_4yarl_8_quoting_ALLOWED == Py_None)) {
  8119. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
  8120. __PYX_ERR(0, 68, __pyx_L1_error)
  8121. }
  8122. __pyx_t_5 = (__Pyx_PyUnicode_ContainsTF(__pyx_t_3, __pyx_v_4yarl_8_quoting_ALLOWED, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 68, __pyx_L1_error)
  8123. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8124. __pyx_t_6 = (__pyx_t_5 != 0);
  8125. if (__pyx_t_6) {
  8126. /* "yarl/_quoting.pyx":69
  8127. * for i in range(128):
  8128. * if chr(i) in ALLOWED:
  8129. * set_bit(ALLOWED_TABLE, i) # <<<<<<<<<<<<<<
  8130. * set_bit(ALLOWED_NOTQS_TABLE, i)
  8131. * if chr(i) in QS:
  8132. */
  8133. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 69, __pyx_L1_error)
  8134. __Pyx_GOTREF(__pyx_t_3);
  8135. __pyx_t_7 = __Pyx_PyInt_As_uint64_t(__pyx_t_3); if (unlikely((__pyx_t_7 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 69, __pyx_L1_error)
  8136. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8137. __pyx_f_4yarl_8_quoting_set_bit(__pyx_v_4yarl_8_quoting_ALLOWED_TABLE, __pyx_t_7);
  8138. /* "yarl/_quoting.pyx":70
  8139. * if chr(i) in ALLOWED:
  8140. * set_bit(ALLOWED_TABLE, i)
  8141. * set_bit(ALLOWED_NOTQS_TABLE, i) # <<<<<<<<<<<<<<
  8142. * if chr(i) in QS:
  8143. * set_bit(ALLOWED_NOTQS_TABLE, i)
  8144. */
  8145. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 70, __pyx_L1_error)
  8146. __Pyx_GOTREF(__pyx_t_3);
  8147. __pyx_t_7 = __Pyx_PyInt_As_uint64_t(__pyx_t_3); if (unlikely((__pyx_t_7 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 70, __pyx_L1_error)
  8148. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8149. __pyx_f_4yarl_8_quoting_set_bit(__pyx_v_4yarl_8_quoting_ALLOWED_NOTQS_TABLE, __pyx_t_7);
  8150. /* "yarl/_quoting.pyx":68
  8151. *
  8152. * for i in range(128):
  8153. * if chr(i) in ALLOWED: # <<<<<<<<<<<<<<
  8154. * set_bit(ALLOWED_TABLE, i)
  8155. * set_bit(ALLOWED_NOTQS_TABLE, i)
  8156. */
  8157. }
  8158. /* "yarl/_quoting.pyx":71
  8159. * set_bit(ALLOWED_TABLE, i)
  8160. * set_bit(ALLOWED_NOTQS_TABLE, i)
  8161. * if chr(i) in QS: # <<<<<<<<<<<<<<
  8162. * set_bit(ALLOWED_NOTQS_TABLE, i)
  8163. *
  8164. */
  8165. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error)
  8166. __Pyx_GOTREF(__pyx_t_3);
  8167. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_chr, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
  8168. __Pyx_GOTREF(__pyx_t_1);
  8169. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8170. if (unlikely(__pyx_v_4yarl_8_quoting_QS == Py_None)) {
  8171. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
  8172. __PYX_ERR(0, 71, __pyx_L1_error)
  8173. }
  8174. __pyx_t_6 = (__Pyx_PyUnicode_ContainsTF(__pyx_t_1, __pyx_v_4yarl_8_quoting_QS, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 71, __pyx_L1_error)
  8175. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8176. __pyx_t_5 = (__pyx_t_6 != 0);
  8177. if (__pyx_t_5) {
  8178. /* "yarl/_quoting.pyx":72
  8179. * set_bit(ALLOWED_NOTQS_TABLE, i)
  8180. * if chr(i) in QS:
  8181. * set_bit(ALLOWED_NOTQS_TABLE, i) # <<<<<<<<<<<<<<
  8182. *
  8183. * # ----------------- writer ---------------------------
  8184. */
  8185. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
  8186. __Pyx_GOTREF(__pyx_t_1);
  8187. __pyx_t_7 = __Pyx_PyInt_As_uint64_t(__pyx_t_1); if (unlikely((__pyx_t_7 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 72, __pyx_L1_error)
  8188. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8189. __pyx_f_4yarl_8_quoting_set_bit(__pyx_v_4yarl_8_quoting_ALLOWED_NOTQS_TABLE, __pyx_t_7);
  8190. /* "yarl/_quoting.pyx":71
  8191. * set_bit(ALLOWED_TABLE, i)
  8192. * set_bit(ALLOWED_NOTQS_TABLE, i)
  8193. * if chr(i) in QS: # <<<<<<<<<<<<<<
  8194. * set_bit(ALLOWED_NOTQS_TABLE, i)
  8195. *
  8196. */
  8197. }
  8198. }
  8199. /* "(tree fragment)":1
  8200. * def __pyx_unpickle__Quoter(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
  8201. * if __pyx_checksum != 0x8f193a6:
  8202. * from pickle import PickleError as __pyx_PickleError
  8203. */
  8204. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4yarl_8_quoting_1__pyx_unpickle__Quoter, NULL, __pyx_n_s_yarl__quoting); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  8205. __Pyx_GOTREF(__pyx_t_1);
  8206. if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle__Quoter, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  8207. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8208. /* "(tree fragment)":9
  8209. * __pyx_unpickle__Quoter__set_state(<_Quoter> __pyx_result, __pyx_state)
  8210. * return __pyx_result
  8211. * cdef __pyx_unpickle__Quoter__set_state(_Quoter __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
  8212. * __pyx_result._protected_table = __pyx_state[0]; __pyx_result._qs = __pyx_state[1]; __pyx_result._safe_table = __pyx_state[2]
  8213. * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
  8214. */
  8215. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4yarl_8_quoting_3__pyx_unpickle__Unquoter, NULL, __pyx_n_s_yarl__quoting); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  8216. __Pyx_GOTREF(__pyx_t_1);
  8217. if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle__Unquoter, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  8218. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8219. /* "yarl/_quoting.pyx":1
  8220. * # cython: language_level=3 # <<<<<<<<<<<<<<
  8221. *
  8222. * from libc.stdint cimport uint8_t, uint64_t
  8223. */
  8224. __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  8225. __Pyx_GOTREF(__pyx_t_1);
  8226. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8227. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8228. /* "carray.from_py":77
  8229. *
  8230. * @cname("__Pyx_carray_from_py_uint8_t")
  8231. * cdef int __Pyx_carray_from_py_uint8_t(object o, base_type *v, Py_ssize_t length) except -1: # <<<<<<<<<<<<<<
  8232. * cdef Py_ssize_t i = length
  8233. * try:
  8234. */
  8235. /*--- Wrapped vars code ---*/
  8236. goto __pyx_L0;
  8237. __pyx_L1_error:;
  8238. __Pyx_XDECREF(__pyx_t_1);
  8239. __Pyx_XDECREF(__pyx_t_2);
  8240. __Pyx_XDECREF(__pyx_t_3);
  8241. if (__pyx_m) {
  8242. if (__pyx_d) {
  8243. __Pyx_AddTraceback("init yarl._quoting", 0, __pyx_lineno, __pyx_filename);
  8244. }
  8245. Py_DECREF(__pyx_m); __pyx_m = 0;
  8246. } else if (!PyErr_Occurred()) {
  8247. PyErr_SetString(PyExc_ImportError, "init yarl._quoting");
  8248. }
  8249. __pyx_L0:;
  8250. __Pyx_RefNannyFinishContext();
  8251. #if CYTHON_PEP489_MULTI_PHASE_INIT
  8252. return (__pyx_m != NULL) ? 0 : -1;
  8253. #elif PY_MAJOR_VERSION >= 3
  8254. return __pyx_m;
  8255. #else
  8256. return;
  8257. #endif
  8258. }
  8259. /* --- Runtime support code --- */
  8260. /* Refnanny */
  8261. #if CYTHON_REFNANNY
  8262. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  8263. PyObject *m = NULL, *p = NULL;
  8264. void *r = NULL;
  8265. m = PyImport_ImportModule((char *)modname);
  8266. if (!m) goto end;
  8267. p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
  8268. if (!p) goto end;
  8269. r = PyLong_AsVoidPtr(p);
  8270. end:
  8271. Py_XDECREF(p);
  8272. Py_XDECREF(m);
  8273. return (__Pyx_RefNannyAPIStruct *)r;
  8274. }
  8275. #endif
  8276. /* PyObjectGetAttrStr */
  8277. #if CYTHON_USE_TYPE_SLOTS
  8278. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  8279. PyTypeObject* tp = Py_TYPE(obj);
  8280. if (likely(tp->tp_getattro))
  8281. return tp->tp_getattro(obj, attr_name);
  8282. #if PY_MAJOR_VERSION < 3
  8283. if (likely(tp->tp_getattr))
  8284. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  8285. #endif
  8286. return PyObject_GetAttr(obj, attr_name);
  8287. }
  8288. #endif
  8289. /* GetBuiltinName */
  8290. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  8291. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  8292. if (unlikely(!result)) {
  8293. PyErr_Format(PyExc_NameError,
  8294. #if PY_MAJOR_VERSION >= 3
  8295. "name '%U' is not defined", name);
  8296. #else
  8297. "name '%.200s' is not defined", PyString_AS_STRING(name));
  8298. #endif
  8299. }
  8300. return result;
  8301. }
  8302. /* PyErrFetchRestore */
  8303. #if CYTHON_FAST_THREAD_STATE
  8304. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  8305. PyObject *tmp_type, *tmp_value, *tmp_tb;
  8306. tmp_type = tstate->curexc_type;
  8307. tmp_value = tstate->curexc_value;
  8308. tmp_tb = tstate->curexc_traceback;
  8309. tstate->curexc_type = type;
  8310. tstate->curexc_value = value;
  8311. tstate->curexc_traceback = tb;
  8312. Py_XDECREF(tmp_type);
  8313. Py_XDECREF(tmp_value);
  8314. Py_XDECREF(tmp_tb);
  8315. }
  8316. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  8317. *type = tstate->curexc_type;
  8318. *value = tstate->curexc_value;
  8319. *tb = tstate->curexc_traceback;
  8320. tstate->curexc_type = 0;
  8321. tstate->curexc_value = 0;
  8322. tstate->curexc_traceback = 0;
  8323. }
  8324. #endif
  8325. /* WriteUnraisableException */
  8326. static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
  8327. CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
  8328. int full_traceback, CYTHON_UNUSED int nogil) {
  8329. PyObject *old_exc, *old_val, *old_tb;
  8330. PyObject *ctx;
  8331. __Pyx_PyThreadState_declare
  8332. #ifdef WITH_THREAD
  8333. PyGILState_STATE state;
  8334. if (nogil)
  8335. state = PyGILState_Ensure();
  8336. #ifdef _MSC_VER
  8337. else state = (PyGILState_STATE)-1;
  8338. #endif
  8339. #endif
  8340. __Pyx_PyThreadState_assign
  8341. __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
  8342. if (full_traceback) {
  8343. Py_XINCREF(old_exc);
  8344. Py_XINCREF(old_val);
  8345. Py_XINCREF(old_tb);
  8346. __Pyx_ErrRestore(old_exc, old_val, old_tb);
  8347. PyErr_PrintEx(1);
  8348. }
  8349. #if PY_MAJOR_VERSION < 3
  8350. ctx = PyString_FromString(name);
  8351. #else
  8352. ctx = PyUnicode_FromString(name);
  8353. #endif
  8354. __Pyx_ErrRestore(old_exc, old_val, old_tb);
  8355. if (!ctx) {
  8356. PyErr_WriteUnraisable(Py_None);
  8357. } else {
  8358. PyErr_WriteUnraisable(ctx);
  8359. Py_DECREF(ctx);
  8360. }
  8361. #ifdef WITH_THREAD
  8362. if (nogil)
  8363. PyGILState_Release(state);
  8364. #endif
  8365. }
  8366. /* RaiseDoubleKeywords */
  8367. static void __Pyx_RaiseDoubleKeywordsError(
  8368. const char* func_name,
  8369. PyObject* kw_name)
  8370. {
  8371. PyErr_Format(PyExc_TypeError,
  8372. #if PY_MAJOR_VERSION >= 3
  8373. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  8374. #else
  8375. "%s() got multiple values for keyword argument '%s'", func_name,
  8376. PyString_AsString(kw_name));
  8377. #endif
  8378. }
  8379. /* ParseKeywords */
  8380. static int __Pyx_ParseOptionalKeywords(
  8381. PyObject *kwds,
  8382. PyObject **argnames[],
  8383. PyObject *kwds2,
  8384. PyObject *values[],
  8385. Py_ssize_t num_pos_args,
  8386. const char* function_name)
  8387. {
  8388. PyObject *key = 0, *value = 0;
  8389. Py_ssize_t pos = 0;
  8390. PyObject*** name;
  8391. PyObject*** first_kw_arg = argnames + num_pos_args;
  8392. while (PyDict_Next(kwds, &pos, &key, &value)) {
  8393. name = first_kw_arg;
  8394. while (*name && (**name != key)) name++;
  8395. if (*name) {
  8396. values[name-argnames] = value;
  8397. continue;
  8398. }
  8399. name = first_kw_arg;
  8400. #if PY_MAJOR_VERSION < 3
  8401. if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
  8402. while (*name) {
  8403. if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
  8404. && _PyString_Eq(**name, key)) {
  8405. values[name-argnames] = value;
  8406. break;
  8407. }
  8408. name++;
  8409. }
  8410. if (*name) continue;
  8411. else {
  8412. PyObject*** argname = argnames;
  8413. while (argname != first_kw_arg) {
  8414. if ((**argname == key) || (
  8415. (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
  8416. && _PyString_Eq(**argname, key))) {
  8417. goto arg_passed_twice;
  8418. }
  8419. argname++;
  8420. }
  8421. }
  8422. } else
  8423. #endif
  8424. if (likely(PyUnicode_Check(key))) {
  8425. while (*name) {
  8426. int cmp = (**name == key) ? 0 :
  8427. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  8428. (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
  8429. #endif
  8430. PyUnicode_Compare(**name, key);
  8431. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  8432. if (cmp == 0) {
  8433. values[name-argnames] = value;
  8434. break;
  8435. }
  8436. name++;
  8437. }
  8438. if (*name) continue;
  8439. else {
  8440. PyObject*** argname = argnames;
  8441. while (argname != first_kw_arg) {
  8442. int cmp = (**argname == key) ? 0 :
  8443. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  8444. (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
  8445. #endif
  8446. PyUnicode_Compare(**argname, key);
  8447. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  8448. if (cmp == 0) goto arg_passed_twice;
  8449. argname++;
  8450. }
  8451. }
  8452. } else
  8453. goto invalid_keyword_type;
  8454. if (kwds2) {
  8455. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  8456. } else {
  8457. goto invalid_keyword;
  8458. }
  8459. }
  8460. return 0;
  8461. arg_passed_twice:
  8462. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  8463. goto bad;
  8464. invalid_keyword_type:
  8465. PyErr_Format(PyExc_TypeError,
  8466. "%.200s() keywords must be strings", function_name);
  8467. goto bad;
  8468. invalid_keyword:
  8469. PyErr_Format(PyExc_TypeError,
  8470. #if PY_MAJOR_VERSION < 3
  8471. "%.200s() got an unexpected keyword argument '%.200s'",
  8472. function_name, PyString_AsString(key));
  8473. #else
  8474. "%s() got an unexpected keyword argument '%U'",
  8475. function_name, key);
  8476. #endif
  8477. bad:
  8478. return -1;
  8479. }
  8480. /* RaiseArgTupleInvalid */
  8481. static void __Pyx_RaiseArgtupleInvalid(
  8482. const char* func_name,
  8483. int exact,
  8484. Py_ssize_t num_min,
  8485. Py_ssize_t num_max,
  8486. Py_ssize_t num_found)
  8487. {
  8488. Py_ssize_t num_expected;
  8489. const char *more_or_less;
  8490. if (num_found < num_min) {
  8491. num_expected = num_min;
  8492. more_or_less = "at least";
  8493. } else {
  8494. num_expected = num_max;
  8495. more_or_less = "at most";
  8496. }
  8497. if (exact) {
  8498. more_or_less = "exactly";
  8499. }
  8500. PyErr_Format(PyExc_TypeError,
  8501. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  8502. func_name, more_or_less, num_expected,
  8503. (num_expected == 1) ? "" : "s", num_found);
  8504. }
  8505. /* ArgTypeTest */
  8506. static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
  8507. {
  8508. if (unlikely(!type)) {
  8509. PyErr_SetString(PyExc_SystemError, "Missing type object");
  8510. return 0;
  8511. }
  8512. else if (exact) {
  8513. #if PY_MAJOR_VERSION == 2
  8514. if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
  8515. #endif
  8516. }
  8517. else {
  8518. if (likely(__Pyx_TypeCheck(obj, type))) return 1;
  8519. }
  8520. PyErr_Format(PyExc_TypeError,
  8521. "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
  8522. name, type->tp_name, Py_TYPE(obj)->tp_name);
  8523. return 0;
  8524. }
  8525. /* unicode_iter */
  8526. static CYTHON_INLINE int __Pyx_init_unicode_iteration(
  8527. PyObject* ustring, Py_ssize_t *length, void** data, int *kind) {
  8528. #if CYTHON_PEP393_ENABLED
  8529. if (unlikely(__Pyx_PyUnicode_READY(ustring) < 0)) return -1;
  8530. *kind = PyUnicode_KIND(ustring);
  8531. *length = PyUnicode_GET_LENGTH(ustring);
  8532. *data = PyUnicode_DATA(ustring);
  8533. #else
  8534. *kind = 0;
  8535. *length = PyUnicode_GET_SIZE(ustring);
  8536. *data = (void*)PyUnicode_AS_UNICODE(ustring);
  8537. #endif
  8538. return 0;
  8539. }
  8540. /* PyObjectCall */
  8541. #if CYTHON_COMPILING_IN_CPYTHON
  8542. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  8543. PyObject *result;
  8544. ternaryfunc call = func->ob_type->tp_call;
  8545. if (unlikely(!call))
  8546. return PyObject_Call(func, arg, kw);
  8547. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  8548. return NULL;
  8549. result = (*call)(func, arg, kw);
  8550. Py_LeaveRecursiveCall();
  8551. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  8552. PyErr_SetString(
  8553. PyExc_SystemError,
  8554. "NULL result without error in PyObject_Call");
  8555. }
  8556. return result;
  8557. }
  8558. #endif
  8559. /* RaiseException */
  8560. #if PY_MAJOR_VERSION < 3
  8561. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
  8562. CYTHON_UNUSED PyObject *cause) {
  8563. __Pyx_PyThreadState_declare
  8564. Py_XINCREF(type);
  8565. if (!value || value == Py_None)
  8566. value = NULL;
  8567. else
  8568. Py_INCREF(value);
  8569. if (!tb || tb == Py_None)
  8570. tb = NULL;
  8571. else {
  8572. Py_INCREF(tb);
  8573. if (!PyTraceBack_Check(tb)) {
  8574. PyErr_SetString(PyExc_TypeError,
  8575. "raise: arg 3 must be a traceback or None");
  8576. goto raise_error;
  8577. }
  8578. }
  8579. if (PyType_Check(type)) {
  8580. #if CYTHON_COMPILING_IN_PYPY
  8581. if (!value) {
  8582. Py_INCREF(Py_None);
  8583. value = Py_None;
  8584. }
  8585. #endif
  8586. PyErr_NormalizeException(&type, &value, &tb);
  8587. } else {
  8588. if (value) {
  8589. PyErr_SetString(PyExc_TypeError,
  8590. "instance exception may not have a separate value");
  8591. goto raise_error;
  8592. }
  8593. value = type;
  8594. type = (PyObject*) Py_TYPE(type);
  8595. Py_INCREF(type);
  8596. if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
  8597. PyErr_SetString(PyExc_TypeError,
  8598. "raise: exception class must be a subclass of BaseException");
  8599. goto raise_error;
  8600. }
  8601. }
  8602. __Pyx_PyThreadState_assign
  8603. __Pyx_ErrRestore(type, value, tb);
  8604. return;
  8605. raise_error:
  8606. Py_XDECREF(value);
  8607. Py_XDECREF(type);
  8608. Py_XDECREF(tb);
  8609. return;
  8610. }
  8611. #else
  8612. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  8613. PyObject* owned_instance = NULL;
  8614. if (tb == Py_None) {
  8615. tb = 0;
  8616. } else if (tb && !PyTraceBack_Check(tb)) {
  8617. PyErr_SetString(PyExc_TypeError,
  8618. "raise: arg 3 must be a traceback or None");
  8619. goto bad;
  8620. }
  8621. if (value == Py_None)
  8622. value = 0;
  8623. if (PyExceptionInstance_Check(type)) {
  8624. if (value) {
  8625. PyErr_SetString(PyExc_TypeError,
  8626. "instance exception may not have a separate value");
  8627. goto bad;
  8628. }
  8629. value = type;
  8630. type = (PyObject*) Py_TYPE(value);
  8631. } else if (PyExceptionClass_Check(type)) {
  8632. PyObject *instance_class = NULL;
  8633. if (value && PyExceptionInstance_Check(value)) {
  8634. instance_class = (PyObject*) Py_TYPE(value);
  8635. if (instance_class != type) {
  8636. int is_subclass = PyObject_IsSubclass(instance_class, type);
  8637. if (!is_subclass) {
  8638. instance_class = NULL;
  8639. } else if (unlikely(is_subclass == -1)) {
  8640. goto bad;
  8641. } else {
  8642. type = instance_class;
  8643. }
  8644. }
  8645. }
  8646. if (!instance_class) {
  8647. PyObject *args;
  8648. if (!value)
  8649. args = PyTuple_New(0);
  8650. else if (PyTuple_Check(value)) {
  8651. Py_INCREF(value);
  8652. args = value;
  8653. } else
  8654. args = PyTuple_Pack(1, value);
  8655. if (!args)
  8656. goto bad;
  8657. owned_instance = PyObject_Call(type, args, NULL);
  8658. Py_DECREF(args);
  8659. if (!owned_instance)
  8660. goto bad;
  8661. value = owned_instance;
  8662. if (!PyExceptionInstance_Check(value)) {
  8663. PyErr_Format(PyExc_TypeError,
  8664. "calling %R should have returned an instance of "
  8665. "BaseException, not %R",
  8666. type, Py_TYPE(value));
  8667. goto bad;
  8668. }
  8669. }
  8670. } else {
  8671. PyErr_SetString(PyExc_TypeError,
  8672. "raise: exception class must be a subclass of BaseException");
  8673. goto bad;
  8674. }
  8675. if (cause) {
  8676. PyObject *fixed_cause;
  8677. if (cause == Py_None) {
  8678. fixed_cause = NULL;
  8679. } else if (PyExceptionClass_Check(cause)) {
  8680. fixed_cause = PyObject_CallObject(cause, NULL);
  8681. if (fixed_cause == NULL)
  8682. goto bad;
  8683. } else if (PyExceptionInstance_Check(cause)) {
  8684. fixed_cause = cause;
  8685. Py_INCREF(fixed_cause);
  8686. } else {
  8687. PyErr_SetString(PyExc_TypeError,
  8688. "exception causes must derive from "
  8689. "BaseException");
  8690. goto bad;
  8691. }
  8692. PyException_SetCause(value, fixed_cause);
  8693. }
  8694. PyErr_SetObject(type, value);
  8695. if (tb) {
  8696. #if CYTHON_COMPILING_IN_PYPY
  8697. PyObject *tmp_type, *tmp_value, *tmp_tb;
  8698. PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
  8699. Py_INCREF(tb);
  8700. PyErr_Restore(tmp_type, tmp_value, tb);
  8701. Py_XDECREF(tmp_tb);
  8702. #else
  8703. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  8704. PyObject* tmp_tb = tstate->curexc_traceback;
  8705. if (tb != tmp_tb) {
  8706. Py_INCREF(tb);
  8707. tstate->curexc_traceback = tb;
  8708. Py_XDECREF(tmp_tb);
  8709. }
  8710. #endif
  8711. }
  8712. bad:
  8713. Py_XDECREF(owned_instance);
  8714. return;
  8715. }
  8716. #endif
  8717. /* PyCFunctionFastCall */
  8718. #if CYTHON_FAST_PYCCALL
  8719. static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
  8720. PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
  8721. PyCFunction meth = PyCFunction_GET_FUNCTION(func);
  8722. PyObject *self = PyCFunction_GET_SELF(func);
  8723. int flags = PyCFunction_GET_FLAGS(func);
  8724. assert(PyCFunction_Check(func));
  8725. assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
  8726. assert(nargs >= 0);
  8727. assert(nargs == 0 || args != NULL);
  8728. /* _PyCFunction_FastCallDict() must not be called with an exception set,
  8729. because it may clear it (directly or indirectly) and so the
  8730. caller loses its exception */
  8731. assert(!PyErr_Occurred());
  8732. if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
  8733. return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
  8734. } else {
  8735. return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
  8736. }
  8737. }
  8738. #endif
  8739. /* PyFunctionFastCall */
  8740. #if CYTHON_FAST_PYCALL
  8741. #include "frameobject.h"
  8742. static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
  8743. PyObject *globals) {
  8744. PyFrameObject *f;
  8745. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  8746. PyObject **fastlocals;
  8747. Py_ssize_t i;
  8748. PyObject *result;
  8749. assert(globals != NULL);
  8750. /* XXX Perhaps we should create a specialized
  8751. PyFrame_New() that doesn't take locals, but does
  8752. take builtins without sanity checking them.
  8753. */
  8754. assert(tstate != NULL);
  8755. f = PyFrame_New(tstate, co, globals, NULL);
  8756. if (f == NULL) {
  8757. return NULL;
  8758. }
  8759. fastlocals = f->f_localsplus;
  8760. for (i = 0; i < na; i++) {
  8761. Py_INCREF(*args);
  8762. fastlocals[i] = *args++;
  8763. }
  8764. result = PyEval_EvalFrameEx(f,0);
  8765. ++tstate->recursion_depth;
  8766. Py_DECREF(f);
  8767. --tstate->recursion_depth;
  8768. return result;
  8769. }
  8770. #if 1 || PY_VERSION_HEX < 0x030600B1
  8771. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
  8772. PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
  8773. PyObject *globals = PyFunction_GET_GLOBALS(func);
  8774. PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
  8775. PyObject *closure;
  8776. #if PY_MAJOR_VERSION >= 3
  8777. PyObject *kwdefs;
  8778. #endif
  8779. PyObject *kwtuple, **k;
  8780. PyObject **d;
  8781. Py_ssize_t nd;
  8782. Py_ssize_t nk;
  8783. PyObject *result;
  8784. assert(kwargs == NULL || PyDict_Check(kwargs));
  8785. nk = kwargs ? PyDict_Size(kwargs) : 0;
  8786. if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
  8787. return NULL;
  8788. }
  8789. if (
  8790. #if PY_MAJOR_VERSION >= 3
  8791. co->co_kwonlyargcount == 0 &&
  8792. #endif
  8793. likely(kwargs == NULL || nk == 0) &&
  8794. co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
  8795. if (argdefs == NULL && co->co_argcount == nargs) {
  8796. result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
  8797. goto done;
  8798. }
  8799. else if (nargs == 0 && argdefs != NULL
  8800. && co->co_argcount == Py_SIZE(argdefs)) {
  8801. /* function called with no arguments, but all parameters have
  8802. a default value: use default values as arguments .*/
  8803. args = &PyTuple_GET_ITEM(argdefs, 0);
  8804. result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
  8805. goto done;
  8806. }
  8807. }
  8808. if (kwargs != NULL) {
  8809. Py_ssize_t pos, i;
  8810. kwtuple = PyTuple_New(2 * nk);
  8811. if (kwtuple == NULL) {
  8812. result = NULL;
  8813. goto done;
  8814. }
  8815. k = &PyTuple_GET_ITEM(kwtuple, 0);
  8816. pos = i = 0;
  8817. while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
  8818. Py_INCREF(k[i]);
  8819. Py_INCREF(k[i+1]);
  8820. i += 2;
  8821. }
  8822. nk = i / 2;
  8823. }
  8824. else {
  8825. kwtuple = NULL;
  8826. k = NULL;
  8827. }
  8828. closure = PyFunction_GET_CLOSURE(func);
  8829. #if PY_MAJOR_VERSION >= 3
  8830. kwdefs = PyFunction_GET_KW_DEFAULTS(func);
  8831. #endif
  8832. if (argdefs != NULL) {
  8833. d = &PyTuple_GET_ITEM(argdefs, 0);
  8834. nd = Py_SIZE(argdefs);
  8835. }
  8836. else {
  8837. d = NULL;
  8838. nd = 0;
  8839. }
  8840. #if PY_MAJOR_VERSION >= 3
  8841. result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
  8842. args, nargs,
  8843. k, (int)nk,
  8844. d, (int)nd, kwdefs, closure);
  8845. #else
  8846. result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
  8847. args, nargs,
  8848. k, (int)nk,
  8849. d, (int)nd, closure);
  8850. #endif
  8851. Py_XDECREF(kwtuple);
  8852. done:
  8853. Py_LeaveRecursiveCall();
  8854. return result;
  8855. }
  8856. #endif
  8857. #endif
  8858. /* PyObjectCallMethO */
  8859. #if CYTHON_COMPILING_IN_CPYTHON
  8860. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
  8861. PyObject *self, *result;
  8862. PyCFunction cfunc;
  8863. cfunc = PyCFunction_GET_FUNCTION(func);
  8864. self = PyCFunction_GET_SELF(func);
  8865. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  8866. return NULL;
  8867. result = cfunc(self, arg);
  8868. Py_LeaveRecursiveCall();
  8869. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  8870. PyErr_SetString(
  8871. PyExc_SystemError,
  8872. "NULL result without error in PyObject_Call");
  8873. }
  8874. return result;
  8875. }
  8876. #endif
  8877. /* PyObjectCallOneArg */
  8878. #if CYTHON_COMPILING_IN_CPYTHON
  8879. static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  8880. PyObject *result;
  8881. PyObject *args = PyTuple_New(1);
  8882. if (unlikely(!args)) return NULL;
  8883. Py_INCREF(arg);
  8884. PyTuple_SET_ITEM(args, 0, arg);
  8885. result = __Pyx_PyObject_Call(func, args, NULL);
  8886. Py_DECREF(args);
  8887. return result;
  8888. }
  8889. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  8890. #if CYTHON_FAST_PYCALL
  8891. if (PyFunction_Check(func)) {
  8892. return __Pyx_PyFunction_FastCall(func, &arg, 1);
  8893. }
  8894. #endif
  8895. if (likely(PyCFunction_Check(func))) {
  8896. if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
  8897. return __Pyx_PyObject_CallMethO(func, arg);
  8898. #if CYTHON_FAST_PYCCALL
  8899. } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
  8900. return __Pyx_PyCFunction_FastCall(func, &arg, 1);
  8901. #endif
  8902. }
  8903. }
  8904. return __Pyx__PyObject_CallOneArg(func, arg);
  8905. }
  8906. #else
  8907. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  8908. PyObject *result;
  8909. PyObject *args = PyTuple_Pack(1, arg);
  8910. if (unlikely(!args)) return NULL;
  8911. result = __Pyx_PyObject_Call(func, args, NULL);
  8912. Py_DECREF(args);
  8913. return result;
  8914. }
  8915. #endif
  8916. /* GetException */
  8917. #if CYTHON_FAST_THREAD_STATE
  8918. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  8919. #else
  8920. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
  8921. #endif
  8922. PyObject *local_type, *local_value, *local_tb;
  8923. #if CYTHON_FAST_THREAD_STATE
  8924. PyObject *tmp_type, *tmp_value, *tmp_tb;
  8925. local_type = tstate->curexc_type;
  8926. local_value = tstate->curexc_value;
  8927. local_tb = tstate->curexc_traceback;
  8928. tstate->curexc_type = 0;
  8929. tstate->curexc_value = 0;
  8930. tstate->curexc_traceback = 0;
  8931. #else
  8932. PyErr_Fetch(&local_type, &local_value, &local_tb);
  8933. #endif
  8934. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  8935. #if CYTHON_FAST_THREAD_STATE
  8936. if (unlikely(tstate->curexc_type))
  8937. #else
  8938. if (unlikely(PyErr_Occurred()))
  8939. #endif
  8940. goto bad;
  8941. #if PY_MAJOR_VERSION >= 3
  8942. if (local_tb) {
  8943. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  8944. goto bad;
  8945. }
  8946. #endif
  8947. Py_XINCREF(local_tb);
  8948. Py_XINCREF(local_type);
  8949. Py_XINCREF(local_value);
  8950. *type = local_type;
  8951. *value = local_value;
  8952. *tb = local_tb;
  8953. #if CYTHON_FAST_THREAD_STATE
  8954. #if PY_VERSION_HEX >= 0x030700A2
  8955. tmp_type = tstate->exc_state.exc_type;
  8956. tmp_value = tstate->exc_state.exc_value;
  8957. tmp_tb = tstate->exc_state.exc_traceback;
  8958. tstate->exc_state.exc_type = local_type;
  8959. tstate->exc_state.exc_value = local_value;
  8960. tstate->exc_state.exc_traceback = local_tb;
  8961. #else
  8962. tmp_type = tstate->exc_type;
  8963. tmp_value = tstate->exc_value;
  8964. tmp_tb = tstate->exc_traceback;
  8965. tstate->exc_type = local_type;
  8966. tstate->exc_value = local_value;
  8967. tstate->exc_traceback = local_tb;
  8968. #endif
  8969. Py_XDECREF(tmp_type);
  8970. Py_XDECREF(tmp_value);
  8971. Py_XDECREF(tmp_tb);
  8972. #else
  8973. PyErr_SetExcInfo(local_type, local_value, local_tb);
  8974. #endif
  8975. return 0;
  8976. bad:
  8977. *type = 0;
  8978. *value = 0;
  8979. *tb = 0;
  8980. Py_XDECREF(local_type);
  8981. Py_XDECREF(local_value);
  8982. Py_XDECREF(local_tb);
  8983. return -1;
  8984. }
  8985. /* SwapException */
  8986. #if CYTHON_FAST_THREAD_STATE
  8987. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  8988. PyObject *tmp_type, *tmp_value, *tmp_tb;
  8989. #if PY_VERSION_HEX >= 0x030700A2
  8990. tmp_type = tstate->exc_state.exc_type;
  8991. tmp_value = tstate->exc_state.exc_value;
  8992. tmp_tb = tstate->exc_state.exc_traceback;
  8993. tstate->exc_state.exc_type = *type;
  8994. tstate->exc_state.exc_value = *value;
  8995. tstate->exc_state.exc_traceback = *tb;
  8996. #else
  8997. tmp_type = tstate->exc_type;
  8998. tmp_value = tstate->exc_value;
  8999. tmp_tb = tstate->exc_traceback;
  9000. tstate->exc_type = *type;
  9001. tstate->exc_value = *value;
  9002. tstate->exc_traceback = *tb;
  9003. #endif
  9004. *type = tmp_type;
  9005. *value = tmp_value;
  9006. *tb = tmp_tb;
  9007. }
  9008. #else
  9009. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
  9010. PyObject *tmp_type, *tmp_value, *tmp_tb;
  9011. PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
  9012. PyErr_SetExcInfo(*type, *value, *tb);
  9013. *type = tmp_type;
  9014. *value = tmp_value;
  9015. *tb = tmp_tb;
  9016. }
  9017. #endif
  9018. /* SaveResetException */
  9019. #if CYTHON_FAST_THREAD_STATE
  9020. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  9021. #if PY_VERSION_HEX >= 0x030700A2
  9022. *type = tstate->exc_state.exc_type;
  9023. *value = tstate->exc_state.exc_value;
  9024. *tb = tstate->exc_state.exc_traceback;
  9025. #else
  9026. *type = tstate->exc_type;
  9027. *value = tstate->exc_value;
  9028. *tb = tstate->exc_traceback;
  9029. #endif
  9030. Py_XINCREF(*type);
  9031. Py_XINCREF(*value);
  9032. Py_XINCREF(*tb);
  9033. }
  9034. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  9035. PyObject *tmp_type, *tmp_value, *tmp_tb;
  9036. #if PY_VERSION_HEX >= 0x030700A2
  9037. tmp_type = tstate->exc_state.exc_type;
  9038. tmp_value = tstate->exc_state.exc_value;
  9039. tmp_tb = tstate->exc_state.exc_traceback;
  9040. tstate->exc_state.exc_type = type;
  9041. tstate->exc_state.exc_value = value;
  9042. tstate->exc_state.exc_traceback = tb;
  9043. #else
  9044. tmp_type = tstate->exc_type;
  9045. tmp_value = tstate->exc_value;
  9046. tmp_tb = tstate->exc_traceback;
  9047. tstate->exc_type = type;
  9048. tstate->exc_value = value;
  9049. tstate->exc_traceback = tb;
  9050. #endif
  9051. Py_XDECREF(tmp_type);
  9052. Py_XDECREF(tmp_value);
  9053. Py_XDECREF(tmp_tb);
  9054. }
  9055. #endif
  9056. /* PyErrExceptionMatches */
  9057. #if CYTHON_FAST_THREAD_STATE
  9058. static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  9059. Py_ssize_t i, n;
  9060. n = PyTuple_GET_SIZE(tuple);
  9061. #if PY_MAJOR_VERSION >= 3
  9062. for (i=0; i<n; i++) {
  9063. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  9064. }
  9065. #endif
  9066. for (i=0; i<n; i++) {
  9067. if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
  9068. }
  9069. return 0;
  9070. }
  9071. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
  9072. PyObject *exc_type = tstate->curexc_type;
  9073. if (exc_type == err) return 1;
  9074. if (unlikely(!exc_type)) return 0;
  9075. if (unlikely(PyTuple_Check(err)))
  9076. return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
  9077. return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
  9078. }
  9079. #endif
  9080. /* GetAttr */
  9081. static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
  9082. #if CYTHON_USE_TYPE_SLOTS
  9083. #if PY_MAJOR_VERSION >= 3
  9084. if (likely(PyUnicode_Check(n)))
  9085. #else
  9086. if (likely(PyString_Check(n)))
  9087. #endif
  9088. return __Pyx_PyObject_GetAttrStr(o, n);
  9089. #endif
  9090. return PyObject_GetAttr(o, n);
  9091. }
  9092. /* GetAttr3 */
  9093. static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
  9094. __Pyx_PyThreadState_declare
  9095. __Pyx_PyThreadState_assign
  9096. if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
  9097. return NULL;
  9098. __Pyx_PyErr_Clear();
  9099. Py_INCREF(d);
  9100. return d;
  9101. }
  9102. static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
  9103. PyObject *r = __Pyx_GetAttr(o, n);
  9104. return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
  9105. }
  9106. /* GetModuleGlobalName */
  9107. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
  9108. PyObject *result;
  9109. #if !CYTHON_AVOID_BORROWED_REFS
  9110. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
  9111. result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
  9112. if (likely(result)) {
  9113. Py_INCREF(result);
  9114. } else if (unlikely(PyErr_Occurred())) {
  9115. result = NULL;
  9116. } else {
  9117. #else
  9118. result = PyDict_GetItem(__pyx_d, name);
  9119. if (likely(result)) {
  9120. Py_INCREF(result);
  9121. } else {
  9122. #endif
  9123. #else
  9124. result = PyObject_GetItem(__pyx_d, name);
  9125. if (!result) {
  9126. PyErr_Clear();
  9127. #endif
  9128. result = __Pyx_GetBuiltinName(name);
  9129. }
  9130. return result;
  9131. }
  9132. /* PyObjectCallNoArg */
  9133. #if CYTHON_COMPILING_IN_CPYTHON
  9134. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
  9135. #if CYTHON_FAST_PYCALL
  9136. if (PyFunction_Check(func)) {
  9137. return __Pyx_PyFunction_FastCall(func, NULL, 0);
  9138. }
  9139. #endif
  9140. #ifdef __Pyx_CyFunction_USED
  9141. if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
  9142. #else
  9143. if (likely(PyCFunction_Check(func))) {
  9144. #endif
  9145. if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
  9146. return __Pyx_PyObject_CallMethO(func, NULL);
  9147. }
  9148. }
  9149. return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
  9150. }
  9151. #endif
  9152. /* PyObjectCallMethod1 */
  9153. static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
  9154. PyObject *result = NULL;
  9155. #if CYTHON_UNPACK_METHODS
  9156. if (likely(PyMethod_Check(method))) {
  9157. PyObject *self = PyMethod_GET_SELF(method);
  9158. if (likely(self)) {
  9159. PyObject *args;
  9160. PyObject *function = PyMethod_GET_FUNCTION(method);
  9161. #if CYTHON_FAST_PYCALL
  9162. if (PyFunction_Check(function)) {
  9163. PyObject *args[2] = {self, arg};
  9164. result = __Pyx_PyFunction_FastCall(function, args, 2);
  9165. goto done;
  9166. }
  9167. #endif
  9168. #if CYTHON_FAST_PYCCALL
  9169. if (__Pyx_PyFastCFunction_Check(function)) {
  9170. PyObject *args[2] = {self, arg};
  9171. result = __Pyx_PyCFunction_FastCall(function, args, 2);
  9172. goto done;
  9173. }
  9174. #endif
  9175. args = PyTuple_New(2);
  9176. if (unlikely(!args)) goto done;
  9177. Py_INCREF(self);
  9178. PyTuple_SET_ITEM(args, 0, self);
  9179. Py_INCREF(arg);
  9180. PyTuple_SET_ITEM(args, 1, arg);
  9181. Py_INCREF(function);
  9182. result = __Pyx_PyObject_Call(function, args, NULL);
  9183. Py_DECREF(args);
  9184. Py_DECREF(function);
  9185. return result;
  9186. }
  9187. }
  9188. #endif
  9189. result = __Pyx_PyObject_CallOneArg(method, arg);
  9190. goto done;
  9191. done:
  9192. return result;
  9193. }
  9194. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
  9195. PyObject *method, *result;
  9196. method = __Pyx_PyObject_GetAttrStr(obj, method_name);
  9197. if (unlikely(!method)) return NULL;
  9198. result = __Pyx__PyObject_CallMethod1(method, arg);
  9199. Py_DECREF(method);
  9200. return result;
  9201. }
  9202. /* ByteArrayAppend */
  9203. static CYTHON_INLINE int __Pyx_PyByteArray_Append(PyObject* bytearray, int value) {
  9204. PyObject *pyval, *retval;
  9205. #if CYTHON_COMPILING_IN_CPYTHON
  9206. if (likely((value >= 0) & (value <= 255))) {
  9207. Py_ssize_t n = Py_SIZE(bytearray);
  9208. if (likely(n != PY_SSIZE_T_MAX)) {
  9209. if (unlikely(PyByteArray_Resize(bytearray, n + 1) < 0))
  9210. return -1;
  9211. PyByteArray_AS_STRING(bytearray)[n] = value;
  9212. return 0;
  9213. }
  9214. } else {
  9215. PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
  9216. return -1;
  9217. }
  9218. #endif
  9219. pyval = PyInt_FromLong(value);
  9220. if (unlikely(!pyval))
  9221. return -1;
  9222. retval = __Pyx_PyObject_CallMethod1(bytearray, __pyx_n_s_append, pyval);
  9223. Py_DECREF(pyval);
  9224. if (unlikely(!retval))
  9225. return -1;
  9226. Py_DECREF(retval);
  9227. return 0;
  9228. }
  9229. /* ByteArrayAppendObject */
  9230. static CYTHON_INLINE int __Pyx_PyByteArray_AppendObject(PyObject* bytearray, PyObject* value) {
  9231. Py_ssize_t ival;
  9232. #if PY_MAJOR_VERSION < 3
  9233. if (unlikely(PyString_Check(value))) {
  9234. if (unlikely(PyString_GET_SIZE(value) != 1)) {
  9235. PyErr_SetString(PyExc_ValueError, "string must be of size 1");
  9236. return -1;
  9237. }
  9238. ival = (unsigned char) (PyString_AS_STRING(value)[0]);
  9239. } else
  9240. #endif
  9241. #if CYTHON_USE_PYLONG_INTERNALS
  9242. if (likely(PyLong_CheckExact(value)) && likely(Py_SIZE(value) == 1 || Py_SIZE(value) == 0)) {
  9243. if (Py_SIZE(value) == 0) {
  9244. ival = 0;
  9245. } else {
  9246. ival = ((PyLongObject*)value)->ob_digit[0];
  9247. if (unlikely(ival > 255)) goto bad_range;
  9248. }
  9249. } else
  9250. #endif
  9251. {
  9252. ival = __Pyx_PyIndex_AsSsize_t(value);
  9253. if (unlikely((ival < 0) | (ival > 255))) {
  9254. if (ival == -1 && PyErr_Occurred())
  9255. return -1;
  9256. goto bad_range;
  9257. }
  9258. }
  9259. return __Pyx_PyByteArray_Append(bytearray, ival);
  9260. bad_range:
  9261. PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
  9262. return -1;
  9263. }
  9264. /* PyUnicode_Substring */
  9265. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring(
  9266. PyObject* text, Py_ssize_t start, Py_ssize_t stop) {
  9267. Py_ssize_t length;
  9268. if (unlikely(__Pyx_PyUnicode_READY(text) == -1)) return NULL;
  9269. length = __Pyx_PyUnicode_GET_LENGTH(text);
  9270. if (start < 0) {
  9271. start += length;
  9272. if (start < 0)
  9273. start = 0;
  9274. }
  9275. if (stop < 0)
  9276. stop += length;
  9277. else if (stop > length)
  9278. stop = length;
  9279. length = stop - start;
  9280. if (length <= 0)
  9281. return PyUnicode_FromUnicode(NULL, 0);
  9282. #if CYTHON_PEP393_ENABLED
  9283. return PyUnicode_FromKindAndData(PyUnicode_KIND(text),
  9284. PyUnicode_1BYTE_DATA(text) + start*PyUnicode_KIND(text), stop-start);
  9285. #else
  9286. return PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(text)+start, stop-start);
  9287. #endif
  9288. }
  9289. /* decode_c_bytes */
  9290. static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
  9291. const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
  9292. const char* encoding, const char* errors,
  9293. PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
  9294. if (unlikely((start < 0) | (stop < 0))) {
  9295. if (start < 0) {
  9296. start += length;
  9297. if (start < 0)
  9298. start = 0;
  9299. }
  9300. if (stop < 0)
  9301. stop += length;
  9302. }
  9303. if (stop > length)
  9304. stop = length;
  9305. length = stop - start;
  9306. if (unlikely(length <= 0))
  9307. return PyUnicode_FromUnicode(NULL, 0);
  9308. cstring += start;
  9309. if (decode_func) {
  9310. return decode_func(cstring, length, errors);
  9311. } else {
  9312. return PyUnicode_Decode(cstring, length, encoding, errors);
  9313. }
  9314. }
  9315. /* SliceObject */
  9316. static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value,
  9317. Py_ssize_t cstart, Py_ssize_t cstop,
  9318. PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
  9319. int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
  9320. #if CYTHON_USE_TYPE_SLOTS
  9321. PyMappingMethods* mp;
  9322. #if PY_MAJOR_VERSION < 3
  9323. PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
  9324. if (likely(ms && ms->sq_ass_slice)) {
  9325. if (!has_cstart) {
  9326. if (_py_start && (*_py_start != Py_None)) {
  9327. cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
  9328. if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
  9329. } else
  9330. cstart = 0;
  9331. }
  9332. if (!has_cstop) {
  9333. if (_py_stop && (*_py_stop != Py_None)) {
  9334. cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
  9335. if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
  9336. } else
  9337. cstop = PY_SSIZE_T_MAX;
  9338. }
  9339. if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
  9340. Py_ssize_t l = ms->sq_length(obj);
  9341. if (likely(l >= 0)) {
  9342. if (cstop < 0) {
  9343. cstop += l;
  9344. if (cstop < 0) cstop = 0;
  9345. }
  9346. if (cstart < 0) {
  9347. cstart += l;
  9348. if (cstart < 0) cstart = 0;
  9349. }
  9350. } else {
  9351. if (!PyErr_ExceptionMatches(PyExc_OverflowError))
  9352. goto bad;
  9353. PyErr_Clear();
  9354. }
  9355. }
  9356. return ms->sq_ass_slice(obj, cstart, cstop, value);
  9357. }
  9358. #endif
  9359. mp = Py_TYPE(obj)->tp_as_mapping;
  9360. if (likely(mp && mp->mp_ass_subscript))
  9361. #endif
  9362. {
  9363. int result;
  9364. PyObject *py_slice, *py_start, *py_stop;
  9365. if (_py_slice) {
  9366. py_slice = *_py_slice;
  9367. } else {
  9368. PyObject* owned_start = NULL;
  9369. PyObject* owned_stop = NULL;
  9370. if (_py_start) {
  9371. py_start = *_py_start;
  9372. } else {
  9373. if (has_cstart) {
  9374. owned_start = py_start = PyInt_FromSsize_t(cstart);
  9375. if (unlikely(!py_start)) goto bad;
  9376. } else
  9377. py_start = Py_None;
  9378. }
  9379. if (_py_stop) {
  9380. py_stop = *_py_stop;
  9381. } else {
  9382. if (has_cstop) {
  9383. owned_stop = py_stop = PyInt_FromSsize_t(cstop);
  9384. if (unlikely(!py_stop)) {
  9385. Py_XDECREF(owned_start);
  9386. goto bad;
  9387. }
  9388. } else
  9389. py_stop = Py_None;
  9390. }
  9391. py_slice = PySlice_New(py_start, py_stop, Py_None);
  9392. Py_XDECREF(owned_start);
  9393. Py_XDECREF(owned_stop);
  9394. if (unlikely(!py_slice)) goto bad;
  9395. }
  9396. #if CYTHON_USE_TYPE_SLOTS
  9397. result = mp->mp_ass_subscript(obj, py_slice, value);
  9398. #else
  9399. result = value ? PyObject_SetItem(obj, py_slice, value) : PyObject_DelItem(obj, py_slice);
  9400. #endif
  9401. if (!_py_slice) {
  9402. Py_DECREF(py_slice);
  9403. }
  9404. return result;
  9405. }
  9406. PyErr_Format(PyExc_TypeError,
  9407. "'%.200s' object does not support slice %.10s",
  9408. Py_TYPE(obj)->tp_name, value ? "assignment" : "deletion");
  9409. bad:
  9410. return -1;
  9411. }
  9412. /* BytesEquals */
  9413. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
  9414. #if CYTHON_COMPILING_IN_PYPY
  9415. return PyObject_RichCompareBool(s1, s2, equals);
  9416. #else
  9417. if (s1 == s2) {
  9418. return (equals == Py_EQ);
  9419. } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
  9420. const char *ps1, *ps2;
  9421. Py_ssize_t length = PyBytes_GET_SIZE(s1);
  9422. if (length != PyBytes_GET_SIZE(s2))
  9423. return (equals == Py_NE);
  9424. ps1 = PyBytes_AS_STRING(s1);
  9425. ps2 = PyBytes_AS_STRING(s2);
  9426. if (ps1[0] != ps2[0]) {
  9427. return (equals == Py_NE);
  9428. } else if (length == 1) {
  9429. return (equals == Py_EQ);
  9430. } else {
  9431. int result;
  9432. #if CYTHON_USE_UNICODE_INTERNALS
  9433. Py_hash_t hash1, hash2;
  9434. hash1 = ((PyBytesObject*)s1)->ob_shash;
  9435. hash2 = ((PyBytesObject*)s2)->ob_shash;
  9436. if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
  9437. return (equals == Py_NE);
  9438. }
  9439. #endif
  9440. result = memcmp(ps1, ps2, (size_t)length);
  9441. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  9442. }
  9443. } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
  9444. return (equals == Py_NE);
  9445. } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
  9446. return (equals == Py_NE);
  9447. } else {
  9448. int result;
  9449. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  9450. if (!py_result)
  9451. return -1;
  9452. result = __Pyx_PyObject_IsTrue(py_result);
  9453. Py_DECREF(py_result);
  9454. return result;
  9455. }
  9456. #endif
  9457. }
  9458. /* UnicodeEquals */
  9459. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
  9460. #if CYTHON_COMPILING_IN_PYPY
  9461. return PyObject_RichCompareBool(s1, s2, equals);
  9462. #else
  9463. #if PY_MAJOR_VERSION < 3
  9464. PyObject* owned_ref = NULL;
  9465. #endif
  9466. int s1_is_unicode, s2_is_unicode;
  9467. if (s1 == s2) {
  9468. goto return_eq;
  9469. }
  9470. s1_is_unicode = PyUnicode_CheckExact(s1);
  9471. s2_is_unicode = PyUnicode_CheckExact(s2);
  9472. #if PY_MAJOR_VERSION < 3
  9473. if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
  9474. owned_ref = PyUnicode_FromObject(s2);
  9475. if (unlikely(!owned_ref))
  9476. return -1;
  9477. s2 = owned_ref;
  9478. s2_is_unicode = 1;
  9479. } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
  9480. owned_ref = PyUnicode_FromObject(s1);
  9481. if (unlikely(!owned_ref))
  9482. return -1;
  9483. s1 = owned_ref;
  9484. s1_is_unicode = 1;
  9485. } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
  9486. return __Pyx_PyBytes_Equals(s1, s2, equals);
  9487. }
  9488. #endif
  9489. if (s1_is_unicode & s2_is_unicode) {
  9490. Py_ssize_t length;
  9491. int kind;
  9492. void *data1, *data2;
  9493. if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
  9494. return -1;
  9495. length = __Pyx_PyUnicode_GET_LENGTH(s1);
  9496. if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
  9497. goto return_ne;
  9498. }
  9499. #if CYTHON_USE_UNICODE_INTERNALS
  9500. {
  9501. Py_hash_t hash1, hash2;
  9502. #if CYTHON_PEP393_ENABLED
  9503. hash1 = ((PyASCIIObject*)s1)->hash;
  9504. hash2 = ((PyASCIIObject*)s2)->hash;
  9505. #else
  9506. hash1 = ((PyUnicodeObject*)s1)->hash;
  9507. hash2 = ((PyUnicodeObject*)s2)->hash;
  9508. #endif
  9509. if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
  9510. goto return_ne;
  9511. }
  9512. }
  9513. #endif
  9514. kind = __Pyx_PyUnicode_KIND(s1);
  9515. if (kind != __Pyx_PyUnicode_KIND(s2)) {
  9516. goto return_ne;
  9517. }
  9518. data1 = __Pyx_PyUnicode_DATA(s1);
  9519. data2 = __Pyx_PyUnicode_DATA(s2);
  9520. if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
  9521. goto return_ne;
  9522. } else if (length == 1) {
  9523. goto return_eq;
  9524. } else {
  9525. int result = memcmp(data1, data2, (size_t)(length * kind));
  9526. #if PY_MAJOR_VERSION < 3
  9527. Py_XDECREF(owned_ref);
  9528. #endif
  9529. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  9530. }
  9531. } else if ((s1 == Py_None) & s2_is_unicode) {
  9532. goto return_ne;
  9533. } else if ((s2 == Py_None) & s1_is_unicode) {
  9534. goto return_ne;
  9535. } else {
  9536. int result;
  9537. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  9538. if (!py_result)
  9539. return -1;
  9540. result = __Pyx_PyObject_IsTrue(py_result);
  9541. Py_DECREF(py_result);
  9542. return result;
  9543. }
  9544. return_eq:
  9545. #if PY_MAJOR_VERSION < 3
  9546. Py_XDECREF(owned_ref);
  9547. #endif
  9548. return (equals == Py_EQ);
  9549. return_ne:
  9550. #if PY_MAJOR_VERSION < 3
  9551. Py_XDECREF(owned_ref);
  9552. #endif
  9553. return (equals == Py_NE);
  9554. #endif
  9555. }
  9556. /* UnicodeAsUCS4 */
  9557. static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject* x) {
  9558. Py_ssize_t length;
  9559. #if CYTHON_PEP393_ENABLED
  9560. length = PyUnicode_GET_LENGTH(x);
  9561. if (likely(length == 1)) {
  9562. return PyUnicode_READ_CHAR(x, 0);
  9563. }
  9564. #else
  9565. length = PyUnicode_GET_SIZE(x);
  9566. if (likely(length == 1)) {
  9567. return PyUnicode_AS_UNICODE(x)[0];
  9568. }
  9569. #if Py_UNICODE_SIZE == 2
  9570. else if (PyUnicode_GET_SIZE(x) == 2) {
  9571. Py_UCS4 high_val = PyUnicode_AS_UNICODE(x)[0];
  9572. if (high_val >= 0xD800 && high_val <= 0xDBFF) {
  9573. Py_UCS4 low_val = PyUnicode_AS_UNICODE(x)[1];
  9574. if (low_val >= 0xDC00 && low_val <= 0xDFFF) {
  9575. return 0x10000 + (((high_val & ((1<<10)-1)) << 10) | (low_val & ((1<<10)-1)));
  9576. }
  9577. }
  9578. }
  9579. #endif
  9580. #endif
  9581. PyErr_Format(PyExc_ValueError,
  9582. "only single character unicode strings can be converted to Py_UCS4, "
  9583. "got length %" CYTHON_FORMAT_SSIZE_T "d", length);
  9584. return (Py_UCS4)-1;
  9585. }
  9586. /* object_ord */
  9587. static long __Pyx__PyObject_Ord(PyObject* c) {
  9588. Py_ssize_t size;
  9589. if (PyBytes_Check(c)) {
  9590. size = PyBytes_GET_SIZE(c);
  9591. if (likely(size == 1)) {
  9592. return (unsigned char) PyBytes_AS_STRING(c)[0];
  9593. }
  9594. #if PY_MAJOR_VERSION < 3
  9595. } else if (PyUnicode_Check(c)) {
  9596. return (long)__Pyx_PyUnicode_AsPy_UCS4(c);
  9597. #endif
  9598. #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
  9599. } else if (PyByteArray_Check(c)) {
  9600. size = PyByteArray_GET_SIZE(c);
  9601. if (likely(size == 1)) {
  9602. return (unsigned char) PyByteArray_AS_STRING(c)[0];
  9603. }
  9604. #endif
  9605. } else {
  9606. PyErr_Format(PyExc_TypeError,
  9607. "ord() expected string of length 1, but %.200s found", c->ob_type->tp_name);
  9608. return (long)(Py_UCS4)-1;
  9609. }
  9610. PyErr_Format(PyExc_TypeError,
  9611. "ord() expected a character, but string of length %zd found", size);
  9612. return (long)(Py_UCS4)-1;
  9613. }
  9614. /* SliceObject */
  9615. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
  9616. Py_ssize_t cstart, Py_ssize_t cstop,
  9617. PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
  9618. int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
  9619. #if CYTHON_USE_TYPE_SLOTS
  9620. PyMappingMethods* mp;
  9621. #if PY_MAJOR_VERSION < 3
  9622. PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
  9623. if (likely(ms && ms->sq_slice)) {
  9624. if (!has_cstart) {
  9625. if (_py_start && (*_py_start != Py_None)) {
  9626. cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
  9627. if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
  9628. } else
  9629. cstart = 0;
  9630. }
  9631. if (!has_cstop) {
  9632. if (_py_stop && (*_py_stop != Py_None)) {
  9633. cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
  9634. if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
  9635. } else
  9636. cstop = PY_SSIZE_T_MAX;
  9637. }
  9638. if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
  9639. Py_ssize_t l = ms->sq_length(obj);
  9640. if (likely(l >= 0)) {
  9641. if (cstop < 0) {
  9642. cstop += l;
  9643. if (cstop < 0) cstop = 0;
  9644. }
  9645. if (cstart < 0) {
  9646. cstart += l;
  9647. if (cstart < 0) cstart = 0;
  9648. }
  9649. } else {
  9650. if (!PyErr_ExceptionMatches(PyExc_OverflowError))
  9651. goto bad;
  9652. PyErr_Clear();
  9653. }
  9654. }
  9655. return ms->sq_slice(obj, cstart, cstop);
  9656. }
  9657. #endif
  9658. mp = Py_TYPE(obj)->tp_as_mapping;
  9659. if (likely(mp && mp->mp_subscript))
  9660. #endif
  9661. {
  9662. PyObject* result;
  9663. PyObject *py_slice, *py_start, *py_stop;
  9664. if (_py_slice) {
  9665. py_slice = *_py_slice;
  9666. } else {
  9667. PyObject* owned_start = NULL;
  9668. PyObject* owned_stop = NULL;
  9669. if (_py_start) {
  9670. py_start = *_py_start;
  9671. } else {
  9672. if (has_cstart) {
  9673. owned_start = py_start = PyInt_FromSsize_t(cstart);
  9674. if (unlikely(!py_start)) goto bad;
  9675. } else
  9676. py_start = Py_None;
  9677. }
  9678. if (_py_stop) {
  9679. py_stop = *_py_stop;
  9680. } else {
  9681. if (has_cstop) {
  9682. owned_stop = py_stop = PyInt_FromSsize_t(cstop);
  9683. if (unlikely(!py_stop)) {
  9684. Py_XDECREF(owned_start);
  9685. goto bad;
  9686. }
  9687. } else
  9688. py_stop = Py_None;
  9689. }
  9690. py_slice = PySlice_New(py_start, py_stop, Py_None);
  9691. Py_XDECREF(owned_start);
  9692. Py_XDECREF(owned_stop);
  9693. if (unlikely(!py_slice)) goto bad;
  9694. }
  9695. #if CYTHON_USE_TYPE_SLOTS
  9696. result = mp->mp_subscript(obj, py_slice);
  9697. #else
  9698. result = PyObject_GetItem(obj, py_slice);
  9699. #endif
  9700. if (!_py_slice) {
  9701. Py_DECREF(py_slice);
  9702. }
  9703. return result;
  9704. }
  9705. PyErr_Format(PyExc_TypeError,
  9706. "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
  9707. bad:
  9708. return NULL;
  9709. }
  9710. /* Import */
  9711. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
  9712. PyObject *empty_list = 0;
  9713. PyObject *module = 0;
  9714. PyObject *global_dict = 0;
  9715. PyObject *empty_dict = 0;
  9716. PyObject *list;
  9717. #if PY_MAJOR_VERSION < 3
  9718. PyObject *py_import;
  9719. py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
  9720. if (!py_import)
  9721. goto bad;
  9722. #endif
  9723. if (from_list)
  9724. list = from_list;
  9725. else {
  9726. empty_list = PyList_New(0);
  9727. if (!empty_list)
  9728. goto bad;
  9729. list = empty_list;
  9730. }
  9731. global_dict = PyModule_GetDict(__pyx_m);
  9732. if (!global_dict)
  9733. goto bad;
  9734. empty_dict = PyDict_New();
  9735. if (!empty_dict)
  9736. goto bad;
  9737. {
  9738. #if PY_MAJOR_VERSION >= 3
  9739. if (level == -1) {
  9740. if (strchr(__Pyx_MODULE_NAME, '.')) {
  9741. module = PyImport_ImportModuleLevelObject(
  9742. name, global_dict, empty_dict, list, 1);
  9743. if (!module) {
  9744. if (!PyErr_ExceptionMatches(PyExc_ImportError))
  9745. goto bad;
  9746. PyErr_Clear();
  9747. }
  9748. }
  9749. level = 0;
  9750. }
  9751. #endif
  9752. if (!module) {
  9753. #if PY_MAJOR_VERSION < 3
  9754. PyObject *py_level = PyInt_FromLong(level);
  9755. if (!py_level)
  9756. goto bad;
  9757. module = PyObject_CallFunctionObjArgs(py_import,
  9758. name, global_dict, empty_dict, list, py_level, NULL);
  9759. Py_DECREF(py_level);
  9760. #else
  9761. module = PyImport_ImportModuleLevelObject(
  9762. name, global_dict, empty_dict, list, level);
  9763. #endif
  9764. }
  9765. }
  9766. bad:
  9767. #if PY_MAJOR_VERSION < 3
  9768. Py_XDECREF(py_import);
  9769. #endif
  9770. Py_XDECREF(empty_list);
  9771. Py_XDECREF(empty_dict);
  9772. return module;
  9773. }
  9774. /* ImportFrom */
  9775. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  9776. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  9777. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  9778. PyErr_Format(PyExc_ImportError,
  9779. #if PY_MAJOR_VERSION < 3
  9780. "cannot import name %.230s", PyString_AS_STRING(name));
  9781. #else
  9782. "cannot import name %S", name);
  9783. #endif
  9784. }
  9785. return value;
  9786. }
  9787. /* GetItemInt */
  9788. static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
  9789. PyObject *r;
  9790. if (!j) return NULL;
  9791. r = PyObject_GetItem(o, j);
  9792. Py_DECREF(j);
  9793. return r;
  9794. }
  9795. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  9796. CYTHON_NCP_UNUSED int wraparound,
  9797. CYTHON_NCP_UNUSED int boundscheck) {
  9798. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  9799. Py_ssize_t wrapped_i = i;
  9800. if (wraparound & unlikely(i < 0)) {
  9801. wrapped_i += PyList_GET_SIZE(o);
  9802. }
  9803. if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) {
  9804. PyObject *r = PyList_GET_ITEM(o, wrapped_i);
  9805. Py_INCREF(r);
  9806. return r;
  9807. }
  9808. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  9809. #else
  9810. return PySequence_GetItem(o, i);
  9811. #endif
  9812. }
  9813. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  9814. CYTHON_NCP_UNUSED int wraparound,
  9815. CYTHON_NCP_UNUSED int boundscheck) {
  9816. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  9817. Py_ssize_t wrapped_i = i;
  9818. if (wraparound & unlikely(i < 0)) {
  9819. wrapped_i += PyTuple_GET_SIZE(o);
  9820. }
  9821. if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) {
  9822. PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
  9823. Py_INCREF(r);
  9824. return r;
  9825. }
  9826. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  9827. #else
  9828. return PySequence_GetItem(o, i);
  9829. #endif
  9830. }
  9831. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
  9832. CYTHON_NCP_UNUSED int wraparound,
  9833. CYTHON_NCP_UNUSED int boundscheck) {
  9834. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
  9835. if (is_list || PyList_CheckExact(o)) {
  9836. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
  9837. if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
  9838. PyObject *r = PyList_GET_ITEM(o, n);
  9839. Py_INCREF(r);
  9840. return r;
  9841. }
  9842. }
  9843. else if (PyTuple_CheckExact(o)) {
  9844. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
  9845. if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
  9846. PyObject *r = PyTuple_GET_ITEM(o, n);
  9847. Py_INCREF(r);
  9848. return r;
  9849. }
  9850. } else {
  9851. PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
  9852. if (likely(m && m->sq_item)) {
  9853. if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
  9854. Py_ssize_t l = m->sq_length(o);
  9855. if (likely(l >= 0)) {
  9856. i += l;
  9857. } else {
  9858. if (!PyErr_ExceptionMatches(PyExc_OverflowError))
  9859. return NULL;
  9860. PyErr_Clear();
  9861. }
  9862. }
  9863. return m->sq_item(o, i);
  9864. }
  9865. }
  9866. #else
  9867. if (is_list || PySequence_Check(o)) {
  9868. return PySequence_GetItem(o, i);
  9869. }
  9870. #endif
  9871. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  9872. }
  9873. /* HasAttr */
  9874. static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
  9875. PyObject *r;
  9876. if (unlikely(!__Pyx_PyBaseString_Check(n))) {
  9877. PyErr_SetString(PyExc_TypeError,
  9878. "hasattr(): attribute name must be string");
  9879. return -1;
  9880. }
  9881. r = __Pyx_GetAttr(o, n);
  9882. if (unlikely(!r)) {
  9883. PyErr_Clear();
  9884. return 0;
  9885. } else {
  9886. Py_DECREF(r);
  9887. return 1;
  9888. }
  9889. }
  9890. /* ExtTypeTest */
  9891. static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
  9892. if (unlikely(!type)) {
  9893. PyErr_SetString(PyExc_SystemError, "Missing type object");
  9894. return 0;
  9895. }
  9896. if (likely(__Pyx_TypeCheck(obj, type)))
  9897. return 1;
  9898. PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
  9899. Py_TYPE(obj)->tp_name, type->tp_name);
  9900. return 0;
  9901. }
  9902. /* PyObject_GenericGetAttrNoDict */
  9903. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  9904. static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
  9905. PyErr_Format(PyExc_AttributeError,
  9906. #if PY_MAJOR_VERSION >= 3
  9907. "'%.50s' object has no attribute '%U'",
  9908. tp->tp_name, attr_name);
  9909. #else
  9910. "'%.50s' object has no attribute '%.400s'",
  9911. tp->tp_name, PyString_AS_STRING(attr_name));
  9912. #endif
  9913. return NULL;
  9914. }
  9915. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
  9916. PyObject *descr;
  9917. PyTypeObject *tp = Py_TYPE(obj);
  9918. if (unlikely(!PyString_Check(attr_name))) {
  9919. return PyObject_GenericGetAttr(obj, attr_name);
  9920. }
  9921. assert(!tp->tp_dictoffset);
  9922. descr = _PyType_Lookup(tp, attr_name);
  9923. if (unlikely(!descr)) {
  9924. return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
  9925. }
  9926. Py_INCREF(descr);
  9927. #if PY_MAJOR_VERSION < 3
  9928. if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
  9929. #endif
  9930. {
  9931. descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
  9932. if (unlikely(f)) {
  9933. PyObject *res = f(descr, obj, (PyObject *)tp);
  9934. Py_DECREF(descr);
  9935. return res;
  9936. }
  9937. }
  9938. return descr;
  9939. }
  9940. #endif
  9941. /* PyObject_GenericGetAttr */
  9942. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  9943. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
  9944. if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
  9945. return PyObject_GenericGetAttr(obj, attr_name);
  9946. }
  9947. return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
  9948. }
  9949. #endif
  9950. /* SetVTable */
  9951. static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
  9952. #if PY_VERSION_HEX >= 0x02070000
  9953. PyObject *ob = PyCapsule_New(vtable, 0, 0);
  9954. #else
  9955. PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
  9956. #endif
  9957. if (!ob)
  9958. goto bad;
  9959. if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
  9960. goto bad;
  9961. Py_DECREF(ob);
  9962. return 0;
  9963. bad:
  9964. Py_XDECREF(ob);
  9965. return -1;
  9966. }
  9967. /* SetupReduce */
  9968. static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  9969. int ret;
  9970. PyObject *name_attr;
  9971. name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  9972. if (likely(name_attr)) {
  9973. ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  9974. } else {
  9975. ret = -1;
  9976. }
  9977. if (unlikely(ret < 0)) {
  9978. PyErr_Clear();
  9979. ret = 0;
  9980. }
  9981. Py_XDECREF(name_attr);
  9982. return ret;
  9983. }
  9984. static int __Pyx_setup_reduce(PyObject* type_obj) {
  9985. int ret = 0;
  9986. PyObject *object_reduce = NULL;
  9987. PyObject *object_reduce_ex = NULL;
  9988. PyObject *reduce = NULL;
  9989. PyObject *reduce_ex = NULL;
  9990. PyObject *reduce_cython = NULL;
  9991. PyObject *setstate = NULL;
  9992. PyObject *setstate_cython = NULL;
  9993. #if CYTHON_USE_PYTYPE_LOOKUP
  9994. if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD;
  9995. #else
  9996. if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD;
  9997. #endif
  9998. #if CYTHON_USE_PYTYPE_LOOKUP
  9999. object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
  10000. #else
  10001. object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
  10002. #endif
  10003. reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD;
  10004. if (reduce_ex == object_reduce_ex) {
  10005. #if CYTHON_USE_PYTYPE_LOOKUP
  10006. object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
  10007. #else
  10008. object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
  10009. #endif
  10010. reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD;
  10011. if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
  10012. reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD;
  10013. ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD;
  10014. ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD;
  10015. setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
  10016. if (!setstate) PyErr_Clear();
  10017. if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
  10018. setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD;
  10019. ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD;
  10020. ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD;
  10021. }
  10022. PyType_Modified((PyTypeObject*)type_obj);
  10023. }
  10024. }
  10025. goto GOOD;
  10026. BAD:
  10027. if (!PyErr_Occurred())
  10028. PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
  10029. ret = -1;
  10030. GOOD:
  10031. #if !CYTHON_USE_PYTYPE_LOOKUP
  10032. Py_XDECREF(object_reduce);
  10033. Py_XDECREF(object_reduce_ex);
  10034. #endif
  10035. Py_XDECREF(reduce);
  10036. Py_XDECREF(reduce_ex);
  10037. Py_XDECREF(reduce_cython);
  10038. Py_XDECREF(setstate);
  10039. Py_XDECREF(setstate_cython);
  10040. return ret;
  10041. }
  10042. /* CLineInTraceback */
  10043. #ifndef CYTHON_CLINE_IN_TRACEBACK
  10044. static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
  10045. PyObject *use_cline;
  10046. PyObject *ptype, *pvalue, *ptraceback;
  10047. #if CYTHON_COMPILING_IN_CPYTHON
  10048. PyObject **cython_runtime_dict;
  10049. #endif
  10050. if (unlikely(!__pyx_cython_runtime)) {
  10051. return c_line;
  10052. }
  10053. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  10054. #if CYTHON_COMPILING_IN_CPYTHON
  10055. cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
  10056. if (likely(cython_runtime_dict)) {
  10057. use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
  10058. } else
  10059. #endif
  10060. {
  10061. PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
  10062. if (use_cline_obj) {
  10063. use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
  10064. Py_DECREF(use_cline_obj);
  10065. } else {
  10066. PyErr_Clear();
  10067. use_cline = NULL;
  10068. }
  10069. }
  10070. if (!use_cline) {
  10071. c_line = 0;
  10072. PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
  10073. }
  10074. else if (PyObject_Not(use_cline) != 0) {
  10075. c_line = 0;
  10076. }
  10077. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  10078. return c_line;
  10079. }
  10080. #endif
  10081. /* CodeObjectCache */
  10082. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  10083. int start = 0, mid = 0, end = count - 1;
  10084. if (end >= 0 && code_line > entries[end].code_line) {
  10085. return count;
  10086. }
  10087. while (start < end) {
  10088. mid = start + (end - start) / 2;
  10089. if (code_line < entries[mid].code_line) {
  10090. end = mid;
  10091. } else if (code_line > entries[mid].code_line) {
  10092. start = mid + 1;
  10093. } else {
  10094. return mid;
  10095. }
  10096. }
  10097. if (code_line <= entries[mid].code_line) {
  10098. return mid;
  10099. } else {
  10100. return mid + 1;
  10101. }
  10102. }
  10103. static PyCodeObject *__pyx_find_code_object(int code_line) {
  10104. PyCodeObject* code_object;
  10105. int pos;
  10106. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  10107. return NULL;
  10108. }
  10109. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  10110. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  10111. return NULL;
  10112. }
  10113. code_object = __pyx_code_cache.entries[pos].code_object;
  10114. Py_INCREF(code_object);
  10115. return code_object;
  10116. }
  10117. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  10118. int pos, i;
  10119. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  10120. if (unlikely(!code_line)) {
  10121. return;
  10122. }
  10123. if (unlikely(!entries)) {
  10124. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  10125. if (likely(entries)) {
  10126. __pyx_code_cache.entries = entries;
  10127. __pyx_code_cache.max_count = 64;
  10128. __pyx_code_cache.count = 1;
  10129. entries[0].code_line = code_line;
  10130. entries[0].code_object = code_object;
  10131. Py_INCREF(code_object);
  10132. }
  10133. return;
  10134. }
  10135. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  10136. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  10137. PyCodeObject* tmp = entries[pos].code_object;
  10138. entries[pos].code_object = code_object;
  10139. Py_DECREF(tmp);
  10140. return;
  10141. }
  10142. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  10143. int new_max = __pyx_code_cache.max_count + 64;
  10144. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  10145. __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  10146. if (unlikely(!entries)) {
  10147. return;
  10148. }
  10149. __pyx_code_cache.entries = entries;
  10150. __pyx_code_cache.max_count = new_max;
  10151. }
  10152. for (i=__pyx_code_cache.count; i>pos; i--) {
  10153. entries[i] = entries[i-1];
  10154. }
  10155. entries[pos].code_line = code_line;
  10156. entries[pos].code_object = code_object;
  10157. __pyx_code_cache.count++;
  10158. Py_INCREF(code_object);
  10159. }
  10160. /* AddTraceback */
  10161. #include "compile.h"
  10162. #include "frameobject.h"
  10163. #include "traceback.h"
  10164. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  10165. const char *funcname, int c_line,
  10166. int py_line, const char *filename) {
  10167. PyCodeObject *py_code = 0;
  10168. PyObject *py_srcfile = 0;
  10169. PyObject *py_funcname = 0;
  10170. #if PY_MAJOR_VERSION < 3
  10171. py_srcfile = PyString_FromString(filename);
  10172. #else
  10173. py_srcfile = PyUnicode_FromString(filename);
  10174. #endif
  10175. if (!py_srcfile) goto bad;
  10176. if (c_line) {
  10177. #if PY_MAJOR_VERSION < 3
  10178. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  10179. #else
  10180. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  10181. #endif
  10182. }
  10183. else {
  10184. #if PY_MAJOR_VERSION < 3
  10185. py_funcname = PyString_FromString(funcname);
  10186. #else
  10187. py_funcname = PyUnicode_FromString(funcname);
  10188. #endif
  10189. }
  10190. if (!py_funcname) goto bad;
  10191. py_code = __Pyx_PyCode_New(
  10192. 0,
  10193. 0,
  10194. 0,
  10195. 0,
  10196. 0,
  10197. __pyx_empty_bytes, /*PyObject *code,*/
  10198. __pyx_empty_tuple, /*PyObject *consts,*/
  10199. __pyx_empty_tuple, /*PyObject *names,*/
  10200. __pyx_empty_tuple, /*PyObject *varnames,*/
  10201. __pyx_empty_tuple, /*PyObject *freevars,*/
  10202. __pyx_empty_tuple, /*PyObject *cellvars,*/
  10203. py_srcfile, /*PyObject *filename,*/
  10204. py_funcname, /*PyObject *name,*/
  10205. py_line,
  10206. __pyx_empty_bytes /*PyObject *lnotab*/
  10207. );
  10208. Py_DECREF(py_srcfile);
  10209. Py_DECREF(py_funcname);
  10210. return py_code;
  10211. bad:
  10212. Py_XDECREF(py_srcfile);
  10213. Py_XDECREF(py_funcname);
  10214. return NULL;
  10215. }
  10216. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  10217. int py_line, const char *filename) {
  10218. PyCodeObject *py_code = 0;
  10219. PyFrameObject *py_frame = 0;
  10220. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  10221. if (c_line) {
  10222. c_line = __Pyx_CLineForTraceback(tstate, c_line);
  10223. }
  10224. py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
  10225. if (!py_code) {
  10226. py_code = __Pyx_CreateCodeObjectForTraceback(
  10227. funcname, c_line, py_line, filename);
  10228. if (!py_code) goto bad;
  10229. __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
  10230. }
  10231. py_frame = PyFrame_New(
  10232. tstate, /*PyThreadState *tstate,*/
  10233. py_code, /*PyCodeObject *code,*/
  10234. __pyx_d, /*PyObject *globals,*/
  10235. 0 /*PyObject *locals*/
  10236. );
  10237. if (!py_frame) goto bad;
  10238. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  10239. PyTraceBack_Here(py_frame);
  10240. bad:
  10241. Py_XDECREF(py_code);
  10242. Py_XDECREF(py_frame);
  10243. }
  10244. /* CIntFromPyVerify */
  10245. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  10246. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  10247. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  10248. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  10249. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  10250. {\
  10251. func_type value = func_value;\
  10252. if (sizeof(target_type) < sizeof(func_type)) {\
  10253. if (unlikely(value != (func_type) (target_type) value)) {\
  10254. func_type zero = 0;\
  10255. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  10256. return (target_type) -1;\
  10257. if (is_unsigned && unlikely(value < zero))\
  10258. goto raise_neg_overflow;\
  10259. else\
  10260. goto raise_overflow;\
  10261. }\
  10262. }\
  10263. return (target_type) value;\
  10264. }
  10265. /* CIntToPy */
  10266. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  10267. const long neg_one = (long) -1, const_zero = (long) 0;
  10268. const int is_unsigned = neg_one > const_zero;
  10269. if (is_unsigned) {
  10270. if (sizeof(long) < sizeof(long)) {
  10271. return PyInt_FromLong((long) value);
  10272. } else if (sizeof(long) <= sizeof(unsigned long)) {
  10273. return PyLong_FromUnsignedLong((unsigned long) value);
  10274. #ifdef HAVE_LONG_LONG
  10275. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  10276. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  10277. #endif
  10278. }
  10279. } else {
  10280. if (sizeof(long) <= sizeof(long)) {
  10281. return PyInt_FromLong((long) value);
  10282. #ifdef HAVE_LONG_LONG
  10283. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  10284. return PyLong_FromLongLong((PY_LONG_LONG) value);
  10285. #endif
  10286. }
  10287. }
  10288. {
  10289. int one = 1; int little = (int)*(unsigned char *)&one;
  10290. unsigned char *bytes = (unsigned char *)&value;
  10291. return _PyLong_FromByteArray(bytes, sizeof(long),
  10292. little, !is_unsigned);
  10293. }
  10294. }
  10295. /* CIntFromPy */
  10296. static CYTHON_INLINE uint8_t __Pyx_PyInt_As_uint8_t(PyObject *x) {
  10297. const uint8_t neg_one = (uint8_t) -1, const_zero = (uint8_t) 0;
  10298. const int is_unsigned = neg_one > const_zero;
  10299. #if PY_MAJOR_VERSION < 3
  10300. if (likely(PyInt_Check(x))) {
  10301. if (sizeof(uint8_t) < sizeof(long)) {
  10302. __PYX_VERIFY_RETURN_INT(uint8_t, long, PyInt_AS_LONG(x))
  10303. } else {
  10304. long val = PyInt_AS_LONG(x);
  10305. if (is_unsigned && unlikely(val < 0)) {
  10306. goto raise_neg_overflow;
  10307. }
  10308. return (uint8_t) val;
  10309. }
  10310. } else
  10311. #endif
  10312. if (likely(PyLong_Check(x))) {
  10313. if (is_unsigned) {
  10314. #if CYTHON_USE_PYLONG_INTERNALS
  10315. const digit* digits = ((PyLongObject*)x)->ob_digit;
  10316. switch (Py_SIZE(x)) {
  10317. case 0: return (uint8_t) 0;
  10318. case 1: __PYX_VERIFY_RETURN_INT(uint8_t, digit, digits[0])
  10319. case 2:
  10320. if (8 * sizeof(uint8_t) > 1 * PyLong_SHIFT) {
  10321. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10322. __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10323. } else if (8 * sizeof(uint8_t) >= 2 * PyLong_SHIFT) {
  10324. return (uint8_t) (((((uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0]));
  10325. }
  10326. }
  10327. break;
  10328. case 3:
  10329. if (8 * sizeof(uint8_t) > 2 * PyLong_SHIFT) {
  10330. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10331. __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10332. } else if (8 * sizeof(uint8_t) >= 3 * PyLong_SHIFT) {
  10333. return (uint8_t) (((((((uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0]));
  10334. }
  10335. }
  10336. break;
  10337. case 4:
  10338. if (8 * sizeof(uint8_t) > 3 * PyLong_SHIFT) {
  10339. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10340. __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10341. } else if (8 * sizeof(uint8_t) >= 4 * PyLong_SHIFT) {
  10342. return (uint8_t) (((((((((uint8_t)digits[3]) << PyLong_SHIFT) | (uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0]));
  10343. }
  10344. }
  10345. break;
  10346. }
  10347. #endif
  10348. #if CYTHON_COMPILING_IN_CPYTHON
  10349. if (unlikely(Py_SIZE(x) < 0)) {
  10350. goto raise_neg_overflow;
  10351. }
  10352. #else
  10353. {
  10354. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  10355. if (unlikely(result < 0))
  10356. return (uint8_t) -1;
  10357. if (unlikely(result == 1))
  10358. goto raise_neg_overflow;
  10359. }
  10360. #endif
  10361. if (sizeof(uint8_t) <= sizeof(unsigned long)) {
  10362. __PYX_VERIFY_RETURN_INT_EXC(uint8_t, unsigned long, PyLong_AsUnsignedLong(x))
  10363. #ifdef HAVE_LONG_LONG
  10364. } else if (sizeof(uint8_t) <= sizeof(unsigned PY_LONG_LONG)) {
  10365. __PYX_VERIFY_RETURN_INT_EXC(uint8_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  10366. #endif
  10367. }
  10368. } else {
  10369. #if CYTHON_USE_PYLONG_INTERNALS
  10370. const digit* digits = ((PyLongObject*)x)->ob_digit;
  10371. switch (Py_SIZE(x)) {
  10372. case 0: return (uint8_t) 0;
  10373. case -1: __PYX_VERIFY_RETURN_INT(uint8_t, sdigit, (sdigit) (-(sdigit)digits[0]))
  10374. case 1: __PYX_VERIFY_RETURN_INT(uint8_t, digit, +digits[0])
  10375. case -2:
  10376. if (8 * sizeof(uint8_t) - 1 > 1 * PyLong_SHIFT) {
  10377. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10378. __PYX_VERIFY_RETURN_INT(uint8_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10379. } else if (8 * sizeof(uint8_t) - 1 > 2 * PyLong_SHIFT) {
  10380. return (uint8_t) (((uint8_t)-1)*(((((uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
  10381. }
  10382. }
  10383. break;
  10384. case 2:
  10385. if (8 * sizeof(uint8_t) > 1 * PyLong_SHIFT) {
  10386. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10387. __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10388. } else if (8 * sizeof(uint8_t) - 1 > 2 * PyLong_SHIFT) {
  10389. return (uint8_t) ((((((uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
  10390. }
  10391. }
  10392. break;
  10393. case -3:
  10394. if (8 * sizeof(uint8_t) - 1 > 2 * PyLong_SHIFT) {
  10395. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10396. __PYX_VERIFY_RETURN_INT(uint8_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10397. } else if (8 * sizeof(uint8_t) - 1 > 3 * PyLong_SHIFT) {
  10398. return (uint8_t) (((uint8_t)-1)*(((((((uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
  10399. }
  10400. }
  10401. break;
  10402. case 3:
  10403. if (8 * sizeof(uint8_t) > 2 * PyLong_SHIFT) {
  10404. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10405. __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10406. } else if (8 * sizeof(uint8_t) - 1 > 3 * PyLong_SHIFT) {
  10407. return (uint8_t) ((((((((uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
  10408. }
  10409. }
  10410. break;
  10411. case -4:
  10412. if (8 * sizeof(uint8_t) - 1 > 3 * PyLong_SHIFT) {
  10413. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10414. __PYX_VERIFY_RETURN_INT(uint8_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10415. } else if (8 * sizeof(uint8_t) - 1 > 4 * PyLong_SHIFT) {
  10416. return (uint8_t) (((uint8_t)-1)*(((((((((uint8_t)digits[3]) << PyLong_SHIFT) | (uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
  10417. }
  10418. }
  10419. break;
  10420. case 4:
  10421. if (8 * sizeof(uint8_t) > 3 * PyLong_SHIFT) {
  10422. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10423. __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10424. } else if (8 * sizeof(uint8_t) - 1 > 4 * PyLong_SHIFT) {
  10425. return (uint8_t) ((((((((((uint8_t)digits[3]) << PyLong_SHIFT) | (uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
  10426. }
  10427. }
  10428. break;
  10429. }
  10430. #endif
  10431. if (sizeof(uint8_t) <= sizeof(long)) {
  10432. __PYX_VERIFY_RETURN_INT_EXC(uint8_t, long, PyLong_AsLong(x))
  10433. #ifdef HAVE_LONG_LONG
  10434. } else if (sizeof(uint8_t) <= sizeof(PY_LONG_LONG)) {
  10435. __PYX_VERIFY_RETURN_INT_EXC(uint8_t, PY_LONG_LONG, PyLong_AsLongLong(x))
  10436. #endif
  10437. }
  10438. }
  10439. {
  10440. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  10441. PyErr_SetString(PyExc_RuntimeError,
  10442. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  10443. #else
  10444. uint8_t val;
  10445. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  10446. #if PY_MAJOR_VERSION < 3
  10447. if (likely(v) && !PyLong_Check(v)) {
  10448. PyObject *tmp = v;
  10449. v = PyNumber_Long(tmp);
  10450. Py_DECREF(tmp);
  10451. }
  10452. #endif
  10453. if (likely(v)) {
  10454. int one = 1; int is_little = (int)*(unsigned char *)&one;
  10455. unsigned char *bytes = (unsigned char *)&val;
  10456. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  10457. bytes, sizeof(val),
  10458. is_little, !is_unsigned);
  10459. Py_DECREF(v);
  10460. if (likely(!ret))
  10461. return val;
  10462. }
  10463. #endif
  10464. return (uint8_t) -1;
  10465. }
  10466. } else {
  10467. uint8_t val;
  10468. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  10469. if (!tmp) return (uint8_t) -1;
  10470. val = __Pyx_PyInt_As_uint8_t(tmp);
  10471. Py_DECREF(tmp);
  10472. return val;
  10473. }
  10474. raise_overflow:
  10475. PyErr_SetString(PyExc_OverflowError,
  10476. "value too large to convert to uint8_t");
  10477. return (uint8_t) -1;
  10478. raise_neg_overflow:
  10479. PyErr_SetString(PyExc_OverflowError,
  10480. "can't convert negative value to uint8_t");
  10481. return (uint8_t) -1;
  10482. }
  10483. /* CIntFromPy */
  10484. static CYTHON_INLINE uint64_t __Pyx_PyInt_As_uint64_t(PyObject *x) {
  10485. const uint64_t neg_one = (uint64_t) -1, const_zero = (uint64_t) 0;
  10486. const int is_unsigned = neg_one > const_zero;
  10487. #if PY_MAJOR_VERSION < 3
  10488. if (likely(PyInt_Check(x))) {
  10489. if (sizeof(uint64_t) < sizeof(long)) {
  10490. __PYX_VERIFY_RETURN_INT(uint64_t, long, PyInt_AS_LONG(x))
  10491. } else {
  10492. long val = PyInt_AS_LONG(x);
  10493. if (is_unsigned && unlikely(val < 0)) {
  10494. goto raise_neg_overflow;
  10495. }
  10496. return (uint64_t) val;
  10497. }
  10498. } else
  10499. #endif
  10500. if (likely(PyLong_Check(x))) {
  10501. if (is_unsigned) {
  10502. #if CYTHON_USE_PYLONG_INTERNALS
  10503. const digit* digits = ((PyLongObject*)x)->ob_digit;
  10504. switch (Py_SIZE(x)) {
  10505. case 0: return (uint64_t) 0;
  10506. case 1: __PYX_VERIFY_RETURN_INT(uint64_t, digit, digits[0])
  10507. case 2:
  10508. if (8 * sizeof(uint64_t) > 1 * PyLong_SHIFT) {
  10509. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10510. __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10511. } else if (8 * sizeof(uint64_t) >= 2 * PyLong_SHIFT) {
  10512. return (uint64_t) (((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
  10513. }
  10514. }
  10515. break;
  10516. case 3:
  10517. if (8 * sizeof(uint64_t) > 2 * PyLong_SHIFT) {
  10518. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10519. __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10520. } else if (8 * sizeof(uint64_t) >= 3 * PyLong_SHIFT) {
  10521. return (uint64_t) (((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
  10522. }
  10523. }
  10524. break;
  10525. case 4:
  10526. if (8 * sizeof(uint64_t) > 3 * PyLong_SHIFT) {
  10527. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10528. __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10529. } else if (8 * sizeof(uint64_t) >= 4 * PyLong_SHIFT) {
  10530. return (uint64_t) (((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
  10531. }
  10532. }
  10533. break;
  10534. }
  10535. #endif
  10536. #if CYTHON_COMPILING_IN_CPYTHON
  10537. if (unlikely(Py_SIZE(x) < 0)) {
  10538. goto raise_neg_overflow;
  10539. }
  10540. #else
  10541. {
  10542. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  10543. if (unlikely(result < 0))
  10544. return (uint64_t) -1;
  10545. if (unlikely(result == 1))
  10546. goto raise_neg_overflow;
  10547. }
  10548. #endif
  10549. if (sizeof(uint64_t) <= sizeof(unsigned long)) {
  10550. __PYX_VERIFY_RETURN_INT_EXC(uint64_t, unsigned long, PyLong_AsUnsignedLong(x))
  10551. #ifdef HAVE_LONG_LONG
  10552. } else if (sizeof(uint64_t) <= sizeof(unsigned PY_LONG_LONG)) {
  10553. __PYX_VERIFY_RETURN_INT_EXC(uint64_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  10554. #endif
  10555. }
  10556. } else {
  10557. #if CYTHON_USE_PYLONG_INTERNALS
  10558. const digit* digits = ((PyLongObject*)x)->ob_digit;
  10559. switch (Py_SIZE(x)) {
  10560. case 0: return (uint64_t) 0;
  10561. case -1: __PYX_VERIFY_RETURN_INT(uint64_t, sdigit, (sdigit) (-(sdigit)digits[0]))
  10562. case 1: __PYX_VERIFY_RETURN_INT(uint64_t, digit, +digits[0])
  10563. case -2:
  10564. if (8 * sizeof(uint64_t) - 1 > 1 * PyLong_SHIFT) {
  10565. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10566. __PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10567. } else if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
  10568. return (uint64_t) (((uint64_t)-1)*(((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
  10569. }
  10570. }
  10571. break;
  10572. case 2:
  10573. if (8 * sizeof(uint64_t) > 1 * PyLong_SHIFT) {
  10574. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10575. __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10576. } else if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
  10577. return (uint64_t) ((((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
  10578. }
  10579. }
  10580. break;
  10581. case -3:
  10582. if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
  10583. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10584. __PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10585. } else if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
  10586. return (uint64_t) (((uint64_t)-1)*(((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
  10587. }
  10588. }
  10589. break;
  10590. case 3:
  10591. if (8 * sizeof(uint64_t) > 2 * PyLong_SHIFT) {
  10592. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10593. __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10594. } else if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
  10595. return (uint64_t) ((((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
  10596. }
  10597. }
  10598. break;
  10599. case -4:
  10600. if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
  10601. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10602. __PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10603. } else if (8 * sizeof(uint64_t) - 1 > 4 * PyLong_SHIFT) {
  10604. return (uint64_t) (((uint64_t)-1)*(((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
  10605. }
  10606. }
  10607. break;
  10608. case 4:
  10609. if (8 * sizeof(uint64_t) > 3 * PyLong_SHIFT) {
  10610. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10611. __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10612. } else if (8 * sizeof(uint64_t) - 1 > 4 * PyLong_SHIFT) {
  10613. return (uint64_t) ((((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
  10614. }
  10615. }
  10616. break;
  10617. }
  10618. #endif
  10619. if (sizeof(uint64_t) <= sizeof(long)) {
  10620. __PYX_VERIFY_RETURN_INT_EXC(uint64_t, long, PyLong_AsLong(x))
  10621. #ifdef HAVE_LONG_LONG
  10622. } else if (sizeof(uint64_t) <= sizeof(PY_LONG_LONG)) {
  10623. __PYX_VERIFY_RETURN_INT_EXC(uint64_t, PY_LONG_LONG, PyLong_AsLongLong(x))
  10624. #endif
  10625. }
  10626. }
  10627. {
  10628. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  10629. PyErr_SetString(PyExc_RuntimeError,
  10630. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  10631. #else
  10632. uint64_t val;
  10633. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  10634. #if PY_MAJOR_VERSION < 3
  10635. if (likely(v) && !PyLong_Check(v)) {
  10636. PyObject *tmp = v;
  10637. v = PyNumber_Long(tmp);
  10638. Py_DECREF(tmp);
  10639. }
  10640. #endif
  10641. if (likely(v)) {
  10642. int one = 1; int is_little = (int)*(unsigned char *)&one;
  10643. unsigned char *bytes = (unsigned char *)&val;
  10644. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  10645. bytes, sizeof(val),
  10646. is_little, !is_unsigned);
  10647. Py_DECREF(v);
  10648. if (likely(!ret))
  10649. return val;
  10650. }
  10651. #endif
  10652. return (uint64_t) -1;
  10653. }
  10654. } else {
  10655. uint64_t val;
  10656. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  10657. if (!tmp) return (uint64_t) -1;
  10658. val = __Pyx_PyInt_As_uint64_t(tmp);
  10659. Py_DECREF(tmp);
  10660. return val;
  10661. }
  10662. raise_overflow:
  10663. PyErr_SetString(PyExc_OverflowError,
  10664. "value too large to convert to uint64_t");
  10665. return (uint64_t) -1;
  10666. raise_neg_overflow:
  10667. PyErr_SetString(PyExc_OverflowError,
  10668. "can't convert negative value to uint64_t");
  10669. return (uint64_t) -1;
  10670. }
  10671. /* CIntFromPy */
  10672. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  10673. const long neg_one = (long) -1, const_zero = (long) 0;
  10674. const int is_unsigned = neg_one > const_zero;
  10675. #if PY_MAJOR_VERSION < 3
  10676. if (likely(PyInt_Check(x))) {
  10677. if (sizeof(long) < sizeof(long)) {
  10678. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
  10679. } else {
  10680. long val = PyInt_AS_LONG(x);
  10681. if (is_unsigned && unlikely(val < 0)) {
  10682. goto raise_neg_overflow;
  10683. }
  10684. return (long) val;
  10685. }
  10686. } else
  10687. #endif
  10688. if (likely(PyLong_Check(x))) {
  10689. if (is_unsigned) {
  10690. #if CYTHON_USE_PYLONG_INTERNALS
  10691. const digit* digits = ((PyLongObject*)x)->ob_digit;
  10692. switch (Py_SIZE(x)) {
  10693. case 0: return (long) 0;
  10694. case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
  10695. case 2:
  10696. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  10697. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10698. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10699. } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
  10700. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  10701. }
  10702. }
  10703. break;
  10704. case 3:
  10705. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  10706. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10707. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10708. } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
  10709. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  10710. }
  10711. }
  10712. break;
  10713. case 4:
  10714. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  10715. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10716. __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])))
  10717. } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
  10718. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  10719. }
  10720. }
  10721. break;
  10722. }
  10723. #endif
  10724. #if CYTHON_COMPILING_IN_CPYTHON
  10725. if (unlikely(Py_SIZE(x) < 0)) {
  10726. goto raise_neg_overflow;
  10727. }
  10728. #else
  10729. {
  10730. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  10731. if (unlikely(result < 0))
  10732. return (long) -1;
  10733. if (unlikely(result == 1))
  10734. goto raise_neg_overflow;
  10735. }
  10736. #endif
  10737. if (sizeof(long) <= sizeof(unsigned long)) {
  10738. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  10739. #ifdef HAVE_LONG_LONG
  10740. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  10741. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  10742. #endif
  10743. }
  10744. } else {
  10745. #if CYTHON_USE_PYLONG_INTERNALS
  10746. const digit* digits = ((PyLongObject*)x)->ob_digit;
  10747. switch (Py_SIZE(x)) {
  10748. case 0: return (long) 0;
  10749. case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
  10750. case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
  10751. case -2:
  10752. if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
  10753. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10754. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10755. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  10756. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  10757. }
  10758. }
  10759. break;
  10760. case 2:
  10761. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  10762. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10763. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10764. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  10765. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  10766. }
  10767. }
  10768. break;
  10769. case -3:
  10770. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  10771. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10772. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10773. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  10774. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  10775. }
  10776. }
  10777. break;
  10778. case 3:
  10779. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  10780. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10781. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10782. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  10783. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  10784. }
  10785. }
  10786. break;
  10787. case -4:
  10788. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  10789. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10790. __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])))
  10791. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  10792. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  10793. }
  10794. }
  10795. break;
  10796. case 4:
  10797. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  10798. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10799. __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])))
  10800. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  10801. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  10802. }
  10803. }
  10804. break;
  10805. }
  10806. #endif
  10807. if (sizeof(long) <= sizeof(long)) {
  10808. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  10809. #ifdef HAVE_LONG_LONG
  10810. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  10811. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  10812. #endif
  10813. }
  10814. }
  10815. {
  10816. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  10817. PyErr_SetString(PyExc_RuntimeError,
  10818. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  10819. #else
  10820. long val;
  10821. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  10822. #if PY_MAJOR_VERSION < 3
  10823. if (likely(v) && !PyLong_Check(v)) {
  10824. PyObject *tmp = v;
  10825. v = PyNumber_Long(tmp);
  10826. Py_DECREF(tmp);
  10827. }
  10828. #endif
  10829. if (likely(v)) {
  10830. int one = 1; int is_little = (int)*(unsigned char *)&one;
  10831. unsigned char *bytes = (unsigned char *)&val;
  10832. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  10833. bytes, sizeof(val),
  10834. is_little, !is_unsigned);
  10835. Py_DECREF(v);
  10836. if (likely(!ret))
  10837. return val;
  10838. }
  10839. #endif
  10840. return (long) -1;
  10841. }
  10842. } else {
  10843. long val;
  10844. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  10845. if (!tmp) return (long) -1;
  10846. val = __Pyx_PyInt_As_long(tmp);
  10847. Py_DECREF(tmp);
  10848. return val;
  10849. }
  10850. raise_overflow:
  10851. PyErr_SetString(PyExc_OverflowError,
  10852. "value too large to convert to long");
  10853. return (long) -1;
  10854. raise_neg_overflow:
  10855. PyErr_SetString(PyExc_OverflowError,
  10856. "can't convert negative value to long");
  10857. return (long) -1;
  10858. }
  10859. /* CIntFromPy */
  10860. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  10861. const int neg_one = (int) -1, const_zero = (int) 0;
  10862. const int is_unsigned = neg_one > const_zero;
  10863. #if PY_MAJOR_VERSION < 3
  10864. if (likely(PyInt_Check(x))) {
  10865. if (sizeof(int) < sizeof(long)) {
  10866. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
  10867. } else {
  10868. long val = PyInt_AS_LONG(x);
  10869. if (is_unsigned && unlikely(val < 0)) {
  10870. goto raise_neg_overflow;
  10871. }
  10872. return (int) val;
  10873. }
  10874. } else
  10875. #endif
  10876. if (likely(PyLong_Check(x))) {
  10877. if (is_unsigned) {
  10878. #if CYTHON_USE_PYLONG_INTERNALS
  10879. const digit* digits = ((PyLongObject*)x)->ob_digit;
  10880. switch (Py_SIZE(x)) {
  10881. case 0: return (int) 0;
  10882. case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
  10883. case 2:
  10884. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  10885. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10886. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10887. } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
  10888. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  10889. }
  10890. }
  10891. break;
  10892. case 3:
  10893. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  10894. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10895. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10896. } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
  10897. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  10898. }
  10899. }
  10900. break;
  10901. case 4:
  10902. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  10903. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10904. __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])))
  10905. } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
  10906. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  10907. }
  10908. }
  10909. break;
  10910. }
  10911. #endif
  10912. #if CYTHON_COMPILING_IN_CPYTHON
  10913. if (unlikely(Py_SIZE(x) < 0)) {
  10914. goto raise_neg_overflow;
  10915. }
  10916. #else
  10917. {
  10918. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  10919. if (unlikely(result < 0))
  10920. return (int) -1;
  10921. if (unlikely(result == 1))
  10922. goto raise_neg_overflow;
  10923. }
  10924. #endif
  10925. if (sizeof(int) <= sizeof(unsigned long)) {
  10926. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  10927. #ifdef HAVE_LONG_LONG
  10928. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  10929. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  10930. #endif
  10931. }
  10932. } else {
  10933. #if CYTHON_USE_PYLONG_INTERNALS
  10934. const digit* digits = ((PyLongObject*)x)->ob_digit;
  10935. switch (Py_SIZE(x)) {
  10936. case 0: return (int) 0;
  10937. case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
  10938. case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
  10939. case -2:
  10940. if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
  10941. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10942. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10943. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  10944. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  10945. }
  10946. }
  10947. break;
  10948. case 2:
  10949. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  10950. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  10951. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10952. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  10953. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  10954. }
  10955. }
  10956. break;
  10957. case -3:
  10958. if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  10959. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10960. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10961. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  10962. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  10963. }
  10964. }
  10965. break;
  10966. case 3:
  10967. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  10968. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  10969. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  10970. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  10971. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  10972. }
  10973. }
  10974. break;
  10975. case -4:
  10976. if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  10977. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10978. __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])))
  10979. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  10980. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  10981. }
  10982. }
  10983. break;
  10984. case 4:
  10985. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  10986. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  10987. __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])))
  10988. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  10989. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  10990. }
  10991. }
  10992. break;
  10993. }
  10994. #endif
  10995. if (sizeof(int) <= sizeof(long)) {
  10996. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  10997. #ifdef HAVE_LONG_LONG
  10998. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  10999. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  11000. #endif
  11001. }
  11002. }
  11003. {
  11004. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  11005. PyErr_SetString(PyExc_RuntimeError,
  11006. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  11007. #else
  11008. int val;
  11009. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  11010. #if PY_MAJOR_VERSION < 3
  11011. if (likely(v) && !PyLong_Check(v)) {
  11012. PyObject *tmp = v;
  11013. v = PyNumber_Long(tmp);
  11014. Py_DECREF(tmp);
  11015. }
  11016. #endif
  11017. if (likely(v)) {
  11018. int one = 1; int is_little = (int)*(unsigned char *)&one;
  11019. unsigned char *bytes = (unsigned char *)&val;
  11020. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  11021. bytes, sizeof(val),
  11022. is_little, !is_unsigned);
  11023. Py_DECREF(v);
  11024. if (likely(!ret))
  11025. return val;
  11026. }
  11027. #endif
  11028. return (int) -1;
  11029. }
  11030. } else {
  11031. int val;
  11032. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  11033. if (!tmp) return (int) -1;
  11034. val = __Pyx_PyInt_As_int(tmp);
  11035. Py_DECREF(tmp);
  11036. return val;
  11037. }
  11038. raise_overflow:
  11039. PyErr_SetString(PyExc_OverflowError,
  11040. "value too large to convert to int");
  11041. return (int) -1;
  11042. raise_neg_overflow:
  11043. PyErr_SetString(PyExc_OverflowError,
  11044. "can't convert negative value to int");
  11045. return (int) -1;
  11046. }
  11047. /* FastTypeChecks */
  11048. #if CYTHON_COMPILING_IN_CPYTHON
  11049. static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
  11050. while (a) {
  11051. a = a->tp_base;
  11052. if (a == b)
  11053. return 1;
  11054. }
  11055. return b == &PyBaseObject_Type;
  11056. }
  11057. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
  11058. PyObject *mro;
  11059. if (a == b) return 1;
  11060. mro = a->tp_mro;
  11061. if (likely(mro)) {
  11062. Py_ssize_t i, n;
  11063. n = PyTuple_GET_SIZE(mro);
  11064. for (i = 0; i < n; i++) {
  11065. if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
  11066. return 1;
  11067. }
  11068. return 0;
  11069. }
  11070. return __Pyx_InBases(a, b);
  11071. }
  11072. #if PY_MAJOR_VERSION == 2
  11073. static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
  11074. PyObject *exception, *value, *tb;
  11075. int res;
  11076. __Pyx_PyThreadState_declare
  11077. __Pyx_PyThreadState_assign
  11078. __Pyx_ErrFetch(&exception, &value, &tb);
  11079. res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
  11080. if (unlikely(res == -1)) {
  11081. PyErr_WriteUnraisable(err);
  11082. res = 0;
  11083. }
  11084. if (!res) {
  11085. res = PyObject_IsSubclass(err, exc_type2);
  11086. if (unlikely(res == -1)) {
  11087. PyErr_WriteUnraisable(err);
  11088. res = 0;
  11089. }
  11090. }
  11091. __Pyx_ErrRestore(exception, value, tb);
  11092. return res;
  11093. }
  11094. #else
  11095. static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
  11096. int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
  11097. if (!res) {
  11098. res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
  11099. }
  11100. return res;
  11101. }
  11102. #endif
  11103. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
  11104. if (likely(err == exc_type)) return 1;
  11105. if (likely(PyExceptionClass_Check(err))) {
  11106. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
  11107. }
  11108. return PyErr_GivenExceptionMatches(err, exc_type);
  11109. }
  11110. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
  11111. if (likely(err == exc_type1 || err == exc_type2)) return 1;
  11112. if (likely(PyExceptionClass_Check(err))) {
  11113. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
  11114. }
  11115. return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
  11116. }
  11117. #endif
  11118. /* CheckBinaryVersion */
  11119. static int __Pyx_check_binary_version(void) {
  11120. char ctversion[4], rtversion[4];
  11121. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  11122. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  11123. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  11124. char message[200];
  11125. PyOS_snprintf(message, sizeof(message),
  11126. "compiletime version %s of module '%.100s' "
  11127. "does not match runtime version %s",
  11128. ctversion, __Pyx_MODULE_NAME, rtversion);
  11129. return PyErr_WarnEx(NULL, message, 1);
  11130. }
  11131. return 0;
  11132. }
  11133. /* ModuleImport */
  11134. #ifndef __PYX_HAVE_RT_ImportModule
  11135. #define __PYX_HAVE_RT_ImportModule
  11136. static PyObject *__Pyx_ImportModule(const char *name) {
  11137. PyObject *py_name = 0;
  11138. PyObject *py_module = 0;
  11139. py_name = __Pyx_PyIdentifier_FromString(name);
  11140. if (!py_name)
  11141. goto bad;
  11142. py_module = PyImport_Import(py_name);
  11143. Py_DECREF(py_name);
  11144. return py_module;
  11145. bad:
  11146. Py_XDECREF(py_name);
  11147. return 0;
  11148. }
  11149. #endif
  11150. /* TypeImport */
  11151. #ifndef __PYX_HAVE_RT_ImportType
  11152. #define __PYX_HAVE_RT_ImportType
  11153. static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
  11154. size_t size, int strict)
  11155. {
  11156. PyObject *py_module = 0;
  11157. PyObject *result = 0;
  11158. PyObject *py_name = 0;
  11159. char warning[200];
  11160. Py_ssize_t basicsize;
  11161. #ifdef Py_LIMITED_API
  11162. PyObject *py_basicsize;
  11163. #endif
  11164. py_module = __Pyx_ImportModule(module_name);
  11165. if (!py_module)
  11166. goto bad;
  11167. py_name = __Pyx_PyIdentifier_FromString(class_name);
  11168. if (!py_name)
  11169. goto bad;
  11170. result = PyObject_GetAttr(py_module, py_name);
  11171. Py_DECREF(py_name);
  11172. py_name = 0;
  11173. Py_DECREF(py_module);
  11174. py_module = 0;
  11175. if (!result)
  11176. goto bad;
  11177. if (!PyType_Check(result)) {
  11178. PyErr_Format(PyExc_TypeError,
  11179. "%.200s.%.200s is not a type object",
  11180. module_name, class_name);
  11181. goto bad;
  11182. }
  11183. #ifndef Py_LIMITED_API
  11184. basicsize = ((PyTypeObject *)result)->tp_basicsize;
  11185. #else
  11186. py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
  11187. if (!py_basicsize)
  11188. goto bad;
  11189. basicsize = PyLong_AsSsize_t(py_basicsize);
  11190. Py_DECREF(py_basicsize);
  11191. py_basicsize = 0;
  11192. if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
  11193. goto bad;
  11194. #endif
  11195. if (!strict && (size_t)basicsize > size) {
  11196. PyOS_snprintf(warning, sizeof(warning),
  11197. "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
  11198. module_name, class_name, basicsize, size);
  11199. if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
  11200. }
  11201. else if ((size_t)basicsize != size) {
  11202. PyErr_Format(PyExc_ValueError,
  11203. "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
  11204. module_name, class_name, basicsize, size);
  11205. goto bad;
  11206. }
  11207. return (PyTypeObject *)result;
  11208. bad:
  11209. Py_XDECREF(py_module);
  11210. Py_XDECREF(result);
  11211. return NULL;
  11212. }
  11213. #endif
  11214. /* InitStrings */
  11215. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  11216. while (t->p) {
  11217. #if PY_MAJOR_VERSION < 3
  11218. if (t->is_unicode) {
  11219. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  11220. } else if (t->intern) {
  11221. *t->p = PyString_InternFromString(t->s);
  11222. } else {
  11223. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  11224. }
  11225. #else
  11226. if (t->is_unicode | t->is_str) {
  11227. if (t->intern) {
  11228. *t->p = PyUnicode_InternFromString(t->s);
  11229. } else if (t->encoding) {
  11230. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  11231. } else {
  11232. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  11233. }
  11234. } else {
  11235. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  11236. }
  11237. #endif
  11238. if (!*t->p)
  11239. return -1;
  11240. if (PyObject_Hash(*t->p) == -1)
  11241. return -1;
  11242. ++t;
  11243. }
  11244. return 0;
  11245. }
  11246. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  11247. return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
  11248. }
  11249. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
  11250. Py_ssize_t ignore;
  11251. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  11252. }
  11253. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  11254. #if !CYTHON_PEP393_ENABLED
  11255. static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  11256. char* defenc_c;
  11257. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  11258. if (!defenc) return NULL;
  11259. defenc_c = PyBytes_AS_STRING(defenc);
  11260. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  11261. {
  11262. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  11263. char* c;
  11264. for (c = defenc_c; c < end; c++) {
  11265. if ((unsigned char) (*c) >= 128) {
  11266. PyUnicode_AsASCIIString(o);
  11267. return NULL;
  11268. }
  11269. }
  11270. }
  11271. #endif
  11272. *length = PyBytes_GET_SIZE(defenc);
  11273. return defenc_c;
  11274. }
  11275. #else
  11276. static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  11277. if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
  11278. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  11279. if (likely(PyUnicode_IS_ASCII(o))) {
  11280. *length = PyUnicode_GET_LENGTH(o);
  11281. return PyUnicode_AsUTF8(o);
  11282. } else {
  11283. PyUnicode_AsASCIIString(o);
  11284. return NULL;
  11285. }
  11286. #else
  11287. return PyUnicode_AsUTF8AndSize(o, length);
  11288. #endif
  11289. }
  11290. #endif
  11291. #endif
  11292. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  11293. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  11294. if (
  11295. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  11296. __Pyx_sys_getdefaultencoding_not_ascii &&
  11297. #endif
  11298. PyUnicode_Check(o)) {
  11299. return __Pyx_PyUnicode_AsStringAndSize(o, length);
  11300. } else
  11301. #endif
  11302. #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
  11303. if (PyByteArray_Check(o)) {
  11304. *length = PyByteArray_GET_SIZE(o);
  11305. return PyByteArray_AS_STRING(o);
  11306. } else
  11307. #endif
  11308. {
  11309. char* result;
  11310. int r = PyBytes_AsStringAndSize(o, &result, length);
  11311. if (unlikely(r < 0)) {
  11312. return NULL;
  11313. } else {
  11314. return result;
  11315. }
  11316. }
  11317. }
  11318. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  11319. int is_true = x == Py_True;
  11320. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  11321. else return PyObject_IsTrue(x);
  11322. }
  11323. static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
  11324. #if PY_MAJOR_VERSION >= 3
  11325. if (PyLong_Check(result)) {
  11326. if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
  11327. "__int__ returned non-int (type %.200s). "
  11328. "The ability to return an instance of a strict subclass of int "
  11329. "is deprecated, and may be removed in a future version of Python.",
  11330. Py_TYPE(result)->tp_name)) {
  11331. Py_DECREF(result);
  11332. return NULL;
  11333. }
  11334. return result;
  11335. }
  11336. #endif
  11337. PyErr_Format(PyExc_TypeError,
  11338. "__%.4s__ returned non-%.4s (type %.200s)",
  11339. type_name, type_name, Py_TYPE(result)->tp_name);
  11340. Py_DECREF(result);
  11341. return NULL;
  11342. }
  11343. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  11344. #if CYTHON_USE_TYPE_SLOTS
  11345. PyNumberMethods *m;
  11346. #endif
  11347. const char *name = NULL;
  11348. PyObject *res = NULL;
  11349. #if PY_MAJOR_VERSION < 3
  11350. if (likely(PyInt_Check(x) || PyLong_Check(x)))
  11351. #else
  11352. if (likely(PyLong_Check(x)))
  11353. #endif
  11354. return __Pyx_NewRef(x);
  11355. #if CYTHON_USE_TYPE_SLOTS
  11356. m = Py_TYPE(x)->tp_as_number;
  11357. #if PY_MAJOR_VERSION < 3
  11358. if (m && m->nb_int) {
  11359. name = "int";
  11360. res = m->nb_int(x);
  11361. }
  11362. else if (m && m->nb_long) {
  11363. name = "long";
  11364. res = m->nb_long(x);
  11365. }
  11366. #else
  11367. if (likely(m && m->nb_int)) {
  11368. name = "int";
  11369. res = m->nb_int(x);
  11370. }
  11371. #endif
  11372. #else
  11373. if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
  11374. res = PyNumber_Int(x);
  11375. }
  11376. #endif
  11377. if (likely(res)) {
  11378. #if PY_MAJOR_VERSION < 3
  11379. if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
  11380. #else
  11381. if (unlikely(!PyLong_CheckExact(res))) {
  11382. #endif
  11383. return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
  11384. }
  11385. }
  11386. else if (!PyErr_Occurred()) {
  11387. PyErr_SetString(PyExc_TypeError,
  11388. "an integer is required");
  11389. }
  11390. return res;
  11391. }
  11392. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  11393. Py_ssize_t ival;
  11394. PyObject *x;
  11395. #if PY_MAJOR_VERSION < 3
  11396. if (likely(PyInt_CheckExact(b))) {
  11397. if (sizeof(Py_ssize_t) >= sizeof(long))
  11398. return PyInt_AS_LONG(b);
  11399. else
  11400. return PyInt_AsSsize_t(x);
  11401. }
  11402. #endif
  11403. if (likely(PyLong_CheckExact(b))) {
  11404. #if CYTHON_USE_PYLONG_INTERNALS
  11405. const digit* digits = ((PyLongObject*)b)->ob_digit;
  11406. const Py_ssize_t size = Py_SIZE(b);
  11407. if (likely(__Pyx_sst_abs(size) <= 1)) {
  11408. ival = likely(size) ? digits[0] : 0;
  11409. if (size == -1) ival = -ival;
  11410. return ival;
  11411. } else {
  11412. switch (size) {
  11413. case 2:
  11414. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  11415. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  11416. }
  11417. break;
  11418. case -2:
  11419. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  11420. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  11421. }
  11422. break;
  11423. case 3:
  11424. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  11425. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  11426. }
  11427. break;
  11428. case -3:
  11429. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  11430. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  11431. }
  11432. break;
  11433. case 4:
  11434. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  11435. 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]));
  11436. }
  11437. break;
  11438. case -4:
  11439. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  11440. 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]));
  11441. }
  11442. break;
  11443. }
  11444. }
  11445. #endif
  11446. return PyLong_AsSsize_t(b);
  11447. }
  11448. x = PyNumber_Index(b);
  11449. if (!x) return -1;
  11450. ival = PyInt_AsSsize_t(x);
  11451. Py_DECREF(x);
  11452. return ival;
  11453. }
  11454. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  11455. return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
  11456. }
  11457. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  11458. return PyInt_FromSize_t(ival);
  11459. }
  11460. #endif /* Py_PYTHON_H */