1 /* Generated by Cython 0.29.21 */
2 
3 #define PY_SSIZE_T_CLEAN
4 #include "Python.h"
5 #ifndef Py_PYTHON_H
6     #error Python headers needed to compile C extensions, please install development version of Python.
7 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
8     #error Cython requires Python 2.6+ or Python 3.3+.
9 #else
10 #define CYTHON_ABI "0_29_21"
11 #define CYTHON_HEX_VERSION 0x001D15F0
12 #define CYTHON_FUTURE_DIVISION 0
13 #include <stddef.h>
14 #ifndef offsetof
15   #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
16 #endif
17 #if !defined(WIN32) && !defined(MS_WINDOWS)
18   #ifndef __stdcall
19     #define __stdcall
20   #endif
21   #ifndef __cdecl
22     #define __cdecl
23   #endif
24   #ifndef __fastcall
25     #define __fastcall
26   #endif
27 #endif
28 #ifndef DL_IMPORT
29   #define DL_IMPORT(t) t
30 #endif
31 #ifndef DL_EXPORT
32   #define DL_EXPORT(t) t
33 #endif
34 #define __PYX_COMMA ,
35 #ifndef HAVE_LONG_LONG
36   #if PY_VERSION_HEX >= 0x02070000
37     #define HAVE_LONG_LONG
38   #endif
39 #endif
40 #ifndef PY_LONG_LONG
41   #define PY_LONG_LONG LONG_LONG
42 #endif
43 #ifndef Py_HUGE_VAL
44   #define Py_HUGE_VAL HUGE_VAL
45 #endif
46 #ifdef PYPY_VERSION
47   #define CYTHON_COMPILING_IN_PYPY 1
48   #define CYTHON_COMPILING_IN_PYSTON 0
49   #define CYTHON_COMPILING_IN_CPYTHON 0
50   #undef CYTHON_USE_TYPE_SLOTS
51   #define CYTHON_USE_TYPE_SLOTS 0
52   #undef CYTHON_USE_PYTYPE_LOOKUP
53   #define CYTHON_USE_PYTYPE_LOOKUP 0
54   #if PY_VERSION_HEX < 0x03050000
55     #undef CYTHON_USE_ASYNC_SLOTS
56     #define CYTHON_USE_ASYNC_SLOTS 0
57   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
58     #define CYTHON_USE_ASYNC_SLOTS 1
59   #endif
60   #undef CYTHON_USE_PYLIST_INTERNALS
61   #define CYTHON_USE_PYLIST_INTERNALS 0
62   #undef CYTHON_USE_UNICODE_INTERNALS
63   #define CYTHON_USE_UNICODE_INTERNALS 0
64   #undef CYTHON_USE_UNICODE_WRITER
65   #define CYTHON_USE_UNICODE_WRITER 0
66   #undef CYTHON_USE_PYLONG_INTERNALS
67   #define CYTHON_USE_PYLONG_INTERNALS 0
68   #undef CYTHON_AVOID_BORROWED_REFS
69   #define CYTHON_AVOID_BORROWED_REFS 1
70   #undef CYTHON_ASSUME_SAFE_MACROS
71   #define CYTHON_ASSUME_SAFE_MACROS 0
72   #undef CYTHON_UNPACK_METHODS
73   #define CYTHON_UNPACK_METHODS 0
74   #undef CYTHON_FAST_THREAD_STATE
75   #define CYTHON_FAST_THREAD_STATE 0
76   #undef CYTHON_FAST_PYCALL
77   #define CYTHON_FAST_PYCALL 0
78   #undef CYTHON_PEP489_MULTI_PHASE_INIT
79   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
80   #undef CYTHON_USE_TP_FINALIZE
81   #define CYTHON_USE_TP_FINALIZE 0
82   #undef CYTHON_USE_DICT_VERSIONS
83   #define CYTHON_USE_DICT_VERSIONS 0
84   #undef CYTHON_USE_EXC_INFO_STACK
85   #define CYTHON_USE_EXC_INFO_STACK 0
86 #elif defined(PYSTON_VERSION)
87   #define CYTHON_COMPILING_IN_PYPY 0
88   #define CYTHON_COMPILING_IN_PYSTON 1
89   #define CYTHON_COMPILING_IN_CPYTHON 0
90   #ifndef CYTHON_USE_TYPE_SLOTS
91     #define CYTHON_USE_TYPE_SLOTS 1
92   #endif
93   #undef CYTHON_USE_PYTYPE_LOOKUP
94   #define CYTHON_USE_PYTYPE_LOOKUP 0
95   #undef CYTHON_USE_ASYNC_SLOTS
96   #define CYTHON_USE_ASYNC_SLOTS 0
97   #undef CYTHON_USE_PYLIST_INTERNALS
98   #define CYTHON_USE_PYLIST_INTERNALS 0
99   #ifndef CYTHON_USE_UNICODE_INTERNALS
100     #define CYTHON_USE_UNICODE_INTERNALS 1
101   #endif
102   #undef CYTHON_USE_UNICODE_WRITER
103   #define CYTHON_USE_UNICODE_WRITER 0
104   #undef CYTHON_USE_PYLONG_INTERNALS
105   #define CYTHON_USE_PYLONG_INTERNALS 0
106   #ifndef CYTHON_AVOID_BORROWED_REFS
107     #define CYTHON_AVOID_BORROWED_REFS 0
108   #endif
109   #ifndef CYTHON_ASSUME_SAFE_MACROS
110     #define CYTHON_ASSUME_SAFE_MACROS 1
111   #endif
112   #ifndef CYTHON_UNPACK_METHODS
113     #define CYTHON_UNPACK_METHODS 1
114   #endif
115   #undef CYTHON_FAST_THREAD_STATE
116   #define CYTHON_FAST_THREAD_STATE 0
117   #undef CYTHON_FAST_PYCALL
118   #define CYTHON_FAST_PYCALL 0
119   #undef CYTHON_PEP489_MULTI_PHASE_INIT
120   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
121   #undef CYTHON_USE_TP_FINALIZE
122   #define CYTHON_USE_TP_FINALIZE 0
123   #undef CYTHON_USE_DICT_VERSIONS
124   #define CYTHON_USE_DICT_VERSIONS 0
125   #undef CYTHON_USE_EXC_INFO_STACK
126   #define CYTHON_USE_EXC_INFO_STACK 0
127 #else
128   #define CYTHON_COMPILING_IN_PYPY 0
129   #define CYTHON_COMPILING_IN_PYSTON 0
130   #define CYTHON_COMPILING_IN_CPYTHON 1
131   #ifndef CYTHON_USE_TYPE_SLOTS
132     #define CYTHON_USE_TYPE_SLOTS 1
133   #endif
134   #if PY_VERSION_HEX < 0x02070000
135     #undef CYTHON_USE_PYTYPE_LOOKUP
136     #define CYTHON_USE_PYTYPE_LOOKUP 0
137   #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
138     #define CYTHON_USE_PYTYPE_LOOKUP 1
139   #endif
140   #if PY_MAJOR_VERSION < 3
141     #undef CYTHON_USE_ASYNC_SLOTS
142     #define CYTHON_USE_ASYNC_SLOTS 0
143   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
144     #define CYTHON_USE_ASYNC_SLOTS 1
145   #endif
146   #if PY_VERSION_HEX < 0x02070000
147     #undef CYTHON_USE_PYLONG_INTERNALS
148     #define CYTHON_USE_PYLONG_INTERNALS 0
149   #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
150     #define CYTHON_USE_PYLONG_INTERNALS 1
151   #endif
152   #ifndef CYTHON_USE_PYLIST_INTERNALS
153     #define CYTHON_USE_PYLIST_INTERNALS 1
154   #endif
155   #ifndef CYTHON_USE_UNICODE_INTERNALS
156     #define CYTHON_USE_UNICODE_INTERNALS 1
157   #endif
158   #if PY_VERSION_HEX < 0x030300F0
159     #undef CYTHON_USE_UNICODE_WRITER
160     #define CYTHON_USE_UNICODE_WRITER 0
161   #elif !defined(CYTHON_USE_UNICODE_WRITER)
162     #define CYTHON_USE_UNICODE_WRITER 1
163   #endif
164   #ifndef CYTHON_AVOID_BORROWED_REFS
165     #define CYTHON_AVOID_BORROWED_REFS 0
166   #endif
167   #ifndef CYTHON_ASSUME_SAFE_MACROS
168     #define CYTHON_ASSUME_SAFE_MACROS 1
169   #endif
170   #ifndef CYTHON_UNPACK_METHODS
171     #define CYTHON_UNPACK_METHODS 1
172   #endif
173   #ifndef CYTHON_FAST_THREAD_STATE
174     #define CYTHON_FAST_THREAD_STATE 1
175   #endif
176   #ifndef CYTHON_FAST_PYCALL
177     #define CYTHON_FAST_PYCALL 1
178   #endif
179   #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
180     #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
181   #endif
182   #ifndef CYTHON_USE_TP_FINALIZE
183     #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
184   #endif
185   #ifndef CYTHON_USE_DICT_VERSIONS
186     #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
187   #endif
188   #ifndef CYTHON_USE_EXC_INFO_STACK
189     #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
190   #endif
191 #endif
192 #if !defined(CYTHON_FAST_PYCCALL)
193 #define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
194 #endif
195 #if CYTHON_USE_PYLONG_INTERNALS
196   #include "longintrepr.h"
197   #undef SHIFT
198   #undef BASE
199   #undef MASK
200   #ifdef SIZEOF_VOID_P
201     enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
202   #endif
203 #endif
204 #ifndef __has_attribute
205   #define __has_attribute(x) 0
206 #endif
207 #ifndef __has_cpp_attribute
208   #define __has_cpp_attribute(x) 0
209 #endif
210 #ifndef CYTHON_RESTRICT
211   #if defined(__GNUC__)
212     #define CYTHON_RESTRICT __restrict__
213   #elif defined(_MSC_VER) && _MSC_VER >= 1400
214     #define CYTHON_RESTRICT __restrict
215   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
216     #define CYTHON_RESTRICT restrict
217   #else
218     #define CYTHON_RESTRICT
219   #endif
220 #endif
221 #ifndef CYTHON_UNUSED
222 # if defined(__GNUC__)
223 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
224 #     define CYTHON_UNUSED __attribute__ ((__unused__))
225 #   else
226 #     define CYTHON_UNUSED
227 #   endif
228 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
229 #   define CYTHON_UNUSED __attribute__ ((__unused__))
230 # else
231 #   define CYTHON_UNUSED
232 # endif
233 #endif
234 #ifndef CYTHON_MAYBE_UNUSED_VAR
235 #  if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)236      template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
237 #  else
238 #    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
239 #  endif
240 #endif
241 #ifndef CYTHON_NCP_UNUSED
242 # if CYTHON_COMPILING_IN_CPYTHON
243 #  define CYTHON_NCP_UNUSED
244 # else
245 #  define CYTHON_NCP_UNUSED CYTHON_UNUSED
246 # endif
247 #endif
248 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
249 #ifdef _MSC_VER
250     #ifndef _MSC_STDINT_H_
251         #if _MSC_VER < 1300
252            typedef unsigned char     uint8_t;
253            typedef unsigned int      uint32_t;
254         #else
255            typedef unsigned __int8   uint8_t;
256            typedef unsigned __int32  uint32_t;
257         #endif
258     #endif
259 #else
260    #include <stdint.h>
261 #endif
262 #ifndef CYTHON_FALLTHROUGH
263   #if defined(__cplusplus) && __cplusplus >= 201103L
264     #if __has_cpp_attribute(fallthrough)
265       #define CYTHON_FALLTHROUGH [[fallthrough]]
266     #elif __has_cpp_attribute(clang::fallthrough)
267       #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
268     #elif __has_cpp_attribute(gnu::fallthrough)
269       #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
270     #endif
271   #endif
272   #ifndef CYTHON_FALLTHROUGH
273     #if __has_attribute(fallthrough)
274       #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
275     #else
276       #define CYTHON_FALLTHROUGH
277     #endif
278   #endif
279   #if defined(__clang__ ) && defined(__apple_build_version__)
280     #if __apple_build_version__ < 7000000
281       #undef  CYTHON_FALLTHROUGH
282       #define CYTHON_FALLTHROUGH
283     #endif
284   #endif
285 #endif
286 
287 #ifndef CYTHON_INLINE
288   #if defined(__clang__)
289     #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
290   #elif defined(__GNUC__)
291     #define CYTHON_INLINE __inline__
292   #elif defined(_MSC_VER)
293     #define CYTHON_INLINE __inline
294   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
295     #define CYTHON_INLINE inline
296   #else
297     #define CYTHON_INLINE
298   #endif
299 #endif
300 
301 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
302   #define Py_OptimizeFlag 0
303 #endif
304 #define __PYX_BUILD_PY_SSIZE_T "n"
305 #define CYTHON_FORMAT_SSIZE_T "z"
306 #if PY_MAJOR_VERSION < 3
307   #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
308   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
309           PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
310   #define __Pyx_DefaultClassType PyClass_Type
311 #else
312   #define __Pyx_BUILTIN_MODULE_NAME "builtins"
313 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
314   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
315           PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
316 #else
317   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
318           PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
319 #endif
320   #define __Pyx_DefaultClassType PyType_Type
321 #endif
322 #ifndef Py_TPFLAGS_CHECKTYPES
323   #define Py_TPFLAGS_CHECKTYPES 0
324 #endif
325 #ifndef Py_TPFLAGS_HAVE_INDEX
326   #define Py_TPFLAGS_HAVE_INDEX 0
327 #endif
328 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
329   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
330 #endif
331 #ifndef Py_TPFLAGS_HAVE_FINALIZE
332   #define Py_TPFLAGS_HAVE_FINALIZE 0
333 #endif
334 #ifndef METH_STACKLESS
335   #define METH_STACKLESS 0
336 #endif
337 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
338   #ifndef METH_FASTCALL
339      #define METH_FASTCALL 0x80
340   #endif
341   typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
342   typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
343                                                           Py_ssize_t nargs, PyObject *kwnames);
344 #else
345   #define __Pyx_PyCFunctionFast _PyCFunctionFast
346   #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
347 #endif
348 #if CYTHON_FAST_PYCCALL
349 #define __Pyx_PyFastCFunction_Check(func)\
350     ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
351 #else
352 #define __Pyx_PyFastCFunction_Check(func) 0
353 #endif
354 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
355   #define PyObject_Malloc(s)   PyMem_Malloc(s)
356   #define PyObject_Free(p)     PyMem_Free(p)
357   #define PyObject_Realloc(p)  PyMem_Realloc(p)
358 #endif
359 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
360   #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
361   #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
362   #define PyMem_RawFree(p)             PyMem_Free(p)
363 #endif
364 #if CYTHON_COMPILING_IN_PYSTON
365   #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
366   #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
367 #else
368   #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
369   #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
370 #endif
371 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
372   #define __Pyx_PyThreadState_Current PyThreadState_GET()
373 #elif PY_VERSION_HEX >= 0x03060000
374   #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
375 #elif PY_VERSION_HEX >= 0x03000000
376   #define __Pyx_PyThreadState_Current PyThreadState_GET()
377 #else
378   #define __Pyx_PyThreadState_Current _PyThreadState_Current
379 #endif
380 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
381 #include "pythread.h"
382 #define Py_tss_NEEDS_INIT 0
383 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)384 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
385   *key = PyThread_create_key();
386   return 0;
387 }
PyThread_tss_alloc(void)388 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
389   Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
390   *key = Py_tss_NEEDS_INIT;
391   return key;
392 }
PyThread_tss_free(Py_tss_t * key)393 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
394   PyObject_Free(key);
395 }
PyThread_tss_is_created(Py_tss_t * key)396 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
397   return *key != Py_tss_NEEDS_INIT;
398 }
PyThread_tss_delete(Py_tss_t * key)399 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
400   PyThread_delete_key(*key);
401   *key = Py_tss_NEEDS_INIT;
402 }
PyThread_tss_set(Py_tss_t * key,void * value)403 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
404   return PyThread_set_key_value(*key, value);
405 }
PyThread_tss_get(Py_tss_t * key)406 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
407   return PyThread_get_key_value(*key);
408 }
409 #endif
410 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
411 #define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
412 #else
413 #define __Pyx_PyDict_NewPresized(n)  PyDict_New()
414 #endif
415 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
416   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
417   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
418 #else
419   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
420   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
421 #endif
422 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
423 #define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
424 #else
425 #define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
426 #endif
427 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
428   #define CYTHON_PEP393_ENABLED 1
429   #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
430                                               0 : _PyUnicode_Ready((PyObject *)(op)))
431   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
432   #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
433   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
434   #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
435   #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
436   #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
437   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
438   #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
439   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
440   #else
441   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
442   #endif
443 #else
444   #define CYTHON_PEP393_ENABLED 0
445   #define PyUnicode_1BYTE_KIND  1
446   #define PyUnicode_2BYTE_KIND  2
447   #define PyUnicode_4BYTE_KIND  4
448   #define __Pyx_PyUnicode_READY(op)       (0)
449   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
450   #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
451   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
452   #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
453   #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
454   #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
455   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
456   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
457 #endif
458 #if CYTHON_COMPILING_IN_PYPY
459   #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
460   #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
461 #else
462   #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
463   #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
464       PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
465 #endif
466 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
467   #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
468 #endif
469 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
470   #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
471 #endif
472 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
473   #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
474 #endif
475 #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))
476 #define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
477 #if PY_MAJOR_VERSION >= 3
478   #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
479 #else
480   #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
481 #endif
482 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
483   #define PyObject_ASCII(o)            PyObject_Repr(o)
484 #endif
485 #if PY_MAJOR_VERSION >= 3
486   #define PyBaseString_Type            PyUnicode_Type
487   #define PyStringObject               PyUnicodeObject
488   #define PyString_Type                PyUnicode_Type
489   #define PyString_Check               PyUnicode_Check
490   #define PyString_CheckExact          PyUnicode_CheckExact
491 #ifndef PyObject_Unicode
492   #define PyObject_Unicode             PyObject_Str
493 #endif
494 #endif
495 #if PY_MAJOR_VERSION >= 3
496   #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
497   #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
498 #else
499   #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
500   #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
501 #endif
502 #ifndef PySet_CheckExact
503   #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
504 #endif
505 #if PY_VERSION_HEX >= 0x030900A4
506   #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
507   #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
508 #else
509   #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
510   #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
511 #endif
512 #if CYTHON_ASSUME_SAFE_MACROS
513   #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
514 #else
515   #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
516 #endif
517 #if PY_MAJOR_VERSION >= 3
518   #define PyIntObject                  PyLongObject
519   #define PyInt_Type                   PyLong_Type
520   #define PyInt_Check(op)              PyLong_Check(op)
521   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
522   #define PyInt_FromString             PyLong_FromString
523   #define PyInt_FromUnicode            PyLong_FromUnicode
524   #define PyInt_FromLong               PyLong_FromLong
525   #define PyInt_FromSize_t             PyLong_FromSize_t
526   #define PyInt_FromSsize_t            PyLong_FromSsize_t
527   #define PyInt_AsLong                 PyLong_AsLong
528   #define PyInt_AS_LONG                PyLong_AS_LONG
529   #define PyInt_AsSsize_t              PyLong_AsSsize_t
530   #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
531   #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
532   #define PyNumber_Int                 PyNumber_Long
533 #endif
534 #if PY_MAJOR_VERSION >= 3
535   #define PyBoolObject                 PyLongObject
536 #endif
537 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
538   #ifndef PyUnicode_InternFromString
539     #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
540   #endif
541 #endif
542 #if PY_VERSION_HEX < 0x030200A4
543   typedef long Py_hash_t;
544   #define __Pyx_PyInt_FromHash_t PyInt_FromLong
545   #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
546 #else
547   #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
548   #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
549 #endif
550 #if PY_MAJOR_VERSION >= 3
551   #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
552 #else
553   #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
554 #endif
555 #if CYTHON_USE_ASYNC_SLOTS
556   #if PY_VERSION_HEX >= 0x030500B1
557     #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
558     #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
559   #else
560     #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
561   #endif
562 #else
563   #define __Pyx_PyType_AsAsync(obj) NULL
564 #endif
565 #ifndef __Pyx_PyAsyncMethodsStruct
566     typedef struct {
567         unaryfunc am_await;
568         unaryfunc am_aiter;
569         unaryfunc am_anext;
570     } __Pyx_PyAsyncMethodsStruct;
571 #endif
572 
573 #if defined(WIN32) || defined(MS_WINDOWS)
574   #define _USE_MATH_DEFINES
575 #endif
576 #include <math.h>
577 #ifdef NAN
578 #define __PYX_NAN() ((float) NAN)
579 #else
__PYX_NAN()580 static CYTHON_INLINE float __PYX_NAN() {
581   float value;
582   memset(&value, 0xFF, sizeof(value));
583   return value;
584 }
585 #endif
586 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
587 #define __Pyx_truncl trunc
588 #else
589 #define __Pyx_truncl truncl
590 #endif
591 
592 #define __PYX_MARK_ERR_POS(f_index, lineno) \
593     { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
594 #define __PYX_ERR(f_index, lineno, Ln_error) \
595     { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
596 
597 #ifndef __PYX_EXTERN_C
598   #ifdef __cplusplus
599     #define __PYX_EXTERN_C extern "C"
600   #else
601     #define __PYX_EXTERN_C extern
602   #endif
603 #endif
604 
605 #define __PYX_HAVE__fiona___shim
606 #define __PYX_HAVE_API__fiona___shim
607 /* Early includes */
608 #include <string.h>
609 #include <stdio.h>
610 #include "ogr_core.h"
611 #include "gdal.h"
612 #include "gdal_version.h"
613 #include "cpl_conv.h"
614 #include "cpl_string.h"
615 #include "sys/stat.h"
616 #include "cpl_vsi.h"
617 #include "ogr_srs_api.h"
618 #include "ogr_api.h"
619 #ifdef _OPENMP
620 #include <omp.h>
621 #endif /* _OPENMP */
622 
623 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
624 #define CYTHON_WITHOUT_ASSERTIONS
625 #endif
626 
627 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
628                 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
629 
630 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
631 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
632 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
633 #define __PYX_DEFAULT_STRING_ENCODING ""
634 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
635 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
636 #define __Pyx_uchar_cast(c) ((unsigned char)c)
637 #define __Pyx_long_cast(x) ((long)x)
638 #define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
639     (sizeof(type) < sizeof(Py_ssize_t))  ||\
640     (sizeof(type) > sizeof(Py_ssize_t) &&\
641           likely(v < (type)PY_SSIZE_T_MAX ||\
642                  v == (type)PY_SSIZE_T_MAX)  &&\
643           (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
644                                 v == (type)PY_SSIZE_T_MIN)))  ||\
645     (sizeof(type) == sizeof(Py_ssize_t) &&\
646           (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
647                                v == (type)PY_SSIZE_T_MAX)))  )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)648 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
649     return (size_t) i < (size_t) limit;
650 }
651 #if defined (__cplusplus) && __cplusplus >= 201103L
652     #include <cstdlib>
653     #define __Pyx_sst_abs(value) std::abs(value)
654 #elif SIZEOF_INT >= SIZEOF_SIZE_T
655     #define __Pyx_sst_abs(value) abs(value)
656 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
657     #define __Pyx_sst_abs(value) labs(value)
658 #elif defined (_MSC_VER)
659     #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
660 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
661     #define __Pyx_sst_abs(value) llabs(value)
662 #elif defined (__GNUC__)
663     #define __Pyx_sst_abs(value) __builtin_llabs(value)
664 #else
665     #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
666 #endif
667 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
668 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
669 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
670 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
671 #define __Pyx_PyBytes_FromString        PyBytes_FromString
672 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
673 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
674 #if PY_MAJOR_VERSION < 3
675     #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
676     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
677 #else
678     #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
679     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
680 #endif
681 #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
682 #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
683 #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
684 #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
685 #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
686 #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
687 #define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
688 #define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
689 #define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
690 #define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
691 #define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
692 #define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
693 #define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
694 #define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
695 #define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
696 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)697 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
698     const Py_UNICODE *u_end = u;
699     while (*u_end++) ;
700     return (size_t)(u_end - u - 1);
701 }
702 #define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
703 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
704 #define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
705 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
706 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
707 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
708 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
709 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
710 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
711 #define __Pyx_PySequence_Tuple(obj)\
712     (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
713 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
714 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
715 #if CYTHON_ASSUME_SAFE_MACROS
716 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
717 #else
718 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
719 #endif
720 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
721 #if PY_MAJOR_VERSION >= 3
722 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
723 #else
724 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
725 #endif
726 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
727 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
728 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)729 static int __Pyx_init_sys_getdefaultencoding_params(void) {
730     PyObject* sys;
731     PyObject* default_encoding = NULL;
732     PyObject* ascii_chars_u = NULL;
733     PyObject* ascii_chars_b = NULL;
734     const char* default_encoding_c;
735     sys = PyImport_ImportModule("sys");
736     if (!sys) goto bad;
737     default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
738     Py_DECREF(sys);
739     if (!default_encoding) goto bad;
740     default_encoding_c = PyBytes_AsString(default_encoding);
741     if (!default_encoding_c) goto bad;
742     if (strcmp(default_encoding_c, "ascii") == 0) {
743         __Pyx_sys_getdefaultencoding_not_ascii = 0;
744     } else {
745         char ascii_chars[128];
746         int c;
747         for (c = 0; c < 128; c++) {
748             ascii_chars[c] = c;
749         }
750         __Pyx_sys_getdefaultencoding_not_ascii = 1;
751         ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
752         if (!ascii_chars_u) goto bad;
753         ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
754         if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
755             PyErr_Format(
756                 PyExc_ValueError,
757                 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
758                 default_encoding_c);
759             goto bad;
760         }
761         Py_DECREF(ascii_chars_u);
762         Py_DECREF(ascii_chars_b);
763     }
764     Py_DECREF(default_encoding);
765     return 0;
766 bad:
767     Py_XDECREF(default_encoding);
768     Py_XDECREF(ascii_chars_u);
769     Py_XDECREF(ascii_chars_b);
770     return -1;
771 }
772 #endif
773 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
774 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
775 #else
776 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
777 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
778 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)779 static int __Pyx_init_sys_getdefaultencoding_params(void) {
780     PyObject* sys;
781     PyObject* default_encoding = NULL;
782     char* default_encoding_c;
783     sys = PyImport_ImportModule("sys");
784     if (!sys) goto bad;
785     default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
786     Py_DECREF(sys);
787     if (!default_encoding) goto bad;
788     default_encoding_c = PyBytes_AsString(default_encoding);
789     if (!default_encoding_c) goto bad;
790     __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
791     if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
792     strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
793     Py_DECREF(default_encoding);
794     return 0;
795 bad:
796     Py_XDECREF(default_encoding);
797     return -1;
798 }
799 #endif
800 #endif
801 
802 
803 /* Test for GCC > 2.95 */
804 #if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
805   #define likely(x)   __builtin_expect(!!(x), 1)
806   #define unlikely(x) __builtin_expect(!!(x), 0)
807 #else /* !__GNUC__ or GCC < 2.95 */
808   #define likely(x)   (x)
809   #define unlikely(x) (x)
810 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)811 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
812 
813 static PyObject *__pyx_m = NULL;
814 static PyObject *__pyx_d;
815 static PyObject *__pyx_b;
816 static PyObject *__pyx_cython_runtime = NULL;
817 static PyObject *__pyx_empty_tuple;
818 static PyObject *__pyx_empty_bytes;
819 static PyObject *__pyx_empty_unicode;
820 static int __pyx_lineno;
821 static int __pyx_clineno = 0;
822 static const char * __pyx_cfilenm= __FILE__;
823 static const char *__pyx_filename;
824 
825 
826 static const char *__pyx_f[] = {
827   "fiona/_shim.pyx",
828 };
829 
830 /*--- Type declarations ---*/
831 
832 /* --- Runtime support code (head) --- */
833 /* Refnanny.proto */
834 #ifndef CYTHON_REFNANNY
835   #define CYTHON_REFNANNY 0
836 #endif
837 #if CYTHON_REFNANNY
838   typedef struct {
839     void (*INCREF)(void*, PyObject*, int);
840     void (*DECREF)(void*, PyObject*, int);
841     void (*GOTREF)(void*, PyObject*, int);
842     void (*GIVEREF)(void*, PyObject*, int);
843     void* (*SetupContext)(const char*, int, const char*);
844     void (*FinishContext)(void**);
845   } __Pyx_RefNannyAPIStruct;
846   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
847   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
848   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
849 #ifdef WITH_THREAD
850   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
851           if (acquire_gil) {\
852               PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
853               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
854               PyGILState_Release(__pyx_gilstate_save);\
855           } else {\
856               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
857           }
858 #else
859   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
860           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
861 #endif
862   #define __Pyx_RefNannyFinishContext()\
863           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
864   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
865   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
866   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
867   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
868   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
869   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
870   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
871   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
872 #else
873   #define __Pyx_RefNannyDeclarations
874   #define __Pyx_RefNannySetupContext(name, acquire_gil)
875   #define __Pyx_RefNannyFinishContext()
876   #define __Pyx_INCREF(r) Py_INCREF(r)
877   #define __Pyx_DECREF(r) Py_DECREF(r)
878   #define __Pyx_GOTREF(r)
879   #define __Pyx_GIVEREF(r)
880   #define __Pyx_XINCREF(r) Py_XINCREF(r)
881   #define __Pyx_XDECREF(r) Py_XDECREF(r)
882   #define __Pyx_XGOTREF(r)
883   #define __Pyx_XGIVEREF(r)
884 #endif
885 #define __Pyx_XDECREF_SET(r, v) do {\
886         PyObject *tmp = (PyObject *) r;\
887         r = v; __Pyx_XDECREF(tmp);\
888     } while (0)
889 #define __Pyx_DECREF_SET(r, v) do {\
890         PyObject *tmp = (PyObject *) r;\
891         r = v; __Pyx_DECREF(tmp);\
892     } while (0)
893 #define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
894 #define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
895 
896 /* PyObjectGetAttrStr.proto */
897 #if CYTHON_USE_TYPE_SLOTS
898 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
899 #else
900 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
901 #endif
902 
903 /* GetBuiltinName.proto */
904 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
905 
906 /* PyDictVersioning.proto */
907 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
908 #define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
909 #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
910 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
911     (version_var) = __PYX_GET_DICT_VERSION(dict);\
912     (cache_var) = (value);
913 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
914     static PY_UINT64_T __pyx_dict_version = 0;\
915     static PyObject *__pyx_dict_cached_value = NULL;\
916     if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
917         (VAR) = __pyx_dict_cached_value;\
918     } else {\
919         (VAR) = __pyx_dict_cached_value = (LOOKUP);\
920         __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
921     }\
922 }
923 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
924 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
925 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
926 #else
927 #define __PYX_GET_DICT_VERSION(dict)  (0)
928 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
929 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
930 #endif
931 
932 /* GetModuleGlobalName.proto */
933 #if CYTHON_USE_DICT_VERSIONS
934 #define __Pyx_GetModuleGlobalName(var, name)  {\
935     static PY_UINT64_T __pyx_dict_version = 0;\
936     static PyObject *__pyx_dict_cached_value = NULL;\
937     (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
938         (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
939         __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
940 }
941 #define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
942     PY_UINT64_T __pyx_dict_version;\
943     PyObject *__pyx_dict_cached_value;\
944     (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
945 }
946 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
947 #else
948 #define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
949 #define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
950 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
951 #endif
952 
953 /* PyObjectLookupSpecial.proto */
954 #if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_LookupSpecial(PyObject * obj,PyObject * attr_name)955 static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) {
956     PyObject *res;
957     PyTypeObject *tp = Py_TYPE(obj);
958 #if PY_MAJOR_VERSION < 3
959     if (unlikely(PyInstance_Check(obj)))
960         return __Pyx_PyObject_GetAttrStr(obj, attr_name);
961 #endif
962     res = _PyType_Lookup(tp, attr_name);
963     if (likely(res)) {
964         descrgetfunc f = Py_TYPE(res)->tp_descr_get;
965         if (!f) {
966             Py_INCREF(res);
967         } else {
968             res = f(res, obj, (PyObject *)tp);
969         }
970     } else {
971         PyErr_SetObject(PyExc_AttributeError, attr_name);
972     }
973     return res;
974 }
975 #else
976 #define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
977 #endif
978 
979 /* PyFunctionFastCall.proto */
980 #if CYTHON_FAST_PYCALL
981 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
982     __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
983 #if 1 || PY_VERSION_HEX < 0x030600B1
984 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
985 #else
986 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
987 #endif
988 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
989     (sizeof(char [1 - 2*!(cond)]) - 1)
990 #ifndef Py_MEMBER_SIZE
991 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
992 #endif
993   static size_t __pyx_pyframe_localsplus_offset = 0;
994   #include "frameobject.h"
995   #define __Pxy_PyFrame_Initialize_Offsets()\
996     ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
997      (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
998   #define __Pyx_PyFrame_GetLocalsplus(frame)\
999     (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1000 #endif
1001 
1002 /* PyObjectCall.proto */
1003 #if CYTHON_COMPILING_IN_CPYTHON
1004 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1005 #else
1006 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1007 #endif
1008 
1009 /* PyObjectCallMethO.proto */
1010 #if CYTHON_COMPILING_IN_CPYTHON
1011 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1012 #endif
1013 
1014 /* PyObjectCallNoArg.proto */
1015 #if CYTHON_COMPILING_IN_CPYTHON
1016 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1017 #else
1018 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1019 #endif
1020 
1021 /* PyCFunctionFastCall.proto */
1022 #if CYTHON_FAST_PYCCALL
1023 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1024 #else
1025 #define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
1026 #endif
1027 
1028 /* PyObjectCallOneArg.proto */
1029 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1030 
1031 /* PyThreadStateGet.proto */
1032 #if CYTHON_FAST_THREAD_STATE
1033 #define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
1034 #define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
1035 #define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
1036 #else
1037 #define __Pyx_PyThreadState_declare
1038 #define __Pyx_PyThreadState_assign
1039 #define __Pyx_PyErr_Occurred()  PyErr_Occurred()
1040 #endif
1041 
1042 /* PyErrFetchRestore.proto */
1043 #if CYTHON_FAST_THREAD_STATE
1044 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1045 #define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1046 #define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1047 #define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1048 #define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1049 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1050 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1051 #if CYTHON_COMPILING_IN_CPYTHON
1052 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1053 #else
1054 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1055 #endif
1056 #else
1057 #define __Pyx_PyErr_Clear() PyErr_Clear()
1058 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1059 #define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
1060 #define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
1061 #define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
1062 #define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
1063 #define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
1064 #define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
1065 #endif
1066 
1067 /* WriteUnraisableException.proto */
1068 static void __Pyx_WriteUnraisable(const char *name, int clineno,
1069                                   int lineno, const char *filename,
1070                                   int full_traceback, int nogil);
1071 
1072 /* RaiseTooManyValuesToUnpack.proto */
1073 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
1074 
1075 /* RaiseNeedMoreValuesToUnpack.proto */
1076 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
1077 
1078 /* IterFinish.proto */
1079 static CYTHON_INLINE int __Pyx_IterFinish(void);
1080 
1081 /* UnpackItemEndCheck.proto */
1082 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
1083 
1084 /* PyObjectCall2Args.proto */
1085 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1086 
1087 /* GetTopmostException.proto */
1088 #if CYTHON_USE_EXC_INFO_STACK
1089 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1090 #endif
1091 
1092 /* SaveResetException.proto */
1093 #if CYTHON_FAST_THREAD_STATE
1094 #define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1095 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1096 #define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1097 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1098 #else
1099 #define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
1100 #define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
1101 #endif
1102 
1103 /* FastTypeChecks.proto */
1104 #if CYTHON_COMPILING_IN_CPYTHON
1105 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1106 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1107 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1108 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1109 #else
1110 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1111 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1112 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1113 #endif
1114 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1115 
1116 /* GetException.proto */
1117 #if CYTHON_FAST_THREAD_STATE
1118 #define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
1119 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1120 #else
1121 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1122 #endif
1123 
1124 /* IncludeStringH.proto */
1125 #include <string.h>
1126 
1127 /* decode_c_string_utf16.proto */
__Pyx_PyUnicode_DecodeUTF16(const char * s,Py_ssize_t size,const char * errors)1128 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
1129     int byteorder = 0;
1130     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1131 }
__Pyx_PyUnicode_DecodeUTF16LE(const char * s,Py_ssize_t size,const char * errors)1132 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
1133     int byteorder = -1;
1134     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1135 }
__Pyx_PyUnicode_DecodeUTF16BE(const char * s,Py_ssize_t size,const char * errors)1136 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
1137     int byteorder = 1;
1138     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1139 }
1140 
1141 /* decode_c_string.proto */
1142 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
1143          const char* cstring, Py_ssize_t start, Py_ssize_t stop,
1144          const char* encoding, const char* errors,
1145          PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
1146 
1147 /* RaiseException.proto */
1148 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1149 
1150 /* SwapException.proto */
1151 #if CYTHON_FAST_THREAD_STATE
1152 #define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
1153 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1154 #else
1155 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
1156 #endif
1157 
1158 /* Import.proto */
1159 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1160 
1161 /* ImportFrom.proto */
1162 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1163 
1164 /* CLineInTraceback.proto */
1165 #ifdef CYTHON_CLINE_IN_TRACEBACK
1166 #define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1167 #else
1168 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1169 #endif
1170 
1171 /* CodeObjectCache.proto */
1172 typedef struct {
1173     PyCodeObject* code_object;
1174     int code_line;
1175 } __Pyx_CodeObjectCacheEntry;
1176 struct __Pyx_CodeObjectCache {
1177     int count;
1178     int max_count;
1179     __Pyx_CodeObjectCacheEntry* entries;
1180 };
1181 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1182 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1183 static PyCodeObject *__pyx_find_code_object(int code_line);
1184 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1185 
1186 /* AddTraceback.proto */
1187 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1188                                int py_line, const char *filename);
1189 
1190 /* CIntToPy.proto */
1191 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1192 
1193 /* CIntFromPy.proto */
1194 static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *);
1195 
1196 /* CIntToPy.proto */
1197 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1198 
1199 /* CIntFromPy.proto */
1200 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1201 
1202 /* CIntFromPy.proto */
1203 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1204 
1205 /* CheckBinaryVersion.proto */
1206 static int __Pyx_check_binary_version(void);
1207 
1208 /* FunctionExport.proto */
1209 static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);
1210 
1211 /* FunctionImport.proto */
1212 static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
1213 
1214 /* InitStrings.proto */
1215 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1216 
1217 
1218 /* Module declarations from 'libc.string' */
1219 
1220 /* Module declarations from 'libc.stdio' */
1221 
1222 /* Module declarations from 'fiona.ogrext2' */
1223 
1224 /* Module declarations from 'fiona._err' */
1225 static void *(*__pyx_f_5fiona_4_err_exc_wrap_pointer)(void *); /*proto*/
1226 
1227 /* Module declarations from 'fiona._shim' */
1228 #define __Pyx_MODULE_NAME "fiona._shim"
1229 extern int __pyx_module_is_main_fiona___shim;
1230 int __pyx_module_is_main_fiona___shim = 0;
1231 
1232 /* Implementation of 'fiona._shim' */
1233 static const char __pyx_k_ON[] = "ON";
1234 static const char __pyx_k_os[] = "os";
1235 static const char __pyx_k_OFF[] = "OFF";
1236 static const char __pyx_k_log[] = "log";
1237 static const char __pyx_k_exit[] = "__exit__";
1238 static const char __pyx_k_main[] = "__main__";
1239 static const char __pyx_k_name[] = "__name__";
1240 static const char __pyx_k_test[] = "__test__";
1241 static const char __pyx_k_debug[] = "debug";
1242 static const char __pyx_k_enter[] = "__enter__";
1243 static const char __pyx_k_items[] = "items";
1244 static const char __pyx_k_upper[] = "upper";
1245 static const char __pyx_k_utf_8[] = "utf-8";
1246 static const char __pyx_k_encode[] = "encode";
1247 static const char __pyx_k_format[] = "format";
1248 static const char __pyx_k_import[] = "__import__";
1249 static const char __pyx_k_environ[] = "environ";
1250 static const char __pyx_k_logging[] = "logging";
1251 static const char __pyx_k_PROJ_LIB[] = "PROJ_LIB";
1252 static const char __pyx_k_cpl_errs[] = "cpl_errs";
1253 static const char __pyx_k_getLogger[] = "getLogger";
1254 static const char __pyx_k_fiona__err[] = "fiona._err";
1255 static const char __pyx_k_DriverError[] = "DriverError";
1256 static const char __pyx_k_fiona_errors[] = "fiona.errors";
1257 static const char __pyx_k_CPLE_BaseError[] = "CPLE_BaseError";
1258 static const char __pyx_k_Set_option_r_r[] = "Set option %r: %r";
1259 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1260 static const char __pyx_k_FionaNullPointerError[] = "FionaNullPointerError";
1261 static const char __pyx_k_Failed_to_create_dataset[] = "Failed to create dataset: {}";
1262 static const char __pyx_k_Failed_to_open_dataset_mode[] = "Failed to open dataset (mode={}): {}";
1263 static const char __pyx_k_Shims_on_top_of_ogrext_for_GDAL[] = "Shims on top of ogrext for GDAL versions > 2";
1264 static PyObject *__pyx_n_s_CPLE_BaseError;
1265 static PyObject *__pyx_n_s_DriverError;
1266 static PyObject *__pyx_kp_s_Failed_to_create_dataset;
1267 static PyObject *__pyx_kp_s_Failed_to_open_dataset_mode;
1268 static PyObject *__pyx_n_s_FionaNullPointerError;
1269 static PyObject *__pyx_n_s_OFF;
1270 static PyObject *__pyx_n_s_ON;
1271 static PyObject *__pyx_n_s_PROJ_LIB;
1272 static PyObject *__pyx_kp_s_Set_option_r_r;
1273 static PyObject *__pyx_n_s_cline_in_traceback;
1274 static PyObject *__pyx_n_s_cpl_errs;
1275 static PyObject *__pyx_n_s_debug;
1276 static PyObject *__pyx_n_s_encode;
1277 static PyObject *__pyx_n_s_enter;
1278 static PyObject *__pyx_n_s_environ;
1279 static PyObject *__pyx_n_s_exit;
1280 static PyObject *__pyx_n_s_fiona__err;
1281 static PyObject *__pyx_n_s_fiona_errors;
1282 static PyObject *__pyx_n_s_format;
1283 static PyObject *__pyx_n_s_getLogger;
1284 static PyObject *__pyx_n_s_import;
1285 static PyObject *__pyx_n_s_items;
1286 static PyObject *__pyx_n_s_log;
1287 static PyObject *__pyx_n_s_logging;
1288 static PyObject *__pyx_n_s_main;
1289 static PyObject *__pyx_n_s_name;
1290 static PyObject *__pyx_n_s_os;
1291 static PyObject *__pyx_n_s_test;
1292 static PyObject *__pyx_n_s_upper;
1293 static PyObject *__pyx_kp_s_utf_8;
1294 static PyObject *__pyx_tuple_;
1295 /* Late includes */
1296 
1297 /* "fiona/_shim.pyx":15
1298  *
1299  *
1300  * cdef bint is_field_null(void *feature, int n):             # <<<<<<<<<<<<<<
1301  *     if not OGR_F_IsFieldSet(feature, n):
1302  *         return True
1303  */
1304 
__pyx_f_5fiona_5_shim_is_field_null(void * __pyx_v_feature,int __pyx_v_n)1305 static int __pyx_f_5fiona_5_shim_is_field_null(void *__pyx_v_feature, int __pyx_v_n) {
1306   int __pyx_r;
1307   __Pyx_RefNannyDeclarations
1308   int __pyx_t_1;
1309   __Pyx_RefNannySetupContext("is_field_null", 0);
1310 
1311   /* "fiona/_shim.pyx":16
1312  *
1313  * cdef bint is_field_null(void *feature, int n):
1314  *     if not OGR_F_IsFieldSet(feature, n):             # <<<<<<<<<<<<<<
1315  *         return True
1316  *     else:
1317  */
1318   __pyx_t_1 = ((!(OGR_F_IsFieldSet(__pyx_v_feature, __pyx_v_n) != 0)) != 0);
1319   if (__pyx_t_1) {
1320 
1321     /* "fiona/_shim.pyx":17
1322  * cdef bint is_field_null(void *feature, int n):
1323  *     if not OGR_F_IsFieldSet(feature, n):
1324  *         return True             # <<<<<<<<<<<<<<
1325  *     else:
1326  *         return False
1327  */
1328     __pyx_r = 1;
1329     goto __pyx_L0;
1330 
1331     /* "fiona/_shim.pyx":16
1332  *
1333  * cdef bint is_field_null(void *feature, int n):
1334  *     if not OGR_F_IsFieldSet(feature, n):             # <<<<<<<<<<<<<<
1335  *         return True
1336  *     else:
1337  */
1338   }
1339 
1340   /* "fiona/_shim.pyx":19
1341  *         return True
1342  *     else:
1343  *         return False             # <<<<<<<<<<<<<<
1344  *
1345  *
1346  */
1347   /*else*/ {
1348     __pyx_r = 0;
1349     goto __pyx_L0;
1350   }
1351 
1352   /* "fiona/_shim.pyx":15
1353  *
1354  *
1355  * cdef bint is_field_null(void *feature, int n):             # <<<<<<<<<<<<<<
1356  *     if not OGR_F_IsFieldSet(feature, n):
1357  *         return True
1358  */
1359 
1360   /* function exit code */
1361   __pyx_L0:;
1362   __Pyx_RefNannyFinishContext();
1363   return __pyx_r;
1364 }
1365 
1366 /* "fiona/_shim.pyx":22
1367  *
1368  *
1369  * cdef void set_field_null(void *feature, int n):             # <<<<<<<<<<<<<<
1370  *     pass
1371  *
1372  */
1373 
__pyx_f_5fiona_5_shim_set_field_null(CYTHON_UNUSED void * __pyx_v_feature,CYTHON_UNUSED int __pyx_v_n)1374 static void __pyx_f_5fiona_5_shim_set_field_null(CYTHON_UNUSED void *__pyx_v_feature, CYTHON_UNUSED int __pyx_v_n) {
1375   __Pyx_RefNannyDeclarations
1376   __Pyx_RefNannySetupContext("set_field_null", 0);
1377 
1378   /* function exit code */
1379   __Pyx_RefNannyFinishContext();
1380 }
1381 
1382 /* "fiona/_shim.pyx":26
1383  *
1384  *
1385  * cdef void gdal_flush_cache(void *cogr_ds):             # <<<<<<<<<<<<<<
1386  *     with cpl_errs:
1387  *         GDALFlushCache(cogr_ds)
1388  */
1389 
__pyx_f_5fiona_5_shim_gdal_flush_cache(void * __pyx_v_cogr_ds)1390 static void __pyx_f_5fiona_5_shim_gdal_flush_cache(void *__pyx_v_cogr_ds) {
1391   __Pyx_RefNannyDeclarations
1392   PyObject *__pyx_t_1 = NULL;
1393   PyObject *__pyx_t_2 = NULL;
1394   PyObject *__pyx_t_3 = NULL;
1395   PyObject *__pyx_t_4 = NULL;
1396   PyObject *__pyx_t_5 = NULL;
1397   PyObject *__pyx_t_6 = NULL;
1398   PyObject *__pyx_t_7 = NULL;
1399   PyObject *__pyx_t_8 = NULL;
1400   int __pyx_lineno = 0;
1401   const char *__pyx_filename = NULL;
1402   int __pyx_clineno = 0;
1403   __Pyx_RefNannySetupContext("gdal_flush_cache", 0);
1404 
1405   /* "fiona/_shim.pyx":27
1406  *
1407  * cdef void gdal_flush_cache(void *cogr_ds):
1408  *     with cpl_errs:             # <<<<<<<<<<<<<<
1409  *         GDALFlushCache(cogr_ds)
1410  *
1411  */
1412   /*with:*/ {
1413     __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_cpl_errs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error)
1414     __Pyx_GOTREF(__pyx_t_1);
1415     __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
1416     __Pyx_GOTREF(__pyx_t_2);
1417     __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 27, __pyx_L3_error)
1418     __Pyx_GOTREF(__pyx_t_4);
1419     __pyx_t_5 = NULL;
1420     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
1421       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
1422       if (likely(__pyx_t_5)) {
1423         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
1424         __Pyx_INCREF(__pyx_t_5);
1425         __Pyx_INCREF(function);
1426         __Pyx_DECREF_SET(__pyx_t_4, function);
1427       }
1428     }
1429     __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
1430     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
1431     if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 27, __pyx_L3_error)
1432     __Pyx_GOTREF(__pyx_t_3);
1433     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1434     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1435     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1436     /*try:*/ {
1437       {
1438         (void)__pyx_t_6; (void)__pyx_t_7; (void)__pyx_t_8; /* mark used */
1439         /*try:*/ {
1440 
1441           /* "fiona/_shim.pyx":28
1442  * cdef void gdal_flush_cache(void *cogr_ds):
1443  *     with cpl_errs:
1444  *         GDALFlushCache(cogr_ds)             # <<<<<<<<<<<<<<
1445  *
1446  *
1447  */
1448           GDALFlushCache(__pyx_v_cogr_ds);
1449 
1450           /* "fiona/_shim.pyx":27
1451  *
1452  * cdef void gdal_flush_cache(void *cogr_ds):
1453  *     with cpl_errs:             # <<<<<<<<<<<<<<
1454  *         GDALFlushCache(cogr_ds)
1455  *
1456  */
1457         }
1458       }
1459     }
1460     /*finally:*/ {
1461       /*normal exit:*/{
1462         if (__pyx_t_2) {
1463           __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple_, NULL);
1464           __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1465           if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 27, __pyx_L1_error)
1466           __Pyx_GOTREF(__pyx_t_8);
1467           __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
1468         }
1469         goto __pyx_L6;
1470       }
1471       __pyx_L6:;
1472     }
1473     goto __pyx_L13;
1474     __pyx_L3_error:;
1475     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1476     goto __pyx_L1_error;
1477     __pyx_L13:;
1478   }
1479 
1480   /* "fiona/_shim.pyx":26
1481  *
1482  *
1483  * cdef void gdal_flush_cache(void *cogr_ds):             # <<<<<<<<<<<<<<
1484  *     with cpl_errs:
1485  *         GDALFlushCache(cogr_ds)
1486  */
1487 
1488   /* function exit code */
1489   goto __pyx_L0;
1490   __pyx_L1_error:;
1491   __Pyx_XDECREF(__pyx_t_1);
1492   __Pyx_XDECREF(__pyx_t_3);
1493   __Pyx_XDECREF(__pyx_t_4);
1494   __Pyx_XDECREF(__pyx_t_5);
1495   __Pyx_WriteUnraisable("fiona._shim.gdal_flush_cache", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
1496   __pyx_L0:;
1497   __Pyx_RefNannyFinishContext();
1498 }
1499 
1500 /* "fiona/_shim.pyx":31
1501  *
1502  *
1503  * cdef void* gdal_open_vector(const char* path_c, int mode, drivers, options) except NULL:             # <<<<<<<<<<<<<<
1504  *     cdef void* cogr_ds = NULL
1505  *     cdef char **drvs = NULL
1506  */
1507 
__pyx_f_5fiona_5_shim_gdal_open_vector(char const * __pyx_v_path_c,int __pyx_v_mode,PyObject * __pyx_v_drivers,PyObject * __pyx_v_options)1508 static void *__pyx_f_5fiona_5_shim_gdal_open_vector(char const *__pyx_v_path_c, int __pyx_v_mode, PyObject *__pyx_v_drivers, PyObject *__pyx_v_options) {
1509   void *__pyx_v_cogr_ds;
1510   char **__pyx_v_drvs;
1511   char **__pyx_v_open_opts;
1512   PyObject *__pyx_v_flags = NULL;
1513   PyObject *__pyx_v_name = NULL;
1514   PyObject *__pyx_v_name_b = NULL;
1515   PyObject *__pyx_v_name_c = NULL;
1516   void *__pyx_v_drv;
1517   PyObject *__pyx_v_k = NULL;
1518   PyObject *__pyx_v_v = NULL;
1519   PyObject *__pyx_v_exc = NULL;
1520   void *__pyx_r;
1521   __Pyx_RefNannyDeclarations
1522   PyObject *__pyx_t_1 = NULL;
1523   int __pyx_t_2;
1524   PyObject *__pyx_t_3 = NULL;
1525   Py_ssize_t __pyx_t_4;
1526   PyObject *(*__pyx_t_5)(PyObject *);
1527   PyObject *__pyx_t_6 = NULL;
1528   PyObject *__pyx_t_7 = NULL;
1529   char const *__pyx_t_8;
1530   char const *__pyx_t_9;
1531   PyObject *__pyx_t_10 = NULL;
1532   PyObject *(*__pyx_t_11)(PyObject *);
1533   int __pyx_t_12;
1534   int __pyx_t_13;
1535   char const *__pyx_t_14;
1536   char const *__pyx_t_15;
1537   PyObject *__pyx_t_16 = NULL;
1538   PyObject *__pyx_t_17 = NULL;
1539   PyObject *__pyx_t_18 = NULL;
1540   unsigned int __pyx_t_19;
1541   void *__pyx_t_20;
1542   PyObject *__pyx_t_21 = NULL;
1543   PyObject *__pyx_t_22 = NULL;
1544   PyObject *__pyx_t_23 = NULL;
1545   PyObject *__pyx_t_24 = NULL;
1546   PyObject *__pyx_t_25 = NULL;
1547   PyObject *__pyx_t_26 = NULL;
1548   int __pyx_t_27;
1549   char const *__pyx_t_28;
1550   PyObject *__pyx_t_29 = NULL;
1551   PyObject *__pyx_t_30 = NULL;
1552   PyObject *__pyx_t_31 = NULL;
1553   int __pyx_lineno = 0;
1554   const char *__pyx_filename = NULL;
1555   int __pyx_clineno = 0;
1556   __Pyx_RefNannySetupContext("gdal_open_vector", 0);
1557 
1558   /* "fiona/_shim.pyx":32
1559  *
1560  * cdef void* gdal_open_vector(const char* path_c, int mode, drivers, options) except NULL:
1561  *     cdef void* cogr_ds = NULL             # <<<<<<<<<<<<<<
1562  *     cdef char **drvs = NULL
1563  *     cdef char **open_opts = NULL
1564  */
1565   __pyx_v_cogr_ds = NULL;
1566 
1567   /* "fiona/_shim.pyx":33
1568  * cdef void* gdal_open_vector(const char* path_c, int mode, drivers, options) except NULL:
1569  *     cdef void* cogr_ds = NULL
1570  *     cdef char **drvs = NULL             # <<<<<<<<<<<<<<
1571  *     cdef char **open_opts = NULL
1572  *
1573  */
1574   __pyx_v_drvs = NULL;
1575 
1576   /* "fiona/_shim.pyx":34
1577  *     cdef void* cogr_ds = NULL
1578  *     cdef char **drvs = NULL
1579  *     cdef char **open_opts = NULL             # <<<<<<<<<<<<<<
1580  *
1581  *     flags = GDAL_OF_VECTOR | GDAL_OF_VERBOSE_ERROR
1582  */
1583   __pyx_v_open_opts = NULL;
1584 
1585   /* "fiona/_shim.pyx":36
1586  *     cdef char **open_opts = NULL
1587  *
1588  *     flags = GDAL_OF_VECTOR | GDAL_OF_VERBOSE_ERROR             # <<<<<<<<<<<<<<
1589  *     if mode == 1:
1590  *         flags |= GDAL_OF_UPDATE
1591  */
1592   __pyx_t_1 = __Pyx_PyInt_From_int((GDAL_OF_VECTOR | GDAL_OF_VERBOSE_ERROR)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error)
1593   __Pyx_GOTREF(__pyx_t_1);
1594   __pyx_v_flags = __pyx_t_1;
1595   __pyx_t_1 = 0;
1596 
1597   /* "fiona/_shim.pyx":37
1598  *
1599  *     flags = GDAL_OF_VECTOR | GDAL_OF_VERBOSE_ERROR
1600  *     if mode == 1:             # <<<<<<<<<<<<<<
1601  *         flags |= GDAL_OF_UPDATE
1602  *     else:
1603  */
1604   __pyx_t_2 = ((__pyx_v_mode == 1) != 0);
1605   if (__pyx_t_2) {
1606 
1607     /* "fiona/_shim.pyx":38
1608  *     flags = GDAL_OF_VECTOR | GDAL_OF_VERBOSE_ERROR
1609  *     if mode == 1:
1610  *         flags |= GDAL_OF_UPDATE             # <<<<<<<<<<<<<<
1611  *     else:
1612  *         flags |= GDAL_OF_READONLY
1613  */
1614     __pyx_t_1 = __Pyx_PyInt_From_int(GDAL_OF_UPDATE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
1615     __Pyx_GOTREF(__pyx_t_1);
1616     __pyx_t_3 = PyNumber_InPlaceOr(__pyx_v_flags, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 38, __pyx_L1_error)
1617     __Pyx_GOTREF(__pyx_t_3);
1618     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1619     __Pyx_DECREF_SET(__pyx_v_flags, __pyx_t_3);
1620     __pyx_t_3 = 0;
1621 
1622     /* "fiona/_shim.pyx":37
1623  *
1624  *     flags = GDAL_OF_VECTOR | GDAL_OF_VERBOSE_ERROR
1625  *     if mode == 1:             # <<<<<<<<<<<<<<
1626  *         flags |= GDAL_OF_UPDATE
1627  *     else:
1628  */
1629     goto __pyx_L3;
1630   }
1631 
1632   /* "fiona/_shim.pyx":40
1633  *         flags |= GDAL_OF_UPDATE
1634  *     else:
1635  *         flags |= GDAL_OF_READONLY             # <<<<<<<<<<<<<<
1636  *
1637  *     if drivers:
1638  */
1639   /*else*/ {
1640     __pyx_t_3 = __Pyx_PyInt_From_int(GDAL_OF_READONLY); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 40, __pyx_L1_error)
1641     __Pyx_GOTREF(__pyx_t_3);
1642     __pyx_t_1 = PyNumber_InPlaceOr(__pyx_v_flags, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
1643     __Pyx_GOTREF(__pyx_t_1);
1644     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1645     __Pyx_DECREF_SET(__pyx_v_flags, __pyx_t_1);
1646     __pyx_t_1 = 0;
1647   }
1648   __pyx_L3:;
1649 
1650   /* "fiona/_shim.pyx":42
1651  *         flags |= GDAL_OF_READONLY
1652  *
1653  *     if drivers:             # <<<<<<<<<<<<<<
1654  *         for name in drivers:
1655  *             name_b = name.encode()
1656  */
1657   __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_drivers); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 42, __pyx_L1_error)
1658   if (__pyx_t_2) {
1659 
1660     /* "fiona/_shim.pyx":43
1661  *
1662  *     if drivers:
1663  *         for name in drivers:             # <<<<<<<<<<<<<<
1664  *             name_b = name.encode()
1665  *             name_c = name_b
1666  */
1667     if (likely(PyList_CheckExact(__pyx_v_drivers)) || PyTuple_CheckExact(__pyx_v_drivers)) {
1668       __pyx_t_1 = __pyx_v_drivers; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
1669       __pyx_t_5 = NULL;
1670     } else {
1671       __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_drivers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
1672       __Pyx_GOTREF(__pyx_t_1);
1673       __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 43, __pyx_L1_error)
1674     }
1675     for (;;) {
1676       if (likely(!__pyx_t_5)) {
1677         if (likely(PyList_CheckExact(__pyx_t_1))) {
1678           if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
1679           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1680           __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 43, __pyx_L1_error)
1681           #else
1682           __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error)
1683           __Pyx_GOTREF(__pyx_t_3);
1684           #endif
1685         } else {
1686           if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
1687           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1688           __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 43, __pyx_L1_error)
1689           #else
1690           __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error)
1691           __Pyx_GOTREF(__pyx_t_3);
1692           #endif
1693         }
1694       } else {
1695         __pyx_t_3 = __pyx_t_5(__pyx_t_1);
1696         if (unlikely(!__pyx_t_3)) {
1697           PyObject* exc_type = PyErr_Occurred();
1698           if (exc_type) {
1699             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
1700             else __PYX_ERR(0, 43, __pyx_L1_error)
1701           }
1702           break;
1703         }
1704         __Pyx_GOTREF(__pyx_t_3);
1705       }
1706       __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_3);
1707       __pyx_t_3 = 0;
1708 
1709       /* "fiona/_shim.pyx":44
1710  *     if drivers:
1711  *         for name in drivers:
1712  *             name_b = name.encode()             # <<<<<<<<<<<<<<
1713  *             name_c = name_b
1714  *             drv = GDALGetDriverByName(name_c)
1715  */
1716       __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_name, __pyx_n_s_encode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 44, __pyx_L1_error)
1717       __Pyx_GOTREF(__pyx_t_6);
1718       __pyx_t_7 = NULL;
1719       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
1720         __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
1721         if (likely(__pyx_t_7)) {
1722           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
1723           __Pyx_INCREF(__pyx_t_7);
1724           __Pyx_INCREF(function);
1725           __Pyx_DECREF_SET(__pyx_t_6, function);
1726         }
1727       }
1728       __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
1729       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
1730       if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error)
1731       __Pyx_GOTREF(__pyx_t_3);
1732       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1733       __Pyx_XDECREF_SET(__pyx_v_name_b, __pyx_t_3);
1734       __pyx_t_3 = 0;
1735 
1736       /* "fiona/_shim.pyx":45
1737  *         for name in drivers:
1738  *             name_b = name.encode()
1739  *             name_c = name_b             # <<<<<<<<<<<<<<
1740  *             drv = GDALGetDriverByName(name_c)
1741  *             if drv != NULL:
1742  */
1743       __Pyx_INCREF(__pyx_v_name_b);
1744       __Pyx_XDECREF_SET(__pyx_v_name_c, __pyx_v_name_b);
1745 
1746       /* "fiona/_shim.pyx":46
1747  *             name_b = name.encode()
1748  *             name_c = name_b
1749  *             drv = GDALGetDriverByName(name_c)             # <<<<<<<<<<<<<<
1750  *             if drv != NULL:
1751  *                 drvs = CSLAddString(drvs, name_c)
1752  */
1753       __pyx_t_8 = __Pyx_PyObject_AsString(__pyx_v_name_c); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L1_error)
1754       __pyx_v_drv = GDALGetDriverByName(__pyx_t_8);
1755 
1756       /* "fiona/_shim.pyx":47
1757  *             name_c = name_b
1758  *             drv = GDALGetDriverByName(name_c)
1759  *             if drv != NULL:             # <<<<<<<<<<<<<<
1760  *                 drvs = CSLAddString(drvs, name_c)
1761  *
1762  */
1763       __pyx_t_2 = ((__pyx_v_drv != NULL) != 0);
1764       if (__pyx_t_2) {
1765 
1766         /* "fiona/_shim.pyx":48
1767  *             drv = GDALGetDriverByName(name_c)
1768  *             if drv != NULL:
1769  *                 drvs = CSLAddString(drvs, name_c)             # <<<<<<<<<<<<<<
1770  *
1771  *     for k, v in options.items():
1772  */
1773         __pyx_t_9 = __Pyx_PyObject_AsString(__pyx_v_name_c); if (unlikely((!__pyx_t_9) && PyErr_Occurred())) __PYX_ERR(0, 48, __pyx_L1_error)
1774         __pyx_v_drvs = CSLAddString(__pyx_v_drvs, __pyx_t_9);
1775 
1776         /* "fiona/_shim.pyx":47
1777  *             name_c = name_b
1778  *             drv = GDALGetDriverByName(name_c)
1779  *             if drv != NULL:             # <<<<<<<<<<<<<<
1780  *                 drvs = CSLAddString(drvs, name_c)
1781  *
1782  */
1783       }
1784 
1785       /* "fiona/_shim.pyx":43
1786  *
1787  *     if drivers:
1788  *         for name in drivers:             # <<<<<<<<<<<<<<
1789  *             name_b = name.encode()
1790  *             name_c = name_b
1791  */
1792     }
1793     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1794 
1795     /* "fiona/_shim.pyx":42
1796  *         flags |= GDAL_OF_READONLY
1797  *
1798  *     if drivers:             # <<<<<<<<<<<<<<
1799  *         for name in drivers:
1800  *             name_b = name.encode()
1801  */
1802   }
1803 
1804   /* "fiona/_shim.pyx":50
1805  *                 drvs = CSLAddString(drvs, name_c)
1806  *
1807  *     for k, v in options.items():             # <<<<<<<<<<<<<<
1808  *
1809  *         if v is None:
1810  */
1811   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s_items); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error)
1812   __Pyx_GOTREF(__pyx_t_3);
1813   __pyx_t_6 = NULL;
1814   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
1815     __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
1816     if (likely(__pyx_t_6)) {
1817       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
1818       __Pyx_INCREF(__pyx_t_6);
1819       __Pyx_INCREF(function);
1820       __Pyx_DECREF_SET(__pyx_t_3, function);
1821     }
1822   }
1823   __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
1824   __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
1825   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
1826   __Pyx_GOTREF(__pyx_t_1);
1827   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1828   if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
1829     __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
1830     __pyx_t_5 = NULL;
1831   } else {
1832     __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error)
1833     __Pyx_GOTREF(__pyx_t_3);
1834     __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 50, __pyx_L1_error)
1835   }
1836   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1837   for (;;) {
1838     if (likely(!__pyx_t_5)) {
1839       if (likely(PyList_CheckExact(__pyx_t_3))) {
1840         if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
1841         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1842         __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 50, __pyx_L1_error)
1843         #else
1844         __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
1845         __Pyx_GOTREF(__pyx_t_1);
1846         #endif
1847       } else {
1848         if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
1849         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1850         __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 50, __pyx_L1_error)
1851         #else
1852         __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
1853         __Pyx_GOTREF(__pyx_t_1);
1854         #endif
1855       }
1856     } else {
1857       __pyx_t_1 = __pyx_t_5(__pyx_t_3);
1858       if (unlikely(!__pyx_t_1)) {
1859         PyObject* exc_type = PyErr_Occurred();
1860         if (exc_type) {
1861           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
1862           else __PYX_ERR(0, 50, __pyx_L1_error)
1863         }
1864         break;
1865       }
1866       __Pyx_GOTREF(__pyx_t_1);
1867     }
1868     if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
1869       PyObject* sequence = __pyx_t_1;
1870       Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
1871       if (unlikely(size != 2)) {
1872         if (size > 2) __Pyx_RaiseTooManyValuesError(2);
1873         else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
1874         __PYX_ERR(0, 50, __pyx_L1_error)
1875       }
1876       #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1877       if (likely(PyTuple_CheckExact(sequence))) {
1878         __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0);
1879         __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1);
1880       } else {
1881         __pyx_t_6 = PyList_GET_ITEM(sequence, 0);
1882         __pyx_t_7 = PyList_GET_ITEM(sequence, 1);
1883       }
1884       __Pyx_INCREF(__pyx_t_6);
1885       __Pyx_INCREF(__pyx_t_7);
1886       #else
1887       __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 50, __pyx_L1_error)
1888       __Pyx_GOTREF(__pyx_t_6);
1889       __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 50, __pyx_L1_error)
1890       __Pyx_GOTREF(__pyx_t_7);
1891       #endif
1892       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1893     } else {
1894       Py_ssize_t index = -1;
1895       __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 50, __pyx_L1_error)
1896       __Pyx_GOTREF(__pyx_t_10);
1897       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1898       __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
1899       index = 0; __pyx_t_6 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_6)) goto __pyx_L10_unpacking_failed;
1900       __Pyx_GOTREF(__pyx_t_6);
1901       index = 1; __pyx_t_7 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_7)) goto __pyx_L10_unpacking_failed;
1902       __Pyx_GOTREF(__pyx_t_7);
1903       if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) __PYX_ERR(0, 50, __pyx_L1_error)
1904       __pyx_t_11 = NULL;
1905       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
1906       goto __pyx_L11_unpacking_done;
1907       __pyx_L10_unpacking_failed:;
1908       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
1909       __pyx_t_11 = NULL;
1910       if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
1911       __PYX_ERR(0, 50, __pyx_L1_error)
1912       __pyx_L11_unpacking_done:;
1913     }
1914     __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_6);
1915     __pyx_t_6 = 0;
1916     __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_7);
1917     __pyx_t_7 = 0;
1918 
1919     /* "fiona/_shim.pyx":52
1920  *     for k, v in options.items():
1921  *
1922  *         if v is None:             # <<<<<<<<<<<<<<
1923  *             continue
1924  *
1925  */
1926     __pyx_t_2 = (__pyx_v_v == Py_None);
1927     __pyx_t_12 = (__pyx_t_2 != 0);
1928     if (__pyx_t_12) {
1929 
1930       /* "fiona/_shim.pyx":53
1931  *
1932  *         if v is None:
1933  *             continue             # <<<<<<<<<<<<<<
1934  *
1935  *         k = k.upper().encode('utf-8')
1936  */
1937       goto __pyx_L8_continue;
1938 
1939       /* "fiona/_shim.pyx":52
1940  *     for k, v in options.items():
1941  *
1942  *         if v is None:             # <<<<<<<<<<<<<<
1943  *             continue
1944  *
1945  */
1946     }
1947 
1948     /* "fiona/_shim.pyx":55
1949  *             continue
1950  *
1951  *         k = k.upper().encode('utf-8')             # <<<<<<<<<<<<<<
1952  *         if isinstance(v, bool):
1953  *             v = ('ON' if v else 'OFF').encode('utf-8')
1954  */
1955     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_k, __pyx_n_s_upper); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 55, __pyx_L1_error)
1956     __Pyx_GOTREF(__pyx_t_6);
1957     __pyx_t_10 = NULL;
1958     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
1959       __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
1960       if (likely(__pyx_t_10)) {
1961         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
1962         __Pyx_INCREF(__pyx_t_10);
1963         __Pyx_INCREF(function);
1964         __Pyx_DECREF_SET(__pyx_t_6, function);
1965       }
1966     }
1967     __pyx_t_7 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
1968     __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
1969     if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 55, __pyx_L1_error)
1970     __Pyx_GOTREF(__pyx_t_7);
1971     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1972     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_encode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 55, __pyx_L1_error)
1973     __Pyx_GOTREF(__pyx_t_6);
1974     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
1975     __pyx_t_7 = NULL;
1976     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
1977       __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
1978       if (likely(__pyx_t_7)) {
1979         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
1980         __Pyx_INCREF(__pyx_t_7);
1981         __Pyx_INCREF(function);
1982         __Pyx_DECREF_SET(__pyx_t_6, function);
1983       }
1984     }
1985     __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_kp_s_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_kp_s_utf_8);
1986     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
1987     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error)
1988     __Pyx_GOTREF(__pyx_t_1);
1989     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1990     __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_1);
1991     __pyx_t_1 = 0;
1992 
1993     /* "fiona/_shim.pyx":56
1994  *
1995  *         k = k.upper().encode('utf-8')
1996  *         if isinstance(v, bool):             # <<<<<<<<<<<<<<
1997  *             v = ('ON' if v else 'OFF').encode('utf-8')
1998  *         else:
1999  */
2000     __pyx_t_1 = ((PyObject*)&PyBool_Type);
2001     __Pyx_INCREF(__pyx_t_1);
2002     __pyx_t_12 = PyObject_IsInstance(__pyx_v_v, __pyx_t_1); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 56, __pyx_L1_error)
2003     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2004     __pyx_t_2 = (__pyx_t_12 != 0);
2005     if (__pyx_t_2) {
2006 
2007       /* "fiona/_shim.pyx":57
2008  *         k = k.upper().encode('utf-8')
2009  *         if isinstance(v, bool):
2010  *             v = ('ON' if v else 'OFF').encode('utf-8')             # <<<<<<<<<<<<<<
2011  *         else:
2012  *             v = str(v).encode('utf-8')
2013  */
2014       __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_v); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 57, __pyx_L1_error)
2015       if (__pyx_t_2) {
2016         __Pyx_INCREF(__pyx_n_s_ON);
2017         __pyx_t_6 = __pyx_n_s_ON;
2018       } else {
2019         __Pyx_INCREF(__pyx_n_s_OFF);
2020         __pyx_t_6 = __pyx_n_s_OFF;
2021       }
2022       __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_encode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 57, __pyx_L1_error)
2023       __Pyx_GOTREF(__pyx_t_7);
2024       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2025       __pyx_t_6 = NULL;
2026       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
2027         __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
2028         if (likely(__pyx_t_6)) {
2029           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
2030           __Pyx_INCREF(__pyx_t_6);
2031           __Pyx_INCREF(function);
2032           __Pyx_DECREF_SET(__pyx_t_7, function);
2033         }
2034       }
2035       __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_6, __pyx_kp_s_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_kp_s_utf_8);
2036       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
2037       if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error)
2038       __Pyx_GOTREF(__pyx_t_1);
2039       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2040       __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_1);
2041       __pyx_t_1 = 0;
2042 
2043       /* "fiona/_shim.pyx":56
2044  *
2045  *         k = k.upper().encode('utf-8')
2046  *         if isinstance(v, bool):             # <<<<<<<<<<<<<<
2047  *             v = ('ON' if v else 'OFF').encode('utf-8')
2048  *         else:
2049  */
2050       goto __pyx_L13;
2051     }
2052 
2053     /* "fiona/_shim.pyx":59
2054  *             v = ('ON' if v else 'OFF').encode('utf-8')
2055  *         else:
2056  *             v = str(v).encode('utf-8')             # <<<<<<<<<<<<<<
2057  *         log.debug("Set option %r: %r", k, v)
2058  *         open_opts = CSLAddNameValue(open_opts, <const char *>k, <const char *>v)
2059  */
2060     /*else*/ {
2061       __pyx_t_7 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_v); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 59, __pyx_L1_error)
2062       __Pyx_GOTREF(__pyx_t_7);
2063       __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_encode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 59, __pyx_L1_error)
2064       __Pyx_GOTREF(__pyx_t_6);
2065       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2066       __pyx_t_7 = NULL;
2067       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
2068         __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
2069         if (likely(__pyx_t_7)) {
2070           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
2071           __Pyx_INCREF(__pyx_t_7);
2072           __Pyx_INCREF(function);
2073           __Pyx_DECREF_SET(__pyx_t_6, function);
2074         }
2075       }
2076       __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_kp_s_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_kp_s_utf_8);
2077       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2078       if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error)
2079       __Pyx_GOTREF(__pyx_t_1);
2080       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2081       __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_1);
2082       __pyx_t_1 = 0;
2083     }
2084     __pyx_L13:;
2085 
2086     /* "fiona/_shim.pyx":60
2087  *         else:
2088  *             v = str(v).encode('utf-8')
2089  *         log.debug("Set option %r: %r", k, v)             # <<<<<<<<<<<<<<
2090  *         open_opts = CSLAddNameValue(open_opts, <const char *>k, <const char *>v)
2091  *
2092  */
2093     __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_log); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 60, __pyx_L1_error)
2094     __Pyx_GOTREF(__pyx_t_6);
2095     __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_debug); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 60, __pyx_L1_error)
2096     __Pyx_GOTREF(__pyx_t_7);
2097     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2098     __pyx_t_6 = NULL;
2099     __pyx_t_13 = 0;
2100     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
2101       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
2102       if (likely(__pyx_t_6)) {
2103         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
2104         __Pyx_INCREF(__pyx_t_6);
2105         __Pyx_INCREF(function);
2106         __Pyx_DECREF_SET(__pyx_t_7, function);
2107         __pyx_t_13 = 1;
2108       }
2109     }
2110     #if CYTHON_FAST_PYCALL
2111     if (PyFunction_Check(__pyx_t_7)) {
2112       PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_Set_option_r_r, __pyx_v_k, __pyx_v_v};
2113       __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_13, 3+__pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
2114       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
2115       __Pyx_GOTREF(__pyx_t_1);
2116     } else
2117     #endif
2118     #if CYTHON_FAST_PYCCALL
2119     if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
2120       PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_s_Set_option_r_r, __pyx_v_k, __pyx_v_v};
2121       __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_13, 3+__pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
2122       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
2123       __Pyx_GOTREF(__pyx_t_1);
2124     } else
2125     #endif
2126     {
2127       __pyx_t_10 = PyTuple_New(3+__pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 60, __pyx_L1_error)
2128       __Pyx_GOTREF(__pyx_t_10);
2129       if (__pyx_t_6) {
2130         __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL;
2131       }
2132       __Pyx_INCREF(__pyx_kp_s_Set_option_r_r);
2133       __Pyx_GIVEREF(__pyx_kp_s_Set_option_r_r);
2134       PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_13, __pyx_kp_s_Set_option_r_r);
2135       __Pyx_INCREF(__pyx_v_k);
2136       __Pyx_GIVEREF(__pyx_v_k);
2137       PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_13, __pyx_v_k);
2138       __Pyx_INCREF(__pyx_v_v);
2139       __Pyx_GIVEREF(__pyx_v_v);
2140       PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_13, __pyx_v_v);
2141       __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
2142       __Pyx_GOTREF(__pyx_t_1);
2143       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2144     }
2145     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2146     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2147 
2148     /* "fiona/_shim.pyx":61
2149  *             v = str(v).encode('utf-8')
2150  *         log.debug("Set option %r: %r", k, v)
2151  *         open_opts = CSLAddNameValue(open_opts, <const char *>k, <const char *>v)             # <<<<<<<<<<<<<<
2152  *
2153  *     open_opts = CSLAddNameValue(open_opts, "VALIDATE_OPEN_OPTIONS", "NO")
2154  */
2155     __pyx_t_14 = __Pyx_PyObject_AsString(__pyx_v_k); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) __PYX_ERR(0, 61, __pyx_L1_error)
2156     __pyx_t_15 = __Pyx_PyObject_AsString(__pyx_v_v); if (unlikely((!__pyx_t_15) && PyErr_Occurred())) __PYX_ERR(0, 61, __pyx_L1_error)
2157     __pyx_v_open_opts = CSLAddNameValue(__pyx_v_open_opts, ((char const *)__pyx_t_14), ((char const *)__pyx_t_15));
2158 
2159     /* "fiona/_shim.pyx":50
2160  *                 drvs = CSLAddString(drvs, name_c)
2161  *
2162  *     for k, v in options.items():             # <<<<<<<<<<<<<<
2163  *
2164  *         if v is None:
2165  */
2166     __pyx_L8_continue:;
2167   }
2168   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2169 
2170   /* "fiona/_shim.pyx":63
2171  *         open_opts = CSLAddNameValue(open_opts, <const char *>k, <const char *>v)
2172  *
2173  *     open_opts = CSLAddNameValue(open_opts, "VALIDATE_OPEN_OPTIONS", "NO")             # <<<<<<<<<<<<<<
2174  *
2175  *     try:
2176  */
2177   __pyx_v_open_opts = CSLAddNameValue(__pyx_v_open_opts, ((char const *)"VALIDATE_OPEN_OPTIONS"), ((char const *)"NO"));
2178 
2179   /* "fiona/_shim.pyx":65
2180  *     open_opts = CSLAddNameValue(open_opts, "VALIDATE_OPEN_OPTIONS", "NO")
2181  *
2182  *     try:             # <<<<<<<<<<<<<<
2183  *         cogr_ds = exc_wrap_pointer(GDALOpenEx(
2184  *             path_c, flags, <const char *const *>drvs, open_opts, NULL)
2185  */
2186   /*try:*/ {
2187     {
2188       __Pyx_PyThreadState_declare
2189       __Pyx_PyThreadState_assign
2190       __Pyx_ExceptionSave(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
2191       __Pyx_XGOTREF(__pyx_t_16);
2192       __Pyx_XGOTREF(__pyx_t_17);
2193       __Pyx_XGOTREF(__pyx_t_18);
2194       /*try:*/ {
2195 
2196         /* "fiona/_shim.pyx":67
2197  *     try:
2198  *         cogr_ds = exc_wrap_pointer(GDALOpenEx(
2199  *             path_c, flags, <const char *const *>drvs, open_opts, NULL)             # <<<<<<<<<<<<<<
2200  *         )
2201  *         return cogr_ds
2202  */
2203         __pyx_t_19 = __Pyx_PyInt_As_unsigned_int(__pyx_v_flags); if (unlikely((__pyx_t_19 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 67, __pyx_L17_error)
2204 
2205         /* "fiona/_shim.pyx":66
2206  *
2207  *     try:
2208  *         cogr_ds = exc_wrap_pointer(GDALOpenEx(             # <<<<<<<<<<<<<<
2209  *             path_c, flags, <const char *const *>drvs, open_opts, NULL)
2210  *         )
2211  */
2212         __pyx_t_20 = __pyx_f_5fiona_4_err_exc_wrap_pointer(GDALOpenEx(__pyx_v_path_c, __pyx_t_19, ((char const *const *)__pyx_v_drvs), __pyx_v_open_opts, NULL)); if (unlikely(__pyx_t_20 == ((void *)NULL))) __PYX_ERR(0, 66, __pyx_L17_error)
2213         __pyx_v_cogr_ds = __pyx_t_20;
2214 
2215         /* "fiona/_shim.pyx":69
2216  *             path_c, flags, <const char *const *>drvs, open_opts, NULL)
2217  *         )
2218  *         return cogr_ds             # <<<<<<<<<<<<<<
2219  *     except FionaNullPointerError:
2220  *         raise DriverError("Failed to open dataset (mode={}): {}".format(mode, path_c.decode("utf-8")))
2221  */
2222         __pyx_r = __pyx_v_cogr_ds;
2223         goto __pyx_L21_try_return;
2224 
2225         /* "fiona/_shim.pyx":65
2226  *     open_opts = CSLAddNameValue(open_opts, "VALIDATE_OPEN_OPTIONS", "NO")
2227  *
2228  *     try:             # <<<<<<<<<<<<<<
2229  *         cogr_ds = exc_wrap_pointer(GDALOpenEx(
2230  *             path_c, flags, <const char *const *>drvs, open_opts, NULL)
2231  */
2232       }
2233       __pyx_L17_error:;
2234       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
2235       __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
2236       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2237       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
2238       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2239 
2240       /* "fiona/_shim.pyx":70
2241  *         )
2242  *         return cogr_ds
2243  *     except FionaNullPointerError:             # <<<<<<<<<<<<<<
2244  *         raise DriverError("Failed to open dataset (mode={}): {}".format(mode, path_c.decode("utf-8")))
2245  *     except CPLE_BaseError as exc:
2246  */
2247       __Pyx_ErrFetch(&__pyx_t_3, &__pyx_t_1, &__pyx_t_7);
2248       __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_FionaNullPointerError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 70, __pyx_L19_except_error)
2249       __Pyx_GOTREF(__pyx_t_10);
2250       __pyx_t_13 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_3, __pyx_t_10);
2251       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2252       __Pyx_ErrRestore(__pyx_t_3, __pyx_t_1, __pyx_t_7);
2253       __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_t_7 = 0;
2254       if (__pyx_t_13) {
2255         __Pyx_AddTraceback("fiona._shim.gdal_open_vector", __pyx_clineno, __pyx_lineno, __pyx_filename);
2256         if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 70, __pyx_L19_except_error)
2257         __Pyx_GOTREF(__pyx_t_7);
2258         __Pyx_GOTREF(__pyx_t_1);
2259         __Pyx_GOTREF(__pyx_t_3);
2260 
2261         /* "fiona/_shim.pyx":71
2262  *         return cogr_ds
2263  *     except FionaNullPointerError:
2264  *         raise DriverError("Failed to open dataset (mode={}): {}".format(mode, path_c.decode("utf-8")))             # <<<<<<<<<<<<<<
2265  *     except CPLE_BaseError as exc:
2266  *         raise DriverError(str(exc))
2267  */
2268         __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_DriverError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 71, __pyx_L19_except_error)
2269         __Pyx_GOTREF(__pyx_t_6);
2270         __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Failed_to_open_dataset_mode, __pyx_n_s_format); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 71, __pyx_L19_except_error)
2271         __Pyx_GOTREF(__pyx_t_22);
2272         __pyx_t_23 = __Pyx_PyInt_From_int(__pyx_v_mode); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 71, __pyx_L19_except_error)
2273         __Pyx_GOTREF(__pyx_t_23);
2274         __pyx_t_24 = __Pyx_decode_c_string(__pyx_v_path_c, 0, strlen(__pyx_v_path_c), NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 71, __pyx_L19_except_error)
2275         __Pyx_GOTREF(__pyx_t_24);
2276         __pyx_t_25 = NULL;
2277         __pyx_t_13 = 0;
2278         if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_22))) {
2279           __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_22);
2280           if (likely(__pyx_t_25)) {
2281             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_22);
2282             __Pyx_INCREF(__pyx_t_25);
2283             __Pyx_INCREF(function);
2284             __Pyx_DECREF_SET(__pyx_t_22, function);
2285             __pyx_t_13 = 1;
2286           }
2287         }
2288         #if CYTHON_FAST_PYCALL
2289         if (PyFunction_Check(__pyx_t_22)) {
2290           PyObject *__pyx_temp[3] = {__pyx_t_25, __pyx_t_23, __pyx_t_24};
2291           __pyx_t_21 = __Pyx_PyFunction_FastCall(__pyx_t_22, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 71, __pyx_L19_except_error)
2292           __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
2293           __Pyx_GOTREF(__pyx_t_21);
2294           __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
2295           __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
2296         } else
2297         #endif
2298         #if CYTHON_FAST_PYCCALL
2299         if (__Pyx_PyFastCFunction_Check(__pyx_t_22)) {
2300           PyObject *__pyx_temp[3] = {__pyx_t_25, __pyx_t_23, __pyx_t_24};
2301           __pyx_t_21 = __Pyx_PyCFunction_FastCall(__pyx_t_22, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 71, __pyx_L19_except_error)
2302           __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
2303           __Pyx_GOTREF(__pyx_t_21);
2304           __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
2305           __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
2306         } else
2307         #endif
2308         {
2309           __pyx_t_26 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 71, __pyx_L19_except_error)
2310           __Pyx_GOTREF(__pyx_t_26);
2311           if (__pyx_t_25) {
2312             __Pyx_GIVEREF(__pyx_t_25); PyTuple_SET_ITEM(__pyx_t_26, 0, __pyx_t_25); __pyx_t_25 = NULL;
2313           }
2314           __Pyx_GIVEREF(__pyx_t_23);
2315           PyTuple_SET_ITEM(__pyx_t_26, 0+__pyx_t_13, __pyx_t_23);
2316           __Pyx_GIVEREF(__pyx_t_24);
2317           PyTuple_SET_ITEM(__pyx_t_26, 1+__pyx_t_13, __pyx_t_24);
2318           __pyx_t_23 = 0;
2319           __pyx_t_24 = 0;
2320           __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_26, NULL); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 71, __pyx_L19_except_error)
2321           __Pyx_GOTREF(__pyx_t_21);
2322           __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
2323         }
2324         __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
2325         __pyx_t_22 = NULL;
2326         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
2327           __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_6);
2328           if (likely(__pyx_t_22)) {
2329             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
2330             __Pyx_INCREF(__pyx_t_22);
2331             __Pyx_INCREF(function);
2332             __Pyx_DECREF_SET(__pyx_t_6, function);
2333           }
2334         }
2335         __pyx_t_10 = (__pyx_t_22) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_22, __pyx_t_21) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_21);
2336         __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
2337         __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
2338         if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 71, __pyx_L19_except_error)
2339         __Pyx_GOTREF(__pyx_t_10);
2340         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2341         __Pyx_Raise(__pyx_t_10, 0, 0, 0);
2342         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2343         __PYX_ERR(0, 71, __pyx_L19_except_error)
2344       }
2345 
2346       /* "fiona/_shim.pyx":72
2347  *     except FionaNullPointerError:
2348  *         raise DriverError("Failed to open dataset (mode={}): {}".format(mode, path_c.decode("utf-8")))
2349  *     except CPLE_BaseError as exc:             # <<<<<<<<<<<<<<
2350  *         raise DriverError(str(exc))
2351  *     finally:
2352  */
2353       __Pyx_ErrFetch(&__pyx_t_3, &__pyx_t_1, &__pyx_t_7);
2354       __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_CPLE_BaseError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 72, __pyx_L19_except_error)
2355       __Pyx_GOTREF(__pyx_t_10);
2356       __pyx_t_13 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_3, __pyx_t_10);
2357       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2358       __Pyx_ErrRestore(__pyx_t_3, __pyx_t_1, __pyx_t_7);
2359       __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_t_7 = 0;
2360       if (__pyx_t_13) {
2361         __Pyx_AddTraceback("fiona._shim.gdal_open_vector", __pyx_clineno, __pyx_lineno, __pyx_filename);
2362         if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 72, __pyx_L19_except_error)
2363         __Pyx_GOTREF(__pyx_t_7);
2364         __Pyx_GOTREF(__pyx_t_1);
2365         __Pyx_GOTREF(__pyx_t_3);
2366         __Pyx_INCREF(__pyx_t_1);
2367         __pyx_v_exc = __pyx_t_1;
2368 
2369         /* "fiona/_shim.pyx":73
2370  *         raise DriverError("Failed to open dataset (mode={}): {}".format(mode, path_c.decode("utf-8")))
2371  *     except CPLE_BaseError as exc:
2372  *         raise DriverError(str(exc))             # <<<<<<<<<<<<<<
2373  *     finally:
2374  *         CSLDestroy(drvs)
2375  */
2376         __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_DriverError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 73, __pyx_L19_except_error)
2377         __Pyx_GOTREF(__pyx_t_6);
2378         __pyx_t_21 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_exc); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 73, __pyx_L19_except_error)
2379         __Pyx_GOTREF(__pyx_t_21);
2380         __pyx_t_22 = NULL;
2381         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
2382           __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_6);
2383           if (likely(__pyx_t_22)) {
2384             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
2385             __Pyx_INCREF(__pyx_t_22);
2386             __Pyx_INCREF(function);
2387             __Pyx_DECREF_SET(__pyx_t_6, function);
2388           }
2389         }
2390         __pyx_t_10 = (__pyx_t_22) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_22, __pyx_t_21) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_21);
2391         __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
2392         __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
2393         if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 73, __pyx_L19_except_error)
2394         __Pyx_GOTREF(__pyx_t_10);
2395         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2396         __Pyx_Raise(__pyx_t_10, 0, 0, 0);
2397         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2398         __PYX_ERR(0, 73, __pyx_L19_except_error)
2399       }
2400       goto __pyx_L19_except_error;
2401       __pyx_L19_except_error:;
2402 
2403       /* "fiona/_shim.pyx":65
2404  *     open_opts = CSLAddNameValue(open_opts, "VALIDATE_OPEN_OPTIONS", "NO")
2405  *
2406  *     try:             # <<<<<<<<<<<<<<
2407  *         cogr_ds = exc_wrap_pointer(GDALOpenEx(
2408  *             path_c, flags, <const char *const *>drvs, open_opts, NULL)
2409  */
2410       __Pyx_XGIVEREF(__pyx_t_16);
2411       __Pyx_XGIVEREF(__pyx_t_17);
2412       __Pyx_XGIVEREF(__pyx_t_18);
2413       __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
2414       goto __pyx_L15_error;
2415       __pyx_L21_try_return:;
2416       __Pyx_XGIVEREF(__pyx_t_16);
2417       __Pyx_XGIVEREF(__pyx_t_17);
2418       __Pyx_XGIVEREF(__pyx_t_18);
2419       __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
2420       goto __pyx_L14_return;
2421     }
2422   }
2423 
2424   /* "fiona/_shim.pyx":75
2425  *         raise DriverError(str(exc))
2426  *     finally:
2427  *         CSLDestroy(drvs)             # <<<<<<<<<<<<<<
2428  *         CSLDestroy(open_opts)
2429  *
2430  */
2431   /*finally:*/ {
2432     __pyx_L15_error:;
2433     /*exception exit:*/{
2434       __Pyx_PyThreadState_declare
2435       __Pyx_PyThreadState_assign
2436       __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0;
2437       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
2438       __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
2439       __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
2440       __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
2441       __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
2442       __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
2443       __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
2444       __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
2445       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2446       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
2447       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2448       if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_29, &__pyx_t_30, &__pyx_t_31);
2449       if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
2450       __Pyx_XGOTREF(__pyx_t_18);
2451       __Pyx_XGOTREF(__pyx_t_17);
2452       __Pyx_XGOTREF(__pyx_t_16);
2453       __Pyx_XGOTREF(__pyx_t_29);
2454       __Pyx_XGOTREF(__pyx_t_30);
2455       __Pyx_XGOTREF(__pyx_t_31);
2456       __pyx_t_13 = __pyx_lineno; __pyx_t_27 = __pyx_clineno; __pyx_t_28 = __pyx_filename;
2457       {
2458         CSLDestroy(__pyx_v_drvs);
2459 
2460         /* "fiona/_shim.pyx":76
2461  *     finally:
2462  *         CSLDestroy(drvs)
2463  *         CSLDestroy(open_opts)             # <<<<<<<<<<<<<<
2464  *
2465  *
2466  */
2467         CSLDestroy(__pyx_v_open_opts);
2468       }
2469       if (PY_MAJOR_VERSION >= 3) {
2470         __Pyx_XGIVEREF(__pyx_t_29);
2471         __Pyx_XGIVEREF(__pyx_t_30);
2472         __Pyx_XGIVEREF(__pyx_t_31);
2473         __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_30, __pyx_t_31);
2474       }
2475       __Pyx_XGIVEREF(__pyx_t_18);
2476       __Pyx_XGIVEREF(__pyx_t_17);
2477       __Pyx_XGIVEREF(__pyx_t_16);
2478       __Pyx_ErrRestore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
2479       __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0;
2480       __pyx_lineno = __pyx_t_13; __pyx_clineno = __pyx_t_27; __pyx_filename = __pyx_t_28;
2481       goto __pyx_L1_error;
2482     }
2483     __pyx_L14_return: {
2484       __pyx_t_20 = __pyx_r;
2485 
2486       /* "fiona/_shim.pyx":75
2487  *         raise DriverError(str(exc))
2488  *     finally:
2489  *         CSLDestroy(drvs)             # <<<<<<<<<<<<<<
2490  *         CSLDestroy(open_opts)
2491  *
2492  */
2493       CSLDestroy(__pyx_v_drvs);
2494 
2495       /* "fiona/_shim.pyx":76
2496  *     finally:
2497  *         CSLDestroy(drvs)
2498  *         CSLDestroy(open_opts)             # <<<<<<<<<<<<<<
2499  *
2500  *
2501  */
2502       CSLDestroy(__pyx_v_open_opts);
2503       __pyx_r = __pyx_t_20;
2504       goto __pyx_L0;
2505     }
2506   }
2507 
2508   /* "fiona/_shim.pyx":31
2509  *
2510  *
2511  * cdef void* gdal_open_vector(const char* path_c, int mode, drivers, options) except NULL:             # <<<<<<<<<<<<<<
2512  *     cdef void* cogr_ds = NULL
2513  *     cdef char **drvs = NULL
2514  */
2515 
2516   /* function exit code */
2517   __pyx_L1_error:;
2518   __Pyx_XDECREF(__pyx_t_1);
2519   __Pyx_XDECREF(__pyx_t_3);
2520   __Pyx_XDECREF(__pyx_t_6);
2521   __Pyx_XDECREF(__pyx_t_7);
2522   __Pyx_XDECREF(__pyx_t_10);
2523   __Pyx_XDECREF(__pyx_t_21);
2524   __Pyx_XDECREF(__pyx_t_22);
2525   __Pyx_XDECREF(__pyx_t_23);
2526   __Pyx_XDECREF(__pyx_t_24);
2527   __Pyx_XDECREF(__pyx_t_25);
2528   __Pyx_XDECREF(__pyx_t_26);
2529   __Pyx_AddTraceback("fiona._shim.gdal_open_vector", __pyx_clineno, __pyx_lineno, __pyx_filename);
2530   __pyx_r = NULL;
2531   __pyx_L0:;
2532   __Pyx_XDECREF(__pyx_v_flags);
2533   __Pyx_XDECREF(__pyx_v_name);
2534   __Pyx_XDECREF(__pyx_v_name_b);
2535   __Pyx_XDECREF(__pyx_v_name_c);
2536   __Pyx_XDECREF(__pyx_v_k);
2537   __Pyx_XDECREF(__pyx_v_v);
2538   __Pyx_XDECREF(__pyx_v_exc);
2539   __Pyx_RefNannyFinishContext();
2540   return __pyx_r;
2541 }
2542 
2543 /* "fiona/_shim.pyx":79
2544  *
2545  *
2546  * cdef void* gdal_create(void* cogr_driver, const char *path_c, options) except NULL:             # <<<<<<<<<<<<<<
2547  *     cdef char **creation_opts = NULL
2548  *
2549  */
2550 
__pyx_f_5fiona_5_shim_gdal_create(void * __pyx_v_cogr_driver,char const * __pyx_v_path_c,PyObject * __pyx_v_options)2551 static void *__pyx_f_5fiona_5_shim_gdal_create(void *__pyx_v_cogr_driver, char const *__pyx_v_path_c, PyObject *__pyx_v_options) {
2552   char **__pyx_v_creation_opts;
2553   PyObject *__pyx_v_k = NULL;
2554   PyObject *__pyx_v_v = NULL;
2555   PyObject *__pyx_v_exc = NULL;
2556   void *__pyx_r;
2557   __Pyx_RefNannyDeclarations
2558   PyObject *__pyx_t_1 = NULL;
2559   PyObject *__pyx_t_2 = NULL;
2560   PyObject *__pyx_t_3 = NULL;
2561   Py_ssize_t __pyx_t_4;
2562   PyObject *(*__pyx_t_5)(PyObject *);
2563   PyObject *__pyx_t_6 = NULL;
2564   PyObject *__pyx_t_7 = NULL;
2565   PyObject *(*__pyx_t_8)(PyObject *);
2566   int __pyx_t_9;
2567   int __pyx_t_10;
2568   int __pyx_t_11;
2569   char const *__pyx_t_12;
2570   char const *__pyx_t_13;
2571   PyObject *__pyx_t_14 = NULL;
2572   PyObject *__pyx_t_15 = NULL;
2573   PyObject *__pyx_t_16 = NULL;
2574   void *__pyx_t_17;
2575   PyObject *__pyx_t_18 = NULL;
2576   PyObject *__pyx_t_19 = NULL;
2577   PyObject *__pyx_t_20 = NULL;
2578   PyObject *__pyx_t_21 = NULL;
2579   int __pyx_t_22;
2580   char const *__pyx_t_23;
2581   PyObject *__pyx_t_24 = NULL;
2582   PyObject *__pyx_t_25 = NULL;
2583   PyObject *__pyx_t_26 = NULL;
2584   int __pyx_lineno = 0;
2585   const char *__pyx_filename = NULL;
2586   int __pyx_clineno = 0;
2587   __Pyx_RefNannySetupContext("gdal_create", 0);
2588 
2589   /* "fiona/_shim.pyx":80
2590  *
2591  * cdef void* gdal_create(void* cogr_driver, const char *path_c, options) except NULL:
2592  *     cdef char **creation_opts = NULL             # <<<<<<<<<<<<<<
2593  *
2594  *     for k, v in options.items():
2595  */
2596   __pyx_v_creation_opts = NULL;
2597 
2598   /* "fiona/_shim.pyx":82
2599  *     cdef char **creation_opts = NULL
2600  *
2601  *     for k, v in options.items():             # <<<<<<<<<<<<<<
2602  *         k = k.upper().encode('utf-8')
2603  *         if isinstance(v, bool):
2604  */
2605   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s_items); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)
2606   __Pyx_GOTREF(__pyx_t_2);
2607   __pyx_t_3 = NULL;
2608   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
2609     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
2610     if (likely(__pyx_t_3)) {
2611       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
2612       __Pyx_INCREF(__pyx_t_3);
2613       __Pyx_INCREF(function);
2614       __Pyx_DECREF_SET(__pyx_t_2, function);
2615     }
2616   }
2617   __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
2618   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2619   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
2620   __Pyx_GOTREF(__pyx_t_1);
2621   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2622   if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
2623     __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
2624     __pyx_t_5 = NULL;
2625   } else {
2626     __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)
2627     __Pyx_GOTREF(__pyx_t_2);
2628     __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L1_error)
2629   }
2630   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2631   for (;;) {
2632     if (likely(!__pyx_t_5)) {
2633       if (likely(PyList_CheckExact(__pyx_t_2))) {
2634         if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
2635         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2636         __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 82, __pyx_L1_error)
2637         #else
2638         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
2639         __Pyx_GOTREF(__pyx_t_1);
2640         #endif
2641       } else {
2642         if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
2643         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2644         __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 82, __pyx_L1_error)
2645         #else
2646         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
2647         __Pyx_GOTREF(__pyx_t_1);
2648         #endif
2649       }
2650     } else {
2651       __pyx_t_1 = __pyx_t_5(__pyx_t_2);
2652       if (unlikely(!__pyx_t_1)) {
2653         PyObject* exc_type = PyErr_Occurred();
2654         if (exc_type) {
2655           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
2656           else __PYX_ERR(0, 82, __pyx_L1_error)
2657         }
2658         break;
2659       }
2660       __Pyx_GOTREF(__pyx_t_1);
2661     }
2662     if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
2663       PyObject* sequence = __pyx_t_1;
2664       Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
2665       if (unlikely(size != 2)) {
2666         if (size > 2) __Pyx_RaiseTooManyValuesError(2);
2667         else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
2668         __PYX_ERR(0, 82, __pyx_L1_error)
2669       }
2670       #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2671       if (likely(PyTuple_CheckExact(sequence))) {
2672         __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
2673         __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
2674       } else {
2675         __pyx_t_3 = PyList_GET_ITEM(sequence, 0);
2676         __pyx_t_6 = PyList_GET_ITEM(sequence, 1);
2677       }
2678       __Pyx_INCREF(__pyx_t_3);
2679       __Pyx_INCREF(__pyx_t_6);
2680       #else
2681       __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L1_error)
2682       __Pyx_GOTREF(__pyx_t_3);
2683       __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 82, __pyx_L1_error)
2684       __Pyx_GOTREF(__pyx_t_6);
2685       #endif
2686       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2687     } else {
2688       Py_ssize_t index = -1;
2689       __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 82, __pyx_L1_error)
2690       __Pyx_GOTREF(__pyx_t_7);
2691       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2692       __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
2693       index = 0; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
2694       __Pyx_GOTREF(__pyx_t_3);
2695       index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
2696       __Pyx_GOTREF(__pyx_t_6);
2697       if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 82, __pyx_L1_error)
2698       __pyx_t_8 = NULL;
2699       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2700       goto __pyx_L6_unpacking_done;
2701       __pyx_L5_unpacking_failed:;
2702       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2703       __pyx_t_8 = NULL;
2704       if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
2705       __PYX_ERR(0, 82, __pyx_L1_error)
2706       __pyx_L6_unpacking_done:;
2707     }
2708     __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_3);
2709     __pyx_t_3 = 0;
2710     __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_6);
2711     __pyx_t_6 = 0;
2712 
2713     /* "fiona/_shim.pyx":83
2714  *
2715  *     for k, v in options.items():
2716  *         k = k.upper().encode('utf-8')             # <<<<<<<<<<<<<<
2717  *         if isinstance(v, bool):
2718  *             v = ('ON' if v else 'OFF').encode('utf-8')
2719  */
2720     __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_k, __pyx_n_s_upper); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error)
2721     __Pyx_GOTREF(__pyx_t_3);
2722     __pyx_t_7 = NULL;
2723     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
2724       __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
2725       if (likely(__pyx_t_7)) {
2726         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2727         __Pyx_INCREF(__pyx_t_7);
2728         __Pyx_INCREF(function);
2729         __Pyx_DECREF_SET(__pyx_t_3, function);
2730       }
2731     }
2732     __pyx_t_6 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
2733     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2734     if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 83, __pyx_L1_error)
2735     __Pyx_GOTREF(__pyx_t_6);
2736     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2737     __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error)
2738     __Pyx_GOTREF(__pyx_t_3);
2739     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2740     __pyx_t_6 = NULL;
2741     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
2742       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
2743       if (likely(__pyx_t_6)) {
2744         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2745         __Pyx_INCREF(__pyx_t_6);
2746         __Pyx_INCREF(function);
2747         __Pyx_DECREF_SET(__pyx_t_3, function);
2748       }
2749     }
2750     __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_6, __pyx_kp_s_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_s_utf_8);
2751     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
2752     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
2753     __Pyx_GOTREF(__pyx_t_1);
2754     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2755     __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_1);
2756     __pyx_t_1 = 0;
2757 
2758     /* "fiona/_shim.pyx":84
2759  *     for k, v in options.items():
2760  *         k = k.upper().encode('utf-8')
2761  *         if isinstance(v, bool):             # <<<<<<<<<<<<<<
2762  *             v = ('ON' if v else 'OFF').encode('utf-8')
2763  *         else:
2764  */
2765     __pyx_t_1 = ((PyObject*)&PyBool_Type);
2766     __Pyx_INCREF(__pyx_t_1);
2767     __pyx_t_9 = PyObject_IsInstance(__pyx_v_v, __pyx_t_1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 84, __pyx_L1_error)
2768     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2769     __pyx_t_10 = (__pyx_t_9 != 0);
2770     if (__pyx_t_10) {
2771 
2772       /* "fiona/_shim.pyx":85
2773  *         k = k.upper().encode('utf-8')
2774  *         if isinstance(v, bool):
2775  *             v = ('ON' if v else 'OFF').encode('utf-8')             # <<<<<<<<<<<<<<
2776  *         else:
2777  *             v = str(v).encode('utf-8')
2778  */
2779       __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_v); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 85, __pyx_L1_error)
2780       if (__pyx_t_10) {
2781         __Pyx_INCREF(__pyx_n_s_ON);
2782         __pyx_t_3 = __pyx_n_s_ON;
2783       } else {
2784         __Pyx_INCREF(__pyx_n_s_OFF);
2785         __pyx_t_3 = __pyx_n_s_OFF;
2786       }
2787       __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_encode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 85, __pyx_L1_error)
2788       __Pyx_GOTREF(__pyx_t_6);
2789       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2790       __pyx_t_3 = NULL;
2791       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
2792         __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
2793         if (likely(__pyx_t_3)) {
2794           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
2795           __Pyx_INCREF(__pyx_t_3);
2796           __Pyx_INCREF(function);
2797           __Pyx_DECREF_SET(__pyx_t_6, function);
2798         }
2799       }
2800       __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_3, __pyx_kp_s_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_kp_s_utf_8);
2801       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2802       if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error)
2803       __Pyx_GOTREF(__pyx_t_1);
2804       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2805       __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_1);
2806       __pyx_t_1 = 0;
2807 
2808       /* "fiona/_shim.pyx":84
2809  *     for k, v in options.items():
2810  *         k = k.upper().encode('utf-8')
2811  *         if isinstance(v, bool):             # <<<<<<<<<<<<<<
2812  *             v = ('ON' if v else 'OFF').encode('utf-8')
2813  *         else:
2814  */
2815       goto __pyx_L7;
2816     }
2817 
2818     /* "fiona/_shim.pyx":87
2819  *             v = ('ON' if v else 'OFF').encode('utf-8')
2820  *         else:
2821  *             v = str(v).encode('utf-8')             # <<<<<<<<<<<<<<
2822  *         log.debug("Set option %r: %r", k, v)
2823  *         creation_opts = CSLAddNameValue(creation_opts, <const char *>k, <const char *>v)
2824  */
2825     /*else*/ {
2826       __pyx_t_6 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_v); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 87, __pyx_L1_error)
2827       __Pyx_GOTREF(__pyx_t_6);
2828       __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error)
2829       __Pyx_GOTREF(__pyx_t_3);
2830       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2831       __pyx_t_6 = NULL;
2832       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
2833         __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
2834         if (likely(__pyx_t_6)) {
2835           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2836           __Pyx_INCREF(__pyx_t_6);
2837           __Pyx_INCREF(function);
2838           __Pyx_DECREF_SET(__pyx_t_3, function);
2839         }
2840       }
2841       __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_6, __pyx_kp_s_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_s_utf_8);
2842       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
2843       if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error)
2844       __Pyx_GOTREF(__pyx_t_1);
2845       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2846       __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_1);
2847       __pyx_t_1 = 0;
2848     }
2849     __pyx_L7:;
2850 
2851     /* "fiona/_shim.pyx":88
2852  *         else:
2853  *             v = str(v).encode('utf-8')
2854  *         log.debug("Set option %r: %r", k, v)             # <<<<<<<<<<<<<<
2855  *         creation_opts = CSLAddNameValue(creation_opts, <const char *>k, <const char *>v)
2856  *
2857  */
2858     __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error)
2859     __Pyx_GOTREF(__pyx_t_3);
2860     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_debug); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 88, __pyx_L1_error)
2861     __Pyx_GOTREF(__pyx_t_6);
2862     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2863     __pyx_t_3 = NULL;
2864     __pyx_t_11 = 0;
2865     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
2866       __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
2867       if (likely(__pyx_t_3)) {
2868         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
2869         __Pyx_INCREF(__pyx_t_3);
2870         __Pyx_INCREF(function);
2871         __Pyx_DECREF_SET(__pyx_t_6, function);
2872         __pyx_t_11 = 1;
2873       }
2874     }
2875     #if CYTHON_FAST_PYCALL
2876     if (PyFunction_Check(__pyx_t_6)) {
2877       PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_kp_s_Set_option_r_r, __pyx_v_k, __pyx_v_v};
2878       __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
2879       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2880       __Pyx_GOTREF(__pyx_t_1);
2881     } else
2882     #endif
2883     #if CYTHON_FAST_PYCCALL
2884     if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
2885       PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_kp_s_Set_option_r_r, __pyx_v_k, __pyx_v_v};
2886       __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
2887       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2888       __Pyx_GOTREF(__pyx_t_1);
2889     } else
2890     #endif
2891     {
2892       __pyx_t_7 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 88, __pyx_L1_error)
2893       __Pyx_GOTREF(__pyx_t_7);
2894       if (__pyx_t_3) {
2895         __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
2896       }
2897       __Pyx_INCREF(__pyx_kp_s_Set_option_r_r);
2898       __Pyx_GIVEREF(__pyx_kp_s_Set_option_r_r);
2899       PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_11, __pyx_kp_s_Set_option_r_r);
2900       __Pyx_INCREF(__pyx_v_k);
2901       __Pyx_GIVEREF(__pyx_v_k);
2902       PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_11, __pyx_v_k);
2903       __Pyx_INCREF(__pyx_v_v);
2904       __Pyx_GIVEREF(__pyx_v_v);
2905       PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_11, __pyx_v_v);
2906       __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
2907       __Pyx_GOTREF(__pyx_t_1);
2908       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2909     }
2910     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2911     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2912 
2913     /* "fiona/_shim.pyx":89
2914  *             v = str(v).encode('utf-8')
2915  *         log.debug("Set option %r: %r", k, v)
2916  *         creation_opts = CSLAddNameValue(creation_opts, <const char *>k, <const char *>v)             # <<<<<<<<<<<<<<
2917  *
2918  *     try:
2919  */
2920     __pyx_t_12 = __Pyx_PyObject_AsString(__pyx_v_k); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) __PYX_ERR(0, 89, __pyx_L1_error)
2921     __pyx_t_13 = __Pyx_PyObject_AsString(__pyx_v_v); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) __PYX_ERR(0, 89, __pyx_L1_error)
2922     __pyx_v_creation_opts = CSLAddNameValue(__pyx_v_creation_opts, ((char const *)__pyx_t_12), ((char const *)__pyx_t_13));
2923 
2924     /* "fiona/_shim.pyx":82
2925  *     cdef char **creation_opts = NULL
2926  *
2927  *     for k, v in options.items():             # <<<<<<<<<<<<<<
2928  *         k = k.upper().encode('utf-8')
2929  *         if isinstance(v, bool):
2930  */
2931   }
2932   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2933 
2934   /* "fiona/_shim.pyx":91
2935  *         creation_opts = CSLAddNameValue(creation_opts, <const char *>k, <const char *>v)
2936  *
2937  *     try:             # <<<<<<<<<<<<<<
2938  *         return exc_wrap_pointer(GDALCreate(cogr_driver, path_c, 0, 0, 0, GDT_Unknown, creation_opts))
2939  *     except FionaNullPointerError:
2940  */
2941   /*try:*/ {
2942     {
2943       __Pyx_PyThreadState_declare
2944       __Pyx_PyThreadState_assign
2945       __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
2946       __Pyx_XGOTREF(__pyx_t_14);
2947       __Pyx_XGOTREF(__pyx_t_15);
2948       __Pyx_XGOTREF(__pyx_t_16);
2949       /*try:*/ {
2950 
2951         /* "fiona/_shim.pyx":92
2952  *
2953  *     try:
2954  *         return exc_wrap_pointer(GDALCreate(cogr_driver, path_c, 0, 0, 0, GDT_Unknown, creation_opts))             # <<<<<<<<<<<<<<
2955  *     except FionaNullPointerError:
2956  *         raise DriverError("Failed to create dataset: {}".format(path_c.decode("utf-8")))
2957  */
2958         __pyx_t_17 = __pyx_f_5fiona_4_err_exc_wrap_pointer(GDALCreate(__pyx_v_cogr_driver, __pyx_v_path_c, 0, 0, 0, GDT_Unknown, __pyx_v_creation_opts)); if (unlikely(__pyx_t_17 == ((void *)NULL))) __PYX_ERR(0, 92, __pyx_L11_error)
2959         __pyx_r = __pyx_t_17;
2960         goto __pyx_L15_try_return;
2961 
2962         /* "fiona/_shim.pyx":91
2963  *         creation_opts = CSLAddNameValue(creation_opts, <const char *>k, <const char *>v)
2964  *
2965  *     try:             # <<<<<<<<<<<<<<
2966  *         return exc_wrap_pointer(GDALCreate(cogr_driver, path_c, 0, 0, 0, GDT_Unknown, creation_opts))
2967  *     except FionaNullPointerError:
2968  */
2969       }
2970       __pyx_L11_error:;
2971       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
2972       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2973       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2974       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
2975       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2976 
2977       /* "fiona/_shim.pyx":93
2978  *     try:
2979  *         return exc_wrap_pointer(GDALCreate(cogr_driver, path_c, 0, 0, 0, GDT_Unknown, creation_opts))
2980  *     except FionaNullPointerError:             # <<<<<<<<<<<<<<
2981  *         raise DriverError("Failed to create dataset: {}".format(path_c.decode("utf-8")))
2982  *     except CPLE_BaseError as exc:
2983  */
2984       __Pyx_ErrFetch(&__pyx_t_2, &__pyx_t_1, &__pyx_t_6);
2985       __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_FionaNullPointerError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 93, __pyx_L13_except_error)
2986       __Pyx_GOTREF(__pyx_t_7);
2987       __pyx_t_11 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_2, __pyx_t_7);
2988       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2989       __Pyx_ErrRestore(__pyx_t_2, __pyx_t_1, __pyx_t_6);
2990       __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_6 = 0;
2991       if (__pyx_t_11) {
2992         __Pyx_AddTraceback("fiona._shim.gdal_create", __pyx_clineno, __pyx_lineno, __pyx_filename);
2993         if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 93, __pyx_L13_except_error)
2994         __Pyx_GOTREF(__pyx_t_6);
2995         __Pyx_GOTREF(__pyx_t_1);
2996         __Pyx_GOTREF(__pyx_t_2);
2997 
2998         /* "fiona/_shim.pyx":94
2999  *         return exc_wrap_pointer(GDALCreate(cogr_driver, path_c, 0, 0, 0, GDT_Unknown, creation_opts))
3000  *     except FionaNullPointerError:
3001  *         raise DriverError("Failed to create dataset: {}".format(path_c.decode("utf-8")))             # <<<<<<<<<<<<<<
3002  *     except CPLE_BaseError as exc:
3003  *         raise DriverError(str(exc))
3004  */
3005         __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_DriverError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 94, __pyx_L13_except_error)
3006         __Pyx_GOTREF(__pyx_t_3);
3007         __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Failed_to_create_dataset, __pyx_n_s_format); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 94, __pyx_L13_except_error)
3008         __Pyx_GOTREF(__pyx_t_19);
3009         __pyx_t_20 = __Pyx_decode_c_string(__pyx_v_path_c, 0, strlen(__pyx_v_path_c), NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 94, __pyx_L13_except_error)
3010         __Pyx_GOTREF(__pyx_t_20);
3011         __pyx_t_21 = NULL;
3012         if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_19))) {
3013           __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_19);
3014           if (likely(__pyx_t_21)) {
3015             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19);
3016             __Pyx_INCREF(__pyx_t_21);
3017             __Pyx_INCREF(function);
3018             __Pyx_DECREF_SET(__pyx_t_19, function);
3019           }
3020         }
3021         __pyx_t_18 = (__pyx_t_21) ? __Pyx_PyObject_Call2Args(__pyx_t_19, __pyx_t_21, __pyx_t_20) : __Pyx_PyObject_CallOneArg(__pyx_t_19, __pyx_t_20);
3022         __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
3023         __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
3024         if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 94, __pyx_L13_except_error)
3025         __Pyx_GOTREF(__pyx_t_18);
3026         __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
3027         __pyx_t_19 = NULL;
3028         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
3029           __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_3);
3030           if (likely(__pyx_t_19)) {
3031             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3032             __Pyx_INCREF(__pyx_t_19);
3033             __Pyx_INCREF(function);
3034             __Pyx_DECREF_SET(__pyx_t_3, function);
3035           }
3036         }
3037         __pyx_t_7 = (__pyx_t_19) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_19, __pyx_t_18) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_18);
3038         __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
3039         __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
3040         if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 94, __pyx_L13_except_error)
3041         __Pyx_GOTREF(__pyx_t_7);
3042         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3043         __Pyx_Raise(__pyx_t_7, 0, 0, 0);
3044         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3045         __PYX_ERR(0, 94, __pyx_L13_except_error)
3046       }
3047 
3048       /* "fiona/_shim.pyx":95
3049  *     except FionaNullPointerError:
3050  *         raise DriverError("Failed to create dataset: {}".format(path_c.decode("utf-8")))
3051  *     except CPLE_BaseError as exc:             # <<<<<<<<<<<<<<
3052  *         raise DriverError(str(exc))
3053  *     finally:
3054  */
3055       __Pyx_ErrFetch(&__pyx_t_2, &__pyx_t_1, &__pyx_t_6);
3056       __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_CPLE_BaseError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 95, __pyx_L13_except_error)
3057       __Pyx_GOTREF(__pyx_t_7);
3058       __pyx_t_11 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_2, __pyx_t_7);
3059       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3060       __Pyx_ErrRestore(__pyx_t_2, __pyx_t_1, __pyx_t_6);
3061       __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_6 = 0;
3062       if (__pyx_t_11) {
3063         __Pyx_AddTraceback("fiona._shim.gdal_create", __pyx_clineno, __pyx_lineno, __pyx_filename);
3064         if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 95, __pyx_L13_except_error)
3065         __Pyx_GOTREF(__pyx_t_6);
3066         __Pyx_GOTREF(__pyx_t_1);
3067         __Pyx_GOTREF(__pyx_t_2);
3068         __Pyx_INCREF(__pyx_t_1);
3069         __pyx_v_exc = __pyx_t_1;
3070 
3071         /* "fiona/_shim.pyx":96
3072  *         raise DriverError("Failed to create dataset: {}".format(path_c.decode("utf-8")))
3073  *     except CPLE_BaseError as exc:
3074  *         raise DriverError(str(exc))             # <<<<<<<<<<<<<<
3075  *     finally:
3076  *         CSLDestroy(creation_opts)
3077  */
3078         __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_DriverError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 96, __pyx_L13_except_error)
3079         __Pyx_GOTREF(__pyx_t_3);
3080         __pyx_t_18 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_exc); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 96, __pyx_L13_except_error)
3081         __Pyx_GOTREF(__pyx_t_18);
3082         __pyx_t_19 = NULL;
3083         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
3084           __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_3);
3085           if (likely(__pyx_t_19)) {
3086             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3087             __Pyx_INCREF(__pyx_t_19);
3088             __Pyx_INCREF(function);
3089             __Pyx_DECREF_SET(__pyx_t_3, function);
3090           }
3091         }
3092         __pyx_t_7 = (__pyx_t_19) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_19, __pyx_t_18) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_18);
3093         __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
3094         __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
3095         if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 96, __pyx_L13_except_error)
3096         __Pyx_GOTREF(__pyx_t_7);
3097         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3098         __Pyx_Raise(__pyx_t_7, 0, 0, 0);
3099         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3100         __PYX_ERR(0, 96, __pyx_L13_except_error)
3101       }
3102       goto __pyx_L13_except_error;
3103       __pyx_L13_except_error:;
3104 
3105       /* "fiona/_shim.pyx":91
3106  *         creation_opts = CSLAddNameValue(creation_opts, <const char *>k, <const char *>v)
3107  *
3108  *     try:             # <<<<<<<<<<<<<<
3109  *         return exc_wrap_pointer(GDALCreate(cogr_driver, path_c, 0, 0, 0, GDT_Unknown, creation_opts))
3110  *     except FionaNullPointerError:
3111  */
3112       __Pyx_XGIVEREF(__pyx_t_14);
3113       __Pyx_XGIVEREF(__pyx_t_15);
3114       __Pyx_XGIVEREF(__pyx_t_16);
3115       __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
3116       goto __pyx_L9_error;
3117       __pyx_L15_try_return:;
3118       __Pyx_XGIVEREF(__pyx_t_14);
3119       __Pyx_XGIVEREF(__pyx_t_15);
3120       __Pyx_XGIVEREF(__pyx_t_16);
3121       __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
3122       goto __pyx_L8_return;
3123     }
3124   }
3125 
3126   /* "fiona/_shim.pyx":98
3127  *         raise DriverError(str(exc))
3128  *     finally:
3129  *         CSLDestroy(creation_opts)             # <<<<<<<<<<<<<<
3130  *
3131  *
3132  */
3133   /*finally:*/ {
3134     __pyx_L9_error:;
3135     /*exception exit:*/{
3136       __Pyx_PyThreadState_declare
3137       __Pyx_PyThreadState_assign
3138       __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
3139       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3140       __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
3141       __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
3142       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3143       __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
3144       __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
3145       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
3146       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3147       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
3148       if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26);
3149       if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_15, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_15, &__pyx_t_14);
3150       __Pyx_XGOTREF(__pyx_t_16);
3151       __Pyx_XGOTREF(__pyx_t_15);
3152       __Pyx_XGOTREF(__pyx_t_14);
3153       __Pyx_XGOTREF(__pyx_t_24);
3154       __Pyx_XGOTREF(__pyx_t_25);
3155       __Pyx_XGOTREF(__pyx_t_26);
3156       __pyx_t_11 = __pyx_lineno; __pyx_t_22 = __pyx_clineno; __pyx_t_23 = __pyx_filename;
3157       {
3158         CSLDestroy(__pyx_v_creation_opts);
3159       }
3160       if (PY_MAJOR_VERSION >= 3) {
3161         __Pyx_XGIVEREF(__pyx_t_24);
3162         __Pyx_XGIVEREF(__pyx_t_25);
3163         __Pyx_XGIVEREF(__pyx_t_26);
3164         __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26);
3165       }
3166       __Pyx_XGIVEREF(__pyx_t_16);
3167       __Pyx_XGIVEREF(__pyx_t_15);
3168       __Pyx_XGIVEREF(__pyx_t_14);
3169       __Pyx_ErrRestore(__pyx_t_16, __pyx_t_15, __pyx_t_14);
3170       __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
3171       __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_22; __pyx_filename = __pyx_t_23;
3172       goto __pyx_L1_error;
3173     }
3174     __pyx_L8_return: {
3175       __pyx_t_17 = __pyx_r;
3176       CSLDestroy(__pyx_v_creation_opts);
3177       __pyx_r = __pyx_t_17;
3178       goto __pyx_L0;
3179     }
3180   }
3181 
3182   /* "fiona/_shim.pyx":79
3183  *
3184  *
3185  * cdef void* gdal_create(void* cogr_driver, const char *path_c, options) except NULL:             # <<<<<<<<<<<<<<
3186  *     cdef char **creation_opts = NULL
3187  *
3188  */
3189 
3190   /* function exit code */
3191   __pyx_L1_error:;
3192   __Pyx_XDECREF(__pyx_t_1);
3193   __Pyx_XDECREF(__pyx_t_2);
3194   __Pyx_XDECREF(__pyx_t_3);
3195   __Pyx_XDECREF(__pyx_t_6);
3196   __Pyx_XDECREF(__pyx_t_7);
3197   __Pyx_XDECREF(__pyx_t_18);
3198   __Pyx_XDECREF(__pyx_t_19);
3199   __Pyx_XDECREF(__pyx_t_20);
3200   __Pyx_XDECREF(__pyx_t_21);
3201   __Pyx_AddTraceback("fiona._shim.gdal_create", __pyx_clineno, __pyx_lineno, __pyx_filename);
3202   __pyx_r = NULL;
3203   __pyx_L0:;
3204   __Pyx_XDECREF(__pyx_v_k);
3205   __Pyx_XDECREF(__pyx_v_v);
3206   __Pyx_XDECREF(__pyx_v_exc);
3207   __Pyx_RefNannyFinishContext();
3208   return __pyx_r;
3209 }
3210 
3211 /* "fiona/_shim.pyx":101
3212  *
3213  *
3214  * cdef bint check_capability_transaction(void *cogr_ds):             # <<<<<<<<<<<<<<
3215  *     return GDALDatasetTestCapability(cogr_ds, ODsCTransactions)
3216  *
3217  */
3218 
__pyx_f_5fiona_5_shim_check_capability_transaction(void * __pyx_v_cogr_ds)3219 static int __pyx_f_5fiona_5_shim_check_capability_transaction(void *__pyx_v_cogr_ds) {
3220   int __pyx_r;
3221   __Pyx_RefNannyDeclarations
3222   __Pyx_RefNannySetupContext("check_capability_transaction", 0);
3223 
3224   /* "fiona/_shim.pyx":102
3225  *
3226  * cdef bint check_capability_transaction(void *cogr_ds):
3227  *     return GDALDatasetTestCapability(cogr_ds, ODsCTransactions)             # <<<<<<<<<<<<<<
3228  *
3229  *
3230  */
3231   __pyx_r = GDALDatasetTestCapability(__pyx_v_cogr_ds, ODsCTransactions);
3232   goto __pyx_L0;
3233 
3234   /* "fiona/_shim.pyx":101
3235  *
3236  *
3237  * cdef bint check_capability_transaction(void *cogr_ds):             # <<<<<<<<<<<<<<
3238  *     return GDALDatasetTestCapability(cogr_ds, ODsCTransactions)
3239  *
3240  */
3241 
3242   /* function exit code */
3243   __pyx_L0:;
3244   __Pyx_RefNannyFinishContext();
3245   return __pyx_r;
3246 }
3247 
3248 /* "fiona/_shim.pyx":105
3249  *
3250  *
3251  * cdef OGRErr gdal_start_transaction(void* cogr_ds, int force):             # <<<<<<<<<<<<<<
3252  *     return GDALDatasetStartTransaction(cogr_ds, force)
3253  *
3254  */
3255 
__pyx_f_5fiona_5_shim_gdal_start_transaction(void * __pyx_v_cogr_ds,int __pyx_v_force)3256 static OGRErr __pyx_f_5fiona_5_shim_gdal_start_transaction(void *__pyx_v_cogr_ds, int __pyx_v_force) {
3257   OGRErr __pyx_r;
3258   __Pyx_RefNannyDeclarations
3259   __Pyx_RefNannySetupContext("gdal_start_transaction", 0);
3260 
3261   /* "fiona/_shim.pyx":106
3262  *
3263  * cdef OGRErr gdal_start_transaction(void* cogr_ds, int force):
3264  *     return GDALDatasetStartTransaction(cogr_ds, force)             # <<<<<<<<<<<<<<
3265  *
3266  *
3267  */
3268   __pyx_r = GDALDatasetStartTransaction(__pyx_v_cogr_ds, __pyx_v_force);
3269   goto __pyx_L0;
3270 
3271   /* "fiona/_shim.pyx":105
3272  *
3273  *
3274  * cdef OGRErr gdal_start_transaction(void* cogr_ds, int force):             # <<<<<<<<<<<<<<
3275  *     return GDALDatasetStartTransaction(cogr_ds, force)
3276  *
3277  */
3278 
3279   /* function exit code */
3280   __pyx_L0:;
3281   __Pyx_RefNannyFinishContext();
3282   return __pyx_r;
3283 }
3284 
3285 /* "fiona/_shim.pyx":109
3286  *
3287  *
3288  * cdef OGRErr gdal_commit_transaction(void* cogr_ds):             # <<<<<<<<<<<<<<
3289  *     return GDALDatasetCommitTransaction(cogr_ds)
3290  *
3291  */
3292 
__pyx_f_5fiona_5_shim_gdal_commit_transaction(void * __pyx_v_cogr_ds)3293 static OGRErr __pyx_f_5fiona_5_shim_gdal_commit_transaction(void *__pyx_v_cogr_ds) {
3294   OGRErr __pyx_r;
3295   __Pyx_RefNannyDeclarations
3296   __Pyx_RefNannySetupContext("gdal_commit_transaction", 0);
3297 
3298   /* "fiona/_shim.pyx":110
3299  *
3300  * cdef OGRErr gdal_commit_transaction(void* cogr_ds):
3301  *     return GDALDatasetCommitTransaction(cogr_ds)             # <<<<<<<<<<<<<<
3302  *
3303  *
3304  */
3305   __pyx_r = GDALDatasetCommitTransaction(__pyx_v_cogr_ds);
3306   goto __pyx_L0;
3307 
3308   /* "fiona/_shim.pyx":109
3309  *
3310  *
3311  * cdef OGRErr gdal_commit_transaction(void* cogr_ds):             # <<<<<<<<<<<<<<
3312  *     return GDALDatasetCommitTransaction(cogr_ds)
3313  *
3314  */
3315 
3316   /* function exit code */
3317   __pyx_L0:;
3318   __Pyx_RefNannyFinishContext();
3319   return __pyx_r;
3320 }
3321 
3322 /* "fiona/_shim.pyx":113
3323  *
3324  *
3325  * cdef OGRErr gdal_rollback_transaction(void* cogr_ds):             # <<<<<<<<<<<<<<
3326  *     return GDALDatasetRollbackTransaction(cogr_ds)
3327  *
3328  */
3329 
__pyx_f_5fiona_5_shim_gdal_rollback_transaction(void * __pyx_v_cogr_ds)3330 static OGRErr __pyx_f_5fiona_5_shim_gdal_rollback_transaction(void *__pyx_v_cogr_ds) {
3331   OGRErr __pyx_r;
3332   __Pyx_RefNannyDeclarations
3333   __Pyx_RefNannySetupContext("gdal_rollback_transaction", 0);
3334 
3335   /* "fiona/_shim.pyx":114
3336  *
3337  * cdef OGRErr gdal_rollback_transaction(void* cogr_ds):
3338  *     return GDALDatasetRollbackTransaction(cogr_ds)             # <<<<<<<<<<<<<<
3339  *
3340  *
3341  */
3342   __pyx_r = GDALDatasetRollbackTransaction(__pyx_v_cogr_ds);
3343   goto __pyx_L0;
3344 
3345   /* "fiona/_shim.pyx":113
3346  *
3347  *
3348  * cdef OGRErr gdal_rollback_transaction(void* cogr_ds):             # <<<<<<<<<<<<<<
3349  *     return GDALDatasetRollbackTransaction(cogr_ds)
3350  *
3351  */
3352 
3353   /* function exit code */
3354   __pyx_L0:;
3355   __Pyx_RefNannyFinishContext();
3356   return __pyx_r;
3357 }
3358 
3359 /* "fiona/_shim.pyx":117
3360  *
3361  *
3362  * cdef OGRFieldSubType get_field_subtype(void *fielddefn):             # <<<<<<<<<<<<<<
3363  *     return OGR_Fld_GetSubType(fielddefn)
3364  *
3365  */
3366 
__pyx_f_5fiona_5_shim_get_field_subtype(void * __pyx_v_fielddefn)3367 static OGRFieldSubType __pyx_f_5fiona_5_shim_get_field_subtype(void *__pyx_v_fielddefn) {
3368   OGRFieldSubType __pyx_r;
3369   __Pyx_RefNannyDeclarations
3370   __Pyx_RefNannySetupContext("get_field_subtype", 0);
3371 
3372   /* "fiona/_shim.pyx":118
3373  *
3374  * cdef OGRFieldSubType get_field_subtype(void *fielddefn):
3375  *     return OGR_Fld_GetSubType(fielddefn)             # <<<<<<<<<<<<<<
3376  *
3377  *
3378  */
3379   __pyx_r = OGR_Fld_GetSubType(__pyx_v_fielddefn);
3380   goto __pyx_L0;
3381 
3382   /* "fiona/_shim.pyx":117
3383  *
3384  *
3385  * cdef OGRFieldSubType get_field_subtype(void *fielddefn):             # <<<<<<<<<<<<<<
3386  *     return OGR_Fld_GetSubType(fielddefn)
3387  *
3388  */
3389 
3390   /* function exit code */
3391   __pyx_L0:;
3392   __Pyx_RefNannyFinishContext();
3393   return __pyx_r;
3394 }
3395 
3396 /* "fiona/_shim.pyx":121
3397  *
3398  *
3399  * cdef void set_field_subtype(void *fielddefn, OGRFieldSubType subtype):             # <<<<<<<<<<<<<<
3400  *     OGR_Fld_SetSubType(fielddefn, subtype)
3401  *
3402  */
3403 
__pyx_f_5fiona_5_shim_set_field_subtype(void * __pyx_v_fielddefn,OGRFieldSubType __pyx_v_subtype)3404 static void __pyx_f_5fiona_5_shim_set_field_subtype(void *__pyx_v_fielddefn, OGRFieldSubType __pyx_v_subtype) {
3405   __Pyx_RefNannyDeclarations
3406   __Pyx_RefNannySetupContext("set_field_subtype", 0);
3407 
3408   /* "fiona/_shim.pyx":122
3409  *
3410  * cdef void set_field_subtype(void *fielddefn, OGRFieldSubType subtype):
3411  *     OGR_Fld_SetSubType(fielddefn, subtype)             # <<<<<<<<<<<<<<
3412  *
3413  *
3414  */
3415   OGR_Fld_SetSubType(__pyx_v_fielddefn, __pyx_v_subtype);
3416 
3417   /* "fiona/_shim.pyx":121
3418  *
3419  *
3420  * cdef void set_field_subtype(void *fielddefn, OGRFieldSubType subtype):             # <<<<<<<<<<<<<<
3421  *     OGR_Fld_SetSubType(fielddefn, subtype)
3422  *
3423  */
3424 
3425   /* function exit code */
3426   __Pyx_RefNannyFinishContext();
3427 }
3428 
3429 /* "fiona/_shim.pyx":125
3430  *
3431  *
3432  * cdef bint check_capability_create_layer(void *cogr_ds):             # <<<<<<<<<<<<<<
3433  *     return GDALDatasetTestCapability(cogr_ds, ODsCCreateLayer)
3434  *
3435  */
3436 
__pyx_f_5fiona_5_shim_check_capability_create_layer(void * __pyx_v_cogr_ds)3437 static int __pyx_f_5fiona_5_shim_check_capability_create_layer(void *__pyx_v_cogr_ds) {
3438   int __pyx_r;
3439   __Pyx_RefNannyDeclarations
3440   __Pyx_RefNannySetupContext("check_capability_create_layer", 0);
3441 
3442   /* "fiona/_shim.pyx":126
3443  *
3444  * cdef bint check_capability_create_layer(void *cogr_ds):
3445  *     return GDALDatasetTestCapability(cogr_ds, ODsCCreateLayer)             # <<<<<<<<<<<<<<
3446  *
3447  *
3448  */
3449   __pyx_r = GDALDatasetTestCapability(__pyx_v_cogr_ds, ODsCCreateLayer);
3450   goto __pyx_L0;
3451 
3452   /* "fiona/_shim.pyx":125
3453  *
3454  *
3455  * cdef bint check_capability_create_layer(void *cogr_ds):             # <<<<<<<<<<<<<<
3456  *     return GDALDatasetTestCapability(cogr_ds, ODsCCreateLayer)
3457  *
3458  */
3459 
3460   /* function exit code */
3461   __pyx_L0:;
3462   __Pyx_RefNannyFinishContext();
3463   return __pyx_r;
3464 }
3465 
3466 /* "fiona/_shim.pyx":129
3467  *
3468  *
3469  * cdef void *get_linear_geometry(void *geom):             # <<<<<<<<<<<<<<
3470  *     return OGR_G_GetLinearGeometry(geom, 0.0, NULL)
3471  *
3472  */
3473 
__pyx_f_5fiona_5_shim_get_linear_geometry(void * __pyx_v_geom)3474 static void *__pyx_f_5fiona_5_shim_get_linear_geometry(void *__pyx_v_geom) {
3475   void *__pyx_r;
3476   __Pyx_RefNannyDeclarations
3477   __Pyx_RefNannySetupContext("get_linear_geometry", 0);
3478 
3479   /* "fiona/_shim.pyx":130
3480  *
3481  * cdef void *get_linear_geometry(void *geom):
3482  *     return OGR_G_GetLinearGeometry(geom, 0.0, NULL)             # <<<<<<<<<<<<<<
3483  *
3484  * cdef const char* osr_get_name(OGRSpatialReferenceH hSrs):
3485  */
3486   __pyx_r = OGR_G_GetLinearGeometry(__pyx_v_geom, 0.0, NULL);
3487   goto __pyx_L0;
3488 
3489   /* "fiona/_shim.pyx":129
3490  *
3491  *
3492  * cdef void *get_linear_geometry(void *geom):             # <<<<<<<<<<<<<<
3493  *     return OGR_G_GetLinearGeometry(geom, 0.0, NULL)
3494  *
3495  */
3496 
3497   /* function exit code */
3498   __pyx_L0:;
3499   __Pyx_RefNannyFinishContext();
3500   return __pyx_r;
3501 }
3502 
3503 /* "fiona/_shim.pyx":132
3504  *     return OGR_G_GetLinearGeometry(geom, 0.0, NULL)
3505  *
3506  * cdef const char* osr_get_name(OGRSpatialReferenceH hSrs):             # <<<<<<<<<<<<<<
3507  *     return ''
3508  *
3509  */
3510 
__pyx_f_5fiona_5_shim_osr_get_name(CYTHON_UNUSED OGRSpatialReferenceH __pyx_v_hSrs)3511 static char const *__pyx_f_5fiona_5_shim_osr_get_name(CYTHON_UNUSED OGRSpatialReferenceH __pyx_v_hSrs) {
3512   char const *__pyx_r;
3513   __Pyx_RefNannyDeclarations
3514   __Pyx_RefNannySetupContext("osr_get_name", 0);
3515 
3516   /* "fiona/_shim.pyx":133
3517  *
3518  * cdef const char* osr_get_name(OGRSpatialReferenceH hSrs):
3519  *     return ''             # <<<<<<<<<<<<<<
3520  *
3521  * cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs):
3522  */
3523   __pyx_r = ((char const *)"");
3524   goto __pyx_L0;
3525 
3526   /* "fiona/_shim.pyx":132
3527  *     return OGR_G_GetLinearGeometry(geom, 0.0, NULL)
3528  *
3529  * cdef const char* osr_get_name(OGRSpatialReferenceH hSrs):             # <<<<<<<<<<<<<<
3530  *     return ''
3531  *
3532  */
3533 
3534   /* function exit code */
3535   __pyx_L0:;
3536   __Pyx_RefNannyFinishContext();
3537   return __pyx_r;
3538 }
3539 
3540 /* "fiona/_shim.pyx":135
3541  *     return ''
3542  *
3543  * cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs):             # <<<<<<<<<<<<<<
3544  *     OSRFixup(hSrs)
3545  *
3546  */
3547 
__pyx_f_5fiona_5_shim_osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH __pyx_v_hSrs)3548 static void __pyx_f_5fiona_5_shim_osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH __pyx_v_hSrs) {
3549   __Pyx_RefNannyDeclarations
3550   __Pyx_RefNannySetupContext("osr_set_traditional_axis_mapping_strategy", 0);
3551 
3552   /* "fiona/_shim.pyx":136
3553  *
3554  * cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs):
3555  *     OSRFixup(hSrs)             # <<<<<<<<<<<<<<
3556  *
3557  *
3558  */
3559   (void)(OSRFixup(__pyx_v_hSrs));
3560 
3561   /* "fiona/_shim.pyx":135
3562  *     return ''
3563  *
3564  * cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs):             # <<<<<<<<<<<<<<
3565  *     OSRFixup(hSrs)
3566  *
3567  */
3568 
3569   /* function exit code */
3570   __Pyx_RefNannyFinishContext();
3571 }
3572 
3573 /* "fiona/_shim.pyx":139
3574  *
3575  *
3576  * cdef void set_proj_search_path(object path):             # <<<<<<<<<<<<<<
3577  *     os.environ["PROJ_LIB"] = path
3578  *
3579  */
3580 
__pyx_f_5fiona_5_shim_set_proj_search_path(PyObject * __pyx_v_path)3581 static void __pyx_f_5fiona_5_shim_set_proj_search_path(PyObject *__pyx_v_path) {
3582   __Pyx_RefNannyDeclarations
3583   PyObject *__pyx_t_1 = NULL;
3584   PyObject *__pyx_t_2 = NULL;
3585   int __pyx_lineno = 0;
3586   const char *__pyx_filename = NULL;
3587   int __pyx_clineno = 0;
3588   __Pyx_RefNannySetupContext("set_proj_search_path", 0);
3589 
3590   /* "fiona/_shim.pyx":140
3591  *
3592  * cdef void set_proj_search_path(object path):
3593  *     os.environ["PROJ_LIB"] = path             # <<<<<<<<<<<<<<
3594  *
3595  *
3596  */
3597   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
3598   __Pyx_GOTREF(__pyx_t_1);
3599   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_environ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
3600   __Pyx_GOTREF(__pyx_t_2);
3601   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3602   if (unlikely(PyObject_SetItem(__pyx_t_2, __pyx_n_s_PROJ_LIB, __pyx_v_path) < 0)) __PYX_ERR(0, 140, __pyx_L1_error)
3603   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3604 
3605   /* "fiona/_shim.pyx":139
3606  *
3607  *
3608  * cdef void set_proj_search_path(object path):             # <<<<<<<<<<<<<<
3609  *     os.environ["PROJ_LIB"] = path
3610  *
3611  */
3612 
3613   /* function exit code */
3614   goto __pyx_L0;
3615   __pyx_L1_error:;
3616   __Pyx_XDECREF(__pyx_t_1);
3617   __Pyx_XDECREF(__pyx_t_2);
3618   __Pyx_WriteUnraisable("fiona._shim.set_proj_search_path", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
3619   __pyx_L0:;
3620   __Pyx_RefNannyFinishContext();
3621 }
3622 
3623 /* "fiona/_shim.pyx":143
3624  *
3625  *
3626  * cdef void get_proj_version(int* major, int* minor, int* patch):             # <<<<<<<<<<<<<<
3627  *     cdef int val = -1
3628  *     major[0] = val
3629  */
3630 
__pyx_f_5fiona_5_shim_get_proj_version(int * __pyx_v_major,int * __pyx_v_minor,int * __pyx_v_patch)3631 static void __pyx_f_5fiona_5_shim_get_proj_version(int *__pyx_v_major, int *__pyx_v_minor, int *__pyx_v_patch) {
3632   int __pyx_v_val;
3633   __Pyx_RefNannyDeclarations
3634   __Pyx_RefNannySetupContext("get_proj_version", 0);
3635 
3636   /* "fiona/_shim.pyx":144
3637  *
3638  * cdef void get_proj_version(int* major, int* minor, int* patch):
3639  *     cdef int val = -1             # <<<<<<<<<<<<<<
3640  *     major[0] = val
3641  *     minor[0] = val
3642  */
3643   __pyx_v_val = -1;
3644 
3645   /* "fiona/_shim.pyx":145
3646  * cdef void get_proj_version(int* major, int* minor, int* patch):
3647  *     cdef int val = -1
3648  *     major[0] = val             # <<<<<<<<<<<<<<
3649  *     minor[0] = val
3650  *     patch[0] = val
3651  */
3652   (__pyx_v_major[0]) = __pyx_v_val;
3653 
3654   /* "fiona/_shim.pyx":146
3655  *     cdef int val = -1
3656  *     major[0] = val
3657  *     minor[0] = val             # <<<<<<<<<<<<<<
3658  *     patch[0] = val
3659  *
3660  */
3661   (__pyx_v_minor[0]) = __pyx_v_val;
3662 
3663   /* "fiona/_shim.pyx":147
3664  *     major[0] = val
3665  *     minor[0] = val
3666  *     patch[0] = val             # <<<<<<<<<<<<<<
3667  *
3668  *
3669  */
3670   (__pyx_v_patch[0]) = __pyx_v_val;
3671 
3672   /* "fiona/_shim.pyx":143
3673  *
3674  *
3675  * cdef void get_proj_version(int* major, int* minor, int* patch):             # <<<<<<<<<<<<<<
3676  *     cdef int val = -1
3677  *     major[0] = val
3678  */
3679 
3680   /* function exit code */
3681   __Pyx_RefNannyFinishContext();
3682 }
3683 
3684 /* "fiona/_shim.pyx":150
3685  *
3686  *
3687  * cdef void set_field_datetime(void *cogr_feature, int iField, int nYear, int nMonth, int nDay, int nHour, int nMinute, float fSecond, int nTZFlag):             # <<<<<<<<<<<<<<
3688  *     OGR_F_SetFieldDateTimeEx(cogr_feature, iField, nYear, nMonth, nDay, nHour, nMinute, fSecond, nTZFlag)
3689  *
3690  */
3691 
__pyx_f_5fiona_5_shim_set_field_datetime(void * __pyx_v_cogr_feature,int __pyx_v_iField,int __pyx_v_nYear,int __pyx_v_nMonth,int __pyx_v_nDay,int __pyx_v_nHour,int __pyx_v_nMinute,float __pyx_v_fSecond,int __pyx_v_nTZFlag)3692 static void __pyx_f_5fiona_5_shim_set_field_datetime(void *__pyx_v_cogr_feature, int __pyx_v_iField, int __pyx_v_nYear, int __pyx_v_nMonth, int __pyx_v_nDay, int __pyx_v_nHour, int __pyx_v_nMinute, float __pyx_v_fSecond, int __pyx_v_nTZFlag) {
3693   __Pyx_RefNannyDeclarations
3694   __Pyx_RefNannySetupContext("set_field_datetime", 0);
3695 
3696   /* "fiona/_shim.pyx":151
3697  *
3698  * cdef void set_field_datetime(void *cogr_feature, int iField, int nYear, int nMonth, int nDay, int nHour, int nMinute, float fSecond, int nTZFlag):
3699  *     OGR_F_SetFieldDateTimeEx(cogr_feature, iField, nYear, nMonth, nDay, nHour, nMinute, fSecond, nTZFlag)             # <<<<<<<<<<<<<<
3700  *
3701  *
3702  */
3703   OGR_F_SetFieldDateTimeEx(__pyx_v_cogr_feature, __pyx_v_iField, __pyx_v_nYear, __pyx_v_nMonth, __pyx_v_nDay, __pyx_v_nHour, __pyx_v_nMinute, __pyx_v_fSecond, __pyx_v_nTZFlag);
3704 
3705   /* "fiona/_shim.pyx":150
3706  *
3707  *
3708  * cdef void set_field_datetime(void *cogr_feature, int iField, int nYear, int nMonth, int nDay, int nHour, int nMinute, float fSecond, int nTZFlag):             # <<<<<<<<<<<<<<
3709  *     OGR_F_SetFieldDateTimeEx(cogr_feature, iField, nYear, nMonth, nDay, nHour, nMinute, fSecond, nTZFlag)
3710  *
3711  */
3712 
3713   /* function exit code */
3714   __Pyx_RefNannyFinishContext();
3715 }
3716 
3717 /* "fiona/_shim.pyx":154
3718  *
3719  *
3720  * cdef int get_field_as_datetime(void *cogr_feature, int iField, int* nYear, int* nMonth, int* nDay, int* nHour, int* nMinute, float* fSecond, int* nTZFlag):             # <<<<<<<<<<<<<<
3721  *     return OGR_F_GetFieldAsDateTimeEx(cogr_feature, iField, nYear, nMonth, nDay, nHour, nMinute, fSecond, nTZFlag)
3722  */
3723 
__pyx_f_5fiona_5_shim_get_field_as_datetime(void * __pyx_v_cogr_feature,int __pyx_v_iField,int * __pyx_v_nYear,int * __pyx_v_nMonth,int * __pyx_v_nDay,int * __pyx_v_nHour,int * __pyx_v_nMinute,float * __pyx_v_fSecond,int * __pyx_v_nTZFlag)3724 static int __pyx_f_5fiona_5_shim_get_field_as_datetime(void *__pyx_v_cogr_feature, int __pyx_v_iField, int *__pyx_v_nYear, int *__pyx_v_nMonth, int *__pyx_v_nDay, int *__pyx_v_nHour, int *__pyx_v_nMinute, float *__pyx_v_fSecond, int *__pyx_v_nTZFlag) {
3725   int __pyx_r;
3726   __Pyx_RefNannyDeclarations
3727   __Pyx_RefNannySetupContext("get_field_as_datetime", 0);
3728 
3729   /* "fiona/_shim.pyx":155
3730  *
3731  * cdef int get_field_as_datetime(void *cogr_feature, int iField, int* nYear, int* nMonth, int* nDay, int* nHour, int* nMinute, float* fSecond, int* nTZFlag):
3732  *     return OGR_F_GetFieldAsDateTimeEx(cogr_feature, iField, nYear, nMonth, nDay, nHour, nMinute, fSecond, nTZFlag)             # <<<<<<<<<<<<<<
3733  */
3734   __pyx_r = OGR_F_GetFieldAsDateTimeEx(__pyx_v_cogr_feature, __pyx_v_iField, __pyx_v_nYear, __pyx_v_nMonth, __pyx_v_nDay, __pyx_v_nHour, __pyx_v_nMinute, __pyx_v_fSecond, __pyx_v_nTZFlag);
3735   goto __pyx_L0;
3736 
3737   /* "fiona/_shim.pyx":154
3738  *
3739  *
3740  * cdef int get_field_as_datetime(void *cogr_feature, int iField, int* nYear, int* nMonth, int* nDay, int* nHour, int* nMinute, float* fSecond, int* nTZFlag):             # <<<<<<<<<<<<<<
3741  *     return OGR_F_GetFieldAsDateTimeEx(cogr_feature, iField, nYear, nMonth, nDay, nHour, nMinute, fSecond, nTZFlag)
3742  */
3743 
3744   /* function exit code */
3745   __pyx_L0:;
3746   __Pyx_RefNannyFinishContext();
3747   return __pyx_r;
3748 }
3749 
3750 static PyMethodDef __pyx_methods[] = {
3751   {0, 0, 0, 0}
3752 };
3753 
3754 #if PY_MAJOR_VERSION >= 3
3755 #if CYTHON_PEP489_MULTI_PHASE_INIT
3756 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
3757 static int __pyx_pymod_exec__shim(PyObject* module); /*proto*/
3758 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
3759   {Py_mod_create, (void*)__pyx_pymod_create},
3760   {Py_mod_exec, (void*)__pyx_pymod_exec__shim},
3761   {0, NULL}
3762 };
3763 #endif
3764 
3765 static struct PyModuleDef __pyx_moduledef = {
3766     PyModuleDef_HEAD_INIT,
3767     "_shim",
3768     __pyx_k_Shims_on_top_of_ogrext_for_GDAL, /* m_doc */
3769   #if CYTHON_PEP489_MULTI_PHASE_INIT
3770     0, /* m_size */
3771   #else
3772     -1, /* m_size */
3773   #endif
3774     __pyx_methods /* m_methods */,
3775   #if CYTHON_PEP489_MULTI_PHASE_INIT
3776     __pyx_moduledef_slots, /* m_slots */
3777   #else
3778     NULL, /* m_reload */
3779   #endif
3780     NULL, /* m_traverse */
3781     NULL, /* m_clear */
3782     NULL /* m_free */
3783 };
3784 #endif
3785 #ifndef CYTHON_SMALL_CODE
3786 #if defined(__clang__)
3787     #define CYTHON_SMALL_CODE
3788 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
3789     #define CYTHON_SMALL_CODE __attribute__((cold))
3790 #else
3791     #define CYTHON_SMALL_CODE
3792 #endif
3793 #endif
3794 
3795 static __Pyx_StringTabEntry __pyx_string_tab[] = {
3796   {&__pyx_n_s_CPLE_BaseError, __pyx_k_CPLE_BaseError, sizeof(__pyx_k_CPLE_BaseError), 0, 0, 1, 1},
3797   {&__pyx_n_s_DriverError, __pyx_k_DriverError, sizeof(__pyx_k_DriverError), 0, 0, 1, 1},
3798   {&__pyx_kp_s_Failed_to_create_dataset, __pyx_k_Failed_to_create_dataset, sizeof(__pyx_k_Failed_to_create_dataset), 0, 0, 1, 0},
3799   {&__pyx_kp_s_Failed_to_open_dataset_mode, __pyx_k_Failed_to_open_dataset_mode, sizeof(__pyx_k_Failed_to_open_dataset_mode), 0, 0, 1, 0},
3800   {&__pyx_n_s_FionaNullPointerError, __pyx_k_FionaNullPointerError, sizeof(__pyx_k_FionaNullPointerError), 0, 0, 1, 1},
3801   {&__pyx_n_s_OFF, __pyx_k_OFF, sizeof(__pyx_k_OFF), 0, 0, 1, 1},
3802   {&__pyx_n_s_ON, __pyx_k_ON, sizeof(__pyx_k_ON), 0, 0, 1, 1},
3803   {&__pyx_n_s_PROJ_LIB, __pyx_k_PROJ_LIB, sizeof(__pyx_k_PROJ_LIB), 0, 0, 1, 1},
3804   {&__pyx_kp_s_Set_option_r_r, __pyx_k_Set_option_r_r, sizeof(__pyx_k_Set_option_r_r), 0, 0, 1, 0},
3805   {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
3806   {&__pyx_n_s_cpl_errs, __pyx_k_cpl_errs, sizeof(__pyx_k_cpl_errs), 0, 0, 1, 1},
3807   {&__pyx_n_s_debug, __pyx_k_debug, sizeof(__pyx_k_debug), 0, 0, 1, 1},
3808   {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
3809   {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
3810   {&__pyx_n_s_environ, __pyx_k_environ, sizeof(__pyx_k_environ), 0, 0, 1, 1},
3811   {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
3812   {&__pyx_n_s_fiona__err, __pyx_k_fiona__err, sizeof(__pyx_k_fiona__err), 0, 0, 1, 1},
3813   {&__pyx_n_s_fiona_errors, __pyx_k_fiona_errors, sizeof(__pyx_k_fiona_errors), 0, 0, 1, 1},
3814   {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
3815   {&__pyx_n_s_getLogger, __pyx_k_getLogger, sizeof(__pyx_k_getLogger), 0, 0, 1, 1},
3816   {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
3817   {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
3818   {&__pyx_n_s_log, __pyx_k_log, sizeof(__pyx_k_log), 0, 0, 1, 1},
3819   {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1},
3820   {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
3821   {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
3822   {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
3823   {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
3824   {&__pyx_n_s_upper, __pyx_k_upper, sizeof(__pyx_k_upper), 0, 0, 1, 1},
3825   {&__pyx_kp_s_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 0, 1, 0},
3826   {0, 0, 0, 0, 0, 0, 0}
3827 };
__Pyx_InitCachedBuiltins(void)3828 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
3829   return 0;
3830 }
3831 
__Pyx_InitCachedConstants(void)3832 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
3833   __Pyx_RefNannyDeclarations
3834   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
3835 
3836   /* "fiona/_shim.pyx":27
3837  *
3838  * cdef void gdal_flush_cache(void *cogr_ds):
3839  *     with cpl_errs:             # <<<<<<<<<<<<<<
3840  *         GDALFlushCache(cogr_ds)
3841  *
3842  */
3843   __pyx_tuple_ = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 27, __pyx_L1_error)
3844   __Pyx_GOTREF(__pyx_tuple_);
3845   __Pyx_GIVEREF(__pyx_tuple_);
3846   __Pyx_RefNannyFinishContext();
3847   return 0;
3848   __pyx_L1_error:;
3849   __Pyx_RefNannyFinishContext();
3850   return -1;
3851 }
3852 
__Pyx_InitGlobals(void)3853 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
3854   if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
3855   return 0;
3856   __pyx_L1_error:;
3857   return -1;
3858 }
3859 
3860 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
3861 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
3862 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
3863 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
3864 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
3865 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
3866 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
3867 
__Pyx_modinit_global_init_code(void)3868 static int __Pyx_modinit_global_init_code(void) {
3869   __Pyx_RefNannyDeclarations
3870   __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
3871   /*--- Global init code ---*/
3872   __Pyx_RefNannyFinishContext();
3873   return 0;
3874 }
3875 
__Pyx_modinit_variable_export_code(void)3876 static int __Pyx_modinit_variable_export_code(void) {
3877   __Pyx_RefNannyDeclarations
3878   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
3879   /*--- Variable export code ---*/
3880   __Pyx_RefNannyFinishContext();
3881   return 0;
3882 }
3883 
__Pyx_modinit_function_export_code(void)3884 static int __Pyx_modinit_function_export_code(void) {
3885   __Pyx_RefNannyDeclarations
3886   int __pyx_lineno = 0;
3887   const char *__pyx_filename = NULL;
3888   int __pyx_clineno = 0;
3889   __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
3890   /*--- Function export code ---*/
3891   if (__Pyx_ExportFunction("is_field_null", (void (*)(void))__pyx_f_5fiona_5_shim_is_field_null, "int (void *, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3892   if (__Pyx_ExportFunction("set_field_null", (void (*)(void))__pyx_f_5fiona_5_shim_set_field_null, "void (void *, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3893   if (__Pyx_ExportFunction("gdal_flush_cache", (void (*)(void))__pyx_f_5fiona_5_shim_gdal_flush_cache, "void (void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3894   if (__Pyx_ExportFunction("gdal_open_vector", (void (*)(void))__pyx_f_5fiona_5_shim_gdal_open_vector, "void *(char const *, int, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3895   if (__Pyx_ExportFunction("gdal_create", (void (*)(void))__pyx_f_5fiona_5_shim_gdal_create, "void *(void *, char const *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3896   if (__Pyx_ExportFunction("check_capability_transaction", (void (*)(void))__pyx_f_5fiona_5_shim_check_capability_transaction, "int (void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3897   if (__Pyx_ExportFunction("gdal_start_transaction", (void (*)(void))__pyx_f_5fiona_5_shim_gdal_start_transaction, "OGRErr (void *, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3898   if (__Pyx_ExportFunction("gdal_commit_transaction", (void (*)(void))__pyx_f_5fiona_5_shim_gdal_commit_transaction, "OGRErr (void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3899   if (__Pyx_ExportFunction("gdal_rollback_transaction", (void (*)(void))__pyx_f_5fiona_5_shim_gdal_rollback_transaction, "OGRErr (void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3900   if (__Pyx_ExportFunction("get_field_subtype", (void (*)(void))__pyx_f_5fiona_5_shim_get_field_subtype, "OGRFieldSubType (void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3901   if (__Pyx_ExportFunction("set_field_subtype", (void (*)(void))__pyx_f_5fiona_5_shim_set_field_subtype, "void (void *, OGRFieldSubType)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3902   if (__Pyx_ExportFunction("check_capability_create_layer", (void (*)(void))__pyx_f_5fiona_5_shim_check_capability_create_layer, "int (void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3903   if (__Pyx_ExportFunction("get_linear_geometry", (void (*)(void))__pyx_f_5fiona_5_shim_get_linear_geometry, "void *(void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3904   if (__Pyx_ExportFunction("osr_get_name", (void (*)(void))__pyx_f_5fiona_5_shim_osr_get_name, "char const *(OGRSpatialReferenceH)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3905   if (__Pyx_ExportFunction("osr_set_traditional_axis_mapping_strategy", (void (*)(void))__pyx_f_5fiona_5_shim_osr_set_traditional_axis_mapping_strategy, "void (OGRSpatialReferenceH)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3906   if (__Pyx_ExportFunction("set_proj_search_path", (void (*)(void))__pyx_f_5fiona_5_shim_set_proj_search_path, "void (PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3907   if (__Pyx_ExportFunction("get_proj_version", (void (*)(void))__pyx_f_5fiona_5_shim_get_proj_version, "void (int *, int *, int *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3908   if (__Pyx_ExportFunction("set_field_datetime", (void (*)(void))__pyx_f_5fiona_5_shim_set_field_datetime, "void (void *, int, int, int, int, int, int, float, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3909   if (__Pyx_ExportFunction("get_field_as_datetime", (void (*)(void))__pyx_f_5fiona_5_shim_get_field_as_datetime, "int (void *, int, int *, int *, int *, int *, int *, float *, int *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3910   __Pyx_RefNannyFinishContext();
3911   return 0;
3912   __pyx_L1_error:;
3913   __Pyx_RefNannyFinishContext();
3914   return -1;
3915 }
3916 
__Pyx_modinit_type_init_code(void)3917 static int __Pyx_modinit_type_init_code(void) {
3918   __Pyx_RefNannyDeclarations
3919   __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
3920   /*--- Type init code ---*/
3921   __Pyx_RefNannyFinishContext();
3922   return 0;
3923 }
3924 
__Pyx_modinit_type_import_code(void)3925 static int __Pyx_modinit_type_import_code(void) {
3926   __Pyx_RefNannyDeclarations
3927   __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
3928   /*--- Type import code ---*/
3929   __Pyx_RefNannyFinishContext();
3930   return 0;
3931 }
3932 
__Pyx_modinit_variable_import_code(void)3933 static int __Pyx_modinit_variable_import_code(void) {
3934   __Pyx_RefNannyDeclarations
3935   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
3936   /*--- Variable import code ---*/
3937   __Pyx_RefNannyFinishContext();
3938   return 0;
3939 }
3940 
__Pyx_modinit_function_import_code(void)3941 static int __Pyx_modinit_function_import_code(void) {
3942   __Pyx_RefNannyDeclarations
3943   PyObject *__pyx_t_1 = NULL;
3944   int __pyx_lineno = 0;
3945   const char *__pyx_filename = NULL;
3946   int __pyx_clineno = 0;
3947   __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
3948   /*--- Function import code ---*/
3949   __pyx_t_1 = PyImport_ImportModule("fiona._err"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
3950   __Pyx_GOTREF(__pyx_t_1);
3951   if (__Pyx_ImportFunction(__pyx_t_1, "exc_wrap_pointer", (void (**)(void))&__pyx_f_5fiona_4_err_exc_wrap_pointer, "void *(void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3952   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3953   __Pyx_RefNannyFinishContext();
3954   return 0;
3955   __pyx_L1_error:;
3956   __Pyx_XDECREF(__pyx_t_1);
3957   __Pyx_RefNannyFinishContext();
3958   return -1;
3959 }
3960 
3961 
3962 #ifndef CYTHON_NO_PYINIT_EXPORT
3963 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
3964 #elif PY_MAJOR_VERSION < 3
3965 #ifdef __cplusplus
3966 #define __Pyx_PyMODINIT_FUNC extern "C" void
3967 #else
3968 #define __Pyx_PyMODINIT_FUNC void
3969 #endif
3970 #else
3971 #ifdef __cplusplus
3972 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
3973 #else
3974 #define __Pyx_PyMODINIT_FUNC PyObject *
3975 #endif
3976 #endif
3977 
3978 
3979 #if PY_MAJOR_VERSION < 3
3980 __Pyx_PyMODINIT_FUNC init_shim(void) CYTHON_SMALL_CODE; /*proto*/
init_shim(void)3981 __Pyx_PyMODINIT_FUNC init_shim(void)
3982 #else
3983 __Pyx_PyMODINIT_FUNC PyInit__shim(void) CYTHON_SMALL_CODE; /*proto*/
3984 __Pyx_PyMODINIT_FUNC PyInit__shim(void)
3985 #if CYTHON_PEP489_MULTI_PHASE_INIT
3986 {
3987   return PyModuleDef_Init(&__pyx_moduledef);
3988 }
3989 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
3990     #if PY_VERSION_HEX >= 0x030700A1
3991     static PY_INT64_T main_interpreter_id = -1;
3992     PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
3993     if (main_interpreter_id == -1) {
3994         main_interpreter_id = current_id;
3995         return (unlikely(current_id == -1)) ? -1 : 0;
3996     } else if (unlikely(main_interpreter_id != current_id))
3997     #else
3998     static PyInterpreterState *main_interpreter = NULL;
3999     PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
4000     if (!main_interpreter) {
4001         main_interpreter = current_interpreter;
4002     } else if (unlikely(main_interpreter != current_interpreter))
4003     #endif
4004     {
4005         PyErr_SetString(
4006             PyExc_ImportError,
4007             "Interpreter change detected - this module can only be loaded into one interpreter per process.");
4008         return -1;
4009     }
4010     return 0;
4011 }
4012 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) {
4013     PyObject *value = PyObject_GetAttrString(spec, from_name);
4014     int result = 0;
4015     if (likely(value)) {
4016         if (allow_none || value != Py_None) {
4017             result = PyDict_SetItemString(moddict, to_name, value);
4018         }
4019         Py_DECREF(value);
4020     } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
4021         PyErr_Clear();
4022     } else {
4023         result = -1;
4024     }
4025     return result;
4026 }
4027 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
4028     PyObject *module = NULL, *moddict, *modname;
4029     if (__Pyx_check_single_interpreter())
4030         return NULL;
4031     if (__pyx_m)
4032         return __Pyx_NewRef(__pyx_m);
4033     modname = PyObject_GetAttrString(spec, "name");
4034     if (unlikely(!modname)) goto bad;
4035     module = PyModule_NewObject(modname);
4036     Py_DECREF(modname);
4037     if (unlikely(!module)) goto bad;
4038     moddict = PyModule_GetDict(module);
4039     if (unlikely(!moddict)) goto bad;
4040     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
4041     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
4042     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
4043     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
4044     return module;
4045 bad:
4046     Py_XDECREF(module);
4047     return NULL;
4048 }
4049 
4050 
4051 static CYTHON_SMALL_CODE int __pyx_pymod_exec__shim(PyObject *__pyx_pyinit_module)
4052 #endif
4053 #endif
4054 {
4055   PyObject *__pyx_t_1 = NULL;
4056   PyObject *__pyx_t_2 = NULL;
4057   PyObject *__pyx_t_3 = NULL;
4058   int __pyx_lineno = 0;
4059   const char *__pyx_filename = NULL;
4060   int __pyx_clineno = 0;
4061   __Pyx_RefNannyDeclarations
4062   #if CYTHON_PEP489_MULTI_PHASE_INIT
4063   if (__pyx_m) {
4064     if (__pyx_m == __pyx_pyinit_module) return 0;
4065     PyErr_SetString(PyExc_RuntimeError, "Module '_shim' has already been imported. Re-initialisation is not supported.");
4066     return -1;
4067   }
4068   #elif PY_MAJOR_VERSION >= 3
4069   if (__pyx_m) return __Pyx_NewRef(__pyx_m);
4070   #endif
4071   #if CYTHON_REFNANNY
4072 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
4073 if (!__Pyx_RefNanny) {
4074   PyErr_Clear();
4075   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
4076   if (!__Pyx_RefNanny)
4077       Py_FatalError("failed to import 'refnanny' module");
4078 }
4079 #endif
4080   __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__shim(void)", 0);
4081   if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4082   #ifdef __Pxy_PyFrame_Initialize_Offsets
4083   __Pxy_PyFrame_Initialize_Offsets();
4084   #endif
4085   __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
4086   __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
4087   __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
4088   #ifdef __Pyx_CyFunction_USED
4089   if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4090   #endif
4091   #ifdef __Pyx_FusedFunction_USED
4092   if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4093   #endif
4094   #ifdef __Pyx_Coroutine_USED
4095   if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4096   #endif
4097   #ifdef __Pyx_Generator_USED
4098   if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4099   #endif
4100   #ifdef __Pyx_AsyncGen_USED
4101   if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4102   #endif
4103   #ifdef __Pyx_StopAsyncIteration_USED
4104   if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4105   #endif
4106   /*--- Library function declarations ---*/
4107   /*--- Threads initialization code ---*/
4108   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
4109   #ifdef WITH_THREAD /* Python build with threading support? */
4110   PyEval_InitThreads();
4111   #endif
4112   #endif
4113   /*--- Module creation code ---*/
4114   #if CYTHON_PEP489_MULTI_PHASE_INIT
4115   __pyx_m = __pyx_pyinit_module;
4116   Py_INCREF(__pyx_m);
4117   #else
4118   #if PY_MAJOR_VERSION < 3
4119   __pyx_m = Py_InitModule4("_shim", __pyx_methods, __pyx_k_Shims_on_top_of_ogrext_for_GDAL, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
4120   #else
4121   __pyx_m = PyModule_Create(&__pyx_moduledef);
4122   #endif
4123   if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
4124   #endif
4125   __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
4126   Py_INCREF(__pyx_d);
4127   __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
4128   Py_INCREF(__pyx_b);
4129   __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
4130   Py_INCREF(__pyx_cython_runtime);
4131   if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
4132   /*--- Initialize various global constants etc. ---*/
4133   if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4134   #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
4135   if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4136   #endif
4137   if (__pyx_module_is_main_fiona___shim) {
4138     if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4139   }
4140   #if PY_MAJOR_VERSION >= 3
4141   {
4142     PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
4143     if (!PyDict_GetItemString(modules, "fiona._shim")) {
4144       if (unlikely(PyDict_SetItemString(modules, "fiona._shim", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
4145     }
4146   }
4147   #endif
4148   /*--- Builtin init code ---*/
4149   if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4150   /*--- Constants init code ---*/
4151   if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4152   /*--- Global type/function init code ---*/
4153   (void)__Pyx_modinit_global_init_code();
4154   (void)__Pyx_modinit_variable_export_code();
4155   if (unlikely(__Pyx_modinit_function_export_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
4156   (void)__Pyx_modinit_type_init_code();
4157   (void)__Pyx_modinit_type_import_code();
4158   (void)__Pyx_modinit_variable_import_code();
4159   if (unlikely(__Pyx_modinit_function_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
4160   /*--- Execution code ---*/
4161   #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
4162   if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4163   #endif
4164 
4165   /* "fiona/_shim.pyx":3
4166  * """Shims on top of ogrext for GDAL versions > 2"""
4167  *
4168  * import logging             # <<<<<<<<<<<<<<
4169  * import os
4170  *
4171  */
4172   __pyx_t_1 = __Pyx_Import(__pyx_n_s_logging, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
4173   __Pyx_GOTREF(__pyx_t_1);
4174   if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
4175   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4176 
4177   /* "fiona/_shim.pyx":4
4178  *
4179  * import logging
4180  * import os             # <<<<<<<<<<<<<<
4181  *
4182  * from fiona.ogrext2 cimport *
4183  */
4184   __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
4185   __Pyx_GOTREF(__pyx_t_1);
4186   if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
4187   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4188 
4189   /* "fiona/_shim.pyx":8
4190  * from fiona.ogrext2 cimport *
4191  * from fiona._err cimport exc_wrap_pointer
4192  * from fiona._err import cpl_errs, CPLE_BaseError, FionaNullPointerError             # <<<<<<<<<<<<<<
4193  * from fiona.errors import DriverError
4194  *
4195  */
4196   __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
4197   __Pyx_GOTREF(__pyx_t_1);
4198   __Pyx_INCREF(__pyx_n_s_cpl_errs);
4199   __Pyx_GIVEREF(__pyx_n_s_cpl_errs);
4200   PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_cpl_errs);
4201   __Pyx_INCREF(__pyx_n_s_CPLE_BaseError);
4202   __Pyx_GIVEREF(__pyx_n_s_CPLE_BaseError);
4203   PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_CPLE_BaseError);
4204   __Pyx_INCREF(__pyx_n_s_FionaNullPointerError);
4205   __Pyx_GIVEREF(__pyx_n_s_FionaNullPointerError);
4206   PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_FionaNullPointerError);
4207   __pyx_t_2 = __Pyx_Import(__pyx_n_s_fiona__err, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
4208   __Pyx_GOTREF(__pyx_t_2);
4209   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4210   __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_cpl_errs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
4211   __Pyx_GOTREF(__pyx_t_1);
4212   if (PyDict_SetItem(__pyx_d, __pyx_n_s_cpl_errs, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
4213   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4214   __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_CPLE_BaseError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
4215   __Pyx_GOTREF(__pyx_t_1);
4216   if (PyDict_SetItem(__pyx_d, __pyx_n_s_CPLE_BaseError, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
4217   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4218   __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_FionaNullPointerError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
4219   __Pyx_GOTREF(__pyx_t_1);
4220   if (PyDict_SetItem(__pyx_d, __pyx_n_s_FionaNullPointerError, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
4221   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4222   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4223 
4224   /* "fiona/_shim.pyx":9
4225  * from fiona._err cimport exc_wrap_pointer
4226  * from fiona._err import cpl_errs, CPLE_BaseError, FionaNullPointerError
4227  * from fiona.errors import DriverError             # <<<<<<<<<<<<<<
4228  *
4229  *
4230  */
4231   __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
4232   __Pyx_GOTREF(__pyx_t_2);
4233   __Pyx_INCREF(__pyx_n_s_DriverError);
4234   __Pyx_GIVEREF(__pyx_n_s_DriverError);
4235   PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_DriverError);
4236   __pyx_t_1 = __Pyx_Import(__pyx_n_s_fiona_errors, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)
4237   __Pyx_GOTREF(__pyx_t_1);
4238   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4239   __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_DriverError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
4240   __Pyx_GOTREF(__pyx_t_2);
4241   if (PyDict_SetItem(__pyx_d, __pyx_n_s_DriverError, __pyx_t_2) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
4242   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4243   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4244 
4245   /* "fiona/_shim.pyx":12
4246  *
4247  *
4248  * log = logging.getLogger(__name__)             # <<<<<<<<<<<<<<
4249  *
4250  *
4251  */
4252   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_logging); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
4253   __Pyx_GOTREF(__pyx_t_1);
4254   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_getLogger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
4255   __Pyx_GOTREF(__pyx_t_2);
4256   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4257   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
4258   __Pyx_GOTREF(__pyx_t_1);
4259   __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 12, __pyx_L1_error)
4260   __Pyx_GOTREF(__pyx_t_3);
4261   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4262   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4263   if (PyDict_SetItem(__pyx_d, __pyx_n_s_log, __pyx_t_3) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
4264   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4265 
4266   /* "fiona/_shim.pyx":1
4267  * """Shims on top of ogrext for GDAL versions > 2"""             # <<<<<<<<<<<<<<
4268  *
4269  * import logging
4270  */
4271   __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error)
4272   __Pyx_GOTREF(__pyx_t_3);
4273   if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4274   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4275 
4276   /*--- Wrapped vars code ---*/
4277 
4278   goto __pyx_L0;
4279   __pyx_L1_error:;
4280   __Pyx_XDECREF(__pyx_t_1);
4281   __Pyx_XDECREF(__pyx_t_2);
4282   __Pyx_XDECREF(__pyx_t_3);
4283   if (__pyx_m) {
4284     if (__pyx_d) {
4285       __Pyx_AddTraceback("init fiona._shim", __pyx_clineno, __pyx_lineno, __pyx_filename);
4286     }
4287     Py_CLEAR(__pyx_m);
4288   } else if (!PyErr_Occurred()) {
4289     PyErr_SetString(PyExc_ImportError, "init fiona._shim");
4290   }
4291   __pyx_L0:;
4292   __Pyx_RefNannyFinishContext();
4293   #if CYTHON_PEP489_MULTI_PHASE_INIT
4294   return (__pyx_m != NULL) ? 0 : -1;
4295   #elif PY_MAJOR_VERSION >= 3
4296   return __pyx_m;
4297   #else
4298   return;
4299   #endif
4300 }
4301 
4302 /* --- Runtime support code --- */
4303 /* Refnanny */
4304 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)4305 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
4306     PyObject *m = NULL, *p = NULL;
4307     void *r = NULL;
4308     m = PyImport_ImportModule(modname);
4309     if (!m) goto end;
4310     p = PyObject_GetAttrString(m, "RefNannyAPI");
4311     if (!p) goto end;
4312     r = PyLong_AsVoidPtr(p);
4313 end:
4314     Py_XDECREF(p);
4315     Py_XDECREF(m);
4316     return (__Pyx_RefNannyAPIStruct *)r;
4317 }
4318 #endif
4319 
4320 /* PyObjectGetAttrStr */
4321 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)4322 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
4323     PyTypeObject* tp = Py_TYPE(obj);
4324     if (likely(tp->tp_getattro))
4325         return tp->tp_getattro(obj, attr_name);
4326 #if PY_MAJOR_VERSION < 3
4327     if (likely(tp->tp_getattr))
4328         return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
4329 #endif
4330     return PyObject_GetAttr(obj, attr_name);
4331 }
4332 #endif
4333 
4334 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)4335 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
4336     PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
4337     if (unlikely(!result)) {
4338         PyErr_Format(PyExc_NameError,
4339 #if PY_MAJOR_VERSION >= 3
4340             "name '%U' is not defined", name);
4341 #else
4342             "name '%.200s' is not defined", PyString_AS_STRING(name));
4343 #endif
4344     }
4345     return result;
4346 }
4347 
4348 /* PyDictVersioning */
4349 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)4350 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
4351     PyObject *dict = Py_TYPE(obj)->tp_dict;
4352     return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
4353 }
__Pyx_get_object_dict_version(PyObject * obj)4354 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
4355     PyObject **dictptr = NULL;
4356     Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
4357     if (offset) {
4358 #if CYTHON_COMPILING_IN_CPYTHON
4359         dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
4360 #else
4361         dictptr = _PyObject_GetDictPtr(obj);
4362 #endif
4363     }
4364     return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
4365 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)4366 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
4367     PyObject *dict = Py_TYPE(obj)->tp_dict;
4368     if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
4369         return 0;
4370     return obj_dict_version == __Pyx_get_object_dict_version(obj);
4371 }
4372 #endif
4373 
4374 /* GetModuleGlobalName */
4375 #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)4376 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
4377 #else
4378 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
4379 #endif
4380 {
4381     PyObject *result;
4382 #if !CYTHON_AVOID_BORROWED_REFS
4383 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
4384     result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
4385     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
4386     if (likely(result)) {
4387         return __Pyx_NewRef(result);
4388     } else if (unlikely(PyErr_Occurred())) {
4389         return NULL;
4390     }
4391 #else
4392     result = PyDict_GetItem(__pyx_d, name);
4393     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
4394     if (likely(result)) {
4395         return __Pyx_NewRef(result);
4396     }
4397 #endif
4398 #else
4399     result = PyObject_GetItem(__pyx_d, name);
4400     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
4401     if (likely(result)) {
4402         return __Pyx_NewRef(result);
4403     }
4404     PyErr_Clear();
4405 #endif
4406     return __Pyx_GetBuiltinName(name);
4407 }
4408 
4409 /* PyFunctionFastCall */
4410 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)4411 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
4412                                                PyObject *globals) {
4413     PyFrameObject *f;
4414     PyThreadState *tstate = __Pyx_PyThreadState_Current;
4415     PyObject **fastlocals;
4416     Py_ssize_t i;
4417     PyObject *result;
4418     assert(globals != NULL);
4419     /* XXX Perhaps we should create a specialized
4420        PyFrame_New() that doesn't take locals, but does
4421        take builtins without sanity checking them.
4422        */
4423     assert(tstate != NULL);
4424     f = PyFrame_New(tstate, co, globals, NULL);
4425     if (f == NULL) {
4426         return NULL;
4427     }
4428     fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
4429     for (i = 0; i < na; i++) {
4430         Py_INCREF(*args);
4431         fastlocals[i] = *args++;
4432     }
4433     result = PyEval_EvalFrameEx(f,0);
4434     ++tstate->recursion_depth;
4435     Py_DECREF(f);
4436     --tstate->recursion_depth;
4437     return result;
4438 }
4439 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)4440 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
4441     PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
4442     PyObject *globals = PyFunction_GET_GLOBALS(func);
4443     PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
4444     PyObject *closure;
4445 #if PY_MAJOR_VERSION >= 3
4446     PyObject *kwdefs;
4447 #endif
4448     PyObject *kwtuple, **k;
4449     PyObject **d;
4450     Py_ssize_t nd;
4451     Py_ssize_t nk;
4452     PyObject *result;
4453     assert(kwargs == NULL || PyDict_Check(kwargs));
4454     nk = kwargs ? PyDict_Size(kwargs) : 0;
4455     if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
4456         return NULL;
4457     }
4458     if (
4459 #if PY_MAJOR_VERSION >= 3
4460             co->co_kwonlyargcount == 0 &&
4461 #endif
4462             likely(kwargs == NULL || nk == 0) &&
4463             co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
4464         if (argdefs == NULL && co->co_argcount == nargs) {
4465             result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
4466             goto done;
4467         }
4468         else if (nargs == 0 && argdefs != NULL
4469                  && co->co_argcount == Py_SIZE(argdefs)) {
4470             /* function called with no arguments, but all parameters have
4471                a default value: use default values as arguments .*/
4472             args = &PyTuple_GET_ITEM(argdefs, 0);
4473             result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
4474             goto done;
4475         }
4476     }
4477     if (kwargs != NULL) {
4478         Py_ssize_t pos, i;
4479         kwtuple = PyTuple_New(2 * nk);
4480         if (kwtuple == NULL) {
4481             result = NULL;
4482             goto done;
4483         }
4484         k = &PyTuple_GET_ITEM(kwtuple, 0);
4485         pos = i = 0;
4486         while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
4487             Py_INCREF(k[i]);
4488             Py_INCREF(k[i+1]);
4489             i += 2;
4490         }
4491         nk = i / 2;
4492     }
4493     else {
4494         kwtuple = NULL;
4495         k = NULL;
4496     }
4497     closure = PyFunction_GET_CLOSURE(func);
4498 #if PY_MAJOR_VERSION >= 3
4499     kwdefs = PyFunction_GET_KW_DEFAULTS(func);
4500 #endif
4501     if (argdefs != NULL) {
4502         d = &PyTuple_GET_ITEM(argdefs, 0);
4503         nd = Py_SIZE(argdefs);
4504     }
4505     else {
4506         d = NULL;
4507         nd = 0;
4508     }
4509 #if PY_MAJOR_VERSION >= 3
4510     result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
4511                                args, (int)nargs,
4512                                k, (int)nk,
4513                                d, (int)nd, kwdefs, closure);
4514 #else
4515     result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
4516                                args, (int)nargs,
4517                                k, (int)nk,
4518                                d, (int)nd, closure);
4519 #endif
4520     Py_XDECREF(kwtuple);
4521 done:
4522     Py_LeaveRecursiveCall();
4523     return result;
4524 }
4525 #endif
4526 #endif
4527 
4528 /* PyObjectCall */
4529 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)4530 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
4531     PyObject *result;
4532     ternaryfunc call = func->ob_type->tp_call;
4533     if (unlikely(!call))
4534         return PyObject_Call(func, arg, kw);
4535     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
4536         return NULL;
4537     result = (*call)(func, arg, kw);
4538     Py_LeaveRecursiveCall();
4539     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
4540         PyErr_SetString(
4541             PyExc_SystemError,
4542             "NULL result without error in PyObject_Call");
4543     }
4544     return result;
4545 }
4546 #endif
4547 
4548 /* PyObjectCallMethO */
4549 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)4550 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
4551     PyObject *self, *result;
4552     PyCFunction cfunc;
4553     cfunc = PyCFunction_GET_FUNCTION(func);
4554     self = PyCFunction_GET_SELF(func);
4555     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
4556         return NULL;
4557     result = cfunc(self, arg);
4558     Py_LeaveRecursiveCall();
4559     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
4560         PyErr_SetString(
4561             PyExc_SystemError,
4562             "NULL result without error in PyObject_Call");
4563     }
4564     return result;
4565 }
4566 #endif
4567 
4568 /* PyObjectCallNoArg */
4569 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallNoArg(PyObject * func)4570 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
4571 #if CYTHON_FAST_PYCALL
4572     if (PyFunction_Check(func)) {
4573         return __Pyx_PyFunction_FastCall(func, NULL, 0);
4574     }
4575 #endif
4576 #ifdef __Pyx_CyFunction_USED
4577     if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
4578 #else
4579     if (likely(PyCFunction_Check(func)))
4580 #endif
4581     {
4582         if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
4583             return __Pyx_PyObject_CallMethO(func, NULL);
4584         }
4585     }
4586     return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
4587 }
4588 #endif
4589 
4590 /* PyCFunctionFastCall */
4591 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)4592 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
4593     PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
4594     PyCFunction meth = PyCFunction_GET_FUNCTION(func);
4595     PyObject *self = PyCFunction_GET_SELF(func);
4596     int flags = PyCFunction_GET_FLAGS(func);
4597     assert(PyCFunction_Check(func));
4598     assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
4599     assert(nargs >= 0);
4600     assert(nargs == 0 || args != NULL);
4601     /* _PyCFunction_FastCallDict() must not be called with an exception set,
4602        because it may clear it (directly or indirectly) and so the
4603        caller loses its exception */
4604     assert(!PyErr_Occurred());
4605     if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
4606         return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
4607     } else {
4608         return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
4609     }
4610 }
4611 #endif
4612 
4613 /* PyObjectCallOneArg */
4614 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)4615 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
4616     PyObject *result;
4617     PyObject *args = PyTuple_New(1);
4618     if (unlikely(!args)) return NULL;
4619     Py_INCREF(arg);
4620     PyTuple_SET_ITEM(args, 0, arg);
4621     result = __Pyx_PyObject_Call(func, args, NULL);
4622     Py_DECREF(args);
4623     return result;
4624 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)4625 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
4626 #if CYTHON_FAST_PYCALL
4627     if (PyFunction_Check(func)) {
4628         return __Pyx_PyFunction_FastCall(func, &arg, 1);
4629     }
4630 #endif
4631     if (likely(PyCFunction_Check(func))) {
4632         if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
4633             return __Pyx_PyObject_CallMethO(func, arg);
4634 #if CYTHON_FAST_PYCCALL
4635         } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
4636             return __Pyx_PyCFunction_FastCall(func, &arg, 1);
4637 #endif
4638         }
4639     }
4640     return __Pyx__PyObject_CallOneArg(func, arg);
4641 }
4642 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)4643 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
4644     PyObject *result;
4645     PyObject *args = PyTuple_Pack(1, arg);
4646     if (unlikely(!args)) return NULL;
4647     result = __Pyx_PyObject_Call(func, args, NULL);
4648     Py_DECREF(args);
4649     return result;
4650 }
4651 #endif
4652 
4653 /* PyErrFetchRestore */
4654 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)4655 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
4656     PyObject *tmp_type, *tmp_value, *tmp_tb;
4657     tmp_type = tstate->curexc_type;
4658     tmp_value = tstate->curexc_value;
4659     tmp_tb = tstate->curexc_traceback;
4660     tstate->curexc_type = type;
4661     tstate->curexc_value = value;
4662     tstate->curexc_traceback = tb;
4663     Py_XDECREF(tmp_type);
4664     Py_XDECREF(tmp_value);
4665     Py_XDECREF(tmp_tb);
4666 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)4667 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
4668     *type = tstate->curexc_type;
4669     *value = tstate->curexc_value;
4670     *tb = tstate->curexc_traceback;
4671     tstate->curexc_type = 0;
4672     tstate->curexc_value = 0;
4673     tstate->curexc_traceback = 0;
4674 }
4675 #endif
4676 
4677 /* WriteUnraisableException */
__Pyx_WriteUnraisable(const char * name,CYTHON_UNUSED int clineno,CYTHON_UNUSED int lineno,CYTHON_UNUSED const char * filename,int full_traceback,CYTHON_UNUSED int nogil)4678 static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
4679                                   CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
4680                                   int full_traceback, CYTHON_UNUSED int nogil) {
4681     PyObject *old_exc, *old_val, *old_tb;
4682     PyObject *ctx;
4683     __Pyx_PyThreadState_declare
4684 #ifdef WITH_THREAD
4685     PyGILState_STATE state;
4686     if (nogil)
4687         state = PyGILState_Ensure();
4688 #ifdef _MSC_VER
4689     else state = (PyGILState_STATE)-1;
4690 #endif
4691 #endif
4692     __Pyx_PyThreadState_assign
4693     __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
4694     if (full_traceback) {
4695         Py_XINCREF(old_exc);
4696         Py_XINCREF(old_val);
4697         Py_XINCREF(old_tb);
4698         __Pyx_ErrRestore(old_exc, old_val, old_tb);
4699         PyErr_PrintEx(1);
4700     }
4701     #if PY_MAJOR_VERSION < 3
4702     ctx = PyString_FromString(name);
4703     #else
4704     ctx = PyUnicode_FromString(name);
4705     #endif
4706     __Pyx_ErrRestore(old_exc, old_val, old_tb);
4707     if (!ctx) {
4708         PyErr_WriteUnraisable(Py_None);
4709     } else {
4710         PyErr_WriteUnraisable(ctx);
4711         Py_DECREF(ctx);
4712     }
4713 #ifdef WITH_THREAD
4714     if (nogil)
4715         PyGILState_Release(state);
4716 #endif
4717 }
4718 
4719 /* RaiseTooManyValuesToUnpack */
__Pyx_RaiseTooManyValuesError(Py_ssize_t expected)4720 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
4721     PyErr_Format(PyExc_ValueError,
4722                  "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
4723 }
4724 
4725 /* RaiseNeedMoreValuesToUnpack */
__Pyx_RaiseNeedMoreValuesError(Py_ssize_t index)4726 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
4727     PyErr_Format(PyExc_ValueError,
4728                  "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
4729                  index, (index == 1) ? "" : "s");
4730 }
4731 
4732 /* IterFinish */
__Pyx_IterFinish(void)4733 static CYTHON_INLINE int __Pyx_IterFinish(void) {
4734 #if CYTHON_FAST_THREAD_STATE
4735     PyThreadState *tstate = __Pyx_PyThreadState_Current;
4736     PyObject* exc_type = tstate->curexc_type;
4737     if (unlikely(exc_type)) {
4738         if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
4739             PyObject *exc_value, *exc_tb;
4740             exc_value = tstate->curexc_value;
4741             exc_tb = tstate->curexc_traceback;
4742             tstate->curexc_type = 0;
4743             tstate->curexc_value = 0;
4744             tstate->curexc_traceback = 0;
4745             Py_DECREF(exc_type);
4746             Py_XDECREF(exc_value);
4747             Py_XDECREF(exc_tb);
4748             return 0;
4749         } else {
4750             return -1;
4751         }
4752     }
4753     return 0;
4754 #else
4755     if (unlikely(PyErr_Occurred())) {
4756         if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
4757             PyErr_Clear();
4758             return 0;
4759         } else {
4760             return -1;
4761         }
4762     }
4763     return 0;
4764 #endif
4765 }
4766 
4767 /* UnpackItemEndCheck */
__Pyx_IternextUnpackEndCheck(PyObject * retval,Py_ssize_t expected)4768 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
4769     if (unlikely(retval)) {
4770         Py_DECREF(retval);
4771         __Pyx_RaiseTooManyValuesError(expected);
4772         return -1;
4773     } else {
4774         return __Pyx_IterFinish();
4775     }
4776     return 0;
4777 }
4778 
4779 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)4780 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
4781     PyObject *args, *result = NULL;
4782     #if CYTHON_FAST_PYCALL
4783     if (PyFunction_Check(function)) {
4784         PyObject *args[2] = {arg1, arg2};
4785         return __Pyx_PyFunction_FastCall(function, args, 2);
4786     }
4787     #endif
4788     #if CYTHON_FAST_PYCCALL
4789     if (__Pyx_PyFastCFunction_Check(function)) {
4790         PyObject *args[2] = {arg1, arg2};
4791         return __Pyx_PyCFunction_FastCall(function, args, 2);
4792     }
4793     #endif
4794     args = PyTuple_New(2);
4795     if (unlikely(!args)) goto done;
4796     Py_INCREF(arg1);
4797     PyTuple_SET_ITEM(args, 0, arg1);
4798     Py_INCREF(arg2);
4799     PyTuple_SET_ITEM(args, 1, arg2);
4800     Py_INCREF(function);
4801     result = __Pyx_PyObject_Call(function, args, NULL);
4802     Py_DECREF(args);
4803     Py_DECREF(function);
4804 done:
4805     return result;
4806 }
4807 
4808 /* GetTopmostException */
4809 #if CYTHON_USE_EXC_INFO_STACK
4810 static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState * tstate)4811 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
4812 {
4813     _PyErr_StackItem *exc_info = tstate->exc_info;
4814     while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
4815            exc_info->previous_item != NULL)
4816     {
4817         exc_info = exc_info->previous_item;
4818     }
4819     return exc_info;
4820 }
4821 #endif
4822 
4823 /* SaveResetException */
4824 #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSave(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)4825 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
4826     #if CYTHON_USE_EXC_INFO_STACK
4827     _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
4828     *type = exc_info->exc_type;
4829     *value = exc_info->exc_value;
4830     *tb = exc_info->exc_traceback;
4831     #else
4832     *type = tstate->exc_type;
4833     *value = tstate->exc_value;
4834     *tb = tstate->exc_traceback;
4835     #endif
4836     Py_XINCREF(*type);
4837     Py_XINCREF(*value);
4838     Py_XINCREF(*tb);
4839 }
__Pyx__ExceptionReset(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)4840 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
4841     PyObject *tmp_type, *tmp_value, *tmp_tb;
4842     #if CYTHON_USE_EXC_INFO_STACK
4843     _PyErr_StackItem *exc_info = tstate->exc_info;
4844     tmp_type = exc_info->exc_type;
4845     tmp_value = exc_info->exc_value;
4846     tmp_tb = exc_info->exc_traceback;
4847     exc_info->exc_type = type;
4848     exc_info->exc_value = value;
4849     exc_info->exc_traceback = tb;
4850     #else
4851     tmp_type = tstate->exc_type;
4852     tmp_value = tstate->exc_value;
4853     tmp_tb = tstate->exc_traceback;
4854     tstate->exc_type = type;
4855     tstate->exc_value = value;
4856     tstate->exc_traceback = tb;
4857     #endif
4858     Py_XDECREF(tmp_type);
4859     Py_XDECREF(tmp_value);
4860     Py_XDECREF(tmp_tb);
4861 }
4862 #endif
4863 
4864 /* FastTypeChecks */
4865 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)4866 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
4867     while (a) {
4868         a = a->tp_base;
4869         if (a == b)
4870             return 1;
4871     }
4872     return b == &PyBaseObject_Type;
4873 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)4874 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
4875     PyObject *mro;
4876     if (a == b) return 1;
4877     mro = a->tp_mro;
4878     if (likely(mro)) {
4879         Py_ssize_t i, n;
4880         n = PyTuple_GET_SIZE(mro);
4881         for (i = 0; i < n; i++) {
4882             if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
4883                 return 1;
4884         }
4885         return 0;
4886     }
4887     return __Pyx_InBases(a, b);
4888 }
4889 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)4890 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
4891     PyObject *exception, *value, *tb;
4892     int res;
4893     __Pyx_PyThreadState_declare
4894     __Pyx_PyThreadState_assign
4895     __Pyx_ErrFetch(&exception, &value, &tb);
4896     res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
4897     if (unlikely(res == -1)) {
4898         PyErr_WriteUnraisable(err);
4899         res = 0;
4900     }
4901     if (!res) {
4902         res = PyObject_IsSubclass(err, exc_type2);
4903         if (unlikely(res == -1)) {
4904             PyErr_WriteUnraisable(err);
4905             res = 0;
4906         }
4907     }
4908     __Pyx_ErrRestore(exception, value, tb);
4909     return res;
4910 }
4911 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)4912 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
4913     int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
4914     if (!res) {
4915         res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
4916     }
4917     return res;
4918 }
4919 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)4920 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
4921     Py_ssize_t i, n;
4922     assert(PyExceptionClass_Check(exc_type));
4923     n = PyTuple_GET_SIZE(tuple);
4924 #if PY_MAJOR_VERSION >= 3
4925     for (i=0; i<n; i++) {
4926         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
4927     }
4928 #endif
4929     for (i=0; i<n; i++) {
4930         PyObject *t = PyTuple_GET_ITEM(tuple, i);
4931         #if PY_MAJOR_VERSION < 3
4932         if (likely(exc_type == t)) return 1;
4933         #endif
4934         if (likely(PyExceptionClass_Check(t))) {
4935             if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
4936         } else {
4937         }
4938     }
4939     return 0;
4940 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)4941 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
4942     if (likely(err == exc_type)) return 1;
4943     if (likely(PyExceptionClass_Check(err))) {
4944         if (likely(PyExceptionClass_Check(exc_type))) {
4945             return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
4946         } else if (likely(PyTuple_Check(exc_type))) {
4947             return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
4948         } else {
4949         }
4950     }
4951     return PyErr_GivenExceptionMatches(err, exc_type);
4952 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)4953 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
4954     assert(PyExceptionClass_Check(exc_type1));
4955     assert(PyExceptionClass_Check(exc_type2));
4956     if (likely(err == exc_type1 || err == exc_type2)) return 1;
4957     if (likely(PyExceptionClass_Check(err))) {
4958         return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
4959     }
4960     return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
4961 }
4962 #endif
4963 
4964 /* GetException */
4965 #if CYTHON_FAST_THREAD_STATE
__Pyx__GetException(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)4966 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
4967 #else
4968 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
4969 #endif
4970 {
4971     PyObject *local_type, *local_value, *local_tb;
4972 #if CYTHON_FAST_THREAD_STATE
4973     PyObject *tmp_type, *tmp_value, *tmp_tb;
4974     local_type = tstate->curexc_type;
4975     local_value = tstate->curexc_value;
4976     local_tb = tstate->curexc_traceback;
4977     tstate->curexc_type = 0;
4978     tstate->curexc_value = 0;
4979     tstate->curexc_traceback = 0;
4980 #else
4981     PyErr_Fetch(&local_type, &local_value, &local_tb);
4982 #endif
4983     PyErr_NormalizeException(&local_type, &local_value, &local_tb);
4984 #if CYTHON_FAST_THREAD_STATE
4985     if (unlikely(tstate->curexc_type))
4986 #else
4987     if (unlikely(PyErr_Occurred()))
4988 #endif
4989         goto bad;
4990     #if PY_MAJOR_VERSION >= 3
4991     if (local_tb) {
4992         if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
4993             goto bad;
4994     }
4995     #endif
4996     Py_XINCREF(local_tb);
4997     Py_XINCREF(local_type);
4998     Py_XINCREF(local_value);
4999     *type = local_type;
5000     *value = local_value;
5001     *tb = local_tb;
5002 #if CYTHON_FAST_THREAD_STATE
5003     #if CYTHON_USE_EXC_INFO_STACK
5004     {
5005         _PyErr_StackItem *exc_info = tstate->exc_info;
5006         tmp_type = exc_info->exc_type;
5007         tmp_value = exc_info->exc_value;
5008         tmp_tb = exc_info->exc_traceback;
5009         exc_info->exc_type = local_type;
5010         exc_info->exc_value = local_value;
5011         exc_info->exc_traceback = local_tb;
5012     }
5013     #else
5014     tmp_type = tstate->exc_type;
5015     tmp_value = tstate->exc_value;
5016     tmp_tb = tstate->exc_traceback;
5017     tstate->exc_type = local_type;
5018     tstate->exc_value = local_value;
5019     tstate->exc_traceback = local_tb;
5020     #endif
5021     Py_XDECREF(tmp_type);
5022     Py_XDECREF(tmp_value);
5023     Py_XDECREF(tmp_tb);
5024 #else
5025     PyErr_SetExcInfo(local_type, local_value, local_tb);
5026 #endif
5027     return 0;
5028 bad:
5029     *type = 0;
5030     *value = 0;
5031     *tb = 0;
5032     Py_XDECREF(local_type);
5033     Py_XDECREF(local_value);
5034     Py_XDECREF(local_tb);
5035     return -1;
5036 }
5037 
5038 /* decode_c_string */
__Pyx_decode_c_string(const char * cstring,Py_ssize_t start,Py_ssize_t stop,const char * encoding,const char * errors,PyObject * (* decode_func)(const char * s,Py_ssize_t size,const char * errors))5039 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
5040          const char* cstring, Py_ssize_t start, Py_ssize_t stop,
5041          const char* encoding, const char* errors,
5042          PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
5043     Py_ssize_t length;
5044     if (unlikely((start < 0) | (stop < 0))) {
5045         size_t slen = strlen(cstring);
5046         if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
5047             PyErr_SetString(PyExc_OverflowError,
5048                             "c-string too long to convert to Python");
5049             return NULL;
5050         }
5051         length = (Py_ssize_t) slen;
5052         if (start < 0) {
5053             start += length;
5054             if (start < 0)
5055                 start = 0;
5056         }
5057         if (stop < 0)
5058             stop += length;
5059     }
5060     if (unlikely(stop <= start))
5061         return __Pyx_NewRef(__pyx_empty_unicode);
5062     length = stop - start;
5063     cstring += start;
5064     if (decode_func) {
5065         return decode_func(cstring, length, errors);
5066     } else {
5067         return PyUnicode_Decode(cstring, length, encoding, errors);
5068     }
5069 }
5070 
5071 /* RaiseException */
5072 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)5073 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
5074                         CYTHON_UNUSED PyObject *cause) {
5075     __Pyx_PyThreadState_declare
5076     Py_XINCREF(type);
5077     if (!value || value == Py_None)
5078         value = NULL;
5079     else
5080         Py_INCREF(value);
5081     if (!tb || tb == Py_None)
5082         tb = NULL;
5083     else {
5084         Py_INCREF(tb);
5085         if (!PyTraceBack_Check(tb)) {
5086             PyErr_SetString(PyExc_TypeError,
5087                 "raise: arg 3 must be a traceback or None");
5088             goto raise_error;
5089         }
5090     }
5091     if (PyType_Check(type)) {
5092 #if CYTHON_COMPILING_IN_PYPY
5093         if (!value) {
5094             Py_INCREF(Py_None);
5095             value = Py_None;
5096         }
5097 #endif
5098         PyErr_NormalizeException(&type, &value, &tb);
5099     } else {
5100         if (value) {
5101             PyErr_SetString(PyExc_TypeError,
5102                 "instance exception may not have a separate value");
5103             goto raise_error;
5104         }
5105         value = type;
5106         type = (PyObject*) Py_TYPE(type);
5107         Py_INCREF(type);
5108         if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
5109             PyErr_SetString(PyExc_TypeError,
5110                 "raise: exception class must be a subclass of BaseException");
5111             goto raise_error;
5112         }
5113     }
5114     __Pyx_PyThreadState_assign
5115     __Pyx_ErrRestore(type, value, tb);
5116     return;
5117 raise_error:
5118     Py_XDECREF(value);
5119     Py_XDECREF(type);
5120     Py_XDECREF(tb);
5121     return;
5122 }
5123 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)5124 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
5125     PyObject* owned_instance = NULL;
5126     if (tb == Py_None) {
5127         tb = 0;
5128     } else if (tb && !PyTraceBack_Check(tb)) {
5129         PyErr_SetString(PyExc_TypeError,
5130             "raise: arg 3 must be a traceback or None");
5131         goto bad;
5132     }
5133     if (value == Py_None)
5134         value = 0;
5135     if (PyExceptionInstance_Check(type)) {
5136         if (value) {
5137             PyErr_SetString(PyExc_TypeError,
5138                 "instance exception may not have a separate value");
5139             goto bad;
5140         }
5141         value = type;
5142         type = (PyObject*) Py_TYPE(value);
5143     } else if (PyExceptionClass_Check(type)) {
5144         PyObject *instance_class = NULL;
5145         if (value && PyExceptionInstance_Check(value)) {
5146             instance_class = (PyObject*) Py_TYPE(value);
5147             if (instance_class != type) {
5148                 int is_subclass = PyObject_IsSubclass(instance_class, type);
5149                 if (!is_subclass) {
5150                     instance_class = NULL;
5151                 } else if (unlikely(is_subclass == -1)) {
5152                     goto bad;
5153                 } else {
5154                     type = instance_class;
5155                 }
5156             }
5157         }
5158         if (!instance_class) {
5159             PyObject *args;
5160             if (!value)
5161                 args = PyTuple_New(0);
5162             else if (PyTuple_Check(value)) {
5163                 Py_INCREF(value);
5164                 args = value;
5165             } else
5166                 args = PyTuple_Pack(1, value);
5167             if (!args)
5168                 goto bad;
5169             owned_instance = PyObject_Call(type, args, NULL);
5170             Py_DECREF(args);
5171             if (!owned_instance)
5172                 goto bad;
5173             value = owned_instance;
5174             if (!PyExceptionInstance_Check(value)) {
5175                 PyErr_Format(PyExc_TypeError,
5176                              "calling %R should have returned an instance of "
5177                              "BaseException, not %R",
5178                              type, Py_TYPE(value));
5179                 goto bad;
5180             }
5181         }
5182     } else {
5183         PyErr_SetString(PyExc_TypeError,
5184             "raise: exception class must be a subclass of BaseException");
5185         goto bad;
5186     }
5187     if (cause) {
5188         PyObject *fixed_cause;
5189         if (cause == Py_None) {
5190             fixed_cause = NULL;
5191         } else if (PyExceptionClass_Check(cause)) {
5192             fixed_cause = PyObject_CallObject(cause, NULL);
5193             if (fixed_cause == NULL)
5194                 goto bad;
5195         } else if (PyExceptionInstance_Check(cause)) {
5196             fixed_cause = cause;
5197             Py_INCREF(fixed_cause);
5198         } else {
5199             PyErr_SetString(PyExc_TypeError,
5200                             "exception causes must derive from "
5201                             "BaseException");
5202             goto bad;
5203         }
5204         PyException_SetCause(value, fixed_cause);
5205     }
5206     PyErr_SetObject(type, value);
5207     if (tb) {
5208 #if CYTHON_COMPILING_IN_PYPY
5209         PyObject *tmp_type, *tmp_value, *tmp_tb;
5210         PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
5211         Py_INCREF(tb);
5212         PyErr_Restore(tmp_type, tmp_value, tb);
5213         Py_XDECREF(tmp_tb);
5214 #else
5215         PyThreadState *tstate = __Pyx_PyThreadState_Current;
5216         PyObject* tmp_tb = tstate->curexc_traceback;
5217         if (tb != tmp_tb) {
5218             Py_INCREF(tb);
5219             tstate->curexc_traceback = tb;
5220             Py_XDECREF(tmp_tb);
5221         }
5222 #endif
5223     }
5224 bad:
5225     Py_XDECREF(owned_instance);
5226     return;
5227 }
5228 #endif
5229 
5230 /* SwapException */
5231 #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSwap(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)5232 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
5233     PyObject *tmp_type, *tmp_value, *tmp_tb;
5234     #if CYTHON_USE_EXC_INFO_STACK
5235     _PyErr_StackItem *exc_info = tstate->exc_info;
5236     tmp_type = exc_info->exc_type;
5237     tmp_value = exc_info->exc_value;
5238     tmp_tb = exc_info->exc_traceback;
5239     exc_info->exc_type = *type;
5240     exc_info->exc_value = *value;
5241     exc_info->exc_traceback = *tb;
5242     #else
5243     tmp_type = tstate->exc_type;
5244     tmp_value = tstate->exc_value;
5245     tmp_tb = tstate->exc_traceback;
5246     tstate->exc_type = *type;
5247     tstate->exc_value = *value;
5248     tstate->exc_traceback = *tb;
5249     #endif
5250     *type = tmp_type;
5251     *value = tmp_value;
5252     *tb = tmp_tb;
5253 }
5254 #else
__Pyx_ExceptionSwap(PyObject ** type,PyObject ** value,PyObject ** tb)5255 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
5256     PyObject *tmp_type, *tmp_value, *tmp_tb;
5257     PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
5258     PyErr_SetExcInfo(*type, *value, *tb);
5259     *type = tmp_type;
5260     *value = tmp_value;
5261     *tb = tmp_tb;
5262 }
5263 #endif
5264 
5265 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)5266 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
5267     PyObject *empty_list = 0;
5268     PyObject *module = 0;
5269     PyObject *global_dict = 0;
5270     PyObject *empty_dict = 0;
5271     PyObject *list;
5272     #if PY_MAJOR_VERSION < 3
5273     PyObject *py_import;
5274     py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
5275     if (!py_import)
5276         goto bad;
5277     #endif
5278     if (from_list)
5279         list = from_list;
5280     else {
5281         empty_list = PyList_New(0);
5282         if (!empty_list)
5283             goto bad;
5284         list = empty_list;
5285     }
5286     global_dict = PyModule_GetDict(__pyx_m);
5287     if (!global_dict)
5288         goto bad;
5289     empty_dict = PyDict_New();
5290     if (!empty_dict)
5291         goto bad;
5292     {
5293         #if PY_MAJOR_VERSION >= 3
5294         if (level == -1) {
5295             if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
5296                 module = PyImport_ImportModuleLevelObject(
5297                     name, global_dict, empty_dict, list, 1);
5298                 if (!module) {
5299                     if (!PyErr_ExceptionMatches(PyExc_ImportError))
5300                         goto bad;
5301                     PyErr_Clear();
5302                 }
5303             }
5304             level = 0;
5305         }
5306         #endif
5307         if (!module) {
5308             #if PY_MAJOR_VERSION < 3
5309             PyObject *py_level = PyInt_FromLong(level);
5310             if (!py_level)
5311                 goto bad;
5312             module = PyObject_CallFunctionObjArgs(py_import,
5313                 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
5314             Py_DECREF(py_level);
5315             #else
5316             module = PyImport_ImportModuleLevelObject(
5317                 name, global_dict, empty_dict, list, level);
5318             #endif
5319         }
5320     }
5321 bad:
5322     #if PY_MAJOR_VERSION < 3
5323     Py_XDECREF(py_import);
5324     #endif
5325     Py_XDECREF(empty_list);
5326     Py_XDECREF(empty_dict);
5327     return module;
5328 }
5329 
5330 /* ImportFrom */
__Pyx_ImportFrom(PyObject * module,PyObject * name)5331 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
5332     PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
5333     if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
5334         PyErr_Format(PyExc_ImportError,
5335         #if PY_MAJOR_VERSION < 3
5336             "cannot import name %.230s", PyString_AS_STRING(name));
5337         #else
5338             "cannot import name %S", name);
5339         #endif
5340     }
5341     return value;
5342 }
5343 
5344 /* CLineInTraceback */
5345 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)5346 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
5347     PyObject *use_cline;
5348     PyObject *ptype, *pvalue, *ptraceback;
5349 #if CYTHON_COMPILING_IN_CPYTHON
5350     PyObject **cython_runtime_dict;
5351 #endif
5352     if (unlikely(!__pyx_cython_runtime)) {
5353         return c_line;
5354     }
5355     __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
5356 #if CYTHON_COMPILING_IN_CPYTHON
5357     cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
5358     if (likely(cython_runtime_dict)) {
5359         __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
5360             use_cline, *cython_runtime_dict,
5361             __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
5362     } else
5363 #endif
5364     {
5365       PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
5366       if (use_cline_obj) {
5367         use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
5368         Py_DECREF(use_cline_obj);
5369       } else {
5370         PyErr_Clear();
5371         use_cline = NULL;
5372       }
5373     }
5374     if (!use_cline) {
5375         c_line = 0;
5376         PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
5377     }
5378     else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
5379         c_line = 0;
5380     }
5381     __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
5382     return c_line;
5383 }
5384 #endif
5385 
5386 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)5387 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
5388     int start = 0, mid = 0, end = count - 1;
5389     if (end >= 0 && code_line > entries[end].code_line) {
5390         return count;
5391     }
5392     while (start < end) {
5393         mid = start + (end - start) / 2;
5394         if (code_line < entries[mid].code_line) {
5395             end = mid;
5396         } else if (code_line > entries[mid].code_line) {
5397              start = mid + 1;
5398         } else {
5399             return mid;
5400         }
5401     }
5402     if (code_line <= entries[mid].code_line) {
5403         return mid;
5404     } else {
5405         return mid + 1;
5406     }
5407 }
__pyx_find_code_object(int code_line)5408 static PyCodeObject *__pyx_find_code_object(int code_line) {
5409     PyCodeObject* code_object;
5410     int pos;
5411     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
5412         return NULL;
5413     }
5414     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
5415     if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
5416         return NULL;
5417     }
5418     code_object = __pyx_code_cache.entries[pos].code_object;
5419     Py_INCREF(code_object);
5420     return code_object;
5421 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)5422 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
5423     int pos, i;
5424     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
5425     if (unlikely(!code_line)) {
5426         return;
5427     }
5428     if (unlikely(!entries)) {
5429         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
5430         if (likely(entries)) {
5431             __pyx_code_cache.entries = entries;
5432             __pyx_code_cache.max_count = 64;
5433             __pyx_code_cache.count = 1;
5434             entries[0].code_line = code_line;
5435             entries[0].code_object = code_object;
5436             Py_INCREF(code_object);
5437         }
5438         return;
5439     }
5440     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
5441     if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
5442         PyCodeObject* tmp = entries[pos].code_object;
5443         entries[pos].code_object = code_object;
5444         Py_DECREF(tmp);
5445         return;
5446     }
5447     if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
5448         int new_max = __pyx_code_cache.max_count + 64;
5449         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
5450             __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
5451         if (unlikely(!entries)) {
5452             return;
5453         }
5454         __pyx_code_cache.entries = entries;
5455         __pyx_code_cache.max_count = new_max;
5456     }
5457     for (i=__pyx_code_cache.count; i>pos; i--) {
5458         entries[i] = entries[i-1];
5459     }
5460     entries[pos].code_line = code_line;
5461     entries[pos].code_object = code_object;
5462     __pyx_code_cache.count++;
5463     Py_INCREF(code_object);
5464 }
5465 
5466 /* AddTraceback */
5467 #include "compile.h"
5468 #include "frameobject.h"
5469 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)5470 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
5471             const char *funcname, int c_line,
5472             int py_line, const char *filename) {
5473     PyCodeObject *py_code = 0;
5474     PyObject *py_srcfile = 0;
5475     PyObject *py_funcname = 0;
5476     #if PY_MAJOR_VERSION < 3
5477     py_srcfile = PyString_FromString(filename);
5478     #else
5479     py_srcfile = PyUnicode_FromString(filename);
5480     #endif
5481     if (!py_srcfile) goto bad;
5482     if (c_line) {
5483         #if PY_MAJOR_VERSION < 3
5484         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
5485         #else
5486         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
5487         #endif
5488     }
5489     else {
5490         #if PY_MAJOR_VERSION < 3
5491         py_funcname = PyString_FromString(funcname);
5492         #else
5493         py_funcname = PyUnicode_FromString(funcname);
5494         #endif
5495     }
5496     if (!py_funcname) goto bad;
5497     py_code = __Pyx_PyCode_New(
5498         0,
5499         0,
5500         0,
5501         0,
5502         0,
5503         __pyx_empty_bytes, /*PyObject *code,*/
5504         __pyx_empty_tuple, /*PyObject *consts,*/
5505         __pyx_empty_tuple, /*PyObject *names,*/
5506         __pyx_empty_tuple, /*PyObject *varnames,*/
5507         __pyx_empty_tuple, /*PyObject *freevars,*/
5508         __pyx_empty_tuple, /*PyObject *cellvars,*/
5509         py_srcfile,   /*PyObject *filename,*/
5510         py_funcname,  /*PyObject *name,*/
5511         py_line,
5512         __pyx_empty_bytes  /*PyObject *lnotab*/
5513     );
5514     Py_DECREF(py_srcfile);
5515     Py_DECREF(py_funcname);
5516     return py_code;
5517 bad:
5518     Py_XDECREF(py_srcfile);
5519     Py_XDECREF(py_funcname);
5520     return NULL;
5521 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)5522 static void __Pyx_AddTraceback(const char *funcname, int c_line,
5523                                int py_line, const char *filename) {
5524     PyCodeObject *py_code = 0;
5525     PyFrameObject *py_frame = 0;
5526     PyThreadState *tstate = __Pyx_PyThreadState_Current;
5527     if (c_line) {
5528         c_line = __Pyx_CLineForTraceback(tstate, c_line);
5529     }
5530     py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
5531     if (!py_code) {
5532         py_code = __Pyx_CreateCodeObjectForTraceback(
5533             funcname, c_line, py_line, filename);
5534         if (!py_code) goto bad;
5535         __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
5536     }
5537     py_frame = PyFrame_New(
5538         tstate,            /*PyThreadState *tstate,*/
5539         py_code,           /*PyCodeObject *code,*/
5540         __pyx_d,    /*PyObject *globals,*/
5541         0                  /*PyObject *locals*/
5542     );
5543     if (!py_frame) goto bad;
5544     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
5545     PyTraceBack_Here(py_frame);
5546 bad:
5547     Py_XDECREF(py_code);
5548     Py_XDECREF(py_frame);
5549 }
5550 
5551 /* CIntToPy */
__Pyx_PyInt_From_int(int value)5552 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
5553     const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
5554     const int is_unsigned = neg_one > const_zero;
5555     if (is_unsigned) {
5556         if (sizeof(int) < sizeof(long)) {
5557             return PyInt_FromLong((long) value);
5558         } else if (sizeof(int) <= sizeof(unsigned long)) {
5559             return PyLong_FromUnsignedLong((unsigned long) value);
5560 #ifdef HAVE_LONG_LONG
5561         } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
5562             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
5563 #endif
5564         }
5565     } else {
5566         if (sizeof(int) <= sizeof(long)) {
5567             return PyInt_FromLong((long) value);
5568 #ifdef HAVE_LONG_LONG
5569         } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
5570             return PyLong_FromLongLong((PY_LONG_LONG) value);
5571 #endif
5572         }
5573     }
5574     {
5575         int one = 1; int little = (int)*(unsigned char *)&one;
5576         unsigned char *bytes = (unsigned char *)&value;
5577         return _PyLong_FromByteArray(bytes, sizeof(int),
5578                                      little, !is_unsigned);
5579     }
5580 }
5581 
5582 /* CIntFromPyVerify */
5583 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
5584     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
5585 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
5586     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
5587 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
5588     {\
5589         func_type value = func_value;\
5590         if (sizeof(target_type) < sizeof(func_type)) {\
5591             if (unlikely(value != (func_type) (target_type) value)) {\
5592                 func_type zero = 0;\
5593                 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
5594                     return (target_type) -1;\
5595                 if (is_unsigned && unlikely(value < zero))\
5596                     goto raise_neg_overflow;\
5597                 else\
5598                     goto raise_overflow;\
5599             }\
5600         }\
5601         return (target_type) value;\
5602     }
5603 
5604 /* CIntFromPy */
__Pyx_PyInt_As_unsigned_int(PyObject * x)5605 static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) {
5606     const unsigned int neg_one = (unsigned int) ((unsigned int) 0 - (unsigned int) 1), const_zero = (unsigned int) 0;
5607     const int is_unsigned = neg_one > const_zero;
5608 #if PY_MAJOR_VERSION < 3
5609     if (likely(PyInt_Check(x))) {
5610         if (sizeof(unsigned int) < sizeof(long)) {
5611             __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x))
5612         } else {
5613             long val = PyInt_AS_LONG(x);
5614             if (is_unsigned && unlikely(val < 0)) {
5615                 goto raise_neg_overflow;
5616             }
5617             return (unsigned int) val;
5618         }
5619     } else
5620 #endif
5621     if (likely(PyLong_Check(x))) {
5622         if (is_unsigned) {
5623 #if CYTHON_USE_PYLONG_INTERNALS
5624             const digit* digits = ((PyLongObject*)x)->ob_digit;
5625             switch (Py_SIZE(x)) {
5626                 case  0: return (unsigned int) 0;
5627                 case  1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0])
5628                 case 2:
5629                     if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
5630                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5631                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5632                         } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) {
5633                             return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
5634                         }
5635                     }
5636                     break;
5637                 case 3:
5638                     if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
5639                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5640                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5641                         } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) {
5642                             return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
5643                         }
5644                     }
5645                     break;
5646                 case 4:
5647                     if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
5648                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5649                             __PYX_VERIFY_RETURN_INT(unsigned 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])))
5650                         } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) {
5651                             return (unsigned int) (((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]));
5652                         }
5653                     }
5654                     break;
5655             }
5656 #endif
5657 #if CYTHON_COMPILING_IN_CPYTHON
5658             if (unlikely(Py_SIZE(x) < 0)) {
5659                 goto raise_neg_overflow;
5660             }
5661 #else
5662             {
5663                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
5664                 if (unlikely(result < 0))
5665                     return (unsigned int) -1;
5666                 if (unlikely(result == 1))
5667                     goto raise_neg_overflow;
5668             }
5669 #endif
5670             if (sizeof(unsigned int) <= sizeof(unsigned long)) {
5671                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x))
5672 #ifdef HAVE_LONG_LONG
5673             } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
5674                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
5675 #endif
5676             }
5677         } else {
5678 #if CYTHON_USE_PYLONG_INTERNALS
5679             const digit* digits = ((PyLongObject*)x)->ob_digit;
5680             switch (Py_SIZE(x)) {
5681                 case  0: return (unsigned int) 0;
5682                 case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, (sdigit) (-(sdigit)digits[0]))
5683                 case  1: __PYX_VERIFY_RETURN_INT(unsigned int,  digit, +digits[0])
5684                 case -2:
5685                     if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) {
5686                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5687                             __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5688                         } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
5689                             return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
5690                         }
5691                     }
5692                     break;
5693                 case 2:
5694                     if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) {
5695                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5696                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5697                         } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
5698                             return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
5699                         }
5700                     }
5701                     break;
5702                 case -3:
5703                     if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) {
5704                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5705                             __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5706                         } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
5707                             return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
5708                         }
5709                     }
5710                     break;
5711                 case 3:
5712                     if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) {
5713                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5714                             __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5715                         } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
5716                             return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
5717                         }
5718                     }
5719                     break;
5720                 case -4:
5721                     if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) {
5722                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5723                             __PYX_VERIFY_RETURN_INT(unsigned 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])))
5724                         } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
5725                             return (unsigned int) (((unsigned int)-1)*(((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
5726                         }
5727                     }
5728                     break;
5729                 case 4:
5730                     if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) {
5731                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5732                             __PYX_VERIFY_RETURN_INT(unsigned 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])))
5733                         } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) {
5734                             return (unsigned int) ((((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])));
5735                         }
5736                     }
5737                     break;
5738             }
5739 #endif
5740             if (sizeof(unsigned int) <= sizeof(long)) {
5741                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x))
5742 #ifdef HAVE_LONG_LONG
5743             } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
5744                 __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x))
5745 #endif
5746             }
5747         }
5748         {
5749 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
5750             PyErr_SetString(PyExc_RuntimeError,
5751                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
5752 #else
5753             unsigned int val;
5754             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
5755  #if PY_MAJOR_VERSION < 3
5756             if (likely(v) && !PyLong_Check(v)) {
5757                 PyObject *tmp = v;
5758                 v = PyNumber_Long(tmp);
5759                 Py_DECREF(tmp);
5760             }
5761  #endif
5762             if (likely(v)) {
5763                 int one = 1; int is_little = (int)*(unsigned char *)&one;
5764                 unsigned char *bytes = (unsigned char *)&val;
5765                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
5766                                               bytes, sizeof(val),
5767                                               is_little, !is_unsigned);
5768                 Py_DECREF(v);
5769                 if (likely(!ret))
5770                     return val;
5771             }
5772 #endif
5773             return (unsigned int) -1;
5774         }
5775     } else {
5776         unsigned int val;
5777         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
5778         if (!tmp) return (unsigned int) -1;
5779         val = __Pyx_PyInt_As_unsigned_int(tmp);
5780         Py_DECREF(tmp);
5781         return val;
5782     }
5783 raise_overflow:
5784     PyErr_SetString(PyExc_OverflowError,
5785         "value too large to convert to unsigned int");
5786     return (unsigned int) -1;
5787 raise_neg_overflow:
5788     PyErr_SetString(PyExc_OverflowError,
5789         "can't convert negative value to unsigned int");
5790     return (unsigned int) -1;
5791 }
5792 
5793 /* CIntToPy */
__Pyx_PyInt_From_long(long value)5794 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
5795     const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
5796     const int is_unsigned = neg_one > const_zero;
5797     if (is_unsigned) {
5798         if (sizeof(long) < sizeof(long)) {
5799             return PyInt_FromLong((long) value);
5800         } else if (sizeof(long) <= sizeof(unsigned long)) {
5801             return PyLong_FromUnsignedLong((unsigned long) value);
5802 #ifdef HAVE_LONG_LONG
5803         } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
5804             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
5805 #endif
5806         }
5807     } else {
5808         if (sizeof(long) <= sizeof(long)) {
5809             return PyInt_FromLong((long) value);
5810 #ifdef HAVE_LONG_LONG
5811         } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
5812             return PyLong_FromLongLong((PY_LONG_LONG) value);
5813 #endif
5814         }
5815     }
5816     {
5817         int one = 1; int little = (int)*(unsigned char *)&one;
5818         unsigned char *bytes = (unsigned char *)&value;
5819         return _PyLong_FromByteArray(bytes, sizeof(long),
5820                                      little, !is_unsigned);
5821     }
5822 }
5823 
5824 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)5825 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
5826     const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
5827     const int is_unsigned = neg_one > const_zero;
5828 #if PY_MAJOR_VERSION < 3
5829     if (likely(PyInt_Check(x))) {
5830         if (sizeof(long) < sizeof(long)) {
5831             __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
5832         } else {
5833             long val = PyInt_AS_LONG(x);
5834             if (is_unsigned && unlikely(val < 0)) {
5835                 goto raise_neg_overflow;
5836             }
5837             return (long) val;
5838         }
5839     } else
5840 #endif
5841     if (likely(PyLong_Check(x))) {
5842         if (is_unsigned) {
5843 #if CYTHON_USE_PYLONG_INTERNALS
5844             const digit* digits = ((PyLongObject*)x)->ob_digit;
5845             switch (Py_SIZE(x)) {
5846                 case  0: return (long) 0;
5847                 case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
5848                 case 2:
5849                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
5850                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5851                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5852                         } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
5853                             return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
5854                         }
5855                     }
5856                     break;
5857                 case 3:
5858                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
5859                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5860                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5861                         } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
5862                             return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
5863                         }
5864                     }
5865                     break;
5866                 case 4:
5867                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
5868                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5869                             __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])))
5870                         } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
5871                             return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
5872                         }
5873                     }
5874                     break;
5875             }
5876 #endif
5877 #if CYTHON_COMPILING_IN_CPYTHON
5878             if (unlikely(Py_SIZE(x) < 0)) {
5879                 goto raise_neg_overflow;
5880             }
5881 #else
5882             {
5883                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
5884                 if (unlikely(result < 0))
5885                     return (long) -1;
5886                 if (unlikely(result == 1))
5887                     goto raise_neg_overflow;
5888             }
5889 #endif
5890             if (sizeof(long) <= sizeof(unsigned long)) {
5891                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
5892 #ifdef HAVE_LONG_LONG
5893             } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
5894                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
5895 #endif
5896             }
5897         } else {
5898 #if CYTHON_USE_PYLONG_INTERNALS
5899             const digit* digits = ((PyLongObject*)x)->ob_digit;
5900             switch (Py_SIZE(x)) {
5901                 case  0: return (long) 0;
5902                 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
5903                 case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
5904                 case -2:
5905                     if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
5906                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5907                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5908                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
5909                             return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5910                         }
5911                     }
5912                     break;
5913                 case 2:
5914                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
5915                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5916                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5917                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
5918                             return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5919                         }
5920                     }
5921                     break;
5922                 case -3:
5923                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
5924                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5925                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5926                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5927                             return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5928                         }
5929                     }
5930                     break;
5931                 case 3:
5932                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
5933                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5934                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5935                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5936                             return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5937                         }
5938                     }
5939                     break;
5940                 case -4:
5941                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5942                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5943                             __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])))
5944                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
5945                             return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5946                         }
5947                     }
5948                     break;
5949                 case 4:
5950                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
5951                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5952                             __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])))
5953                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
5954                             return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5955                         }
5956                     }
5957                     break;
5958             }
5959 #endif
5960             if (sizeof(long) <= sizeof(long)) {
5961                 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
5962 #ifdef HAVE_LONG_LONG
5963             } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
5964                 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
5965 #endif
5966             }
5967         }
5968         {
5969 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
5970             PyErr_SetString(PyExc_RuntimeError,
5971                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
5972 #else
5973             long val;
5974             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
5975  #if PY_MAJOR_VERSION < 3
5976             if (likely(v) && !PyLong_Check(v)) {
5977                 PyObject *tmp = v;
5978                 v = PyNumber_Long(tmp);
5979                 Py_DECREF(tmp);
5980             }
5981  #endif
5982             if (likely(v)) {
5983                 int one = 1; int is_little = (int)*(unsigned char *)&one;
5984                 unsigned char *bytes = (unsigned char *)&val;
5985                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
5986                                               bytes, sizeof(val),
5987                                               is_little, !is_unsigned);
5988                 Py_DECREF(v);
5989                 if (likely(!ret))
5990                     return val;
5991             }
5992 #endif
5993             return (long) -1;
5994         }
5995     } else {
5996         long val;
5997         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
5998         if (!tmp) return (long) -1;
5999         val = __Pyx_PyInt_As_long(tmp);
6000         Py_DECREF(tmp);
6001         return val;
6002     }
6003 raise_overflow:
6004     PyErr_SetString(PyExc_OverflowError,
6005         "value too large to convert to long");
6006     return (long) -1;
6007 raise_neg_overflow:
6008     PyErr_SetString(PyExc_OverflowError,
6009         "can't convert negative value to long");
6010     return (long) -1;
6011 }
6012 
6013 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)6014 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
6015     const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
6016     const int is_unsigned = neg_one > const_zero;
6017 #if PY_MAJOR_VERSION < 3
6018     if (likely(PyInt_Check(x))) {
6019         if (sizeof(int) < sizeof(long)) {
6020             __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
6021         } else {
6022             long val = PyInt_AS_LONG(x);
6023             if (is_unsigned && unlikely(val < 0)) {
6024                 goto raise_neg_overflow;
6025             }
6026             return (int) val;
6027         }
6028     } else
6029 #endif
6030     if (likely(PyLong_Check(x))) {
6031         if (is_unsigned) {
6032 #if CYTHON_USE_PYLONG_INTERNALS
6033             const digit* digits = ((PyLongObject*)x)->ob_digit;
6034             switch (Py_SIZE(x)) {
6035                 case  0: return (int) 0;
6036                 case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
6037                 case 2:
6038                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
6039                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6040                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6041                         } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
6042                             return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
6043                         }
6044                     }
6045                     break;
6046                 case 3:
6047                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
6048                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6049                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6050                         } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
6051                             return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
6052                         }
6053                     }
6054                     break;
6055                 case 4:
6056                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
6057                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6058                             __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])))
6059                         } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
6060                             return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
6061                         }
6062                     }
6063                     break;
6064             }
6065 #endif
6066 #if CYTHON_COMPILING_IN_CPYTHON
6067             if (unlikely(Py_SIZE(x) < 0)) {
6068                 goto raise_neg_overflow;
6069             }
6070 #else
6071             {
6072                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
6073                 if (unlikely(result < 0))
6074                     return (int) -1;
6075                 if (unlikely(result == 1))
6076                     goto raise_neg_overflow;
6077             }
6078 #endif
6079             if (sizeof(int) <= sizeof(unsigned long)) {
6080                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
6081 #ifdef HAVE_LONG_LONG
6082             } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
6083                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
6084 #endif
6085             }
6086         } else {
6087 #if CYTHON_USE_PYLONG_INTERNALS
6088             const digit* digits = ((PyLongObject*)x)->ob_digit;
6089             switch (Py_SIZE(x)) {
6090                 case  0: return (int) 0;
6091                 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
6092                 case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
6093                 case -2:
6094                     if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
6095                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6096                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6097                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
6098                             return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
6099                         }
6100                     }
6101                     break;
6102                 case 2:
6103                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
6104                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6105                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6106                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
6107                             return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
6108                         }
6109                     }
6110                     break;
6111                 case -3:
6112                     if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
6113                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6114                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6115                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
6116                             return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
6117                         }
6118                     }
6119                     break;
6120                 case 3:
6121                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
6122                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6123                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6124                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
6125                             return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
6126                         }
6127                     }
6128                     break;
6129                 case -4:
6130                     if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
6131                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6132                             __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])))
6133                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
6134                             return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
6135                         }
6136                     }
6137                     break;
6138                 case 4:
6139                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
6140                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6141                             __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])))
6142                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
6143                             return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
6144                         }
6145                     }
6146                     break;
6147             }
6148 #endif
6149             if (sizeof(int) <= sizeof(long)) {
6150                 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
6151 #ifdef HAVE_LONG_LONG
6152             } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
6153                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
6154 #endif
6155             }
6156         }
6157         {
6158 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
6159             PyErr_SetString(PyExc_RuntimeError,
6160                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
6161 #else
6162             int val;
6163             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
6164  #if PY_MAJOR_VERSION < 3
6165             if (likely(v) && !PyLong_Check(v)) {
6166                 PyObject *tmp = v;
6167                 v = PyNumber_Long(tmp);
6168                 Py_DECREF(tmp);
6169             }
6170  #endif
6171             if (likely(v)) {
6172                 int one = 1; int is_little = (int)*(unsigned char *)&one;
6173                 unsigned char *bytes = (unsigned char *)&val;
6174                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
6175                                               bytes, sizeof(val),
6176                                               is_little, !is_unsigned);
6177                 Py_DECREF(v);
6178                 if (likely(!ret))
6179                     return val;
6180             }
6181 #endif
6182             return (int) -1;
6183         }
6184     } else {
6185         int val;
6186         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
6187         if (!tmp) return (int) -1;
6188         val = __Pyx_PyInt_As_int(tmp);
6189         Py_DECREF(tmp);
6190         return val;
6191     }
6192 raise_overflow:
6193     PyErr_SetString(PyExc_OverflowError,
6194         "value too large to convert to int");
6195     return (int) -1;
6196 raise_neg_overflow:
6197     PyErr_SetString(PyExc_OverflowError,
6198         "can't convert negative value to int");
6199     return (int) -1;
6200 }
6201 
6202 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)6203 static int __Pyx_check_binary_version(void) {
6204     char ctversion[4], rtversion[4];
6205     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
6206     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
6207     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
6208         char message[200];
6209         PyOS_snprintf(message, sizeof(message),
6210                       "compiletime version %s of module '%.100s' "
6211                       "does not match runtime version %s",
6212                       ctversion, __Pyx_MODULE_NAME, rtversion);
6213         return PyErr_WarnEx(NULL, message, 1);
6214     }
6215     return 0;
6216 }
6217 
6218 /* FunctionExport */
__Pyx_ExportFunction(const char * name,void (* f)(void),const char * sig)6219 static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
6220     PyObject *d = 0;
6221     PyObject *cobj = 0;
6222     union {
6223         void (*fp)(void);
6224         void *p;
6225     } tmp;
6226     d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
6227     if (!d) {
6228         PyErr_Clear();
6229         d = PyDict_New();
6230         if (!d)
6231             goto bad;
6232         Py_INCREF(d);
6233         if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
6234             goto bad;
6235     }
6236     tmp.fp = f;
6237 #if PY_VERSION_HEX >= 0x02070000
6238     cobj = PyCapsule_New(tmp.p, sig, 0);
6239 #else
6240     cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
6241 #endif
6242     if (!cobj)
6243         goto bad;
6244     if (PyDict_SetItemString(d, name, cobj) < 0)
6245         goto bad;
6246     Py_DECREF(cobj);
6247     Py_DECREF(d);
6248     return 0;
6249 bad:
6250     Py_XDECREF(cobj);
6251     Py_XDECREF(d);
6252     return -1;
6253 }
6254 
6255 /* FunctionImport */
6256 #ifndef __PYX_HAVE_RT_ImportFunction
6257 #define __PYX_HAVE_RT_ImportFunction
__Pyx_ImportFunction(PyObject * module,const char * funcname,void (** f)(void),const char * sig)6258 static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
6259     PyObject *d = 0;
6260     PyObject *cobj = 0;
6261     union {
6262         void (*fp)(void);
6263         void *p;
6264     } tmp;
6265     d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
6266     if (!d)
6267         goto bad;
6268     cobj = PyDict_GetItemString(d, funcname);
6269     if (!cobj) {
6270         PyErr_Format(PyExc_ImportError,
6271             "%.200s does not export expected C function %.200s",
6272                 PyModule_GetName(module), funcname);
6273         goto bad;
6274     }
6275 #if PY_VERSION_HEX >= 0x02070000
6276     if (!PyCapsule_IsValid(cobj, sig)) {
6277         PyErr_Format(PyExc_TypeError,
6278             "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
6279              PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
6280         goto bad;
6281     }
6282     tmp.p = PyCapsule_GetPointer(cobj, sig);
6283 #else
6284     {const char *desc, *s1, *s2;
6285     desc = (const char *)PyCObject_GetDesc(cobj);
6286     if (!desc)
6287         goto bad;
6288     s1 = desc; s2 = sig;
6289     while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
6290     if (*s1 != *s2) {
6291         PyErr_Format(PyExc_TypeError,
6292             "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
6293              PyModule_GetName(module), funcname, sig, desc);
6294         goto bad;
6295     }
6296     tmp.p = PyCObject_AsVoidPtr(cobj);}
6297 #endif
6298     *f = tmp.fp;
6299     if (!(*f))
6300         goto bad;
6301     Py_DECREF(d);
6302     return 0;
6303 bad:
6304     Py_XDECREF(d);
6305     return -1;
6306 }
6307 #endif
6308 
6309 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)6310 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
6311     while (t->p) {
6312         #if PY_MAJOR_VERSION < 3
6313         if (t->is_unicode) {
6314             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
6315         } else if (t->intern) {
6316             *t->p = PyString_InternFromString(t->s);
6317         } else {
6318             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
6319         }
6320         #else
6321         if (t->is_unicode | t->is_str) {
6322             if (t->intern) {
6323                 *t->p = PyUnicode_InternFromString(t->s);
6324             } else if (t->encoding) {
6325                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
6326             } else {
6327                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
6328             }
6329         } else {
6330             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
6331         }
6332         #endif
6333         if (!*t->p)
6334             return -1;
6335         if (PyObject_Hash(*t->p) == -1)
6336             return -1;
6337         ++t;
6338     }
6339     return 0;
6340 }
6341 
__Pyx_PyUnicode_FromString(const char * c_str)6342 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
6343     return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
6344 }
__Pyx_PyObject_AsString(PyObject * o)6345 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
6346     Py_ssize_t ignore;
6347     return __Pyx_PyObject_AsStringAndSize(o, &ignore);
6348 }
6349 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
6350 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)6351 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
6352     char* defenc_c;
6353     PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
6354     if (!defenc) return NULL;
6355     defenc_c = PyBytes_AS_STRING(defenc);
6356 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
6357     {
6358         char* end = defenc_c + PyBytes_GET_SIZE(defenc);
6359         char* c;
6360         for (c = defenc_c; c < end; c++) {
6361             if ((unsigned char) (*c) >= 128) {
6362                 PyUnicode_AsASCIIString(o);
6363                 return NULL;
6364             }
6365         }
6366     }
6367 #endif
6368     *length = PyBytes_GET_SIZE(defenc);
6369     return defenc_c;
6370 }
6371 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)6372 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
6373     if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
6374 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
6375     if (likely(PyUnicode_IS_ASCII(o))) {
6376         *length = PyUnicode_GET_LENGTH(o);
6377         return PyUnicode_AsUTF8(o);
6378     } else {
6379         PyUnicode_AsASCIIString(o);
6380         return NULL;
6381     }
6382 #else
6383     return PyUnicode_AsUTF8AndSize(o, length);
6384 #endif
6385 }
6386 #endif
6387 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)6388 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
6389 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
6390     if (
6391 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
6392             __Pyx_sys_getdefaultencoding_not_ascii &&
6393 #endif
6394             PyUnicode_Check(o)) {
6395         return __Pyx_PyUnicode_AsStringAndSize(o, length);
6396     } else
6397 #endif
6398 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
6399     if (PyByteArray_Check(o)) {
6400         *length = PyByteArray_GET_SIZE(o);
6401         return PyByteArray_AS_STRING(o);
6402     } else
6403 #endif
6404     {
6405         char* result;
6406         int r = PyBytes_AsStringAndSize(o, &result, length);
6407         if (unlikely(r < 0)) {
6408             return NULL;
6409         } else {
6410             return result;
6411         }
6412     }
6413 }
__Pyx_PyObject_IsTrue(PyObject * x)6414 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
6415    int is_true = x == Py_True;
6416    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
6417    else return PyObject_IsTrue(x);
6418 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)6419 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
6420     int retval;
6421     if (unlikely(!x)) return -1;
6422     retval = __Pyx_PyObject_IsTrue(x);
6423     Py_DECREF(x);
6424     return retval;
6425 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)6426 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
6427 #if PY_MAJOR_VERSION >= 3
6428     if (PyLong_Check(result)) {
6429         if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
6430                 "__int__ returned non-int (type %.200s).  "
6431                 "The ability to return an instance of a strict subclass of int "
6432                 "is deprecated, and may be removed in a future version of Python.",
6433                 Py_TYPE(result)->tp_name)) {
6434             Py_DECREF(result);
6435             return NULL;
6436         }
6437         return result;
6438     }
6439 #endif
6440     PyErr_Format(PyExc_TypeError,
6441                  "__%.4s__ returned non-%.4s (type %.200s)",
6442                  type_name, type_name, Py_TYPE(result)->tp_name);
6443     Py_DECREF(result);
6444     return NULL;
6445 }
__Pyx_PyNumber_IntOrLong(PyObject * x)6446 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
6447 #if CYTHON_USE_TYPE_SLOTS
6448   PyNumberMethods *m;
6449 #endif
6450   const char *name = NULL;
6451   PyObject *res = NULL;
6452 #if PY_MAJOR_VERSION < 3
6453   if (likely(PyInt_Check(x) || PyLong_Check(x)))
6454 #else
6455   if (likely(PyLong_Check(x)))
6456 #endif
6457     return __Pyx_NewRef(x);
6458 #if CYTHON_USE_TYPE_SLOTS
6459   m = Py_TYPE(x)->tp_as_number;
6460   #if PY_MAJOR_VERSION < 3
6461   if (m && m->nb_int) {
6462     name = "int";
6463     res = m->nb_int(x);
6464   }
6465   else if (m && m->nb_long) {
6466     name = "long";
6467     res = m->nb_long(x);
6468   }
6469   #else
6470   if (likely(m && m->nb_int)) {
6471     name = "int";
6472     res = m->nb_int(x);
6473   }
6474   #endif
6475 #else
6476   if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
6477     res = PyNumber_Int(x);
6478   }
6479 #endif
6480   if (likely(res)) {
6481 #if PY_MAJOR_VERSION < 3
6482     if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
6483 #else
6484     if (unlikely(!PyLong_CheckExact(res))) {
6485 #endif
6486         return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
6487     }
6488   }
6489   else if (!PyErr_Occurred()) {
6490     PyErr_SetString(PyExc_TypeError,
6491                     "an integer is required");
6492   }
6493   return res;
6494 }
6495 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
6496   Py_ssize_t ival;
6497   PyObject *x;
6498 #if PY_MAJOR_VERSION < 3
6499   if (likely(PyInt_CheckExact(b))) {
6500     if (sizeof(Py_ssize_t) >= sizeof(long))
6501         return PyInt_AS_LONG(b);
6502     else
6503         return PyInt_AsSsize_t(b);
6504   }
6505 #endif
6506   if (likely(PyLong_CheckExact(b))) {
6507     #if CYTHON_USE_PYLONG_INTERNALS
6508     const digit* digits = ((PyLongObject*)b)->ob_digit;
6509     const Py_ssize_t size = Py_SIZE(b);
6510     if (likely(__Pyx_sst_abs(size) <= 1)) {
6511         ival = likely(size) ? digits[0] : 0;
6512         if (size == -1) ival = -ival;
6513         return ival;
6514     } else {
6515       switch (size) {
6516          case 2:
6517            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
6518              return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6519            }
6520            break;
6521          case -2:
6522            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
6523              return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6524            }
6525            break;
6526          case 3:
6527            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
6528              return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6529            }
6530            break;
6531          case -3:
6532            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
6533              return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6534            }
6535            break;
6536          case 4:
6537            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
6538              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]));
6539            }
6540            break;
6541          case -4:
6542            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
6543              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]));
6544            }
6545            break;
6546       }
6547     }
6548     #endif
6549     return PyLong_AsSsize_t(b);
6550   }
6551   x = PyNumber_Index(b);
6552   if (!x) return -1;
6553   ival = PyInt_AsSsize_t(x);
6554   Py_DECREF(x);
6555   return ival;
6556 }
6557 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
6558   return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
6559 }
6560 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
6561     return PyInt_FromSize_t(ival);
6562 }
6563 
6564 
6565 #endif /* Py_PYTHON_H */
6566