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