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___seekbzip2
677 #define __PYX_HAVE_API__bx__misc___seekbzip2
678 /* Early includes */
679 #include "micro-bunzip.h"
680 #include "unistd.h"
681 #include "stdlib.h"
682 #ifdef _OPENMP
683 #include <omp.h>
684 #endif /* _OPENMP */
685
686 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
687 #define CYTHON_WITHOUT_ASSERTIONS
688 #endif
689
690 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
691 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
692
693 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
694 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
695 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
696 #define __PYX_DEFAULT_STRING_ENCODING ""
697 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
698 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
699 #define __Pyx_uchar_cast(c) ((unsigned char)c)
700 #define __Pyx_long_cast(x) ((long)x)
701 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
702 (sizeof(type) < sizeof(Py_ssize_t)) ||\
703 (sizeof(type) > sizeof(Py_ssize_t) &&\
704 likely(v < (type)PY_SSIZE_T_MAX ||\
705 v == (type)PY_SSIZE_T_MAX) &&\
706 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
707 v == (type)PY_SSIZE_T_MIN))) ||\
708 (sizeof(type) == sizeof(Py_ssize_t) &&\
709 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
710 v == (type)PY_SSIZE_T_MAX))) )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)711 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
712 return (size_t) i < (size_t) limit;
713 }
714 #if defined (__cplusplus) && __cplusplus >= 201103L
715 #include <cstdlib>
716 #define __Pyx_sst_abs(value) std::abs(value)
717 #elif SIZEOF_INT >= SIZEOF_SIZE_T
718 #define __Pyx_sst_abs(value) abs(value)
719 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
720 #define __Pyx_sst_abs(value) labs(value)
721 #elif defined (_MSC_VER)
722 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
723 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
724 #define __Pyx_sst_abs(value) llabs(value)
725 #elif defined (__GNUC__)
726 #define __Pyx_sst_abs(value) __builtin_llabs(value)
727 #else
728 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
729 #endif
730 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
731 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
732 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
733 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
734 #define __Pyx_PyBytes_FromString PyBytes_FromString
735 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
736 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
737 #if PY_MAJOR_VERSION < 3
738 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
739 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
740 #else
741 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
742 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
743 #endif
744 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
745 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
746 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
747 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
748 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
749 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
750 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
751 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
752 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
753 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
754 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
755 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
756 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
757 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
758 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
759 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)760 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
761 const Py_UNICODE *u_end = u;
762 while (*u_end++) ;
763 return (size_t)(u_end - u - 1);
764 }
765 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
766 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
767 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
768 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
769 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
770 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
771 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
772 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
773 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
774 #define __Pyx_PySequence_Tuple(obj)\
775 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
776 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
777 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
778 static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
779 #if CYTHON_ASSUME_SAFE_MACROS
780 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
781 #else
782 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
783 #endif
784 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
785 #if PY_MAJOR_VERSION >= 3
786 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
787 #else
788 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
789 #endif
790 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
791 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
792 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)793 static int __Pyx_init_sys_getdefaultencoding_params(void) {
794 PyObject* sys;
795 PyObject* default_encoding = NULL;
796 PyObject* ascii_chars_u = NULL;
797 PyObject* ascii_chars_b = NULL;
798 const char* default_encoding_c;
799 sys = PyImport_ImportModule("sys");
800 if (!sys) goto bad;
801 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
802 Py_DECREF(sys);
803 if (!default_encoding) goto bad;
804 default_encoding_c = PyBytes_AsString(default_encoding);
805 if (!default_encoding_c) goto bad;
806 if (strcmp(default_encoding_c, "ascii") == 0) {
807 __Pyx_sys_getdefaultencoding_not_ascii = 0;
808 } else {
809 char ascii_chars[128];
810 int c;
811 for (c = 0; c < 128; c++) {
812 ascii_chars[c] = c;
813 }
814 __Pyx_sys_getdefaultencoding_not_ascii = 1;
815 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
816 if (!ascii_chars_u) goto bad;
817 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
818 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
819 PyErr_Format(
820 PyExc_ValueError,
821 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
822 default_encoding_c);
823 goto bad;
824 }
825 Py_DECREF(ascii_chars_u);
826 Py_DECREF(ascii_chars_b);
827 }
828 Py_DECREF(default_encoding);
829 return 0;
830 bad:
831 Py_XDECREF(default_encoding);
832 Py_XDECREF(ascii_chars_u);
833 Py_XDECREF(ascii_chars_b);
834 return -1;
835 }
836 #endif
837 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
838 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
839 #else
840 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
841 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
842 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)843 static int __Pyx_init_sys_getdefaultencoding_params(void) {
844 PyObject* sys;
845 PyObject* default_encoding = NULL;
846 char* default_encoding_c;
847 sys = PyImport_ImportModule("sys");
848 if (!sys) goto bad;
849 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
850 Py_DECREF(sys);
851 if (!default_encoding) goto bad;
852 default_encoding_c = PyBytes_AsString(default_encoding);
853 if (!default_encoding_c) goto bad;
854 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
855 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
856 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
857 Py_DECREF(default_encoding);
858 return 0;
859 bad:
860 Py_XDECREF(default_encoding);
861 return -1;
862 }
863 #endif
864 #endif
865
866
867 /* Test for GCC > 2.95 */
868 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
869 #define likely(x) __builtin_expect(!!(x), 1)
870 #define unlikely(x) __builtin_expect(!!(x), 0)
871 #else /* !__GNUC__ or GCC < 2.95 */
872 #define likely(x) (x)
873 #define unlikely(x) (x)
874 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)875 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
876
877 static PyObject *__pyx_m = NULL;
878 static PyObject *__pyx_d;
879 static PyObject *__pyx_b;
880 static PyObject *__pyx_cython_runtime = NULL;
881 static PyObject *__pyx_empty_tuple;
882 static PyObject *__pyx_empty_bytes;
883 static PyObject *__pyx_empty_unicode;
884 static int __pyx_lineno;
885 static int __pyx_clineno = 0;
886 static const char * __pyx_cfilenm= __FILE__;
887 static const char *__pyx_filename;
888
889
890 static const char *__pyx_f[] = {
891 "stringsource",
892 "lib/bx/misc/_seekbzip2.pyx",
893 };
894
895 /*--- Type declarations ---*/
896 struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2;
897
898 /* "bx/misc/_seekbzip2.pyx":38
899 * import os
900 *
901 * cdef class SeekBzip2: # <<<<<<<<<<<<<<
902 *
903 * cdef bunzip_data * bd
904 */
905 struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 {
906 PyObject_HEAD
907 bunzip_data *bd;
908 int file_fd;
909 int at_eof;
910 };
911
912
913 /* --- Runtime support code (head) --- */
914 /* Refnanny.proto */
915 #ifndef CYTHON_REFNANNY
916 #define CYTHON_REFNANNY 0
917 #endif
918 #if CYTHON_REFNANNY
919 typedef struct {
920 void (*INCREF)(void*, PyObject*, int);
921 void (*DECREF)(void*, PyObject*, int);
922 void (*GOTREF)(void*, PyObject*, int);
923 void (*GIVEREF)(void*, PyObject*, int);
924 void* (*SetupContext)(const char*, int, const char*);
925 void (*FinishContext)(void**);
926 } __Pyx_RefNannyAPIStruct;
927 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
928 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
929 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
930 #ifdef WITH_THREAD
931 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
932 if (acquire_gil) {\
933 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
934 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
935 PyGILState_Release(__pyx_gilstate_save);\
936 } else {\
937 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
938 }
939 #else
940 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
941 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
942 #endif
943 #define __Pyx_RefNannyFinishContext()\
944 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
945 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
946 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
947 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
948 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
949 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
950 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
951 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
952 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
953 #else
954 #define __Pyx_RefNannyDeclarations
955 #define __Pyx_RefNannySetupContext(name, acquire_gil)
956 #define __Pyx_RefNannyFinishContext()
957 #define __Pyx_INCREF(r) Py_INCREF(r)
958 #define __Pyx_DECREF(r) Py_DECREF(r)
959 #define __Pyx_GOTREF(r)
960 #define __Pyx_GIVEREF(r)
961 #define __Pyx_XINCREF(r) Py_XINCREF(r)
962 #define __Pyx_XDECREF(r) Py_XDECREF(r)
963 #define __Pyx_XGOTREF(r)
964 #define __Pyx_XGIVEREF(r)
965 #endif
966 #define __Pyx_XDECREF_SET(r, v) do {\
967 PyObject *tmp = (PyObject *) r;\
968 r = v; __Pyx_XDECREF(tmp);\
969 } while (0)
970 #define __Pyx_DECREF_SET(r, v) do {\
971 PyObject *tmp = (PyObject *) r;\
972 r = v; __Pyx_DECREF(tmp);\
973 } while (0)
974 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
975 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
976
977 /* PyObjectGetAttrStr.proto */
978 #if CYTHON_USE_TYPE_SLOTS
979 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
980 #else
981 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
982 #endif
983
984 /* GetBuiltinName.proto */
985 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
986
987 /* RaiseDoubleKeywords.proto */
988 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
989
990 /* ParseKeywords.proto */
991 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
992 PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
993 const char* function_name);
994
995 /* RaiseArgTupleInvalid.proto */
996 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
997 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
998
999 /* PyDictVersioning.proto */
1000 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1001 #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
1002 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
1003 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1004 (version_var) = __PYX_GET_DICT_VERSION(dict);\
1005 (cache_var) = (value);
1006 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1007 static PY_UINT64_T __pyx_dict_version = 0;\
1008 static PyObject *__pyx_dict_cached_value = NULL;\
1009 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1010 (VAR) = __pyx_dict_cached_value;\
1011 } else {\
1012 (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1013 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1014 }\
1015 }
1016 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1017 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1018 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1019 #else
1020 #define __PYX_GET_DICT_VERSION(dict) (0)
1021 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1022 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
1023 #endif
1024
1025 /* GetModuleGlobalName.proto */
1026 #if CYTHON_USE_DICT_VERSIONS
1027 #define __Pyx_GetModuleGlobalName(var, name) {\
1028 static PY_UINT64_T __pyx_dict_version = 0;\
1029 static PyObject *__pyx_dict_cached_value = NULL;\
1030 (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1031 (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1032 __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1033 }
1034 #define __Pyx_GetModuleGlobalNameUncached(var, name) {\
1035 PY_UINT64_T __pyx_dict_version;\
1036 PyObject *__pyx_dict_cached_value;\
1037 (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1038 }
1039 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1040 #else
1041 #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1042 #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1043 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1044 #endif
1045
1046 /* PyFunctionFastCall.proto */
1047 #if CYTHON_FAST_PYCALL
1048 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1049 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1050 #if 1 || PY_VERSION_HEX < 0x030600B1
1051 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1052 #else
1053 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1054 #endif
1055 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1056 (sizeof(char [1 - 2*!(cond)]) - 1)
1057 #ifndef Py_MEMBER_SIZE
1058 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1059 #endif
1060 #if CYTHON_FAST_PYCALL
1061 static size_t __pyx_pyframe_localsplus_offset = 0;
1062 #include "frameobject.h"
1063 #define __Pxy_PyFrame_Initialize_Offsets()\
1064 ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1065 (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1066 #define __Pyx_PyFrame_GetLocalsplus(frame)\
1067 (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1068 #endif // CYTHON_FAST_PYCALL
1069 #endif
1070
1071 /* PyCFunctionFastCall.proto */
1072 #if CYTHON_FAST_PYCCALL
1073 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1074 #else
1075 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
1076 #endif
1077
1078 /* PyObjectCall.proto */
1079 #if CYTHON_COMPILING_IN_CPYTHON
1080 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1081 #else
1082 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1083 #endif
1084
1085 /* PyObjectCall2Args.proto */
1086 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1087
1088 /* PyObjectCallMethO.proto */
1089 #if CYTHON_COMPILING_IN_CPYTHON
1090 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1091 #endif
1092
1093 /* PyObjectCallOneArg.proto */
1094 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1095
1096 /* PyThreadStateGet.proto */
1097 #if CYTHON_FAST_THREAD_STATE
1098 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1099 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1100 #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
1101 #else
1102 #define __Pyx_PyThreadState_declare
1103 #define __Pyx_PyThreadState_assign
1104 #define __Pyx_PyErr_Occurred() PyErr_Occurred()
1105 #endif
1106
1107 /* PyErrFetchRestore.proto */
1108 #if CYTHON_FAST_THREAD_STATE
1109 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1110 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1111 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1112 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1113 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1114 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1115 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1116 #if CYTHON_COMPILING_IN_CPYTHON
1117 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1118 #else
1119 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1120 #endif
1121 #else
1122 #define __Pyx_PyErr_Clear() PyErr_Clear()
1123 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1124 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1125 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1126 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1127 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1128 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1129 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1130 #endif
1131
1132 /* RaiseException.proto */
1133 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1134
1135 /* ListAppend.proto */
1136 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_PyList_Append(PyObject * list,PyObject * x)1137 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
1138 PyListObject* L = (PyListObject*) list;
1139 Py_ssize_t len = Py_SIZE(list);
1140 if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
1141 Py_INCREF(x);
1142 PyList_SET_ITEM(list, len, x);
1143 __Pyx_SET_SIZE(list, len + 1);
1144 return 0;
1145 }
1146 return PyList_Append(list, x);
1147 }
1148 #else
1149 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
1150 #endif
1151
1152 /* SliceObject.proto */
1153 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
1154 PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
1155 PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
1156 int has_cstart, int has_cstop, int wraparound);
1157
1158 /* StringJoin.proto */
1159 #if PY_MAJOR_VERSION < 3
1160 #define __Pyx_PyString_Join __Pyx_PyBytes_Join
1161 #define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v))
1162 #else
1163 #define __Pyx_PyString_Join PyUnicode_Join
1164 #define __Pyx_PyBaseString_Join PyUnicode_Join
1165 #endif
1166 #if CYTHON_COMPILING_IN_CPYTHON
1167 #if PY_MAJOR_VERSION < 3
1168 #define __Pyx_PyBytes_Join _PyString_Join
1169 #else
1170 #define __Pyx_PyBytes_Join _PyBytes_Join
1171 #endif
1172 #else
1173 static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values);
1174 #endif
1175
1176 /* PyObject_GenericGetAttrNoDict.proto */
1177 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1178 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
1179 #else
1180 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1181 #endif
1182
1183 /* PyObject_GenericGetAttr.proto */
1184 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1185 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
1186 #else
1187 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
1188 #endif
1189
1190 /* PyErrExceptionMatches.proto */
1191 #if CYTHON_FAST_THREAD_STATE
1192 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1193 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1194 #else
1195 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1196 #endif
1197
1198 /* PyObjectGetAttrStrNoError.proto */
1199 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1200
1201 /* SetupReduce.proto */
1202 static int __Pyx_setup_reduce(PyObject* type_obj);
1203
1204 /* Import.proto */
1205 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1206
1207 /* CLineInTraceback.proto */
1208 #ifdef CYTHON_CLINE_IN_TRACEBACK
1209 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1210 #else
1211 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1212 #endif
1213
1214 /* CodeObjectCache.proto */
1215 typedef struct {
1216 PyCodeObject* code_object;
1217 int code_line;
1218 } __Pyx_CodeObjectCacheEntry;
1219 struct __Pyx_CodeObjectCache {
1220 int count;
1221 int max_count;
1222 __Pyx_CodeObjectCacheEntry* entries;
1223 };
1224 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1225 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1226 static PyCodeObject *__pyx_find_code_object(int code_line);
1227 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1228
1229 /* AddTraceback.proto */
1230 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1231 int py_line, const char *filename);
1232
1233 /* GCCDiagnostics.proto */
1234 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
1235 #define __Pyx_HAS_GCC_DIAGNOSTIC
1236 #endif
1237
1238 /* CIntFromPy.proto */
1239 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject *);
1240
1241 /* CIntFromPy.proto */
1242 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1243
1244 /* CIntToPy.proto */
1245 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1246
1247 /* CIntToPy.proto */
1248 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1249
1250 /* CIntFromPy.proto */
1251 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1252
1253 /* FastTypeChecks.proto */
1254 #if CYTHON_COMPILING_IN_CPYTHON
1255 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1256 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1257 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1258 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1259 #else
1260 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1261 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1262 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1263 #endif
1264 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1265
1266 /* CheckBinaryVersion.proto */
1267 static int __Pyx_check_binary_version(void);
1268
1269 /* InitStrings.proto */
1270 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1271
1272
1273 /* Module declarations from 'bx.misc._seekbzip2' */
1274 static PyTypeObject *__pyx_ptype_2bx_4misc_10_seekbzip2_SeekBzip2 = 0;
1275 #define __Pyx_MODULE_NAME "bx.misc._seekbzip2"
1276 extern int __pyx_module_is_main_bx__misc___seekbzip2;
1277 int __pyx_module_is_main_bx__misc___seekbzip2 = 0;
1278
1279 /* Implementation of 'bx.misc._seekbzip2' */
1280 static PyObject *__pyx_builtin_TypeError;
1281 static const char __pyx_k__2[] = "";
1282 static const char __pyx_k_os[] = "os";
1283 static const char __pyx_k_sys[] = "sys";
1284 static const char __pyx_k_join[] = "join";
1285 static const char __pyx_k_main[] = "__main__";
1286 static const char __pyx_k_name[] = "__name__";
1287 static const char __pyx_k_open[] = "open";
1288 static const char __pyx_k_test[] = "__test__";
1289 static const char __pyx_k_close[] = "close";
1290 static const char __pyx_k_import[] = "__import__";
1291 static const char __pyx_k_reduce[] = "__reduce__";
1292 static const char __pyx_k_O_RDONLY[] = "O_RDONLY";
1293 static const char __pyx_k_filename[] = "filename";
1294 static const char __pyx_k_getstate[] = "__getstate__";
1295 static const char __pyx_k_setstate[] = "__setstate__";
1296 static const char __pyx_k_SeekBzip2[] = "SeekBzip2";
1297 static const char __pyx_k_TypeError[] = "TypeError";
1298 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
1299 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
1300 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
1301 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1302 static const char __pyx_k_read_bunzip_error_d[] = "read_bunzip error %d";
1303 static const char __pyx_k_Pyrex_C_extension_supporting_bx[] = "\nPyrex/C extension supporting `bx.misc.seekbzip2` (wrapping the low level\nfunctions in `micro-bunzip.c`).\n";
1304 static const char __pyx_k_lseek_of_underlying_file_failed[] = "lseek of underlying file failed";
1305 static const char __pyx_k_self_bd_cannot_be_converted_to_a[] = "self.bd cannot be converted to a Python object for pickling";
1306 static PyObject *__pyx_n_s_O_RDONLY;
1307 static PyObject *__pyx_n_s_SeekBzip2;
1308 static PyObject *__pyx_n_s_TypeError;
1309 static PyObject *__pyx_kp_s__2;
1310 static PyObject *__pyx_n_s_cline_in_traceback;
1311 static PyObject *__pyx_n_s_close;
1312 static PyObject *__pyx_n_s_filename;
1313 static PyObject *__pyx_n_s_getstate;
1314 static PyObject *__pyx_n_s_import;
1315 static PyObject *__pyx_n_s_join;
1316 static PyObject *__pyx_kp_s_lseek_of_underlying_file_failed;
1317 static PyObject *__pyx_n_s_main;
1318 static PyObject *__pyx_n_s_name;
1319 static PyObject *__pyx_n_s_open;
1320 static PyObject *__pyx_n_s_os;
1321 static PyObject *__pyx_kp_s_read_bunzip_error_d;
1322 static PyObject *__pyx_n_s_reduce;
1323 static PyObject *__pyx_n_s_reduce_cython;
1324 static PyObject *__pyx_n_s_reduce_ex;
1325 static PyObject *__pyx_kp_s_self_bd_cannot_be_converted_to_a;
1326 static PyObject *__pyx_n_s_setstate;
1327 static PyObject *__pyx_n_s_setstate_cython;
1328 static PyObject *__pyx_n_s_sys;
1329 static PyObject *__pyx_n_s_test;
1330 static int __pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2___init__(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *__pyx_v_self, PyObject *__pyx_v_filename); /* proto */
1331 static PyObject *__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_2close(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *__pyx_v_self); /* proto */
1332 static PyObject *__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_4seek(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_position); /* proto */
1333 static PyObject *__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_6readline(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *__pyx_v_self, int __pyx_v_amount); /* proto */
1334 static PyObject *__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_8read(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *__pyx_v_self, int __pyx_v_amount); /* proto */
1335 static PyObject *__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *__pyx_v_self); /* proto */
1336 static PyObject *__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
1337 static PyObject *__pyx_tp_new_2bx_4misc_10_seekbzip2_SeekBzip2(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1338 static PyObject *__pyx_tuple_;
1339 static PyObject *__pyx_tuple__3;
1340 static PyObject *__pyx_tuple__4;
1341 /* Late includes */
1342
1343 /* "bx/misc/_seekbzip2.pyx":44
1344 * cdef int at_eof
1345 *
1346 * def __init__( self, filename ): # <<<<<<<<<<<<<<
1347 * self.at_eof = 0
1348 * self.file_fd = os.open( filename, os.O_RDONLY )
1349 */
1350
1351 /* Python wrapper */
1352 static int __pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_1__init__(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1353 static int __pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1354 PyObject *__pyx_v_filename = 0;
1355 int __pyx_lineno = 0;
1356 const char *__pyx_filename = NULL;
1357 int __pyx_clineno = 0;
1358 int __pyx_r;
1359 __Pyx_RefNannyDeclarations
1360 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
1361 {
1362 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_filename,0};
1363 PyObject* values[1] = {0};
1364 if (unlikely(__pyx_kwds)) {
1365 Py_ssize_t kw_args;
1366 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1367 switch (pos_args) {
1368 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1369 CYTHON_FALLTHROUGH;
1370 case 0: break;
1371 default: goto __pyx_L5_argtuple_error;
1372 }
1373 kw_args = PyDict_Size(__pyx_kwds);
1374 switch (pos_args) {
1375 case 0:
1376 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_filename)) != 0)) kw_args--;
1377 else goto __pyx_L5_argtuple_error;
1378 }
1379 if (unlikely(kw_args > 0)) {
1380 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(1, 44, __pyx_L3_error)
1381 }
1382 } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
1383 goto __pyx_L5_argtuple_error;
1384 } else {
1385 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1386 }
1387 __pyx_v_filename = values[0];
1388 }
1389 goto __pyx_L4_argument_unpacking_done;
1390 __pyx_L5_argtuple_error:;
1391 __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 44, __pyx_L3_error)
1392 __pyx_L3_error:;
1393 __Pyx_AddTraceback("bx.misc._seekbzip2.SeekBzip2.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1394 __Pyx_RefNannyFinishContext();
1395 return -1;
1396 __pyx_L4_argument_unpacking_done:;
1397 __pyx_r = __pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2___init__(((struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *)__pyx_v_self), __pyx_v_filename);
1398
1399 /* function exit code */
1400 __Pyx_RefNannyFinishContext();
1401 return __pyx_r;
1402 }
1403
__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2___init__(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 * __pyx_v_self,PyObject * __pyx_v_filename)1404 static int __pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2___init__(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *__pyx_v_self, PyObject *__pyx_v_filename) {
1405 int __pyx_r;
1406 __Pyx_RefNannyDeclarations
1407 PyObject *__pyx_t_1 = NULL;
1408 PyObject *__pyx_t_2 = NULL;
1409 PyObject *__pyx_t_3 = NULL;
1410 PyObject *__pyx_t_4 = NULL;
1411 int __pyx_t_5;
1412 PyObject *__pyx_t_6 = NULL;
1413 int __pyx_lineno = 0;
1414 const char *__pyx_filename = NULL;
1415 int __pyx_clineno = 0;
1416 __Pyx_RefNannySetupContext("__init__", 0);
1417
1418 /* "bx/misc/_seekbzip2.pyx":45
1419 *
1420 * def __init__( self, filename ):
1421 * self.at_eof = 0 # <<<<<<<<<<<<<<
1422 * self.file_fd = os.open( filename, os.O_RDONLY )
1423 * # Initialize bunzip_data from the file
1424 */
1425 __pyx_v_self->at_eof = 0;
1426
1427 /* "bx/misc/_seekbzip2.pyx":46
1428 * def __init__( self, filename ):
1429 * self.at_eof = 0
1430 * self.file_fd = os.open( filename, os.O_RDONLY ) # <<<<<<<<<<<<<<
1431 * # Initialize bunzip_data from the file
1432 * start_bunzip( &( self.bd ), self.file_fd, NULL, 0 )
1433 */
1434 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 46, __pyx_L1_error)
1435 __Pyx_GOTREF(__pyx_t_2);
1436 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_open); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 46, __pyx_L1_error)
1437 __Pyx_GOTREF(__pyx_t_3);
1438 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1439 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 46, __pyx_L1_error)
1440 __Pyx_GOTREF(__pyx_t_2);
1441 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_O_RDONLY); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 46, __pyx_L1_error)
1442 __Pyx_GOTREF(__pyx_t_4);
1443 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1444 __pyx_t_2 = NULL;
1445 __pyx_t_5 = 0;
1446 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
1447 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
1448 if (likely(__pyx_t_2)) {
1449 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
1450 __Pyx_INCREF(__pyx_t_2);
1451 __Pyx_INCREF(function);
1452 __Pyx_DECREF_SET(__pyx_t_3, function);
1453 __pyx_t_5 = 1;
1454 }
1455 }
1456 #if CYTHON_FAST_PYCALL
1457 if (PyFunction_Check(__pyx_t_3)) {
1458 PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_filename, __pyx_t_4};
1459 __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 46, __pyx_L1_error)
1460 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
1461 __Pyx_GOTREF(__pyx_t_1);
1462 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1463 } else
1464 #endif
1465 #if CYTHON_FAST_PYCCALL
1466 if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
1467 PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_filename, __pyx_t_4};
1468 __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 46, __pyx_L1_error)
1469 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
1470 __Pyx_GOTREF(__pyx_t_1);
1471 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1472 } else
1473 #endif
1474 {
1475 __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 46, __pyx_L1_error)
1476 __Pyx_GOTREF(__pyx_t_6);
1477 if (__pyx_t_2) {
1478 __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
1479 }
1480 __Pyx_INCREF(__pyx_v_filename);
1481 __Pyx_GIVEREF(__pyx_v_filename);
1482 PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_filename);
1483 __Pyx_GIVEREF(__pyx_t_4);
1484 PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_4);
1485 __pyx_t_4 = 0;
1486 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 46, __pyx_L1_error)
1487 __Pyx_GOTREF(__pyx_t_1);
1488 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1489 }
1490 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1491 __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 46, __pyx_L1_error)
1492 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1493 __pyx_v_self->file_fd = __pyx_t_5;
1494
1495 /* "bx/misc/_seekbzip2.pyx":48
1496 * self.file_fd = os.open( filename, os.O_RDONLY )
1497 * # Initialize bunzip_data from the file
1498 * start_bunzip( &( self.bd ), self.file_fd, NULL, 0 ) # <<<<<<<<<<<<<<
1499 *
1500 * def close( self ):
1501 */
1502 (void)(start_bunzip((&__pyx_v_self->bd), __pyx_v_self->file_fd, NULL, 0));
1503
1504 /* "bx/misc/_seekbzip2.pyx":44
1505 * cdef int at_eof
1506 *
1507 * def __init__( self, filename ): # <<<<<<<<<<<<<<
1508 * self.at_eof = 0
1509 * self.file_fd = os.open( filename, os.O_RDONLY )
1510 */
1511
1512 /* function exit code */
1513 __pyx_r = 0;
1514 goto __pyx_L0;
1515 __pyx_L1_error:;
1516 __Pyx_XDECREF(__pyx_t_1);
1517 __Pyx_XDECREF(__pyx_t_2);
1518 __Pyx_XDECREF(__pyx_t_3);
1519 __Pyx_XDECREF(__pyx_t_4);
1520 __Pyx_XDECREF(__pyx_t_6);
1521 __Pyx_AddTraceback("bx.misc._seekbzip2.SeekBzip2.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1522 __pyx_r = -1;
1523 __pyx_L0:;
1524 __Pyx_RefNannyFinishContext();
1525 return __pyx_r;
1526 }
1527
1528 /* "bx/misc/_seekbzip2.pyx":50
1529 * start_bunzip( &( self.bd ), self.file_fd, NULL, 0 )
1530 *
1531 * def close( self ): # <<<<<<<<<<<<<<
1532 * free( self.bd.dbuf )
1533 * free( self.bd )
1534 */
1535
1536 /* Python wrapper */
1537 static PyObject *__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_3close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_3close(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)1538 static PyObject *__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_3close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1539 PyObject *__pyx_r = 0;
1540 __Pyx_RefNannyDeclarations
1541 __Pyx_RefNannySetupContext("close (wrapper)", 0);
1542 __pyx_r = __pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_2close(((struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *)__pyx_v_self));
1543
1544 /* function exit code */
1545 __Pyx_RefNannyFinishContext();
1546 return __pyx_r;
1547 }
1548
__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_2close(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 * __pyx_v_self)1549 static PyObject *__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_2close(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *__pyx_v_self) {
1550 PyObject *__pyx_r = NULL;
1551 __Pyx_RefNannyDeclarations
1552 PyObject *__pyx_t_1 = NULL;
1553 PyObject *__pyx_t_2 = NULL;
1554 PyObject *__pyx_t_3 = NULL;
1555 PyObject *__pyx_t_4 = NULL;
1556 int __pyx_lineno = 0;
1557 const char *__pyx_filename = NULL;
1558 int __pyx_clineno = 0;
1559 __Pyx_RefNannySetupContext("close", 0);
1560
1561 /* "bx/misc/_seekbzip2.pyx":51
1562 *
1563 * def close( self ):
1564 * free( self.bd.dbuf ) # <<<<<<<<<<<<<<
1565 * free( self.bd )
1566 * os.close( self.file_fd )
1567 */
1568 free(__pyx_v_self->bd->dbuf);
1569
1570 /* "bx/misc/_seekbzip2.pyx":52
1571 * def close( self ):
1572 * free( self.bd.dbuf )
1573 * free( self.bd ) # <<<<<<<<<<<<<<
1574 * os.close( self.file_fd )
1575 *
1576 */
1577 free(__pyx_v_self->bd);
1578
1579 /* "bx/misc/_seekbzip2.pyx":53
1580 * free( self.bd.dbuf )
1581 * free( self.bd )
1582 * os.close( self.file_fd ) # <<<<<<<<<<<<<<
1583 *
1584 * def seek( self, unsigned long long position ):
1585 */
1586 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 53, __pyx_L1_error)
1587 __Pyx_GOTREF(__pyx_t_2);
1588 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_close); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 53, __pyx_L1_error)
1589 __Pyx_GOTREF(__pyx_t_3);
1590 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1591 __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->file_fd); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 53, __pyx_L1_error)
1592 __Pyx_GOTREF(__pyx_t_2);
1593 __pyx_t_4 = NULL;
1594 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
1595 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
1596 if (likely(__pyx_t_4)) {
1597 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
1598 __Pyx_INCREF(__pyx_t_4);
1599 __Pyx_INCREF(function);
1600 __Pyx_DECREF_SET(__pyx_t_3, function);
1601 }
1602 }
1603 __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
1604 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
1605 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1606 if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 53, __pyx_L1_error)
1607 __Pyx_GOTREF(__pyx_t_1);
1608 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1609 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1610
1611 /* "bx/misc/_seekbzip2.pyx":50
1612 * start_bunzip( &( self.bd ), self.file_fd, NULL, 0 )
1613 *
1614 * def close( self ): # <<<<<<<<<<<<<<
1615 * free( self.bd.dbuf )
1616 * free( self.bd )
1617 */
1618
1619 /* function exit code */
1620 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1621 goto __pyx_L0;
1622 __pyx_L1_error:;
1623 __Pyx_XDECREF(__pyx_t_1);
1624 __Pyx_XDECREF(__pyx_t_2);
1625 __Pyx_XDECREF(__pyx_t_3);
1626 __Pyx_XDECREF(__pyx_t_4);
1627 __Pyx_AddTraceback("bx.misc._seekbzip2.SeekBzip2.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
1628 __pyx_r = NULL;
1629 __pyx_L0:;
1630 __Pyx_XGIVEREF(__pyx_r);
1631 __Pyx_RefNannyFinishContext();
1632 return __pyx_r;
1633 }
1634
1635 /* "bx/misc/_seekbzip2.pyx":55
1636 * os.close( self.file_fd )
1637 *
1638 * def seek( self, unsigned long long position ): # <<<<<<<<<<<<<<
1639 * """
1640 * Seek the bunzip_data to a specific chunk (position must correspond to
1641 */
1642
1643 /* Python wrapper */
1644 static PyObject *__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_5seek(PyObject *__pyx_v_self, PyObject *__pyx_arg_position); /*proto*/
1645 static char __pyx_doc_2bx_4misc_10_seekbzip2_9SeekBzip2_4seek[] = "\n Seek the bunzip_data to a specific chunk (position must correspond to\n that start of a compressed data block).\n ";
__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_5seek(PyObject * __pyx_v_self,PyObject * __pyx_arg_position)1646 static PyObject *__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_5seek(PyObject *__pyx_v_self, PyObject *__pyx_arg_position) {
1647 unsigned PY_LONG_LONG __pyx_v_position;
1648 int __pyx_lineno = 0;
1649 const char *__pyx_filename = NULL;
1650 int __pyx_clineno = 0;
1651 PyObject *__pyx_r = 0;
1652 __Pyx_RefNannyDeclarations
1653 __Pyx_RefNannySetupContext("seek (wrapper)", 0);
1654 assert(__pyx_arg_position); {
1655 __pyx_v_position = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_arg_position); if (unlikely((__pyx_v_position == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 55, __pyx_L3_error)
1656 }
1657 goto __pyx_L4_argument_unpacking_done;
1658 __pyx_L3_error:;
1659 __Pyx_AddTraceback("bx.misc._seekbzip2.SeekBzip2.seek", __pyx_clineno, __pyx_lineno, __pyx_filename);
1660 __Pyx_RefNannyFinishContext();
1661 return NULL;
1662 __pyx_L4_argument_unpacking_done:;
1663 __pyx_r = __pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_4seek(((struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *)__pyx_v_self), ((unsigned PY_LONG_LONG)__pyx_v_position));
1664
1665 /* function exit code */
1666 __Pyx_RefNannyFinishContext();
1667 return __pyx_r;
1668 }
1669
__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_4seek(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 * __pyx_v_self,unsigned PY_LONG_LONG __pyx_v_position)1670 static PyObject *__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_4seek(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_position) {
1671 off_t __pyx_v_n_byte;
1672 int __pyx_v_n_bit;
1673 PyObject *__pyx_r = NULL;
1674 __Pyx_RefNannyDeclarations
1675 int __pyx_t_1;
1676 PyObject *__pyx_t_2 = NULL;
1677 int __pyx_lineno = 0;
1678 const char *__pyx_filename = NULL;
1679 int __pyx_clineno = 0;
1680 __Pyx_RefNannySetupContext("seek", 0);
1681
1682 /* "bx/misc/_seekbzip2.pyx":64
1683 * # Break position into bit and byte offsets
1684 * ## sys.stderr.write( "arg pos: %d\n" % position )
1685 * n_byte = position / 8; # <<<<<<<<<<<<<<
1686 * n_bit = position % 8;
1687 * ## sys.stderr.write( "byte pos: %d\n" % n_byte )
1688 */
1689 __pyx_v_n_byte = (__pyx_v_position / 8);
1690
1691 /* "bx/misc/_seekbzip2.pyx":65
1692 * ## sys.stderr.write( "arg pos: %d\n" % position )
1693 * n_byte = position / 8;
1694 * n_bit = position % 8; # <<<<<<<<<<<<<<
1695 * ## sys.stderr.write( "byte pos: %d\n" % n_byte )
1696 * ## sys.stderr.write( "bit pos: %d\n" % n_bit )
1697 */
1698 __pyx_v_n_bit = (__pyx_v_position % 8);
1699
1700 /* "bx/misc/_seekbzip2.pyx":70
1701 * ## sys.stderr.flush()
1702 * # Seek the underlying file descriptor
1703 * if ( lseek( self.file_fd, n_byte, 0 ) != n_byte ): # <<<<<<<<<<<<<<
1704 * raise Exception( "lseek of underlying file failed" )
1705 * # Init the buffer at the right bit position
1706 */
1707 __pyx_t_1 = ((lseek(__pyx_v_self->file_fd, __pyx_v_n_byte, 0) != __pyx_v_n_byte) != 0);
1708 if (unlikely(__pyx_t_1)) {
1709
1710 /* "bx/misc/_seekbzip2.pyx":71
1711 * # Seek the underlying file descriptor
1712 * if ( lseek( self.file_fd, n_byte, 0 ) != n_byte ):
1713 * raise Exception( "lseek of underlying file failed" ) # <<<<<<<<<<<<<<
1714 * # Init the buffer at the right bit position
1715 * self.bd.inbufBitCount = self.bd.inbufPos = self.bd.inbufCount = 0
1716 */
1717 __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 71, __pyx_L1_error)
1718 __Pyx_GOTREF(__pyx_t_2);
1719 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
1720 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1721 __PYX_ERR(1, 71, __pyx_L1_error)
1722
1723 /* "bx/misc/_seekbzip2.pyx":70
1724 * ## sys.stderr.flush()
1725 * # Seek the underlying file descriptor
1726 * if ( lseek( self.file_fd, n_byte, 0 ) != n_byte ): # <<<<<<<<<<<<<<
1727 * raise Exception( "lseek of underlying file failed" )
1728 * # Init the buffer at the right bit position
1729 */
1730 }
1731
1732 /* "bx/misc/_seekbzip2.pyx":73
1733 * raise Exception( "lseek of underlying file failed" )
1734 * # Init the buffer at the right bit position
1735 * self.bd.inbufBitCount = self.bd.inbufPos = self.bd.inbufCount = 0 # <<<<<<<<<<<<<<
1736 * get_bits( self.bd, n_bit )
1737 * # This ensures that the next read call will return 0, causing the
1738 */
1739 __pyx_v_self->bd->inbufBitCount = 0;
1740 __pyx_v_self->bd->inbufPos = 0;
1741 __pyx_v_self->bd->inbufCount = 0;
1742
1743 /* "bx/misc/_seekbzip2.pyx":74
1744 * # Init the buffer at the right bit position
1745 * self.bd.inbufBitCount = self.bd.inbufPos = self.bd.inbufCount = 0
1746 * get_bits( self.bd, n_bit ) # <<<<<<<<<<<<<<
1747 * # This ensures that the next read call will return 0, causing the
1748 * # buffer to be re-initialized
1749 */
1750 (void)(get_bits(__pyx_v_self->bd, __pyx_v_n_bit));
1751
1752 /* "bx/misc/_seekbzip2.pyx":77
1753 * # This ensures that the next read call will return 0, causing the
1754 * # buffer to be re-initialized
1755 * self.bd.writeCount = -1 # <<<<<<<<<<<<<<
1756 * # Reset EOF tracking
1757 * self.at_eof = 0
1758 */
1759 __pyx_v_self->bd->writeCount = -1;
1760
1761 /* "bx/misc/_seekbzip2.pyx":79
1762 * self.bd.writeCount = -1
1763 * # Reset EOF tracking
1764 * self.at_eof = 0 # <<<<<<<<<<<<<<
1765 *
1766 * def readline( self, int amount ):
1767 */
1768 __pyx_v_self->at_eof = 0;
1769
1770 /* "bx/misc/_seekbzip2.pyx":55
1771 * os.close( self.file_fd )
1772 *
1773 * def seek( self, unsigned long long position ): # <<<<<<<<<<<<<<
1774 * """
1775 * Seek the bunzip_data to a specific chunk (position must correspond to
1776 */
1777
1778 /* function exit code */
1779 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1780 goto __pyx_L0;
1781 __pyx_L1_error:;
1782 __Pyx_XDECREF(__pyx_t_2);
1783 __Pyx_AddTraceback("bx.misc._seekbzip2.SeekBzip2.seek", __pyx_clineno, __pyx_lineno, __pyx_filename);
1784 __pyx_r = NULL;
1785 __pyx_L0:;
1786 __Pyx_XGIVEREF(__pyx_r);
1787 __Pyx_RefNannyFinishContext();
1788 return __pyx_r;
1789 }
1790
1791 /* "bx/misc/_seekbzip2.pyx":81
1792 * self.at_eof = 0
1793 *
1794 * def readline( self, int amount ): # <<<<<<<<<<<<<<
1795 * cdef object rval
1796 * cdef char * p_rval
1797 */
1798
1799 /* Python wrapper */
1800 static PyObject *__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_7readline(PyObject *__pyx_v_self, PyObject *__pyx_arg_amount); /*proto*/
__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_7readline(PyObject * __pyx_v_self,PyObject * __pyx_arg_amount)1801 static PyObject *__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_7readline(PyObject *__pyx_v_self, PyObject *__pyx_arg_amount) {
1802 int __pyx_v_amount;
1803 int __pyx_lineno = 0;
1804 const char *__pyx_filename = NULL;
1805 int __pyx_clineno = 0;
1806 PyObject *__pyx_r = 0;
1807 __Pyx_RefNannyDeclarations
1808 __Pyx_RefNannySetupContext("readline (wrapper)", 0);
1809 assert(__pyx_arg_amount); {
1810 __pyx_v_amount = __Pyx_PyInt_As_int(__pyx_arg_amount); if (unlikely((__pyx_v_amount == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 81, __pyx_L3_error)
1811 }
1812 goto __pyx_L4_argument_unpacking_done;
1813 __pyx_L3_error:;
1814 __Pyx_AddTraceback("bx.misc._seekbzip2.SeekBzip2.readline", __pyx_clineno, __pyx_lineno, __pyx_filename);
1815 __Pyx_RefNannyFinishContext();
1816 return NULL;
1817 __pyx_L4_argument_unpacking_done:;
1818 __pyx_r = __pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_6readline(((struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *)__pyx_v_self), ((int)__pyx_v_amount));
1819
1820 /* function exit code */
1821 __Pyx_RefNannyFinishContext();
1822 return __pyx_r;
1823 }
1824
__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_6readline(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 * __pyx_v_self,int __pyx_v_amount)1825 static PyObject *__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_6readline(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *__pyx_v_self, int __pyx_v_amount) {
1826 PyObject *__pyx_v_rval = 0;
1827 char *__pyx_v_p_rval;
1828 int __pyx_v_gotcount;
1829 CYTHON_UNUSED int __pyx_v_totalcount;
1830 int __pyx_v_status;
1831 int __pyx_v_spaceleft;
1832 int __pyx_v_desired;
1833 PyObject *__pyx_v_chunks = NULL;
1834 PyObject *__pyx_r = NULL;
1835 __Pyx_RefNannyDeclarations
1836 int __pyx_t_1;
1837 PyObject *__pyx_t_2 = NULL;
1838 int __pyx_t_3;
1839 int __pyx_t_4;
1840 PyObject *__pyx_t_5 = NULL;
1841 int __pyx_lineno = 0;
1842 const char *__pyx_filename = NULL;
1843 int __pyx_clineno = 0;
1844 __Pyx_RefNannySetupContext("readline", 0);
1845
1846 /* "bx/misc/_seekbzip2.pyx":89
1847 * cdef int spaceleft
1848 * cdef int desired
1849 * gotcount = 0 # <<<<<<<<<<<<<<
1850 * totalcount = 0
1851 * # If already at EOF return None
1852 */
1853 __pyx_v_gotcount = 0;
1854
1855 /* "bx/misc/_seekbzip2.pyx":90
1856 * cdef int desired
1857 * gotcount = 0
1858 * totalcount = 0 # <<<<<<<<<<<<<<
1859 * # If already at EOF return None
1860 * if self.at_eof:
1861 */
1862 __pyx_v_totalcount = 0;
1863
1864 /* "bx/misc/_seekbzip2.pyx":92
1865 * totalcount = 0
1866 * # If already at EOF return None
1867 * if self.at_eof: # <<<<<<<<<<<<<<
1868 * return None
1869 * chunks = []
1870 */
1871 __pyx_t_1 = (__pyx_v_self->at_eof != 0);
1872 if (__pyx_t_1) {
1873
1874 /* "bx/misc/_seekbzip2.pyx":93
1875 * # If already at EOF return None
1876 * if self.at_eof:
1877 * return None # <<<<<<<<<<<<<<
1878 * chunks = []
1879 * # We have great difficulty resizing buffers, so we'll just create
1880 */
1881 __Pyx_XDECREF(__pyx_r);
1882 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1883 goto __pyx_L0;
1884
1885 /* "bx/misc/_seekbzip2.pyx":92
1886 * totalcount = 0
1887 * # If already at EOF return None
1888 * if self.at_eof: # <<<<<<<<<<<<<<
1889 * return None
1890 * chunks = []
1891 */
1892 }
1893
1894 /* "bx/misc/_seekbzip2.pyx":94
1895 * if self.at_eof:
1896 * return None
1897 * chunks = [] # <<<<<<<<<<<<<<
1898 * # We have great difficulty resizing buffers, so we'll just create
1899 * # one 8k string at a time
1900 */
1901 __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 94, __pyx_L1_error)
1902 __Pyx_GOTREF(__pyx_t_2);
1903 __pyx_v_chunks = ((PyObject*)__pyx_t_2);
1904 __pyx_t_2 = 0;
1905
1906 /* "bx/misc/_seekbzip2.pyx":97
1907 * # We have great difficulty resizing buffers, so we'll just create
1908 * # one 8k string at a time
1909 * rval = PyBytes_FromStringAndSize( NULL, 8192 ) # <<<<<<<<<<<<<<
1910 * p_rval = PyBytes_AsString( rval )
1911 * spaceleft = 8192
1912 */
1913 __pyx_t_2 = PyBytes_FromStringAndSize(NULL, 0x2000); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 97, __pyx_L1_error)
1914 __Pyx_GOTREF(__pyx_t_2);
1915 __pyx_v_rval = __pyx_t_2;
1916 __pyx_t_2 = 0;
1917
1918 /* "bx/misc/_seekbzip2.pyx":98
1919 * # one 8k string at a time
1920 * rval = PyBytes_FromStringAndSize( NULL, 8192 )
1921 * p_rval = PyBytes_AsString( rval ) # <<<<<<<<<<<<<<
1922 * spaceleft = 8192
1923 * while amount != 0:
1924 */
1925 __pyx_v_p_rval = PyBytes_AsString(__pyx_v_rval);
1926
1927 /* "bx/misc/_seekbzip2.pyx":99
1928 * rval = PyBytes_FromStringAndSize( NULL, 8192 )
1929 * p_rval = PyBytes_AsString( rval )
1930 * spaceleft = 8192 # <<<<<<<<<<<<<<
1931 * while amount != 0:
1932 * if amount > 0 and amount < spaceleft:
1933 */
1934 __pyx_v_spaceleft = 0x2000;
1935
1936 /* "bx/misc/_seekbzip2.pyx":100
1937 * p_rval = PyBytes_AsString( rval )
1938 * spaceleft = 8192
1939 * while amount != 0: # <<<<<<<<<<<<<<
1940 * if amount > 0 and amount < spaceleft:
1941 * desired = amount
1942 */
1943 while (1) {
1944 __pyx_t_1 = ((__pyx_v_amount != 0) != 0);
1945 if (!__pyx_t_1) break;
1946
1947 /* "bx/misc/_seekbzip2.pyx":101
1948 * spaceleft = 8192
1949 * while amount != 0:
1950 * if amount > 0 and amount < spaceleft: # <<<<<<<<<<<<<<
1951 * desired = amount
1952 * else:
1953 */
1954 __pyx_t_3 = ((__pyx_v_amount > 0) != 0);
1955 if (__pyx_t_3) {
1956 } else {
1957 __pyx_t_1 = __pyx_t_3;
1958 goto __pyx_L7_bool_binop_done;
1959 }
1960 __pyx_t_3 = ((__pyx_v_amount < __pyx_v_spaceleft) != 0);
1961 __pyx_t_1 = __pyx_t_3;
1962 __pyx_L7_bool_binop_done:;
1963 if (__pyx_t_1) {
1964
1965 /* "bx/misc/_seekbzip2.pyx":102
1966 * while amount != 0:
1967 * if amount > 0 and amount < spaceleft:
1968 * desired = amount # <<<<<<<<<<<<<<
1969 * else:
1970 * desired = spaceleft
1971 */
1972 __pyx_v_desired = __pyx_v_amount;
1973
1974 /* "bx/misc/_seekbzip2.pyx":101
1975 * spaceleft = 8192
1976 * while amount != 0:
1977 * if amount > 0 and amount < spaceleft: # <<<<<<<<<<<<<<
1978 * desired = amount
1979 * else:
1980 */
1981 goto __pyx_L6;
1982 }
1983
1984 /* "bx/misc/_seekbzip2.pyx":104
1985 * desired = amount
1986 * else:
1987 * desired = spaceleft # <<<<<<<<<<<<<<
1988 * ## sys.stderr.write( "readline, amount: %d\n" % amount )
1989 * ## sys.stderr.write( "buffer: %r" % rval[:100] )
1990 */
1991 /*else*/ {
1992 __pyx_v_desired = __pyx_v_spaceleft;
1993 }
1994 __pyx_L6:;
1995
1996 /* "bx/misc/_seekbzip2.pyx":110
1997 * ## sys.stderr.flush()
1998 * # ord( "\n" ) = 10
1999 * status = read_bunzip_to_char( self.bd, p_rval, desired, &gotcount, 10 ); # <<<<<<<<<<<<<<
2000 * ## sys.stderr.write( "readline, desired: %d, gotcount: %d\n" % ( desired, gotcount ) );
2001 * ## sys.stderr.write( "buffer: %r" % rval[:100] )
2002 */
2003 __pyx_v_status = read_bunzip_to_char(__pyx_v_self->bd, __pyx_v_p_rval, __pyx_v_desired, (&__pyx_v_gotcount), 10);
2004
2005 /* "bx/misc/_seekbzip2.pyx":115
2006 * ## sys.stderr.write( "\n" )
2007 * ## sys.stderr.flush()
2008 * if status == -9: # <<<<<<<<<<<<<<
2009 * ## sys.stderr.write( "readline, STOP_CHAR\n" ); sys.stderr.flush()
2010 * # Reached the stop character (RETVAL_STOPCHAR == -9), so
2011 */
2012 switch (__pyx_v_status) {
2013 case -9L:
2014
2015 /* "bx/misc/_seekbzip2.pyx":119
2016 * # Reached the stop character (RETVAL_STOPCHAR == -9), so
2017 * # we can stop
2018 * chunks.append( rval[:8192-spaceleft+gotcount] ) # <<<<<<<<<<<<<<
2019 * break
2020 * elif status == -10:
2021 */
2022 __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_rval, 0, ((0x2000 - __pyx_v_spaceleft) + __pyx_v_gotcount), NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 119, __pyx_L1_error)
2023 __Pyx_GOTREF(__pyx_t_2);
2024 __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_chunks, __pyx_t_2); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 119, __pyx_L1_error)
2025 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2026
2027 /* "bx/misc/_seekbzip2.pyx":120
2028 * # we can stop
2029 * chunks.append( rval[:8192-spaceleft+gotcount] )
2030 * break # <<<<<<<<<<<<<<
2031 * elif status == -10:
2032 * ## sys.stderr.write( "readline, BUFFER_FULL\n" ); sys.stderr.flush()
2033 */
2034 goto __pyx_L5_break;
2035
2036 /* "bx/misc/_seekbzip2.pyx":115
2037 * ## sys.stderr.write( "\n" )
2038 * ## sys.stderr.flush()
2039 * if status == -9: # <<<<<<<<<<<<<<
2040 * ## sys.stderr.write( "readline, STOP_CHAR\n" ); sys.stderr.flush()
2041 * # Reached the stop character (RETVAL_STOPCHAR == -9), so
2042 */
2043 break;
2044 case -10L:
2045
2046 /* "bx/misc/_seekbzip2.pyx":125
2047 * # Filled the buffer (RETVAL_BUFFER_FULL == -10), so create
2048 * # new buffer and keep going
2049 * chunks.append( rval ) # <<<<<<<<<<<<<<
2050 * amount = amount - gotcount
2051 * if amount == 0:
2052 */
2053 __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_chunks, __pyx_v_rval); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 125, __pyx_L1_error)
2054
2055 /* "bx/misc/_seekbzip2.pyx":126
2056 * # new buffer and keep going
2057 * chunks.append( rval )
2058 * amount = amount - gotcount # <<<<<<<<<<<<<<
2059 * if amount == 0:
2060 * # Got the desired amount
2061 */
2062 __pyx_v_amount = (__pyx_v_amount - __pyx_v_gotcount);
2063
2064 /* "bx/misc/_seekbzip2.pyx":127
2065 * chunks.append( rval )
2066 * amount = amount - gotcount
2067 * if amount == 0: # <<<<<<<<<<<<<<
2068 * # Got the desired amount
2069 * break
2070 */
2071 __pyx_t_1 = ((__pyx_v_amount == 0) != 0);
2072 if (__pyx_t_1) {
2073
2074 /* "bx/misc/_seekbzip2.pyx":129
2075 * if amount == 0:
2076 * # Got the desired amount
2077 * break # <<<<<<<<<<<<<<
2078 * rval = PyBytes_FromStringAndSize( NULL, 8192 )
2079 * p_rval = PyBytes_AsString( rval )
2080 */
2081 goto __pyx_L5_break;
2082
2083 /* "bx/misc/_seekbzip2.pyx":127
2084 * chunks.append( rval )
2085 * amount = amount - gotcount
2086 * if amount == 0: # <<<<<<<<<<<<<<
2087 * # Got the desired amount
2088 * break
2089 */
2090 }
2091
2092 /* "bx/misc/_seekbzip2.pyx":130
2093 * # Got the desired amount
2094 * break
2095 * rval = PyBytes_FromStringAndSize( NULL, 8192 ) # <<<<<<<<<<<<<<
2096 * p_rval = PyBytes_AsString( rval )
2097 * spaceleft = 8192
2098 */
2099 __pyx_t_2 = PyBytes_FromStringAndSize(NULL, 0x2000); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 130, __pyx_L1_error)
2100 __Pyx_GOTREF(__pyx_t_2);
2101 __Pyx_DECREF_SET(__pyx_v_rval, __pyx_t_2);
2102 __pyx_t_2 = 0;
2103
2104 /* "bx/misc/_seekbzip2.pyx":131
2105 * break
2106 * rval = PyBytes_FromStringAndSize( NULL, 8192 )
2107 * p_rval = PyBytes_AsString( rval ) # <<<<<<<<<<<<<<
2108 * spaceleft = 8192
2109 * elif status == -8:
2110 */
2111 __pyx_v_p_rval = PyBytes_AsString(__pyx_v_rval);
2112
2113 /* "bx/misc/_seekbzip2.pyx":132
2114 * rval = PyBytes_FromStringAndSize( NULL, 8192 )
2115 * p_rval = PyBytes_AsString( rval )
2116 * spaceleft = 8192 # <<<<<<<<<<<<<<
2117 * elif status == -8:
2118 * ## sys.stderr.write( "readline, END_OF_BLOCK\n" ); sys.stderr.flush()
2119 */
2120 __pyx_v_spaceleft = 0x2000;
2121
2122 /* "bx/misc/_seekbzip2.pyx":121
2123 * chunks.append( rval[:8192-spaceleft+gotcount] )
2124 * break
2125 * elif status == -10: # <<<<<<<<<<<<<<
2126 * ## sys.stderr.write( "readline, BUFFER_FULL\n" ); sys.stderr.flush()
2127 * # Filled the buffer (RETVAL_BUFFER_FULL == -10), so create
2128 */
2129 break;
2130 case -8L:
2131
2132 /* "bx/misc/_seekbzip2.pyx":136
2133 * ## sys.stderr.write( "readline, END_OF_BLOCK\n" ); sys.stderr.flush()
2134 * # No more data in the decomp buffer (RETVAL_END_OF_BLOCK == -10)
2135 * if gotcount and p_rval[ gotcount - 1 ] == 10: # <<<<<<<<<<<<<<
2136 * chunks.append( rval[:8192-spaceleft+gotcount] )
2137 * break
2138 */
2139 __pyx_t_3 = (__pyx_v_gotcount != 0);
2140 if (__pyx_t_3) {
2141 } else {
2142 __pyx_t_1 = __pyx_t_3;
2143 goto __pyx_L11_bool_binop_done;
2144 }
2145 __pyx_t_3 = (((__pyx_v_p_rval[(__pyx_v_gotcount - 1)]) == 10) != 0);
2146 __pyx_t_1 = __pyx_t_3;
2147 __pyx_L11_bool_binop_done:;
2148 if (__pyx_t_1) {
2149
2150 /* "bx/misc/_seekbzip2.pyx":137
2151 * # No more data in the decomp buffer (RETVAL_END_OF_BLOCK == -10)
2152 * if gotcount and p_rval[ gotcount - 1 ] == 10:
2153 * chunks.append( rval[:8192-spaceleft+gotcount] ) # <<<<<<<<<<<<<<
2154 * break
2155 * # Update buffer info
2156 */
2157 __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_rval, 0, ((0x2000 - __pyx_v_spaceleft) + __pyx_v_gotcount), NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 137, __pyx_L1_error)
2158 __Pyx_GOTREF(__pyx_t_2);
2159 __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_chunks, __pyx_t_2); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 137, __pyx_L1_error)
2160 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2161
2162 /* "bx/misc/_seekbzip2.pyx":138
2163 * if gotcount and p_rval[ gotcount - 1 ] == 10:
2164 * chunks.append( rval[:8192-spaceleft+gotcount] )
2165 * break # <<<<<<<<<<<<<<
2166 * # Update buffer info
2167 * p_rval = p_rval + gotcount
2168 */
2169 goto __pyx_L5_break;
2170
2171 /* "bx/misc/_seekbzip2.pyx":136
2172 * ## sys.stderr.write( "readline, END_OF_BLOCK\n" ); sys.stderr.flush()
2173 * # No more data in the decomp buffer (RETVAL_END_OF_BLOCK == -10)
2174 * if gotcount and p_rval[ gotcount - 1 ] == 10: # <<<<<<<<<<<<<<
2175 * chunks.append( rval[:8192-spaceleft+gotcount] )
2176 * break
2177 */
2178 }
2179
2180 /* "bx/misc/_seekbzip2.pyx":140
2181 * break
2182 * # Update buffer info
2183 * p_rval = p_rval + gotcount # <<<<<<<<<<<<<<
2184 * spaceleft = spaceleft - gotcount
2185 * amount = amount - gotcount
2186 */
2187 __pyx_v_p_rval = (__pyx_v_p_rval + __pyx_v_gotcount);
2188
2189 /* "bx/misc/_seekbzip2.pyx":141
2190 * # Update buffer info
2191 * p_rval = p_rval + gotcount
2192 * spaceleft = spaceleft - gotcount # <<<<<<<<<<<<<<
2193 * amount = amount - gotcount
2194 * # Get the next block
2195 */
2196 __pyx_v_spaceleft = (__pyx_v_spaceleft - __pyx_v_gotcount);
2197
2198 /* "bx/misc/_seekbzip2.pyx":142
2199 * p_rval = p_rval + gotcount
2200 * spaceleft = spaceleft - gotcount
2201 * amount = amount - gotcount # <<<<<<<<<<<<<<
2202 * # Get the next block
2203 * status = get_next_block( self.bd )
2204 */
2205 __pyx_v_amount = (__pyx_v_amount - __pyx_v_gotcount);
2206
2207 /* "bx/misc/_seekbzip2.pyx":144
2208 * amount = amount - gotcount
2209 * # Get the next block
2210 * status = get_next_block( self.bd ) # <<<<<<<<<<<<<<
2211 * if status == -1:
2212 * # Block is end of stream block (RETVAL_LAST_BLOCK == -1)
2213 */
2214 __pyx_v_status = get_next_block(__pyx_v_self->bd);
2215
2216 /* "bx/misc/_seekbzip2.pyx":145
2217 * # Get the next block
2218 * status = get_next_block( self.bd )
2219 * if status == -1: # <<<<<<<<<<<<<<
2220 * # Block is end of stream block (RETVAL_LAST_BLOCK == -1)
2221 * self.at_eof = 1
2222 */
2223 __pyx_t_1 = ((__pyx_v_status == -1L) != 0);
2224 if (__pyx_t_1) {
2225
2226 /* "bx/misc/_seekbzip2.pyx":147
2227 * if status == -1:
2228 * # Block is end of stream block (RETVAL_LAST_BLOCK == -1)
2229 * self.at_eof = 1 # <<<<<<<<<<<<<<
2230 * chunks.append( rval[:gotcount] )
2231 * break
2232 */
2233 __pyx_v_self->at_eof = 1;
2234
2235 /* "bx/misc/_seekbzip2.pyx":148
2236 * # Block is end of stream block (RETVAL_LAST_BLOCK == -1)
2237 * self.at_eof = 1
2238 * chunks.append( rval[:gotcount] ) # <<<<<<<<<<<<<<
2239 * break
2240 * self.bd.writeCRC = 0xffffffff
2241 */
2242 __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_rval, 0, __pyx_v_gotcount, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 148, __pyx_L1_error)
2243 __Pyx_GOTREF(__pyx_t_2);
2244 __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_chunks, __pyx_t_2); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 148, __pyx_L1_error)
2245 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2246
2247 /* "bx/misc/_seekbzip2.pyx":149
2248 * self.at_eof = 1
2249 * chunks.append( rval[:gotcount] )
2250 * break # <<<<<<<<<<<<<<
2251 * self.bd.writeCRC = 0xffffffff
2252 * self.bd.writeCopies = 0
2253 */
2254 goto __pyx_L5_break;
2255
2256 /* "bx/misc/_seekbzip2.pyx":145
2257 * # Get the next block
2258 * status = get_next_block( self.bd )
2259 * if status == -1: # <<<<<<<<<<<<<<
2260 * # Block is end of stream block (RETVAL_LAST_BLOCK == -1)
2261 * self.at_eof = 1
2262 */
2263 }
2264
2265 /* "bx/misc/_seekbzip2.pyx":150
2266 * chunks.append( rval[:gotcount] )
2267 * break
2268 * self.bd.writeCRC = 0xffffffff # <<<<<<<<<<<<<<
2269 * self.bd.writeCopies = 0
2270 * else:
2271 */
2272 __pyx_v_self->bd->writeCRC = 0xffffffff;
2273
2274 /* "bx/misc/_seekbzip2.pyx":151
2275 * break
2276 * self.bd.writeCRC = 0xffffffff
2277 * self.bd.writeCopies = 0 # <<<<<<<<<<<<<<
2278 * else:
2279 * # Some other status
2280 */
2281 __pyx_v_self->bd->writeCopies = 0;
2282
2283 /* "bx/misc/_seekbzip2.pyx":133
2284 * p_rval = PyBytes_AsString( rval )
2285 * spaceleft = 8192
2286 * elif status == -8: # <<<<<<<<<<<<<<
2287 * ## sys.stderr.write( "readline, END_OF_BLOCK\n" ); sys.stderr.flush()
2288 * # No more data in the decomp buffer (RETVAL_END_OF_BLOCK == -10)
2289 */
2290 break;
2291 default:
2292
2293 /* "bx/misc/_seekbzip2.pyx":154
2294 * else:
2295 * # Some other status
2296 * raise Exception( "read_bunzip error %d" % status ) # <<<<<<<<<<<<<<
2297 * # Return whatever we read
2298 * return "".join( chunks )
2299 */
2300 __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 154, __pyx_L1_error)
2301 __Pyx_GOTREF(__pyx_t_2);
2302 __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_read_bunzip_error_d, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 154, __pyx_L1_error)
2303 __Pyx_GOTREF(__pyx_t_5);
2304 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2305 __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 154, __pyx_L1_error)
2306 __Pyx_GOTREF(__pyx_t_2);
2307 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2308 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
2309 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2310 __PYX_ERR(1, 154, __pyx_L1_error)
2311 break;
2312 }
2313 }
2314 __pyx_L5_break:;
2315
2316 /* "bx/misc/_seekbzip2.pyx":156
2317 * raise Exception( "read_bunzip error %d" % status )
2318 * # Return whatever we read
2319 * return "".join( chunks ) # <<<<<<<<<<<<<<
2320 *
2321 * def read( self, int amount ):
2322 */
2323 __Pyx_XDECREF(__pyx_r);
2324 __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__2, __pyx_v_chunks); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 156, __pyx_L1_error)
2325 __Pyx_GOTREF(__pyx_t_2);
2326 __pyx_r = __pyx_t_2;
2327 __pyx_t_2 = 0;
2328 goto __pyx_L0;
2329
2330 /* "bx/misc/_seekbzip2.pyx":81
2331 * self.at_eof = 0
2332 *
2333 * def readline( self, int amount ): # <<<<<<<<<<<<<<
2334 * cdef object rval
2335 * cdef char * p_rval
2336 */
2337
2338 /* function exit code */
2339 __pyx_L1_error:;
2340 __Pyx_XDECREF(__pyx_t_2);
2341 __Pyx_XDECREF(__pyx_t_5);
2342 __Pyx_AddTraceback("bx.misc._seekbzip2.SeekBzip2.readline", __pyx_clineno, __pyx_lineno, __pyx_filename);
2343 __pyx_r = NULL;
2344 __pyx_L0:;
2345 __Pyx_XDECREF(__pyx_v_rval);
2346 __Pyx_XDECREF(__pyx_v_chunks);
2347 __Pyx_XGIVEREF(__pyx_r);
2348 __Pyx_RefNannyFinishContext();
2349 return __pyx_r;
2350 }
2351
2352 /* "bx/misc/_seekbzip2.pyx":158
2353 * return "".join( chunks )
2354 *
2355 * def read( self, int amount ): # <<<<<<<<<<<<<<
2356 * cdef object rval
2357 * cdef char * p_rval
2358 */
2359
2360 /* Python wrapper */
2361 static PyObject *__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_9read(PyObject *__pyx_v_self, PyObject *__pyx_arg_amount); /*proto*/
__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_9read(PyObject * __pyx_v_self,PyObject * __pyx_arg_amount)2362 static PyObject *__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_9read(PyObject *__pyx_v_self, PyObject *__pyx_arg_amount) {
2363 int __pyx_v_amount;
2364 int __pyx_lineno = 0;
2365 const char *__pyx_filename = NULL;
2366 int __pyx_clineno = 0;
2367 PyObject *__pyx_r = 0;
2368 __Pyx_RefNannyDeclarations
2369 __Pyx_RefNannySetupContext("read (wrapper)", 0);
2370 assert(__pyx_arg_amount); {
2371 __pyx_v_amount = __Pyx_PyInt_As_int(__pyx_arg_amount); if (unlikely((__pyx_v_amount == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 158, __pyx_L3_error)
2372 }
2373 goto __pyx_L4_argument_unpacking_done;
2374 __pyx_L3_error:;
2375 __Pyx_AddTraceback("bx.misc._seekbzip2.SeekBzip2.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
2376 __Pyx_RefNannyFinishContext();
2377 return NULL;
2378 __pyx_L4_argument_unpacking_done:;
2379 __pyx_r = __pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_8read(((struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *)__pyx_v_self), ((int)__pyx_v_amount));
2380
2381 /* function exit code */
2382 __Pyx_RefNannyFinishContext();
2383 return __pyx_r;
2384 }
2385
__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_8read(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 * __pyx_v_self,int __pyx_v_amount)2386 static PyObject *__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_8read(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *__pyx_v_self, int __pyx_v_amount) {
2387 PyObject *__pyx_v_rval = 0;
2388 char *__pyx_v_p_rval;
2389 int __pyx_v_gotcount;
2390 int __pyx_v_totalcount;
2391 int __pyx_v_status;
2392 PyObject *__pyx_r = NULL;
2393 __Pyx_RefNannyDeclarations
2394 int __pyx_t_1;
2395 PyObject *__pyx_t_2 = NULL;
2396 PyObject *__pyx_t_3 = NULL;
2397 int __pyx_lineno = 0;
2398 const char *__pyx_filename = NULL;
2399 int __pyx_clineno = 0;
2400 __Pyx_RefNannySetupContext("read", 0);
2401
2402 /* "bx/misc/_seekbzip2.pyx":164
2403 * cdef int totalcount
2404 * cdef int status
2405 * totalcount = 0 # <<<<<<<<<<<<<<
2406 * # If already at EOF return None
2407 * if self.at_eof:
2408 */
2409 __pyx_v_totalcount = 0;
2410
2411 /* "bx/misc/_seekbzip2.pyx":166
2412 * totalcount = 0
2413 * # If already at EOF return None
2414 * if self.at_eof: # <<<<<<<<<<<<<<
2415 * return None
2416 * # Create a new python bytes string large enough to hold the result
2417 */
2418 __pyx_t_1 = (__pyx_v_self->at_eof != 0);
2419 if (__pyx_t_1) {
2420
2421 /* "bx/misc/_seekbzip2.pyx":167
2422 * # If already at EOF return None
2423 * if self.at_eof:
2424 * return None # <<<<<<<<<<<<<<
2425 * # Create a new python bytes string large enough to hold the result
2426 * rval = PyBytes_FromStringAndSize( NULL, amount )
2427 */
2428 __Pyx_XDECREF(__pyx_r);
2429 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2430 goto __pyx_L0;
2431
2432 /* "bx/misc/_seekbzip2.pyx":166
2433 * totalcount = 0
2434 * # If already at EOF return None
2435 * if self.at_eof: # <<<<<<<<<<<<<<
2436 * return None
2437 * # Create a new python bytes string large enough to hold the result
2438 */
2439 }
2440
2441 /* "bx/misc/_seekbzip2.pyx":169
2442 * return None
2443 * # Create a new python bytes string large enough to hold the result
2444 * rval = PyBytes_FromStringAndSize( NULL, amount ) # <<<<<<<<<<<<<<
2445 * p_rval = PyBytes_AsString( rval )
2446 * # Read into it
2447 */
2448 __pyx_t_2 = PyBytes_FromStringAndSize(NULL, __pyx_v_amount); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 169, __pyx_L1_error)
2449 __Pyx_GOTREF(__pyx_t_2);
2450 __pyx_v_rval = __pyx_t_2;
2451 __pyx_t_2 = 0;
2452
2453 /* "bx/misc/_seekbzip2.pyx":170
2454 * # Create a new python bytes string large enough to hold the result
2455 * rval = PyBytes_FromStringAndSize( NULL, amount )
2456 * p_rval = PyBytes_AsString( rval ) # <<<<<<<<<<<<<<
2457 * # Read into it
2458 * ## sys.stderr.write( "read called, bd.current: %x\n" % self.bd.writeCurrent ); sys.stderr.flush()
2459 */
2460 __pyx_v_p_rval = PyBytes_AsString(__pyx_v_rval);
2461
2462 /* "bx/misc/_seekbzip2.pyx":173
2463 * # Read into it
2464 * ## sys.stderr.write( "read called, bd.current: %x\n" % self.bd.writeCurrent ); sys.stderr.flush()
2465 * while amount > 0: # <<<<<<<<<<<<<<
2466 * gotcount = read_bunzip( self.bd, p_rval, amount );
2467 * if gotcount < 0:
2468 */
2469 while (1) {
2470 __pyx_t_1 = ((__pyx_v_amount > 0) != 0);
2471 if (!__pyx_t_1) break;
2472
2473 /* "bx/misc/_seekbzip2.pyx":174
2474 * ## sys.stderr.write( "read called, bd.current: %x\n" % self.bd.writeCurrent ); sys.stderr.flush()
2475 * while amount > 0:
2476 * gotcount = read_bunzip( self.bd, p_rval, amount ); # <<<<<<<<<<<<<<
2477 * if gotcount < 0:
2478 * raise Exception( "read_bunzip error %d" % gotcount )
2479 */
2480 __pyx_v_gotcount = read_bunzip(__pyx_v_self->bd, __pyx_v_p_rval, __pyx_v_amount);
2481
2482 /* "bx/misc/_seekbzip2.pyx":175
2483 * while amount > 0:
2484 * gotcount = read_bunzip( self.bd, p_rval, amount );
2485 * if gotcount < 0: # <<<<<<<<<<<<<<
2486 * raise Exception( "read_bunzip error %d" % gotcount )
2487 * elif gotcount == 0:
2488 */
2489 __pyx_t_1 = ((__pyx_v_gotcount < 0) != 0);
2490 if (unlikely(__pyx_t_1)) {
2491
2492 /* "bx/misc/_seekbzip2.pyx":176
2493 * gotcount = read_bunzip( self.bd, p_rval, amount );
2494 * if gotcount < 0:
2495 * raise Exception( "read_bunzip error %d" % gotcount ) # <<<<<<<<<<<<<<
2496 * elif gotcount == 0:
2497 * status = get_next_block( self.bd )
2498 */
2499 __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_gotcount); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 176, __pyx_L1_error)
2500 __Pyx_GOTREF(__pyx_t_2);
2501 __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_read_bunzip_error_d, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 176, __pyx_L1_error)
2502 __Pyx_GOTREF(__pyx_t_3);
2503 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2504 __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 176, __pyx_L1_error)
2505 __Pyx_GOTREF(__pyx_t_2);
2506 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2507 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
2508 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2509 __PYX_ERR(1, 176, __pyx_L1_error)
2510
2511 /* "bx/misc/_seekbzip2.pyx":175
2512 * while amount > 0:
2513 * gotcount = read_bunzip( self.bd, p_rval, amount );
2514 * if gotcount < 0: # <<<<<<<<<<<<<<
2515 * raise Exception( "read_bunzip error %d" % gotcount )
2516 * elif gotcount == 0:
2517 */
2518 }
2519
2520 /* "bx/misc/_seekbzip2.pyx":177
2521 * if gotcount < 0:
2522 * raise Exception( "read_bunzip error %d" % gotcount )
2523 * elif gotcount == 0: # <<<<<<<<<<<<<<
2524 * status = get_next_block( self.bd )
2525 * if status == -1:
2526 */
2527 __pyx_t_1 = ((__pyx_v_gotcount == 0) != 0);
2528 if (__pyx_t_1) {
2529
2530 /* "bx/misc/_seekbzip2.pyx":178
2531 * raise Exception( "read_bunzip error %d" % gotcount )
2532 * elif gotcount == 0:
2533 * status = get_next_block( self.bd ) # <<<<<<<<<<<<<<
2534 * if status == -1:
2535 * self.at_eof = 1
2536 */
2537 __pyx_v_status = get_next_block(__pyx_v_self->bd);
2538
2539 /* "bx/misc/_seekbzip2.pyx":179
2540 * elif gotcount == 0:
2541 * status = get_next_block( self.bd )
2542 * if status == -1: # <<<<<<<<<<<<<<
2543 * self.at_eof = 1
2544 * break
2545 */
2546 __pyx_t_1 = ((__pyx_v_status == -1L) != 0);
2547 if (__pyx_t_1) {
2548
2549 /* "bx/misc/_seekbzip2.pyx":180
2550 * status = get_next_block( self.bd )
2551 * if status == -1:
2552 * self.at_eof = 1 # <<<<<<<<<<<<<<
2553 * break
2554 * self.bd.writeCRC = 0xffffffff
2555 */
2556 __pyx_v_self->at_eof = 1;
2557
2558 /* "bx/misc/_seekbzip2.pyx":181
2559 * if status == -1:
2560 * self.at_eof = 1
2561 * break # <<<<<<<<<<<<<<
2562 * self.bd.writeCRC = 0xffffffff
2563 * self.bd.writeCopies = 0
2564 */
2565 goto __pyx_L5_break;
2566
2567 /* "bx/misc/_seekbzip2.pyx":179
2568 * elif gotcount == 0:
2569 * status = get_next_block( self.bd )
2570 * if status == -1: # <<<<<<<<<<<<<<
2571 * self.at_eof = 1
2572 * break
2573 */
2574 }
2575
2576 /* "bx/misc/_seekbzip2.pyx":182
2577 * self.at_eof = 1
2578 * break
2579 * self.bd.writeCRC = 0xffffffff # <<<<<<<<<<<<<<
2580 * self.bd.writeCopies = 0
2581 * else:
2582 */
2583 __pyx_v_self->bd->writeCRC = 0xffffffff;
2584
2585 /* "bx/misc/_seekbzip2.pyx":183
2586 * break
2587 * self.bd.writeCRC = 0xffffffff
2588 * self.bd.writeCopies = 0 # <<<<<<<<<<<<<<
2589 * else:
2590 * totalcount = totalcount + gotcount
2591 */
2592 __pyx_v_self->bd->writeCopies = 0;
2593
2594 /* "bx/misc/_seekbzip2.pyx":177
2595 * if gotcount < 0:
2596 * raise Exception( "read_bunzip error %d" % gotcount )
2597 * elif gotcount == 0: # <<<<<<<<<<<<<<
2598 * status = get_next_block( self.bd )
2599 * if status == -1:
2600 */
2601 goto __pyx_L6;
2602 }
2603
2604 /* "bx/misc/_seekbzip2.pyx":185
2605 * self.bd.writeCopies = 0
2606 * else:
2607 * totalcount = totalcount + gotcount # <<<<<<<<<<<<<<
2608 * amount = amount - gotcount
2609 * p_rval = p_rval + gotcount
2610 */
2611 /*else*/ {
2612 __pyx_v_totalcount = (__pyx_v_totalcount + __pyx_v_gotcount);
2613
2614 /* "bx/misc/_seekbzip2.pyx":186
2615 * else:
2616 * totalcount = totalcount + gotcount
2617 * amount = amount - gotcount # <<<<<<<<<<<<<<
2618 * p_rval = p_rval + gotcount
2619 * # Return whatever we read
2620 */
2621 __pyx_v_amount = (__pyx_v_amount - __pyx_v_gotcount);
2622
2623 /* "bx/misc/_seekbzip2.pyx":187
2624 * totalcount = totalcount + gotcount
2625 * amount = amount - gotcount
2626 * p_rval = p_rval + gotcount # <<<<<<<<<<<<<<
2627 * # Return whatever we read
2628 * return rval[:totalcount]
2629 */
2630 __pyx_v_p_rval = (__pyx_v_p_rval + __pyx_v_gotcount);
2631 }
2632 __pyx_L6:;
2633 }
2634 __pyx_L5_break:;
2635
2636 /* "bx/misc/_seekbzip2.pyx":189
2637 * p_rval = p_rval + gotcount
2638 * # Return whatever we read
2639 * return rval[:totalcount] # <<<<<<<<<<<<<<
2640 */
2641 __Pyx_XDECREF(__pyx_r);
2642 __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_rval, 0, __pyx_v_totalcount, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 189, __pyx_L1_error)
2643 __Pyx_GOTREF(__pyx_t_2);
2644 __pyx_r = __pyx_t_2;
2645 __pyx_t_2 = 0;
2646 goto __pyx_L0;
2647
2648 /* "bx/misc/_seekbzip2.pyx":158
2649 * return "".join( chunks )
2650 *
2651 * def read( self, int amount ): # <<<<<<<<<<<<<<
2652 * cdef object rval
2653 * cdef char * p_rval
2654 */
2655
2656 /* function exit code */
2657 __pyx_L1_error:;
2658 __Pyx_XDECREF(__pyx_t_2);
2659 __Pyx_XDECREF(__pyx_t_3);
2660 __Pyx_AddTraceback("bx.misc._seekbzip2.SeekBzip2.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
2661 __pyx_r = NULL;
2662 __pyx_L0:;
2663 __Pyx_XDECREF(__pyx_v_rval);
2664 __Pyx_XGIVEREF(__pyx_r);
2665 __Pyx_RefNannyFinishContext();
2666 return __pyx_r;
2667 }
2668
2669 /* "(tree fragment)":1
2670 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
2671 * raise TypeError("self.bd cannot be converted to a Python object for pickling")
2672 * def __setstate_cython__(self, __pyx_state):
2673 */
2674
2675 /* Python wrapper */
2676 static PyObject *__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_11__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)2677 static PyObject *__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
2678 PyObject *__pyx_r = 0;
2679 __Pyx_RefNannyDeclarations
2680 __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
2681 __pyx_r = __pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_10__reduce_cython__(((struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *)__pyx_v_self));
2682
2683 /* function exit code */
2684 __Pyx_RefNannyFinishContext();
2685 return __pyx_r;
2686 }
2687
__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 * __pyx_v_self)2688 static PyObject *__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *__pyx_v_self) {
2689 PyObject *__pyx_r = NULL;
2690 __Pyx_RefNannyDeclarations
2691 PyObject *__pyx_t_1 = NULL;
2692 int __pyx_lineno = 0;
2693 const char *__pyx_filename = NULL;
2694 int __pyx_clineno = 0;
2695 __Pyx_RefNannySetupContext("__reduce_cython__", 0);
2696
2697 /* "(tree fragment)":2
2698 * def __reduce_cython__(self):
2699 * raise TypeError("self.bd cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
2700 * def __setstate_cython__(self, __pyx_state):
2701 * raise TypeError("self.bd cannot be converted to a Python object for pickling")
2702 */
2703 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error)
2704 __Pyx_GOTREF(__pyx_t_1);
2705 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
2706 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2707 __PYX_ERR(0, 2, __pyx_L1_error)
2708
2709 /* "(tree fragment)":1
2710 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
2711 * raise TypeError("self.bd cannot be converted to a Python object for pickling")
2712 * def __setstate_cython__(self, __pyx_state):
2713 */
2714
2715 /* function exit code */
2716 __pyx_L1_error:;
2717 __Pyx_XDECREF(__pyx_t_1);
2718 __Pyx_AddTraceback("bx.misc._seekbzip2.SeekBzip2.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2719 __pyx_r = NULL;
2720 __Pyx_XGIVEREF(__pyx_r);
2721 __Pyx_RefNannyFinishContext();
2722 return __pyx_r;
2723 }
2724
2725 /* "(tree fragment)":3
2726 * def __reduce_cython__(self):
2727 * raise TypeError("self.bd cannot be converted to a Python object for pickling")
2728 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
2729 * raise TypeError("self.bd cannot be converted to a Python object for pickling")
2730 */
2731
2732 /* Python wrapper */
2733 static PyObject *__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_13__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)2734 static PyObject *__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
2735 PyObject *__pyx_r = 0;
2736 __Pyx_RefNannyDeclarations
2737 __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
2738 __pyx_r = __pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_12__setstate_cython__(((struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
2739
2740 /* function exit code */
2741 __Pyx_RefNannyFinishContext();
2742 return __pyx_r;
2743 }
2744
__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)2745 static PyObject *__pyx_pf_2bx_4misc_10_seekbzip2_9SeekBzip2_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2 *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
2746 PyObject *__pyx_r = NULL;
2747 __Pyx_RefNannyDeclarations
2748 PyObject *__pyx_t_1 = NULL;
2749 int __pyx_lineno = 0;
2750 const char *__pyx_filename = NULL;
2751 int __pyx_clineno = 0;
2752 __Pyx_RefNannySetupContext("__setstate_cython__", 0);
2753
2754 /* "(tree fragment)":4
2755 * raise TypeError("self.bd cannot be converted to a Python object for pickling")
2756 * def __setstate_cython__(self, __pyx_state):
2757 * raise TypeError("self.bd cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
2758 */
2759 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
2760 __Pyx_GOTREF(__pyx_t_1);
2761 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
2762 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2763 __PYX_ERR(0, 4, __pyx_L1_error)
2764
2765 /* "(tree fragment)":3
2766 * def __reduce_cython__(self):
2767 * raise TypeError("self.bd cannot be converted to a Python object for pickling")
2768 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
2769 * raise TypeError("self.bd cannot be converted to a Python object for pickling")
2770 */
2771
2772 /* function exit code */
2773 __pyx_L1_error:;
2774 __Pyx_XDECREF(__pyx_t_1);
2775 __Pyx_AddTraceback("bx.misc._seekbzip2.SeekBzip2.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2776 __pyx_r = NULL;
2777 __Pyx_XGIVEREF(__pyx_r);
2778 __Pyx_RefNannyFinishContext();
2779 return __pyx_r;
2780 }
2781
__pyx_tp_new_2bx_4misc_10_seekbzip2_SeekBzip2(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)2782 static PyObject *__pyx_tp_new_2bx_4misc_10_seekbzip2_SeekBzip2(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
2783 PyObject *o;
2784 if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
2785 o = (*t->tp_alloc)(t, 0);
2786 } else {
2787 o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
2788 }
2789 if (unlikely(!o)) return 0;
2790 return o;
2791 }
2792
__pyx_tp_dealloc_2bx_4misc_10_seekbzip2_SeekBzip2(PyObject * o)2793 static void __pyx_tp_dealloc_2bx_4misc_10_seekbzip2_SeekBzip2(PyObject *o) {
2794 #if CYTHON_USE_TP_FINALIZE
2795 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))) {
2796 if (PyObject_CallFinalizerFromDealloc(o)) return;
2797 }
2798 #endif
2799 (*Py_TYPE(o)->tp_free)(o);
2800 }
2801
2802 static PyMethodDef __pyx_methods_2bx_4misc_10_seekbzip2_SeekBzip2[] = {
2803 {"close", (PyCFunction)__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_3close, METH_NOARGS, 0},
2804 {"seek", (PyCFunction)__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_5seek, METH_O, __pyx_doc_2bx_4misc_10_seekbzip2_9SeekBzip2_4seek},
2805 {"readline", (PyCFunction)__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_7readline, METH_O, 0},
2806 {"read", (PyCFunction)__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_9read, METH_O, 0},
2807 {"__reduce_cython__", (PyCFunction)__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_11__reduce_cython__, METH_NOARGS, 0},
2808 {"__setstate_cython__", (PyCFunction)__pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_13__setstate_cython__, METH_O, 0},
2809 {0, 0, 0, 0}
2810 };
2811
2812 static PyTypeObject __pyx_type_2bx_4misc_10_seekbzip2_SeekBzip2 = {
2813 PyVarObject_HEAD_INIT(0, 0)
2814 "bx.misc._seekbzip2.SeekBzip2", /*tp_name*/
2815 sizeof(struct __pyx_obj_2bx_4misc_10_seekbzip2_SeekBzip2), /*tp_basicsize*/
2816 0, /*tp_itemsize*/
2817 __pyx_tp_dealloc_2bx_4misc_10_seekbzip2_SeekBzip2, /*tp_dealloc*/
2818 #if PY_VERSION_HEX < 0x030800b4
2819 0, /*tp_print*/
2820 #endif
2821 #if PY_VERSION_HEX >= 0x030800b4
2822 0, /*tp_vectorcall_offset*/
2823 #endif
2824 0, /*tp_getattr*/
2825 0, /*tp_setattr*/
2826 #if PY_MAJOR_VERSION < 3
2827 0, /*tp_compare*/
2828 #endif
2829 #if PY_MAJOR_VERSION >= 3
2830 0, /*tp_as_async*/
2831 #endif
2832 0, /*tp_repr*/
2833 0, /*tp_as_number*/
2834 0, /*tp_as_sequence*/
2835 0, /*tp_as_mapping*/
2836 0, /*tp_hash*/
2837 0, /*tp_call*/
2838 0, /*tp_str*/
2839 0, /*tp_getattro*/
2840 0, /*tp_setattro*/
2841 0, /*tp_as_buffer*/
2842 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
2843 0, /*tp_doc*/
2844 0, /*tp_traverse*/
2845 0, /*tp_clear*/
2846 0, /*tp_richcompare*/
2847 0, /*tp_weaklistoffset*/
2848 0, /*tp_iter*/
2849 0, /*tp_iternext*/
2850 __pyx_methods_2bx_4misc_10_seekbzip2_SeekBzip2, /*tp_methods*/
2851 0, /*tp_members*/
2852 0, /*tp_getset*/
2853 0, /*tp_base*/
2854 0, /*tp_dict*/
2855 0, /*tp_descr_get*/
2856 0, /*tp_descr_set*/
2857 0, /*tp_dictoffset*/
2858 __pyx_pw_2bx_4misc_10_seekbzip2_9SeekBzip2_1__init__, /*tp_init*/
2859 0, /*tp_alloc*/
2860 __pyx_tp_new_2bx_4misc_10_seekbzip2_SeekBzip2, /*tp_new*/
2861 0, /*tp_free*/
2862 0, /*tp_is_gc*/
2863 0, /*tp_bases*/
2864 0, /*tp_mro*/
2865 0, /*tp_cache*/
2866 0, /*tp_subclasses*/
2867 0, /*tp_weaklist*/
2868 0, /*tp_del*/
2869 0, /*tp_version_tag*/
2870 #if PY_VERSION_HEX >= 0x030400a1
2871 0, /*tp_finalize*/
2872 #endif
2873 #if PY_VERSION_HEX >= 0x030800b1
2874 0, /*tp_vectorcall*/
2875 #endif
2876 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
2877 0, /*tp_print*/
2878 #endif
2879 #if PY_VERSION_HEX >= 0x030B00A2
2880 0, /*tp_inline_values_offset*/
2881 #endif
2882 };
2883
2884 static PyMethodDef __pyx_methods[] = {
2885 {0, 0, 0, 0}
2886 };
2887
2888 #if PY_MAJOR_VERSION >= 3
2889 #if CYTHON_PEP489_MULTI_PHASE_INIT
2890 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
2891 static int __pyx_pymod_exec__seekbzip2(PyObject* module); /*proto*/
2892 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
2893 {Py_mod_create, (void*)__pyx_pymod_create},
2894 {Py_mod_exec, (void*)__pyx_pymod_exec__seekbzip2},
2895 {0, NULL}
2896 };
2897 #endif
2898
2899 static struct PyModuleDef __pyx_moduledef = {
2900 PyModuleDef_HEAD_INIT,
2901 "_seekbzip2",
2902 __pyx_k_Pyrex_C_extension_supporting_bx, /* m_doc */
2903 #if CYTHON_PEP489_MULTI_PHASE_INIT
2904 0, /* m_size */
2905 #else
2906 -1, /* m_size */
2907 #endif
2908 __pyx_methods /* m_methods */,
2909 #if CYTHON_PEP489_MULTI_PHASE_INIT
2910 __pyx_moduledef_slots, /* m_slots */
2911 #else
2912 NULL, /* m_reload */
2913 #endif
2914 NULL, /* m_traverse */
2915 NULL, /* m_clear */
2916 NULL /* m_free */
2917 };
2918 #endif
2919 #ifndef CYTHON_SMALL_CODE
2920 #if defined(__clang__)
2921 #define CYTHON_SMALL_CODE
2922 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
2923 #define CYTHON_SMALL_CODE __attribute__((cold))
2924 #else
2925 #define CYTHON_SMALL_CODE
2926 #endif
2927 #endif
2928
2929 static __Pyx_StringTabEntry __pyx_string_tab[] = {
2930 {&__pyx_n_s_O_RDONLY, __pyx_k_O_RDONLY, sizeof(__pyx_k_O_RDONLY), 0, 0, 1, 1},
2931 {&__pyx_n_s_SeekBzip2, __pyx_k_SeekBzip2, sizeof(__pyx_k_SeekBzip2), 0, 0, 1, 1},
2932 {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
2933 {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0},
2934 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
2935 {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
2936 {&__pyx_n_s_filename, __pyx_k_filename, sizeof(__pyx_k_filename), 0, 0, 1, 1},
2937 {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
2938 {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
2939 {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
2940 {&__pyx_kp_s_lseek_of_underlying_file_failed, __pyx_k_lseek_of_underlying_file_failed, sizeof(__pyx_k_lseek_of_underlying_file_failed), 0, 0, 1, 0},
2941 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
2942 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
2943 {&__pyx_n_s_open, __pyx_k_open, sizeof(__pyx_k_open), 0, 0, 1, 1},
2944 {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
2945 {&__pyx_kp_s_read_bunzip_error_d, __pyx_k_read_bunzip_error_d, sizeof(__pyx_k_read_bunzip_error_d), 0, 0, 1, 0},
2946 {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
2947 {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
2948 {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
2949 {&__pyx_kp_s_self_bd_cannot_be_converted_to_a, __pyx_k_self_bd_cannot_be_converted_to_a, sizeof(__pyx_k_self_bd_cannot_be_converted_to_a), 0, 0, 1, 0},
2950 {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
2951 {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
2952 {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
2953 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
2954 {0, 0, 0, 0, 0, 0, 0}
2955 };
__Pyx_InitCachedBuiltins(void)2956 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
2957 __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 2, __pyx_L1_error)
2958 return 0;
2959 __pyx_L1_error:;
2960 return -1;
2961 }
2962
__Pyx_InitCachedConstants(void)2963 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
2964 __Pyx_RefNannyDeclarations
2965 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
2966
2967 /* "bx/misc/_seekbzip2.pyx":71
2968 * # Seek the underlying file descriptor
2969 * if ( lseek( self.file_fd, n_byte, 0 ) != n_byte ):
2970 * raise Exception( "lseek of underlying file failed" ) # <<<<<<<<<<<<<<
2971 * # Init the buffer at the right bit position
2972 * self.bd.inbufBitCount = self.bd.inbufPos = self.bd.inbufCount = 0
2973 */
2974 __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_lseek_of_underlying_file_failed); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 71, __pyx_L1_error)
2975 __Pyx_GOTREF(__pyx_tuple_);
2976 __Pyx_GIVEREF(__pyx_tuple_);
2977
2978 /* "(tree fragment)":2
2979 * def __reduce_cython__(self):
2980 * raise TypeError("self.bd cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
2981 * def __setstate_cython__(self, __pyx_state):
2982 * raise TypeError("self.bd cannot be converted to a Python object for pickling")
2983 */
2984 __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_self_bd_cannot_be_converted_to_a); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 2, __pyx_L1_error)
2985 __Pyx_GOTREF(__pyx_tuple__3);
2986 __Pyx_GIVEREF(__pyx_tuple__3);
2987
2988 /* "(tree fragment)":4
2989 * raise TypeError("self.bd cannot be converted to a Python object for pickling")
2990 * def __setstate_cython__(self, __pyx_state):
2991 * raise TypeError("self.bd cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
2992 */
2993 __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_self_bd_cannot_be_converted_to_a); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 4, __pyx_L1_error)
2994 __Pyx_GOTREF(__pyx_tuple__4);
2995 __Pyx_GIVEREF(__pyx_tuple__4);
2996 __Pyx_RefNannyFinishContext();
2997 return 0;
2998 __pyx_L1_error:;
2999 __Pyx_RefNannyFinishContext();
3000 return -1;
3001 }
3002
__Pyx_InitGlobals(void)3003 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
3004 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(1, 1, __pyx_L1_error);
3005 return 0;
3006 __pyx_L1_error:;
3007 return -1;
3008 }
3009
3010 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
3011 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
3012 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
3013 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
3014 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
3015 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
3016 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
3017
__Pyx_modinit_global_init_code(void)3018 static int __Pyx_modinit_global_init_code(void) {
3019 __Pyx_RefNannyDeclarations
3020 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
3021 /*--- Global init code ---*/
3022 __Pyx_RefNannyFinishContext();
3023 return 0;
3024 }
3025
__Pyx_modinit_variable_export_code(void)3026 static int __Pyx_modinit_variable_export_code(void) {
3027 __Pyx_RefNannyDeclarations
3028 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
3029 /*--- Variable export code ---*/
3030 __Pyx_RefNannyFinishContext();
3031 return 0;
3032 }
3033
__Pyx_modinit_function_export_code(void)3034 static int __Pyx_modinit_function_export_code(void) {
3035 __Pyx_RefNannyDeclarations
3036 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
3037 /*--- Function export code ---*/
3038 __Pyx_RefNannyFinishContext();
3039 return 0;
3040 }
3041
__Pyx_modinit_type_init_code(void)3042 static int __Pyx_modinit_type_init_code(void) {
3043 __Pyx_RefNannyDeclarations
3044 int __pyx_lineno = 0;
3045 const char *__pyx_filename = NULL;
3046 int __pyx_clineno = 0;
3047 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
3048 /*--- Type init code ---*/
3049 if (PyType_Ready(&__pyx_type_2bx_4misc_10_seekbzip2_SeekBzip2) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
3050 #if PY_VERSION_HEX < 0x030800B1
3051 __pyx_type_2bx_4misc_10_seekbzip2_SeekBzip2.tp_print = 0;
3052 #endif
3053 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_2bx_4misc_10_seekbzip2_SeekBzip2.tp_dictoffset && __pyx_type_2bx_4misc_10_seekbzip2_SeekBzip2.tp_getattro == PyObject_GenericGetAttr)) {
3054 __pyx_type_2bx_4misc_10_seekbzip2_SeekBzip2.tp_getattro = __Pyx_PyObject_GenericGetAttr;
3055 }
3056 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_SeekBzip2, (PyObject *)&__pyx_type_2bx_4misc_10_seekbzip2_SeekBzip2) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
3057 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_2bx_4misc_10_seekbzip2_SeekBzip2) < 0) __PYX_ERR(1, 38, __pyx_L1_error)
3058 __pyx_ptype_2bx_4misc_10_seekbzip2_SeekBzip2 = &__pyx_type_2bx_4misc_10_seekbzip2_SeekBzip2;
3059 __Pyx_RefNannyFinishContext();
3060 return 0;
3061 __pyx_L1_error:;
3062 __Pyx_RefNannyFinishContext();
3063 return -1;
3064 }
3065
__Pyx_modinit_type_import_code(void)3066 static int __Pyx_modinit_type_import_code(void) {
3067 __Pyx_RefNannyDeclarations
3068 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
3069 /*--- Type import code ---*/
3070 __Pyx_RefNannyFinishContext();
3071 return 0;
3072 }
3073
__Pyx_modinit_variable_import_code(void)3074 static int __Pyx_modinit_variable_import_code(void) {
3075 __Pyx_RefNannyDeclarations
3076 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
3077 /*--- Variable import code ---*/
3078 __Pyx_RefNannyFinishContext();
3079 return 0;
3080 }
3081
__Pyx_modinit_function_import_code(void)3082 static int __Pyx_modinit_function_import_code(void) {
3083 __Pyx_RefNannyDeclarations
3084 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
3085 /*--- Function import code ---*/
3086 __Pyx_RefNannyFinishContext();
3087 return 0;
3088 }
3089
3090
3091 #ifndef CYTHON_NO_PYINIT_EXPORT
3092 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
3093 #elif PY_MAJOR_VERSION < 3
3094 #ifdef __cplusplus
3095 #define __Pyx_PyMODINIT_FUNC extern "C" void
3096 #else
3097 #define __Pyx_PyMODINIT_FUNC void
3098 #endif
3099 #else
3100 #ifdef __cplusplus
3101 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
3102 #else
3103 #define __Pyx_PyMODINIT_FUNC PyObject *
3104 #endif
3105 #endif
3106
3107
3108 #if PY_MAJOR_VERSION < 3
3109 __Pyx_PyMODINIT_FUNC init_seekbzip2(void) CYTHON_SMALL_CODE; /*proto*/
init_seekbzip2(void)3110 __Pyx_PyMODINIT_FUNC init_seekbzip2(void)
3111 #else
3112 __Pyx_PyMODINIT_FUNC PyInit__seekbzip2(void) CYTHON_SMALL_CODE; /*proto*/
3113 __Pyx_PyMODINIT_FUNC PyInit__seekbzip2(void)
3114 #if CYTHON_PEP489_MULTI_PHASE_INIT
3115 {
3116 return PyModuleDef_Init(&__pyx_moduledef);
3117 }
3118 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
3119 #if PY_VERSION_HEX >= 0x030700A1
3120 static PY_INT64_T main_interpreter_id = -1;
3121 PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
3122 if (main_interpreter_id == -1) {
3123 main_interpreter_id = current_id;
3124 return (unlikely(current_id == -1)) ? -1 : 0;
3125 } else if (unlikely(main_interpreter_id != current_id))
3126 #else
3127 static PyInterpreterState *main_interpreter = NULL;
3128 PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
3129 if (!main_interpreter) {
3130 main_interpreter = current_interpreter;
3131 } else if (unlikely(main_interpreter != current_interpreter))
3132 #endif
3133 {
3134 PyErr_SetString(
3135 PyExc_ImportError,
3136 "Interpreter change detected - this module can only be loaded into one interpreter per process.");
3137 return -1;
3138 }
3139 return 0;
3140 }
3141 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) {
3142 PyObject *value = PyObject_GetAttrString(spec, from_name);
3143 int result = 0;
3144 if (likely(value)) {
3145 if (allow_none || value != Py_None) {
3146 result = PyDict_SetItemString(moddict, to_name, value);
3147 }
3148 Py_DECREF(value);
3149 } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
3150 PyErr_Clear();
3151 } else {
3152 result = -1;
3153 }
3154 return result;
3155 }
3156 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
3157 PyObject *module = NULL, *moddict, *modname;
3158 if (__Pyx_check_single_interpreter())
3159 return NULL;
3160 if (__pyx_m)
3161 return __Pyx_NewRef(__pyx_m);
3162 modname = PyObject_GetAttrString(spec, "name");
3163 if (unlikely(!modname)) goto bad;
3164 module = PyModule_NewObject(modname);
3165 Py_DECREF(modname);
3166 if (unlikely(!module)) goto bad;
3167 moddict = PyModule_GetDict(module);
3168 if (unlikely(!moddict)) goto bad;
3169 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
3170 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
3171 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
3172 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
3173 return module;
3174 bad:
3175 Py_XDECREF(module);
3176 return NULL;
3177 }
3178
3179
3180 static CYTHON_SMALL_CODE int __pyx_pymod_exec__seekbzip2(PyObject *__pyx_pyinit_module)
3181 #endif
3182 #endif
3183 {
3184 PyObject *__pyx_t_1 = NULL;
3185 int __pyx_lineno = 0;
3186 const char *__pyx_filename = NULL;
3187 int __pyx_clineno = 0;
3188 __Pyx_RefNannyDeclarations
3189 #if CYTHON_PEP489_MULTI_PHASE_INIT
3190 if (__pyx_m) {
3191 if (__pyx_m == __pyx_pyinit_module) return 0;
3192 PyErr_SetString(PyExc_RuntimeError, "Module '_seekbzip2' has already been imported. Re-initialisation is not supported.");
3193 return -1;
3194 }
3195 #elif PY_MAJOR_VERSION >= 3
3196 if (__pyx_m) return __Pyx_NewRef(__pyx_m);
3197 #endif
3198 #if CYTHON_REFNANNY
3199 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
3200 if (!__Pyx_RefNanny) {
3201 PyErr_Clear();
3202 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
3203 if (!__Pyx_RefNanny)
3204 Py_FatalError("failed to import 'refnanny' module");
3205 }
3206 #endif
3207 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__seekbzip2(void)", 0);
3208 if (__Pyx_check_binary_version() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
3209 #ifdef __Pxy_PyFrame_Initialize_Offsets
3210 __Pxy_PyFrame_Initialize_Offsets();
3211 #endif
3212 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(1, 1, __pyx_L1_error)
3213 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(1, 1, __pyx_L1_error)
3214 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(1, 1, __pyx_L1_error)
3215 #ifdef __Pyx_CyFunction_USED
3216 if (__pyx_CyFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
3217 #endif
3218 #ifdef __Pyx_FusedFunction_USED
3219 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
3220 #endif
3221 #ifdef __Pyx_Coroutine_USED
3222 if (__pyx_Coroutine_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
3223 #endif
3224 #ifdef __Pyx_Generator_USED
3225 if (__pyx_Generator_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
3226 #endif
3227 #ifdef __Pyx_AsyncGen_USED
3228 if (__pyx_AsyncGen_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
3229 #endif
3230 #ifdef __Pyx_StopAsyncIteration_USED
3231 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
3232 #endif
3233 /*--- Library function declarations ---*/
3234 /*--- Threads initialization code ---*/
3235 #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
3236 PyEval_InitThreads();
3237 #endif
3238 /*--- Module creation code ---*/
3239 #if CYTHON_PEP489_MULTI_PHASE_INIT
3240 __pyx_m = __pyx_pyinit_module;
3241 Py_INCREF(__pyx_m);
3242 #else
3243 #if PY_MAJOR_VERSION < 3
3244 __pyx_m = Py_InitModule4("_seekbzip2", __pyx_methods, __pyx_k_Pyrex_C_extension_supporting_bx, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
3245 #else
3246 __pyx_m = PyModule_Create(&__pyx_moduledef);
3247 #endif
3248 if (unlikely(!__pyx_m)) __PYX_ERR(1, 1, __pyx_L1_error)
3249 #endif
3250 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(1, 1, __pyx_L1_error)
3251 Py_INCREF(__pyx_d);
3252 __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(1, 1, __pyx_L1_error)
3253 Py_INCREF(__pyx_b);
3254 __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(1, 1, __pyx_L1_error)
3255 Py_INCREF(__pyx_cython_runtime);
3256 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(1, 1, __pyx_L1_error);
3257 /*--- Initialize various global constants etc. ---*/
3258 if (__Pyx_InitGlobals() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
3259 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
3260 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
3261 #endif
3262 if (__pyx_module_is_main_bx__misc___seekbzip2) {
3263 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
3264 }
3265 #if PY_MAJOR_VERSION >= 3
3266 {
3267 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(1, 1, __pyx_L1_error)
3268 if (!PyDict_GetItemString(modules, "bx.misc._seekbzip2")) {
3269 if (unlikely(PyDict_SetItemString(modules, "bx.misc._seekbzip2", __pyx_m) < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
3270 }
3271 }
3272 #endif
3273 /*--- Builtin init code ---*/
3274 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
3275 /*--- Constants init code ---*/
3276 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
3277 /*--- Global type/function init code ---*/
3278 (void)__Pyx_modinit_global_init_code();
3279 (void)__Pyx_modinit_variable_export_code();
3280 (void)__Pyx_modinit_function_export_code();
3281 if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
3282 (void)__Pyx_modinit_type_import_code();
3283 (void)__Pyx_modinit_variable_import_code();
3284 (void)__Pyx_modinit_function_import_code();
3285 /*--- Execution code ---*/
3286 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
3287 if (__Pyx_patch_abc() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
3288 #endif
3289
3290 /* "bx/misc/_seekbzip2.pyx":35
3291 * void free( void *ptr )
3292 *
3293 * import sys # <<<<<<<<<<<<<<
3294 * import os
3295 *
3296 */
3297 __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 35, __pyx_L1_error)
3298 __Pyx_GOTREF(__pyx_t_1);
3299 if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(1, 35, __pyx_L1_error)
3300 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3301
3302 /* "bx/misc/_seekbzip2.pyx":36
3303 *
3304 * import sys
3305 * import os # <<<<<<<<<<<<<<
3306 *
3307 * cdef class SeekBzip2:
3308 */
3309 __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 36, __pyx_L1_error)
3310 __Pyx_GOTREF(__pyx_t_1);
3311 if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(1, 36, __pyx_L1_error)
3312 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3313
3314 /* "bx/misc/_seekbzip2.pyx":1
3315 * """ # <<<<<<<<<<<<<<
3316 * Pyrex/C extension supporting `bx.misc.seekbzip2` (wrapping the low level
3317 * functions in `micro-bunzip.c`).
3318 */
3319 __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
3320 __Pyx_GOTREF(__pyx_t_1);
3321 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
3322 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3323
3324 /*--- Wrapped vars code ---*/
3325
3326 goto __pyx_L0;
3327 __pyx_L1_error:;
3328 __Pyx_XDECREF(__pyx_t_1);
3329 if (__pyx_m) {
3330 if (__pyx_d) {
3331 __Pyx_AddTraceback("init bx.misc._seekbzip2", __pyx_clineno, __pyx_lineno, __pyx_filename);
3332 }
3333 Py_CLEAR(__pyx_m);
3334 } else if (!PyErr_Occurred()) {
3335 PyErr_SetString(PyExc_ImportError, "init bx.misc._seekbzip2");
3336 }
3337 __pyx_L0:;
3338 __Pyx_RefNannyFinishContext();
3339 #if CYTHON_PEP489_MULTI_PHASE_INIT
3340 return (__pyx_m != NULL) ? 0 : -1;
3341 #elif PY_MAJOR_VERSION >= 3
3342 return __pyx_m;
3343 #else
3344 return;
3345 #endif
3346 }
3347
3348 /* --- Runtime support code --- */
3349 /* Refnanny */
3350 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)3351 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
3352 PyObject *m = NULL, *p = NULL;
3353 void *r = NULL;
3354 m = PyImport_ImportModule(modname);
3355 if (!m) goto end;
3356 p = PyObject_GetAttrString(m, "RefNannyAPI");
3357 if (!p) goto end;
3358 r = PyLong_AsVoidPtr(p);
3359 end:
3360 Py_XDECREF(p);
3361 Py_XDECREF(m);
3362 return (__Pyx_RefNannyAPIStruct *)r;
3363 }
3364 #endif
3365
3366 /* PyObjectGetAttrStr */
3367 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)3368 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
3369 PyTypeObject* tp = Py_TYPE(obj);
3370 if (likely(tp->tp_getattro))
3371 return tp->tp_getattro(obj, attr_name);
3372 #if PY_MAJOR_VERSION < 3
3373 if (likely(tp->tp_getattr))
3374 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
3375 #endif
3376 return PyObject_GetAttr(obj, attr_name);
3377 }
3378 #endif
3379
3380 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)3381 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
3382 PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
3383 if (unlikely(!result)) {
3384 PyErr_Format(PyExc_NameError,
3385 #if PY_MAJOR_VERSION >= 3
3386 "name '%U' is not defined", name);
3387 #else
3388 "name '%.200s' is not defined", PyString_AS_STRING(name));
3389 #endif
3390 }
3391 return result;
3392 }
3393
3394 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)3395 static void __Pyx_RaiseDoubleKeywordsError(
3396 const char* func_name,
3397 PyObject* kw_name)
3398 {
3399 PyErr_Format(PyExc_TypeError,
3400 #if PY_MAJOR_VERSION >= 3
3401 "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
3402 #else
3403 "%s() got multiple values for keyword argument '%s'", func_name,
3404 PyString_AsString(kw_name));
3405 #endif
3406 }
3407
3408 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)3409 static int __Pyx_ParseOptionalKeywords(
3410 PyObject *kwds,
3411 PyObject **argnames[],
3412 PyObject *kwds2,
3413 PyObject *values[],
3414 Py_ssize_t num_pos_args,
3415 const char* function_name)
3416 {
3417 PyObject *key = 0, *value = 0;
3418 Py_ssize_t pos = 0;
3419 PyObject*** name;
3420 PyObject*** first_kw_arg = argnames + num_pos_args;
3421 while (PyDict_Next(kwds, &pos, &key, &value)) {
3422 name = first_kw_arg;
3423 while (*name && (**name != key)) name++;
3424 if (*name) {
3425 values[name-argnames] = value;
3426 continue;
3427 }
3428 name = first_kw_arg;
3429 #if PY_MAJOR_VERSION < 3
3430 if (likely(PyString_Check(key))) {
3431 while (*name) {
3432 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
3433 && _PyString_Eq(**name, key)) {
3434 values[name-argnames] = value;
3435 break;
3436 }
3437 name++;
3438 }
3439 if (*name) continue;
3440 else {
3441 PyObject*** argname = argnames;
3442 while (argname != first_kw_arg) {
3443 if ((**argname == key) || (
3444 (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
3445 && _PyString_Eq(**argname, key))) {
3446 goto arg_passed_twice;
3447 }
3448 argname++;
3449 }
3450 }
3451 } else
3452 #endif
3453 if (likely(PyUnicode_Check(key))) {
3454 while (*name) {
3455 int cmp = (**name == key) ? 0 :
3456 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
3457 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
3458 #endif
3459 PyUnicode_Compare(**name, key);
3460 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
3461 if (cmp == 0) {
3462 values[name-argnames] = value;
3463 break;
3464 }
3465 name++;
3466 }
3467 if (*name) continue;
3468 else {
3469 PyObject*** argname = argnames;
3470 while (argname != first_kw_arg) {
3471 int cmp = (**argname == key) ? 0 :
3472 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
3473 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
3474 #endif
3475 PyUnicode_Compare(**argname, key);
3476 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
3477 if (cmp == 0) goto arg_passed_twice;
3478 argname++;
3479 }
3480 }
3481 } else
3482 goto invalid_keyword_type;
3483 if (kwds2) {
3484 if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
3485 } else {
3486 goto invalid_keyword;
3487 }
3488 }
3489 return 0;
3490 arg_passed_twice:
3491 __Pyx_RaiseDoubleKeywordsError(function_name, key);
3492 goto bad;
3493 invalid_keyword_type:
3494 PyErr_Format(PyExc_TypeError,
3495 "%.200s() keywords must be strings", function_name);
3496 goto bad;
3497 invalid_keyword:
3498 PyErr_Format(PyExc_TypeError,
3499 #if PY_MAJOR_VERSION < 3
3500 "%.200s() got an unexpected keyword argument '%.200s'",
3501 function_name, PyString_AsString(key));
3502 #else
3503 "%s() got an unexpected keyword argument '%U'",
3504 function_name, key);
3505 #endif
3506 bad:
3507 return -1;
3508 }
3509
3510 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)3511 static void __Pyx_RaiseArgtupleInvalid(
3512 const char* func_name,
3513 int exact,
3514 Py_ssize_t num_min,
3515 Py_ssize_t num_max,
3516 Py_ssize_t num_found)
3517 {
3518 Py_ssize_t num_expected;
3519 const char *more_or_less;
3520 if (num_found < num_min) {
3521 num_expected = num_min;
3522 more_or_less = "at least";
3523 } else {
3524 num_expected = num_max;
3525 more_or_less = "at most";
3526 }
3527 if (exact) {
3528 more_or_less = "exactly";
3529 }
3530 PyErr_Format(PyExc_TypeError,
3531 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
3532 func_name, more_or_less, num_expected,
3533 (num_expected == 1) ? "" : "s", num_found);
3534 }
3535
3536 /* PyDictVersioning */
3537 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)3538 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
3539 PyObject *dict = Py_TYPE(obj)->tp_dict;
3540 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
3541 }
__Pyx_get_object_dict_version(PyObject * obj)3542 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
3543 PyObject **dictptr = NULL;
3544 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
3545 if (offset) {
3546 #if CYTHON_COMPILING_IN_CPYTHON
3547 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
3548 #else
3549 dictptr = _PyObject_GetDictPtr(obj);
3550 #endif
3551 }
3552 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
3553 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)3554 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
3555 PyObject *dict = Py_TYPE(obj)->tp_dict;
3556 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
3557 return 0;
3558 return obj_dict_version == __Pyx_get_object_dict_version(obj);
3559 }
3560 #endif
3561
3562 /* GetModuleGlobalName */
3563 #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)3564 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
3565 #else
3566 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
3567 #endif
3568 {
3569 PyObject *result;
3570 #if !CYTHON_AVOID_BORROWED_REFS
3571 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
3572 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
3573 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
3574 if (likely(result)) {
3575 return __Pyx_NewRef(result);
3576 } else if (unlikely(PyErr_Occurred())) {
3577 return NULL;
3578 }
3579 #else
3580 result = PyDict_GetItem(__pyx_d, name);
3581 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
3582 if (likely(result)) {
3583 return __Pyx_NewRef(result);
3584 }
3585 #endif
3586 #else
3587 result = PyObject_GetItem(__pyx_d, name);
3588 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
3589 if (likely(result)) {
3590 return __Pyx_NewRef(result);
3591 }
3592 PyErr_Clear();
3593 #endif
3594 return __Pyx_GetBuiltinName(name);
3595 }
3596
3597 /* PyFunctionFastCall */
3598 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)3599 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
3600 PyObject *globals) {
3601 PyFrameObject *f;
3602 PyThreadState *tstate = __Pyx_PyThreadState_Current;
3603 PyObject **fastlocals;
3604 Py_ssize_t i;
3605 PyObject *result;
3606 assert(globals != NULL);
3607 /* XXX Perhaps we should create a specialized
3608 PyFrame_New() that doesn't take locals, but does
3609 take builtins without sanity checking them.
3610 */
3611 assert(tstate != NULL);
3612 f = PyFrame_New(tstate, co, globals, NULL);
3613 if (f == NULL) {
3614 return NULL;
3615 }
3616 fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
3617 for (i = 0; i < na; i++) {
3618 Py_INCREF(*args);
3619 fastlocals[i] = *args++;
3620 }
3621 result = PyEval_EvalFrameEx(f,0);
3622 ++tstate->recursion_depth;
3623 Py_DECREF(f);
3624 --tstate->recursion_depth;
3625 return result;
3626 }
3627 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)3628 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
3629 PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
3630 PyObject *globals = PyFunction_GET_GLOBALS(func);
3631 PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
3632 PyObject *closure;
3633 #if PY_MAJOR_VERSION >= 3
3634 PyObject *kwdefs;
3635 #endif
3636 PyObject *kwtuple, **k;
3637 PyObject **d;
3638 Py_ssize_t nd;
3639 Py_ssize_t nk;
3640 PyObject *result;
3641 assert(kwargs == NULL || PyDict_Check(kwargs));
3642 nk = kwargs ? PyDict_Size(kwargs) : 0;
3643 if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
3644 return NULL;
3645 }
3646 if (
3647 #if PY_MAJOR_VERSION >= 3
3648 co->co_kwonlyargcount == 0 &&
3649 #endif
3650 likely(kwargs == NULL || nk == 0) &&
3651 co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
3652 if (argdefs == NULL && co->co_argcount == nargs) {
3653 result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
3654 goto done;
3655 }
3656 else if (nargs == 0 && argdefs != NULL
3657 && co->co_argcount == Py_SIZE(argdefs)) {
3658 /* function called with no arguments, but all parameters have
3659 a default value: use default values as arguments .*/
3660 args = &PyTuple_GET_ITEM(argdefs, 0);
3661 result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
3662 goto done;
3663 }
3664 }
3665 if (kwargs != NULL) {
3666 Py_ssize_t pos, i;
3667 kwtuple = PyTuple_New(2 * nk);
3668 if (kwtuple == NULL) {
3669 result = NULL;
3670 goto done;
3671 }
3672 k = &PyTuple_GET_ITEM(kwtuple, 0);
3673 pos = i = 0;
3674 while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
3675 Py_INCREF(k[i]);
3676 Py_INCREF(k[i+1]);
3677 i += 2;
3678 }
3679 nk = i / 2;
3680 }
3681 else {
3682 kwtuple = NULL;
3683 k = NULL;
3684 }
3685 closure = PyFunction_GET_CLOSURE(func);
3686 #if PY_MAJOR_VERSION >= 3
3687 kwdefs = PyFunction_GET_KW_DEFAULTS(func);
3688 #endif
3689 if (argdefs != NULL) {
3690 d = &PyTuple_GET_ITEM(argdefs, 0);
3691 nd = Py_SIZE(argdefs);
3692 }
3693 else {
3694 d = NULL;
3695 nd = 0;
3696 }
3697 #if PY_MAJOR_VERSION >= 3
3698 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
3699 args, (int)nargs,
3700 k, (int)nk,
3701 d, (int)nd, kwdefs, closure);
3702 #else
3703 result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
3704 args, (int)nargs,
3705 k, (int)nk,
3706 d, (int)nd, closure);
3707 #endif
3708 Py_XDECREF(kwtuple);
3709 done:
3710 Py_LeaveRecursiveCall();
3711 return result;
3712 }
3713 #endif
3714 #endif
3715
3716 /* PyCFunctionFastCall */
3717 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)3718 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
3719 PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
3720 PyCFunction meth = PyCFunction_GET_FUNCTION(func);
3721 PyObject *self = PyCFunction_GET_SELF(func);
3722 int flags = PyCFunction_GET_FLAGS(func);
3723 assert(PyCFunction_Check(func));
3724 assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
3725 assert(nargs >= 0);
3726 assert(nargs == 0 || args != NULL);
3727 /* _PyCFunction_FastCallDict() must not be called with an exception set,
3728 because it may clear it (directly or indirectly) and so the
3729 caller loses its exception */
3730 assert(!PyErr_Occurred());
3731 if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
3732 return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
3733 } else {
3734 return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
3735 }
3736 }
3737 #endif
3738
3739 /* PyObjectCall */
3740 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)3741 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
3742 PyObject *result;
3743 ternaryfunc call = Py_TYPE(func)->tp_call;
3744 if (unlikely(!call))
3745 return PyObject_Call(func, arg, kw);
3746 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
3747 return NULL;
3748 result = (*call)(func, arg, kw);
3749 Py_LeaveRecursiveCall();
3750 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
3751 PyErr_SetString(
3752 PyExc_SystemError,
3753 "NULL result without error in PyObject_Call");
3754 }
3755 return result;
3756 }
3757 #endif
3758
3759 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)3760 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
3761 PyObject *args, *result = NULL;
3762 #if CYTHON_FAST_PYCALL
3763 if (PyFunction_Check(function)) {
3764 PyObject *args[2] = {arg1, arg2};
3765 return __Pyx_PyFunction_FastCall(function, args, 2);
3766 }
3767 #endif
3768 #if CYTHON_FAST_PYCCALL
3769 if (__Pyx_PyFastCFunction_Check(function)) {
3770 PyObject *args[2] = {arg1, arg2};
3771 return __Pyx_PyCFunction_FastCall(function, args, 2);
3772 }
3773 #endif
3774 args = PyTuple_New(2);
3775 if (unlikely(!args)) goto done;
3776 Py_INCREF(arg1);
3777 PyTuple_SET_ITEM(args, 0, arg1);
3778 Py_INCREF(arg2);
3779 PyTuple_SET_ITEM(args, 1, arg2);
3780 Py_INCREF(function);
3781 result = __Pyx_PyObject_Call(function, args, NULL);
3782 Py_DECREF(args);
3783 Py_DECREF(function);
3784 done:
3785 return result;
3786 }
3787
3788 /* PyObjectCallMethO */
3789 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)3790 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
3791 PyObject *self, *result;
3792 PyCFunction cfunc;
3793 cfunc = PyCFunction_GET_FUNCTION(func);
3794 self = PyCFunction_GET_SELF(func);
3795 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
3796 return NULL;
3797 result = cfunc(self, arg);
3798 Py_LeaveRecursiveCall();
3799 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
3800 PyErr_SetString(
3801 PyExc_SystemError,
3802 "NULL result without error in PyObject_Call");
3803 }
3804 return result;
3805 }
3806 #endif
3807
3808 /* PyObjectCallOneArg */
3809 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)3810 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
3811 PyObject *result;
3812 PyObject *args = PyTuple_New(1);
3813 if (unlikely(!args)) return NULL;
3814 Py_INCREF(arg);
3815 PyTuple_SET_ITEM(args, 0, arg);
3816 result = __Pyx_PyObject_Call(func, args, NULL);
3817 Py_DECREF(args);
3818 return result;
3819 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)3820 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
3821 #if CYTHON_FAST_PYCALL
3822 if (PyFunction_Check(func)) {
3823 return __Pyx_PyFunction_FastCall(func, &arg, 1);
3824 }
3825 #endif
3826 if (likely(PyCFunction_Check(func))) {
3827 if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
3828 return __Pyx_PyObject_CallMethO(func, arg);
3829 #if CYTHON_FAST_PYCCALL
3830 } else if (__Pyx_PyFastCFunction_Check(func)) {
3831 return __Pyx_PyCFunction_FastCall(func, &arg, 1);
3832 #endif
3833 }
3834 }
3835 return __Pyx__PyObject_CallOneArg(func, arg);
3836 }
3837 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)3838 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
3839 PyObject *result;
3840 PyObject *args = PyTuple_Pack(1, arg);
3841 if (unlikely(!args)) return NULL;
3842 result = __Pyx_PyObject_Call(func, args, NULL);
3843 Py_DECREF(args);
3844 return result;
3845 }
3846 #endif
3847
3848 /* PyErrFetchRestore */
3849 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)3850 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
3851 PyObject *tmp_type, *tmp_value, *tmp_tb;
3852 tmp_type = tstate->curexc_type;
3853 tmp_value = tstate->curexc_value;
3854 tmp_tb = tstate->curexc_traceback;
3855 tstate->curexc_type = type;
3856 tstate->curexc_value = value;
3857 tstate->curexc_traceback = tb;
3858 Py_XDECREF(tmp_type);
3859 Py_XDECREF(tmp_value);
3860 Py_XDECREF(tmp_tb);
3861 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)3862 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
3863 *type = tstate->curexc_type;
3864 *value = tstate->curexc_value;
3865 *tb = tstate->curexc_traceback;
3866 tstate->curexc_type = 0;
3867 tstate->curexc_value = 0;
3868 tstate->curexc_traceback = 0;
3869 }
3870 #endif
3871
3872 /* RaiseException */
3873 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)3874 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
3875 CYTHON_UNUSED PyObject *cause) {
3876 __Pyx_PyThreadState_declare
3877 Py_XINCREF(type);
3878 if (!value || value == Py_None)
3879 value = NULL;
3880 else
3881 Py_INCREF(value);
3882 if (!tb || tb == Py_None)
3883 tb = NULL;
3884 else {
3885 Py_INCREF(tb);
3886 if (!PyTraceBack_Check(tb)) {
3887 PyErr_SetString(PyExc_TypeError,
3888 "raise: arg 3 must be a traceback or None");
3889 goto raise_error;
3890 }
3891 }
3892 if (PyType_Check(type)) {
3893 #if CYTHON_COMPILING_IN_PYPY
3894 if (!value) {
3895 Py_INCREF(Py_None);
3896 value = Py_None;
3897 }
3898 #endif
3899 PyErr_NormalizeException(&type, &value, &tb);
3900 } else {
3901 if (value) {
3902 PyErr_SetString(PyExc_TypeError,
3903 "instance exception may not have a separate value");
3904 goto raise_error;
3905 }
3906 value = type;
3907 type = (PyObject*) Py_TYPE(type);
3908 Py_INCREF(type);
3909 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
3910 PyErr_SetString(PyExc_TypeError,
3911 "raise: exception class must be a subclass of BaseException");
3912 goto raise_error;
3913 }
3914 }
3915 __Pyx_PyThreadState_assign
3916 __Pyx_ErrRestore(type, value, tb);
3917 return;
3918 raise_error:
3919 Py_XDECREF(value);
3920 Py_XDECREF(type);
3921 Py_XDECREF(tb);
3922 return;
3923 }
3924 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)3925 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
3926 PyObject* owned_instance = NULL;
3927 if (tb == Py_None) {
3928 tb = 0;
3929 } else if (tb && !PyTraceBack_Check(tb)) {
3930 PyErr_SetString(PyExc_TypeError,
3931 "raise: arg 3 must be a traceback or None");
3932 goto bad;
3933 }
3934 if (value == Py_None)
3935 value = 0;
3936 if (PyExceptionInstance_Check(type)) {
3937 if (value) {
3938 PyErr_SetString(PyExc_TypeError,
3939 "instance exception may not have a separate value");
3940 goto bad;
3941 }
3942 value = type;
3943 type = (PyObject*) Py_TYPE(value);
3944 } else if (PyExceptionClass_Check(type)) {
3945 PyObject *instance_class = NULL;
3946 if (value && PyExceptionInstance_Check(value)) {
3947 instance_class = (PyObject*) Py_TYPE(value);
3948 if (instance_class != type) {
3949 int is_subclass = PyObject_IsSubclass(instance_class, type);
3950 if (!is_subclass) {
3951 instance_class = NULL;
3952 } else if (unlikely(is_subclass == -1)) {
3953 goto bad;
3954 } else {
3955 type = instance_class;
3956 }
3957 }
3958 }
3959 if (!instance_class) {
3960 PyObject *args;
3961 if (!value)
3962 args = PyTuple_New(0);
3963 else if (PyTuple_Check(value)) {
3964 Py_INCREF(value);
3965 args = value;
3966 } else
3967 args = PyTuple_Pack(1, value);
3968 if (!args)
3969 goto bad;
3970 owned_instance = PyObject_Call(type, args, NULL);
3971 Py_DECREF(args);
3972 if (!owned_instance)
3973 goto bad;
3974 value = owned_instance;
3975 if (!PyExceptionInstance_Check(value)) {
3976 PyErr_Format(PyExc_TypeError,
3977 "calling %R should have returned an instance of "
3978 "BaseException, not %R",
3979 type, Py_TYPE(value));
3980 goto bad;
3981 }
3982 }
3983 } else {
3984 PyErr_SetString(PyExc_TypeError,
3985 "raise: exception class must be a subclass of BaseException");
3986 goto bad;
3987 }
3988 if (cause) {
3989 PyObject *fixed_cause;
3990 if (cause == Py_None) {
3991 fixed_cause = NULL;
3992 } else if (PyExceptionClass_Check(cause)) {
3993 fixed_cause = PyObject_CallObject(cause, NULL);
3994 if (fixed_cause == NULL)
3995 goto bad;
3996 } else if (PyExceptionInstance_Check(cause)) {
3997 fixed_cause = cause;
3998 Py_INCREF(fixed_cause);
3999 } else {
4000 PyErr_SetString(PyExc_TypeError,
4001 "exception causes must derive from "
4002 "BaseException");
4003 goto bad;
4004 }
4005 PyException_SetCause(value, fixed_cause);
4006 }
4007 PyErr_SetObject(type, value);
4008 if (tb) {
4009 #if CYTHON_COMPILING_IN_PYPY
4010 PyObject *tmp_type, *tmp_value, *tmp_tb;
4011 PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
4012 Py_INCREF(tb);
4013 PyErr_Restore(tmp_type, tmp_value, tb);
4014 Py_XDECREF(tmp_tb);
4015 #else
4016 PyThreadState *tstate = __Pyx_PyThreadState_Current;
4017 PyObject* tmp_tb = tstate->curexc_traceback;
4018 if (tb != tmp_tb) {
4019 Py_INCREF(tb);
4020 tstate->curexc_traceback = tb;
4021 Py_XDECREF(tmp_tb);
4022 }
4023 #endif
4024 }
4025 bad:
4026 Py_XDECREF(owned_instance);
4027 return;
4028 }
4029 #endif
4030
4031 /* SliceObject */
__Pyx_PyObject_GetSlice(PyObject * obj,Py_ssize_t cstart,Py_ssize_t cstop,PyObject ** _py_start,PyObject ** _py_stop,PyObject ** _py_slice,int has_cstart,int has_cstop,CYTHON_UNUSED int wraparound)4032 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
4033 Py_ssize_t cstart, Py_ssize_t cstop,
4034 PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
4035 int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
4036 #if CYTHON_USE_TYPE_SLOTS
4037 PyMappingMethods* mp;
4038 #if PY_MAJOR_VERSION < 3
4039 PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
4040 if (likely(ms && ms->sq_slice)) {
4041 if (!has_cstart) {
4042 if (_py_start && (*_py_start != Py_None)) {
4043 cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
4044 if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
4045 } else
4046 cstart = 0;
4047 }
4048 if (!has_cstop) {
4049 if (_py_stop && (*_py_stop != Py_None)) {
4050 cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
4051 if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
4052 } else
4053 cstop = PY_SSIZE_T_MAX;
4054 }
4055 if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
4056 Py_ssize_t l = ms->sq_length(obj);
4057 if (likely(l >= 0)) {
4058 if (cstop < 0) {
4059 cstop += l;
4060 if (cstop < 0) cstop = 0;
4061 }
4062 if (cstart < 0) {
4063 cstart += l;
4064 if (cstart < 0) cstart = 0;
4065 }
4066 } else {
4067 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
4068 goto bad;
4069 PyErr_Clear();
4070 }
4071 }
4072 return ms->sq_slice(obj, cstart, cstop);
4073 }
4074 #endif
4075 mp = Py_TYPE(obj)->tp_as_mapping;
4076 if (likely(mp && mp->mp_subscript))
4077 #endif
4078 {
4079 PyObject* result;
4080 PyObject *py_slice, *py_start, *py_stop;
4081 if (_py_slice) {
4082 py_slice = *_py_slice;
4083 } else {
4084 PyObject* owned_start = NULL;
4085 PyObject* owned_stop = NULL;
4086 if (_py_start) {
4087 py_start = *_py_start;
4088 } else {
4089 if (has_cstart) {
4090 owned_start = py_start = PyInt_FromSsize_t(cstart);
4091 if (unlikely(!py_start)) goto bad;
4092 } else
4093 py_start = Py_None;
4094 }
4095 if (_py_stop) {
4096 py_stop = *_py_stop;
4097 } else {
4098 if (has_cstop) {
4099 owned_stop = py_stop = PyInt_FromSsize_t(cstop);
4100 if (unlikely(!py_stop)) {
4101 Py_XDECREF(owned_start);
4102 goto bad;
4103 }
4104 } else
4105 py_stop = Py_None;
4106 }
4107 py_slice = PySlice_New(py_start, py_stop, Py_None);
4108 Py_XDECREF(owned_start);
4109 Py_XDECREF(owned_stop);
4110 if (unlikely(!py_slice)) goto bad;
4111 }
4112 #if CYTHON_USE_TYPE_SLOTS
4113 result = mp->mp_subscript(obj, py_slice);
4114 #else
4115 result = PyObject_GetItem(obj, py_slice);
4116 #endif
4117 if (!_py_slice) {
4118 Py_DECREF(py_slice);
4119 }
4120 return result;
4121 }
4122 PyErr_Format(PyExc_TypeError,
4123 "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
4124 bad:
4125 return NULL;
4126 }
4127
4128 /* StringJoin */
4129 #if !CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyBytes_Join(PyObject * sep,PyObject * values)4130 static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
4131 return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
4132 }
4133 #endif
4134
4135 /* PyObject_GenericGetAttrNoDict */
4136 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_RaiseGenericGetAttributeError(PyTypeObject * tp,PyObject * attr_name)4137 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
4138 PyErr_Format(PyExc_AttributeError,
4139 #if PY_MAJOR_VERSION >= 3
4140 "'%.50s' object has no attribute '%U'",
4141 tp->tp_name, attr_name);
4142 #else
4143 "'%.50s' object has no attribute '%.400s'",
4144 tp->tp_name, PyString_AS_STRING(attr_name));
4145 #endif
4146 return NULL;
4147 }
__Pyx_PyObject_GenericGetAttrNoDict(PyObject * obj,PyObject * attr_name)4148 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
4149 PyObject *descr;
4150 PyTypeObject *tp = Py_TYPE(obj);
4151 if (unlikely(!PyString_Check(attr_name))) {
4152 return PyObject_GenericGetAttr(obj, attr_name);
4153 }
4154 assert(!tp->tp_dictoffset);
4155 descr = _PyType_Lookup(tp, attr_name);
4156 if (unlikely(!descr)) {
4157 return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
4158 }
4159 Py_INCREF(descr);
4160 #if PY_MAJOR_VERSION < 3
4161 if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
4162 #endif
4163 {
4164 descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
4165 if (unlikely(f)) {
4166 PyObject *res = f(descr, obj, (PyObject *)tp);
4167 Py_DECREF(descr);
4168 return res;
4169 }
4170 }
4171 return descr;
4172 }
4173 #endif
4174
4175 /* PyObject_GenericGetAttr */
4176 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_PyObject_GenericGetAttr(PyObject * obj,PyObject * attr_name)4177 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
4178 if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
4179 return PyObject_GenericGetAttr(obj, attr_name);
4180 }
4181 return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
4182 }
4183 #endif
4184
4185 /* PyErrExceptionMatches */
4186 #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)4187 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
4188 Py_ssize_t i, n;
4189 n = PyTuple_GET_SIZE(tuple);
4190 #if PY_MAJOR_VERSION >= 3
4191 for (i=0; i<n; i++) {
4192 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
4193 }
4194 #endif
4195 for (i=0; i<n; i++) {
4196 if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
4197 }
4198 return 0;
4199 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)4200 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
4201 PyObject *exc_type = tstate->curexc_type;
4202 if (exc_type == err) return 1;
4203 if (unlikely(!exc_type)) return 0;
4204 if (unlikely(PyTuple_Check(err)))
4205 return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
4206 return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
4207 }
4208 #endif
4209
4210 /* PyObjectGetAttrStrNoError */
__Pyx_PyObject_GetAttrStr_ClearAttributeError(void)4211 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
4212 __Pyx_PyThreadState_declare
4213 __Pyx_PyThreadState_assign
4214 if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
4215 __Pyx_PyErr_Clear();
4216 }
__Pyx_PyObject_GetAttrStrNoError(PyObject * obj,PyObject * attr_name)4217 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
4218 PyObject *result;
4219 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
4220 PyTypeObject* tp = Py_TYPE(obj);
4221 if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
4222 return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
4223 }
4224 #endif
4225 result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
4226 if (unlikely(!result)) {
4227 __Pyx_PyObject_GetAttrStr_ClearAttributeError();
4228 }
4229 return result;
4230 }
4231
4232 /* SetupReduce */
__Pyx_setup_reduce_is_named(PyObject * meth,PyObject * name)4233 static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
4234 int ret;
4235 PyObject *name_attr;
4236 name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
4237 if (likely(name_attr)) {
4238 ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
4239 } else {
4240 ret = -1;
4241 }
4242 if (unlikely(ret < 0)) {
4243 PyErr_Clear();
4244 ret = 0;
4245 }
4246 Py_XDECREF(name_attr);
4247 return ret;
4248 }
__Pyx_setup_reduce(PyObject * type_obj)4249 static int __Pyx_setup_reduce(PyObject* type_obj) {
4250 int ret = 0;
4251 PyObject *object_reduce = NULL;
4252 PyObject *object_reduce_ex = NULL;
4253 PyObject *reduce = NULL;
4254 PyObject *reduce_ex = NULL;
4255 PyObject *reduce_cython = NULL;
4256 PyObject *setstate = NULL;
4257 PyObject *setstate_cython = NULL;
4258 #if CYTHON_USE_PYTYPE_LOOKUP
4259 if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
4260 #else
4261 if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
4262 #endif
4263 #if CYTHON_USE_PYTYPE_LOOKUP
4264 object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
4265 #else
4266 object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
4267 #endif
4268 reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
4269 if (reduce_ex == object_reduce_ex) {
4270 #if CYTHON_USE_PYTYPE_LOOKUP
4271 object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
4272 #else
4273 object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
4274 #endif
4275 reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
4276 if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
4277 reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
4278 if (likely(reduce_cython)) {
4279 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
4280 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
4281 } else if (reduce == object_reduce || PyErr_Occurred()) {
4282 goto __PYX_BAD;
4283 }
4284 setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
4285 if (!setstate) PyErr_Clear();
4286 if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
4287 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
4288 if (likely(setstate_cython)) {
4289 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
4290 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
4291 } else if (!setstate || PyErr_Occurred()) {
4292 goto __PYX_BAD;
4293 }
4294 }
4295 PyType_Modified((PyTypeObject*)type_obj);
4296 }
4297 }
4298 goto __PYX_GOOD;
4299 __PYX_BAD:
4300 if (!PyErr_Occurred())
4301 PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
4302 ret = -1;
4303 __PYX_GOOD:
4304 #if !CYTHON_USE_PYTYPE_LOOKUP
4305 Py_XDECREF(object_reduce);
4306 Py_XDECREF(object_reduce_ex);
4307 #endif
4308 Py_XDECREF(reduce);
4309 Py_XDECREF(reduce_ex);
4310 Py_XDECREF(reduce_cython);
4311 Py_XDECREF(setstate);
4312 Py_XDECREF(setstate_cython);
4313 return ret;
4314 }
4315
4316 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)4317 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
4318 PyObject *empty_list = 0;
4319 PyObject *module = 0;
4320 PyObject *global_dict = 0;
4321 PyObject *empty_dict = 0;
4322 PyObject *list;
4323 #if PY_MAJOR_VERSION < 3
4324 PyObject *py_import;
4325 py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
4326 if (!py_import)
4327 goto bad;
4328 #endif
4329 if (from_list)
4330 list = from_list;
4331 else {
4332 empty_list = PyList_New(0);
4333 if (!empty_list)
4334 goto bad;
4335 list = empty_list;
4336 }
4337 global_dict = PyModule_GetDict(__pyx_m);
4338 if (!global_dict)
4339 goto bad;
4340 empty_dict = PyDict_New();
4341 if (!empty_dict)
4342 goto bad;
4343 {
4344 #if PY_MAJOR_VERSION >= 3
4345 if (level == -1) {
4346 if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
4347 module = PyImport_ImportModuleLevelObject(
4348 name, global_dict, empty_dict, list, 1);
4349 if (!module) {
4350 if (!PyErr_ExceptionMatches(PyExc_ImportError))
4351 goto bad;
4352 PyErr_Clear();
4353 }
4354 }
4355 level = 0;
4356 }
4357 #endif
4358 if (!module) {
4359 #if PY_MAJOR_VERSION < 3
4360 PyObject *py_level = PyInt_FromLong(level);
4361 if (!py_level)
4362 goto bad;
4363 module = PyObject_CallFunctionObjArgs(py_import,
4364 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
4365 Py_DECREF(py_level);
4366 #else
4367 module = PyImport_ImportModuleLevelObject(
4368 name, global_dict, empty_dict, list, level);
4369 #endif
4370 }
4371 }
4372 bad:
4373 #if PY_MAJOR_VERSION < 3
4374 Py_XDECREF(py_import);
4375 #endif
4376 Py_XDECREF(empty_list);
4377 Py_XDECREF(empty_dict);
4378 return module;
4379 }
4380
4381 /* CLineInTraceback */
4382 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)4383 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
4384 PyObject *use_cline;
4385 PyObject *ptype, *pvalue, *ptraceback;
4386 #if CYTHON_COMPILING_IN_CPYTHON
4387 PyObject **cython_runtime_dict;
4388 #endif
4389 if (unlikely(!__pyx_cython_runtime)) {
4390 return c_line;
4391 }
4392 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
4393 #if CYTHON_COMPILING_IN_CPYTHON
4394 cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
4395 if (likely(cython_runtime_dict)) {
4396 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
4397 use_cline, *cython_runtime_dict,
4398 __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
4399 } else
4400 #endif
4401 {
4402 PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
4403 if (use_cline_obj) {
4404 use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
4405 Py_DECREF(use_cline_obj);
4406 } else {
4407 PyErr_Clear();
4408 use_cline = NULL;
4409 }
4410 }
4411 if (!use_cline) {
4412 c_line = 0;
4413 (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
4414 }
4415 else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
4416 c_line = 0;
4417 }
4418 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
4419 return c_line;
4420 }
4421 #endif
4422
4423 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)4424 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
4425 int start = 0, mid = 0, end = count - 1;
4426 if (end >= 0 && code_line > entries[end].code_line) {
4427 return count;
4428 }
4429 while (start < end) {
4430 mid = start + (end - start) / 2;
4431 if (code_line < entries[mid].code_line) {
4432 end = mid;
4433 } else if (code_line > entries[mid].code_line) {
4434 start = mid + 1;
4435 } else {
4436 return mid;
4437 }
4438 }
4439 if (code_line <= entries[mid].code_line) {
4440 return mid;
4441 } else {
4442 return mid + 1;
4443 }
4444 }
__pyx_find_code_object(int code_line)4445 static PyCodeObject *__pyx_find_code_object(int code_line) {
4446 PyCodeObject* code_object;
4447 int pos;
4448 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
4449 return NULL;
4450 }
4451 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
4452 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
4453 return NULL;
4454 }
4455 code_object = __pyx_code_cache.entries[pos].code_object;
4456 Py_INCREF(code_object);
4457 return code_object;
4458 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)4459 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
4460 int pos, i;
4461 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
4462 if (unlikely(!code_line)) {
4463 return;
4464 }
4465 if (unlikely(!entries)) {
4466 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
4467 if (likely(entries)) {
4468 __pyx_code_cache.entries = entries;
4469 __pyx_code_cache.max_count = 64;
4470 __pyx_code_cache.count = 1;
4471 entries[0].code_line = code_line;
4472 entries[0].code_object = code_object;
4473 Py_INCREF(code_object);
4474 }
4475 return;
4476 }
4477 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
4478 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
4479 PyCodeObject* tmp = entries[pos].code_object;
4480 entries[pos].code_object = code_object;
4481 Py_DECREF(tmp);
4482 return;
4483 }
4484 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
4485 int new_max = __pyx_code_cache.max_count + 64;
4486 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
4487 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
4488 if (unlikely(!entries)) {
4489 return;
4490 }
4491 __pyx_code_cache.entries = entries;
4492 __pyx_code_cache.max_count = new_max;
4493 }
4494 for (i=__pyx_code_cache.count; i>pos; i--) {
4495 entries[i] = entries[i-1];
4496 }
4497 entries[pos].code_line = code_line;
4498 entries[pos].code_object = code_object;
4499 __pyx_code_cache.count++;
4500 Py_INCREF(code_object);
4501 }
4502
4503 /* AddTraceback */
4504 #include "compile.h"
4505 #include "frameobject.h"
4506 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)4507 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
4508 const char *funcname, int c_line,
4509 int py_line, const char *filename) {
4510 PyCodeObject *py_code = NULL;
4511 PyObject *py_funcname = NULL;
4512 #if PY_MAJOR_VERSION < 3
4513 PyObject *py_srcfile = NULL;
4514 py_srcfile = PyString_FromString(filename);
4515 if (!py_srcfile) goto bad;
4516 #endif
4517 if (c_line) {
4518 #if PY_MAJOR_VERSION < 3
4519 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
4520 if (!py_funcname) goto bad;
4521 #else
4522 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
4523 if (!py_funcname) goto bad;
4524 funcname = PyUnicode_AsUTF8(py_funcname);
4525 if (!funcname) goto bad;
4526 #endif
4527 }
4528 else {
4529 #if PY_MAJOR_VERSION < 3
4530 py_funcname = PyString_FromString(funcname);
4531 if (!py_funcname) goto bad;
4532 #endif
4533 }
4534 #if PY_MAJOR_VERSION < 3
4535 py_code = __Pyx_PyCode_New(
4536 0,
4537 0,
4538 0,
4539 0,
4540 0,
4541 __pyx_empty_bytes, /*PyObject *code,*/
4542 __pyx_empty_tuple, /*PyObject *consts,*/
4543 __pyx_empty_tuple, /*PyObject *names,*/
4544 __pyx_empty_tuple, /*PyObject *varnames,*/
4545 __pyx_empty_tuple, /*PyObject *freevars,*/
4546 __pyx_empty_tuple, /*PyObject *cellvars,*/
4547 py_srcfile, /*PyObject *filename,*/
4548 py_funcname, /*PyObject *name,*/
4549 py_line,
4550 __pyx_empty_bytes /*PyObject *lnotab*/
4551 );
4552 Py_DECREF(py_srcfile);
4553 #else
4554 py_code = PyCode_NewEmpty(filename, funcname, py_line);
4555 #endif
4556 Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline
4557 return py_code;
4558 bad:
4559 Py_XDECREF(py_funcname);
4560 #if PY_MAJOR_VERSION < 3
4561 Py_XDECREF(py_srcfile);
4562 #endif
4563 return NULL;
4564 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)4565 static void __Pyx_AddTraceback(const char *funcname, int c_line,
4566 int py_line, const char *filename) {
4567 PyCodeObject *py_code = 0;
4568 PyFrameObject *py_frame = 0;
4569 PyThreadState *tstate = __Pyx_PyThreadState_Current;
4570 if (c_line) {
4571 c_line = __Pyx_CLineForTraceback(tstate, c_line);
4572 }
4573 py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
4574 if (!py_code) {
4575 py_code = __Pyx_CreateCodeObjectForTraceback(
4576 funcname, c_line, py_line, filename);
4577 if (!py_code) goto bad;
4578 __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
4579 }
4580 py_frame = PyFrame_New(
4581 tstate, /*PyThreadState *tstate,*/
4582 py_code, /*PyCodeObject *code,*/
4583 __pyx_d, /*PyObject *globals,*/
4584 0 /*PyObject *locals*/
4585 );
4586 if (!py_frame) goto bad;
4587 __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
4588 PyTraceBack_Here(py_frame);
4589 bad:
4590 Py_XDECREF(py_code);
4591 Py_XDECREF(py_frame);
4592 }
4593
4594 /* CIntFromPyVerify */
4595 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
4596 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
4597 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
4598 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
4599 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
4600 {\
4601 func_type value = func_value;\
4602 if (sizeof(target_type) < sizeof(func_type)) {\
4603 if (unlikely(value != (func_type) (target_type) value)) {\
4604 func_type zero = 0;\
4605 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
4606 return (target_type) -1;\
4607 if (is_unsigned && unlikely(value < zero))\
4608 goto raise_neg_overflow;\
4609 else\
4610 goto raise_overflow;\
4611 }\
4612 }\
4613 return (target_type) value;\
4614 }
4615
4616 /* CIntFromPy */
__Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject * x)4617 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject *x) {
4618 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4619 #pragma GCC diagnostic push
4620 #pragma GCC diagnostic ignored "-Wconversion"
4621 #endif
4622 const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) -1, const_zero = (unsigned PY_LONG_LONG) 0;
4623 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4624 #pragma GCC diagnostic pop
4625 #endif
4626 const int is_unsigned = neg_one > const_zero;
4627 #if PY_MAJOR_VERSION < 3
4628 if (likely(PyInt_Check(x))) {
4629 if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) {
4630 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, PyInt_AS_LONG(x))
4631 } else {
4632 long val = PyInt_AS_LONG(x);
4633 if (is_unsigned && unlikely(val < 0)) {
4634 goto raise_neg_overflow;
4635 }
4636 return (unsigned PY_LONG_LONG) val;
4637 }
4638 } else
4639 #endif
4640 if (likely(PyLong_Check(x))) {
4641 if (is_unsigned) {
4642 #if CYTHON_USE_PYLONG_INTERNALS
4643 const digit* digits = ((PyLongObject*)x)->ob_digit;
4644 switch (Py_SIZE(x)) {
4645 case 0: return (unsigned PY_LONG_LONG) 0;
4646 case 1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, digit, digits[0])
4647 case 2:
4648 if (8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT) {
4649 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4650 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4651 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 2 * PyLong_SHIFT) {
4652 return (unsigned PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
4653 }
4654 }
4655 break;
4656 case 3:
4657 if (8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT) {
4658 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4659 __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])))
4660 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 3 * PyLong_SHIFT) {
4661 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]));
4662 }
4663 }
4664 break;
4665 case 4:
4666 if (8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT) {
4667 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4668 __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])))
4669 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 4 * PyLong_SHIFT) {
4670 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]));
4671 }
4672 }
4673 break;
4674 }
4675 #endif
4676 #if CYTHON_COMPILING_IN_CPYTHON
4677 if (unlikely(Py_SIZE(x) < 0)) {
4678 goto raise_neg_overflow;
4679 }
4680 #else
4681 {
4682 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
4683 if (unlikely(result < 0))
4684 return (unsigned PY_LONG_LONG) -1;
4685 if (unlikely(result == 1))
4686 goto raise_neg_overflow;
4687 }
4688 #endif
4689 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) {
4690 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned long, PyLong_AsUnsignedLong(x))
4691 #ifdef HAVE_LONG_LONG
4692 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
4693 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
4694 #endif
4695 }
4696 } else {
4697 #if CYTHON_USE_PYLONG_INTERNALS
4698 const digit* digits = ((PyLongObject*)x)->ob_digit;
4699 switch (Py_SIZE(x)) {
4700 case 0: return (unsigned PY_LONG_LONG) 0;
4701 case -1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, sdigit, (sdigit) (-(sdigit)digits[0]))
4702 case 1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, digit, +digits[0])
4703 case -2:
4704 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 1 * PyLong_SHIFT) {
4705 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4706 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4707 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
4708 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
4709 }
4710 }
4711 break;
4712 case 2:
4713 if (8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT) {
4714 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4715 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4716 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
4717 return (unsigned PY_LONG_LONG) ((((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
4718 }
4719 }
4720 break;
4721 case -3:
4722 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
4723 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4724 __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])))
4725 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
4726 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])));
4727 }
4728 }
4729 break;
4730 case 3:
4731 if (8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT) {
4732 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4733 __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])))
4734 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
4735 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])));
4736 }
4737 }
4738 break;
4739 case -4:
4740 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
4741 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4742 __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])))
4743 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
4744 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])));
4745 }
4746 }
4747 break;
4748 case 4:
4749 if (8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT) {
4750 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4751 __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])))
4752 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
4753 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])));
4754 }
4755 }
4756 break;
4757 }
4758 #endif
4759 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) {
4760 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, long, PyLong_AsLong(x))
4761 #ifdef HAVE_LONG_LONG
4762 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
4763 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, PY_LONG_LONG, PyLong_AsLongLong(x))
4764 #endif
4765 }
4766 }
4767 {
4768 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
4769 PyErr_SetString(PyExc_RuntimeError,
4770 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
4771 #else
4772 unsigned PY_LONG_LONG val;
4773 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
4774 #if PY_MAJOR_VERSION < 3
4775 if (likely(v) && !PyLong_Check(v)) {
4776 PyObject *tmp = v;
4777 v = PyNumber_Long(tmp);
4778 Py_DECREF(tmp);
4779 }
4780 #endif
4781 if (likely(v)) {
4782 int one = 1; int is_little = (int)*(unsigned char *)&one;
4783 unsigned char *bytes = (unsigned char *)&val;
4784 int ret = _PyLong_AsByteArray((PyLongObject *)v,
4785 bytes, sizeof(val),
4786 is_little, !is_unsigned);
4787 Py_DECREF(v);
4788 if (likely(!ret))
4789 return val;
4790 }
4791 #endif
4792 return (unsigned PY_LONG_LONG) -1;
4793 }
4794 } else {
4795 unsigned PY_LONG_LONG val;
4796 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
4797 if (!tmp) return (unsigned PY_LONG_LONG) -1;
4798 val = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(tmp);
4799 Py_DECREF(tmp);
4800 return val;
4801 }
4802 raise_overflow:
4803 PyErr_SetString(PyExc_OverflowError,
4804 "value too large to convert to unsigned PY_LONG_LONG");
4805 return (unsigned PY_LONG_LONG) -1;
4806 raise_neg_overflow:
4807 PyErr_SetString(PyExc_OverflowError,
4808 "can't convert negative value to unsigned PY_LONG_LONG");
4809 return (unsigned PY_LONG_LONG) -1;
4810 }
4811
4812 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)4813 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
4814 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4815 #pragma GCC diagnostic push
4816 #pragma GCC diagnostic ignored "-Wconversion"
4817 #endif
4818 const int neg_one = (int) -1, const_zero = (int) 0;
4819 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4820 #pragma GCC diagnostic pop
4821 #endif
4822 const int is_unsigned = neg_one > const_zero;
4823 #if PY_MAJOR_VERSION < 3
4824 if (likely(PyInt_Check(x))) {
4825 if (sizeof(int) < sizeof(long)) {
4826 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
4827 } else {
4828 long val = PyInt_AS_LONG(x);
4829 if (is_unsigned && unlikely(val < 0)) {
4830 goto raise_neg_overflow;
4831 }
4832 return (int) val;
4833 }
4834 } else
4835 #endif
4836 if (likely(PyLong_Check(x))) {
4837 if (is_unsigned) {
4838 #if CYTHON_USE_PYLONG_INTERNALS
4839 const digit* digits = ((PyLongObject*)x)->ob_digit;
4840 switch (Py_SIZE(x)) {
4841 case 0: return (int) 0;
4842 case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
4843 case 2:
4844 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
4845 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4846 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4847 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
4848 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
4849 }
4850 }
4851 break;
4852 case 3:
4853 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
4854 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4855 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4856 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
4857 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
4858 }
4859 }
4860 break;
4861 case 4:
4862 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
4863 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4864 __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])))
4865 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
4866 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
4867 }
4868 }
4869 break;
4870 }
4871 #endif
4872 #if CYTHON_COMPILING_IN_CPYTHON
4873 if (unlikely(Py_SIZE(x) < 0)) {
4874 goto raise_neg_overflow;
4875 }
4876 #else
4877 {
4878 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
4879 if (unlikely(result < 0))
4880 return (int) -1;
4881 if (unlikely(result == 1))
4882 goto raise_neg_overflow;
4883 }
4884 #endif
4885 if (sizeof(int) <= sizeof(unsigned long)) {
4886 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
4887 #ifdef HAVE_LONG_LONG
4888 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
4889 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
4890 #endif
4891 }
4892 } else {
4893 #if CYTHON_USE_PYLONG_INTERNALS
4894 const digit* digits = ((PyLongObject*)x)->ob_digit;
4895 switch (Py_SIZE(x)) {
4896 case 0: return (int) 0;
4897 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
4898 case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
4899 case -2:
4900 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
4901 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4902 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4903 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
4904 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4905 }
4906 }
4907 break;
4908 case 2:
4909 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
4910 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4911 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4912 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
4913 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4914 }
4915 }
4916 break;
4917 case -3:
4918 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
4919 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4920 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4921 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
4922 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4923 }
4924 }
4925 break;
4926 case 3:
4927 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
4928 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4929 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4930 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
4931 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4932 }
4933 }
4934 break;
4935 case -4:
4936 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
4937 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4938 __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])))
4939 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
4940 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4941 }
4942 }
4943 break;
4944 case 4:
4945 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
4946 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4947 __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])))
4948 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
4949 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4950 }
4951 }
4952 break;
4953 }
4954 #endif
4955 if (sizeof(int) <= sizeof(long)) {
4956 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
4957 #ifdef HAVE_LONG_LONG
4958 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
4959 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
4960 #endif
4961 }
4962 }
4963 {
4964 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
4965 PyErr_SetString(PyExc_RuntimeError,
4966 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
4967 #else
4968 int val;
4969 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
4970 #if PY_MAJOR_VERSION < 3
4971 if (likely(v) && !PyLong_Check(v)) {
4972 PyObject *tmp = v;
4973 v = PyNumber_Long(tmp);
4974 Py_DECREF(tmp);
4975 }
4976 #endif
4977 if (likely(v)) {
4978 int one = 1; int is_little = (int)*(unsigned char *)&one;
4979 unsigned char *bytes = (unsigned char *)&val;
4980 int ret = _PyLong_AsByteArray((PyLongObject *)v,
4981 bytes, sizeof(val),
4982 is_little, !is_unsigned);
4983 Py_DECREF(v);
4984 if (likely(!ret))
4985 return val;
4986 }
4987 #endif
4988 return (int) -1;
4989 }
4990 } else {
4991 int val;
4992 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
4993 if (!tmp) return (int) -1;
4994 val = __Pyx_PyInt_As_int(tmp);
4995 Py_DECREF(tmp);
4996 return val;
4997 }
4998 raise_overflow:
4999 PyErr_SetString(PyExc_OverflowError,
5000 "value too large to convert to int");
5001 return (int) -1;
5002 raise_neg_overflow:
5003 PyErr_SetString(PyExc_OverflowError,
5004 "can't convert negative value to int");
5005 return (int) -1;
5006 }
5007
5008 /* CIntToPy */
__Pyx_PyInt_From_int(int value)5009 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
5010 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
5011 #pragma GCC diagnostic push
5012 #pragma GCC diagnostic ignored "-Wconversion"
5013 #endif
5014 const int neg_one = (int) -1, const_zero = (int) 0;
5015 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
5016 #pragma GCC diagnostic pop
5017 #endif
5018 const int is_unsigned = neg_one > const_zero;
5019 if (is_unsigned) {
5020 if (sizeof(int) < sizeof(long)) {
5021 return PyInt_FromLong((long) value);
5022 } else if (sizeof(int) <= sizeof(unsigned long)) {
5023 return PyLong_FromUnsignedLong((unsigned long) value);
5024 #ifdef HAVE_LONG_LONG
5025 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
5026 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
5027 #endif
5028 }
5029 } else {
5030 if (sizeof(int) <= sizeof(long)) {
5031 return PyInt_FromLong((long) value);
5032 #ifdef HAVE_LONG_LONG
5033 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
5034 return PyLong_FromLongLong((PY_LONG_LONG) value);
5035 #endif
5036 }
5037 }
5038 {
5039 int one = 1; int little = (int)*(unsigned char *)&one;
5040 unsigned char *bytes = (unsigned char *)&value;
5041 return _PyLong_FromByteArray(bytes, sizeof(int),
5042 little, !is_unsigned);
5043 }
5044 }
5045
5046 /* CIntToPy */
__Pyx_PyInt_From_long(long value)5047 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
5048 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
5049 #pragma GCC diagnostic push
5050 #pragma GCC diagnostic ignored "-Wconversion"
5051 #endif
5052 const long neg_one = (long) -1, const_zero = (long) 0;
5053 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
5054 #pragma GCC diagnostic pop
5055 #endif
5056 const int is_unsigned = neg_one > const_zero;
5057 if (is_unsigned) {
5058 if (sizeof(long) < sizeof(long)) {
5059 return PyInt_FromLong((long) value);
5060 } else if (sizeof(long) <= sizeof(unsigned long)) {
5061 return PyLong_FromUnsignedLong((unsigned long) value);
5062 #ifdef HAVE_LONG_LONG
5063 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
5064 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
5065 #endif
5066 }
5067 } else {
5068 if (sizeof(long) <= sizeof(long)) {
5069 return PyInt_FromLong((long) value);
5070 #ifdef HAVE_LONG_LONG
5071 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
5072 return PyLong_FromLongLong((PY_LONG_LONG) value);
5073 #endif
5074 }
5075 }
5076 {
5077 int one = 1; int little = (int)*(unsigned char *)&one;
5078 unsigned char *bytes = (unsigned char *)&value;
5079 return _PyLong_FromByteArray(bytes, sizeof(long),
5080 little, !is_unsigned);
5081 }
5082 }
5083
5084 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)5085 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
5086 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
5087 #pragma GCC diagnostic push
5088 #pragma GCC diagnostic ignored "-Wconversion"
5089 #endif
5090 const long neg_one = (long) -1, const_zero = (long) 0;
5091 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
5092 #pragma GCC diagnostic pop
5093 #endif
5094 const int is_unsigned = neg_one > const_zero;
5095 #if PY_MAJOR_VERSION < 3
5096 if (likely(PyInt_Check(x))) {
5097 if (sizeof(long) < sizeof(long)) {
5098 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
5099 } else {
5100 long val = PyInt_AS_LONG(x);
5101 if (is_unsigned && unlikely(val < 0)) {
5102 goto raise_neg_overflow;
5103 }
5104 return (long) val;
5105 }
5106 } else
5107 #endif
5108 if (likely(PyLong_Check(x))) {
5109 if (is_unsigned) {
5110 #if CYTHON_USE_PYLONG_INTERNALS
5111 const digit* digits = ((PyLongObject*)x)->ob_digit;
5112 switch (Py_SIZE(x)) {
5113 case 0: return (long) 0;
5114 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
5115 case 2:
5116 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
5117 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5118 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5119 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
5120 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
5121 }
5122 }
5123 break;
5124 case 3:
5125 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
5126 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5127 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5128 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
5129 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
5130 }
5131 }
5132 break;
5133 case 4:
5134 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
5135 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5136 __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])))
5137 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
5138 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
5139 }
5140 }
5141 break;
5142 }
5143 #endif
5144 #if CYTHON_COMPILING_IN_CPYTHON
5145 if (unlikely(Py_SIZE(x) < 0)) {
5146 goto raise_neg_overflow;
5147 }
5148 #else
5149 {
5150 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
5151 if (unlikely(result < 0))
5152 return (long) -1;
5153 if (unlikely(result == 1))
5154 goto raise_neg_overflow;
5155 }
5156 #endif
5157 if (sizeof(long) <= sizeof(unsigned long)) {
5158 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
5159 #ifdef HAVE_LONG_LONG
5160 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
5161 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
5162 #endif
5163 }
5164 } else {
5165 #if CYTHON_USE_PYLONG_INTERNALS
5166 const digit* digits = ((PyLongObject*)x)->ob_digit;
5167 switch (Py_SIZE(x)) {
5168 case 0: return (long) 0;
5169 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
5170 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
5171 case -2:
5172 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
5173 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5174 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5175 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
5176 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5177 }
5178 }
5179 break;
5180 case 2:
5181 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
5182 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5183 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5184 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
5185 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5186 }
5187 }
5188 break;
5189 case -3:
5190 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
5191 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5192 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5193 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5194 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5195 }
5196 }
5197 break;
5198 case 3:
5199 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
5200 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5201 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5202 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5203 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5204 }
5205 }
5206 break;
5207 case -4:
5208 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5209 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5210 __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])))
5211 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
5212 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5213 }
5214 }
5215 break;
5216 case 4:
5217 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
5218 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5219 __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])))
5220 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
5221 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5222 }
5223 }
5224 break;
5225 }
5226 #endif
5227 if (sizeof(long) <= sizeof(long)) {
5228 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
5229 #ifdef HAVE_LONG_LONG
5230 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
5231 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
5232 #endif
5233 }
5234 }
5235 {
5236 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
5237 PyErr_SetString(PyExc_RuntimeError,
5238 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
5239 #else
5240 long val;
5241 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
5242 #if PY_MAJOR_VERSION < 3
5243 if (likely(v) && !PyLong_Check(v)) {
5244 PyObject *tmp = v;
5245 v = PyNumber_Long(tmp);
5246 Py_DECREF(tmp);
5247 }
5248 #endif
5249 if (likely(v)) {
5250 int one = 1; int is_little = (int)*(unsigned char *)&one;
5251 unsigned char *bytes = (unsigned char *)&val;
5252 int ret = _PyLong_AsByteArray((PyLongObject *)v,
5253 bytes, sizeof(val),
5254 is_little, !is_unsigned);
5255 Py_DECREF(v);
5256 if (likely(!ret))
5257 return val;
5258 }
5259 #endif
5260 return (long) -1;
5261 }
5262 } else {
5263 long val;
5264 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
5265 if (!tmp) return (long) -1;
5266 val = __Pyx_PyInt_As_long(tmp);
5267 Py_DECREF(tmp);
5268 return val;
5269 }
5270 raise_overflow:
5271 PyErr_SetString(PyExc_OverflowError,
5272 "value too large to convert to long");
5273 return (long) -1;
5274 raise_neg_overflow:
5275 PyErr_SetString(PyExc_OverflowError,
5276 "can't convert negative value to long");
5277 return (long) -1;
5278 }
5279
5280 /* FastTypeChecks */
5281 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)5282 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
5283 while (a) {
5284 a = a->tp_base;
5285 if (a == b)
5286 return 1;
5287 }
5288 return b == &PyBaseObject_Type;
5289 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)5290 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
5291 PyObject *mro;
5292 if (a == b) return 1;
5293 mro = a->tp_mro;
5294 if (likely(mro)) {
5295 Py_ssize_t i, n;
5296 n = PyTuple_GET_SIZE(mro);
5297 for (i = 0; i < n; i++) {
5298 if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
5299 return 1;
5300 }
5301 return 0;
5302 }
5303 return __Pyx_InBases(a, b);
5304 }
5305 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)5306 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
5307 PyObject *exception, *value, *tb;
5308 int res;
5309 __Pyx_PyThreadState_declare
5310 __Pyx_PyThreadState_assign
5311 __Pyx_ErrFetch(&exception, &value, &tb);
5312 res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
5313 if (unlikely(res == -1)) {
5314 PyErr_WriteUnraisable(err);
5315 res = 0;
5316 }
5317 if (!res) {
5318 res = PyObject_IsSubclass(err, exc_type2);
5319 if (unlikely(res == -1)) {
5320 PyErr_WriteUnraisable(err);
5321 res = 0;
5322 }
5323 }
5324 __Pyx_ErrRestore(exception, value, tb);
5325 return res;
5326 }
5327 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)5328 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
5329 int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
5330 if (!res) {
5331 res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
5332 }
5333 return res;
5334 }
5335 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)5336 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
5337 Py_ssize_t i, n;
5338 assert(PyExceptionClass_Check(exc_type));
5339 n = PyTuple_GET_SIZE(tuple);
5340 #if PY_MAJOR_VERSION >= 3
5341 for (i=0; i<n; i++) {
5342 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
5343 }
5344 #endif
5345 for (i=0; i<n; i++) {
5346 PyObject *t = PyTuple_GET_ITEM(tuple, i);
5347 #if PY_MAJOR_VERSION < 3
5348 if (likely(exc_type == t)) return 1;
5349 #endif
5350 if (likely(PyExceptionClass_Check(t))) {
5351 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
5352 } else {
5353 }
5354 }
5355 return 0;
5356 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)5357 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
5358 if (likely(err == exc_type)) return 1;
5359 if (likely(PyExceptionClass_Check(err))) {
5360 if (likely(PyExceptionClass_Check(exc_type))) {
5361 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
5362 } else if (likely(PyTuple_Check(exc_type))) {
5363 return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
5364 } else {
5365 }
5366 }
5367 return PyErr_GivenExceptionMatches(err, exc_type);
5368 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)5369 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
5370 assert(PyExceptionClass_Check(exc_type1));
5371 assert(PyExceptionClass_Check(exc_type2));
5372 if (likely(err == exc_type1 || err == exc_type2)) return 1;
5373 if (likely(PyExceptionClass_Check(err))) {
5374 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
5375 }
5376 return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
5377 }
5378 #endif
5379
5380 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)5381 static int __Pyx_check_binary_version(void) {
5382 char ctversion[4], rtversion[4];
5383 PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
5384 PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
5385 if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
5386 char message[200];
5387 PyOS_snprintf(message, sizeof(message),
5388 "compiletime version %s of module '%.100s' "
5389 "does not match runtime version %s",
5390 ctversion, __Pyx_MODULE_NAME, rtversion);
5391 return PyErr_WarnEx(NULL, message, 1);
5392 }
5393 return 0;
5394 }
5395
5396 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)5397 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
5398 while (t->p) {
5399 #if PY_MAJOR_VERSION < 3
5400 if (t->is_unicode) {
5401 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
5402 } else if (t->intern) {
5403 *t->p = PyString_InternFromString(t->s);
5404 } else {
5405 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
5406 }
5407 #else
5408 if (t->is_unicode | t->is_str) {
5409 if (t->intern) {
5410 *t->p = PyUnicode_InternFromString(t->s);
5411 } else if (t->encoding) {
5412 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
5413 } else {
5414 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
5415 }
5416 } else {
5417 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
5418 }
5419 #endif
5420 if (!*t->p)
5421 return -1;
5422 if (PyObject_Hash(*t->p) == -1)
5423 return -1;
5424 ++t;
5425 }
5426 return 0;
5427 }
5428
__Pyx_PyUnicode_FromString(const char * c_str)5429 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
5430 return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
5431 }
__Pyx_PyObject_AsString(PyObject * o)5432 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
5433 Py_ssize_t ignore;
5434 return __Pyx_PyObject_AsStringAndSize(o, &ignore);
5435 }
5436 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
5437 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)5438 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
5439 char* defenc_c;
5440 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
5441 if (!defenc) return NULL;
5442 defenc_c = PyBytes_AS_STRING(defenc);
5443 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
5444 {
5445 char* end = defenc_c + PyBytes_GET_SIZE(defenc);
5446 char* c;
5447 for (c = defenc_c; c < end; c++) {
5448 if ((unsigned char) (*c) >= 128) {
5449 PyUnicode_AsASCIIString(o);
5450 return NULL;
5451 }
5452 }
5453 }
5454 #endif
5455 *length = PyBytes_GET_SIZE(defenc);
5456 return defenc_c;
5457 }
5458 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)5459 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
5460 if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
5461 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
5462 if (likely(PyUnicode_IS_ASCII(o))) {
5463 *length = PyUnicode_GET_LENGTH(o);
5464 return PyUnicode_AsUTF8(o);
5465 } else {
5466 PyUnicode_AsASCIIString(o);
5467 return NULL;
5468 }
5469 #else
5470 return PyUnicode_AsUTF8AndSize(o, length);
5471 #endif
5472 }
5473 #endif
5474 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)5475 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
5476 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
5477 if (
5478 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
5479 __Pyx_sys_getdefaultencoding_not_ascii &&
5480 #endif
5481 PyUnicode_Check(o)) {
5482 return __Pyx_PyUnicode_AsStringAndSize(o, length);
5483 } else
5484 #endif
5485 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
5486 if (PyByteArray_Check(o)) {
5487 *length = PyByteArray_GET_SIZE(o);
5488 return PyByteArray_AS_STRING(o);
5489 } else
5490 #endif
5491 {
5492 char* result;
5493 int r = PyBytes_AsStringAndSize(o, &result, length);
5494 if (unlikely(r < 0)) {
5495 return NULL;
5496 } else {
5497 return result;
5498 }
5499 }
5500 }
__Pyx_PyObject_IsTrue(PyObject * x)5501 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
5502 int is_true = x == Py_True;
5503 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
5504 else return PyObject_IsTrue(x);
5505 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)5506 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
5507 int retval;
5508 if (unlikely(!x)) return -1;
5509 retval = __Pyx_PyObject_IsTrue(x);
5510 Py_DECREF(x);
5511 return retval;
5512 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)5513 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
5514 #if PY_MAJOR_VERSION >= 3
5515 if (PyLong_Check(result)) {
5516 if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
5517 "__int__ returned non-int (type %.200s). "
5518 "The ability to return an instance of a strict subclass of int "
5519 "is deprecated, and may be removed in a future version of Python.",
5520 Py_TYPE(result)->tp_name)) {
5521 Py_DECREF(result);
5522 return NULL;
5523 }
5524 return result;
5525 }
5526 #endif
5527 PyErr_Format(PyExc_TypeError,
5528 "__%.4s__ returned non-%.4s (type %.200s)",
5529 type_name, type_name, Py_TYPE(result)->tp_name);
5530 Py_DECREF(result);
5531 return NULL;
5532 }
__Pyx_PyNumber_IntOrLong(PyObject * x)5533 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
5534 #if CYTHON_USE_TYPE_SLOTS
5535 PyNumberMethods *m;
5536 #endif
5537 const char *name = NULL;
5538 PyObject *res = NULL;
5539 #if PY_MAJOR_VERSION < 3
5540 if (likely(PyInt_Check(x) || PyLong_Check(x)))
5541 #else
5542 if (likely(PyLong_Check(x)))
5543 #endif
5544 return __Pyx_NewRef(x);
5545 #if CYTHON_USE_TYPE_SLOTS
5546 m = Py_TYPE(x)->tp_as_number;
5547 #if PY_MAJOR_VERSION < 3
5548 if (m && m->nb_int) {
5549 name = "int";
5550 res = m->nb_int(x);
5551 }
5552 else if (m && m->nb_long) {
5553 name = "long";
5554 res = m->nb_long(x);
5555 }
5556 #else
5557 if (likely(m && m->nb_int)) {
5558 name = "int";
5559 res = m->nb_int(x);
5560 }
5561 #endif
5562 #else
5563 if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
5564 res = PyNumber_Int(x);
5565 }
5566 #endif
5567 if (likely(res)) {
5568 #if PY_MAJOR_VERSION < 3
5569 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
5570 #else
5571 if (unlikely(!PyLong_CheckExact(res))) {
5572 #endif
5573 return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
5574 }
5575 }
5576 else if (!PyErr_Occurred()) {
5577 PyErr_SetString(PyExc_TypeError,
5578 "an integer is required");
5579 }
5580 return res;
5581 }
5582 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
5583 Py_ssize_t ival;
5584 PyObject *x;
5585 #if PY_MAJOR_VERSION < 3
5586 if (likely(PyInt_CheckExact(b))) {
5587 if (sizeof(Py_ssize_t) >= sizeof(long))
5588 return PyInt_AS_LONG(b);
5589 else
5590 return PyInt_AsSsize_t(b);
5591 }
5592 #endif
5593 if (likely(PyLong_CheckExact(b))) {
5594 #if CYTHON_USE_PYLONG_INTERNALS
5595 const digit* digits = ((PyLongObject*)b)->ob_digit;
5596 const Py_ssize_t size = Py_SIZE(b);
5597 if (likely(__Pyx_sst_abs(size) <= 1)) {
5598 ival = likely(size) ? digits[0] : 0;
5599 if (size == -1) ival = -ival;
5600 return ival;
5601 } else {
5602 switch (size) {
5603 case 2:
5604 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
5605 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5606 }
5607 break;
5608 case -2:
5609 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
5610 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5611 }
5612 break;
5613 case 3:
5614 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
5615 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5616 }
5617 break;
5618 case -3:
5619 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
5620 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5621 }
5622 break;
5623 case 4:
5624 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
5625 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]));
5626 }
5627 break;
5628 case -4:
5629 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
5630 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]));
5631 }
5632 break;
5633 }
5634 }
5635 #endif
5636 return PyLong_AsSsize_t(b);
5637 }
5638 x = PyNumber_Index(b);
5639 if (!x) return -1;
5640 ival = PyInt_AsSsize_t(x);
5641 Py_DECREF(x);
5642 return ival;
5643 }
5644 static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
5645 if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
5646 return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
5647 #if PY_MAJOR_VERSION < 3
5648 } else if (likely(PyInt_CheckExact(o))) {
5649 return PyInt_AS_LONG(o);
5650 #endif
5651 } else {
5652 Py_ssize_t ival;
5653 PyObject *x;
5654 x = PyNumber_Index(o);
5655 if (!x) return -1;
5656 ival = PyInt_AsLong(x);
5657 Py_DECREF(x);
5658 return ival;
5659 }
5660 }
5661 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
5662 return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
5663 }
5664 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
5665 return PyInt_FromSize_t(ival);
5666 }
5667
5668
5669 #endif /* Py_PYTHON_H */
5670