comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/site-packages/pysam/libcutils.c @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
comparison
equal deleted inserted replaced
67:0e9998148a16 69:33d812a61356
1 /* Generated by Cython 3.0.11 */
2
3 /* BEGIN: Cython Metadata
4 {
5 "distutils": {
6 "define_macros": [
7 [
8 "BUILDING_WHEEL",
9 null
10 ]
11 ],
12 "depends": [
13 "/project/bcftools/bcftools.pysam.h",
14 "/project/samtools/samtools.pysam.h"
15 ],
16 "extra_compile_args": [
17 "-Wno-unused",
18 "-Wno-strict-prototypes",
19 "-Wno-sign-compare",
20 "-Wno-error=declaration-after-statement"
21 ],
22 "extra_link_args": [
23 "-Wl,-rpath,$ORIGIN"
24 ],
25 "include_dirs": [
26 "/project/pysam",
27 "/project/htslib",
28 "/project/samtools",
29 "/project/samtools/lz4",
30 "/project/bcftools",
31 "/project"
32 ],
33 "language": "c",
34 "libraries": [
35 "z",
36 "lzma",
37 "bz2",
38 "z",
39 "m",
40 "curl",
41 "crypto",
42 "chtslib.cpython-37m-x86_64-linux-gnu",
43 "csamtools.cpython-37m-x86_64-linux-gnu",
44 "cbcftools.cpython-37m-x86_64-linux-gnu"
45 ],
46 "library_dirs": [
47 "/project/pysam",
48 "/project",
49 "build/lib.linux-x86_64-cpython-37/pysam",
50 "build/lib.linux-x86_64-cpython-37/pysam",
51 "build/lib.linux-x86_64-cpython-37/pysam",
52 "build/lib.linux-x86_64-cpython-37/pysam"
53 ],
54 "name": "pysam.libcutils",
55 "sources": [
56 "pysam/libcutils.pyx",
57 "pysam/pysam_util.c"
58 ]
59 },
60 "module_name": "pysam.libcutils"
61 }
62 END: Cython Metadata */
63
64 #ifndef PY_SSIZE_T_CLEAN
65 #define PY_SSIZE_T_CLEAN
66 #endif /* PY_SSIZE_T_CLEAN */
67 #if defined(CYTHON_LIMITED_API) && 0
68 #ifndef Py_LIMITED_API
69 #if CYTHON_LIMITED_API+0 > 0x03030000
70 #define Py_LIMITED_API CYTHON_LIMITED_API
71 #else
72 #define Py_LIMITED_API 0x03030000
73 #endif
74 #endif
75 #endif
76
77 #include "Python.h"
78
79 #if PY_MAJOR_VERSION >= 3
80 #define __Pyx_PyFloat_FromString(obj) PyFloat_FromString(obj)
81 #else
82 #define __Pyx_PyFloat_FromString(obj) PyFloat_FromString(obj, NULL)
83 #endif
84
85
86 #if PY_MAJOR_VERSION <= 2
87 #define PyDict_GetItemWithError _PyDict_GetItemWithError
88 #endif
89
90
91 #if (PY_VERSION_HEX < 0x030700b1 || (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030600)) && !defined(PyContextVar_Get)
92 #define PyContextVar_Get(var, d, v) ((d) ? ((void)(var), Py_INCREF(d), (v)[0] = (d), 0) : ((v)[0] = NULL, 0) )
93 #endif
94
95 #ifndef Py_PYTHON_H
96 #error Python headers needed to compile C extensions, please install development version of Python.
97 #elif PY_VERSION_HEX < 0x02070000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
98 #error Cython requires Python 2.7+ or Python 3.3+.
99 #else
100 #if defined(CYTHON_LIMITED_API) && CYTHON_LIMITED_API
101 #define __PYX_EXTRA_ABI_MODULE_NAME "limited"
102 #else
103 #define __PYX_EXTRA_ABI_MODULE_NAME ""
104 #endif
105 #define CYTHON_ABI "3_0_11" __PYX_EXTRA_ABI_MODULE_NAME
106 #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI
107 #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "."
108 #define CYTHON_HEX_VERSION 0x03000BF0
109 #define CYTHON_FUTURE_DIVISION 1
110 #include <stddef.h>
111 #ifndef offsetof
112 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
113 #endif
114 #if !defined(_WIN32) && !defined(WIN32) && !defined(MS_WINDOWS)
115 #ifndef __stdcall
116 #define __stdcall
117 #endif
118 #ifndef __cdecl
119 #define __cdecl
120 #endif
121 #ifndef __fastcall
122 #define __fastcall
123 #endif
124 #endif
125 #ifndef DL_IMPORT
126 #define DL_IMPORT(t) t
127 #endif
128 #ifndef DL_EXPORT
129 #define DL_EXPORT(t) t
130 #endif
131 #define __PYX_COMMA ,
132 #ifndef HAVE_LONG_LONG
133 #define HAVE_LONG_LONG
134 #endif
135 #ifndef PY_LONG_LONG
136 #define PY_LONG_LONG LONG_LONG
137 #endif
138 #ifndef Py_HUGE_VAL
139 #define Py_HUGE_VAL HUGE_VAL
140 #endif
141 #define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX
142 #if defined(GRAALVM_PYTHON)
143 /* For very preliminary testing purposes. Most variables are set the same as PyPy.
144 The existence of this section does not imply that anything works or is even tested */
145 #define CYTHON_COMPILING_IN_PYPY 0
146 #define CYTHON_COMPILING_IN_CPYTHON 0
147 #define CYTHON_COMPILING_IN_LIMITED_API 0
148 #define CYTHON_COMPILING_IN_GRAAL 1
149 #define CYTHON_COMPILING_IN_NOGIL 0
150 #undef CYTHON_USE_TYPE_SLOTS
151 #define CYTHON_USE_TYPE_SLOTS 0
152 #undef CYTHON_USE_TYPE_SPECS
153 #define CYTHON_USE_TYPE_SPECS 0
154 #undef CYTHON_USE_PYTYPE_LOOKUP
155 #define CYTHON_USE_PYTYPE_LOOKUP 0
156 #if PY_VERSION_HEX < 0x03050000
157 #undef CYTHON_USE_ASYNC_SLOTS
158 #define CYTHON_USE_ASYNC_SLOTS 0
159 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
160 #define CYTHON_USE_ASYNC_SLOTS 1
161 #endif
162 #undef CYTHON_USE_PYLIST_INTERNALS
163 #define CYTHON_USE_PYLIST_INTERNALS 0
164 #undef CYTHON_USE_UNICODE_INTERNALS
165 #define CYTHON_USE_UNICODE_INTERNALS 0
166 #undef CYTHON_USE_UNICODE_WRITER
167 #define CYTHON_USE_UNICODE_WRITER 0
168 #undef CYTHON_USE_PYLONG_INTERNALS
169 #define CYTHON_USE_PYLONG_INTERNALS 0
170 #undef CYTHON_AVOID_BORROWED_REFS
171 #define CYTHON_AVOID_BORROWED_REFS 1
172 #undef CYTHON_ASSUME_SAFE_MACROS
173 #define CYTHON_ASSUME_SAFE_MACROS 0
174 #undef CYTHON_UNPACK_METHODS
175 #define CYTHON_UNPACK_METHODS 0
176 #undef CYTHON_FAST_THREAD_STATE
177 #define CYTHON_FAST_THREAD_STATE 0
178 #undef CYTHON_FAST_GIL
179 #define CYTHON_FAST_GIL 0
180 #undef CYTHON_METH_FASTCALL
181 #define CYTHON_METH_FASTCALL 0
182 #undef CYTHON_FAST_PYCALL
183 #define CYTHON_FAST_PYCALL 0
184 #ifndef CYTHON_PEP487_INIT_SUBCLASS
185 #define CYTHON_PEP487_INIT_SUBCLASS (PY_MAJOR_VERSION >= 3)
186 #endif
187 #undef CYTHON_PEP489_MULTI_PHASE_INIT
188 #define CYTHON_PEP489_MULTI_PHASE_INIT 1
189 #undef CYTHON_USE_MODULE_STATE
190 #define CYTHON_USE_MODULE_STATE 0
191 #undef CYTHON_USE_TP_FINALIZE
192 #define CYTHON_USE_TP_FINALIZE 0
193 #undef CYTHON_USE_DICT_VERSIONS
194 #define CYTHON_USE_DICT_VERSIONS 0
195 #undef CYTHON_USE_EXC_INFO_STACK
196 #define CYTHON_USE_EXC_INFO_STACK 0
197 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
198 #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
199 #endif
200 #undef CYTHON_USE_FREELISTS
201 #define CYTHON_USE_FREELISTS 0
202 #elif defined(PYPY_VERSION)
203 #define CYTHON_COMPILING_IN_PYPY 1
204 #define CYTHON_COMPILING_IN_CPYTHON 0
205 #define CYTHON_COMPILING_IN_LIMITED_API 0
206 #define CYTHON_COMPILING_IN_GRAAL 0
207 #define CYTHON_COMPILING_IN_NOGIL 0
208 #undef CYTHON_USE_TYPE_SLOTS
209 #define CYTHON_USE_TYPE_SLOTS 0
210 #ifndef CYTHON_USE_TYPE_SPECS
211 #define CYTHON_USE_TYPE_SPECS 0
212 #endif
213 #undef CYTHON_USE_PYTYPE_LOOKUP
214 #define CYTHON_USE_PYTYPE_LOOKUP 0
215 #if PY_VERSION_HEX < 0x03050000
216 #undef CYTHON_USE_ASYNC_SLOTS
217 #define CYTHON_USE_ASYNC_SLOTS 0
218 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
219 #define CYTHON_USE_ASYNC_SLOTS 1
220 #endif
221 #undef CYTHON_USE_PYLIST_INTERNALS
222 #define CYTHON_USE_PYLIST_INTERNALS 0
223 #undef CYTHON_USE_UNICODE_INTERNALS
224 #define CYTHON_USE_UNICODE_INTERNALS 0
225 #undef CYTHON_USE_UNICODE_WRITER
226 #define CYTHON_USE_UNICODE_WRITER 0
227 #undef CYTHON_USE_PYLONG_INTERNALS
228 #define CYTHON_USE_PYLONG_INTERNALS 0
229 #undef CYTHON_AVOID_BORROWED_REFS
230 #define CYTHON_AVOID_BORROWED_REFS 1
231 #undef CYTHON_ASSUME_SAFE_MACROS
232 #define CYTHON_ASSUME_SAFE_MACROS 0
233 #undef CYTHON_UNPACK_METHODS
234 #define CYTHON_UNPACK_METHODS 0
235 #undef CYTHON_FAST_THREAD_STATE
236 #define CYTHON_FAST_THREAD_STATE 0
237 #undef CYTHON_FAST_GIL
238 #define CYTHON_FAST_GIL 0
239 #undef CYTHON_METH_FASTCALL
240 #define CYTHON_METH_FASTCALL 0
241 #undef CYTHON_FAST_PYCALL
242 #define CYTHON_FAST_PYCALL 0
243 #ifndef CYTHON_PEP487_INIT_SUBCLASS
244 #define CYTHON_PEP487_INIT_SUBCLASS (PY_MAJOR_VERSION >= 3)
245 #endif
246 #if PY_VERSION_HEX < 0x03090000
247 #undef CYTHON_PEP489_MULTI_PHASE_INIT
248 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
249 #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT)
250 #define CYTHON_PEP489_MULTI_PHASE_INIT 1
251 #endif
252 #undef CYTHON_USE_MODULE_STATE
253 #define CYTHON_USE_MODULE_STATE 0
254 #undef CYTHON_USE_TP_FINALIZE
255 #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1 && PYPY_VERSION_NUM >= 0x07030C00)
256 #undef CYTHON_USE_DICT_VERSIONS
257 #define CYTHON_USE_DICT_VERSIONS 0
258 #undef CYTHON_USE_EXC_INFO_STACK
259 #define CYTHON_USE_EXC_INFO_STACK 0
260 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
261 #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
262 #endif
263 #undef CYTHON_USE_FREELISTS
264 #define CYTHON_USE_FREELISTS 0
265 #elif defined(CYTHON_LIMITED_API)
266 #ifdef Py_LIMITED_API
267 #undef __PYX_LIMITED_VERSION_HEX
268 #define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API
269 #endif
270 #define CYTHON_COMPILING_IN_PYPY 0
271 #define CYTHON_COMPILING_IN_CPYTHON 0
272 #define CYTHON_COMPILING_IN_LIMITED_API 1
273 #define CYTHON_COMPILING_IN_GRAAL 0
274 #define CYTHON_COMPILING_IN_NOGIL 0
275 #undef CYTHON_CLINE_IN_TRACEBACK
276 #define CYTHON_CLINE_IN_TRACEBACK 0
277 #undef CYTHON_USE_TYPE_SLOTS
278 #define CYTHON_USE_TYPE_SLOTS 0
279 #undef CYTHON_USE_TYPE_SPECS
280 #define CYTHON_USE_TYPE_SPECS 1
281 #undef CYTHON_USE_PYTYPE_LOOKUP
282 #define CYTHON_USE_PYTYPE_LOOKUP 0
283 #undef CYTHON_USE_ASYNC_SLOTS
284 #define CYTHON_USE_ASYNC_SLOTS 0
285 #undef CYTHON_USE_PYLIST_INTERNALS
286 #define CYTHON_USE_PYLIST_INTERNALS 0
287 #undef CYTHON_USE_UNICODE_INTERNALS
288 #define CYTHON_USE_UNICODE_INTERNALS 0
289 #ifndef CYTHON_USE_UNICODE_WRITER
290 #define CYTHON_USE_UNICODE_WRITER 0
291 #endif
292 #undef CYTHON_USE_PYLONG_INTERNALS
293 #define CYTHON_USE_PYLONG_INTERNALS 0
294 #ifndef CYTHON_AVOID_BORROWED_REFS
295 #define CYTHON_AVOID_BORROWED_REFS 0
296 #endif
297 #undef CYTHON_ASSUME_SAFE_MACROS
298 #define CYTHON_ASSUME_SAFE_MACROS 0
299 #undef CYTHON_UNPACK_METHODS
300 #define CYTHON_UNPACK_METHODS 0
301 #undef CYTHON_FAST_THREAD_STATE
302 #define CYTHON_FAST_THREAD_STATE 0
303 #undef CYTHON_FAST_GIL
304 #define CYTHON_FAST_GIL 0
305 #undef CYTHON_METH_FASTCALL
306 #define CYTHON_METH_FASTCALL 0
307 #undef CYTHON_FAST_PYCALL
308 #define CYTHON_FAST_PYCALL 0
309 #ifndef CYTHON_PEP487_INIT_SUBCLASS
310 #define CYTHON_PEP487_INIT_SUBCLASS 1
311 #endif
312 #undef CYTHON_PEP489_MULTI_PHASE_INIT
313 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
314 #undef CYTHON_USE_MODULE_STATE
315 #define CYTHON_USE_MODULE_STATE 1
316 #ifndef CYTHON_USE_TP_FINALIZE
317 #define CYTHON_USE_TP_FINALIZE 0
318 #endif
319 #undef CYTHON_USE_DICT_VERSIONS
320 #define CYTHON_USE_DICT_VERSIONS 0
321 #undef CYTHON_USE_EXC_INFO_STACK
322 #define CYTHON_USE_EXC_INFO_STACK 0
323 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
324 #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
325 #endif
326 #undef CYTHON_USE_FREELISTS
327 #define CYTHON_USE_FREELISTS 0
328 #elif defined(Py_GIL_DISABLED) || defined(Py_NOGIL)
329 #define CYTHON_COMPILING_IN_PYPY 0
330 #define CYTHON_COMPILING_IN_CPYTHON 0
331 #define CYTHON_COMPILING_IN_LIMITED_API 0
332 #define CYTHON_COMPILING_IN_GRAAL 0
333 #define CYTHON_COMPILING_IN_NOGIL 1
334 #ifndef CYTHON_USE_TYPE_SLOTS
335 #define CYTHON_USE_TYPE_SLOTS 1
336 #endif
337 #ifndef CYTHON_USE_TYPE_SPECS
338 #define CYTHON_USE_TYPE_SPECS 0
339 #endif
340 #undef CYTHON_USE_PYTYPE_LOOKUP
341 #define CYTHON_USE_PYTYPE_LOOKUP 0
342 #ifndef CYTHON_USE_ASYNC_SLOTS
343 #define CYTHON_USE_ASYNC_SLOTS 1
344 #endif
345 #ifndef CYTHON_USE_PYLONG_INTERNALS
346 #define CYTHON_USE_PYLONG_INTERNALS 0
347 #endif
348 #undef CYTHON_USE_PYLIST_INTERNALS
349 #define CYTHON_USE_PYLIST_INTERNALS 0
350 #ifndef CYTHON_USE_UNICODE_INTERNALS
351 #define CYTHON_USE_UNICODE_INTERNALS 1
352 #endif
353 #undef CYTHON_USE_UNICODE_WRITER
354 #define CYTHON_USE_UNICODE_WRITER 0
355 #ifndef CYTHON_AVOID_BORROWED_REFS
356 #define CYTHON_AVOID_BORROWED_REFS 0
357 #endif
358 #ifndef CYTHON_ASSUME_SAFE_MACROS
359 #define CYTHON_ASSUME_SAFE_MACROS 1
360 #endif
361 #ifndef CYTHON_UNPACK_METHODS
362 #define CYTHON_UNPACK_METHODS 1
363 #endif
364 #undef CYTHON_FAST_THREAD_STATE
365 #define CYTHON_FAST_THREAD_STATE 0
366 #undef CYTHON_FAST_GIL
367 #define CYTHON_FAST_GIL 0
368 #ifndef CYTHON_METH_FASTCALL
369 #define CYTHON_METH_FASTCALL 1
370 #endif
371 #undef CYTHON_FAST_PYCALL
372 #define CYTHON_FAST_PYCALL 0
373 #ifndef CYTHON_PEP487_INIT_SUBCLASS
374 #define CYTHON_PEP487_INIT_SUBCLASS 1
375 #endif
376 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
377 #define CYTHON_PEP489_MULTI_PHASE_INIT 1
378 #endif
379 #ifndef CYTHON_USE_MODULE_STATE
380 #define CYTHON_USE_MODULE_STATE 0
381 #endif
382 #ifndef CYTHON_USE_TP_FINALIZE
383 #define CYTHON_USE_TP_FINALIZE 1
384 #endif
385 #undef CYTHON_USE_DICT_VERSIONS
386 #define CYTHON_USE_DICT_VERSIONS 0
387 #undef CYTHON_USE_EXC_INFO_STACK
388 #define CYTHON_USE_EXC_INFO_STACK 0
389 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
390 #define CYTHON_UPDATE_DESCRIPTOR_DOC 1
391 #endif
392 #ifndef CYTHON_USE_FREELISTS
393 #define CYTHON_USE_FREELISTS 0
394 #endif
395 #else
396 #define CYTHON_COMPILING_IN_PYPY 0
397 #define CYTHON_COMPILING_IN_CPYTHON 1
398 #define CYTHON_COMPILING_IN_LIMITED_API 0
399 #define CYTHON_COMPILING_IN_GRAAL 0
400 #define CYTHON_COMPILING_IN_NOGIL 0
401 #ifndef CYTHON_USE_TYPE_SLOTS
402 #define CYTHON_USE_TYPE_SLOTS 1
403 #endif
404 #ifndef CYTHON_USE_TYPE_SPECS
405 #define CYTHON_USE_TYPE_SPECS 0
406 #endif
407 #ifndef CYTHON_USE_PYTYPE_LOOKUP
408 #define CYTHON_USE_PYTYPE_LOOKUP 1
409 #endif
410 #if PY_MAJOR_VERSION < 3
411 #undef CYTHON_USE_ASYNC_SLOTS
412 #define CYTHON_USE_ASYNC_SLOTS 0
413 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
414 #define CYTHON_USE_ASYNC_SLOTS 1
415 #endif
416 #ifndef CYTHON_USE_PYLONG_INTERNALS
417 #define CYTHON_USE_PYLONG_INTERNALS 1
418 #endif
419 #ifndef CYTHON_USE_PYLIST_INTERNALS
420 #define CYTHON_USE_PYLIST_INTERNALS 1
421 #endif
422 #ifndef CYTHON_USE_UNICODE_INTERNALS
423 #define CYTHON_USE_UNICODE_INTERNALS 1
424 #endif
425 #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2
426 #undef CYTHON_USE_UNICODE_WRITER
427 #define CYTHON_USE_UNICODE_WRITER 0
428 #elif !defined(CYTHON_USE_UNICODE_WRITER)
429 #define CYTHON_USE_UNICODE_WRITER 1
430 #endif
431 #ifndef CYTHON_AVOID_BORROWED_REFS
432 #define CYTHON_AVOID_BORROWED_REFS 0
433 #endif
434 #ifndef CYTHON_ASSUME_SAFE_MACROS
435 #define CYTHON_ASSUME_SAFE_MACROS 1
436 #endif
437 #ifndef CYTHON_UNPACK_METHODS
438 #define CYTHON_UNPACK_METHODS 1
439 #endif
440 #ifndef CYTHON_FAST_THREAD_STATE
441 #define CYTHON_FAST_THREAD_STATE 1
442 #endif
443 #ifndef CYTHON_FAST_GIL
444 #define CYTHON_FAST_GIL (PY_MAJOR_VERSION < 3 || PY_VERSION_HEX >= 0x03060000 && PY_VERSION_HEX < 0x030C00A6)
445 #endif
446 #ifndef CYTHON_METH_FASTCALL
447 #define CYTHON_METH_FASTCALL (PY_VERSION_HEX >= 0x030700A1)
448 #endif
449 #ifndef CYTHON_FAST_PYCALL
450 #define CYTHON_FAST_PYCALL 1
451 #endif
452 #ifndef CYTHON_PEP487_INIT_SUBCLASS
453 #define CYTHON_PEP487_INIT_SUBCLASS 1
454 #endif
455 #if PY_VERSION_HEX < 0x03050000
456 #undef CYTHON_PEP489_MULTI_PHASE_INIT
457 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
458 #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT)
459 #define CYTHON_PEP489_MULTI_PHASE_INIT 1
460 #endif
461 #ifndef CYTHON_USE_MODULE_STATE
462 #define CYTHON_USE_MODULE_STATE 0
463 #endif
464 #if PY_VERSION_HEX < 0x030400a1
465 #undef CYTHON_USE_TP_FINALIZE
466 #define CYTHON_USE_TP_FINALIZE 0
467 #elif !defined(CYTHON_USE_TP_FINALIZE)
468 #define CYTHON_USE_TP_FINALIZE 1
469 #endif
470 #if PY_VERSION_HEX < 0x030600B1
471 #undef CYTHON_USE_DICT_VERSIONS
472 #define CYTHON_USE_DICT_VERSIONS 0
473 #elif !defined(CYTHON_USE_DICT_VERSIONS)
474 #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX < 0x030C00A5)
475 #endif
476 #if PY_VERSION_HEX < 0x030700A3
477 #undef CYTHON_USE_EXC_INFO_STACK
478 #define CYTHON_USE_EXC_INFO_STACK 0
479 #elif !defined(CYTHON_USE_EXC_INFO_STACK)
480 #define CYTHON_USE_EXC_INFO_STACK 1
481 #endif
482 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
483 #define CYTHON_UPDATE_DESCRIPTOR_DOC 1
484 #endif
485 #ifndef CYTHON_USE_FREELISTS
486 #define CYTHON_USE_FREELISTS 1
487 #endif
488 #endif
489 #if !defined(CYTHON_FAST_PYCCALL)
490 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
491 #endif
492 #if !defined(CYTHON_VECTORCALL)
493 #define CYTHON_VECTORCALL (CYTHON_FAST_PYCCALL && PY_VERSION_HEX >= 0x030800B1)
494 #endif
495 #define CYTHON_BACKPORT_VECTORCALL (CYTHON_METH_FASTCALL && PY_VERSION_HEX < 0x030800B1)
496 #if CYTHON_USE_PYLONG_INTERNALS
497 #if PY_MAJOR_VERSION < 3
498 #include "longintrepr.h"
499 #endif
500 #undef SHIFT
501 #undef BASE
502 #undef MASK
503 #ifdef SIZEOF_VOID_P
504 enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
505 #endif
506 #endif
507 #ifndef __has_attribute
508 #define __has_attribute(x) 0
509 #endif
510 #ifndef __has_cpp_attribute
511 #define __has_cpp_attribute(x) 0
512 #endif
513 #ifndef CYTHON_RESTRICT
514 #if defined(__GNUC__)
515 #define CYTHON_RESTRICT __restrict__
516 #elif defined(_MSC_VER) && _MSC_VER >= 1400
517 #define CYTHON_RESTRICT __restrict
518 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
519 #define CYTHON_RESTRICT restrict
520 #else
521 #define CYTHON_RESTRICT
522 #endif
523 #endif
524 #ifndef CYTHON_UNUSED
525 #if defined(__cplusplus)
526 /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17
527 * but leads to warnings with -pedantic, since it is a C++17 feature */
528 #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
529 #if __has_cpp_attribute(maybe_unused)
530 #define CYTHON_UNUSED [[maybe_unused]]
531 #endif
532 #endif
533 #endif
534 #endif
535 #ifndef CYTHON_UNUSED
536 # if defined(__GNUC__)
537 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
538 # define CYTHON_UNUSED __attribute__ ((__unused__))
539 # else
540 # define CYTHON_UNUSED
541 # endif
542 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
543 # define CYTHON_UNUSED __attribute__ ((__unused__))
544 # else
545 # define CYTHON_UNUSED
546 # endif
547 #endif
548 #ifndef CYTHON_UNUSED_VAR
549 # if defined(__cplusplus)
550 template<class T> void CYTHON_UNUSED_VAR( const T& ) { }
551 # else
552 # define CYTHON_UNUSED_VAR(x) (void)(x)
553 # endif
554 #endif
555 #ifndef CYTHON_MAYBE_UNUSED_VAR
556 #define CYTHON_MAYBE_UNUSED_VAR(x) CYTHON_UNUSED_VAR(x)
557 #endif
558 #ifndef CYTHON_NCP_UNUSED
559 # if CYTHON_COMPILING_IN_CPYTHON
560 # define CYTHON_NCP_UNUSED
561 # else
562 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
563 # endif
564 #endif
565 #ifndef CYTHON_USE_CPP_STD_MOVE
566 #if defined(__cplusplus) && (\
567 __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600))
568 #define CYTHON_USE_CPP_STD_MOVE 1
569 #else
570 #define CYTHON_USE_CPP_STD_MOVE 0
571 #endif
572 #endif
573 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
574 #ifdef _MSC_VER
575 #ifndef _MSC_STDINT_H_
576 #if _MSC_VER < 1300
577 typedef unsigned char uint8_t;
578 typedef unsigned short uint16_t;
579 typedef unsigned int uint32_t;
580 #else
581 typedef unsigned __int8 uint8_t;
582 typedef unsigned __int16 uint16_t;
583 typedef unsigned __int32 uint32_t;
584 #endif
585 #endif
586 #if _MSC_VER < 1300
587 #ifdef _WIN64
588 typedef unsigned long long __pyx_uintptr_t;
589 #else
590 typedef unsigned int __pyx_uintptr_t;
591 #endif
592 #else
593 #ifdef _WIN64
594 typedef unsigned __int64 __pyx_uintptr_t;
595 #else
596 typedef unsigned __int32 __pyx_uintptr_t;
597 #endif
598 #endif
599 #else
600 #include <stdint.h>
601 typedef uintptr_t __pyx_uintptr_t;
602 #endif
603 #ifndef CYTHON_FALLTHROUGH
604 #if defined(__cplusplus)
605 /* for clang __has_cpp_attribute(fallthrough) is true even before C++17
606 * but leads to warnings with -pedantic, since it is a C++17 feature */
607 #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
608 #if __has_cpp_attribute(fallthrough)
609 #define CYTHON_FALLTHROUGH [[fallthrough]]
610 #endif
611 #endif
612 #ifndef CYTHON_FALLTHROUGH
613 #if __has_cpp_attribute(clang::fallthrough)
614 #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
615 #elif __has_cpp_attribute(gnu::fallthrough)
616 #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
617 #endif
618 #endif
619 #endif
620 #ifndef CYTHON_FALLTHROUGH
621 #if __has_attribute(fallthrough)
622 #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
623 #else
624 #define CYTHON_FALLTHROUGH
625 #endif
626 #endif
627 #if defined(__clang__) && defined(__apple_build_version__)
628 #if __apple_build_version__ < 7000000
629 #undef CYTHON_FALLTHROUGH
630 #define CYTHON_FALLTHROUGH
631 #endif
632 #endif
633 #endif
634 #ifdef __cplusplus
635 template <typename T>
636 struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);};
637 #define __PYX_IS_UNSIGNED(type) (__PYX_IS_UNSIGNED_IMPL<type>::value)
638 #else
639 #define __PYX_IS_UNSIGNED(type) (((type)-1) > 0)
640 #endif
641 #if CYTHON_COMPILING_IN_PYPY == 1
642 #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x030A0000)
643 #else
644 #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000)
645 #endif
646 #define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer))
647
648 #ifndef CYTHON_INLINE
649 #if defined(__clang__)
650 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
651 #elif defined(__GNUC__)
652 #define CYTHON_INLINE __inline__
653 #elif defined(_MSC_VER)
654 #define CYTHON_INLINE __inline
655 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
656 #define CYTHON_INLINE inline
657 #else
658 #define CYTHON_INLINE
659 #endif
660 #endif
661
662 #define __PYX_BUILD_PY_SSIZE_T "n"
663 #define CYTHON_FORMAT_SSIZE_T "z"
664 #if PY_MAJOR_VERSION < 3
665 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
666 #define __Pyx_DefaultClassType PyClass_Type
667 #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
668 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
669 #else
670 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
671 #define __Pyx_DefaultClassType PyType_Type
672 #if CYTHON_COMPILING_IN_LIMITED_API
673 static CYTHON_INLINE PyObject* __Pyx_PyCode_New(int a, int p, int k, int l, int s, int f,
674 PyObject *code, PyObject *c, PyObject* n, PyObject *v,
675 PyObject *fv, PyObject *cell, PyObject* fn,
676 PyObject *name, int fline, PyObject *lnos) {
677 PyObject *exception_table = NULL;
678 PyObject *types_module=NULL, *code_type=NULL, *result=NULL;
679 #if __PYX_LIMITED_VERSION_HEX < 0x030B0000
680 PyObject *version_info;
681 PyObject *py_minor_version = NULL;
682 #endif
683 long minor_version = 0;
684 PyObject *type, *value, *traceback;
685 PyErr_Fetch(&type, &value, &traceback);
686 #if __PYX_LIMITED_VERSION_HEX >= 0x030B0000
687 minor_version = 11;
688 #else
689 if (!(version_info = PySys_GetObject("version_info"))) goto end;
690 if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end;
691 minor_version = PyLong_AsLong(py_minor_version);
692 Py_DECREF(py_minor_version);
693 if (minor_version == -1 && PyErr_Occurred()) goto end;
694 #endif
695 if (!(types_module = PyImport_ImportModule("types"))) goto end;
696 if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end;
697 if (minor_version <= 7) {
698 (void)p;
699 result = PyObject_CallFunction(code_type, "iiiiiOOOOOOiOO", a, k, l, s, f, code,
700 c, n, v, fn, name, fline, lnos, fv, cell);
701 } else if (minor_version <= 10) {
702 result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOO", a,p, k, l, s, f, code,
703 c, n, v, fn, name, fline, lnos, fv, cell);
704 } else {
705 if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end;
706 result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOO", a,p, k, l, s, f, code,
707 c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell);
708 }
709 end:
710 Py_XDECREF(code_type);
711 Py_XDECREF(exception_table);
712 Py_XDECREF(types_module);
713 if (type) {
714 PyErr_Restore(type, value, traceback);
715 }
716 return result;
717 }
718 #ifndef CO_OPTIMIZED
719 #define CO_OPTIMIZED 0x0001
720 #endif
721 #ifndef CO_NEWLOCALS
722 #define CO_NEWLOCALS 0x0002
723 #endif
724 #ifndef CO_VARARGS
725 #define CO_VARARGS 0x0004
726 #endif
727 #ifndef CO_VARKEYWORDS
728 #define CO_VARKEYWORDS 0x0008
729 #endif
730 #ifndef CO_ASYNC_GENERATOR
731 #define CO_ASYNC_GENERATOR 0x0200
732 #endif
733 #ifndef CO_GENERATOR
734 #define CO_GENERATOR 0x0020
735 #endif
736 #ifndef CO_COROUTINE
737 #define CO_COROUTINE 0x0080
738 #endif
739 #elif PY_VERSION_HEX >= 0x030B0000
740 static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int p, int k, int l, int s, int f,
741 PyObject *code, PyObject *c, PyObject* n, PyObject *v,
742 PyObject *fv, PyObject *cell, PyObject* fn,
743 PyObject *name, int fline, PyObject *lnos) {
744 PyCodeObject *result;
745 PyObject *empty_bytes = PyBytes_FromStringAndSize("", 0);
746 if (!empty_bytes) return NULL;
747 result =
748 #if PY_VERSION_HEX >= 0x030C0000
749 PyUnstable_Code_NewWithPosOnlyArgs
750 #else
751 PyCode_NewWithPosOnlyArgs
752 #endif
753 (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, empty_bytes);
754 Py_DECREF(empty_bytes);
755 return result;
756 }
757 #elif PY_VERSION_HEX >= 0x030800B2 && !CYTHON_COMPILING_IN_PYPY
758 #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
759 PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
760 #else
761 #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
762 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
763 #endif
764 #endif
765 #if PY_VERSION_HEX >= 0x030900A4 || defined(Py_IS_TYPE)
766 #define __Pyx_IS_TYPE(ob, type) Py_IS_TYPE(ob, type)
767 #else
768 #define __Pyx_IS_TYPE(ob, type) (((const PyObject*)ob)->ob_type == (type))
769 #endif
770 #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_Is)
771 #define __Pyx_Py_Is(x, y) Py_Is(x, y)
772 #else
773 #define __Pyx_Py_Is(x, y) ((x) == (y))
774 #endif
775 #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsNone)
776 #define __Pyx_Py_IsNone(ob) Py_IsNone(ob)
777 #else
778 #define __Pyx_Py_IsNone(ob) __Pyx_Py_Is((ob), Py_None)
779 #endif
780 #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsTrue)
781 #define __Pyx_Py_IsTrue(ob) Py_IsTrue(ob)
782 #else
783 #define __Pyx_Py_IsTrue(ob) __Pyx_Py_Is((ob), Py_True)
784 #endif
785 #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsFalse)
786 #define __Pyx_Py_IsFalse(ob) Py_IsFalse(ob)
787 #else
788 #define __Pyx_Py_IsFalse(ob) __Pyx_Py_Is((ob), Py_False)
789 #endif
790 #define __Pyx_NoneAsNull(obj) (__Pyx_Py_IsNone(obj) ? NULL : (obj))
791 #if PY_VERSION_HEX >= 0x030900F0 && !CYTHON_COMPILING_IN_PYPY
792 #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o)
793 #else
794 #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o)
795 #endif
796 #ifndef CO_COROUTINE
797 #define CO_COROUTINE 0x80
798 #endif
799 #ifndef CO_ASYNC_GENERATOR
800 #define CO_ASYNC_GENERATOR 0x200
801 #endif
802 #ifndef Py_TPFLAGS_CHECKTYPES
803 #define Py_TPFLAGS_CHECKTYPES 0
804 #endif
805 #ifndef Py_TPFLAGS_HAVE_INDEX
806 #define Py_TPFLAGS_HAVE_INDEX 0
807 #endif
808 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
809 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
810 #endif
811 #ifndef Py_TPFLAGS_HAVE_FINALIZE
812 #define Py_TPFLAGS_HAVE_FINALIZE 0
813 #endif
814 #ifndef Py_TPFLAGS_SEQUENCE
815 #define Py_TPFLAGS_SEQUENCE 0
816 #endif
817 #ifndef Py_TPFLAGS_MAPPING
818 #define Py_TPFLAGS_MAPPING 0
819 #endif
820 #ifndef METH_STACKLESS
821 #define METH_STACKLESS 0
822 #endif
823 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
824 #ifndef METH_FASTCALL
825 #define METH_FASTCALL 0x80
826 #endif
827 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
828 typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
829 Py_ssize_t nargs, PyObject *kwnames);
830 #else
831 #if PY_VERSION_HEX >= 0x030d00A4
832 # define __Pyx_PyCFunctionFast PyCFunctionFast
833 # define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords
834 #else
835 # define __Pyx_PyCFunctionFast _PyCFunctionFast
836 # define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
837 #endif
838 #endif
839 #if CYTHON_METH_FASTCALL
840 #define __Pyx_METH_FASTCALL METH_FASTCALL
841 #define __Pyx_PyCFunction_FastCall __Pyx_PyCFunctionFast
842 #define __Pyx_PyCFunction_FastCallWithKeywords __Pyx_PyCFunctionFastWithKeywords
843 #else
844 #define __Pyx_METH_FASTCALL METH_VARARGS
845 #define __Pyx_PyCFunction_FastCall PyCFunction
846 #define __Pyx_PyCFunction_FastCallWithKeywords PyCFunctionWithKeywords
847 #endif
848 #if CYTHON_VECTORCALL
849 #define __pyx_vectorcallfunc vectorcallfunc
850 #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET PY_VECTORCALL_ARGUMENTS_OFFSET
851 #define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS((size_t)(n))
852 #elif CYTHON_BACKPORT_VECTORCALL
853 typedef PyObject *(*__pyx_vectorcallfunc)(PyObject *callable, PyObject *const *args,
854 size_t nargsf, PyObject *kwnames);
855 #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET ((size_t)1 << (8 * sizeof(size_t) - 1))
856 #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(((size_t)(n)) & ~__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET))
857 #else
858 #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0
859 #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(n))
860 #endif
861 #if PY_MAJOR_VERSION >= 0x030900B1
862 #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_CheckExact(func)
863 #else
864 #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_Check(func)
865 #endif
866 #define __Pyx_CyOrPyCFunction_Check(func) PyCFunction_Check(func)
867 #if CYTHON_COMPILING_IN_CPYTHON
868 #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) (((PyCFunctionObject*)(func))->m_ml->ml_meth)
869 #elif !CYTHON_COMPILING_IN_LIMITED_API
870 #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(func)
871 #endif
872 #if CYTHON_COMPILING_IN_CPYTHON
873 #define __Pyx_CyOrPyCFunction_GET_FLAGS(func) (((PyCFunctionObject*)(func))->m_ml->ml_flags)
874 static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) {
875 return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self;
876 }
877 #endif
878 static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void *cfunc) {
879 #if CYTHON_COMPILING_IN_LIMITED_API
880 return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
881 #else
882 return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
883 #endif
884 }
885 #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCFunction(func, cfunc)
886 #if __PYX_LIMITED_VERSION_HEX < 0x030900B1
887 #define __Pyx_PyType_FromModuleAndSpec(m, s, b) ((void)m, PyType_FromSpecWithBases(s, b))
888 typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *);
889 #else
890 #define __Pyx_PyType_FromModuleAndSpec(m, s, b) PyType_FromModuleAndSpec(m, s, b)
891 #define __Pyx_PyCMethod PyCMethod
892 #endif
893 #ifndef METH_METHOD
894 #define METH_METHOD 0x200
895 #endif
896 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
897 #define PyObject_Malloc(s) PyMem_Malloc(s)
898 #define PyObject_Free(p) PyMem_Free(p)
899 #define PyObject_Realloc(p) PyMem_Realloc(p)
900 #endif
901 #if CYTHON_COMPILING_IN_LIMITED_API
902 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
903 #define __Pyx_PyFrame_SetLineNumber(frame, lineno)
904 #else
905 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
906 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
907 #endif
908 #if CYTHON_COMPILING_IN_LIMITED_API
909 #define __Pyx_PyThreadState_Current PyThreadState_Get()
910 #elif !CYTHON_FAST_THREAD_STATE
911 #define __Pyx_PyThreadState_Current PyThreadState_GET()
912 #elif PY_VERSION_HEX >= 0x030d00A1
913 #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked()
914 #elif PY_VERSION_HEX >= 0x03060000
915 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
916 #elif PY_VERSION_HEX >= 0x03000000
917 #define __Pyx_PyThreadState_Current PyThreadState_GET()
918 #else
919 #define __Pyx_PyThreadState_Current _PyThreadState_Current
920 #endif
921 #if CYTHON_COMPILING_IN_LIMITED_API
922 static CYTHON_INLINE void *__Pyx_PyModule_GetState(PyObject *op)
923 {
924 void *result;
925 result = PyModule_GetState(op);
926 if (!result)
927 Py_FatalError("Couldn't find the module state");
928 return result;
929 }
930 #endif
931 #define __Pyx_PyObject_GetSlot(obj, name, func_ctype) __Pyx_PyType_GetSlot(Py_TYPE(obj), name, func_ctype)
932 #if CYTHON_COMPILING_IN_LIMITED_API
933 #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((func_ctype) PyType_GetSlot((type), Py_##name))
934 #else
935 #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((type)->name)
936 #endif
937 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
938 #include "pythread.h"
939 #define Py_tss_NEEDS_INIT 0
940 typedef int Py_tss_t;
941 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
942 *key = PyThread_create_key();
943 return 0;
944 }
945 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
946 Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
947 *key = Py_tss_NEEDS_INIT;
948 return key;
949 }
950 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
951 PyObject_Free(key);
952 }
953 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
954 return *key != Py_tss_NEEDS_INIT;
955 }
956 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
957 PyThread_delete_key(*key);
958 *key = Py_tss_NEEDS_INIT;
959 }
960 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
961 return PyThread_set_key_value(*key, value);
962 }
963 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
964 return PyThread_get_key_value(*key);
965 }
966 #endif
967 #if PY_MAJOR_VERSION < 3
968 #if CYTHON_COMPILING_IN_PYPY
969 #if PYPY_VERSION_NUM < 0x07030600
970 #if defined(__cplusplus) && __cplusplus >= 201402L
971 [[deprecated("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6")]]
972 #elif defined(__GNUC__) || defined(__clang__)
973 __attribute__ ((__deprecated__("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6")))
974 #elif defined(_MSC_VER)
975 __declspec(deprecated("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6"))
976 #endif
977 static CYTHON_INLINE int PyGILState_Check(void) {
978 return 0;
979 }
980 #else // PYPY_VERSION_NUM < 0x07030600
981 #endif // PYPY_VERSION_NUM < 0x07030600
982 #else
983 static CYTHON_INLINE int PyGILState_Check(void) {
984 PyThreadState * tstate = _PyThreadState_Current;
985 return tstate && (tstate == PyGILState_GetThisThreadState());
986 }
987 #endif
988 #endif
989 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000 || defined(_PyDict_NewPresized)
990 #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
991 #else
992 #define __Pyx_PyDict_NewPresized(n) PyDict_New()
993 #endif
994 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
995 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
996 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
997 #else
998 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
999 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
1000 #endif
1001 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B4 && PY_VERSION_HEX < 0x030d0000 && CYTHON_USE_UNICODE_INTERNALS
1002 #define __Pyx_PyDict_GetItemStrWithError(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
1003 static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) {
1004 PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name);
1005 if (res == NULL) PyErr_Clear();
1006 return res;
1007 }
1008 #elif PY_MAJOR_VERSION >= 3 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000)
1009 #define __Pyx_PyDict_GetItemStrWithError PyDict_GetItemWithError
1010 #define __Pyx_PyDict_GetItemStr PyDict_GetItem
1011 #else
1012 static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) {
1013 #if CYTHON_COMPILING_IN_PYPY
1014 return PyDict_GetItem(dict, name);
1015 #else
1016 PyDictEntry *ep;
1017 PyDictObject *mp = (PyDictObject*) dict;
1018 long hash = ((PyStringObject *) name)->ob_shash;
1019 assert(hash != -1);
1020 ep = (mp->ma_lookup)(mp, name, hash);
1021 if (ep == NULL) {
1022 return NULL;
1023 }
1024 return ep->me_value;
1025 #endif
1026 }
1027 #define __Pyx_PyDict_GetItemStr PyDict_GetItem
1028 #endif
1029 #if CYTHON_USE_TYPE_SLOTS
1030 #define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags)
1031 #define __Pyx_PyType_HasFeature(type, feature) ((__Pyx_PyType_GetFlags(type) & (feature)) != 0)
1032 #define __Pyx_PyObject_GetIterNextFunc(obj) (Py_TYPE(obj)->tp_iternext)
1033 #else
1034 #define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp))
1035 #define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature)
1036 #define __Pyx_PyObject_GetIterNextFunc(obj) PyIter_Next
1037 #endif
1038 #if CYTHON_COMPILING_IN_LIMITED_API
1039 #define __Pyx_SetItemOnTypeDict(tp, k, v) PyObject_GenericSetAttr((PyObject*)tp, k, v)
1040 #else
1041 #define __Pyx_SetItemOnTypeDict(tp, k, v) PyDict_SetItem(tp->tp_dict, k, v)
1042 #endif
1043 #if CYTHON_USE_TYPE_SPECS && PY_VERSION_HEX >= 0x03080000
1044 #define __Pyx_PyHeapTypeObject_GC_Del(obj) {\
1045 PyTypeObject *type = Py_TYPE((PyObject*)obj);\
1046 assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE));\
1047 PyObject_GC_Del(obj);\
1048 Py_DECREF(type);\
1049 }
1050 #else
1051 #define __Pyx_PyHeapTypeObject_GC_Del(obj) PyObject_GC_Del(obj)
1052 #endif
1053 #if CYTHON_COMPILING_IN_LIMITED_API
1054 #define CYTHON_PEP393_ENABLED 1
1055 #define __Pyx_PyUnicode_READY(op) (0)
1056 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GetLength(u)
1057 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i)
1058 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111U)
1059 #define __Pyx_PyUnicode_KIND(u) ((void)u, (0))
1060 #define __Pyx_PyUnicode_DATA(u) ((void*)u)
1061 #define __Pyx_PyUnicode_READ(k, d, i) ((void)k, PyUnicode_ReadChar((PyObject*)(d), i))
1062 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GetLength(u))
1063 #elif PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
1064 #define CYTHON_PEP393_ENABLED 1
1065 #if PY_VERSION_HEX >= 0x030C0000
1066 #define __Pyx_PyUnicode_READY(op) (0)
1067 #else
1068 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
1069 0 : _PyUnicode_Ready((PyObject *)(op)))
1070 #endif
1071 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
1072 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
1073 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
1074 #define __Pyx_PyUnicode_KIND(u) ((int)PyUnicode_KIND(u))
1075 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
1076 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
1077 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, (Py_UCS4) ch)
1078 #if PY_VERSION_HEX >= 0x030C0000
1079 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
1080 #else
1081 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
1082 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
1083 #else
1084 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
1085 #endif
1086 #endif
1087 #else
1088 #define CYTHON_PEP393_ENABLED 0
1089 #define PyUnicode_1BYTE_KIND 1
1090 #define PyUnicode_2BYTE_KIND 2
1091 #define PyUnicode_4BYTE_KIND 4
1092 #define __Pyx_PyUnicode_READY(op) (0)
1093 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
1094 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
1095 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535U : 1114111U)
1096 #define __Pyx_PyUnicode_KIND(u) ((int)sizeof(Py_UNICODE))
1097 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
1098 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
1099 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = (Py_UNICODE) ch)
1100 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
1101 #endif
1102 #if CYTHON_COMPILING_IN_PYPY
1103 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
1104 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
1105 #else
1106 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
1107 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
1108 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
1109 #endif
1110 #if CYTHON_COMPILING_IN_PYPY
1111 #if !defined(PyUnicode_DecodeUnicodeEscape)
1112 #define PyUnicode_DecodeUnicodeEscape(s, size, errors) PyUnicode_Decode(s, size, "unicode_escape", errors)
1113 #endif
1114 #if !defined(PyUnicode_Contains) || (PY_MAJOR_VERSION == 2 && PYPY_VERSION_NUM < 0x07030500)
1115 #undef PyUnicode_Contains
1116 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
1117 #endif
1118 #if !defined(PyByteArray_Check)
1119 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
1120 #endif
1121 #if !defined(PyObject_Format)
1122 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
1123 #endif
1124 #endif
1125 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
1126 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
1127 #if PY_MAJOR_VERSION >= 3
1128 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
1129 #else
1130 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
1131 #endif
1132 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
1133 #define PyObject_ASCII(o) PyObject_Repr(o)
1134 #endif
1135 #if PY_MAJOR_VERSION >= 3
1136 #define PyBaseString_Type PyUnicode_Type
1137 #define PyStringObject PyUnicodeObject
1138 #define PyString_Type PyUnicode_Type
1139 #define PyString_Check PyUnicode_Check
1140 #define PyString_CheckExact PyUnicode_CheckExact
1141 #ifndef PyObject_Unicode
1142 #define PyObject_Unicode PyObject_Str
1143 #endif
1144 #endif
1145 #if PY_MAJOR_VERSION >= 3
1146 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
1147 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
1148 #else
1149 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
1150 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
1151 #endif
1152 #if CYTHON_COMPILING_IN_CPYTHON
1153 #define __Pyx_PySequence_ListKeepNew(obj)\
1154 (likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj))
1155 #else
1156 #define __Pyx_PySequence_ListKeepNew(obj) PySequence_List(obj)
1157 #endif
1158 #ifndef PySet_CheckExact
1159 #define PySet_CheckExact(obj) __Pyx_IS_TYPE(obj, &PySet_Type)
1160 #endif
1161 #if PY_VERSION_HEX >= 0x030900A4
1162 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
1163 #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
1164 #else
1165 #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
1166 #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
1167 #endif
1168 #if CYTHON_ASSUME_SAFE_MACROS
1169 #define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i)
1170 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
1171 #define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0))
1172 #define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0))
1173 #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o)
1174 #define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o)
1175 #define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o)
1176 #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o)
1177 #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o)
1178 #else
1179 #define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i)
1180 #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
1181 #define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v)
1182 #define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v)
1183 #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o)
1184 #define __Pyx_PyList_GET_SIZE(o) PyList_Size(o)
1185 #define __Pyx_PySet_GET_SIZE(o) PySet_Size(o)
1186 #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o)
1187 #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o)
1188 #endif
1189 #if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1
1190 #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name)
1191 #else
1192 static CYTHON_INLINE PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
1193 PyObject *module = PyImport_AddModule(name);
1194 Py_XINCREF(module);
1195 return module;
1196 }
1197 #endif
1198 #if PY_MAJOR_VERSION >= 3
1199 #define PyIntObject PyLongObject
1200 #define PyInt_Type PyLong_Type
1201 #define PyInt_Check(op) PyLong_Check(op)
1202 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
1203 #define __Pyx_Py3Int_Check(op) PyLong_Check(op)
1204 #define __Pyx_Py3Int_CheckExact(op) PyLong_CheckExact(op)
1205 #define PyInt_FromString PyLong_FromString
1206 #define PyInt_FromUnicode PyLong_FromUnicode
1207 #define PyInt_FromLong PyLong_FromLong
1208 #define PyInt_FromSize_t PyLong_FromSize_t
1209 #define PyInt_FromSsize_t PyLong_FromSsize_t
1210 #define PyInt_AsLong PyLong_AsLong
1211 #define PyInt_AS_LONG PyLong_AS_LONG
1212 #define PyInt_AsSsize_t PyLong_AsSsize_t
1213 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
1214 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
1215 #define PyNumber_Int PyNumber_Long
1216 #else
1217 #define __Pyx_Py3Int_Check(op) (PyLong_Check(op) || PyInt_Check(op))
1218 #define __Pyx_Py3Int_CheckExact(op) (PyLong_CheckExact(op) || PyInt_CheckExact(op))
1219 #endif
1220 #if PY_MAJOR_VERSION >= 3
1221 #define PyBoolObject PyLongObject
1222 #endif
1223 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
1224 #ifndef PyUnicode_InternFromString
1225 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
1226 #endif
1227 #endif
1228 #if PY_VERSION_HEX < 0x030200A4
1229 typedef long Py_hash_t;
1230 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
1231 #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t
1232 #else
1233 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
1234 #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t
1235 #endif
1236 #if CYTHON_USE_ASYNC_SLOTS
1237 #if PY_VERSION_HEX >= 0x030500B1
1238 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
1239 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
1240 #else
1241 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
1242 #endif
1243 #else
1244 #define __Pyx_PyType_AsAsync(obj) NULL
1245 #endif
1246 #ifndef __Pyx_PyAsyncMethodsStruct
1247 typedef struct {
1248 unaryfunc am_await;
1249 unaryfunc am_aiter;
1250 unaryfunc am_anext;
1251 } __Pyx_PyAsyncMethodsStruct;
1252 #endif
1253
1254 #if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)
1255 #if !defined(_USE_MATH_DEFINES)
1256 #define _USE_MATH_DEFINES
1257 #endif
1258 #endif
1259 #include <math.h>
1260 #ifdef NAN
1261 #define __PYX_NAN() ((float) NAN)
1262 #else
1263 static CYTHON_INLINE float __PYX_NAN() {
1264 float value;
1265 memset(&value, 0xFF, sizeof(value));
1266 return value;
1267 }
1268 #endif
1269 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
1270 #define __Pyx_truncl trunc
1271 #else
1272 #define __Pyx_truncl truncl
1273 #endif
1274
1275 #define __PYX_MARK_ERR_POS(f_index, lineno) \
1276 { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
1277 #define __PYX_ERR(f_index, lineno, Ln_error) \
1278 { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
1279
1280 #ifdef CYTHON_EXTERN_C
1281 #undef __PYX_EXTERN_C
1282 #define __PYX_EXTERN_C CYTHON_EXTERN_C
1283 #elif defined(__PYX_EXTERN_C)
1284 #ifdef _MSC_VER
1285 #pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.")
1286 #else
1287 #warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.
1288 #endif
1289 #else
1290 #ifdef __cplusplus
1291 #define __PYX_EXTERN_C extern "C"
1292 #else
1293 #define __PYX_EXTERN_C extern
1294 #endif
1295 #endif
1296
1297 #define __PYX_HAVE__pysam__libcutils
1298 #define __PYX_HAVE_API__pysam__libcutils
1299 /* Early includes */
1300 #include <string.h>
1301 #include <stdio.h>
1302 #include <stddef.h>
1303 #include "pythread.h"
1304
1305 #if CYTHON_COMPILING_IN_PYPY
1306 #ifdef _MSC_VER
1307 #pragma message ("This module uses CPython specific internals of 'array.array', which are not available in PyPy.")
1308 #else
1309 #warning This module uses CPython specific internals of 'array.array', which are not available in PyPy.
1310 #endif
1311 #endif
1312
1313 #include <errno.h>
1314 #include <stdlib.h>
1315 #include <stdint.h>
1316 #include <sys/types.h>
1317 #include <fcntl.h>
1318 #include <unistd.h>
1319 #include "samtools.pysam.h"
1320 #include "bcftools.pysam.h"
1321 #ifdef _OPENMP
1322 #include <omp.h>
1323 #endif /* _OPENMP */
1324
1325 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
1326 #define CYTHON_WITHOUT_ASSERTIONS
1327 #endif
1328
1329 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
1330 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
1331
1332 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
1333 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
1334 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
1335 #define __PYX_DEFAULT_STRING_ENCODING ""
1336 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
1337 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
1338 #define __Pyx_uchar_cast(c) ((unsigned char)c)
1339 #define __Pyx_long_cast(x) ((long)x)
1340 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
1341 (sizeof(type) < sizeof(Py_ssize_t)) ||\
1342 (sizeof(type) > sizeof(Py_ssize_t) &&\
1343 likely(v < (type)PY_SSIZE_T_MAX ||\
1344 v == (type)PY_SSIZE_T_MAX) &&\
1345 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
1346 v == (type)PY_SSIZE_T_MIN))) ||\
1347 (sizeof(type) == sizeof(Py_ssize_t) &&\
1348 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
1349 v == (type)PY_SSIZE_T_MAX))) )
1350 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
1351 return (size_t) i < (size_t) limit;
1352 }
1353 #if defined (__cplusplus) && __cplusplus >= 201103L
1354 #include <cstdlib>
1355 #define __Pyx_sst_abs(value) std::abs(value)
1356 #elif SIZEOF_INT >= SIZEOF_SIZE_T
1357 #define __Pyx_sst_abs(value) abs(value)
1358 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
1359 #define __Pyx_sst_abs(value) labs(value)
1360 #elif defined (_MSC_VER)
1361 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
1362 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
1363 #define __Pyx_sst_abs(value) llabs(value)
1364 #elif defined (__GNUC__)
1365 #define __Pyx_sst_abs(value) __builtin_llabs(value)
1366 #else
1367 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
1368 #endif
1369 static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s);
1370 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
1371 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
1372 static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*);
1373 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
1374 #define __Pyx_PyBytes_FromString PyBytes_FromString
1375 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
1376 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
1377 #if PY_MAJOR_VERSION < 3
1378 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
1379 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
1380 #else
1381 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
1382 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
1383 #endif
1384 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
1385 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
1386 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
1387 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
1388 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
1389 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
1390 #define __Pyx_PyObject_AsWritableString(s) ((char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
1391 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
1392 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
1393 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
1394 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
1395 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
1396 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
1397 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
1398 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
1399 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
1400 #define __Pyx_PyUnicode_FromOrdinal(o) PyUnicode_FromOrdinal((int)o)
1401 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
1402 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
1403 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
1404 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
1405 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
1406 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
1407 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
1408 #define __Pyx_PySequence_Tuple(obj)\
1409 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
1410 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
1411 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
1412 static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
1413 #if CYTHON_ASSUME_SAFE_MACROS
1414 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
1415 #else
1416 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
1417 #endif
1418 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
1419 #if PY_MAJOR_VERSION >= 3
1420 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
1421 #else
1422 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
1423 #endif
1424 #if CYTHON_USE_PYLONG_INTERNALS
1425 #if PY_VERSION_HEX >= 0x030C00A7
1426 #ifndef _PyLong_SIGN_MASK
1427 #define _PyLong_SIGN_MASK 3
1428 #endif
1429 #ifndef _PyLong_NON_SIZE_BITS
1430 #define _PyLong_NON_SIZE_BITS 3
1431 #endif
1432 #define __Pyx_PyLong_Sign(x) (((PyLongObject*)x)->long_value.lv_tag & _PyLong_SIGN_MASK)
1433 #define __Pyx_PyLong_IsNeg(x) ((__Pyx_PyLong_Sign(x) & 2) != 0)
1434 #define __Pyx_PyLong_IsNonNeg(x) (!__Pyx_PyLong_IsNeg(x))
1435 #define __Pyx_PyLong_IsZero(x) (__Pyx_PyLong_Sign(x) & 1)
1436 #define __Pyx_PyLong_IsPos(x) (__Pyx_PyLong_Sign(x) == 0)
1437 #define __Pyx_PyLong_CompactValueUnsigned(x) (__Pyx_PyLong_Digits(x)[0])
1438 #define __Pyx_PyLong_DigitCount(x) ((Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag >> _PyLong_NON_SIZE_BITS))
1439 #define __Pyx_PyLong_SignedDigitCount(x)\
1440 ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * __Pyx_PyLong_DigitCount(x))
1441 #if defined(PyUnstable_Long_IsCompact) && defined(PyUnstable_Long_CompactValue)
1442 #define __Pyx_PyLong_IsCompact(x) PyUnstable_Long_IsCompact((PyLongObject*) x)
1443 #define __Pyx_PyLong_CompactValue(x) PyUnstable_Long_CompactValue((PyLongObject*) x)
1444 #else
1445 #define __Pyx_PyLong_IsCompact(x) (((PyLongObject*)x)->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS))
1446 #define __Pyx_PyLong_CompactValue(x) ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0])
1447 #endif
1448 typedef Py_ssize_t __Pyx_compact_pylong;
1449 typedef size_t __Pyx_compact_upylong;
1450 #else
1451 #define __Pyx_PyLong_IsNeg(x) (Py_SIZE(x) < 0)
1452 #define __Pyx_PyLong_IsNonNeg(x) (Py_SIZE(x) >= 0)
1453 #define __Pyx_PyLong_IsZero(x) (Py_SIZE(x) == 0)
1454 #define __Pyx_PyLong_IsPos(x) (Py_SIZE(x) > 0)
1455 #define __Pyx_PyLong_CompactValueUnsigned(x) ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0])
1456 #define __Pyx_PyLong_DigitCount(x) __Pyx_sst_abs(Py_SIZE(x))
1457 #define __Pyx_PyLong_SignedDigitCount(x) Py_SIZE(x)
1458 #define __Pyx_PyLong_IsCompact(x) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1)
1459 #define __Pyx_PyLong_CompactValue(x)\
1460 ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0]))
1461 typedef sdigit __Pyx_compact_pylong;
1462 typedef digit __Pyx_compact_upylong;
1463 #endif
1464 #if PY_VERSION_HEX >= 0x030C00A5
1465 #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->long_value.ob_digit)
1466 #else
1467 #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->ob_digit)
1468 #endif
1469 #endif
1470 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
1471 #include <string.h>
1472 static int __Pyx_sys_getdefaultencoding_not_ascii;
1473 static int __Pyx_init_sys_getdefaultencoding_params(void) {
1474 PyObject* sys;
1475 PyObject* default_encoding = NULL;
1476 PyObject* ascii_chars_u = NULL;
1477 PyObject* ascii_chars_b = NULL;
1478 const char* default_encoding_c;
1479 sys = PyImport_ImportModule("sys");
1480 if (!sys) goto bad;
1481 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
1482 Py_DECREF(sys);
1483 if (!default_encoding) goto bad;
1484 default_encoding_c = PyBytes_AsString(default_encoding);
1485 if (!default_encoding_c) goto bad;
1486 if (strcmp(default_encoding_c, "ascii") == 0) {
1487 __Pyx_sys_getdefaultencoding_not_ascii = 0;
1488 } else {
1489 char ascii_chars[128];
1490 int c;
1491 for (c = 0; c < 128; c++) {
1492 ascii_chars[c] = (char) c;
1493 }
1494 __Pyx_sys_getdefaultencoding_not_ascii = 1;
1495 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
1496 if (!ascii_chars_u) goto bad;
1497 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
1498 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
1499 PyErr_Format(
1500 PyExc_ValueError,
1501 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
1502 default_encoding_c);
1503 goto bad;
1504 }
1505 Py_DECREF(ascii_chars_u);
1506 Py_DECREF(ascii_chars_b);
1507 }
1508 Py_DECREF(default_encoding);
1509 return 0;
1510 bad:
1511 Py_XDECREF(default_encoding);
1512 Py_XDECREF(ascii_chars_u);
1513 Py_XDECREF(ascii_chars_b);
1514 return -1;
1515 }
1516 #endif
1517 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
1518 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
1519 #else
1520 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
1521 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
1522 #include <string.h>
1523 static char* __PYX_DEFAULT_STRING_ENCODING;
1524 static int __Pyx_init_sys_getdefaultencoding_params(void) {
1525 PyObject* sys;
1526 PyObject* default_encoding = NULL;
1527 char* default_encoding_c;
1528 sys = PyImport_ImportModule("sys");
1529 if (!sys) goto bad;
1530 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
1531 Py_DECREF(sys);
1532 if (!default_encoding) goto bad;
1533 default_encoding_c = PyBytes_AsString(default_encoding);
1534 if (!default_encoding_c) goto bad;
1535 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
1536 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
1537 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
1538 Py_DECREF(default_encoding);
1539 return 0;
1540 bad:
1541 Py_XDECREF(default_encoding);
1542 return -1;
1543 }
1544 #endif
1545 #endif
1546
1547
1548 /* Test for GCC > 2.95 */
1549 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
1550 #define likely(x) __builtin_expect(!!(x), 1)
1551 #define unlikely(x) __builtin_expect(!!(x), 0)
1552 #else /* !__GNUC__ or GCC < 2.95 */
1553 #define likely(x) (x)
1554 #define unlikely(x) (x)
1555 #endif /* __GNUC__ */
1556 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
1557
1558 #if !CYTHON_USE_MODULE_STATE
1559 static PyObject *__pyx_m = NULL;
1560 #endif
1561 static int __pyx_lineno;
1562 static int __pyx_clineno = 0;
1563 static const char * __pyx_cfilenm = __FILE__;
1564 static const char *__pyx_filename;
1565
1566 /* #### Code section: filename_table ### */
1567
1568 static const char *__pyx_f[] = {
1569 "pysam/libcutils.pyx",
1570 "contextvars.pxd",
1571 "array.pxd",
1572 "type.pxd",
1573 "bool.pxd",
1574 "complex.pxd",
1575 };
1576 /* #### Code section: utility_code_proto_before_types ### */
1577 /* ForceInitThreads.proto */
1578 #ifndef __PYX_FORCE_INIT_THREADS
1579 #define __PYX_FORCE_INIT_THREADS 0
1580 #endif
1581
1582 /* #### Code section: numeric_typedefs ### */
1583 /* #### Code section: complex_type_declarations ### */
1584 /* #### Code section: type_declarations ### */
1585
1586 /*--- Type declarations ---*/
1587 #ifndef _ARRAYARRAY_H
1588 struct arrayobject;
1589 typedef struct arrayobject arrayobject;
1590 #endif
1591 struct __pyx_opt_args_7cpython_11contextvars_get_value;
1592 struct __pyx_opt_args_7cpython_11contextvars_get_value_no_default;
1593
1594 /* "cpython/contextvars.pxd":112
1595 *
1596 *
1597 * cdef inline object get_value(var, default_value=None): # <<<<<<<<<<<<<<
1598 * """Return a new reference to the value of the context variable,
1599 * or the default value of the context variable,
1600 */
1601 struct __pyx_opt_args_7cpython_11contextvars_get_value {
1602 int __pyx_n;
1603 PyObject *default_value;
1604 };
1605
1606 /* "cpython/contextvars.pxd":129
1607 *
1608 *
1609 * cdef inline object get_value_no_default(var, default_value=None): # <<<<<<<<<<<<<<
1610 * """Return a new reference to the value of the context variable,
1611 * or the provided default value if no such value was found.
1612 */
1613 struct __pyx_opt_args_7cpython_11contextvars_get_value_no_default {
1614 int __pyx_n;
1615 PyObject *default_value;
1616 };
1617 struct __pyx_opt_args_5pysam_9libcutils_parse_region;
1618 struct __pyx_opt_args_5pysam_9libcutils_qualitystring_to_array;
1619 struct __pyx_opt_args_5pysam_9libcutils_array_to_qualitystring;
1620 struct __pyx_opt_args_5pysam_9libcutils_qualities_to_qualitystring;
1621 struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str;
1622 struct __pyx_opt_args_5pysam_9libcutils_charptr_to_bytes;
1623 struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str_w_len;
1624 struct __pyx_opt_args_5pysam_9libcutils_force_str;
1625 struct __pyx_opt_args_5pysam_9libcutils_force_bytes;
1626 struct __pyx_opt_args_5pysam_9libcutils_decode_bytes;
1627
1628 /* "pysam/libcutils.pxd":8
1629 * from cpython cimport array as c_array
1630 *
1631 * cpdef parse_region(contig=*, start=*, stop=*, region=*, reference=*, end=*) # <<<<<<<<<<<<<<
1632 *
1633 * cdef int libc_whence_from_io(int whence)
1634 */
1635 struct __pyx_opt_args_5pysam_9libcutils_parse_region {
1636 int __pyx_n;
1637 PyObject *contig;
1638 PyObject *start;
1639 PyObject *stop;
1640 PyObject *region;
1641 PyObject *reference;
1642 PyObject *end;
1643 };
1644
1645 /* "pysam/libcutils.pxd":15
1646 * # Utility functions for quality string conversions
1647 *
1648 * cpdef c_array.array qualitystring_to_array(input_str, int offset=*) # <<<<<<<<<<<<<<
1649 * cpdef array_to_qualitystring(c_array.array arr, int offset=*)
1650 * cpdef qualities_to_qualitystring(qualities, int offset=*)
1651 */
1652 struct __pyx_opt_args_5pysam_9libcutils_qualitystring_to_array {
1653 int __pyx_n;
1654 int offset;
1655 };
1656
1657 /* "pysam/libcutils.pxd":16
1658 *
1659 * cpdef c_array.array qualitystring_to_array(input_str, int offset=*)
1660 * cpdef array_to_qualitystring(c_array.array arr, int offset=*) # <<<<<<<<<<<<<<
1661 * cpdef qualities_to_qualitystring(qualities, int offset=*)
1662 *
1663 */
1664 struct __pyx_opt_args_5pysam_9libcutils_array_to_qualitystring {
1665 int __pyx_n;
1666 int offset;
1667 };
1668
1669 /* "pysam/libcutils.pxd":17
1670 * cpdef c_array.array qualitystring_to_array(input_str, int offset=*)
1671 * cpdef array_to_qualitystring(c_array.array arr, int offset=*)
1672 * cpdef qualities_to_qualitystring(qualities, int offset=*) # <<<<<<<<<<<<<<
1673 *
1674 * ########################################################################
1675 */
1676 struct __pyx_opt_args_5pysam_9libcutils_qualities_to_qualitystring {
1677 int __pyx_n;
1678 int offset;
1679 };
1680
1681 /* "pysam/libcutils.pxd":29
1682 * ## Python 3 compatibility functions
1683 * ########################################################################
1684 * cdef charptr_to_str(const char *s, encoding=*, errors=*) # <<<<<<<<<<<<<<
1685 * cdef bytes charptr_to_bytes(const char *s, encoding=*, errors=*)
1686 * cdef charptr_to_str_w_len(const char* s, size_t n, encoding=*, errors=*)
1687 */
1688 struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str {
1689 int __pyx_n;
1690 PyObject *encoding;
1691 PyObject *errors;
1692 };
1693
1694 /* "pysam/libcutils.pxd":30
1695 * ########################################################################
1696 * cdef charptr_to_str(const char *s, encoding=*, errors=*)
1697 * cdef bytes charptr_to_bytes(const char *s, encoding=*, errors=*) # <<<<<<<<<<<<<<
1698 * cdef charptr_to_str_w_len(const char* s, size_t n, encoding=*, errors=*)
1699 * cdef force_str(object s, encoding=*, errors=*)
1700 */
1701 struct __pyx_opt_args_5pysam_9libcutils_charptr_to_bytes {
1702 int __pyx_n;
1703 PyObject *encoding;
1704 PyObject *errors;
1705 };
1706
1707 /* "pysam/libcutils.pxd":31
1708 * cdef charptr_to_str(const char *s, encoding=*, errors=*)
1709 * cdef bytes charptr_to_bytes(const char *s, encoding=*, errors=*)
1710 * cdef charptr_to_str_w_len(const char* s, size_t n, encoding=*, errors=*) # <<<<<<<<<<<<<<
1711 * cdef force_str(object s, encoding=*, errors=*)
1712 * cdef bytes force_bytes(object s, encoding=*, errors=*)
1713 */
1714 struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str_w_len {
1715 int __pyx_n;
1716 PyObject *encoding;
1717 PyObject *errors;
1718 };
1719
1720 /* "pysam/libcutils.pxd":32
1721 * cdef bytes charptr_to_bytes(const char *s, encoding=*, errors=*)
1722 * cdef charptr_to_str_w_len(const char* s, size_t n, encoding=*, errors=*)
1723 * cdef force_str(object s, encoding=*, errors=*) # <<<<<<<<<<<<<<
1724 * cdef bytes force_bytes(object s, encoding=*, errors=*)
1725 * cdef decode_bytes(bytes s, encoding=*, errors=*)
1726 */
1727 struct __pyx_opt_args_5pysam_9libcutils_force_str {
1728 int __pyx_n;
1729 PyObject *encoding;
1730 PyObject *errors;
1731 };
1732
1733 /* "pysam/libcutils.pxd":33
1734 * cdef charptr_to_str_w_len(const char* s, size_t n, encoding=*, errors=*)
1735 * cdef force_str(object s, encoding=*, errors=*)
1736 * cdef bytes force_bytes(object s, encoding=*, errors=*) # <<<<<<<<<<<<<<
1737 * cdef decode_bytes(bytes s, encoding=*, errors=*)
1738 * cdef bytes encode_filename(object filename)
1739 */
1740 struct __pyx_opt_args_5pysam_9libcutils_force_bytes {
1741 int __pyx_n;
1742 PyObject *encoding;
1743 PyObject *errors;
1744 };
1745
1746 /* "pysam/libcutils.pxd":34
1747 * cdef force_str(object s, encoding=*, errors=*)
1748 * cdef bytes force_bytes(object s, encoding=*, errors=*)
1749 * cdef decode_bytes(bytes s, encoding=*, errors=*) # <<<<<<<<<<<<<<
1750 * cdef bytes encode_filename(object filename)
1751 * cdef from_string_and_size(const char *s, size_t length)
1752 */
1753 struct __pyx_opt_args_5pysam_9libcutils_decode_bytes {
1754 int __pyx_n;
1755 PyObject *encoding;
1756 PyObject *errors;
1757 };
1758 /* #### Code section: utility_code_proto ### */
1759
1760 /* --- Runtime support code (head) --- */
1761 /* Refnanny.proto */
1762 #ifndef CYTHON_REFNANNY
1763 #define CYTHON_REFNANNY 0
1764 #endif
1765 #if CYTHON_REFNANNY
1766 typedef struct {
1767 void (*INCREF)(void*, PyObject*, Py_ssize_t);
1768 void (*DECREF)(void*, PyObject*, Py_ssize_t);
1769 void (*GOTREF)(void*, PyObject*, Py_ssize_t);
1770 void (*GIVEREF)(void*, PyObject*, Py_ssize_t);
1771 void* (*SetupContext)(const char*, Py_ssize_t, const char*);
1772 void (*FinishContext)(void**);
1773 } __Pyx_RefNannyAPIStruct;
1774 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
1775 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
1776 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
1777 #ifdef WITH_THREAD
1778 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1779 if (acquire_gil) {\
1780 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1781 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\
1782 PyGILState_Release(__pyx_gilstate_save);\
1783 } else {\
1784 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\
1785 }
1786 #define __Pyx_RefNannyFinishContextNogil() {\
1787 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1788 __Pyx_RefNannyFinishContext();\
1789 PyGILState_Release(__pyx_gilstate_save);\
1790 }
1791 #else
1792 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1793 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__))
1794 #define __Pyx_RefNannyFinishContextNogil() __Pyx_RefNannyFinishContext()
1795 #endif
1796 #define __Pyx_RefNannyFinishContextNogil() {\
1797 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1798 __Pyx_RefNannyFinishContext();\
1799 PyGILState_Release(__pyx_gilstate_save);\
1800 }
1801 #define __Pyx_RefNannyFinishContext()\
1802 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
1803 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
1804 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
1805 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
1806 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
1807 #define __Pyx_XINCREF(r) do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0)
1808 #define __Pyx_XDECREF(r) do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0)
1809 #define __Pyx_XGOTREF(r) do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0)
1810 #define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0)
1811 #else
1812 #define __Pyx_RefNannyDeclarations
1813 #define __Pyx_RefNannySetupContext(name, acquire_gil)
1814 #define __Pyx_RefNannyFinishContextNogil()
1815 #define __Pyx_RefNannyFinishContext()
1816 #define __Pyx_INCREF(r) Py_INCREF(r)
1817 #define __Pyx_DECREF(r) Py_DECREF(r)
1818 #define __Pyx_GOTREF(r)
1819 #define __Pyx_GIVEREF(r)
1820 #define __Pyx_XINCREF(r) Py_XINCREF(r)
1821 #define __Pyx_XDECREF(r) Py_XDECREF(r)
1822 #define __Pyx_XGOTREF(r)
1823 #define __Pyx_XGIVEREF(r)
1824 #endif
1825 #define __Pyx_Py_XDECREF_SET(r, v) do {\
1826 PyObject *tmp = (PyObject *) r;\
1827 r = v; Py_XDECREF(tmp);\
1828 } while (0)
1829 #define __Pyx_XDECREF_SET(r, v) do {\
1830 PyObject *tmp = (PyObject *) r;\
1831 r = v; __Pyx_XDECREF(tmp);\
1832 } while (0)
1833 #define __Pyx_DECREF_SET(r, v) do {\
1834 PyObject *tmp = (PyObject *) r;\
1835 r = v; __Pyx_DECREF(tmp);\
1836 } while (0)
1837 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1838 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1839
1840 /* PyErrExceptionMatches.proto */
1841 #if CYTHON_FAST_THREAD_STATE
1842 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1843 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1844 #else
1845 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1846 #endif
1847
1848 /* PyThreadStateGet.proto */
1849 #if CYTHON_FAST_THREAD_STATE
1850 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1851 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1852 #if PY_VERSION_HEX >= 0x030C00A6
1853 #define __Pyx_PyErr_Occurred() (__pyx_tstate->current_exception != NULL)
1854 #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->current_exception ? (PyObject*) Py_TYPE(__pyx_tstate->current_exception) : (PyObject*) NULL)
1855 #else
1856 #define __Pyx_PyErr_Occurred() (__pyx_tstate->curexc_type != NULL)
1857 #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->curexc_type)
1858 #endif
1859 #else
1860 #define __Pyx_PyThreadState_declare
1861 #define __Pyx_PyThreadState_assign
1862 #define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL)
1863 #define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred()
1864 #endif
1865
1866 /* PyErrFetchRestore.proto */
1867 #if CYTHON_FAST_THREAD_STATE
1868 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1869 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1870 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1871 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1872 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1873 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1874 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1875 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6
1876 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1877 #else
1878 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1879 #endif
1880 #else
1881 #define __Pyx_PyErr_Clear() PyErr_Clear()
1882 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1883 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1884 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1885 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1886 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1887 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1888 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1889 #endif
1890
1891 /* PyObjectGetAttrStr.proto */
1892 #if CYTHON_USE_TYPE_SLOTS
1893 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
1894 #else
1895 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1896 #endif
1897
1898 /* PyObjectGetAttrStrNoError.proto */
1899 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1900
1901 /* GetBuiltinName.proto */
1902 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1903
1904 /* TupleAndListFromArray.proto */
1905 #if CYTHON_COMPILING_IN_CPYTHON
1906 static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n);
1907 static CYTHON_INLINE PyObject* __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n);
1908 #endif
1909
1910 /* IncludeStringH.proto */
1911 #include <string.h>
1912
1913 /* BytesEquals.proto */
1914 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
1915
1916 /* UnicodeEquals.proto */
1917 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
1918
1919 /* fastcall.proto */
1920 #if CYTHON_AVOID_BORROWED_REFS
1921 #define __Pyx_Arg_VARARGS(args, i) PySequence_GetItem(args, i)
1922 #elif CYTHON_ASSUME_SAFE_MACROS
1923 #define __Pyx_Arg_VARARGS(args, i) PyTuple_GET_ITEM(args, i)
1924 #else
1925 #define __Pyx_Arg_VARARGS(args, i) PyTuple_GetItem(args, i)
1926 #endif
1927 #if CYTHON_AVOID_BORROWED_REFS
1928 #define __Pyx_Arg_NewRef_VARARGS(arg) __Pyx_NewRef(arg)
1929 #define __Pyx_Arg_XDECREF_VARARGS(arg) Py_XDECREF(arg)
1930 #else
1931 #define __Pyx_Arg_NewRef_VARARGS(arg) arg
1932 #define __Pyx_Arg_XDECREF_VARARGS(arg)
1933 #endif
1934 #define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds)
1935 #define __Pyx_KwValues_VARARGS(args, nargs) NULL
1936 #define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s)
1937 #define __Pyx_KwargsAsDict_VARARGS(kw, kwvalues) PyDict_Copy(kw)
1938 #if CYTHON_METH_FASTCALL
1939 #define __Pyx_Arg_FASTCALL(args, i) args[i]
1940 #define __Pyx_NumKwargs_FASTCALL(kwds) PyTuple_GET_SIZE(kwds)
1941 #define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs))
1942 static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s);
1943 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
1944 CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues);
1945 #else
1946 #define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw)
1947 #endif
1948 #define __Pyx_Arg_NewRef_FASTCALL(arg) arg /* no-op, __Pyx_Arg_FASTCALL is direct and this needs
1949 to have the same reference counting */
1950 #define __Pyx_Arg_XDECREF_FASTCALL(arg)
1951 #else
1952 #define __Pyx_Arg_FASTCALL __Pyx_Arg_VARARGS
1953 #define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS
1954 #define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS
1955 #define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS
1956 #define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS
1957 #define __Pyx_Arg_NewRef_FASTCALL(arg) __Pyx_Arg_NewRef_VARARGS(arg)
1958 #define __Pyx_Arg_XDECREF_FASTCALL(arg) __Pyx_Arg_XDECREF_VARARGS(arg)
1959 #endif
1960 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1961 #define __Pyx_ArgsSlice_VARARGS(args, start, stop) __Pyx_PyTuple_FromArray(&__Pyx_Arg_VARARGS(args, start), stop - start)
1962 #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(&__Pyx_Arg_FASTCALL(args, start), stop - start)
1963 #else
1964 #define __Pyx_ArgsSlice_VARARGS(args, start, stop) PyTuple_GetSlice(args, start, stop)
1965 #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) PyTuple_GetSlice(args, start, stop)
1966 #endif
1967
1968 /* ListCompAppend.proto */
1969 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
1970 static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
1971 PyListObject* L = (PyListObject*) list;
1972 Py_ssize_t len = Py_SIZE(list);
1973 if (likely(L->allocated > len)) {
1974 Py_INCREF(x);
1975 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
1976 L->ob_item[len] = x;
1977 #else
1978 PyList_SET_ITEM(list, len, x);
1979 #endif
1980 __Pyx_SET_SIZE(list, len + 1);
1981 return 0;
1982 }
1983 return PyList_Append(list, x);
1984 }
1985 #else
1986 #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
1987 #endif
1988
1989 /* PyObjectCall.proto */
1990 #if CYTHON_COMPILING_IN_CPYTHON
1991 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1992 #else
1993 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1994 #endif
1995
1996 /* RaiseDoubleKeywords.proto */
1997 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1998
1999 /* ParseKeywords.proto */
2000 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject *const *kwvalues,
2001 PyObject **argnames[],
2002 PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,
2003 const char* function_name);
2004
2005 /* RaiseArgTupleInvalid.proto */
2006 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
2007 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
2008
2009 /* GetItemInt.proto */
2010 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
2011 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
2012 __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
2013 (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
2014 __Pyx_GetItemInt_Generic(o, to_py_func(i))))
2015 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
2016 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
2017 __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
2018 (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
2019 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
2020 int wraparound, int boundscheck);
2021 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
2022 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
2023 __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
2024 (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
2025 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
2026 int wraparound, int boundscheck);
2027 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
2028 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
2029 int is_list, int wraparound, int boundscheck);
2030
2031 /* SetItemInt.proto */
2032 #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
2033 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
2034 __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
2035 (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
2036 __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
2037 static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
2038 static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
2039 int is_list, int wraparound, int boundscheck);
2040
2041 /* PyFunctionFastCall.proto */
2042 #if CYTHON_FAST_PYCALL
2043 #if !CYTHON_VECTORCALL
2044 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
2045 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
2046 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
2047 #endif
2048 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
2049 (sizeof(char [1 - 2*!(cond)]) - 1)
2050 #ifndef Py_MEMBER_SIZE
2051 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
2052 #endif
2053 #if !CYTHON_VECTORCALL
2054 #if PY_VERSION_HEX >= 0x03080000
2055 #include "frameobject.h"
2056 #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API
2057 #ifndef Py_BUILD_CORE
2058 #define Py_BUILD_CORE 1
2059 #endif
2060 #include "internal/pycore_frame.h"
2061 #endif
2062 #define __Pxy_PyFrame_Initialize_Offsets()
2063 #define __Pyx_PyFrame_GetLocalsplus(frame) ((frame)->f_localsplus)
2064 #else
2065 static size_t __pyx_pyframe_localsplus_offset = 0;
2066 #include "frameobject.h"
2067 #define __Pxy_PyFrame_Initialize_Offsets()\
2068 ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
2069 (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
2070 #define __Pyx_PyFrame_GetLocalsplus(frame)\
2071 (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
2072 #endif
2073 #endif
2074 #endif
2075
2076 /* PyObjectCallMethO.proto */
2077 #if CYTHON_COMPILING_IN_CPYTHON
2078 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
2079 #endif
2080
2081 /* PyObjectFastCall.proto */
2082 #define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL)
2083 static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject **args, size_t nargs, PyObject *kwargs);
2084
2085 /* ArgTypeTest.proto */
2086 #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
2087 ((likely(__Pyx_IS_TYPE(obj, type) | (none_allowed && (obj == Py_None)))) ? 1 :\
2088 __Pyx__ArgTypeTest(obj, type, name, exact))
2089 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
2090
2091 /* ExtTypeTest.proto */
2092 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
2093
2094 /* PyObjectCallOneArg.proto */
2095 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
2096
2097 /* ObjectGetItem.proto */
2098 #if CYTHON_USE_TYPE_SLOTS
2099 static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key);
2100 #else
2101 #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
2102 #endif
2103
2104 /* RaiseUnexpectedTypeError.proto */
2105 static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj);
2106
2107 /* PyDictVersioning.proto */
2108 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
2109 #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
2110 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
2111 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
2112 (version_var) = __PYX_GET_DICT_VERSION(dict);\
2113 (cache_var) = (value);
2114 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
2115 static PY_UINT64_T __pyx_dict_version = 0;\
2116 static PyObject *__pyx_dict_cached_value = NULL;\
2117 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
2118 (VAR) = __pyx_dict_cached_value;\
2119 } else {\
2120 (VAR) = __pyx_dict_cached_value = (LOOKUP);\
2121 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
2122 }\
2123 }
2124 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
2125 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
2126 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
2127 #else
2128 #define __PYX_GET_DICT_VERSION(dict) (0)
2129 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
2130 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
2131 #endif
2132
2133 /* GetModuleGlobalName.proto */
2134 #if CYTHON_USE_DICT_VERSIONS
2135 #define __Pyx_GetModuleGlobalName(var, name) do {\
2136 static PY_UINT64_T __pyx_dict_version = 0;\
2137 static PyObject *__pyx_dict_cached_value = NULL;\
2138 (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
2139 (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
2140 __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
2141 } while(0)
2142 #define __Pyx_GetModuleGlobalNameUncached(var, name) do {\
2143 PY_UINT64_T __pyx_dict_version;\
2144 PyObject *__pyx_dict_cached_value;\
2145 (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
2146 } while(0)
2147 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
2148 #else
2149 #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
2150 #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
2151 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
2152 #endif
2153
2154 /* RaiseException.proto */
2155 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
2156
2157 /* GetTopmostException.proto */
2158 #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
2159 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
2160 #endif
2161
2162 /* SaveResetException.proto */
2163 #if CYTHON_FAST_THREAD_STATE
2164 #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
2165 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
2166 #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
2167 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
2168 #else
2169 #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
2170 #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
2171 #endif
2172
2173 /* GetException.proto */
2174 #if CYTHON_FAST_THREAD_STATE
2175 #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
2176 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
2177 #else
2178 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
2179 #endif
2180
2181 /* PySequenceContains.proto */
2182 static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
2183 int result = PySequence_Contains(seq, item);
2184 return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
2185 }
2186
2187 /* RaiseTooManyValuesToUnpack.proto */
2188 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
2189
2190 /* RaiseNeedMoreValuesToUnpack.proto */
2191 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
2192
2193 /* IterFinish.proto */
2194 static CYTHON_INLINE int __Pyx_IterFinish(void);
2195
2196 /* UnpackItemEndCheck.proto */
2197 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
2198
2199 /* PyIntBinop.proto */
2200 #if !CYTHON_COMPILING_IN_PYPY
2201 static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
2202 #else
2203 #define __Pyx_PyInt_SubtractObjC(op1, op2, intval, inplace, zerodivision_check)\
2204 (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
2205 #endif
2206
2207 /* PyObjectLookupSpecial.proto */
2208 #if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
2209 #define __Pyx_PyObject_LookupSpecialNoError(obj, attr_name) __Pyx__PyObject_LookupSpecial(obj, attr_name, 0)
2210 #define __Pyx_PyObject_LookupSpecial(obj, attr_name) __Pyx__PyObject_LookupSpecial(obj, attr_name, 1)
2211 static CYTHON_INLINE PyObject* __Pyx__PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name, int with_error);
2212 #else
2213 #define __Pyx_PyObject_LookupSpecialNoError(o,n) __Pyx_PyObject_GetAttrStrNoError(o,n)
2214 #define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
2215 #endif
2216
2217 /* SwapException.proto */
2218 #if CYTHON_FAST_THREAD_STATE
2219 #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
2220 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
2221 #else
2222 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
2223 #endif
2224
2225 /* PyIntCompare.proto */
2226 static CYTHON_INLINE int __Pyx_PyInt_BoolEqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);
2227
2228 /* DictGetItem.proto */
2229 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
2230 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
2231 #define __Pyx_PyObject_Dict_GetItem(obj, name)\
2232 (likely(PyDict_CheckExact(obj)) ?\
2233 __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
2234 #else
2235 #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
2236 #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name)
2237 #endif
2238
2239 /* IncludeStructmemberH.proto */
2240 #include <structmember.h>
2241
2242 /* FixUpExtensionType.proto */
2243 #if CYTHON_USE_TYPE_SPECS
2244 static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type);
2245 #endif
2246
2247 /* FetchSharedCythonModule.proto */
2248 static PyObject *__Pyx_FetchSharedCythonABIModule(void);
2249
2250 /* FetchCommonType.proto */
2251 #if !CYTHON_USE_TYPE_SPECS
2252 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
2253 #else
2254 static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyObject *module, PyType_Spec *spec, PyObject *bases);
2255 #endif
2256
2257 /* PyMethodNew.proto */
2258 #if CYTHON_COMPILING_IN_LIMITED_API
2259 static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) {
2260 PyObject *typesModule=NULL, *methodType=NULL, *result=NULL;
2261 CYTHON_UNUSED_VAR(typ);
2262 if (!self)
2263 return __Pyx_NewRef(func);
2264 typesModule = PyImport_ImportModule("types");
2265 if (!typesModule) return NULL;
2266 methodType = PyObject_GetAttrString(typesModule, "MethodType");
2267 Py_DECREF(typesModule);
2268 if (!methodType) return NULL;
2269 result = PyObject_CallFunctionObjArgs(methodType, func, self, NULL);
2270 Py_DECREF(methodType);
2271 return result;
2272 }
2273 #elif PY_MAJOR_VERSION >= 3
2274 static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) {
2275 CYTHON_UNUSED_VAR(typ);
2276 if (!self)
2277 return __Pyx_NewRef(func);
2278 return PyMethod_New(func, self);
2279 }
2280 #else
2281 #define __Pyx_PyMethod_New PyMethod_New
2282 #endif
2283
2284 /* PyVectorcallFastCallDict.proto */
2285 #if CYTHON_METH_FASTCALL
2286 static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw);
2287 #endif
2288
2289 /* CythonFunctionShared.proto */
2290 #define __Pyx_CyFunction_USED
2291 #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
2292 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
2293 #define __Pyx_CYFUNCTION_CCLASS 0x04
2294 #define __Pyx_CYFUNCTION_COROUTINE 0x08
2295 #define __Pyx_CyFunction_GetClosure(f)\
2296 (((__pyx_CyFunctionObject *) (f))->func_closure)
2297 #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
2298 #define __Pyx_CyFunction_GetClassObj(f)\
2299 (((__pyx_CyFunctionObject *) (f))->func_classobj)
2300 #else
2301 #define __Pyx_CyFunction_GetClassObj(f)\
2302 ((PyObject*) ((PyCMethodObject *) (f))->mm_class)
2303 #endif
2304 #define __Pyx_CyFunction_SetClassObj(f, classobj)\
2305 __Pyx__CyFunction_SetClassObj((__pyx_CyFunctionObject *) (f), (classobj))
2306 #define __Pyx_CyFunction_Defaults(type, f)\
2307 ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
2308 #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
2309 ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
2310 typedef struct {
2311 #if CYTHON_COMPILING_IN_LIMITED_API
2312 PyObject_HEAD
2313 PyObject *func;
2314 #elif PY_VERSION_HEX < 0x030900B1
2315 PyCFunctionObject func;
2316 #else
2317 PyCMethodObject func;
2318 #endif
2319 #if CYTHON_BACKPORT_VECTORCALL
2320 __pyx_vectorcallfunc func_vectorcall;
2321 #endif
2322 #if PY_VERSION_HEX < 0x030500A0 || CYTHON_COMPILING_IN_LIMITED_API
2323 PyObject *func_weakreflist;
2324 #endif
2325 PyObject *func_dict;
2326 PyObject *func_name;
2327 PyObject *func_qualname;
2328 PyObject *func_doc;
2329 PyObject *func_globals;
2330 PyObject *func_code;
2331 PyObject *func_closure;
2332 #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
2333 PyObject *func_classobj;
2334 #endif
2335 void *defaults;
2336 int defaults_pyobjects;
2337 size_t defaults_size;
2338 int flags;
2339 PyObject *defaults_tuple;
2340 PyObject *defaults_kwdict;
2341 PyObject *(*defaults_getter)(PyObject *);
2342 PyObject *func_annotations;
2343 PyObject *func_is_coroutine;
2344 } __pyx_CyFunctionObject;
2345 #undef __Pyx_CyOrPyCFunction_Check
2346 #define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, __pyx_CyFunctionType)
2347 #define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, __pyx_CyFunctionType, &PyCFunction_Type)
2348 #define __Pyx_CyFunction_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_CyFunctionType)
2349 static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void *cfunc);
2350 #undef __Pyx_IsSameCFunction
2351 #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc)
2352 static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
2353 int flags, PyObject* qualname,
2354 PyObject *closure,
2355 PyObject *module, PyObject *globals,
2356 PyObject* code);
2357 static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj);
2358 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
2359 size_t size,
2360 int pyobjects);
2361 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
2362 PyObject *tuple);
2363 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
2364 PyObject *dict);
2365 static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
2366 PyObject *dict);
2367 static int __pyx_CyFunction_init(PyObject *module);
2368 #if CYTHON_METH_FASTCALL
2369 static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
2370 static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
2371 static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
2372 static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
2373 #if CYTHON_BACKPORT_VECTORCALL
2374 #define __Pyx_CyFunction_func_vectorcall(f) (((__pyx_CyFunctionObject*)f)->func_vectorcall)
2375 #else
2376 #define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall)
2377 #endif
2378 #endif
2379
2380 /* CythonFunction.proto */
2381 static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
2382 int flags, PyObject* qualname,
2383 PyObject *closure,
2384 PyObject *module, PyObject *globals,
2385 PyObject* code);
2386
2387 /* RaiseUnboundLocalError.proto */
2388 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
2389
2390 /* TypeImport.proto */
2391 #ifndef __PYX_HAVE_RT_ImportType_proto_3_0_11
2392 #define __PYX_HAVE_RT_ImportType_proto_3_0_11
2393 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
2394 #include <stdalign.h>
2395 #endif
2396 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || __cplusplus >= 201103L
2397 #define __PYX_GET_STRUCT_ALIGNMENT_3_0_11(s) alignof(s)
2398 #else
2399 #define __PYX_GET_STRUCT_ALIGNMENT_3_0_11(s) sizeof(void*)
2400 #endif
2401 enum __Pyx_ImportType_CheckSize_3_0_11 {
2402 __Pyx_ImportType_CheckSize_Error_3_0_11 = 0,
2403 __Pyx_ImportType_CheckSize_Warn_3_0_11 = 1,
2404 __Pyx_ImportType_CheckSize_Ignore_3_0_11 = 2
2405 };
2406 static PyTypeObject *__Pyx_ImportType_3_0_11(PyObject* module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_0_11 check_size);
2407 #endif
2408
2409 /* Import.proto */
2410 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
2411
2412 /* ImportDottedModule.proto */
2413 static PyObject *__Pyx_ImportDottedModule(PyObject *name, PyObject *parts_tuple);
2414 #if PY_MAJOR_VERSION >= 3
2415 static PyObject *__Pyx_ImportDottedModule_WalkParts(PyObject *module, PyObject *name, PyObject *parts_tuple);
2416 #endif
2417
2418 /* ImportFrom.proto */
2419 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
2420
2421 /* PyObjectCallNoArg.proto */
2422 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
2423
2424 /* CLineInTraceback.proto */
2425 #ifdef CYTHON_CLINE_IN_TRACEBACK
2426 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
2427 #else
2428 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
2429 #endif
2430
2431 /* CodeObjectCache.proto */
2432 #if !CYTHON_COMPILING_IN_LIMITED_API
2433 typedef struct {
2434 PyCodeObject* code_object;
2435 int code_line;
2436 } __Pyx_CodeObjectCacheEntry;
2437 struct __Pyx_CodeObjectCache {
2438 int count;
2439 int max_count;
2440 __Pyx_CodeObjectCacheEntry* entries;
2441 };
2442 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
2443 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
2444 static PyCodeObject *__pyx_find_code_object(int code_line);
2445 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
2446 #endif
2447
2448 /* AddTraceback.proto */
2449 static void __Pyx_AddTraceback(const char *funcname, int c_line,
2450 int py_line, const char *filename);
2451
2452 /* ArrayAPI.proto */
2453 #ifndef _ARRAYARRAY_H
2454 #define _ARRAYARRAY_H
2455 typedef struct arraydescr {
2456 int typecode;
2457 int itemsize;
2458 PyObject * (*getitem)(struct arrayobject *, Py_ssize_t);
2459 int (*setitem)(struct arrayobject *, Py_ssize_t, PyObject *);
2460 #if PY_MAJOR_VERSION >= 3
2461 char *formats;
2462 #endif
2463 } arraydescr;
2464 struct arrayobject {
2465 PyObject_HEAD
2466 Py_ssize_t ob_size;
2467 union {
2468 char *ob_item;
2469 float *as_floats;
2470 double *as_doubles;
2471 int *as_ints;
2472 unsigned int *as_uints;
2473 unsigned char *as_uchars;
2474 signed char *as_schars;
2475 char *as_chars;
2476 unsigned long *as_ulongs;
2477 long *as_longs;
2478 #if PY_MAJOR_VERSION >= 3
2479 unsigned long long *as_ulonglongs;
2480 long long *as_longlongs;
2481 #endif
2482 short *as_shorts;
2483 unsigned short *as_ushorts;
2484 Py_UNICODE *as_pyunicodes;
2485 void *as_voidptr;
2486 } data;
2487 Py_ssize_t allocated;
2488 struct arraydescr *ob_descr;
2489 PyObject *weakreflist;
2490 #if PY_MAJOR_VERSION >= 3
2491 int ob_exports;
2492 #endif
2493 };
2494 #ifndef NO_NEWARRAY_INLINE
2495 static CYTHON_INLINE PyObject * newarrayobject(PyTypeObject *type, Py_ssize_t size,
2496 struct arraydescr *descr) {
2497 arrayobject *op;
2498 size_t nbytes;
2499 if (size < 0) {
2500 PyErr_BadInternalCall();
2501 return NULL;
2502 }
2503 nbytes = size * descr->itemsize;
2504 if (nbytes / descr->itemsize != (size_t)size) {
2505 return PyErr_NoMemory();
2506 }
2507 op = (arrayobject *) type->tp_alloc(type, 0);
2508 if (op == NULL) {
2509 return NULL;
2510 }
2511 op->ob_descr = descr;
2512 op->allocated = size;
2513 op->weakreflist = NULL;
2514 __Pyx_SET_SIZE(op, size);
2515 if (size <= 0) {
2516 op->data.ob_item = NULL;
2517 }
2518 else {
2519 op->data.ob_item = PyMem_NEW(char, nbytes);
2520 if (op->data.ob_item == NULL) {
2521 Py_DECREF(op);
2522 return PyErr_NoMemory();
2523 }
2524 }
2525 return (PyObject *) op;
2526 }
2527 #else
2528 PyObject* newarrayobject(PyTypeObject *type, Py_ssize_t size,
2529 struct arraydescr *descr);
2530 #endif
2531 static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) {
2532 void *items = (void*) self->data.ob_item;
2533 PyMem_Resize(items, char, (size_t)(n * self->ob_descr->itemsize));
2534 if (items == NULL) {
2535 PyErr_NoMemory();
2536 return -1;
2537 }
2538 self->data.ob_item = (char*) items;
2539 __Pyx_SET_SIZE(self, n);
2540 self->allocated = n;
2541 return 0;
2542 }
2543 static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) {
2544 void *items = (void*) self->data.ob_item;
2545 Py_ssize_t newsize;
2546 if (n < self->allocated && n*4 > self->allocated) {
2547 __Pyx_SET_SIZE(self, n);
2548 return 0;
2549 }
2550 newsize = n + (n / 2) + 1;
2551 if (newsize <= n) {
2552 PyErr_NoMemory();
2553 return -1;
2554 }
2555 PyMem_Resize(items, char, (size_t)(newsize * self->ob_descr->itemsize));
2556 if (items == NULL) {
2557 PyErr_NoMemory();
2558 return -1;
2559 }
2560 self->data.ob_item = (char*) items;
2561 __Pyx_SET_SIZE(self, n);
2562 self->allocated = newsize;
2563 return 0;
2564 }
2565 #endif
2566
2567 /* GCCDiagnostics.proto */
2568 #if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
2569 #define __Pyx_HAS_GCC_DIAGNOSTIC
2570 #endif
2571
2572 /* CIntFromPy.proto */
2573 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
2574
2575 /* CIntFromPy.proto */
2576 static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);
2577
2578 /* CIntToPy.proto */
2579 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
2580
2581 /* CIntFromPy.proto */
2582 static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *);
2583
2584 /* CIntToPy.proto */
2585 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
2586
2587 /* CIntToPy.proto */
2588 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int32_t(int32_t value);
2589
2590 /* FormatTypeName.proto */
2591 #if CYTHON_COMPILING_IN_LIMITED_API
2592 typedef PyObject *__Pyx_TypeName;
2593 #define __Pyx_FMT_TYPENAME "%U"
2594 static __Pyx_TypeName __Pyx_PyType_GetName(PyTypeObject* tp);
2595 #define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj)
2596 #else
2597 typedef const char *__Pyx_TypeName;
2598 #define __Pyx_FMT_TYPENAME "%.200s"
2599 #define __Pyx_PyType_GetName(tp) ((tp)->tp_name)
2600 #define __Pyx_DECREF_TypeName(obj)
2601 #endif
2602
2603 /* CIntFromPy.proto */
2604 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
2605
2606 /* FastTypeChecks.proto */
2607 #if CYTHON_COMPILING_IN_CPYTHON
2608 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
2609 #define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2)
2610 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
2611 static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b);
2612 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
2613 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
2614 #else
2615 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
2616 #define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2))
2617 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
2618 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
2619 #endif
2620 #define __Pyx_PyErr_ExceptionMatches2(err1, err2) __Pyx_PyErr_GivenExceptionMatches2(__Pyx_PyErr_CurrentExceptionType(), err1, err2)
2621 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
2622
2623 /* CheckBinaryVersion.proto */
2624 static unsigned long __Pyx_get_runtime_version(void);
2625 static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer);
2626
2627 /* FunctionExport.proto */
2628 static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
2629
2630 /* InitStrings.proto */
2631 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
2632
2633 /* #### Code section: module_declarations ### */
2634 static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4real_real(PyComplexObject *__pyx_v_self); /* proto*/
2635 static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4imag_imag(PyComplexObject *__pyx_v_self); /* proto*/
2636
2637 /* Module declarations from "cython" */
2638
2639 /* Module declarations from "cpython.version" */
2640
2641 /* Module declarations from "__builtin__" */
2642
2643 /* Module declarations from "cpython.type" */
2644
2645 /* Module declarations from "libc.string" */
2646
2647 /* Module declarations from "libc.stdio" */
2648
2649 /* Module declarations from "cpython.object" */
2650
2651 /* Module declarations from "cpython.ref" */
2652
2653 /* Module declarations from "cpython.exc" */
2654
2655 /* Module declarations from "cpython.module" */
2656
2657 /* Module declarations from "cpython.mem" */
2658
2659 /* Module declarations from "cpython.tuple" */
2660
2661 /* Module declarations from "cpython.list" */
2662
2663 /* Module declarations from "cpython.sequence" */
2664
2665 /* Module declarations from "cpython.mapping" */
2666
2667 /* Module declarations from "cpython.iterator" */
2668
2669 /* Module declarations from "cpython.number" */
2670
2671 /* Module declarations from "cpython.int" */
2672
2673 /* Module declarations from "__builtin__" */
2674
2675 /* Module declarations from "cpython.bool" */
2676
2677 /* Module declarations from "cpython.long" */
2678
2679 /* Module declarations from "cpython.float" */
2680
2681 /* Module declarations from "__builtin__" */
2682
2683 /* Module declarations from "cpython.complex" */
2684
2685 /* Module declarations from "cpython.string" */
2686
2687 /* Module declarations from "libc.stddef" */
2688
2689 /* Module declarations from "cpython.unicode" */
2690
2691 /* Module declarations from "cpython.pyport" */
2692
2693 /* Module declarations from "cpython.dict" */
2694
2695 /* Module declarations from "cpython.instance" */
2696
2697 /* Module declarations from "cpython.function" */
2698
2699 /* Module declarations from "cpython.method" */
2700
2701 /* Module declarations from "cpython.weakref" */
2702
2703 /* Module declarations from "cpython.getargs" */
2704
2705 /* Module declarations from "cpython.pythread" */
2706
2707 /* Module declarations from "cpython.pystate" */
2708
2709 /* Module declarations from "cpython.cobject" */
2710
2711 /* Module declarations from "cpython.oldbuffer" */
2712
2713 /* Module declarations from "cpython.set" */
2714
2715 /* Module declarations from "cpython.buffer" */
2716
2717 /* Module declarations from "cpython.bytes" */
2718
2719 /* Module declarations from "cpython.pycapsule" */
2720
2721 /* Module declarations from "cpython.contextvars" */
2722
2723 /* Module declarations from "cpython" */
2724
2725 /* Module declarations from "array" */
2726
2727 /* Module declarations from "cpython.array" */
2728 static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_clone(arrayobject *, Py_ssize_t, int); /*proto*/
2729 static CYTHON_INLINE int __pyx_f_7cpython_5array_extend_buffer(arrayobject *, char *, Py_ssize_t); /*proto*/
2730
2731 /* Module declarations from "libc.errno" */
2732
2733 /* Module declarations from "libc.stdlib" */
2734
2735 /* Module declarations from "libc.stdint" */
2736
2737 /* Module declarations from "posix.types" */
2738
2739 /* Module declarations from "posix.fcntl" */
2740
2741 /* Module declarations from "posix.unistd" */
2742
2743 /* Module declarations from "pysam.libcsamtools" */
2744
2745 /* Module declarations from "pysam.libcbcftools" */
2746
2747 /* Module declarations from "pysam.libcutils" */
2748 static int __pyx_v_5pysam_9libcutils_MAX_POS;
2749 static PyObject *__pyx_v_5pysam_9libcutils_ERROR_HANDLER = 0;
2750 static PyObject *__pyx_v_5pysam_9libcutils_FILENAME_ENCODING = 0;
2751 static PyObject *__pyx_v_5pysam_9libcutils_TEXT_ENCODING = 0;
2752 static PyObject *__pyx_f_5pysam_9libcutils_parse_region(int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_9libcutils_parse_region *__pyx_optional_args); /*proto*/
2753 static arrayobject *__pyx_f_5pysam_9libcutils_qualitystring_to_array(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_9libcutils_qualitystring_to_array *__pyx_optional_args); /*proto*/
2754 static PyObject *__pyx_f_5pysam_9libcutils_array_to_qualitystring(arrayobject *, int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_9libcutils_array_to_qualitystring *__pyx_optional_args); /*proto*/
2755 static PyObject *__pyx_f_5pysam_9libcutils_qualities_to_qualitystring(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_9libcutils_qualities_to_qualitystring *__pyx_optional_args); /*proto*/
2756 static PyObject *__pyx_f_5pysam_9libcutils_get_encoding_error_handler(int __pyx_skip_dispatch); /*proto*/
2757 static PyObject *__pyx_f_5pysam_9libcutils_set_encoding_error_handler(PyObject *, int __pyx_skip_dispatch); /*proto*/
2758 static PyObject *__pyx_f_5pysam_9libcutils_force_str(PyObject *, struct __pyx_opt_args_5pysam_9libcutils_force_str *__pyx_optional_args); /*proto*/
2759 static PyObject *__pyx_f_5pysam_9libcutils_force_bytes(PyObject *, struct __pyx_opt_args_5pysam_9libcutils_force_bytes *__pyx_optional_args); /*proto*/
2760 /* #### Code section: typeinfo ### */
2761 /* #### Code section: before_global_var ### */
2762 #define __Pyx_MODULE_NAME "pysam.libcutils"
2763 extern int __pyx_module_is_main_pysam__libcutils;
2764 int __pyx_module_is_main_pysam__libcutils = 0;
2765
2766 /* Implementation of "pysam.libcutils" */
2767 /* #### Code section: global_var ### */
2768 static PyObject *__pyx_builtin_chr;
2769 static PyObject *__pyx_builtin_TypeError;
2770 static PyObject *__pyx_builtin_ValueError;
2771 static PyObject *__pyx_builtin_OverflowError;
2772 static PyObject *__pyx_builtin_IOError;
2773 static PyObject *__pyx_builtin_OSError;
2774 static PyObject *__pyx_builtin_open;
2775 static PyObject *__pyx_builtin_UnicodeDecodeError;
2776 static PyObject *__pyx_builtin_MemoryError;
2777 /* #### Code section: string_decls ### */
2778 static const char __pyx_k_[] = "";
2779 static const char __pyx_k_B[] = "B";
2780 static const char __pyx_k_a[] = "a";
2781 static const char __pyx_k_c[] = "-c";
2782 static const char __pyx_k_i[] = "i";
2783 static const char __pyx_k_l[] = "l";
2784 static const char __pyx_k_m[] = "-m";
2785 static const char __pyx_k_n[] = "n";
2786 static const char __pyx_k_o[] = "-o";
2787 static const char __pyx_k_r[] = "r";
2788 static const char __pyx_k__7[] = ":";
2789 static const char __pyx_k__8[] = "-";
2790 static const char __pyx_k_fn[] = "fn";
2791 static const char __pyx_k_io[] = "io";
2792 static const char __pyx_k_os[] = "os";
2793 static const char __pyx_k_rb[] = "rb";
2794 static const char __pyx_k_re[] = "re";
2795 static const char __pyx_k__10[] = "-@";
2796 static const char __pyx_k__11[] = " ";
2797 static const char __pyx_k__14[] = "*";
2798 static const char __pyx_k__15[] = ".";
2799 static const char __pyx_k__33[] = "?";
2800 static const char __pyx_k_all[] = "__all__";
2801 static const char __pyx_k_arg[] = "arg";
2802 static const char __pyx_k_chr[] = "chr";
2803 static const char __pyx_k_end[] = "end";
2804 static const char __pyx_k_inf[] = "inf";
2805 static const char __pyx_k_o_2[] = "-o {}";
2806 static const char __pyx_k_out[] = "out";
2807 static const char __pyx_k_roh[] = "roh";
2808 static const char __pyx_k_sys[] = "sys";
2809 static const char __pyx_k_args[] = "args";
2810 static const char __pyx_k_exit[] = "__exit__";
2811 static const char __pyx_k_head[] = "head";
2812 static const char __pyx_k_main[] = "__main__";
2813 static const char __pyx_k_name[] = "name";
2814 static const char __pyx_k_open[] = "open";
2815 static const char __pyx_k_path[] = "path";
2816 static const char __pyx_k_read[] = "read";
2817 static const char __pyx_k_spec[] = "__spec__";
2818 static const char __pyx_k_stop[] = "stop";
2819 static const char __pyx_k_test[] = "__test__";
2820 static const char __pyx_k_view[] = "view";
2821 static const char __pyx_k_ascii[] = "ascii";
2822 static const char __pyx_k_calmd[] = "calmd";
2823 static const char __pyx_k_cargs[] = "cargs";
2824 static const char __pyx_k_close[] = "close";
2825 static const char __pyx_k_depad[] = "depad";
2826 static const char __pyx_k_enter[] = "__enter__";
2827 static const char __pyx_k_index[] = "index";
2828 static const char __pyx_k_split[] = "split";
2829 static const char __pyx_k_start[] = "start";
2830 static const char __pyx_k_stats[] = "stats";
2831 static const char __pyx_k_types[] = "types";
2832 static const char __pyx_k_utf_8[] = "utf-8";
2833 static const char __pyx_k_codecs[] = "codecs";
2834 static const char __pyx_k_contig[] = "contig";
2835 static const char __pyx_k_decode[] = "decode";
2836 static const char __pyx_k_encode[] = "encode";
2837 static const char __pyx_k_exists[] = "exists";
2838 static const char __pyx_k_extend[] = "extend";
2839 static const char __pyx_k_format[] = "format";
2840 static const char __pyx_k_import[] = "__import__";
2841 static const char __pyx_k_method[] = "method";
2842 static const char __pyx_k_name_2[] = "__name__";
2843 static const char __pyx_k_object[] = "object";
2844 static const char __pyx_k_offset[] = "offset";
2845 static const char __pyx_k_output[] = "--output";
2846 static const char __pyx_k_region[] = "region";
2847 static const char __pyx_k_remove[] = "remove";
2848 static const char __pyx_k_retval[] = "retval";
2849 static const char __pyx_k_strict[] = "strict";
2850 static const char __pyx_k_string[] = "string";
2851 static const char __pyx_k_IOError[] = "IOError";
2852 static const char __pyx_k_OSError[] = "OSError";
2853 static const char __pyx_k_collect[] = "_collect";
2854 static const char __pyx_k_mkstemp[] = "mkstemp";
2855 static const char __pyx_k_mpileup[] = "mpileup";
2856 static const char __pyx_k_threads[] = "--threads";
2857 static const char __pyx_k_tobytes[] = "tobytes";
2858 static const char __pyx_k_bcftools[] = "bcftools";
2859 static const char __pyx_k_fsencode[] = "fsencode";
2860 static const char __pyx_k_is_usage[] = "is_usage";
2861 static const char __pyx_k_samtools[] = "samtools";
2862 static const char __pyx_k_stderr_f[] = "stderr_f";
2863 static const char __pyx_k_stderr_h[] = "stderr_h";
2864 static const char __pyx_k_stdout_f[] = "stdout_f";
2865 static const char __pyx_k_stdout_h[] = "stdout_h";
2866 static const char __pyx_k_tempfile[] = "tempfile";
2867 static const char __pyx_k_ARGUMENTS[] = "ARGUMENTS";
2868 static const char __pyx_k_TypeError[] = "TypeError";
2869 static const char __pyx_k_exception[] = "exception";
2870 static const char __pyx_k_input_str[] = "input_str";
2871 static const char __pyx_k_min_shift[] = "--min-shift";
2872 static const char __pyx_k_qualities[] = "qualities";
2873 static const char __pyx_k_reference[] = "reference";
2874 static const char __pyx_k_skip_next[] = "skip_next";
2875 static const char __pyx_k_ValueError[] = "ValueError";
2876 static const char __pyx_k_collection[] = "collection";
2877 static const char __pyx_k_contextlib[] = "contextlib";
2878 static const char __pyx_k_extra_args[] = "extra_args";
2879 static const char __pyx_k_out_stderr[] = "out_stderr";
2880 static const char __pyx_k_out_stdout[] = "out_stdout";
2881 static const char __pyx_k_startswith[] = "startswith";
2882 static const char __pyx_k_MemoryError[] = "MemoryError";
2883 static const char __pyx_k_output_file[] = "--output-file";
2884 static const char __pyx_k_save_stdout[] = "save_stdout";
2885 static const char __pyx_k_catch_stdout[] = "catch_stdout";
2886 static const char __pyx_k_initializing[] = "_initializing";
2887 static const char __pyx_k_is_coroutine[] = "_is_coroutine";
2888 static const char __pyx_k_parse_region[] = "parse_region";
2889 static const char __pyx_k_OverflowError[] = "OverflowError";
2890 static const char __pyx_k_class_getitem[] = "__class_getitem__";
2891 static const char __pyx_k_stdout_option[] = "stdout_option";
2892 static const char __pyx_k_contextmanager[] = "contextmanager";
2893 static const char __pyx_k_latin1_replace[] = "latin1_replace";
2894 static const char __pyx_k_pysam_dispatch[] = "_pysam_dispatch";
2895 static const char __pyx_k_register_error[] = "register_error";
2896 static const char __pyx_k_pysam_libcutils[] = "pysam.libcutils";
2897 static const char __pyx_k_MAP_STDOUT_OPTIONS[] = "MAP_STDOUT_OPTIONS";
2898 static const char __pyx_k_UnicodeDecodeError[] = "UnicodeDecodeError";
2899 static const char __pyx_k_asyncio_coroutines[] = "asyncio.coroutines";
2900 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
2901 static const char __pyx_k_getdefaultencoding[] = "getdefaultencoding";
2902 static const char __pyx_k_pysam_latin1replace[] = "pysam.latin1replace";
2903 static const char __pyx_k_pysam_libcutils_pyx[] = "pysam/libcutils.pyx";
2904 static const char __pyx_k_stop_out_of_range_i[] = "stop out of range (%i)";
2905 static const char __pyx_k_start_out_of_range_i[] = "start out of range (%i)";
2906 static const char __pyx_k_getfilesystemencoding[] = "getfilesystemencoding";
2907 static const char __pyx_k_array_to_qualitystring[] = "array_to_qualitystring";
2908 static const char __pyx_k_qualitystring_to_array[] = "qualitystring_to_array";
2909 static const char __pyx_k_get_encoding_error_handler[] = "get_encoding_error_handler";
2910 static const char __pyx_k_qualities_to_qualitystring[] = "qualities_to_qualitystring";
2911 static const char __pyx_k_set_encoding_error_handler[] = "set_encoding_error_handler";
2912 static const char __pyx_k_No_such_file_or_directory_s[] = "No such file or directory: '%s'";
2913 static const char __pyx_k_pysam_dispatch_locals__collect[] = "_pysam_dispatch.<locals>._collect";
2914 static const char __pyx_k_contig_and_reference_should_not[] = "contig and reference should not both be specified";
2915 static const char __pyx_k_stop_and_end_should_not_both_be[] = "stop and end should not both be specified";
2916 static const char __pyx_k_Argument_must_be_string_bytes_or[] = "Argument must be string, bytes or unicode.";
2917 static const char __pyx_k_contig_reference_and_region_shou[] = "contig/reference and region should not both be specified";
2918 static const char __pyx_k_error_while_opening_file_for_wri[] = "error while opening file for writing";
2919 static const char __pyx_k_invalid_coordinates_start_i_stop[] = "invalid coordinates: start (%i) > stop (%i)";
2920 static const char __pyx_k_neither_contig_nor_region_are_gi[] = "neither contig nor region are given";
2921 /* #### Code section: decls ### */
2922 static int __pyx_pf_7cpython_5array_5array___getbuffer__(arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info, CYTHON_UNUSED int __pyx_v_flags); /* proto */
2923 static void __pyx_pf_7cpython_5array_5array_2__releasebuffer__(CYTHON_UNUSED arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */
2924 static PyObject *__pyx_pf_5pysam_9libcutils_qualitystring_to_array(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_input_str, int __pyx_v_offset); /* proto */
2925 static PyObject *__pyx_pf_5pysam_9libcutils_2array_to_qualitystring(CYTHON_UNUSED PyObject *__pyx_self, arrayobject *__pyx_v_qualities, int __pyx_v_offset); /* proto */
2926 static PyObject *__pyx_pf_5pysam_9libcutils_4qualities_to_qualitystring(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_qualities, int __pyx_v_offset); /* proto */
2927 static PyObject *__pyx_pf_5pysam_9libcutils_6latin1_replace(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_exception); /* proto */
2928 static PyObject *__pyx_pf_5pysam_9libcutils_8get_encoding_error_handler(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
2929 static PyObject *__pyx_pf_5pysam_9libcutils_10set_encoding_error_handler(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name); /* proto */
2930 static PyObject *__pyx_pf_5pysam_9libcutils_12parse_region(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_contig, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_region, PyObject *__pyx_v_reference, PyObject *__pyx_v_end); /* proto */
2931 static PyObject *__pyx_pf_5pysam_9libcutils_15_pysam_dispatch__collect(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_fn); /* proto */
2932 static PyObject *__pyx_pf_5pysam_9libcutils_14_pysam_dispatch(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_collection, PyObject *__pyx_v_method, PyObject *__pyx_v_args, PyObject *__pyx_v_catch_stdout, PyObject *__pyx_v_is_usage, PyObject *__pyx_v_save_stdout); /* proto */
2933 /* #### Code section: late_includes ### */
2934 /* #### Code section: module_state ### */
2935 typedef struct {
2936 PyObject *__pyx_d;
2937 PyObject *__pyx_b;
2938 PyObject *__pyx_cython_runtime;
2939 PyObject *__pyx_empty_tuple;
2940 PyObject *__pyx_empty_bytes;
2941 PyObject *__pyx_empty_unicode;
2942 #ifdef __Pyx_CyFunction_USED
2943 PyTypeObject *__pyx_CyFunctionType;
2944 #endif
2945 #ifdef __Pyx_FusedFunction_USED
2946 PyTypeObject *__pyx_FusedFunctionType;
2947 #endif
2948 #ifdef __Pyx_Generator_USED
2949 PyTypeObject *__pyx_GeneratorType;
2950 #endif
2951 #ifdef __Pyx_IterableCoroutine_USED
2952 PyTypeObject *__pyx_IterableCoroutineType;
2953 #endif
2954 #ifdef __Pyx_Coroutine_USED
2955 PyTypeObject *__pyx_CoroutineAwaitType;
2956 #endif
2957 #ifdef __Pyx_Coroutine_USED
2958 PyTypeObject *__pyx_CoroutineType;
2959 #endif
2960 #if CYTHON_USE_MODULE_STATE
2961 #endif
2962 #if CYTHON_USE_MODULE_STATE
2963 #endif
2964 #if CYTHON_USE_MODULE_STATE
2965 #endif
2966 #if CYTHON_USE_MODULE_STATE
2967 #endif
2968 PyTypeObject *__pyx_ptype_7cpython_4type_type;
2969 #if CYTHON_USE_MODULE_STATE
2970 #endif
2971 #if CYTHON_USE_MODULE_STATE
2972 #endif
2973 #if CYTHON_USE_MODULE_STATE
2974 #endif
2975 #if CYTHON_USE_MODULE_STATE
2976 #endif
2977 #if CYTHON_USE_MODULE_STATE
2978 #endif
2979 #if CYTHON_USE_MODULE_STATE
2980 #endif
2981 #if CYTHON_USE_MODULE_STATE
2982 #endif
2983 #if CYTHON_USE_MODULE_STATE
2984 #endif
2985 #if CYTHON_USE_MODULE_STATE
2986 #endif
2987 #if CYTHON_USE_MODULE_STATE
2988 #endif
2989 #if CYTHON_USE_MODULE_STATE
2990 #endif
2991 #if CYTHON_USE_MODULE_STATE
2992 #endif
2993 #if CYTHON_USE_MODULE_STATE
2994 #endif
2995 #if CYTHON_USE_MODULE_STATE
2996 #endif
2997 #if CYTHON_USE_MODULE_STATE
2998 #endif
2999 #if CYTHON_USE_MODULE_STATE
3000 #endif
3001 PyTypeObject *__pyx_ptype_7cpython_4bool_bool;
3002 #if CYTHON_USE_MODULE_STATE
3003 #endif
3004 #if CYTHON_USE_MODULE_STATE
3005 #endif
3006 #if CYTHON_USE_MODULE_STATE
3007 #endif
3008 #if CYTHON_USE_MODULE_STATE
3009 #endif
3010 PyTypeObject *__pyx_ptype_7cpython_7complex_complex;
3011 #if CYTHON_USE_MODULE_STATE
3012 #endif
3013 #if CYTHON_USE_MODULE_STATE
3014 #endif
3015 #if CYTHON_USE_MODULE_STATE
3016 #endif
3017 #if CYTHON_USE_MODULE_STATE
3018 #endif
3019 #if CYTHON_USE_MODULE_STATE
3020 #endif
3021 #if CYTHON_USE_MODULE_STATE
3022 #endif
3023 #if CYTHON_USE_MODULE_STATE
3024 #endif
3025 #if CYTHON_USE_MODULE_STATE
3026 #endif
3027 #if CYTHON_USE_MODULE_STATE
3028 #endif
3029 #if CYTHON_USE_MODULE_STATE
3030 #endif
3031 #if CYTHON_USE_MODULE_STATE
3032 #endif
3033 #if CYTHON_USE_MODULE_STATE
3034 #endif
3035 #if CYTHON_USE_MODULE_STATE
3036 #endif
3037 #if CYTHON_USE_MODULE_STATE
3038 #endif
3039 #if CYTHON_USE_MODULE_STATE
3040 #endif
3041 #if CYTHON_USE_MODULE_STATE
3042 #endif
3043 #if CYTHON_USE_MODULE_STATE
3044 #endif
3045 #if CYTHON_USE_MODULE_STATE
3046 #endif
3047 #if CYTHON_USE_MODULE_STATE
3048 #endif
3049 #if CYTHON_USE_MODULE_STATE
3050 #endif
3051 #if CYTHON_USE_MODULE_STATE
3052 #endif
3053 #if CYTHON_USE_MODULE_STATE
3054 #endif
3055 PyTypeObject *__pyx_ptype_7cpython_5array_array;
3056 #if CYTHON_USE_MODULE_STATE
3057 #endif
3058 #if CYTHON_USE_MODULE_STATE
3059 #endif
3060 #if CYTHON_USE_MODULE_STATE
3061 #endif
3062 #if CYTHON_USE_MODULE_STATE
3063 #endif
3064 #if CYTHON_USE_MODULE_STATE
3065 #endif
3066 #if CYTHON_USE_MODULE_STATE
3067 #endif
3068 #if CYTHON_USE_MODULE_STATE
3069 #endif
3070 #if CYTHON_USE_MODULE_STATE
3071 #endif
3072 #if CYTHON_USE_MODULE_STATE
3073 #endif
3074 PyObject *__pyx_kp_u_;
3075 PyObject *__pyx_n_s_ARGUMENTS;
3076 PyObject *__pyx_kp_u_Argument_must_be_string_bytes_or;
3077 PyObject *__pyx_n_u_B;
3078 PyObject *__pyx_n_s_IOError;
3079 PyObject *__pyx_n_s_MAP_STDOUT_OPTIONS;
3080 PyObject *__pyx_n_s_MemoryError;
3081 PyObject *__pyx_kp_u_No_such_file_or_directory_s;
3082 PyObject *__pyx_n_s_OSError;
3083 PyObject *__pyx_n_s_OverflowError;
3084 PyObject *__pyx_n_s_TypeError;
3085 PyObject *__pyx_n_s_UnicodeDecodeError;
3086 PyObject *__pyx_n_s_ValueError;
3087 PyObject *__pyx_kp_u__10;
3088 PyObject *__pyx_kp_u__11;
3089 PyObject *__pyx_n_s__14;
3090 PyObject *__pyx_kp_u__15;
3091 PyObject *__pyx_n_s__33;
3092 PyObject *__pyx_kp_u__7;
3093 PyObject *__pyx_kp_u__8;
3094 PyObject *__pyx_n_s_a;
3095 PyObject *__pyx_n_s_all;
3096 PyObject *__pyx_n_s_arg;
3097 PyObject *__pyx_n_s_args;
3098 PyObject *__pyx_n_s_array_to_qualitystring;
3099 PyObject *__pyx_n_u_array_to_qualitystring;
3100 PyObject *__pyx_n_u_ascii;
3101 PyObject *__pyx_n_s_asyncio_coroutines;
3102 PyObject *__pyx_n_b_bcftools;
3103 PyObject *__pyx_n_u_bcftools;
3104 PyObject *__pyx_kp_u_c;
3105 PyObject *__pyx_n_u_calmd;
3106 PyObject *__pyx_n_s_cargs;
3107 PyObject *__pyx_n_s_catch_stdout;
3108 PyObject *__pyx_n_s_chr;
3109 PyObject *__pyx_n_s_class_getitem;
3110 PyObject *__pyx_n_s_cline_in_traceback;
3111 PyObject *__pyx_n_s_close;
3112 PyObject *__pyx_n_s_codecs;
3113 PyObject *__pyx_n_s_collect;
3114 PyObject *__pyx_n_s_collection;
3115 PyObject *__pyx_n_s_contextlib;
3116 PyObject *__pyx_n_s_contextmanager;
3117 PyObject *__pyx_n_s_contig;
3118 PyObject *__pyx_kp_u_contig_and_reference_should_not;
3119 PyObject *__pyx_kp_u_contig_reference_and_region_shou;
3120 PyObject *__pyx_n_s_decode;
3121 PyObject *__pyx_n_u_depad;
3122 PyObject *__pyx_n_s_encode;
3123 PyObject *__pyx_n_s_end;
3124 PyObject *__pyx_n_s_enter;
3125 PyObject *__pyx_kp_u_error_while_opening_file_for_wri;
3126 PyObject *__pyx_n_s_exception;
3127 PyObject *__pyx_n_s_exists;
3128 PyObject *__pyx_n_s_exit;
3129 PyObject *__pyx_n_s_extend;
3130 PyObject *__pyx_n_s_extra_args;
3131 PyObject *__pyx_n_s_fn;
3132 PyObject *__pyx_n_s_format;
3133 PyObject *__pyx_n_s_fsencode;
3134 PyObject *__pyx_n_s_get_encoding_error_handler;
3135 PyObject *__pyx_n_u_get_encoding_error_handler;
3136 PyObject *__pyx_n_s_getdefaultencoding;
3137 PyObject *__pyx_n_s_getfilesystemencoding;
3138 PyObject *__pyx_n_u_head;
3139 PyObject *__pyx_n_s_i;
3140 PyObject *__pyx_n_s_import;
3141 PyObject *__pyx_n_b_index;
3142 PyObject *__pyx_n_u_index;
3143 PyObject *__pyx_n_s_inf;
3144 PyObject *__pyx_n_s_initializing;
3145 PyObject *__pyx_n_s_input_str;
3146 PyObject *__pyx_kp_u_invalid_coordinates_start_i_stop;
3147 PyObject *__pyx_n_s_io;
3148 PyObject *__pyx_n_s_is_coroutine;
3149 PyObject *__pyx_n_s_is_usage;
3150 PyObject *__pyx_n_s_l;
3151 PyObject *__pyx_n_s_latin1_replace;
3152 PyObject *__pyx_kp_u_m;
3153 PyObject *__pyx_n_s_main;
3154 PyObject *__pyx_n_s_method;
3155 PyObject *__pyx_kp_u_min_shift;
3156 PyObject *__pyx_n_s_mkstemp;
3157 PyObject *__pyx_n_u_mpileup;
3158 PyObject *__pyx_n_s_n;
3159 PyObject *__pyx_n_s_name;
3160 PyObject *__pyx_n_s_name_2;
3161 PyObject *__pyx_kp_u_neither_contig_nor_region_are_gi;
3162 PyObject *__pyx_kp_u_o;
3163 PyObject *__pyx_kp_u_o_2;
3164 PyObject *__pyx_n_s_object;
3165 PyObject *__pyx_n_s_offset;
3166 PyObject *__pyx_n_s_open;
3167 PyObject *__pyx_n_s_os;
3168 PyObject *__pyx_n_s_out;
3169 PyObject *__pyx_n_s_out_stderr;
3170 PyObject *__pyx_n_s_out_stdout;
3171 PyObject *__pyx_kp_u_output;
3172 PyObject *__pyx_kp_u_output_file;
3173 PyObject *__pyx_n_s_parse_region;
3174 PyObject *__pyx_n_s_path;
3175 PyObject *__pyx_n_s_pysam_dispatch;
3176 PyObject *__pyx_n_s_pysam_dispatch_locals__collect;
3177 PyObject *__pyx_kp_u_pysam_latin1replace;
3178 PyObject *__pyx_n_s_pysam_libcutils;
3179 PyObject *__pyx_kp_s_pysam_libcutils_pyx;
3180 PyObject *__pyx_n_s_qualities;
3181 PyObject *__pyx_n_s_qualities_to_qualitystring;
3182 PyObject *__pyx_n_u_qualities_to_qualitystring;
3183 PyObject *__pyx_n_s_qualitystring_to_array;
3184 PyObject *__pyx_n_u_qualitystring_to_array;
3185 PyObject *__pyx_n_u_r;
3186 PyObject *__pyx_n_u_rb;
3187 PyObject *__pyx_n_s_re;
3188 PyObject *__pyx_n_s_read;
3189 PyObject *__pyx_n_s_reference;
3190 PyObject *__pyx_n_s_region;
3191 PyObject *__pyx_n_s_register_error;
3192 PyObject *__pyx_n_s_remove;
3193 PyObject *__pyx_n_s_retval;
3194 PyObject *__pyx_n_u_roh;
3195 PyObject *__pyx_n_b_samtools;
3196 PyObject *__pyx_n_u_samtools;
3197 PyObject *__pyx_n_s_save_stdout;
3198 PyObject *__pyx_n_s_set_encoding_error_handler;
3199 PyObject *__pyx_n_u_set_encoding_error_handler;
3200 PyObject *__pyx_n_s_skip_next;
3201 PyObject *__pyx_n_s_spec;
3202 PyObject *__pyx_n_s_split;
3203 PyObject *__pyx_n_s_start;
3204 PyObject *__pyx_kp_u_start_out_of_range_i;
3205 PyObject *__pyx_n_s_startswith;
3206 PyObject *__pyx_n_u_stats;
3207 PyObject *__pyx_n_s_stderr_f;
3208 PyObject *__pyx_n_s_stderr_h;
3209 PyObject *__pyx_n_s_stdout_f;
3210 PyObject *__pyx_n_s_stdout_h;
3211 PyObject *__pyx_n_s_stdout_option;
3212 PyObject *__pyx_n_s_stop;
3213 PyObject *__pyx_kp_u_stop_and_end_should_not_both_be;
3214 PyObject *__pyx_kp_u_stop_out_of_range_i;
3215 PyObject *__pyx_n_u_strict;
3216 PyObject *__pyx_n_s_string;
3217 PyObject *__pyx_n_s_sys;
3218 PyObject *__pyx_n_s_tempfile;
3219 PyObject *__pyx_n_s_test;
3220 PyObject *__pyx_kp_u_threads;
3221 PyObject *__pyx_n_s_tobytes;
3222 PyObject *__pyx_n_s_types;
3223 PyObject *__pyx_kp_u_utf_8;
3224 PyObject *__pyx_n_u_view;
3225 PyObject *__pyx_int_1;
3226 PyObject *__pyx_int_33;
3227 PyObject *__pyx_int_neg_1;
3228 PyObject *__pyx_tuple__2;
3229 PyObject *__pyx_tuple__3;
3230 PyObject *__pyx_tuple__4;
3231 PyObject *__pyx_tuple__5;
3232 PyObject *__pyx_tuple__6;
3233 PyObject *__pyx_tuple__9;
3234 PyObject *__pyx_tuple__12;
3235 PyObject *__pyx_tuple__16;
3236 PyObject *__pyx_tuple__18;
3237 PyObject *__pyx_tuple__19;
3238 PyObject *__pyx_tuple__22;
3239 PyObject *__pyx_tuple__25;
3240 PyObject *__pyx_tuple__27;
3241 PyObject *__pyx_tuple__29;
3242 PyObject *__pyx_tuple__30;
3243 PyObject *__pyx_tuple__32;
3244 PyObject *__pyx_codeobj__13;
3245 PyObject *__pyx_codeobj__17;
3246 PyObject *__pyx_codeobj__20;
3247 PyObject *__pyx_codeobj__21;
3248 PyObject *__pyx_codeobj__23;
3249 PyObject *__pyx_codeobj__24;
3250 PyObject *__pyx_codeobj__26;
3251 PyObject *__pyx_codeobj__28;
3252 PyObject *__pyx_codeobj__31;
3253 } __pyx_mstate;
3254
3255 #if CYTHON_USE_MODULE_STATE
3256 #ifdef __cplusplus
3257 namespace {
3258 extern struct PyModuleDef __pyx_moduledef;
3259 } /* anonymous namespace */
3260 #else
3261 static struct PyModuleDef __pyx_moduledef;
3262 #endif
3263
3264 #define __pyx_mstate(o) ((__pyx_mstate *)__Pyx_PyModule_GetState(o))
3265
3266 #define __pyx_mstate_global (__pyx_mstate(PyState_FindModule(&__pyx_moduledef)))
3267
3268 #define __pyx_m (PyState_FindModule(&__pyx_moduledef))
3269 #else
3270 static __pyx_mstate __pyx_mstate_global_static =
3271 #ifdef __cplusplus
3272 {};
3273 #else
3274 {0};
3275 #endif
3276 static __pyx_mstate *__pyx_mstate_global = &__pyx_mstate_global_static;
3277 #endif
3278 /* #### Code section: module_state_clear ### */
3279 #if CYTHON_USE_MODULE_STATE
3280 static int __pyx_m_clear(PyObject *m) {
3281 __pyx_mstate *clear_module_state = __pyx_mstate(m);
3282 if (!clear_module_state) return 0;
3283 Py_CLEAR(clear_module_state->__pyx_d);
3284 Py_CLEAR(clear_module_state->__pyx_b);
3285 Py_CLEAR(clear_module_state->__pyx_cython_runtime);
3286 Py_CLEAR(clear_module_state->__pyx_empty_tuple);
3287 Py_CLEAR(clear_module_state->__pyx_empty_bytes);
3288 Py_CLEAR(clear_module_state->__pyx_empty_unicode);
3289 #ifdef __Pyx_CyFunction_USED
3290 Py_CLEAR(clear_module_state->__pyx_CyFunctionType);
3291 #endif
3292 #ifdef __Pyx_FusedFunction_USED
3293 Py_CLEAR(clear_module_state->__pyx_FusedFunctionType);
3294 #endif
3295 Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_4type_type);
3296 Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_4bool_bool);
3297 Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_7complex_complex);
3298 Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_5array_array);
3299 Py_CLEAR(clear_module_state->__pyx_kp_u_);
3300 Py_CLEAR(clear_module_state->__pyx_n_s_ARGUMENTS);
3301 Py_CLEAR(clear_module_state->__pyx_kp_u_Argument_must_be_string_bytes_or);
3302 Py_CLEAR(clear_module_state->__pyx_n_u_B);
3303 Py_CLEAR(clear_module_state->__pyx_n_s_IOError);
3304 Py_CLEAR(clear_module_state->__pyx_n_s_MAP_STDOUT_OPTIONS);
3305 Py_CLEAR(clear_module_state->__pyx_n_s_MemoryError);
3306 Py_CLEAR(clear_module_state->__pyx_kp_u_No_such_file_or_directory_s);
3307 Py_CLEAR(clear_module_state->__pyx_n_s_OSError);
3308 Py_CLEAR(clear_module_state->__pyx_n_s_OverflowError);
3309 Py_CLEAR(clear_module_state->__pyx_n_s_TypeError);
3310 Py_CLEAR(clear_module_state->__pyx_n_s_UnicodeDecodeError);
3311 Py_CLEAR(clear_module_state->__pyx_n_s_ValueError);
3312 Py_CLEAR(clear_module_state->__pyx_kp_u__10);
3313 Py_CLEAR(clear_module_state->__pyx_kp_u__11);
3314 Py_CLEAR(clear_module_state->__pyx_n_s__14);
3315 Py_CLEAR(clear_module_state->__pyx_kp_u__15);
3316 Py_CLEAR(clear_module_state->__pyx_n_s__33);
3317 Py_CLEAR(clear_module_state->__pyx_kp_u__7);
3318 Py_CLEAR(clear_module_state->__pyx_kp_u__8);
3319 Py_CLEAR(clear_module_state->__pyx_n_s_a);
3320 Py_CLEAR(clear_module_state->__pyx_n_s_all);
3321 Py_CLEAR(clear_module_state->__pyx_n_s_arg);
3322 Py_CLEAR(clear_module_state->__pyx_n_s_args);
3323 Py_CLEAR(clear_module_state->__pyx_n_s_array_to_qualitystring);
3324 Py_CLEAR(clear_module_state->__pyx_n_u_array_to_qualitystring);
3325 Py_CLEAR(clear_module_state->__pyx_n_u_ascii);
3326 Py_CLEAR(clear_module_state->__pyx_n_s_asyncio_coroutines);
3327 Py_CLEAR(clear_module_state->__pyx_n_b_bcftools);
3328 Py_CLEAR(clear_module_state->__pyx_n_u_bcftools);
3329 Py_CLEAR(clear_module_state->__pyx_kp_u_c);
3330 Py_CLEAR(clear_module_state->__pyx_n_u_calmd);
3331 Py_CLEAR(clear_module_state->__pyx_n_s_cargs);
3332 Py_CLEAR(clear_module_state->__pyx_n_s_catch_stdout);
3333 Py_CLEAR(clear_module_state->__pyx_n_s_chr);
3334 Py_CLEAR(clear_module_state->__pyx_n_s_class_getitem);
3335 Py_CLEAR(clear_module_state->__pyx_n_s_cline_in_traceback);
3336 Py_CLEAR(clear_module_state->__pyx_n_s_close);
3337 Py_CLEAR(clear_module_state->__pyx_n_s_codecs);
3338 Py_CLEAR(clear_module_state->__pyx_n_s_collect);
3339 Py_CLEAR(clear_module_state->__pyx_n_s_collection);
3340 Py_CLEAR(clear_module_state->__pyx_n_s_contextlib);
3341 Py_CLEAR(clear_module_state->__pyx_n_s_contextmanager);
3342 Py_CLEAR(clear_module_state->__pyx_n_s_contig);
3343 Py_CLEAR(clear_module_state->__pyx_kp_u_contig_and_reference_should_not);
3344 Py_CLEAR(clear_module_state->__pyx_kp_u_contig_reference_and_region_shou);
3345 Py_CLEAR(clear_module_state->__pyx_n_s_decode);
3346 Py_CLEAR(clear_module_state->__pyx_n_u_depad);
3347 Py_CLEAR(clear_module_state->__pyx_n_s_encode);
3348 Py_CLEAR(clear_module_state->__pyx_n_s_end);
3349 Py_CLEAR(clear_module_state->__pyx_n_s_enter);
3350 Py_CLEAR(clear_module_state->__pyx_kp_u_error_while_opening_file_for_wri);
3351 Py_CLEAR(clear_module_state->__pyx_n_s_exception);
3352 Py_CLEAR(clear_module_state->__pyx_n_s_exists);
3353 Py_CLEAR(clear_module_state->__pyx_n_s_exit);
3354 Py_CLEAR(clear_module_state->__pyx_n_s_extend);
3355 Py_CLEAR(clear_module_state->__pyx_n_s_extra_args);
3356 Py_CLEAR(clear_module_state->__pyx_n_s_fn);
3357 Py_CLEAR(clear_module_state->__pyx_n_s_format);
3358 Py_CLEAR(clear_module_state->__pyx_n_s_fsencode);
3359 Py_CLEAR(clear_module_state->__pyx_n_s_get_encoding_error_handler);
3360 Py_CLEAR(clear_module_state->__pyx_n_u_get_encoding_error_handler);
3361 Py_CLEAR(clear_module_state->__pyx_n_s_getdefaultencoding);
3362 Py_CLEAR(clear_module_state->__pyx_n_s_getfilesystemencoding);
3363 Py_CLEAR(clear_module_state->__pyx_n_u_head);
3364 Py_CLEAR(clear_module_state->__pyx_n_s_i);
3365 Py_CLEAR(clear_module_state->__pyx_n_s_import);
3366 Py_CLEAR(clear_module_state->__pyx_n_b_index);
3367 Py_CLEAR(clear_module_state->__pyx_n_u_index);
3368 Py_CLEAR(clear_module_state->__pyx_n_s_inf);
3369 Py_CLEAR(clear_module_state->__pyx_n_s_initializing);
3370 Py_CLEAR(clear_module_state->__pyx_n_s_input_str);
3371 Py_CLEAR(clear_module_state->__pyx_kp_u_invalid_coordinates_start_i_stop);
3372 Py_CLEAR(clear_module_state->__pyx_n_s_io);
3373 Py_CLEAR(clear_module_state->__pyx_n_s_is_coroutine);
3374 Py_CLEAR(clear_module_state->__pyx_n_s_is_usage);
3375 Py_CLEAR(clear_module_state->__pyx_n_s_l);
3376 Py_CLEAR(clear_module_state->__pyx_n_s_latin1_replace);
3377 Py_CLEAR(clear_module_state->__pyx_kp_u_m);
3378 Py_CLEAR(clear_module_state->__pyx_n_s_main);
3379 Py_CLEAR(clear_module_state->__pyx_n_s_method);
3380 Py_CLEAR(clear_module_state->__pyx_kp_u_min_shift);
3381 Py_CLEAR(clear_module_state->__pyx_n_s_mkstemp);
3382 Py_CLEAR(clear_module_state->__pyx_n_u_mpileup);
3383 Py_CLEAR(clear_module_state->__pyx_n_s_n);
3384 Py_CLEAR(clear_module_state->__pyx_n_s_name);
3385 Py_CLEAR(clear_module_state->__pyx_n_s_name_2);
3386 Py_CLEAR(clear_module_state->__pyx_kp_u_neither_contig_nor_region_are_gi);
3387 Py_CLEAR(clear_module_state->__pyx_kp_u_o);
3388 Py_CLEAR(clear_module_state->__pyx_kp_u_o_2);
3389 Py_CLEAR(clear_module_state->__pyx_n_s_object);
3390 Py_CLEAR(clear_module_state->__pyx_n_s_offset);
3391 Py_CLEAR(clear_module_state->__pyx_n_s_open);
3392 Py_CLEAR(clear_module_state->__pyx_n_s_os);
3393 Py_CLEAR(clear_module_state->__pyx_n_s_out);
3394 Py_CLEAR(clear_module_state->__pyx_n_s_out_stderr);
3395 Py_CLEAR(clear_module_state->__pyx_n_s_out_stdout);
3396 Py_CLEAR(clear_module_state->__pyx_kp_u_output);
3397 Py_CLEAR(clear_module_state->__pyx_kp_u_output_file);
3398 Py_CLEAR(clear_module_state->__pyx_n_s_parse_region);
3399 Py_CLEAR(clear_module_state->__pyx_n_s_path);
3400 Py_CLEAR(clear_module_state->__pyx_n_s_pysam_dispatch);
3401 Py_CLEAR(clear_module_state->__pyx_n_s_pysam_dispatch_locals__collect);
3402 Py_CLEAR(clear_module_state->__pyx_kp_u_pysam_latin1replace);
3403 Py_CLEAR(clear_module_state->__pyx_n_s_pysam_libcutils);
3404 Py_CLEAR(clear_module_state->__pyx_kp_s_pysam_libcutils_pyx);
3405 Py_CLEAR(clear_module_state->__pyx_n_s_qualities);
3406 Py_CLEAR(clear_module_state->__pyx_n_s_qualities_to_qualitystring);
3407 Py_CLEAR(clear_module_state->__pyx_n_u_qualities_to_qualitystring);
3408 Py_CLEAR(clear_module_state->__pyx_n_s_qualitystring_to_array);
3409 Py_CLEAR(clear_module_state->__pyx_n_u_qualitystring_to_array);
3410 Py_CLEAR(clear_module_state->__pyx_n_u_r);
3411 Py_CLEAR(clear_module_state->__pyx_n_u_rb);
3412 Py_CLEAR(clear_module_state->__pyx_n_s_re);
3413 Py_CLEAR(clear_module_state->__pyx_n_s_read);
3414 Py_CLEAR(clear_module_state->__pyx_n_s_reference);
3415 Py_CLEAR(clear_module_state->__pyx_n_s_region);
3416 Py_CLEAR(clear_module_state->__pyx_n_s_register_error);
3417 Py_CLEAR(clear_module_state->__pyx_n_s_remove);
3418 Py_CLEAR(clear_module_state->__pyx_n_s_retval);
3419 Py_CLEAR(clear_module_state->__pyx_n_u_roh);
3420 Py_CLEAR(clear_module_state->__pyx_n_b_samtools);
3421 Py_CLEAR(clear_module_state->__pyx_n_u_samtools);
3422 Py_CLEAR(clear_module_state->__pyx_n_s_save_stdout);
3423 Py_CLEAR(clear_module_state->__pyx_n_s_set_encoding_error_handler);
3424 Py_CLEAR(clear_module_state->__pyx_n_u_set_encoding_error_handler);
3425 Py_CLEAR(clear_module_state->__pyx_n_s_skip_next);
3426 Py_CLEAR(clear_module_state->__pyx_n_s_spec);
3427 Py_CLEAR(clear_module_state->__pyx_n_s_split);
3428 Py_CLEAR(clear_module_state->__pyx_n_s_start);
3429 Py_CLEAR(clear_module_state->__pyx_kp_u_start_out_of_range_i);
3430 Py_CLEAR(clear_module_state->__pyx_n_s_startswith);
3431 Py_CLEAR(clear_module_state->__pyx_n_u_stats);
3432 Py_CLEAR(clear_module_state->__pyx_n_s_stderr_f);
3433 Py_CLEAR(clear_module_state->__pyx_n_s_stderr_h);
3434 Py_CLEAR(clear_module_state->__pyx_n_s_stdout_f);
3435 Py_CLEAR(clear_module_state->__pyx_n_s_stdout_h);
3436 Py_CLEAR(clear_module_state->__pyx_n_s_stdout_option);
3437 Py_CLEAR(clear_module_state->__pyx_n_s_stop);
3438 Py_CLEAR(clear_module_state->__pyx_kp_u_stop_and_end_should_not_both_be);
3439 Py_CLEAR(clear_module_state->__pyx_kp_u_stop_out_of_range_i);
3440 Py_CLEAR(clear_module_state->__pyx_n_u_strict);
3441 Py_CLEAR(clear_module_state->__pyx_n_s_string);
3442 Py_CLEAR(clear_module_state->__pyx_n_s_sys);
3443 Py_CLEAR(clear_module_state->__pyx_n_s_tempfile);
3444 Py_CLEAR(clear_module_state->__pyx_n_s_test);
3445 Py_CLEAR(clear_module_state->__pyx_kp_u_threads);
3446 Py_CLEAR(clear_module_state->__pyx_n_s_tobytes);
3447 Py_CLEAR(clear_module_state->__pyx_n_s_types);
3448 Py_CLEAR(clear_module_state->__pyx_kp_u_utf_8);
3449 Py_CLEAR(clear_module_state->__pyx_n_u_view);
3450 Py_CLEAR(clear_module_state->__pyx_int_1);
3451 Py_CLEAR(clear_module_state->__pyx_int_33);
3452 Py_CLEAR(clear_module_state->__pyx_int_neg_1);
3453 Py_CLEAR(clear_module_state->__pyx_tuple__2);
3454 Py_CLEAR(clear_module_state->__pyx_tuple__3);
3455 Py_CLEAR(clear_module_state->__pyx_tuple__4);
3456 Py_CLEAR(clear_module_state->__pyx_tuple__5);
3457 Py_CLEAR(clear_module_state->__pyx_tuple__6);
3458 Py_CLEAR(clear_module_state->__pyx_tuple__9);
3459 Py_CLEAR(clear_module_state->__pyx_tuple__12);
3460 Py_CLEAR(clear_module_state->__pyx_tuple__16);
3461 Py_CLEAR(clear_module_state->__pyx_tuple__18);
3462 Py_CLEAR(clear_module_state->__pyx_tuple__19);
3463 Py_CLEAR(clear_module_state->__pyx_tuple__22);
3464 Py_CLEAR(clear_module_state->__pyx_tuple__25);
3465 Py_CLEAR(clear_module_state->__pyx_tuple__27);
3466 Py_CLEAR(clear_module_state->__pyx_tuple__29);
3467 Py_CLEAR(clear_module_state->__pyx_tuple__30);
3468 Py_CLEAR(clear_module_state->__pyx_tuple__32);
3469 Py_CLEAR(clear_module_state->__pyx_codeobj__13);
3470 Py_CLEAR(clear_module_state->__pyx_codeobj__17);
3471 Py_CLEAR(clear_module_state->__pyx_codeobj__20);
3472 Py_CLEAR(clear_module_state->__pyx_codeobj__21);
3473 Py_CLEAR(clear_module_state->__pyx_codeobj__23);
3474 Py_CLEAR(clear_module_state->__pyx_codeobj__24);
3475 Py_CLEAR(clear_module_state->__pyx_codeobj__26);
3476 Py_CLEAR(clear_module_state->__pyx_codeobj__28);
3477 Py_CLEAR(clear_module_state->__pyx_codeobj__31);
3478 return 0;
3479 }
3480 #endif
3481 /* #### Code section: module_state_traverse ### */
3482 #if CYTHON_USE_MODULE_STATE
3483 static int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) {
3484 __pyx_mstate *traverse_module_state = __pyx_mstate(m);
3485 if (!traverse_module_state) return 0;
3486 Py_VISIT(traverse_module_state->__pyx_d);
3487 Py_VISIT(traverse_module_state->__pyx_b);
3488 Py_VISIT(traverse_module_state->__pyx_cython_runtime);
3489 Py_VISIT(traverse_module_state->__pyx_empty_tuple);
3490 Py_VISIT(traverse_module_state->__pyx_empty_bytes);
3491 Py_VISIT(traverse_module_state->__pyx_empty_unicode);
3492 #ifdef __Pyx_CyFunction_USED
3493 Py_VISIT(traverse_module_state->__pyx_CyFunctionType);
3494 #endif
3495 #ifdef __Pyx_FusedFunction_USED
3496 Py_VISIT(traverse_module_state->__pyx_FusedFunctionType);
3497 #endif
3498 Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_4type_type);
3499 Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_4bool_bool);
3500 Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_7complex_complex);
3501 Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_5array_array);
3502 Py_VISIT(traverse_module_state->__pyx_kp_u_);
3503 Py_VISIT(traverse_module_state->__pyx_n_s_ARGUMENTS);
3504 Py_VISIT(traverse_module_state->__pyx_kp_u_Argument_must_be_string_bytes_or);
3505 Py_VISIT(traverse_module_state->__pyx_n_u_B);
3506 Py_VISIT(traverse_module_state->__pyx_n_s_IOError);
3507 Py_VISIT(traverse_module_state->__pyx_n_s_MAP_STDOUT_OPTIONS);
3508 Py_VISIT(traverse_module_state->__pyx_n_s_MemoryError);
3509 Py_VISIT(traverse_module_state->__pyx_kp_u_No_such_file_or_directory_s);
3510 Py_VISIT(traverse_module_state->__pyx_n_s_OSError);
3511 Py_VISIT(traverse_module_state->__pyx_n_s_OverflowError);
3512 Py_VISIT(traverse_module_state->__pyx_n_s_TypeError);
3513 Py_VISIT(traverse_module_state->__pyx_n_s_UnicodeDecodeError);
3514 Py_VISIT(traverse_module_state->__pyx_n_s_ValueError);
3515 Py_VISIT(traverse_module_state->__pyx_kp_u__10);
3516 Py_VISIT(traverse_module_state->__pyx_kp_u__11);
3517 Py_VISIT(traverse_module_state->__pyx_n_s__14);
3518 Py_VISIT(traverse_module_state->__pyx_kp_u__15);
3519 Py_VISIT(traverse_module_state->__pyx_n_s__33);
3520 Py_VISIT(traverse_module_state->__pyx_kp_u__7);
3521 Py_VISIT(traverse_module_state->__pyx_kp_u__8);
3522 Py_VISIT(traverse_module_state->__pyx_n_s_a);
3523 Py_VISIT(traverse_module_state->__pyx_n_s_all);
3524 Py_VISIT(traverse_module_state->__pyx_n_s_arg);
3525 Py_VISIT(traverse_module_state->__pyx_n_s_args);
3526 Py_VISIT(traverse_module_state->__pyx_n_s_array_to_qualitystring);
3527 Py_VISIT(traverse_module_state->__pyx_n_u_array_to_qualitystring);
3528 Py_VISIT(traverse_module_state->__pyx_n_u_ascii);
3529 Py_VISIT(traverse_module_state->__pyx_n_s_asyncio_coroutines);
3530 Py_VISIT(traverse_module_state->__pyx_n_b_bcftools);
3531 Py_VISIT(traverse_module_state->__pyx_n_u_bcftools);
3532 Py_VISIT(traverse_module_state->__pyx_kp_u_c);
3533 Py_VISIT(traverse_module_state->__pyx_n_u_calmd);
3534 Py_VISIT(traverse_module_state->__pyx_n_s_cargs);
3535 Py_VISIT(traverse_module_state->__pyx_n_s_catch_stdout);
3536 Py_VISIT(traverse_module_state->__pyx_n_s_chr);
3537 Py_VISIT(traverse_module_state->__pyx_n_s_class_getitem);
3538 Py_VISIT(traverse_module_state->__pyx_n_s_cline_in_traceback);
3539 Py_VISIT(traverse_module_state->__pyx_n_s_close);
3540 Py_VISIT(traverse_module_state->__pyx_n_s_codecs);
3541 Py_VISIT(traverse_module_state->__pyx_n_s_collect);
3542 Py_VISIT(traverse_module_state->__pyx_n_s_collection);
3543 Py_VISIT(traverse_module_state->__pyx_n_s_contextlib);
3544 Py_VISIT(traverse_module_state->__pyx_n_s_contextmanager);
3545 Py_VISIT(traverse_module_state->__pyx_n_s_contig);
3546 Py_VISIT(traverse_module_state->__pyx_kp_u_contig_and_reference_should_not);
3547 Py_VISIT(traverse_module_state->__pyx_kp_u_contig_reference_and_region_shou);
3548 Py_VISIT(traverse_module_state->__pyx_n_s_decode);
3549 Py_VISIT(traverse_module_state->__pyx_n_u_depad);
3550 Py_VISIT(traverse_module_state->__pyx_n_s_encode);
3551 Py_VISIT(traverse_module_state->__pyx_n_s_end);
3552 Py_VISIT(traverse_module_state->__pyx_n_s_enter);
3553 Py_VISIT(traverse_module_state->__pyx_kp_u_error_while_opening_file_for_wri);
3554 Py_VISIT(traverse_module_state->__pyx_n_s_exception);
3555 Py_VISIT(traverse_module_state->__pyx_n_s_exists);
3556 Py_VISIT(traverse_module_state->__pyx_n_s_exit);
3557 Py_VISIT(traverse_module_state->__pyx_n_s_extend);
3558 Py_VISIT(traverse_module_state->__pyx_n_s_extra_args);
3559 Py_VISIT(traverse_module_state->__pyx_n_s_fn);
3560 Py_VISIT(traverse_module_state->__pyx_n_s_format);
3561 Py_VISIT(traverse_module_state->__pyx_n_s_fsencode);
3562 Py_VISIT(traverse_module_state->__pyx_n_s_get_encoding_error_handler);
3563 Py_VISIT(traverse_module_state->__pyx_n_u_get_encoding_error_handler);
3564 Py_VISIT(traverse_module_state->__pyx_n_s_getdefaultencoding);
3565 Py_VISIT(traverse_module_state->__pyx_n_s_getfilesystemencoding);
3566 Py_VISIT(traverse_module_state->__pyx_n_u_head);
3567 Py_VISIT(traverse_module_state->__pyx_n_s_i);
3568 Py_VISIT(traverse_module_state->__pyx_n_s_import);
3569 Py_VISIT(traverse_module_state->__pyx_n_b_index);
3570 Py_VISIT(traverse_module_state->__pyx_n_u_index);
3571 Py_VISIT(traverse_module_state->__pyx_n_s_inf);
3572 Py_VISIT(traverse_module_state->__pyx_n_s_initializing);
3573 Py_VISIT(traverse_module_state->__pyx_n_s_input_str);
3574 Py_VISIT(traverse_module_state->__pyx_kp_u_invalid_coordinates_start_i_stop);
3575 Py_VISIT(traverse_module_state->__pyx_n_s_io);
3576 Py_VISIT(traverse_module_state->__pyx_n_s_is_coroutine);
3577 Py_VISIT(traverse_module_state->__pyx_n_s_is_usage);
3578 Py_VISIT(traverse_module_state->__pyx_n_s_l);
3579 Py_VISIT(traverse_module_state->__pyx_n_s_latin1_replace);
3580 Py_VISIT(traverse_module_state->__pyx_kp_u_m);
3581 Py_VISIT(traverse_module_state->__pyx_n_s_main);
3582 Py_VISIT(traverse_module_state->__pyx_n_s_method);
3583 Py_VISIT(traverse_module_state->__pyx_kp_u_min_shift);
3584 Py_VISIT(traverse_module_state->__pyx_n_s_mkstemp);
3585 Py_VISIT(traverse_module_state->__pyx_n_u_mpileup);
3586 Py_VISIT(traverse_module_state->__pyx_n_s_n);
3587 Py_VISIT(traverse_module_state->__pyx_n_s_name);
3588 Py_VISIT(traverse_module_state->__pyx_n_s_name_2);
3589 Py_VISIT(traverse_module_state->__pyx_kp_u_neither_contig_nor_region_are_gi);
3590 Py_VISIT(traverse_module_state->__pyx_kp_u_o);
3591 Py_VISIT(traverse_module_state->__pyx_kp_u_o_2);
3592 Py_VISIT(traverse_module_state->__pyx_n_s_object);
3593 Py_VISIT(traverse_module_state->__pyx_n_s_offset);
3594 Py_VISIT(traverse_module_state->__pyx_n_s_open);
3595 Py_VISIT(traverse_module_state->__pyx_n_s_os);
3596 Py_VISIT(traverse_module_state->__pyx_n_s_out);
3597 Py_VISIT(traverse_module_state->__pyx_n_s_out_stderr);
3598 Py_VISIT(traverse_module_state->__pyx_n_s_out_stdout);
3599 Py_VISIT(traverse_module_state->__pyx_kp_u_output);
3600 Py_VISIT(traverse_module_state->__pyx_kp_u_output_file);
3601 Py_VISIT(traverse_module_state->__pyx_n_s_parse_region);
3602 Py_VISIT(traverse_module_state->__pyx_n_s_path);
3603 Py_VISIT(traverse_module_state->__pyx_n_s_pysam_dispatch);
3604 Py_VISIT(traverse_module_state->__pyx_n_s_pysam_dispatch_locals__collect);
3605 Py_VISIT(traverse_module_state->__pyx_kp_u_pysam_latin1replace);
3606 Py_VISIT(traverse_module_state->__pyx_n_s_pysam_libcutils);
3607 Py_VISIT(traverse_module_state->__pyx_kp_s_pysam_libcutils_pyx);
3608 Py_VISIT(traverse_module_state->__pyx_n_s_qualities);
3609 Py_VISIT(traverse_module_state->__pyx_n_s_qualities_to_qualitystring);
3610 Py_VISIT(traverse_module_state->__pyx_n_u_qualities_to_qualitystring);
3611 Py_VISIT(traverse_module_state->__pyx_n_s_qualitystring_to_array);
3612 Py_VISIT(traverse_module_state->__pyx_n_u_qualitystring_to_array);
3613 Py_VISIT(traverse_module_state->__pyx_n_u_r);
3614 Py_VISIT(traverse_module_state->__pyx_n_u_rb);
3615 Py_VISIT(traverse_module_state->__pyx_n_s_re);
3616 Py_VISIT(traverse_module_state->__pyx_n_s_read);
3617 Py_VISIT(traverse_module_state->__pyx_n_s_reference);
3618 Py_VISIT(traverse_module_state->__pyx_n_s_region);
3619 Py_VISIT(traverse_module_state->__pyx_n_s_register_error);
3620 Py_VISIT(traverse_module_state->__pyx_n_s_remove);
3621 Py_VISIT(traverse_module_state->__pyx_n_s_retval);
3622 Py_VISIT(traverse_module_state->__pyx_n_u_roh);
3623 Py_VISIT(traverse_module_state->__pyx_n_b_samtools);
3624 Py_VISIT(traverse_module_state->__pyx_n_u_samtools);
3625 Py_VISIT(traverse_module_state->__pyx_n_s_save_stdout);
3626 Py_VISIT(traverse_module_state->__pyx_n_s_set_encoding_error_handler);
3627 Py_VISIT(traverse_module_state->__pyx_n_u_set_encoding_error_handler);
3628 Py_VISIT(traverse_module_state->__pyx_n_s_skip_next);
3629 Py_VISIT(traverse_module_state->__pyx_n_s_spec);
3630 Py_VISIT(traverse_module_state->__pyx_n_s_split);
3631 Py_VISIT(traverse_module_state->__pyx_n_s_start);
3632 Py_VISIT(traverse_module_state->__pyx_kp_u_start_out_of_range_i);
3633 Py_VISIT(traverse_module_state->__pyx_n_s_startswith);
3634 Py_VISIT(traverse_module_state->__pyx_n_u_stats);
3635 Py_VISIT(traverse_module_state->__pyx_n_s_stderr_f);
3636 Py_VISIT(traverse_module_state->__pyx_n_s_stderr_h);
3637 Py_VISIT(traverse_module_state->__pyx_n_s_stdout_f);
3638 Py_VISIT(traverse_module_state->__pyx_n_s_stdout_h);
3639 Py_VISIT(traverse_module_state->__pyx_n_s_stdout_option);
3640 Py_VISIT(traverse_module_state->__pyx_n_s_stop);
3641 Py_VISIT(traverse_module_state->__pyx_kp_u_stop_and_end_should_not_both_be);
3642 Py_VISIT(traverse_module_state->__pyx_kp_u_stop_out_of_range_i);
3643 Py_VISIT(traverse_module_state->__pyx_n_u_strict);
3644 Py_VISIT(traverse_module_state->__pyx_n_s_string);
3645 Py_VISIT(traverse_module_state->__pyx_n_s_sys);
3646 Py_VISIT(traverse_module_state->__pyx_n_s_tempfile);
3647 Py_VISIT(traverse_module_state->__pyx_n_s_test);
3648 Py_VISIT(traverse_module_state->__pyx_kp_u_threads);
3649 Py_VISIT(traverse_module_state->__pyx_n_s_tobytes);
3650 Py_VISIT(traverse_module_state->__pyx_n_s_types);
3651 Py_VISIT(traverse_module_state->__pyx_kp_u_utf_8);
3652 Py_VISIT(traverse_module_state->__pyx_n_u_view);
3653 Py_VISIT(traverse_module_state->__pyx_int_1);
3654 Py_VISIT(traverse_module_state->__pyx_int_33);
3655 Py_VISIT(traverse_module_state->__pyx_int_neg_1);
3656 Py_VISIT(traverse_module_state->__pyx_tuple__2);
3657 Py_VISIT(traverse_module_state->__pyx_tuple__3);
3658 Py_VISIT(traverse_module_state->__pyx_tuple__4);
3659 Py_VISIT(traverse_module_state->__pyx_tuple__5);
3660 Py_VISIT(traverse_module_state->__pyx_tuple__6);
3661 Py_VISIT(traverse_module_state->__pyx_tuple__9);
3662 Py_VISIT(traverse_module_state->__pyx_tuple__12);
3663 Py_VISIT(traverse_module_state->__pyx_tuple__16);
3664 Py_VISIT(traverse_module_state->__pyx_tuple__18);
3665 Py_VISIT(traverse_module_state->__pyx_tuple__19);
3666 Py_VISIT(traverse_module_state->__pyx_tuple__22);
3667 Py_VISIT(traverse_module_state->__pyx_tuple__25);
3668 Py_VISIT(traverse_module_state->__pyx_tuple__27);
3669 Py_VISIT(traverse_module_state->__pyx_tuple__29);
3670 Py_VISIT(traverse_module_state->__pyx_tuple__30);
3671 Py_VISIT(traverse_module_state->__pyx_tuple__32);
3672 Py_VISIT(traverse_module_state->__pyx_codeobj__13);
3673 Py_VISIT(traverse_module_state->__pyx_codeobj__17);
3674 Py_VISIT(traverse_module_state->__pyx_codeobj__20);
3675 Py_VISIT(traverse_module_state->__pyx_codeobj__21);
3676 Py_VISIT(traverse_module_state->__pyx_codeobj__23);
3677 Py_VISIT(traverse_module_state->__pyx_codeobj__24);
3678 Py_VISIT(traverse_module_state->__pyx_codeobj__26);
3679 Py_VISIT(traverse_module_state->__pyx_codeobj__28);
3680 Py_VISIT(traverse_module_state->__pyx_codeobj__31);
3681 return 0;
3682 }
3683 #endif
3684 /* #### Code section: module_state_defines ### */
3685 #define __pyx_d __pyx_mstate_global->__pyx_d
3686 #define __pyx_b __pyx_mstate_global->__pyx_b
3687 #define __pyx_cython_runtime __pyx_mstate_global->__pyx_cython_runtime
3688 #define __pyx_empty_tuple __pyx_mstate_global->__pyx_empty_tuple
3689 #define __pyx_empty_bytes __pyx_mstate_global->__pyx_empty_bytes
3690 #define __pyx_empty_unicode __pyx_mstate_global->__pyx_empty_unicode
3691 #ifdef __Pyx_CyFunction_USED
3692 #define __pyx_CyFunctionType __pyx_mstate_global->__pyx_CyFunctionType
3693 #endif
3694 #ifdef __Pyx_FusedFunction_USED
3695 #define __pyx_FusedFunctionType __pyx_mstate_global->__pyx_FusedFunctionType
3696 #endif
3697 #ifdef __Pyx_Generator_USED
3698 #define __pyx_GeneratorType __pyx_mstate_global->__pyx_GeneratorType
3699 #endif
3700 #ifdef __Pyx_IterableCoroutine_USED
3701 #define __pyx_IterableCoroutineType __pyx_mstate_global->__pyx_IterableCoroutineType
3702 #endif
3703 #ifdef __Pyx_Coroutine_USED
3704 #define __pyx_CoroutineAwaitType __pyx_mstate_global->__pyx_CoroutineAwaitType
3705 #endif
3706 #ifdef __Pyx_Coroutine_USED
3707 #define __pyx_CoroutineType __pyx_mstate_global->__pyx_CoroutineType
3708 #endif
3709 #if CYTHON_USE_MODULE_STATE
3710 #endif
3711 #if CYTHON_USE_MODULE_STATE
3712 #endif
3713 #if CYTHON_USE_MODULE_STATE
3714 #endif
3715 #if CYTHON_USE_MODULE_STATE
3716 #endif
3717 #define __pyx_ptype_7cpython_4type_type __pyx_mstate_global->__pyx_ptype_7cpython_4type_type
3718 #if CYTHON_USE_MODULE_STATE
3719 #endif
3720 #if CYTHON_USE_MODULE_STATE
3721 #endif
3722 #if CYTHON_USE_MODULE_STATE
3723 #endif
3724 #if CYTHON_USE_MODULE_STATE
3725 #endif
3726 #if CYTHON_USE_MODULE_STATE
3727 #endif
3728 #if CYTHON_USE_MODULE_STATE
3729 #endif
3730 #if CYTHON_USE_MODULE_STATE
3731 #endif
3732 #if CYTHON_USE_MODULE_STATE
3733 #endif
3734 #if CYTHON_USE_MODULE_STATE
3735 #endif
3736 #if CYTHON_USE_MODULE_STATE
3737 #endif
3738 #if CYTHON_USE_MODULE_STATE
3739 #endif
3740 #if CYTHON_USE_MODULE_STATE
3741 #endif
3742 #if CYTHON_USE_MODULE_STATE
3743 #endif
3744 #if CYTHON_USE_MODULE_STATE
3745 #endif
3746 #if CYTHON_USE_MODULE_STATE
3747 #endif
3748 #if CYTHON_USE_MODULE_STATE
3749 #endif
3750 #define __pyx_ptype_7cpython_4bool_bool __pyx_mstate_global->__pyx_ptype_7cpython_4bool_bool
3751 #if CYTHON_USE_MODULE_STATE
3752 #endif
3753 #if CYTHON_USE_MODULE_STATE
3754 #endif
3755 #if CYTHON_USE_MODULE_STATE
3756 #endif
3757 #if CYTHON_USE_MODULE_STATE
3758 #endif
3759 #define __pyx_ptype_7cpython_7complex_complex __pyx_mstate_global->__pyx_ptype_7cpython_7complex_complex
3760 #if CYTHON_USE_MODULE_STATE
3761 #endif
3762 #if CYTHON_USE_MODULE_STATE
3763 #endif
3764 #if CYTHON_USE_MODULE_STATE
3765 #endif
3766 #if CYTHON_USE_MODULE_STATE
3767 #endif
3768 #if CYTHON_USE_MODULE_STATE
3769 #endif
3770 #if CYTHON_USE_MODULE_STATE
3771 #endif
3772 #if CYTHON_USE_MODULE_STATE
3773 #endif
3774 #if CYTHON_USE_MODULE_STATE
3775 #endif
3776 #if CYTHON_USE_MODULE_STATE
3777 #endif
3778 #if CYTHON_USE_MODULE_STATE
3779 #endif
3780 #if CYTHON_USE_MODULE_STATE
3781 #endif
3782 #if CYTHON_USE_MODULE_STATE
3783 #endif
3784 #if CYTHON_USE_MODULE_STATE
3785 #endif
3786 #if CYTHON_USE_MODULE_STATE
3787 #endif
3788 #if CYTHON_USE_MODULE_STATE
3789 #endif
3790 #if CYTHON_USE_MODULE_STATE
3791 #endif
3792 #if CYTHON_USE_MODULE_STATE
3793 #endif
3794 #if CYTHON_USE_MODULE_STATE
3795 #endif
3796 #if CYTHON_USE_MODULE_STATE
3797 #endif
3798 #if CYTHON_USE_MODULE_STATE
3799 #endif
3800 #if CYTHON_USE_MODULE_STATE
3801 #endif
3802 #if CYTHON_USE_MODULE_STATE
3803 #endif
3804 #define __pyx_ptype_7cpython_5array_array __pyx_mstate_global->__pyx_ptype_7cpython_5array_array
3805 #if CYTHON_USE_MODULE_STATE
3806 #endif
3807 #if CYTHON_USE_MODULE_STATE
3808 #endif
3809 #if CYTHON_USE_MODULE_STATE
3810 #endif
3811 #if CYTHON_USE_MODULE_STATE
3812 #endif
3813 #if CYTHON_USE_MODULE_STATE
3814 #endif
3815 #if CYTHON_USE_MODULE_STATE
3816 #endif
3817 #if CYTHON_USE_MODULE_STATE
3818 #endif
3819 #if CYTHON_USE_MODULE_STATE
3820 #endif
3821 #if CYTHON_USE_MODULE_STATE
3822 #endif
3823 #define __pyx_kp_u_ __pyx_mstate_global->__pyx_kp_u_
3824 #define __pyx_n_s_ARGUMENTS __pyx_mstate_global->__pyx_n_s_ARGUMENTS
3825 #define __pyx_kp_u_Argument_must_be_string_bytes_or __pyx_mstate_global->__pyx_kp_u_Argument_must_be_string_bytes_or
3826 #define __pyx_n_u_B __pyx_mstate_global->__pyx_n_u_B
3827 #define __pyx_n_s_IOError __pyx_mstate_global->__pyx_n_s_IOError
3828 #define __pyx_n_s_MAP_STDOUT_OPTIONS __pyx_mstate_global->__pyx_n_s_MAP_STDOUT_OPTIONS
3829 #define __pyx_n_s_MemoryError __pyx_mstate_global->__pyx_n_s_MemoryError
3830 #define __pyx_kp_u_No_such_file_or_directory_s __pyx_mstate_global->__pyx_kp_u_No_such_file_or_directory_s
3831 #define __pyx_n_s_OSError __pyx_mstate_global->__pyx_n_s_OSError
3832 #define __pyx_n_s_OverflowError __pyx_mstate_global->__pyx_n_s_OverflowError
3833 #define __pyx_n_s_TypeError __pyx_mstate_global->__pyx_n_s_TypeError
3834 #define __pyx_n_s_UnicodeDecodeError __pyx_mstate_global->__pyx_n_s_UnicodeDecodeError
3835 #define __pyx_n_s_ValueError __pyx_mstate_global->__pyx_n_s_ValueError
3836 #define __pyx_kp_u__10 __pyx_mstate_global->__pyx_kp_u__10
3837 #define __pyx_kp_u__11 __pyx_mstate_global->__pyx_kp_u__11
3838 #define __pyx_n_s__14 __pyx_mstate_global->__pyx_n_s__14
3839 #define __pyx_kp_u__15 __pyx_mstate_global->__pyx_kp_u__15
3840 #define __pyx_n_s__33 __pyx_mstate_global->__pyx_n_s__33
3841 #define __pyx_kp_u__7 __pyx_mstate_global->__pyx_kp_u__7
3842 #define __pyx_kp_u__8 __pyx_mstate_global->__pyx_kp_u__8
3843 #define __pyx_n_s_a __pyx_mstate_global->__pyx_n_s_a
3844 #define __pyx_n_s_all __pyx_mstate_global->__pyx_n_s_all
3845 #define __pyx_n_s_arg __pyx_mstate_global->__pyx_n_s_arg
3846 #define __pyx_n_s_args __pyx_mstate_global->__pyx_n_s_args
3847 #define __pyx_n_s_array_to_qualitystring __pyx_mstate_global->__pyx_n_s_array_to_qualitystring
3848 #define __pyx_n_u_array_to_qualitystring __pyx_mstate_global->__pyx_n_u_array_to_qualitystring
3849 #define __pyx_n_u_ascii __pyx_mstate_global->__pyx_n_u_ascii
3850 #define __pyx_n_s_asyncio_coroutines __pyx_mstate_global->__pyx_n_s_asyncio_coroutines
3851 #define __pyx_n_b_bcftools __pyx_mstate_global->__pyx_n_b_bcftools
3852 #define __pyx_n_u_bcftools __pyx_mstate_global->__pyx_n_u_bcftools
3853 #define __pyx_kp_u_c __pyx_mstate_global->__pyx_kp_u_c
3854 #define __pyx_n_u_calmd __pyx_mstate_global->__pyx_n_u_calmd
3855 #define __pyx_n_s_cargs __pyx_mstate_global->__pyx_n_s_cargs
3856 #define __pyx_n_s_catch_stdout __pyx_mstate_global->__pyx_n_s_catch_stdout
3857 #define __pyx_n_s_chr __pyx_mstate_global->__pyx_n_s_chr
3858 #define __pyx_n_s_class_getitem __pyx_mstate_global->__pyx_n_s_class_getitem
3859 #define __pyx_n_s_cline_in_traceback __pyx_mstate_global->__pyx_n_s_cline_in_traceback
3860 #define __pyx_n_s_close __pyx_mstate_global->__pyx_n_s_close
3861 #define __pyx_n_s_codecs __pyx_mstate_global->__pyx_n_s_codecs
3862 #define __pyx_n_s_collect __pyx_mstate_global->__pyx_n_s_collect
3863 #define __pyx_n_s_collection __pyx_mstate_global->__pyx_n_s_collection
3864 #define __pyx_n_s_contextlib __pyx_mstate_global->__pyx_n_s_contextlib
3865 #define __pyx_n_s_contextmanager __pyx_mstate_global->__pyx_n_s_contextmanager
3866 #define __pyx_n_s_contig __pyx_mstate_global->__pyx_n_s_contig
3867 #define __pyx_kp_u_contig_and_reference_should_not __pyx_mstate_global->__pyx_kp_u_contig_and_reference_should_not
3868 #define __pyx_kp_u_contig_reference_and_region_shou __pyx_mstate_global->__pyx_kp_u_contig_reference_and_region_shou
3869 #define __pyx_n_s_decode __pyx_mstate_global->__pyx_n_s_decode
3870 #define __pyx_n_u_depad __pyx_mstate_global->__pyx_n_u_depad
3871 #define __pyx_n_s_encode __pyx_mstate_global->__pyx_n_s_encode
3872 #define __pyx_n_s_end __pyx_mstate_global->__pyx_n_s_end
3873 #define __pyx_n_s_enter __pyx_mstate_global->__pyx_n_s_enter
3874 #define __pyx_kp_u_error_while_opening_file_for_wri __pyx_mstate_global->__pyx_kp_u_error_while_opening_file_for_wri
3875 #define __pyx_n_s_exception __pyx_mstate_global->__pyx_n_s_exception
3876 #define __pyx_n_s_exists __pyx_mstate_global->__pyx_n_s_exists
3877 #define __pyx_n_s_exit __pyx_mstate_global->__pyx_n_s_exit
3878 #define __pyx_n_s_extend __pyx_mstate_global->__pyx_n_s_extend
3879 #define __pyx_n_s_extra_args __pyx_mstate_global->__pyx_n_s_extra_args
3880 #define __pyx_n_s_fn __pyx_mstate_global->__pyx_n_s_fn
3881 #define __pyx_n_s_format __pyx_mstate_global->__pyx_n_s_format
3882 #define __pyx_n_s_fsencode __pyx_mstate_global->__pyx_n_s_fsencode
3883 #define __pyx_n_s_get_encoding_error_handler __pyx_mstate_global->__pyx_n_s_get_encoding_error_handler
3884 #define __pyx_n_u_get_encoding_error_handler __pyx_mstate_global->__pyx_n_u_get_encoding_error_handler
3885 #define __pyx_n_s_getdefaultencoding __pyx_mstate_global->__pyx_n_s_getdefaultencoding
3886 #define __pyx_n_s_getfilesystemencoding __pyx_mstate_global->__pyx_n_s_getfilesystemencoding
3887 #define __pyx_n_u_head __pyx_mstate_global->__pyx_n_u_head
3888 #define __pyx_n_s_i __pyx_mstate_global->__pyx_n_s_i
3889 #define __pyx_n_s_import __pyx_mstate_global->__pyx_n_s_import
3890 #define __pyx_n_b_index __pyx_mstate_global->__pyx_n_b_index
3891 #define __pyx_n_u_index __pyx_mstate_global->__pyx_n_u_index
3892 #define __pyx_n_s_inf __pyx_mstate_global->__pyx_n_s_inf
3893 #define __pyx_n_s_initializing __pyx_mstate_global->__pyx_n_s_initializing
3894 #define __pyx_n_s_input_str __pyx_mstate_global->__pyx_n_s_input_str
3895 #define __pyx_kp_u_invalid_coordinates_start_i_stop __pyx_mstate_global->__pyx_kp_u_invalid_coordinates_start_i_stop
3896 #define __pyx_n_s_io __pyx_mstate_global->__pyx_n_s_io
3897 #define __pyx_n_s_is_coroutine __pyx_mstate_global->__pyx_n_s_is_coroutine
3898 #define __pyx_n_s_is_usage __pyx_mstate_global->__pyx_n_s_is_usage
3899 #define __pyx_n_s_l __pyx_mstate_global->__pyx_n_s_l
3900 #define __pyx_n_s_latin1_replace __pyx_mstate_global->__pyx_n_s_latin1_replace
3901 #define __pyx_kp_u_m __pyx_mstate_global->__pyx_kp_u_m
3902 #define __pyx_n_s_main __pyx_mstate_global->__pyx_n_s_main
3903 #define __pyx_n_s_method __pyx_mstate_global->__pyx_n_s_method
3904 #define __pyx_kp_u_min_shift __pyx_mstate_global->__pyx_kp_u_min_shift
3905 #define __pyx_n_s_mkstemp __pyx_mstate_global->__pyx_n_s_mkstemp
3906 #define __pyx_n_u_mpileup __pyx_mstate_global->__pyx_n_u_mpileup
3907 #define __pyx_n_s_n __pyx_mstate_global->__pyx_n_s_n
3908 #define __pyx_n_s_name __pyx_mstate_global->__pyx_n_s_name
3909 #define __pyx_n_s_name_2 __pyx_mstate_global->__pyx_n_s_name_2
3910 #define __pyx_kp_u_neither_contig_nor_region_are_gi __pyx_mstate_global->__pyx_kp_u_neither_contig_nor_region_are_gi
3911 #define __pyx_kp_u_o __pyx_mstate_global->__pyx_kp_u_o
3912 #define __pyx_kp_u_o_2 __pyx_mstate_global->__pyx_kp_u_o_2
3913 #define __pyx_n_s_object __pyx_mstate_global->__pyx_n_s_object
3914 #define __pyx_n_s_offset __pyx_mstate_global->__pyx_n_s_offset
3915 #define __pyx_n_s_open __pyx_mstate_global->__pyx_n_s_open
3916 #define __pyx_n_s_os __pyx_mstate_global->__pyx_n_s_os
3917 #define __pyx_n_s_out __pyx_mstate_global->__pyx_n_s_out
3918 #define __pyx_n_s_out_stderr __pyx_mstate_global->__pyx_n_s_out_stderr
3919 #define __pyx_n_s_out_stdout __pyx_mstate_global->__pyx_n_s_out_stdout
3920 #define __pyx_kp_u_output __pyx_mstate_global->__pyx_kp_u_output
3921 #define __pyx_kp_u_output_file __pyx_mstate_global->__pyx_kp_u_output_file
3922 #define __pyx_n_s_parse_region __pyx_mstate_global->__pyx_n_s_parse_region
3923 #define __pyx_n_s_path __pyx_mstate_global->__pyx_n_s_path
3924 #define __pyx_n_s_pysam_dispatch __pyx_mstate_global->__pyx_n_s_pysam_dispatch
3925 #define __pyx_n_s_pysam_dispatch_locals__collect __pyx_mstate_global->__pyx_n_s_pysam_dispatch_locals__collect
3926 #define __pyx_kp_u_pysam_latin1replace __pyx_mstate_global->__pyx_kp_u_pysam_latin1replace
3927 #define __pyx_n_s_pysam_libcutils __pyx_mstate_global->__pyx_n_s_pysam_libcutils
3928 #define __pyx_kp_s_pysam_libcutils_pyx __pyx_mstate_global->__pyx_kp_s_pysam_libcutils_pyx
3929 #define __pyx_n_s_qualities __pyx_mstate_global->__pyx_n_s_qualities
3930 #define __pyx_n_s_qualities_to_qualitystring __pyx_mstate_global->__pyx_n_s_qualities_to_qualitystring
3931 #define __pyx_n_u_qualities_to_qualitystring __pyx_mstate_global->__pyx_n_u_qualities_to_qualitystring
3932 #define __pyx_n_s_qualitystring_to_array __pyx_mstate_global->__pyx_n_s_qualitystring_to_array
3933 #define __pyx_n_u_qualitystring_to_array __pyx_mstate_global->__pyx_n_u_qualitystring_to_array
3934 #define __pyx_n_u_r __pyx_mstate_global->__pyx_n_u_r
3935 #define __pyx_n_u_rb __pyx_mstate_global->__pyx_n_u_rb
3936 #define __pyx_n_s_re __pyx_mstate_global->__pyx_n_s_re
3937 #define __pyx_n_s_read __pyx_mstate_global->__pyx_n_s_read
3938 #define __pyx_n_s_reference __pyx_mstate_global->__pyx_n_s_reference
3939 #define __pyx_n_s_region __pyx_mstate_global->__pyx_n_s_region
3940 #define __pyx_n_s_register_error __pyx_mstate_global->__pyx_n_s_register_error
3941 #define __pyx_n_s_remove __pyx_mstate_global->__pyx_n_s_remove
3942 #define __pyx_n_s_retval __pyx_mstate_global->__pyx_n_s_retval
3943 #define __pyx_n_u_roh __pyx_mstate_global->__pyx_n_u_roh
3944 #define __pyx_n_b_samtools __pyx_mstate_global->__pyx_n_b_samtools
3945 #define __pyx_n_u_samtools __pyx_mstate_global->__pyx_n_u_samtools
3946 #define __pyx_n_s_save_stdout __pyx_mstate_global->__pyx_n_s_save_stdout
3947 #define __pyx_n_s_set_encoding_error_handler __pyx_mstate_global->__pyx_n_s_set_encoding_error_handler
3948 #define __pyx_n_u_set_encoding_error_handler __pyx_mstate_global->__pyx_n_u_set_encoding_error_handler
3949 #define __pyx_n_s_skip_next __pyx_mstate_global->__pyx_n_s_skip_next
3950 #define __pyx_n_s_spec __pyx_mstate_global->__pyx_n_s_spec
3951 #define __pyx_n_s_split __pyx_mstate_global->__pyx_n_s_split
3952 #define __pyx_n_s_start __pyx_mstate_global->__pyx_n_s_start
3953 #define __pyx_kp_u_start_out_of_range_i __pyx_mstate_global->__pyx_kp_u_start_out_of_range_i
3954 #define __pyx_n_s_startswith __pyx_mstate_global->__pyx_n_s_startswith
3955 #define __pyx_n_u_stats __pyx_mstate_global->__pyx_n_u_stats
3956 #define __pyx_n_s_stderr_f __pyx_mstate_global->__pyx_n_s_stderr_f
3957 #define __pyx_n_s_stderr_h __pyx_mstate_global->__pyx_n_s_stderr_h
3958 #define __pyx_n_s_stdout_f __pyx_mstate_global->__pyx_n_s_stdout_f
3959 #define __pyx_n_s_stdout_h __pyx_mstate_global->__pyx_n_s_stdout_h
3960 #define __pyx_n_s_stdout_option __pyx_mstate_global->__pyx_n_s_stdout_option
3961 #define __pyx_n_s_stop __pyx_mstate_global->__pyx_n_s_stop
3962 #define __pyx_kp_u_stop_and_end_should_not_both_be __pyx_mstate_global->__pyx_kp_u_stop_and_end_should_not_both_be
3963 #define __pyx_kp_u_stop_out_of_range_i __pyx_mstate_global->__pyx_kp_u_stop_out_of_range_i
3964 #define __pyx_n_u_strict __pyx_mstate_global->__pyx_n_u_strict
3965 #define __pyx_n_s_string __pyx_mstate_global->__pyx_n_s_string
3966 #define __pyx_n_s_sys __pyx_mstate_global->__pyx_n_s_sys
3967 #define __pyx_n_s_tempfile __pyx_mstate_global->__pyx_n_s_tempfile
3968 #define __pyx_n_s_test __pyx_mstate_global->__pyx_n_s_test
3969 #define __pyx_kp_u_threads __pyx_mstate_global->__pyx_kp_u_threads
3970 #define __pyx_n_s_tobytes __pyx_mstate_global->__pyx_n_s_tobytes
3971 #define __pyx_n_s_types __pyx_mstate_global->__pyx_n_s_types
3972 #define __pyx_kp_u_utf_8 __pyx_mstate_global->__pyx_kp_u_utf_8
3973 #define __pyx_n_u_view __pyx_mstate_global->__pyx_n_u_view
3974 #define __pyx_int_1 __pyx_mstate_global->__pyx_int_1
3975 #define __pyx_int_33 __pyx_mstate_global->__pyx_int_33
3976 #define __pyx_int_neg_1 __pyx_mstate_global->__pyx_int_neg_1
3977 #define __pyx_tuple__2 __pyx_mstate_global->__pyx_tuple__2
3978 #define __pyx_tuple__3 __pyx_mstate_global->__pyx_tuple__3
3979 #define __pyx_tuple__4 __pyx_mstate_global->__pyx_tuple__4
3980 #define __pyx_tuple__5 __pyx_mstate_global->__pyx_tuple__5
3981 #define __pyx_tuple__6 __pyx_mstate_global->__pyx_tuple__6
3982 #define __pyx_tuple__9 __pyx_mstate_global->__pyx_tuple__9
3983 #define __pyx_tuple__12 __pyx_mstate_global->__pyx_tuple__12
3984 #define __pyx_tuple__16 __pyx_mstate_global->__pyx_tuple__16
3985 #define __pyx_tuple__18 __pyx_mstate_global->__pyx_tuple__18
3986 #define __pyx_tuple__19 __pyx_mstate_global->__pyx_tuple__19
3987 #define __pyx_tuple__22 __pyx_mstate_global->__pyx_tuple__22
3988 #define __pyx_tuple__25 __pyx_mstate_global->__pyx_tuple__25
3989 #define __pyx_tuple__27 __pyx_mstate_global->__pyx_tuple__27
3990 #define __pyx_tuple__29 __pyx_mstate_global->__pyx_tuple__29
3991 #define __pyx_tuple__30 __pyx_mstate_global->__pyx_tuple__30
3992 #define __pyx_tuple__32 __pyx_mstate_global->__pyx_tuple__32
3993 #define __pyx_codeobj__13 __pyx_mstate_global->__pyx_codeobj__13
3994 #define __pyx_codeobj__17 __pyx_mstate_global->__pyx_codeobj__17
3995 #define __pyx_codeobj__20 __pyx_mstate_global->__pyx_codeobj__20
3996 #define __pyx_codeobj__21 __pyx_mstate_global->__pyx_codeobj__21
3997 #define __pyx_codeobj__23 __pyx_mstate_global->__pyx_codeobj__23
3998 #define __pyx_codeobj__24 __pyx_mstate_global->__pyx_codeobj__24
3999 #define __pyx_codeobj__26 __pyx_mstate_global->__pyx_codeobj__26
4000 #define __pyx_codeobj__28 __pyx_mstate_global->__pyx_codeobj__28
4001 #define __pyx_codeobj__31 __pyx_mstate_global->__pyx_codeobj__31
4002 /* #### Code section: module_code ### */
4003
4004 /* "cpython/complex.pxd":19
4005 *
4006 * @property
4007 * cdef inline double real(self) noexcept: # <<<<<<<<<<<<<<
4008 * return self.cval.real
4009 *
4010 */
4011
4012 static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4real_real(PyComplexObject *__pyx_v_self) {
4013 double __pyx_r;
4014
4015 /* "cpython/complex.pxd":20
4016 * @property
4017 * cdef inline double real(self) noexcept:
4018 * return self.cval.real # <<<<<<<<<<<<<<
4019 *
4020 * @property
4021 */
4022 __pyx_r = __pyx_v_self->cval.real;
4023 goto __pyx_L0;
4024
4025 /* "cpython/complex.pxd":19
4026 *
4027 * @property
4028 * cdef inline double real(self) noexcept: # <<<<<<<<<<<<<<
4029 * return self.cval.real
4030 *
4031 */
4032
4033 /* function exit code */
4034 __pyx_L0:;
4035 return __pyx_r;
4036 }
4037
4038 /* "cpython/complex.pxd":23
4039 *
4040 * @property
4041 * cdef inline double imag(self) noexcept: # <<<<<<<<<<<<<<
4042 * return self.cval.imag
4043 *
4044 */
4045
4046 static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4imag_imag(PyComplexObject *__pyx_v_self) {
4047 double __pyx_r;
4048
4049 /* "cpython/complex.pxd":24
4050 * @property
4051 * cdef inline double imag(self) noexcept:
4052 * return self.cval.imag # <<<<<<<<<<<<<<
4053 *
4054 * # PyTypeObject PyComplex_Type
4055 */
4056 __pyx_r = __pyx_v_self->cval.imag;
4057 goto __pyx_L0;
4058
4059 /* "cpython/complex.pxd":23
4060 *
4061 * @property
4062 * cdef inline double imag(self) noexcept: # <<<<<<<<<<<<<<
4063 * return self.cval.imag
4064 *
4065 */
4066
4067 /* function exit code */
4068 __pyx_L0:;
4069 return __pyx_r;
4070 }
4071
4072 /* "cpython/contextvars.pxd":112
4073 *
4074 *
4075 * cdef inline object get_value(var, default_value=None): # <<<<<<<<<<<<<<
4076 * """Return a new reference to the value of the context variable,
4077 * or the default value of the context variable,
4078 */
4079
4080 static CYTHON_INLINE PyObject *__pyx_f_7cpython_11contextvars_get_value(PyObject *__pyx_v_var, struct __pyx_opt_args_7cpython_11contextvars_get_value *__pyx_optional_args) {
4081 PyObject *__pyx_v_default_value = ((PyObject *)Py_None);
4082 PyObject *__pyx_v_value;
4083 PyObject *__pyx_v_pyvalue = NULL;
4084 PyObject *__pyx_r = NULL;
4085 __Pyx_RefNannyDeclarations
4086 int __pyx_t_1;
4087 int __pyx_t_2;
4088 PyObject *__pyx_t_3 = NULL;
4089 int __pyx_lineno = 0;
4090 const char *__pyx_filename = NULL;
4091 int __pyx_clineno = 0;
4092 __Pyx_RefNannySetupContext("get_value", 1);
4093 if (__pyx_optional_args) {
4094 if (__pyx_optional_args->__pyx_n > 0) {
4095 __pyx_v_default_value = __pyx_optional_args->default_value;
4096 }
4097 }
4098
4099 /* "cpython/contextvars.pxd":117
4100 * or None if no such value or default was found.
4101 * """
4102 * cdef PyObject *value = NULL # <<<<<<<<<<<<<<
4103 * PyContextVar_Get(var, NULL, &value)
4104 * if value is NULL:
4105 */
4106 __pyx_v_value = NULL;
4107
4108 /* "cpython/contextvars.pxd":118
4109 * """
4110 * cdef PyObject *value = NULL
4111 * PyContextVar_Get(var, NULL, &value) # <<<<<<<<<<<<<<
4112 * if value is NULL:
4113 * # context variable does not have a default
4114 */
4115 __pyx_t_1 = PyContextVar_Get(__pyx_v_var, NULL, (&__pyx_v_value)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(1, 118, __pyx_L1_error)
4116
4117 /* "cpython/contextvars.pxd":119
4118 * cdef PyObject *value = NULL
4119 * PyContextVar_Get(var, NULL, &value)
4120 * if value is NULL: # <<<<<<<<<<<<<<
4121 * # context variable does not have a default
4122 * pyvalue = default_value
4123 */
4124 __pyx_t_2 = (__pyx_v_value == NULL);
4125 if (__pyx_t_2) {
4126
4127 /* "cpython/contextvars.pxd":121
4128 * if value is NULL:
4129 * # context variable does not have a default
4130 * pyvalue = default_value # <<<<<<<<<<<<<<
4131 * else:
4132 * # value or default value of context variable
4133 */
4134 __Pyx_INCREF(__pyx_v_default_value);
4135 __pyx_v_pyvalue = __pyx_v_default_value;
4136
4137 /* "cpython/contextvars.pxd":119
4138 * cdef PyObject *value = NULL
4139 * PyContextVar_Get(var, NULL, &value)
4140 * if value is NULL: # <<<<<<<<<<<<<<
4141 * # context variable does not have a default
4142 * pyvalue = default_value
4143 */
4144 goto __pyx_L3;
4145 }
4146
4147 /* "cpython/contextvars.pxd":124
4148 * else:
4149 * # value or default value of context variable
4150 * pyvalue = <object>value # <<<<<<<<<<<<<<
4151 * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*'
4152 * return pyvalue
4153 */
4154 /*else*/ {
4155 __pyx_t_3 = ((PyObject *)__pyx_v_value);
4156 __Pyx_INCREF(__pyx_t_3);
4157 __pyx_v_pyvalue = __pyx_t_3;
4158 __pyx_t_3 = 0;
4159
4160 /* "cpython/contextvars.pxd":125
4161 * # value or default value of context variable
4162 * pyvalue = <object>value
4163 * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' # <<<<<<<<<<<<<<
4164 * return pyvalue
4165 *
4166 */
4167 Py_XDECREF(__pyx_v_value);
4168 }
4169 __pyx_L3:;
4170
4171 /* "cpython/contextvars.pxd":126
4172 * pyvalue = <object>value
4173 * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*'
4174 * return pyvalue # <<<<<<<<<<<<<<
4175 *
4176 *
4177 */
4178 __Pyx_XDECREF(__pyx_r);
4179 __Pyx_INCREF(__pyx_v_pyvalue);
4180 __pyx_r = __pyx_v_pyvalue;
4181 goto __pyx_L0;
4182
4183 /* "cpython/contextvars.pxd":112
4184 *
4185 *
4186 * cdef inline object get_value(var, default_value=None): # <<<<<<<<<<<<<<
4187 * """Return a new reference to the value of the context variable,
4188 * or the default value of the context variable,
4189 */
4190
4191 /* function exit code */
4192 __pyx_L1_error:;
4193 __Pyx_XDECREF(__pyx_t_3);
4194 __Pyx_AddTraceback("cpython.contextvars.get_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
4195 __pyx_r = 0;
4196 __pyx_L0:;
4197 __Pyx_XDECREF(__pyx_v_pyvalue);
4198 __Pyx_XGIVEREF(__pyx_r);
4199 __Pyx_RefNannyFinishContext();
4200 return __pyx_r;
4201 }
4202
4203 /* "cpython/contextvars.pxd":129
4204 *
4205 *
4206 * cdef inline object get_value_no_default(var, default_value=None): # <<<<<<<<<<<<<<
4207 * """Return a new reference to the value of the context variable,
4208 * or the provided default value if no such value was found.
4209 */
4210
4211 static CYTHON_INLINE PyObject *__pyx_f_7cpython_11contextvars_get_value_no_default(PyObject *__pyx_v_var, struct __pyx_opt_args_7cpython_11contextvars_get_value_no_default *__pyx_optional_args) {
4212 PyObject *__pyx_v_default_value = ((PyObject *)Py_None);
4213 PyObject *__pyx_v_value;
4214 PyObject *__pyx_v_pyvalue = NULL;
4215 PyObject *__pyx_r = NULL;
4216 __Pyx_RefNannyDeclarations
4217 int __pyx_t_1;
4218 PyObject *__pyx_t_2 = NULL;
4219 int __pyx_lineno = 0;
4220 const char *__pyx_filename = NULL;
4221 int __pyx_clineno = 0;
4222 __Pyx_RefNannySetupContext("get_value_no_default", 1);
4223 if (__pyx_optional_args) {
4224 if (__pyx_optional_args->__pyx_n > 0) {
4225 __pyx_v_default_value = __pyx_optional_args->default_value;
4226 }
4227 }
4228
4229 /* "cpython/contextvars.pxd":135
4230 * Ignores the default value of the context variable, if any.
4231 * """
4232 * cdef PyObject *value = NULL # <<<<<<<<<<<<<<
4233 * PyContextVar_Get(var, <PyObject*>default_value, &value)
4234 * # value of context variable or 'default_value'
4235 */
4236 __pyx_v_value = NULL;
4237
4238 /* "cpython/contextvars.pxd":136
4239 * """
4240 * cdef PyObject *value = NULL
4241 * PyContextVar_Get(var, <PyObject*>default_value, &value) # <<<<<<<<<<<<<<
4242 * # value of context variable or 'default_value'
4243 * pyvalue = <object>value
4244 */
4245 __pyx_t_1 = PyContextVar_Get(__pyx_v_var, ((PyObject *)__pyx_v_default_value), (&__pyx_v_value)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(1, 136, __pyx_L1_error)
4246
4247 /* "cpython/contextvars.pxd":138
4248 * PyContextVar_Get(var, <PyObject*>default_value, &value)
4249 * # value of context variable or 'default_value'
4250 * pyvalue = <object>value # <<<<<<<<<<<<<<
4251 * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*'
4252 * return pyvalue
4253 */
4254 __pyx_t_2 = ((PyObject *)__pyx_v_value);
4255 __Pyx_INCREF(__pyx_t_2);
4256 __pyx_v_pyvalue = __pyx_t_2;
4257 __pyx_t_2 = 0;
4258
4259 /* "cpython/contextvars.pxd":139
4260 * # value of context variable or 'default_value'
4261 * pyvalue = <object>value
4262 * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' # <<<<<<<<<<<<<<
4263 * return pyvalue
4264 */
4265 Py_XDECREF(__pyx_v_value);
4266
4267 /* "cpython/contextvars.pxd":140
4268 * pyvalue = <object>value
4269 * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*'
4270 * return pyvalue # <<<<<<<<<<<<<<
4271 */
4272 __Pyx_XDECREF(__pyx_r);
4273 __Pyx_INCREF(__pyx_v_pyvalue);
4274 __pyx_r = __pyx_v_pyvalue;
4275 goto __pyx_L0;
4276
4277 /* "cpython/contextvars.pxd":129
4278 *
4279 *
4280 * cdef inline object get_value_no_default(var, default_value=None): # <<<<<<<<<<<<<<
4281 * """Return a new reference to the value of the context variable,
4282 * or the provided default value if no such value was found.
4283 */
4284
4285 /* function exit code */
4286 __pyx_L1_error:;
4287 __Pyx_XDECREF(__pyx_t_2);
4288 __Pyx_AddTraceback("cpython.contextvars.get_value_no_default", __pyx_clineno, __pyx_lineno, __pyx_filename);
4289 __pyx_r = 0;
4290 __pyx_L0:;
4291 __Pyx_XDECREF(__pyx_v_pyvalue);
4292 __Pyx_XGIVEREF(__pyx_r);
4293 __Pyx_RefNannyFinishContext();
4294 return __pyx_r;
4295 }
4296
4297 /* "array.pxd":104
4298 * __data_union data
4299 *
4300 * def __getbuffer__(self, Py_buffer* info, int flags): # <<<<<<<<<<<<<<
4301 * # This implementation of getbuffer is geared towards Cython
4302 * # requirements, and does not yet fulfill the PEP.
4303 */
4304
4305 /* Python wrapper */
4306 CYTHON_UNUSED static int __pyx_pw_7cpython_5array_5array_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
4307 CYTHON_UNUSED static int __pyx_pw_7cpython_5array_5array_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
4308 CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
4309 int __pyx_r;
4310 __Pyx_RefNannyDeclarations
4311 __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
4312 __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
4313 __pyx_r = __pyx_pf_7cpython_5array_5array___getbuffer__(((arrayobject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
4314
4315 /* function exit code */
4316 __Pyx_RefNannyFinishContext();
4317 return __pyx_r;
4318 }
4319
4320 static int __pyx_pf_7cpython_5array_5array___getbuffer__(arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info, CYTHON_UNUSED int __pyx_v_flags) {
4321 PyObject *__pyx_v_item_count = NULL;
4322 int __pyx_r;
4323 __Pyx_RefNannyDeclarations
4324 PyObject *__pyx_t_1 = NULL;
4325 char *__pyx_t_2;
4326 int __pyx_t_3;
4327 PyObject *__pyx_t_4 = NULL;
4328 Py_ssize_t __pyx_t_5;
4329 int __pyx_t_6;
4330 char __pyx_t_7;
4331 int __pyx_lineno = 0;
4332 const char *__pyx_filename = NULL;
4333 int __pyx_clineno = 0;
4334 if (unlikely(__pyx_v_info == NULL)) {
4335 PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
4336 return -1;
4337 }
4338 __Pyx_RefNannySetupContext("__getbuffer__", 0);
4339 __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
4340 __Pyx_GIVEREF(__pyx_v_info->obj);
4341
4342 /* "array.pxd":109
4343 * # In particular strided access is always provided regardless
4344 * # of flags
4345 * item_count = Py_SIZE(self) # <<<<<<<<<<<<<<
4346 *
4347 * info.suboffsets = NULL
4348 */
4349 __pyx_t_1 = PyInt_FromSsize_t(Py_SIZE(((PyObject *)__pyx_v_self))); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 109, __pyx_L1_error)
4350 __Pyx_GOTREF(__pyx_t_1);
4351 __pyx_v_item_count = __pyx_t_1;
4352 __pyx_t_1 = 0;
4353
4354 /* "array.pxd":111
4355 * item_count = Py_SIZE(self)
4356 *
4357 * info.suboffsets = NULL # <<<<<<<<<<<<<<
4358 * info.buf = self.data.as_chars
4359 * info.readonly = 0
4360 */
4361 __pyx_v_info->suboffsets = NULL;
4362
4363 /* "array.pxd":112
4364 *
4365 * info.suboffsets = NULL
4366 * info.buf = self.data.as_chars # <<<<<<<<<<<<<<
4367 * info.readonly = 0
4368 * info.ndim = 1
4369 */
4370 __pyx_t_2 = __pyx_v_self->data.as_chars;
4371 __pyx_v_info->buf = __pyx_t_2;
4372
4373 /* "array.pxd":113
4374 * info.suboffsets = NULL
4375 * info.buf = self.data.as_chars
4376 * info.readonly = 0 # <<<<<<<<<<<<<<
4377 * info.ndim = 1
4378 * info.itemsize = self.ob_descr.itemsize # e.g. sizeof(float)
4379 */
4380 __pyx_v_info->readonly = 0;
4381
4382 /* "array.pxd":114
4383 * info.buf = self.data.as_chars
4384 * info.readonly = 0
4385 * info.ndim = 1 # <<<<<<<<<<<<<<
4386 * info.itemsize = self.ob_descr.itemsize # e.g. sizeof(float)
4387 * info.len = info.itemsize * item_count
4388 */
4389 __pyx_v_info->ndim = 1;
4390
4391 /* "array.pxd":115
4392 * info.readonly = 0
4393 * info.ndim = 1
4394 * info.itemsize = self.ob_descr.itemsize # e.g. sizeof(float) # <<<<<<<<<<<<<<
4395 * info.len = info.itemsize * item_count
4396 *
4397 */
4398 __pyx_t_3 = __pyx_v_self->ob_descr->itemsize;
4399 __pyx_v_info->itemsize = __pyx_t_3;
4400
4401 /* "array.pxd":116
4402 * info.ndim = 1
4403 * info.itemsize = self.ob_descr.itemsize # e.g. sizeof(float)
4404 * info.len = info.itemsize * item_count # <<<<<<<<<<<<<<
4405 *
4406 * info.shape = <Py_ssize_t*> PyObject_Malloc(sizeof(Py_ssize_t) + 2)
4407 */
4408 __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_info->itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 116, __pyx_L1_error)
4409 __Pyx_GOTREF(__pyx_t_1);
4410 __pyx_t_4 = PyNumber_Multiply(__pyx_t_1, __pyx_v_item_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 116, __pyx_L1_error)
4411 __Pyx_GOTREF(__pyx_t_4);
4412 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4413 __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 116, __pyx_L1_error)
4414 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4415 __pyx_v_info->len = __pyx_t_5;
4416
4417 /* "array.pxd":118
4418 * info.len = info.itemsize * item_count
4419 *
4420 * info.shape = <Py_ssize_t*> PyObject_Malloc(sizeof(Py_ssize_t) + 2) # <<<<<<<<<<<<<<
4421 * if not info.shape:
4422 * raise MemoryError()
4423 */
4424 __pyx_v_info->shape = ((Py_ssize_t *)PyObject_Malloc(((sizeof(Py_ssize_t)) + 2)));
4425
4426 /* "array.pxd":119
4427 *
4428 * info.shape = <Py_ssize_t*> PyObject_Malloc(sizeof(Py_ssize_t) + 2)
4429 * if not info.shape: # <<<<<<<<<<<<<<
4430 * raise MemoryError()
4431 * info.shape[0] = item_count # constant regardless of resizing
4432 */
4433 __pyx_t_6 = (!(__pyx_v_info->shape != 0));
4434 if (unlikely(__pyx_t_6)) {
4435
4436 /* "array.pxd":120
4437 * info.shape = <Py_ssize_t*> PyObject_Malloc(sizeof(Py_ssize_t) + 2)
4438 * if not info.shape:
4439 * raise MemoryError() # <<<<<<<<<<<<<<
4440 * info.shape[0] = item_count # constant regardless of resizing
4441 * info.strides = &info.itemsize
4442 */
4443 PyErr_NoMemory(); __PYX_ERR(2, 120, __pyx_L1_error)
4444
4445 /* "array.pxd":119
4446 *
4447 * info.shape = <Py_ssize_t*> PyObject_Malloc(sizeof(Py_ssize_t) + 2)
4448 * if not info.shape: # <<<<<<<<<<<<<<
4449 * raise MemoryError()
4450 * info.shape[0] = item_count # constant regardless of resizing
4451 */
4452 }
4453
4454 /* "array.pxd":121
4455 * if not info.shape:
4456 * raise MemoryError()
4457 * info.shape[0] = item_count # constant regardless of resizing # <<<<<<<<<<<<<<
4458 * info.strides = &info.itemsize
4459 *
4460 */
4461 __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_item_count); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(2, 121, __pyx_L1_error)
4462 (__pyx_v_info->shape[0]) = __pyx_t_5;
4463
4464 /* "array.pxd":122
4465 * raise MemoryError()
4466 * info.shape[0] = item_count # constant regardless of resizing
4467 * info.strides = &info.itemsize # <<<<<<<<<<<<<<
4468 *
4469 * info.format = <char*> (info.shape + 1)
4470 */
4471 __pyx_v_info->strides = (&__pyx_v_info->itemsize);
4472
4473 /* "array.pxd":124
4474 * info.strides = &info.itemsize
4475 *
4476 * info.format = <char*> (info.shape + 1) # <<<<<<<<<<<<<<
4477 * info.format[0] = self.ob_descr.typecode
4478 * info.format[1] = 0
4479 */
4480 __pyx_v_info->format = ((char *)(__pyx_v_info->shape + 1));
4481
4482 /* "array.pxd":125
4483 *
4484 * info.format = <char*> (info.shape + 1)
4485 * info.format[0] = self.ob_descr.typecode # <<<<<<<<<<<<<<
4486 * info.format[1] = 0
4487 * info.obj = self
4488 */
4489 __pyx_t_7 = __pyx_v_self->ob_descr->typecode;
4490 (__pyx_v_info->format[0]) = __pyx_t_7;
4491
4492 /* "array.pxd":126
4493 * info.format = <char*> (info.shape + 1)
4494 * info.format[0] = self.ob_descr.typecode
4495 * info.format[1] = 0 # <<<<<<<<<<<<<<
4496 * info.obj = self
4497 *
4498 */
4499 (__pyx_v_info->format[1]) = 0;
4500
4501 /* "array.pxd":127
4502 * info.format[0] = self.ob_descr.typecode
4503 * info.format[1] = 0
4504 * info.obj = self # <<<<<<<<<<<<<<
4505 *
4506 * def __releasebuffer__(self, Py_buffer* info):
4507 */
4508 __Pyx_INCREF((PyObject *)__pyx_v_self);
4509 __Pyx_GIVEREF((PyObject *)__pyx_v_self);
4510 __Pyx_GOTREF(__pyx_v_info->obj);
4511 __Pyx_DECREF(__pyx_v_info->obj);
4512 __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
4513
4514 /* "array.pxd":104
4515 * __data_union data
4516 *
4517 * def __getbuffer__(self, Py_buffer* info, int flags): # <<<<<<<<<<<<<<
4518 * # This implementation of getbuffer is geared towards Cython
4519 * # requirements, and does not yet fulfill the PEP.
4520 */
4521
4522 /* function exit code */
4523 __pyx_r = 0;
4524 goto __pyx_L0;
4525 __pyx_L1_error:;
4526 __Pyx_XDECREF(__pyx_t_1);
4527 __Pyx_XDECREF(__pyx_t_4);
4528 __Pyx_AddTraceback("cpython.array.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4529 __pyx_r = -1;
4530 if (__pyx_v_info->obj != NULL) {
4531 __Pyx_GOTREF(__pyx_v_info->obj);
4532 __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
4533 }
4534 goto __pyx_L2;
4535 __pyx_L0:;
4536 if (__pyx_v_info->obj == Py_None) {
4537 __Pyx_GOTREF(__pyx_v_info->obj);
4538 __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
4539 }
4540 __pyx_L2:;
4541 __Pyx_XDECREF(__pyx_v_item_count);
4542 __Pyx_RefNannyFinishContext();
4543 return __pyx_r;
4544 }
4545
4546 /* "array.pxd":129
4547 * info.obj = self
4548 *
4549 * def __releasebuffer__(self, Py_buffer* info): # <<<<<<<<<<<<<<
4550 * PyObject_Free(info.shape)
4551 *
4552 */
4553
4554 /* Python wrapper */
4555 CYTHON_UNUSED static void __pyx_pw_7cpython_5array_5array_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
4556 CYTHON_UNUSED static void __pyx_pw_7cpython_5array_5array_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
4557 CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
4558 __Pyx_RefNannyDeclarations
4559 __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
4560 __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
4561 __pyx_pf_7cpython_5array_5array_2__releasebuffer__(((arrayobject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info));
4562
4563 /* function exit code */
4564 __Pyx_RefNannyFinishContext();
4565 }
4566
4567 static void __pyx_pf_7cpython_5array_5array_2__releasebuffer__(CYTHON_UNUSED arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info) {
4568
4569 /* "array.pxd":130
4570 *
4571 * def __releasebuffer__(self, Py_buffer* info):
4572 * PyObject_Free(info.shape) # <<<<<<<<<<<<<<
4573 *
4574 * array newarrayobject(PyTypeObject* type, Py_ssize_t size, arraydescr *descr)
4575 */
4576 PyObject_Free(__pyx_v_info->shape);
4577
4578 /* "array.pxd":129
4579 * info.obj = self
4580 *
4581 * def __releasebuffer__(self, Py_buffer* info): # <<<<<<<<<<<<<<
4582 * PyObject_Free(info.shape)
4583 *
4584 */
4585
4586 /* function exit code */
4587 }
4588
4589 /* "array.pxd":141
4590 *
4591 *
4592 * cdef inline array clone(array template, Py_ssize_t length, bint zero): # <<<<<<<<<<<<<<
4593 * """ fast creation of a new array, given a template array.
4594 * type will be same as template.
4595 */
4596
4597 static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_clone(arrayobject *__pyx_v_template, Py_ssize_t __pyx_v_length, int __pyx_v_zero) {
4598 arrayobject *__pyx_v_op = 0;
4599 arrayobject *__pyx_r = NULL;
4600 __Pyx_RefNannyDeclarations
4601 PyObject *__pyx_t_1 = NULL;
4602 int __pyx_t_2;
4603 int __pyx_t_3;
4604 int __pyx_lineno = 0;
4605 const char *__pyx_filename = NULL;
4606 int __pyx_clineno = 0;
4607 __Pyx_RefNannySetupContext("clone", 1);
4608
4609 /* "array.pxd":145
4610 * type will be same as template.
4611 * if zero is true, new array will be initialized with zeroes."""
4612 * cdef array op = newarrayobject(Py_TYPE(template), length, template.ob_descr) # <<<<<<<<<<<<<<
4613 * if zero and op is not None:
4614 * memset(op.data.as_chars, 0, length * op.ob_descr.itemsize)
4615 */
4616 __pyx_t_1 = ((PyObject *)newarrayobject(Py_TYPE(((PyObject *)__pyx_v_template)), __pyx_v_length, __pyx_v_template->ob_descr)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 145, __pyx_L1_error)
4617 __Pyx_GOTREF(__pyx_t_1);
4618 __pyx_v_op = ((arrayobject *)__pyx_t_1);
4619 __pyx_t_1 = 0;
4620
4621 /* "array.pxd":146
4622 * if zero is true, new array will be initialized with zeroes."""
4623 * cdef array op = newarrayobject(Py_TYPE(template), length, template.ob_descr)
4624 * if zero and op is not None: # <<<<<<<<<<<<<<
4625 * memset(op.data.as_chars, 0, length * op.ob_descr.itemsize)
4626 * return op
4627 */
4628 if (__pyx_v_zero) {
4629 } else {
4630 __pyx_t_2 = __pyx_v_zero;
4631 goto __pyx_L4_bool_binop_done;
4632 }
4633 __pyx_t_3 = (((PyObject *)__pyx_v_op) != Py_None);
4634 __pyx_t_2 = __pyx_t_3;
4635 __pyx_L4_bool_binop_done:;
4636 if (__pyx_t_2) {
4637
4638 /* "array.pxd":147
4639 * cdef array op = newarrayobject(Py_TYPE(template), length, template.ob_descr)
4640 * if zero and op is not None:
4641 * memset(op.data.as_chars, 0, length * op.ob_descr.itemsize) # <<<<<<<<<<<<<<
4642 * return op
4643 *
4644 */
4645 (void)(memset(__pyx_v_op->data.as_chars, 0, (__pyx_v_length * __pyx_v_op->ob_descr->itemsize)));
4646
4647 /* "array.pxd":146
4648 * if zero is true, new array will be initialized with zeroes."""
4649 * cdef array op = newarrayobject(Py_TYPE(template), length, template.ob_descr)
4650 * if zero and op is not None: # <<<<<<<<<<<<<<
4651 * memset(op.data.as_chars, 0, length * op.ob_descr.itemsize)
4652 * return op
4653 */
4654 }
4655
4656 /* "array.pxd":148
4657 * if zero and op is not None:
4658 * memset(op.data.as_chars, 0, length * op.ob_descr.itemsize)
4659 * return op # <<<<<<<<<<<<<<
4660 *
4661 * cdef inline array copy(array self):
4662 */
4663 __Pyx_XDECREF((PyObject *)__pyx_r);
4664 __Pyx_INCREF((PyObject *)__pyx_v_op);
4665 __pyx_r = __pyx_v_op;
4666 goto __pyx_L0;
4667
4668 /* "array.pxd":141
4669 *
4670 *
4671 * cdef inline array clone(array template, Py_ssize_t length, bint zero): # <<<<<<<<<<<<<<
4672 * """ fast creation of a new array, given a template array.
4673 * type will be same as template.
4674 */
4675
4676 /* function exit code */
4677 __pyx_L1_error:;
4678 __Pyx_XDECREF(__pyx_t_1);
4679 __Pyx_AddTraceback("cpython.array.clone", __pyx_clineno, __pyx_lineno, __pyx_filename);
4680 __pyx_r = 0;
4681 __pyx_L0:;
4682 __Pyx_XDECREF((PyObject *)__pyx_v_op);
4683 __Pyx_XGIVEREF((PyObject *)__pyx_r);
4684 __Pyx_RefNannyFinishContext();
4685 return __pyx_r;
4686 }
4687
4688 /* "array.pxd":150
4689 * return op
4690 *
4691 * cdef inline array copy(array self): # <<<<<<<<<<<<<<
4692 * """ make a copy of an array. """
4693 * cdef array op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr)
4694 */
4695
4696 static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_copy(arrayobject *__pyx_v_self) {
4697 arrayobject *__pyx_v_op = 0;
4698 arrayobject *__pyx_r = NULL;
4699 __Pyx_RefNannyDeclarations
4700 PyObject *__pyx_t_1 = NULL;
4701 int __pyx_lineno = 0;
4702 const char *__pyx_filename = NULL;
4703 int __pyx_clineno = 0;
4704 __Pyx_RefNannySetupContext("copy", 1);
4705
4706 /* "array.pxd":152
4707 * cdef inline array copy(array self):
4708 * """ make a copy of an array. """
4709 * cdef array op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr) # <<<<<<<<<<<<<<
4710 * memcpy(op.data.as_chars, self.data.as_chars, Py_SIZE(op) * op.ob_descr.itemsize)
4711 * return op
4712 */
4713 __pyx_t_1 = ((PyObject *)newarrayobject(Py_TYPE(((PyObject *)__pyx_v_self)), Py_SIZE(((PyObject *)__pyx_v_self)), __pyx_v_self->ob_descr)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 152, __pyx_L1_error)
4714 __Pyx_GOTREF(__pyx_t_1);
4715 __pyx_v_op = ((arrayobject *)__pyx_t_1);
4716 __pyx_t_1 = 0;
4717
4718 /* "array.pxd":153
4719 * """ make a copy of an array. """
4720 * cdef array op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr)
4721 * memcpy(op.data.as_chars, self.data.as_chars, Py_SIZE(op) * op.ob_descr.itemsize) # <<<<<<<<<<<<<<
4722 * return op
4723 *
4724 */
4725 (void)(memcpy(__pyx_v_op->data.as_chars, __pyx_v_self->data.as_chars, (Py_SIZE(((PyObject *)__pyx_v_op)) * __pyx_v_op->ob_descr->itemsize)));
4726
4727 /* "array.pxd":154
4728 * cdef array op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr)
4729 * memcpy(op.data.as_chars, self.data.as_chars, Py_SIZE(op) * op.ob_descr.itemsize)
4730 * return op # <<<<<<<<<<<<<<
4731 *
4732 * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1:
4733 */
4734 __Pyx_XDECREF((PyObject *)__pyx_r);
4735 __Pyx_INCREF((PyObject *)__pyx_v_op);
4736 __pyx_r = __pyx_v_op;
4737 goto __pyx_L0;
4738
4739 /* "array.pxd":150
4740 * return op
4741 *
4742 * cdef inline array copy(array self): # <<<<<<<<<<<<<<
4743 * """ make a copy of an array. """
4744 * cdef array op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr)
4745 */
4746
4747 /* function exit code */
4748 __pyx_L1_error:;
4749 __Pyx_XDECREF(__pyx_t_1);
4750 __Pyx_AddTraceback("cpython.array.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
4751 __pyx_r = 0;
4752 __pyx_L0:;
4753 __Pyx_XDECREF((PyObject *)__pyx_v_op);
4754 __Pyx_XGIVEREF((PyObject *)__pyx_r);
4755 __Pyx_RefNannyFinishContext();
4756 return __pyx_r;
4757 }
4758
4759 /* "array.pxd":156
4760 * return op
4761 *
4762 * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1: # <<<<<<<<<<<<<<
4763 * """ efficient appending of new stuff of same type
4764 * (e.g. of same array type)
4765 */
4766
4767 static CYTHON_INLINE int __pyx_f_7cpython_5array_extend_buffer(arrayobject *__pyx_v_self, char *__pyx_v_stuff, Py_ssize_t __pyx_v_n) {
4768 Py_ssize_t __pyx_v_itemsize;
4769 Py_ssize_t __pyx_v_origsize;
4770 int __pyx_r;
4771 int __pyx_t_1;
4772 int __pyx_lineno = 0;
4773 const char *__pyx_filename = NULL;
4774 int __pyx_clineno = 0;
4775
4776 /* "array.pxd":160
4777 * (e.g. of same array type)
4778 * n: number of elements (not number of bytes!) """
4779 * cdef Py_ssize_t itemsize = self.ob_descr.itemsize # <<<<<<<<<<<<<<
4780 * cdef Py_ssize_t origsize = Py_SIZE(self)
4781 * resize_smart(self, origsize + n)
4782 */
4783 __pyx_t_1 = __pyx_v_self->ob_descr->itemsize;
4784 __pyx_v_itemsize = __pyx_t_1;
4785
4786 /* "array.pxd":161
4787 * n: number of elements (not number of bytes!) """
4788 * cdef Py_ssize_t itemsize = self.ob_descr.itemsize
4789 * cdef Py_ssize_t origsize = Py_SIZE(self) # <<<<<<<<<<<<<<
4790 * resize_smart(self, origsize + n)
4791 * memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize)
4792 */
4793 __pyx_v_origsize = Py_SIZE(((PyObject *)__pyx_v_self));
4794
4795 /* "array.pxd":162
4796 * cdef Py_ssize_t itemsize = self.ob_descr.itemsize
4797 * cdef Py_ssize_t origsize = Py_SIZE(self)
4798 * resize_smart(self, origsize + n) # <<<<<<<<<<<<<<
4799 * memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize)
4800 * return 0
4801 */
4802 __pyx_t_1 = resize_smart(__pyx_v_self, (__pyx_v_origsize + __pyx_v_n)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(2, 162, __pyx_L1_error)
4803
4804 /* "array.pxd":163
4805 * cdef Py_ssize_t origsize = Py_SIZE(self)
4806 * resize_smart(self, origsize + n)
4807 * memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize) # <<<<<<<<<<<<<<
4808 * return 0
4809 *
4810 */
4811 (void)(memcpy((__pyx_v_self->data.as_chars + (__pyx_v_origsize * __pyx_v_itemsize)), __pyx_v_stuff, (__pyx_v_n * __pyx_v_itemsize)));
4812
4813 /* "array.pxd":164
4814 * resize_smart(self, origsize + n)
4815 * memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize)
4816 * return 0 # <<<<<<<<<<<<<<
4817 *
4818 * cdef inline int extend(array self, array other) except -1:
4819 */
4820 __pyx_r = 0;
4821 goto __pyx_L0;
4822
4823 /* "array.pxd":156
4824 * return op
4825 *
4826 * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1: # <<<<<<<<<<<<<<
4827 * """ efficient appending of new stuff of same type
4828 * (e.g. of same array type)
4829 */
4830
4831 /* function exit code */
4832 __pyx_L1_error:;
4833 __Pyx_AddTraceback("cpython.array.extend_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
4834 __pyx_r = -1;
4835 __pyx_L0:;
4836 return __pyx_r;
4837 }
4838
4839 /* "array.pxd":166
4840 * return 0
4841 *
4842 * cdef inline int extend(array self, array other) except -1: # <<<<<<<<<<<<<<
4843 * """ extend array with data from another array; types must match. """
4844 * if self.ob_descr.typecode != other.ob_descr.typecode:
4845 */
4846
4847 static CYTHON_INLINE int __pyx_f_7cpython_5array_extend(arrayobject *__pyx_v_self, arrayobject *__pyx_v_other) {
4848 int __pyx_r;
4849 int __pyx_t_1;
4850 int __pyx_t_2;
4851 int __pyx_lineno = 0;
4852 const char *__pyx_filename = NULL;
4853 int __pyx_clineno = 0;
4854
4855 /* "array.pxd":168
4856 * cdef inline int extend(array self, array other) except -1:
4857 * """ extend array with data from another array; types must match. """
4858 * if self.ob_descr.typecode != other.ob_descr.typecode: # <<<<<<<<<<<<<<
4859 * PyErr_BadArgument()
4860 * return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
4861 */
4862 __pyx_t_1 = (__pyx_v_self->ob_descr->typecode != __pyx_v_other->ob_descr->typecode);
4863 if (__pyx_t_1) {
4864
4865 /* "array.pxd":169
4866 * """ extend array with data from another array; types must match. """
4867 * if self.ob_descr.typecode != other.ob_descr.typecode:
4868 * PyErr_BadArgument() # <<<<<<<<<<<<<<
4869 * return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
4870 *
4871 */
4872 __pyx_t_2 = PyErr_BadArgument(); if (unlikely(__pyx_t_2 == ((int)0))) __PYX_ERR(2, 169, __pyx_L1_error)
4873
4874 /* "array.pxd":168
4875 * cdef inline int extend(array self, array other) except -1:
4876 * """ extend array with data from another array; types must match. """
4877 * if self.ob_descr.typecode != other.ob_descr.typecode: # <<<<<<<<<<<<<<
4878 * PyErr_BadArgument()
4879 * return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
4880 */
4881 }
4882
4883 /* "array.pxd":170
4884 * if self.ob_descr.typecode != other.ob_descr.typecode:
4885 * PyErr_BadArgument()
4886 * return extend_buffer(self, other.data.as_chars, Py_SIZE(other)) # <<<<<<<<<<<<<<
4887 *
4888 * cdef inline void zero(array self) noexcept:
4889 */
4890 __pyx_t_2 = __pyx_f_7cpython_5array_extend_buffer(__pyx_v_self, __pyx_v_other->data.as_chars, Py_SIZE(((PyObject *)__pyx_v_other))); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(2, 170, __pyx_L1_error)
4891 __pyx_r = __pyx_t_2;
4892 goto __pyx_L0;
4893
4894 /* "array.pxd":166
4895 * return 0
4896 *
4897 * cdef inline int extend(array self, array other) except -1: # <<<<<<<<<<<<<<
4898 * """ extend array with data from another array; types must match. """
4899 * if self.ob_descr.typecode != other.ob_descr.typecode:
4900 */
4901
4902 /* function exit code */
4903 __pyx_L1_error:;
4904 __Pyx_AddTraceback("cpython.array.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
4905 __pyx_r = -1;
4906 __pyx_L0:;
4907 return __pyx_r;
4908 }
4909
4910 /* "array.pxd":172
4911 * return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
4912 *
4913 * cdef inline void zero(array self) noexcept: # <<<<<<<<<<<<<<
4914 * """ set all elements of array to zero. """
4915 * memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize)
4916 */
4917
4918 static CYTHON_INLINE void __pyx_f_7cpython_5array_zero(arrayobject *__pyx_v_self) {
4919
4920 /* "array.pxd":174
4921 * cdef inline void zero(array self) noexcept:
4922 * """ set all elements of array to zero. """
4923 * memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize) # <<<<<<<<<<<<<<
4924 */
4925 (void)(memset(__pyx_v_self->data.as_chars, 0, (Py_SIZE(((PyObject *)__pyx_v_self)) * __pyx_v_self->ob_descr->itemsize)));
4926
4927 /* "array.pxd":172
4928 * return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
4929 *
4930 * cdef inline void zero(array self) noexcept: # <<<<<<<<<<<<<<
4931 * """ set all elements of array to zero. """
4932 * memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize)
4933 */
4934
4935 /* function exit code */
4936 }
4937
4938 /* "pysam/libcutils.pyx":36
4939 * #################################################################
4940 * # Utility functions for quality string conversions
4941 * cpdef c_array.array qualitystring_to_array(input_str, int offset=33): # <<<<<<<<<<<<<<
4942 * """convert a qualitystring to an array of quality values."""
4943 * if input_str is None:
4944 */
4945
4946 static PyObject *__pyx_pw_5pysam_9libcutils_1qualitystring_to_array(PyObject *__pyx_self,
4947 #if CYTHON_METH_FASTCALL
4948 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
4949 #else
4950 PyObject *__pyx_args, PyObject *__pyx_kwds
4951 #endif
4952 ); /*proto*/
4953 static arrayobject *__pyx_f_5pysam_9libcutils_qualitystring_to_array(PyObject *__pyx_v_input_str, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_9libcutils_qualitystring_to_array *__pyx_optional_args) {
4954 int __pyx_v_offset = ((int)33);
4955 PyObject *__pyx_v_qs = NULL;
4956 char __pyx_7genexpr__pyx_v_i;
4957 arrayobject *__pyx_r = NULL;
4958 __Pyx_RefNannyDeclarations
4959 int __pyx_t_1;
4960 PyObject *__pyx_t_2 = NULL;
4961 PyObject *__pyx_t_3 = NULL;
4962 char *__pyx_t_4;
4963 char *__pyx_t_5;
4964 char *__pyx_t_6;
4965 char *__pyx_t_7;
4966 PyObject *__pyx_t_8 = NULL;
4967 int __pyx_lineno = 0;
4968 const char *__pyx_filename = NULL;
4969 int __pyx_clineno = 0;
4970 __Pyx_RefNannySetupContext("qualitystring_to_array", 1);
4971 if (__pyx_optional_args) {
4972 if (__pyx_optional_args->__pyx_n > 0) {
4973 __pyx_v_offset = __pyx_optional_args->offset;
4974 }
4975 }
4976
4977 /* "pysam/libcutils.pyx":38
4978 * cpdef c_array.array qualitystring_to_array(input_str, int offset=33):
4979 * """convert a qualitystring to an array of quality values."""
4980 * if input_str is None: # <<<<<<<<<<<<<<
4981 * return None
4982 * qs = force_bytes(input_str)
4983 */
4984 __pyx_t_1 = (__pyx_v_input_str == Py_None);
4985 if (__pyx_t_1) {
4986
4987 /* "pysam/libcutils.pyx":39
4988 * """convert a qualitystring to an array of quality values."""
4989 * if input_str is None:
4990 * return None # <<<<<<<<<<<<<<
4991 * qs = force_bytes(input_str)
4992 * cdef char i
4993 */
4994 __Pyx_XDECREF((PyObject *)__pyx_r);
4995 __pyx_r = ((arrayobject *)Py_None); __Pyx_INCREF(Py_None);
4996 goto __pyx_L0;
4997
4998 /* "pysam/libcutils.pyx":38
4999 * cpdef c_array.array qualitystring_to_array(input_str, int offset=33):
5000 * """convert a qualitystring to an array of quality values."""
5001 * if input_str is None: # <<<<<<<<<<<<<<
5002 * return None
5003 * qs = force_bytes(input_str)
5004 */
5005 }
5006
5007 /* "pysam/libcutils.pyx":40
5008 * if input_str is None:
5009 * return None
5010 * qs = force_bytes(input_str) # <<<<<<<<<<<<<<
5011 * cdef char i
5012 * return c_array.array('B', [i - offset for i in qs])
5013 */
5014 __pyx_t_2 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_input_str, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error)
5015 __Pyx_GOTREF(__pyx_t_2);
5016 __pyx_v_qs = ((PyObject*)__pyx_t_2);
5017 __pyx_t_2 = 0;
5018
5019 /* "pysam/libcutils.pyx":42
5020 * qs = force_bytes(input_str)
5021 * cdef char i
5022 * return c_array.array('B', [i - offset for i in qs]) # <<<<<<<<<<<<<<
5023 *
5024 *
5025 */
5026 __Pyx_XDECREF((PyObject *)__pyx_r);
5027 { /* enter inner scope */
5028 __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error)
5029 __Pyx_GOTREF(__pyx_t_2);
5030 if (unlikely(__pyx_v_qs == Py_None)) {
5031 PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
5032 __PYX_ERR(0, 42, __pyx_L1_error)
5033 }
5034 __Pyx_INCREF(__pyx_v_qs);
5035 __pyx_t_3 = __pyx_v_qs;
5036 __pyx_t_5 = PyBytes_AS_STRING(__pyx_t_3);
5037 __pyx_t_6 = (__pyx_t_5 + PyBytes_GET_SIZE(__pyx_t_3));
5038 for (__pyx_t_7 = __pyx_t_5; __pyx_t_7 < __pyx_t_6; __pyx_t_7++) {
5039 __pyx_t_4 = __pyx_t_7;
5040 __pyx_7genexpr__pyx_v_i = (__pyx_t_4[0]);
5041 __pyx_t_8 = __Pyx_PyInt_From_int((__pyx_7genexpr__pyx_v_i - __pyx_v_offset)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 42, __pyx_L1_error)
5042 __Pyx_GOTREF(__pyx_t_8);
5043 if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 42, __pyx_L1_error)
5044 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5045 }
5046 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5047 } /* exit inner scope */
5048 __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 42, __pyx_L1_error)
5049 __Pyx_GOTREF(__pyx_t_8);
5050 __Pyx_INCREF(__pyx_n_u_B);
5051 __Pyx_GIVEREF(__pyx_n_u_B);
5052 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_n_u_B)) __PYX_ERR(0, 42, __pyx_L1_error);
5053 __Pyx_GIVEREF(__pyx_t_2);
5054 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error);
5055 __pyx_t_2 = 0;
5056 __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7cpython_5array_array), __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error)
5057 __Pyx_GOTREF(__pyx_t_2);
5058 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5059 __pyx_r = ((arrayobject *)__pyx_t_2);
5060 __pyx_t_2 = 0;
5061 goto __pyx_L0;
5062
5063 /* "pysam/libcutils.pyx":36
5064 * #################################################################
5065 * # Utility functions for quality string conversions
5066 * cpdef c_array.array qualitystring_to_array(input_str, int offset=33): # <<<<<<<<<<<<<<
5067 * """convert a qualitystring to an array of quality values."""
5068 * if input_str is None:
5069 */
5070
5071 /* function exit code */
5072 __pyx_L1_error:;
5073 __Pyx_XDECREF(__pyx_t_2);
5074 __Pyx_XDECREF(__pyx_t_3);
5075 __Pyx_XDECREF(__pyx_t_8);
5076 __Pyx_AddTraceback("pysam.libcutils.qualitystring_to_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
5077 __pyx_r = 0;
5078 __pyx_L0:;
5079 __Pyx_XDECREF(__pyx_v_qs);
5080 __Pyx_XGIVEREF((PyObject *)__pyx_r);
5081 __Pyx_RefNannyFinishContext();
5082 return __pyx_r;
5083 }
5084
5085 /* Python wrapper */
5086 static PyObject *__pyx_pw_5pysam_9libcutils_1qualitystring_to_array(PyObject *__pyx_self,
5087 #if CYTHON_METH_FASTCALL
5088 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
5089 #else
5090 PyObject *__pyx_args, PyObject *__pyx_kwds
5091 #endif
5092 ); /*proto*/
5093 PyDoc_STRVAR(__pyx_doc_5pysam_9libcutils_qualitystring_to_array, "convert a qualitystring to an array of quality values.");
5094 static PyMethodDef __pyx_mdef_5pysam_9libcutils_1qualitystring_to_array = {"qualitystring_to_array", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pysam_9libcutils_1qualitystring_to_array, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pysam_9libcutils_qualitystring_to_array};
5095 static PyObject *__pyx_pw_5pysam_9libcutils_1qualitystring_to_array(PyObject *__pyx_self,
5096 #if CYTHON_METH_FASTCALL
5097 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
5098 #else
5099 PyObject *__pyx_args, PyObject *__pyx_kwds
5100 #endif
5101 ) {
5102 PyObject *__pyx_v_input_str = 0;
5103 int __pyx_v_offset;
5104 #if !CYTHON_METH_FASTCALL
5105 CYTHON_UNUSED Py_ssize_t __pyx_nargs;
5106 #endif
5107 CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
5108 PyObject* values[2] = {0,0};
5109 int __pyx_lineno = 0;
5110 const char *__pyx_filename = NULL;
5111 int __pyx_clineno = 0;
5112 PyObject *__pyx_r = 0;
5113 __Pyx_RefNannyDeclarations
5114 __Pyx_RefNannySetupContext("qualitystring_to_array (wrapper)", 0);
5115 #if !CYTHON_METH_FASTCALL
5116 #if CYTHON_ASSUME_SAFE_MACROS
5117 __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
5118 #else
5119 __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
5120 #endif
5121 #endif
5122 __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
5123 {
5124 PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input_str,&__pyx_n_s_offset,0};
5125 if (__pyx_kwds) {
5126 Py_ssize_t kw_args;
5127 switch (__pyx_nargs) {
5128 case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
5129 CYTHON_FALLTHROUGH;
5130 case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
5131 CYTHON_FALLTHROUGH;
5132 case 0: break;
5133 default: goto __pyx_L5_argtuple_error;
5134 }
5135 kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
5136 switch (__pyx_nargs) {
5137 case 0:
5138 if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_input_str)) != 0)) {
5139 (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
5140 kw_args--;
5141 }
5142 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 36, __pyx_L3_error)
5143 else goto __pyx_L5_argtuple_error;
5144 CYTHON_FALLTHROUGH;
5145 case 1:
5146 if (kw_args > 0) {
5147 PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_offset);
5148 if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
5149 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 36, __pyx_L3_error)
5150 }
5151 }
5152 if (unlikely(kw_args > 0)) {
5153 const Py_ssize_t kwd_pos_args = __pyx_nargs;
5154 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "qualitystring_to_array") < 0)) __PYX_ERR(0, 36, __pyx_L3_error)
5155 }
5156 } else {
5157 switch (__pyx_nargs) {
5158 case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
5159 CYTHON_FALLTHROUGH;
5160 case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
5161 break;
5162 default: goto __pyx_L5_argtuple_error;
5163 }
5164 }
5165 __pyx_v_input_str = values[0];
5166 if (values[1]) {
5167 __pyx_v_offset = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_offset == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 36, __pyx_L3_error)
5168 } else {
5169 __pyx_v_offset = ((int)33);
5170 }
5171 }
5172 goto __pyx_L6_skip;
5173 __pyx_L5_argtuple_error:;
5174 __Pyx_RaiseArgtupleInvalid("qualitystring_to_array", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 36, __pyx_L3_error)
5175 __pyx_L6_skip:;
5176 goto __pyx_L4_argument_unpacking_done;
5177 __pyx_L3_error:;
5178 {
5179 Py_ssize_t __pyx_temp;
5180 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
5181 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
5182 }
5183 }
5184 __Pyx_AddTraceback("pysam.libcutils.qualitystring_to_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
5185 __Pyx_RefNannyFinishContext();
5186 return NULL;
5187 __pyx_L4_argument_unpacking_done:;
5188 __pyx_r = __pyx_pf_5pysam_9libcutils_qualitystring_to_array(__pyx_self, __pyx_v_input_str, __pyx_v_offset);
5189
5190 /* function exit code */
5191 {
5192 Py_ssize_t __pyx_temp;
5193 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
5194 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
5195 }
5196 }
5197 __Pyx_RefNannyFinishContext();
5198 return __pyx_r;
5199 }
5200
5201 static PyObject *__pyx_pf_5pysam_9libcutils_qualitystring_to_array(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_input_str, int __pyx_v_offset) {
5202 PyObject *__pyx_r = NULL;
5203 __Pyx_RefNannyDeclarations
5204 PyObject *__pyx_t_1 = NULL;
5205 struct __pyx_opt_args_5pysam_9libcutils_qualitystring_to_array __pyx_t_2;
5206 int __pyx_lineno = 0;
5207 const char *__pyx_filename = NULL;
5208 int __pyx_clineno = 0;
5209 __Pyx_RefNannySetupContext("qualitystring_to_array", 1);
5210 __Pyx_XDECREF(__pyx_r);
5211 __pyx_t_2.__pyx_n = 1;
5212 __pyx_t_2.offset = __pyx_v_offset;
5213 __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_9libcutils_qualitystring_to_array(__pyx_v_input_str, 0, &__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error)
5214 __Pyx_GOTREF(__pyx_t_1);
5215 __pyx_r = __pyx_t_1;
5216 __pyx_t_1 = 0;
5217 goto __pyx_L0;
5218
5219 /* function exit code */
5220 __pyx_L1_error:;
5221 __Pyx_XDECREF(__pyx_t_1);
5222 __Pyx_AddTraceback("pysam.libcutils.qualitystring_to_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
5223 __pyx_r = NULL;
5224 __pyx_L0:;
5225 __Pyx_XGIVEREF(__pyx_r);
5226 __Pyx_RefNannyFinishContext();
5227 return __pyx_r;
5228 }
5229
5230 /* "pysam/libcutils.pyx":45
5231 *
5232 *
5233 * cpdef array_to_qualitystring(c_array.array qualities, int offset=33): # <<<<<<<<<<<<<<
5234 * """convert an array of quality values to a string."""
5235 * if qualities is None:
5236 */
5237
5238 static PyObject *__pyx_pw_5pysam_9libcutils_3array_to_qualitystring(PyObject *__pyx_self,
5239 #if CYTHON_METH_FASTCALL
5240 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
5241 #else
5242 PyObject *__pyx_args, PyObject *__pyx_kwds
5243 #endif
5244 ); /*proto*/
5245 static PyObject *__pyx_f_5pysam_9libcutils_array_to_qualitystring(arrayobject *__pyx_v_qualities, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_9libcutils_array_to_qualitystring *__pyx_optional_args) {
5246 int __pyx_v_offset = ((int)33);
5247 int __pyx_v_x;
5248 arrayobject *__pyx_v_result = 0;
5249 PyObject *__pyx_r = NULL;
5250 __Pyx_RefNannyDeclarations
5251 int __pyx_t_1;
5252 Py_ssize_t __pyx_t_2;
5253 PyObject *__pyx_t_3 = NULL;
5254 PyObject *__pyx_t_4 = NULL;
5255 PyObject *__pyx_t_5 = NULL;
5256 unsigned int __pyx_t_6;
5257 int __pyx_lineno = 0;
5258 const char *__pyx_filename = NULL;
5259 int __pyx_clineno = 0;
5260 __Pyx_RefNannySetupContext("array_to_qualitystring", 1);
5261 if (__pyx_optional_args) {
5262 if (__pyx_optional_args->__pyx_n > 0) {
5263 __pyx_v_offset = __pyx_optional_args->offset;
5264 }
5265 }
5266
5267 /* "pysam/libcutils.pyx":47
5268 * cpdef array_to_qualitystring(c_array.array qualities, int offset=33):
5269 * """convert an array of quality values to a string."""
5270 * if qualities is None: # <<<<<<<<<<<<<<
5271 * return None
5272 * cdef int x
5273 */
5274 __pyx_t_1 = (((PyObject *)__pyx_v_qualities) == Py_None);
5275 if (__pyx_t_1) {
5276
5277 /* "pysam/libcutils.pyx":48
5278 * """convert an array of quality values to a string."""
5279 * if qualities is None:
5280 * return None # <<<<<<<<<<<<<<
5281 * cdef int x
5282 *
5283 */
5284 __Pyx_XDECREF(__pyx_r);
5285 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5286 goto __pyx_L0;
5287
5288 /* "pysam/libcutils.pyx":47
5289 * cpdef array_to_qualitystring(c_array.array qualities, int offset=33):
5290 * """convert an array of quality values to a string."""
5291 * if qualities is None: # <<<<<<<<<<<<<<
5292 * return None
5293 * cdef int x
5294 */
5295 }
5296
5297 /* "pysam/libcutils.pyx":52
5298 *
5299 * cdef c_array.array result
5300 * result = c_array.clone(qualities, len(qualities), zero=False) # <<<<<<<<<<<<<<
5301 *
5302 * for x from 0 <= x < len(qualities):
5303 */
5304 if (unlikely(((PyObject *)__pyx_v_qualities) == Py_None)) {
5305 PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
5306 __PYX_ERR(0, 52, __pyx_L1_error)
5307 }
5308 __pyx_t_2 = Py_SIZE(((PyObject *)__pyx_v_qualities)); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 52, __pyx_L1_error)
5309 __pyx_t_3 = ((PyObject *)__pyx_f_7cpython_5array_clone(__pyx_v_qualities, __pyx_t_2, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 52, __pyx_L1_error)
5310 __Pyx_GOTREF(__pyx_t_3);
5311 __pyx_v_result = ((arrayobject *)__pyx_t_3);
5312 __pyx_t_3 = 0;
5313
5314 /* "pysam/libcutils.pyx":54
5315 * result = c_array.clone(qualities, len(qualities), zero=False)
5316 *
5317 * for x from 0 <= x < len(qualities): # <<<<<<<<<<<<<<
5318 * result[x] = qualities[x] + offset
5319 * return force_str(result.tobytes())
5320 */
5321 if (unlikely(((PyObject *)__pyx_v_qualities) == Py_None)) {
5322 PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
5323 __PYX_ERR(0, 54, __pyx_L1_error)
5324 }
5325 __pyx_t_2 = Py_SIZE(((PyObject *)__pyx_v_qualities)); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 54, __pyx_L1_error)
5326 for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_2; __pyx_v_x++) {
5327
5328 /* "pysam/libcutils.pyx":55
5329 *
5330 * for x from 0 <= x < len(qualities):
5331 * result[x] = qualities[x] + offset # <<<<<<<<<<<<<<
5332 * return force_str(result.tobytes())
5333 *
5334 */
5335 __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_qualities), __pyx_v_x, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 55, __pyx_L1_error)
5336 __Pyx_GOTREF(__pyx_t_3);
5337 __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_offset); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 55, __pyx_L1_error)
5338 __Pyx_GOTREF(__pyx_t_4);
5339 __pyx_t_5 = PyNumber_Add(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 55, __pyx_L1_error)
5340 __Pyx_GOTREF(__pyx_t_5);
5341 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5342 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5343 if (unlikely((__Pyx_SetItemInt(((PyObject *)__pyx_v_result), __pyx_v_x, __pyx_t_5, int, 1, __Pyx_PyInt_From_int, 0, 1, 1) < 0))) __PYX_ERR(0, 55, __pyx_L1_error)
5344 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5345 }
5346
5347 /* "pysam/libcutils.pyx":56
5348 * for x from 0 <= x < len(qualities):
5349 * result[x] = qualities[x] + offset
5350 * return force_str(result.tobytes()) # <<<<<<<<<<<<<<
5351 *
5352 *
5353 */
5354 __Pyx_XDECREF(__pyx_r);
5355 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_result), __pyx_n_s_tobytes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error)
5356 __Pyx_GOTREF(__pyx_t_4);
5357 __pyx_t_3 = NULL;
5358 __pyx_t_6 = 0;
5359 #if CYTHON_UNPACK_METHODS
5360 if (likely(PyMethod_Check(__pyx_t_4))) {
5361 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
5362 if (likely(__pyx_t_3)) {
5363 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
5364 __Pyx_INCREF(__pyx_t_3);
5365 __Pyx_INCREF(function);
5366 __Pyx_DECREF_SET(__pyx_t_4, function);
5367 __pyx_t_6 = 1;
5368 }
5369 }
5370 #endif
5371 {
5372 PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
5373 __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6);
5374 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5375 if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 56, __pyx_L1_error)
5376 __Pyx_GOTREF(__pyx_t_5);
5377 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5378 }
5379 __pyx_t_4 = __pyx_f_5pysam_9libcutils_force_str(__pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error)
5380 __Pyx_GOTREF(__pyx_t_4);
5381 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5382 __pyx_r = __pyx_t_4;
5383 __pyx_t_4 = 0;
5384 goto __pyx_L0;
5385
5386 /* "pysam/libcutils.pyx":45
5387 *
5388 *
5389 * cpdef array_to_qualitystring(c_array.array qualities, int offset=33): # <<<<<<<<<<<<<<
5390 * """convert an array of quality values to a string."""
5391 * if qualities is None:
5392 */
5393
5394 /* function exit code */
5395 __pyx_L1_error:;
5396 __Pyx_XDECREF(__pyx_t_3);
5397 __Pyx_XDECREF(__pyx_t_4);
5398 __Pyx_XDECREF(__pyx_t_5);
5399 __Pyx_AddTraceback("pysam.libcutils.array_to_qualitystring", __pyx_clineno, __pyx_lineno, __pyx_filename);
5400 __pyx_r = 0;
5401 __pyx_L0:;
5402 __Pyx_XDECREF((PyObject *)__pyx_v_result);
5403 __Pyx_XGIVEREF(__pyx_r);
5404 __Pyx_RefNannyFinishContext();
5405 return __pyx_r;
5406 }
5407
5408 /* Python wrapper */
5409 static PyObject *__pyx_pw_5pysam_9libcutils_3array_to_qualitystring(PyObject *__pyx_self,
5410 #if CYTHON_METH_FASTCALL
5411 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
5412 #else
5413 PyObject *__pyx_args, PyObject *__pyx_kwds
5414 #endif
5415 ); /*proto*/
5416 PyDoc_STRVAR(__pyx_doc_5pysam_9libcutils_2array_to_qualitystring, "convert an array of quality values to a string.");
5417 static PyMethodDef __pyx_mdef_5pysam_9libcutils_3array_to_qualitystring = {"array_to_qualitystring", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pysam_9libcutils_3array_to_qualitystring, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pysam_9libcutils_2array_to_qualitystring};
5418 static PyObject *__pyx_pw_5pysam_9libcutils_3array_to_qualitystring(PyObject *__pyx_self,
5419 #if CYTHON_METH_FASTCALL
5420 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
5421 #else
5422 PyObject *__pyx_args, PyObject *__pyx_kwds
5423 #endif
5424 ) {
5425 arrayobject *__pyx_v_qualities = 0;
5426 int __pyx_v_offset;
5427 #if !CYTHON_METH_FASTCALL
5428 CYTHON_UNUSED Py_ssize_t __pyx_nargs;
5429 #endif
5430 CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
5431 PyObject* values[2] = {0,0};
5432 int __pyx_lineno = 0;
5433 const char *__pyx_filename = NULL;
5434 int __pyx_clineno = 0;
5435 PyObject *__pyx_r = 0;
5436 __Pyx_RefNannyDeclarations
5437 __Pyx_RefNannySetupContext("array_to_qualitystring (wrapper)", 0);
5438 #if !CYTHON_METH_FASTCALL
5439 #if CYTHON_ASSUME_SAFE_MACROS
5440 __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
5441 #else
5442 __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
5443 #endif
5444 #endif
5445 __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
5446 {
5447 PyObject **__pyx_pyargnames[] = {&__pyx_n_s_qualities,&__pyx_n_s_offset,0};
5448 if (__pyx_kwds) {
5449 Py_ssize_t kw_args;
5450 switch (__pyx_nargs) {
5451 case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
5452 CYTHON_FALLTHROUGH;
5453 case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
5454 CYTHON_FALLTHROUGH;
5455 case 0: break;
5456 default: goto __pyx_L5_argtuple_error;
5457 }
5458 kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
5459 switch (__pyx_nargs) {
5460 case 0:
5461 if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_qualities)) != 0)) {
5462 (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
5463 kw_args--;
5464 }
5465 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L3_error)
5466 else goto __pyx_L5_argtuple_error;
5467 CYTHON_FALLTHROUGH;
5468 case 1:
5469 if (kw_args > 0) {
5470 PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_offset);
5471 if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
5472 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L3_error)
5473 }
5474 }
5475 if (unlikely(kw_args > 0)) {
5476 const Py_ssize_t kwd_pos_args = __pyx_nargs;
5477 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "array_to_qualitystring") < 0)) __PYX_ERR(0, 45, __pyx_L3_error)
5478 }
5479 } else {
5480 switch (__pyx_nargs) {
5481 case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
5482 CYTHON_FALLTHROUGH;
5483 case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
5484 break;
5485 default: goto __pyx_L5_argtuple_error;
5486 }
5487 }
5488 __pyx_v_qualities = ((arrayobject *)values[0]);
5489 if (values[1]) {
5490 __pyx_v_offset = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_offset == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L3_error)
5491 } else {
5492 __pyx_v_offset = ((int)33);
5493 }
5494 }
5495 goto __pyx_L6_skip;
5496 __pyx_L5_argtuple_error:;
5497 __Pyx_RaiseArgtupleInvalid("array_to_qualitystring", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 45, __pyx_L3_error)
5498 __pyx_L6_skip:;
5499 goto __pyx_L4_argument_unpacking_done;
5500 __pyx_L3_error:;
5501 {
5502 Py_ssize_t __pyx_temp;
5503 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
5504 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
5505 }
5506 }
5507 __Pyx_AddTraceback("pysam.libcutils.array_to_qualitystring", __pyx_clineno, __pyx_lineno, __pyx_filename);
5508 __Pyx_RefNannyFinishContext();
5509 return NULL;
5510 __pyx_L4_argument_unpacking_done:;
5511 if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_qualities), __pyx_ptype_7cpython_5array_array, 1, "qualities", 0))) __PYX_ERR(0, 45, __pyx_L1_error)
5512 __pyx_r = __pyx_pf_5pysam_9libcutils_2array_to_qualitystring(__pyx_self, __pyx_v_qualities, __pyx_v_offset);
5513
5514 /* function exit code */
5515 goto __pyx_L0;
5516 __pyx_L1_error:;
5517 __pyx_r = NULL;
5518 __pyx_L0:;
5519 {
5520 Py_ssize_t __pyx_temp;
5521 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
5522 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
5523 }
5524 }
5525 __Pyx_RefNannyFinishContext();
5526 return __pyx_r;
5527 }
5528
5529 static PyObject *__pyx_pf_5pysam_9libcutils_2array_to_qualitystring(CYTHON_UNUSED PyObject *__pyx_self, arrayobject *__pyx_v_qualities, int __pyx_v_offset) {
5530 PyObject *__pyx_r = NULL;
5531 __Pyx_RefNannyDeclarations
5532 PyObject *__pyx_t_1 = NULL;
5533 struct __pyx_opt_args_5pysam_9libcutils_array_to_qualitystring __pyx_t_2;
5534 int __pyx_lineno = 0;
5535 const char *__pyx_filename = NULL;
5536 int __pyx_clineno = 0;
5537 __Pyx_RefNannySetupContext("array_to_qualitystring", 1);
5538 __Pyx_XDECREF(__pyx_r);
5539 __pyx_t_2.__pyx_n = 1;
5540 __pyx_t_2.offset = __pyx_v_offset;
5541 __pyx_t_1 = __pyx_f_5pysam_9libcutils_array_to_qualitystring(__pyx_v_qualities, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
5542 __Pyx_GOTREF(__pyx_t_1);
5543 __pyx_r = __pyx_t_1;
5544 __pyx_t_1 = 0;
5545 goto __pyx_L0;
5546
5547 /* function exit code */
5548 __pyx_L1_error:;
5549 __Pyx_XDECREF(__pyx_t_1);
5550 __Pyx_AddTraceback("pysam.libcutils.array_to_qualitystring", __pyx_clineno, __pyx_lineno, __pyx_filename);
5551 __pyx_r = NULL;
5552 __pyx_L0:;
5553 __Pyx_XGIVEREF(__pyx_r);
5554 __Pyx_RefNannyFinishContext();
5555 return __pyx_r;
5556 }
5557
5558 /* "pysam/libcutils.pyx":59
5559 *
5560 *
5561 * cpdef qualities_to_qualitystring(qualities, int offset=33): # <<<<<<<<<<<<<<
5562 * """convert a list or array of quality scores to the string
5563 * representation used in the SAM format.
5564 */
5565
5566 static PyObject *__pyx_pw_5pysam_9libcutils_5qualities_to_qualitystring(PyObject *__pyx_self,
5567 #if CYTHON_METH_FASTCALL
5568 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
5569 #else
5570 PyObject *__pyx_args, PyObject *__pyx_kwds
5571 #endif
5572 ); /*proto*/
5573 static PyObject *__pyx_f_5pysam_9libcutils_qualities_to_qualitystring(PyObject *__pyx_v_qualities, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_9libcutils_qualities_to_qualitystring *__pyx_optional_args) {
5574 int __pyx_v_offset = ((int)33);
5575 char __pyx_8genexpr1__pyx_v_x;
5576 PyObject *__pyx_r = NULL;
5577 __Pyx_RefNannyDeclarations
5578 int __pyx_t_1;
5579 PyObject *__pyx_t_2 = NULL;
5580 struct __pyx_opt_args_5pysam_9libcutils_array_to_qualitystring __pyx_t_3;
5581 PyObject *__pyx_t_4 = NULL;
5582 Py_ssize_t __pyx_t_5;
5583 PyObject *(*__pyx_t_6)(PyObject *);
5584 PyObject *__pyx_t_7 = NULL;
5585 char __pyx_t_8;
5586 PyObject *__pyx_t_9 = NULL;
5587 int __pyx_lineno = 0;
5588 const char *__pyx_filename = NULL;
5589 int __pyx_clineno = 0;
5590 __Pyx_RefNannySetupContext("qualities_to_qualitystring", 1);
5591 if (__pyx_optional_args) {
5592 if (__pyx_optional_args->__pyx_n > 0) {
5593 __pyx_v_offset = __pyx_optional_args->offset;
5594 }
5595 }
5596
5597 /* "pysam/libcutils.pyx":76
5598 * """
5599 * cdef char x
5600 * if qualities is None: # <<<<<<<<<<<<<<
5601 * return None
5602 * elif isinstance(qualities, c_array.array):
5603 */
5604 __pyx_t_1 = (__pyx_v_qualities == Py_None);
5605 if (__pyx_t_1) {
5606
5607 /* "pysam/libcutils.pyx":77
5608 * cdef char x
5609 * if qualities is None:
5610 * return None # <<<<<<<<<<<<<<
5611 * elif isinstance(qualities, c_array.array):
5612 * return array_to_qualitystring(qualities, offset=offset)
5613 */
5614 __Pyx_XDECREF(__pyx_r);
5615 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5616 goto __pyx_L0;
5617
5618 /* "pysam/libcutils.pyx":76
5619 * """
5620 * cdef char x
5621 * if qualities is None: # <<<<<<<<<<<<<<
5622 * return None
5623 * elif isinstance(qualities, c_array.array):
5624 */
5625 }
5626
5627 /* "pysam/libcutils.pyx":78
5628 * if qualities is None:
5629 * return None
5630 * elif isinstance(qualities, c_array.array): # <<<<<<<<<<<<<<
5631 * return array_to_qualitystring(qualities, offset=offset)
5632 * else:
5633 */
5634 __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_qualities, __pyx_ptype_7cpython_5array_array);
5635 if (__pyx_t_1) {
5636
5637 /* "pysam/libcutils.pyx":79
5638 * return None
5639 * elif isinstance(qualities, c_array.array):
5640 * return array_to_qualitystring(qualities, offset=offset) # <<<<<<<<<<<<<<
5641 * else:
5642 * # tuples and lists
5643 */
5644 __Pyx_XDECREF(__pyx_r);
5645 if (!(likely(((__pyx_v_qualities) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_qualities, __pyx_ptype_7cpython_5array_array))))) __PYX_ERR(0, 79, __pyx_L1_error)
5646 __pyx_t_3.__pyx_n = 1;
5647 __pyx_t_3.offset = __pyx_v_offset;
5648 __pyx_t_2 = __pyx_f_5pysam_9libcutils_array_to_qualitystring(((arrayobject *)__pyx_v_qualities), 0, &__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error)
5649 __Pyx_GOTREF(__pyx_t_2);
5650 __pyx_r = __pyx_t_2;
5651 __pyx_t_2 = 0;
5652 goto __pyx_L0;
5653
5654 /* "pysam/libcutils.pyx":78
5655 * if qualities is None:
5656 * return None
5657 * elif isinstance(qualities, c_array.array): # <<<<<<<<<<<<<<
5658 * return array_to_qualitystring(qualities, offset=offset)
5659 * else:
5660 */
5661 }
5662
5663 /* "pysam/libcutils.pyx":82
5664 * else:
5665 * # tuples and lists
5666 * return force_str("".join([chr(x + offset) for x in qualities])) # <<<<<<<<<<<<<<
5667 *
5668 *
5669 */
5670 /*else*/ {
5671 __Pyx_XDECREF(__pyx_r);
5672 { /* enter inner scope */
5673 __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)
5674 __Pyx_GOTREF(__pyx_t_2);
5675 if (likely(PyList_CheckExact(__pyx_v_qualities)) || PyTuple_CheckExact(__pyx_v_qualities)) {
5676 __pyx_t_4 = __pyx_v_qualities; __Pyx_INCREF(__pyx_t_4);
5677 __pyx_t_5 = 0;
5678 __pyx_t_6 = NULL;
5679 } else {
5680 __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_qualities); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 82, __pyx_L1_error)
5681 __Pyx_GOTREF(__pyx_t_4);
5682 __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 82, __pyx_L1_error)
5683 }
5684 for (;;) {
5685 if (likely(!__pyx_t_6)) {
5686 if (likely(PyList_CheckExact(__pyx_t_4))) {
5687 {
5688 Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4);
5689 #if !CYTHON_ASSUME_SAFE_MACROS
5690 if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 82, __pyx_L1_error)
5691 #endif
5692 if (__pyx_t_5 >= __pyx_temp) break;
5693 }
5694 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5695 __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 82, __pyx_L1_error)
5696 #else
5697 __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 82, __pyx_L1_error)
5698 __Pyx_GOTREF(__pyx_t_7);
5699 #endif
5700 } else {
5701 {
5702 Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4);
5703 #if !CYTHON_ASSUME_SAFE_MACROS
5704 if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 82, __pyx_L1_error)
5705 #endif
5706 if (__pyx_t_5 >= __pyx_temp) break;
5707 }
5708 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5709 __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 82, __pyx_L1_error)
5710 #else
5711 __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 82, __pyx_L1_error)
5712 __Pyx_GOTREF(__pyx_t_7);
5713 #endif
5714 }
5715 } else {
5716 __pyx_t_7 = __pyx_t_6(__pyx_t_4);
5717 if (unlikely(!__pyx_t_7)) {
5718 PyObject* exc_type = PyErr_Occurred();
5719 if (exc_type) {
5720 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
5721 else __PYX_ERR(0, 82, __pyx_L1_error)
5722 }
5723 break;
5724 }
5725 __Pyx_GOTREF(__pyx_t_7);
5726 }
5727 __pyx_t_8 = __Pyx_PyInt_As_char(__pyx_t_7); if (unlikely((__pyx_t_8 == (char)-1) && PyErr_Occurred())) __PYX_ERR(0, 82, __pyx_L1_error)
5728 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
5729 __pyx_8genexpr1__pyx_v_x = __pyx_t_8;
5730 __pyx_t_7 = __Pyx_PyInt_From_int((__pyx_8genexpr1__pyx_v_x + __pyx_v_offset)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 82, __pyx_L1_error)
5731 __Pyx_GOTREF(__pyx_t_7);
5732 __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_chr, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 82, __pyx_L1_error)
5733 __Pyx_GOTREF(__pyx_t_9);
5734 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
5735 if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 82, __pyx_L1_error)
5736 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
5737 }
5738 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5739 } /* exit inner scope */
5740 __pyx_t_4 = PyUnicode_Join(__pyx_kp_u_, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 82, __pyx_L1_error)
5741 __Pyx_GOTREF(__pyx_t_4);
5742 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5743 __pyx_t_2 = __pyx_f_5pysam_9libcutils_force_str(__pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)
5744 __Pyx_GOTREF(__pyx_t_2);
5745 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5746 __pyx_r = __pyx_t_2;
5747 __pyx_t_2 = 0;
5748 goto __pyx_L0;
5749 }
5750
5751 /* "pysam/libcutils.pyx":59
5752 *
5753 *
5754 * cpdef qualities_to_qualitystring(qualities, int offset=33): # <<<<<<<<<<<<<<
5755 * """convert a list or array of quality scores to the string
5756 * representation used in the SAM format.
5757 */
5758
5759 /* function exit code */
5760 __pyx_L1_error:;
5761 __Pyx_XDECREF(__pyx_t_2);
5762 __Pyx_XDECREF(__pyx_t_4);
5763 __Pyx_XDECREF(__pyx_t_7);
5764 __Pyx_XDECREF(__pyx_t_9);
5765 __Pyx_AddTraceback("pysam.libcutils.qualities_to_qualitystring", __pyx_clineno, __pyx_lineno, __pyx_filename);
5766 __pyx_r = 0;
5767 __pyx_L0:;
5768 __Pyx_XGIVEREF(__pyx_r);
5769 __Pyx_RefNannyFinishContext();
5770 return __pyx_r;
5771 }
5772
5773 /* Python wrapper */
5774 static PyObject *__pyx_pw_5pysam_9libcutils_5qualities_to_qualitystring(PyObject *__pyx_self,
5775 #if CYTHON_METH_FASTCALL
5776 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
5777 #else
5778 PyObject *__pyx_args, PyObject *__pyx_kwds
5779 #endif
5780 ); /*proto*/
5781 PyDoc_STRVAR(__pyx_doc_5pysam_9libcutils_4qualities_to_qualitystring, "convert a list or array of quality scores to the string\n representation used in the SAM format.\n\n Parameters\n ----------\n offset : int\n offset to be added to the quality scores to arrive at\n the characters of the quality string (default=33).\n\n Returns\n -------\n string\n a quality string\n\n ");
5782 static PyMethodDef __pyx_mdef_5pysam_9libcutils_5qualities_to_qualitystring = {"qualities_to_qualitystring", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pysam_9libcutils_5qualities_to_qualitystring, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pysam_9libcutils_4qualities_to_qualitystring};
5783 static PyObject *__pyx_pw_5pysam_9libcutils_5qualities_to_qualitystring(PyObject *__pyx_self,
5784 #if CYTHON_METH_FASTCALL
5785 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
5786 #else
5787 PyObject *__pyx_args, PyObject *__pyx_kwds
5788 #endif
5789 ) {
5790 PyObject *__pyx_v_qualities = 0;
5791 int __pyx_v_offset;
5792 #if !CYTHON_METH_FASTCALL
5793 CYTHON_UNUSED Py_ssize_t __pyx_nargs;
5794 #endif
5795 CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
5796 PyObject* values[2] = {0,0};
5797 int __pyx_lineno = 0;
5798 const char *__pyx_filename = NULL;
5799 int __pyx_clineno = 0;
5800 PyObject *__pyx_r = 0;
5801 __Pyx_RefNannyDeclarations
5802 __Pyx_RefNannySetupContext("qualities_to_qualitystring (wrapper)", 0);
5803 #if !CYTHON_METH_FASTCALL
5804 #if CYTHON_ASSUME_SAFE_MACROS
5805 __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
5806 #else
5807 __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
5808 #endif
5809 #endif
5810 __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
5811 {
5812 PyObject **__pyx_pyargnames[] = {&__pyx_n_s_qualities,&__pyx_n_s_offset,0};
5813 if (__pyx_kwds) {
5814 Py_ssize_t kw_args;
5815 switch (__pyx_nargs) {
5816 case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
5817 CYTHON_FALLTHROUGH;
5818 case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
5819 CYTHON_FALLTHROUGH;
5820 case 0: break;
5821 default: goto __pyx_L5_argtuple_error;
5822 }
5823 kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
5824 switch (__pyx_nargs) {
5825 case 0:
5826 if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_qualities)) != 0)) {
5827 (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
5828 kw_args--;
5829 }
5830 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 59, __pyx_L3_error)
5831 else goto __pyx_L5_argtuple_error;
5832 CYTHON_FALLTHROUGH;
5833 case 1:
5834 if (kw_args > 0) {
5835 PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_offset);
5836 if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
5837 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 59, __pyx_L3_error)
5838 }
5839 }
5840 if (unlikely(kw_args > 0)) {
5841 const Py_ssize_t kwd_pos_args = __pyx_nargs;
5842 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "qualities_to_qualitystring") < 0)) __PYX_ERR(0, 59, __pyx_L3_error)
5843 }
5844 } else {
5845 switch (__pyx_nargs) {
5846 case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
5847 CYTHON_FALLTHROUGH;
5848 case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
5849 break;
5850 default: goto __pyx_L5_argtuple_error;
5851 }
5852 }
5853 __pyx_v_qualities = values[0];
5854 if (values[1]) {
5855 __pyx_v_offset = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_offset == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 59, __pyx_L3_error)
5856 } else {
5857 __pyx_v_offset = ((int)33);
5858 }
5859 }
5860 goto __pyx_L6_skip;
5861 __pyx_L5_argtuple_error:;
5862 __Pyx_RaiseArgtupleInvalid("qualities_to_qualitystring", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 59, __pyx_L3_error)
5863 __pyx_L6_skip:;
5864 goto __pyx_L4_argument_unpacking_done;
5865 __pyx_L3_error:;
5866 {
5867 Py_ssize_t __pyx_temp;
5868 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
5869 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
5870 }
5871 }
5872 __Pyx_AddTraceback("pysam.libcutils.qualities_to_qualitystring", __pyx_clineno, __pyx_lineno, __pyx_filename);
5873 __Pyx_RefNannyFinishContext();
5874 return NULL;
5875 __pyx_L4_argument_unpacking_done:;
5876 __pyx_r = __pyx_pf_5pysam_9libcutils_4qualities_to_qualitystring(__pyx_self, __pyx_v_qualities, __pyx_v_offset);
5877
5878 /* function exit code */
5879 {
5880 Py_ssize_t __pyx_temp;
5881 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
5882 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
5883 }
5884 }
5885 __Pyx_RefNannyFinishContext();
5886 return __pyx_r;
5887 }
5888
5889 static PyObject *__pyx_pf_5pysam_9libcutils_4qualities_to_qualitystring(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_qualities, int __pyx_v_offset) {
5890 PyObject *__pyx_r = NULL;
5891 __Pyx_RefNannyDeclarations
5892 PyObject *__pyx_t_1 = NULL;
5893 struct __pyx_opt_args_5pysam_9libcutils_qualities_to_qualitystring __pyx_t_2;
5894 int __pyx_lineno = 0;
5895 const char *__pyx_filename = NULL;
5896 int __pyx_clineno = 0;
5897 __Pyx_RefNannySetupContext("qualities_to_qualitystring", 1);
5898 __Pyx_XDECREF(__pyx_r);
5899 __pyx_t_2.__pyx_n = 1;
5900 __pyx_t_2.offset = __pyx_v_offset;
5901 __pyx_t_1 = __pyx_f_5pysam_9libcutils_qualities_to_qualitystring(__pyx_v_qualities, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error)
5902 __Pyx_GOTREF(__pyx_t_1);
5903 __pyx_r = __pyx_t_1;
5904 __pyx_t_1 = 0;
5905 goto __pyx_L0;
5906
5907 /* function exit code */
5908 __pyx_L1_error:;
5909 __Pyx_XDECREF(__pyx_t_1);
5910 __Pyx_AddTraceback("pysam.libcutils.qualities_to_qualitystring", __pyx_clineno, __pyx_lineno, __pyx_filename);
5911 __pyx_r = NULL;
5912 __pyx_L0:;
5913 __Pyx_XGIVEREF(__pyx_r);
5914 __Pyx_RefNannyFinishContext();
5915 return __pyx_r;
5916 }
5917
5918 /* "pysam/libcutils.pyx":90
5919 *
5920 * # Codec error handler that just interprets each bad byte as ISO-8859-1.
5921 * def latin1_replace(exception): # <<<<<<<<<<<<<<
5922 * return (chr(exception.object[exception.start]), exception.end)
5923 *
5924 */
5925
5926 /* Python wrapper */
5927 static PyObject *__pyx_pw_5pysam_9libcutils_7latin1_replace(PyObject *__pyx_self,
5928 #if CYTHON_METH_FASTCALL
5929 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
5930 #else
5931 PyObject *__pyx_args, PyObject *__pyx_kwds
5932 #endif
5933 ); /*proto*/
5934 static PyMethodDef __pyx_mdef_5pysam_9libcutils_7latin1_replace = {"latin1_replace", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pysam_9libcutils_7latin1_replace, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
5935 static PyObject *__pyx_pw_5pysam_9libcutils_7latin1_replace(PyObject *__pyx_self,
5936 #if CYTHON_METH_FASTCALL
5937 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
5938 #else
5939 PyObject *__pyx_args, PyObject *__pyx_kwds
5940 #endif
5941 ) {
5942 PyObject *__pyx_v_exception = 0;
5943 #if !CYTHON_METH_FASTCALL
5944 CYTHON_UNUSED Py_ssize_t __pyx_nargs;
5945 #endif
5946 CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
5947 PyObject* values[1] = {0};
5948 int __pyx_lineno = 0;
5949 const char *__pyx_filename = NULL;
5950 int __pyx_clineno = 0;
5951 PyObject *__pyx_r = 0;
5952 __Pyx_RefNannyDeclarations
5953 __Pyx_RefNannySetupContext("latin1_replace (wrapper)", 0);
5954 #if !CYTHON_METH_FASTCALL
5955 #if CYTHON_ASSUME_SAFE_MACROS
5956 __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
5957 #else
5958 __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
5959 #endif
5960 #endif
5961 __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
5962 {
5963 PyObject **__pyx_pyargnames[] = {&__pyx_n_s_exception,0};
5964 if (__pyx_kwds) {
5965 Py_ssize_t kw_args;
5966 switch (__pyx_nargs) {
5967 case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
5968 CYTHON_FALLTHROUGH;
5969 case 0: break;
5970 default: goto __pyx_L5_argtuple_error;
5971 }
5972 kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
5973 switch (__pyx_nargs) {
5974 case 0:
5975 if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_exception)) != 0)) {
5976 (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
5977 kw_args--;
5978 }
5979 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 90, __pyx_L3_error)
5980 else goto __pyx_L5_argtuple_error;
5981 }
5982 if (unlikely(kw_args > 0)) {
5983 const Py_ssize_t kwd_pos_args = __pyx_nargs;
5984 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "latin1_replace") < 0)) __PYX_ERR(0, 90, __pyx_L3_error)
5985 }
5986 } else if (unlikely(__pyx_nargs != 1)) {
5987 goto __pyx_L5_argtuple_error;
5988 } else {
5989 values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
5990 }
5991 __pyx_v_exception = values[0];
5992 }
5993 goto __pyx_L6_skip;
5994 __pyx_L5_argtuple_error:;
5995 __Pyx_RaiseArgtupleInvalid("latin1_replace", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 90, __pyx_L3_error)
5996 __pyx_L6_skip:;
5997 goto __pyx_L4_argument_unpacking_done;
5998 __pyx_L3_error:;
5999 {
6000 Py_ssize_t __pyx_temp;
6001 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
6002 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
6003 }
6004 }
6005 __Pyx_AddTraceback("pysam.libcutils.latin1_replace", __pyx_clineno, __pyx_lineno, __pyx_filename);
6006 __Pyx_RefNannyFinishContext();
6007 return NULL;
6008 __pyx_L4_argument_unpacking_done:;
6009 __pyx_r = __pyx_pf_5pysam_9libcutils_6latin1_replace(__pyx_self, __pyx_v_exception);
6010
6011 /* function exit code */
6012 {
6013 Py_ssize_t __pyx_temp;
6014 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
6015 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
6016 }
6017 }
6018 __Pyx_RefNannyFinishContext();
6019 return __pyx_r;
6020 }
6021
6022 static PyObject *__pyx_pf_5pysam_9libcutils_6latin1_replace(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_exception) {
6023 PyObject *__pyx_r = NULL;
6024 __Pyx_RefNannyDeclarations
6025 PyObject *__pyx_t_1 = NULL;
6026 PyObject *__pyx_t_2 = NULL;
6027 PyObject *__pyx_t_3 = NULL;
6028 int __pyx_lineno = 0;
6029 const char *__pyx_filename = NULL;
6030 int __pyx_clineno = 0;
6031 __Pyx_RefNannySetupContext("latin1_replace", 1);
6032
6033 /* "pysam/libcutils.pyx":91
6034 * # Codec error handler that just interprets each bad byte as ISO-8859-1.
6035 * def latin1_replace(exception):
6036 * return (chr(exception.object[exception.start]), exception.end) # <<<<<<<<<<<<<<
6037 *
6038 * register_error('pysam.latin1replace', latin1_replace)
6039 */
6040 __Pyx_XDECREF(__pyx_r);
6041 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_exception, __pyx_n_s_object); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
6042 __Pyx_GOTREF(__pyx_t_1);
6043 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_exception, __pyx_n_s_start); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error)
6044 __Pyx_GOTREF(__pyx_t_2);
6045 __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error)
6046 __Pyx_GOTREF(__pyx_t_3);
6047 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6048 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6049 __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_chr, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error)
6050 __Pyx_GOTREF(__pyx_t_2);
6051 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6052 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_exception, __pyx_n_s_end); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error)
6053 __Pyx_GOTREF(__pyx_t_3);
6054 __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
6055 __Pyx_GOTREF(__pyx_t_1);
6056 __Pyx_GIVEREF(__pyx_t_2);
6057 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error);
6058 __Pyx_GIVEREF(__pyx_t_3);
6059 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error);
6060 __pyx_t_2 = 0;
6061 __pyx_t_3 = 0;
6062 __pyx_r = __pyx_t_1;
6063 __pyx_t_1 = 0;
6064 goto __pyx_L0;
6065
6066 /* "pysam/libcutils.pyx":90
6067 *
6068 * # Codec error handler that just interprets each bad byte as ISO-8859-1.
6069 * def latin1_replace(exception): # <<<<<<<<<<<<<<
6070 * return (chr(exception.object[exception.start]), exception.end)
6071 *
6072 */
6073
6074 /* function exit code */
6075 __pyx_L1_error:;
6076 __Pyx_XDECREF(__pyx_t_1);
6077 __Pyx_XDECREF(__pyx_t_2);
6078 __Pyx_XDECREF(__pyx_t_3);
6079 __Pyx_AddTraceback("pysam.libcutils.latin1_replace", __pyx_clineno, __pyx_lineno, __pyx_filename);
6080 __pyx_r = NULL;
6081 __pyx_L0:;
6082 __Pyx_XGIVEREF(__pyx_r);
6083 __Pyx_RefNannyFinishContext();
6084 return __pyx_r;
6085 }
6086
6087 /* "pysam/libcutils.pyx":98
6088 * cdef str ERROR_HANDLER = 'strict'
6089 *
6090 * cpdef get_encoding_error_handler(): # <<<<<<<<<<<<<<
6091 * return ERROR_HANDLER
6092 *
6093 */
6094
6095 static PyObject *__pyx_pw_5pysam_9libcutils_9get_encoding_error_handler(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
6096 static PyObject *__pyx_f_5pysam_9libcutils_get_encoding_error_handler(CYTHON_UNUSED int __pyx_skip_dispatch) {
6097 PyObject *__pyx_r = NULL;
6098 __Pyx_RefNannyDeclarations
6099 __Pyx_RefNannySetupContext("get_encoding_error_handler", 1);
6100
6101 /* "pysam/libcutils.pyx":99
6102 *
6103 * cpdef get_encoding_error_handler():
6104 * return ERROR_HANDLER # <<<<<<<<<<<<<<
6105 *
6106 * cpdef set_encoding_error_handler(name):
6107 */
6108 __Pyx_XDECREF(__pyx_r);
6109 __Pyx_INCREF(__pyx_v_5pysam_9libcutils_ERROR_HANDLER);
6110 __pyx_r = __pyx_v_5pysam_9libcutils_ERROR_HANDLER;
6111 goto __pyx_L0;
6112
6113 /* "pysam/libcutils.pyx":98
6114 * cdef str ERROR_HANDLER = 'strict'
6115 *
6116 * cpdef get_encoding_error_handler(): # <<<<<<<<<<<<<<
6117 * return ERROR_HANDLER
6118 *
6119 */
6120
6121 /* function exit code */
6122 __pyx_L0:;
6123 __Pyx_XGIVEREF(__pyx_r);
6124 __Pyx_RefNannyFinishContext();
6125 return __pyx_r;
6126 }
6127
6128 /* Python wrapper */
6129 static PyObject *__pyx_pw_5pysam_9libcutils_9get_encoding_error_handler(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
6130 static PyMethodDef __pyx_mdef_5pysam_9libcutils_9get_encoding_error_handler = {"get_encoding_error_handler", (PyCFunction)__pyx_pw_5pysam_9libcutils_9get_encoding_error_handler, METH_NOARGS, 0};
6131 static PyObject *__pyx_pw_5pysam_9libcutils_9get_encoding_error_handler(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
6132 CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
6133 PyObject *__pyx_r = 0;
6134 __Pyx_RefNannyDeclarations
6135 __Pyx_RefNannySetupContext("get_encoding_error_handler (wrapper)", 0);
6136 __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
6137 __pyx_r = __pyx_pf_5pysam_9libcutils_8get_encoding_error_handler(__pyx_self);
6138
6139 /* function exit code */
6140 __Pyx_RefNannyFinishContext();
6141 return __pyx_r;
6142 }
6143
6144 static PyObject *__pyx_pf_5pysam_9libcutils_8get_encoding_error_handler(CYTHON_UNUSED PyObject *__pyx_self) {
6145 PyObject *__pyx_r = NULL;
6146 __Pyx_RefNannyDeclarations
6147 PyObject *__pyx_t_1 = NULL;
6148 int __pyx_lineno = 0;
6149 const char *__pyx_filename = NULL;
6150 int __pyx_clineno = 0;
6151 __Pyx_RefNannySetupContext("get_encoding_error_handler", 1);
6152 __Pyx_XDECREF(__pyx_r);
6153 __pyx_t_1 = __pyx_f_5pysam_9libcutils_get_encoding_error_handler(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
6154 __Pyx_GOTREF(__pyx_t_1);
6155 __pyx_r = __pyx_t_1;
6156 __pyx_t_1 = 0;
6157 goto __pyx_L0;
6158
6159 /* function exit code */
6160 __pyx_L1_error:;
6161 __Pyx_XDECREF(__pyx_t_1);
6162 __Pyx_AddTraceback("pysam.libcutils.get_encoding_error_handler", __pyx_clineno, __pyx_lineno, __pyx_filename);
6163 __pyx_r = NULL;
6164 __pyx_L0:;
6165 __Pyx_XGIVEREF(__pyx_r);
6166 __Pyx_RefNannyFinishContext();
6167 return __pyx_r;
6168 }
6169
6170 /* "pysam/libcutils.pyx":101
6171 * return ERROR_HANDLER
6172 *
6173 * cpdef set_encoding_error_handler(name): # <<<<<<<<<<<<<<
6174 * global ERROR_HANDLER
6175 * previous = ERROR_HANDLER
6176 */
6177
6178 static PyObject *__pyx_pw_5pysam_9libcutils_11set_encoding_error_handler(PyObject *__pyx_self,
6179 #if CYTHON_METH_FASTCALL
6180 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
6181 #else
6182 PyObject *__pyx_args, PyObject *__pyx_kwds
6183 #endif
6184 ); /*proto*/
6185 static PyObject *__pyx_f_5pysam_9libcutils_set_encoding_error_handler(PyObject *__pyx_v_name, CYTHON_UNUSED int __pyx_skip_dispatch) {
6186 PyObject *__pyx_v_previous = NULL;
6187 PyObject *__pyx_r = NULL;
6188 __Pyx_RefNannyDeclarations
6189 PyObject *__pyx_t_1 = NULL;
6190 int __pyx_lineno = 0;
6191 const char *__pyx_filename = NULL;
6192 int __pyx_clineno = 0;
6193 __Pyx_RefNannySetupContext("set_encoding_error_handler", 1);
6194
6195 /* "pysam/libcutils.pyx":103
6196 * cpdef set_encoding_error_handler(name):
6197 * global ERROR_HANDLER
6198 * previous = ERROR_HANDLER # <<<<<<<<<<<<<<
6199 * ERROR_HANDLER = name
6200 * return previous
6201 */
6202 __Pyx_INCREF(__pyx_v_5pysam_9libcutils_ERROR_HANDLER);
6203 __pyx_v_previous = __pyx_v_5pysam_9libcutils_ERROR_HANDLER;
6204
6205 /* "pysam/libcutils.pyx":104
6206 * global ERROR_HANDLER
6207 * previous = ERROR_HANDLER
6208 * ERROR_HANDLER = name # <<<<<<<<<<<<<<
6209 * return previous
6210 *
6211 */
6212 if (!(likely(PyUnicode_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_v_name))) __PYX_ERR(0, 104, __pyx_L1_error)
6213 __pyx_t_1 = __pyx_v_name;
6214 __Pyx_INCREF(__pyx_t_1);
6215 __Pyx_XGOTREF(__pyx_v_5pysam_9libcutils_ERROR_HANDLER);
6216 __Pyx_DECREF_SET(__pyx_v_5pysam_9libcutils_ERROR_HANDLER, ((PyObject*)__pyx_t_1));
6217 __Pyx_GIVEREF(__pyx_t_1);
6218 __pyx_t_1 = 0;
6219
6220 /* "pysam/libcutils.pyx":105
6221 * previous = ERROR_HANDLER
6222 * ERROR_HANDLER = name
6223 * return previous # <<<<<<<<<<<<<<
6224 *
6225 * ########################################################################
6226 */
6227 __Pyx_XDECREF(__pyx_r);
6228 __Pyx_INCREF(__pyx_v_previous);
6229 __pyx_r = __pyx_v_previous;
6230 goto __pyx_L0;
6231
6232 /* "pysam/libcutils.pyx":101
6233 * return ERROR_HANDLER
6234 *
6235 * cpdef set_encoding_error_handler(name): # <<<<<<<<<<<<<<
6236 * global ERROR_HANDLER
6237 * previous = ERROR_HANDLER
6238 */
6239
6240 /* function exit code */
6241 __pyx_L1_error:;
6242 __Pyx_XDECREF(__pyx_t_1);
6243 __Pyx_AddTraceback("pysam.libcutils.set_encoding_error_handler", __pyx_clineno, __pyx_lineno, __pyx_filename);
6244 __pyx_r = 0;
6245 __pyx_L0:;
6246 __Pyx_XDECREF(__pyx_v_previous);
6247 __Pyx_XGIVEREF(__pyx_r);
6248 __Pyx_RefNannyFinishContext();
6249 return __pyx_r;
6250 }
6251
6252 /* Python wrapper */
6253 static PyObject *__pyx_pw_5pysam_9libcutils_11set_encoding_error_handler(PyObject *__pyx_self,
6254 #if CYTHON_METH_FASTCALL
6255 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
6256 #else
6257 PyObject *__pyx_args, PyObject *__pyx_kwds
6258 #endif
6259 ); /*proto*/
6260 static PyMethodDef __pyx_mdef_5pysam_9libcutils_11set_encoding_error_handler = {"set_encoding_error_handler", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pysam_9libcutils_11set_encoding_error_handler, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
6261 static PyObject *__pyx_pw_5pysam_9libcutils_11set_encoding_error_handler(PyObject *__pyx_self,
6262 #if CYTHON_METH_FASTCALL
6263 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
6264 #else
6265 PyObject *__pyx_args, PyObject *__pyx_kwds
6266 #endif
6267 ) {
6268 PyObject *__pyx_v_name = 0;
6269 #if !CYTHON_METH_FASTCALL
6270 CYTHON_UNUSED Py_ssize_t __pyx_nargs;
6271 #endif
6272 CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
6273 PyObject* values[1] = {0};
6274 int __pyx_lineno = 0;
6275 const char *__pyx_filename = NULL;
6276 int __pyx_clineno = 0;
6277 PyObject *__pyx_r = 0;
6278 __Pyx_RefNannyDeclarations
6279 __Pyx_RefNannySetupContext("set_encoding_error_handler (wrapper)", 0);
6280 #if !CYTHON_METH_FASTCALL
6281 #if CYTHON_ASSUME_SAFE_MACROS
6282 __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
6283 #else
6284 __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
6285 #endif
6286 #endif
6287 __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
6288 {
6289 PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0};
6290 if (__pyx_kwds) {
6291 Py_ssize_t kw_args;
6292 switch (__pyx_nargs) {
6293 case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
6294 CYTHON_FALLTHROUGH;
6295 case 0: break;
6296 default: goto __pyx_L5_argtuple_error;
6297 }
6298 kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
6299 switch (__pyx_nargs) {
6300 case 0:
6301 if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_name)) != 0)) {
6302 (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
6303 kw_args--;
6304 }
6305 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 101, __pyx_L3_error)
6306 else goto __pyx_L5_argtuple_error;
6307 }
6308 if (unlikely(kw_args > 0)) {
6309 const Py_ssize_t kwd_pos_args = __pyx_nargs;
6310 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "set_encoding_error_handler") < 0)) __PYX_ERR(0, 101, __pyx_L3_error)
6311 }
6312 } else if (unlikely(__pyx_nargs != 1)) {
6313 goto __pyx_L5_argtuple_error;
6314 } else {
6315 values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
6316 }
6317 __pyx_v_name = values[0];
6318 }
6319 goto __pyx_L6_skip;
6320 __pyx_L5_argtuple_error:;
6321 __Pyx_RaiseArgtupleInvalid("set_encoding_error_handler", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 101, __pyx_L3_error)
6322 __pyx_L6_skip:;
6323 goto __pyx_L4_argument_unpacking_done;
6324 __pyx_L3_error:;
6325 {
6326 Py_ssize_t __pyx_temp;
6327 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
6328 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
6329 }
6330 }
6331 __Pyx_AddTraceback("pysam.libcutils.set_encoding_error_handler", __pyx_clineno, __pyx_lineno, __pyx_filename);
6332 __Pyx_RefNannyFinishContext();
6333 return NULL;
6334 __pyx_L4_argument_unpacking_done:;
6335 __pyx_r = __pyx_pf_5pysam_9libcutils_10set_encoding_error_handler(__pyx_self, __pyx_v_name);
6336
6337 /* function exit code */
6338 {
6339 Py_ssize_t __pyx_temp;
6340 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
6341 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
6342 }
6343 }
6344 __Pyx_RefNannyFinishContext();
6345 return __pyx_r;
6346 }
6347
6348 static PyObject *__pyx_pf_5pysam_9libcutils_10set_encoding_error_handler(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name) {
6349 PyObject *__pyx_r = NULL;
6350 __Pyx_RefNannyDeclarations
6351 PyObject *__pyx_t_1 = NULL;
6352 int __pyx_lineno = 0;
6353 const char *__pyx_filename = NULL;
6354 int __pyx_clineno = 0;
6355 __Pyx_RefNannySetupContext("set_encoding_error_handler", 1);
6356 __Pyx_XDECREF(__pyx_r);
6357 __pyx_t_1 = __pyx_f_5pysam_9libcutils_set_encoding_error_handler(__pyx_v_name, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 101, __pyx_L1_error)
6358 __Pyx_GOTREF(__pyx_t_1);
6359 __pyx_r = __pyx_t_1;
6360 __pyx_t_1 = 0;
6361 goto __pyx_L0;
6362
6363 /* function exit code */
6364 __pyx_L1_error:;
6365 __Pyx_XDECREF(__pyx_t_1);
6366 __Pyx_AddTraceback("pysam.libcutils.set_encoding_error_handler", __pyx_clineno, __pyx_lineno, __pyx_filename);
6367 __pyx_r = NULL;
6368 __pyx_L0:;
6369 __Pyx_XGIVEREF(__pyx_r);
6370 __Pyx_RefNannyFinishContext();
6371 return __pyx_r;
6372 }
6373
6374 /* "pysam/libcutils.pyx":111
6375 * ########################################################################
6376 *
6377 * cdef from_string_and_size(const char* s, size_t length): # <<<<<<<<<<<<<<
6378 * return s[:length].decode('utf-8', ERROR_HANDLER)
6379 *
6380 */
6381
6382 static PyObject *__pyx_f_5pysam_9libcutils_from_string_and_size(char const *__pyx_v_s, size_t __pyx_v_length) {
6383 PyObject *__pyx_r = NULL;
6384 __Pyx_RefNannyDeclarations
6385 PyObject *__pyx_t_1 = NULL;
6386 PyObject *__pyx_t_2 = NULL;
6387 PyObject *__pyx_t_3 = NULL;
6388 unsigned int __pyx_t_4;
6389 int __pyx_lineno = 0;
6390 const char *__pyx_filename = NULL;
6391 int __pyx_clineno = 0;
6392 __Pyx_RefNannySetupContext("from_string_and_size", 1);
6393
6394 /* "pysam/libcutils.pyx":112
6395 *
6396 * cdef from_string_and_size(const char* s, size_t length):
6397 * return s[:length].decode('utf-8', ERROR_HANDLER) # <<<<<<<<<<<<<<
6398 *
6399 * # filename encoding (adapted from lxml.etree.pyx)
6400 */
6401 __Pyx_XDECREF(__pyx_r);
6402 __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_s + 0, __pyx_v_length - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error)
6403 __Pyx_GOTREF(__pyx_t_2);
6404 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_decode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 112, __pyx_L1_error)
6405 __Pyx_GOTREF(__pyx_t_3);
6406 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6407 __pyx_t_2 = NULL;
6408 __pyx_t_4 = 0;
6409 #if CYTHON_UNPACK_METHODS
6410 if (likely(PyMethod_Check(__pyx_t_3))) {
6411 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
6412 if (likely(__pyx_t_2)) {
6413 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
6414 __Pyx_INCREF(__pyx_t_2);
6415 __Pyx_INCREF(function);
6416 __Pyx_DECREF_SET(__pyx_t_3, function);
6417 __pyx_t_4 = 1;
6418 }
6419 }
6420 #endif
6421 {
6422 PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_kp_u_utf_8, __pyx_v_5pysam_9libcutils_ERROR_HANDLER};
6423 __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4);
6424 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
6425 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error)
6426 __Pyx_GOTREF(__pyx_t_1);
6427 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6428 }
6429 __pyx_r = __pyx_t_1;
6430 __pyx_t_1 = 0;
6431 goto __pyx_L0;
6432
6433 /* "pysam/libcutils.pyx":111
6434 * ########################################################################
6435 *
6436 * cdef from_string_and_size(const char* s, size_t length): # <<<<<<<<<<<<<<
6437 * return s[:length].decode('utf-8', ERROR_HANDLER)
6438 *
6439 */
6440
6441 /* function exit code */
6442 __pyx_L1_error:;
6443 __Pyx_XDECREF(__pyx_t_1);
6444 __Pyx_XDECREF(__pyx_t_2);
6445 __Pyx_XDECREF(__pyx_t_3);
6446 __Pyx_AddTraceback("pysam.libcutils.from_string_and_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
6447 __pyx_r = 0;
6448 __pyx_L0:;
6449 __Pyx_XGIVEREF(__pyx_r);
6450 __Pyx_RefNannyFinishContext();
6451 return __pyx_r;
6452 }
6453
6454 /* "pysam/libcutils.pyx":118
6455 * cdef str TEXT_ENCODING = 'utf-8'
6456 *
6457 * cdef bytes encode_filename(object filename): # <<<<<<<<<<<<<<
6458 * """Make sure a filename is 8-bit encoded (or None)."""
6459 * if filename is None:
6460 */
6461
6462 static PyObject *__pyx_f_5pysam_9libcutils_encode_filename(PyObject *__pyx_v_filename) {
6463 PyObject *__pyx_r = NULL;
6464 __Pyx_RefNannyDeclarations
6465 int __pyx_t_1;
6466 PyObject *__pyx_t_2 = NULL;
6467 PyObject *__pyx_t_3 = NULL;
6468 PyObject *__pyx_t_4 = NULL;
6469 unsigned int __pyx_t_5;
6470 int __pyx_lineno = 0;
6471 const char *__pyx_filename = NULL;
6472 int __pyx_clineno = 0;
6473 __Pyx_RefNannySetupContext("encode_filename", 1);
6474
6475 /* "pysam/libcutils.pyx":120
6476 * cdef bytes encode_filename(object filename):
6477 * """Make sure a filename is 8-bit encoded (or None)."""
6478 * if filename is None: # <<<<<<<<<<<<<<
6479 * return None
6480 * return os.fsencode(filename)
6481 */
6482 __pyx_t_1 = (__pyx_v_filename == Py_None);
6483 if (__pyx_t_1) {
6484
6485 /* "pysam/libcutils.pyx":121
6486 * """Make sure a filename is 8-bit encoded (or None)."""
6487 * if filename is None:
6488 * return None # <<<<<<<<<<<<<<
6489 * return os.fsencode(filename)
6490 *
6491 */
6492 __Pyx_XDECREF(__pyx_r);
6493 __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
6494 goto __pyx_L0;
6495
6496 /* "pysam/libcutils.pyx":120
6497 * cdef bytes encode_filename(object filename):
6498 * """Make sure a filename is 8-bit encoded (or None)."""
6499 * if filename is None: # <<<<<<<<<<<<<<
6500 * return None
6501 * return os.fsencode(filename)
6502 */
6503 }
6504
6505 /* "pysam/libcutils.pyx":122
6506 * if filename is None:
6507 * return None
6508 * return os.fsencode(filename) # <<<<<<<<<<<<<<
6509 *
6510 *
6511 */
6512 __Pyx_XDECREF(__pyx_r);
6513 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error)
6514 __Pyx_GOTREF(__pyx_t_3);
6515 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_fsencode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 122, __pyx_L1_error)
6516 __Pyx_GOTREF(__pyx_t_4);
6517 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6518 __pyx_t_3 = NULL;
6519 __pyx_t_5 = 0;
6520 #if CYTHON_UNPACK_METHODS
6521 if (unlikely(PyMethod_Check(__pyx_t_4))) {
6522 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
6523 if (likely(__pyx_t_3)) {
6524 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6525 __Pyx_INCREF(__pyx_t_3);
6526 __Pyx_INCREF(function);
6527 __Pyx_DECREF_SET(__pyx_t_4, function);
6528 __pyx_t_5 = 1;
6529 }
6530 }
6531 #endif
6532 {
6533 PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_filename};
6534 __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5);
6535 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
6536 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 122, __pyx_L1_error)
6537 __Pyx_GOTREF(__pyx_t_2);
6538 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6539 }
6540 if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytes", __pyx_t_2))) __PYX_ERR(0, 122, __pyx_L1_error)
6541 __pyx_r = ((PyObject*)__pyx_t_2);
6542 __pyx_t_2 = 0;
6543 goto __pyx_L0;
6544
6545 /* "pysam/libcutils.pyx":118
6546 * cdef str TEXT_ENCODING = 'utf-8'
6547 *
6548 * cdef bytes encode_filename(object filename): # <<<<<<<<<<<<<<
6549 * """Make sure a filename is 8-bit encoded (or None)."""
6550 * if filename is None:
6551 */
6552
6553 /* function exit code */
6554 __pyx_L1_error:;
6555 __Pyx_XDECREF(__pyx_t_2);
6556 __Pyx_XDECREF(__pyx_t_3);
6557 __Pyx_XDECREF(__pyx_t_4);
6558 __Pyx_AddTraceback("pysam.libcutils.encode_filename", __pyx_clineno, __pyx_lineno, __pyx_filename);
6559 __pyx_r = 0;
6560 __pyx_L0:;
6561 __Pyx_XGIVEREF(__pyx_r);
6562 __Pyx_RefNannyFinishContext();
6563 return __pyx_r;
6564 }
6565
6566 /* "pysam/libcutils.pyx":125
6567 *
6568 *
6569 * cdef bytes force_bytes(object s, encoding=None, errors=None): # <<<<<<<<<<<<<<
6570 * """convert string or unicode object to bytes, assuming
6571 * utf8 encoding.
6572 */
6573
6574 static PyObject *__pyx_f_5pysam_9libcutils_force_bytes(PyObject *__pyx_v_s, struct __pyx_opt_args_5pysam_9libcutils_force_bytes *__pyx_optional_args) {
6575 PyObject *__pyx_v_encoding = ((PyObject *)Py_None);
6576 PyObject *__pyx_v_errors = ((PyObject *)Py_None);
6577 PyObject *__pyx_r = NULL;
6578 __Pyx_RefNannyDeclarations
6579 int __pyx_t_1;
6580 PyObject *__pyx_t_2 = NULL;
6581 PyObject *__pyx_t_3 = NULL;
6582 PyObject *__pyx_t_4 = NULL;
6583 PyObject *__pyx_t_5 = NULL;
6584 PyObject *__pyx_t_6 = NULL;
6585 unsigned int __pyx_t_7;
6586 int __pyx_lineno = 0;
6587 const char *__pyx_filename = NULL;
6588 int __pyx_clineno = 0;
6589 __Pyx_RefNannySetupContext("force_bytes", 1);
6590 if (__pyx_optional_args) {
6591 if (__pyx_optional_args->__pyx_n > 0) {
6592 __pyx_v_encoding = __pyx_optional_args->encoding;
6593 if (__pyx_optional_args->__pyx_n > 1) {
6594 __pyx_v_errors = __pyx_optional_args->errors;
6595 }
6596 }
6597 }
6598
6599 /* "pysam/libcutils.pyx":129
6600 * utf8 encoding.
6601 * """
6602 * if s is None: # <<<<<<<<<<<<<<
6603 * return None
6604 * elif PyBytes_Check(s):
6605 */
6606 __pyx_t_1 = (__pyx_v_s == Py_None);
6607 if (__pyx_t_1) {
6608
6609 /* "pysam/libcutils.pyx":130
6610 * """
6611 * if s is None:
6612 * return None # <<<<<<<<<<<<<<
6613 * elif PyBytes_Check(s):
6614 * return s
6615 */
6616 __Pyx_XDECREF(__pyx_r);
6617 __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
6618 goto __pyx_L0;
6619
6620 /* "pysam/libcutils.pyx":129
6621 * utf8 encoding.
6622 * """
6623 * if s is None: # <<<<<<<<<<<<<<
6624 * return None
6625 * elif PyBytes_Check(s):
6626 */
6627 }
6628
6629 /* "pysam/libcutils.pyx":131
6630 * if s is None:
6631 * return None
6632 * elif PyBytes_Check(s): # <<<<<<<<<<<<<<
6633 * return s
6634 * elif PyUnicode_Check(s):
6635 */
6636 __pyx_t_1 = PyBytes_Check(__pyx_v_s);
6637 if (__pyx_t_1) {
6638
6639 /* "pysam/libcutils.pyx":132
6640 * return None
6641 * elif PyBytes_Check(s):
6642 * return s # <<<<<<<<<<<<<<
6643 * elif PyUnicode_Check(s):
6644 * return s.encode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
6645 */
6646 __Pyx_XDECREF(__pyx_r);
6647 if (!(likely(PyBytes_CheckExact(__pyx_v_s))||((__pyx_v_s) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytes", __pyx_v_s))) __PYX_ERR(0, 132, __pyx_L1_error)
6648 __Pyx_INCREF(__pyx_v_s);
6649 __pyx_r = ((PyObject*)__pyx_v_s);
6650 goto __pyx_L0;
6651
6652 /* "pysam/libcutils.pyx":131
6653 * if s is None:
6654 * return None
6655 * elif PyBytes_Check(s): # <<<<<<<<<<<<<<
6656 * return s
6657 * elif PyUnicode_Check(s):
6658 */
6659 }
6660
6661 /* "pysam/libcutils.pyx":133
6662 * elif PyBytes_Check(s):
6663 * return s
6664 * elif PyUnicode_Check(s): # <<<<<<<<<<<<<<
6665 * return s.encode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
6666 * else:
6667 */
6668 __pyx_t_1 = PyUnicode_Check(__pyx_v_s);
6669 if (likely(__pyx_t_1)) {
6670
6671 /* "pysam/libcutils.pyx":134
6672 * return s
6673 * elif PyUnicode_Check(s):
6674 * return s.encode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER) # <<<<<<<<<<<<<<
6675 * else:
6676 * raise TypeError("Argument must be string, bytes or unicode.")
6677 */
6678 __Pyx_XDECREF(__pyx_r);
6679 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 134, __pyx_L1_error)
6680 __Pyx_GOTREF(__pyx_t_3);
6681 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_encoding); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 134, __pyx_L1_error)
6682 if (!__pyx_t_1) {
6683 } else {
6684 __Pyx_INCREF(__pyx_v_encoding);
6685 __pyx_t_4 = __pyx_v_encoding;
6686 goto __pyx_L4_bool_binop_done;
6687 }
6688 __Pyx_INCREF(__pyx_v_5pysam_9libcutils_TEXT_ENCODING);
6689 __pyx_t_4 = __pyx_v_5pysam_9libcutils_TEXT_ENCODING;
6690 __pyx_L4_bool_binop_done:;
6691 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_errors); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 134, __pyx_L1_error)
6692 if (!__pyx_t_1) {
6693 } else {
6694 __Pyx_INCREF(__pyx_v_errors);
6695 __pyx_t_5 = __pyx_v_errors;
6696 goto __pyx_L6_bool_binop_done;
6697 }
6698 __Pyx_INCREF(__pyx_v_5pysam_9libcutils_ERROR_HANDLER);
6699 __pyx_t_5 = __pyx_v_5pysam_9libcutils_ERROR_HANDLER;
6700 __pyx_L6_bool_binop_done:;
6701 __pyx_t_6 = NULL;
6702 __pyx_t_7 = 0;
6703 #if CYTHON_UNPACK_METHODS
6704 if (likely(PyMethod_Check(__pyx_t_3))) {
6705 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
6706 if (likely(__pyx_t_6)) {
6707 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
6708 __Pyx_INCREF(__pyx_t_6);
6709 __Pyx_INCREF(function);
6710 __Pyx_DECREF_SET(__pyx_t_3, function);
6711 __pyx_t_7 = 1;
6712 }
6713 }
6714 #endif
6715 {
6716 PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_t_4, __pyx_t_5};
6717 __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7);
6718 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
6719 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6720 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6721 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error)
6722 __Pyx_GOTREF(__pyx_t_2);
6723 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6724 }
6725 if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytes", __pyx_t_2))) __PYX_ERR(0, 134, __pyx_L1_error)
6726 __pyx_r = ((PyObject*)__pyx_t_2);
6727 __pyx_t_2 = 0;
6728 goto __pyx_L0;
6729
6730 /* "pysam/libcutils.pyx":133
6731 * elif PyBytes_Check(s):
6732 * return s
6733 * elif PyUnicode_Check(s): # <<<<<<<<<<<<<<
6734 * return s.encode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
6735 * else:
6736 */
6737 }
6738
6739 /* "pysam/libcutils.pyx":136
6740 * return s.encode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
6741 * else:
6742 * raise TypeError("Argument must be string, bytes or unicode.") # <<<<<<<<<<<<<<
6743 *
6744 *
6745 */
6746 /*else*/ {
6747 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error)
6748 __Pyx_GOTREF(__pyx_t_2);
6749 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
6750 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6751 __PYX_ERR(0, 136, __pyx_L1_error)
6752 }
6753
6754 /* "pysam/libcutils.pyx":125
6755 *
6756 *
6757 * cdef bytes force_bytes(object s, encoding=None, errors=None): # <<<<<<<<<<<<<<
6758 * """convert string or unicode object to bytes, assuming
6759 * utf8 encoding.
6760 */
6761
6762 /* function exit code */
6763 __pyx_L1_error:;
6764 __Pyx_XDECREF(__pyx_t_2);
6765 __Pyx_XDECREF(__pyx_t_3);
6766 __Pyx_XDECREF(__pyx_t_4);
6767 __Pyx_XDECREF(__pyx_t_5);
6768 __Pyx_XDECREF(__pyx_t_6);
6769 __Pyx_AddTraceback("pysam.libcutils.force_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
6770 __pyx_r = 0;
6771 __pyx_L0:;
6772 __Pyx_XGIVEREF(__pyx_r);
6773 __Pyx_RefNannyFinishContext();
6774 return __pyx_r;
6775 }
6776
6777 /* "pysam/libcutils.pyx":139
6778 *
6779 *
6780 * cdef charptr_to_str(const char* s, encoding=None, errors=None): # <<<<<<<<<<<<<<
6781 * if s == NULL:
6782 * return None
6783 */
6784
6785 static PyObject *__pyx_f_5pysam_9libcutils_charptr_to_str(char const *__pyx_v_s, struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str *__pyx_optional_args) {
6786 PyObject *__pyx_v_encoding = ((PyObject *)Py_None);
6787 PyObject *__pyx_v_errors = ((PyObject *)Py_None);
6788 PyObject *__pyx_r = NULL;
6789 __Pyx_RefNannyDeclarations
6790 int __pyx_t_1;
6791 PyObject *__pyx_t_2 = NULL;
6792 PyObject *__pyx_t_3 = NULL;
6793 PyObject *__pyx_t_4 = NULL;
6794 PyObject *__pyx_t_5 = NULL;
6795 PyObject *__pyx_t_6 = NULL;
6796 unsigned int __pyx_t_7;
6797 int __pyx_lineno = 0;
6798 const char *__pyx_filename = NULL;
6799 int __pyx_clineno = 0;
6800 __Pyx_RefNannySetupContext("charptr_to_str", 1);
6801 if (__pyx_optional_args) {
6802 if (__pyx_optional_args->__pyx_n > 0) {
6803 __pyx_v_encoding = __pyx_optional_args->encoding;
6804 if (__pyx_optional_args->__pyx_n > 1) {
6805 __pyx_v_errors = __pyx_optional_args->errors;
6806 }
6807 }
6808 }
6809
6810 /* "pysam/libcutils.pyx":140
6811 *
6812 * cdef charptr_to_str(const char* s, encoding=None, errors=None):
6813 * if s == NULL: # <<<<<<<<<<<<<<
6814 * return None
6815 * return s.decode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
6816 */
6817 __pyx_t_1 = (__pyx_v_s == NULL);
6818 if (__pyx_t_1) {
6819
6820 /* "pysam/libcutils.pyx":141
6821 * cdef charptr_to_str(const char* s, encoding=None, errors=None):
6822 * if s == NULL:
6823 * return None # <<<<<<<<<<<<<<
6824 * return s.decode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
6825 *
6826 */
6827 __Pyx_XDECREF(__pyx_r);
6828 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6829 goto __pyx_L0;
6830
6831 /* "pysam/libcutils.pyx":140
6832 *
6833 * cdef charptr_to_str(const char* s, encoding=None, errors=None):
6834 * if s == NULL: # <<<<<<<<<<<<<<
6835 * return None
6836 * return s.decode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
6837 */
6838 }
6839
6840 /* "pysam/libcutils.pyx":142
6841 * if s == NULL:
6842 * return None
6843 * return s.decode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER) # <<<<<<<<<<<<<<
6844 *
6845 *
6846 */
6847 __Pyx_XDECREF(__pyx_r);
6848 __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_s); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 142, __pyx_L1_error)
6849 __Pyx_GOTREF(__pyx_t_3);
6850 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_decode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 142, __pyx_L1_error)
6851 __Pyx_GOTREF(__pyx_t_4);
6852 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6853 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_encoding); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 142, __pyx_L1_error)
6854 if (!__pyx_t_1) {
6855 } else {
6856 __Pyx_INCREF(__pyx_v_encoding);
6857 __pyx_t_3 = __pyx_v_encoding;
6858 goto __pyx_L4_bool_binop_done;
6859 }
6860 __Pyx_INCREF(__pyx_v_5pysam_9libcutils_TEXT_ENCODING);
6861 __pyx_t_3 = __pyx_v_5pysam_9libcutils_TEXT_ENCODING;
6862 __pyx_L4_bool_binop_done:;
6863 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_errors); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 142, __pyx_L1_error)
6864 if (!__pyx_t_1) {
6865 } else {
6866 __Pyx_INCREF(__pyx_v_errors);
6867 __pyx_t_5 = __pyx_v_errors;
6868 goto __pyx_L6_bool_binop_done;
6869 }
6870 __Pyx_INCREF(__pyx_v_5pysam_9libcutils_ERROR_HANDLER);
6871 __pyx_t_5 = __pyx_v_5pysam_9libcutils_ERROR_HANDLER;
6872 __pyx_L6_bool_binop_done:;
6873 __pyx_t_6 = NULL;
6874 __pyx_t_7 = 0;
6875 #if CYTHON_UNPACK_METHODS
6876 if (likely(PyMethod_Check(__pyx_t_4))) {
6877 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
6878 if (likely(__pyx_t_6)) {
6879 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6880 __Pyx_INCREF(__pyx_t_6);
6881 __Pyx_INCREF(function);
6882 __Pyx_DECREF_SET(__pyx_t_4, function);
6883 __pyx_t_7 = 1;
6884 }
6885 }
6886 #endif
6887 {
6888 PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_5};
6889 __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7);
6890 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
6891 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6892 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6893 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error)
6894 __Pyx_GOTREF(__pyx_t_2);
6895 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6896 }
6897 __pyx_r = __pyx_t_2;
6898 __pyx_t_2 = 0;
6899 goto __pyx_L0;
6900
6901 /* "pysam/libcutils.pyx":139
6902 *
6903 *
6904 * cdef charptr_to_str(const char* s, encoding=None, errors=None): # <<<<<<<<<<<<<<
6905 * if s == NULL:
6906 * return None
6907 */
6908
6909 /* function exit code */
6910 __pyx_L1_error:;
6911 __Pyx_XDECREF(__pyx_t_2);
6912 __Pyx_XDECREF(__pyx_t_3);
6913 __Pyx_XDECREF(__pyx_t_4);
6914 __Pyx_XDECREF(__pyx_t_5);
6915 __Pyx_XDECREF(__pyx_t_6);
6916 __Pyx_AddTraceback("pysam.libcutils.charptr_to_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
6917 __pyx_r = 0;
6918 __pyx_L0:;
6919 __Pyx_XGIVEREF(__pyx_r);
6920 __Pyx_RefNannyFinishContext();
6921 return __pyx_r;
6922 }
6923
6924 /* "pysam/libcutils.pyx":145
6925 *
6926 *
6927 * cdef charptr_to_str_w_len(const char* s, size_t n, encoding=None, errors=None): # <<<<<<<<<<<<<<
6928 * if s == NULL:
6929 * return None
6930 */
6931
6932 static PyObject *__pyx_f_5pysam_9libcutils_charptr_to_str_w_len(char const *__pyx_v_s, size_t __pyx_v_n, struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str_w_len *__pyx_optional_args) {
6933 PyObject *__pyx_v_encoding = ((PyObject *)Py_None);
6934 PyObject *__pyx_v_errors = ((PyObject *)Py_None);
6935 PyObject *__pyx_r = NULL;
6936 __Pyx_RefNannyDeclarations
6937 int __pyx_t_1;
6938 PyObject *__pyx_t_2 = NULL;
6939 PyObject *__pyx_t_3 = NULL;
6940 PyObject *__pyx_t_4 = NULL;
6941 PyObject *__pyx_t_5 = NULL;
6942 PyObject *__pyx_t_6 = NULL;
6943 unsigned int __pyx_t_7;
6944 int __pyx_lineno = 0;
6945 const char *__pyx_filename = NULL;
6946 int __pyx_clineno = 0;
6947 __Pyx_RefNannySetupContext("charptr_to_str_w_len", 1);
6948 if (__pyx_optional_args) {
6949 if (__pyx_optional_args->__pyx_n > 0) {
6950 __pyx_v_encoding = __pyx_optional_args->encoding;
6951 if (__pyx_optional_args->__pyx_n > 1) {
6952 __pyx_v_errors = __pyx_optional_args->errors;
6953 }
6954 }
6955 }
6956
6957 /* "pysam/libcutils.pyx":146
6958 *
6959 * cdef charptr_to_str_w_len(const char* s, size_t n, encoding=None, errors=None):
6960 * if s == NULL: # <<<<<<<<<<<<<<
6961 * return None
6962 * return s[:n].decode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
6963 */
6964 __pyx_t_1 = (__pyx_v_s == NULL);
6965 if (__pyx_t_1) {
6966
6967 /* "pysam/libcutils.pyx":147
6968 * cdef charptr_to_str_w_len(const char* s, size_t n, encoding=None, errors=None):
6969 * if s == NULL:
6970 * return None # <<<<<<<<<<<<<<
6971 * return s[:n].decode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
6972 *
6973 */
6974 __Pyx_XDECREF(__pyx_r);
6975 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6976 goto __pyx_L0;
6977
6978 /* "pysam/libcutils.pyx":146
6979 *
6980 * cdef charptr_to_str_w_len(const char* s, size_t n, encoding=None, errors=None):
6981 * if s == NULL: # <<<<<<<<<<<<<<
6982 * return None
6983 * return s[:n].decode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
6984 */
6985 }
6986
6987 /* "pysam/libcutils.pyx":148
6988 * if s == NULL:
6989 * return None
6990 * return s[:n].decode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER) # <<<<<<<<<<<<<<
6991 *
6992 *
6993 */
6994 __Pyx_XDECREF(__pyx_r);
6995 __pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_s + 0, __pyx_v_n - 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 148, __pyx_L1_error)
6996 __Pyx_GOTREF(__pyx_t_3);
6997 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_decode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 148, __pyx_L1_error)
6998 __Pyx_GOTREF(__pyx_t_4);
6999 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7000 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_encoding); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 148, __pyx_L1_error)
7001 if (!__pyx_t_1) {
7002 } else {
7003 __Pyx_INCREF(__pyx_v_encoding);
7004 __pyx_t_3 = __pyx_v_encoding;
7005 goto __pyx_L4_bool_binop_done;
7006 }
7007 __Pyx_INCREF(__pyx_v_5pysam_9libcutils_TEXT_ENCODING);
7008 __pyx_t_3 = __pyx_v_5pysam_9libcutils_TEXT_ENCODING;
7009 __pyx_L4_bool_binop_done:;
7010 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_errors); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 148, __pyx_L1_error)
7011 if (!__pyx_t_1) {
7012 } else {
7013 __Pyx_INCREF(__pyx_v_errors);
7014 __pyx_t_5 = __pyx_v_errors;
7015 goto __pyx_L6_bool_binop_done;
7016 }
7017 __Pyx_INCREF(__pyx_v_5pysam_9libcutils_ERROR_HANDLER);
7018 __pyx_t_5 = __pyx_v_5pysam_9libcutils_ERROR_HANDLER;
7019 __pyx_L6_bool_binop_done:;
7020 __pyx_t_6 = NULL;
7021 __pyx_t_7 = 0;
7022 #if CYTHON_UNPACK_METHODS
7023 if (likely(PyMethod_Check(__pyx_t_4))) {
7024 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
7025 if (likely(__pyx_t_6)) {
7026 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
7027 __Pyx_INCREF(__pyx_t_6);
7028 __Pyx_INCREF(function);
7029 __Pyx_DECREF_SET(__pyx_t_4, function);
7030 __pyx_t_7 = 1;
7031 }
7032 }
7033 #endif
7034 {
7035 PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_5};
7036 __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7);
7037 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
7038 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7039 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7040 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error)
7041 __Pyx_GOTREF(__pyx_t_2);
7042 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7043 }
7044 __pyx_r = __pyx_t_2;
7045 __pyx_t_2 = 0;
7046 goto __pyx_L0;
7047
7048 /* "pysam/libcutils.pyx":145
7049 *
7050 *
7051 * cdef charptr_to_str_w_len(const char* s, size_t n, encoding=None, errors=None): # <<<<<<<<<<<<<<
7052 * if s == NULL:
7053 * return None
7054 */
7055
7056 /* function exit code */
7057 __pyx_L1_error:;
7058 __Pyx_XDECREF(__pyx_t_2);
7059 __Pyx_XDECREF(__pyx_t_3);
7060 __Pyx_XDECREF(__pyx_t_4);
7061 __Pyx_XDECREF(__pyx_t_5);
7062 __Pyx_XDECREF(__pyx_t_6);
7063 __Pyx_AddTraceback("pysam.libcutils.charptr_to_str_w_len", __pyx_clineno, __pyx_lineno, __pyx_filename);
7064 __pyx_r = 0;
7065 __pyx_L0:;
7066 __Pyx_XGIVEREF(__pyx_r);
7067 __Pyx_RefNannyFinishContext();
7068 return __pyx_r;
7069 }
7070
7071 /* "pysam/libcutils.pyx":151
7072 *
7073 *
7074 * cdef bytes charptr_to_bytes(const char* s, encoding=None, errors=None): # <<<<<<<<<<<<<<
7075 * if s == NULL:
7076 * return None
7077 */
7078
7079 static PyObject *__pyx_f_5pysam_9libcutils_charptr_to_bytes(char const *__pyx_v_s, struct __pyx_opt_args_5pysam_9libcutils_charptr_to_bytes *__pyx_optional_args) {
7080 PyObject *__pyx_r = NULL;
7081 __Pyx_RefNannyDeclarations
7082 int __pyx_t_1;
7083 PyObject *__pyx_t_2 = NULL;
7084 int __pyx_lineno = 0;
7085 const char *__pyx_filename = NULL;
7086 int __pyx_clineno = 0;
7087 __Pyx_RefNannySetupContext("charptr_to_bytes", 1);
7088 if (__pyx_optional_args) {
7089 }
7090
7091 /* "pysam/libcutils.pyx":152
7092 *
7093 * cdef bytes charptr_to_bytes(const char* s, encoding=None, errors=None):
7094 * if s == NULL: # <<<<<<<<<<<<<<
7095 * return None
7096 * else:
7097 */
7098 __pyx_t_1 = (__pyx_v_s == NULL);
7099 if (__pyx_t_1) {
7100
7101 /* "pysam/libcutils.pyx":153
7102 * cdef bytes charptr_to_bytes(const char* s, encoding=None, errors=None):
7103 * if s == NULL:
7104 * return None # <<<<<<<<<<<<<<
7105 * else:
7106 * return s
7107 */
7108 __Pyx_XDECREF(__pyx_r);
7109 __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
7110 goto __pyx_L0;
7111
7112 /* "pysam/libcutils.pyx":152
7113 *
7114 * cdef bytes charptr_to_bytes(const char* s, encoding=None, errors=None):
7115 * if s == NULL: # <<<<<<<<<<<<<<
7116 * return None
7117 * else:
7118 */
7119 }
7120
7121 /* "pysam/libcutils.pyx":155
7122 * return None
7123 * else:
7124 * return s # <<<<<<<<<<<<<<
7125 *
7126 *
7127 */
7128 /*else*/ {
7129 __Pyx_XDECREF(__pyx_r);
7130 __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_s); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 155, __pyx_L1_error)
7131 __Pyx_GOTREF(__pyx_t_2);
7132 __pyx_r = ((PyObject*)__pyx_t_2);
7133 __pyx_t_2 = 0;
7134 goto __pyx_L0;
7135 }
7136
7137 /* "pysam/libcutils.pyx":151
7138 *
7139 *
7140 * cdef bytes charptr_to_bytes(const char* s, encoding=None, errors=None): # <<<<<<<<<<<<<<
7141 * if s == NULL:
7142 * return None
7143 */
7144
7145 /* function exit code */
7146 __pyx_L1_error:;
7147 __Pyx_XDECREF(__pyx_t_2);
7148 __Pyx_AddTraceback("pysam.libcutils.charptr_to_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
7149 __pyx_r = 0;
7150 __pyx_L0:;
7151 __Pyx_XGIVEREF(__pyx_r);
7152 __Pyx_RefNannyFinishContext();
7153 return __pyx_r;
7154 }
7155
7156 /* "pysam/libcutils.pyx":158
7157 *
7158 *
7159 * cdef force_str(object s, encoding=None, errors=None): # <<<<<<<<<<<<<<
7160 * """Return s converted to str type of current Python
7161 * (bytes in Py2, unicode in Py3)"""
7162 */
7163
7164 static PyObject *__pyx_f_5pysam_9libcutils_force_str(PyObject *__pyx_v_s, struct __pyx_opt_args_5pysam_9libcutils_force_str *__pyx_optional_args) {
7165 PyObject *__pyx_v_encoding = ((PyObject *)Py_None);
7166 PyObject *__pyx_v_errors = ((PyObject *)Py_None);
7167 PyObject *__pyx_r = NULL;
7168 __Pyx_RefNannyDeclarations
7169 int __pyx_t_1;
7170 PyObject *__pyx_t_2 = NULL;
7171 PyObject *__pyx_t_3 = NULL;
7172 PyObject *__pyx_t_4 = NULL;
7173 PyObject *__pyx_t_5 = NULL;
7174 PyObject *__pyx_t_6 = NULL;
7175 unsigned int __pyx_t_7;
7176 int __pyx_lineno = 0;
7177 const char *__pyx_filename = NULL;
7178 int __pyx_clineno = 0;
7179 __Pyx_RefNannySetupContext("force_str", 1);
7180 if (__pyx_optional_args) {
7181 if (__pyx_optional_args->__pyx_n > 0) {
7182 __pyx_v_encoding = __pyx_optional_args->encoding;
7183 if (__pyx_optional_args->__pyx_n > 1) {
7184 __pyx_v_errors = __pyx_optional_args->errors;
7185 }
7186 }
7187 }
7188
7189 /* "pysam/libcutils.pyx":161
7190 * """Return s converted to str type of current Python
7191 * (bytes in Py2, unicode in Py3)"""
7192 * if s is None: # <<<<<<<<<<<<<<
7193 * return None
7194 * if PyBytes_Check(s):
7195 */
7196 __pyx_t_1 = (__pyx_v_s == Py_None);
7197 if (__pyx_t_1) {
7198
7199 /* "pysam/libcutils.pyx":162
7200 * (bytes in Py2, unicode in Py3)"""
7201 * if s is None:
7202 * return None # <<<<<<<<<<<<<<
7203 * if PyBytes_Check(s):
7204 * return s.decode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
7205 */
7206 __Pyx_XDECREF(__pyx_r);
7207 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7208 goto __pyx_L0;
7209
7210 /* "pysam/libcutils.pyx":161
7211 * """Return s converted to str type of current Python
7212 * (bytes in Py2, unicode in Py3)"""
7213 * if s is None: # <<<<<<<<<<<<<<
7214 * return None
7215 * if PyBytes_Check(s):
7216 */
7217 }
7218
7219 /* "pysam/libcutils.pyx":163
7220 * if s is None:
7221 * return None
7222 * if PyBytes_Check(s): # <<<<<<<<<<<<<<
7223 * return s.decode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
7224 * # assume unicode
7225 */
7226 __pyx_t_1 = PyBytes_Check(__pyx_v_s);
7227 if (__pyx_t_1) {
7228
7229 /* "pysam/libcutils.pyx":164
7230 * return None
7231 * if PyBytes_Check(s):
7232 * return s.decode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER) # <<<<<<<<<<<<<<
7233 * # assume unicode
7234 * return s
7235 */
7236 __Pyx_XDECREF(__pyx_r);
7237 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_decode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 164, __pyx_L1_error)
7238 __Pyx_GOTREF(__pyx_t_3);
7239 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_encoding); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 164, __pyx_L1_error)
7240 if (!__pyx_t_1) {
7241 } else {
7242 __Pyx_INCREF(__pyx_v_encoding);
7243 __pyx_t_4 = __pyx_v_encoding;
7244 goto __pyx_L5_bool_binop_done;
7245 }
7246 __Pyx_INCREF(__pyx_v_5pysam_9libcutils_TEXT_ENCODING);
7247 __pyx_t_4 = __pyx_v_5pysam_9libcutils_TEXT_ENCODING;
7248 __pyx_L5_bool_binop_done:;
7249 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_errors); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 164, __pyx_L1_error)
7250 if (!__pyx_t_1) {
7251 } else {
7252 __Pyx_INCREF(__pyx_v_errors);
7253 __pyx_t_5 = __pyx_v_errors;
7254 goto __pyx_L7_bool_binop_done;
7255 }
7256 __Pyx_INCREF(__pyx_v_5pysam_9libcutils_ERROR_HANDLER);
7257 __pyx_t_5 = __pyx_v_5pysam_9libcutils_ERROR_HANDLER;
7258 __pyx_L7_bool_binop_done:;
7259 __pyx_t_6 = NULL;
7260 __pyx_t_7 = 0;
7261 #if CYTHON_UNPACK_METHODS
7262 if (likely(PyMethod_Check(__pyx_t_3))) {
7263 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
7264 if (likely(__pyx_t_6)) {
7265 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
7266 __Pyx_INCREF(__pyx_t_6);
7267 __Pyx_INCREF(function);
7268 __Pyx_DECREF_SET(__pyx_t_3, function);
7269 __pyx_t_7 = 1;
7270 }
7271 }
7272 #endif
7273 {
7274 PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_t_4, __pyx_t_5};
7275 __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7);
7276 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
7277 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7278 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7279 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 164, __pyx_L1_error)
7280 __Pyx_GOTREF(__pyx_t_2);
7281 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7282 }
7283 __pyx_r = __pyx_t_2;
7284 __pyx_t_2 = 0;
7285 goto __pyx_L0;
7286
7287 /* "pysam/libcutils.pyx":163
7288 * if s is None:
7289 * return None
7290 * if PyBytes_Check(s): # <<<<<<<<<<<<<<
7291 * return s.decode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
7292 * # assume unicode
7293 */
7294 }
7295
7296 /* "pysam/libcutils.pyx":166
7297 * return s.decode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
7298 * # assume unicode
7299 * return s # <<<<<<<<<<<<<<
7300 *
7301 *
7302 */
7303 __Pyx_XDECREF(__pyx_r);
7304 __Pyx_INCREF(__pyx_v_s);
7305 __pyx_r = __pyx_v_s;
7306 goto __pyx_L0;
7307
7308 /* "pysam/libcutils.pyx":158
7309 *
7310 *
7311 * cdef force_str(object s, encoding=None, errors=None): # <<<<<<<<<<<<<<
7312 * """Return s converted to str type of current Python
7313 * (bytes in Py2, unicode in Py3)"""
7314 */
7315
7316 /* function exit code */
7317 __pyx_L1_error:;
7318 __Pyx_XDECREF(__pyx_t_2);
7319 __Pyx_XDECREF(__pyx_t_3);
7320 __Pyx_XDECREF(__pyx_t_4);
7321 __Pyx_XDECREF(__pyx_t_5);
7322 __Pyx_XDECREF(__pyx_t_6);
7323 __Pyx_AddTraceback("pysam.libcutils.force_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
7324 __pyx_r = 0;
7325 __pyx_L0:;
7326 __Pyx_XGIVEREF(__pyx_r);
7327 __Pyx_RefNannyFinishContext();
7328 return __pyx_r;
7329 }
7330
7331 /* "pysam/libcutils.pyx":169
7332 *
7333 *
7334 * cdef decode_bytes(bytes s, encoding=None, errors=None): # <<<<<<<<<<<<<<
7335 * """Return s converted to current Python's str type,
7336 * always decoding even in Python 2"""
7337 */
7338
7339 static PyObject *__pyx_f_5pysam_9libcutils_decode_bytes(PyObject *__pyx_v_s, struct __pyx_opt_args_5pysam_9libcutils_decode_bytes *__pyx_optional_args) {
7340 PyObject *__pyx_v_encoding = ((PyObject *)Py_None);
7341 PyObject *__pyx_v_errors = ((PyObject *)Py_None);
7342 PyObject *__pyx_r = NULL;
7343 __Pyx_RefNannyDeclarations
7344 int __pyx_t_1;
7345 PyObject *__pyx_t_2 = NULL;
7346 PyObject *__pyx_t_3 = NULL;
7347 PyObject *__pyx_t_4 = NULL;
7348 PyObject *__pyx_t_5 = NULL;
7349 PyObject *__pyx_t_6 = NULL;
7350 unsigned int __pyx_t_7;
7351 int __pyx_lineno = 0;
7352 const char *__pyx_filename = NULL;
7353 int __pyx_clineno = 0;
7354 __Pyx_RefNannySetupContext("decode_bytes", 1);
7355 if (__pyx_optional_args) {
7356 if (__pyx_optional_args->__pyx_n > 0) {
7357 __pyx_v_encoding = __pyx_optional_args->encoding;
7358 if (__pyx_optional_args->__pyx_n > 1) {
7359 __pyx_v_errors = __pyx_optional_args->errors;
7360 }
7361 }
7362 }
7363
7364 /* "pysam/libcutils.pyx":172
7365 * """Return s converted to current Python's str type,
7366 * always decoding even in Python 2"""
7367 * if s is None: # <<<<<<<<<<<<<<
7368 * return None
7369 * else:
7370 */
7371 __pyx_t_1 = (__pyx_v_s == ((PyObject*)Py_None));
7372 if (__pyx_t_1) {
7373
7374 /* "pysam/libcutils.pyx":173
7375 * always decoding even in Python 2"""
7376 * if s is None:
7377 * return None # <<<<<<<<<<<<<<
7378 * else:
7379 * return s.decode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
7380 */
7381 __Pyx_XDECREF(__pyx_r);
7382 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7383 goto __pyx_L0;
7384
7385 /* "pysam/libcutils.pyx":172
7386 * """Return s converted to current Python's str type,
7387 * always decoding even in Python 2"""
7388 * if s is None: # <<<<<<<<<<<<<<
7389 * return None
7390 * else:
7391 */
7392 }
7393
7394 /* "pysam/libcutils.pyx":175
7395 * return None
7396 * else:
7397 * return s.decode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER) # <<<<<<<<<<<<<<
7398 *
7399 *
7400 */
7401 /*else*/ {
7402 __Pyx_XDECREF(__pyx_r);
7403 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_decode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 175, __pyx_L1_error)
7404 __Pyx_GOTREF(__pyx_t_3);
7405 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_encoding); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 175, __pyx_L1_error)
7406 if (!__pyx_t_1) {
7407 } else {
7408 __Pyx_INCREF(__pyx_v_encoding);
7409 __pyx_t_4 = __pyx_v_encoding;
7410 goto __pyx_L4_bool_binop_done;
7411 }
7412 __Pyx_INCREF(__pyx_v_5pysam_9libcutils_TEXT_ENCODING);
7413 __pyx_t_4 = __pyx_v_5pysam_9libcutils_TEXT_ENCODING;
7414 __pyx_L4_bool_binop_done:;
7415 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_errors); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 175, __pyx_L1_error)
7416 if (!__pyx_t_1) {
7417 } else {
7418 __Pyx_INCREF(__pyx_v_errors);
7419 __pyx_t_5 = __pyx_v_errors;
7420 goto __pyx_L6_bool_binop_done;
7421 }
7422 __Pyx_INCREF(__pyx_v_5pysam_9libcutils_ERROR_HANDLER);
7423 __pyx_t_5 = __pyx_v_5pysam_9libcutils_ERROR_HANDLER;
7424 __pyx_L6_bool_binop_done:;
7425 __pyx_t_6 = NULL;
7426 __pyx_t_7 = 0;
7427 #if CYTHON_UNPACK_METHODS
7428 if (likely(PyMethod_Check(__pyx_t_3))) {
7429 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
7430 if (likely(__pyx_t_6)) {
7431 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
7432 __Pyx_INCREF(__pyx_t_6);
7433 __Pyx_INCREF(function);
7434 __Pyx_DECREF_SET(__pyx_t_3, function);
7435 __pyx_t_7 = 1;
7436 }
7437 }
7438 #endif
7439 {
7440 PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_t_4, __pyx_t_5};
7441 __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7);
7442 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
7443 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7444 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7445 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 175, __pyx_L1_error)
7446 __Pyx_GOTREF(__pyx_t_2);
7447 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7448 }
7449 __pyx_r = __pyx_t_2;
7450 __pyx_t_2 = 0;
7451 goto __pyx_L0;
7452 }
7453
7454 /* "pysam/libcutils.pyx":169
7455 *
7456 *
7457 * cdef decode_bytes(bytes s, encoding=None, errors=None): # <<<<<<<<<<<<<<
7458 * """Return s converted to current Python's str type,
7459 * always decoding even in Python 2"""
7460 */
7461
7462 /* function exit code */
7463 __pyx_L1_error:;
7464 __Pyx_XDECREF(__pyx_t_2);
7465 __Pyx_XDECREF(__pyx_t_3);
7466 __Pyx_XDECREF(__pyx_t_4);
7467 __Pyx_XDECREF(__pyx_t_5);
7468 __Pyx_XDECREF(__pyx_t_6);
7469 __Pyx_AddTraceback("pysam.libcutils.decode_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
7470 __pyx_r = 0;
7471 __pyx_L0:;
7472 __Pyx_XGIVEREF(__pyx_r);
7473 __Pyx_RefNannyFinishContext();
7474 return __pyx_r;
7475 }
7476
7477 /* "pysam/libcutils.pyx":178
7478 *
7479 *
7480 * cpdef parse_region(contig=None, # <<<<<<<<<<<<<<
7481 * start=None,
7482 * stop=None,
7483 */
7484
7485 static PyObject *__pyx_pw_5pysam_9libcutils_13parse_region(PyObject *__pyx_self,
7486 #if CYTHON_METH_FASTCALL
7487 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
7488 #else
7489 PyObject *__pyx_args, PyObject *__pyx_kwds
7490 #endif
7491 ); /*proto*/
7492 static PyObject *__pyx_f_5pysam_9libcutils_parse_region(CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_9libcutils_parse_region *__pyx_optional_args) {
7493 PyObject *__pyx_v_contig = ((PyObject *)Py_None);
7494
7495 /* "pysam/libcutils.pyx":179
7496 *
7497 * cpdef parse_region(contig=None,
7498 * start=None, # <<<<<<<<<<<<<<
7499 * stop=None,
7500 * region=None,
7501 */
7502 PyObject *__pyx_v_start = ((PyObject *)Py_None);
7503
7504 /* "pysam/libcutils.pyx":180
7505 * cpdef parse_region(contig=None,
7506 * start=None,
7507 * stop=None, # <<<<<<<<<<<<<<
7508 * region=None,
7509 * reference=None,
7510 */
7511 PyObject *__pyx_v_stop = ((PyObject *)Py_None);
7512
7513 /* "pysam/libcutils.pyx":181
7514 * start=None,
7515 * stop=None,
7516 * region=None, # <<<<<<<<<<<<<<
7517 * reference=None,
7518 * end=None):
7519 */
7520 PyObject *__pyx_v_region = ((PyObject *)Py_None);
7521
7522 /* "pysam/libcutils.pyx":182
7523 * stop=None,
7524 * region=None,
7525 * reference=None, # <<<<<<<<<<<<<<
7526 * end=None):
7527 * """parse alternative ways to specify a genomic region. A region can
7528 */
7529 PyObject *__pyx_v_reference = ((PyObject *)Py_None);
7530
7531 /* "pysam/libcutils.pyx":183
7532 * region=None,
7533 * reference=None,
7534 * end=None): # <<<<<<<<<<<<<<
7535 * """parse alternative ways to specify a genomic region. A region can
7536 * either be specified by :term:`reference`, `start` and
7537 */
7538 PyObject *__pyx_v_end = ((PyObject *)Py_None);
7539 int32_t __pyx_v_rstart;
7540 int32_t __pyx_v_rstop;
7541 PyObject *__pyx_v_coord = NULL;
7542 PyObject *__pyx_v_parts = NULL;
7543 PyObject *__pyx_r = NULL;
7544 __Pyx_RefNannyDeclarations
7545 int __pyx_t_1;
7546 PyObject *__pyx_t_2 = NULL;
7547 int __pyx_t_3;
7548 PyObject *__pyx_t_4 = NULL;
7549 PyObject *__pyx_t_5 = NULL;
7550 PyObject *__pyx_t_6 = NULL;
7551 int32_t __pyx_t_7;
7552 int __pyx_t_8;
7553 PyObject *__pyx_t_9 = NULL;
7554 PyObject *__pyx_t_10 = NULL;
7555 PyObject *__pyx_t_11 = NULL;
7556 PyObject *__pyx_t_12 = NULL;
7557 unsigned int __pyx_t_13;
7558 PyObject *(*__pyx_t_14)(PyObject *);
7559 Py_ssize_t __pyx_t_15;
7560 int __pyx_lineno = 0;
7561 const char *__pyx_filename = NULL;
7562 int __pyx_clineno = 0;
7563 __Pyx_RefNannySetupContext("parse_region", 0);
7564 if (__pyx_optional_args) {
7565 if (__pyx_optional_args->__pyx_n > 0) {
7566 __pyx_v_contig = __pyx_optional_args->contig;
7567 if (__pyx_optional_args->__pyx_n > 1) {
7568 __pyx_v_start = __pyx_optional_args->start;
7569 if (__pyx_optional_args->__pyx_n > 2) {
7570 __pyx_v_stop = __pyx_optional_args->stop;
7571 if (__pyx_optional_args->__pyx_n > 3) {
7572 __pyx_v_region = __pyx_optional_args->region;
7573 if (__pyx_optional_args->__pyx_n > 4) {
7574 __pyx_v_reference = __pyx_optional_args->reference;
7575 if (__pyx_optional_args->__pyx_n > 5) {
7576 __pyx_v_end = __pyx_optional_args->end;
7577 }
7578 }
7579 }
7580 }
7581 }
7582 }
7583 }
7584 __Pyx_INCREF(__pyx_v_contig);
7585 __Pyx_INCREF(__pyx_v_stop);
7586
7587 /* "pysam/libcutils.pyx":216
7588 *
7589 *
7590 * if reference is not None: # <<<<<<<<<<<<<<
7591 * if contig is not None:
7592 * raise ValueError('contig and reference should not both be specified')
7593 */
7594 __pyx_t_1 = (__pyx_v_reference != Py_None);
7595 if (__pyx_t_1) {
7596
7597 /* "pysam/libcutils.pyx":217
7598 *
7599 * if reference is not None:
7600 * if contig is not None: # <<<<<<<<<<<<<<
7601 * raise ValueError('contig and reference should not both be specified')
7602 * contig = reference
7603 */
7604 __pyx_t_1 = (__pyx_v_contig != Py_None);
7605 if (unlikely(__pyx_t_1)) {
7606
7607 /* "pysam/libcutils.pyx":218
7608 * if reference is not None:
7609 * if contig is not None:
7610 * raise ValueError('contig and reference should not both be specified') # <<<<<<<<<<<<<<
7611 * contig = reference
7612 *
7613 */
7614 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error)
7615 __Pyx_GOTREF(__pyx_t_2);
7616 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
7617 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7618 __PYX_ERR(0, 218, __pyx_L1_error)
7619
7620 /* "pysam/libcutils.pyx":217
7621 *
7622 * if reference is not None:
7623 * if contig is not None: # <<<<<<<<<<<<<<
7624 * raise ValueError('contig and reference should not both be specified')
7625 * contig = reference
7626 */
7627 }
7628
7629 /* "pysam/libcutils.pyx":219
7630 * if contig is not None:
7631 * raise ValueError('contig and reference should not both be specified')
7632 * contig = reference # <<<<<<<<<<<<<<
7633 *
7634 * if contig is not None and region is not None:
7635 */
7636 __Pyx_INCREF(__pyx_v_reference);
7637 __Pyx_DECREF_SET(__pyx_v_contig, __pyx_v_reference);
7638
7639 /* "pysam/libcutils.pyx":216
7640 *
7641 *
7642 * if reference is not None: # <<<<<<<<<<<<<<
7643 * if contig is not None:
7644 * raise ValueError('contig and reference should not both be specified')
7645 */
7646 }
7647
7648 /* "pysam/libcutils.pyx":221
7649 * contig = reference
7650 *
7651 * if contig is not None and region is not None: # <<<<<<<<<<<<<<
7652 * raise ValueError('contig/reference and region should not both be specified')
7653 *
7654 */
7655 __pyx_t_3 = (__pyx_v_contig != Py_None);
7656 if (__pyx_t_3) {
7657 } else {
7658 __pyx_t_1 = __pyx_t_3;
7659 goto __pyx_L6_bool_binop_done;
7660 }
7661 __pyx_t_3 = (__pyx_v_region != Py_None);
7662 __pyx_t_1 = __pyx_t_3;
7663 __pyx_L6_bool_binop_done:;
7664 if (unlikely(__pyx_t_1)) {
7665
7666 /* "pysam/libcutils.pyx":222
7667 *
7668 * if contig is not None and region is not None:
7669 * raise ValueError('contig/reference and region should not both be specified') # <<<<<<<<<<<<<<
7670 *
7671 * if end is not None:
7672 */
7673 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 222, __pyx_L1_error)
7674 __Pyx_GOTREF(__pyx_t_2);
7675 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
7676 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7677 __PYX_ERR(0, 222, __pyx_L1_error)
7678
7679 /* "pysam/libcutils.pyx":221
7680 * contig = reference
7681 *
7682 * if contig is not None and region is not None: # <<<<<<<<<<<<<<
7683 * raise ValueError('contig/reference and region should not both be specified')
7684 *
7685 */
7686 }
7687
7688 /* "pysam/libcutils.pyx":224
7689 * raise ValueError('contig/reference and region should not both be specified')
7690 *
7691 * if end is not None: # <<<<<<<<<<<<<<
7692 * if stop is not None:
7693 * raise ValueError('stop and end should not both be specified')
7694 */
7695 __pyx_t_1 = (__pyx_v_end != Py_None);
7696 if (__pyx_t_1) {
7697
7698 /* "pysam/libcutils.pyx":225
7699 *
7700 * if end is not None:
7701 * if stop is not None: # <<<<<<<<<<<<<<
7702 * raise ValueError('stop and end should not both be specified')
7703 * stop = end
7704 */
7705 __pyx_t_1 = (__pyx_v_stop != Py_None);
7706 if (unlikely(__pyx_t_1)) {
7707
7708 /* "pysam/libcutils.pyx":226
7709 * if end is not None:
7710 * if stop is not None:
7711 * raise ValueError('stop and end should not both be specified') # <<<<<<<<<<<<<<
7712 * stop = end
7713 *
7714 */
7715 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 226, __pyx_L1_error)
7716 __Pyx_GOTREF(__pyx_t_2);
7717 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
7718 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7719 __PYX_ERR(0, 226, __pyx_L1_error)
7720
7721 /* "pysam/libcutils.pyx":225
7722 *
7723 * if end is not None:
7724 * if stop is not None: # <<<<<<<<<<<<<<
7725 * raise ValueError('stop and end should not both be specified')
7726 * stop = end
7727 */
7728 }
7729
7730 /* "pysam/libcutils.pyx":227
7731 * if stop is not None:
7732 * raise ValueError('stop and end should not both be specified')
7733 * stop = end # <<<<<<<<<<<<<<
7734 *
7735 * if contig is None and region is None:
7736 */
7737 __Pyx_INCREF(__pyx_v_end);
7738 __Pyx_DECREF_SET(__pyx_v_stop, __pyx_v_end);
7739
7740 /* "pysam/libcutils.pyx":224
7741 * raise ValueError('contig/reference and region should not both be specified')
7742 *
7743 * if end is not None: # <<<<<<<<<<<<<<
7744 * if stop is not None:
7745 * raise ValueError('stop and end should not both be specified')
7746 */
7747 }
7748
7749 /* "pysam/libcutils.pyx":229
7750 * stop = end
7751 *
7752 * if contig is None and region is None: # <<<<<<<<<<<<<<
7753 * raise ValueError("neither contig nor region are given")
7754 *
7755 */
7756 __pyx_t_3 = (__pyx_v_contig == Py_None);
7757 if (__pyx_t_3) {
7758 } else {
7759 __pyx_t_1 = __pyx_t_3;
7760 goto __pyx_L11_bool_binop_done;
7761 }
7762 __pyx_t_3 = (__pyx_v_region == Py_None);
7763 __pyx_t_1 = __pyx_t_3;
7764 __pyx_L11_bool_binop_done:;
7765 if (unlikely(__pyx_t_1)) {
7766
7767 /* "pysam/libcutils.pyx":230
7768 *
7769 * if contig is None and region is None:
7770 * raise ValueError("neither contig nor region are given") # <<<<<<<<<<<<<<
7771 *
7772 * rstart = 0
7773 */
7774 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 230, __pyx_L1_error)
7775 __Pyx_GOTREF(__pyx_t_2);
7776 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
7777 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7778 __PYX_ERR(0, 230, __pyx_L1_error)
7779
7780 /* "pysam/libcutils.pyx":229
7781 * stop = end
7782 *
7783 * if contig is None and region is None: # <<<<<<<<<<<<<<
7784 * raise ValueError("neither contig nor region are given")
7785 *
7786 */
7787 }
7788
7789 /* "pysam/libcutils.pyx":232
7790 * raise ValueError("neither contig nor region are given")
7791 *
7792 * rstart = 0 # <<<<<<<<<<<<<<
7793 * rstop = MAX_POS
7794 * if start is not None:
7795 */
7796 __pyx_v_rstart = 0;
7797
7798 /* "pysam/libcutils.pyx":233
7799 *
7800 * rstart = 0
7801 * rstop = MAX_POS # <<<<<<<<<<<<<<
7802 * if start is not None:
7803 * try:
7804 */
7805 __pyx_v_rstop = __pyx_v_5pysam_9libcutils_MAX_POS;
7806
7807 /* "pysam/libcutils.pyx":234
7808 * rstart = 0
7809 * rstop = MAX_POS
7810 * if start is not None: # <<<<<<<<<<<<<<
7811 * try:
7812 * rstart = start
7813 */
7814 __pyx_t_1 = (__pyx_v_start != Py_None);
7815 if (__pyx_t_1) {
7816
7817 /* "pysam/libcutils.pyx":235
7818 * rstop = MAX_POS
7819 * if start is not None:
7820 * try: # <<<<<<<<<<<<<<
7821 * rstart = start
7822 * except OverflowError:
7823 */
7824 {
7825 __Pyx_PyThreadState_declare
7826 __Pyx_PyThreadState_assign
7827 __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
7828 __Pyx_XGOTREF(__pyx_t_4);
7829 __Pyx_XGOTREF(__pyx_t_5);
7830 __Pyx_XGOTREF(__pyx_t_6);
7831 /*try:*/ {
7832
7833 /* "pysam/libcutils.pyx":236
7834 * if start is not None:
7835 * try:
7836 * rstart = start # <<<<<<<<<<<<<<
7837 * except OverflowError:
7838 * raise ValueError('start out of range (%i)' % start)
7839 */
7840 __pyx_t_7 = __Pyx_PyInt_As_int32_t(__pyx_v_start); if (unlikely((__pyx_t_7 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 236, __pyx_L14_error)
7841 __pyx_v_rstart = __pyx_t_7;
7842
7843 /* "pysam/libcutils.pyx":235
7844 * rstop = MAX_POS
7845 * if start is not None:
7846 * try: # <<<<<<<<<<<<<<
7847 * rstart = start
7848 * except OverflowError:
7849 */
7850 }
7851 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
7852 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
7853 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
7854 goto __pyx_L19_try_end;
7855 __pyx_L14_error:;
7856 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
7857
7858 /* "pysam/libcutils.pyx":237
7859 * try:
7860 * rstart = start
7861 * except OverflowError: # <<<<<<<<<<<<<<
7862 * raise ValueError('start out of range (%i)' % start)
7863 *
7864 */
7865 __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_OverflowError);
7866 if (__pyx_t_8) {
7867 __Pyx_AddTraceback("pysam.libcutils.parse_region", __pyx_clineno, __pyx_lineno, __pyx_filename);
7868 if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_9, &__pyx_t_10) < 0) __PYX_ERR(0, 237, __pyx_L16_except_error)
7869 __Pyx_XGOTREF(__pyx_t_2);
7870 __Pyx_XGOTREF(__pyx_t_9);
7871 __Pyx_XGOTREF(__pyx_t_10);
7872
7873 /* "pysam/libcutils.pyx":238
7874 * rstart = start
7875 * except OverflowError:
7876 * raise ValueError('start out of range (%i)' % start) # <<<<<<<<<<<<<<
7877 *
7878 * if stop is not None:
7879 */
7880 __pyx_t_11 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_start_out_of_range_i, __pyx_v_start); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 238, __pyx_L16_except_error)
7881 __Pyx_GOTREF(__pyx_t_11);
7882 __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 238, __pyx_L16_except_error)
7883 __Pyx_GOTREF(__pyx_t_12);
7884 __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
7885 __Pyx_Raise(__pyx_t_12, 0, 0, 0);
7886 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
7887 __PYX_ERR(0, 238, __pyx_L16_except_error)
7888 }
7889 goto __pyx_L16_except_error;
7890
7891 /* "pysam/libcutils.pyx":235
7892 * rstop = MAX_POS
7893 * if start is not None:
7894 * try: # <<<<<<<<<<<<<<
7895 * rstart = start
7896 * except OverflowError:
7897 */
7898 __pyx_L16_except_error:;
7899 __Pyx_XGIVEREF(__pyx_t_4);
7900 __Pyx_XGIVEREF(__pyx_t_5);
7901 __Pyx_XGIVEREF(__pyx_t_6);
7902 __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
7903 goto __pyx_L1_error;
7904 __pyx_L19_try_end:;
7905 }
7906
7907 /* "pysam/libcutils.pyx":234
7908 * rstart = 0
7909 * rstop = MAX_POS
7910 * if start is not None: # <<<<<<<<<<<<<<
7911 * try:
7912 * rstart = start
7913 */
7914 }
7915
7916 /* "pysam/libcutils.pyx":240
7917 * raise ValueError('start out of range (%i)' % start)
7918 *
7919 * if stop is not None: # <<<<<<<<<<<<<<
7920 * try:
7921 * rstop = stop
7922 */
7923 __pyx_t_1 = (__pyx_v_stop != Py_None);
7924 if (__pyx_t_1) {
7925
7926 /* "pysam/libcutils.pyx":241
7927 *
7928 * if stop is not None:
7929 * try: # <<<<<<<<<<<<<<
7930 * rstop = stop
7931 * except OverflowError:
7932 */
7933 {
7934 __Pyx_PyThreadState_declare
7935 __Pyx_PyThreadState_assign
7936 __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4);
7937 __Pyx_XGOTREF(__pyx_t_6);
7938 __Pyx_XGOTREF(__pyx_t_5);
7939 __Pyx_XGOTREF(__pyx_t_4);
7940 /*try:*/ {
7941
7942 /* "pysam/libcutils.pyx":242
7943 * if stop is not None:
7944 * try:
7945 * rstop = stop # <<<<<<<<<<<<<<
7946 * except OverflowError:
7947 * raise ValueError('stop out of range (%i)' % stop)
7948 */
7949 __pyx_t_7 = __Pyx_PyInt_As_int32_t(__pyx_v_stop); if (unlikely((__pyx_t_7 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 242, __pyx_L23_error)
7950 __pyx_v_rstop = __pyx_t_7;
7951
7952 /* "pysam/libcutils.pyx":241
7953 *
7954 * if stop is not None:
7955 * try: # <<<<<<<<<<<<<<
7956 * rstop = stop
7957 * except OverflowError:
7958 */
7959 }
7960 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
7961 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
7962 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
7963 goto __pyx_L28_try_end;
7964 __pyx_L23_error:;
7965 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
7966 __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
7967 __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
7968 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
7969 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
7970
7971 /* "pysam/libcutils.pyx":243
7972 * try:
7973 * rstop = stop
7974 * except OverflowError: # <<<<<<<<<<<<<<
7975 * raise ValueError('stop out of range (%i)' % stop)
7976 *
7977 */
7978 __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_OverflowError);
7979 if (__pyx_t_8) {
7980 __Pyx_AddTraceback("pysam.libcutils.parse_region", __pyx_clineno, __pyx_lineno, __pyx_filename);
7981 if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_9, &__pyx_t_2) < 0) __PYX_ERR(0, 243, __pyx_L25_except_error)
7982 __Pyx_XGOTREF(__pyx_t_10);
7983 __Pyx_XGOTREF(__pyx_t_9);
7984 __Pyx_XGOTREF(__pyx_t_2);
7985
7986 /* "pysam/libcutils.pyx":244
7987 * rstop = stop
7988 * except OverflowError:
7989 * raise ValueError('stop out of range (%i)' % stop) # <<<<<<<<<<<<<<
7990 *
7991 * if region:
7992 */
7993 __pyx_t_12 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_stop_out_of_range_i, __pyx_v_stop); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 244, __pyx_L25_except_error)
7994 __Pyx_GOTREF(__pyx_t_12);
7995 __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 244, __pyx_L25_except_error)
7996 __Pyx_GOTREF(__pyx_t_11);
7997 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
7998 __Pyx_Raise(__pyx_t_11, 0, 0, 0);
7999 __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
8000 __PYX_ERR(0, 244, __pyx_L25_except_error)
8001 }
8002 goto __pyx_L25_except_error;
8003
8004 /* "pysam/libcutils.pyx":241
8005 *
8006 * if stop is not None:
8007 * try: # <<<<<<<<<<<<<<
8008 * rstop = stop
8009 * except OverflowError:
8010 */
8011 __pyx_L25_except_error:;
8012 __Pyx_XGIVEREF(__pyx_t_6);
8013 __Pyx_XGIVEREF(__pyx_t_5);
8014 __Pyx_XGIVEREF(__pyx_t_4);
8015 __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4);
8016 goto __pyx_L1_error;
8017 __pyx_L28_try_end:;
8018 }
8019
8020 /* "pysam/libcutils.pyx":240
8021 * raise ValueError('start out of range (%i)' % start)
8022 *
8023 * if stop is not None: # <<<<<<<<<<<<<<
8024 * try:
8025 * rstop = stop
8026 */
8027 }
8028
8029 /* "pysam/libcutils.pyx":246
8030 * raise ValueError('stop out of range (%i)' % stop)
8031 *
8032 * if region: # <<<<<<<<<<<<<<
8033 * if ":" in region:
8034 * contig, coord = region.split(":")
8035 */
8036 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 246, __pyx_L1_error)
8037 if (__pyx_t_1) {
8038
8039 /* "pysam/libcutils.pyx":247
8040 *
8041 * if region:
8042 * if ":" in region: # <<<<<<<<<<<<<<
8043 * contig, coord = region.split(":")
8044 * parts = coord.split("-")
8045 */
8046 __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_kp_u__7, __pyx_v_region, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 247, __pyx_L1_error)
8047 if (__pyx_t_1) {
8048
8049 /* "pysam/libcutils.pyx":248
8050 * if region:
8051 * if ":" in region:
8052 * contig, coord = region.split(":") # <<<<<<<<<<<<<<
8053 * parts = coord.split("-")
8054 * rstart = int(parts[0]) - 1
8055 */
8056 __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_region, __pyx_n_s_split); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 248, __pyx_L1_error)
8057 __Pyx_GOTREF(__pyx_t_9);
8058 __pyx_t_10 = NULL;
8059 __pyx_t_13 = 0;
8060 #if CYTHON_UNPACK_METHODS
8061 if (likely(PyMethod_Check(__pyx_t_9))) {
8062 __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
8063 if (likely(__pyx_t_10)) {
8064 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
8065 __Pyx_INCREF(__pyx_t_10);
8066 __Pyx_INCREF(function);
8067 __Pyx_DECREF_SET(__pyx_t_9, function);
8068 __pyx_t_13 = 1;
8069 }
8070 }
8071 #endif
8072 {
8073 PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_kp_u__7};
8074 __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_13, 1+__pyx_t_13);
8075 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
8076 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 248, __pyx_L1_error)
8077 __Pyx_GOTREF(__pyx_t_2);
8078 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
8079 }
8080 if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
8081 PyObject* sequence = __pyx_t_2;
8082 Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
8083 if (unlikely(size != 2)) {
8084 if (size > 2) __Pyx_RaiseTooManyValuesError(2);
8085 else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
8086 __PYX_ERR(0, 248, __pyx_L1_error)
8087 }
8088 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8089 if (likely(PyTuple_CheckExact(sequence))) {
8090 __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0);
8091 __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1);
8092 } else {
8093 __pyx_t_9 = PyList_GET_ITEM(sequence, 0);
8094 __pyx_t_10 = PyList_GET_ITEM(sequence, 1);
8095 }
8096 __Pyx_INCREF(__pyx_t_9);
8097 __Pyx_INCREF(__pyx_t_10);
8098 #else
8099 __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 248, __pyx_L1_error)
8100 __Pyx_GOTREF(__pyx_t_9);
8101 __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 248, __pyx_L1_error)
8102 __Pyx_GOTREF(__pyx_t_10);
8103 #endif
8104 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8105 } else {
8106 Py_ssize_t index = -1;
8107 __pyx_t_11 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 248, __pyx_L1_error)
8108 __Pyx_GOTREF(__pyx_t_11);
8109 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8110 __pyx_t_14 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_11);
8111 index = 0; __pyx_t_9 = __pyx_t_14(__pyx_t_11); if (unlikely(!__pyx_t_9)) goto __pyx_L33_unpacking_failed;
8112 __Pyx_GOTREF(__pyx_t_9);
8113 index = 1; __pyx_t_10 = __pyx_t_14(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L33_unpacking_failed;
8114 __Pyx_GOTREF(__pyx_t_10);
8115 if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_11), 2) < 0) __PYX_ERR(0, 248, __pyx_L1_error)
8116 __pyx_t_14 = NULL;
8117 __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
8118 goto __pyx_L34_unpacking_done;
8119 __pyx_L33_unpacking_failed:;
8120 __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
8121 __pyx_t_14 = NULL;
8122 if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
8123 __PYX_ERR(0, 248, __pyx_L1_error)
8124 __pyx_L34_unpacking_done:;
8125 }
8126 __Pyx_DECREF_SET(__pyx_v_contig, __pyx_t_9);
8127 __pyx_t_9 = 0;
8128 __pyx_v_coord = __pyx_t_10;
8129 __pyx_t_10 = 0;
8130
8131 /* "pysam/libcutils.pyx":249
8132 * if ":" in region:
8133 * contig, coord = region.split(":")
8134 * parts = coord.split("-") # <<<<<<<<<<<<<<
8135 * rstart = int(parts[0]) - 1
8136 * if len(parts) >= 1:
8137 */
8138 __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_coord, __pyx_n_s_split); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 249, __pyx_L1_error)
8139 __Pyx_GOTREF(__pyx_t_10);
8140 __pyx_t_9 = NULL;
8141 __pyx_t_13 = 0;
8142 #if CYTHON_UNPACK_METHODS
8143 if (likely(PyMethod_Check(__pyx_t_10))) {
8144 __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
8145 if (likely(__pyx_t_9)) {
8146 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
8147 __Pyx_INCREF(__pyx_t_9);
8148 __Pyx_INCREF(function);
8149 __Pyx_DECREF_SET(__pyx_t_10, function);
8150 __pyx_t_13 = 1;
8151 }
8152 }
8153 #endif
8154 {
8155 PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_kp_u__8};
8156 __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_13, 1+__pyx_t_13);
8157 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
8158 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error)
8159 __Pyx_GOTREF(__pyx_t_2);
8160 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
8161 }
8162 __pyx_v_parts = __pyx_t_2;
8163 __pyx_t_2 = 0;
8164
8165 /* "pysam/libcutils.pyx":250
8166 * contig, coord = region.split(":")
8167 * parts = coord.split("-")
8168 * rstart = int(parts[0]) - 1 # <<<<<<<<<<<<<<
8169 * if len(parts) >= 1:
8170 * rstop = int(parts[1])
8171 */
8172 __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_parts, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 250, __pyx_L1_error)
8173 __Pyx_GOTREF(__pyx_t_2);
8174 __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 250, __pyx_L1_error)
8175 __Pyx_GOTREF(__pyx_t_10);
8176 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8177 __pyx_t_2 = __Pyx_PyInt_SubtractObjC(__pyx_t_10, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 250, __pyx_L1_error)
8178 __Pyx_GOTREF(__pyx_t_2);
8179 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
8180 __pyx_t_7 = __Pyx_PyInt_As_int32_t(__pyx_t_2); if (unlikely((__pyx_t_7 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 250, __pyx_L1_error)
8181 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8182 __pyx_v_rstart = __pyx_t_7;
8183
8184 /* "pysam/libcutils.pyx":251
8185 * parts = coord.split("-")
8186 * rstart = int(parts[0]) - 1
8187 * if len(parts) >= 1: # <<<<<<<<<<<<<<
8188 * rstop = int(parts[1])
8189 * else:
8190 */
8191 __pyx_t_15 = PyObject_Length(__pyx_v_parts); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 251, __pyx_L1_error)
8192 __pyx_t_1 = (__pyx_t_15 >= 1);
8193 if (__pyx_t_1) {
8194
8195 /* "pysam/libcutils.pyx":252
8196 * rstart = int(parts[0]) - 1
8197 * if len(parts) >= 1:
8198 * rstop = int(parts[1]) # <<<<<<<<<<<<<<
8199 * else:
8200 * contig = region
8201 */
8202 __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_parts, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error)
8203 __Pyx_GOTREF(__pyx_t_2);
8204 __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 252, __pyx_L1_error)
8205 __Pyx_GOTREF(__pyx_t_10);
8206 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8207 __pyx_t_7 = __Pyx_PyInt_As_int32_t(__pyx_t_10); if (unlikely((__pyx_t_7 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 252, __pyx_L1_error)
8208 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
8209 __pyx_v_rstop = __pyx_t_7;
8210
8211 /* "pysam/libcutils.pyx":251
8212 * parts = coord.split("-")
8213 * rstart = int(parts[0]) - 1
8214 * if len(parts) >= 1: # <<<<<<<<<<<<<<
8215 * rstop = int(parts[1])
8216 * else:
8217 */
8218 }
8219
8220 /* "pysam/libcutils.pyx":247
8221 *
8222 * if region:
8223 * if ":" in region: # <<<<<<<<<<<<<<
8224 * contig, coord = region.split(":")
8225 * parts = coord.split("-")
8226 */
8227 goto __pyx_L32;
8228 }
8229
8230 /* "pysam/libcutils.pyx":254
8231 * rstop = int(parts[1])
8232 * else:
8233 * contig = region # <<<<<<<<<<<<<<
8234 *
8235 * if rstart > rstop:
8236 */
8237 /*else*/ {
8238 __Pyx_INCREF(__pyx_v_region);
8239 __Pyx_DECREF_SET(__pyx_v_contig, __pyx_v_region);
8240 }
8241 __pyx_L32:;
8242
8243 /* "pysam/libcutils.pyx":246
8244 * raise ValueError('stop out of range (%i)' % stop)
8245 *
8246 * if region: # <<<<<<<<<<<<<<
8247 * if ":" in region:
8248 * contig, coord = region.split(":")
8249 */
8250 }
8251
8252 /* "pysam/libcutils.pyx":256
8253 * contig = region
8254 *
8255 * if rstart > rstop: # <<<<<<<<<<<<<<
8256 * raise ValueError('invalid coordinates: start (%i) > stop (%i)' % (rstart, rstop))
8257 * if not 0 <= rstart < MAX_POS:
8258 */
8259 __pyx_t_1 = (__pyx_v_rstart > __pyx_v_rstop);
8260 if (unlikely(__pyx_t_1)) {
8261
8262 /* "pysam/libcutils.pyx":257
8263 *
8264 * if rstart > rstop:
8265 * raise ValueError('invalid coordinates: start (%i) > stop (%i)' % (rstart, rstop)) # <<<<<<<<<<<<<<
8266 * if not 0 <= rstart < MAX_POS:
8267 * raise ValueError('start out of range (%i)' % rstart)
8268 */
8269 __pyx_t_10 = __Pyx_PyInt_From_int32_t(__pyx_v_rstart); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 257, __pyx_L1_error)
8270 __Pyx_GOTREF(__pyx_t_10);
8271 __pyx_t_2 = __Pyx_PyInt_From_int32_t(__pyx_v_rstop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error)
8272 __Pyx_GOTREF(__pyx_t_2);
8273 __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 257, __pyx_L1_error)
8274 __Pyx_GOTREF(__pyx_t_9);
8275 __Pyx_GIVEREF(__pyx_t_10);
8276 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10)) __PYX_ERR(0, 257, __pyx_L1_error);
8277 __Pyx_GIVEREF(__pyx_t_2);
8278 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error);
8279 __pyx_t_10 = 0;
8280 __pyx_t_2 = 0;
8281 __pyx_t_2 = PyUnicode_Format(__pyx_kp_u_invalid_coordinates_start_i_stop, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error)
8282 __Pyx_GOTREF(__pyx_t_2);
8283 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
8284 __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 257, __pyx_L1_error)
8285 __Pyx_GOTREF(__pyx_t_9);
8286 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8287 __Pyx_Raise(__pyx_t_9, 0, 0, 0);
8288 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
8289 __PYX_ERR(0, 257, __pyx_L1_error)
8290
8291 /* "pysam/libcutils.pyx":256
8292 * contig = region
8293 *
8294 * if rstart > rstop: # <<<<<<<<<<<<<<
8295 * raise ValueError('invalid coordinates: start (%i) > stop (%i)' % (rstart, rstop))
8296 * if not 0 <= rstart < MAX_POS:
8297 */
8298 }
8299
8300 /* "pysam/libcutils.pyx":258
8301 * if rstart > rstop:
8302 * raise ValueError('invalid coordinates: start (%i) > stop (%i)' % (rstart, rstop))
8303 * if not 0 <= rstart < MAX_POS: # <<<<<<<<<<<<<<
8304 * raise ValueError('start out of range (%i)' % rstart)
8305 * if not 0 <= rstop <= MAX_POS:
8306 */
8307 __pyx_t_1 = (0 <= __pyx_v_rstart);
8308 if (__pyx_t_1) {
8309 __pyx_t_1 = (__pyx_v_rstart < __pyx_v_5pysam_9libcutils_MAX_POS);
8310 }
8311 __pyx_t_3 = (!__pyx_t_1);
8312 if (unlikely(__pyx_t_3)) {
8313
8314 /* "pysam/libcutils.pyx":259
8315 * raise ValueError('invalid coordinates: start (%i) > stop (%i)' % (rstart, rstop))
8316 * if not 0 <= rstart < MAX_POS:
8317 * raise ValueError('start out of range (%i)' % rstart) # <<<<<<<<<<<<<<
8318 * if not 0 <= rstop <= MAX_POS:
8319 * raise ValueError('stop out of range (%i)' % rstop)
8320 */
8321 __pyx_t_9 = __Pyx_PyInt_From_int32_t(__pyx_v_rstart); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 259, __pyx_L1_error)
8322 __Pyx_GOTREF(__pyx_t_9);
8323 __pyx_t_2 = PyUnicode_Format(__pyx_kp_u_start_out_of_range_i, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 259, __pyx_L1_error)
8324 __Pyx_GOTREF(__pyx_t_2);
8325 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
8326 __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 259, __pyx_L1_error)
8327 __Pyx_GOTREF(__pyx_t_9);
8328 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8329 __Pyx_Raise(__pyx_t_9, 0, 0, 0);
8330 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
8331 __PYX_ERR(0, 259, __pyx_L1_error)
8332
8333 /* "pysam/libcutils.pyx":258
8334 * if rstart > rstop:
8335 * raise ValueError('invalid coordinates: start (%i) > stop (%i)' % (rstart, rstop))
8336 * if not 0 <= rstart < MAX_POS: # <<<<<<<<<<<<<<
8337 * raise ValueError('start out of range (%i)' % rstart)
8338 * if not 0 <= rstop <= MAX_POS:
8339 */
8340 }
8341
8342 /* "pysam/libcutils.pyx":260
8343 * if not 0 <= rstart < MAX_POS:
8344 * raise ValueError('start out of range (%i)' % rstart)
8345 * if not 0 <= rstop <= MAX_POS: # <<<<<<<<<<<<<<
8346 * raise ValueError('stop out of range (%i)' % rstop)
8347 *
8348 */
8349 __pyx_t_3 = (0 <= __pyx_v_rstop);
8350 if (__pyx_t_3) {
8351 __pyx_t_3 = (__pyx_v_rstop <= __pyx_v_5pysam_9libcutils_MAX_POS);
8352 }
8353 __pyx_t_1 = (!__pyx_t_3);
8354 if (unlikely(__pyx_t_1)) {
8355
8356 /* "pysam/libcutils.pyx":261
8357 * raise ValueError('start out of range (%i)' % rstart)
8358 * if not 0 <= rstop <= MAX_POS:
8359 * raise ValueError('stop out of range (%i)' % rstop) # <<<<<<<<<<<<<<
8360 *
8361 * return contig, rstart, rstop
8362 */
8363 __pyx_t_9 = __Pyx_PyInt_From_int32_t(__pyx_v_rstop); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 261, __pyx_L1_error)
8364 __Pyx_GOTREF(__pyx_t_9);
8365 __pyx_t_2 = PyUnicode_Format(__pyx_kp_u_stop_out_of_range_i, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error)
8366 __Pyx_GOTREF(__pyx_t_2);
8367 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
8368 __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 261, __pyx_L1_error)
8369 __Pyx_GOTREF(__pyx_t_9);
8370 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8371 __Pyx_Raise(__pyx_t_9, 0, 0, 0);
8372 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
8373 __PYX_ERR(0, 261, __pyx_L1_error)
8374
8375 /* "pysam/libcutils.pyx":260
8376 * if not 0 <= rstart < MAX_POS:
8377 * raise ValueError('start out of range (%i)' % rstart)
8378 * if not 0 <= rstop <= MAX_POS: # <<<<<<<<<<<<<<
8379 * raise ValueError('stop out of range (%i)' % rstop)
8380 *
8381 */
8382 }
8383
8384 /* "pysam/libcutils.pyx":263
8385 * raise ValueError('stop out of range (%i)' % rstop)
8386 *
8387 * return contig, rstart, rstop # <<<<<<<<<<<<<<
8388 *
8389 *
8390 */
8391 __Pyx_XDECREF(__pyx_r);
8392 __pyx_t_9 = __Pyx_PyInt_From_int32_t(__pyx_v_rstart); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 263, __pyx_L1_error)
8393 __Pyx_GOTREF(__pyx_t_9);
8394 __pyx_t_2 = __Pyx_PyInt_From_int32_t(__pyx_v_rstop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 263, __pyx_L1_error)
8395 __Pyx_GOTREF(__pyx_t_2);
8396 __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 263, __pyx_L1_error)
8397 __Pyx_GOTREF(__pyx_t_10);
8398 __Pyx_INCREF(__pyx_v_contig);
8399 __Pyx_GIVEREF(__pyx_v_contig);
8400 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_contig)) __PYX_ERR(0, 263, __pyx_L1_error);
8401 __Pyx_GIVEREF(__pyx_t_9);
8402 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9)) __PYX_ERR(0, 263, __pyx_L1_error);
8403 __Pyx_GIVEREF(__pyx_t_2);
8404 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_2)) __PYX_ERR(0, 263, __pyx_L1_error);
8405 __pyx_t_9 = 0;
8406 __pyx_t_2 = 0;
8407 __pyx_r = __pyx_t_10;
8408 __pyx_t_10 = 0;
8409 goto __pyx_L0;
8410
8411 /* "pysam/libcutils.pyx":178
8412 *
8413 *
8414 * cpdef parse_region(contig=None, # <<<<<<<<<<<<<<
8415 * start=None,
8416 * stop=None,
8417 */
8418
8419 /* function exit code */
8420 __pyx_L1_error:;
8421 __Pyx_XDECREF(__pyx_t_2);
8422 __Pyx_XDECREF(__pyx_t_9);
8423 __Pyx_XDECREF(__pyx_t_10);
8424 __Pyx_XDECREF(__pyx_t_11);
8425 __Pyx_XDECREF(__pyx_t_12);
8426 __Pyx_AddTraceback("pysam.libcutils.parse_region", __pyx_clineno, __pyx_lineno, __pyx_filename);
8427 __pyx_r = 0;
8428 __pyx_L0:;
8429 __Pyx_XDECREF(__pyx_v_coord);
8430 __Pyx_XDECREF(__pyx_v_parts);
8431 __Pyx_XDECREF(__pyx_v_contig);
8432 __Pyx_XDECREF(__pyx_v_stop);
8433 __Pyx_XGIVEREF(__pyx_r);
8434 __Pyx_RefNannyFinishContext();
8435 return __pyx_r;
8436 }
8437
8438 /* Python wrapper */
8439 static PyObject *__pyx_pw_5pysam_9libcutils_13parse_region(PyObject *__pyx_self,
8440 #if CYTHON_METH_FASTCALL
8441 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
8442 #else
8443 PyObject *__pyx_args, PyObject *__pyx_kwds
8444 #endif
8445 ); /*proto*/
8446 PyDoc_STRVAR(__pyx_doc_5pysam_9libcutils_12parse_region, "parse alternative ways to specify a genomic region. A region can\n either be specified by :term:`reference`, `start` and\n `end`. `start` and `end` denote 0-based, half-open intervals.\n \n :term:`reference` and `end` are also accepted for backward\n compatibility as synonyms for :term:`contig` and `stop`,\n respectively.\n\n Alternatively, a samtools :term:`region` string can be supplied.\n\n If any of the coordinates are missing they will be replaced by the\n minimum (`start`) or maximum (`end`) coordinate.\n\n Note that region strings are 1-based, while `start` and `end`\n denote an interval in python coordinates.\n\n Returns\n -------\n\n tuple : a tuple of `reference`, `start` and `end`.\n\n Raises\n ------\n\n ValueError\n for invalid or out of bounds regions.\n\n ");
8447 static PyMethodDef __pyx_mdef_5pysam_9libcutils_13parse_region = {"parse_region", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pysam_9libcutils_13parse_region, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pysam_9libcutils_12parse_region};
8448 static PyObject *__pyx_pw_5pysam_9libcutils_13parse_region(PyObject *__pyx_self,
8449 #if CYTHON_METH_FASTCALL
8450 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
8451 #else
8452 PyObject *__pyx_args, PyObject *__pyx_kwds
8453 #endif
8454 ) {
8455 PyObject *__pyx_v_contig = 0;
8456 PyObject *__pyx_v_start = 0;
8457 PyObject *__pyx_v_stop = 0;
8458 PyObject *__pyx_v_region = 0;
8459 PyObject *__pyx_v_reference = 0;
8460 PyObject *__pyx_v_end = 0;
8461 #if !CYTHON_METH_FASTCALL
8462 CYTHON_UNUSED Py_ssize_t __pyx_nargs;
8463 #endif
8464 CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
8465 PyObject* values[6] = {0,0,0,0,0,0};
8466 int __pyx_lineno = 0;
8467 const char *__pyx_filename = NULL;
8468 int __pyx_clineno = 0;
8469 PyObject *__pyx_r = 0;
8470 __Pyx_RefNannyDeclarations
8471 __Pyx_RefNannySetupContext("parse_region (wrapper)", 0);
8472 #if !CYTHON_METH_FASTCALL
8473 #if CYTHON_ASSUME_SAFE_MACROS
8474 __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
8475 #else
8476 __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
8477 #endif
8478 #endif
8479 __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
8480 {
8481 PyObject **__pyx_pyargnames[] = {&__pyx_n_s_contig,&__pyx_n_s_start,&__pyx_n_s_stop,&__pyx_n_s_region,&__pyx_n_s_reference,&__pyx_n_s_end,0};
8482 values[0] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
8483
8484 /* "pysam/libcutils.pyx":179
8485 *
8486 * cpdef parse_region(contig=None,
8487 * start=None, # <<<<<<<<<<<<<<
8488 * stop=None,
8489 * region=None,
8490 */
8491 values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
8492
8493 /* "pysam/libcutils.pyx":180
8494 * cpdef parse_region(contig=None,
8495 * start=None,
8496 * stop=None, # <<<<<<<<<<<<<<
8497 * region=None,
8498 * reference=None,
8499 */
8500 values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
8501
8502 /* "pysam/libcutils.pyx":181
8503 * start=None,
8504 * stop=None,
8505 * region=None, # <<<<<<<<<<<<<<
8506 * reference=None,
8507 * end=None):
8508 */
8509 values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
8510
8511 /* "pysam/libcutils.pyx":182
8512 * stop=None,
8513 * region=None,
8514 * reference=None, # <<<<<<<<<<<<<<
8515 * end=None):
8516 * """parse alternative ways to specify a genomic region. A region can
8517 */
8518 values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
8519
8520 /* "pysam/libcutils.pyx":183
8521 * region=None,
8522 * reference=None,
8523 * end=None): # <<<<<<<<<<<<<<
8524 * """parse alternative ways to specify a genomic region. A region can
8525 * either be specified by :term:`reference`, `start` and
8526 */
8527 values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
8528 if (__pyx_kwds) {
8529 Py_ssize_t kw_args;
8530 switch (__pyx_nargs) {
8531 case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5);
8532 CYTHON_FALLTHROUGH;
8533 case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
8534 CYTHON_FALLTHROUGH;
8535 case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
8536 CYTHON_FALLTHROUGH;
8537 case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
8538 CYTHON_FALLTHROUGH;
8539 case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
8540 CYTHON_FALLTHROUGH;
8541 case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
8542 CYTHON_FALLTHROUGH;
8543 case 0: break;
8544 default: goto __pyx_L5_argtuple_error;
8545 }
8546 kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
8547 switch (__pyx_nargs) {
8548 case 0:
8549 if (kw_args > 0) {
8550 PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_contig);
8551 if (value) { values[0] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
8552 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 178, __pyx_L3_error)
8553 }
8554 CYTHON_FALLTHROUGH;
8555 case 1:
8556 if (kw_args > 0) {
8557 PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_start);
8558 if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
8559 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 178, __pyx_L3_error)
8560 }
8561 CYTHON_FALLTHROUGH;
8562 case 2:
8563 if (kw_args > 0) {
8564 PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_stop);
8565 if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
8566 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 178, __pyx_L3_error)
8567 }
8568 CYTHON_FALLTHROUGH;
8569 case 3:
8570 if (kw_args > 0) {
8571 PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_region);
8572 if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
8573 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 178, __pyx_L3_error)
8574 }
8575 CYTHON_FALLTHROUGH;
8576 case 4:
8577 if (kw_args > 0) {
8578 PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_reference);
8579 if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
8580 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 178, __pyx_L3_error)
8581 }
8582 CYTHON_FALLTHROUGH;
8583 case 5:
8584 if (kw_args > 0) {
8585 PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_end);
8586 if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
8587 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 178, __pyx_L3_error)
8588 }
8589 }
8590 if (unlikely(kw_args > 0)) {
8591 const Py_ssize_t kwd_pos_args = __pyx_nargs;
8592 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "parse_region") < 0)) __PYX_ERR(0, 178, __pyx_L3_error)
8593 }
8594 } else {
8595 switch (__pyx_nargs) {
8596 case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5);
8597 CYTHON_FALLTHROUGH;
8598 case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
8599 CYTHON_FALLTHROUGH;
8600 case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
8601 CYTHON_FALLTHROUGH;
8602 case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
8603 CYTHON_FALLTHROUGH;
8604 case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
8605 CYTHON_FALLTHROUGH;
8606 case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
8607 CYTHON_FALLTHROUGH;
8608 case 0: break;
8609 default: goto __pyx_L5_argtuple_error;
8610 }
8611 }
8612 __pyx_v_contig = values[0];
8613 __pyx_v_start = values[1];
8614 __pyx_v_stop = values[2];
8615 __pyx_v_region = values[3];
8616 __pyx_v_reference = values[4];
8617 __pyx_v_end = values[5];
8618 }
8619 goto __pyx_L6_skip;
8620 __pyx_L5_argtuple_error:;
8621 __Pyx_RaiseArgtupleInvalid("parse_region", 0, 0, 6, __pyx_nargs); __PYX_ERR(0, 178, __pyx_L3_error)
8622 __pyx_L6_skip:;
8623 goto __pyx_L4_argument_unpacking_done;
8624 __pyx_L3_error:;
8625 {
8626 Py_ssize_t __pyx_temp;
8627 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
8628 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
8629 }
8630 }
8631 __Pyx_AddTraceback("pysam.libcutils.parse_region", __pyx_clineno, __pyx_lineno, __pyx_filename);
8632 __Pyx_RefNannyFinishContext();
8633 return NULL;
8634 __pyx_L4_argument_unpacking_done:;
8635 __pyx_r = __pyx_pf_5pysam_9libcutils_12parse_region(__pyx_self, __pyx_v_contig, __pyx_v_start, __pyx_v_stop, __pyx_v_region, __pyx_v_reference, __pyx_v_end);
8636
8637 /* "pysam/libcutils.pyx":178
8638 *
8639 *
8640 * cpdef parse_region(contig=None, # <<<<<<<<<<<<<<
8641 * start=None,
8642 * stop=None,
8643 */
8644
8645 /* function exit code */
8646 {
8647 Py_ssize_t __pyx_temp;
8648 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
8649 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
8650 }
8651 }
8652 __Pyx_RefNannyFinishContext();
8653 return __pyx_r;
8654 }
8655
8656 static PyObject *__pyx_pf_5pysam_9libcutils_12parse_region(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_contig, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_region, PyObject *__pyx_v_reference, PyObject *__pyx_v_end) {
8657 PyObject *__pyx_r = NULL;
8658 __Pyx_RefNannyDeclarations
8659 PyObject *__pyx_t_1 = NULL;
8660 struct __pyx_opt_args_5pysam_9libcutils_parse_region __pyx_t_2;
8661 int __pyx_lineno = 0;
8662 const char *__pyx_filename = NULL;
8663 int __pyx_clineno = 0;
8664 __Pyx_RefNannySetupContext("parse_region", 1);
8665 __Pyx_XDECREF(__pyx_r);
8666 __pyx_t_2.__pyx_n = 6;
8667 __pyx_t_2.contig = __pyx_v_contig;
8668 __pyx_t_2.start = __pyx_v_start;
8669 __pyx_t_2.stop = __pyx_v_stop;
8670 __pyx_t_2.region = __pyx_v_region;
8671 __pyx_t_2.reference = __pyx_v_reference;
8672 __pyx_t_2.end = __pyx_v_end;
8673 __pyx_t_1 = __pyx_f_5pysam_9libcutils_parse_region(0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error)
8674 __Pyx_GOTREF(__pyx_t_1);
8675 __pyx_r = __pyx_t_1;
8676 __pyx_t_1 = 0;
8677 goto __pyx_L0;
8678
8679 /* function exit code */
8680 __pyx_L1_error:;
8681 __Pyx_XDECREF(__pyx_t_1);
8682 __Pyx_AddTraceback("pysam.libcutils.parse_region", __pyx_clineno, __pyx_lineno, __pyx_filename);
8683 __pyx_r = NULL;
8684 __pyx_L0:;
8685 __Pyx_XGIVEREF(__pyx_r);
8686 __Pyx_RefNannyFinishContext();
8687 return __pyx_r;
8688 }
8689
8690 /* "pysam/libcutils.pyx":266
8691 *
8692 *
8693 * cdef int libc_whence_from_io(int whence): # <<<<<<<<<<<<<<
8694 * # io.SEEK_SET/_CUR/_END are by definition 0/1/2 but C/POSIX's equivalents
8695 * # have unspecified values. So we must translate, but checking for 0/1/2
8696 */
8697
8698 static int __pyx_f_5pysam_9libcutils_libc_whence_from_io(int __pyx_v_whence) {
8699 int __pyx_r;
8700 int __pyx_t_1;
8701
8702 /* "pysam/libcutils.pyx":270
8703 * # have unspecified values. So we must translate, but checking for 0/1/2
8704 * # rather than io.SEEK_SET/etc suffices.
8705 * if whence == 0: return SEEK_SET # <<<<<<<<<<<<<<
8706 * if whence == 1: return SEEK_CUR
8707 * if whence == 2: return SEEK_END
8708 */
8709 __pyx_t_1 = (__pyx_v_whence == 0);
8710 if (__pyx_t_1) {
8711 __pyx_r = SEEK_SET;
8712 goto __pyx_L0;
8713 }
8714
8715 /* "pysam/libcutils.pyx":271
8716 * # rather than io.SEEK_SET/etc suffices.
8717 * if whence == 0: return SEEK_SET
8718 * if whence == 1: return SEEK_CUR # <<<<<<<<<<<<<<
8719 * if whence == 2: return SEEK_END
8720 * return whence # Otherwise likely invalid, but let HTSlib or OS report it
8721 */
8722 __pyx_t_1 = (__pyx_v_whence == 1);
8723 if (__pyx_t_1) {
8724 __pyx_r = SEEK_CUR;
8725 goto __pyx_L0;
8726 }
8727
8728 /* "pysam/libcutils.pyx":272
8729 * if whence == 0: return SEEK_SET
8730 * if whence == 1: return SEEK_CUR
8731 * if whence == 2: return SEEK_END # <<<<<<<<<<<<<<
8732 * return whence # Otherwise likely invalid, but let HTSlib or OS report it
8733 *
8734 */
8735 __pyx_t_1 = (__pyx_v_whence == 2);
8736 if (__pyx_t_1) {
8737 __pyx_r = SEEK_END;
8738 goto __pyx_L0;
8739 }
8740
8741 /* "pysam/libcutils.pyx":273
8742 * if whence == 1: return SEEK_CUR
8743 * if whence == 2: return SEEK_END
8744 * return whence # Otherwise likely invalid, but let HTSlib or OS report it # <<<<<<<<<<<<<<
8745 *
8746 *
8747 */
8748 __pyx_r = __pyx_v_whence;
8749 goto __pyx_L0;
8750
8751 /* "pysam/libcutils.pyx":266
8752 *
8753 *
8754 * cdef int libc_whence_from_io(int whence): # <<<<<<<<<<<<<<
8755 * # io.SEEK_SET/_CUR/_END are by definition 0/1/2 but C/POSIX's equivalents
8756 * # have unspecified values. So we must translate, but checking for 0/1/2
8757 */
8758
8759 /* function exit code */
8760 __pyx_L0:;
8761 return __pyx_r;
8762 }
8763
8764 /* "pysam/libcutils.pyx":276
8765 *
8766 *
8767 * def _pysam_dispatch(collection, # <<<<<<<<<<<<<<
8768 * method,
8769 * args=None,
8770 */
8771
8772 /* Python wrapper */
8773 static PyObject *__pyx_pw_5pysam_9libcutils_15_pysam_dispatch(PyObject *__pyx_self,
8774 #if CYTHON_METH_FASTCALL
8775 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
8776 #else
8777 PyObject *__pyx_args, PyObject *__pyx_kwds
8778 #endif
8779 ); /*proto*/
8780 PyDoc_STRVAR(__pyx_doc_5pysam_9libcutils_14_pysam_dispatch, "call ``method`` in samtools/bcftools providing arguments in args.\n \n By default, stdout is redirected to a temporary file using the patched\n C sources except for a few commands that have an explicit output option\n (typically: -o). In these commands (such as samtools view), this explicit\n option is used. If *is_usage* is True, then these explicit output options\n will not be used.\n\n Catching of stdout can be turned off by setting *catch_stdout* to\n False.\n ");
8781 static PyMethodDef __pyx_mdef_5pysam_9libcutils_15_pysam_dispatch = {"_pysam_dispatch", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pysam_9libcutils_15_pysam_dispatch, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pysam_9libcutils_14_pysam_dispatch};
8782 static PyObject *__pyx_pw_5pysam_9libcutils_15_pysam_dispatch(PyObject *__pyx_self,
8783 #if CYTHON_METH_FASTCALL
8784 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
8785 #else
8786 PyObject *__pyx_args, PyObject *__pyx_kwds
8787 #endif
8788 ) {
8789 PyObject *__pyx_v_collection = 0;
8790 PyObject *__pyx_v_method = 0;
8791 PyObject *__pyx_v_args = 0;
8792 PyObject *__pyx_v_catch_stdout = 0;
8793 PyObject *__pyx_v_is_usage = 0;
8794 PyObject *__pyx_v_save_stdout = 0;
8795 #if !CYTHON_METH_FASTCALL
8796 CYTHON_UNUSED Py_ssize_t __pyx_nargs;
8797 #endif
8798 CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
8799 PyObject* values[6] = {0,0,0,0,0,0};
8800 int __pyx_lineno = 0;
8801 const char *__pyx_filename = NULL;
8802 int __pyx_clineno = 0;
8803 PyObject *__pyx_r = 0;
8804 __Pyx_RefNannyDeclarations
8805 __Pyx_RefNannySetupContext("_pysam_dispatch (wrapper)", 0);
8806 #if !CYTHON_METH_FASTCALL
8807 #if CYTHON_ASSUME_SAFE_MACROS
8808 __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
8809 #else
8810 __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
8811 #endif
8812 #endif
8813 __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
8814 {
8815 PyObject **__pyx_pyargnames[] = {&__pyx_n_s_collection,&__pyx_n_s_method,&__pyx_n_s_args,&__pyx_n_s_catch_stdout,&__pyx_n_s_is_usage,&__pyx_n_s_save_stdout,0};
8816
8817 /* "pysam/libcutils.pyx":278
8818 * def _pysam_dispatch(collection,
8819 * method,
8820 * args=None, # <<<<<<<<<<<<<<
8821 * catch_stdout=True,
8822 * is_usage=False,
8823 */
8824 values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
8825
8826 /* "pysam/libcutils.pyx":279
8827 * method,
8828 * args=None,
8829 * catch_stdout=True, # <<<<<<<<<<<<<<
8830 * is_usage=False,
8831 * save_stdout=None):
8832 */
8833 values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True)));
8834
8835 /* "pysam/libcutils.pyx":280
8836 * args=None,
8837 * catch_stdout=True,
8838 * is_usage=False, # <<<<<<<<<<<<<<
8839 * save_stdout=None):
8840 * '''call ``method`` in samtools/bcftools providing arguments in args.
8841 */
8842 values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
8843
8844 /* "pysam/libcutils.pyx":281
8845 * catch_stdout=True,
8846 * is_usage=False,
8847 * save_stdout=None): # <<<<<<<<<<<<<<
8848 * '''call ``method`` in samtools/bcftools providing arguments in args.
8849 *
8850 */
8851 values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
8852 if (__pyx_kwds) {
8853 Py_ssize_t kw_args;
8854 switch (__pyx_nargs) {
8855 case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5);
8856 CYTHON_FALLTHROUGH;
8857 case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
8858 CYTHON_FALLTHROUGH;
8859 case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
8860 CYTHON_FALLTHROUGH;
8861 case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
8862 CYTHON_FALLTHROUGH;
8863 case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
8864 CYTHON_FALLTHROUGH;
8865 case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
8866 CYTHON_FALLTHROUGH;
8867 case 0: break;
8868 default: goto __pyx_L5_argtuple_error;
8869 }
8870 kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
8871 switch (__pyx_nargs) {
8872 case 0:
8873 if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_collection)) != 0)) {
8874 (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
8875 kw_args--;
8876 }
8877 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 276, __pyx_L3_error)
8878 else goto __pyx_L5_argtuple_error;
8879 CYTHON_FALLTHROUGH;
8880 case 1:
8881 if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_method)) != 0)) {
8882 (void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
8883 kw_args--;
8884 }
8885 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 276, __pyx_L3_error)
8886 else {
8887 __Pyx_RaiseArgtupleInvalid("_pysam_dispatch", 0, 2, 6, 1); __PYX_ERR(0, 276, __pyx_L3_error)
8888 }
8889 CYTHON_FALLTHROUGH;
8890 case 2:
8891 if (kw_args > 0) {
8892 PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_args);
8893 if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
8894 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 276, __pyx_L3_error)
8895 }
8896 CYTHON_FALLTHROUGH;
8897 case 3:
8898 if (kw_args > 0) {
8899 PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_catch_stdout);
8900 if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
8901 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 276, __pyx_L3_error)
8902 }
8903 CYTHON_FALLTHROUGH;
8904 case 4:
8905 if (kw_args > 0) {
8906 PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_is_usage);
8907 if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
8908 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 276, __pyx_L3_error)
8909 }
8910 CYTHON_FALLTHROUGH;
8911 case 5:
8912 if (kw_args > 0) {
8913 PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_save_stdout);
8914 if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
8915 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 276, __pyx_L3_error)
8916 }
8917 }
8918 if (unlikely(kw_args > 0)) {
8919 const Py_ssize_t kwd_pos_args = __pyx_nargs;
8920 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_pysam_dispatch") < 0)) __PYX_ERR(0, 276, __pyx_L3_error)
8921 }
8922 } else {
8923 switch (__pyx_nargs) {
8924 case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5);
8925 CYTHON_FALLTHROUGH;
8926 case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
8927 CYTHON_FALLTHROUGH;
8928 case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
8929 CYTHON_FALLTHROUGH;
8930 case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
8931 CYTHON_FALLTHROUGH;
8932 case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
8933 values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
8934 break;
8935 default: goto __pyx_L5_argtuple_error;
8936 }
8937 }
8938 __pyx_v_collection = values[0];
8939 __pyx_v_method = values[1];
8940 __pyx_v_args = values[2];
8941 __pyx_v_catch_stdout = values[3];
8942 __pyx_v_is_usage = values[4];
8943 __pyx_v_save_stdout = values[5];
8944 }
8945 goto __pyx_L6_skip;
8946 __pyx_L5_argtuple_error:;
8947 __Pyx_RaiseArgtupleInvalid("_pysam_dispatch", 0, 2, 6, __pyx_nargs); __PYX_ERR(0, 276, __pyx_L3_error)
8948 __pyx_L6_skip:;
8949 goto __pyx_L4_argument_unpacking_done;
8950 __pyx_L3_error:;
8951 {
8952 Py_ssize_t __pyx_temp;
8953 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
8954 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
8955 }
8956 }
8957 __Pyx_AddTraceback("pysam.libcutils._pysam_dispatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
8958 __Pyx_RefNannyFinishContext();
8959 return NULL;
8960 __pyx_L4_argument_unpacking_done:;
8961 __pyx_r = __pyx_pf_5pysam_9libcutils_14_pysam_dispatch(__pyx_self, __pyx_v_collection, __pyx_v_method, __pyx_v_args, __pyx_v_catch_stdout, __pyx_v_is_usage, __pyx_v_save_stdout);
8962
8963 /* "pysam/libcutils.pyx":276
8964 *
8965 *
8966 * def _pysam_dispatch(collection, # <<<<<<<<<<<<<<
8967 * method,
8968 * args=None,
8969 */
8970
8971 /* function exit code */
8972 {
8973 Py_ssize_t __pyx_temp;
8974 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
8975 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
8976 }
8977 }
8978 __Pyx_RefNannyFinishContext();
8979 return __pyx_r;
8980 }
8981
8982 /* "pysam/libcutils.pyx":413
8983 *
8984 * # get error messages
8985 * def _collect(fn): # <<<<<<<<<<<<<<
8986 * out = []
8987 * try:
8988 */
8989
8990 /* Python wrapper */
8991 static PyObject *__pyx_pw_5pysam_9libcutils_15_pysam_dispatch_1_collect(PyObject *__pyx_self,
8992 #if CYTHON_METH_FASTCALL
8993 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
8994 #else
8995 PyObject *__pyx_args, PyObject *__pyx_kwds
8996 #endif
8997 ); /*proto*/
8998 static PyMethodDef __pyx_mdef_5pysam_9libcutils_15_pysam_dispatch_1_collect = {"_collect", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pysam_9libcutils_15_pysam_dispatch_1_collect, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
8999 static PyObject *__pyx_pw_5pysam_9libcutils_15_pysam_dispatch_1_collect(PyObject *__pyx_self,
9000 #if CYTHON_METH_FASTCALL
9001 PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
9002 #else
9003 PyObject *__pyx_args, PyObject *__pyx_kwds
9004 #endif
9005 ) {
9006 PyObject *__pyx_v_fn = 0;
9007 #if !CYTHON_METH_FASTCALL
9008 CYTHON_UNUSED Py_ssize_t __pyx_nargs;
9009 #endif
9010 CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
9011 PyObject* values[1] = {0};
9012 int __pyx_lineno = 0;
9013 const char *__pyx_filename = NULL;
9014 int __pyx_clineno = 0;
9015 PyObject *__pyx_r = 0;
9016 __Pyx_RefNannyDeclarations
9017 __Pyx_RefNannySetupContext("_collect (wrapper)", 0);
9018 #if !CYTHON_METH_FASTCALL
9019 #if CYTHON_ASSUME_SAFE_MACROS
9020 __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
9021 #else
9022 __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
9023 #endif
9024 #endif
9025 __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
9026 {
9027 PyObject **__pyx_pyargnames[] = {&__pyx_n_s_fn,0};
9028 if (__pyx_kwds) {
9029 Py_ssize_t kw_args;
9030 switch (__pyx_nargs) {
9031 case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
9032 CYTHON_FALLTHROUGH;
9033 case 0: break;
9034 default: goto __pyx_L5_argtuple_error;
9035 }
9036 kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
9037 switch (__pyx_nargs) {
9038 case 0:
9039 if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_fn)) != 0)) {
9040 (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
9041 kw_args--;
9042 }
9043 else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 413, __pyx_L3_error)
9044 else goto __pyx_L5_argtuple_error;
9045 }
9046 if (unlikely(kw_args > 0)) {
9047 const Py_ssize_t kwd_pos_args = __pyx_nargs;
9048 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_collect") < 0)) __PYX_ERR(0, 413, __pyx_L3_error)
9049 }
9050 } else if (unlikely(__pyx_nargs != 1)) {
9051 goto __pyx_L5_argtuple_error;
9052 } else {
9053 values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
9054 }
9055 __pyx_v_fn = values[0];
9056 }
9057 goto __pyx_L6_skip;
9058 __pyx_L5_argtuple_error:;
9059 __Pyx_RaiseArgtupleInvalid("_collect", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 413, __pyx_L3_error)
9060 __pyx_L6_skip:;
9061 goto __pyx_L4_argument_unpacking_done;
9062 __pyx_L3_error:;
9063 {
9064 Py_ssize_t __pyx_temp;
9065 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
9066 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
9067 }
9068 }
9069 __Pyx_AddTraceback("pysam.libcutils._pysam_dispatch._collect", __pyx_clineno, __pyx_lineno, __pyx_filename);
9070 __Pyx_RefNannyFinishContext();
9071 return NULL;
9072 __pyx_L4_argument_unpacking_done:;
9073 __pyx_r = __pyx_pf_5pysam_9libcutils_15_pysam_dispatch__collect(__pyx_self, __pyx_v_fn);
9074
9075 /* function exit code */
9076 {
9077 Py_ssize_t __pyx_temp;
9078 for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
9079 __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
9080 }
9081 }
9082 __Pyx_RefNannyFinishContext();
9083 return __pyx_r;
9084 }
9085
9086 static PyObject *__pyx_pf_5pysam_9libcutils_15_pysam_dispatch__collect(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_fn) {
9087 PyObject *__pyx_v_out = NULL;
9088 PyObject *__pyx_v_inf = NULL;
9089 PyObject *__pyx_r = NULL;
9090 __Pyx_RefNannyDeclarations
9091 PyObject *__pyx_t_1 = NULL;
9092 PyObject *__pyx_t_2 = NULL;
9093 PyObject *__pyx_t_3 = NULL;
9094 PyObject *__pyx_t_4 = NULL;
9095 PyObject *__pyx_t_5 = NULL;
9096 PyObject *__pyx_t_6 = NULL;
9097 PyObject *__pyx_t_7 = NULL;
9098 PyObject *__pyx_t_8 = NULL;
9099 unsigned int __pyx_t_9;
9100 PyObject *__pyx_t_10 = NULL;
9101 PyObject *__pyx_t_11 = NULL;
9102 PyObject *__pyx_t_12 = NULL;
9103 PyObject *__pyx_t_13 = NULL;
9104 int __pyx_t_14;
9105 int __pyx_t_15;
9106 int __pyx_t_16;
9107 PyObject *__pyx_t_17 = NULL;
9108 PyObject *__pyx_t_18 = NULL;
9109 PyObject *__pyx_t_19 = NULL;
9110 int __pyx_t_20;
9111 char const *__pyx_t_21;
9112 int __pyx_lineno = 0;
9113 const char *__pyx_filename = NULL;
9114 int __pyx_clineno = 0;
9115 __Pyx_RefNannySetupContext("_collect", 1);
9116
9117 /* "pysam/libcutils.pyx":414
9118 * # get error messages
9119 * def _collect(fn):
9120 * out = [] # <<<<<<<<<<<<<<
9121 * try:
9122 * with open(fn, "r") as inf:
9123 */
9124 __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error)
9125 __Pyx_GOTREF(__pyx_t_1);
9126 __pyx_v_out = __pyx_t_1;
9127 __pyx_t_1 = 0;
9128
9129 /* "pysam/libcutils.pyx":415
9130 * def _collect(fn):
9131 * out = []
9132 * try: # <<<<<<<<<<<<<<
9133 * with open(fn, "r") as inf:
9134 * out = inf.read()
9135 */
9136 /*try:*/ {
9137 {
9138 __Pyx_PyThreadState_declare
9139 __Pyx_PyThreadState_assign
9140 __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
9141 __Pyx_XGOTREF(__pyx_t_2);
9142 __Pyx_XGOTREF(__pyx_t_3);
9143 __Pyx_XGOTREF(__pyx_t_4);
9144 /*try:*/ {
9145
9146 /* "pysam/libcutils.pyx":416
9147 * out = []
9148 * try:
9149 * with open(fn, "r") as inf: # <<<<<<<<<<<<<<
9150 * out = inf.read()
9151 * except UnicodeDecodeError:
9152 */
9153 /*with:*/ {
9154 __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 416, __pyx_L6_error)
9155 __Pyx_GOTREF(__pyx_t_1);
9156 __Pyx_INCREF(__pyx_v_fn);
9157 __Pyx_GIVEREF(__pyx_v_fn);
9158 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_fn)) __PYX_ERR(0, 416, __pyx_L6_error);
9159 __Pyx_INCREF(__pyx_n_u_r);
9160 __Pyx_GIVEREF(__pyx_n_u_r);
9161 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_u_r)) __PYX_ERR(0, 416, __pyx_L6_error);
9162 __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 416, __pyx_L6_error)
9163 __Pyx_GOTREF(__pyx_t_5);
9164 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9165 __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_5, __pyx_n_s_exit); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 416, __pyx_L6_error)
9166 __Pyx_GOTREF(__pyx_t_6);
9167 __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_5, __pyx_n_s_enter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 416, __pyx_L12_error)
9168 __Pyx_GOTREF(__pyx_t_7);
9169 __pyx_t_8 = NULL;
9170 __pyx_t_9 = 0;
9171 #if CYTHON_UNPACK_METHODS
9172 if (likely(PyMethod_Check(__pyx_t_7))) {
9173 __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
9174 if (likely(__pyx_t_8)) {
9175 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
9176 __Pyx_INCREF(__pyx_t_8);
9177 __Pyx_INCREF(function);
9178 __Pyx_DECREF_SET(__pyx_t_7, function);
9179 __pyx_t_9 = 1;
9180 }
9181 }
9182 #endif
9183 {
9184 PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
9185 __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_9, 0+__pyx_t_9);
9186 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
9187 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 416, __pyx_L12_error)
9188 __Pyx_GOTREF(__pyx_t_1);
9189 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9190 }
9191 __pyx_t_7 = __pyx_t_1;
9192 __pyx_t_1 = 0;
9193 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9194 /*try:*/ {
9195 {
9196 __Pyx_PyThreadState_declare
9197 __Pyx_PyThreadState_assign
9198 __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
9199 __Pyx_XGOTREF(__pyx_t_10);
9200 __Pyx_XGOTREF(__pyx_t_11);
9201 __Pyx_XGOTREF(__pyx_t_12);
9202 /*try:*/ {
9203 __pyx_v_inf = __pyx_t_7;
9204 __pyx_t_7 = 0;
9205
9206 /* "pysam/libcutils.pyx":417
9207 * try:
9208 * with open(fn, "r") as inf:
9209 * out = inf.read() # <<<<<<<<<<<<<<
9210 * except UnicodeDecodeError:
9211 * with open(fn, "rb") as inf:
9212 */
9213 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_inf, __pyx_n_s_read); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 417, __pyx_L16_error)
9214 __Pyx_GOTREF(__pyx_t_5);
9215 __pyx_t_1 = NULL;
9216 __pyx_t_9 = 0;
9217 #if CYTHON_UNPACK_METHODS
9218 if (likely(PyMethod_Check(__pyx_t_5))) {
9219 __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
9220 if (likely(__pyx_t_1)) {
9221 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
9222 __Pyx_INCREF(__pyx_t_1);
9223 __Pyx_INCREF(function);
9224 __Pyx_DECREF_SET(__pyx_t_5, function);
9225 __pyx_t_9 = 1;
9226 }
9227 }
9228 #endif
9229 {
9230 PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
9231 __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_9, 0+__pyx_t_9);
9232 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
9233 if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 417, __pyx_L16_error)
9234 __Pyx_GOTREF(__pyx_t_7);
9235 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9236 }
9237 __Pyx_DECREF_SET(__pyx_v_out, __pyx_t_7);
9238 __pyx_t_7 = 0;
9239
9240 /* "pysam/libcutils.pyx":416
9241 * out = []
9242 * try:
9243 * with open(fn, "r") as inf: # <<<<<<<<<<<<<<
9244 * out = inf.read()
9245 * except UnicodeDecodeError:
9246 */
9247 }
9248 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
9249 __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
9250 __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
9251 goto __pyx_L21_try_end;
9252 __pyx_L16_error:;
9253 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
9254 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
9255 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
9256 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
9257 /*except:*/ {
9258 __Pyx_AddTraceback("pysam.libcutils._pysam_dispatch._collect", __pyx_clineno, __pyx_lineno, __pyx_filename);
9259 if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(0, 416, __pyx_L18_except_error)
9260 __Pyx_XGOTREF(__pyx_t_7);
9261 __Pyx_XGOTREF(__pyx_t_5);
9262 __Pyx_XGOTREF(__pyx_t_1);
9263 __pyx_t_8 = PyTuple_Pack(3, __pyx_t_7, __pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 416, __pyx_L18_except_error)
9264 __Pyx_GOTREF(__pyx_t_8);
9265 __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL);
9266 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9267 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
9268 if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 416, __pyx_L18_except_error)
9269 __Pyx_GOTREF(__pyx_t_13);
9270 __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_13);
9271 __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
9272 if (__pyx_t_14 < 0) __PYX_ERR(0, 416, __pyx_L18_except_error)
9273 __pyx_t_15 = (!__pyx_t_14);
9274 if (unlikely(__pyx_t_15)) {
9275 __Pyx_GIVEREF(__pyx_t_7);
9276 __Pyx_GIVEREF(__pyx_t_5);
9277 __Pyx_XGIVEREF(__pyx_t_1);
9278 __Pyx_ErrRestoreWithState(__pyx_t_7, __pyx_t_5, __pyx_t_1);
9279 __pyx_t_7 = 0; __pyx_t_5 = 0; __pyx_t_1 = 0;
9280 __PYX_ERR(0, 416, __pyx_L18_except_error)
9281 }
9282 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
9283 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
9284 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
9285 goto __pyx_L17_exception_handled;
9286 }
9287 __pyx_L18_except_error:;
9288 __Pyx_XGIVEREF(__pyx_t_10);
9289 __Pyx_XGIVEREF(__pyx_t_11);
9290 __Pyx_XGIVEREF(__pyx_t_12);
9291 __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
9292 goto __pyx_L6_error;
9293 __pyx_L17_exception_handled:;
9294 __Pyx_XGIVEREF(__pyx_t_10);
9295 __Pyx_XGIVEREF(__pyx_t_11);
9296 __Pyx_XGIVEREF(__pyx_t_12);
9297 __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
9298 __pyx_L21_try_end:;
9299 }
9300 }
9301 /*finally:*/ {
9302 /*normal exit:*/{
9303 if (__pyx_t_6) {
9304 __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__9, NULL);
9305 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9306 if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 416, __pyx_L6_error)
9307 __Pyx_GOTREF(__pyx_t_12);
9308 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
9309 }
9310 goto __pyx_L15;
9311 }
9312 __pyx_L15:;
9313 }
9314 goto __pyx_L25;
9315 __pyx_L12_error:;
9316 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9317 goto __pyx_L6_error;
9318 __pyx_L25:;
9319 }
9320
9321 /* "pysam/libcutils.pyx":415
9322 * def _collect(fn):
9323 * out = []
9324 * try: # <<<<<<<<<<<<<<
9325 * with open(fn, "r") as inf:
9326 * out = inf.read()
9327 */
9328 }
9329 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
9330 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
9331 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
9332 goto __pyx_L11_try_end;
9333 __pyx_L6_error:;
9334 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
9335 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
9336 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
9337 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
9338
9339 /* "pysam/libcutils.pyx":418
9340 * with open(fn, "r") as inf:
9341 * out = inf.read()
9342 * except UnicodeDecodeError: # <<<<<<<<<<<<<<
9343 * with open(fn, "rb") as inf:
9344 * # read binary output
9345 */
9346 __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
9347 if (__pyx_t_16) {
9348 __Pyx_AddTraceback("pysam.libcutils._pysam_dispatch._collect", __pyx_clineno, __pyx_lineno, __pyx_filename);
9349 if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_7) < 0) __PYX_ERR(0, 418, __pyx_L8_except_error)
9350 __Pyx_XGOTREF(__pyx_t_1);
9351 __Pyx_XGOTREF(__pyx_t_5);
9352 __Pyx_XGOTREF(__pyx_t_7);
9353
9354 /* "pysam/libcutils.pyx":419
9355 * out = inf.read()
9356 * except UnicodeDecodeError:
9357 * with open(fn, "rb") as inf: # <<<<<<<<<<<<<<
9358 * # read binary output
9359 * out = inf.read()
9360 */
9361 /*with:*/ {
9362 __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 419, __pyx_L8_except_error)
9363 __Pyx_GOTREF(__pyx_t_8);
9364 __Pyx_INCREF(__pyx_v_fn);
9365 __Pyx_GIVEREF(__pyx_v_fn);
9366 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_fn)) __PYX_ERR(0, 419, __pyx_L8_except_error);
9367 __Pyx_INCREF(__pyx_n_u_rb);
9368 __Pyx_GIVEREF(__pyx_n_u_rb);
9369 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_n_u_rb)) __PYX_ERR(0, 419, __pyx_L8_except_error);
9370 __pyx_t_17 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_8, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 419, __pyx_L8_except_error)
9371 __Pyx_GOTREF(__pyx_t_17);
9372 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
9373 __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_17, __pyx_n_s_exit); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 419, __pyx_L8_except_error)
9374 __Pyx_GOTREF(__pyx_t_6);
9375 __pyx_t_18 = __Pyx_PyObject_LookupSpecial(__pyx_t_17, __pyx_n_s_enter); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 419, __pyx_L28_error)
9376 __Pyx_GOTREF(__pyx_t_18);
9377 __pyx_t_19 = NULL;
9378 __pyx_t_9 = 0;
9379 #if CYTHON_UNPACK_METHODS
9380 if (likely(PyMethod_Check(__pyx_t_18))) {
9381 __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_18);
9382 if (likely(__pyx_t_19)) {
9383 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18);
9384 __Pyx_INCREF(__pyx_t_19);
9385 __Pyx_INCREF(function);
9386 __Pyx_DECREF_SET(__pyx_t_18, function);
9387 __pyx_t_9 = 1;
9388 }
9389 }
9390 #endif
9391 {
9392 PyObject *__pyx_callargs[2] = {__pyx_t_19, NULL};
9393 __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_18, __pyx_callargs+1-__pyx_t_9, 0+__pyx_t_9);
9394 __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
9395 if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 419, __pyx_L28_error)
9396 __Pyx_GOTREF(__pyx_t_8);
9397 __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
9398 }
9399 __pyx_t_18 = __pyx_t_8;
9400 __pyx_t_8 = 0;
9401 __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
9402 /*try:*/ {
9403 {
9404 __Pyx_PyThreadState_declare
9405 __Pyx_PyThreadState_assign
9406 __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
9407 __Pyx_XGOTREF(__pyx_t_12);
9408 __Pyx_XGOTREF(__pyx_t_11);
9409 __Pyx_XGOTREF(__pyx_t_10);
9410 /*try:*/ {
9411 __Pyx_XDECREF_SET(__pyx_v_inf, __pyx_t_18);
9412 __pyx_t_18 = 0;
9413
9414 /* "pysam/libcutils.pyx":421
9415 * with open(fn, "rb") as inf:
9416 * # read binary output
9417 * out = inf.read() # <<<<<<<<<<<<<<
9418 * finally:
9419 * os.remove(fn)
9420 */
9421 __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_v_inf, __pyx_n_s_read); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 421, __pyx_L34_error)
9422 __Pyx_GOTREF(__pyx_t_17);
9423 __pyx_t_8 = NULL;
9424 __pyx_t_9 = 0;
9425 #if CYTHON_UNPACK_METHODS
9426 if (likely(PyMethod_Check(__pyx_t_17))) {
9427 __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_17);
9428 if (likely(__pyx_t_8)) {
9429 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
9430 __Pyx_INCREF(__pyx_t_8);
9431 __Pyx_INCREF(function);
9432 __Pyx_DECREF_SET(__pyx_t_17, function);
9433 __pyx_t_9 = 1;
9434 }
9435 }
9436 #endif
9437 {
9438 PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
9439 __pyx_t_18 = __Pyx_PyObject_FastCall(__pyx_t_17, __pyx_callargs+1-__pyx_t_9, 0+__pyx_t_9);
9440 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
9441 if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 421, __pyx_L34_error)
9442 __Pyx_GOTREF(__pyx_t_18);
9443 __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
9444 }
9445 __Pyx_DECREF_SET(__pyx_v_out, __pyx_t_18);
9446 __pyx_t_18 = 0;
9447
9448 /* "pysam/libcutils.pyx":419
9449 * out = inf.read()
9450 * except UnicodeDecodeError:
9451 * with open(fn, "rb") as inf: # <<<<<<<<<<<<<<
9452 * # read binary output
9453 * out = inf.read()
9454 */
9455 }
9456 __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
9457 __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
9458 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
9459 goto __pyx_L41_try_end;
9460 __pyx_L34_error:;
9461 __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
9462 __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
9463 __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
9464 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
9465 /*except:*/ {
9466 __Pyx_AddTraceback("pysam.libcutils._pysam_dispatch._collect", __pyx_clineno, __pyx_lineno, __pyx_filename);
9467 if (__Pyx_GetException(&__pyx_t_18, &__pyx_t_17, &__pyx_t_8) < 0) __PYX_ERR(0, 419, __pyx_L36_except_error)
9468 __Pyx_XGOTREF(__pyx_t_18);
9469 __Pyx_XGOTREF(__pyx_t_17);
9470 __Pyx_XGOTREF(__pyx_t_8);
9471 __pyx_t_19 = PyTuple_Pack(3, __pyx_t_18, __pyx_t_17, __pyx_t_8); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 419, __pyx_L36_except_error)
9472 __Pyx_GOTREF(__pyx_t_19);
9473 __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_19, NULL);
9474 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9475 __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
9476 if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 419, __pyx_L36_except_error)
9477 __Pyx_GOTREF(__pyx_t_13);
9478 __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_13);
9479 __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
9480 if (__pyx_t_15 < 0) __PYX_ERR(0, 419, __pyx_L36_except_error)
9481 __pyx_t_14 = (!__pyx_t_15);
9482 if (unlikely(__pyx_t_14)) {
9483 __Pyx_GIVEREF(__pyx_t_18);
9484 __Pyx_GIVEREF(__pyx_t_17);
9485 __Pyx_XGIVEREF(__pyx_t_8);
9486 __Pyx_ErrRestoreWithState(__pyx_t_18, __pyx_t_17, __pyx_t_8);
9487 __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_8 = 0;
9488 __PYX_ERR(0, 419, __pyx_L36_except_error)
9489 }
9490 __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
9491 __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
9492 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
9493 goto __pyx_L35_exception_handled;
9494 }
9495 __pyx_L36_except_error:;
9496 __Pyx_XGIVEREF(__pyx_t_12);
9497 __Pyx_XGIVEREF(__pyx_t_11);
9498 __Pyx_XGIVEREF(__pyx_t_10);
9499 __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_10);
9500 goto __pyx_L8_except_error;
9501 __pyx_L35_exception_handled:;
9502 __Pyx_XGIVEREF(__pyx_t_12);
9503 __Pyx_XGIVEREF(__pyx_t_11);
9504 __Pyx_XGIVEREF(__pyx_t_10);
9505 __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_10);
9506 __pyx_L41_try_end:;
9507 }
9508 }
9509 /*finally:*/ {
9510 /*normal exit:*/{
9511 if (__pyx_t_6) {
9512 __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__9, NULL);
9513 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9514 if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 419, __pyx_L8_except_error)
9515 __Pyx_GOTREF(__pyx_t_10);
9516 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
9517 }
9518 goto __pyx_L33;
9519 }
9520 __pyx_L33:;
9521 }
9522 goto __pyx_L45;
9523 __pyx_L28_error:;
9524 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9525 goto __pyx_L8_except_error;
9526 __pyx_L45:;
9527 }
9528 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
9529 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
9530 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
9531 goto __pyx_L7_exception_handled;
9532 }
9533 goto __pyx_L8_except_error;
9534
9535 /* "pysam/libcutils.pyx":415
9536 * def _collect(fn):
9537 * out = []
9538 * try: # <<<<<<<<<<<<<<
9539 * with open(fn, "r") as inf:
9540 * out = inf.read()
9541 */
9542 __pyx_L8_except_error:;
9543 __Pyx_XGIVEREF(__pyx_t_2);
9544 __Pyx_XGIVEREF(__pyx_t_3);
9545 __Pyx_XGIVEREF(__pyx_t_4);
9546 __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
9547 goto __pyx_L4_error;
9548 __pyx_L7_exception_handled:;
9549 __Pyx_XGIVEREF(__pyx_t_2);
9550 __Pyx_XGIVEREF(__pyx_t_3);
9551 __Pyx_XGIVEREF(__pyx_t_4);
9552 __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
9553 __pyx_L11_try_end:;
9554 }
9555 }
9556
9557 /* "pysam/libcutils.pyx":423
9558 * out = inf.read()
9559 * finally:
9560 * os.remove(fn) # <<<<<<<<<<<<<<
9561 * return out
9562 *
9563 */
9564 /*finally:*/ {
9565 /*normal exit:*/{
9566 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 423, __pyx_L1_error)
9567 __Pyx_GOTREF(__pyx_t_5);
9568 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_remove); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 423, __pyx_L1_error)
9569 __Pyx_GOTREF(__pyx_t_1);
9570 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9571 __pyx_t_5 = NULL;
9572 __pyx_t_9 = 0;
9573 #if CYTHON_UNPACK_METHODS
9574 if (unlikely(PyMethod_Check(__pyx_t_1))) {
9575 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
9576 if (likely(__pyx_t_5)) {
9577 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
9578 __Pyx_INCREF(__pyx_t_5);
9579 __Pyx_INCREF(function);
9580 __Pyx_DECREF_SET(__pyx_t_1, function);
9581 __pyx_t_9 = 1;
9582 }
9583 }
9584 #endif
9585 {
9586 PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_fn};
9587 __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9);
9588 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
9589 if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 423, __pyx_L1_error)
9590 __Pyx_GOTREF(__pyx_t_7);
9591 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9592 }
9593 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9594 goto __pyx_L5;
9595 }
9596 __pyx_L4_error:;
9597 /*exception exit:*/{
9598 __Pyx_PyThreadState_declare
9599 __Pyx_PyThreadState_assign
9600 __pyx_t_4 = 0; __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_6 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
9601 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
9602 __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
9603 __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
9604 __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
9605 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
9606 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
9607 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
9608 if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_6, &__pyx_t_10, &__pyx_t_11);
9609 if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_2) < 0)) __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_3, &__pyx_t_2);
9610 __Pyx_XGOTREF(__pyx_t_4);
9611 __Pyx_XGOTREF(__pyx_t_3);
9612 __Pyx_XGOTREF(__pyx_t_2);
9613 __Pyx_XGOTREF(__pyx_t_6);
9614 __Pyx_XGOTREF(__pyx_t_10);
9615 __Pyx_XGOTREF(__pyx_t_11);
9616 __pyx_t_16 = __pyx_lineno; __pyx_t_20 = __pyx_clineno; __pyx_t_21 = __pyx_filename;
9617 {
9618 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 423, __pyx_L47_error)
9619 __Pyx_GOTREF(__pyx_t_1);
9620 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_remove); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 423, __pyx_L47_error)
9621 __Pyx_GOTREF(__pyx_t_5);
9622 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9623 __pyx_t_1 = NULL;
9624 __pyx_t_9 = 0;
9625 #if CYTHON_UNPACK_METHODS
9626 if (unlikely(PyMethod_Check(__pyx_t_5))) {
9627 __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
9628 if (likely(__pyx_t_1)) {
9629 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
9630 __Pyx_INCREF(__pyx_t_1);
9631 __Pyx_INCREF(function);
9632 __Pyx_DECREF_SET(__pyx_t_5, function);
9633 __pyx_t_9 = 1;
9634 }
9635 }
9636 #endif
9637 {
9638 PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_fn};
9639 __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9);
9640 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
9641 if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 423, __pyx_L47_error)
9642 __Pyx_GOTREF(__pyx_t_7);
9643 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9644 }
9645 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9646 }
9647 if (PY_MAJOR_VERSION >= 3) {
9648 __Pyx_XGIVEREF(__pyx_t_6);
9649 __Pyx_XGIVEREF(__pyx_t_10);
9650 __Pyx_XGIVEREF(__pyx_t_11);
9651 __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_10, __pyx_t_11);
9652 }
9653 __Pyx_XGIVEREF(__pyx_t_4);
9654 __Pyx_XGIVEREF(__pyx_t_3);
9655 __Pyx_XGIVEREF(__pyx_t_2);
9656 __Pyx_ErrRestore(__pyx_t_4, __pyx_t_3, __pyx_t_2);
9657 __pyx_t_4 = 0; __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_6 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
9658 __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_20; __pyx_filename = __pyx_t_21;
9659 goto __pyx_L1_error;
9660 __pyx_L47_error:;
9661 if (PY_MAJOR_VERSION >= 3) {
9662 __Pyx_XGIVEREF(__pyx_t_6);
9663 __Pyx_XGIVEREF(__pyx_t_10);
9664 __Pyx_XGIVEREF(__pyx_t_11);
9665 __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_10, __pyx_t_11);
9666 }
9667 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
9668 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
9669 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
9670 __pyx_t_6 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0;
9671 goto __pyx_L1_error;
9672 }
9673 __pyx_L5:;
9674 }
9675
9676 /* "pysam/libcutils.pyx":424
9677 * finally:
9678 * os.remove(fn)
9679 * return out # <<<<<<<<<<<<<<
9680 *
9681 * out_stderr = _collect(stderr_f)
9682 */
9683 __Pyx_XDECREF(__pyx_r);
9684 __Pyx_INCREF(__pyx_v_out);
9685 __pyx_r = __pyx_v_out;
9686 goto __pyx_L0;
9687
9688 /* "pysam/libcutils.pyx":413
9689 *
9690 * # get error messages
9691 * def _collect(fn): # <<<<<<<<<<<<<<
9692 * out = []
9693 * try:
9694 */
9695
9696 /* function exit code */
9697 __pyx_L1_error:;
9698 __Pyx_XDECREF(__pyx_t_1);
9699 __Pyx_XDECREF(__pyx_t_5);
9700 __Pyx_XDECREF(__pyx_t_7);
9701 __Pyx_XDECREF(__pyx_t_8);
9702 __Pyx_XDECREF(__pyx_t_17);
9703 __Pyx_XDECREF(__pyx_t_18);
9704 __Pyx_XDECREF(__pyx_t_19);
9705 __Pyx_AddTraceback("pysam.libcutils._pysam_dispatch._collect", __pyx_clineno, __pyx_lineno, __pyx_filename);
9706 __pyx_r = NULL;
9707 __pyx_L0:;
9708 __Pyx_XDECREF(__pyx_v_out);
9709 __Pyx_XDECREF(__pyx_v_inf);
9710 __Pyx_XGIVEREF(__pyx_r);
9711 __Pyx_RefNannyFinishContext();
9712 return __pyx_r;
9713 }
9714
9715 /* "pysam/libcutils.pyx":276
9716 *
9717 *
9718 * def _pysam_dispatch(collection, # <<<<<<<<<<<<<<
9719 * method,
9720 * args=None,
9721 */
9722
9723 static PyObject *__pyx_pf_5pysam_9libcutils_14_pysam_dispatch(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_collection, PyObject *__pyx_v_method, PyObject *__pyx_v_args, PyObject *__pyx_v_catch_stdout, PyObject *__pyx_v_is_usage, PyObject *__pyx_v_save_stdout) {
9724 PyObject *__pyx_v_ARGUMENTS = NULL;
9725 int __pyx_v_skip_next;
9726 PyObject *__pyx_v_arg = NULL;
9727 PyObject *__pyx_v_stderr_h = NULL;
9728 PyObject *__pyx_v_stderr_f = NULL;
9729 PyObject *__pyx_v_stdout_f = NULL;
9730 PyObject *__pyx_v_stdout_h = NULL;
9731 PyObject *__pyx_v_MAP_STDOUT_OPTIONS = NULL;
9732 PyObject *__pyx_v_stdout_option = NULL;
9733 char **__pyx_v_cargs;
9734 int __pyx_v_i;
9735 int __pyx_v_n;
9736 int __pyx_v_retval;
9737 int __pyx_v_l;
9738 int __pyx_v_extra_args;
9739 PyObject *__pyx_v__collect = 0;
9740 PyObject *__pyx_v_out_stderr = NULL;
9741 PyObject *__pyx_v_out_stdout = NULL;
9742 PyObject *__pyx_8genexpr2__pyx_v_a = NULL;
9743 PyObject *__pyx_r = NULL;
9744 __Pyx_RefNannyDeclarations
9745 int __pyx_t_1;
9746 int __pyx_t_2;
9747 PyObject *__pyx_t_3 = NULL;
9748 Py_ssize_t __pyx_t_4;
9749 PyObject *(*__pyx_t_5)(PyObject *);
9750 PyObject *__pyx_t_6 = NULL;
9751 PyObject *__pyx_t_7 = NULL;
9752 PyObject *__pyx_t_8 = NULL;
9753 unsigned int __pyx_t_9;
9754 PyObject *(*__pyx_t_10)(PyObject *);
9755 char const *__pyx_t_11;
9756 char const *__pyx_t_12;
9757 char const *__pyx_t_13;
9758 int __pyx_t_14;
9759 PyObject *__pyx_t_15 = NULL;
9760 PyObject *__pyx_t_16 = NULL;
9761 char *__pyx_t_17;
9762 int __pyx_t_18;
9763 char const *__pyx_t_19;
9764 int __pyx_lineno = 0;
9765 const char *__pyx_filename = NULL;
9766 int __pyx_clineno = 0;
9767 __Pyx_RefNannySetupContext("_pysam_dispatch", 0);
9768 __Pyx_INCREF(__pyx_v_collection);
9769 __Pyx_INCREF(__pyx_v_method);
9770 __Pyx_INCREF(__pyx_v_args);
9771
9772 /* "pysam/libcutils.pyx":294
9773 * '''
9774 *
9775 * if method == "index" and args: # <<<<<<<<<<<<<<
9776 * # We make sure that at least the first specified input file exists,
9777 * # and if it doesn't we raise an IOError.
9778 */
9779 __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_method, __pyx_n_u_index, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 294, __pyx_L1_error)
9780 if (__pyx_t_2) {
9781 } else {
9782 __pyx_t_1 = __pyx_t_2;
9783 goto __pyx_L4_bool_binop_done;
9784 }
9785 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_args); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 294, __pyx_L1_error)
9786 __pyx_t_1 = __pyx_t_2;
9787 __pyx_L4_bool_binop_done:;
9788 if (__pyx_t_1) {
9789
9790 /* "pysam/libcutils.pyx":297
9791 * # We make sure that at least the first specified input file exists,
9792 * # and if it doesn't we raise an IOError.
9793 * ARGUMENTS = ['-m', '--min-shift', '-o', '--output', '--output-file', '-@', '--threads'] # <<<<<<<<<<<<<<
9794 * skip_next = False
9795 * for arg in args:
9796 */
9797 __pyx_t_3 = PyList_New(7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 297, __pyx_L1_error)
9798 __Pyx_GOTREF(__pyx_t_3);
9799 __Pyx_INCREF(__pyx_kp_u_m);
9800 __Pyx_GIVEREF(__pyx_kp_u_m);
9801 if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_m)) __PYX_ERR(0, 297, __pyx_L1_error);
9802 __Pyx_INCREF(__pyx_kp_u_min_shift);
9803 __Pyx_GIVEREF(__pyx_kp_u_min_shift);
9804 if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_kp_u_min_shift)) __PYX_ERR(0, 297, __pyx_L1_error);
9805 __Pyx_INCREF(__pyx_kp_u_o);
9806 __Pyx_GIVEREF(__pyx_kp_u_o);
9807 if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_o)) __PYX_ERR(0, 297, __pyx_L1_error);
9808 __Pyx_INCREF(__pyx_kp_u_output);
9809 __Pyx_GIVEREF(__pyx_kp_u_output);
9810 if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 3, __pyx_kp_u_output)) __PYX_ERR(0, 297, __pyx_L1_error);
9811 __Pyx_INCREF(__pyx_kp_u_output_file);
9812 __Pyx_GIVEREF(__pyx_kp_u_output_file);
9813 if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 4, __pyx_kp_u_output_file)) __PYX_ERR(0, 297, __pyx_L1_error);
9814 __Pyx_INCREF(__pyx_kp_u__10);
9815 __Pyx_GIVEREF(__pyx_kp_u__10);
9816 if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 5, __pyx_kp_u__10)) __PYX_ERR(0, 297, __pyx_L1_error);
9817 __Pyx_INCREF(__pyx_kp_u_threads);
9818 __Pyx_GIVEREF(__pyx_kp_u_threads);
9819 if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 6, __pyx_kp_u_threads)) __PYX_ERR(0, 297, __pyx_L1_error);
9820 __pyx_v_ARGUMENTS = ((PyObject*)__pyx_t_3);
9821 __pyx_t_3 = 0;
9822
9823 /* "pysam/libcutils.pyx":298
9824 * # and if it doesn't we raise an IOError.
9825 * ARGUMENTS = ['-m', '--min-shift', '-o', '--output', '--output-file', '-@', '--threads']
9826 * skip_next = False # <<<<<<<<<<<<<<
9827 * for arg in args:
9828 * if skip_next:
9829 */
9830 __pyx_v_skip_next = 0;
9831
9832 /* "pysam/libcutils.pyx":299
9833 * ARGUMENTS = ['-m', '--min-shift', '-o', '--output', '--output-file', '-@', '--threads']
9834 * skip_next = False
9835 * for arg in args: # <<<<<<<<<<<<<<
9836 * if skip_next:
9837 * skip_next = False
9838 */
9839 if (likely(PyList_CheckExact(__pyx_v_args)) || PyTuple_CheckExact(__pyx_v_args)) {
9840 __pyx_t_3 = __pyx_v_args; __Pyx_INCREF(__pyx_t_3);
9841 __pyx_t_4 = 0;
9842 __pyx_t_5 = NULL;
9843 } else {
9844 __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 299, __pyx_L1_error)
9845 __Pyx_GOTREF(__pyx_t_3);
9846 __pyx_t_5 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 299, __pyx_L1_error)
9847 }
9848 for (;;) {
9849 if (likely(!__pyx_t_5)) {
9850 if (likely(PyList_CheckExact(__pyx_t_3))) {
9851 {
9852 Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3);
9853 #if !CYTHON_ASSUME_SAFE_MACROS
9854 if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 299, __pyx_L1_error)
9855 #endif
9856 if (__pyx_t_4 >= __pyx_temp) break;
9857 }
9858 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9859 __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 299, __pyx_L1_error)
9860 #else
9861 __pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 299, __pyx_L1_error)
9862 __Pyx_GOTREF(__pyx_t_6);
9863 #endif
9864 } else {
9865 {
9866 Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3);
9867 #if !CYTHON_ASSUME_SAFE_MACROS
9868 if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 299, __pyx_L1_error)
9869 #endif
9870 if (__pyx_t_4 >= __pyx_temp) break;
9871 }
9872 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9873 __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 299, __pyx_L1_error)
9874 #else
9875 __pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 299, __pyx_L1_error)
9876 __Pyx_GOTREF(__pyx_t_6);
9877 #endif
9878 }
9879 } else {
9880 __pyx_t_6 = __pyx_t_5(__pyx_t_3);
9881 if (unlikely(!__pyx_t_6)) {
9882 PyObject* exc_type = PyErr_Occurred();
9883 if (exc_type) {
9884 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
9885 else __PYX_ERR(0, 299, __pyx_L1_error)
9886 }
9887 break;
9888 }
9889 __Pyx_GOTREF(__pyx_t_6);
9890 }
9891 __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_6);
9892 __pyx_t_6 = 0;
9893
9894 /* "pysam/libcutils.pyx":300
9895 * skip_next = False
9896 * for arg in args:
9897 * if skip_next: # <<<<<<<<<<<<<<
9898 * skip_next = False
9899 * continue
9900 */
9901 if (__pyx_v_skip_next) {
9902
9903 /* "pysam/libcutils.pyx":301
9904 * for arg in args:
9905 * if skip_next:
9906 * skip_next = False # <<<<<<<<<<<<<<
9907 * continue
9908 * if arg.startswith('-'):
9909 */
9910 __pyx_v_skip_next = 0;
9911
9912 /* "pysam/libcutils.pyx":302
9913 * if skip_next:
9914 * skip_next = False
9915 * continue # <<<<<<<<<<<<<<
9916 * if arg.startswith('-'):
9917 * # Skip next argument for e.g. '--min-shift' '12' or '-m' '12' but not '-m12'
9918 */
9919 goto __pyx_L6_continue;
9920
9921 /* "pysam/libcutils.pyx":300
9922 * skip_next = False
9923 * for arg in args:
9924 * if skip_next: # <<<<<<<<<<<<<<
9925 * skip_next = False
9926 * continue
9927 */
9928 }
9929
9930 /* "pysam/libcutils.pyx":303
9931 * skip_next = False
9932 * continue
9933 * if arg.startswith('-'): # <<<<<<<<<<<<<<
9934 * # Skip next argument for e.g. '--min-shift' '12' or '-m' '12' but not '-m12'
9935 * if arg in ARGUMENTS:
9936 */
9937 __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_startswith); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 303, __pyx_L1_error)
9938 __Pyx_GOTREF(__pyx_t_7);
9939 __pyx_t_8 = NULL;
9940 __pyx_t_9 = 0;
9941 #if CYTHON_UNPACK_METHODS
9942 if (likely(PyMethod_Check(__pyx_t_7))) {
9943 __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
9944 if (likely(__pyx_t_8)) {
9945 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
9946 __Pyx_INCREF(__pyx_t_8);
9947 __Pyx_INCREF(function);
9948 __Pyx_DECREF_SET(__pyx_t_7, function);
9949 __pyx_t_9 = 1;
9950 }
9951 }
9952 #endif
9953 {
9954 PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_kp_u__8};
9955 __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9);
9956 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
9957 if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 303, __pyx_L1_error)
9958 __Pyx_GOTREF(__pyx_t_6);
9959 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9960 }
9961 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 303, __pyx_L1_error)
9962 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9963 if (__pyx_t_1) {
9964
9965 /* "pysam/libcutils.pyx":305
9966 * if arg.startswith('-'):
9967 * # Skip next argument for e.g. '--min-shift' '12' or '-m' '12' but not '-m12'
9968 * if arg in ARGUMENTS: # <<<<<<<<<<<<<<
9969 * skip_next = True
9970 * continue
9971 */
9972 __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_arg, __pyx_v_ARGUMENTS, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 305, __pyx_L1_error)
9973 if (__pyx_t_1) {
9974
9975 /* "pysam/libcutils.pyx":306
9976 * # Skip next argument for e.g. '--min-shift' '12' or '-m' '12' but not '-m12'
9977 * if arg in ARGUMENTS:
9978 * skip_next = True # <<<<<<<<<<<<<<
9979 * continue
9980 * if not os.path.exists(arg):
9981 */
9982 __pyx_v_skip_next = 1;
9983
9984 /* "pysam/libcutils.pyx":305
9985 * if arg.startswith('-'):
9986 * # Skip next argument for e.g. '--min-shift' '12' or '-m' '12' but not '-m12'
9987 * if arg in ARGUMENTS: # <<<<<<<<<<<<<<
9988 * skip_next = True
9989 * continue
9990 */
9991 }
9992
9993 /* "pysam/libcutils.pyx":307
9994 * if arg in ARGUMENTS:
9995 * skip_next = True
9996 * continue # <<<<<<<<<<<<<<
9997 * if not os.path.exists(arg):
9998 * raise IOError("No such file or directory: '%s'" % arg)
9999 */
10000 goto __pyx_L6_continue;
10001
10002 /* "pysam/libcutils.pyx":303
10003 * skip_next = False
10004 * continue
10005 * if arg.startswith('-'): # <<<<<<<<<<<<<<
10006 * # Skip next argument for e.g. '--min-shift' '12' or '-m' '12' but not '-m12'
10007 * if arg in ARGUMENTS:
10008 */
10009 }
10010
10011 /* "pysam/libcutils.pyx":308
10012 * skip_next = True
10013 * continue
10014 * if not os.path.exists(arg): # <<<<<<<<<<<<<<
10015 * raise IOError("No such file or directory: '%s'" % arg)
10016 * else:
10017 */
10018 __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 308, __pyx_L1_error)
10019 __Pyx_GOTREF(__pyx_t_7);
10020 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_path); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 308, __pyx_L1_error)
10021 __Pyx_GOTREF(__pyx_t_8);
10022 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
10023 __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_exists); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 308, __pyx_L1_error)
10024 __Pyx_GOTREF(__pyx_t_7);
10025 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
10026 __pyx_t_8 = NULL;
10027 __pyx_t_9 = 0;
10028 #if CYTHON_UNPACK_METHODS
10029 if (likely(PyMethod_Check(__pyx_t_7))) {
10030 __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
10031 if (likely(__pyx_t_8)) {
10032 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
10033 __Pyx_INCREF(__pyx_t_8);
10034 __Pyx_INCREF(function);
10035 __Pyx_DECREF_SET(__pyx_t_7, function);
10036 __pyx_t_9 = 1;
10037 }
10038 }
10039 #endif
10040 {
10041 PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_v_arg};
10042 __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9);
10043 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
10044 if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 308, __pyx_L1_error)
10045 __Pyx_GOTREF(__pyx_t_6);
10046 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
10047 }
10048 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 308, __pyx_L1_error)
10049 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
10050 __pyx_t_2 = (!__pyx_t_1);
10051 if (unlikely(__pyx_t_2)) {
10052
10053 /* "pysam/libcutils.pyx":309
10054 * continue
10055 * if not os.path.exists(arg):
10056 * raise IOError("No such file or directory: '%s'" % arg) # <<<<<<<<<<<<<<
10057 * else:
10058 * break
10059 */
10060 __pyx_t_6 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_No_such_file_or_directory_s, __pyx_v_arg); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 309, __pyx_L1_error)
10061 __Pyx_GOTREF(__pyx_t_6);
10062 __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IOError, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 309, __pyx_L1_error)
10063 __Pyx_GOTREF(__pyx_t_7);
10064 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
10065 __Pyx_Raise(__pyx_t_7, 0, 0, 0);
10066 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
10067 __PYX_ERR(0, 309, __pyx_L1_error)
10068
10069 /* "pysam/libcutils.pyx":308
10070 * skip_next = True
10071 * continue
10072 * if not os.path.exists(arg): # <<<<<<<<<<<<<<
10073 * raise IOError("No such file or directory: '%s'" % arg)
10074 * else:
10075 */
10076 }
10077
10078 /* "pysam/libcutils.pyx":311
10079 * raise IOError("No such file or directory: '%s'" % arg)
10080 * else:
10081 * break # <<<<<<<<<<<<<<
10082 *
10083 * if args is None:
10084 */
10085 /*else*/ {
10086 goto __pyx_L7_break;
10087 }
10088
10089 /* "pysam/libcutils.pyx":299
10090 * ARGUMENTS = ['-m', '--min-shift', '-o', '--output', '--output-file', '-@', '--threads']
10091 * skip_next = False
10092 * for arg in args: # <<<<<<<<<<<<<<
10093 * if skip_next:
10094 * skip_next = False
10095 */
10096 __pyx_L6_continue:;
10097 }
10098 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10099 goto __pyx_L12_for_end;
10100 __pyx_L7_break:;
10101 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10102 goto __pyx_L12_for_end;
10103 __pyx_L12_for_end:;
10104
10105 /* "pysam/libcutils.pyx":294
10106 * '''
10107 *
10108 * if method == "index" and args: # <<<<<<<<<<<<<<
10109 * # We make sure that at least the first specified input file exists,
10110 * # and if it doesn't we raise an IOError.
10111 */
10112 }
10113
10114 /* "pysam/libcutils.pyx":313
10115 * break
10116 *
10117 * if args is None: # <<<<<<<<<<<<<<
10118 * args = []
10119 * else:
10120 */
10121 __pyx_t_2 = (__pyx_v_args == Py_None);
10122 if (__pyx_t_2) {
10123
10124 /* "pysam/libcutils.pyx":314
10125 *
10126 * if args is None:
10127 * args = [] # <<<<<<<<<<<<<<
10128 * else:
10129 * args = list(args)
10130 */
10131 __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 314, __pyx_L1_error)
10132 __Pyx_GOTREF(__pyx_t_3);
10133 __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_3);
10134 __pyx_t_3 = 0;
10135
10136 /* "pysam/libcutils.pyx":313
10137 * break
10138 *
10139 * if args is None: # <<<<<<<<<<<<<<
10140 * args = []
10141 * else:
10142 */
10143 goto __pyx_L13;
10144 }
10145
10146 /* "pysam/libcutils.pyx":316
10147 * args = []
10148 * else:
10149 * args = list(args) # <<<<<<<<<<<<<<
10150 *
10151 * # redirect stderr to file
10152 */
10153 /*else*/ {
10154 __pyx_t_3 = PySequence_List(__pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error)
10155 __Pyx_GOTREF(__pyx_t_3);
10156 __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_3);
10157 __pyx_t_3 = 0;
10158 }
10159 __pyx_L13:;
10160
10161 /* "pysam/libcutils.pyx":319
10162 *
10163 * # redirect stderr to file
10164 * stderr_h, stderr_f = tempfile.mkstemp() # <<<<<<<<<<<<<<
10165 *
10166 * # redirect stdout to file
10167 */
10168 __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_tempfile); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 319, __pyx_L1_error)
10169 __Pyx_GOTREF(__pyx_t_7);
10170 __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_mkstemp); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 319, __pyx_L1_error)
10171 __Pyx_GOTREF(__pyx_t_6);
10172 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
10173 __pyx_t_7 = NULL;
10174 __pyx_t_9 = 0;
10175 #if CYTHON_UNPACK_METHODS
10176 if (unlikely(PyMethod_Check(__pyx_t_6))) {
10177 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
10178 if (likely(__pyx_t_7)) {
10179 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
10180 __Pyx_INCREF(__pyx_t_7);
10181 __Pyx_INCREF(function);
10182 __Pyx_DECREF_SET(__pyx_t_6, function);
10183 __pyx_t_9 = 1;
10184 }
10185 }
10186 #endif
10187 {
10188 PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
10189 __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_9, 0+__pyx_t_9);
10190 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
10191 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 319, __pyx_L1_error)
10192 __Pyx_GOTREF(__pyx_t_3);
10193 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
10194 }
10195 if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
10196 PyObject* sequence = __pyx_t_3;
10197 Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
10198 if (unlikely(size != 2)) {
10199 if (size > 2) __Pyx_RaiseTooManyValuesError(2);
10200 else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
10201 __PYX_ERR(0, 319, __pyx_L1_error)
10202 }
10203 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10204 if (likely(PyTuple_CheckExact(sequence))) {
10205 __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0);
10206 __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1);
10207 } else {
10208 __pyx_t_6 = PyList_GET_ITEM(sequence, 0);
10209 __pyx_t_7 = PyList_GET_ITEM(sequence, 1);
10210 }
10211 __Pyx_INCREF(__pyx_t_6);
10212 __Pyx_INCREF(__pyx_t_7);
10213 #else
10214 __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 319, __pyx_L1_error)
10215 __Pyx_GOTREF(__pyx_t_6);
10216 __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 319, __pyx_L1_error)
10217 __Pyx_GOTREF(__pyx_t_7);
10218 #endif
10219 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10220 } else {
10221 Py_ssize_t index = -1;
10222 __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 319, __pyx_L1_error)
10223 __Pyx_GOTREF(__pyx_t_8);
10224 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10225 __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_8);
10226 index = 0; __pyx_t_6 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L14_unpacking_failed;
10227 __Pyx_GOTREF(__pyx_t_6);
10228 index = 1; __pyx_t_7 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L14_unpacking_failed;
10229 __Pyx_GOTREF(__pyx_t_7);
10230 if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_8), 2) < 0) __PYX_ERR(0, 319, __pyx_L1_error)
10231 __pyx_t_10 = NULL;
10232 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
10233 goto __pyx_L15_unpacking_done;
10234 __pyx_L14_unpacking_failed:;
10235 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
10236 __pyx_t_10 = NULL;
10237 if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
10238 __PYX_ERR(0, 319, __pyx_L1_error)
10239 __pyx_L15_unpacking_done:;
10240 }
10241 __pyx_v_stderr_h = __pyx_t_6;
10242 __pyx_t_6 = 0;
10243 __pyx_v_stderr_f = __pyx_t_7;
10244 __pyx_t_7 = 0;
10245
10246 /* "pysam/libcutils.pyx":322
10247 *
10248 * # redirect stdout to file
10249 * if save_stdout: # <<<<<<<<<<<<<<
10250 * stdout_f = save_stdout
10251 * stdout_h = c_open(force_bytes(stdout_f),
10252 */
10253 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_save_stdout); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 322, __pyx_L1_error)
10254 if (__pyx_t_2) {
10255
10256 /* "pysam/libcutils.pyx":323
10257 * # redirect stdout to file
10258 * if save_stdout:
10259 * stdout_f = save_stdout # <<<<<<<<<<<<<<
10260 * stdout_h = c_open(force_bytes(stdout_f),
10261 * O_WRONLY|O_CREAT|O_TRUNC, 0666)
10262 */
10263 __Pyx_INCREF(__pyx_v_save_stdout);
10264 __pyx_v_stdout_f = __pyx_v_save_stdout;
10265
10266 /* "pysam/libcutils.pyx":324
10267 * if save_stdout:
10268 * stdout_f = save_stdout
10269 * stdout_h = c_open(force_bytes(stdout_f), # <<<<<<<<<<<<<<
10270 * O_WRONLY|O_CREAT|O_TRUNC, 0666)
10271 * if stdout_h == -1:
10272 */
10273 __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_stdout_f, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 324, __pyx_L1_error)
10274 __Pyx_GOTREF(__pyx_t_3);
10275 if (unlikely(__pyx_t_3 == Py_None)) {
10276 PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
10277 __PYX_ERR(0, 324, __pyx_L1_error)
10278 }
10279 __pyx_t_11 = __Pyx_PyBytes_AsString(__pyx_t_3); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) __PYX_ERR(0, 324, __pyx_L1_error)
10280
10281 /* "pysam/libcutils.pyx":325
10282 * stdout_f = save_stdout
10283 * stdout_h = c_open(force_bytes(stdout_f),
10284 * O_WRONLY|O_CREAT|O_TRUNC, 0666) # <<<<<<<<<<<<<<
10285 * if stdout_h == -1:
10286 * raise OSError(errno, "error while opening file for writing", stdout_f)
10287 */
10288 __pyx_t_7 = __Pyx_PyInt_From_int(open(__pyx_t_11, ((O_WRONLY | O_CREAT) | O_TRUNC), 0666)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 324, __pyx_L1_error)
10289 __Pyx_GOTREF(__pyx_t_7);
10290 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10291 __pyx_v_stdout_h = __pyx_t_7;
10292 __pyx_t_7 = 0;
10293
10294 /* "pysam/libcutils.pyx":326
10295 * stdout_h = c_open(force_bytes(stdout_f),
10296 * O_WRONLY|O_CREAT|O_TRUNC, 0666)
10297 * if stdout_h == -1: # <<<<<<<<<<<<<<
10298 * raise OSError(errno, "error while opening file for writing", stdout_f)
10299 *
10300 */
10301 __pyx_t_2 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_stdout_h, __pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 326, __pyx_L1_error)
10302 if (unlikely(__pyx_t_2)) {
10303
10304 /* "pysam/libcutils.pyx":327
10305 * O_WRONLY|O_CREAT|O_TRUNC, 0666)
10306 * if stdout_h == -1:
10307 * raise OSError(errno, "error while opening file for writing", stdout_f) # <<<<<<<<<<<<<<
10308 *
10309 * samtools_set_stdout_fn(force_bytes(stdout_f))
10310 */
10311 __pyx_t_7 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 327, __pyx_L1_error)
10312 __Pyx_GOTREF(__pyx_t_7);
10313 __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 327, __pyx_L1_error)
10314 __Pyx_GOTREF(__pyx_t_3);
10315 __Pyx_GIVEREF(__pyx_t_7);
10316 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7)) __PYX_ERR(0, 327, __pyx_L1_error);
10317 __Pyx_INCREF(__pyx_kp_u_error_while_opening_file_for_wri);
10318 __Pyx_GIVEREF(__pyx_kp_u_error_while_opening_file_for_wri);
10319 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_kp_u_error_while_opening_file_for_wri)) __PYX_ERR(0, 327, __pyx_L1_error);
10320 __Pyx_INCREF(__pyx_v_stdout_f);
10321 __Pyx_GIVEREF(__pyx_v_stdout_f);
10322 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_stdout_f)) __PYX_ERR(0, 327, __pyx_L1_error);
10323 __pyx_t_7 = 0;
10324 __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 327, __pyx_L1_error)
10325 __Pyx_GOTREF(__pyx_t_7);
10326 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10327 __Pyx_Raise(__pyx_t_7, 0, 0, 0);
10328 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
10329 __PYX_ERR(0, 327, __pyx_L1_error)
10330
10331 /* "pysam/libcutils.pyx":326
10332 * stdout_h = c_open(force_bytes(stdout_f),
10333 * O_WRONLY|O_CREAT|O_TRUNC, 0666)
10334 * if stdout_h == -1: # <<<<<<<<<<<<<<
10335 * raise OSError(errno, "error while opening file for writing", stdout_f)
10336 *
10337 */
10338 }
10339
10340 /* "pysam/libcutils.pyx":329
10341 * raise OSError(errno, "error while opening file for writing", stdout_f)
10342 *
10343 * samtools_set_stdout_fn(force_bytes(stdout_f)) # <<<<<<<<<<<<<<
10344 * bcftools_set_stdout_fn(force_bytes(stdout_f))
10345 *
10346 */
10347 __pyx_t_7 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_stdout_f, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 329, __pyx_L1_error)
10348 __Pyx_GOTREF(__pyx_t_7);
10349 if (unlikely(__pyx_t_7 == Py_None)) {
10350 PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
10351 __PYX_ERR(0, 329, __pyx_L1_error)
10352 }
10353 __pyx_t_12 = __Pyx_PyBytes_AsString(__pyx_t_7); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) __PYX_ERR(0, 329, __pyx_L1_error)
10354 samtools_set_stdout_fn(__pyx_t_12);
10355 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
10356
10357 /* "pysam/libcutils.pyx":330
10358 *
10359 * samtools_set_stdout_fn(force_bytes(stdout_f))
10360 * bcftools_set_stdout_fn(force_bytes(stdout_f)) # <<<<<<<<<<<<<<
10361 *
10362 * elif catch_stdout:
10363 */
10364 __pyx_t_7 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_stdout_f, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 330, __pyx_L1_error)
10365 __Pyx_GOTREF(__pyx_t_7);
10366 if (unlikely(__pyx_t_7 == Py_None)) {
10367 PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
10368 __PYX_ERR(0, 330, __pyx_L1_error)
10369 }
10370 __pyx_t_13 = __Pyx_PyBytes_AsString(__pyx_t_7); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) __PYX_ERR(0, 330, __pyx_L1_error)
10371 bcftools_set_stdout_fn(__pyx_t_13);
10372 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
10373
10374 /* "pysam/libcutils.pyx":322
10375 *
10376 * # redirect stdout to file
10377 * if save_stdout: # <<<<<<<<<<<<<<
10378 * stdout_f = save_stdout
10379 * stdout_h = c_open(force_bytes(stdout_f),
10380 */
10381 goto __pyx_L16;
10382 }
10383
10384 /* "pysam/libcutils.pyx":332
10385 * bcftools_set_stdout_fn(force_bytes(stdout_f))
10386 *
10387 * elif catch_stdout: # <<<<<<<<<<<<<<
10388 * stdout_h, stdout_f = tempfile.mkstemp()
10389 * MAP_STDOUT_OPTIONS = {
10390 */
10391 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stdout); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 332, __pyx_L1_error)
10392 if (__pyx_t_2) {
10393
10394 /* "pysam/libcutils.pyx":333
10395 *
10396 * elif catch_stdout:
10397 * stdout_h, stdout_f = tempfile.mkstemp() # <<<<<<<<<<<<<<
10398 * MAP_STDOUT_OPTIONS = {
10399 * "samtools": {
10400 */
10401 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_tempfile); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 333, __pyx_L1_error)
10402 __Pyx_GOTREF(__pyx_t_3);
10403 __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_mkstemp); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 333, __pyx_L1_error)
10404 __Pyx_GOTREF(__pyx_t_6);
10405 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10406 __pyx_t_3 = NULL;
10407 __pyx_t_9 = 0;
10408 #if CYTHON_UNPACK_METHODS
10409 if (unlikely(PyMethod_Check(__pyx_t_6))) {
10410 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
10411 if (likely(__pyx_t_3)) {
10412 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
10413 __Pyx_INCREF(__pyx_t_3);
10414 __Pyx_INCREF(function);
10415 __Pyx_DECREF_SET(__pyx_t_6, function);
10416 __pyx_t_9 = 1;
10417 }
10418 }
10419 #endif
10420 {
10421 PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
10422 __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_9, 0+__pyx_t_9);
10423 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
10424 if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 333, __pyx_L1_error)
10425 __Pyx_GOTREF(__pyx_t_7);
10426 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
10427 }
10428 if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) {
10429 PyObject* sequence = __pyx_t_7;
10430 Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
10431 if (unlikely(size != 2)) {
10432 if (size > 2) __Pyx_RaiseTooManyValuesError(2);
10433 else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
10434 __PYX_ERR(0, 333, __pyx_L1_error)
10435 }
10436 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10437 if (likely(PyTuple_CheckExact(sequence))) {
10438 __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0);
10439 __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
10440 } else {
10441 __pyx_t_6 = PyList_GET_ITEM(sequence, 0);
10442 __pyx_t_3 = PyList_GET_ITEM(sequence, 1);
10443 }
10444 __Pyx_INCREF(__pyx_t_6);
10445 __Pyx_INCREF(__pyx_t_3);
10446 #else
10447 __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 333, __pyx_L1_error)
10448 __Pyx_GOTREF(__pyx_t_6);
10449 __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 333, __pyx_L1_error)
10450 __Pyx_GOTREF(__pyx_t_3);
10451 #endif
10452 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
10453 } else {
10454 Py_ssize_t index = -1;
10455 __pyx_t_8 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 333, __pyx_L1_error)
10456 __Pyx_GOTREF(__pyx_t_8);
10457 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
10458 __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_8);
10459 index = 0; __pyx_t_6 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L18_unpacking_failed;
10460 __Pyx_GOTREF(__pyx_t_6);
10461 index = 1; __pyx_t_3 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_3)) goto __pyx_L18_unpacking_failed;
10462 __Pyx_GOTREF(__pyx_t_3);
10463 if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_8), 2) < 0) __PYX_ERR(0, 333, __pyx_L1_error)
10464 __pyx_t_10 = NULL;
10465 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
10466 goto __pyx_L19_unpacking_done;
10467 __pyx_L18_unpacking_failed:;
10468 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
10469 __pyx_t_10 = NULL;
10470 if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
10471 __PYX_ERR(0, 333, __pyx_L1_error)
10472 __pyx_L19_unpacking_done:;
10473 }
10474 __pyx_v_stdout_h = __pyx_t_6;
10475 __pyx_t_6 = 0;
10476 __pyx_v_stdout_f = __pyx_t_3;
10477 __pyx_t_3 = 0;
10478
10479 /* "pysam/libcutils.pyx":335
10480 * stdout_h, stdout_f = tempfile.mkstemp()
10481 * MAP_STDOUT_OPTIONS = {
10482 * "samtools": { # <<<<<<<<<<<<<<
10483 * "view": "-o {}",
10484 * "mpileup": "-o {}",
10485 */
10486 __pyx_t_7 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 335, __pyx_L1_error)
10487 __Pyx_GOTREF(__pyx_t_7);
10488
10489 /* "pysam/libcutils.pyx":336
10490 * MAP_STDOUT_OPTIONS = {
10491 * "samtools": {
10492 * "view": "-o {}", # <<<<<<<<<<<<<<
10493 * "mpileup": "-o {}",
10494 * "depad": "-o {}",
10495 */
10496 __pyx_t_3 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 336, __pyx_L1_error)
10497 __Pyx_GOTREF(__pyx_t_3);
10498 if (PyDict_SetItem(__pyx_t_3, __pyx_n_u_view, __pyx_kp_u_o_2) < 0) __PYX_ERR(0, 336, __pyx_L1_error)
10499 if (PyDict_SetItem(__pyx_t_3, __pyx_n_u_mpileup, __pyx_kp_u_o_2) < 0) __PYX_ERR(0, 336, __pyx_L1_error)
10500 if (PyDict_SetItem(__pyx_t_3, __pyx_n_u_depad, __pyx_kp_u_o_2) < 0) __PYX_ERR(0, 336, __pyx_L1_error)
10501 if (PyDict_SetItem(__pyx_t_3, __pyx_n_u_calmd, __pyx_kp_u_) < 0) __PYX_ERR(0, 336, __pyx_L1_error)
10502 if (PyDict_SetItem(__pyx_t_7, __pyx_n_u_samtools, __pyx_t_3) < 0) __PYX_ERR(0, 335, __pyx_L1_error)
10503 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10504
10505 /* "pysam/libcutils.pyx":341
10506 * "calmd": "", # uses pysam_stdout_fn
10507 * },
10508 * "bcftools": {} # <<<<<<<<<<<<<<
10509 * }
10510 *
10511 */
10512 __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 341, __pyx_L1_error)
10513 __Pyx_GOTREF(__pyx_t_3);
10514 if (PyDict_SetItem(__pyx_t_7, __pyx_n_u_bcftools, __pyx_t_3) < 0) __PYX_ERR(0, 335, __pyx_L1_error)
10515 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10516 __pyx_v_MAP_STDOUT_OPTIONS = ((PyObject*)__pyx_t_7);
10517 __pyx_t_7 = 0;
10518
10519 /* "pysam/libcutils.pyx":344
10520 * }
10521 *
10522 * stdout_option = None # <<<<<<<<<<<<<<
10523 * if collection == "bcftools":
10524 * # in bcftools, most methods accept -o, the exceptions
10525 */
10526 __Pyx_INCREF(Py_None);
10527 __pyx_v_stdout_option = Py_None;
10528
10529 /* "pysam/libcutils.pyx":345
10530 *
10531 * stdout_option = None
10532 * if collection == "bcftools": # <<<<<<<<<<<<<<
10533 * # in bcftools, most methods accept -o, the exceptions
10534 * # are below:
10535 */
10536 __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_collection, __pyx_n_u_bcftools, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 345, __pyx_L1_error)
10537 if (__pyx_t_2) {
10538
10539 /* "pysam/libcutils.pyx":348
10540 * # in bcftools, most methods accept -o, the exceptions
10541 * # are below:
10542 * if method not in ("head", "index", "roh", "stats"): # <<<<<<<<<<<<<<
10543 * stdout_option = "-o {}"
10544 * elif method in MAP_STDOUT_OPTIONS[collection]:
10545 */
10546 __Pyx_INCREF(__pyx_v_method);
10547 __pyx_t_7 = __pyx_v_method;
10548 __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_t_7, __pyx_n_u_head, Py_NE)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 348, __pyx_L1_error)
10549 if (__pyx_t_1) {
10550 } else {
10551 __pyx_t_2 = __pyx_t_1;
10552 goto __pyx_L22_bool_binop_done;
10553 }
10554 __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_t_7, __pyx_n_u_index, Py_NE)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 348, __pyx_L1_error)
10555 if (__pyx_t_1) {
10556 } else {
10557 __pyx_t_2 = __pyx_t_1;
10558 goto __pyx_L22_bool_binop_done;
10559 }
10560 __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_t_7, __pyx_n_u_roh, Py_NE)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 348, __pyx_L1_error)
10561 if (__pyx_t_1) {
10562 } else {
10563 __pyx_t_2 = __pyx_t_1;
10564 goto __pyx_L22_bool_binop_done;
10565 }
10566 __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_t_7, __pyx_n_u_stats, Py_NE)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 348, __pyx_L1_error)
10567 __pyx_t_2 = __pyx_t_1;
10568 __pyx_L22_bool_binop_done:;
10569 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
10570 __pyx_t_1 = __pyx_t_2;
10571 if (__pyx_t_1) {
10572
10573 /* "pysam/libcutils.pyx":349
10574 * # are below:
10575 * if method not in ("head", "index", "roh", "stats"):
10576 * stdout_option = "-o {}" # <<<<<<<<<<<<<<
10577 * elif method in MAP_STDOUT_OPTIONS[collection]:
10578 * # special case - samtools view -c outputs on stdout
10579 */
10580 __Pyx_INCREF(__pyx_kp_u_o_2);
10581 __Pyx_DECREF_SET(__pyx_v_stdout_option, __pyx_kp_u_o_2);
10582
10583 /* "pysam/libcutils.pyx":348
10584 * # in bcftools, most methods accept -o, the exceptions
10585 * # are below:
10586 * if method not in ("head", "index", "roh", "stats"): # <<<<<<<<<<<<<<
10587 * stdout_option = "-o {}"
10588 * elif method in MAP_STDOUT_OPTIONS[collection]:
10589 */
10590 }
10591
10592 /* "pysam/libcutils.pyx":345
10593 *
10594 * stdout_option = None
10595 * if collection == "bcftools": # <<<<<<<<<<<<<<
10596 * # in bcftools, most methods accept -o, the exceptions
10597 * # are below:
10598 */
10599 goto __pyx_L20;
10600 }
10601
10602 /* "pysam/libcutils.pyx":350
10603 * if method not in ("head", "index", "roh", "stats"):
10604 * stdout_option = "-o {}"
10605 * elif method in MAP_STDOUT_OPTIONS[collection]: # <<<<<<<<<<<<<<
10606 * # special case - samtools view -c outputs on stdout
10607 * if not(method == "view" and "-c" in args):
10608 */
10609 __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_MAP_STDOUT_OPTIONS, __pyx_v_collection); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 350, __pyx_L1_error)
10610 __Pyx_GOTREF(__pyx_t_7);
10611 __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_method, __pyx_t_7, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 350, __pyx_L1_error)
10612 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
10613 if (__pyx_t_1) {
10614
10615 /* "pysam/libcutils.pyx":352
10616 * elif method in MAP_STDOUT_OPTIONS[collection]:
10617 * # special case - samtools view -c outputs on stdout
10618 * if not(method == "view" and "-c" in args): # <<<<<<<<<<<<<<
10619 * stdout_option = MAP_STDOUT_OPTIONS[collection][method]
10620 *
10621 */
10622 __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_method, __pyx_n_u_view, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 352, __pyx_L1_error)
10623 if (__pyx_t_2) {
10624 } else {
10625 __pyx_t_1 = __pyx_t_2;
10626 goto __pyx_L27_bool_binop_done;
10627 }
10628 __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_kp_u_c, __pyx_v_args, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 352, __pyx_L1_error)
10629 __pyx_t_1 = __pyx_t_2;
10630 __pyx_L27_bool_binop_done:;
10631 __pyx_t_2 = (!__pyx_t_1);
10632 if (__pyx_t_2) {
10633
10634 /* "pysam/libcutils.pyx":353
10635 * # special case - samtools view -c outputs on stdout
10636 * if not(method == "view" and "-c" in args):
10637 * stdout_option = MAP_STDOUT_OPTIONS[collection][method] # <<<<<<<<<<<<<<
10638 *
10639 * if stdout_option is not None and not is_usage:
10640 */
10641 __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_MAP_STDOUT_OPTIONS, __pyx_v_collection); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 353, __pyx_L1_error)
10642 __Pyx_GOTREF(__pyx_t_7);
10643 __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_7, __pyx_v_method); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 353, __pyx_L1_error)
10644 __Pyx_GOTREF(__pyx_t_3);
10645 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
10646 __Pyx_DECREF_SET(__pyx_v_stdout_option, __pyx_t_3);
10647 __pyx_t_3 = 0;
10648
10649 /* "pysam/libcutils.pyx":352
10650 * elif method in MAP_STDOUT_OPTIONS[collection]:
10651 * # special case - samtools view -c outputs on stdout
10652 * if not(method == "view" and "-c" in args): # <<<<<<<<<<<<<<
10653 * stdout_option = MAP_STDOUT_OPTIONS[collection][method]
10654 *
10655 */
10656 }
10657
10658 /* "pysam/libcutils.pyx":350
10659 * if method not in ("head", "index", "roh", "stats"):
10660 * stdout_option = "-o {}"
10661 * elif method in MAP_STDOUT_OPTIONS[collection]: # <<<<<<<<<<<<<<
10662 * # special case - samtools view -c outputs on stdout
10663 * if not(method == "view" and "-c" in args):
10664 */
10665 }
10666 __pyx_L20:;
10667
10668 /* "pysam/libcutils.pyx":355
10669 * stdout_option = MAP_STDOUT_OPTIONS[collection][method]
10670 *
10671 * if stdout_option is not None and not is_usage: # <<<<<<<<<<<<<<
10672 * os.close(stdout_h)
10673 * samtools_set_stdout_fn(force_bytes(stdout_f))
10674 */
10675 __pyx_t_1 = (__pyx_v_stdout_option != Py_None);
10676 if (__pyx_t_1) {
10677 } else {
10678 __pyx_t_2 = __pyx_t_1;
10679 goto __pyx_L30_bool_binop_done;
10680 }
10681 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_is_usage); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 355, __pyx_L1_error)
10682 __pyx_t_14 = (!__pyx_t_1);
10683 __pyx_t_2 = __pyx_t_14;
10684 __pyx_L30_bool_binop_done:;
10685 if (__pyx_t_2) {
10686
10687 /* "pysam/libcutils.pyx":356
10688 *
10689 * if stdout_option is not None and not is_usage:
10690 * os.close(stdout_h) # <<<<<<<<<<<<<<
10691 * samtools_set_stdout_fn(force_bytes(stdout_f))
10692 * bcftools_set_stdout_fn(force_bytes(stdout_f))
10693 */
10694 __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 356, __pyx_L1_error)
10695 __Pyx_GOTREF(__pyx_t_7);
10696 __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_close); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 356, __pyx_L1_error)
10697 __Pyx_GOTREF(__pyx_t_6);
10698 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
10699 __pyx_t_7 = NULL;
10700 __pyx_t_9 = 0;
10701 #if CYTHON_UNPACK_METHODS
10702 if (unlikely(PyMethod_Check(__pyx_t_6))) {
10703 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
10704 if (likely(__pyx_t_7)) {
10705 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
10706 __Pyx_INCREF(__pyx_t_7);
10707 __Pyx_INCREF(function);
10708 __Pyx_DECREF_SET(__pyx_t_6, function);
10709 __pyx_t_9 = 1;
10710 }
10711 }
10712 #endif
10713 {
10714 PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_stdout_h};
10715 __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9);
10716 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
10717 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 356, __pyx_L1_error)
10718 __Pyx_GOTREF(__pyx_t_3);
10719 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
10720 }
10721 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10722
10723 /* "pysam/libcutils.pyx":357
10724 * if stdout_option is not None and not is_usage:
10725 * os.close(stdout_h)
10726 * samtools_set_stdout_fn(force_bytes(stdout_f)) # <<<<<<<<<<<<<<
10727 * bcftools_set_stdout_fn(force_bytes(stdout_f))
10728 * args.extend(stdout_option.format(stdout_f).split(" "))
10729 */
10730 __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_stdout_f, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 357, __pyx_L1_error)
10731 __Pyx_GOTREF(__pyx_t_3);
10732 if (unlikely(__pyx_t_3 == Py_None)) {
10733 PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
10734 __PYX_ERR(0, 357, __pyx_L1_error)
10735 }
10736 __pyx_t_12 = __Pyx_PyBytes_AsString(__pyx_t_3); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) __PYX_ERR(0, 357, __pyx_L1_error)
10737 samtools_set_stdout_fn(__pyx_t_12);
10738 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10739
10740 /* "pysam/libcutils.pyx":358
10741 * os.close(stdout_h)
10742 * samtools_set_stdout_fn(force_bytes(stdout_f))
10743 * bcftools_set_stdout_fn(force_bytes(stdout_f)) # <<<<<<<<<<<<<<
10744 * args.extend(stdout_option.format(stdout_f).split(" "))
10745 * stdout_h = c_open(b"/dev/null", O_WRONLY)
10746 */
10747 __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_stdout_f, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 358, __pyx_L1_error)
10748 __Pyx_GOTREF(__pyx_t_3);
10749 if (unlikely(__pyx_t_3 == Py_None)) {
10750 PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
10751 __PYX_ERR(0, 358, __pyx_L1_error)
10752 }
10753 __pyx_t_13 = __Pyx_PyBytes_AsString(__pyx_t_3); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) __PYX_ERR(0, 358, __pyx_L1_error)
10754 bcftools_set_stdout_fn(__pyx_t_13);
10755 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10756
10757 /* "pysam/libcutils.pyx":359
10758 * samtools_set_stdout_fn(force_bytes(stdout_f))
10759 * bcftools_set_stdout_fn(force_bytes(stdout_f))
10760 * args.extend(stdout_option.format(stdout_f).split(" ")) # <<<<<<<<<<<<<<
10761 * stdout_h = c_open(b"/dev/null", O_WRONLY)
10762 * else:
10763 */
10764 __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_args, __pyx_n_s_extend); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 359, __pyx_L1_error)
10765 __Pyx_GOTREF(__pyx_t_6);
10766 __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_stdout_option, __pyx_n_s_format); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 359, __pyx_L1_error)
10767 __Pyx_GOTREF(__pyx_t_15);
10768 __pyx_t_16 = NULL;
10769 __pyx_t_9 = 0;
10770 #if CYTHON_UNPACK_METHODS
10771 if (likely(PyMethod_Check(__pyx_t_15))) {
10772 __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_15);
10773 if (likely(__pyx_t_16)) {
10774 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
10775 __Pyx_INCREF(__pyx_t_16);
10776 __Pyx_INCREF(function);
10777 __Pyx_DECREF_SET(__pyx_t_15, function);
10778 __pyx_t_9 = 1;
10779 }
10780 }
10781 #endif
10782 {
10783 PyObject *__pyx_callargs[2] = {__pyx_t_16, __pyx_v_stdout_f};
10784 __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9);
10785 __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
10786 if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 359, __pyx_L1_error)
10787 __Pyx_GOTREF(__pyx_t_8);
10788 __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
10789 }
10790 __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_split); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 359, __pyx_L1_error)
10791 __Pyx_GOTREF(__pyx_t_15);
10792 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
10793 __pyx_t_8 = NULL;
10794 __pyx_t_9 = 0;
10795 #if CYTHON_UNPACK_METHODS
10796 if (likely(PyMethod_Check(__pyx_t_15))) {
10797 __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_15);
10798 if (likely(__pyx_t_8)) {
10799 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
10800 __Pyx_INCREF(__pyx_t_8);
10801 __Pyx_INCREF(function);
10802 __Pyx_DECREF_SET(__pyx_t_15, function);
10803 __pyx_t_9 = 1;
10804 }
10805 }
10806 #endif
10807 {
10808 PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_kp_u__11};
10809 __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9);
10810 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
10811 if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 359, __pyx_L1_error)
10812 __Pyx_GOTREF(__pyx_t_7);
10813 __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
10814 }
10815 __pyx_t_15 = NULL;
10816 __pyx_t_9 = 0;
10817 #if CYTHON_UNPACK_METHODS
10818 if (likely(PyMethod_Check(__pyx_t_6))) {
10819 __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
10820 if (likely(__pyx_t_15)) {
10821 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
10822 __Pyx_INCREF(__pyx_t_15);
10823 __Pyx_INCREF(function);
10824 __Pyx_DECREF_SET(__pyx_t_6, function);
10825 __pyx_t_9 = 1;
10826 }
10827 }
10828 #endif
10829 {
10830 PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_t_7};
10831 __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9);
10832 __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
10833 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
10834 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 359, __pyx_L1_error)
10835 __Pyx_GOTREF(__pyx_t_3);
10836 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
10837 }
10838 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10839
10840 /* "pysam/libcutils.pyx":360
10841 * bcftools_set_stdout_fn(force_bytes(stdout_f))
10842 * args.extend(stdout_option.format(stdout_f).split(" "))
10843 * stdout_h = c_open(b"/dev/null", O_WRONLY) # <<<<<<<<<<<<<<
10844 * else:
10845 * samtools_set_stdout_fn("-")
10846 */
10847 __pyx_t_3 = __Pyx_PyInt_From_int(open(((char const *)"/dev/null"), O_WRONLY)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 360, __pyx_L1_error)
10848 __Pyx_GOTREF(__pyx_t_3);
10849 __Pyx_DECREF_SET(__pyx_v_stdout_h, __pyx_t_3);
10850 __pyx_t_3 = 0;
10851
10852 /* "pysam/libcutils.pyx":355
10853 * stdout_option = MAP_STDOUT_OPTIONS[collection][method]
10854 *
10855 * if stdout_option is not None and not is_usage: # <<<<<<<<<<<<<<
10856 * os.close(stdout_h)
10857 * samtools_set_stdout_fn(force_bytes(stdout_f))
10858 */
10859 }
10860
10861 /* "pysam/libcutils.pyx":332
10862 * bcftools_set_stdout_fn(force_bytes(stdout_f))
10863 *
10864 * elif catch_stdout: # <<<<<<<<<<<<<<
10865 * stdout_h, stdout_f = tempfile.mkstemp()
10866 * MAP_STDOUT_OPTIONS = {
10867 */
10868 goto __pyx_L16;
10869 }
10870
10871 /* "pysam/libcutils.pyx":362
10872 * stdout_h = c_open(b"/dev/null", O_WRONLY)
10873 * else:
10874 * samtools_set_stdout_fn("-") # <<<<<<<<<<<<<<
10875 * bcftools_set_stdout_fn("-")
10876 * stdout_h = c_open(b"/dev/null", O_WRONLY)
10877 */
10878 /*else*/ {
10879 samtools_set_stdout_fn(((char const *)"-"));
10880
10881 /* "pysam/libcutils.pyx":363
10882 * else:
10883 * samtools_set_stdout_fn("-")
10884 * bcftools_set_stdout_fn("-") # <<<<<<<<<<<<<<
10885 * stdout_h = c_open(b"/dev/null", O_WRONLY)
10886 *
10887 */
10888 bcftools_set_stdout_fn(((char const *)"-"));
10889
10890 /* "pysam/libcutils.pyx":364
10891 * samtools_set_stdout_fn("-")
10892 * bcftools_set_stdout_fn("-")
10893 * stdout_h = c_open(b"/dev/null", O_WRONLY) # <<<<<<<<<<<<<<
10894 *
10895 * # setup the function call to samtools/bcftools main
10896 */
10897 __pyx_t_3 = __Pyx_PyInt_From_int(open(((char const *)"/dev/null"), O_WRONLY)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 364, __pyx_L1_error)
10898 __Pyx_GOTREF(__pyx_t_3);
10899 __pyx_v_stdout_h = __pyx_t_3;
10900 __pyx_t_3 = 0;
10901 }
10902 __pyx_L16:;
10903
10904 /* "pysam/libcutils.pyx":369
10905 * cdef char ** cargs
10906 * cdef int i, n, retval, l
10907 * n = len(args) # <<<<<<<<<<<<<<
10908 * method = force_bytes(method)
10909 * collection = force_bytes(collection)
10910 */
10911 __pyx_t_4 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 369, __pyx_L1_error)
10912 __pyx_v_n = __pyx_t_4;
10913
10914 /* "pysam/libcutils.pyx":370
10915 * cdef int i, n, retval, l
10916 * n = len(args)
10917 * method = force_bytes(method) # <<<<<<<<<<<<<<
10918 * collection = force_bytes(collection)
10919 * args = [force_bytes(a) for a in args]
10920 */
10921 __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_method, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 370, __pyx_L1_error)
10922 __Pyx_GOTREF(__pyx_t_3);
10923 __Pyx_DECREF_SET(__pyx_v_method, __pyx_t_3);
10924 __pyx_t_3 = 0;
10925
10926 /* "pysam/libcutils.pyx":371
10927 * n = len(args)
10928 * method = force_bytes(method)
10929 * collection = force_bytes(collection) # <<<<<<<<<<<<<<
10930 * args = [force_bytes(a) for a in args]
10931 *
10932 */
10933 __pyx_t_3 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_v_collection, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L1_error)
10934 __Pyx_GOTREF(__pyx_t_3);
10935 __Pyx_DECREF_SET(__pyx_v_collection, __pyx_t_3);
10936 __pyx_t_3 = 0;
10937
10938 /* "pysam/libcutils.pyx":372
10939 * method = force_bytes(method)
10940 * collection = force_bytes(collection)
10941 * args = [force_bytes(a) for a in args] # <<<<<<<<<<<<<<
10942 *
10943 * # allocate two more for first (dummy) argument (contains command)
10944 */
10945 { /* enter inner scope */
10946 __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 372, __pyx_L34_error)
10947 __Pyx_GOTREF(__pyx_t_3);
10948 if (likely(PyList_CheckExact(__pyx_v_args)) || PyTuple_CheckExact(__pyx_v_args)) {
10949 __pyx_t_6 = __pyx_v_args; __Pyx_INCREF(__pyx_t_6);
10950 __pyx_t_4 = 0;
10951 __pyx_t_5 = NULL;
10952 } else {
10953 __pyx_t_4 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 372, __pyx_L34_error)
10954 __Pyx_GOTREF(__pyx_t_6);
10955 __pyx_t_5 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 372, __pyx_L34_error)
10956 }
10957 for (;;) {
10958 if (likely(!__pyx_t_5)) {
10959 if (likely(PyList_CheckExact(__pyx_t_6))) {
10960 {
10961 Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
10962 #if !CYTHON_ASSUME_SAFE_MACROS
10963 if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 372, __pyx_L34_error)
10964 #endif
10965 if (__pyx_t_4 >= __pyx_temp) break;
10966 }
10967 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10968 __pyx_t_7 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_7); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 372, __pyx_L34_error)
10969 #else
10970 __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 372, __pyx_L34_error)
10971 __Pyx_GOTREF(__pyx_t_7);
10972 #endif
10973 } else {
10974 {
10975 Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
10976 #if !CYTHON_ASSUME_SAFE_MACROS
10977 if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 372, __pyx_L34_error)
10978 #endif
10979 if (__pyx_t_4 >= __pyx_temp) break;
10980 }
10981 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10982 __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_4); __Pyx_INCREF(__pyx_t_7); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 372, __pyx_L34_error)
10983 #else
10984 __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 372, __pyx_L34_error)
10985 __Pyx_GOTREF(__pyx_t_7);
10986 #endif
10987 }
10988 } else {
10989 __pyx_t_7 = __pyx_t_5(__pyx_t_6);
10990 if (unlikely(!__pyx_t_7)) {
10991 PyObject* exc_type = PyErr_Occurred();
10992 if (exc_type) {
10993 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
10994 else __PYX_ERR(0, 372, __pyx_L34_error)
10995 }
10996 break;
10997 }
10998 __Pyx_GOTREF(__pyx_t_7);
10999 }
11000 __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_a, __pyx_t_7);
11001 __pyx_t_7 = 0;
11002 __pyx_t_7 = __pyx_f_5pysam_9libcutils_force_bytes(__pyx_8genexpr2__pyx_v_a, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 372, __pyx_L34_error)
11003 __Pyx_GOTREF(__pyx_t_7);
11004 if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 372, __pyx_L34_error)
11005 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
11006 }
11007 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11008 __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_a); __pyx_8genexpr2__pyx_v_a = 0;
11009 goto __pyx_L38_exit_scope;
11010 __pyx_L34_error:;
11011 __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_a); __pyx_8genexpr2__pyx_v_a = 0;
11012 goto __pyx_L1_error;
11013 __pyx_L38_exit_scope:;
11014 } /* exit inner scope */
11015 __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_3);
11016 __pyx_t_3 = 0;
11017
11018 /* "pysam/libcutils.pyx":375
11019 *
11020 * # allocate two more for first (dummy) argument (contains command)
11021 * cdef int extra_args = 0 # <<<<<<<<<<<<<<
11022 * if method == b"index":
11023 * extra_args = 1
11024 */
11025 __pyx_v_extra_args = 0;
11026
11027 /* "pysam/libcutils.pyx":376
11028 * # allocate two more for first (dummy) argument (contains command)
11029 * cdef int extra_args = 0
11030 * if method == b"index": # <<<<<<<<<<<<<<
11031 * extra_args = 1
11032 * # add extra arguments for commands accepting optional arguments
11033 */
11034 __pyx_t_2 = (__Pyx_PyBytes_Equals(__pyx_v_method, __pyx_n_b_index, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 376, __pyx_L1_error)
11035 if (__pyx_t_2) {
11036
11037 /* "pysam/libcutils.pyx":377
11038 * cdef int extra_args = 0
11039 * if method == b"index":
11040 * extra_args = 1 # <<<<<<<<<<<<<<
11041 * # add extra arguments for commands accepting optional arguments
11042 * # such as 'samtools index x.bam [out.index]'
11043 */
11044 __pyx_v_extra_args = 1;
11045
11046 /* "pysam/libcutils.pyx":376
11047 * # allocate two more for first (dummy) argument (contains command)
11048 * cdef int extra_args = 0
11049 * if method == b"index": # <<<<<<<<<<<<<<
11050 * extra_args = 1
11051 * # add extra arguments for commands accepting optional arguments
11052 */
11053 }
11054
11055 /* "pysam/libcutils.pyx":380
11056 * # add extra arguments for commands accepting optional arguments
11057 * # such as 'samtools index x.bam [out.index]'
11058 * cargs = <char**>calloc(n + 2 + extra_args, sizeof(char *)) # <<<<<<<<<<<<<<
11059 * cargs[0] = collection
11060 * cargs[1] = method
11061 */
11062 __pyx_v_cargs = ((char **)calloc(((__pyx_v_n + 2) + __pyx_v_extra_args), (sizeof(char *))));
11063
11064 /* "pysam/libcutils.pyx":381
11065 * # such as 'samtools index x.bam [out.index]'
11066 * cargs = <char**>calloc(n + 2 + extra_args, sizeof(char *))
11067 * cargs[0] = collection # <<<<<<<<<<<<<<
11068 * cargs[1] = method
11069 *
11070 */
11071 __pyx_t_17 = __Pyx_PyObject_AsWritableString(__pyx_v_collection); if (unlikely((!__pyx_t_17) && PyErr_Occurred())) __PYX_ERR(0, 381, __pyx_L1_error)
11072 (__pyx_v_cargs[0]) = __pyx_t_17;
11073
11074 /* "pysam/libcutils.pyx":382
11075 * cargs = <char**>calloc(n + 2 + extra_args, sizeof(char *))
11076 * cargs[0] = collection
11077 * cargs[1] = method # <<<<<<<<<<<<<<
11078 *
11079 * # create copies of strings - getopt for long options permutes
11080 */
11081 __pyx_t_17 = __Pyx_PyObject_AsWritableString(__pyx_v_method); if (unlikely((!__pyx_t_17) && PyErr_Occurred())) __PYX_ERR(0, 382, __pyx_L1_error)
11082 (__pyx_v_cargs[1]) = __pyx_t_17;
11083
11084 /* "pysam/libcutils.pyx":386
11085 * # create copies of strings - getopt for long options permutes
11086 * # arguments
11087 * for i from 0 <= i < n: # <<<<<<<<<<<<<<
11088 * l = len(args[i])
11089 * cargs[i + 2] = <char *>calloc(l + 1, sizeof(char))
11090 */
11091 __pyx_t_18 = __pyx_v_n;
11092 for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_18; __pyx_v_i++) {
11093
11094 /* "pysam/libcutils.pyx":387
11095 * # arguments
11096 * for i from 0 <= i < n:
11097 * l = len(args[i]) # <<<<<<<<<<<<<<
11098 * cargs[i + 2] = <char *>calloc(l + 1, sizeof(char))
11099 * strncpy(cargs[i + 2], args[i], l)
11100 */
11101 __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_args, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 387, __pyx_L1_error)
11102 __Pyx_GOTREF(__pyx_t_3);
11103 __pyx_t_4 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 387, __pyx_L1_error)
11104 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11105 __pyx_v_l = __pyx_t_4;
11106
11107 /* "pysam/libcutils.pyx":388
11108 * for i from 0 <= i < n:
11109 * l = len(args[i])
11110 * cargs[i + 2] = <char *>calloc(l + 1, sizeof(char)) # <<<<<<<<<<<<<<
11111 * strncpy(cargs[i + 2], args[i], l)
11112 *
11113 */
11114 (__pyx_v_cargs[(__pyx_v_i + 2)]) = ((char *)calloc((__pyx_v_l + 1), (sizeof(char))));
11115
11116 /* "pysam/libcutils.pyx":389
11117 * l = len(args[i])
11118 * cargs[i + 2] = <char *>calloc(l + 1, sizeof(char))
11119 * strncpy(cargs[i + 2], args[i], l) # <<<<<<<<<<<<<<
11120 *
11121 * # call samtools/bcftools
11122 */
11123 __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_args, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 389, __pyx_L1_error)
11124 __Pyx_GOTREF(__pyx_t_3);
11125 __pyx_t_19 = __Pyx_PyObject_AsString(__pyx_t_3); if (unlikely((!__pyx_t_19) && PyErr_Occurred())) __PYX_ERR(0, 389, __pyx_L1_error)
11126 (void)(strncpy((__pyx_v_cargs[(__pyx_v_i + 2)]), __pyx_t_19, __pyx_v_l));
11127 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11128 }
11129
11130 /* "pysam/libcutils.pyx":392
11131 *
11132 * # call samtools/bcftools
11133 * if collection == b"samtools": # <<<<<<<<<<<<<<
11134 * samtools_set_stdout(stdout_h)
11135 * samtools_set_stderr(stderr_h)
11136 */
11137 __pyx_t_2 = (__Pyx_PyBytes_Equals(__pyx_v_collection, __pyx_n_b_samtools, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 392, __pyx_L1_error)
11138 if (__pyx_t_2) {
11139
11140 /* "pysam/libcutils.pyx":393
11141 * # call samtools/bcftools
11142 * if collection == b"samtools":
11143 * samtools_set_stdout(stdout_h) # <<<<<<<<<<<<<<
11144 * samtools_set_stderr(stderr_h)
11145 * retval = samtools_dispatch(n + 2, cargs)
11146 */
11147 __pyx_t_18 = __Pyx_PyInt_As_int(__pyx_v_stdout_h); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 393, __pyx_L1_error)
11148 samtools_set_stdout(__pyx_t_18);
11149
11150 /* "pysam/libcutils.pyx":394
11151 * if collection == b"samtools":
11152 * samtools_set_stdout(stdout_h)
11153 * samtools_set_stderr(stderr_h) # <<<<<<<<<<<<<<
11154 * retval = samtools_dispatch(n + 2, cargs)
11155 * samtools_close_stdout()
11156 */
11157 __pyx_t_18 = __Pyx_PyInt_As_int(__pyx_v_stderr_h); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 394, __pyx_L1_error)
11158 samtools_set_stderr(__pyx_t_18);
11159
11160 /* "pysam/libcutils.pyx":395
11161 * samtools_set_stdout(stdout_h)
11162 * samtools_set_stderr(stderr_h)
11163 * retval = samtools_dispatch(n + 2, cargs) # <<<<<<<<<<<<<<
11164 * samtools_close_stdout()
11165 * samtools_close_stderr()
11166 */
11167 __pyx_v_retval = samtools_dispatch((__pyx_v_n + 2), __pyx_v_cargs);
11168
11169 /* "pysam/libcutils.pyx":396
11170 * samtools_set_stderr(stderr_h)
11171 * retval = samtools_dispatch(n + 2, cargs)
11172 * samtools_close_stdout() # <<<<<<<<<<<<<<
11173 * samtools_close_stderr()
11174 * elif collection == b"bcftools":
11175 */
11176 samtools_close_stdout();
11177
11178 /* "pysam/libcutils.pyx":397
11179 * retval = samtools_dispatch(n + 2, cargs)
11180 * samtools_close_stdout()
11181 * samtools_close_stderr() # <<<<<<<<<<<<<<
11182 * elif collection == b"bcftools":
11183 * bcftools_set_stdout(stdout_h)
11184 */
11185 samtools_close_stderr();
11186
11187 /* "pysam/libcutils.pyx":392
11188 *
11189 * # call samtools/bcftools
11190 * if collection == b"samtools": # <<<<<<<<<<<<<<
11191 * samtools_set_stdout(stdout_h)
11192 * samtools_set_stderr(stderr_h)
11193 */
11194 goto __pyx_L42;
11195 }
11196
11197 /* "pysam/libcutils.pyx":398
11198 * samtools_close_stdout()
11199 * samtools_close_stderr()
11200 * elif collection == b"bcftools": # <<<<<<<<<<<<<<
11201 * bcftools_set_stdout(stdout_h)
11202 * bcftools_set_stderr(stderr_h)
11203 */
11204 __pyx_t_2 = (__Pyx_PyBytes_Equals(__pyx_v_collection, __pyx_n_b_bcftools, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 398, __pyx_L1_error)
11205 if (__pyx_t_2) {
11206
11207 /* "pysam/libcutils.pyx":399
11208 * samtools_close_stderr()
11209 * elif collection == b"bcftools":
11210 * bcftools_set_stdout(stdout_h) # <<<<<<<<<<<<<<
11211 * bcftools_set_stderr(stderr_h)
11212 * retval = bcftools_dispatch(n + 2, cargs)
11213 */
11214 __pyx_t_18 = __Pyx_PyInt_As_int(__pyx_v_stdout_h); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 399, __pyx_L1_error)
11215 bcftools_set_stdout(__pyx_t_18);
11216
11217 /* "pysam/libcutils.pyx":400
11218 * elif collection == b"bcftools":
11219 * bcftools_set_stdout(stdout_h)
11220 * bcftools_set_stderr(stderr_h) # <<<<<<<<<<<<<<
11221 * retval = bcftools_dispatch(n + 2, cargs)
11222 * bcftools_close_stdout()
11223 */
11224 __pyx_t_18 = __Pyx_PyInt_As_int(__pyx_v_stderr_h); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L1_error)
11225 bcftools_set_stderr(__pyx_t_18);
11226
11227 /* "pysam/libcutils.pyx":401
11228 * bcftools_set_stdout(stdout_h)
11229 * bcftools_set_stderr(stderr_h)
11230 * retval = bcftools_dispatch(n + 2, cargs) # <<<<<<<<<<<<<<
11231 * bcftools_close_stdout()
11232 * bcftools_close_stderr()
11233 */
11234 __pyx_v_retval = bcftools_dispatch((__pyx_v_n + 2), __pyx_v_cargs);
11235
11236 /* "pysam/libcutils.pyx":402
11237 * bcftools_set_stderr(stderr_h)
11238 * retval = bcftools_dispatch(n + 2, cargs)
11239 * bcftools_close_stdout() # <<<<<<<<<<<<<<
11240 * bcftools_close_stderr()
11241 * else:
11242 */
11243 bcftools_close_stdout();
11244
11245 /* "pysam/libcutils.pyx":403
11246 * retval = bcftools_dispatch(n + 2, cargs)
11247 * bcftools_close_stdout()
11248 * bcftools_close_stderr() # <<<<<<<<<<<<<<
11249 * else:
11250 * # unknown -- just return a Unix shell's "command not found" exit status
11251 */
11252 bcftools_close_stderr();
11253
11254 /* "pysam/libcutils.pyx":398
11255 * samtools_close_stdout()
11256 * samtools_close_stderr()
11257 * elif collection == b"bcftools": # <<<<<<<<<<<<<<
11258 * bcftools_set_stdout(stdout_h)
11259 * bcftools_set_stderr(stderr_h)
11260 */
11261 goto __pyx_L42;
11262 }
11263
11264 /* "pysam/libcutils.pyx":406
11265 * else:
11266 * # unknown -- just return a Unix shell's "command not found" exit status
11267 * retval = 127 # <<<<<<<<<<<<<<
11268 *
11269 * for i from 0 <= i < n:
11270 */
11271 /*else*/ {
11272 __pyx_v_retval = 0x7F;
11273 }
11274 __pyx_L42:;
11275
11276 /* "pysam/libcutils.pyx":408
11277 * retval = 127
11278 *
11279 * for i from 0 <= i < n: # <<<<<<<<<<<<<<
11280 * free(cargs[i + 2])
11281 * free(cargs)
11282 */
11283 __pyx_t_18 = __pyx_v_n;
11284 for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_18; __pyx_v_i++) {
11285
11286 /* "pysam/libcutils.pyx":409
11287 *
11288 * for i from 0 <= i < n:
11289 * free(cargs[i + 2]) # <<<<<<<<<<<<<<
11290 * free(cargs)
11291 *
11292 */
11293 free((__pyx_v_cargs[(__pyx_v_i + 2)]));
11294 }
11295
11296 /* "pysam/libcutils.pyx":410
11297 * for i from 0 <= i < n:
11298 * free(cargs[i + 2])
11299 * free(cargs) # <<<<<<<<<<<<<<
11300 *
11301 * # get error messages
11302 */
11303 free(__pyx_v_cargs);
11304
11305 /* "pysam/libcutils.pyx":413
11306 *
11307 * # get error messages
11308 * def _collect(fn): # <<<<<<<<<<<<<<
11309 * out = []
11310 * try:
11311 */
11312 __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_5pysam_9libcutils_15_pysam_dispatch_1_collect, 0, __pyx_n_s_pysam_dispatch_locals__collect, NULL, __pyx_n_s_pysam_libcutils, __pyx_d, ((PyObject *)__pyx_codeobj__13)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 413, __pyx_L1_error)
11313 __Pyx_GOTREF(__pyx_t_3);
11314 __pyx_v__collect = __pyx_t_3;
11315 __pyx_t_3 = 0;
11316
11317 /* "pysam/libcutils.pyx":426
11318 * return out
11319 *
11320 * out_stderr = _collect(stderr_f) # <<<<<<<<<<<<<<
11321 * if save_stdout:
11322 * out_stdout = None
11323 */
11324 __pyx_t_3 = __pyx_pf_5pysam_9libcutils_15_pysam_dispatch__collect(__pyx_v__collect, __pyx_v_stderr_f); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 426, __pyx_L1_error)
11325 __Pyx_GOTREF(__pyx_t_3);
11326 __pyx_v_out_stderr = __pyx_t_3;
11327 __pyx_t_3 = 0;
11328
11329 /* "pysam/libcutils.pyx":427
11330 *
11331 * out_stderr = _collect(stderr_f)
11332 * if save_stdout: # <<<<<<<<<<<<<<
11333 * out_stdout = None
11334 * elif catch_stdout:
11335 */
11336 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_save_stdout); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 427, __pyx_L1_error)
11337 if (__pyx_t_2) {
11338
11339 /* "pysam/libcutils.pyx":428
11340 * out_stderr = _collect(stderr_f)
11341 * if save_stdout:
11342 * out_stdout = None # <<<<<<<<<<<<<<
11343 * elif catch_stdout:
11344 * out_stdout = _collect(stdout_f)
11345 */
11346 __Pyx_INCREF(Py_None);
11347 __pyx_v_out_stdout = Py_None;
11348
11349 /* "pysam/libcutils.pyx":427
11350 *
11351 * out_stderr = _collect(stderr_f)
11352 * if save_stdout: # <<<<<<<<<<<<<<
11353 * out_stdout = None
11354 * elif catch_stdout:
11355 */
11356 goto __pyx_L45;
11357 }
11358
11359 /* "pysam/libcutils.pyx":429
11360 * if save_stdout:
11361 * out_stdout = None
11362 * elif catch_stdout: # <<<<<<<<<<<<<<
11363 * out_stdout = _collect(stdout_f)
11364 * else:
11365 */
11366 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stdout); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 429, __pyx_L1_error)
11367 if (__pyx_t_2) {
11368
11369 /* "pysam/libcutils.pyx":430
11370 * out_stdout = None
11371 * elif catch_stdout:
11372 * out_stdout = _collect(stdout_f) # <<<<<<<<<<<<<<
11373 * else:
11374 * out_stdout = None
11375 */
11376 if (unlikely(!__pyx_v_stdout_f)) { __Pyx_RaiseUnboundLocalError("stdout_f"); __PYX_ERR(0, 430, __pyx_L1_error) }
11377 __pyx_t_3 = __pyx_pf_5pysam_9libcutils_15_pysam_dispatch__collect(__pyx_v__collect, __pyx_v_stdout_f); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 430, __pyx_L1_error)
11378 __Pyx_GOTREF(__pyx_t_3);
11379 __pyx_v_out_stdout = __pyx_t_3;
11380 __pyx_t_3 = 0;
11381
11382 /* "pysam/libcutils.pyx":429
11383 * if save_stdout:
11384 * out_stdout = None
11385 * elif catch_stdout: # <<<<<<<<<<<<<<
11386 * out_stdout = _collect(stdout_f)
11387 * else:
11388 */
11389 goto __pyx_L45;
11390 }
11391
11392 /* "pysam/libcutils.pyx":432
11393 * out_stdout = _collect(stdout_f)
11394 * else:
11395 * out_stdout = None # <<<<<<<<<<<<<<
11396 *
11397 * return retval, out_stderr, out_stdout
11398 */
11399 /*else*/ {
11400 __Pyx_INCREF(Py_None);
11401 __pyx_v_out_stdout = Py_None;
11402 }
11403 __pyx_L45:;
11404
11405 /* "pysam/libcutils.pyx":434
11406 * out_stdout = None
11407 *
11408 * return retval, out_stderr, out_stdout # <<<<<<<<<<<<<<
11409 *
11410 *
11411 */
11412 __Pyx_XDECREF(__pyx_r);
11413 __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_retval); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 434, __pyx_L1_error)
11414 __Pyx_GOTREF(__pyx_t_3);
11415 __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 434, __pyx_L1_error)
11416 __Pyx_GOTREF(__pyx_t_6);
11417 __Pyx_GIVEREF(__pyx_t_3);
11418 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3)) __PYX_ERR(0, 434, __pyx_L1_error);
11419 __Pyx_INCREF(__pyx_v_out_stderr);
11420 __Pyx_GIVEREF(__pyx_v_out_stderr);
11421 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_out_stderr)) __PYX_ERR(0, 434, __pyx_L1_error);
11422 __Pyx_INCREF(__pyx_v_out_stdout);
11423 __Pyx_GIVEREF(__pyx_v_out_stdout);
11424 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_out_stdout)) __PYX_ERR(0, 434, __pyx_L1_error);
11425 __pyx_t_3 = 0;
11426 __pyx_r = __pyx_t_6;
11427 __pyx_t_6 = 0;
11428 goto __pyx_L0;
11429
11430 /* "pysam/libcutils.pyx":276
11431 *
11432 *
11433 * def _pysam_dispatch(collection, # <<<<<<<<<<<<<<
11434 * method,
11435 * args=None,
11436 */
11437
11438 /* function exit code */
11439 __pyx_L1_error:;
11440 __Pyx_XDECREF(__pyx_t_3);
11441 __Pyx_XDECREF(__pyx_t_6);
11442 __Pyx_XDECREF(__pyx_t_7);
11443 __Pyx_XDECREF(__pyx_t_8);
11444 __Pyx_XDECREF(__pyx_t_15);
11445 __Pyx_XDECREF(__pyx_t_16);
11446 __Pyx_AddTraceback("pysam.libcutils._pysam_dispatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
11447 __pyx_r = NULL;
11448 __pyx_L0:;
11449 __Pyx_XDECREF(__pyx_v_ARGUMENTS);
11450 __Pyx_XDECREF(__pyx_v_arg);
11451 __Pyx_XDECREF(__pyx_v_stderr_h);
11452 __Pyx_XDECREF(__pyx_v_stderr_f);
11453 __Pyx_XDECREF(__pyx_v_stdout_f);
11454 __Pyx_XDECREF(__pyx_v_stdout_h);
11455 __Pyx_XDECREF(__pyx_v_MAP_STDOUT_OPTIONS);
11456 __Pyx_XDECREF(__pyx_v_stdout_option);
11457 __Pyx_XDECREF(__pyx_v__collect);
11458 __Pyx_XDECREF(__pyx_v_out_stderr);
11459 __Pyx_XDECREF(__pyx_v_out_stdout);
11460 __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_a);
11461 __Pyx_XDECREF(__pyx_v_collection);
11462 __Pyx_XDECREF(__pyx_v_method);
11463 __Pyx_XDECREF(__pyx_v_args);
11464 __Pyx_XGIVEREF(__pyx_r);
11465 __Pyx_RefNannyFinishContext();
11466 return __pyx_r;
11467 }
11468
11469 static PyMethodDef __pyx_methods[] = {
11470 {0, 0, 0, 0}
11471 };
11472 #ifndef CYTHON_SMALL_CODE
11473 #if defined(__clang__)
11474 #define CYTHON_SMALL_CODE
11475 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
11476 #define CYTHON_SMALL_CODE __attribute__((cold))
11477 #else
11478 #define CYTHON_SMALL_CODE
11479 #endif
11480 #endif
11481 /* #### Code section: pystring_table ### */
11482
11483 static int __Pyx_CreateStringTabAndInitStrings(void) {
11484 __Pyx_StringTabEntry __pyx_string_tab[] = {
11485 {&__pyx_kp_u_, __pyx_k_, sizeof(__pyx_k_), 0, 1, 0, 0},
11486 {&__pyx_n_s_ARGUMENTS, __pyx_k_ARGUMENTS, sizeof(__pyx_k_ARGUMENTS), 0, 0, 1, 1},
11487 {&__pyx_kp_u_Argument_must_be_string_bytes_or, __pyx_k_Argument_must_be_string_bytes_or, sizeof(__pyx_k_Argument_must_be_string_bytes_or), 0, 1, 0, 0},
11488 {&__pyx_n_u_B, __pyx_k_B, sizeof(__pyx_k_B), 0, 1, 0, 1},
11489 {&__pyx_n_s_IOError, __pyx_k_IOError, sizeof(__pyx_k_IOError), 0, 0, 1, 1},
11490 {&__pyx_n_s_MAP_STDOUT_OPTIONS, __pyx_k_MAP_STDOUT_OPTIONS, sizeof(__pyx_k_MAP_STDOUT_OPTIONS), 0, 0, 1, 1},
11491 {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
11492 {&__pyx_kp_u_No_such_file_or_directory_s, __pyx_k_No_such_file_or_directory_s, sizeof(__pyx_k_No_such_file_or_directory_s), 0, 1, 0, 0},
11493 {&__pyx_n_s_OSError, __pyx_k_OSError, sizeof(__pyx_k_OSError), 0, 0, 1, 1},
11494 {&__pyx_n_s_OverflowError, __pyx_k_OverflowError, sizeof(__pyx_k_OverflowError), 0, 0, 1, 1},
11495 {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
11496 {&__pyx_n_s_UnicodeDecodeError, __pyx_k_UnicodeDecodeError, sizeof(__pyx_k_UnicodeDecodeError), 0, 0, 1, 1},
11497 {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
11498 {&__pyx_kp_u__10, __pyx_k__10, sizeof(__pyx_k__10), 0, 1, 0, 0},
11499 {&__pyx_kp_u__11, __pyx_k__11, sizeof(__pyx_k__11), 0, 1, 0, 0},
11500 {&__pyx_n_s__14, __pyx_k__14, sizeof(__pyx_k__14), 0, 0, 1, 1},
11501 {&__pyx_kp_u__15, __pyx_k__15, sizeof(__pyx_k__15), 0, 1, 0, 0},
11502 {&__pyx_n_s__33, __pyx_k__33, sizeof(__pyx_k__33), 0, 0, 1, 1},
11503 {&__pyx_kp_u__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 1, 0, 0},
11504 {&__pyx_kp_u__8, __pyx_k__8, sizeof(__pyx_k__8), 0, 1, 0, 0},
11505 {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
11506 {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
11507 {&__pyx_n_s_arg, __pyx_k_arg, sizeof(__pyx_k_arg), 0, 0, 1, 1},
11508 {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
11509 {&__pyx_n_s_array_to_qualitystring, __pyx_k_array_to_qualitystring, sizeof(__pyx_k_array_to_qualitystring), 0, 0, 1, 1},
11510 {&__pyx_n_u_array_to_qualitystring, __pyx_k_array_to_qualitystring, sizeof(__pyx_k_array_to_qualitystring), 0, 1, 0, 1},
11511 {&__pyx_n_u_ascii, __pyx_k_ascii, sizeof(__pyx_k_ascii), 0, 1, 0, 1},
11512 {&__pyx_n_s_asyncio_coroutines, __pyx_k_asyncio_coroutines, sizeof(__pyx_k_asyncio_coroutines), 0, 0, 1, 1},
11513 {&__pyx_n_b_bcftools, __pyx_k_bcftools, sizeof(__pyx_k_bcftools), 0, 0, 0, 1},
11514 {&__pyx_n_u_bcftools, __pyx_k_bcftools, sizeof(__pyx_k_bcftools), 0, 1, 0, 1},
11515 {&__pyx_kp_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 0},
11516 {&__pyx_n_u_calmd, __pyx_k_calmd, sizeof(__pyx_k_calmd), 0, 1, 0, 1},
11517 {&__pyx_n_s_cargs, __pyx_k_cargs, sizeof(__pyx_k_cargs), 0, 0, 1, 1},
11518 {&__pyx_n_s_catch_stdout, __pyx_k_catch_stdout, sizeof(__pyx_k_catch_stdout), 0, 0, 1, 1},
11519 {&__pyx_n_s_chr, __pyx_k_chr, sizeof(__pyx_k_chr), 0, 0, 1, 1},
11520 {&__pyx_n_s_class_getitem, __pyx_k_class_getitem, sizeof(__pyx_k_class_getitem), 0, 0, 1, 1},
11521 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
11522 {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
11523 {&__pyx_n_s_codecs, __pyx_k_codecs, sizeof(__pyx_k_codecs), 0, 0, 1, 1},
11524 {&__pyx_n_s_collect, __pyx_k_collect, sizeof(__pyx_k_collect), 0, 0, 1, 1},
11525 {&__pyx_n_s_collection, __pyx_k_collection, sizeof(__pyx_k_collection), 0, 0, 1, 1},
11526 {&__pyx_n_s_contextlib, __pyx_k_contextlib, sizeof(__pyx_k_contextlib), 0, 0, 1, 1},
11527 {&__pyx_n_s_contextmanager, __pyx_k_contextmanager, sizeof(__pyx_k_contextmanager), 0, 0, 1, 1},
11528 {&__pyx_n_s_contig, __pyx_k_contig, sizeof(__pyx_k_contig), 0, 0, 1, 1},
11529 {&__pyx_kp_u_contig_and_reference_should_not, __pyx_k_contig_and_reference_should_not, sizeof(__pyx_k_contig_and_reference_should_not), 0, 1, 0, 0},
11530 {&__pyx_kp_u_contig_reference_and_region_shou, __pyx_k_contig_reference_and_region_shou, sizeof(__pyx_k_contig_reference_and_region_shou), 0, 1, 0, 0},
11531 {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1},
11532 {&__pyx_n_u_depad, __pyx_k_depad, sizeof(__pyx_k_depad), 0, 1, 0, 1},
11533 {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
11534 {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
11535 {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
11536 {&__pyx_kp_u_error_while_opening_file_for_wri, __pyx_k_error_while_opening_file_for_wri, sizeof(__pyx_k_error_while_opening_file_for_wri), 0, 1, 0, 0},
11537 {&__pyx_n_s_exception, __pyx_k_exception, sizeof(__pyx_k_exception), 0, 0, 1, 1},
11538 {&__pyx_n_s_exists, __pyx_k_exists, sizeof(__pyx_k_exists), 0, 0, 1, 1},
11539 {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
11540 {&__pyx_n_s_extend, __pyx_k_extend, sizeof(__pyx_k_extend), 0, 0, 1, 1},
11541 {&__pyx_n_s_extra_args, __pyx_k_extra_args, sizeof(__pyx_k_extra_args), 0, 0, 1, 1},
11542 {&__pyx_n_s_fn, __pyx_k_fn, sizeof(__pyx_k_fn), 0, 0, 1, 1},
11543 {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
11544 {&__pyx_n_s_fsencode, __pyx_k_fsencode, sizeof(__pyx_k_fsencode), 0, 0, 1, 1},
11545 {&__pyx_n_s_get_encoding_error_handler, __pyx_k_get_encoding_error_handler, sizeof(__pyx_k_get_encoding_error_handler), 0, 0, 1, 1},
11546 {&__pyx_n_u_get_encoding_error_handler, __pyx_k_get_encoding_error_handler, sizeof(__pyx_k_get_encoding_error_handler), 0, 1, 0, 1},
11547 {&__pyx_n_s_getdefaultencoding, __pyx_k_getdefaultencoding, sizeof(__pyx_k_getdefaultencoding), 0, 0, 1, 1},
11548 {&__pyx_n_s_getfilesystemencoding, __pyx_k_getfilesystemencoding, sizeof(__pyx_k_getfilesystemencoding), 0, 0, 1, 1},
11549 {&__pyx_n_u_head, __pyx_k_head, sizeof(__pyx_k_head), 0, 1, 0, 1},
11550 {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
11551 {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
11552 {&__pyx_n_b_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 0, 1},
11553 {&__pyx_n_u_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 1, 0, 1},
11554 {&__pyx_n_s_inf, __pyx_k_inf, sizeof(__pyx_k_inf), 0, 0, 1, 1},
11555 {&__pyx_n_s_initializing, __pyx_k_initializing, sizeof(__pyx_k_initializing), 0, 0, 1, 1},
11556 {&__pyx_n_s_input_str, __pyx_k_input_str, sizeof(__pyx_k_input_str), 0, 0, 1, 1},
11557 {&__pyx_kp_u_invalid_coordinates_start_i_stop, __pyx_k_invalid_coordinates_start_i_stop, sizeof(__pyx_k_invalid_coordinates_start_i_stop), 0, 1, 0, 0},
11558 {&__pyx_n_s_io, __pyx_k_io, sizeof(__pyx_k_io), 0, 0, 1, 1},
11559 {&__pyx_n_s_is_coroutine, __pyx_k_is_coroutine, sizeof(__pyx_k_is_coroutine), 0, 0, 1, 1},
11560 {&__pyx_n_s_is_usage, __pyx_k_is_usage, sizeof(__pyx_k_is_usage), 0, 0, 1, 1},
11561 {&__pyx_n_s_l, __pyx_k_l, sizeof(__pyx_k_l), 0, 0, 1, 1},
11562 {&__pyx_n_s_latin1_replace, __pyx_k_latin1_replace, sizeof(__pyx_k_latin1_replace), 0, 0, 1, 1},
11563 {&__pyx_kp_u_m, __pyx_k_m, sizeof(__pyx_k_m), 0, 1, 0, 0},
11564 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
11565 {&__pyx_n_s_method, __pyx_k_method, sizeof(__pyx_k_method), 0, 0, 1, 1},
11566 {&__pyx_kp_u_min_shift, __pyx_k_min_shift, sizeof(__pyx_k_min_shift), 0, 1, 0, 0},
11567 {&__pyx_n_s_mkstemp, __pyx_k_mkstemp, sizeof(__pyx_k_mkstemp), 0, 0, 1, 1},
11568 {&__pyx_n_u_mpileup, __pyx_k_mpileup, sizeof(__pyx_k_mpileup), 0, 1, 0, 1},
11569 {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1},
11570 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
11571 {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
11572 {&__pyx_kp_u_neither_contig_nor_region_are_gi, __pyx_k_neither_contig_nor_region_are_gi, sizeof(__pyx_k_neither_contig_nor_region_are_gi), 0, 1, 0, 0},
11573 {&__pyx_kp_u_o, __pyx_k_o, sizeof(__pyx_k_o), 0, 1, 0, 0},
11574 {&__pyx_kp_u_o_2, __pyx_k_o_2, sizeof(__pyx_k_o_2), 0, 1, 0, 0},
11575 {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
11576 {&__pyx_n_s_offset, __pyx_k_offset, sizeof(__pyx_k_offset), 0, 0, 1, 1},
11577 {&__pyx_n_s_open, __pyx_k_open, sizeof(__pyx_k_open), 0, 0, 1, 1},
11578 {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
11579 {&__pyx_n_s_out, __pyx_k_out, sizeof(__pyx_k_out), 0, 0, 1, 1},
11580 {&__pyx_n_s_out_stderr, __pyx_k_out_stderr, sizeof(__pyx_k_out_stderr), 0, 0, 1, 1},
11581 {&__pyx_n_s_out_stdout, __pyx_k_out_stdout, sizeof(__pyx_k_out_stdout), 0, 0, 1, 1},
11582 {&__pyx_kp_u_output, __pyx_k_output, sizeof(__pyx_k_output), 0, 1, 0, 0},
11583 {&__pyx_kp_u_output_file, __pyx_k_output_file, sizeof(__pyx_k_output_file), 0, 1, 0, 0},
11584 {&__pyx_n_s_parse_region, __pyx_k_parse_region, sizeof(__pyx_k_parse_region), 0, 0, 1, 1},
11585 {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1},
11586 {&__pyx_n_s_pysam_dispatch, __pyx_k_pysam_dispatch, sizeof(__pyx_k_pysam_dispatch), 0, 0, 1, 1},
11587 {&__pyx_n_s_pysam_dispatch_locals__collect, __pyx_k_pysam_dispatch_locals__collect, sizeof(__pyx_k_pysam_dispatch_locals__collect), 0, 0, 1, 1},
11588 {&__pyx_kp_u_pysam_latin1replace, __pyx_k_pysam_latin1replace, sizeof(__pyx_k_pysam_latin1replace), 0, 1, 0, 0},
11589 {&__pyx_n_s_pysam_libcutils, __pyx_k_pysam_libcutils, sizeof(__pyx_k_pysam_libcutils), 0, 0, 1, 1},
11590 {&__pyx_kp_s_pysam_libcutils_pyx, __pyx_k_pysam_libcutils_pyx, sizeof(__pyx_k_pysam_libcutils_pyx), 0, 0, 1, 0},
11591 {&__pyx_n_s_qualities, __pyx_k_qualities, sizeof(__pyx_k_qualities), 0, 0, 1, 1},
11592 {&__pyx_n_s_qualities_to_qualitystring, __pyx_k_qualities_to_qualitystring, sizeof(__pyx_k_qualities_to_qualitystring), 0, 0, 1, 1},
11593 {&__pyx_n_u_qualities_to_qualitystring, __pyx_k_qualities_to_qualitystring, sizeof(__pyx_k_qualities_to_qualitystring), 0, 1, 0, 1},
11594 {&__pyx_n_s_qualitystring_to_array, __pyx_k_qualitystring_to_array, sizeof(__pyx_k_qualitystring_to_array), 0, 0, 1, 1},
11595 {&__pyx_n_u_qualitystring_to_array, __pyx_k_qualitystring_to_array, sizeof(__pyx_k_qualitystring_to_array), 0, 1, 0, 1},
11596 {&__pyx_n_u_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 1, 0, 1},
11597 {&__pyx_n_u_rb, __pyx_k_rb, sizeof(__pyx_k_rb), 0, 1, 0, 1},
11598 {&__pyx_n_s_re, __pyx_k_re, sizeof(__pyx_k_re), 0, 0, 1, 1},
11599 {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1},
11600 {&__pyx_n_s_reference, __pyx_k_reference, sizeof(__pyx_k_reference), 0, 0, 1, 1},
11601 {&__pyx_n_s_region, __pyx_k_region, sizeof(__pyx_k_region), 0, 0, 1, 1},
11602 {&__pyx_n_s_register_error, __pyx_k_register_error, sizeof(__pyx_k_register_error), 0, 0, 1, 1},
11603 {&__pyx_n_s_remove, __pyx_k_remove, sizeof(__pyx_k_remove), 0, 0, 1, 1},
11604 {&__pyx_n_s_retval, __pyx_k_retval, sizeof(__pyx_k_retval), 0, 0, 1, 1},
11605 {&__pyx_n_u_roh, __pyx_k_roh, sizeof(__pyx_k_roh), 0, 1, 0, 1},
11606 {&__pyx_n_b_samtools, __pyx_k_samtools, sizeof(__pyx_k_samtools), 0, 0, 0, 1},
11607 {&__pyx_n_u_samtools, __pyx_k_samtools, sizeof(__pyx_k_samtools), 0, 1, 0, 1},
11608 {&__pyx_n_s_save_stdout, __pyx_k_save_stdout, sizeof(__pyx_k_save_stdout), 0, 0, 1, 1},
11609 {&__pyx_n_s_set_encoding_error_handler, __pyx_k_set_encoding_error_handler, sizeof(__pyx_k_set_encoding_error_handler), 0, 0, 1, 1},
11610 {&__pyx_n_u_set_encoding_error_handler, __pyx_k_set_encoding_error_handler, sizeof(__pyx_k_set_encoding_error_handler), 0, 1, 0, 1},
11611 {&__pyx_n_s_skip_next, __pyx_k_skip_next, sizeof(__pyx_k_skip_next), 0, 0, 1, 1},
11612 {&__pyx_n_s_spec, __pyx_k_spec, sizeof(__pyx_k_spec), 0, 0, 1, 1},
11613 {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
11614 {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
11615 {&__pyx_kp_u_start_out_of_range_i, __pyx_k_start_out_of_range_i, sizeof(__pyx_k_start_out_of_range_i), 0, 1, 0, 0},
11616 {&__pyx_n_s_startswith, __pyx_k_startswith, sizeof(__pyx_k_startswith), 0, 0, 1, 1},
11617 {&__pyx_n_u_stats, __pyx_k_stats, sizeof(__pyx_k_stats), 0, 1, 0, 1},
11618 {&__pyx_n_s_stderr_f, __pyx_k_stderr_f, sizeof(__pyx_k_stderr_f), 0, 0, 1, 1},
11619 {&__pyx_n_s_stderr_h, __pyx_k_stderr_h, sizeof(__pyx_k_stderr_h), 0, 0, 1, 1},
11620 {&__pyx_n_s_stdout_f, __pyx_k_stdout_f, sizeof(__pyx_k_stdout_f), 0, 0, 1, 1},
11621 {&__pyx_n_s_stdout_h, __pyx_k_stdout_h, sizeof(__pyx_k_stdout_h), 0, 0, 1, 1},
11622 {&__pyx_n_s_stdout_option, __pyx_k_stdout_option, sizeof(__pyx_k_stdout_option), 0, 0, 1, 1},
11623 {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
11624 {&__pyx_kp_u_stop_and_end_should_not_both_be, __pyx_k_stop_and_end_should_not_both_be, sizeof(__pyx_k_stop_and_end_should_not_both_be), 0, 1, 0, 0},
11625 {&__pyx_kp_u_stop_out_of_range_i, __pyx_k_stop_out_of_range_i, sizeof(__pyx_k_stop_out_of_range_i), 0, 1, 0, 0},
11626 {&__pyx_n_u_strict, __pyx_k_strict, sizeof(__pyx_k_strict), 0, 1, 0, 1},
11627 {&__pyx_n_s_string, __pyx_k_string, sizeof(__pyx_k_string), 0, 0, 1, 1},
11628 {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
11629 {&__pyx_n_s_tempfile, __pyx_k_tempfile, sizeof(__pyx_k_tempfile), 0, 0, 1, 1},
11630 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
11631 {&__pyx_kp_u_threads, __pyx_k_threads, sizeof(__pyx_k_threads), 0, 1, 0, 0},
11632 {&__pyx_n_s_tobytes, __pyx_k_tobytes, sizeof(__pyx_k_tobytes), 0, 0, 1, 1},
11633 {&__pyx_n_s_types, __pyx_k_types, sizeof(__pyx_k_types), 0, 0, 1, 1},
11634 {&__pyx_kp_u_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 1, 0, 0},
11635 {&__pyx_n_u_view, __pyx_k_view, sizeof(__pyx_k_view), 0, 1, 0, 1},
11636 {0, 0, 0, 0, 0, 0, 0}
11637 };
11638 return __Pyx_InitStrings(__pyx_string_tab);
11639 }
11640 /* #### Code section: cached_builtins ### */
11641 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
11642 __pyx_builtin_chr = __Pyx_GetBuiltinName(__pyx_n_s_chr); if (!__pyx_builtin_chr) __PYX_ERR(0, 82, __pyx_L1_error)
11643 __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 136, __pyx_L1_error)
11644 __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 218, __pyx_L1_error)
11645 __pyx_builtin_OverflowError = __Pyx_GetBuiltinName(__pyx_n_s_OverflowError); if (!__pyx_builtin_OverflowError) __PYX_ERR(0, 237, __pyx_L1_error)
11646 __pyx_builtin_IOError = __Pyx_GetBuiltinName(__pyx_n_s_IOError); if (!__pyx_builtin_IOError) __PYX_ERR(0, 309, __pyx_L1_error)
11647 __pyx_builtin_OSError = __Pyx_GetBuiltinName(__pyx_n_s_OSError); if (!__pyx_builtin_OSError) __PYX_ERR(0, 327, __pyx_L1_error)
11648 __pyx_builtin_open = __Pyx_GetBuiltinName(__pyx_n_s_open); if (!__pyx_builtin_open) __PYX_ERR(0, 416, __pyx_L1_error)
11649 __pyx_builtin_UnicodeDecodeError = __Pyx_GetBuiltinName(__pyx_n_s_UnicodeDecodeError); if (!__pyx_builtin_UnicodeDecodeError) __PYX_ERR(0, 418, __pyx_L1_error)
11650 __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(2, 120, __pyx_L1_error)
11651 return 0;
11652 __pyx_L1_error:;
11653 return -1;
11654 }
11655 /* #### Code section: cached_constants ### */
11656
11657 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
11658 __Pyx_RefNannyDeclarations
11659 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
11660
11661 /* "pysam/libcutils.pyx":136
11662 * return s.encode(encoding or TEXT_ENCODING, errors or ERROR_HANDLER)
11663 * else:
11664 * raise TypeError("Argument must be string, bytes or unicode.") # <<<<<<<<<<<<<<
11665 *
11666 *
11667 */
11668 __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_Argument_must_be_string_bytes_or); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 136, __pyx_L1_error)
11669 __Pyx_GOTREF(__pyx_tuple__2);
11670 __Pyx_GIVEREF(__pyx_tuple__2);
11671
11672 /* "pysam/libcutils.pyx":218
11673 * if reference is not None:
11674 * if contig is not None:
11675 * raise ValueError('contig and reference should not both be specified') # <<<<<<<<<<<<<<
11676 * contig = reference
11677 *
11678 */
11679 __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_contig_and_reference_should_not); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 218, __pyx_L1_error)
11680 __Pyx_GOTREF(__pyx_tuple__3);
11681 __Pyx_GIVEREF(__pyx_tuple__3);
11682
11683 /* "pysam/libcutils.pyx":222
11684 *
11685 * if contig is not None and region is not None:
11686 * raise ValueError('contig/reference and region should not both be specified') # <<<<<<<<<<<<<<
11687 *
11688 * if end is not None:
11689 */
11690 __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_contig_reference_and_region_shou); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 222, __pyx_L1_error)
11691 __Pyx_GOTREF(__pyx_tuple__4);
11692 __Pyx_GIVEREF(__pyx_tuple__4);
11693
11694 /* "pysam/libcutils.pyx":226
11695 * if end is not None:
11696 * if stop is not None:
11697 * raise ValueError('stop and end should not both be specified') # <<<<<<<<<<<<<<
11698 * stop = end
11699 *
11700 */
11701 __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_stop_and_end_should_not_both_be); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 226, __pyx_L1_error)
11702 __Pyx_GOTREF(__pyx_tuple__5);
11703 __Pyx_GIVEREF(__pyx_tuple__5);
11704
11705 /* "pysam/libcutils.pyx":230
11706 *
11707 * if contig is None and region is None:
11708 * raise ValueError("neither contig nor region are given") # <<<<<<<<<<<<<<
11709 *
11710 * rstart = 0
11711 */
11712 __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_neither_contig_nor_region_are_gi); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 230, __pyx_L1_error)
11713 __Pyx_GOTREF(__pyx_tuple__6);
11714 __Pyx_GIVEREF(__pyx_tuple__6);
11715
11716 /* "pysam/libcutils.pyx":416
11717 * out = []
11718 * try:
11719 * with open(fn, "r") as inf: # <<<<<<<<<<<<<<
11720 * out = inf.read()
11721 * except UnicodeDecodeError:
11722 */
11723 __pyx_tuple__9 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 416, __pyx_L1_error)
11724 __Pyx_GOTREF(__pyx_tuple__9);
11725 __Pyx_GIVEREF(__pyx_tuple__9);
11726
11727 /* "pysam/libcutils.pyx":413
11728 *
11729 * # get error messages
11730 * def _collect(fn): # <<<<<<<<<<<<<<
11731 * out = []
11732 * try:
11733 */
11734 __pyx_tuple__12 = PyTuple_Pack(3, __pyx_n_s_fn, __pyx_n_s_out, __pyx_n_s_inf); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 413, __pyx_L1_error)
11735 __Pyx_GOTREF(__pyx_tuple__12);
11736 __Pyx_GIVEREF(__pyx_tuple__12);
11737 __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__12, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pysam_libcutils_pyx, __pyx_n_s_collect, 413, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 413, __pyx_L1_error)
11738
11739 /* "pysam/libcutils.pyx":36
11740 * #################################################################
11741 * # Utility functions for quality string conversions
11742 * cpdef c_array.array qualitystring_to_array(input_str, int offset=33): # <<<<<<<<<<<<<<
11743 * """convert a qualitystring to an array of quality values."""
11744 * if input_str is None:
11745 */
11746 __pyx_tuple__16 = PyTuple_Pack(2, __pyx_n_s_input_str, __pyx_n_s_offset); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 36, __pyx_L1_error)
11747 __Pyx_GOTREF(__pyx_tuple__16);
11748 __Pyx_GIVEREF(__pyx_tuple__16);
11749 __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 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_pysam_libcutils_pyx, __pyx_n_s_qualitystring_to_array, 36, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 36, __pyx_L1_error)
11750 __pyx_tuple__18 = PyTuple_Pack(1, __pyx_int_33); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 36, __pyx_L1_error)
11751 __Pyx_GOTREF(__pyx_tuple__18);
11752 __Pyx_GIVEREF(__pyx_tuple__18);
11753
11754 /* "pysam/libcutils.pyx":45
11755 *
11756 *
11757 * cpdef array_to_qualitystring(c_array.array qualities, int offset=33): # <<<<<<<<<<<<<<
11758 * """convert an array of quality values to a string."""
11759 * if qualities is None:
11760 */
11761 __pyx_tuple__19 = PyTuple_Pack(2, __pyx_n_s_qualities, __pyx_n_s_offset); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 45, __pyx_L1_error)
11762 __Pyx_GOTREF(__pyx_tuple__19);
11763 __Pyx_GIVEREF(__pyx_tuple__19);
11764 __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pysam_libcutils_pyx, __pyx_n_s_array_to_qualitystring, 45, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 45, __pyx_L1_error)
11765
11766 /* "pysam/libcutils.pyx":59
11767 *
11768 *
11769 * cpdef qualities_to_qualitystring(qualities, int offset=33): # <<<<<<<<<<<<<<
11770 * """convert a list or array of quality scores to the string
11771 * representation used in the SAM format.
11772 */
11773 __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pysam_libcutils_pyx, __pyx_n_s_qualities_to_qualitystring, 59, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 59, __pyx_L1_error)
11774
11775 /* "pysam/libcutils.pyx":90
11776 *
11777 * # Codec error handler that just interprets each bad byte as ISO-8859-1.
11778 * def latin1_replace(exception): # <<<<<<<<<<<<<<
11779 * return (chr(exception.object[exception.start]), exception.end)
11780 *
11781 */
11782 __pyx_tuple__22 = PyTuple_Pack(1, __pyx_n_s_exception); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 90, __pyx_L1_error)
11783 __Pyx_GOTREF(__pyx_tuple__22);
11784 __Pyx_GIVEREF(__pyx_tuple__22);
11785 __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pysam_libcutils_pyx, __pyx_n_s_latin1_replace, 90, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 90, __pyx_L1_error)
11786
11787 /* "pysam/libcutils.pyx":98
11788 * cdef str ERROR_HANDLER = 'strict'
11789 *
11790 * cpdef get_encoding_error_handler(): # <<<<<<<<<<<<<<
11791 * return ERROR_HANDLER
11792 *
11793 */
11794 __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pysam_libcutils_pyx, __pyx_n_s_get_encoding_error_handler, 98, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 98, __pyx_L1_error)
11795
11796 /* "pysam/libcutils.pyx":101
11797 * return ERROR_HANDLER
11798 *
11799 * cpdef set_encoding_error_handler(name): # <<<<<<<<<<<<<<
11800 * global ERROR_HANDLER
11801 * previous = ERROR_HANDLER
11802 */
11803 __pyx_tuple__25 = PyTuple_Pack(1, __pyx_n_s_name); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 101, __pyx_L1_error)
11804 __Pyx_GOTREF(__pyx_tuple__25);
11805 __Pyx_GIVEREF(__pyx_tuple__25);
11806 __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pysam_libcutils_pyx, __pyx_n_s_set_encoding_error_handler, 101, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 101, __pyx_L1_error)
11807
11808 /* "pysam/libcutils.pyx":178
11809 *
11810 *
11811 * cpdef parse_region(contig=None, # <<<<<<<<<<<<<<
11812 * start=None,
11813 * stop=None,
11814 */
11815 __pyx_tuple__27 = PyTuple_Pack(6, __pyx_n_s_contig, __pyx_n_s_start, __pyx_n_s_stop, __pyx_n_s_region, __pyx_n_s_reference, __pyx_n_s_end); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 178, __pyx_L1_error)
11816 __Pyx_GOTREF(__pyx_tuple__27);
11817 __Pyx_GIVEREF(__pyx_tuple__27);
11818 __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(6, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pysam_libcutils_pyx, __pyx_n_s_parse_region, 178, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 178, __pyx_L1_error)
11819 __pyx_tuple__29 = PyTuple_Pack(6, Py_None, Py_None, Py_None, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 178, __pyx_L1_error)
11820 __Pyx_GOTREF(__pyx_tuple__29);
11821 __Pyx_GIVEREF(__pyx_tuple__29);
11822
11823 /* "pysam/libcutils.pyx":276
11824 *
11825 *
11826 * def _pysam_dispatch(collection, # <<<<<<<<<<<<<<
11827 * method,
11828 * args=None,
11829 */
11830 __pyx_tuple__30 = PyTuple_Pack(26, __pyx_n_s_collection, __pyx_n_s_method, __pyx_n_s_args, __pyx_n_s_catch_stdout, __pyx_n_s_is_usage, __pyx_n_s_save_stdout, __pyx_n_s_ARGUMENTS, __pyx_n_s_skip_next, __pyx_n_s_arg, __pyx_n_s_stderr_h, __pyx_n_s_stderr_f, __pyx_n_s_stdout_f, __pyx_n_s_stdout_h, __pyx_n_s_MAP_STDOUT_OPTIONS, __pyx_n_s_stdout_option, __pyx_n_s_cargs, __pyx_n_s_i, __pyx_n_s_n, __pyx_n_s_retval, __pyx_n_s_l, __pyx_n_s_extra_args, __pyx_n_s_collect, __pyx_n_s_collect, __pyx_n_s_out_stderr, __pyx_n_s_out_stdout, __pyx_n_s_a); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 276, __pyx_L1_error)
11831 __Pyx_GOTREF(__pyx_tuple__30);
11832 __Pyx_GIVEREF(__pyx_tuple__30);
11833 __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(6, 0, 0, 26, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pysam_libcutils_pyx, __pyx_n_s_pysam_dispatch, 276, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 276, __pyx_L1_error)
11834 __pyx_tuple__32 = PyTuple_Pack(4, Py_None, ((PyObject *)Py_True), ((PyObject *)Py_False), Py_None); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 276, __pyx_L1_error)
11835 __Pyx_GOTREF(__pyx_tuple__32);
11836 __Pyx_GIVEREF(__pyx_tuple__32);
11837 __Pyx_RefNannyFinishContext();
11838 return 0;
11839 __pyx_L1_error:;
11840 __Pyx_RefNannyFinishContext();
11841 return -1;
11842 }
11843 /* #### Code section: init_constants ### */
11844
11845 static CYTHON_SMALL_CODE int __Pyx_InitConstants(void) {
11846 if (__Pyx_CreateStringTabAndInitStrings() < 0) __PYX_ERR(0, 1, __pyx_L1_error);
11847 __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
11848 __pyx_int_33 = PyInt_FromLong(33); if (unlikely(!__pyx_int_33)) __PYX_ERR(0, 1, __pyx_L1_error)
11849 __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
11850 return 0;
11851 __pyx_L1_error:;
11852 return -1;
11853 }
11854 /* #### Code section: init_globals ### */
11855
11856 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
11857 return 0;
11858 }
11859 /* #### Code section: init_module ### */
11860
11861 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
11862 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
11863 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
11864 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
11865 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
11866 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
11867 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
11868
11869 static int __Pyx_modinit_global_init_code(void) {
11870 __Pyx_RefNannyDeclarations
11871 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
11872 /*--- Global init code ---*/
11873 __pyx_v_5pysam_9libcutils_ERROR_HANDLER = ((PyObject*)Py_None); Py_INCREF(Py_None);
11874 __pyx_v_5pysam_9libcutils_FILENAME_ENCODING = ((PyObject*)Py_None); Py_INCREF(Py_None);
11875 __pyx_v_5pysam_9libcutils_TEXT_ENCODING = ((PyObject*)Py_None); Py_INCREF(Py_None);
11876 __Pyx_RefNannyFinishContext();
11877 return 0;
11878 }
11879
11880 static int __Pyx_modinit_variable_export_code(void) {
11881 __Pyx_RefNannyDeclarations
11882 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
11883 /*--- Variable export code ---*/
11884 __Pyx_RefNannyFinishContext();
11885 return 0;
11886 }
11887
11888 static int __Pyx_modinit_function_export_code(void) {
11889 __Pyx_RefNannyDeclarations
11890 int __pyx_lineno = 0;
11891 const char *__pyx_filename = NULL;
11892 int __pyx_clineno = 0;
11893 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
11894 /*--- Function export code ---*/
11895 if (__Pyx_ExportFunction("parse_region", (void (*)(void))__pyx_f_5pysam_9libcutils_parse_region, "PyObject *(int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_9libcutils_parse_region *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11896 if (__Pyx_ExportFunction("libc_whence_from_io", (void (*)(void))__pyx_f_5pysam_9libcutils_libc_whence_from_io, "int (int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11897 if (__Pyx_ExportFunction("qualitystring_to_array", (void (*)(void))__pyx_f_5pysam_9libcutils_qualitystring_to_array, "arrayobject *(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_9libcutils_qualitystring_to_array *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11898 if (__Pyx_ExportFunction("array_to_qualitystring", (void (*)(void))__pyx_f_5pysam_9libcutils_array_to_qualitystring, "PyObject *(arrayobject *, int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_9libcutils_array_to_qualitystring *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11899 if (__Pyx_ExportFunction("qualities_to_qualitystring", (void (*)(void))__pyx_f_5pysam_9libcutils_qualities_to_qualitystring, "PyObject *(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_9libcutils_qualities_to_qualitystring *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11900 if (__Pyx_ExportFunction("get_encoding_error_handler", (void (*)(void))__pyx_f_5pysam_9libcutils_get_encoding_error_handler, "PyObject *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11901 if (__Pyx_ExportFunction("set_encoding_error_handler", (void (*)(void))__pyx_f_5pysam_9libcutils_set_encoding_error_handler, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11902 if (__Pyx_ExportFunction("charptr_to_str", (void (*)(void))__pyx_f_5pysam_9libcutils_charptr_to_str, "PyObject *(char const *, struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11903 if (__Pyx_ExportFunction("charptr_to_bytes", (void (*)(void))__pyx_f_5pysam_9libcutils_charptr_to_bytes, "PyObject *(char const *, struct __pyx_opt_args_5pysam_9libcutils_charptr_to_bytes *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11904 if (__Pyx_ExportFunction("charptr_to_str_w_len", (void (*)(void))__pyx_f_5pysam_9libcutils_charptr_to_str_w_len, "PyObject *(char const *, size_t, struct __pyx_opt_args_5pysam_9libcutils_charptr_to_str_w_len *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11905 if (__Pyx_ExportFunction("force_str", (void (*)(void))__pyx_f_5pysam_9libcutils_force_str, "PyObject *(PyObject *, struct __pyx_opt_args_5pysam_9libcutils_force_str *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11906 if (__Pyx_ExportFunction("force_bytes", (void (*)(void))__pyx_f_5pysam_9libcutils_force_bytes, "PyObject *(PyObject *, struct __pyx_opt_args_5pysam_9libcutils_force_bytes *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11907 if (__Pyx_ExportFunction("decode_bytes", (void (*)(void))__pyx_f_5pysam_9libcutils_decode_bytes, "PyObject *(PyObject *, struct __pyx_opt_args_5pysam_9libcutils_decode_bytes *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11908 if (__Pyx_ExportFunction("encode_filename", (void (*)(void))__pyx_f_5pysam_9libcutils_encode_filename, "PyObject *(PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11909 if (__Pyx_ExportFunction("from_string_and_size", (void (*)(void))__pyx_f_5pysam_9libcutils_from_string_and_size, "PyObject *(char const *, size_t)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
11910 __Pyx_RefNannyFinishContext();
11911 return 0;
11912 __pyx_L1_error:;
11913 __Pyx_RefNannyFinishContext();
11914 return -1;
11915 }
11916
11917 static int __Pyx_modinit_type_init_code(void) {
11918 __Pyx_RefNannyDeclarations
11919 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
11920 /*--- Type init code ---*/
11921 __Pyx_RefNannyFinishContext();
11922 return 0;
11923 }
11924
11925 static int __Pyx_modinit_type_import_code(void) {
11926 __Pyx_RefNannyDeclarations
11927 PyObject *__pyx_t_1 = NULL;
11928 int __pyx_lineno = 0;
11929 const char *__pyx_filename = NULL;
11930 int __pyx_clineno = 0;
11931 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
11932 /*--- Type import code ---*/
11933 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __pyx_L1_error)
11934 __Pyx_GOTREF(__pyx_t_1);
11935 __pyx_ptype_7cpython_4type_type = __Pyx_ImportType_3_0_11(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
11936 #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
11937 sizeof(PyTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_11(PyTypeObject),
11938 #elif CYTHON_COMPILING_IN_LIMITED_API
11939 sizeof(PyTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_11(PyTypeObject),
11940 #else
11941 sizeof(PyHeapTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_11(PyHeapTypeObject),
11942 #endif
11943 __Pyx_ImportType_CheckSize_Warn_3_0_11); if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(3, 9, __pyx_L1_error)
11944 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11945 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 8, __pyx_L1_error)
11946 __Pyx_GOTREF(__pyx_t_1);
11947 __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType_3_0_11(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_11(PyBoolObject),__Pyx_ImportType_CheckSize_Warn_3_0_11); if (!__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(4, 8, __pyx_L1_error)
11948 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11949 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 15, __pyx_L1_error)
11950 __Pyx_GOTREF(__pyx_t_1);
11951 __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType_3_0_11(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_11(PyComplexObject),__Pyx_ImportType_CheckSize_Warn_3_0_11); if (!__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(5, 15, __pyx_L1_error)
11952 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11953 __pyx_t_1 = PyImport_ImportModule("array"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 69, __pyx_L1_error)
11954 __Pyx_GOTREF(__pyx_t_1);
11955 __pyx_ptype_7cpython_5array_array = __Pyx_ImportType_3_0_11(__pyx_t_1, "array", "array", sizeof(arrayobject), __PYX_GET_STRUCT_ALIGNMENT_3_0_11(arrayobject),__Pyx_ImportType_CheckSize_Warn_3_0_11); if (!__pyx_ptype_7cpython_5array_array) __PYX_ERR(2, 69, __pyx_L1_error)
11956 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11957 __Pyx_RefNannyFinishContext();
11958 return 0;
11959 __pyx_L1_error:;
11960 __Pyx_XDECREF(__pyx_t_1);
11961 __Pyx_RefNannyFinishContext();
11962 return -1;
11963 }
11964
11965 static int __Pyx_modinit_variable_import_code(void) {
11966 __Pyx_RefNannyDeclarations
11967 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
11968 /*--- Variable import code ---*/
11969 __Pyx_RefNannyFinishContext();
11970 return 0;
11971 }
11972
11973 static int __Pyx_modinit_function_import_code(void) {
11974 __Pyx_RefNannyDeclarations
11975 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
11976 /*--- Function import code ---*/
11977 __Pyx_RefNannyFinishContext();
11978 return 0;
11979 }
11980
11981
11982 #if PY_MAJOR_VERSION >= 3
11983 #if CYTHON_PEP489_MULTI_PHASE_INIT
11984 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
11985 static int __pyx_pymod_exec_libcutils(PyObject* module); /*proto*/
11986 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
11987 {Py_mod_create, (void*)__pyx_pymod_create},
11988 {Py_mod_exec, (void*)__pyx_pymod_exec_libcutils},
11989 {0, NULL}
11990 };
11991 #endif
11992
11993 #ifdef __cplusplus
11994 namespace {
11995 struct PyModuleDef __pyx_moduledef =
11996 #else
11997 static struct PyModuleDef __pyx_moduledef =
11998 #endif
11999 {
12000 PyModuleDef_HEAD_INIT,
12001 "libcutils",
12002 0, /* m_doc */
12003 #if CYTHON_PEP489_MULTI_PHASE_INIT
12004 0, /* m_size */
12005 #elif CYTHON_USE_MODULE_STATE
12006 sizeof(__pyx_mstate), /* m_size */
12007 #else
12008 -1, /* m_size */
12009 #endif
12010 __pyx_methods /* m_methods */,
12011 #if CYTHON_PEP489_MULTI_PHASE_INIT
12012 __pyx_moduledef_slots, /* m_slots */
12013 #else
12014 NULL, /* m_reload */
12015 #endif
12016 #if CYTHON_USE_MODULE_STATE
12017 __pyx_m_traverse, /* m_traverse */
12018 __pyx_m_clear, /* m_clear */
12019 NULL /* m_free */
12020 #else
12021 NULL, /* m_traverse */
12022 NULL, /* m_clear */
12023 NULL /* m_free */
12024 #endif
12025 };
12026 #ifdef __cplusplus
12027 } /* anonymous namespace */
12028 #endif
12029 #endif
12030
12031 #ifndef CYTHON_NO_PYINIT_EXPORT
12032 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
12033 #elif PY_MAJOR_VERSION < 3
12034 #ifdef __cplusplus
12035 #define __Pyx_PyMODINIT_FUNC extern "C" void
12036 #else
12037 #define __Pyx_PyMODINIT_FUNC void
12038 #endif
12039 #else
12040 #ifdef __cplusplus
12041 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
12042 #else
12043 #define __Pyx_PyMODINIT_FUNC PyObject *
12044 #endif
12045 #endif
12046
12047
12048 #if PY_MAJOR_VERSION < 3
12049 __Pyx_PyMODINIT_FUNC initlibcutils(void) CYTHON_SMALL_CODE; /*proto*/
12050 __Pyx_PyMODINIT_FUNC initlibcutils(void)
12051 #else
12052 __Pyx_PyMODINIT_FUNC PyInit_libcutils(void) CYTHON_SMALL_CODE; /*proto*/
12053 __Pyx_PyMODINIT_FUNC PyInit_libcutils(void)
12054 #if CYTHON_PEP489_MULTI_PHASE_INIT
12055 {
12056 return PyModuleDef_Init(&__pyx_moduledef);
12057 }
12058 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
12059 #if PY_VERSION_HEX >= 0x030700A1
12060 static PY_INT64_T main_interpreter_id = -1;
12061 PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
12062 if (main_interpreter_id == -1) {
12063 main_interpreter_id = current_id;
12064 return (unlikely(current_id == -1)) ? -1 : 0;
12065 } else if (unlikely(main_interpreter_id != current_id))
12066 #else
12067 static PyInterpreterState *main_interpreter = NULL;
12068 PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
12069 if (!main_interpreter) {
12070 main_interpreter = current_interpreter;
12071 } else if (unlikely(main_interpreter != current_interpreter))
12072 #endif
12073 {
12074 PyErr_SetString(
12075 PyExc_ImportError,
12076 "Interpreter change detected - this module can only be loaded into one interpreter per process.");
12077 return -1;
12078 }
12079 return 0;
12080 }
12081 #if CYTHON_COMPILING_IN_LIMITED_API
12082 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *module, const char* from_name, const char* to_name, int allow_none)
12083 #else
12084 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none)
12085 #endif
12086 {
12087 PyObject *value = PyObject_GetAttrString(spec, from_name);
12088 int result = 0;
12089 if (likely(value)) {
12090 if (allow_none || value != Py_None) {
12091 #if CYTHON_COMPILING_IN_LIMITED_API
12092 result = PyModule_AddObject(module, to_name, value);
12093 #else
12094 result = PyDict_SetItemString(moddict, to_name, value);
12095 #endif
12096 }
12097 Py_DECREF(value);
12098 } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
12099 PyErr_Clear();
12100 } else {
12101 result = -1;
12102 }
12103 return result;
12104 }
12105 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) {
12106 PyObject *module = NULL, *moddict, *modname;
12107 CYTHON_UNUSED_VAR(def);
12108 if (__Pyx_check_single_interpreter())
12109 return NULL;
12110 if (__pyx_m)
12111 return __Pyx_NewRef(__pyx_m);
12112 modname = PyObject_GetAttrString(spec, "name");
12113 if (unlikely(!modname)) goto bad;
12114 module = PyModule_NewObject(modname);
12115 Py_DECREF(modname);
12116 if (unlikely(!module)) goto bad;
12117 #if CYTHON_COMPILING_IN_LIMITED_API
12118 moddict = module;
12119 #else
12120 moddict = PyModule_GetDict(module);
12121 if (unlikely(!moddict)) goto bad;
12122 #endif
12123 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
12124 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
12125 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
12126 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
12127 return module;
12128 bad:
12129 Py_XDECREF(module);
12130 return NULL;
12131 }
12132
12133
12134 static CYTHON_SMALL_CODE int __pyx_pymod_exec_libcutils(PyObject *__pyx_pyinit_module)
12135 #endif
12136 #endif
12137 {
12138 int stringtab_initialized = 0;
12139 #if CYTHON_USE_MODULE_STATE
12140 int pystate_addmodule_run = 0;
12141 #endif
12142 PyObject *__pyx_t_1 = NULL;
12143 PyObject *__pyx_t_2 = NULL;
12144 PyObject *__pyx_t_3 = NULL;
12145 PyObject *__pyx_t_4 = NULL;
12146 int __pyx_t_5;
12147 int __pyx_lineno = 0;
12148 const char *__pyx_filename = NULL;
12149 int __pyx_clineno = 0;
12150 __Pyx_RefNannyDeclarations
12151 #if CYTHON_PEP489_MULTI_PHASE_INIT
12152 if (__pyx_m) {
12153 if (__pyx_m == __pyx_pyinit_module) return 0;
12154 PyErr_SetString(PyExc_RuntimeError, "Module 'libcutils' has already been imported. Re-initialisation is not supported.");
12155 return -1;
12156 }
12157 #elif PY_MAJOR_VERSION >= 3
12158 if (__pyx_m) return __Pyx_NewRef(__pyx_m);
12159 #endif
12160 /*--- Module creation code ---*/
12161 #if CYTHON_PEP489_MULTI_PHASE_INIT
12162 __pyx_m = __pyx_pyinit_module;
12163 Py_INCREF(__pyx_m);
12164 #else
12165 #if PY_MAJOR_VERSION < 3
12166 __pyx_m = Py_InitModule4("libcutils", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
12167 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
12168 #elif CYTHON_USE_MODULE_STATE
12169 __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
12170 {
12171 int add_module_result = PyState_AddModule(__pyx_t_1, &__pyx_moduledef);
12172 __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "libcutils" pseudovariable */
12173 if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
12174 pystate_addmodule_run = 1;
12175 }
12176 #else
12177 __pyx_m = PyModule_Create(&__pyx_moduledef);
12178 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
12179 #endif
12180 #endif
12181 CYTHON_UNUSED_VAR(__pyx_t_1);
12182 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
12183 Py_INCREF(__pyx_d);
12184 __pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
12185 __pyx_cython_runtime = __Pyx_PyImport_AddModuleRef((const char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
12186 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12187 #if CYTHON_REFNANNY
12188 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
12189 if (!__Pyx_RefNanny) {
12190 PyErr_Clear();
12191 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
12192 if (!__Pyx_RefNanny)
12193 Py_FatalError("failed to import 'refnanny' module");
12194 }
12195 #endif
12196 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_libcutils(void)", 0);
12197 if (__Pyx_check_binary_version(__PYX_LIMITED_VERSION_HEX, __Pyx_get_runtime_version(), CYTHON_COMPILING_IN_LIMITED_API) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12198 #ifdef __Pxy_PyFrame_Initialize_Offsets
12199 __Pxy_PyFrame_Initialize_Offsets();
12200 #endif
12201 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
12202 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
12203 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
12204 #ifdef __Pyx_CyFunction_USED
12205 if (__pyx_CyFunction_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12206 #endif
12207 #ifdef __Pyx_FusedFunction_USED
12208 if (__pyx_FusedFunction_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12209 #endif
12210 #ifdef __Pyx_Coroutine_USED
12211 if (__pyx_Coroutine_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12212 #endif
12213 #ifdef __Pyx_Generator_USED
12214 if (__pyx_Generator_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12215 #endif
12216 #ifdef __Pyx_AsyncGen_USED
12217 if (__pyx_AsyncGen_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12218 #endif
12219 #ifdef __Pyx_StopAsyncIteration_USED
12220 if (__pyx_StopAsyncIteration_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12221 #endif
12222 /*--- Library function declarations ---*/
12223 /*--- Threads initialization code ---*/
12224 #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
12225 PyEval_InitThreads();
12226 #endif
12227 /*--- Initialize various global constants etc. ---*/
12228 if (__Pyx_InitConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12229 stringtab_initialized = 1;
12230 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12231 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
12232 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12233 #endif
12234 if (__pyx_module_is_main_pysam__libcutils) {
12235 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12236 }
12237 #if PY_MAJOR_VERSION >= 3
12238 {
12239 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
12240 if (!PyDict_GetItemString(modules, "pysam.libcutils")) {
12241 if (unlikely((PyDict_SetItemString(modules, "pysam.libcutils", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
12242 }
12243 }
12244 #endif
12245 /*--- Builtin init code ---*/
12246 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12247 /*--- Constants init code ---*/
12248 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12249 /*--- Global type/function init code ---*/
12250 (void)__Pyx_modinit_global_init_code();
12251 (void)__Pyx_modinit_variable_export_code();
12252 if (unlikely((__Pyx_modinit_function_export_code() < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
12253 (void)__Pyx_modinit_type_init_code();
12254 if (unlikely((__Pyx_modinit_type_import_code() < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
12255 (void)__Pyx_modinit_variable_import_code();
12256 (void)__Pyx_modinit_function_import_code();
12257 /*--- Execution code ---*/
12258 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
12259 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12260 #endif
12261
12262 /* "pysam/libcutils.pyx":2
12263 * # cython: language_level=3
12264 * import types # <<<<<<<<<<<<<<
12265 * import sys
12266 * import string
12267 */
12268 __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_types, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2, __pyx_L1_error)
12269 __Pyx_GOTREF(__pyx_t_2);
12270 if (PyDict_SetItem(__pyx_d, __pyx_n_s_types, __pyx_t_2) < 0) __PYX_ERR(0, 2, __pyx_L1_error)
12271 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12272
12273 /* "pysam/libcutils.pyx":3
12274 * # cython: language_level=3
12275 * import types
12276 * import sys # <<<<<<<<<<<<<<
12277 * import string
12278 * import re
12279 */
12280 __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_sys, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error)
12281 __Pyx_GOTREF(__pyx_t_2);
12282 if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
12283 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12284
12285 /* "pysam/libcutils.pyx":4
12286 * import types
12287 * import sys
12288 * import string # <<<<<<<<<<<<<<
12289 * import re
12290 * import tempfile
12291 */
12292 __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_string, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4, __pyx_L1_error)
12293 __Pyx_GOTREF(__pyx_t_2);
12294 if (PyDict_SetItem(__pyx_d, __pyx_n_s_string, __pyx_t_2) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
12295 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12296
12297 /* "pysam/libcutils.pyx":5
12298 * import sys
12299 * import string
12300 * import re # <<<<<<<<<<<<<<
12301 * import tempfile
12302 * import os
12303 */
12304 __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_re, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error)
12305 __Pyx_GOTREF(__pyx_t_2);
12306 if (PyDict_SetItem(__pyx_d, __pyx_n_s_re, __pyx_t_2) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
12307 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12308
12309 /* "pysam/libcutils.pyx":6
12310 * import string
12311 * import re
12312 * import tempfile # <<<<<<<<<<<<<<
12313 * import os
12314 * import io
12315 */
12316 __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_tempfile, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error)
12317 __Pyx_GOTREF(__pyx_t_2);
12318 if (PyDict_SetItem(__pyx_d, __pyx_n_s_tempfile, __pyx_t_2) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
12319 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12320
12321 /* "pysam/libcutils.pyx":7
12322 * import re
12323 * import tempfile
12324 * import os # <<<<<<<<<<<<<<
12325 * import io
12326 * from contextlib import contextmanager
12327 */
12328 __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_os, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
12329 __Pyx_GOTREF(__pyx_t_2);
12330 if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
12331 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12332
12333 /* "pysam/libcutils.pyx":8
12334 * import tempfile
12335 * import os
12336 * import io # <<<<<<<<<<<<<<
12337 * from contextlib import contextmanager
12338 * from codecs import register_error
12339 */
12340 __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_io, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
12341 __Pyx_GOTREF(__pyx_t_2);
12342 if (PyDict_SetItem(__pyx_d, __pyx_n_s_io, __pyx_t_2) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
12343 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12344
12345 /* "pysam/libcutils.pyx":9
12346 * import os
12347 * import io
12348 * from contextlib import contextmanager # <<<<<<<<<<<<<<
12349 * from codecs import register_error
12350 *
12351 */
12352 __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
12353 __Pyx_GOTREF(__pyx_t_2);
12354 __Pyx_INCREF(__pyx_n_s_contextmanager);
12355 __Pyx_GIVEREF(__pyx_n_s_contextmanager);
12356 if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_contextmanager)) __PYX_ERR(0, 9, __pyx_L1_error);
12357 __pyx_t_3 = __Pyx_Import(__pyx_n_s_contextlib, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9, __pyx_L1_error)
12358 __Pyx_GOTREF(__pyx_t_3);
12359 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12360 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_contextmanager); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
12361 __Pyx_GOTREF(__pyx_t_2);
12362 if (PyDict_SetItem(__pyx_d, __pyx_n_s_contextmanager, __pyx_t_2) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
12363 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12364 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12365
12366 /* "pysam/libcutils.pyx":10
12367 * import io
12368 * from contextlib import contextmanager
12369 * from codecs import register_error # <<<<<<<<<<<<<<
12370 *
12371 * from cpython.version cimport PY_MAJOR_VERSION, PY_MINOR_VERSION
12372 */
12373 __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 10, __pyx_L1_error)
12374 __Pyx_GOTREF(__pyx_t_3);
12375 __Pyx_INCREF(__pyx_n_s_register_error);
12376 __Pyx_GIVEREF(__pyx_n_s_register_error);
12377 if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_register_error)) __PYX_ERR(0, 10, __pyx_L1_error);
12378 __pyx_t_2 = __Pyx_Import(__pyx_n_s_codecs, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
12379 __Pyx_GOTREF(__pyx_t_2);
12380 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12381 __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_register_error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 10, __pyx_L1_error)
12382 __Pyx_GOTREF(__pyx_t_3);
12383 if (PyDict_SetItem(__pyx_d, __pyx_n_s_register_error, __pyx_t_3) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
12384 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12385 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12386
12387 /* "pysam/libcutils.pyx":32
12388 * #####################################################################
12389 * # hard-coded constants
12390 * cdef int MAX_POS = (1 << 31) - 1 # <<<<<<<<<<<<<<
12391 *
12392 * #################################################################
12393 */
12394 __pyx_v_5pysam_9libcutils_MAX_POS = 0x7fffffff;
12395
12396 /* "pysam/libcutils.pyx":36
12397 * #################################################################
12398 * # Utility functions for quality string conversions
12399 * cpdef c_array.array qualitystring_to_array(input_str, int offset=33): # <<<<<<<<<<<<<<
12400 * """convert a qualitystring to an array of quality values."""
12401 * if input_str is None:
12402 */
12403 __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_5pysam_9libcutils_1qualitystring_to_array, 0, __pyx_n_s_qualitystring_to_array, NULL, __pyx_n_s_pysam_libcutils, __pyx_d, ((PyObject *)__pyx_codeobj__17)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
12404 __Pyx_GOTREF(__pyx_t_2);
12405 __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__18);
12406 if (PyDict_SetItem(__pyx_d, __pyx_n_s_qualitystring_to_array, __pyx_t_2) < 0) __PYX_ERR(0, 36, __pyx_L1_error)
12407 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12408
12409 /* "pysam/libcutils.pyx":45
12410 *
12411 *
12412 * cpdef array_to_qualitystring(c_array.array qualities, int offset=33): # <<<<<<<<<<<<<<
12413 * """convert an array of quality values to a string."""
12414 * if qualities is None:
12415 */
12416 __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_5pysam_9libcutils_3array_to_qualitystring, 0, __pyx_n_s_array_to_qualitystring, NULL, __pyx_n_s_pysam_libcutils, __pyx_d, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
12417 __Pyx_GOTREF(__pyx_t_2);
12418 __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__18);
12419 if (PyDict_SetItem(__pyx_d, __pyx_n_s_array_to_qualitystring, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error)
12420 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12421
12422 /* "pysam/libcutils.pyx":59
12423 *
12424 *
12425 * cpdef qualities_to_qualitystring(qualities, int offset=33): # <<<<<<<<<<<<<<
12426 * """convert a list or array of quality scores to the string
12427 * representation used in the SAM format.
12428 */
12429 __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_5pysam_9libcutils_5qualities_to_qualitystring, 0, __pyx_n_s_qualities_to_qualitystring, NULL, __pyx_n_s_pysam_libcutils, __pyx_d, ((PyObject *)__pyx_codeobj__21)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error)
12430 __Pyx_GOTREF(__pyx_t_2);
12431 __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__18);
12432 if (PyDict_SetItem(__pyx_d, __pyx_n_s_qualities_to_qualitystring, __pyx_t_2) < 0) __PYX_ERR(0, 59, __pyx_L1_error)
12433 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12434
12435 /* "pysam/libcutils.pyx":90
12436 *
12437 * # Codec error handler that just interprets each bad byte as ISO-8859-1.
12438 * def latin1_replace(exception): # <<<<<<<<<<<<<<
12439 * return (chr(exception.object[exception.start]), exception.end)
12440 *
12441 */
12442 __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_5pysam_9libcutils_7latin1_replace, 0, __pyx_n_s_latin1_replace, NULL, __pyx_n_s_pysam_libcutils, __pyx_d, ((PyObject *)__pyx_codeobj__23)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
12443 __Pyx_GOTREF(__pyx_t_2);
12444 if (PyDict_SetItem(__pyx_d, __pyx_n_s_latin1_replace, __pyx_t_2) < 0) __PYX_ERR(0, 90, __pyx_L1_error)
12445 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12446
12447 /* "pysam/libcutils.pyx":93
12448 * return (chr(exception.object[exception.start]), exception.end)
12449 *
12450 * register_error('pysam.latin1replace', latin1_replace) # <<<<<<<<<<<<<<
12451 *
12452 *
12453 */
12454 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_register_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error)
12455 __Pyx_GOTREF(__pyx_t_2);
12456 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_latin1_replace); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error)
12457 __Pyx_GOTREF(__pyx_t_3);
12458 __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 93, __pyx_L1_error)
12459 __Pyx_GOTREF(__pyx_t_4);
12460 __Pyx_INCREF(__pyx_kp_u_pysam_latin1replace);
12461 __Pyx_GIVEREF(__pyx_kp_u_pysam_latin1replace);
12462 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_u_pysam_latin1replace)) __PYX_ERR(0, 93, __pyx_L1_error);
12463 __Pyx_GIVEREF(__pyx_t_3);
12464 if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error);
12465 __pyx_t_3 = 0;
12466 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error)
12467 __Pyx_GOTREF(__pyx_t_3);
12468 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12469 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12470 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12471
12472 /* "pysam/libcutils.pyx":96
12473 *
12474 *
12475 * cdef str ERROR_HANDLER = 'strict' # <<<<<<<<<<<<<<
12476 *
12477 * cpdef get_encoding_error_handler():
12478 */
12479 __Pyx_INCREF(__pyx_n_u_strict);
12480 __Pyx_XGOTREF(__pyx_v_5pysam_9libcutils_ERROR_HANDLER);
12481 __Pyx_DECREF_SET(__pyx_v_5pysam_9libcutils_ERROR_HANDLER, __pyx_n_u_strict);
12482 __Pyx_GIVEREF(__pyx_n_u_strict);
12483
12484 /* "pysam/libcutils.pyx":98
12485 * cdef str ERROR_HANDLER = 'strict'
12486 *
12487 * cpdef get_encoding_error_handler(): # <<<<<<<<<<<<<<
12488 * return ERROR_HANDLER
12489 *
12490 */
12491 __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_5pysam_9libcutils_9get_encoding_error_handler, 0, __pyx_n_s_get_encoding_error_handler, NULL, __pyx_n_s_pysam_libcutils, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 98, __pyx_L1_error)
12492 __Pyx_GOTREF(__pyx_t_3);
12493 if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_encoding_error_handler, __pyx_t_3) < 0) __PYX_ERR(0, 98, __pyx_L1_error)
12494 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12495
12496 /* "pysam/libcutils.pyx":101
12497 * return ERROR_HANDLER
12498 *
12499 * cpdef set_encoding_error_handler(name): # <<<<<<<<<<<<<<
12500 * global ERROR_HANDLER
12501 * previous = ERROR_HANDLER
12502 */
12503 __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_5pysam_9libcutils_11set_encoding_error_handler, 0, __pyx_n_s_set_encoding_error_handler, NULL, __pyx_n_s_pysam_libcutils, __pyx_d, ((PyObject *)__pyx_codeobj__26)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 101, __pyx_L1_error)
12504 __Pyx_GOTREF(__pyx_t_3);
12505 if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_encoding_error_handler, __pyx_t_3) < 0) __PYX_ERR(0, 101, __pyx_L1_error)
12506 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12507
12508 /* "pysam/libcutils.pyx":115
12509 *
12510 * # filename encoding (adapted from lxml.etree.pyx)
12511 * cdef str FILENAME_ENCODING = sys.getfilesystemencoding() or sys.getdefaultencoding() or 'ascii' # <<<<<<<<<<<<<<
12512 * cdef str TEXT_ENCODING = 'utf-8'
12513 *
12514 */
12515 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_sys); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error)
12516 __Pyx_GOTREF(__pyx_t_4);
12517 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_getfilesystemencoding); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error)
12518 __Pyx_GOTREF(__pyx_t_2);
12519 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12520 __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error)
12521 __Pyx_GOTREF(__pyx_t_4);
12522 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12523 __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 115, __pyx_L1_error)
12524 if (!__pyx_t_5) {
12525 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12526 } else {
12527 if (!(likely(PyUnicode_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_4))) __PYX_ERR(0, 115, __pyx_L1_error)
12528 __Pyx_INCREF(__pyx_t_4);
12529 __pyx_t_3 = __pyx_t_4;
12530 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12531 goto __pyx_L2_bool_binop_done;
12532 }
12533 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_sys); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error)
12534 __Pyx_GOTREF(__pyx_t_4);
12535 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_getdefaultencoding); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error)
12536 __Pyx_GOTREF(__pyx_t_2);
12537 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12538 __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error)
12539 __Pyx_GOTREF(__pyx_t_4);
12540 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12541 __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 115, __pyx_L1_error)
12542 if (!__pyx_t_5) {
12543 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12544 } else {
12545 if (!(likely(PyUnicode_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_4))) __PYX_ERR(0, 115, __pyx_L1_error)
12546 __Pyx_INCREF(__pyx_t_4);
12547 __pyx_t_3 = __pyx_t_4;
12548 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12549 goto __pyx_L2_bool_binop_done;
12550 }
12551 __Pyx_INCREF(__pyx_n_u_ascii);
12552 __pyx_t_3 = __pyx_n_u_ascii;
12553 __pyx_L2_bool_binop_done:;
12554 __Pyx_XGOTREF(__pyx_v_5pysam_9libcutils_FILENAME_ENCODING);
12555 __Pyx_DECREF_SET(__pyx_v_5pysam_9libcutils_FILENAME_ENCODING, ((PyObject*)__pyx_t_3));
12556 __Pyx_GIVEREF(__pyx_t_3);
12557 __pyx_t_3 = 0;
12558
12559 /* "pysam/libcutils.pyx":116
12560 * # filename encoding (adapted from lxml.etree.pyx)
12561 * cdef str FILENAME_ENCODING = sys.getfilesystemencoding() or sys.getdefaultencoding() or 'ascii'
12562 * cdef str TEXT_ENCODING = 'utf-8' # <<<<<<<<<<<<<<
12563 *
12564 * cdef bytes encode_filename(object filename):
12565 */
12566 __Pyx_INCREF(__pyx_kp_u_utf_8);
12567 __Pyx_XGOTREF(__pyx_v_5pysam_9libcutils_TEXT_ENCODING);
12568 __Pyx_DECREF_SET(__pyx_v_5pysam_9libcutils_TEXT_ENCODING, __pyx_kp_u_utf_8);
12569 __Pyx_GIVEREF(__pyx_kp_u_utf_8);
12570
12571 /* "pysam/libcutils.pyx":178
12572 *
12573 *
12574 * cpdef parse_region(contig=None, # <<<<<<<<<<<<<<
12575 * start=None,
12576 * stop=None,
12577 */
12578 __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_5pysam_9libcutils_13parse_region, 0, __pyx_n_s_parse_region, NULL, __pyx_n_s_pysam_libcutils, __pyx_d, ((PyObject *)__pyx_codeobj__28)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error)
12579 __Pyx_GOTREF(__pyx_t_3);
12580 __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_tuple__29);
12581 if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_region, __pyx_t_3) < 0) __PYX_ERR(0, 178, __pyx_L1_error)
12582 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12583
12584 /* "pysam/libcutils.pyx":276
12585 *
12586 *
12587 * def _pysam_dispatch(collection, # <<<<<<<<<<<<<<
12588 * method,
12589 * args=None,
12590 */
12591 __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_5pysam_9libcutils_15_pysam_dispatch, 0, __pyx_n_s_pysam_dispatch, NULL, __pyx_n_s_pysam_libcutils, __pyx_d, ((PyObject *)__pyx_codeobj__31)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
12592 __Pyx_GOTREF(__pyx_t_3);
12593 __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_tuple__32);
12594 if (PyDict_SetItem(__pyx_d, __pyx_n_s_pysam_dispatch, __pyx_t_3) < 0) __PYX_ERR(0, 276, __pyx_L1_error)
12595 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12596
12597 /* "pysam/libcutils.pyx":437
12598 *
12599 *
12600 * __all__ = [ # <<<<<<<<<<<<<<
12601 * "qualitystring_to_array",
12602 * "array_to_qualitystring",
12603 */
12604 __pyx_t_3 = PyList_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 437, __pyx_L1_error)
12605 __Pyx_GOTREF(__pyx_t_3);
12606 __Pyx_INCREF(__pyx_n_u_qualitystring_to_array);
12607 __Pyx_GIVEREF(__pyx_n_u_qualitystring_to_array);
12608 if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_u_qualitystring_to_array)) __PYX_ERR(0, 437, __pyx_L1_error);
12609 __Pyx_INCREF(__pyx_n_u_array_to_qualitystring);
12610 __Pyx_GIVEREF(__pyx_n_u_array_to_qualitystring);
12611 if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_u_array_to_qualitystring)) __PYX_ERR(0, 437, __pyx_L1_error);
12612 __Pyx_INCREF(__pyx_n_u_qualities_to_qualitystring);
12613 __Pyx_GIVEREF(__pyx_n_u_qualities_to_qualitystring);
12614 if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_u_qualities_to_qualitystring)) __PYX_ERR(0, 437, __pyx_L1_error);
12615 __Pyx_INCREF(__pyx_n_u_get_encoding_error_handler);
12616 __Pyx_GIVEREF(__pyx_n_u_get_encoding_error_handler);
12617 if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 3, __pyx_n_u_get_encoding_error_handler)) __PYX_ERR(0, 437, __pyx_L1_error);
12618 __Pyx_INCREF(__pyx_n_u_set_encoding_error_handler);
12619 __Pyx_GIVEREF(__pyx_n_u_set_encoding_error_handler);
12620 if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 4, __pyx_n_u_set_encoding_error_handler)) __PYX_ERR(0, 437, __pyx_L1_error);
12621 if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_3) < 0) __PYX_ERR(0, 437, __pyx_L1_error)
12622 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12623
12624 /* "pysam/libcutils.pyx":1
12625 * # cython: language_level=3 # <<<<<<<<<<<<<<
12626 * import types
12627 * import sys
12628 */
12629 __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error)
12630 __Pyx_GOTREF(__pyx_t_3);
12631 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
12632 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12633
12634 /*--- Wrapped vars code ---*/
12635
12636 goto __pyx_L0;
12637 __pyx_L1_error:;
12638 __Pyx_XDECREF(__pyx_t_2);
12639 __Pyx_XDECREF(__pyx_t_3);
12640 __Pyx_XDECREF(__pyx_t_4);
12641 if (__pyx_m) {
12642 if (__pyx_d && stringtab_initialized) {
12643 __Pyx_AddTraceback("init pysam.libcutils", __pyx_clineno, __pyx_lineno, __pyx_filename);
12644 }
12645 #if !CYTHON_USE_MODULE_STATE
12646 Py_CLEAR(__pyx_m);
12647 #else
12648 Py_DECREF(__pyx_m);
12649 if (pystate_addmodule_run) {
12650 PyObject *tp, *value, *tb;
12651 PyErr_Fetch(&tp, &value, &tb);
12652 PyState_RemoveModule(&__pyx_moduledef);
12653 PyErr_Restore(tp, value, tb);
12654 }
12655 #endif
12656 } else if (!PyErr_Occurred()) {
12657 PyErr_SetString(PyExc_ImportError, "init pysam.libcutils");
12658 }
12659 __pyx_L0:;
12660 __Pyx_RefNannyFinishContext();
12661 #if CYTHON_PEP489_MULTI_PHASE_INIT
12662 return (__pyx_m != NULL) ? 0 : -1;
12663 #elif PY_MAJOR_VERSION >= 3
12664 return __pyx_m;
12665 #else
12666 return;
12667 #endif
12668 }
12669 /* #### Code section: cleanup_globals ### */
12670 /* #### Code section: cleanup_module ### */
12671 /* #### Code section: main_method ### */
12672 /* #### Code section: utility_code_pragmas ### */
12673 #ifdef _MSC_VER
12674 #pragma warning( push )
12675 /* Warning 4127: conditional expression is constant
12676 * Cython uses constant conditional expressions to allow in inline functions to be optimized at
12677 * compile-time, so this warning is not useful
12678 */
12679 #pragma warning( disable : 4127 )
12680 #endif
12681
12682
12683
12684 /* #### Code section: utility_code_def ### */
12685
12686 /* --- Runtime support code --- */
12687 /* Refnanny */
12688 #if CYTHON_REFNANNY
12689 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
12690 PyObject *m = NULL, *p = NULL;
12691 void *r = NULL;
12692 m = PyImport_ImportModule(modname);
12693 if (!m) goto end;
12694 p = PyObject_GetAttrString(m, "RefNannyAPI");
12695 if (!p) goto end;
12696 r = PyLong_AsVoidPtr(p);
12697 end:
12698 Py_XDECREF(p);
12699 Py_XDECREF(m);
12700 return (__Pyx_RefNannyAPIStruct *)r;
12701 }
12702 #endif
12703
12704 /* PyErrExceptionMatches */
12705 #if CYTHON_FAST_THREAD_STATE
12706 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
12707 Py_ssize_t i, n;
12708 n = PyTuple_GET_SIZE(tuple);
12709 #if PY_MAJOR_VERSION >= 3
12710 for (i=0; i<n; i++) {
12711 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
12712 }
12713 #endif
12714 for (i=0; i<n; i++) {
12715 if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
12716 }
12717 return 0;
12718 }
12719 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
12720 int result;
12721 PyObject *exc_type;
12722 #if PY_VERSION_HEX >= 0x030C00A6
12723 PyObject *current_exception = tstate->current_exception;
12724 if (unlikely(!current_exception)) return 0;
12725 exc_type = (PyObject*) Py_TYPE(current_exception);
12726 if (exc_type == err) return 1;
12727 #else
12728 exc_type = tstate->curexc_type;
12729 if (exc_type == err) return 1;
12730 if (unlikely(!exc_type)) return 0;
12731 #endif
12732 #if CYTHON_AVOID_BORROWED_REFS
12733 Py_INCREF(exc_type);
12734 #endif
12735 if (unlikely(PyTuple_Check(err))) {
12736 result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
12737 } else {
12738 result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
12739 }
12740 #if CYTHON_AVOID_BORROWED_REFS
12741 Py_DECREF(exc_type);
12742 #endif
12743 return result;
12744 }
12745 #endif
12746
12747 /* PyErrFetchRestore */
12748 #if CYTHON_FAST_THREAD_STATE
12749 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
12750 #if PY_VERSION_HEX >= 0x030C00A6
12751 PyObject *tmp_value;
12752 assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value)));
12753 if (value) {
12754 #if CYTHON_COMPILING_IN_CPYTHON
12755 if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb))
12756 #endif
12757 PyException_SetTraceback(value, tb);
12758 }
12759 tmp_value = tstate->current_exception;
12760 tstate->current_exception = value;
12761 Py_XDECREF(tmp_value);
12762 Py_XDECREF(type);
12763 Py_XDECREF(tb);
12764 #else
12765 PyObject *tmp_type, *tmp_value, *tmp_tb;
12766 tmp_type = tstate->curexc_type;
12767 tmp_value = tstate->curexc_value;
12768 tmp_tb = tstate->curexc_traceback;
12769 tstate->curexc_type = type;
12770 tstate->curexc_value = value;
12771 tstate->curexc_traceback = tb;
12772 Py_XDECREF(tmp_type);
12773 Py_XDECREF(tmp_value);
12774 Py_XDECREF(tmp_tb);
12775 #endif
12776 }
12777 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
12778 #if PY_VERSION_HEX >= 0x030C00A6
12779 PyObject* exc_value;
12780 exc_value = tstate->current_exception;
12781 tstate->current_exception = 0;
12782 *value = exc_value;
12783 *type = NULL;
12784 *tb = NULL;
12785 if (exc_value) {
12786 *type = (PyObject*) Py_TYPE(exc_value);
12787 Py_INCREF(*type);
12788 #if CYTHON_COMPILING_IN_CPYTHON
12789 *tb = ((PyBaseExceptionObject*) exc_value)->traceback;
12790 Py_XINCREF(*tb);
12791 #else
12792 *tb = PyException_GetTraceback(exc_value);
12793 #endif
12794 }
12795 #else
12796 *type = tstate->curexc_type;
12797 *value = tstate->curexc_value;
12798 *tb = tstate->curexc_traceback;
12799 tstate->curexc_type = 0;
12800 tstate->curexc_value = 0;
12801 tstate->curexc_traceback = 0;
12802 #endif
12803 }
12804 #endif
12805
12806 /* PyObjectGetAttrStr */
12807 #if CYTHON_USE_TYPE_SLOTS
12808 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
12809 PyTypeObject* tp = Py_TYPE(obj);
12810 if (likely(tp->tp_getattro))
12811 return tp->tp_getattro(obj, attr_name);
12812 #if PY_MAJOR_VERSION < 3
12813 if (likely(tp->tp_getattr))
12814 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
12815 #endif
12816 return PyObject_GetAttr(obj, attr_name);
12817 }
12818 #endif
12819
12820 /* PyObjectGetAttrStrNoError */
12821 #if __PYX_LIMITED_VERSION_HEX < 0x030d00A1
12822 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
12823 __Pyx_PyThreadState_declare
12824 __Pyx_PyThreadState_assign
12825 if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
12826 __Pyx_PyErr_Clear();
12827 }
12828 #endif
12829 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
12830 PyObject *result;
12831 #if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1
12832 (void) PyObject_GetOptionalAttr(obj, attr_name, &result);
12833 return result;
12834 #else
12835 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
12836 PyTypeObject* tp = Py_TYPE(obj);
12837 if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
12838 return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
12839 }
12840 #endif
12841 result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
12842 if (unlikely(!result)) {
12843 __Pyx_PyObject_GetAttrStr_ClearAttributeError();
12844 }
12845 return result;
12846 #endif
12847 }
12848
12849 /* GetBuiltinName */
12850 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
12851 PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_b, name);
12852 if (unlikely(!result) && !PyErr_Occurred()) {
12853 PyErr_Format(PyExc_NameError,
12854 #if PY_MAJOR_VERSION >= 3
12855 "name '%U' is not defined", name);
12856 #else
12857 "name '%.200s' is not defined", PyString_AS_STRING(name));
12858 #endif
12859 }
12860 return result;
12861 }
12862
12863 /* TupleAndListFromArray */
12864 #if CYTHON_COMPILING_IN_CPYTHON
12865 static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
12866 PyObject *v;
12867 Py_ssize_t i;
12868 for (i = 0; i < length; i++) {
12869 v = dest[i] = src[i];
12870 Py_INCREF(v);
12871 }
12872 }
12873 static CYTHON_INLINE PyObject *
12874 __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
12875 {
12876 PyObject *res;
12877 if (n <= 0) {
12878 Py_INCREF(__pyx_empty_tuple);
12879 return __pyx_empty_tuple;
12880 }
12881 res = PyTuple_New(n);
12882 if (unlikely(res == NULL)) return NULL;
12883 __Pyx_copy_object_array(src, ((PyTupleObject*)res)->ob_item, n);
12884 return res;
12885 }
12886 static CYTHON_INLINE PyObject *
12887 __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n)
12888 {
12889 PyObject *res;
12890 if (n <= 0) {
12891 return PyList_New(0);
12892 }
12893 res = PyList_New(n);
12894 if (unlikely(res == NULL)) return NULL;
12895 __Pyx_copy_object_array(src, ((PyListObject*)res)->ob_item, n);
12896 return res;
12897 }
12898 #endif
12899
12900 /* BytesEquals */
12901 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
12902 #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API
12903 return PyObject_RichCompareBool(s1, s2, equals);
12904 #else
12905 if (s1 == s2) {
12906 return (equals == Py_EQ);
12907 } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
12908 const char *ps1, *ps2;
12909 Py_ssize_t length = PyBytes_GET_SIZE(s1);
12910 if (length != PyBytes_GET_SIZE(s2))
12911 return (equals == Py_NE);
12912 ps1 = PyBytes_AS_STRING(s1);
12913 ps2 = PyBytes_AS_STRING(s2);
12914 if (ps1[0] != ps2[0]) {
12915 return (equals == Py_NE);
12916 } else if (length == 1) {
12917 return (equals == Py_EQ);
12918 } else {
12919 int result;
12920 #if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000)
12921 Py_hash_t hash1, hash2;
12922 hash1 = ((PyBytesObject*)s1)->ob_shash;
12923 hash2 = ((PyBytesObject*)s2)->ob_shash;
12924 if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
12925 return (equals == Py_NE);
12926 }
12927 #endif
12928 result = memcmp(ps1, ps2, (size_t)length);
12929 return (equals == Py_EQ) ? (result == 0) : (result != 0);
12930 }
12931 } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
12932 return (equals == Py_NE);
12933 } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
12934 return (equals == Py_NE);
12935 } else {
12936 int result;
12937 PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
12938 if (!py_result)
12939 return -1;
12940 result = __Pyx_PyObject_IsTrue(py_result);
12941 Py_DECREF(py_result);
12942 return result;
12943 }
12944 #endif
12945 }
12946
12947 /* UnicodeEquals */
12948 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
12949 #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API
12950 return PyObject_RichCompareBool(s1, s2, equals);
12951 #else
12952 #if PY_MAJOR_VERSION < 3
12953 PyObject* owned_ref = NULL;
12954 #endif
12955 int s1_is_unicode, s2_is_unicode;
12956 if (s1 == s2) {
12957 goto return_eq;
12958 }
12959 s1_is_unicode = PyUnicode_CheckExact(s1);
12960 s2_is_unicode = PyUnicode_CheckExact(s2);
12961 #if PY_MAJOR_VERSION < 3
12962 if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
12963 owned_ref = PyUnicode_FromObject(s2);
12964 if (unlikely(!owned_ref))
12965 return -1;
12966 s2 = owned_ref;
12967 s2_is_unicode = 1;
12968 } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
12969 owned_ref = PyUnicode_FromObject(s1);
12970 if (unlikely(!owned_ref))
12971 return -1;
12972 s1 = owned_ref;
12973 s1_is_unicode = 1;
12974 } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
12975 return __Pyx_PyBytes_Equals(s1, s2, equals);
12976 }
12977 #endif
12978 if (s1_is_unicode & s2_is_unicode) {
12979 Py_ssize_t length;
12980 int kind;
12981 void *data1, *data2;
12982 if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
12983 return -1;
12984 length = __Pyx_PyUnicode_GET_LENGTH(s1);
12985 if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
12986 goto return_ne;
12987 }
12988 #if CYTHON_USE_UNICODE_INTERNALS
12989 {
12990 Py_hash_t hash1, hash2;
12991 #if CYTHON_PEP393_ENABLED
12992 hash1 = ((PyASCIIObject*)s1)->hash;
12993 hash2 = ((PyASCIIObject*)s2)->hash;
12994 #else
12995 hash1 = ((PyUnicodeObject*)s1)->hash;
12996 hash2 = ((PyUnicodeObject*)s2)->hash;
12997 #endif
12998 if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
12999 goto return_ne;
13000 }
13001 }
13002 #endif
13003 kind = __Pyx_PyUnicode_KIND(s1);
13004 if (kind != __Pyx_PyUnicode_KIND(s2)) {
13005 goto return_ne;
13006 }
13007 data1 = __Pyx_PyUnicode_DATA(s1);
13008 data2 = __Pyx_PyUnicode_DATA(s2);
13009 if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
13010 goto return_ne;
13011 } else if (length == 1) {
13012 goto return_eq;
13013 } else {
13014 int result = memcmp(data1, data2, (size_t)(length * kind));
13015 #if PY_MAJOR_VERSION < 3
13016 Py_XDECREF(owned_ref);
13017 #endif
13018 return (equals == Py_EQ) ? (result == 0) : (result != 0);
13019 }
13020 } else if ((s1 == Py_None) & s2_is_unicode) {
13021 goto return_ne;
13022 } else if ((s2 == Py_None) & s1_is_unicode) {
13023 goto return_ne;
13024 } else {
13025 int result;
13026 PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
13027 #if PY_MAJOR_VERSION < 3
13028 Py_XDECREF(owned_ref);
13029 #endif
13030 if (!py_result)
13031 return -1;
13032 result = __Pyx_PyObject_IsTrue(py_result);
13033 Py_DECREF(py_result);
13034 return result;
13035 }
13036 return_eq:
13037 #if PY_MAJOR_VERSION < 3
13038 Py_XDECREF(owned_ref);
13039 #endif
13040 return (equals == Py_EQ);
13041 return_ne:
13042 #if PY_MAJOR_VERSION < 3
13043 Py_XDECREF(owned_ref);
13044 #endif
13045 return (equals == Py_NE);
13046 #endif
13047 }
13048
13049 /* fastcall */
13050 #if CYTHON_METH_FASTCALL
13051 static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s)
13052 {
13053 Py_ssize_t i, n = PyTuple_GET_SIZE(kwnames);
13054 for (i = 0; i < n; i++)
13055 {
13056 if (s == PyTuple_GET_ITEM(kwnames, i)) return kwvalues[i];
13057 }
13058 for (i = 0; i < n; i++)
13059 {
13060 int eq = __Pyx_PyUnicode_Equals(s, PyTuple_GET_ITEM(kwnames, i), Py_EQ);
13061 if (unlikely(eq != 0)) {
13062 if (unlikely(eq < 0)) return NULL;
13063 return kwvalues[i];
13064 }
13065 }
13066 return NULL;
13067 }
13068 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
13069 CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) {
13070 Py_ssize_t i, nkwargs = PyTuple_GET_SIZE(kwnames);
13071 PyObject *dict;
13072 dict = PyDict_New();
13073 if (unlikely(!dict))
13074 return NULL;
13075 for (i=0; i<nkwargs; i++) {
13076 PyObject *key = PyTuple_GET_ITEM(kwnames, i);
13077 if (unlikely(PyDict_SetItem(dict, key, kwvalues[i]) < 0))
13078 goto bad;
13079 }
13080 return dict;
13081 bad:
13082 Py_DECREF(dict);
13083 return NULL;
13084 }
13085 #endif
13086 #endif
13087
13088 /* PyObjectCall */
13089 #if CYTHON_COMPILING_IN_CPYTHON
13090 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
13091 PyObject *result;
13092 ternaryfunc call = Py_TYPE(func)->tp_call;
13093 if (unlikely(!call))
13094 return PyObject_Call(func, arg, kw);
13095 #if PY_MAJOR_VERSION < 3
13096 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
13097 return NULL;
13098 #else
13099 if (unlikely(Py_EnterRecursiveCall(" while calling a Python object")))
13100 return NULL;
13101 #endif
13102 result = (*call)(func, arg, kw);
13103 Py_LeaveRecursiveCall();
13104 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
13105 PyErr_SetString(
13106 PyExc_SystemError,
13107 "NULL result without error in PyObject_Call");
13108 }
13109 return result;
13110 }
13111 #endif
13112
13113 /* RaiseDoubleKeywords */
13114 static void __Pyx_RaiseDoubleKeywordsError(
13115 const char* func_name,
13116 PyObject* kw_name)
13117 {
13118 PyErr_Format(PyExc_TypeError,
13119 #if PY_MAJOR_VERSION >= 3
13120 "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
13121 #else
13122 "%s() got multiple values for keyword argument '%s'", func_name,
13123 PyString_AsString(kw_name));
13124 #endif
13125 }
13126
13127 /* ParseKeywords */
13128 static int __Pyx_ParseOptionalKeywords(
13129 PyObject *kwds,
13130 PyObject *const *kwvalues,
13131 PyObject **argnames[],
13132 PyObject *kwds2,
13133 PyObject *values[],
13134 Py_ssize_t num_pos_args,
13135 const char* function_name)
13136 {
13137 PyObject *key = 0, *value = 0;
13138 Py_ssize_t pos = 0;
13139 PyObject*** name;
13140 PyObject*** first_kw_arg = argnames + num_pos_args;
13141 int kwds_is_tuple = CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds));
13142 while (1) {
13143 Py_XDECREF(key); key = NULL;
13144 Py_XDECREF(value); value = NULL;
13145 if (kwds_is_tuple) {
13146 Py_ssize_t size;
13147 #if CYTHON_ASSUME_SAFE_MACROS
13148 size = PyTuple_GET_SIZE(kwds);
13149 #else
13150 size = PyTuple_Size(kwds);
13151 if (size < 0) goto bad;
13152 #endif
13153 if (pos >= size) break;
13154 #if CYTHON_AVOID_BORROWED_REFS
13155 key = __Pyx_PySequence_ITEM(kwds, pos);
13156 if (!key) goto bad;
13157 #elif CYTHON_ASSUME_SAFE_MACROS
13158 key = PyTuple_GET_ITEM(kwds, pos);
13159 #else
13160 key = PyTuple_GetItem(kwds, pos);
13161 if (!key) goto bad;
13162 #endif
13163 value = kwvalues[pos];
13164 pos++;
13165 }
13166 else
13167 {
13168 if (!PyDict_Next(kwds, &pos, &key, &value)) break;
13169 #if CYTHON_AVOID_BORROWED_REFS
13170 Py_INCREF(key);
13171 #endif
13172 }
13173 name = first_kw_arg;
13174 while (*name && (**name != key)) name++;
13175 if (*name) {
13176 values[name-argnames] = value;
13177 #if CYTHON_AVOID_BORROWED_REFS
13178 Py_INCREF(value);
13179 Py_DECREF(key);
13180 #endif
13181 key = NULL;
13182 value = NULL;
13183 continue;
13184 }
13185 #if !CYTHON_AVOID_BORROWED_REFS
13186 Py_INCREF(key);
13187 #endif
13188 Py_INCREF(value);
13189 name = first_kw_arg;
13190 #if PY_MAJOR_VERSION < 3
13191 if (likely(PyString_Check(key))) {
13192 while (*name) {
13193 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
13194 && _PyString_Eq(**name, key)) {
13195 values[name-argnames] = value;
13196 #if CYTHON_AVOID_BORROWED_REFS
13197 value = NULL;
13198 #endif
13199 break;
13200 }
13201 name++;
13202 }
13203 if (*name) continue;
13204 else {
13205 PyObject*** argname = argnames;
13206 while (argname != first_kw_arg) {
13207 if ((**argname == key) || (
13208 (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
13209 && _PyString_Eq(**argname, key))) {
13210 goto arg_passed_twice;
13211 }
13212 argname++;
13213 }
13214 }
13215 } else
13216 #endif
13217 if (likely(PyUnicode_Check(key))) {
13218 while (*name) {
13219 int cmp = (
13220 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
13221 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
13222 #endif
13223 PyUnicode_Compare(**name, key)
13224 );
13225 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
13226 if (cmp == 0) {
13227 values[name-argnames] = value;
13228 #if CYTHON_AVOID_BORROWED_REFS
13229 value = NULL;
13230 #endif
13231 break;
13232 }
13233 name++;
13234 }
13235 if (*name) continue;
13236 else {
13237 PyObject*** argname = argnames;
13238 while (argname != first_kw_arg) {
13239 int cmp = (**argname == key) ? 0 :
13240 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
13241 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
13242 #endif
13243 PyUnicode_Compare(**argname, key);
13244 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
13245 if (cmp == 0) goto arg_passed_twice;
13246 argname++;
13247 }
13248 }
13249 } else
13250 goto invalid_keyword_type;
13251 if (kwds2) {
13252 if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
13253 } else {
13254 goto invalid_keyword;
13255 }
13256 }
13257 Py_XDECREF(key);
13258 Py_XDECREF(value);
13259 return 0;
13260 arg_passed_twice:
13261 __Pyx_RaiseDoubleKeywordsError(function_name, key);
13262 goto bad;
13263 invalid_keyword_type:
13264 PyErr_Format(PyExc_TypeError,
13265 "%.200s() keywords must be strings", function_name);
13266 goto bad;
13267 invalid_keyword:
13268 #if PY_MAJOR_VERSION < 3
13269 PyErr_Format(PyExc_TypeError,
13270 "%.200s() got an unexpected keyword argument '%.200s'",
13271 function_name, PyString_AsString(key));
13272 #else
13273 PyErr_Format(PyExc_TypeError,
13274 "%s() got an unexpected keyword argument '%U'",
13275 function_name, key);
13276 #endif
13277 bad:
13278 Py_XDECREF(key);
13279 Py_XDECREF(value);
13280 return -1;
13281 }
13282
13283 /* RaiseArgTupleInvalid */
13284 static void __Pyx_RaiseArgtupleInvalid(
13285 const char* func_name,
13286 int exact,
13287 Py_ssize_t num_min,
13288 Py_ssize_t num_max,
13289 Py_ssize_t num_found)
13290 {
13291 Py_ssize_t num_expected;
13292 const char *more_or_less;
13293 if (num_found < num_min) {
13294 num_expected = num_min;
13295 more_or_less = "at least";
13296 } else {
13297 num_expected = num_max;
13298 more_or_less = "at most";
13299 }
13300 if (exact) {
13301 more_or_less = "exactly";
13302 }
13303 PyErr_Format(PyExc_TypeError,
13304 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
13305 func_name, more_or_less, num_expected,
13306 (num_expected == 1) ? "" : "s", num_found);
13307 }
13308
13309 /* GetItemInt */
13310 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
13311 PyObject *r;
13312 if (unlikely(!j)) return NULL;
13313 r = PyObject_GetItem(o, j);
13314 Py_DECREF(j);
13315 return r;
13316 }
13317 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
13318 CYTHON_NCP_UNUSED int wraparound,
13319 CYTHON_NCP_UNUSED int boundscheck) {
13320 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
13321 Py_ssize_t wrapped_i = i;
13322 if (wraparound & unlikely(i < 0)) {
13323 wrapped_i += PyList_GET_SIZE(o);
13324 }
13325 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
13326 PyObject *r = PyList_GET_ITEM(o, wrapped_i);
13327 Py_INCREF(r);
13328 return r;
13329 }
13330 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
13331 #else
13332 return PySequence_GetItem(o, i);
13333 #endif
13334 }
13335 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
13336 CYTHON_NCP_UNUSED int wraparound,
13337 CYTHON_NCP_UNUSED int boundscheck) {
13338 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
13339 Py_ssize_t wrapped_i = i;
13340 if (wraparound & unlikely(i < 0)) {
13341 wrapped_i += PyTuple_GET_SIZE(o);
13342 }
13343 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
13344 PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
13345 Py_INCREF(r);
13346 return r;
13347 }
13348 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
13349 #else
13350 return PySequence_GetItem(o, i);
13351 #endif
13352 }
13353 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
13354 CYTHON_NCP_UNUSED int wraparound,
13355 CYTHON_NCP_UNUSED int boundscheck) {
13356 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
13357 if (is_list || PyList_CheckExact(o)) {
13358 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
13359 if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
13360 PyObject *r = PyList_GET_ITEM(o, n);
13361 Py_INCREF(r);
13362 return r;
13363 }
13364 }
13365 else if (PyTuple_CheckExact(o)) {
13366 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
13367 if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
13368 PyObject *r = PyTuple_GET_ITEM(o, n);
13369 Py_INCREF(r);
13370 return r;
13371 }
13372 } else {
13373 PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
13374 PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
13375 if (mm && mm->mp_subscript) {
13376 PyObject *r, *key = PyInt_FromSsize_t(i);
13377 if (unlikely(!key)) return NULL;
13378 r = mm->mp_subscript(o, key);
13379 Py_DECREF(key);
13380 return r;
13381 }
13382 if (likely(sm && sm->sq_item)) {
13383 if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
13384 Py_ssize_t l = sm->sq_length(o);
13385 if (likely(l >= 0)) {
13386 i += l;
13387 } else {
13388 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
13389 return NULL;
13390 PyErr_Clear();
13391 }
13392 }
13393 return sm->sq_item(o, i);
13394 }
13395 }
13396 #else
13397 if (is_list || !PyMapping_Check(o)) {
13398 return PySequence_GetItem(o, i);
13399 }
13400 #endif
13401 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
13402 }
13403
13404 /* SetItemInt */
13405 static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
13406 int r;
13407 if (unlikely(!j)) return -1;
13408 r = PyObject_SetItem(o, j, v);
13409 Py_DECREF(j);
13410 return r;
13411 }
13412 static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
13413 CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
13414 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
13415 if (is_list || PyList_CheckExact(o)) {
13416 Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
13417 if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) {
13418 PyObject* old = PyList_GET_ITEM(o, n);
13419 Py_INCREF(v);
13420 PyList_SET_ITEM(o, n, v);
13421 Py_DECREF(old);
13422 return 1;
13423 }
13424 } else {
13425 PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
13426 PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
13427 if (mm && mm->mp_ass_subscript) {
13428 int r;
13429 PyObject *key = PyInt_FromSsize_t(i);
13430 if (unlikely(!key)) return -1;
13431 r = mm->mp_ass_subscript(o, key, v);
13432 Py_DECREF(key);
13433 return r;
13434 }
13435 if (likely(sm && sm->sq_ass_item)) {
13436 if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
13437 Py_ssize_t l = sm->sq_length(o);
13438 if (likely(l >= 0)) {
13439 i += l;
13440 } else {
13441 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
13442 return -1;
13443 PyErr_Clear();
13444 }
13445 }
13446 return sm->sq_ass_item(o, i, v);
13447 }
13448 }
13449 #else
13450 if (is_list || !PyMapping_Check(o))
13451 {
13452 return PySequence_SetItem(o, i, v);
13453 }
13454 #endif
13455 return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
13456 }
13457
13458 /* PyFunctionFastCall */
13459 #if CYTHON_FAST_PYCALL && !CYTHON_VECTORCALL
13460 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
13461 PyObject *globals) {
13462 PyFrameObject *f;
13463 PyThreadState *tstate = __Pyx_PyThreadState_Current;
13464 PyObject **fastlocals;
13465 Py_ssize_t i;
13466 PyObject *result;
13467 assert(globals != NULL);
13468 /* XXX Perhaps we should create a specialized
13469 PyFrame_New() that doesn't take locals, but does
13470 take builtins without sanity checking them.
13471 */
13472 assert(tstate != NULL);
13473 f = PyFrame_New(tstate, co, globals, NULL);
13474 if (f == NULL) {
13475 return NULL;
13476 }
13477 fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
13478 for (i = 0; i < na; i++) {
13479 Py_INCREF(*args);
13480 fastlocals[i] = *args++;
13481 }
13482 result = PyEval_EvalFrameEx(f,0);
13483 ++tstate->recursion_depth;
13484 Py_DECREF(f);
13485 --tstate->recursion_depth;
13486 return result;
13487 }
13488 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
13489 PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
13490 PyObject *globals = PyFunction_GET_GLOBALS(func);
13491 PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
13492 PyObject *closure;
13493 #if PY_MAJOR_VERSION >= 3
13494 PyObject *kwdefs;
13495 #endif
13496 PyObject *kwtuple, **k;
13497 PyObject **d;
13498 Py_ssize_t nd;
13499 Py_ssize_t nk;
13500 PyObject *result;
13501 assert(kwargs == NULL || PyDict_Check(kwargs));
13502 nk = kwargs ? PyDict_Size(kwargs) : 0;
13503 #if PY_MAJOR_VERSION < 3
13504 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) {
13505 return NULL;
13506 }
13507 #else
13508 if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) {
13509 return NULL;
13510 }
13511 #endif
13512 if (
13513 #if PY_MAJOR_VERSION >= 3
13514 co->co_kwonlyargcount == 0 &&
13515 #endif
13516 likely(kwargs == NULL || nk == 0) &&
13517 co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
13518 if (argdefs == NULL && co->co_argcount == nargs) {
13519 result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
13520 goto done;
13521 }
13522 else if (nargs == 0 && argdefs != NULL
13523 && co->co_argcount == Py_SIZE(argdefs)) {
13524 /* function called with no arguments, but all parameters have
13525 a default value: use default values as arguments .*/
13526 args = &PyTuple_GET_ITEM(argdefs, 0);
13527 result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
13528 goto done;
13529 }
13530 }
13531 if (kwargs != NULL) {
13532 Py_ssize_t pos, i;
13533 kwtuple = PyTuple_New(2 * nk);
13534 if (kwtuple == NULL) {
13535 result = NULL;
13536 goto done;
13537 }
13538 k = &PyTuple_GET_ITEM(kwtuple, 0);
13539 pos = i = 0;
13540 while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
13541 Py_INCREF(k[i]);
13542 Py_INCREF(k[i+1]);
13543 i += 2;
13544 }
13545 nk = i / 2;
13546 }
13547 else {
13548 kwtuple = NULL;
13549 k = NULL;
13550 }
13551 closure = PyFunction_GET_CLOSURE(func);
13552 #if PY_MAJOR_VERSION >= 3
13553 kwdefs = PyFunction_GET_KW_DEFAULTS(func);
13554 #endif
13555 if (argdefs != NULL) {
13556 d = &PyTuple_GET_ITEM(argdefs, 0);
13557 nd = Py_SIZE(argdefs);
13558 }
13559 else {
13560 d = NULL;
13561 nd = 0;
13562 }
13563 #if PY_MAJOR_VERSION >= 3
13564 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
13565 args, (int)nargs,
13566 k, (int)nk,
13567 d, (int)nd, kwdefs, closure);
13568 #else
13569 result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
13570 args, (int)nargs,
13571 k, (int)nk,
13572 d, (int)nd, closure);
13573 #endif
13574 Py_XDECREF(kwtuple);
13575 done:
13576 Py_LeaveRecursiveCall();
13577 return result;
13578 }
13579 #endif
13580
13581 /* PyObjectCallMethO */
13582 #if CYTHON_COMPILING_IN_CPYTHON
13583 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
13584 PyObject *self, *result;
13585 PyCFunction cfunc;
13586 cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func);
13587 self = __Pyx_CyOrPyCFunction_GET_SELF(func);
13588 #if PY_MAJOR_VERSION < 3
13589 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
13590 return NULL;
13591 #else
13592 if (unlikely(Py_EnterRecursiveCall(" while calling a Python object")))
13593 return NULL;
13594 #endif
13595 result = cfunc(self, arg);
13596 Py_LeaveRecursiveCall();
13597 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
13598 PyErr_SetString(
13599 PyExc_SystemError,
13600 "NULL result without error in PyObject_Call");
13601 }
13602 return result;
13603 }
13604 #endif
13605
13606 /* PyObjectFastCall */
13607 #if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API
13608 static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject **args, size_t nargs, PyObject *kwargs) {
13609 PyObject *argstuple;
13610 PyObject *result = 0;
13611 size_t i;
13612 argstuple = PyTuple_New((Py_ssize_t)nargs);
13613 if (unlikely(!argstuple)) return NULL;
13614 for (i = 0; i < nargs; i++) {
13615 Py_INCREF(args[i]);
13616 if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) < 0) goto bad;
13617 }
13618 result = __Pyx_PyObject_Call(func, argstuple, kwargs);
13619 bad:
13620 Py_DECREF(argstuple);
13621 return result;
13622 }
13623 #endif
13624 static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject **args, size_t _nargs, PyObject *kwargs) {
13625 Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs);
13626 #if CYTHON_COMPILING_IN_CPYTHON
13627 if (nargs == 0 && kwargs == NULL) {
13628 if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS))
13629 return __Pyx_PyObject_CallMethO(func, NULL);
13630 }
13631 else if (nargs == 1 && kwargs == NULL) {
13632 if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O))
13633 return __Pyx_PyObject_CallMethO(func, args[0]);
13634 }
13635 #endif
13636 #if PY_VERSION_HEX < 0x030800B1
13637 #if CYTHON_FAST_PYCCALL
13638 if (PyCFunction_Check(func)) {
13639 if (kwargs) {
13640 return _PyCFunction_FastCallDict(func, args, nargs, kwargs);
13641 } else {
13642 return _PyCFunction_FastCallKeywords(func, args, nargs, NULL);
13643 }
13644 }
13645 #if PY_VERSION_HEX >= 0x030700A1
13646 if (!kwargs && __Pyx_IS_TYPE(func, &PyMethodDescr_Type)) {
13647 return _PyMethodDescr_FastCallKeywords(func, args, nargs, NULL);
13648 }
13649 #endif
13650 #endif
13651 #if CYTHON_FAST_PYCALL
13652 if (PyFunction_Check(func)) {
13653 return __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs);
13654 }
13655 #endif
13656 #endif
13657 if (kwargs == NULL) {
13658 #if CYTHON_VECTORCALL
13659 #if PY_VERSION_HEX < 0x03090000
13660 vectorcallfunc f = _PyVectorcall_Function(func);
13661 #else
13662 vectorcallfunc f = PyVectorcall_Function(func);
13663 #endif
13664 if (f) {
13665 return f(func, args, (size_t)nargs, NULL);
13666 }
13667 #elif defined(__Pyx_CyFunction_USED) && CYTHON_BACKPORT_VECTORCALL
13668 if (__Pyx_CyFunction_CheckExact(func)) {
13669 __pyx_vectorcallfunc f = __Pyx_CyFunction_func_vectorcall(func);
13670 if (f) return f(func, args, (size_t)nargs, NULL);
13671 }
13672 #endif
13673 }
13674 if (nargs == 0) {
13675 return __Pyx_PyObject_Call(func, __pyx_empty_tuple, kwargs);
13676 }
13677 #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API
13678 return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs);
13679 #else
13680 return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs);
13681 #endif
13682 }
13683
13684 /* ArgTypeTest */
13685 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
13686 {
13687 __Pyx_TypeName type_name;
13688 __Pyx_TypeName obj_type_name;
13689 if (unlikely(!type)) {
13690 PyErr_SetString(PyExc_SystemError, "Missing type object");
13691 return 0;
13692 }
13693 else if (exact) {
13694 #if PY_MAJOR_VERSION == 2
13695 if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
13696 #endif
13697 }
13698 else {
13699 if (likely(__Pyx_TypeCheck(obj, type))) return 1;
13700 }
13701 type_name = __Pyx_PyType_GetName(type);
13702 obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
13703 PyErr_Format(PyExc_TypeError,
13704 "Argument '%.200s' has incorrect type (expected " __Pyx_FMT_TYPENAME
13705 ", got " __Pyx_FMT_TYPENAME ")", name, type_name, obj_type_name);
13706 __Pyx_DECREF_TypeName(type_name);
13707 __Pyx_DECREF_TypeName(obj_type_name);
13708 return 0;
13709 }
13710
13711 /* ExtTypeTest */
13712 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
13713 __Pyx_TypeName obj_type_name;
13714 __Pyx_TypeName type_name;
13715 if (unlikely(!type)) {
13716 PyErr_SetString(PyExc_SystemError, "Missing type object");
13717 return 0;
13718 }
13719 if (likely(__Pyx_TypeCheck(obj, type)))
13720 return 1;
13721 obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
13722 type_name = __Pyx_PyType_GetName(type);
13723 PyErr_Format(PyExc_TypeError,
13724 "Cannot convert " __Pyx_FMT_TYPENAME " to " __Pyx_FMT_TYPENAME,
13725 obj_type_name, type_name);
13726 __Pyx_DECREF_TypeName(obj_type_name);
13727 __Pyx_DECREF_TypeName(type_name);
13728 return 0;
13729 }
13730
13731 /* PyObjectCallOneArg */
13732 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
13733 PyObject *args[2] = {NULL, arg};
13734 return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
13735 }
13736
13737 /* ObjectGetItem */
13738 #if CYTHON_USE_TYPE_SLOTS
13739 static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject *index) {
13740 PyObject *runerr = NULL;
13741 Py_ssize_t key_value;
13742 key_value = __Pyx_PyIndex_AsSsize_t(index);
13743 if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
13744 return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
13745 }
13746 if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
13747 __Pyx_TypeName index_type_name = __Pyx_PyType_GetName(Py_TYPE(index));
13748 PyErr_Clear();
13749 PyErr_Format(PyExc_IndexError,
13750 "cannot fit '" __Pyx_FMT_TYPENAME "' into an index-sized integer", index_type_name);
13751 __Pyx_DECREF_TypeName(index_type_name);
13752 }
13753 return NULL;
13754 }
13755 static PyObject *__Pyx_PyObject_GetItem_Slow(PyObject *obj, PyObject *key) {
13756 __Pyx_TypeName obj_type_name;
13757 if (likely(PyType_Check(obj))) {
13758 PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(obj, __pyx_n_s_class_getitem);
13759 if (!meth) {
13760 PyErr_Clear();
13761 } else {
13762 PyObject *result = __Pyx_PyObject_CallOneArg(meth, key);
13763 Py_DECREF(meth);
13764 return result;
13765 }
13766 }
13767 obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
13768 PyErr_Format(PyExc_TypeError,
13769 "'" __Pyx_FMT_TYPENAME "' object is not subscriptable", obj_type_name);
13770 __Pyx_DECREF_TypeName(obj_type_name);
13771 return NULL;
13772 }
13773 static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key) {
13774 PyTypeObject *tp = Py_TYPE(obj);
13775 PyMappingMethods *mm = tp->tp_as_mapping;
13776 PySequenceMethods *sm = tp->tp_as_sequence;
13777 if (likely(mm && mm->mp_subscript)) {
13778 return mm->mp_subscript(obj, key);
13779 }
13780 if (likely(sm && sm->sq_item)) {
13781 return __Pyx_PyObject_GetIndex(obj, key);
13782 }
13783 return __Pyx_PyObject_GetItem_Slow(obj, key);
13784 }
13785 #endif
13786
13787 /* RaiseUnexpectedTypeError */
13788 static int
13789 __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj)
13790 {
13791 __Pyx_TypeName obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
13792 PyErr_Format(PyExc_TypeError, "Expected %s, got " __Pyx_FMT_TYPENAME,
13793 expected, obj_type_name);
13794 __Pyx_DECREF_TypeName(obj_type_name);
13795 return 0;
13796 }
13797
13798 /* PyDictVersioning */
13799 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
13800 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
13801 PyObject *dict = Py_TYPE(obj)->tp_dict;
13802 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
13803 }
13804 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
13805 PyObject **dictptr = NULL;
13806 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
13807 if (offset) {
13808 #if CYTHON_COMPILING_IN_CPYTHON
13809 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
13810 #else
13811 dictptr = _PyObject_GetDictPtr(obj);
13812 #endif
13813 }
13814 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
13815 }
13816 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
13817 PyObject *dict = Py_TYPE(obj)->tp_dict;
13818 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
13819 return 0;
13820 return obj_dict_version == __Pyx_get_object_dict_version(obj);
13821 }
13822 #endif
13823
13824 /* GetModuleGlobalName */
13825 #if CYTHON_USE_DICT_VERSIONS
13826 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
13827 #else
13828 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
13829 #endif
13830 {
13831 PyObject *result;
13832 #if !CYTHON_AVOID_BORROWED_REFS
13833 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && PY_VERSION_HEX < 0x030d0000
13834 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
13835 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
13836 if (likely(result)) {
13837 return __Pyx_NewRef(result);
13838 } else if (unlikely(PyErr_Occurred())) {
13839 return NULL;
13840 }
13841 #elif CYTHON_COMPILING_IN_LIMITED_API
13842 if (unlikely(!__pyx_m)) {
13843 return NULL;
13844 }
13845 result = PyObject_GetAttr(__pyx_m, name);
13846 if (likely(result)) {
13847 return result;
13848 }
13849 #else
13850 result = PyDict_GetItem(__pyx_d, name);
13851 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
13852 if (likely(result)) {
13853 return __Pyx_NewRef(result);
13854 }
13855 #endif
13856 #else
13857 result = PyObject_GetItem(__pyx_d, name);
13858 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
13859 if (likely(result)) {
13860 return __Pyx_NewRef(result);
13861 }
13862 PyErr_Clear();
13863 #endif
13864 return __Pyx_GetBuiltinName(name);
13865 }
13866
13867 /* RaiseException */
13868 #if PY_MAJOR_VERSION < 3
13869 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
13870 __Pyx_PyThreadState_declare
13871 CYTHON_UNUSED_VAR(cause);
13872 Py_XINCREF(type);
13873 if (!value || value == Py_None)
13874 value = NULL;
13875 else
13876 Py_INCREF(value);
13877 if (!tb || tb == Py_None)
13878 tb = NULL;
13879 else {
13880 Py_INCREF(tb);
13881 if (!PyTraceBack_Check(tb)) {
13882 PyErr_SetString(PyExc_TypeError,
13883 "raise: arg 3 must be a traceback or None");
13884 goto raise_error;
13885 }
13886 }
13887 if (PyType_Check(type)) {
13888 #if CYTHON_COMPILING_IN_PYPY
13889 if (!value) {
13890 Py_INCREF(Py_None);
13891 value = Py_None;
13892 }
13893 #endif
13894 PyErr_NormalizeException(&type, &value, &tb);
13895 } else {
13896 if (value) {
13897 PyErr_SetString(PyExc_TypeError,
13898 "instance exception may not have a separate value");
13899 goto raise_error;
13900 }
13901 value = type;
13902 type = (PyObject*) Py_TYPE(type);
13903 Py_INCREF(type);
13904 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
13905 PyErr_SetString(PyExc_TypeError,
13906 "raise: exception class must be a subclass of BaseException");
13907 goto raise_error;
13908 }
13909 }
13910 __Pyx_PyThreadState_assign
13911 __Pyx_ErrRestore(type, value, tb);
13912 return;
13913 raise_error:
13914 Py_XDECREF(value);
13915 Py_XDECREF(type);
13916 Py_XDECREF(tb);
13917 return;
13918 }
13919 #else
13920 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
13921 PyObject* owned_instance = NULL;
13922 if (tb == Py_None) {
13923 tb = 0;
13924 } else if (tb && !PyTraceBack_Check(tb)) {
13925 PyErr_SetString(PyExc_TypeError,
13926 "raise: arg 3 must be a traceback or None");
13927 goto bad;
13928 }
13929 if (value == Py_None)
13930 value = 0;
13931 if (PyExceptionInstance_Check(type)) {
13932 if (value) {
13933 PyErr_SetString(PyExc_TypeError,
13934 "instance exception may not have a separate value");
13935 goto bad;
13936 }
13937 value = type;
13938 type = (PyObject*) Py_TYPE(value);
13939 } else if (PyExceptionClass_Check(type)) {
13940 PyObject *instance_class = NULL;
13941 if (value && PyExceptionInstance_Check(value)) {
13942 instance_class = (PyObject*) Py_TYPE(value);
13943 if (instance_class != type) {
13944 int is_subclass = PyObject_IsSubclass(instance_class, type);
13945 if (!is_subclass) {
13946 instance_class = NULL;
13947 } else if (unlikely(is_subclass == -1)) {
13948 goto bad;
13949 } else {
13950 type = instance_class;
13951 }
13952 }
13953 }
13954 if (!instance_class) {
13955 PyObject *args;
13956 if (!value)
13957 args = PyTuple_New(0);
13958 else if (PyTuple_Check(value)) {
13959 Py_INCREF(value);
13960 args = value;
13961 } else
13962 args = PyTuple_Pack(1, value);
13963 if (!args)
13964 goto bad;
13965 owned_instance = PyObject_Call(type, args, NULL);
13966 Py_DECREF(args);
13967 if (!owned_instance)
13968 goto bad;
13969 value = owned_instance;
13970 if (!PyExceptionInstance_Check(value)) {
13971 PyErr_Format(PyExc_TypeError,
13972 "calling %R should have returned an instance of "
13973 "BaseException, not %R",
13974 type, Py_TYPE(value));
13975 goto bad;
13976 }
13977 }
13978 } else {
13979 PyErr_SetString(PyExc_TypeError,
13980 "raise: exception class must be a subclass of BaseException");
13981 goto bad;
13982 }
13983 if (cause) {
13984 PyObject *fixed_cause;
13985 if (cause == Py_None) {
13986 fixed_cause = NULL;
13987 } else if (PyExceptionClass_Check(cause)) {
13988 fixed_cause = PyObject_CallObject(cause, NULL);
13989 if (fixed_cause == NULL)
13990 goto bad;
13991 } else if (PyExceptionInstance_Check(cause)) {
13992 fixed_cause = cause;
13993 Py_INCREF(fixed_cause);
13994 } else {
13995 PyErr_SetString(PyExc_TypeError,
13996 "exception causes must derive from "
13997 "BaseException");
13998 goto bad;
13999 }
14000 PyException_SetCause(value, fixed_cause);
14001 }
14002 PyErr_SetObject(type, value);
14003 if (tb) {
14004 #if PY_VERSION_HEX >= 0x030C00A6
14005 PyException_SetTraceback(value, tb);
14006 #elif CYTHON_FAST_THREAD_STATE
14007 PyThreadState *tstate = __Pyx_PyThreadState_Current;
14008 PyObject* tmp_tb = tstate->curexc_traceback;
14009 if (tb != tmp_tb) {
14010 Py_INCREF(tb);
14011 tstate->curexc_traceback = tb;
14012 Py_XDECREF(tmp_tb);
14013 }
14014 #else
14015 PyObject *tmp_type, *tmp_value, *tmp_tb;
14016 PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
14017 Py_INCREF(tb);
14018 PyErr_Restore(tmp_type, tmp_value, tb);
14019 Py_XDECREF(tmp_tb);
14020 #endif
14021 }
14022 bad:
14023 Py_XDECREF(owned_instance);
14024 return;
14025 }
14026 #endif
14027
14028 /* GetTopmostException */
14029 #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
14030 static _PyErr_StackItem *
14031 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
14032 {
14033 _PyErr_StackItem *exc_info = tstate->exc_info;
14034 while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) &&
14035 exc_info->previous_item != NULL)
14036 {
14037 exc_info = exc_info->previous_item;
14038 }
14039 return exc_info;
14040 }
14041 #endif
14042
14043 /* SaveResetException */
14044 #if CYTHON_FAST_THREAD_STATE
14045 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
14046 #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
14047 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
14048 PyObject *exc_value = exc_info->exc_value;
14049 if (exc_value == NULL || exc_value == Py_None) {
14050 *value = NULL;
14051 *type = NULL;
14052 *tb = NULL;
14053 } else {
14054 *value = exc_value;
14055 Py_INCREF(*value);
14056 *type = (PyObject*) Py_TYPE(exc_value);
14057 Py_INCREF(*type);
14058 *tb = PyException_GetTraceback(exc_value);
14059 }
14060 #elif CYTHON_USE_EXC_INFO_STACK
14061 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
14062 *type = exc_info->exc_type;
14063 *value = exc_info->exc_value;
14064 *tb = exc_info->exc_traceback;
14065 Py_XINCREF(*type);
14066 Py_XINCREF(*value);
14067 Py_XINCREF(*tb);
14068 #else
14069 *type = tstate->exc_type;
14070 *value = tstate->exc_value;
14071 *tb = tstate->exc_traceback;
14072 Py_XINCREF(*type);
14073 Py_XINCREF(*value);
14074 Py_XINCREF(*tb);
14075 #endif
14076 }
14077 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
14078 #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
14079 _PyErr_StackItem *exc_info = tstate->exc_info;
14080 PyObject *tmp_value = exc_info->exc_value;
14081 exc_info->exc_value = value;
14082 Py_XDECREF(tmp_value);
14083 Py_XDECREF(type);
14084 Py_XDECREF(tb);
14085 #else
14086 PyObject *tmp_type, *tmp_value, *tmp_tb;
14087 #if CYTHON_USE_EXC_INFO_STACK
14088 _PyErr_StackItem *exc_info = tstate->exc_info;
14089 tmp_type = exc_info->exc_type;
14090 tmp_value = exc_info->exc_value;
14091 tmp_tb = exc_info->exc_traceback;
14092 exc_info->exc_type = type;
14093 exc_info->exc_value = value;
14094 exc_info->exc_traceback = tb;
14095 #else
14096 tmp_type = tstate->exc_type;
14097 tmp_value = tstate->exc_value;
14098 tmp_tb = tstate->exc_traceback;
14099 tstate->exc_type = type;
14100 tstate->exc_value = value;
14101 tstate->exc_traceback = tb;
14102 #endif
14103 Py_XDECREF(tmp_type);
14104 Py_XDECREF(tmp_value);
14105 Py_XDECREF(tmp_tb);
14106 #endif
14107 }
14108 #endif
14109
14110 /* GetException */
14111 #if CYTHON_FAST_THREAD_STATE
14112 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
14113 #else
14114 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
14115 #endif
14116 {
14117 PyObject *local_type = NULL, *local_value, *local_tb = NULL;
14118 #if CYTHON_FAST_THREAD_STATE
14119 PyObject *tmp_type, *tmp_value, *tmp_tb;
14120 #if PY_VERSION_HEX >= 0x030C00A6
14121 local_value = tstate->current_exception;
14122 tstate->current_exception = 0;
14123 if (likely(local_value)) {
14124 local_type = (PyObject*) Py_TYPE(local_value);
14125 Py_INCREF(local_type);
14126 local_tb = PyException_GetTraceback(local_value);
14127 }
14128 #else
14129 local_type = tstate->curexc_type;
14130 local_value = tstate->curexc_value;
14131 local_tb = tstate->curexc_traceback;
14132 tstate->curexc_type = 0;
14133 tstate->curexc_value = 0;
14134 tstate->curexc_traceback = 0;
14135 #endif
14136 #else
14137 PyErr_Fetch(&local_type, &local_value, &local_tb);
14138 #endif
14139 PyErr_NormalizeException(&local_type, &local_value, &local_tb);
14140 #if CYTHON_FAST_THREAD_STATE && PY_VERSION_HEX >= 0x030C00A6
14141 if (unlikely(tstate->current_exception))
14142 #elif CYTHON_FAST_THREAD_STATE
14143 if (unlikely(tstate->curexc_type))
14144 #else
14145 if (unlikely(PyErr_Occurred()))
14146 #endif
14147 goto bad;
14148 #if PY_MAJOR_VERSION >= 3
14149 if (local_tb) {
14150 if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
14151 goto bad;
14152 }
14153 #endif
14154 Py_XINCREF(local_tb);
14155 Py_XINCREF(local_type);
14156 Py_XINCREF(local_value);
14157 *type = local_type;
14158 *value = local_value;
14159 *tb = local_tb;
14160 #if CYTHON_FAST_THREAD_STATE
14161 #if CYTHON_USE_EXC_INFO_STACK
14162 {
14163 _PyErr_StackItem *exc_info = tstate->exc_info;
14164 #if PY_VERSION_HEX >= 0x030B00a4
14165 tmp_value = exc_info->exc_value;
14166 exc_info->exc_value = local_value;
14167 tmp_type = NULL;
14168 tmp_tb = NULL;
14169 Py_XDECREF(local_type);
14170 Py_XDECREF(local_tb);
14171 #else
14172 tmp_type = exc_info->exc_type;
14173 tmp_value = exc_info->exc_value;
14174 tmp_tb = exc_info->exc_traceback;
14175 exc_info->exc_type = local_type;
14176 exc_info->exc_value = local_value;
14177 exc_info->exc_traceback = local_tb;
14178 #endif
14179 }
14180 #else
14181 tmp_type = tstate->exc_type;
14182 tmp_value = tstate->exc_value;
14183 tmp_tb = tstate->exc_traceback;
14184 tstate->exc_type = local_type;
14185 tstate->exc_value = local_value;
14186 tstate->exc_traceback = local_tb;
14187 #endif
14188 Py_XDECREF(tmp_type);
14189 Py_XDECREF(tmp_value);
14190 Py_XDECREF(tmp_tb);
14191 #else
14192 PyErr_SetExcInfo(local_type, local_value, local_tb);
14193 #endif
14194 return 0;
14195 bad:
14196 *type = 0;
14197 *value = 0;
14198 *tb = 0;
14199 Py_XDECREF(local_type);
14200 Py_XDECREF(local_value);
14201 Py_XDECREF(local_tb);
14202 return -1;
14203 }
14204
14205 /* RaiseTooManyValuesToUnpack */
14206 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
14207 PyErr_Format(PyExc_ValueError,
14208 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
14209 }
14210
14211 /* RaiseNeedMoreValuesToUnpack */
14212 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
14213 PyErr_Format(PyExc_ValueError,
14214 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
14215 index, (index == 1) ? "" : "s");
14216 }
14217
14218 /* IterFinish */
14219 static CYTHON_INLINE int __Pyx_IterFinish(void) {
14220 PyObject* exc_type;
14221 __Pyx_PyThreadState_declare
14222 __Pyx_PyThreadState_assign
14223 exc_type = __Pyx_PyErr_CurrentExceptionType();
14224 if (unlikely(exc_type)) {
14225 if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
14226 return -1;
14227 __Pyx_PyErr_Clear();
14228 return 0;
14229 }
14230 return 0;
14231 }
14232
14233 /* UnpackItemEndCheck */
14234 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
14235 if (unlikely(retval)) {
14236 Py_DECREF(retval);
14237 __Pyx_RaiseTooManyValuesError(expected);
14238 return -1;
14239 }
14240 return __Pyx_IterFinish();
14241 }
14242
14243 /* PyIntBinop */
14244 #if !CYTHON_COMPILING_IN_PYPY
14245 static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
14246 CYTHON_MAYBE_UNUSED_VAR(intval);
14247 CYTHON_MAYBE_UNUSED_VAR(inplace);
14248 CYTHON_UNUSED_VAR(zerodivision_check);
14249 #if PY_MAJOR_VERSION < 3
14250 if (likely(PyInt_CheckExact(op1))) {
14251 const long b = intval;
14252 long x;
14253 long a = PyInt_AS_LONG(op1);
14254
14255 x = (long)((unsigned long)a - (unsigned long)b);
14256 if (likely((x^a) >= 0 || (x^~b) >= 0))
14257 return PyInt_FromLong(x);
14258 return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
14259 }
14260 #endif
14261 #if CYTHON_USE_PYLONG_INTERNALS
14262 if (likely(PyLong_CheckExact(op1))) {
14263 const long b = intval;
14264 long a, x;
14265 #ifdef HAVE_LONG_LONG
14266 const PY_LONG_LONG llb = intval;
14267 PY_LONG_LONG lla, llx;
14268 #endif
14269 if (unlikely(__Pyx_PyLong_IsZero(op1))) {
14270 return PyLong_FromLong(-intval);
14271 }
14272 if (likely(__Pyx_PyLong_IsCompact(op1))) {
14273 a = __Pyx_PyLong_CompactValue(op1);
14274 } else {
14275 const digit* digits = __Pyx_PyLong_Digits(op1);
14276 const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(op1);
14277 switch (size) {
14278 case -2:
14279 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
14280 a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
14281 break;
14282 #ifdef HAVE_LONG_LONG
14283 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
14284 lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
14285 goto long_long;
14286 #endif
14287 }
14288 CYTHON_FALLTHROUGH;
14289 case 2:
14290 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
14291 a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
14292 break;
14293 #ifdef HAVE_LONG_LONG
14294 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
14295 lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
14296 goto long_long;
14297 #endif
14298 }
14299 CYTHON_FALLTHROUGH;
14300 case -3:
14301 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
14302 a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
14303 break;
14304 #ifdef HAVE_LONG_LONG
14305 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
14306 lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
14307 goto long_long;
14308 #endif
14309 }
14310 CYTHON_FALLTHROUGH;
14311 case 3:
14312 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
14313 a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
14314 break;
14315 #ifdef HAVE_LONG_LONG
14316 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
14317 lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
14318 goto long_long;
14319 #endif
14320 }
14321 CYTHON_FALLTHROUGH;
14322 case -4:
14323 if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
14324 a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
14325 break;
14326 #ifdef HAVE_LONG_LONG
14327 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
14328 lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
14329 goto long_long;
14330 #endif
14331 }
14332 CYTHON_FALLTHROUGH;
14333 case 4:
14334 if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
14335 a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
14336 break;
14337 #ifdef HAVE_LONG_LONG
14338 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
14339 lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
14340 goto long_long;
14341 #endif
14342 }
14343 CYTHON_FALLTHROUGH;
14344 default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
14345 }
14346 }
14347 x = a - b;
14348 return PyLong_FromLong(x);
14349 #ifdef HAVE_LONG_LONG
14350 long_long:
14351 llx = lla - llb;
14352 return PyLong_FromLongLong(llx);
14353 #endif
14354
14355
14356 }
14357 #endif
14358 if (PyFloat_CheckExact(op1)) {
14359 const long b = intval;
14360 #if CYTHON_COMPILING_IN_LIMITED_API
14361 double a = __pyx_PyFloat_AsDouble(op1);
14362 #else
14363 double a = PyFloat_AS_DOUBLE(op1);
14364 #endif
14365 double result;
14366
14367 PyFPE_START_PROTECT("subtract", return NULL)
14368 result = ((double)a) - (double)b;
14369 PyFPE_END_PROTECT(result)
14370 return PyFloat_FromDouble(result);
14371 }
14372 return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
14373 }
14374 #endif
14375
14376 /* PyObjectLookupSpecial */
14377 #if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
14378 static CYTHON_INLINE PyObject* __Pyx__PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name, int with_error) {
14379 PyObject *res;
14380 PyTypeObject *tp = Py_TYPE(obj);
14381 #if PY_MAJOR_VERSION < 3
14382 if (unlikely(PyInstance_Check(obj)))
14383 return with_error ? __Pyx_PyObject_GetAttrStr(obj, attr_name) : __Pyx_PyObject_GetAttrStrNoError(obj, attr_name);
14384 #endif
14385 res = _PyType_Lookup(tp, attr_name);
14386 if (likely(res)) {
14387 descrgetfunc f = Py_TYPE(res)->tp_descr_get;
14388 if (!f) {
14389 Py_INCREF(res);
14390 } else {
14391 res = f(res, obj, (PyObject *)tp);
14392 }
14393 } else if (with_error) {
14394 PyErr_SetObject(PyExc_AttributeError, attr_name);
14395 }
14396 return res;
14397 }
14398 #endif
14399
14400 /* SwapException */
14401 #if CYTHON_FAST_THREAD_STATE
14402 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
14403 PyObject *tmp_type, *tmp_value, *tmp_tb;
14404 #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
14405 _PyErr_StackItem *exc_info = tstate->exc_info;
14406 tmp_value = exc_info->exc_value;
14407 exc_info->exc_value = *value;
14408 if (tmp_value == NULL || tmp_value == Py_None) {
14409 Py_XDECREF(tmp_value);
14410 tmp_value = NULL;
14411 tmp_type = NULL;
14412 tmp_tb = NULL;
14413 } else {
14414 tmp_type = (PyObject*) Py_TYPE(tmp_value);
14415 Py_INCREF(tmp_type);
14416 #if CYTHON_COMPILING_IN_CPYTHON
14417 tmp_tb = ((PyBaseExceptionObject*) tmp_value)->traceback;
14418 Py_XINCREF(tmp_tb);
14419 #else
14420 tmp_tb = PyException_GetTraceback(tmp_value);
14421 #endif
14422 }
14423 #elif CYTHON_USE_EXC_INFO_STACK
14424 _PyErr_StackItem *exc_info = tstate->exc_info;
14425 tmp_type = exc_info->exc_type;
14426 tmp_value = exc_info->exc_value;
14427 tmp_tb = exc_info->exc_traceback;
14428 exc_info->exc_type = *type;
14429 exc_info->exc_value = *value;
14430 exc_info->exc_traceback = *tb;
14431 #else
14432 tmp_type = tstate->exc_type;
14433 tmp_value = tstate->exc_value;
14434 tmp_tb = tstate->exc_traceback;
14435 tstate->exc_type = *type;
14436 tstate->exc_value = *value;
14437 tstate->exc_traceback = *tb;
14438 #endif
14439 *type = tmp_type;
14440 *value = tmp_value;
14441 *tb = tmp_tb;
14442 }
14443 #else
14444 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
14445 PyObject *tmp_type, *tmp_value, *tmp_tb;
14446 PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
14447 PyErr_SetExcInfo(*type, *value, *tb);
14448 *type = tmp_type;
14449 *value = tmp_value;
14450 *tb = tmp_tb;
14451 }
14452 #endif
14453
14454 /* PyIntCompare */
14455 static CYTHON_INLINE int __Pyx_PyInt_BoolEqObjC(PyObject *op1, PyObject *op2, long intval, long inplace) {
14456 CYTHON_MAYBE_UNUSED_VAR(intval);
14457 CYTHON_UNUSED_VAR(inplace);
14458 if (op1 == op2) {
14459 return 1;
14460 }
14461 #if PY_MAJOR_VERSION < 3
14462 if (likely(PyInt_CheckExact(op1))) {
14463 const long b = intval;
14464 long a = PyInt_AS_LONG(op1);
14465 return (a == b);
14466 }
14467 #endif
14468 #if CYTHON_USE_PYLONG_INTERNALS
14469 if (likely(PyLong_CheckExact(op1))) {
14470 int unequal;
14471 unsigned long uintval;
14472 Py_ssize_t size = __Pyx_PyLong_DigitCount(op1);
14473 const digit* digits = __Pyx_PyLong_Digits(op1);
14474 if (intval == 0) {
14475 return (__Pyx_PyLong_IsZero(op1) == 1);
14476 } else if (intval < 0) {
14477 if (__Pyx_PyLong_IsNonNeg(op1))
14478 return 0;
14479 intval = -intval;
14480 } else {
14481 if (__Pyx_PyLong_IsNeg(op1))
14482 return 0;
14483 }
14484 uintval = (unsigned long) intval;
14485 #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
14486 if (uintval >> (PyLong_SHIFT * 4)) {
14487 unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
14488 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
14489 } else
14490 #endif
14491 #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
14492 if (uintval >> (PyLong_SHIFT * 3)) {
14493 unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
14494 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
14495 } else
14496 #endif
14497 #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
14498 if (uintval >> (PyLong_SHIFT * 2)) {
14499 unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
14500 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
14501 } else
14502 #endif
14503 #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
14504 if (uintval >> (PyLong_SHIFT * 1)) {
14505 unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
14506 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
14507 } else
14508 #endif
14509 unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
14510 return (unequal == 0);
14511 }
14512 #endif
14513 if (PyFloat_CheckExact(op1)) {
14514 const long b = intval;
14515 #if CYTHON_COMPILING_IN_LIMITED_API
14516 double a = __pyx_PyFloat_AsDouble(op1);
14517 #else
14518 double a = PyFloat_AS_DOUBLE(op1);
14519 #endif
14520 return ((double)a == (double)b);
14521 }
14522 return __Pyx_PyObject_IsTrueAndDecref(
14523 PyObject_RichCompare(op1, op2, Py_EQ));
14524 }
14525
14526 /* DictGetItem */
14527 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
14528 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
14529 PyObject *value;
14530 value = PyDict_GetItemWithError(d, key);
14531 if (unlikely(!value)) {
14532 if (!PyErr_Occurred()) {
14533 if (unlikely(PyTuple_Check(key))) {
14534 PyObject* args = PyTuple_Pack(1, key);
14535 if (likely(args)) {
14536 PyErr_SetObject(PyExc_KeyError, args);
14537 Py_DECREF(args);
14538 }
14539 } else {
14540 PyErr_SetObject(PyExc_KeyError, key);
14541 }
14542 }
14543 return NULL;
14544 }
14545 Py_INCREF(value);
14546 return value;
14547 }
14548 #endif
14549
14550 /* FixUpExtensionType */
14551 #if CYTHON_USE_TYPE_SPECS
14552 static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type) {
14553 #if PY_VERSION_HEX > 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
14554 CYTHON_UNUSED_VAR(spec);
14555 CYTHON_UNUSED_VAR(type);
14556 #else
14557 const PyType_Slot *slot = spec->slots;
14558 while (slot && slot->slot && slot->slot != Py_tp_members)
14559 slot++;
14560 if (slot && slot->slot == Py_tp_members) {
14561 int changed = 0;
14562 #if !(PY_VERSION_HEX <= 0x030900b1 && CYTHON_COMPILING_IN_CPYTHON)
14563 const
14564 #endif
14565 PyMemberDef *memb = (PyMemberDef*) slot->pfunc;
14566 while (memb && memb->name) {
14567 if (memb->name[0] == '_' && memb->name[1] == '_') {
14568 #if PY_VERSION_HEX < 0x030900b1
14569 if (strcmp(memb->name, "__weaklistoffset__") == 0) {
14570 assert(memb->type == T_PYSSIZET);
14571 assert(memb->flags == READONLY);
14572 type->tp_weaklistoffset = memb->offset;
14573 changed = 1;
14574 }
14575 else if (strcmp(memb->name, "__dictoffset__") == 0) {
14576 assert(memb->type == T_PYSSIZET);
14577 assert(memb->flags == READONLY);
14578 type->tp_dictoffset = memb->offset;
14579 changed = 1;
14580 }
14581 #if CYTHON_METH_FASTCALL
14582 else if (strcmp(memb->name, "__vectorcalloffset__") == 0) {
14583 assert(memb->type == T_PYSSIZET);
14584 assert(memb->flags == READONLY);
14585 #if PY_VERSION_HEX >= 0x030800b4
14586 type->tp_vectorcall_offset = memb->offset;
14587 #else
14588 type->tp_print = (printfunc) memb->offset;
14589 #endif
14590 changed = 1;
14591 }
14592 #endif
14593 #else
14594 if ((0));
14595 #endif
14596 #if PY_VERSION_HEX <= 0x030900b1 && CYTHON_COMPILING_IN_CPYTHON
14597 else if (strcmp(memb->name, "__module__") == 0) {
14598 PyObject *descr;
14599 assert(memb->type == T_OBJECT);
14600 assert(memb->flags == 0 || memb->flags == READONLY);
14601 descr = PyDescr_NewMember(type, memb);
14602 if (unlikely(!descr))
14603 return -1;
14604 if (unlikely(PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr) < 0)) {
14605 Py_DECREF(descr);
14606 return -1;
14607 }
14608 Py_DECREF(descr);
14609 changed = 1;
14610 }
14611 #endif
14612 }
14613 memb++;
14614 }
14615 if (changed)
14616 PyType_Modified(type);
14617 }
14618 #endif
14619 return 0;
14620 }
14621 #endif
14622
14623 /* FetchSharedCythonModule */
14624 static PyObject *__Pyx_FetchSharedCythonABIModule(void) {
14625 return __Pyx_PyImport_AddModuleRef((char*) __PYX_ABI_MODULE_NAME);
14626 }
14627
14628 /* FetchCommonType */
14629 static int __Pyx_VerifyCachedType(PyObject *cached_type,
14630 const char *name,
14631 Py_ssize_t basicsize,
14632 Py_ssize_t expected_basicsize) {
14633 if (!PyType_Check(cached_type)) {
14634 PyErr_Format(PyExc_TypeError,
14635 "Shared Cython type %.200s is not a type object", name);
14636 return -1;
14637 }
14638 if (basicsize != expected_basicsize) {
14639 PyErr_Format(PyExc_TypeError,
14640 "Shared Cython type %.200s has the wrong size, try recompiling",
14641 name);
14642 return -1;
14643 }
14644 return 0;
14645 }
14646 #if !CYTHON_USE_TYPE_SPECS
14647 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
14648 PyObject* abi_module;
14649 const char* object_name;
14650 PyTypeObject *cached_type = NULL;
14651 abi_module = __Pyx_FetchSharedCythonABIModule();
14652 if (!abi_module) return NULL;
14653 object_name = strrchr(type->tp_name, '.');
14654 object_name = object_name ? object_name+1 : type->tp_name;
14655 cached_type = (PyTypeObject*) PyObject_GetAttrString(abi_module, object_name);
14656 if (cached_type) {
14657 if (__Pyx_VerifyCachedType(
14658 (PyObject *)cached_type,
14659 object_name,
14660 cached_type->tp_basicsize,
14661 type->tp_basicsize) < 0) {
14662 goto bad;
14663 }
14664 goto done;
14665 }
14666 if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
14667 PyErr_Clear();
14668 if (PyType_Ready(type) < 0) goto bad;
14669 if (PyObject_SetAttrString(abi_module, object_name, (PyObject *)type) < 0)
14670 goto bad;
14671 Py_INCREF(type);
14672 cached_type = type;
14673 done:
14674 Py_DECREF(abi_module);
14675 return cached_type;
14676 bad:
14677 Py_XDECREF(cached_type);
14678 cached_type = NULL;
14679 goto done;
14680 }
14681 #else
14682 static PyTypeObject *__Pyx_FetchCommonTypeFromSpec(PyObject *module, PyType_Spec *spec, PyObject *bases) {
14683 PyObject *abi_module, *cached_type = NULL;
14684 const char* object_name = strrchr(spec->name, '.');
14685 object_name = object_name ? object_name+1 : spec->name;
14686 abi_module = __Pyx_FetchSharedCythonABIModule();
14687 if (!abi_module) return NULL;
14688 cached_type = PyObject_GetAttrString(abi_module, object_name);
14689 if (cached_type) {
14690 Py_ssize_t basicsize;
14691 #if CYTHON_COMPILING_IN_LIMITED_API
14692 PyObject *py_basicsize;
14693 py_basicsize = PyObject_GetAttrString(cached_type, "__basicsize__");
14694 if (unlikely(!py_basicsize)) goto bad;
14695 basicsize = PyLong_AsSsize_t(py_basicsize);
14696 Py_DECREF(py_basicsize);
14697 py_basicsize = 0;
14698 if (unlikely(basicsize == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
14699 #else
14700 basicsize = likely(PyType_Check(cached_type)) ? ((PyTypeObject*) cached_type)->tp_basicsize : -1;
14701 #endif
14702 if (__Pyx_VerifyCachedType(
14703 cached_type,
14704 object_name,
14705 basicsize,
14706 spec->basicsize) < 0) {
14707 goto bad;
14708 }
14709 goto done;
14710 }
14711 if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
14712 PyErr_Clear();
14713 CYTHON_UNUSED_VAR(module);
14714 cached_type = __Pyx_PyType_FromModuleAndSpec(abi_module, spec, bases);
14715 if (unlikely(!cached_type)) goto bad;
14716 if (unlikely(__Pyx_fix_up_extension_type_from_spec(spec, (PyTypeObject *) cached_type) < 0)) goto bad;
14717 if (PyObject_SetAttrString(abi_module, object_name, cached_type) < 0) goto bad;
14718 done:
14719 Py_DECREF(abi_module);
14720 assert(cached_type == NULL || PyType_Check(cached_type));
14721 return (PyTypeObject *) cached_type;
14722 bad:
14723 Py_XDECREF(cached_type);
14724 cached_type = NULL;
14725 goto done;
14726 }
14727 #endif
14728
14729 /* PyVectorcallFastCallDict */
14730 #if CYTHON_METH_FASTCALL
14731 static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
14732 {
14733 PyObject *res = NULL;
14734 PyObject *kwnames;
14735 PyObject **newargs;
14736 PyObject **kwvalues;
14737 Py_ssize_t i, pos;
14738 size_t j;
14739 PyObject *key, *value;
14740 unsigned long keys_are_strings;
14741 Py_ssize_t nkw = PyDict_GET_SIZE(kw);
14742 newargs = (PyObject **)PyMem_Malloc((nargs + (size_t)nkw) * sizeof(args[0]));
14743 if (unlikely(newargs == NULL)) {
14744 PyErr_NoMemory();
14745 return NULL;
14746 }
14747 for (j = 0; j < nargs; j++) newargs[j] = args[j];
14748 kwnames = PyTuple_New(nkw);
14749 if (unlikely(kwnames == NULL)) {
14750 PyMem_Free(newargs);
14751 return NULL;
14752 }
14753 kwvalues = newargs + nargs;
14754 pos = i = 0;
14755 keys_are_strings = Py_TPFLAGS_UNICODE_SUBCLASS;
14756 while (PyDict_Next(kw, &pos, &key, &value)) {
14757 keys_are_strings &= Py_TYPE(key)->tp_flags;
14758 Py_INCREF(key);
14759 Py_INCREF(value);
14760 PyTuple_SET_ITEM(kwnames, i, key);
14761 kwvalues[i] = value;
14762 i++;
14763 }
14764 if (unlikely(!keys_are_strings)) {
14765 PyErr_SetString(PyExc_TypeError, "keywords must be strings");
14766 goto cleanup;
14767 }
14768 res = vc(func, newargs, nargs, kwnames);
14769 cleanup:
14770 Py_DECREF(kwnames);
14771 for (i = 0; i < nkw; i++)
14772 Py_DECREF(kwvalues[i]);
14773 PyMem_Free(newargs);
14774 return res;
14775 }
14776 static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
14777 {
14778 if (likely(kw == NULL) || PyDict_GET_SIZE(kw) == 0) {
14779 return vc(func, args, nargs, NULL);
14780 }
14781 return __Pyx_PyVectorcall_FastCallDict_kw(func, vc, args, nargs, kw);
14782 }
14783 #endif
14784
14785 /* CythonFunctionShared */
14786 #if CYTHON_COMPILING_IN_LIMITED_API
14787 static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void *cfunc) {
14788 if (__Pyx_CyFunction_Check(func)) {
14789 return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc;
14790 } else if (PyCFunction_Check(func)) {
14791 return PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
14792 }
14793 return 0;
14794 }
14795 #else
14796 static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void *cfunc) {
14797 return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
14798 }
14799 #endif
14800 static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) {
14801 #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
14802 __Pyx_Py_XDECREF_SET(
14803 __Pyx_CyFunction_GetClassObj(f),
14804 ((classobj) ? __Pyx_NewRef(classobj) : NULL));
14805 #else
14806 __Pyx_Py_XDECREF_SET(
14807 ((PyCMethodObject *) (f))->mm_class,
14808 (PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL));
14809 #endif
14810 }
14811 static PyObject *
14812 __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure)
14813 {
14814 CYTHON_UNUSED_VAR(closure);
14815 if (unlikely(op->func_doc == NULL)) {
14816 #if CYTHON_COMPILING_IN_LIMITED_API
14817 op->func_doc = PyObject_GetAttrString(op->func, "__doc__");
14818 if (unlikely(!op->func_doc)) return NULL;
14819 #else
14820 if (((PyCFunctionObject*)op)->m_ml->ml_doc) {
14821 #if PY_MAJOR_VERSION >= 3
14822 op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc);
14823 #else
14824 op->func_doc = PyString_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc);
14825 #endif
14826 if (unlikely(op->func_doc == NULL))
14827 return NULL;
14828 } else {
14829 Py_INCREF(Py_None);
14830 return Py_None;
14831 }
14832 #endif
14833 }
14834 Py_INCREF(op->func_doc);
14835 return op->func_doc;
14836 }
14837 static int
14838 __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, void *context)
14839 {
14840 CYTHON_UNUSED_VAR(context);
14841 if (value == NULL) {
14842 value = Py_None;
14843 }
14844 Py_INCREF(value);
14845 __Pyx_Py_XDECREF_SET(op->func_doc, value);
14846 return 0;
14847 }
14848 static PyObject *
14849 __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context)
14850 {
14851 CYTHON_UNUSED_VAR(context);
14852 if (unlikely(op->func_name == NULL)) {
14853 #if CYTHON_COMPILING_IN_LIMITED_API
14854 op->func_name = PyObject_GetAttrString(op->func, "__name__");
14855 #elif PY_MAJOR_VERSION >= 3
14856 op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name);
14857 #else
14858 op->func_name = PyString_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name);
14859 #endif
14860 if (unlikely(op->func_name == NULL))
14861 return NULL;
14862 }
14863 Py_INCREF(op->func_name);
14864 return op->func_name;
14865 }
14866 static int
14867 __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *context)
14868 {
14869 CYTHON_UNUSED_VAR(context);
14870 #if PY_MAJOR_VERSION >= 3
14871 if (unlikely(value == NULL || !PyUnicode_Check(value)))
14872 #else
14873 if (unlikely(value == NULL || !PyString_Check(value)))
14874 #endif
14875 {
14876 PyErr_SetString(PyExc_TypeError,
14877 "__name__ must be set to a string object");
14878 return -1;
14879 }
14880 Py_INCREF(value);
14881 __Pyx_Py_XDECREF_SET(op->func_name, value);
14882 return 0;
14883 }
14884 static PyObject *
14885 __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context)
14886 {
14887 CYTHON_UNUSED_VAR(context);
14888 Py_INCREF(op->func_qualname);
14889 return op->func_qualname;
14890 }
14891 static int
14892 __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void *context)
14893 {
14894 CYTHON_UNUSED_VAR(context);
14895 #if PY_MAJOR_VERSION >= 3
14896 if (unlikely(value == NULL || !PyUnicode_Check(value)))
14897 #else
14898 if (unlikely(value == NULL || !PyString_Check(value)))
14899 #endif
14900 {
14901 PyErr_SetString(PyExc_TypeError,
14902 "__qualname__ must be set to a string object");
14903 return -1;
14904 }
14905 Py_INCREF(value);
14906 __Pyx_Py_XDECREF_SET(op->func_qualname, value);
14907 return 0;
14908 }
14909 static PyObject *
14910 __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context)
14911 {
14912 CYTHON_UNUSED_VAR(context);
14913 if (unlikely(op->func_dict == NULL)) {
14914 op->func_dict = PyDict_New();
14915 if (unlikely(op->func_dict == NULL))
14916 return NULL;
14917 }
14918 Py_INCREF(op->func_dict);
14919 return op->func_dict;
14920 }
14921 static int
14922 __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, void *context)
14923 {
14924 CYTHON_UNUSED_VAR(context);
14925 if (unlikely(value == NULL)) {
14926 PyErr_SetString(PyExc_TypeError,
14927 "function's dictionary may not be deleted");
14928 return -1;
14929 }
14930 if (unlikely(!PyDict_Check(value))) {
14931 PyErr_SetString(PyExc_TypeError,
14932 "setting function's dictionary to a non-dict");
14933 return -1;
14934 }
14935 Py_INCREF(value);
14936 __Pyx_Py_XDECREF_SET(op->func_dict, value);
14937 return 0;
14938 }
14939 static PyObject *
14940 __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, void *context)
14941 {
14942 CYTHON_UNUSED_VAR(context);
14943 Py_INCREF(op->func_globals);
14944 return op->func_globals;
14945 }
14946 static PyObject *
14947 __Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context)
14948 {
14949 CYTHON_UNUSED_VAR(op);
14950 CYTHON_UNUSED_VAR(context);
14951 Py_INCREF(Py_None);
14952 return Py_None;
14953 }
14954 static PyObject *
14955 __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context)
14956 {
14957 PyObject* result = (op->func_code) ? op->func_code : Py_None;
14958 CYTHON_UNUSED_VAR(context);
14959 Py_INCREF(result);
14960 return result;
14961 }
14962 static int
14963 __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
14964 int result = 0;
14965 PyObject *res = op->defaults_getter((PyObject *) op);
14966 if (unlikely(!res))
14967 return -1;
14968 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
14969 op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
14970 Py_INCREF(op->defaults_tuple);
14971 op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
14972 Py_INCREF(op->defaults_kwdict);
14973 #else
14974 op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0);
14975 if (unlikely(!op->defaults_tuple)) result = -1;
14976 else {
14977 op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1);
14978 if (unlikely(!op->defaults_kwdict)) result = -1;
14979 }
14980 #endif
14981 Py_DECREF(res);
14982 return result;
14983 }
14984 static int
14985 __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
14986 CYTHON_UNUSED_VAR(context);
14987 if (!value) {
14988 value = Py_None;
14989 } else if (unlikely(value != Py_None && !PyTuple_Check(value))) {
14990 PyErr_SetString(PyExc_TypeError,
14991 "__defaults__ must be set to a tuple object");
14992 return -1;
14993 }
14994 PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not "
14995 "currently affect the values used in function calls", 1);
14996 Py_INCREF(value);
14997 __Pyx_Py_XDECREF_SET(op->defaults_tuple, value);
14998 return 0;
14999 }
15000 static PyObject *
15001 __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) {
15002 PyObject* result = op->defaults_tuple;
15003 CYTHON_UNUSED_VAR(context);
15004 if (unlikely(!result)) {
15005 if (op->defaults_getter) {
15006 if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
15007 result = op->defaults_tuple;
15008 } else {
15009 result = Py_None;
15010 }
15011 }
15012 Py_INCREF(result);
15013 return result;
15014 }
15015 static int
15016 __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
15017 CYTHON_UNUSED_VAR(context);
15018 if (!value) {
15019 value = Py_None;
15020 } else if (unlikely(value != Py_None && !PyDict_Check(value))) {
15021 PyErr_SetString(PyExc_TypeError,
15022 "__kwdefaults__ must be set to a dict object");
15023 return -1;
15024 }
15025 PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not "
15026 "currently affect the values used in function calls", 1);
15027 Py_INCREF(value);
15028 __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value);
15029 return 0;
15030 }
15031 static PyObject *
15032 __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) {
15033 PyObject* result = op->defaults_kwdict;
15034 CYTHON_UNUSED_VAR(context);
15035 if (unlikely(!result)) {
15036 if (op->defaults_getter) {
15037 if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
15038 result = op->defaults_kwdict;
15039 } else {
15040 result = Py_None;
15041 }
15042 }
15043 Py_INCREF(result);
15044 return result;
15045 }
15046 static int
15047 __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
15048 CYTHON_UNUSED_VAR(context);
15049 if (!value || value == Py_None) {
15050 value = NULL;
15051 } else if (unlikely(!PyDict_Check(value))) {
15052 PyErr_SetString(PyExc_TypeError,
15053 "__annotations__ must be set to a dict object");
15054 return -1;
15055 }
15056 Py_XINCREF(value);
15057 __Pyx_Py_XDECREF_SET(op->func_annotations, value);
15058 return 0;
15059 }
15060 static PyObject *
15061 __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, void *context) {
15062 PyObject* result = op->func_annotations;
15063 CYTHON_UNUSED_VAR(context);
15064 if (unlikely(!result)) {
15065 result = PyDict_New();
15066 if (unlikely(!result)) return NULL;
15067 op->func_annotations = result;
15068 }
15069 Py_INCREF(result);
15070 return result;
15071 }
15072 static PyObject *
15073 __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) {
15074 int is_coroutine;
15075 CYTHON_UNUSED_VAR(context);
15076 if (op->func_is_coroutine) {
15077 return __Pyx_NewRef(op->func_is_coroutine);
15078 }
15079 is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE;
15080 #if PY_VERSION_HEX >= 0x03050000
15081 if (is_coroutine) {
15082 PyObject *module, *fromlist, *marker = __pyx_n_s_is_coroutine;
15083 fromlist = PyList_New(1);
15084 if (unlikely(!fromlist)) return NULL;
15085 Py_INCREF(marker);
15086 #if CYTHON_ASSUME_SAFE_MACROS
15087 PyList_SET_ITEM(fromlist, 0, marker);
15088 #else
15089 if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) {
15090 Py_DECREF(marker);
15091 Py_DECREF(fromlist);
15092 return NULL;
15093 }
15094 #endif
15095 module = PyImport_ImportModuleLevelObject(__pyx_n_s_asyncio_coroutines, NULL, NULL, fromlist, 0);
15096 Py_DECREF(fromlist);
15097 if (unlikely(!module)) goto ignore;
15098 op->func_is_coroutine = __Pyx_PyObject_GetAttrStr(module, marker);
15099 Py_DECREF(module);
15100 if (likely(op->func_is_coroutine)) {
15101 return __Pyx_NewRef(op->func_is_coroutine);
15102 }
15103 ignore:
15104 PyErr_Clear();
15105 }
15106 #endif
15107 op->func_is_coroutine = __Pyx_PyBool_FromLong(is_coroutine);
15108 return __Pyx_NewRef(op->func_is_coroutine);
15109 }
15110 #if CYTHON_COMPILING_IN_LIMITED_API
15111 static PyObject *
15112 __Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) {
15113 CYTHON_UNUSED_VAR(context);
15114 return PyObject_GetAttrString(op->func, "__module__");
15115 }
15116 static int
15117 __Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
15118 CYTHON_UNUSED_VAR(context);
15119 return PyObject_SetAttrString(op->func, "__module__", value);
15120 }
15121 #endif
15122 static PyGetSetDef __pyx_CyFunction_getsets[] = {
15123 {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
15124 {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
15125 {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
15126 {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
15127 {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
15128 {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
15129 {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
15130 {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
15131 {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
15132 {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
15133 {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
15134 {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
15135 {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
15136 {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
15137 {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
15138 {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
15139 {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
15140 {(char *) "_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0},
15141 #if CYTHON_COMPILING_IN_LIMITED_API
15142 {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0},
15143 #endif
15144 {0, 0, 0, 0, 0}
15145 };
15146 static PyMemberDef __pyx_CyFunction_members[] = {
15147 #if !CYTHON_COMPILING_IN_LIMITED_API
15148 {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0},
15149 #endif
15150 #if CYTHON_USE_TYPE_SPECS
15151 {(char *) "__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0},
15152 #if CYTHON_METH_FASTCALL
15153 #if CYTHON_BACKPORT_VECTORCALL
15154 {(char *) "__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0},
15155 #else
15156 #if !CYTHON_COMPILING_IN_LIMITED_API
15157 {(char *) "__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0},
15158 #endif
15159 #endif
15160 #endif
15161 #if PY_VERSION_HEX < 0x030500A0 || CYTHON_COMPILING_IN_LIMITED_API
15162 {(char *) "__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0},
15163 #else
15164 {(char *) "__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0},
15165 #endif
15166 #endif
15167 {0, 0, 0, 0, 0}
15168 };
15169 static PyObject *
15170 __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args)
15171 {
15172 CYTHON_UNUSED_VAR(args);
15173 #if PY_MAJOR_VERSION >= 3
15174 Py_INCREF(m->func_qualname);
15175 return m->func_qualname;
15176 #else
15177 return PyString_FromString(((PyCFunctionObject*)m)->m_ml->ml_name);
15178 #endif
15179 }
15180 static PyMethodDef __pyx_CyFunction_methods[] = {
15181 {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
15182 {0, 0, 0, 0}
15183 };
15184 #if PY_VERSION_HEX < 0x030500A0 || CYTHON_COMPILING_IN_LIMITED_API
15185 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
15186 #else
15187 #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist)
15188 #endif
15189 static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
15190 PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
15191 #if !CYTHON_COMPILING_IN_LIMITED_API
15192 PyCFunctionObject *cf = (PyCFunctionObject*) op;
15193 #endif
15194 if (unlikely(op == NULL))
15195 return NULL;
15196 #if CYTHON_COMPILING_IN_LIMITED_API
15197 op->func = PyCFunction_NewEx(ml, (PyObject*)op, module);
15198 if (unlikely(!op->func)) return NULL;
15199 #endif
15200 op->flags = flags;
15201 __Pyx_CyFunction_weakreflist(op) = NULL;
15202 #if !CYTHON_COMPILING_IN_LIMITED_API
15203 cf->m_ml = ml;
15204 cf->m_self = (PyObject *) op;
15205 #endif
15206 Py_XINCREF(closure);
15207 op->func_closure = closure;
15208 #if !CYTHON_COMPILING_IN_LIMITED_API
15209 Py_XINCREF(module);
15210 cf->m_module = module;
15211 #endif
15212 op->func_dict = NULL;
15213 op->func_name = NULL;
15214 Py_INCREF(qualname);
15215 op->func_qualname = qualname;
15216 op->func_doc = NULL;
15217 #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
15218 op->func_classobj = NULL;
15219 #else
15220 ((PyCMethodObject*)op)->mm_class = NULL;
15221 #endif
15222 op->func_globals = globals;
15223 Py_INCREF(op->func_globals);
15224 Py_XINCREF(code);
15225 op->func_code = code;
15226 op->defaults_pyobjects = 0;
15227 op->defaults_size = 0;
15228 op->defaults = NULL;
15229 op->defaults_tuple = NULL;
15230 op->defaults_kwdict = NULL;
15231 op->defaults_getter = NULL;
15232 op->func_annotations = NULL;
15233 op->func_is_coroutine = NULL;
15234 #if CYTHON_METH_FASTCALL
15235 switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) {
15236 case METH_NOARGS:
15237 __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS;
15238 break;
15239 case METH_O:
15240 __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O;
15241 break;
15242 case METH_METHOD | METH_FASTCALL | METH_KEYWORDS:
15243 __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD;
15244 break;
15245 case METH_FASTCALL | METH_KEYWORDS:
15246 __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS;
15247 break;
15248 case METH_VARARGS | METH_KEYWORDS:
15249 __Pyx_CyFunction_func_vectorcall(op) = NULL;
15250 break;
15251 default:
15252 PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
15253 Py_DECREF(op);
15254 return NULL;
15255 }
15256 #endif
15257 return (PyObject *) op;
15258 }
15259 static int
15260 __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
15261 {
15262 Py_CLEAR(m->func_closure);
15263 #if CYTHON_COMPILING_IN_LIMITED_API
15264 Py_CLEAR(m->func);
15265 #else
15266 Py_CLEAR(((PyCFunctionObject*)m)->m_module);
15267 #endif
15268 Py_CLEAR(m->func_dict);
15269 Py_CLEAR(m->func_name);
15270 Py_CLEAR(m->func_qualname);
15271 Py_CLEAR(m->func_doc);
15272 Py_CLEAR(m->func_globals);
15273 Py_CLEAR(m->func_code);
15274 #if !CYTHON_COMPILING_IN_LIMITED_API
15275 #if PY_VERSION_HEX < 0x030900B1
15276 Py_CLEAR(__Pyx_CyFunction_GetClassObj(m));
15277 #else
15278 {
15279 PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class;
15280 ((PyCMethodObject *) (m))->mm_class = NULL;
15281 Py_XDECREF(cls);
15282 }
15283 #endif
15284 #endif
15285 Py_CLEAR(m->defaults_tuple);
15286 Py_CLEAR(m->defaults_kwdict);
15287 Py_CLEAR(m->func_annotations);
15288 Py_CLEAR(m->func_is_coroutine);
15289 if (m->defaults) {
15290 PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
15291 int i;
15292 for (i = 0; i < m->defaults_pyobjects; i++)
15293 Py_XDECREF(pydefaults[i]);
15294 PyObject_Free(m->defaults);
15295 m->defaults = NULL;
15296 }
15297 return 0;
15298 }
15299 static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
15300 {
15301 if (__Pyx_CyFunction_weakreflist(m) != NULL)
15302 PyObject_ClearWeakRefs((PyObject *) m);
15303 __Pyx_CyFunction_clear(m);
15304 __Pyx_PyHeapTypeObject_GC_Del(m);
15305 }
15306 static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
15307 {
15308 PyObject_GC_UnTrack(m);
15309 __Pyx__CyFunction_dealloc(m);
15310 }
15311 static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
15312 {
15313 Py_VISIT(m->func_closure);
15314 #if CYTHON_COMPILING_IN_LIMITED_API
15315 Py_VISIT(m->func);
15316 #else
15317 Py_VISIT(((PyCFunctionObject*)m)->m_module);
15318 #endif
15319 Py_VISIT(m->func_dict);
15320 Py_VISIT(m->func_name);
15321 Py_VISIT(m->func_qualname);
15322 Py_VISIT(m->func_doc);
15323 Py_VISIT(m->func_globals);
15324 Py_VISIT(m->func_code);
15325 #if !CYTHON_COMPILING_IN_LIMITED_API
15326 Py_VISIT(__Pyx_CyFunction_GetClassObj(m));
15327 #endif
15328 Py_VISIT(m->defaults_tuple);
15329 Py_VISIT(m->defaults_kwdict);
15330 Py_VISIT(m->func_is_coroutine);
15331 if (m->defaults) {
15332 PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
15333 int i;
15334 for (i = 0; i < m->defaults_pyobjects; i++)
15335 Py_VISIT(pydefaults[i]);
15336 }
15337 return 0;
15338 }
15339 static PyObject*
15340 __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
15341 {
15342 #if PY_MAJOR_VERSION >= 3
15343 return PyUnicode_FromFormat("<cyfunction %U at %p>",
15344 op->func_qualname, (void *)op);
15345 #else
15346 return PyString_FromFormat("<cyfunction %s at %p>",
15347 PyString_AsString(op->func_qualname), (void *)op);
15348 #endif
15349 }
15350 static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
15351 #if CYTHON_COMPILING_IN_LIMITED_API
15352 PyObject *f = ((__pyx_CyFunctionObject*)func)->func;
15353 PyObject *py_name = NULL;
15354 PyCFunction meth;
15355 int flags;
15356 meth = PyCFunction_GetFunction(f);
15357 if (unlikely(!meth)) return NULL;
15358 flags = PyCFunction_GetFlags(f);
15359 if (unlikely(flags < 0)) return NULL;
15360 #else
15361 PyCFunctionObject* f = (PyCFunctionObject*)func;
15362 PyCFunction meth = f->m_ml->ml_meth;
15363 int flags = f->m_ml->ml_flags;
15364 #endif
15365 Py_ssize_t size;
15366 switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
15367 case METH_VARARGS:
15368 if (likely(kw == NULL || PyDict_Size(kw) == 0))
15369 return (*meth)(self, arg);
15370 break;
15371 case METH_VARARGS | METH_KEYWORDS:
15372 return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
15373 case METH_NOARGS:
15374 if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
15375 #if CYTHON_ASSUME_SAFE_MACROS
15376 size = PyTuple_GET_SIZE(arg);
15377 #else
15378 size = PyTuple_Size(arg);
15379 if (unlikely(size < 0)) return NULL;
15380 #endif
15381 if (likely(size == 0))
15382 return (*meth)(self, NULL);
15383 #if CYTHON_COMPILING_IN_LIMITED_API
15384 py_name = __Pyx_CyFunction_get_name((__pyx_CyFunctionObject*)func, NULL);
15385 if (!py_name) return NULL;
15386 PyErr_Format(PyExc_TypeError,
15387 "%.200S() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
15388 py_name, size);
15389 Py_DECREF(py_name);
15390 #else
15391 PyErr_Format(PyExc_TypeError,
15392 "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
15393 f->m_ml->ml_name, size);
15394 #endif
15395 return NULL;
15396 }
15397 break;
15398 case METH_O:
15399 if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
15400 #if CYTHON_ASSUME_SAFE_MACROS
15401 size = PyTuple_GET_SIZE(arg);
15402 #else
15403 size = PyTuple_Size(arg);
15404 if (unlikely(size < 0)) return NULL;
15405 #endif
15406 if (likely(size == 1)) {
15407 PyObject *result, *arg0;
15408 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
15409 arg0 = PyTuple_GET_ITEM(arg, 0);
15410 #else
15411 arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
15412 #endif
15413 result = (*meth)(self, arg0);
15414 #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
15415 Py_DECREF(arg0);
15416 #endif
15417 return result;
15418 }
15419 #if CYTHON_COMPILING_IN_LIMITED_API
15420 py_name = __Pyx_CyFunction_get_name((__pyx_CyFunctionObject*)func, NULL);
15421 if (!py_name) return NULL;
15422 PyErr_Format(PyExc_TypeError,
15423 "%.200S() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
15424 py_name, size);
15425 Py_DECREF(py_name);
15426 #else
15427 PyErr_Format(PyExc_TypeError,
15428 "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
15429 f->m_ml->ml_name, size);
15430 #endif
15431 return NULL;
15432 }
15433 break;
15434 default:
15435 PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
15436 return NULL;
15437 }
15438 #if CYTHON_COMPILING_IN_LIMITED_API
15439 py_name = __Pyx_CyFunction_get_name((__pyx_CyFunctionObject*)func, NULL);
15440 if (!py_name) return NULL;
15441 PyErr_Format(PyExc_TypeError, "%.200S() takes no keyword arguments",
15442 py_name);
15443 Py_DECREF(py_name);
15444 #else
15445 PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
15446 f->m_ml->ml_name);
15447 #endif
15448 return NULL;
15449 }
15450 static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
15451 PyObject *self, *result;
15452 #if CYTHON_COMPILING_IN_LIMITED_API
15453 self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func);
15454 if (unlikely(!self) && PyErr_Occurred()) return NULL;
15455 #else
15456 self = ((PyCFunctionObject*)func)->m_self;
15457 #endif
15458 result = __Pyx_CyFunction_CallMethod(func, self, arg, kw);
15459 return result;
15460 }
15461 static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
15462 PyObject *result;
15463 __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
15464 #if CYTHON_METH_FASTCALL
15465 __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc);
15466 if (vc) {
15467 #if CYTHON_ASSUME_SAFE_MACROS
15468 return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw);
15469 #else
15470 (void) &__Pyx_PyVectorcall_FastCallDict;
15471 return PyVectorcall_Call(func, args, kw);
15472 #endif
15473 }
15474 #endif
15475 if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
15476 Py_ssize_t argc;
15477 PyObject *new_args;
15478 PyObject *self;
15479 #if CYTHON_ASSUME_SAFE_MACROS
15480 argc = PyTuple_GET_SIZE(args);
15481 #else
15482 argc = PyTuple_Size(args);
15483 if (unlikely(!argc) < 0) return NULL;
15484 #endif
15485 new_args = PyTuple_GetSlice(args, 1, argc);
15486 if (unlikely(!new_args))
15487 return NULL;
15488 self = PyTuple_GetItem(args, 0);
15489 if (unlikely(!self)) {
15490 Py_DECREF(new_args);
15491 #if PY_MAJOR_VERSION > 2
15492 PyErr_Format(PyExc_TypeError,
15493 "unbound method %.200S() needs an argument",
15494 cyfunc->func_qualname);
15495 #else
15496 PyErr_SetString(PyExc_TypeError,
15497 "unbound method needs an argument");
15498 #endif
15499 return NULL;
15500 }
15501 result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
15502 Py_DECREF(new_args);
15503 } else {
15504 result = __Pyx_CyFunction_Call(func, args, kw);
15505 }
15506 return result;
15507 }
15508 #if CYTHON_METH_FASTCALL
15509 static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames)
15510 {
15511 int ret = 0;
15512 if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
15513 if (unlikely(nargs < 1)) {
15514 PyErr_Format(PyExc_TypeError, "%.200s() needs an argument",
15515 ((PyCFunctionObject*)cyfunc)->m_ml->ml_name);
15516 return -1;
15517 }
15518 ret = 1;
15519 }
15520 if (unlikely(kwnames) && unlikely(PyTuple_GET_SIZE(kwnames))) {
15521 PyErr_Format(PyExc_TypeError,
15522 "%.200s() takes no keyword arguments", ((PyCFunctionObject*)cyfunc)->m_ml->ml_name);
15523 return -1;
15524 }
15525 return ret;
15526 }
15527 static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
15528 {
15529 __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
15530 PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml;
15531 #if CYTHON_BACKPORT_VECTORCALL
15532 Py_ssize_t nargs = (Py_ssize_t)nargsf;
15533 #else
15534 Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
15535 #endif
15536 PyObject *self;
15537 switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
15538 case 1:
15539 self = args[0];
15540 args += 1;
15541 nargs -= 1;
15542 break;
15543 case 0:
15544 self = ((PyCFunctionObject*)cyfunc)->m_self;
15545 break;
15546 default:
15547 return NULL;
15548 }
15549 if (unlikely(nargs != 0)) {
15550 PyErr_Format(PyExc_TypeError,
15551 "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
15552 def->ml_name, nargs);
15553 return NULL;
15554 }
15555 return def->ml_meth(self, NULL);
15556 }
15557 static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
15558 {
15559 __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
15560 PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml;
15561 #if CYTHON_BACKPORT_VECTORCALL
15562 Py_ssize_t nargs = (Py_ssize_t)nargsf;
15563 #else
15564 Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
15565 #endif
15566 PyObject *self;
15567 switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
15568 case 1:
15569 self = args[0];
15570 args += 1;
15571 nargs -= 1;
15572 break;
15573 case 0:
15574 self = ((PyCFunctionObject*)cyfunc)->m_self;
15575 break;
15576 default:
15577 return NULL;
15578 }
15579 if (unlikely(nargs != 1)) {
15580 PyErr_Format(PyExc_TypeError,
15581 "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
15582 def->ml_name, nargs);
15583 return NULL;
15584 }
15585 return def->ml_meth(self, args[0]);
15586 }
15587 static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
15588 {
15589 __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
15590 PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml;
15591 #if CYTHON_BACKPORT_VECTORCALL
15592 Py_ssize_t nargs = (Py_ssize_t)nargsf;
15593 #else
15594 Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
15595 #endif
15596 PyObject *self;
15597 switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
15598 case 1:
15599 self = args[0];
15600 args += 1;
15601 nargs -= 1;
15602 break;
15603 case 0:
15604 self = ((PyCFunctionObject*)cyfunc)->m_self;
15605 break;
15606 default:
15607 return NULL;
15608 }
15609 return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))def->ml_meth)(self, args, nargs, kwnames);
15610 }
15611 static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
15612 {
15613 __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
15614 PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml;
15615 PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_GetClassObj(cyfunc);
15616 #if CYTHON_BACKPORT_VECTORCALL
15617 Py_ssize_t nargs = (Py_ssize_t)nargsf;
15618 #else
15619 Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
15620 #endif
15621 PyObject *self;
15622 switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
15623 case 1:
15624 self = args[0];
15625 args += 1;
15626 nargs -= 1;
15627 break;
15628 case 0:
15629 self = ((PyCFunctionObject*)cyfunc)->m_self;
15630 break;
15631 default:
15632 return NULL;
15633 }
15634 return ((__Pyx_PyCMethod)(void(*)(void))def->ml_meth)(self, cls, args, (size_t)nargs, kwnames);
15635 }
15636 #endif
15637 #if CYTHON_USE_TYPE_SPECS
15638 static PyType_Slot __pyx_CyFunctionType_slots[] = {
15639 {Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc},
15640 {Py_tp_repr, (void *)__Pyx_CyFunction_repr},
15641 {Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod},
15642 {Py_tp_traverse, (void *)__Pyx_CyFunction_traverse},
15643 {Py_tp_clear, (void *)__Pyx_CyFunction_clear},
15644 {Py_tp_methods, (void *)__pyx_CyFunction_methods},
15645 {Py_tp_members, (void *)__pyx_CyFunction_members},
15646 {Py_tp_getset, (void *)__pyx_CyFunction_getsets},
15647 {Py_tp_descr_get, (void *)__Pyx_PyMethod_New},
15648 {0, 0},
15649 };
15650 static PyType_Spec __pyx_CyFunctionType_spec = {
15651 __PYX_TYPE_MODULE_PREFIX "cython_function_or_method",
15652 sizeof(__pyx_CyFunctionObject),
15653 0,
15654 #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR
15655 Py_TPFLAGS_METHOD_DESCRIPTOR |
15656 #endif
15657 #if (defined(_Py_TPFLAGS_HAVE_VECTORCALL) && CYTHON_METH_FASTCALL)
15658 _Py_TPFLAGS_HAVE_VECTORCALL |
15659 #endif
15660 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
15661 __pyx_CyFunctionType_slots
15662 };
15663 #else
15664 static PyTypeObject __pyx_CyFunctionType_type = {
15665 PyVarObject_HEAD_INIT(0, 0)
15666 __PYX_TYPE_MODULE_PREFIX "cython_function_or_method",
15667 sizeof(__pyx_CyFunctionObject),
15668 0,
15669 (destructor) __Pyx_CyFunction_dealloc,
15670 #if !CYTHON_METH_FASTCALL
15671 0,
15672 #elif CYTHON_BACKPORT_VECTORCALL
15673 (printfunc)offsetof(__pyx_CyFunctionObject, func_vectorcall),
15674 #else
15675 offsetof(PyCFunctionObject, vectorcall),
15676 #endif
15677 0,
15678 0,
15679 #if PY_MAJOR_VERSION < 3
15680 0,
15681 #else
15682 0,
15683 #endif
15684 (reprfunc) __Pyx_CyFunction_repr,
15685 0,
15686 0,
15687 0,
15688 0,
15689 __Pyx_CyFunction_CallAsMethod,
15690 0,
15691 0,
15692 0,
15693 0,
15694 #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR
15695 Py_TPFLAGS_METHOD_DESCRIPTOR |
15696 #endif
15697 #if defined(_Py_TPFLAGS_HAVE_VECTORCALL) && CYTHON_METH_FASTCALL
15698 _Py_TPFLAGS_HAVE_VECTORCALL |
15699 #endif
15700 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
15701 0,
15702 (traverseproc) __Pyx_CyFunction_traverse,
15703 (inquiry) __Pyx_CyFunction_clear,
15704 0,
15705 #if PY_VERSION_HEX < 0x030500A0
15706 offsetof(__pyx_CyFunctionObject, func_weakreflist),
15707 #else
15708 offsetof(PyCFunctionObject, m_weakreflist),
15709 #endif
15710 0,
15711 0,
15712 __pyx_CyFunction_methods,
15713 __pyx_CyFunction_members,
15714 __pyx_CyFunction_getsets,
15715 0,
15716 0,
15717 __Pyx_PyMethod_New,
15718 0,
15719 offsetof(__pyx_CyFunctionObject, func_dict),
15720 0,
15721 0,
15722 0,
15723 0,
15724 0,
15725 0,
15726 0,
15727 0,
15728 0,
15729 0,
15730 0,
15731 0,
15732 #if PY_VERSION_HEX >= 0x030400a1
15733 0,
15734 #endif
15735 #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
15736 0,
15737 #endif
15738 #if __PYX_NEED_TP_PRINT_SLOT
15739 0,
15740 #endif
15741 #if PY_VERSION_HEX >= 0x030C0000
15742 0,
15743 #endif
15744 #if PY_VERSION_HEX >= 0x030d00A4
15745 0,
15746 #endif
15747 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
15748 0,
15749 #endif
15750 };
15751 #endif
15752 static int __pyx_CyFunction_init(PyObject *module) {
15753 #if CYTHON_USE_TYPE_SPECS
15754 __pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec(module, &__pyx_CyFunctionType_spec, NULL);
15755 #else
15756 CYTHON_UNUSED_VAR(module);
15757 __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
15758 #endif
15759 if (unlikely(__pyx_CyFunctionType == NULL)) {
15760 return -1;
15761 }
15762 return 0;
15763 }
15764 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
15765 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
15766 m->defaults = PyObject_Malloc(size);
15767 if (unlikely(!m->defaults))
15768 return PyErr_NoMemory();
15769 memset(m->defaults, 0, size);
15770 m->defaults_pyobjects = pyobjects;
15771 m->defaults_size = size;
15772 return m->defaults;
15773 }
15774 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
15775 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
15776 m->defaults_tuple = tuple;
15777 Py_INCREF(tuple);
15778 }
15779 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
15780 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
15781 m->defaults_kwdict = dict;
15782 Py_INCREF(dict);
15783 }
15784 static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
15785 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
15786 m->func_annotations = dict;
15787 Py_INCREF(dict);
15788 }
15789
15790 /* CythonFunction */
15791 static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
15792 PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
15793 PyObject *op = __Pyx_CyFunction_Init(
15794 PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType),
15795 ml, flags, qualname, closure, module, globals, code
15796 );
15797 if (likely(op)) {
15798 PyObject_GC_Track(op);
15799 }
15800 return op;
15801 }
15802
15803 /* RaiseUnboundLocalError */
15804 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
15805 PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
15806 }
15807
15808 /* TypeImport */
15809 #ifndef __PYX_HAVE_RT_ImportType_3_0_11
15810 #define __PYX_HAVE_RT_ImportType_3_0_11
15811 static PyTypeObject *__Pyx_ImportType_3_0_11(PyObject *module, const char *module_name, const char *class_name,
15812 size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_0_11 check_size)
15813 {
15814 PyObject *result = 0;
15815 char warning[200];
15816 Py_ssize_t basicsize;
15817 Py_ssize_t itemsize;
15818 #if CYTHON_COMPILING_IN_LIMITED_API
15819 PyObject *py_basicsize;
15820 PyObject *py_itemsize;
15821 #endif
15822 result = PyObject_GetAttrString(module, class_name);
15823 if (!result)
15824 goto bad;
15825 if (!PyType_Check(result)) {
15826 PyErr_Format(PyExc_TypeError,
15827 "%.200s.%.200s is not a type object",
15828 module_name, class_name);
15829 goto bad;
15830 }
15831 #if !CYTHON_COMPILING_IN_LIMITED_API
15832 basicsize = ((PyTypeObject *)result)->tp_basicsize;
15833 itemsize = ((PyTypeObject *)result)->tp_itemsize;
15834 #else
15835 py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
15836 if (!py_basicsize)
15837 goto bad;
15838 basicsize = PyLong_AsSsize_t(py_basicsize);
15839 Py_DECREF(py_basicsize);
15840 py_basicsize = 0;
15841 if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
15842 goto bad;
15843 py_itemsize = PyObject_GetAttrString(result, "__itemsize__");
15844 if (!py_itemsize)
15845 goto bad;
15846 itemsize = PyLong_AsSsize_t(py_itemsize);
15847 Py_DECREF(py_itemsize);
15848 py_itemsize = 0;
15849 if (itemsize == (Py_ssize_t)-1 && PyErr_Occurred())
15850 goto bad;
15851 #endif
15852 if (itemsize) {
15853 if (size % alignment) {
15854 alignment = size % alignment;
15855 }
15856 if (itemsize < (Py_ssize_t)alignment)
15857 itemsize = (Py_ssize_t)alignment;
15858 }
15859 if ((size_t)(basicsize + itemsize) < size) {
15860 PyErr_Format(PyExc_ValueError,
15861 "%.200s.%.200s size changed, may indicate binary incompatibility. "
15862 "Expected %zd from C header, got %zd from PyObject",
15863 module_name, class_name, size, basicsize+itemsize);
15864 goto bad;
15865 }
15866 if (check_size == __Pyx_ImportType_CheckSize_Error_3_0_11 &&
15867 ((size_t)basicsize > size || (size_t)(basicsize + itemsize) < size)) {
15868 PyErr_Format(PyExc_ValueError,
15869 "%.200s.%.200s size changed, may indicate binary incompatibility. "
15870 "Expected %zd from C header, got %zd-%zd from PyObject",
15871 module_name, class_name, size, basicsize, basicsize+itemsize);
15872 goto bad;
15873 }
15874 else if (check_size == __Pyx_ImportType_CheckSize_Warn_3_0_11 && (size_t)basicsize > size) {
15875 PyOS_snprintf(warning, sizeof(warning),
15876 "%s.%s size changed, may indicate binary incompatibility. "
15877 "Expected %zd from C header, got %zd from PyObject",
15878 module_name, class_name, size, basicsize);
15879 if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
15880 }
15881 return (PyTypeObject *)result;
15882 bad:
15883 Py_XDECREF(result);
15884 return NULL;
15885 }
15886 #endif
15887
15888 /* Import */
15889 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
15890 PyObject *module = 0;
15891 PyObject *empty_dict = 0;
15892 PyObject *empty_list = 0;
15893 #if PY_MAJOR_VERSION < 3
15894 PyObject *py_import;
15895 py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
15896 if (unlikely(!py_import))
15897 goto bad;
15898 if (!from_list) {
15899 empty_list = PyList_New(0);
15900 if (unlikely(!empty_list))
15901 goto bad;
15902 from_list = empty_list;
15903 }
15904 #endif
15905 empty_dict = PyDict_New();
15906 if (unlikely(!empty_dict))
15907 goto bad;
15908 {
15909 #if PY_MAJOR_VERSION >= 3
15910 if (level == -1) {
15911 if (strchr(__Pyx_MODULE_NAME, '.') != NULL) {
15912 module = PyImport_ImportModuleLevelObject(
15913 name, __pyx_d, empty_dict, from_list, 1);
15914 if (unlikely(!module)) {
15915 if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError)))
15916 goto bad;
15917 PyErr_Clear();
15918 }
15919 }
15920 level = 0;
15921 }
15922 #endif
15923 if (!module) {
15924 #if PY_MAJOR_VERSION < 3
15925 PyObject *py_level = PyInt_FromLong(level);
15926 if (unlikely(!py_level))
15927 goto bad;
15928 module = PyObject_CallFunctionObjArgs(py_import,
15929 name, __pyx_d, empty_dict, from_list, py_level, (PyObject *)NULL);
15930 Py_DECREF(py_level);
15931 #else
15932 module = PyImport_ImportModuleLevelObject(
15933 name, __pyx_d, empty_dict, from_list, level);
15934 #endif
15935 }
15936 }
15937 bad:
15938 Py_XDECREF(empty_dict);
15939 Py_XDECREF(empty_list);
15940 #if PY_MAJOR_VERSION < 3
15941 Py_XDECREF(py_import);
15942 #endif
15943 return module;
15944 }
15945
15946 /* ImportDottedModule */
15947 #if PY_MAJOR_VERSION >= 3
15948 static PyObject *__Pyx__ImportDottedModule_Error(PyObject *name, PyObject *parts_tuple, Py_ssize_t count) {
15949 PyObject *partial_name = NULL, *slice = NULL, *sep = NULL;
15950 if (unlikely(PyErr_Occurred())) {
15951 PyErr_Clear();
15952 }
15953 if (likely(PyTuple_GET_SIZE(parts_tuple) == count)) {
15954 partial_name = name;
15955 } else {
15956 slice = PySequence_GetSlice(parts_tuple, 0, count);
15957 if (unlikely(!slice))
15958 goto bad;
15959 sep = PyUnicode_FromStringAndSize(".", 1);
15960 if (unlikely(!sep))
15961 goto bad;
15962 partial_name = PyUnicode_Join(sep, slice);
15963 }
15964 PyErr_Format(
15965 #if PY_MAJOR_VERSION < 3
15966 PyExc_ImportError,
15967 "No module named '%s'", PyString_AS_STRING(partial_name));
15968 #else
15969 #if PY_VERSION_HEX >= 0x030600B1
15970 PyExc_ModuleNotFoundError,
15971 #else
15972 PyExc_ImportError,
15973 #endif
15974 "No module named '%U'", partial_name);
15975 #endif
15976 bad:
15977 Py_XDECREF(sep);
15978 Py_XDECREF(slice);
15979 Py_XDECREF(partial_name);
15980 return NULL;
15981 }
15982 #endif
15983 #if PY_MAJOR_VERSION >= 3
15984 static PyObject *__Pyx__ImportDottedModule_Lookup(PyObject *name) {
15985 PyObject *imported_module;
15986 #if PY_VERSION_HEX < 0x030700A1 || (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400)
15987 PyObject *modules = PyImport_GetModuleDict();
15988 if (unlikely(!modules))
15989 return NULL;
15990 imported_module = __Pyx_PyDict_GetItemStr(modules, name);
15991 Py_XINCREF(imported_module);
15992 #else
15993 imported_module = PyImport_GetModule(name);
15994 #endif
15995 return imported_module;
15996 }
15997 #endif
15998 #if PY_MAJOR_VERSION >= 3
15999 static PyObject *__Pyx_ImportDottedModule_WalkParts(PyObject *module, PyObject *name, PyObject *parts_tuple) {
16000 Py_ssize_t i, nparts;
16001 nparts = PyTuple_GET_SIZE(parts_tuple);
16002 for (i=1; i < nparts && module; i++) {
16003 PyObject *part, *submodule;
16004 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
16005 part = PyTuple_GET_ITEM(parts_tuple, i);
16006 #else
16007 part = PySequence_ITEM(parts_tuple, i);
16008 #endif
16009 submodule = __Pyx_PyObject_GetAttrStrNoError(module, part);
16010 #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
16011 Py_DECREF(part);
16012 #endif
16013 Py_DECREF(module);
16014 module = submodule;
16015 }
16016 if (unlikely(!module)) {
16017 return __Pyx__ImportDottedModule_Error(name, parts_tuple, i);
16018 }
16019 return module;
16020 }
16021 #endif
16022 static PyObject *__Pyx__ImportDottedModule(PyObject *name, PyObject *parts_tuple) {
16023 #if PY_MAJOR_VERSION < 3
16024 PyObject *module, *from_list, *star = __pyx_n_s__14;
16025 CYTHON_UNUSED_VAR(parts_tuple);
16026 from_list = PyList_New(1);
16027 if (unlikely(!from_list))
16028 return NULL;
16029 Py_INCREF(star);
16030 PyList_SET_ITEM(from_list, 0, star);
16031 module = __Pyx_Import(name, from_list, 0);
16032 Py_DECREF(from_list);
16033 return module;
16034 #else
16035 PyObject *imported_module;
16036 PyObject *module = __Pyx_Import(name, NULL, 0);
16037 if (!parts_tuple || unlikely(!module))
16038 return module;
16039 imported_module = __Pyx__ImportDottedModule_Lookup(name);
16040 if (likely(imported_module)) {
16041 Py_DECREF(module);
16042 return imported_module;
16043 }
16044 PyErr_Clear();
16045 return __Pyx_ImportDottedModule_WalkParts(module, name, parts_tuple);
16046 #endif
16047 }
16048 static PyObject *__Pyx_ImportDottedModule(PyObject *name, PyObject *parts_tuple) {
16049 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030400B1
16050 PyObject *module = __Pyx__ImportDottedModule_Lookup(name);
16051 if (likely(module)) {
16052 PyObject *spec = __Pyx_PyObject_GetAttrStrNoError(module, __pyx_n_s_spec);
16053 if (likely(spec)) {
16054 PyObject *unsafe = __Pyx_PyObject_GetAttrStrNoError(spec, __pyx_n_s_initializing);
16055 if (likely(!unsafe || !__Pyx_PyObject_IsTrue(unsafe))) {
16056 Py_DECREF(spec);
16057 spec = NULL;
16058 }
16059 Py_XDECREF(unsafe);
16060 }
16061 if (likely(!spec)) {
16062 PyErr_Clear();
16063 return module;
16064 }
16065 Py_DECREF(spec);
16066 Py_DECREF(module);
16067 } else if (PyErr_Occurred()) {
16068 PyErr_Clear();
16069 }
16070 #endif
16071 return __Pyx__ImportDottedModule(name, parts_tuple);
16072 }
16073
16074 /* ImportFrom */
16075 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
16076 PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
16077 if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
16078 const char* module_name_str = 0;
16079 PyObject* module_name = 0;
16080 PyObject* module_dot = 0;
16081 PyObject* full_name = 0;
16082 PyErr_Clear();
16083 module_name_str = PyModule_GetName(module);
16084 if (unlikely(!module_name_str)) { goto modbad; }
16085 module_name = PyUnicode_FromString(module_name_str);
16086 if (unlikely(!module_name)) { goto modbad; }
16087 module_dot = PyUnicode_Concat(module_name, __pyx_kp_u__15);
16088 if (unlikely(!module_dot)) { goto modbad; }
16089 full_name = PyUnicode_Concat(module_dot, name);
16090 if (unlikely(!full_name)) { goto modbad; }
16091 #if PY_VERSION_HEX < 0x030700A1 || (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400)
16092 {
16093 PyObject *modules = PyImport_GetModuleDict();
16094 if (unlikely(!modules))
16095 goto modbad;
16096 value = PyObject_GetItem(modules, full_name);
16097 }
16098 #else
16099 value = PyImport_GetModule(full_name);
16100 #endif
16101 modbad:
16102 Py_XDECREF(full_name);
16103 Py_XDECREF(module_dot);
16104 Py_XDECREF(module_name);
16105 }
16106 if (unlikely(!value)) {
16107 PyErr_Format(PyExc_ImportError,
16108 #if PY_MAJOR_VERSION < 3
16109 "cannot import name %.230s", PyString_AS_STRING(name));
16110 #else
16111 "cannot import name %S", name);
16112 #endif
16113 }
16114 return value;
16115 }
16116
16117 /* PyObjectCallNoArg */
16118 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
16119 PyObject *arg[2] = {NULL, NULL};
16120 return __Pyx_PyObject_FastCall(func, arg + 1, 0 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
16121 }
16122
16123 /* CLineInTraceback */
16124 #ifndef CYTHON_CLINE_IN_TRACEBACK
16125 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
16126 PyObject *use_cline;
16127 PyObject *ptype, *pvalue, *ptraceback;
16128 #if CYTHON_COMPILING_IN_CPYTHON
16129 PyObject **cython_runtime_dict;
16130 #endif
16131 CYTHON_MAYBE_UNUSED_VAR(tstate);
16132 if (unlikely(!__pyx_cython_runtime)) {
16133 return c_line;
16134 }
16135 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
16136 #if CYTHON_COMPILING_IN_CPYTHON
16137 cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
16138 if (likely(cython_runtime_dict)) {
16139 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
16140 use_cline, *cython_runtime_dict,
16141 __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
16142 } else
16143 #endif
16144 {
16145 PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStrNoError(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
16146 if (use_cline_obj) {
16147 use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
16148 Py_DECREF(use_cline_obj);
16149 } else {
16150 PyErr_Clear();
16151 use_cline = NULL;
16152 }
16153 }
16154 if (!use_cline) {
16155 c_line = 0;
16156 (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
16157 }
16158 else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
16159 c_line = 0;
16160 }
16161 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
16162 return c_line;
16163 }
16164 #endif
16165
16166 /* CodeObjectCache */
16167 #if !CYTHON_COMPILING_IN_LIMITED_API
16168 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
16169 int start = 0, mid = 0, end = count - 1;
16170 if (end >= 0 && code_line > entries[end].code_line) {
16171 return count;
16172 }
16173 while (start < end) {
16174 mid = start + (end - start) / 2;
16175 if (code_line < entries[mid].code_line) {
16176 end = mid;
16177 } else if (code_line > entries[mid].code_line) {
16178 start = mid + 1;
16179 } else {
16180 return mid;
16181 }
16182 }
16183 if (code_line <= entries[mid].code_line) {
16184 return mid;
16185 } else {
16186 return mid + 1;
16187 }
16188 }
16189 static PyCodeObject *__pyx_find_code_object(int code_line) {
16190 PyCodeObject* code_object;
16191 int pos;
16192 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
16193 return NULL;
16194 }
16195 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
16196 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
16197 return NULL;
16198 }
16199 code_object = __pyx_code_cache.entries[pos].code_object;
16200 Py_INCREF(code_object);
16201 return code_object;
16202 }
16203 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
16204 int pos, i;
16205 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
16206 if (unlikely(!code_line)) {
16207 return;
16208 }
16209 if (unlikely(!entries)) {
16210 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
16211 if (likely(entries)) {
16212 __pyx_code_cache.entries = entries;
16213 __pyx_code_cache.max_count = 64;
16214 __pyx_code_cache.count = 1;
16215 entries[0].code_line = code_line;
16216 entries[0].code_object = code_object;
16217 Py_INCREF(code_object);
16218 }
16219 return;
16220 }
16221 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
16222 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
16223 PyCodeObject* tmp = entries[pos].code_object;
16224 entries[pos].code_object = code_object;
16225 Py_DECREF(tmp);
16226 return;
16227 }
16228 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
16229 int new_max = __pyx_code_cache.max_count + 64;
16230 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
16231 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
16232 if (unlikely(!entries)) {
16233 return;
16234 }
16235 __pyx_code_cache.entries = entries;
16236 __pyx_code_cache.max_count = new_max;
16237 }
16238 for (i=__pyx_code_cache.count; i>pos; i--) {
16239 entries[i] = entries[i-1];
16240 }
16241 entries[pos].code_line = code_line;
16242 entries[pos].code_object = code_object;
16243 __pyx_code_cache.count++;
16244 Py_INCREF(code_object);
16245 }
16246 #endif
16247
16248 /* AddTraceback */
16249 #include "compile.h"
16250 #include "frameobject.h"
16251 #include "traceback.h"
16252 #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API
16253 #ifndef Py_BUILD_CORE
16254 #define Py_BUILD_CORE 1
16255 #endif
16256 #include "internal/pycore_frame.h"
16257 #endif
16258 #if CYTHON_COMPILING_IN_LIMITED_API
16259 static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict,
16260 PyObject *firstlineno, PyObject *name) {
16261 PyObject *replace = NULL;
16262 if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL;
16263 if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL;
16264 replace = PyObject_GetAttrString(code, "replace");
16265 if (likely(replace)) {
16266 PyObject *result;
16267 result = PyObject_Call(replace, __pyx_empty_tuple, scratch_dict);
16268 Py_DECREF(replace);
16269 return result;
16270 }
16271 PyErr_Clear();
16272 #if __PYX_LIMITED_VERSION_HEX < 0x030780000
16273 {
16274 PyObject *compiled = NULL, *result = NULL;
16275 if (unlikely(PyDict_SetItemString(scratch_dict, "code", code))) return NULL;
16276 if (unlikely(PyDict_SetItemString(scratch_dict, "type", (PyObject*)(&PyType_Type)))) return NULL;
16277 compiled = Py_CompileString(
16278 "out = type(code)(\n"
16279 " code.co_argcount, code.co_kwonlyargcount, code.co_nlocals, code.co_stacksize,\n"
16280 " code.co_flags, code.co_code, code.co_consts, code.co_names,\n"
16281 " code.co_varnames, code.co_filename, co_name, co_firstlineno,\n"
16282 " code.co_lnotab)\n", "<dummy>", Py_file_input);
16283 if (!compiled) return NULL;
16284 result = PyEval_EvalCode(compiled, scratch_dict, scratch_dict);
16285 Py_DECREF(compiled);
16286 if (!result) PyErr_Print();
16287 Py_DECREF(result);
16288 result = PyDict_GetItemString(scratch_dict, "out");
16289 if (result) Py_INCREF(result);
16290 return result;
16291 }
16292 #else
16293 return NULL;
16294 #endif
16295 }
16296 static void __Pyx_AddTraceback(const char *funcname, int c_line,
16297 int py_line, const char *filename) {
16298 PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL;
16299 PyObject *replace = NULL, *getframe = NULL, *frame = NULL;
16300 PyObject *exc_type, *exc_value, *exc_traceback;
16301 int success = 0;
16302 if (c_line) {
16303 (void) __pyx_cfilenm;
16304 (void) __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line);
16305 }
16306 PyErr_Fetch(&exc_type, &exc_value, &exc_traceback);
16307 code_object = Py_CompileString("_getframe()", filename, Py_eval_input);
16308 if (unlikely(!code_object)) goto bad;
16309 py_py_line = PyLong_FromLong(py_line);
16310 if (unlikely(!py_py_line)) goto bad;
16311 py_funcname = PyUnicode_FromString(funcname);
16312 if (unlikely(!py_funcname)) goto bad;
16313 dict = PyDict_New();
16314 if (unlikely(!dict)) goto bad;
16315 {
16316 PyObject *old_code_object = code_object;
16317 code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname);
16318 Py_DECREF(old_code_object);
16319 }
16320 if (unlikely(!code_object)) goto bad;
16321 getframe = PySys_GetObject("_getframe");
16322 if (unlikely(!getframe)) goto bad;
16323 if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad;
16324 frame = PyEval_EvalCode(code_object, dict, dict);
16325 if (unlikely(!frame) || frame == Py_None) goto bad;
16326 success = 1;
16327 bad:
16328 PyErr_Restore(exc_type, exc_value, exc_traceback);
16329 Py_XDECREF(code_object);
16330 Py_XDECREF(py_py_line);
16331 Py_XDECREF(py_funcname);
16332 Py_XDECREF(dict);
16333 Py_XDECREF(replace);
16334 if (success) {
16335 PyTraceBack_Here(
16336 (struct _frame*)frame);
16337 }
16338 Py_XDECREF(frame);
16339 }
16340 #else
16341 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
16342 const char *funcname, int c_line,
16343 int py_line, const char *filename) {
16344 PyCodeObject *py_code = NULL;
16345 PyObject *py_funcname = NULL;
16346 #if PY_MAJOR_VERSION < 3
16347 PyObject *py_srcfile = NULL;
16348 py_srcfile = PyString_FromString(filename);
16349 if (!py_srcfile) goto bad;
16350 #endif
16351 if (c_line) {
16352 #if PY_MAJOR_VERSION < 3
16353 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
16354 if (!py_funcname) goto bad;
16355 #else
16356 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
16357 if (!py_funcname) goto bad;
16358 funcname = PyUnicode_AsUTF8(py_funcname);
16359 if (!funcname) goto bad;
16360 #endif
16361 }
16362 else {
16363 #if PY_MAJOR_VERSION < 3
16364 py_funcname = PyString_FromString(funcname);
16365 if (!py_funcname) goto bad;
16366 #endif
16367 }
16368 #if PY_MAJOR_VERSION < 3
16369 py_code = __Pyx_PyCode_New(
16370 0,
16371 0,
16372 0,
16373 0,
16374 0,
16375 0,
16376 __pyx_empty_bytes, /*PyObject *code,*/
16377 __pyx_empty_tuple, /*PyObject *consts,*/
16378 __pyx_empty_tuple, /*PyObject *names,*/
16379 __pyx_empty_tuple, /*PyObject *varnames,*/
16380 __pyx_empty_tuple, /*PyObject *freevars,*/
16381 __pyx_empty_tuple, /*PyObject *cellvars,*/
16382 py_srcfile, /*PyObject *filename,*/
16383 py_funcname, /*PyObject *name,*/
16384 py_line,
16385 __pyx_empty_bytes /*PyObject *lnotab*/
16386 );
16387 Py_DECREF(py_srcfile);
16388 #else
16389 py_code = PyCode_NewEmpty(filename, funcname, py_line);
16390 #endif
16391 Py_XDECREF(py_funcname);
16392 return py_code;
16393 bad:
16394 Py_XDECREF(py_funcname);
16395 #if PY_MAJOR_VERSION < 3
16396 Py_XDECREF(py_srcfile);
16397 #endif
16398 return NULL;
16399 }
16400 static void __Pyx_AddTraceback(const char *funcname, int c_line,
16401 int py_line, const char *filename) {
16402 PyCodeObject *py_code = 0;
16403 PyFrameObject *py_frame = 0;
16404 PyThreadState *tstate = __Pyx_PyThreadState_Current;
16405 PyObject *ptype, *pvalue, *ptraceback;
16406 if (c_line) {
16407 c_line = __Pyx_CLineForTraceback(tstate, c_line);
16408 }
16409 py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
16410 if (!py_code) {
16411 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
16412 py_code = __Pyx_CreateCodeObjectForTraceback(
16413 funcname, c_line, py_line, filename);
16414 if (!py_code) {
16415 /* If the code object creation fails, then we should clear the
16416 fetched exception references and propagate the new exception */
16417 Py_XDECREF(ptype);
16418 Py_XDECREF(pvalue);
16419 Py_XDECREF(ptraceback);
16420 goto bad;
16421 }
16422 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
16423 __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
16424 }
16425 py_frame = PyFrame_New(
16426 tstate, /*PyThreadState *tstate,*/
16427 py_code, /*PyCodeObject *code,*/
16428 __pyx_d, /*PyObject *globals,*/
16429 0 /*PyObject *locals*/
16430 );
16431 if (!py_frame) goto bad;
16432 __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
16433 PyTraceBack_Here(py_frame);
16434 bad:
16435 Py_XDECREF(py_code);
16436 Py_XDECREF(py_frame);
16437 }
16438 #endif
16439
16440 /* CIntFromPyVerify */
16441 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
16442 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
16443 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
16444 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
16445 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
16446 {\
16447 func_type value = func_value;\
16448 if (sizeof(target_type) < sizeof(func_type)) {\
16449 if (unlikely(value != (func_type) (target_type) value)) {\
16450 func_type zero = 0;\
16451 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
16452 return (target_type) -1;\
16453 if (is_unsigned && unlikely(value < zero))\
16454 goto raise_neg_overflow;\
16455 else\
16456 goto raise_overflow;\
16457 }\
16458 }\
16459 return (target_type) value;\
16460 }
16461
16462 /* CIntFromPy */
16463 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
16464 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
16465 #pragma GCC diagnostic push
16466 #pragma GCC diagnostic ignored "-Wconversion"
16467 #endif
16468 const int neg_one = (int) -1, const_zero = (int) 0;
16469 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
16470 #pragma GCC diagnostic pop
16471 #endif
16472 const int is_unsigned = neg_one > const_zero;
16473 #if PY_MAJOR_VERSION < 3
16474 if (likely(PyInt_Check(x))) {
16475 if ((sizeof(int) < sizeof(long))) {
16476 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
16477 } else {
16478 long val = PyInt_AS_LONG(x);
16479 if (is_unsigned && unlikely(val < 0)) {
16480 goto raise_neg_overflow;
16481 }
16482 return (int) val;
16483 }
16484 }
16485 #endif
16486 if (unlikely(!PyLong_Check(x))) {
16487 int val;
16488 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
16489 if (!tmp) return (int) -1;
16490 val = __Pyx_PyInt_As_int(tmp);
16491 Py_DECREF(tmp);
16492 return val;
16493 }
16494 if (is_unsigned) {
16495 #if CYTHON_USE_PYLONG_INTERNALS
16496 if (unlikely(__Pyx_PyLong_IsNeg(x))) {
16497 goto raise_neg_overflow;
16498 } else if (__Pyx_PyLong_IsCompact(x)) {
16499 __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
16500 } else {
16501 const digit* digits = __Pyx_PyLong_Digits(x);
16502 assert(__Pyx_PyLong_DigitCount(x) > 1);
16503 switch (__Pyx_PyLong_DigitCount(x)) {
16504 case 2:
16505 if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
16506 if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
16507 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16508 } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) {
16509 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
16510 }
16511 }
16512 break;
16513 case 3:
16514 if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
16515 if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
16516 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16517 } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) {
16518 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
16519 }
16520 }
16521 break;
16522 case 4:
16523 if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
16524 if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
16525 __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])))
16526 } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) {
16527 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
16528 }
16529 }
16530 break;
16531 }
16532 }
16533 #endif
16534 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
16535 if (unlikely(Py_SIZE(x) < 0)) {
16536 goto raise_neg_overflow;
16537 }
16538 #else
16539 {
16540 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
16541 if (unlikely(result < 0))
16542 return (int) -1;
16543 if (unlikely(result == 1))
16544 goto raise_neg_overflow;
16545 }
16546 #endif
16547 if ((sizeof(int) <= sizeof(unsigned long))) {
16548 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
16549 #ifdef HAVE_LONG_LONG
16550 } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) {
16551 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
16552 #endif
16553 }
16554 } else {
16555 #if CYTHON_USE_PYLONG_INTERNALS
16556 if (__Pyx_PyLong_IsCompact(x)) {
16557 __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
16558 } else {
16559 const digit* digits = __Pyx_PyLong_Digits(x);
16560 assert(__Pyx_PyLong_DigitCount(x) > 1);
16561 switch (__Pyx_PyLong_SignedDigitCount(x)) {
16562 case -2:
16563 if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) {
16564 if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
16565 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16566 } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
16567 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
16568 }
16569 }
16570 break;
16571 case 2:
16572 if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
16573 if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
16574 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16575 } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
16576 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
16577 }
16578 }
16579 break;
16580 case -3:
16581 if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
16582 if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
16583 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16584 } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
16585 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
16586 }
16587 }
16588 break;
16589 case 3:
16590 if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
16591 if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
16592 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16593 } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
16594 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
16595 }
16596 }
16597 break;
16598 case -4:
16599 if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
16600 if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
16601 __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])))
16602 } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
16603 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
16604 }
16605 }
16606 break;
16607 case 4:
16608 if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
16609 if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
16610 __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])))
16611 } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
16612 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
16613 }
16614 }
16615 break;
16616 }
16617 }
16618 #endif
16619 if ((sizeof(int) <= sizeof(long))) {
16620 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
16621 #ifdef HAVE_LONG_LONG
16622 } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) {
16623 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
16624 #endif
16625 }
16626 }
16627 {
16628 int val;
16629 int ret = -1;
16630 #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
16631 Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
16632 x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
16633 if (unlikely(bytes_copied == -1)) {
16634 } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
16635 goto raise_overflow;
16636 } else {
16637 ret = 0;
16638 }
16639 #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
16640 int one = 1; int is_little = (int)*(unsigned char *)&one;
16641 unsigned char *bytes = (unsigned char *)&val;
16642 ret = _PyLong_AsByteArray((PyLongObject *)x,
16643 bytes, sizeof(val),
16644 is_little, !is_unsigned);
16645 #else
16646 PyObject *v;
16647 PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
16648 int bits, remaining_bits, is_negative = 0;
16649 int chunk_size = (sizeof(long) < 8) ? 30 : 62;
16650 if (likely(PyLong_CheckExact(x))) {
16651 v = __Pyx_NewRef(x);
16652 } else {
16653 v = PyNumber_Long(x);
16654 if (unlikely(!v)) return (int) -1;
16655 assert(PyLong_CheckExact(v));
16656 }
16657 {
16658 int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
16659 if (unlikely(result < 0)) {
16660 Py_DECREF(v);
16661 return (int) -1;
16662 }
16663 is_negative = result == 1;
16664 }
16665 if (is_unsigned && unlikely(is_negative)) {
16666 Py_DECREF(v);
16667 goto raise_neg_overflow;
16668 } else if (is_negative) {
16669 stepval = PyNumber_Invert(v);
16670 Py_DECREF(v);
16671 if (unlikely(!stepval))
16672 return (int) -1;
16673 } else {
16674 stepval = v;
16675 }
16676 v = NULL;
16677 val = (int) 0;
16678 mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
16679 shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
16680 for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
16681 PyObject *tmp, *digit;
16682 long idigit;
16683 digit = PyNumber_And(stepval, mask);
16684 if (unlikely(!digit)) goto done;
16685 idigit = PyLong_AsLong(digit);
16686 Py_DECREF(digit);
16687 if (unlikely(idigit < 0)) goto done;
16688 val |= ((int) idigit) << bits;
16689 tmp = PyNumber_Rshift(stepval, shift);
16690 if (unlikely(!tmp)) goto done;
16691 Py_DECREF(stepval); stepval = tmp;
16692 }
16693 Py_DECREF(shift); shift = NULL;
16694 Py_DECREF(mask); mask = NULL;
16695 {
16696 long idigit = PyLong_AsLong(stepval);
16697 if (unlikely(idigit < 0)) goto done;
16698 remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
16699 if (unlikely(idigit >= (1L << remaining_bits)))
16700 goto raise_overflow;
16701 val |= ((int) idigit) << bits;
16702 }
16703 if (!is_unsigned) {
16704 if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
16705 goto raise_overflow;
16706 if (is_negative)
16707 val = ~val;
16708 }
16709 ret = 0;
16710 done:
16711 Py_XDECREF(shift);
16712 Py_XDECREF(mask);
16713 Py_XDECREF(stepval);
16714 #endif
16715 if (unlikely(ret))
16716 return (int) -1;
16717 return val;
16718 }
16719 raise_overflow:
16720 PyErr_SetString(PyExc_OverflowError,
16721 "value too large to convert to int");
16722 return (int) -1;
16723 raise_neg_overflow:
16724 PyErr_SetString(PyExc_OverflowError,
16725 "can't convert negative value to int");
16726 return (int) -1;
16727 }
16728
16729 /* CIntFromPy */
16730 static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
16731 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
16732 #pragma GCC diagnostic push
16733 #pragma GCC diagnostic ignored "-Wconversion"
16734 #endif
16735 const char neg_one = (char) -1, const_zero = (char) 0;
16736 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
16737 #pragma GCC diagnostic pop
16738 #endif
16739 const int is_unsigned = neg_one > const_zero;
16740 #if PY_MAJOR_VERSION < 3
16741 if (likely(PyInt_Check(x))) {
16742 if ((sizeof(char) < sizeof(long))) {
16743 __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
16744 } else {
16745 long val = PyInt_AS_LONG(x);
16746 if (is_unsigned && unlikely(val < 0)) {
16747 goto raise_neg_overflow;
16748 }
16749 return (char) val;
16750 }
16751 }
16752 #endif
16753 if (unlikely(!PyLong_Check(x))) {
16754 char val;
16755 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
16756 if (!tmp) return (char) -1;
16757 val = __Pyx_PyInt_As_char(tmp);
16758 Py_DECREF(tmp);
16759 return val;
16760 }
16761 if (is_unsigned) {
16762 #if CYTHON_USE_PYLONG_INTERNALS
16763 if (unlikely(__Pyx_PyLong_IsNeg(x))) {
16764 goto raise_neg_overflow;
16765 } else if (__Pyx_PyLong_IsCompact(x)) {
16766 __PYX_VERIFY_RETURN_INT(char, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
16767 } else {
16768 const digit* digits = __Pyx_PyLong_Digits(x);
16769 assert(__Pyx_PyLong_DigitCount(x) > 1);
16770 switch (__Pyx_PyLong_DigitCount(x)) {
16771 case 2:
16772 if ((8 * sizeof(char) > 1 * PyLong_SHIFT)) {
16773 if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
16774 __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16775 } else if ((8 * sizeof(char) >= 2 * PyLong_SHIFT)) {
16776 return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
16777 }
16778 }
16779 break;
16780 case 3:
16781 if ((8 * sizeof(char) > 2 * PyLong_SHIFT)) {
16782 if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
16783 __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16784 } else if ((8 * sizeof(char) >= 3 * PyLong_SHIFT)) {
16785 return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
16786 }
16787 }
16788 break;
16789 case 4:
16790 if ((8 * sizeof(char) > 3 * PyLong_SHIFT)) {
16791 if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
16792 __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16793 } else if ((8 * sizeof(char) >= 4 * PyLong_SHIFT)) {
16794 return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
16795 }
16796 }
16797 break;
16798 }
16799 }
16800 #endif
16801 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
16802 if (unlikely(Py_SIZE(x) < 0)) {
16803 goto raise_neg_overflow;
16804 }
16805 #else
16806 {
16807 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
16808 if (unlikely(result < 0))
16809 return (char) -1;
16810 if (unlikely(result == 1))
16811 goto raise_neg_overflow;
16812 }
16813 #endif
16814 if ((sizeof(char) <= sizeof(unsigned long))) {
16815 __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
16816 #ifdef HAVE_LONG_LONG
16817 } else if ((sizeof(char) <= sizeof(unsigned PY_LONG_LONG))) {
16818 __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
16819 #endif
16820 }
16821 } else {
16822 #if CYTHON_USE_PYLONG_INTERNALS
16823 if (__Pyx_PyLong_IsCompact(x)) {
16824 __PYX_VERIFY_RETURN_INT(char, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
16825 } else {
16826 const digit* digits = __Pyx_PyLong_Digits(x);
16827 assert(__Pyx_PyLong_DigitCount(x) > 1);
16828 switch (__Pyx_PyLong_SignedDigitCount(x)) {
16829 case -2:
16830 if ((8 * sizeof(char) - 1 > 1 * PyLong_SHIFT)) {
16831 if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
16832 __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16833 } else if ((8 * sizeof(char) - 1 > 2 * PyLong_SHIFT)) {
16834 return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
16835 }
16836 }
16837 break;
16838 case 2:
16839 if ((8 * sizeof(char) > 1 * PyLong_SHIFT)) {
16840 if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
16841 __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16842 } else if ((8 * sizeof(char) - 1 > 2 * PyLong_SHIFT)) {
16843 return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
16844 }
16845 }
16846 break;
16847 case -3:
16848 if ((8 * sizeof(char) - 1 > 2 * PyLong_SHIFT)) {
16849 if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
16850 __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16851 } else if ((8 * sizeof(char) - 1 > 3 * PyLong_SHIFT)) {
16852 return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
16853 }
16854 }
16855 break;
16856 case 3:
16857 if ((8 * sizeof(char) > 2 * PyLong_SHIFT)) {
16858 if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
16859 __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16860 } else if ((8 * sizeof(char) - 1 > 3 * PyLong_SHIFT)) {
16861 return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
16862 }
16863 }
16864 break;
16865 case -4:
16866 if ((8 * sizeof(char) - 1 > 3 * PyLong_SHIFT)) {
16867 if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
16868 __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16869 } else if ((8 * sizeof(char) - 1 > 4 * PyLong_SHIFT)) {
16870 return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
16871 }
16872 }
16873 break;
16874 case 4:
16875 if ((8 * sizeof(char) > 3 * PyLong_SHIFT)) {
16876 if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
16877 __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
16878 } else if ((8 * sizeof(char) - 1 > 4 * PyLong_SHIFT)) {
16879 return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
16880 }
16881 }
16882 break;
16883 }
16884 }
16885 #endif
16886 if ((sizeof(char) <= sizeof(long))) {
16887 __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
16888 #ifdef HAVE_LONG_LONG
16889 } else if ((sizeof(char) <= sizeof(PY_LONG_LONG))) {
16890 __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
16891 #endif
16892 }
16893 }
16894 {
16895 char val;
16896 int ret = -1;
16897 #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
16898 Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
16899 x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
16900 if (unlikely(bytes_copied == -1)) {
16901 } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
16902 goto raise_overflow;
16903 } else {
16904 ret = 0;
16905 }
16906 #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
16907 int one = 1; int is_little = (int)*(unsigned char *)&one;
16908 unsigned char *bytes = (unsigned char *)&val;
16909 ret = _PyLong_AsByteArray((PyLongObject *)x,
16910 bytes, sizeof(val),
16911 is_little, !is_unsigned);
16912 #else
16913 PyObject *v;
16914 PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
16915 int bits, remaining_bits, is_negative = 0;
16916 int chunk_size = (sizeof(long) < 8) ? 30 : 62;
16917 if (likely(PyLong_CheckExact(x))) {
16918 v = __Pyx_NewRef(x);
16919 } else {
16920 v = PyNumber_Long(x);
16921 if (unlikely(!v)) return (char) -1;
16922 assert(PyLong_CheckExact(v));
16923 }
16924 {
16925 int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
16926 if (unlikely(result < 0)) {
16927 Py_DECREF(v);
16928 return (char) -1;
16929 }
16930 is_negative = result == 1;
16931 }
16932 if (is_unsigned && unlikely(is_negative)) {
16933 Py_DECREF(v);
16934 goto raise_neg_overflow;
16935 } else if (is_negative) {
16936 stepval = PyNumber_Invert(v);
16937 Py_DECREF(v);
16938 if (unlikely(!stepval))
16939 return (char) -1;
16940 } else {
16941 stepval = v;
16942 }
16943 v = NULL;
16944 val = (char) 0;
16945 mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
16946 shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
16947 for (bits = 0; bits < (int) sizeof(char) * 8 - chunk_size; bits += chunk_size) {
16948 PyObject *tmp, *digit;
16949 long idigit;
16950 digit = PyNumber_And(stepval, mask);
16951 if (unlikely(!digit)) goto done;
16952 idigit = PyLong_AsLong(digit);
16953 Py_DECREF(digit);
16954 if (unlikely(idigit < 0)) goto done;
16955 val |= ((char) idigit) << bits;
16956 tmp = PyNumber_Rshift(stepval, shift);
16957 if (unlikely(!tmp)) goto done;
16958 Py_DECREF(stepval); stepval = tmp;
16959 }
16960 Py_DECREF(shift); shift = NULL;
16961 Py_DECREF(mask); mask = NULL;
16962 {
16963 long idigit = PyLong_AsLong(stepval);
16964 if (unlikely(idigit < 0)) goto done;
16965 remaining_bits = ((int) sizeof(char) * 8) - bits - (is_unsigned ? 0 : 1);
16966 if (unlikely(idigit >= (1L << remaining_bits)))
16967 goto raise_overflow;
16968 val |= ((char) idigit) << bits;
16969 }
16970 if (!is_unsigned) {
16971 if (unlikely(val & (((char) 1) << (sizeof(char) * 8 - 1))))
16972 goto raise_overflow;
16973 if (is_negative)
16974 val = ~val;
16975 }
16976 ret = 0;
16977 done:
16978 Py_XDECREF(shift);
16979 Py_XDECREF(mask);
16980 Py_XDECREF(stepval);
16981 #endif
16982 if (unlikely(ret))
16983 return (char) -1;
16984 return val;
16985 }
16986 raise_overflow:
16987 PyErr_SetString(PyExc_OverflowError,
16988 "value too large to convert to char");
16989 return (char) -1;
16990 raise_neg_overflow:
16991 PyErr_SetString(PyExc_OverflowError,
16992 "can't convert negative value to char");
16993 return (char) -1;
16994 }
16995
16996 /* CIntToPy */
16997 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
16998 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
16999 #pragma GCC diagnostic push
17000 #pragma GCC diagnostic ignored "-Wconversion"
17001 #endif
17002 const int neg_one = (int) -1, const_zero = (int) 0;
17003 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
17004 #pragma GCC diagnostic pop
17005 #endif
17006 const int is_unsigned = neg_one > const_zero;
17007 if (is_unsigned) {
17008 if (sizeof(int) < sizeof(long)) {
17009 return PyInt_FromLong((long) value);
17010 } else if (sizeof(int) <= sizeof(unsigned long)) {
17011 return PyLong_FromUnsignedLong((unsigned long) value);
17012 #ifdef HAVE_LONG_LONG
17013 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
17014 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
17015 #endif
17016 }
17017 } else {
17018 if (sizeof(int) <= sizeof(long)) {
17019 return PyInt_FromLong((long) value);
17020 #ifdef HAVE_LONG_LONG
17021 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
17022 return PyLong_FromLongLong((PY_LONG_LONG) value);
17023 #endif
17024 }
17025 }
17026 {
17027 unsigned char *bytes = (unsigned char *)&value;
17028 #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
17029 if (is_unsigned) {
17030 return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
17031 } else {
17032 return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
17033 }
17034 #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
17035 int one = 1; int little = (int)*(unsigned char *)&one;
17036 return _PyLong_FromByteArray(bytes, sizeof(int),
17037 little, !is_unsigned);
17038 #else
17039 int one = 1; int little = (int)*(unsigned char *)&one;
17040 PyObject *from_bytes, *result = NULL;
17041 PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL;
17042 from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
17043 if (!from_bytes) return NULL;
17044 py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(int));
17045 if (!py_bytes) goto limited_bad;
17046 order_str = PyUnicode_FromString(little ? "little" : "big");
17047 if (!order_str) goto limited_bad;
17048 arg_tuple = PyTuple_Pack(2, py_bytes, order_str);
17049 if (!arg_tuple) goto limited_bad;
17050 if (!is_unsigned) {
17051 kwds = PyDict_New();
17052 if (!kwds) goto limited_bad;
17053 if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad;
17054 }
17055 result = PyObject_Call(from_bytes, arg_tuple, kwds);
17056 limited_bad:
17057 Py_XDECREF(kwds);
17058 Py_XDECREF(arg_tuple);
17059 Py_XDECREF(order_str);
17060 Py_XDECREF(py_bytes);
17061 Py_XDECREF(from_bytes);
17062 return result;
17063 #endif
17064 }
17065 }
17066
17067 /* CIntFromPy */
17068 static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *x) {
17069 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
17070 #pragma GCC diagnostic push
17071 #pragma GCC diagnostic ignored "-Wconversion"
17072 #endif
17073 const int32_t neg_one = (int32_t) -1, const_zero = (int32_t) 0;
17074 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
17075 #pragma GCC diagnostic pop
17076 #endif
17077 const int is_unsigned = neg_one > const_zero;
17078 #if PY_MAJOR_VERSION < 3
17079 if (likely(PyInt_Check(x))) {
17080 if ((sizeof(int32_t) < sizeof(long))) {
17081 __PYX_VERIFY_RETURN_INT(int32_t, long, PyInt_AS_LONG(x))
17082 } else {
17083 long val = PyInt_AS_LONG(x);
17084 if (is_unsigned && unlikely(val < 0)) {
17085 goto raise_neg_overflow;
17086 }
17087 return (int32_t) val;
17088 }
17089 }
17090 #endif
17091 if (unlikely(!PyLong_Check(x))) {
17092 int32_t val;
17093 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
17094 if (!tmp) return (int32_t) -1;
17095 val = __Pyx_PyInt_As_int32_t(tmp);
17096 Py_DECREF(tmp);
17097 return val;
17098 }
17099 if (is_unsigned) {
17100 #if CYTHON_USE_PYLONG_INTERNALS
17101 if (unlikely(__Pyx_PyLong_IsNeg(x))) {
17102 goto raise_neg_overflow;
17103 } else if (__Pyx_PyLong_IsCompact(x)) {
17104 __PYX_VERIFY_RETURN_INT(int32_t, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
17105 } else {
17106 const digit* digits = __Pyx_PyLong_Digits(x);
17107 assert(__Pyx_PyLong_DigitCount(x) > 1);
17108 switch (__Pyx_PyLong_DigitCount(x)) {
17109 case 2:
17110 if ((8 * sizeof(int32_t) > 1 * PyLong_SHIFT)) {
17111 if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
17112 __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
17113 } else if ((8 * sizeof(int32_t) >= 2 * PyLong_SHIFT)) {
17114 return (int32_t) (((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
17115 }
17116 }
17117 break;
17118 case 3:
17119 if ((8 * sizeof(int32_t) > 2 * PyLong_SHIFT)) {
17120 if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
17121 __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
17122 } else if ((8 * sizeof(int32_t) >= 3 * PyLong_SHIFT)) {
17123 return (int32_t) (((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
17124 }
17125 }
17126 break;
17127 case 4:
17128 if ((8 * sizeof(int32_t) > 3 * PyLong_SHIFT)) {
17129 if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
17130 __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
17131 } else if ((8 * sizeof(int32_t) >= 4 * PyLong_SHIFT)) {
17132 return (int32_t) (((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]));
17133 }
17134 }
17135 break;
17136 }
17137 }
17138 #endif
17139 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
17140 if (unlikely(Py_SIZE(x) < 0)) {
17141 goto raise_neg_overflow;
17142 }
17143 #else
17144 {
17145 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
17146 if (unlikely(result < 0))
17147 return (int32_t) -1;
17148 if (unlikely(result == 1))
17149 goto raise_neg_overflow;
17150 }
17151 #endif
17152 if ((sizeof(int32_t) <= sizeof(unsigned long))) {
17153 __PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned long, PyLong_AsUnsignedLong(x))
17154 #ifdef HAVE_LONG_LONG
17155 } else if ((sizeof(int32_t) <= sizeof(unsigned PY_LONG_LONG))) {
17156 __PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
17157 #endif
17158 }
17159 } else {
17160 #if CYTHON_USE_PYLONG_INTERNALS
17161 if (__Pyx_PyLong_IsCompact(x)) {
17162 __PYX_VERIFY_RETURN_INT(int32_t, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
17163 } else {
17164 const digit* digits = __Pyx_PyLong_Digits(x);
17165 assert(__Pyx_PyLong_DigitCount(x) > 1);
17166 switch (__Pyx_PyLong_SignedDigitCount(x)) {
17167 case -2:
17168 if ((8 * sizeof(int32_t) - 1 > 1 * PyLong_SHIFT)) {
17169 if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
17170 __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
17171 } else if ((8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT)) {
17172 return (int32_t) (((int32_t)-1)*(((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
17173 }
17174 }
17175 break;
17176 case 2:
17177 if ((8 * sizeof(int32_t) > 1 * PyLong_SHIFT)) {
17178 if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
17179 __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
17180 } else if ((8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT)) {
17181 return (int32_t) ((((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
17182 }
17183 }
17184 break;
17185 case -3:
17186 if ((8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT)) {
17187 if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
17188 __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
17189 } else if ((8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT)) {
17190 return (int32_t) (((int32_t)-1)*(((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
17191 }
17192 }
17193 break;
17194 case 3:
17195 if ((8 * sizeof(int32_t) > 2 * PyLong_SHIFT)) {
17196 if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
17197 __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
17198 } else if ((8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT)) {
17199 return (int32_t) ((((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
17200 }
17201 }
17202 break;
17203 case -4:
17204 if ((8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT)) {
17205 if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
17206 __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
17207 } else if ((8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT)) {
17208 return (int32_t) (((int32_t)-1)*(((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
17209 }
17210 }
17211 break;
17212 case 4:
17213 if ((8 * sizeof(int32_t) > 3 * PyLong_SHIFT)) {
17214 if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
17215 __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
17216 } else if ((8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT)) {
17217 return (int32_t) ((((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])));
17218 }
17219 }
17220 break;
17221 }
17222 }
17223 #endif
17224 if ((sizeof(int32_t) <= sizeof(long))) {
17225 __PYX_VERIFY_RETURN_INT_EXC(int32_t, long, PyLong_AsLong(x))
17226 #ifdef HAVE_LONG_LONG
17227 } else if ((sizeof(int32_t) <= sizeof(PY_LONG_LONG))) {
17228 __PYX_VERIFY_RETURN_INT_EXC(int32_t, PY_LONG_LONG, PyLong_AsLongLong(x))
17229 #endif
17230 }
17231 }
17232 {
17233 int32_t val;
17234 int ret = -1;
17235 #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
17236 Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
17237 x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
17238 if (unlikely(bytes_copied == -1)) {
17239 } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
17240 goto raise_overflow;
17241 } else {
17242 ret = 0;
17243 }
17244 #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
17245 int one = 1; int is_little = (int)*(unsigned char *)&one;
17246 unsigned char *bytes = (unsigned char *)&val;
17247 ret = _PyLong_AsByteArray((PyLongObject *)x,
17248 bytes, sizeof(val),
17249 is_little, !is_unsigned);
17250 #else
17251 PyObject *v;
17252 PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
17253 int bits, remaining_bits, is_negative = 0;
17254 int chunk_size = (sizeof(long) < 8) ? 30 : 62;
17255 if (likely(PyLong_CheckExact(x))) {
17256 v = __Pyx_NewRef(x);
17257 } else {
17258 v = PyNumber_Long(x);
17259 if (unlikely(!v)) return (int32_t) -1;
17260 assert(PyLong_CheckExact(v));
17261 }
17262 {
17263 int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
17264 if (unlikely(result < 0)) {
17265 Py_DECREF(v);
17266 return (int32_t) -1;
17267 }
17268 is_negative = result == 1;
17269 }
17270 if (is_unsigned && unlikely(is_negative)) {
17271 Py_DECREF(v);
17272 goto raise_neg_overflow;
17273 } else if (is_negative) {
17274 stepval = PyNumber_Invert(v);
17275 Py_DECREF(v);
17276 if (unlikely(!stepval))
17277 return (int32_t) -1;
17278 } else {
17279 stepval = v;
17280 }
17281 v = NULL;
17282 val = (int32_t) 0;
17283 mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
17284 shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
17285 for (bits = 0; bits < (int) sizeof(int32_t) * 8 - chunk_size; bits += chunk_size) {
17286 PyObject *tmp, *digit;
17287 long idigit;
17288 digit = PyNumber_And(stepval, mask);
17289 if (unlikely(!digit)) goto done;
17290 idigit = PyLong_AsLong(digit);
17291 Py_DECREF(digit);
17292 if (unlikely(idigit < 0)) goto done;
17293 val |= ((int32_t) idigit) << bits;
17294 tmp = PyNumber_Rshift(stepval, shift);
17295 if (unlikely(!tmp)) goto done;
17296 Py_DECREF(stepval); stepval = tmp;
17297 }
17298 Py_DECREF(shift); shift = NULL;
17299 Py_DECREF(mask); mask = NULL;
17300 {
17301 long idigit = PyLong_AsLong(stepval);
17302 if (unlikely(idigit < 0)) goto done;
17303 remaining_bits = ((int) sizeof(int32_t) * 8) - bits - (is_unsigned ? 0 : 1);
17304 if (unlikely(idigit >= (1L << remaining_bits)))
17305 goto raise_overflow;
17306 val |= ((int32_t) idigit) << bits;
17307 }
17308 if (!is_unsigned) {
17309 if (unlikely(val & (((int32_t) 1) << (sizeof(int32_t) * 8 - 1))))
17310 goto raise_overflow;
17311 if (is_negative)
17312 val = ~val;
17313 }
17314 ret = 0;
17315 done:
17316 Py_XDECREF(shift);
17317 Py_XDECREF(mask);
17318 Py_XDECREF(stepval);
17319 #endif
17320 if (unlikely(ret))
17321 return (int32_t) -1;
17322 return val;
17323 }
17324 raise_overflow:
17325 PyErr_SetString(PyExc_OverflowError,
17326 "value too large to convert to int32_t");
17327 return (int32_t) -1;
17328 raise_neg_overflow:
17329 PyErr_SetString(PyExc_OverflowError,
17330 "can't convert negative value to int32_t");
17331 return (int32_t) -1;
17332 }
17333
17334 /* CIntToPy */
17335 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
17336 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
17337 #pragma GCC diagnostic push
17338 #pragma GCC diagnostic ignored "-Wconversion"
17339 #endif
17340 const long neg_one = (long) -1, const_zero = (long) 0;
17341 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
17342 #pragma GCC diagnostic pop
17343 #endif
17344 const int is_unsigned = neg_one > const_zero;
17345 if (is_unsigned) {
17346 if (sizeof(long) < sizeof(long)) {
17347 return PyInt_FromLong((long) value);
17348 } else if (sizeof(long) <= sizeof(unsigned long)) {
17349 return PyLong_FromUnsignedLong((unsigned long) value);
17350 #ifdef HAVE_LONG_LONG
17351 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
17352 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
17353 #endif
17354 }
17355 } else {
17356 if (sizeof(long) <= sizeof(long)) {
17357 return PyInt_FromLong((long) value);
17358 #ifdef HAVE_LONG_LONG
17359 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
17360 return PyLong_FromLongLong((PY_LONG_LONG) value);
17361 #endif
17362 }
17363 }
17364 {
17365 unsigned char *bytes = (unsigned char *)&value;
17366 #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
17367 if (is_unsigned) {
17368 return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
17369 } else {
17370 return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
17371 }
17372 #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
17373 int one = 1; int little = (int)*(unsigned char *)&one;
17374 return _PyLong_FromByteArray(bytes, sizeof(long),
17375 little, !is_unsigned);
17376 #else
17377 int one = 1; int little = (int)*(unsigned char *)&one;
17378 PyObject *from_bytes, *result = NULL;
17379 PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL;
17380 from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
17381 if (!from_bytes) return NULL;
17382 py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long));
17383 if (!py_bytes) goto limited_bad;
17384 order_str = PyUnicode_FromString(little ? "little" : "big");
17385 if (!order_str) goto limited_bad;
17386 arg_tuple = PyTuple_Pack(2, py_bytes, order_str);
17387 if (!arg_tuple) goto limited_bad;
17388 if (!is_unsigned) {
17389 kwds = PyDict_New();
17390 if (!kwds) goto limited_bad;
17391 if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad;
17392 }
17393 result = PyObject_Call(from_bytes, arg_tuple, kwds);
17394 limited_bad:
17395 Py_XDECREF(kwds);
17396 Py_XDECREF(arg_tuple);
17397 Py_XDECREF(order_str);
17398 Py_XDECREF(py_bytes);
17399 Py_XDECREF(from_bytes);
17400 return result;
17401 #endif
17402 }
17403 }
17404
17405 /* CIntToPy */
17406 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int32_t(int32_t value) {
17407 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
17408 #pragma GCC diagnostic push
17409 #pragma GCC diagnostic ignored "-Wconversion"
17410 #endif
17411 const int32_t neg_one = (int32_t) -1, const_zero = (int32_t) 0;
17412 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
17413 #pragma GCC diagnostic pop
17414 #endif
17415 const int is_unsigned = neg_one > const_zero;
17416 if (is_unsigned) {
17417 if (sizeof(int32_t) < sizeof(long)) {
17418 return PyInt_FromLong((long) value);
17419 } else if (sizeof(int32_t) <= sizeof(unsigned long)) {
17420 return PyLong_FromUnsignedLong((unsigned long) value);
17421 #ifdef HAVE_LONG_LONG
17422 } else if (sizeof(int32_t) <= sizeof(unsigned PY_LONG_LONG)) {
17423 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
17424 #endif
17425 }
17426 } else {
17427 if (sizeof(int32_t) <= sizeof(long)) {
17428 return PyInt_FromLong((long) value);
17429 #ifdef HAVE_LONG_LONG
17430 } else if (sizeof(int32_t) <= sizeof(PY_LONG_LONG)) {
17431 return PyLong_FromLongLong((PY_LONG_LONG) value);
17432 #endif
17433 }
17434 }
17435 {
17436 unsigned char *bytes = (unsigned char *)&value;
17437 #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
17438 if (is_unsigned) {
17439 return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
17440 } else {
17441 return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
17442 }
17443 #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
17444 int one = 1; int little = (int)*(unsigned char *)&one;
17445 return _PyLong_FromByteArray(bytes, sizeof(int32_t),
17446 little, !is_unsigned);
17447 #else
17448 int one = 1; int little = (int)*(unsigned char *)&one;
17449 PyObject *from_bytes, *result = NULL;
17450 PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL;
17451 from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
17452 if (!from_bytes) return NULL;
17453 py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(int32_t));
17454 if (!py_bytes) goto limited_bad;
17455 order_str = PyUnicode_FromString(little ? "little" : "big");
17456 if (!order_str) goto limited_bad;
17457 arg_tuple = PyTuple_Pack(2, py_bytes, order_str);
17458 if (!arg_tuple) goto limited_bad;
17459 if (!is_unsigned) {
17460 kwds = PyDict_New();
17461 if (!kwds) goto limited_bad;
17462 if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad;
17463 }
17464 result = PyObject_Call(from_bytes, arg_tuple, kwds);
17465 limited_bad:
17466 Py_XDECREF(kwds);
17467 Py_XDECREF(arg_tuple);
17468 Py_XDECREF(order_str);
17469 Py_XDECREF(py_bytes);
17470 Py_XDECREF(from_bytes);
17471 return result;
17472 #endif
17473 }
17474 }
17475
17476 /* FormatTypeName */
17477 #if CYTHON_COMPILING_IN_LIMITED_API
17478 static __Pyx_TypeName
17479 __Pyx_PyType_GetName(PyTypeObject* tp)
17480 {
17481 PyObject *name = __Pyx_PyObject_GetAttrStr((PyObject *)tp,
17482 __pyx_n_s_name_2);
17483 if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) {
17484 PyErr_Clear();
17485 Py_XDECREF(name);
17486 name = __Pyx_NewRef(__pyx_n_s__33);
17487 }
17488 return name;
17489 }
17490 #endif
17491
17492 /* CIntFromPy */
17493 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
17494 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
17495 #pragma GCC diagnostic push
17496 #pragma GCC diagnostic ignored "-Wconversion"
17497 #endif
17498 const long neg_one = (long) -1, const_zero = (long) 0;
17499 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
17500 #pragma GCC diagnostic pop
17501 #endif
17502 const int is_unsigned = neg_one > const_zero;
17503 #if PY_MAJOR_VERSION < 3
17504 if (likely(PyInt_Check(x))) {
17505 if ((sizeof(long) < sizeof(long))) {
17506 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
17507 } else {
17508 long val = PyInt_AS_LONG(x);
17509 if (is_unsigned && unlikely(val < 0)) {
17510 goto raise_neg_overflow;
17511 }
17512 return (long) val;
17513 }
17514 }
17515 #endif
17516 if (unlikely(!PyLong_Check(x))) {
17517 long val;
17518 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
17519 if (!tmp) return (long) -1;
17520 val = __Pyx_PyInt_As_long(tmp);
17521 Py_DECREF(tmp);
17522 return val;
17523 }
17524 if (is_unsigned) {
17525 #if CYTHON_USE_PYLONG_INTERNALS
17526 if (unlikely(__Pyx_PyLong_IsNeg(x))) {
17527 goto raise_neg_overflow;
17528 } else if (__Pyx_PyLong_IsCompact(x)) {
17529 __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
17530 } else {
17531 const digit* digits = __Pyx_PyLong_Digits(x);
17532 assert(__Pyx_PyLong_DigitCount(x) > 1);
17533 switch (__Pyx_PyLong_DigitCount(x)) {
17534 case 2:
17535 if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
17536 if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
17537 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
17538 } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) {
17539 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
17540 }
17541 }
17542 break;
17543 case 3:
17544 if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
17545 if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
17546 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
17547 } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) {
17548 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
17549 }
17550 }
17551 break;
17552 case 4:
17553 if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
17554 if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
17555 __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])))
17556 } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) {
17557 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
17558 }
17559 }
17560 break;
17561 }
17562 }
17563 #endif
17564 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
17565 if (unlikely(Py_SIZE(x) < 0)) {
17566 goto raise_neg_overflow;
17567 }
17568 #else
17569 {
17570 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
17571 if (unlikely(result < 0))
17572 return (long) -1;
17573 if (unlikely(result == 1))
17574 goto raise_neg_overflow;
17575 }
17576 #endif
17577 if ((sizeof(long) <= sizeof(unsigned long))) {
17578 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
17579 #ifdef HAVE_LONG_LONG
17580 } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) {
17581 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
17582 #endif
17583 }
17584 } else {
17585 #if CYTHON_USE_PYLONG_INTERNALS
17586 if (__Pyx_PyLong_IsCompact(x)) {
17587 __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
17588 } else {
17589 const digit* digits = __Pyx_PyLong_Digits(x);
17590 assert(__Pyx_PyLong_DigitCount(x) > 1);
17591 switch (__Pyx_PyLong_SignedDigitCount(x)) {
17592 case -2:
17593 if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) {
17594 if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
17595 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
17596 } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
17597 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
17598 }
17599 }
17600 break;
17601 case 2:
17602 if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
17603 if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
17604 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
17605 } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
17606 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
17607 }
17608 }
17609 break;
17610 case -3:
17611 if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
17612 if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
17613 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
17614 } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
17615 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
17616 }
17617 }
17618 break;
17619 case 3:
17620 if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
17621 if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
17622 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
17623 } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
17624 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
17625 }
17626 }
17627 break;
17628 case -4:
17629 if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
17630 if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
17631 __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])))
17632 } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
17633 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
17634 }
17635 }
17636 break;
17637 case 4:
17638 if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
17639 if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
17640 __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])))
17641 } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
17642 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
17643 }
17644 }
17645 break;
17646 }
17647 }
17648 #endif
17649 if ((sizeof(long) <= sizeof(long))) {
17650 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
17651 #ifdef HAVE_LONG_LONG
17652 } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) {
17653 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
17654 #endif
17655 }
17656 }
17657 {
17658 long val;
17659 int ret = -1;
17660 #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
17661 Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
17662 x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
17663 if (unlikely(bytes_copied == -1)) {
17664 } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
17665 goto raise_overflow;
17666 } else {
17667 ret = 0;
17668 }
17669 #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
17670 int one = 1; int is_little = (int)*(unsigned char *)&one;
17671 unsigned char *bytes = (unsigned char *)&val;
17672 ret = _PyLong_AsByteArray((PyLongObject *)x,
17673 bytes, sizeof(val),
17674 is_little, !is_unsigned);
17675 #else
17676 PyObject *v;
17677 PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
17678 int bits, remaining_bits, is_negative = 0;
17679 int chunk_size = (sizeof(long) < 8) ? 30 : 62;
17680 if (likely(PyLong_CheckExact(x))) {
17681 v = __Pyx_NewRef(x);
17682 } else {
17683 v = PyNumber_Long(x);
17684 if (unlikely(!v)) return (long) -1;
17685 assert(PyLong_CheckExact(v));
17686 }
17687 {
17688 int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
17689 if (unlikely(result < 0)) {
17690 Py_DECREF(v);
17691 return (long) -1;
17692 }
17693 is_negative = result == 1;
17694 }
17695 if (is_unsigned && unlikely(is_negative)) {
17696 Py_DECREF(v);
17697 goto raise_neg_overflow;
17698 } else if (is_negative) {
17699 stepval = PyNumber_Invert(v);
17700 Py_DECREF(v);
17701 if (unlikely(!stepval))
17702 return (long) -1;
17703 } else {
17704 stepval = v;
17705 }
17706 v = NULL;
17707 val = (long) 0;
17708 mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
17709 shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
17710 for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
17711 PyObject *tmp, *digit;
17712 long idigit;
17713 digit = PyNumber_And(stepval, mask);
17714 if (unlikely(!digit)) goto done;
17715 idigit = PyLong_AsLong(digit);
17716 Py_DECREF(digit);
17717 if (unlikely(idigit < 0)) goto done;
17718 val |= ((long) idigit) << bits;
17719 tmp = PyNumber_Rshift(stepval, shift);
17720 if (unlikely(!tmp)) goto done;
17721 Py_DECREF(stepval); stepval = tmp;
17722 }
17723 Py_DECREF(shift); shift = NULL;
17724 Py_DECREF(mask); mask = NULL;
17725 {
17726 long idigit = PyLong_AsLong(stepval);
17727 if (unlikely(idigit < 0)) goto done;
17728 remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
17729 if (unlikely(idigit >= (1L << remaining_bits)))
17730 goto raise_overflow;
17731 val |= ((long) idigit) << bits;
17732 }
17733 if (!is_unsigned) {
17734 if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
17735 goto raise_overflow;
17736 if (is_negative)
17737 val = ~val;
17738 }
17739 ret = 0;
17740 done:
17741 Py_XDECREF(shift);
17742 Py_XDECREF(mask);
17743 Py_XDECREF(stepval);
17744 #endif
17745 if (unlikely(ret))
17746 return (long) -1;
17747 return val;
17748 }
17749 raise_overflow:
17750 PyErr_SetString(PyExc_OverflowError,
17751 "value too large to convert to long");
17752 return (long) -1;
17753 raise_neg_overflow:
17754 PyErr_SetString(PyExc_OverflowError,
17755 "can't convert negative value to long");
17756 return (long) -1;
17757 }
17758
17759 /* FastTypeChecks */
17760 #if CYTHON_COMPILING_IN_CPYTHON
17761 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
17762 while (a) {
17763 a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*);
17764 if (a == b)
17765 return 1;
17766 }
17767 return b == &PyBaseObject_Type;
17768 }
17769 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
17770 PyObject *mro;
17771 if (a == b) return 1;
17772 mro = a->tp_mro;
17773 if (likely(mro)) {
17774 Py_ssize_t i, n;
17775 n = PyTuple_GET_SIZE(mro);
17776 for (i = 0; i < n; i++) {
17777 if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
17778 return 1;
17779 }
17780 return 0;
17781 }
17782 return __Pyx_InBases(a, b);
17783 }
17784 static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) {
17785 PyObject *mro;
17786 if (cls == a || cls == b) return 1;
17787 mro = cls->tp_mro;
17788 if (likely(mro)) {
17789 Py_ssize_t i, n;
17790 n = PyTuple_GET_SIZE(mro);
17791 for (i = 0; i < n; i++) {
17792 PyObject *base = PyTuple_GET_ITEM(mro, i);
17793 if (base == (PyObject *)a || base == (PyObject *)b)
17794 return 1;
17795 }
17796 return 0;
17797 }
17798 return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b);
17799 }
17800 #if PY_MAJOR_VERSION == 2
17801 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
17802 PyObject *exception, *value, *tb;
17803 int res;
17804 __Pyx_PyThreadState_declare
17805 __Pyx_PyThreadState_assign
17806 __Pyx_ErrFetch(&exception, &value, &tb);
17807 res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
17808 if (unlikely(res == -1)) {
17809 PyErr_WriteUnraisable(err);
17810 res = 0;
17811 }
17812 if (!res) {
17813 res = PyObject_IsSubclass(err, exc_type2);
17814 if (unlikely(res == -1)) {
17815 PyErr_WriteUnraisable(err);
17816 res = 0;
17817 }
17818 }
17819 __Pyx_ErrRestore(exception, value, tb);
17820 return res;
17821 }
17822 #else
17823 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
17824 if (exc_type1) {
17825 return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2);
17826 } else {
17827 return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
17828 }
17829 }
17830 #endif
17831 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
17832 Py_ssize_t i, n;
17833 assert(PyExceptionClass_Check(exc_type));
17834 n = PyTuple_GET_SIZE(tuple);
17835 #if PY_MAJOR_VERSION >= 3
17836 for (i=0; i<n; i++) {
17837 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
17838 }
17839 #endif
17840 for (i=0; i<n; i++) {
17841 PyObject *t = PyTuple_GET_ITEM(tuple, i);
17842 #if PY_MAJOR_VERSION < 3
17843 if (likely(exc_type == t)) return 1;
17844 #endif
17845 if (likely(PyExceptionClass_Check(t))) {
17846 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
17847 } else {
17848 }
17849 }
17850 return 0;
17851 }
17852 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
17853 if (likely(err == exc_type)) return 1;
17854 if (likely(PyExceptionClass_Check(err))) {
17855 if (likely(PyExceptionClass_Check(exc_type))) {
17856 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
17857 } else if (likely(PyTuple_Check(exc_type))) {
17858 return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
17859 } else {
17860 }
17861 }
17862 return PyErr_GivenExceptionMatches(err, exc_type);
17863 }
17864 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
17865 assert(PyExceptionClass_Check(exc_type1));
17866 assert(PyExceptionClass_Check(exc_type2));
17867 if (likely(err == exc_type1 || err == exc_type2)) return 1;
17868 if (likely(PyExceptionClass_Check(err))) {
17869 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
17870 }
17871 return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
17872 }
17873 #endif
17874
17875 /* CheckBinaryVersion */
17876 static unsigned long __Pyx_get_runtime_version(void) {
17877 #if __PYX_LIMITED_VERSION_HEX >= 0x030B00A4
17878 return Py_Version & ~0xFFUL;
17879 #else
17880 const char* rt_version = Py_GetVersion();
17881 unsigned long version = 0;
17882 unsigned long factor = 0x01000000UL;
17883 unsigned int digit = 0;
17884 int i = 0;
17885 while (factor) {
17886 while ('0' <= rt_version[i] && rt_version[i] <= '9') {
17887 digit = digit * 10 + (unsigned int) (rt_version[i] - '0');
17888 ++i;
17889 }
17890 version += factor * digit;
17891 if (rt_version[i] != '.')
17892 break;
17893 digit = 0;
17894 factor >>= 8;
17895 ++i;
17896 }
17897 return version;
17898 #endif
17899 }
17900 static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) {
17901 const unsigned long MAJOR_MINOR = 0xFFFF0000UL;
17902 if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR))
17903 return 0;
17904 if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR)))
17905 return 1;
17906 {
17907 char message[200];
17908 PyOS_snprintf(message, sizeof(message),
17909 "compile time Python version %d.%d "
17910 "of module '%.100s' "
17911 "%s "
17912 "runtime version %d.%d",
17913 (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF),
17914 __Pyx_MODULE_NAME,
17915 (allow_newer) ? "was newer than" : "does not match",
17916 (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF)
17917 );
17918 return PyErr_WarnEx(NULL, message, 1);
17919 }
17920 }
17921
17922 /* FunctionExport */
17923 static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
17924 PyObject *d = 0;
17925 PyObject *cobj = 0;
17926 union {
17927 void (*fp)(void);
17928 void *p;
17929 } tmp;
17930 d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
17931 if (!d) {
17932 PyErr_Clear();
17933 d = PyDict_New();
17934 if (!d)
17935 goto bad;
17936 Py_INCREF(d);
17937 if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
17938 goto bad;
17939 }
17940 tmp.fp = f;
17941 cobj = PyCapsule_New(tmp.p, sig, 0);
17942 if (!cobj)
17943 goto bad;
17944 if (PyDict_SetItemString(d, name, cobj) < 0)
17945 goto bad;
17946 Py_DECREF(cobj);
17947 Py_DECREF(d);
17948 return 0;
17949 bad:
17950 Py_XDECREF(cobj);
17951 Py_XDECREF(d);
17952 return -1;
17953 }
17954
17955 /* InitStrings */
17956 #if PY_MAJOR_VERSION >= 3
17957 static int __Pyx_InitString(__Pyx_StringTabEntry t, PyObject **str) {
17958 if (t.is_unicode | t.is_str) {
17959 if (t.intern) {
17960 *str = PyUnicode_InternFromString(t.s);
17961 } else if (t.encoding) {
17962 *str = PyUnicode_Decode(t.s, t.n - 1, t.encoding, NULL);
17963 } else {
17964 *str = PyUnicode_FromStringAndSize(t.s, t.n - 1);
17965 }
17966 } else {
17967 *str = PyBytes_FromStringAndSize(t.s, t.n - 1);
17968 }
17969 if (!*str)
17970 return -1;
17971 if (PyObject_Hash(*str) == -1)
17972 return -1;
17973 return 0;
17974 }
17975 #endif
17976 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
17977 while (t->p) {
17978 #if PY_MAJOR_VERSION >= 3
17979 __Pyx_InitString(*t, t->p);
17980 #else
17981 if (t->is_unicode) {
17982 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
17983 } else if (t->intern) {
17984 *t->p = PyString_InternFromString(t->s);
17985 } else {
17986 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
17987 }
17988 if (!*t->p)
17989 return -1;
17990 if (PyObject_Hash(*t->p) == -1)
17991 return -1;
17992 #endif
17993 ++t;
17994 }
17995 return 0;
17996 }
17997
17998 #include <string.h>
17999 static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) {
18000 size_t len = strlen(s);
18001 if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) {
18002 PyErr_SetString(PyExc_OverflowError, "byte string is too long");
18003 return -1;
18004 }
18005 return (Py_ssize_t) len;
18006 }
18007 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
18008 Py_ssize_t len = __Pyx_ssize_strlen(c_str);
18009 if (unlikely(len < 0)) return NULL;
18010 return __Pyx_PyUnicode_FromStringAndSize(c_str, len);
18011 }
18012 static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) {
18013 Py_ssize_t len = __Pyx_ssize_strlen(c_str);
18014 if (unlikely(len < 0)) return NULL;
18015 return PyByteArray_FromStringAndSize(c_str, len);
18016 }
18017 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
18018 Py_ssize_t ignore;
18019 return __Pyx_PyObject_AsStringAndSize(o, &ignore);
18020 }
18021 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
18022 #if !CYTHON_PEP393_ENABLED
18023 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
18024 char* defenc_c;
18025 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
18026 if (!defenc) return NULL;
18027 defenc_c = PyBytes_AS_STRING(defenc);
18028 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
18029 {
18030 char* end = defenc_c + PyBytes_GET_SIZE(defenc);
18031 char* c;
18032 for (c = defenc_c; c < end; c++) {
18033 if ((unsigned char) (*c) >= 128) {
18034 PyUnicode_AsASCIIString(o);
18035 return NULL;
18036 }
18037 }
18038 }
18039 #endif
18040 *length = PyBytes_GET_SIZE(defenc);
18041 return defenc_c;
18042 }
18043 #else
18044 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
18045 if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
18046 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
18047 if (likely(PyUnicode_IS_ASCII(o))) {
18048 *length = PyUnicode_GET_LENGTH(o);
18049 return PyUnicode_AsUTF8(o);
18050 } else {
18051 PyUnicode_AsASCIIString(o);
18052 return NULL;
18053 }
18054 #else
18055 return PyUnicode_AsUTF8AndSize(o, length);
18056 #endif
18057 }
18058 #endif
18059 #endif
18060 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
18061 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
18062 if (
18063 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
18064 __Pyx_sys_getdefaultencoding_not_ascii &&
18065 #endif
18066 PyUnicode_Check(o)) {
18067 return __Pyx_PyUnicode_AsStringAndSize(o, length);
18068 } else
18069 #endif
18070 #if (!CYTHON_COMPILING_IN_PYPY && !CYTHON_COMPILING_IN_LIMITED_API) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
18071 if (PyByteArray_Check(o)) {
18072 *length = PyByteArray_GET_SIZE(o);
18073 return PyByteArray_AS_STRING(o);
18074 } else
18075 #endif
18076 {
18077 char* result;
18078 int r = PyBytes_AsStringAndSize(o, &result, length);
18079 if (unlikely(r < 0)) {
18080 return NULL;
18081 } else {
18082 return result;
18083 }
18084 }
18085 }
18086 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
18087 int is_true = x == Py_True;
18088 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
18089 else return PyObject_IsTrue(x);
18090 }
18091 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
18092 int retval;
18093 if (unlikely(!x)) return -1;
18094 retval = __Pyx_PyObject_IsTrue(x);
18095 Py_DECREF(x);
18096 return retval;
18097 }
18098 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
18099 __Pyx_TypeName result_type_name = __Pyx_PyType_GetName(Py_TYPE(result));
18100 #if PY_MAJOR_VERSION >= 3
18101 if (PyLong_Check(result)) {
18102 if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
18103 "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). "
18104 "The ability to return an instance of a strict subclass of int is deprecated, "
18105 "and may be removed in a future version of Python.",
18106 result_type_name)) {
18107 __Pyx_DECREF_TypeName(result_type_name);
18108 Py_DECREF(result);
18109 return NULL;
18110 }
18111 __Pyx_DECREF_TypeName(result_type_name);
18112 return result;
18113 }
18114 #endif
18115 PyErr_Format(PyExc_TypeError,
18116 "__%.4s__ returned non-%.4s (type " __Pyx_FMT_TYPENAME ")",
18117 type_name, type_name, result_type_name);
18118 __Pyx_DECREF_TypeName(result_type_name);
18119 Py_DECREF(result);
18120 return NULL;
18121 }
18122 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
18123 #if CYTHON_USE_TYPE_SLOTS
18124 PyNumberMethods *m;
18125 #endif
18126 const char *name = NULL;
18127 PyObject *res = NULL;
18128 #if PY_MAJOR_VERSION < 3
18129 if (likely(PyInt_Check(x) || PyLong_Check(x)))
18130 #else
18131 if (likely(PyLong_Check(x)))
18132 #endif
18133 return __Pyx_NewRef(x);
18134 #if CYTHON_USE_TYPE_SLOTS
18135 m = Py_TYPE(x)->tp_as_number;
18136 #if PY_MAJOR_VERSION < 3
18137 if (m && m->nb_int) {
18138 name = "int";
18139 res = m->nb_int(x);
18140 }
18141 else if (m && m->nb_long) {
18142 name = "long";
18143 res = m->nb_long(x);
18144 }
18145 #else
18146 if (likely(m && m->nb_int)) {
18147 name = "int";
18148 res = m->nb_int(x);
18149 }
18150 #endif
18151 #else
18152 if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
18153 res = PyNumber_Int(x);
18154 }
18155 #endif
18156 if (likely(res)) {
18157 #if PY_MAJOR_VERSION < 3
18158 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
18159 #else
18160 if (unlikely(!PyLong_CheckExact(res))) {
18161 #endif
18162 return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
18163 }
18164 }
18165 else if (!PyErr_Occurred()) {
18166 PyErr_SetString(PyExc_TypeError,
18167 "an integer is required");
18168 }
18169 return res;
18170 }
18171 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
18172 Py_ssize_t ival;
18173 PyObject *x;
18174 #if PY_MAJOR_VERSION < 3
18175 if (likely(PyInt_CheckExact(b))) {
18176 if (sizeof(Py_ssize_t) >= sizeof(long))
18177 return PyInt_AS_LONG(b);
18178 else
18179 return PyInt_AsSsize_t(b);
18180 }
18181 #endif
18182 if (likely(PyLong_CheckExact(b))) {
18183 #if CYTHON_USE_PYLONG_INTERNALS
18184 if (likely(__Pyx_PyLong_IsCompact(b))) {
18185 return __Pyx_PyLong_CompactValue(b);
18186 } else {
18187 const digit* digits = __Pyx_PyLong_Digits(b);
18188 const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b);
18189 switch (size) {
18190 case 2:
18191 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
18192 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
18193 }
18194 break;
18195 case -2:
18196 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
18197 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
18198 }
18199 break;
18200 case 3:
18201 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
18202 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
18203 }
18204 break;
18205 case -3:
18206 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
18207 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
18208 }
18209 break;
18210 case 4:
18211 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
18212 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]));
18213 }
18214 break;
18215 case -4:
18216 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
18217 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]));
18218 }
18219 break;
18220 }
18221 }
18222 #endif
18223 return PyLong_AsSsize_t(b);
18224 }
18225 x = PyNumber_Index(b);
18226 if (!x) return -1;
18227 ival = PyInt_AsSsize_t(x);
18228 Py_DECREF(x);
18229 return ival;
18230 }
18231 static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
18232 if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
18233 return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
18234 #if PY_MAJOR_VERSION < 3
18235 } else if (likely(PyInt_CheckExact(o))) {
18236 return PyInt_AS_LONG(o);
18237 #endif
18238 } else {
18239 Py_ssize_t ival;
18240 PyObject *x;
18241 x = PyNumber_Index(o);
18242 if (!x) return -1;
18243 ival = PyInt_AsLong(x);
18244 Py_DECREF(x);
18245 return ival;
18246 }
18247 }
18248 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
18249 return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
18250 }
18251 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
18252 return PyInt_FromSize_t(ival);
18253 }
18254
18255
18256 /* #### Code section: utility_code_pragmas_end ### */
18257 #ifdef _MSC_VER
18258 #pragma warning( pop )
18259 #endif
18260
18261
18262
18263 /* #### Code section: end ### */
18264 #endif /* Py_PYTHON_H */