1 /* Generated by Cython 0.29.25 */
2
3 #ifndef PY_SSIZE_T_CLEAN
4 #define PY_SSIZE_T_CLEAN
5 #endif /* PY_SSIZE_T_CLEAN */
6 #include "Python.h"
7 #ifndef Py_PYTHON_H
8 #error Python headers needed to compile C extensions, please install development version of Python.
9 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
10 #error Cython requires Python 2.6+ or Python 3.3+.
11 #else
12 #define CYTHON_ABI "0_29_25"
13 #define CYTHON_HEX_VERSION 0x001D19F0
14 #define CYTHON_FUTURE_DIVISION 0
15 #include <stddef.h>
16 #ifndef offsetof
17 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
18 #endif
19 #if !defined(WIN32) && !defined(MS_WINDOWS)
20 #ifndef __stdcall
21 #define __stdcall
22 #endif
23 #ifndef __cdecl
24 #define __cdecl
25 #endif
26 #ifndef __fastcall
27 #define __fastcall
28 #endif
29 #endif
30 #ifndef DL_IMPORT
31 #define DL_IMPORT(t) t
32 #endif
33 #ifndef DL_EXPORT
34 #define DL_EXPORT(t) t
35 #endif
36 #define __PYX_COMMA ,
37 #ifndef HAVE_LONG_LONG
38 #if PY_VERSION_HEX >= 0x02070000
39 #define HAVE_LONG_LONG
40 #endif
41 #endif
42 #ifndef PY_LONG_LONG
43 #define PY_LONG_LONG LONG_LONG
44 #endif
45 #ifndef Py_HUGE_VAL
46 #define Py_HUGE_VAL HUGE_VAL
47 #endif
48 #ifdef PYPY_VERSION
49 #define CYTHON_COMPILING_IN_PYPY 1
50 #define CYTHON_COMPILING_IN_PYSTON 0
51 #define CYTHON_COMPILING_IN_CPYTHON 0
52 #undef CYTHON_USE_TYPE_SLOTS
53 #define CYTHON_USE_TYPE_SLOTS 0
54 #undef CYTHON_USE_PYTYPE_LOOKUP
55 #define CYTHON_USE_PYTYPE_LOOKUP 0
56 #if PY_VERSION_HEX < 0x03050000
57 #undef CYTHON_USE_ASYNC_SLOTS
58 #define CYTHON_USE_ASYNC_SLOTS 0
59 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
60 #define CYTHON_USE_ASYNC_SLOTS 1
61 #endif
62 #undef CYTHON_USE_PYLIST_INTERNALS
63 #define CYTHON_USE_PYLIST_INTERNALS 0
64 #undef CYTHON_USE_UNICODE_INTERNALS
65 #define CYTHON_USE_UNICODE_INTERNALS 0
66 #undef CYTHON_USE_UNICODE_WRITER
67 #define CYTHON_USE_UNICODE_WRITER 0
68 #undef CYTHON_USE_PYLONG_INTERNALS
69 #define CYTHON_USE_PYLONG_INTERNALS 0
70 #undef CYTHON_AVOID_BORROWED_REFS
71 #define CYTHON_AVOID_BORROWED_REFS 1
72 #undef CYTHON_ASSUME_SAFE_MACROS
73 #define CYTHON_ASSUME_SAFE_MACROS 0
74 #undef CYTHON_UNPACK_METHODS
75 #define CYTHON_UNPACK_METHODS 0
76 #undef CYTHON_FAST_THREAD_STATE
77 #define CYTHON_FAST_THREAD_STATE 0
78 #undef CYTHON_FAST_PYCALL
79 #define CYTHON_FAST_PYCALL 0
80 #undef CYTHON_PEP489_MULTI_PHASE_INIT
81 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
82 #undef CYTHON_USE_TP_FINALIZE
83 #define CYTHON_USE_TP_FINALIZE 0
84 #undef CYTHON_USE_DICT_VERSIONS
85 #define CYTHON_USE_DICT_VERSIONS 0
86 #undef CYTHON_USE_EXC_INFO_STACK
87 #define CYTHON_USE_EXC_INFO_STACK 0
88 #elif defined(PYSTON_VERSION)
89 #define CYTHON_COMPILING_IN_PYPY 0
90 #define CYTHON_COMPILING_IN_PYSTON 1
91 #define CYTHON_COMPILING_IN_CPYTHON 0
92 #ifndef CYTHON_USE_TYPE_SLOTS
93 #define CYTHON_USE_TYPE_SLOTS 1
94 #endif
95 #undef CYTHON_USE_PYTYPE_LOOKUP
96 #define CYTHON_USE_PYTYPE_LOOKUP 0
97 #undef CYTHON_USE_ASYNC_SLOTS
98 #define CYTHON_USE_ASYNC_SLOTS 0
99 #undef CYTHON_USE_PYLIST_INTERNALS
100 #define CYTHON_USE_PYLIST_INTERNALS 0
101 #ifndef CYTHON_USE_UNICODE_INTERNALS
102 #define CYTHON_USE_UNICODE_INTERNALS 1
103 #endif
104 #undef CYTHON_USE_UNICODE_WRITER
105 #define CYTHON_USE_UNICODE_WRITER 0
106 #undef CYTHON_USE_PYLONG_INTERNALS
107 #define CYTHON_USE_PYLONG_INTERNALS 0
108 #ifndef CYTHON_AVOID_BORROWED_REFS
109 #define CYTHON_AVOID_BORROWED_REFS 0
110 #endif
111 #ifndef CYTHON_ASSUME_SAFE_MACROS
112 #define CYTHON_ASSUME_SAFE_MACROS 1
113 #endif
114 #ifndef CYTHON_UNPACK_METHODS
115 #define CYTHON_UNPACK_METHODS 1
116 #endif
117 #undef CYTHON_FAST_THREAD_STATE
118 #define CYTHON_FAST_THREAD_STATE 0
119 #undef CYTHON_FAST_PYCALL
120 #define CYTHON_FAST_PYCALL 0
121 #undef CYTHON_PEP489_MULTI_PHASE_INIT
122 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
123 #undef CYTHON_USE_TP_FINALIZE
124 #define CYTHON_USE_TP_FINALIZE 0
125 #undef CYTHON_USE_DICT_VERSIONS
126 #define CYTHON_USE_DICT_VERSIONS 0
127 #undef CYTHON_USE_EXC_INFO_STACK
128 #define CYTHON_USE_EXC_INFO_STACK 0
129 #else
130 #define CYTHON_COMPILING_IN_PYPY 0
131 #define CYTHON_COMPILING_IN_PYSTON 0
132 #define CYTHON_COMPILING_IN_CPYTHON 1
133 #ifndef CYTHON_USE_TYPE_SLOTS
134 #define CYTHON_USE_TYPE_SLOTS 1
135 #endif
136 #if PY_VERSION_HEX < 0x02070000
137 #undef CYTHON_USE_PYTYPE_LOOKUP
138 #define CYTHON_USE_PYTYPE_LOOKUP 0
139 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
140 #define CYTHON_USE_PYTYPE_LOOKUP 1
141 #endif
142 #if PY_MAJOR_VERSION < 3
143 #undef CYTHON_USE_ASYNC_SLOTS
144 #define CYTHON_USE_ASYNC_SLOTS 0
145 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
146 #define CYTHON_USE_ASYNC_SLOTS 1
147 #endif
148 #if PY_VERSION_HEX < 0x02070000
149 #undef CYTHON_USE_PYLONG_INTERNALS
150 #define CYTHON_USE_PYLONG_INTERNALS 0
151 #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
152 #define CYTHON_USE_PYLONG_INTERNALS 1
153 #endif
154 #ifndef CYTHON_USE_PYLIST_INTERNALS
155 #define CYTHON_USE_PYLIST_INTERNALS 1
156 #endif
157 #ifndef CYTHON_USE_UNICODE_INTERNALS
158 #define CYTHON_USE_UNICODE_INTERNALS 1
159 #endif
160 #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2
161 #undef CYTHON_USE_UNICODE_WRITER
162 #define CYTHON_USE_UNICODE_WRITER 0
163 #elif !defined(CYTHON_USE_UNICODE_WRITER)
164 #define CYTHON_USE_UNICODE_WRITER 1
165 #endif
166 #ifndef CYTHON_AVOID_BORROWED_REFS
167 #define CYTHON_AVOID_BORROWED_REFS 0
168 #endif
169 #ifndef CYTHON_ASSUME_SAFE_MACROS
170 #define CYTHON_ASSUME_SAFE_MACROS 1
171 #endif
172 #ifndef CYTHON_UNPACK_METHODS
173 #define CYTHON_UNPACK_METHODS 1
174 #endif
175 #ifndef CYTHON_FAST_THREAD_STATE
176 #define CYTHON_FAST_THREAD_STATE 1
177 #endif
178 #ifndef CYTHON_FAST_PYCALL
179 #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030B00A1)
180 #endif
181 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
182 #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
183 #endif
184 #ifndef CYTHON_USE_TP_FINALIZE
185 #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
186 #endif
187 #ifndef CYTHON_USE_DICT_VERSIONS
188 #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
189 #endif
190 #ifndef CYTHON_USE_EXC_INFO_STACK
191 #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
192 #endif
193 #endif
194 #if !defined(CYTHON_FAST_PYCCALL)
195 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
196 #endif
197 #if CYTHON_USE_PYLONG_INTERNALS
198 #if PY_MAJOR_VERSION < 3
199 #include "longintrepr.h"
200 #endif
201 #undef SHIFT
202 #undef BASE
203 #undef MASK
204 #ifdef SIZEOF_VOID_P
205 enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
206 #endif
207 #endif
208 #ifndef __has_attribute
209 #define __has_attribute(x) 0
210 #endif
211 #ifndef __has_cpp_attribute
212 #define __has_cpp_attribute(x) 0
213 #endif
214 #ifndef CYTHON_RESTRICT
215 #if defined(__GNUC__)
216 #define CYTHON_RESTRICT __restrict__
217 #elif defined(_MSC_VER) && _MSC_VER >= 1400
218 #define CYTHON_RESTRICT __restrict
219 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
220 #define CYTHON_RESTRICT restrict
221 #else
222 #define CYTHON_RESTRICT
223 #endif
224 #endif
225 #ifndef CYTHON_UNUSED
226 # if defined(__GNUC__)
227 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
228 # define CYTHON_UNUSED __attribute__ ((__unused__))
229 # else
230 # define CYTHON_UNUSED
231 # endif
232 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
233 # define CYTHON_UNUSED __attribute__ ((__unused__))
234 # else
235 # define CYTHON_UNUSED
236 # endif
237 #endif
238 #ifndef CYTHON_MAYBE_UNUSED_VAR
239 # if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)240 template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
241 # else
242 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
243 # endif
244 #endif
245 #ifndef CYTHON_NCP_UNUSED
246 # if CYTHON_COMPILING_IN_CPYTHON
247 # define CYTHON_NCP_UNUSED
248 # else
249 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
250 # endif
251 #endif
252 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
253 #ifdef _MSC_VER
254 #ifndef _MSC_STDINT_H_
255 #if _MSC_VER < 1300
256 typedef unsigned char uint8_t;
257 typedef unsigned int uint32_t;
258 #else
259 typedef unsigned __int8 uint8_t;
260 typedef unsigned __int32 uint32_t;
261 #endif
262 #endif
263 #else
264 #include <stdint.h>
265 #endif
266 #ifndef CYTHON_FALLTHROUGH
267 #if defined(__cplusplus) && __cplusplus >= 201103L
268 #if __has_cpp_attribute(fallthrough)
269 #define CYTHON_FALLTHROUGH [[fallthrough]]
270 #elif __has_cpp_attribute(clang::fallthrough)
271 #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
272 #elif __has_cpp_attribute(gnu::fallthrough)
273 #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
274 #endif
275 #endif
276 #ifndef CYTHON_FALLTHROUGH
277 #if __has_attribute(fallthrough)
278 #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
279 #else
280 #define CYTHON_FALLTHROUGH
281 #endif
282 #endif
283 #if defined(__clang__ ) && defined(__apple_build_version__)
284 #if __apple_build_version__ < 7000000
285 #undef CYTHON_FALLTHROUGH
286 #define CYTHON_FALLTHROUGH
287 #endif
288 #endif
289 #endif
290
291 #ifndef CYTHON_INLINE
292 #if defined(__clang__)
293 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
294 #elif defined(__GNUC__)
295 #define CYTHON_INLINE __inline__
296 #elif defined(_MSC_VER)
297 #define CYTHON_INLINE __inline
298 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
299 #define CYTHON_INLINE inline
300 #else
301 #define CYTHON_INLINE
302 #endif
303 #endif
304
305 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
306 #define Py_OptimizeFlag 0
307 #endif
308 #define __PYX_BUILD_PY_SSIZE_T "n"
309 #define CYTHON_FORMAT_SSIZE_T "z"
310 #if PY_MAJOR_VERSION < 3
311 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
312 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
313 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
314 #define __Pyx_DefaultClassType PyClass_Type
315 #else
316 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
317 #define __Pyx_DefaultClassType PyType_Type
318 #if PY_VERSION_HEX >= 0x030B00A1
__Pyx_PyCode_New(int a,int k,int l,int s,int f,PyObject * code,PyObject * c,PyObject * n,PyObject * v,PyObject * fv,PyObject * cell,PyObject * fn,PyObject * name,int fline,PyObject * lnos)319 static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f,
320 PyObject *code, PyObject *c, PyObject* n, PyObject *v,
321 PyObject *fv, PyObject *cell, PyObject* fn,
322 PyObject *name, int fline, PyObject *lnos) {
323 PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL;
324 PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL;
325 const char *fn_cstr=NULL;
326 const char *name_cstr=NULL;
327 PyCodeObject* co=NULL;
328 PyObject *type, *value, *traceback;
329 PyErr_Fetch(&type, &value, &traceback);
330 if (!(kwds=PyDict_New())) goto end;
331 if (!(argcount=PyLong_FromLong(a))) goto end;
332 if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end;
333 if (!(posonlyargcount=PyLong_FromLong(0))) goto end;
334 if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end;
335 if (!(kwonlyargcount=PyLong_FromLong(k))) goto end;
336 if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end;
337 if (!(nlocals=PyLong_FromLong(l))) goto end;
338 if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end;
339 if (!(stacksize=PyLong_FromLong(s))) goto end;
340 if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end;
341 if (!(flags=PyLong_FromLong(f))) goto end;
342 if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end;
343 if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end;
344 if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end;
345 if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end;
346 if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end;
347 if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end;
348 if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end;
349 if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end;
350 if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end;
351 if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end;
352 if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end;
353 if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too;
354 if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here
355 if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too;
356 Py_XDECREF((PyObject*)co);
357 co = (PyCodeObject*)call_result;
358 call_result = NULL;
359 if (0) {
360 cleanup_code_too:
361 Py_XDECREF((PyObject*)co);
362 co = NULL;
363 }
364 end:
365 Py_XDECREF(kwds);
366 Py_XDECREF(argcount);
367 Py_XDECREF(posonlyargcount);
368 Py_XDECREF(kwonlyargcount);
369 Py_XDECREF(nlocals);
370 Py_XDECREF(stacksize);
371 Py_XDECREF(replace);
372 Py_XDECREF(call_result);
373 Py_XDECREF(empty);
374 if (type) {
375 PyErr_Restore(type, value, traceback);
376 }
377 return co;
378 }
379 #else
380 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
381 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
382 #endif
383 #define __Pyx_DefaultClassType PyType_Type
384 #endif
385 #ifndef Py_TPFLAGS_CHECKTYPES
386 #define Py_TPFLAGS_CHECKTYPES 0
387 #endif
388 #ifndef Py_TPFLAGS_HAVE_INDEX
389 #define Py_TPFLAGS_HAVE_INDEX 0
390 #endif
391 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
392 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
393 #endif
394 #ifndef Py_TPFLAGS_HAVE_FINALIZE
395 #define Py_TPFLAGS_HAVE_FINALIZE 0
396 #endif
397 #ifndef METH_STACKLESS
398 #define METH_STACKLESS 0
399 #endif
400 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
401 #ifndef METH_FASTCALL
402 #define METH_FASTCALL 0x80
403 #endif
404 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
405 typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
406 Py_ssize_t nargs, PyObject *kwnames);
407 #else
408 #define __Pyx_PyCFunctionFast _PyCFunctionFast
409 #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
410 #endif
411 #if CYTHON_FAST_PYCCALL
412 #define __Pyx_PyFastCFunction_Check(func)\
413 ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
414 #else
415 #define __Pyx_PyFastCFunction_Check(func) 0
416 #endif
417 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
418 #define PyObject_Malloc(s) PyMem_Malloc(s)
419 #define PyObject_Free(p) PyMem_Free(p)
420 #define PyObject_Realloc(p) PyMem_Realloc(p)
421 #endif
422 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
423 #define PyMem_RawMalloc(n) PyMem_Malloc(n)
424 #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
425 #define PyMem_RawFree(p) PyMem_Free(p)
426 #endif
427 #if CYTHON_COMPILING_IN_PYSTON
428 #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
429 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
430 #else
431 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
432 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
433 #endif
434 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
435 #define __Pyx_PyThreadState_Current PyThreadState_GET()
436 #elif PY_VERSION_HEX >= 0x03060000
437 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
438 #elif PY_VERSION_HEX >= 0x03000000
439 #define __Pyx_PyThreadState_Current PyThreadState_GET()
440 #else
441 #define __Pyx_PyThreadState_Current _PyThreadState_Current
442 #endif
443 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
444 #include "pythread.h"
445 #define Py_tss_NEEDS_INIT 0
446 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)447 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
448 *key = PyThread_create_key();
449 return 0;
450 }
PyThread_tss_alloc(void)451 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
452 Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
453 *key = Py_tss_NEEDS_INIT;
454 return key;
455 }
PyThread_tss_free(Py_tss_t * key)456 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
457 PyObject_Free(key);
458 }
PyThread_tss_is_created(Py_tss_t * key)459 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
460 return *key != Py_tss_NEEDS_INIT;
461 }
PyThread_tss_delete(Py_tss_t * key)462 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
463 PyThread_delete_key(*key);
464 *key = Py_tss_NEEDS_INIT;
465 }
PyThread_tss_set(Py_tss_t * key,void * value)466 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
467 return PyThread_set_key_value(*key, value);
468 }
PyThread_tss_get(Py_tss_t * key)469 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
470 return PyThread_get_key_value(*key);
471 }
472 #endif
473 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
474 #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
475 #else
476 #define __Pyx_PyDict_NewPresized(n) PyDict_New()
477 #endif
478 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
479 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
480 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
481 #else
482 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
483 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
484 #endif
485 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
486 #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
487 #else
488 #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
489 #endif
490 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
491 #define CYTHON_PEP393_ENABLED 1
492 #if defined(PyUnicode_IS_READY)
493 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
494 0 : _PyUnicode_Ready((PyObject *)(op)))
495 #else
496 #define __Pyx_PyUnicode_READY(op) (0)
497 #endif
498 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
499 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
500 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
501 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
502 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
503 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
504 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
505 #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
506 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
507 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
508 #else
509 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
510 #endif
511 #else
512 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
513 #endif
514 #else
515 #define CYTHON_PEP393_ENABLED 0
516 #define PyUnicode_1BYTE_KIND 1
517 #define PyUnicode_2BYTE_KIND 2
518 #define PyUnicode_4BYTE_KIND 4
519 #define __Pyx_PyUnicode_READY(op) (0)
520 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
521 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
522 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
523 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
524 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
525 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
526 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
527 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
528 #endif
529 #if CYTHON_COMPILING_IN_PYPY
530 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
531 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
532 #else
533 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
534 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
535 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
536 #endif
537 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
538 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
539 #endif
540 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
541 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
542 #endif
543 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
544 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
545 #endif
546 #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))
547 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
548 #if PY_MAJOR_VERSION >= 3
549 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
550 #else
551 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
552 #endif
553 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
554 #define PyObject_ASCII(o) PyObject_Repr(o)
555 #endif
556 #if PY_MAJOR_VERSION >= 3
557 #define PyBaseString_Type PyUnicode_Type
558 #define PyStringObject PyUnicodeObject
559 #define PyString_Type PyUnicode_Type
560 #define PyString_Check PyUnicode_Check
561 #define PyString_CheckExact PyUnicode_CheckExact
562 #ifndef PyObject_Unicode
563 #define PyObject_Unicode PyObject_Str
564 #endif
565 #endif
566 #if PY_MAJOR_VERSION >= 3
567 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
568 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
569 #else
570 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
571 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
572 #endif
573 #ifndef PySet_CheckExact
574 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
575 #endif
576 #if PY_VERSION_HEX >= 0x030900A4
577 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
578 #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
579 #else
580 #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
581 #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
582 #endif
583 #if CYTHON_ASSUME_SAFE_MACROS
584 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
585 #else
586 #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
587 #endif
588 #if PY_MAJOR_VERSION >= 3
589 #define PyIntObject PyLongObject
590 #define PyInt_Type PyLong_Type
591 #define PyInt_Check(op) PyLong_Check(op)
592 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
593 #define PyInt_FromString PyLong_FromString
594 #define PyInt_FromUnicode PyLong_FromUnicode
595 #define PyInt_FromLong PyLong_FromLong
596 #define PyInt_FromSize_t PyLong_FromSize_t
597 #define PyInt_FromSsize_t PyLong_FromSsize_t
598 #define PyInt_AsLong PyLong_AsLong
599 #define PyInt_AS_LONG PyLong_AS_LONG
600 #define PyInt_AsSsize_t PyLong_AsSsize_t
601 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
602 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
603 #define PyNumber_Int PyNumber_Long
604 #endif
605 #if PY_MAJOR_VERSION >= 3
606 #define PyBoolObject PyLongObject
607 #endif
608 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
609 #ifndef PyUnicode_InternFromString
610 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
611 #endif
612 #endif
613 #if PY_VERSION_HEX < 0x030200A4
614 typedef long Py_hash_t;
615 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
616 #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t
617 #else
618 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
619 #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t
620 #endif
621 #if PY_MAJOR_VERSION >= 3
622 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
623 #else
624 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
625 #endif
626 #if CYTHON_USE_ASYNC_SLOTS
627 #if PY_VERSION_HEX >= 0x030500B1
628 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
629 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
630 #else
631 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
632 #endif
633 #else
634 #define __Pyx_PyType_AsAsync(obj) NULL
635 #endif
636 #ifndef __Pyx_PyAsyncMethodsStruct
637 typedef struct {
638 unaryfunc am_await;
639 unaryfunc am_aiter;
640 unaryfunc am_anext;
641 } __Pyx_PyAsyncMethodsStruct;
642 #endif
643
644 #if defined(WIN32) || defined(MS_WINDOWS)
645 #define _USE_MATH_DEFINES
646 #endif
647 #include <math.h>
648 #ifdef NAN
649 #define __PYX_NAN() ((float) NAN)
650 #else
__PYX_NAN()651 static CYTHON_INLINE float __PYX_NAN() {
652 float value;
653 memset(&value, 0xFF, sizeof(value));
654 return value;
655 }
656 #endif
657 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
658 #define __Pyx_truncl trunc
659 #else
660 #define __Pyx_truncl truncl
661 #endif
662
663 #define __PYX_MARK_ERR_POS(f_index, lineno) \
664 { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
665 #define __PYX_ERR(f_index, lineno, Ln_error) \
666 { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
667
668 #ifndef __PYX_EXTERN_C
669 #ifdef __cplusplus
670 #define __PYX_EXTERN_C extern "C"
671 #else
672 #define __PYX_EXTERN_C extern
673 #endif
674 #endif
675
676 #define __PYX_HAVE__bx__misc__bgzf
677 #define __PYX_HAVE_API__bx__misc__bgzf
678 /* Early includes */
679 #include "bgzf.h"
680 #ifdef _OPENMP
681 #include <omp.h>
682 #endif /* _OPENMP */
683
684 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
685 #define CYTHON_WITHOUT_ASSERTIONS
686 #endif
687
688 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
689 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
690
691 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
692 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
693 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
694 #define __PYX_DEFAULT_STRING_ENCODING ""
695 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
696 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
697 #define __Pyx_uchar_cast(c) ((unsigned char)c)
698 #define __Pyx_long_cast(x) ((long)x)
699 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
700 (sizeof(type) < sizeof(Py_ssize_t)) ||\
701 (sizeof(type) > sizeof(Py_ssize_t) &&\
702 likely(v < (type)PY_SSIZE_T_MAX ||\
703 v == (type)PY_SSIZE_T_MAX) &&\
704 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
705 v == (type)PY_SSIZE_T_MIN))) ||\
706 (sizeof(type) == sizeof(Py_ssize_t) &&\
707 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
708 v == (type)PY_SSIZE_T_MAX))) )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)709 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
710 return (size_t) i < (size_t) limit;
711 }
712 #if defined (__cplusplus) && __cplusplus >= 201103L
713 #include <cstdlib>
714 #define __Pyx_sst_abs(value) std::abs(value)
715 #elif SIZEOF_INT >= SIZEOF_SIZE_T
716 #define __Pyx_sst_abs(value) abs(value)
717 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
718 #define __Pyx_sst_abs(value) labs(value)
719 #elif defined (_MSC_VER)
720 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
721 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
722 #define __Pyx_sst_abs(value) llabs(value)
723 #elif defined (__GNUC__)
724 #define __Pyx_sst_abs(value) __builtin_llabs(value)
725 #else
726 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
727 #endif
728 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
729 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
730 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
731 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
732 #define __Pyx_PyBytes_FromString PyBytes_FromString
733 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
734 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
735 #if PY_MAJOR_VERSION < 3
736 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
737 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
738 #else
739 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
740 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
741 #endif
742 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
743 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
744 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
745 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
746 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
747 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
748 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
749 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
750 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
751 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
752 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
753 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
754 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
755 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
756 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
757 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)758 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
759 const Py_UNICODE *u_end = u;
760 while (*u_end++) ;
761 return (size_t)(u_end - u - 1);
762 }
763 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
764 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
765 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
766 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
767 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
768 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
769 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
770 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
771 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
772 #define __Pyx_PySequence_Tuple(obj)\
773 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
774 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
775 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
776 static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
777 #if CYTHON_ASSUME_SAFE_MACROS
778 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
779 #else
780 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
781 #endif
782 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
783 #if PY_MAJOR_VERSION >= 3
784 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
785 #else
786 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
787 #endif
788 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
789 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
790 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)791 static int __Pyx_init_sys_getdefaultencoding_params(void) {
792 PyObject* sys;
793 PyObject* default_encoding = NULL;
794 PyObject* ascii_chars_u = NULL;
795 PyObject* ascii_chars_b = NULL;
796 const char* default_encoding_c;
797 sys = PyImport_ImportModule("sys");
798 if (!sys) goto bad;
799 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
800 Py_DECREF(sys);
801 if (!default_encoding) goto bad;
802 default_encoding_c = PyBytes_AsString(default_encoding);
803 if (!default_encoding_c) goto bad;
804 if (strcmp(default_encoding_c, "ascii") == 0) {
805 __Pyx_sys_getdefaultencoding_not_ascii = 0;
806 } else {
807 char ascii_chars[128];
808 int c;
809 for (c = 0; c < 128; c++) {
810 ascii_chars[c] = c;
811 }
812 __Pyx_sys_getdefaultencoding_not_ascii = 1;
813 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
814 if (!ascii_chars_u) goto bad;
815 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
816 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
817 PyErr_Format(
818 PyExc_ValueError,
819 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
820 default_encoding_c);
821 goto bad;
822 }
823 Py_DECREF(ascii_chars_u);
824 Py_DECREF(ascii_chars_b);
825 }
826 Py_DECREF(default_encoding);
827 return 0;
828 bad:
829 Py_XDECREF(default_encoding);
830 Py_XDECREF(ascii_chars_u);
831 Py_XDECREF(ascii_chars_b);
832 return -1;
833 }
834 #endif
835 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
836 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
837 #else
838 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
839 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
840 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)841 static int __Pyx_init_sys_getdefaultencoding_params(void) {
842 PyObject* sys;
843 PyObject* default_encoding = NULL;
844 char* default_encoding_c;
845 sys = PyImport_ImportModule("sys");
846 if (!sys) goto bad;
847 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
848 Py_DECREF(sys);
849 if (!default_encoding) goto bad;
850 default_encoding_c = PyBytes_AsString(default_encoding);
851 if (!default_encoding_c) goto bad;
852 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
853 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
854 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
855 Py_DECREF(default_encoding);
856 return 0;
857 bad:
858 Py_XDECREF(default_encoding);
859 return -1;
860 }
861 #endif
862 #endif
863
864
865 /* Test for GCC > 2.95 */
866 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
867 #define likely(x) __builtin_expect(!!(x), 1)
868 #define unlikely(x) __builtin_expect(!!(x), 0)
869 #else /* !__GNUC__ or GCC < 2.95 */
870 #define likely(x) (x)
871 #define unlikely(x) (x)
872 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)873 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
874
875 static PyObject *__pyx_m = NULL;
876 static PyObject *__pyx_d;
877 static PyObject *__pyx_b;
878 static PyObject *__pyx_cython_runtime = NULL;
879 static PyObject *__pyx_empty_tuple;
880 static PyObject *__pyx_empty_bytes;
881 static PyObject *__pyx_empty_unicode;
882 static int __pyx_lineno;
883 static int __pyx_clineno = 0;
884 static const char * __pyx_cfilenm= __FILE__;
885 static const char *__pyx_filename;
886
887
888 static const char *__pyx_f[] = {
889 "lib/bx/misc/bgzf.pyx",
890 "stringsource",
891 };
892
893 /* "bx/misc/bgzf.pyx":8
894 * from cpython.version cimport PY_MAJOR_VERSION
895 *
896 * ctypedef unsigned long long int64_t # <<<<<<<<<<<<<<
897 *
898 * cdef extern from "Python.h":
899 */
900 typedef unsigned PY_LONG_LONG __pyx_t_2bx_4misc_4bgzf_int64_t;
901
902 /*--- Type declarations ---*/
903 struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile;
904
905 /* "bx/misc/bgzf.pyx":22
906 * int64_t bgzf_seek( BGZF * fp, int64_t pos, int where )
907 *
908 * cdef class BGZFFile( object ): # <<<<<<<<<<<<<<
909 * cdef BGZF * bgzf
910 * def __init__( self, path, mode="r" ):
911 */
912 struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile {
913 PyObject_HEAD
914 BGZF *bgzf;
915 };
916
917
918 /* --- Runtime support code (head) --- */
919 /* Refnanny.proto */
920 #ifndef CYTHON_REFNANNY
921 #define CYTHON_REFNANNY 0
922 #endif
923 #if CYTHON_REFNANNY
924 typedef struct {
925 void (*INCREF)(void*, PyObject*, int);
926 void (*DECREF)(void*, PyObject*, int);
927 void (*GOTREF)(void*, PyObject*, int);
928 void (*GIVEREF)(void*, PyObject*, int);
929 void* (*SetupContext)(const char*, int, const char*);
930 void (*FinishContext)(void**);
931 } __Pyx_RefNannyAPIStruct;
932 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
933 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
934 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
935 #ifdef WITH_THREAD
936 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
937 if (acquire_gil) {\
938 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
939 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
940 PyGILState_Release(__pyx_gilstate_save);\
941 } else {\
942 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
943 }
944 #else
945 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
946 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
947 #endif
948 #define __Pyx_RefNannyFinishContext()\
949 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
950 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
951 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
952 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
953 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
954 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
955 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
956 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
957 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
958 #else
959 #define __Pyx_RefNannyDeclarations
960 #define __Pyx_RefNannySetupContext(name, acquire_gil)
961 #define __Pyx_RefNannyFinishContext()
962 #define __Pyx_INCREF(r) Py_INCREF(r)
963 #define __Pyx_DECREF(r) Py_DECREF(r)
964 #define __Pyx_GOTREF(r)
965 #define __Pyx_GIVEREF(r)
966 #define __Pyx_XINCREF(r) Py_XINCREF(r)
967 #define __Pyx_XDECREF(r) Py_XDECREF(r)
968 #define __Pyx_XGOTREF(r)
969 #define __Pyx_XGIVEREF(r)
970 #endif
971 #define __Pyx_XDECREF_SET(r, v) do {\
972 PyObject *tmp = (PyObject *) r;\
973 r = v; __Pyx_XDECREF(tmp);\
974 } while (0)
975 #define __Pyx_DECREF_SET(r, v) do {\
976 PyObject *tmp = (PyObject *) r;\
977 r = v; __Pyx_DECREF(tmp);\
978 } while (0)
979 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
980 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
981
982 /* PyObjectGetAttrStr.proto */
983 #if CYTHON_USE_TYPE_SLOTS
984 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
985 #else
986 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
987 #endif
988
989 /* GetBuiltinName.proto */
990 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
991
992 /* RaiseDoubleKeywords.proto */
993 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
994
995 /* ParseKeywords.proto */
996 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
997 PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
998 const char* function_name);
999
1000 /* RaiseArgTupleInvalid.proto */
1001 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1002 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1003
1004 /* PyFunctionFastCall.proto */
1005 #if CYTHON_FAST_PYCALL
1006 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1007 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1008 #if 1 || PY_VERSION_HEX < 0x030600B1
1009 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1010 #else
1011 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1012 #endif
1013 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1014 (sizeof(char [1 - 2*!(cond)]) - 1)
1015 #ifndef Py_MEMBER_SIZE
1016 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1017 #endif
1018 #if CYTHON_FAST_PYCALL
1019 static size_t __pyx_pyframe_localsplus_offset = 0;
1020 #include "frameobject.h"
1021 #define __Pxy_PyFrame_Initialize_Offsets()\
1022 ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1023 (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1024 #define __Pyx_PyFrame_GetLocalsplus(frame)\
1025 (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1026 #endif // CYTHON_FAST_PYCALL
1027 #endif
1028
1029 /* PyObjectCall.proto */
1030 #if CYTHON_COMPILING_IN_CPYTHON
1031 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1032 #else
1033 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1034 #endif
1035
1036 /* PyObjectCallMethO.proto */
1037 #if CYTHON_COMPILING_IN_CPYTHON
1038 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1039 #endif
1040
1041 /* PyObjectCallNoArg.proto */
1042 #if CYTHON_COMPILING_IN_CPYTHON
1043 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1044 #else
1045 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1046 #endif
1047
1048 /* PyCFunctionFastCall.proto */
1049 #if CYTHON_FAST_PYCCALL
1050 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1051 #else
1052 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
1053 #endif
1054
1055 /* PyObjectCallOneArg.proto */
1056 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1057
1058 /* PyThreadStateGet.proto */
1059 #if CYTHON_FAST_THREAD_STATE
1060 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1061 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1062 #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
1063 #else
1064 #define __Pyx_PyThreadState_declare
1065 #define __Pyx_PyThreadState_assign
1066 #define __Pyx_PyErr_Occurred() PyErr_Occurred()
1067 #endif
1068
1069 /* PyErrFetchRestore.proto */
1070 #if CYTHON_FAST_THREAD_STATE
1071 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1072 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1073 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1074 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1075 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1076 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1077 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1078 #if CYTHON_COMPILING_IN_CPYTHON
1079 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1080 #else
1081 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1082 #endif
1083 #else
1084 #define __Pyx_PyErr_Clear() PyErr_Clear()
1085 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1086 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1087 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1088 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1089 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1090 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1091 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1092 #endif
1093
1094 /* RaiseException.proto */
1095 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1096
1097 /* PyObject_GenericGetAttrNoDict.proto */
1098 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1099 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
1100 #else
1101 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1102 #endif
1103
1104 /* PyObject_GenericGetAttr.proto */
1105 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1106 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
1107 #else
1108 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
1109 #endif
1110
1111 /* PyErrExceptionMatches.proto */
1112 #if CYTHON_FAST_THREAD_STATE
1113 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1114 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1115 #else
1116 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1117 #endif
1118
1119 /* PyObjectGetAttrStrNoError.proto */
1120 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1121
1122 /* SetupReduce.proto */
1123 static int __Pyx_setup_reduce(PyObject* type_obj);
1124
1125 /* PyDictVersioning.proto */
1126 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1127 #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
1128 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
1129 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1130 (version_var) = __PYX_GET_DICT_VERSION(dict);\
1131 (cache_var) = (value);
1132 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1133 static PY_UINT64_T __pyx_dict_version = 0;\
1134 static PyObject *__pyx_dict_cached_value = NULL;\
1135 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1136 (VAR) = __pyx_dict_cached_value;\
1137 } else {\
1138 (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1139 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1140 }\
1141 }
1142 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1143 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1144 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1145 #else
1146 #define __PYX_GET_DICT_VERSION(dict) (0)
1147 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1148 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
1149 #endif
1150
1151 /* CLineInTraceback.proto */
1152 #ifdef CYTHON_CLINE_IN_TRACEBACK
1153 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1154 #else
1155 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1156 #endif
1157
1158 /* CodeObjectCache.proto */
1159 typedef struct {
1160 PyCodeObject* code_object;
1161 int code_line;
1162 } __Pyx_CodeObjectCacheEntry;
1163 struct __Pyx_CodeObjectCache {
1164 int count;
1165 int max_count;
1166 __Pyx_CodeObjectCacheEntry* entries;
1167 };
1168 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1169 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1170 static PyCodeObject *__pyx_find_code_object(int code_line);
1171 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1172
1173 /* AddTraceback.proto */
1174 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1175 int py_line, const char *filename);
1176
1177 /* GCCDiagnostics.proto */
1178 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
1179 #define __Pyx_HAS_GCC_DIAGNOSTIC
1180 #endif
1181
1182 /* CIntFromPy.proto */
1183 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1184
1185 /* CIntFromPy.proto */
1186 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject *);
1187
1188 /* CIntToPy.proto */
1189 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value);
1190
1191 /* CIntToPy.proto */
1192 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1193
1194 /* CIntFromPy.proto */
1195 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1196
1197 /* FastTypeChecks.proto */
1198 #if CYTHON_COMPILING_IN_CPYTHON
1199 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1200 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1201 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1202 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1203 #else
1204 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1205 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1206 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1207 #endif
1208 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1209
1210 /* CheckBinaryVersion.proto */
1211 static int __Pyx_check_binary_version(void);
1212
1213 /* InitStrings.proto */
1214 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1215
1216
1217 /* Module declarations from 'cpython.version' */
1218
1219 /* Module declarations from 'bx.misc.bgzf' */
1220 static PyTypeObject *__pyx_ptype_2bx_4misc_4bgzf_BGZFFile = 0;
1221 #define __Pyx_MODULE_NAME "bx.misc.bgzf"
1222 extern int __pyx_module_is_main_bx__misc__bgzf;
1223 int __pyx_module_is_main_bx__misc__bgzf = 0;
1224
1225 /* Implementation of 'bx.misc.bgzf' */
1226 static PyObject *__pyx_builtin_IOError;
1227 static PyObject *__pyx_builtin_TypeError;
1228 static const char __pyx_k_r[] = "r";
1229 static const char __pyx_k_pos[] = "pos";
1230 static const char __pyx_k_main[] = "__main__";
1231 static const char __pyx_k_mode[] = "mode";
1232 static const char __pyx_k_name[] = "__name__";
1233 static const char __pyx_k_path[] = "path";
1234 static const char __pyx_k_test[] = "__test__";
1235 static const char __pyx_k_where[] = "where";
1236 static const char __pyx_k_encode[] = "encode";
1237 static const char __pyx_k_reduce[] = "__reduce__";
1238 static const char __pyx_k_IOError[] = "IOError";
1239 static const char __pyx_k_BGZFFile[] = "BGZFFile";
1240 static const char __pyx_k_getstate[] = "__getstate__";
1241 static const char __pyx_k_setstate[] = "__setstate__";
1242 static const char __pyx_k_TypeError[] = "TypeError";
1243 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
1244 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
1245 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
1246 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1247 static const char __pyx_k_Could_not_open_file[] = "Could not open file";
1248 static const char __pyx_k_Seekable_access_to_BGZ_files_ba[] = "\nSeekable access to BGZ files based on samtools code. Does not yet implement\ncomplete file-like interface.\n";
1249 static const char __pyx_k_self_bgzf_cannot_be_converted_to[] = "self.bgzf cannot be converted to a Python object for pickling";
1250 static PyObject *__pyx_n_s_BGZFFile;
1251 static PyObject *__pyx_kp_s_Could_not_open_file;
1252 static PyObject *__pyx_n_s_IOError;
1253 static PyObject *__pyx_n_s_TypeError;
1254 static PyObject *__pyx_n_s_cline_in_traceback;
1255 static PyObject *__pyx_n_s_encode;
1256 static PyObject *__pyx_n_s_getstate;
1257 static PyObject *__pyx_n_s_main;
1258 static PyObject *__pyx_n_s_mode;
1259 static PyObject *__pyx_n_s_name;
1260 static PyObject *__pyx_n_s_path;
1261 static PyObject *__pyx_n_s_pos;
1262 static PyObject *__pyx_n_s_r;
1263 static PyObject *__pyx_n_s_reduce;
1264 static PyObject *__pyx_n_s_reduce_cython;
1265 static PyObject *__pyx_n_s_reduce_ex;
1266 static PyObject *__pyx_kp_s_self_bgzf_cannot_be_converted_to;
1267 static PyObject *__pyx_n_s_setstate;
1268 static PyObject *__pyx_n_s_setstate_cython;
1269 static PyObject *__pyx_n_s_test;
1270 static PyObject *__pyx_n_s_where;
1271 static int __pyx_pf_2bx_4misc_4bgzf_8BGZFFile___init__(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *__pyx_v_self, PyObject *__pyx_v_path, PyObject *__pyx_v_mode); /* proto */
1272 static PyObject *__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_2close(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *__pyx_v_self); /* proto */
1273 static PyObject *__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_4read(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *__pyx_v_self, int __pyx_v_length); /* proto */
1274 static PyObject *__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_6tell(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *__pyx_v_self); /* proto */
1275 static PyObject *__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_8seek(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *__pyx_v_self, __pyx_t_2bx_4misc_4bgzf_int64_t __pyx_v_pos, int __pyx_v_where); /* proto */
1276 static PyObject *__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *__pyx_v_self); /* proto */
1277 static PyObject *__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
1278 static PyObject *__pyx_tp_new_2bx_4misc_4bgzf_BGZFFile(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1279 static PyObject *__pyx_tuple_;
1280 static PyObject *__pyx_tuple__2;
1281 static PyObject *__pyx_tuple__3;
1282 /* Late includes */
1283
1284 /* "bx/misc/bgzf.pyx":24
1285 * cdef class BGZFFile( object ):
1286 * cdef BGZF * bgzf
1287 * def __init__( self, path, mode="r" ): # <<<<<<<<<<<<<<
1288 * if PY_MAJOR_VERSION >= 3:
1289 * bytes_path, bytes_mode = path.encode(), mode.encode()
1290 */
1291
1292 /* Python wrapper */
1293 static int __pyx_pw_2bx_4misc_4bgzf_8BGZFFile_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_1__init__(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1294 static int __pyx_pw_2bx_4misc_4bgzf_8BGZFFile_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1295 PyObject *__pyx_v_path = 0;
1296 PyObject *__pyx_v_mode = 0;
1297 int __pyx_lineno = 0;
1298 const char *__pyx_filename = NULL;
1299 int __pyx_clineno = 0;
1300 int __pyx_r;
1301 __Pyx_RefNannyDeclarations
1302 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
1303 {
1304 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_path,&__pyx_n_s_mode,0};
1305 PyObject* values[2] = {0,0};
1306 values[1] = ((PyObject *)__pyx_n_s_r);
1307 if (unlikely(__pyx_kwds)) {
1308 Py_ssize_t kw_args;
1309 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1310 switch (pos_args) {
1311 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1312 CYTHON_FALLTHROUGH;
1313 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1314 CYTHON_FALLTHROUGH;
1315 case 0: break;
1316 default: goto __pyx_L5_argtuple_error;
1317 }
1318 kw_args = PyDict_Size(__pyx_kwds);
1319 switch (pos_args) {
1320 case 0:
1321 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--;
1322 else goto __pyx_L5_argtuple_error;
1323 CYTHON_FALLTHROUGH;
1324 case 1:
1325 if (kw_args > 0) {
1326 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode);
1327 if (value) { values[1] = value; kw_args--; }
1328 }
1329 }
1330 if (unlikely(kw_args > 0)) {
1331 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 24, __pyx_L3_error)
1332 }
1333 } else {
1334 switch (PyTuple_GET_SIZE(__pyx_args)) {
1335 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1336 CYTHON_FALLTHROUGH;
1337 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1338 break;
1339 default: goto __pyx_L5_argtuple_error;
1340 }
1341 }
1342 __pyx_v_path = values[0];
1343 __pyx_v_mode = values[1];
1344 }
1345 goto __pyx_L4_argument_unpacking_done;
1346 __pyx_L5_argtuple_error:;
1347 __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 24, __pyx_L3_error)
1348 __pyx_L3_error:;
1349 __Pyx_AddTraceback("bx.misc.bgzf.BGZFFile.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1350 __Pyx_RefNannyFinishContext();
1351 return -1;
1352 __pyx_L4_argument_unpacking_done:;
1353 __pyx_r = __pyx_pf_2bx_4misc_4bgzf_8BGZFFile___init__(((struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *)__pyx_v_self), __pyx_v_path, __pyx_v_mode);
1354
1355 /* function exit code */
1356 __Pyx_RefNannyFinishContext();
1357 return __pyx_r;
1358 }
1359
__pyx_pf_2bx_4misc_4bgzf_8BGZFFile___init__(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile * __pyx_v_self,PyObject * __pyx_v_path,PyObject * __pyx_v_mode)1360 static int __pyx_pf_2bx_4misc_4bgzf_8BGZFFile___init__(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *__pyx_v_self, PyObject *__pyx_v_path, PyObject *__pyx_v_mode) {
1361 PyObject *__pyx_v_bytes_path = NULL;
1362 PyObject *__pyx_v_bytes_mode = NULL;
1363 int __pyx_r;
1364 __Pyx_RefNannyDeclarations
1365 int __pyx_t_1;
1366 PyObject *__pyx_t_2 = NULL;
1367 PyObject *__pyx_t_3 = NULL;
1368 PyObject *__pyx_t_4 = NULL;
1369 PyObject *__pyx_t_5 = NULL;
1370 char const *__pyx_t_6;
1371 char const *__pyx_t_7;
1372 int __pyx_lineno = 0;
1373 const char *__pyx_filename = NULL;
1374 int __pyx_clineno = 0;
1375 __Pyx_RefNannySetupContext("__init__", 0);
1376
1377 /* "bx/misc/bgzf.pyx":25
1378 * cdef BGZF * bgzf
1379 * def __init__( self, path, mode="r" ):
1380 * if PY_MAJOR_VERSION >= 3: # <<<<<<<<<<<<<<
1381 * bytes_path, bytes_mode = path.encode(), mode.encode()
1382 * else:
1383 */
1384 __pyx_t_1 = ((PY_MAJOR_VERSION >= 3) != 0);
1385 if (__pyx_t_1) {
1386
1387 /* "bx/misc/bgzf.pyx":26
1388 * def __init__( self, path, mode="r" ):
1389 * if PY_MAJOR_VERSION >= 3:
1390 * bytes_path, bytes_mode = path.encode(), mode.encode() # <<<<<<<<<<<<<<
1391 * else:
1392 * bytes_path, bytes_mode = path, mode
1393 */
1394 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_path, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 26, __pyx_L1_error)
1395 __Pyx_GOTREF(__pyx_t_3);
1396 __pyx_t_4 = NULL;
1397 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
1398 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
1399 if (likely(__pyx_t_4)) {
1400 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
1401 __Pyx_INCREF(__pyx_t_4);
1402 __Pyx_INCREF(function);
1403 __Pyx_DECREF_SET(__pyx_t_3, function);
1404 }
1405 }
1406 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
1407 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
1408 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 26, __pyx_L1_error)
1409 __Pyx_GOTREF(__pyx_t_2);
1410 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1411 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_mode, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 26, __pyx_L1_error)
1412 __Pyx_GOTREF(__pyx_t_4);
1413 __pyx_t_5 = NULL;
1414 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
1415 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
1416 if (likely(__pyx_t_5)) {
1417 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
1418 __Pyx_INCREF(__pyx_t_5);
1419 __Pyx_INCREF(function);
1420 __Pyx_DECREF_SET(__pyx_t_4, function);
1421 }
1422 }
1423 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
1424 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
1425 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 26, __pyx_L1_error)
1426 __Pyx_GOTREF(__pyx_t_3);
1427 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1428 __pyx_v_bytes_path = __pyx_t_2;
1429 __pyx_t_2 = 0;
1430 __pyx_v_bytes_mode = __pyx_t_3;
1431 __pyx_t_3 = 0;
1432
1433 /* "bx/misc/bgzf.pyx":25
1434 * cdef BGZF * bgzf
1435 * def __init__( self, path, mode="r" ):
1436 * if PY_MAJOR_VERSION >= 3: # <<<<<<<<<<<<<<
1437 * bytes_path, bytes_mode = path.encode(), mode.encode()
1438 * else:
1439 */
1440 goto __pyx_L3;
1441 }
1442
1443 /* "bx/misc/bgzf.pyx":28
1444 * bytes_path, bytes_mode = path.encode(), mode.encode()
1445 * else:
1446 * bytes_path, bytes_mode = path, mode # <<<<<<<<<<<<<<
1447 * self.bgzf = bgzf_open( bytes_path, bytes_mode )
1448 * if not self.bgzf:
1449 */
1450 /*else*/ {
1451 __pyx_t_3 = __pyx_v_path;
1452 __Pyx_INCREF(__pyx_t_3);
1453 __pyx_t_2 = __pyx_v_mode;
1454 __Pyx_INCREF(__pyx_t_2);
1455 __pyx_v_bytes_path = __pyx_t_3;
1456 __pyx_t_3 = 0;
1457 __pyx_v_bytes_mode = __pyx_t_2;
1458 __pyx_t_2 = 0;
1459 }
1460 __pyx_L3:;
1461
1462 /* "bx/misc/bgzf.pyx":29
1463 * else:
1464 * bytes_path, bytes_mode = path, mode
1465 * self.bgzf = bgzf_open( bytes_path, bytes_mode ) # <<<<<<<<<<<<<<
1466 * if not self.bgzf:
1467 * raise IOError( "Could not open file" )
1468 */
1469 __pyx_t_6 = __Pyx_PyObject_AsString(__pyx_v_bytes_path); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 29, __pyx_L1_error)
1470 __pyx_t_7 = __Pyx_PyObject_AsString(__pyx_v_bytes_mode); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 29, __pyx_L1_error)
1471 __pyx_v_self->bgzf = bgzf_open(__pyx_t_6, __pyx_t_7);
1472
1473 /* "bx/misc/bgzf.pyx":30
1474 * bytes_path, bytes_mode = path, mode
1475 * self.bgzf = bgzf_open( bytes_path, bytes_mode )
1476 * if not self.bgzf: # <<<<<<<<<<<<<<
1477 * raise IOError( "Could not open file" )
1478 *
1479 */
1480 __pyx_t_1 = ((!(__pyx_v_self->bgzf != 0)) != 0);
1481 if (unlikely(__pyx_t_1)) {
1482
1483 /* "bx/misc/bgzf.pyx":31
1484 * self.bgzf = bgzf_open( bytes_path, bytes_mode )
1485 * if not self.bgzf:
1486 * raise IOError( "Could not open file" ) # <<<<<<<<<<<<<<
1487 *
1488 * def close( self ):
1489 */
1490 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
1491 __Pyx_GOTREF(__pyx_t_2);
1492 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
1493 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1494 __PYX_ERR(0, 31, __pyx_L1_error)
1495
1496 /* "bx/misc/bgzf.pyx":30
1497 * bytes_path, bytes_mode = path, mode
1498 * self.bgzf = bgzf_open( bytes_path, bytes_mode )
1499 * if not self.bgzf: # <<<<<<<<<<<<<<
1500 * raise IOError( "Could not open file" )
1501 *
1502 */
1503 }
1504
1505 /* "bx/misc/bgzf.pyx":24
1506 * cdef class BGZFFile( object ):
1507 * cdef BGZF * bgzf
1508 * def __init__( self, path, mode="r" ): # <<<<<<<<<<<<<<
1509 * if PY_MAJOR_VERSION >= 3:
1510 * bytes_path, bytes_mode = path.encode(), mode.encode()
1511 */
1512
1513 /* function exit code */
1514 __pyx_r = 0;
1515 goto __pyx_L0;
1516 __pyx_L1_error:;
1517 __Pyx_XDECREF(__pyx_t_2);
1518 __Pyx_XDECREF(__pyx_t_3);
1519 __Pyx_XDECREF(__pyx_t_4);
1520 __Pyx_XDECREF(__pyx_t_5);
1521 __Pyx_AddTraceback("bx.misc.bgzf.BGZFFile.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1522 __pyx_r = -1;
1523 __pyx_L0:;
1524 __Pyx_XDECREF(__pyx_v_bytes_path);
1525 __Pyx_XDECREF(__pyx_v_bytes_mode);
1526 __Pyx_RefNannyFinishContext();
1527 return __pyx_r;
1528 }
1529
1530 /* "bx/misc/bgzf.pyx":33
1531 * raise IOError( "Could not open file" )
1532 *
1533 * def close( self ): # <<<<<<<<<<<<<<
1534 * if self.bgzf:
1535 * bgzf_close( self.bgzf )
1536 */
1537
1538 /* Python wrapper */
1539 static PyObject *__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_3close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_3close(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)1540 static PyObject *__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_3close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1541 PyObject *__pyx_r = 0;
1542 __Pyx_RefNannyDeclarations
1543 __Pyx_RefNannySetupContext("close (wrapper)", 0);
1544 __pyx_r = __pyx_pf_2bx_4misc_4bgzf_8BGZFFile_2close(((struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *)__pyx_v_self));
1545
1546 /* function exit code */
1547 __Pyx_RefNannyFinishContext();
1548 return __pyx_r;
1549 }
1550
__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_2close(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile * __pyx_v_self)1551 static PyObject *__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_2close(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *__pyx_v_self) {
1552 PyObject *__pyx_r = NULL;
1553 __Pyx_RefNannyDeclarations
1554 int __pyx_t_1;
1555 __Pyx_RefNannySetupContext("close", 0);
1556
1557 /* "bx/misc/bgzf.pyx":34
1558 *
1559 * def close( self ):
1560 * if self.bgzf: # <<<<<<<<<<<<<<
1561 * bgzf_close( self.bgzf )
1562 * def read( self, int length ):
1563 */
1564 __pyx_t_1 = (__pyx_v_self->bgzf != 0);
1565 if (__pyx_t_1) {
1566
1567 /* "bx/misc/bgzf.pyx":35
1568 * def close( self ):
1569 * if self.bgzf:
1570 * bgzf_close( self.bgzf ) # <<<<<<<<<<<<<<
1571 * def read( self, int length ):
1572 * cdef object rval
1573 */
1574 (void)(bgzf_close(__pyx_v_self->bgzf));
1575
1576 /* "bx/misc/bgzf.pyx":34
1577 *
1578 * def close( self ):
1579 * if self.bgzf: # <<<<<<<<<<<<<<
1580 * bgzf_close( self.bgzf )
1581 * def read( self, int length ):
1582 */
1583 }
1584
1585 /* "bx/misc/bgzf.pyx":33
1586 * raise IOError( "Could not open file" )
1587 *
1588 * def close( self ): # <<<<<<<<<<<<<<
1589 * if self.bgzf:
1590 * bgzf_close( self.bgzf )
1591 */
1592
1593 /* function exit code */
1594 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1595 __Pyx_XGIVEREF(__pyx_r);
1596 __Pyx_RefNannyFinishContext();
1597 return __pyx_r;
1598 }
1599
1600 /* "bx/misc/bgzf.pyx":36
1601 * if self.bgzf:
1602 * bgzf_close( self.bgzf )
1603 * def read( self, int length ): # <<<<<<<<<<<<<<
1604 * cdef object rval
1605 * rval = PyBytes_FromStringAndSize( NULL, length )
1606 */
1607
1608 /* Python wrapper */
1609 static PyObject *__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_5read(PyObject *__pyx_v_self, PyObject *__pyx_arg_length); /*proto*/
__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_5read(PyObject * __pyx_v_self,PyObject * __pyx_arg_length)1610 static PyObject *__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_5read(PyObject *__pyx_v_self, PyObject *__pyx_arg_length) {
1611 int __pyx_v_length;
1612 int __pyx_lineno = 0;
1613 const char *__pyx_filename = NULL;
1614 int __pyx_clineno = 0;
1615 PyObject *__pyx_r = 0;
1616 __Pyx_RefNannyDeclarations
1617 __Pyx_RefNannySetupContext("read (wrapper)", 0);
1618 assert(__pyx_arg_length); {
1619 __pyx_v_length = __Pyx_PyInt_As_int(__pyx_arg_length); if (unlikely((__pyx_v_length == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 36, __pyx_L3_error)
1620 }
1621 goto __pyx_L4_argument_unpacking_done;
1622 __pyx_L3_error:;
1623 __Pyx_AddTraceback("bx.misc.bgzf.BGZFFile.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
1624 __Pyx_RefNannyFinishContext();
1625 return NULL;
1626 __pyx_L4_argument_unpacking_done:;
1627 __pyx_r = __pyx_pf_2bx_4misc_4bgzf_8BGZFFile_4read(((struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *)__pyx_v_self), ((int)__pyx_v_length));
1628
1629 /* function exit code */
1630 __Pyx_RefNannyFinishContext();
1631 return __pyx_r;
1632 }
1633
__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_4read(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile * __pyx_v_self,int __pyx_v_length)1634 static PyObject *__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_4read(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *__pyx_v_self, int __pyx_v_length) {
1635 PyObject *__pyx_v_rval = 0;
1636 PyObject *__pyx_r = NULL;
1637 __Pyx_RefNannyDeclarations
1638 PyObject *__pyx_t_1 = NULL;
1639 int __pyx_lineno = 0;
1640 const char *__pyx_filename = NULL;
1641 int __pyx_clineno = 0;
1642 __Pyx_RefNannySetupContext("read", 0);
1643
1644 /* "bx/misc/bgzf.pyx":38
1645 * def read( self, int length ):
1646 * cdef object rval
1647 * rval = PyBytes_FromStringAndSize( NULL, length ) # <<<<<<<<<<<<<<
1648 * bgzf_read( self.bgzf, PyBytes_AsString( rval ), length )
1649 * return rval
1650 */
1651 __pyx_t_1 = PyBytes_FromStringAndSize(NULL, __pyx_v_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
1652 __Pyx_GOTREF(__pyx_t_1);
1653 __pyx_v_rval = __pyx_t_1;
1654 __pyx_t_1 = 0;
1655
1656 /* "bx/misc/bgzf.pyx":39
1657 * cdef object rval
1658 * rval = PyBytes_FromStringAndSize( NULL, length )
1659 * bgzf_read( self.bgzf, PyBytes_AsString( rval ), length ) # <<<<<<<<<<<<<<
1660 * return rval
1661 * def tell( self ):
1662 */
1663 (void)(bgzf_read(__pyx_v_self->bgzf, PyBytes_AsString(__pyx_v_rval), __pyx_v_length));
1664
1665 /* "bx/misc/bgzf.pyx":40
1666 * rval = PyBytes_FromStringAndSize( NULL, length )
1667 * bgzf_read( self.bgzf, PyBytes_AsString( rval ), length )
1668 * return rval # <<<<<<<<<<<<<<
1669 * def tell( self ):
1670 * return bgzf_tell( self.bgzf )
1671 */
1672 __Pyx_XDECREF(__pyx_r);
1673 __Pyx_INCREF(__pyx_v_rval);
1674 __pyx_r = __pyx_v_rval;
1675 goto __pyx_L0;
1676
1677 /* "bx/misc/bgzf.pyx":36
1678 * if self.bgzf:
1679 * bgzf_close( self.bgzf )
1680 * def read( self, int length ): # <<<<<<<<<<<<<<
1681 * cdef object rval
1682 * rval = PyBytes_FromStringAndSize( NULL, length )
1683 */
1684
1685 /* function exit code */
1686 __pyx_L1_error:;
1687 __Pyx_XDECREF(__pyx_t_1);
1688 __Pyx_AddTraceback("bx.misc.bgzf.BGZFFile.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
1689 __pyx_r = NULL;
1690 __pyx_L0:;
1691 __Pyx_XDECREF(__pyx_v_rval);
1692 __Pyx_XGIVEREF(__pyx_r);
1693 __Pyx_RefNannyFinishContext();
1694 return __pyx_r;
1695 }
1696
1697 /* "bx/misc/bgzf.pyx":41
1698 * bgzf_read( self.bgzf, PyBytes_AsString( rval ), length )
1699 * return rval
1700 * def tell( self ): # <<<<<<<<<<<<<<
1701 * return bgzf_tell( self.bgzf )
1702 * def seek( self, int64_t pos, int where=0 ):
1703 */
1704
1705 /* Python wrapper */
1706 static PyObject *__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_7tell(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_7tell(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)1707 static PyObject *__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_7tell(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1708 PyObject *__pyx_r = 0;
1709 __Pyx_RefNannyDeclarations
1710 __Pyx_RefNannySetupContext("tell (wrapper)", 0);
1711 __pyx_r = __pyx_pf_2bx_4misc_4bgzf_8BGZFFile_6tell(((struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *)__pyx_v_self));
1712
1713 /* function exit code */
1714 __Pyx_RefNannyFinishContext();
1715 return __pyx_r;
1716 }
1717
__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_6tell(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile * __pyx_v_self)1718 static PyObject *__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_6tell(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *__pyx_v_self) {
1719 PyObject *__pyx_r = NULL;
1720 __Pyx_RefNannyDeclarations
1721 PyObject *__pyx_t_1 = NULL;
1722 int __pyx_lineno = 0;
1723 const char *__pyx_filename = NULL;
1724 int __pyx_clineno = 0;
1725 __Pyx_RefNannySetupContext("tell", 0);
1726
1727 /* "bx/misc/bgzf.pyx":42
1728 * return rval
1729 * def tell( self ):
1730 * return bgzf_tell( self.bgzf ) # <<<<<<<<<<<<<<
1731 * def seek( self, int64_t pos, int where=0 ):
1732 * return bgzf_seek( self.bgzf, pos, where )
1733 */
1734 __Pyx_XDECREF(__pyx_r);
1735 __pyx_t_1 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(bgzf_tell(__pyx_v_self->bgzf)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
1736 __Pyx_GOTREF(__pyx_t_1);
1737 __pyx_r = __pyx_t_1;
1738 __pyx_t_1 = 0;
1739 goto __pyx_L0;
1740
1741 /* "bx/misc/bgzf.pyx":41
1742 * bgzf_read( self.bgzf, PyBytes_AsString( rval ), length )
1743 * return rval
1744 * def tell( self ): # <<<<<<<<<<<<<<
1745 * return bgzf_tell( self.bgzf )
1746 * def seek( self, int64_t pos, int where=0 ):
1747 */
1748
1749 /* function exit code */
1750 __pyx_L1_error:;
1751 __Pyx_XDECREF(__pyx_t_1);
1752 __Pyx_AddTraceback("bx.misc.bgzf.BGZFFile.tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
1753 __pyx_r = NULL;
1754 __pyx_L0:;
1755 __Pyx_XGIVEREF(__pyx_r);
1756 __Pyx_RefNannyFinishContext();
1757 return __pyx_r;
1758 }
1759
1760 /* "bx/misc/bgzf.pyx":43
1761 * def tell( self ):
1762 * return bgzf_tell( self.bgzf )
1763 * def seek( self, int64_t pos, int where=0 ): # <<<<<<<<<<<<<<
1764 * return bgzf_seek( self.bgzf, pos, where )
1765 */
1766
1767 /* Python wrapper */
1768 static PyObject *__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_9seek(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_9seek(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1769 static PyObject *__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_9seek(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1770 __pyx_t_2bx_4misc_4bgzf_int64_t __pyx_v_pos;
1771 int __pyx_v_where;
1772 int __pyx_lineno = 0;
1773 const char *__pyx_filename = NULL;
1774 int __pyx_clineno = 0;
1775 PyObject *__pyx_r = 0;
1776 __Pyx_RefNannyDeclarations
1777 __Pyx_RefNannySetupContext("seek (wrapper)", 0);
1778 {
1779 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pos,&__pyx_n_s_where,0};
1780 PyObject* values[2] = {0,0};
1781 if (unlikely(__pyx_kwds)) {
1782 Py_ssize_t kw_args;
1783 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1784 switch (pos_args) {
1785 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1786 CYTHON_FALLTHROUGH;
1787 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1788 CYTHON_FALLTHROUGH;
1789 case 0: break;
1790 default: goto __pyx_L5_argtuple_error;
1791 }
1792 kw_args = PyDict_Size(__pyx_kwds);
1793 switch (pos_args) {
1794 case 0:
1795 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pos)) != 0)) kw_args--;
1796 else goto __pyx_L5_argtuple_error;
1797 CYTHON_FALLTHROUGH;
1798 case 1:
1799 if (kw_args > 0) {
1800 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_where);
1801 if (value) { values[1] = value; kw_args--; }
1802 }
1803 }
1804 if (unlikely(kw_args > 0)) {
1805 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "seek") < 0)) __PYX_ERR(0, 43, __pyx_L3_error)
1806 }
1807 } else {
1808 switch (PyTuple_GET_SIZE(__pyx_args)) {
1809 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1810 CYTHON_FALLTHROUGH;
1811 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1812 break;
1813 default: goto __pyx_L5_argtuple_error;
1814 }
1815 }
1816 __pyx_v_pos = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(values[0]); if (unlikely((__pyx_v_pos == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L3_error)
1817 if (values[1]) {
1818 __pyx_v_where = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_where == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L3_error)
1819 } else {
1820 __pyx_v_where = ((int)0);
1821 }
1822 }
1823 goto __pyx_L4_argument_unpacking_done;
1824 __pyx_L5_argtuple_error:;
1825 __Pyx_RaiseArgtupleInvalid("seek", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 43, __pyx_L3_error)
1826 __pyx_L3_error:;
1827 __Pyx_AddTraceback("bx.misc.bgzf.BGZFFile.seek", __pyx_clineno, __pyx_lineno, __pyx_filename);
1828 __Pyx_RefNannyFinishContext();
1829 return NULL;
1830 __pyx_L4_argument_unpacking_done:;
1831 __pyx_r = __pyx_pf_2bx_4misc_4bgzf_8BGZFFile_8seek(((struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *)__pyx_v_self), __pyx_v_pos, __pyx_v_where);
1832
1833 /* function exit code */
1834 __Pyx_RefNannyFinishContext();
1835 return __pyx_r;
1836 }
1837
__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_8seek(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile * __pyx_v_self,__pyx_t_2bx_4misc_4bgzf_int64_t __pyx_v_pos,int __pyx_v_where)1838 static PyObject *__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_8seek(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *__pyx_v_self, __pyx_t_2bx_4misc_4bgzf_int64_t __pyx_v_pos, int __pyx_v_where) {
1839 PyObject *__pyx_r = NULL;
1840 __Pyx_RefNannyDeclarations
1841 PyObject *__pyx_t_1 = NULL;
1842 int __pyx_lineno = 0;
1843 const char *__pyx_filename = NULL;
1844 int __pyx_clineno = 0;
1845 __Pyx_RefNannySetupContext("seek", 0);
1846
1847 /* "bx/misc/bgzf.pyx":44
1848 * return bgzf_tell( self.bgzf )
1849 * def seek( self, int64_t pos, int where=0 ):
1850 * return bgzf_seek( self.bgzf, pos, where ) # <<<<<<<<<<<<<<
1851 */
1852 __Pyx_XDECREF(__pyx_r);
1853 __pyx_t_1 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(bgzf_seek(__pyx_v_self->bgzf, __pyx_v_pos, __pyx_v_where)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
1854 __Pyx_GOTREF(__pyx_t_1);
1855 __pyx_r = __pyx_t_1;
1856 __pyx_t_1 = 0;
1857 goto __pyx_L0;
1858
1859 /* "bx/misc/bgzf.pyx":43
1860 * def tell( self ):
1861 * return bgzf_tell( self.bgzf )
1862 * def seek( self, int64_t pos, int where=0 ): # <<<<<<<<<<<<<<
1863 * return bgzf_seek( self.bgzf, pos, where )
1864 */
1865
1866 /* function exit code */
1867 __pyx_L1_error:;
1868 __Pyx_XDECREF(__pyx_t_1);
1869 __Pyx_AddTraceback("bx.misc.bgzf.BGZFFile.seek", __pyx_clineno, __pyx_lineno, __pyx_filename);
1870 __pyx_r = NULL;
1871 __pyx_L0:;
1872 __Pyx_XGIVEREF(__pyx_r);
1873 __Pyx_RefNannyFinishContext();
1874 return __pyx_r;
1875 }
1876
1877 /* "(tree fragment)":1
1878 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
1879 * raise TypeError("self.bgzf cannot be converted to a Python object for pickling")
1880 * def __setstate_cython__(self, __pyx_state):
1881 */
1882
1883 /* Python wrapper */
1884 static PyObject *__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_11__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)1885 static PyObject *__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1886 PyObject *__pyx_r = 0;
1887 __Pyx_RefNannyDeclarations
1888 __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
1889 __pyx_r = __pyx_pf_2bx_4misc_4bgzf_8BGZFFile_10__reduce_cython__(((struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *)__pyx_v_self));
1890
1891 /* function exit code */
1892 __Pyx_RefNannyFinishContext();
1893 return __pyx_r;
1894 }
1895
__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile * __pyx_v_self)1896 static PyObject *__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *__pyx_v_self) {
1897 PyObject *__pyx_r = NULL;
1898 __Pyx_RefNannyDeclarations
1899 PyObject *__pyx_t_1 = NULL;
1900 int __pyx_lineno = 0;
1901 const char *__pyx_filename = NULL;
1902 int __pyx_clineno = 0;
1903 __Pyx_RefNannySetupContext("__reduce_cython__", 0);
1904
1905 /* "(tree fragment)":2
1906 * def __reduce_cython__(self):
1907 * raise TypeError("self.bgzf cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
1908 * def __setstate_cython__(self, __pyx_state):
1909 * raise TypeError("self.bgzf cannot be converted to a Python object for pickling")
1910 */
1911 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
1912 __Pyx_GOTREF(__pyx_t_1);
1913 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
1914 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1915 __PYX_ERR(1, 2, __pyx_L1_error)
1916
1917 /* "(tree fragment)":1
1918 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
1919 * raise TypeError("self.bgzf cannot be converted to a Python object for pickling")
1920 * def __setstate_cython__(self, __pyx_state):
1921 */
1922
1923 /* function exit code */
1924 __pyx_L1_error:;
1925 __Pyx_XDECREF(__pyx_t_1);
1926 __Pyx_AddTraceback("bx.misc.bgzf.BGZFFile.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1927 __pyx_r = NULL;
1928 __Pyx_XGIVEREF(__pyx_r);
1929 __Pyx_RefNannyFinishContext();
1930 return __pyx_r;
1931 }
1932
1933 /* "(tree fragment)":3
1934 * def __reduce_cython__(self):
1935 * raise TypeError("self.bgzf cannot be converted to a Python object for pickling")
1936 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
1937 * raise TypeError("self.bgzf cannot be converted to a Python object for pickling")
1938 */
1939
1940 /* Python wrapper */
1941 static PyObject *__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_13__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)1942 static PyObject *__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
1943 PyObject *__pyx_r = 0;
1944 __Pyx_RefNannyDeclarations
1945 __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
1946 __pyx_r = __pyx_pf_2bx_4misc_4bgzf_8BGZFFile_12__setstate_cython__(((struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
1947
1948 /* function exit code */
1949 __Pyx_RefNannyFinishContext();
1950 return __pyx_r;
1951 }
1952
__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)1953 static PyObject *__pyx_pf_2bx_4misc_4bgzf_8BGZFFile_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
1954 PyObject *__pyx_r = NULL;
1955 __Pyx_RefNannyDeclarations
1956 PyObject *__pyx_t_1 = NULL;
1957 int __pyx_lineno = 0;
1958 const char *__pyx_filename = NULL;
1959 int __pyx_clineno = 0;
1960 __Pyx_RefNannySetupContext("__setstate_cython__", 0);
1961
1962 /* "(tree fragment)":4
1963 * raise TypeError("self.bgzf cannot be converted to a Python object for pickling")
1964 * def __setstate_cython__(self, __pyx_state):
1965 * raise TypeError("self.bgzf cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
1966 */
1967 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
1968 __Pyx_GOTREF(__pyx_t_1);
1969 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
1970 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1971 __PYX_ERR(1, 4, __pyx_L1_error)
1972
1973 /* "(tree fragment)":3
1974 * def __reduce_cython__(self):
1975 * raise TypeError("self.bgzf cannot be converted to a Python object for pickling")
1976 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
1977 * raise TypeError("self.bgzf cannot be converted to a Python object for pickling")
1978 */
1979
1980 /* function exit code */
1981 __pyx_L1_error:;
1982 __Pyx_XDECREF(__pyx_t_1);
1983 __Pyx_AddTraceback("bx.misc.bgzf.BGZFFile.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1984 __pyx_r = NULL;
1985 __Pyx_XGIVEREF(__pyx_r);
1986 __Pyx_RefNannyFinishContext();
1987 return __pyx_r;
1988 }
1989
__pyx_tp_new_2bx_4misc_4bgzf_BGZFFile(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)1990 static PyObject *__pyx_tp_new_2bx_4misc_4bgzf_BGZFFile(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
1991 PyObject *o;
1992 if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
1993 o = (*t->tp_alloc)(t, 0);
1994 } else {
1995 o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
1996 }
1997 if (unlikely(!o)) return 0;
1998 return o;
1999 }
2000
__pyx_tp_dealloc_2bx_4misc_4bgzf_BGZFFile(PyObject * o)2001 static void __pyx_tp_dealloc_2bx_4misc_4bgzf_BGZFFile(PyObject *o) {
2002 #if CYTHON_USE_TP_FINALIZE
2003 if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
2004 if (PyObject_CallFinalizerFromDealloc(o)) return;
2005 }
2006 #endif
2007 (*Py_TYPE(o)->tp_free)(o);
2008 }
2009
2010 static PyMethodDef __pyx_methods_2bx_4misc_4bgzf_BGZFFile[] = {
2011 {"close", (PyCFunction)__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_3close, METH_NOARGS, 0},
2012 {"read", (PyCFunction)__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_5read, METH_O, 0},
2013 {"tell", (PyCFunction)__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_7tell, METH_NOARGS, 0},
2014 {"seek", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_9seek, METH_VARARGS|METH_KEYWORDS, 0},
2015 {"__reduce_cython__", (PyCFunction)__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_11__reduce_cython__, METH_NOARGS, 0},
2016 {"__setstate_cython__", (PyCFunction)__pyx_pw_2bx_4misc_4bgzf_8BGZFFile_13__setstate_cython__, METH_O, 0},
2017 {0, 0, 0, 0}
2018 };
2019
2020 static PyTypeObject __pyx_type_2bx_4misc_4bgzf_BGZFFile = {
2021 PyVarObject_HEAD_INIT(0, 0)
2022 "bx.misc.bgzf.BGZFFile", /*tp_name*/
2023 sizeof(struct __pyx_obj_2bx_4misc_4bgzf_BGZFFile), /*tp_basicsize*/
2024 0, /*tp_itemsize*/
2025 __pyx_tp_dealloc_2bx_4misc_4bgzf_BGZFFile, /*tp_dealloc*/
2026 #if PY_VERSION_HEX < 0x030800b4
2027 0, /*tp_print*/
2028 #endif
2029 #if PY_VERSION_HEX >= 0x030800b4
2030 0, /*tp_vectorcall_offset*/
2031 #endif
2032 0, /*tp_getattr*/
2033 0, /*tp_setattr*/
2034 #if PY_MAJOR_VERSION < 3
2035 0, /*tp_compare*/
2036 #endif
2037 #if PY_MAJOR_VERSION >= 3
2038 0, /*tp_as_async*/
2039 #endif
2040 0, /*tp_repr*/
2041 0, /*tp_as_number*/
2042 0, /*tp_as_sequence*/
2043 0, /*tp_as_mapping*/
2044 0, /*tp_hash*/
2045 0, /*tp_call*/
2046 0, /*tp_str*/
2047 0, /*tp_getattro*/
2048 0, /*tp_setattro*/
2049 0, /*tp_as_buffer*/
2050 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
2051 0, /*tp_doc*/
2052 0, /*tp_traverse*/
2053 0, /*tp_clear*/
2054 0, /*tp_richcompare*/
2055 0, /*tp_weaklistoffset*/
2056 0, /*tp_iter*/
2057 0, /*tp_iternext*/
2058 __pyx_methods_2bx_4misc_4bgzf_BGZFFile, /*tp_methods*/
2059 0, /*tp_members*/
2060 0, /*tp_getset*/
2061 0, /*tp_base*/
2062 0, /*tp_dict*/
2063 0, /*tp_descr_get*/
2064 0, /*tp_descr_set*/
2065 0, /*tp_dictoffset*/
2066 __pyx_pw_2bx_4misc_4bgzf_8BGZFFile_1__init__, /*tp_init*/
2067 0, /*tp_alloc*/
2068 __pyx_tp_new_2bx_4misc_4bgzf_BGZFFile, /*tp_new*/
2069 0, /*tp_free*/
2070 0, /*tp_is_gc*/
2071 0, /*tp_bases*/
2072 0, /*tp_mro*/
2073 0, /*tp_cache*/
2074 0, /*tp_subclasses*/
2075 0, /*tp_weaklist*/
2076 0, /*tp_del*/
2077 0, /*tp_version_tag*/
2078 #if PY_VERSION_HEX >= 0x030400a1
2079 0, /*tp_finalize*/
2080 #endif
2081 #if PY_VERSION_HEX >= 0x030800b1
2082 0, /*tp_vectorcall*/
2083 #endif
2084 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
2085 0, /*tp_print*/
2086 #endif
2087 #if PY_VERSION_HEX >= 0x030B00A2
2088 0, /*tp_inline_values_offset*/
2089 #endif
2090 };
2091
2092 static PyMethodDef __pyx_methods[] = {
2093 {0, 0, 0, 0}
2094 };
2095
2096 #if PY_MAJOR_VERSION >= 3
2097 #if CYTHON_PEP489_MULTI_PHASE_INIT
2098 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
2099 static int __pyx_pymod_exec_bgzf(PyObject* module); /*proto*/
2100 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
2101 {Py_mod_create, (void*)__pyx_pymod_create},
2102 {Py_mod_exec, (void*)__pyx_pymod_exec_bgzf},
2103 {0, NULL}
2104 };
2105 #endif
2106
2107 static struct PyModuleDef __pyx_moduledef = {
2108 PyModuleDef_HEAD_INIT,
2109 "bgzf",
2110 __pyx_k_Seekable_access_to_BGZ_files_ba, /* m_doc */
2111 #if CYTHON_PEP489_MULTI_PHASE_INIT
2112 0, /* m_size */
2113 #else
2114 -1, /* m_size */
2115 #endif
2116 __pyx_methods /* m_methods */,
2117 #if CYTHON_PEP489_MULTI_PHASE_INIT
2118 __pyx_moduledef_slots, /* m_slots */
2119 #else
2120 NULL, /* m_reload */
2121 #endif
2122 NULL, /* m_traverse */
2123 NULL, /* m_clear */
2124 NULL /* m_free */
2125 };
2126 #endif
2127 #ifndef CYTHON_SMALL_CODE
2128 #if defined(__clang__)
2129 #define CYTHON_SMALL_CODE
2130 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
2131 #define CYTHON_SMALL_CODE __attribute__((cold))
2132 #else
2133 #define CYTHON_SMALL_CODE
2134 #endif
2135 #endif
2136
2137 static __Pyx_StringTabEntry __pyx_string_tab[] = {
2138 {&__pyx_n_s_BGZFFile, __pyx_k_BGZFFile, sizeof(__pyx_k_BGZFFile), 0, 0, 1, 1},
2139 {&__pyx_kp_s_Could_not_open_file, __pyx_k_Could_not_open_file, sizeof(__pyx_k_Could_not_open_file), 0, 0, 1, 0},
2140 {&__pyx_n_s_IOError, __pyx_k_IOError, sizeof(__pyx_k_IOError), 0, 0, 1, 1},
2141 {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
2142 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
2143 {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
2144 {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
2145 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
2146 {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
2147 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
2148 {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1},
2149 {&__pyx_n_s_pos, __pyx_k_pos, sizeof(__pyx_k_pos), 0, 0, 1, 1},
2150 {&__pyx_n_s_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 1, 1},
2151 {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
2152 {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
2153 {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
2154 {&__pyx_kp_s_self_bgzf_cannot_be_converted_to, __pyx_k_self_bgzf_cannot_be_converted_to, sizeof(__pyx_k_self_bgzf_cannot_be_converted_to), 0, 0, 1, 0},
2155 {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
2156 {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
2157 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
2158 {&__pyx_n_s_where, __pyx_k_where, sizeof(__pyx_k_where), 0, 0, 1, 1},
2159 {0, 0, 0, 0, 0, 0, 0}
2160 };
__Pyx_InitCachedBuiltins(void)2161 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
2162 __pyx_builtin_IOError = __Pyx_GetBuiltinName(__pyx_n_s_IOError); if (!__pyx_builtin_IOError) __PYX_ERR(0, 31, __pyx_L1_error)
2163 __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error)
2164 return 0;
2165 __pyx_L1_error:;
2166 return -1;
2167 }
2168
__Pyx_InitCachedConstants(void)2169 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
2170 __Pyx_RefNannyDeclarations
2171 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
2172
2173 /* "bx/misc/bgzf.pyx":31
2174 * self.bgzf = bgzf_open( bytes_path, bytes_mode )
2175 * if not self.bgzf:
2176 * raise IOError( "Could not open file" ) # <<<<<<<<<<<<<<
2177 *
2178 * def close( self ):
2179 */
2180 __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Could_not_open_file); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 31, __pyx_L1_error)
2181 __Pyx_GOTREF(__pyx_tuple_);
2182 __Pyx_GIVEREF(__pyx_tuple_);
2183
2184 /* "(tree fragment)":2
2185 * def __reduce_cython__(self):
2186 * raise TypeError("self.bgzf cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
2187 * def __setstate_cython__(self, __pyx_state):
2188 * raise TypeError("self.bgzf cannot be converted to a Python object for pickling")
2189 */
2190 __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_self_bgzf_cannot_be_converted_to); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 2, __pyx_L1_error)
2191 __Pyx_GOTREF(__pyx_tuple__2);
2192 __Pyx_GIVEREF(__pyx_tuple__2);
2193
2194 /* "(tree fragment)":4
2195 * raise TypeError("self.bgzf cannot be converted to a Python object for pickling")
2196 * def __setstate_cython__(self, __pyx_state):
2197 * raise TypeError("self.bgzf cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
2198 */
2199 __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_self_bgzf_cannot_be_converted_to); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 4, __pyx_L1_error)
2200 __Pyx_GOTREF(__pyx_tuple__3);
2201 __Pyx_GIVEREF(__pyx_tuple__3);
2202 __Pyx_RefNannyFinishContext();
2203 return 0;
2204 __pyx_L1_error:;
2205 __Pyx_RefNannyFinishContext();
2206 return -1;
2207 }
2208
__Pyx_InitGlobals(void)2209 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
2210 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
2211 return 0;
2212 __pyx_L1_error:;
2213 return -1;
2214 }
2215
2216 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
2217 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
2218 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
2219 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
2220 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
2221 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
2222 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
2223
__Pyx_modinit_global_init_code(void)2224 static int __Pyx_modinit_global_init_code(void) {
2225 __Pyx_RefNannyDeclarations
2226 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
2227 /*--- Global init code ---*/
2228 __Pyx_RefNannyFinishContext();
2229 return 0;
2230 }
2231
__Pyx_modinit_variable_export_code(void)2232 static int __Pyx_modinit_variable_export_code(void) {
2233 __Pyx_RefNannyDeclarations
2234 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
2235 /*--- Variable export code ---*/
2236 __Pyx_RefNannyFinishContext();
2237 return 0;
2238 }
2239
__Pyx_modinit_function_export_code(void)2240 static int __Pyx_modinit_function_export_code(void) {
2241 __Pyx_RefNannyDeclarations
2242 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
2243 /*--- Function export code ---*/
2244 __Pyx_RefNannyFinishContext();
2245 return 0;
2246 }
2247
__Pyx_modinit_type_init_code(void)2248 static int __Pyx_modinit_type_init_code(void) {
2249 __Pyx_RefNannyDeclarations
2250 int __pyx_lineno = 0;
2251 const char *__pyx_filename = NULL;
2252 int __pyx_clineno = 0;
2253 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
2254 /*--- Type init code ---*/
2255 if (PyType_Ready(&__pyx_type_2bx_4misc_4bgzf_BGZFFile) < 0) __PYX_ERR(0, 22, __pyx_L1_error)
2256 #if PY_VERSION_HEX < 0x030800B1
2257 __pyx_type_2bx_4misc_4bgzf_BGZFFile.tp_print = 0;
2258 #endif
2259 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_2bx_4misc_4bgzf_BGZFFile.tp_dictoffset && __pyx_type_2bx_4misc_4bgzf_BGZFFile.tp_getattro == PyObject_GenericGetAttr)) {
2260 __pyx_type_2bx_4misc_4bgzf_BGZFFile.tp_getattro = __Pyx_PyObject_GenericGetAttr;
2261 }
2262 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BGZFFile, (PyObject *)&__pyx_type_2bx_4misc_4bgzf_BGZFFile) < 0) __PYX_ERR(0, 22, __pyx_L1_error)
2263 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_2bx_4misc_4bgzf_BGZFFile) < 0) __PYX_ERR(0, 22, __pyx_L1_error)
2264 __pyx_ptype_2bx_4misc_4bgzf_BGZFFile = &__pyx_type_2bx_4misc_4bgzf_BGZFFile;
2265 __Pyx_RefNannyFinishContext();
2266 return 0;
2267 __pyx_L1_error:;
2268 __Pyx_RefNannyFinishContext();
2269 return -1;
2270 }
2271
__Pyx_modinit_type_import_code(void)2272 static int __Pyx_modinit_type_import_code(void) {
2273 __Pyx_RefNannyDeclarations
2274 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
2275 /*--- Type import code ---*/
2276 __Pyx_RefNannyFinishContext();
2277 return 0;
2278 }
2279
__Pyx_modinit_variable_import_code(void)2280 static int __Pyx_modinit_variable_import_code(void) {
2281 __Pyx_RefNannyDeclarations
2282 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
2283 /*--- Variable import code ---*/
2284 __Pyx_RefNannyFinishContext();
2285 return 0;
2286 }
2287
__Pyx_modinit_function_import_code(void)2288 static int __Pyx_modinit_function_import_code(void) {
2289 __Pyx_RefNannyDeclarations
2290 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
2291 /*--- Function import code ---*/
2292 __Pyx_RefNannyFinishContext();
2293 return 0;
2294 }
2295
2296
2297 #ifndef CYTHON_NO_PYINIT_EXPORT
2298 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
2299 #elif PY_MAJOR_VERSION < 3
2300 #ifdef __cplusplus
2301 #define __Pyx_PyMODINIT_FUNC extern "C" void
2302 #else
2303 #define __Pyx_PyMODINIT_FUNC void
2304 #endif
2305 #else
2306 #ifdef __cplusplus
2307 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
2308 #else
2309 #define __Pyx_PyMODINIT_FUNC PyObject *
2310 #endif
2311 #endif
2312
2313
2314 #if PY_MAJOR_VERSION < 3
2315 __Pyx_PyMODINIT_FUNC initbgzf(void) CYTHON_SMALL_CODE; /*proto*/
initbgzf(void)2316 __Pyx_PyMODINIT_FUNC initbgzf(void)
2317 #else
2318 __Pyx_PyMODINIT_FUNC PyInit_bgzf(void) CYTHON_SMALL_CODE; /*proto*/
2319 __Pyx_PyMODINIT_FUNC PyInit_bgzf(void)
2320 #if CYTHON_PEP489_MULTI_PHASE_INIT
2321 {
2322 return PyModuleDef_Init(&__pyx_moduledef);
2323 }
2324 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
2325 #if PY_VERSION_HEX >= 0x030700A1
2326 static PY_INT64_T main_interpreter_id = -1;
2327 PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
2328 if (main_interpreter_id == -1) {
2329 main_interpreter_id = current_id;
2330 return (unlikely(current_id == -1)) ? -1 : 0;
2331 } else if (unlikely(main_interpreter_id != current_id))
2332 #else
2333 static PyInterpreterState *main_interpreter = NULL;
2334 PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
2335 if (!main_interpreter) {
2336 main_interpreter = current_interpreter;
2337 } else if (unlikely(main_interpreter != current_interpreter))
2338 #endif
2339 {
2340 PyErr_SetString(
2341 PyExc_ImportError,
2342 "Interpreter change detected - this module can only be loaded into one interpreter per process.");
2343 return -1;
2344 }
2345 return 0;
2346 }
2347 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) {
2348 PyObject *value = PyObject_GetAttrString(spec, from_name);
2349 int result = 0;
2350 if (likely(value)) {
2351 if (allow_none || value != Py_None) {
2352 result = PyDict_SetItemString(moddict, to_name, value);
2353 }
2354 Py_DECREF(value);
2355 } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
2356 PyErr_Clear();
2357 } else {
2358 result = -1;
2359 }
2360 return result;
2361 }
2362 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
2363 PyObject *module = NULL, *moddict, *modname;
2364 if (__Pyx_check_single_interpreter())
2365 return NULL;
2366 if (__pyx_m)
2367 return __Pyx_NewRef(__pyx_m);
2368 modname = PyObject_GetAttrString(spec, "name");
2369 if (unlikely(!modname)) goto bad;
2370 module = PyModule_NewObject(modname);
2371 Py_DECREF(modname);
2372 if (unlikely(!module)) goto bad;
2373 moddict = PyModule_GetDict(module);
2374 if (unlikely(!moddict)) goto bad;
2375 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
2376 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
2377 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
2378 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
2379 return module;
2380 bad:
2381 Py_XDECREF(module);
2382 return NULL;
2383 }
2384
2385
2386 static CYTHON_SMALL_CODE int __pyx_pymod_exec_bgzf(PyObject *__pyx_pyinit_module)
2387 #endif
2388 #endif
2389 {
2390 PyObject *__pyx_t_1 = NULL;
2391 int __pyx_lineno = 0;
2392 const char *__pyx_filename = NULL;
2393 int __pyx_clineno = 0;
2394 __Pyx_RefNannyDeclarations
2395 #if CYTHON_PEP489_MULTI_PHASE_INIT
2396 if (__pyx_m) {
2397 if (__pyx_m == __pyx_pyinit_module) return 0;
2398 PyErr_SetString(PyExc_RuntimeError, "Module 'bgzf' has already been imported. Re-initialisation is not supported.");
2399 return -1;
2400 }
2401 #elif PY_MAJOR_VERSION >= 3
2402 if (__pyx_m) return __Pyx_NewRef(__pyx_m);
2403 #endif
2404 #if CYTHON_REFNANNY
2405 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
2406 if (!__Pyx_RefNanny) {
2407 PyErr_Clear();
2408 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
2409 if (!__Pyx_RefNanny)
2410 Py_FatalError("failed to import 'refnanny' module");
2411 }
2412 #endif
2413 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_bgzf(void)", 0);
2414 if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2415 #ifdef __Pxy_PyFrame_Initialize_Offsets
2416 __Pxy_PyFrame_Initialize_Offsets();
2417 #endif
2418 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
2419 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
2420 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
2421 #ifdef __Pyx_CyFunction_USED
2422 if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2423 #endif
2424 #ifdef __Pyx_FusedFunction_USED
2425 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2426 #endif
2427 #ifdef __Pyx_Coroutine_USED
2428 if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2429 #endif
2430 #ifdef __Pyx_Generator_USED
2431 if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2432 #endif
2433 #ifdef __Pyx_AsyncGen_USED
2434 if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2435 #endif
2436 #ifdef __Pyx_StopAsyncIteration_USED
2437 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2438 #endif
2439 /*--- Library function declarations ---*/
2440 /*--- Threads initialization code ---*/
2441 #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
2442 PyEval_InitThreads();
2443 #endif
2444 /*--- Module creation code ---*/
2445 #if CYTHON_PEP489_MULTI_PHASE_INIT
2446 __pyx_m = __pyx_pyinit_module;
2447 Py_INCREF(__pyx_m);
2448 #else
2449 #if PY_MAJOR_VERSION < 3
2450 __pyx_m = Py_InitModule4("bgzf", __pyx_methods, __pyx_k_Seekable_access_to_BGZ_files_ba, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
2451 #else
2452 __pyx_m = PyModule_Create(&__pyx_moduledef);
2453 #endif
2454 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
2455 #endif
2456 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
2457 Py_INCREF(__pyx_d);
2458 __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
2459 Py_INCREF(__pyx_b);
2460 __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
2461 Py_INCREF(__pyx_cython_runtime);
2462 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
2463 /*--- Initialize various global constants etc. ---*/
2464 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2465 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
2466 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2467 #endif
2468 if (__pyx_module_is_main_bx__misc__bgzf) {
2469 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2470 }
2471 #if PY_MAJOR_VERSION >= 3
2472 {
2473 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
2474 if (!PyDict_GetItemString(modules, "bx.misc.bgzf")) {
2475 if (unlikely(PyDict_SetItemString(modules, "bx.misc.bgzf", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
2476 }
2477 }
2478 #endif
2479 /*--- Builtin init code ---*/
2480 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2481 /*--- Constants init code ---*/
2482 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2483 /*--- Global type/function init code ---*/
2484 (void)__Pyx_modinit_global_init_code();
2485 (void)__Pyx_modinit_variable_export_code();
2486 (void)__Pyx_modinit_function_export_code();
2487 if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
2488 (void)__Pyx_modinit_type_import_code();
2489 (void)__Pyx_modinit_variable_import_code();
2490 (void)__Pyx_modinit_function_import_code();
2491 /*--- Execution code ---*/
2492 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
2493 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2494 #endif
2495
2496 /* "bx/misc/bgzf.pyx":1
2497 * """ # <<<<<<<<<<<<<<
2498 * Seekable access to BGZ files based on samtools code. Does not yet implement
2499 * complete file-like interface.
2500 */
2501 __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
2502 __Pyx_GOTREF(__pyx_t_1);
2503 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2504 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2505
2506 /*--- Wrapped vars code ---*/
2507
2508 goto __pyx_L0;
2509 __pyx_L1_error:;
2510 __Pyx_XDECREF(__pyx_t_1);
2511 if (__pyx_m) {
2512 if (__pyx_d) {
2513 __Pyx_AddTraceback("init bx.misc.bgzf", __pyx_clineno, __pyx_lineno, __pyx_filename);
2514 }
2515 Py_CLEAR(__pyx_m);
2516 } else if (!PyErr_Occurred()) {
2517 PyErr_SetString(PyExc_ImportError, "init bx.misc.bgzf");
2518 }
2519 __pyx_L0:;
2520 __Pyx_RefNannyFinishContext();
2521 #if CYTHON_PEP489_MULTI_PHASE_INIT
2522 return (__pyx_m != NULL) ? 0 : -1;
2523 #elif PY_MAJOR_VERSION >= 3
2524 return __pyx_m;
2525 #else
2526 return;
2527 #endif
2528 }
2529
2530 /* --- Runtime support code --- */
2531 /* Refnanny */
2532 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)2533 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
2534 PyObject *m = NULL, *p = NULL;
2535 void *r = NULL;
2536 m = PyImport_ImportModule(modname);
2537 if (!m) goto end;
2538 p = PyObject_GetAttrString(m, "RefNannyAPI");
2539 if (!p) goto end;
2540 r = PyLong_AsVoidPtr(p);
2541 end:
2542 Py_XDECREF(p);
2543 Py_XDECREF(m);
2544 return (__Pyx_RefNannyAPIStruct *)r;
2545 }
2546 #endif
2547
2548 /* PyObjectGetAttrStr */
2549 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)2550 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
2551 PyTypeObject* tp = Py_TYPE(obj);
2552 if (likely(tp->tp_getattro))
2553 return tp->tp_getattro(obj, attr_name);
2554 #if PY_MAJOR_VERSION < 3
2555 if (likely(tp->tp_getattr))
2556 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
2557 #endif
2558 return PyObject_GetAttr(obj, attr_name);
2559 }
2560 #endif
2561
2562 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)2563 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
2564 PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
2565 if (unlikely(!result)) {
2566 PyErr_Format(PyExc_NameError,
2567 #if PY_MAJOR_VERSION >= 3
2568 "name '%U' is not defined", name);
2569 #else
2570 "name '%.200s' is not defined", PyString_AS_STRING(name));
2571 #endif
2572 }
2573 return result;
2574 }
2575
2576 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)2577 static void __Pyx_RaiseDoubleKeywordsError(
2578 const char* func_name,
2579 PyObject* kw_name)
2580 {
2581 PyErr_Format(PyExc_TypeError,
2582 #if PY_MAJOR_VERSION >= 3
2583 "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
2584 #else
2585 "%s() got multiple values for keyword argument '%s'", func_name,
2586 PyString_AsString(kw_name));
2587 #endif
2588 }
2589
2590 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)2591 static int __Pyx_ParseOptionalKeywords(
2592 PyObject *kwds,
2593 PyObject **argnames[],
2594 PyObject *kwds2,
2595 PyObject *values[],
2596 Py_ssize_t num_pos_args,
2597 const char* function_name)
2598 {
2599 PyObject *key = 0, *value = 0;
2600 Py_ssize_t pos = 0;
2601 PyObject*** name;
2602 PyObject*** first_kw_arg = argnames + num_pos_args;
2603 while (PyDict_Next(kwds, &pos, &key, &value)) {
2604 name = first_kw_arg;
2605 while (*name && (**name != key)) name++;
2606 if (*name) {
2607 values[name-argnames] = value;
2608 continue;
2609 }
2610 name = first_kw_arg;
2611 #if PY_MAJOR_VERSION < 3
2612 if (likely(PyString_Check(key))) {
2613 while (*name) {
2614 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
2615 && _PyString_Eq(**name, key)) {
2616 values[name-argnames] = value;
2617 break;
2618 }
2619 name++;
2620 }
2621 if (*name) continue;
2622 else {
2623 PyObject*** argname = argnames;
2624 while (argname != first_kw_arg) {
2625 if ((**argname == key) || (
2626 (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
2627 && _PyString_Eq(**argname, key))) {
2628 goto arg_passed_twice;
2629 }
2630 argname++;
2631 }
2632 }
2633 } else
2634 #endif
2635 if (likely(PyUnicode_Check(key))) {
2636 while (*name) {
2637 int cmp = (**name == key) ? 0 :
2638 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2639 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
2640 #endif
2641 PyUnicode_Compare(**name, key);
2642 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
2643 if (cmp == 0) {
2644 values[name-argnames] = value;
2645 break;
2646 }
2647 name++;
2648 }
2649 if (*name) continue;
2650 else {
2651 PyObject*** argname = argnames;
2652 while (argname != first_kw_arg) {
2653 int cmp = (**argname == key) ? 0 :
2654 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2655 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
2656 #endif
2657 PyUnicode_Compare(**argname, key);
2658 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
2659 if (cmp == 0) goto arg_passed_twice;
2660 argname++;
2661 }
2662 }
2663 } else
2664 goto invalid_keyword_type;
2665 if (kwds2) {
2666 if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
2667 } else {
2668 goto invalid_keyword;
2669 }
2670 }
2671 return 0;
2672 arg_passed_twice:
2673 __Pyx_RaiseDoubleKeywordsError(function_name, key);
2674 goto bad;
2675 invalid_keyword_type:
2676 PyErr_Format(PyExc_TypeError,
2677 "%.200s() keywords must be strings", function_name);
2678 goto bad;
2679 invalid_keyword:
2680 PyErr_Format(PyExc_TypeError,
2681 #if PY_MAJOR_VERSION < 3
2682 "%.200s() got an unexpected keyword argument '%.200s'",
2683 function_name, PyString_AsString(key));
2684 #else
2685 "%s() got an unexpected keyword argument '%U'",
2686 function_name, key);
2687 #endif
2688 bad:
2689 return -1;
2690 }
2691
2692 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)2693 static void __Pyx_RaiseArgtupleInvalid(
2694 const char* func_name,
2695 int exact,
2696 Py_ssize_t num_min,
2697 Py_ssize_t num_max,
2698 Py_ssize_t num_found)
2699 {
2700 Py_ssize_t num_expected;
2701 const char *more_or_less;
2702 if (num_found < num_min) {
2703 num_expected = num_min;
2704 more_or_less = "at least";
2705 } else {
2706 num_expected = num_max;
2707 more_or_less = "at most";
2708 }
2709 if (exact) {
2710 more_or_less = "exactly";
2711 }
2712 PyErr_Format(PyExc_TypeError,
2713 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
2714 func_name, more_or_less, num_expected,
2715 (num_expected == 1) ? "" : "s", num_found);
2716 }
2717
2718 /* PyFunctionFastCall */
2719 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)2720 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
2721 PyObject *globals) {
2722 PyFrameObject *f;
2723 PyThreadState *tstate = __Pyx_PyThreadState_Current;
2724 PyObject **fastlocals;
2725 Py_ssize_t i;
2726 PyObject *result;
2727 assert(globals != NULL);
2728 /* XXX Perhaps we should create a specialized
2729 PyFrame_New() that doesn't take locals, but does
2730 take builtins without sanity checking them.
2731 */
2732 assert(tstate != NULL);
2733 f = PyFrame_New(tstate, co, globals, NULL);
2734 if (f == NULL) {
2735 return NULL;
2736 }
2737 fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
2738 for (i = 0; i < na; i++) {
2739 Py_INCREF(*args);
2740 fastlocals[i] = *args++;
2741 }
2742 result = PyEval_EvalFrameEx(f,0);
2743 ++tstate->recursion_depth;
2744 Py_DECREF(f);
2745 --tstate->recursion_depth;
2746 return result;
2747 }
2748 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)2749 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
2750 PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
2751 PyObject *globals = PyFunction_GET_GLOBALS(func);
2752 PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
2753 PyObject *closure;
2754 #if PY_MAJOR_VERSION >= 3
2755 PyObject *kwdefs;
2756 #endif
2757 PyObject *kwtuple, **k;
2758 PyObject **d;
2759 Py_ssize_t nd;
2760 Py_ssize_t nk;
2761 PyObject *result;
2762 assert(kwargs == NULL || PyDict_Check(kwargs));
2763 nk = kwargs ? PyDict_Size(kwargs) : 0;
2764 if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
2765 return NULL;
2766 }
2767 if (
2768 #if PY_MAJOR_VERSION >= 3
2769 co->co_kwonlyargcount == 0 &&
2770 #endif
2771 likely(kwargs == NULL || nk == 0) &&
2772 co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
2773 if (argdefs == NULL && co->co_argcount == nargs) {
2774 result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
2775 goto done;
2776 }
2777 else if (nargs == 0 && argdefs != NULL
2778 && co->co_argcount == Py_SIZE(argdefs)) {
2779 /* function called with no arguments, but all parameters have
2780 a default value: use default values as arguments .*/
2781 args = &PyTuple_GET_ITEM(argdefs, 0);
2782 result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
2783 goto done;
2784 }
2785 }
2786 if (kwargs != NULL) {
2787 Py_ssize_t pos, i;
2788 kwtuple = PyTuple_New(2 * nk);
2789 if (kwtuple == NULL) {
2790 result = NULL;
2791 goto done;
2792 }
2793 k = &PyTuple_GET_ITEM(kwtuple, 0);
2794 pos = i = 0;
2795 while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
2796 Py_INCREF(k[i]);
2797 Py_INCREF(k[i+1]);
2798 i += 2;
2799 }
2800 nk = i / 2;
2801 }
2802 else {
2803 kwtuple = NULL;
2804 k = NULL;
2805 }
2806 closure = PyFunction_GET_CLOSURE(func);
2807 #if PY_MAJOR_VERSION >= 3
2808 kwdefs = PyFunction_GET_KW_DEFAULTS(func);
2809 #endif
2810 if (argdefs != NULL) {
2811 d = &PyTuple_GET_ITEM(argdefs, 0);
2812 nd = Py_SIZE(argdefs);
2813 }
2814 else {
2815 d = NULL;
2816 nd = 0;
2817 }
2818 #if PY_MAJOR_VERSION >= 3
2819 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
2820 args, (int)nargs,
2821 k, (int)nk,
2822 d, (int)nd, kwdefs, closure);
2823 #else
2824 result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
2825 args, (int)nargs,
2826 k, (int)nk,
2827 d, (int)nd, closure);
2828 #endif
2829 Py_XDECREF(kwtuple);
2830 done:
2831 Py_LeaveRecursiveCall();
2832 return result;
2833 }
2834 #endif
2835 #endif
2836
2837 /* PyObjectCall */
2838 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)2839 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
2840 PyObject *result;
2841 ternaryfunc call = Py_TYPE(func)->tp_call;
2842 if (unlikely(!call))
2843 return PyObject_Call(func, arg, kw);
2844 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
2845 return NULL;
2846 result = (*call)(func, arg, kw);
2847 Py_LeaveRecursiveCall();
2848 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
2849 PyErr_SetString(
2850 PyExc_SystemError,
2851 "NULL result without error in PyObject_Call");
2852 }
2853 return result;
2854 }
2855 #endif
2856
2857 /* PyObjectCallMethO */
2858 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)2859 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
2860 PyObject *self, *result;
2861 PyCFunction cfunc;
2862 cfunc = PyCFunction_GET_FUNCTION(func);
2863 self = PyCFunction_GET_SELF(func);
2864 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
2865 return NULL;
2866 result = cfunc(self, arg);
2867 Py_LeaveRecursiveCall();
2868 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
2869 PyErr_SetString(
2870 PyExc_SystemError,
2871 "NULL result without error in PyObject_Call");
2872 }
2873 return result;
2874 }
2875 #endif
2876
2877 /* PyObjectCallNoArg */
2878 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallNoArg(PyObject * func)2879 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
2880 #if CYTHON_FAST_PYCALL
2881 if (PyFunction_Check(func)) {
2882 return __Pyx_PyFunction_FastCall(func, NULL, 0);
2883 }
2884 #endif
2885 #ifdef __Pyx_CyFunction_USED
2886 if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
2887 #else
2888 if (likely(PyCFunction_Check(func)))
2889 #endif
2890 {
2891 if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
2892 return __Pyx_PyObject_CallMethO(func, NULL);
2893 }
2894 }
2895 return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
2896 }
2897 #endif
2898
2899 /* PyCFunctionFastCall */
2900 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)2901 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
2902 PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
2903 PyCFunction meth = PyCFunction_GET_FUNCTION(func);
2904 PyObject *self = PyCFunction_GET_SELF(func);
2905 int flags = PyCFunction_GET_FLAGS(func);
2906 assert(PyCFunction_Check(func));
2907 assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
2908 assert(nargs >= 0);
2909 assert(nargs == 0 || args != NULL);
2910 /* _PyCFunction_FastCallDict() must not be called with an exception set,
2911 because it may clear it (directly or indirectly) and so the
2912 caller loses its exception */
2913 assert(!PyErr_Occurred());
2914 if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
2915 return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
2916 } else {
2917 return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
2918 }
2919 }
2920 #endif
2921
2922 /* PyObjectCallOneArg */
2923 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)2924 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2925 PyObject *result;
2926 PyObject *args = PyTuple_New(1);
2927 if (unlikely(!args)) return NULL;
2928 Py_INCREF(arg);
2929 PyTuple_SET_ITEM(args, 0, arg);
2930 result = __Pyx_PyObject_Call(func, args, NULL);
2931 Py_DECREF(args);
2932 return result;
2933 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)2934 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2935 #if CYTHON_FAST_PYCALL
2936 if (PyFunction_Check(func)) {
2937 return __Pyx_PyFunction_FastCall(func, &arg, 1);
2938 }
2939 #endif
2940 if (likely(PyCFunction_Check(func))) {
2941 if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
2942 return __Pyx_PyObject_CallMethO(func, arg);
2943 #if CYTHON_FAST_PYCCALL
2944 } else if (__Pyx_PyFastCFunction_Check(func)) {
2945 return __Pyx_PyCFunction_FastCall(func, &arg, 1);
2946 #endif
2947 }
2948 }
2949 return __Pyx__PyObject_CallOneArg(func, arg);
2950 }
2951 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)2952 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2953 PyObject *result;
2954 PyObject *args = PyTuple_Pack(1, arg);
2955 if (unlikely(!args)) return NULL;
2956 result = __Pyx_PyObject_Call(func, args, NULL);
2957 Py_DECREF(args);
2958 return result;
2959 }
2960 #endif
2961
2962 /* PyErrFetchRestore */
2963 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)2964 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
2965 PyObject *tmp_type, *tmp_value, *tmp_tb;
2966 tmp_type = tstate->curexc_type;
2967 tmp_value = tstate->curexc_value;
2968 tmp_tb = tstate->curexc_traceback;
2969 tstate->curexc_type = type;
2970 tstate->curexc_value = value;
2971 tstate->curexc_traceback = tb;
2972 Py_XDECREF(tmp_type);
2973 Py_XDECREF(tmp_value);
2974 Py_XDECREF(tmp_tb);
2975 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)2976 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
2977 *type = tstate->curexc_type;
2978 *value = tstate->curexc_value;
2979 *tb = tstate->curexc_traceback;
2980 tstate->curexc_type = 0;
2981 tstate->curexc_value = 0;
2982 tstate->curexc_traceback = 0;
2983 }
2984 #endif
2985
2986 /* RaiseException */
2987 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)2988 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
2989 CYTHON_UNUSED PyObject *cause) {
2990 __Pyx_PyThreadState_declare
2991 Py_XINCREF(type);
2992 if (!value || value == Py_None)
2993 value = NULL;
2994 else
2995 Py_INCREF(value);
2996 if (!tb || tb == Py_None)
2997 tb = NULL;
2998 else {
2999 Py_INCREF(tb);
3000 if (!PyTraceBack_Check(tb)) {
3001 PyErr_SetString(PyExc_TypeError,
3002 "raise: arg 3 must be a traceback or None");
3003 goto raise_error;
3004 }
3005 }
3006 if (PyType_Check(type)) {
3007 #if CYTHON_COMPILING_IN_PYPY
3008 if (!value) {
3009 Py_INCREF(Py_None);
3010 value = Py_None;
3011 }
3012 #endif
3013 PyErr_NormalizeException(&type, &value, &tb);
3014 } else {
3015 if (value) {
3016 PyErr_SetString(PyExc_TypeError,
3017 "instance exception may not have a separate value");
3018 goto raise_error;
3019 }
3020 value = type;
3021 type = (PyObject*) Py_TYPE(type);
3022 Py_INCREF(type);
3023 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
3024 PyErr_SetString(PyExc_TypeError,
3025 "raise: exception class must be a subclass of BaseException");
3026 goto raise_error;
3027 }
3028 }
3029 __Pyx_PyThreadState_assign
3030 __Pyx_ErrRestore(type, value, tb);
3031 return;
3032 raise_error:
3033 Py_XDECREF(value);
3034 Py_XDECREF(type);
3035 Py_XDECREF(tb);
3036 return;
3037 }
3038 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)3039 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
3040 PyObject* owned_instance = NULL;
3041 if (tb == Py_None) {
3042 tb = 0;
3043 } else if (tb && !PyTraceBack_Check(tb)) {
3044 PyErr_SetString(PyExc_TypeError,
3045 "raise: arg 3 must be a traceback or None");
3046 goto bad;
3047 }
3048 if (value == Py_None)
3049 value = 0;
3050 if (PyExceptionInstance_Check(type)) {
3051 if (value) {
3052 PyErr_SetString(PyExc_TypeError,
3053 "instance exception may not have a separate value");
3054 goto bad;
3055 }
3056 value = type;
3057 type = (PyObject*) Py_TYPE(value);
3058 } else if (PyExceptionClass_Check(type)) {
3059 PyObject *instance_class = NULL;
3060 if (value && PyExceptionInstance_Check(value)) {
3061 instance_class = (PyObject*) Py_TYPE(value);
3062 if (instance_class != type) {
3063 int is_subclass = PyObject_IsSubclass(instance_class, type);
3064 if (!is_subclass) {
3065 instance_class = NULL;
3066 } else if (unlikely(is_subclass == -1)) {
3067 goto bad;
3068 } else {
3069 type = instance_class;
3070 }
3071 }
3072 }
3073 if (!instance_class) {
3074 PyObject *args;
3075 if (!value)
3076 args = PyTuple_New(0);
3077 else if (PyTuple_Check(value)) {
3078 Py_INCREF(value);
3079 args = value;
3080 } else
3081 args = PyTuple_Pack(1, value);
3082 if (!args)
3083 goto bad;
3084 owned_instance = PyObject_Call(type, args, NULL);
3085 Py_DECREF(args);
3086 if (!owned_instance)
3087 goto bad;
3088 value = owned_instance;
3089 if (!PyExceptionInstance_Check(value)) {
3090 PyErr_Format(PyExc_TypeError,
3091 "calling %R should have returned an instance of "
3092 "BaseException, not %R",
3093 type, Py_TYPE(value));
3094 goto bad;
3095 }
3096 }
3097 } else {
3098 PyErr_SetString(PyExc_TypeError,
3099 "raise: exception class must be a subclass of BaseException");
3100 goto bad;
3101 }
3102 if (cause) {
3103 PyObject *fixed_cause;
3104 if (cause == Py_None) {
3105 fixed_cause = NULL;
3106 } else if (PyExceptionClass_Check(cause)) {
3107 fixed_cause = PyObject_CallObject(cause, NULL);
3108 if (fixed_cause == NULL)
3109 goto bad;
3110 } else if (PyExceptionInstance_Check(cause)) {
3111 fixed_cause = cause;
3112 Py_INCREF(fixed_cause);
3113 } else {
3114 PyErr_SetString(PyExc_TypeError,
3115 "exception causes must derive from "
3116 "BaseException");
3117 goto bad;
3118 }
3119 PyException_SetCause(value, fixed_cause);
3120 }
3121 PyErr_SetObject(type, value);
3122 if (tb) {
3123 #if CYTHON_COMPILING_IN_PYPY
3124 PyObject *tmp_type, *tmp_value, *tmp_tb;
3125 PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
3126 Py_INCREF(tb);
3127 PyErr_Restore(tmp_type, tmp_value, tb);
3128 Py_XDECREF(tmp_tb);
3129 #else
3130 PyThreadState *tstate = __Pyx_PyThreadState_Current;
3131 PyObject* tmp_tb = tstate->curexc_traceback;
3132 if (tb != tmp_tb) {
3133 Py_INCREF(tb);
3134 tstate->curexc_traceback = tb;
3135 Py_XDECREF(tmp_tb);
3136 }
3137 #endif
3138 }
3139 bad:
3140 Py_XDECREF(owned_instance);
3141 return;
3142 }
3143 #endif
3144
3145 /* PyObject_GenericGetAttrNoDict */
3146 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_RaiseGenericGetAttributeError(PyTypeObject * tp,PyObject * attr_name)3147 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
3148 PyErr_Format(PyExc_AttributeError,
3149 #if PY_MAJOR_VERSION >= 3
3150 "'%.50s' object has no attribute '%U'",
3151 tp->tp_name, attr_name);
3152 #else
3153 "'%.50s' object has no attribute '%.400s'",
3154 tp->tp_name, PyString_AS_STRING(attr_name));
3155 #endif
3156 return NULL;
3157 }
__Pyx_PyObject_GenericGetAttrNoDict(PyObject * obj,PyObject * attr_name)3158 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
3159 PyObject *descr;
3160 PyTypeObject *tp = Py_TYPE(obj);
3161 if (unlikely(!PyString_Check(attr_name))) {
3162 return PyObject_GenericGetAttr(obj, attr_name);
3163 }
3164 assert(!tp->tp_dictoffset);
3165 descr = _PyType_Lookup(tp, attr_name);
3166 if (unlikely(!descr)) {
3167 return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
3168 }
3169 Py_INCREF(descr);
3170 #if PY_MAJOR_VERSION < 3
3171 if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
3172 #endif
3173 {
3174 descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
3175 if (unlikely(f)) {
3176 PyObject *res = f(descr, obj, (PyObject *)tp);
3177 Py_DECREF(descr);
3178 return res;
3179 }
3180 }
3181 return descr;
3182 }
3183 #endif
3184
3185 /* PyObject_GenericGetAttr */
3186 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_PyObject_GenericGetAttr(PyObject * obj,PyObject * attr_name)3187 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
3188 if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
3189 return PyObject_GenericGetAttr(obj, attr_name);
3190 }
3191 return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
3192 }
3193 #endif
3194
3195 /* PyErrExceptionMatches */
3196 #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)3197 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
3198 Py_ssize_t i, n;
3199 n = PyTuple_GET_SIZE(tuple);
3200 #if PY_MAJOR_VERSION >= 3
3201 for (i=0; i<n; i++) {
3202 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
3203 }
3204 #endif
3205 for (i=0; i<n; i++) {
3206 if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
3207 }
3208 return 0;
3209 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)3210 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
3211 PyObject *exc_type = tstate->curexc_type;
3212 if (exc_type == err) return 1;
3213 if (unlikely(!exc_type)) return 0;
3214 if (unlikely(PyTuple_Check(err)))
3215 return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
3216 return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
3217 }
3218 #endif
3219
3220 /* PyObjectGetAttrStrNoError */
__Pyx_PyObject_GetAttrStr_ClearAttributeError(void)3221 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
3222 __Pyx_PyThreadState_declare
3223 __Pyx_PyThreadState_assign
3224 if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
3225 __Pyx_PyErr_Clear();
3226 }
__Pyx_PyObject_GetAttrStrNoError(PyObject * obj,PyObject * attr_name)3227 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
3228 PyObject *result;
3229 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
3230 PyTypeObject* tp = Py_TYPE(obj);
3231 if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
3232 return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
3233 }
3234 #endif
3235 result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
3236 if (unlikely(!result)) {
3237 __Pyx_PyObject_GetAttrStr_ClearAttributeError();
3238 }
3239 return result;
3240 }
3241
3242 /* SetupReduce */
__Pyx_setup_reduce_is_named(PyObject * meth,PyObject * name)3243 static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
3244 int ret;
3245 PyObject *name_attr;
3246 name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
3247 if (likely(name_attr)) {
3248 ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
3249 } else {
3250 ret = -1;
3251 }
3252 if (unlikely(ret < 0)) {
3253 PyErr_Clear();
3254 ret = 0;
3255 }
3256 Py_XDECREF(name_attr);
3257 return ret;
3258 }
__Pyx_setup_reduce(PyObject * type_obj)3259 static int __Pyx_setup_reduce(PyObject* type_obj) {
3260 int ret = 0;
3261 PyObject *object_reduce = NULL;
3262 PyObject *object_reduce_ex = NULL;
3263 PyObject *reduce = NULL;
3264 PyObject *reduce_ex = NULL;
3265 PyObject *reduce_cython = NULL;
3266 PyObject *setstate = NULL;
3267 PyObject *setstate_cython = NULL;
3268 #if CYTHON_USE_PYTYPE_LOOKUP
3269 if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
3270 #else
3271 if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
3272 #endif
3273 #if CYTHON_USE_PYTYPE_LOOKUP
3274 object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
3275 #else
3276 object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
3277 #endif
3278 reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
3279 if (reduce_ex == object_reduce_ex) {
3280 #if CYTHON_USE_PYTYPE_LOOKUP
3281 object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
3282 #else
3283 object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
3284 #endif
3285 reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
3286 if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
3287 reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
3288 if (likely(reduce_cython)) {
3289 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
3290 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
3291 } else if (reduce == object_reduce || PyErr_Occurred()) {
3292 goto __PYX_BAD;
3293 }
3294 setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
3295 if (!setstate) PyErr_Clear();
3296 if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
3297 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
3298 if (likely(setstate_cython)) {
3299 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
3300 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
3301 } else if (!setstate || PyErr_Occurred()) {
3302 goto __PYX_BAD;
3303 }
3304 }
3305 PyType_Modified((PyTypeObject*)type_obj);
3306 }
3307 }
3308 goto __PYX_GOOD;
3309 __PYX_BAD:
3310 if (!PyErr_Occurred())
3311 PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
3312 ret = -1;
3313 __PYX_GOOD:
3314 #if !CYTHON_USE_PYTYPE_LOOKUP
3315 Py_XDECREF(object_reduce);
3316 Py_XDECREF(object_reduce_ex);
3317 #endif
3318 Py_XDECREF(reduce);
3319 Py_XDECREF(reduce_ex);
3320 Py_XDECREF(reduce_cython);
3321 Py_XDECREF(setstate);
3322 Py_XDECREF(setstate_cython);
3323 return ret;
3324 }
3325
3326 /* PyDictVersioning */
3327 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)3328 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
3329 PyObject *dict = Py_TYPE(obj)->tp_dict;
3330 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
3331 }
__Pyx_get_object_dict_version(PyObject * obj)3332 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
3333 PyObject **dictptr = NULL;
3334 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
3335 if (offset) {
3336 #if CYTHON_COMPILING_IN_CPYTHON
3337 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
3338 #else
3339 dictptr = _PyObject_GetDictPtr(obj);
3340 #endif
3341 }
3342 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
3343 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)3344 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
3345 PyObject *dict = Py_TYPE(obj)->tp_dict;
3346 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
3347 return 0;
3348 return obj_dict_version == __Pyx_get_object_dict_version(obj);
3349 }
3350 #endif
3351
3352 /* CLineInTraceback */
3353 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)3354 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
3355 PyObject *use_cline;
3356 PyObject *ptype, *pvalue, *ptraceback;
3357 #if CYTHON_COMPILING_IN_CPYTHON
3358 PyObject **cython_runtime_dict;
3359 #endif
3360 if (unlikely(!__pyx_cython_runtime)) {
3361 return c_line;
3362 }
3363 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
3364 #if CYTHON_COMPILING_IN_CPYTHON
3365 cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
3366 if (likely(cython_runtime_dict)) {
3367 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
3368 use_cline, *cython_runtime_dict,
3369 __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
3370 } else
3371 #endif
3372 {
3373 PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
3374 if (use_cline_obj) {
3375 use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
3376 Py_DECREF(use_cline_obj);
3377 } else {
3378 PyErr_Clear();
3379 use_cline = NULL;
3380 }
3381 }
3382 if (!use_cline) {
3383 c_line = 0;
3384 (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
3385 }
3386 else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
3387 c_line = 0;
3388 }
3389 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
3390 return c_line;
3391 }
3392 #endif
3393
3394 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)3395 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
3396 int start = 0, mid = 0, end = count - 1;
3397 if (end >= 0 && code_line > entries[end].code_line) {
3398 return count;
3399 }
3400 while (start < end) {
3401 mid = start + (end - start) / 2;
3402 if (code_line < entries[mid].code_line) {
3403 end = mid;
3404 } else if (code_line > entries[mid].code_line) {
3405 start = mid + 1;
3406 } else {
3407 return mid;
3408 }
3409 }
3410 if (code_line <= entries[mid].code_line) {
3411 return mid;
3412 } else {
3413 return mid + 1;
3414 }
3415 }
__pyx_find_code_object(int code_line)3416 static PyCodeObject *__pyx_find_code_object(int code_line) {
3417 PyCodeObject* code_object;
3418 int pos;
3419 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
3420 return NULL;
3421 }
3422 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
3423 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
3424 return NULL;
3425 }
3426 code_object = __pyx_code_cache.entries[pos].code_object;
3427 Py_INCREF(code_object);
3428 return code_object;
3429 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)3430 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
3431 int pos, i;
3432 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
3433 if (unlikely(!code_line)) {
3434 return;
3435 }
3436 if (unlikely(!entries)) {
3437 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
3438 if (likely(entries)) {
3439 __pyx_code_cache.entries = entries;
3440 __pyx_code_cache.max_count = 64;
3441 __pyx_code_cache.count = 1;
3442 entries[0].code_line = code_line;
3443 entries[0].code_object = code_object;
3444 Py_INCREF(code_object);
3445 }
3446 return;
3447 }
3448 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
3449 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
3450 PyCodeObject* tmp = entries[pos].code_object;
3451 entries[pos].code_object = code_object;
3452 Py_DECREF(tmp);
3453 return;
3454 }
3455 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
3456 int new_max = __pyx_code_cache.max_count + 64;
3457 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
3458 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
3459 if (unlikely(!entries)) {
3460 return;
3461 }
3462 __pyx_code_cache.entries = entries;
3463 __pyx_code_cache.max_count = new_max;
3464 }
3465 for (i=__pyx_code_cache.count; i>pos; i--) {
3466 entries[i] = entries[i-1];
3467 }
3468 entries[pos].code_line = code_line;
3469 entries[pos].code_object = code_object;
3470 __pyx_code_cache.count++;
3471 Py_INCREF(code_object);
3472 }
3473
3474 /* AddTraceback */
3475 #include "compile.h"
3476 #include "frameobject.h"
3477 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)3478 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
3479 const char *funcname, int c_line,
3480 int py_line, const char *filename) {
3481 PyCodeObject *py_code = NULL;
3482 PyObject *py_funcname = NULL;
3483 #if PY_MAJOR_VERSION < 3
3484 PyObject *py_srcfile = NULL;
3485 py_srcfile = PyString_FromString(filename);
3486 if (!py_srcfile) goto bad;
3487 #endif
3488 if (c_line) {
3489 #if PY_MAJOR_VERSION < 3
3490 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
3491 if (!py_funcname) goto bad;
3492 #else
3493 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
3494 if (!py_funcname) goto bad;
3495 funcname = PyUnicode_AsUTF8(py_funcname);
3496 if (!funcname) goto bad;
3497 #endif
3498 }
3499 else {
3500 #if PY_MAJOR_VERSION < 3
3501 py_funcname = PyString_FromString(funcname);
3502 if (!py_funcname) goto bad;
3503 #endif
3504 }
3505 #if PY_MAJOR_VERSION < 3
3506 py_code = __Pyx_PyCode_New(
3507 0,
3508 0,
3509 0,
3510 0,
3511 0,
3512 __pyx_empty_bytes, /*PyObject *code,*/
3513 __pyx_empty_tuple, /*PyObject *consts,*/
3514 __pyx_empty_tuple, /*PyObject *names,*/
3515 __pyx_empty_tuple, /*PyObject *varnames,*/
3516 __pyx_empty_tuple, /*PyObject *freevars,*/
3517 __pyx_empty_tuple, /*PyObject *cellvars,*/
3518 py_srcfile, /*PyObject *filename,*/
3519 py_funcname, /*PyObject *name,*/
3520 py_line,
3521 __pyx_empty_bytes /*PyObject *lnotab*/
3522 );
3523 Py_DECREF(py_srcfile);
3524 #else
3525 py_code = PyCode_NewEmpty(filename, funcname, py_line);
3526 #endif
3527 Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline
3528 return py_code;
3529 bad:
3530 Py_XDECREF(py_funcname);
3531 #if PY_MAJOR_VERSION < 3
3532 Py_XDECREF(py_srcfile);
3533 #endif
3534 return NULL;
3535 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)3536 static void __Pyx_AddTraceback(const char *funcname, int c_line,
3537 int py_line, const char *filename) {
3538 PyCodeObject *py_code = 0;
3539 PyFrameObject *py_frame = 0;
3540 PyThreadState *tstate = __Pyx_PyThreadState_Current;
3541 if (c_line) {
3542 c_line = __Pyx_CLineForTraceback(tstate, c_line);
3543 }
3544 py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
3545 if (!py_code) {
3546 py_code = __Pyx_CreateCodeObjectForTraceback(
3547 funcname, c_line, py_line, filename);
3548 if (!py_code) goto bad;
3549 __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
3550 }
3551 py_frame = PyFrame_New(
3552 tstate, /*PyThreadState *tstate,*/
3553 py_code, /*PyCodeObject *code,*/
3554 __pyx_d, /*PyObject *globals,*/
3555 0 /*PyObject *locals*/
3556 );
3557 if (!py_frame) goto bad;
3558 __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
3559 PyTraceBack_Here(py_frame);
3560 bad:
3561 Py_XDECREF(py_code);
3562 Py_XDECREF(py_frame);
3563 }
3564
3565 /* CIntFromPyVerify */
3566 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
3567 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
3568 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
3569 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
3570 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
3571 {\
3572 func_type value = func_value;\
3573 if (sizeof(target_type) < sizeof(func_type)) {\
3574 if (unlikely(value != (func_type) (target_type) value)) {\
3575 func_type zero = 0;\
3576 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
3577 return (target_type) -1;\
3578 if (is_unsigned && unlikely(value < zero))\
3579 goto raise_neg_overflow;\
3580 else\
3581 goto raise_overflow;\
3582 }\
3583 }\
3584 return (target_type) value;\
3585 }
3586
3587 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)3588 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
3589 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3590 #pragma GCC diagnostic push
3591 #pragma GCC diagnostic ignored "-Wconversion"
3592 #endif
3593 const int neg_one = (int) -1, const_zero = (int) 0;
3594 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3595 #pragma GCC diagnostic pop
3596 #endif
3597 const int is_unsigned = neg_one > const_zero;
3598 #if PY_MAJOR_VERSION < 3
3599 if (likely(PyInt_Check(x))) {
3600 if (sizeof(int) < sizeof(long)) {
3601 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
3602 } else {
3603 long val = PyInt_AS_LONG(x);
3604 if (is_unsigned && unlikely(val < 0)) {
3605 goto raise_neg_overflow;
3606 }
3607 return (int) val;
3608 }
3609 } else
3610 #endif
3611 if (likely(PyLong_Check(x))) {
3612 if (is_unsigned) {
3613 #if CYTHON_USE_PYLONG_INTERNALS
3614 const digit* digits = ((PyLongObject*)x)->ob_digit;
3615 switch (Py_SIZE(x)) {
3616 case 0: return (int) 0;
3617 case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
3618 case 2:
3619 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
3620 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3621 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3622 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
3623 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3624 }
3625 }
3626 break;
3627 case 3:
3628 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
3629 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3630 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3631 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
3632 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3633 }
3634 }
3635 break;
3636 case 4:
3637 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
3638 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3639 __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])))
3640 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
3641 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3642 }
3643 }
3644 break;
3645 }
3646 #endif
3647 #if CYTHON_COMPILING_IN_CPYTHON
3648 if (unlikely(Py_SIZE(x) < 0)) {
3649 goto raise_neg_overflow;
3650 }
3651 #else
3652 {
3653 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
3654 if (unlikely(result < 0))
3655 return (int) -1;
3656 if (unlikely(result == 1))
3657 goto raise_neg_overflow;
3658 }
3659 #endif
3660 if (sizeof(int) <= sizeof(unsigned long)) {
3661 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
3662 #ifdef HAVE_LONG_LONG
3663 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
3664 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
3665 #endif
3666 }
3667 } else {
3668 #if CYTHON_USE_PYLONG_INTERNALS
3669 const digit* digits = ((PyLongObject*)x)->ob_digit;
3670 switch (Py_SIZE(x)) {
3671 case 0: return (int) 0;
3672 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
3673 case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
3674 case -2:
3675 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
3676 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3677 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3678 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3679 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3680 }
3681 }
3682 break;
3683 case 2:
3684 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
3685 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3686 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3687 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3688 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3689 }
3690 }
3691 break;
3692 case -3:
3693 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3694 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3695 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3696 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3697 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3698 }
3699 }
3700 break;
3701 case 3:
3702 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
3703 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3704 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3705 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3706 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3707 }
3708 }
3709 break;
3710 case -4:
3711 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3712 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3713 __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])))
3714 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
3715 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3716 }
3717 }
3718 break;
3719 case 4:
3720 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
3721 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3722 __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])))
3723 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
3724 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3725 }
3726 }
3727 break;
3728 }
3729 #endif
3730 if (sizeof(int) <= sizeof(long)) {
3731 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
3732 #ifdef HAVE_LONG_LONG
3733 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
3734 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
3735 #endif
3736 }
3737 }
3738 {
3739 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
3740 PyErr_SetString(PyExc_RuntimeError,
3741 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
3742 #else
3743 int val;
3744 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
3745 #if PY_MAJOR_VERSION < 3
3746 if (likely(v) && !PyLong_Check(v)) {
3747 PyObject *tmp = v;
3748 v = PyNumber_Long(tmp);
3749 Py_DECREF(tmp);
3750 }
3751 #endif
3752 if (likely(v)) {
3753 int one = 1; int is_little = (int)*(unsigned char *)&one;
3754 unsigned char *bytes = (unsigned char *)&val;
3755 int ret = _PyLong_AsByteArray((PyLongObject *)v,
3756 bytes, sizeof(val),
3757 is_little, !is_unsigned);
3758 Py_DECREF(v);
3759 if (likely(!ret))
3760 return val;
3761 }
3762 #endif
3763 return (int) -1;
3764 }
3765 } else {
3766 int val;
3767 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
3768 if (!tmp) return (int) -1;
3769 val = __Pyx_PyInt_As_int(tmp);
3770 Py_DECREF(tmp);
3771 return val;
3772 }
3773 raise_overflow:
3774 PyErr_SetString(PyExc_OverflowError,
3775 "value too large to convert to int");
3776 return (int) -1;
3777 raise_neg_overflow:
3778 PyErr_SetString(PyExc_OverflowError,
3779 "can't convert negative value to int");
3780 return (int) -1;
3781 }
3782
3783 /* CIntFromPy */
__Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject * x)3784 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject *x) {
3785 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3786 #pragma GCC diagnostic push
3787 #pragma GCC diagnostic ignored "-Wconversion"
3788 #endif
3789 const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) -1, const_zero = (unsigned PY_LONG_LONG) 0;
3790 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3791 #pragma GCC diagnostic pop
3792 #endif
3793 const int is_unsigned = neg_one > const_zero;
3794 #if PY_MAJOR_VERSION < 3
3795 if (likely(PyInt_Check(x))) {
3796 if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) {
3797 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, PyInt_AS_LONG(x))
3798 } else {
3799 long val = PyInt_AS_LONG(x);
3800 if (is_unsigned && unlikely(val < 0)) {
3801 goto raise_neg_overflow;
3802 }
3803 return (unsigned PY_LONG_LONG) val;
3804 }
3805 } else
3806 #endif
3807 if (likely(PyLong_Check(x))) {
3808 if (is_unsigned) {
3809 #if CYTHON_USE_PYLONG_INTERNALS
3810 const digit* digits = ((PyLongObject*)x)->ob_digit;
3811 switch (Py_SIZE(x)) {
3812 case 0: return (unsigned PY_LONG_LONG) 0;
3813 case 1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, digit, digits[0])
3814 case 2:
3815 if (8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT) {
3816 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3817 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3818 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 2 * PyLong_SHIFT) {
3819 return (unsigned PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
3820 }
3821 }
3822 break;
3823 case 3:
3824 if (8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT) {
3825 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3826 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3827 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 3 * PyLong_SHIFT) {
3828 return (unsigned 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]));
3829 }
3830 }
3831 break;
3832 case 4:
3833 if (8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT) {
3834 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3835 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_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])))
3836 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 4 * PyLong_SHIFT) {
3837 return (unsigned 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]));
3838 }
3839 }
3840 break;
3841 }
3842 #endif
3843 #if CYTHON_COMPILING_IN_CPYTHON
3844 if (unlikely(Py_SIZE(x) < 0)) {
3845 goto raise_neg_overflow;
3846 }
3847 #else
3848 {
3849 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
3850 if (unlikely(result < 0))
3851 return (unsigned PY_LONG_LONG) -1;
3852 if (unlikely(result == 1))
3853 goto raise_neg_overflow;
3854 }
3855 #endif
3856 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) {
3857 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned long, PyLong_AsUnsignedLong(x))
3858 #ifdef HAVE_LONG_LONG
3859 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
3860 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
3861 #endif
3862 }
3863 } else {
3864 #if CYTHON_USE_PYLONG_INTERNALS
3865 const digit* digits = ((PyLongObject*)x)->ob_digit;
3866 switch (Py_SIZE(x)) {
3867 case 0: return (unsigned PY_LONG_LONG) 0;
3868 case -1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, sdigit, (sdigit) (-(sdigit)digits[0]))
3869 case 1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, digit, +digits[0])
3870 case -2:
3871 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 1 * PyLong_SHIFT) {
3872 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3873 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3874 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
3875 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
3876 }
3877 }
3878 break;
3879 case 2:
3880 if (8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT) {
3881 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3882 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3883 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
3884 return (unsigned PY_LONG_LONG) ((((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
3885 }
3886 }
3887 break;
3888 case -3:
3889 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
3890 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3891 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3892 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
3893 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
3894 }
3895 }
3896 break;
3897 case 3:
3898 if (8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT) {
3899 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3900 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3901 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
3902 return (unsigned 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])));
3903 }
3904 }
3905 break;
3906 case -4:
3907 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
3908 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3909 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_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])))
3910 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
3911 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((((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])));
3912 }
3913 }
3914 break;
3915 case 4:
3916 if (8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT) {
3917 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3918 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_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])))
3919 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
3920 return (unsigned 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])));
3921 }
3922 }
3923 break;
3924 }
3925 #endif
3926 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) {
3927 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, long, PyLong_AsLong(x))
3928 #ifdef HAVE_LONG_LONG
3929 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
3930 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, PY_LONG_LONG, PyLong_AsLongLong(x))
3931 #endif
3932 }
3933 }
3934 {
3935 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
3936 PyErr_SetString(PyExc_RuntimeError,
3937 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
3938 #else
3939 unsigned PY_LONG_LONG val;
3940 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
3941 #if PY_MAJOR_VERSION < 3
3942 if (likely(v) && !PyLong_Check(v)) {
3943 PyObject *tmp = v;
3944 v = PyNumber_Long(tmp);
3945 Py_DECREF(tmp);
3946 }
3947 #endif
3948 if (likely(v)) {
3949 int one = 1; int is_little = (int)*(unsigned char *)&one;
3950 unsigned char *bytes = (unsigned char *)&val;
3951 int ret = _PyLong_AsByteArray((PyLongObject *)v,
3952 bytes, sizeof(val),
3953 is_little, !is_unsigned);
3954 Py_DECREF(v);
3955 if (likely(!ret))
3956 return val;
3957 }
3958 #endif
3959 return (unsigned PY_LONG_LONG) -1;
3960 }
3961 } else {
3962 unsigned PY_LONG_LONG val;
3963 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
3964 if (!tmp) return (unsigned PY_LONG_LONG) -1;
3965 val = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(tmp);
3966 Py_DECREF(tmp);
3967 return val;
3968 }
3969 raise_overflow:
3970 PyErr_SetString(PyExc_OverflowError,
3971 "value too large to convert to unsigned PY_LONG_LONG");
3972 return (unsigned PY_LONG_LONG) -1;
3973 raise_neg_overflow:
3974 PyErr_SetString(PyExc_OverflowError,
3975 "can't convert negative value to unsigned PY_LONG_LONG");
3976 return (unsigned PY_LONG_LONG) -1;
3977 }
3978
3979 /* CIntToPy */
__Pyx_PyInt_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value)3980 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value) {
3981 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3982 #pragma GCC diagnostic push
3983 #pragma GCC diagnostic ignored "-Wconversion"
3984 #endif
3985 const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) -1, const_zero = (unsigned PY_LONG_LONG) 0;
3986 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3987 #pragma GCC diagnostic pop
3988 #endif
3989 const int is_unsigned = neg_one > const_zero;
3990 if (is_unsigned) {
3991 if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) {
3992 return PyInt_FromLong((long) value);
3993 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) {
3994 return PyLong_FromUnsignedLong((unsigned long) value);
3995 #ifdef HAVE_LONG_LONG
3996 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
3997 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
3998 #endif
3999 }
4000 } else {
4001 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) {
4002 return PyInt_FromLong((long) value);
4003 #ifdef HAVE_LONG_LONG
4004 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
4005 return PyLong_FromLongLong((PY_LONG_LONG) value);
4006 #endif
4007 }
4008 }
4009 {
4010 int one = 1; int little = (int)*(unsigned char *)&one;
4011 unsigned char *bytes = (unsigned char *)&value;
4012 return _PyLong_FromByteArray(bytes, sizeof(unsigned PY_LONG_LONG),
4013 little, !is_unsigned);
4014 }
4015 }
4016
4017 /* CIntToPy */
__Pyx_PyInt_From_long(long value)4018 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
4019 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4020 #pragma GCC diagnostic push
4021 #pragma GCC diagnostic ignored "-Wconversion"
4022 #endif
4023 const long neg_one = (long) -1, const_zero = (long) 0;
4024 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4025 #pragma GCC diagnostic pop
4026 #endif
4027 const int is_unsigned = neg_one > const_zero;
4028 if (is_unsigned) {
4029 if (sizeof(long) < sizeof(long)) {
4030 return PyInt_FromLong((long) value);
4031 } else if (sizeof(long) <= sizeof(unsigned long)) {
4032 return PyLong_FromUnsignedLong((unsigned long) value);
4033 #ifdef HAVE_LONG_LONG
4034 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
4035 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
4036 #endif
4037 }
4038 } else {
4039 if (sizeof(long) <= sizeof(long)) {
4040 return PyInt_FromLong((long) value);
4041 #ifdef HAVE_LONG_LONG
4042 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
4043 return PyLong_FromLongLong((PY_LONG_LONG) value);
4044 #endif
4045 }
4046 }
4047 {
4048 int one = 1; int little = (int)*(unsigned char *)&one;
4049 unsigned char *bytes = (unsigned char *)&value;
4050 return _PyLong_FromByteArray(bytes, sizeof(long),
4051 little, !is_unsigned);
4052 }
4053 }
4054
4055 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)4056 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
4057 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4058 #pragma GCC diagnostic push
4059 #pragma GCC diagnostic ignored "-Wconversion"
4060 #endif
4061 const long neg_one = (long) -1, const_zero = (long) 0;
4062 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4063 #pragma GCC diagnostic pop
4064 #endif
4065 const int is_unsigned = neg_one > const_zero;
4066 #if PY_MAJOR_VERSION < 3
4067 if (likely(PyInt_Check(x))) {
4068 if (sizeof(long) < sizeof(long)) {
4069 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
4070 } else {
4071 long val = PyInt_AS_LONG(x);
4072 if (is_unsigned && unlikely(val < 0)) {
4073 goto raise_neg_overflow;
4074 }
4075 return (long) val;
4076 }
4077 } else
4078 #endif
4079 if (likely(PyLong_Check(x))) {
4080 if (is_unsigned) {
4081 #if CYTHON_USE_PYLONG_INTERNALS
4082 const digit* digits = ((PyLongObject*)x)->ob_digit;
4083 switch (Py_SIZE(x)) {
4084 case 0: return (long) 0;
4085 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
4086 case 2:
4087 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
4088 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4089 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4090 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
4091 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
4092 }
4093 }
4094 break;
4095 case 3:
4096 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
4097 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4098 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4099 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
4100 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
4101 }
4102 }
4103 break;
4104 case 4:
4105 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
4106 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4107 __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])))
4108 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
4109 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
4110 }
4111 }
4112 break;
4113 }
4114 #endif
4115 #if CYTHON_COMPILING_IN_CPYTHON
4116 if (unlikely(Py_SIZE(x) < 0)) {
4117 goto raise_neg_overflow;
4118 }
4119 #else
4120 {
4121 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
4122 if (unlikely(result < 0))
4123 return (long) -1;
4124 if (unlikely(result == 1))
4125 goto raise_neg_overflow;
4126 }
4127 #endif
4128 if (sizeof(long) <= sizeof(unsigned long)) {
4129 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
4130 #ifdef HAVE_LONG_LONG
4131 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
4132 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
4133 #endif
4134 }
4135 } else {
4136 #if CYTHON_USE_PYLONG_INTERNALS
4137 const digit* digits = ((PyLongObject*)x)->ob_digit;
4138 switch (Py_SIZE(x)) {
4139 case 0: return (long) 0;
4140 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
4141 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
4142 case -2:
4143 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
4144 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4145 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4146 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
4147 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4148 }
4149 }
4150 break;
4151 case 2:
4152 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
4153 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4154 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4155 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
4156 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4157 }
4158 }
4159 break;
4160 case -3:
4161 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
4162 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4163 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4164 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
4165 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4166 }
4167 }
4168 break;
4169 case 3:
4170 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
4171 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4172 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4173 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
4174 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4175 }
4176 }
4177 break;
4178 case -4:
4179 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
4180 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4181 __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])))
4182 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
4183 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4184 }
4185 }
4186 break;
4187 case 4:
4188 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
4189 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4190 __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])))
4191 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
4192 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4193 }
4194 }
4195 break;
4196 }
4197 #endif
4198 if (sizeof(long) <= sizeof(long)) {
4199 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
4200 #ifdef HAVE_LONG_LONG
4201 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
4202 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
4203 #endif
4204 }
4205 }
4206 {
4207 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
4208 PyErr_SetString(PyExc_RuntimeError,
4209 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
4210 #else
4211 long val;
4212 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
4213 #if PY_MAJOR_VERSION < 3
4214 if (likely(v) && !PyLong_Check(v)) {
4215 PyObject *tmp = v;
4216 v = PyNumber_Long(tmp);
4217 Py_DECREF(tmp);
4218 }
4219 #endif
4220 if (likely(v)) {
4221 int one = 1; int is_little = (int)*(unsigned char *)&one;
4222 unsigned char *bytes = (unsigned char *)&val;
4223 int ret = _PyLong_AsByteArray((PyLongObject *)v,
4224 bytes, sizeof(val),
4225 is_little, !is_unsigned);
4226 Py_DECREF(v);
4227 if (likely(!ret))
4228 return val;
4229 }
4230 #endif
4231 return (long) -1;
4232 }
4233 } else {
4234 long val;
4235 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
4236 if (!tmp) return (long) -1;
4237 val = __Pyx_PyInt_As_long(tmp);
4238 Py_DECREF(tmp);
4239 return val;
4240 }
4241 raise_overflow:
4242 PyErr_SetString(PyExc_OverflowError,
4243 "value too large to convert to long");
4244 return (long) -1;
4245 raise_neg_overflow:
4246 PyErr_SetString(PyExc_OverflowError,
4247 "can't convert negative value to long");
4248 return (long) -1;
4249 }
4250
4251 /* FastTypeChecks */
4252 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)4253 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
4254 while (a) {
4255 a = a->tp_base;
4256 if (a == b)
4257 return 1;
4258 }
4259 return b == &PyBaseObject_Type;
4260 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)4261 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
4262 PyObject *mro;
4263 if (a == b) return 1;
4264 mro = a->tp_mro;
4265 if (likely(mro)) {
4266 Py_ssize_t i, n;
4267 n = PyTuple_GET_SIZE(mro);
4268 for (i = 0; i < n; i++) {
4269 if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
4270 return 1;
4271 }
4272 return 0;
4273 }
4274 return __Pyx_InBases(a, b);
4275 }
4276 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)4277 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
4278 PyObject *exception, *value, *tb;
4279 int res;
4280 __Pyx_PyThreadState_declare
4281 __Pyx_PyThreadState_assign
4282 __Pyx_ErrFetch(&exception, &value, &tb);
4283 res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
4284 if (unlikely(res == -1)) {
4285 PyErr_WriteUnraisable(err);
4286 res = 0;
4287 }
4288 if (!res) {
4289 res = PyObject_IsSubclass(err, exc_type2);
4290 if (unlikely(res == -1)) {
4291 PyErr_WriteUnraisable(err);
4292 res = 0;
4293 }
4294 }
4295 __Pyx_ErrRestore(exception, value, tb);
4296 return res;
4297 }
4298 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)4299 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
4300 int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
4301 if (!res) {
4302 res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
4303 }
4304 return res;
4305 }
4306 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)4307 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
4308 Py_ssize_t i, n;
4309 assert(PyExceptionClass_Check(exc_type));
4310 n = PyTuple_GET_SIZE(tuple);
4311 #if PY_MAJOR_VERSION >= 3
4312 for (i=0; i<n; i++) {
4313 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
4314 }
4315 #endif
4316 for (i=0; i<n; i++) {
4317 PyObject *t = PyTuple_GET_ITEM(tuple, i);
4318 #if PY_MAJOR_VERSION < 3
4319 if (likely(exc_type == t)) return 1;
4320 #endif
4321 if (likely(PyExceptionClass_Check(t))) {
4322 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
4323 } else {
4324 }
4325 }
4326 return 0;
4327 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)4328 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
4329 if (likely(err == exc_type)) return 1;
4330 if (likely(PyExceptionClass_Check(err))) {
4331 if (likely(PyExceptionClass_Check(exc_type))) {
4332 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
4333 } else if (likely(PyTuple_Check(exc_type))) {
4334 return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
4335 } else {
4336 }
4337 }
4338 return PyErr_GivenExceptionMatches(err, exc_type);
4339 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)4340 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
4341 assert(PyExceptionClass_Check(exc_type1));
4342 assert(PyExceptionClass_Check(exc_type2));
4343 if (likely(err == exc_type1 || err == exc_type2)) return 1;
4344 if (likely(PyExceptionClass_Check(err))) {
4345 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
4346 }
4347 return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
4348 }
4349 #endif
4350
4351 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)4352 static int __Pyx_check_binary_version(void) {
4353 char ctversion[4], rtversion[4];
4354 PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
4355 PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
4356 if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
4357 char message[200];
4358 PyOS_snprintf(message, sizeof(message),
4359 "compiletime version %s of module '%.100s' "
4360 "does not match runtime version %s",
4361 ctversion, __Pyx_MODULE_NAME, rtversion);
4362 return PyErr_WarnEx(NULL, message, 1);
4363 }
4364 return 0;
4365 }
4366
4367 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)4368 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
4369 while (t->p) {
4370 #if PY_MAJOR_VERSION < 3
4371 if (t->is_unicode) {
4372 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
4373 } else if (t->intern) {
4374 *t->p = PyString_InternFromString(t->s);
4375 } else {
4376 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
4377 }
4378 #else
4379 if (t->is_unicode | t->is_str) {
4380 if (t->intern) {
4381 *t->p = PyUnicode_InternFromString(t->s);
4382 } else if (t->encoding) {
4383 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
4384 } else {
4385 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
4386 }
4387 } else {
4388 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
4389 }
4390 #endif
4391 if (!*t->p)
4392 return -1;
4393 if (PyObject_Hash(*t->p) == -1)
4394 return -1;
4395 ++t;
4396 }
4397 return 0;
4398 }
4399
__Pyx_PyUnicode_FromString(const char * c_str)4400 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
4401 return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
4402 }
__Pyx_PyObject_AsString(PyObject * o)4403 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
4404 Py_ssize_t ignore;
4405 return __Pyx_PyObject_AsStringAndSize(o, &ignore);
4406 }
4407 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
4408 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)4409 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
4410 char* defenc_c;
4411 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
4412 if (!defenc) return NULL;
4413 defenc_c = PyBytes_AS_STRING(defenc);
4414 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
4415 {
4416 char* end = defenc_c + PyBytes_GET_SIZE(defenc);
4417 char* c;
4418 for (c = defenc_c; c < end; c++) {
4419 if ((unsigned char) (*c) >= 128) {
4420 PyUnicode_AsASCIIString(o);
4421 return NULL;
4422 }
4423 }
4424 }
4425 #endif
4426 *length = PyBytes_GET_SIZE(defenc);
4427 return defenc_c;
4428 }
4429 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)4430 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
4431 if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
4432 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
4433 if (likely(PyUnicode_IS_ASCII(o))) {
4434 *length = PyUnicode_GET_LENGTH(o);
4435 return PyUnicode_AsUTF8(o);
4436 } else {
4437 PyUnicode_AsASCIIString(o);
4438 return NULL;
4439 }
4440 #else
4441 return PyUnicode_AsUTF8AndSize(o, length);
4442 #endif
4443 }
4444 #endif
4445 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)4446 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
4447 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
4448 if (
4449 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
4450 __Pyx_sys_getdefaultencoding_not_ascii &&
4451 #endif
4452 PyUnicode_Check(o)) {
4453 return __Pyx_PyUnicode_AsStringAndSize(o, length);
4454 } else
4455 #endif
4456 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
4457 if (PyByteArray_Check(o)) {
4458 *length = PyByteArray_GET_SIZE(o);
4459 return PyByteArray_AS_STRING(o);
4460 } else
4461 #endif
4462 {
4463 char* result;
4464 int r = PyBytes_AsStringAndSize(o, &result, length);
4465 if (unlikely(r < 0)) {
4466 return NULL;
4467 } else {
4468 return result;
4469 }
4470 }
4471 }
__Pyx_PyObject_IsTrue(PyObject * x)4472 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
4473 int is_true = x == Py_True;
4474 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
4475 else return PyObject_IsTrue(x);
4476 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)4477 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
4478 int retval;
4479 if (unlikely(!x)) return -1;
4480 retval = __Pyx_PyObject_IsTrue(x);
4481 Py_DECREF(x);
4482 return retval;
4483 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)4484 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
4485 #if PY_MAJOR_VERSION >= 3
4486 if (PyLong_Check(result)) {
4487 if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
4488 "__int__ returned non-int (type %.200s). "
4489 "The ability to return an instance of a strict subclass of int "
4490 "is deprecated, and may be removed in a future version of Python.",
4491 Py_TYPE(result)->tp_name)) {
4492 Py_DECREF(result);
4493 return NULL;
4494 }
4495 return result;
4496 }
4497 #endif
4498 PyErr_Format(PyExc_TypeError,
4499 "__%.4s__ returned non-%.4s (type %.200s)",
4500 type_name, type_name, Py_TYPE(result)->tp_name);
4501 Py_DECREF(result);
4502 return NULL;
4503 }
__Pyx_PyNumber_IntOrLong(PyObject * x)4504 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
4505 #if CYTHON_USE_TYPE_SLOTS
4506 PyNumberMethods *m;
4507 #endif
4508 const char *name = NULL;
4509 PyObject *res = NULL;
4510 #if PY_MAJOR_VERSION < 3
4511 if (likely(PyInt_Check(x) || PyLong_Check(x)))
4512 #else
4513 if (likely(PyLong_Check(x)))
4514 #endif
4515 return __Pyx_NewRef(x);
4516 #if CYTHON_USE_TYPE_SLOTS
4517 m = Py_TYPE(x)->tp_as_number;
4518 #if PY_MAJOR_VERSION < 3
4519 if (m && m->nb_int) {
4520 name = "int";
4521 res = m->nb_int(x);
4522 }
4523 else if (m && m->nb_long) {
4524 name = "long";
4525 res = m->nb_long(x);
4526 }
4527 #else
4528 if (likely(m && m->nb_int)) {
4529 name = "int";
4530 res = m->nb_int(x);
4531 }
4532 #endif
4533 #else
4534 if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
4535 res = PyNumber_Int(x);
4536 }
4537 #endif
4538 if (likely(res)) {
4539 #if PY_MAJOR_VERSION < 3
4540 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
4541 #else
4542 if (unlikely(!PyLong_CheckExact(res))) {
4543 #endif
4544 return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
4545 }
4546 }
4547 else if (!PyErr_Occurred()) {
4548 PyErr_SetString(PyExc_TypeError,
4549 "an integer is required");
4550 }
4551 return res;
4552 }
4553 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
4554 Py_ssize_t ival;
4555 PyObject *x;
4556 #if PY_MAJOR_VERSION < 3
4557 if (likely(PyInt_CheckExact(b))) {
4558 if (sizeof(Py_ssize_t) >= sizeof(long))
4559 return PyInt_AS_LONG(b);
4560 else
4561 return PyInt_AsSsize_t(b);
4562 }
4563 #endif
4564 if (likely(PyLong_CheckExact(b))) {
4565 #if CYTHON_USE_PYLONG_INTERNALS
4566 const digit* digits = ((PyLongObject*)b)->ob_digit;
4567 const Py_ssize_t size = Py_SIZE(b);
4568 if (likely(__Pyx_sst_abs(size) <= 1)) {
4569 ival = likely(size) ? digits[0] : 0;
4570 if (size == -1) ival = -ival;
4571 return ival;
4572 } else {
4573 switch (size) {
4574 case 2:
4575 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
4576 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4577 }
4578 break;
4579 case -2:
4580 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
4581 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4582 }
4583 break;
4584 case 3:
4585 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
4586 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4587 }
4588 break;
4589 case -3:
4590 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
4591 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4592 }
4593 break;
4594 case 4:
4595 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
4596 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]));
4597 }
4598 break;
4599 case -4:
4600 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
4601 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]));
4602 }
4603 break;
4604 }
4605 }
4606 #endif
4607 return PyLong_AsSsize_t(b);
4608 }
4609 x = PyNumber_Index(b);
4610 if (!x) return -1;
4611 ival = PyInt_AsSsize_t(x);
4612 Py_DECREF(x);
4613 return ival;
4614 }
4615 static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
4616 if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
4617 return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
4618 #if PY_MAJOR_VERSION < 3
4619 } else if (likely(PyInt_CheckExact(o))) {
4620 return PyInt_AS_LONG(o);
4621 #endif
4622 } else {
4623 Py_ssize_t ival;
4624 PyObject *x;
4625 x = PyNumber_Index(o);
4626 if (!x) return -1;
4627 ival = PyInt_AsLong(x);
4628 Py_DECREF(x);
4629 return ival;
4630 }
4631 }
4632 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
4633 return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
4634 }
4635 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
4636 return PyInt_FromSize_t(ival);
4637 }
4638
4639
4640 #endif /* Py_PYTHON_H */
4641