Spaces:
Runtime error
Runtime error
| /* Generated by Cython 3.0.0 */ | |
| /* BEGIN: Cython Metadata | |
| { | |
| "distutils": { | |
| "name": "box.exceptions", | |
| "sources": [ | |
| "box/exceptions.py" | |
| ] | |
| }, | |
| "module_name": "box.exceptions" | |
| } | |
| END: Cython Metadata */ | |
| /* For very preliminary testing purposes. Most variables are set the same as PyPy. | |
| The existence of this section does not imply that anything works or is even tested */ | |
| enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; | |
| /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17 | |
| * but leads to warnings with -pedantic, since it is a C++17 feature */ | |
| template<class T> void CYTHON_UNUSED_VAR( const T& ) { } | |
| typedef unsigned char uint8_t; | |
| typedef unsigned short uint16_t; | |
| typedef unsigned int uint32_t; | |
| typedef unsigned __int8 uint8_t; | |
| typedef unsigned __int16 uint16_t; | |
| typedef unsigned __int32 uint32_t; | |
| typedef unsigned long long __pyx_uintptr_t; | |
| typedef unsigned int __pyx_uintptr_t; | |
| typedef unsigned __int64 __pyx_uintptr_t; | |
| typedef unsigned __int32 __pyx_uintptr_t; | |
| typedef uintptr_t __pyx_uintptr_t; | |
| /* for clang __has_cpp_attribute(fallthrough) is true even before C++17 | |
| * but leads to warnings with -pedantic, since it is a C++17 feature */ | |
| template <typename T> | |
| struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);}; | |
| static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int p, int k, int l, int s, int f, | |
| PyObject *code, PyObject *c, PyObject* n, PyObject *v, | |
| PyObject *fv, PyObject *cell, PyObject* fn, | |
| PyObject *name, int fline, PyObject *lnos) { | |
| PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL; | |
| PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *empty=NULL; | |
| const char *fn_cstr=NULL; | |
| const char *name_cstr=NULL; | |
| PyCodeObject *co=NULL, *result=NULL; | |
| PyObject *type, *value, *traceback; | |
| PyErr_Fetch(&type, &value, &traceback); | |
| if (!(kwds=PyDict_New())) goto end; | |
| if (!(argcount=PyLong_FromLong(a))) goto end; | |
| if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end; | |
| if (!(posonlyargcount=PyLong_FromLong(p))) goto end; | |
| if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end; | |
| if (!(kwonlyargcount=PyLong_FromLong(k))) goto end; | |
| if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end; | |
| if (!(nlocals=PyLong_FromLong(l))) goto end; | |
| if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end; | |
| if (!(stacksize=PyLong_FromLong(s))) goto end; | |
| if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end; | |
| if (!(flags=PyLong_FromLong(f))) goto end; | |
| if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end; | |
| if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end; | |
| if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end; | |
| if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end; | |
| if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end; | |
| if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end; | |
| if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end; | |
| if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end; | |
| if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end; | |
| if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end; | |
| if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end; | |
| if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto end; | |
| if (!(empty = PyTuple_New(0))) goto end; | |
| result = (PyCodeObject*) PyObject_Call(replace, empty, kwds); | |
| end: | |
| Py_XDECREF((PyObject*) co); | |
| Py_XDECREF(kwds); | |
| Py_XDECREF(argcount); | |
| Py_XDECREF(posonlyargcount); | |
| Py_XDECREF(kwonlyargcount); | |
| Py_XDECREF(nlocals); | |
| Py_XDECREF(stacksize); | |
| Py_XDECREF(replace); | |
| Py_XDECREF(empty); | |
| if (type) { | |
| PyErr_Restore(type, value, traceback); | |
| } | |
| return result; | |
| } | |
| typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); | |
| typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, | |
| Py_ssize_t nargs, PyObject *kwnames); | |
| typedef PyObject *(*__pyx_vectorcallfunc)(PyObject *callable, PyObject *const *args, | |
| size_t nargsf, PyObject *kwnames); | |
| typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *); | |
| static CYTHON_INLINE void *__Pyx_PyModule_GetState(PyObject *op) | |
| { | |
| void *result; | |
| result = PyModule_GetState(op); | |
| if (!result) | |
| Py_FatalError("Couldn't find the module state"); | |
| return result; | |
| } | |
| typedef int Py_tss_t; | |
| static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { | |
| *key = PyThread_create_key(); | |
| return 0; | |
| } | |
| static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { | |
| Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); | |
| *key = Py_tss_NEEDS_INIT; | |
| return key; | |
| } | |
| static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { | |
| PyObject_Free(key); | |
| } | |
| static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { | |
| return *key != Py_tss_NEEDS_INIT; | |
| } | |
| static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { | |
| PyThread_delete_key(*key); | |
| *key = Py_tss_NEEDS_INIT; | |
| } | |
| static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { | |
| return PyThread_set_key_value(*key, value); | |
| } | |
| static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { | |
| return PyThread_get_key_value(*key); | |
| } | |
| [[deprecated("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6")]] | |
| __attribute__ ((__deprecated__("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6"))) | |
| __declspec(deprecated("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6")) | |
| static CYTHON_INLINE int PyGILState_Check(void) { | |
| return 0; | |
| } | |
| static CYTHON_INLINE int PyGILState_Check(void) { | |
| PyThreadState * tstate = _PyThreadState_Current; | |
| return tstate && (tstate == PyGILState_GetThisThreadState()); | |
| } | |
| static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) { | |
| PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name); | |
| if (res == NULL) PyErr_Clear(); | |
| return res; | |
| } | |
| static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) { | |
| return PyDict_GetItem(dict, name); | |
| PyDictEntry *ep; | |
| PyDictObject *mp = (PyDictObject*) dict; | |
| long hash = ((PyStringObject *) name)->ob_shash; | |
| assert(hash != -1); | |
| ep = (mp->ma_lookup)(mp, name, hash); | |
| if (ep == NULL) { | |
| return NULL; | |
| } | |
| return ep->me_value; | |
| } | |
| typedef long Py_hash_t; | |
| typedef struct { | |
| unaryfunc am_await; | |
| unaryfunc am_aiter; | |
| unaryfunc am_anext; | |
| } __Pyx_PyAsyncMethodsStruct; | |
| static CYTHON_INLINE float __PYX_NAN() { | |
| float value; | |
| memset(&value, 0xFF, sizeof(value)); | |
| return value; | |
| } | |
| /* Early includes */ | |
| typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; | |
| const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; | |
| static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { | |
| return (size_t) i < (size_t) limit; | |
| } | |
| static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); | |
| static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); | |
| static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); | |
| static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const wchar_t *u) | |
| { | |
| const wchar_t *u_end = u; | |
| while (*u_end++) ; | |
| return (size_t)(u_end - u - 1); | |
| } | |
| static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) | |
| { | |
| const Py_UNICODE *u_end = u; | |
| while (*u_end++) ; | |
| return (size_t)(u_end - u - 1); | |
| } | |
| static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); | |
| static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); | |
| static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); | |
| static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); | |
| static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); | |
| static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); | |
| static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); | |
| typedef Py_ssize_t __Pyx_compact_pylong; | |
| typedef size_t __Pyx_compact_upylong; | |
| typedef sdigit __Pyx_compact_pylong; | |
| typedef digit __Pyx_compact_upylong; | |
| static int __Pyx_sys_getdefaultencoding_not_ascii; | |
| static int __Pyx_init_sys_getdefaultencoding_params(void) { | |
| PyObject* sys; | |
| PyObject* default_encoding = NULL; | |
| PyObject* ascii_chars_u = NULL; | |
| PyObject* ascii_chars_b = NULL; | |
| const char* default_encoding_c; | |
| sys = PyImport_ImportModule("sys"); | |
| if (!sys) goto bad; | |
| default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); | |
| Py_DECREF(sys); | |
| if (!default_encoding) goto bad; | |
| default_encoding_c = PyBytes_AsString(default_encoding); | |
| if (!default_encoding_c) goto bad; | |
| if (strcmp(default_encoding_c, "ascii") == 0) { | |
| __Pyx_sys_getdefaultencoding_not_ascii = 0; | |
| } else { | |
| char ascii_chars[128]; | |
| int c; | |
| for (c = 0; c < 128; c++) { | |
| ascii_chars[c] = (char) c; | |
| } | |
| __Pyx_sys_getdefaultencoding_not_ascii = 1; | |
| ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); | |
| if (!ascii_chars_u) goto bad; | |
| ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); | |
| if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { | |
| PyErr_Format( | |
| PyExc_ValueError, | |
| "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", | |
| default_encoding_c); | |
| goto bad; | |
| } | |
| Py_DECREF(ascii_chars_u); | |
| Py_DECREF(ascii_chars_b); | |
| } | |
| Py_DECREF(default_encoding); | |
| return 0; | |
| bad: | |
| Py_XDECREF(default_encoding); | |
| Py_XDECREF(ascii_chars_u); | |
| Py_XDECREF(ascii_chars_b); | |
| return -1; | |
| } | |
| static char* __PYX_DEFAULT_STRING_ENCODING; | |
| static int __Pyx_init_sys_getdefaultencoding_params(void) { | |
| PyObject* sys; | |
| PyObject* default_encoding = NULL; | |
| char* default_encoding_c; | |
| sys = PyImport_ImportModule("sys"); | |
| if (!sys) goto bad; | |
| default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); | |
| Py_DECREF(sys); | |
| if (!default_encoding) goto bad; | |
| default_encoding_c = PyBytes_AsString(default_encoding); | |
| if (!default_encoding_c) goto bad; | |
| __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); | |
| if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; | |
| strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); | |
| Py_DECREF(default_encoding); | |
| return 0; | |
| bad: | |
| Py_XDECREF(default_encoding); | |
| return -1; | |
| } | |
| /* Test for GCC > 2.95 */ | |
| static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } | |
| static PyObject *__pyx_m = NULL; | |
| static int __pyx_lineno; | |
| static int __pyx_clineno = 0; | |
| static const char * __pyx_cfilenm = __FILE__; | |
| static const char *__pyx_filename; | |
| /* #### Code section: filename_table ### */ | |
| static const char *__pyx_f[] = { | |
| "box/exceptions.py", | |
| }; | |
| /* #### Code section: utility_code_proto_before_types ### */ | |
| /* #### Code section: numeric_typedefs ### */ | |
| /* #### Code section: complex_type_declarations ### */ | |
| /* #### Code section: type_declarations ### */ | |
| /*--- Type declarations ---*/ | |
| /* #### Code section: utility_code_proto ### */ | |
| /* --- Runtime support code (head) --- */ | |
| /* Refnanny.proto */ | |
| typedef struct { | |
| void (*INCREF)(void*, PyObject*, Py_ssize_t); | |
| void (*DECREF)(void*, PyObject*, Py_ssize_t); | |
| void (*GOTREF)(void*, PyObject*, Py_ssize_t); | |
| void (*GIVEREF)(void*, PyObject*, Py_ssize_t); | |
| void* (*SetupContext)(const char*, Py_ssize_t, const char*); | |
| void (*FinishContext)(void**); | |
| } __Pyx_RefNannyAPIStruct; | |
| static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; | |
| static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); | |
| /* PyErrExceptionMatches.proto */ | |
| static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); | |
| /* PyThreadStateGet.proto */ | |
| /* PyErrFetchRestore.proto */ | |
| static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); | |
| static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); | |
| /* PyObjectGetAttrStr.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); | |
| /* PyObjectGetAttrStrNoError.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name); | |
| /* GetBuiltinName.proto */ | |
| static PyObject *__Pyx_GetBuiltinName(PyObject *name); | |
| /* PyFunctionFastCall.proto */ | |
| static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); | |
| static size_t __pyx_pyframe_localsplus_offset = 0; | |
| /* PyObjectCall.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); | |
| /* PyObjectCallMethO.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); | |
| /* PyObjectFastCall.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject **args, size_t nargs, PyObject *kwargs); | |
| /* PyObjectCallOneArg.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); | |
| /* Py3UpdateBases.proto */ | |
| static PyObject* __Pyx_PEP560_update_bases(PyObject *bases); | |
| /* CalculateMetaclass.proto */ | |
| static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases); | |
| /* PyObjectCall2Args.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); | |
| /* PyObjectLookupSpecial.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx__PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name, int with_error); | |
| /* Py3ClassCreate.proto */ | |
| static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, | |
| PyObject *mkw, PyObject *modname, PyObject *doc); | |
| static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, | |
| PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); | |
| /* PyDictVersioning.proto */ | |
| static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); | |
| static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); | |
| static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); | |
| /* GetModuleGlobalName.proto */ | |
| static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); | |
| static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); | |
| /* CLineInTraceback.proto */ | |
| static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); | |
| /* CodeObjectCache.proto */ | |
| typedef struct { | |
| PyCodeObject* code_object; | |
| int code_line; | |
| } __Pyx_CodeObjectCacheEntry; | |
| struct __Pyx_CodeObjectCache { | |
| int count; | |
| int max_count; | |
| __Pyx_CodeObjectCacheEntry* entries; | |
| }; | |
| static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; | |
| static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); | |
| static PyCodeObject *__pyx_find_code_object(int code_line); | |
| static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); | |
| /* AddTraceback.proto */ | |
| static void __Pyx_AddTraceback(const char *funcname, int c_line, | |
| int py_line, const char *filename); | |
| /* FormatTypeName.proto */ | |
| typedef PyObject *__Pyx_TypeName; | |
| static __Pyx_TypeName __Pyx_PyType_GetName(PyTypeObject* tp); | |
| typedef const char *__Pyx_TypeName; | |
| /* GCCDiagnostics.proto */ | |
| /* CIntToPy.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); | |
| /* CIntFromPy.proto */ | |
| static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); | |
| /* CIntFromPy.proto */ | |
| static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); | |
| /* FastTypeChecks.proto */ | |
| static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); | |
| static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b); | |
| static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); | |
| static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); | |
| /* CheckBinaryVersion.proto */ | |
| static int __Pyx_check_binary_version(void); | |
| /* InitStrings.proto */ | |
| static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); | |
| /* #### Code section: module_declarations ### */ | |
| /* Module declarations from "box.exceptions" */ | |
| /* #### Code section: typeinfo ### */ | |
| /* #### Code section: before_global_var ### */ | |
| extern int __pyx_module_is_main_box__exceptions; | |
| int __pyx_module_is_main_box__exceptions = 0; | |
| /* Implementation of "box.exceptions" */ | |
| /* #### Code section: global_var ### */ | |
| static PyObject *__pyx_builtin_KeyError; | |
| static PyObject *__pyx_builtin_AttributeError; | |
| static PyObject *__pyx_builtin_TypeError; | |
| static PyObject *__pyx_builtin_ValueError; | |
| static PyObject *__pyx_builtin_UserWarning; | |
| /* #### Code section: string_decls ### */ | |
| static const char __pyx_k__3[] = "?"; | |
| static const char __pyx_k_doc[] = "__doc__"; | |
| static const char __pyx_k_dict[] = "__dict__"; | |
| static const char __pyx_k_main[] = "__main__"; | |
| static const char __pyx_k_name[] = "__name__"; | |
| static const char __pyx_k_test[] = "__test__"; | |
| static const char __pyx_k_super[] = "super"; | |
| static const char __pyx_k_module[] = "__module__"; | |
| static const char __pyx_k_prepare[] = "__prepare__"; | |
| static const char __pyx_k_BoxError[] = "BoxError"; | |
| static const char __pyx_k_KeyError[] = "KeyError"; | |
| static const char __pyx_k_qualname[] = "__qualname__"; | |
| static const char __pyx_k_set_name[] = "__set_name__"; | |
| static const char __pyx_k_TypeError[] = "TypeError"; | |
| static const char __pyx_k_metaclass[] = "__metaclass__"; | |
| static const char __pyx_k_BoxWarning[] = "BoxWarning"; | |
| static const char __pyx_k_ValueError[] = "ValueError"; | |
| static const char __pyx_k_BoxKeyError[] = "BoxKeyError"; | |
| static const char __pyx_k_UserWarning[] = "UserWarning"; | |
| static const char __pyx_k_mro_entries[] = "__mro_entries__"; | |
| static const char __pyx_k_BoxTypeError[] = "BoxTypeError"; | |
| static const char __pyx_k_BoxValueError[] = "BoxValueError"; | |
| static const char __pyx_k_init_subclass[] = "__init_subclass__"; | |
| static const char __pyx_k_AttributeError[] = "AttributeError"; | |
| static const char __pyx_k_box_exceptions[] = "box.exceptions"; | |
| static const char __pyx_k_Here_be_dragons[] = "Here be dragons"; | |
| static const char __pyx_k_Key_does_not_exist[] = "Key does not exist"; | |
| static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; | |
| static const char __pyx_k_Issue_doing_something_with_that[] = "Issue doing something with that value"; | |
| static const char __pyx_k_Cannot_handle_that_instance_s_ty[] = "Cannot handle that instance's type"; | |
| static const char __pyx_k_Non_standard_dictionary_exceptio[] = "Non standard dictionary exceptions"; | |
| /* #### Code section: decls ### */ | |
| /* #### Code section: late_includes ### */ | |
| /* #### Code section: module_state ### */ | |
| typedef struct { | |
| PyObject *__pyx_d; | |
| PyObject *__pyx_b; | |
| PyObject *__pyx_cython_runtime; | |
| PyObject *__pyx_empty_tuple; | |
| PyObject *__pyx_empty_bytes; | |
| PyObject *__pyx_empty_unicode; | |
| PyTypeObject *__pyx_CyFunctionType; | |
| PyTypeObject *__pyx_FusedFunctionType; | |
| PyTypeObject *__pyx_GeneratorType; | |
| PyTypeObject *__pyx_IterableCoroutineType; | |
| PyTypeObject *__pyx_CoroutineAwaitType; | |
| PyTypeObject *__pyx_CoroutineType; | |
| PyObject *__pyx_n_s_AttributeError; | |
| PyObject *__pyx_n_s_BoxError; | |
| PyObject *__pyx_n_s_BoxKeyError; | |
| PyObject *__pyx_n_s_BoxTypeError; | |
| PyObject *__pyx_n_s_BoxValueError; | |
| PyObject *__pyx_n_s_BoxWarning; | |
| PyObject *__pyx_kp_s_Cannot_handle_that_instance_s_ty; | |
| PyObject *__pyx_kp_s_Here_be_dragons; | |
| PyObject *__pyx_kp_s_Issue_doing_something_with_that; | |
| PyObject *__pyx_n_s_KeyError; | |
| PyObject *__pyx_kp_s_Key_does_not_exist; | |
| PyObject *__pyx_kp_s_Non_standard_dictionary_exceptio; | |
| PyObject *__pyx_n_s_TypeError; | |
| PyObject *__pyx_n_s_UserWarning; | |
| PyObject *__pyx_n_s_ValueError; | |
| PyObject *__pyx_n_s__3; | |
| PyObject *__pyx_n_s_box_exceptions; | |
| PyObject *__pyx_n_s_cline_in_traceback; | |
| PyObject *__pyx_n_s_dict; | |
| PyObject *__pyx_n_s_doc; | |
| PyObject *__pyx_n_s_init_subclass; | |
| PyObject *__pyx_n_s_main; | |
| PyObject *__pyx_n_s_metaclass; | |
| PyObject *__pyx_n_s_module; | |
| PyObject *__pyx_n_s_mro_entries; | |
| PyObject *__pyx_n_s_name; | |
| PyObject *__pyx_n_s_prepare; | |
| PyObject *__pyx_n_s_qualname; | |
| PyObject *__pyx_n_s_set_name; | |
| PyObject *__pyx_n_s_super; | |
| PyObject *__pyx_n_s_test; | |
| PyObject *__pyx_tuple_; | |
| PyObject *__pyx_tuple__2; | |
| } __pyx_mstate; | |
| namespace { | |
| extern struct PyModuleDef __pyx_moduledef; | |
| } /* anonymous namespace */ | |
| static struct PyModuleDef __pyx_moduledef; | |
| static __pyx_mstate __pyx_mstate_global_static = | |
| {}; | |
| {0}; | |
| static __pyx_mstate *__pyx_mstate_global = &__pyx_mstate_global_static; | |
| /* #### Code section: module_state_clear ### */ | |
| static int __pyx_m_clear(PyObject *m) { | |
| __pyx_mstate *clear_module_state = __pyx_mstate(m); | |
| if (!clear_module_state) return 0; | |
| Py_CLEAR(clear_module_state->__pyx_d); | |
| Py_CLEAR(clear_module_state->__pyx_b); | |
| Py_CLEAR(clear_module_state->__pyx_cython_runtime); | |
| Py_CLEAR(clear_module_state->__pyx_empty_tuple); | |
| Py_CLEAR(clear_module_state->__pyx_empty_bytes); | |
| Py_CLEAR(clear_module_state->__pyx_empty_unicode); | |
| Py_CLEAR(clear_module_state->__pyx_CyFunctionType); | |
| Py_CLEAR(clear_module_state->__pyx_FusedFunctionType); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_AttributeError); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_BoxError); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_BoxKeyError); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_BoxTypeError); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_BoxValueError); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_BoxWarning); | |
| Py_CLEAR(clear_module_state->__pyx_kp_s_Cannot_handle_that_instance_s_ty); | |
| Py_CLEAR(clear_module_state->__pyx_kp_s_Here_be_dragons); | |
| Py_CLEAR(clear_module_state->__pyx_kp_s_Issue_doing_something_with_that); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_KeyError); | |
| Py_CLEAR(clear_module_state->__pyx_kp_s_Key_does_not_exist); | |
| Py_CLEAR(clear_module_state->__pyx_kp_s_Non_standard_dictionary_exceptio); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_TypeError); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_UserWarning); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_ValueError); | |
| Py_CLEAR(clear_module_state->__pyx_n_s__3); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_box_exceptions); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_cline_in_traceback); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_dict); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_doc); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_init_subclass); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_main); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_metaclass); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_module); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_mro_entries); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_name); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_prepare); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_qualname); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_set_name); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_super); | |
| Py_CLEAR(clear_module_state->__pyx_n_s_test); | |
| Py_CLEAR(clear_module_state->__pyx_tuple_); | |
| Py_CLEAR(clear_module_state->__pyx_tuple__2); | |
| return 0; | |
| } | |
| /* #### Code section: module_state_traverse ### */ | |
| static int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) { | |
| __pyx_mstate *traverse_module_state = __pyx_mstate(m); | |
| if (!traverse_module_state) return 0; | |
| Py_VISIT(traverse_module_state->__pyx_d); | |
| Py_VISIT(traverse_module_state->__pyx_b); | |
| Py_VISIT(traverse_module_state->__pyx_cython_runtime); | |
| Py_VISIT(traverse_module_state->__pyx_empty_tuple); | |
| Py_VISIT(traverse_module_state->__pyx_empty_bytes); | |
| Py_VISIT(traverse_module_state->__pyx_empty_unicode); | |
| Py_VISIT(traverse_module_state->__pyx_CyFunctionType); | |
| Py_VISIT(traverse_module_state->__pyx_FusedFunctionType); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_AttributeError); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_BoxError); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_BoxKeyError); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_BoxTypeError); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_BoxValueError); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_BoxWarning); | |
| Py_VISIT(traverse_module_state->__pyx_kp_s_Cannot_handle_that_instance_s_ty); | |
| Py_VISIT(traverse_module_state->__pyx_kp_s_Here_be_dragons); | |
| Py_VISIT(traverse_module_state->__pyx_kp_s_Issue_doing_something_with_that); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_KeyError); | |
| Py_VISIT(traverse_module_state->__pyx_kp_s_Key_does_not_exist); | |
| Py_VISIT(traverse_module_state->__pyx_kp_s_Non_standard_dictionary_exceptio); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_TypeError); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_UserWarning); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_ValueError); | |
| Py_VISIT(traverse_module_state->__pyx_n_s__3); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_box_exceptions); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_cline_in_traceback); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_dict); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_doc); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_init_subclass); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_main); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_metaclass); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_module); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_mro_entries); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_name); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_prepare); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_qualname); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_set_name); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_super); | |
| Py_VISIT(traverse_module_state->__pyx_n_s_test); | |
| Py_VISIT(traverse_module_state->__pyx_tuple_); | |
| Py_VISIT(traverse_module_state->__pyx_tuple__2); | |
| return 0; | |
| } | |
| /* #### Code section: module_state_defines ### */ | |
| /* #### Code section: module_code ### */ | |
| static PyMethodDef __pyx_methods[] = { | |
| {0, 0, 0, 0} | |
| }; | |
| /* #### Code section: pystring_table ### */ | |
| static int __Pyx_CreateStringTabAndInitStrings(void) { | |
| __Pyx_StringTabEntry __pyx_string_tab[] = { | |
| {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1}, | |
| {&__pyx_n_s_BoxError, __pyx_k_BoxError, sizeof(__pyx_k_BoxError), 0, 0, 1, 1}, | |
| {&__pyx_n_s_BoxKeyError, __pyx_k_BoxKeyError, sizeof(__pyx_k_BoxKeyError), 0, 0, 1, 1}, | |
| {&__pyx_n_s_BoxTypeError, __pyx_k_BoxTypeError, sizeof(__pyx_k_BoxTypeError), 0, 0, 1, 1}, | |
| {&__pyx_n_s_BoxValueError, __pyx_k_BoxValueError, sizeof(__pyx_k_BoxValueError), 0, 0, 1, 1}, | |
| {&__pyx_n_s_BoxWarning, __pyx_k_BoxWarning, sizeof(__pyx_k_BoxWarning), 0, 0, 1, 1}, | |
| {&__pyx_kp_s_Cannot_handle_that_instance_s_ty, __pyx_k_Cannot_handle_that_instance_s_ty, sizeof(__pyx_k_Cannot_handle_that_instance_s_ty), 0, 0, 1, 0}, | |
| {&__pyx_kp_s_Here_be_dragons, __pyx_k_Here_be_dragons, sizeof(__pyx_k_Here_be_dragons), 0, 0, 1, 0}, | |
| {&__pyx_kp_s_Issue_doing_something_with_that, __pyx_k_Issue_doing_something_with_that, sizeof(__pyx_k_Issue_doing_something_with_that), 0, 0, 1, 0}, | |
| {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1}, | |
| {&__pyx_kp_s_Key_does_not_exist, __pyx_k_Key_does_not_exist, sizeof(__pyx_k_Key_does_not_exist), 0, 0, 1, 0}, | |
| {&__pyx_kp_s_Non_standard_dictionary_exceptio, __pyx_k_Non_standard_dictionary_exceptio, sizeof(__pyx_k_Non_standard_dictionary_exceptio), 0, 0, 1, 0}, | |
| {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, | |
| {&__pyx_n_s_UserWarning, __pyx_k_UserWarning, sizeof(__pyx_k_UserWarning), 0, 0, 1, 1}, | |
| {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, | |
| {&__pyx_n_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 1}, | |
| {&__pyx_n_s_box_exceptions, __pyx_k_box_exceptions, sizeof(__pyx_k_box_exceptions), 0, 0, 1, 1}, | |
| {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, | |
| {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1}, | |
| {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1}, | |
| {&__pyx_n_s_init_subclass, __pyx_k_init_subclass, sizeof(__pyx_k_init_subclass), 0, 0, 1, 1}, | |
| {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, | |
| {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1}, | |
| {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1}, | |
| {&__pyx_n_s_mro_entries, __pyx_k_mro_entries, sizeof(__pyx_k_mro_entries), 0, 0, 1, 1}, | |
| {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, | |
| {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1}, | |
| {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1}, | |
| {&__pyx_n_s_set_name, __pyx_k_set_name, sizeof(__pyx_k_set_name), 0, 0, 1, 1}, | |
| {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1}, | |
| {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, | |
| {0, 0, 0, 0, 0, 0, 0} | |
| }; | |
| return __Pyx_InitStrings(__pyx_string_tab); | |
| } | |
| /* #### Code section: cached_builtins ### */ | |
| static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { | |
| __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 9, __pyx_L1_error) | |
| __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 9, __pyx_L1_error) | |
| __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 13, __pyx_L1_error) | |
| __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 17, __pyx_L1_error) | |
| __pyx_builtin_UserWarning = __Pyx_GetBuiltinName(__pyx_n_s_UserWarning); if (!__pyx_builtin_UserWarning) __PYX_ERR(0, 21, __pyx_L1_error) | |
| return 0; | |
| __pyx_L1_error:; | |
| return -1; | |
| } | |
| /* #### Code section: cached_constants ### */ | |
| static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); | |
| /* "box/exceptions.py":21 | |
| * | |
| * | |
| * class BoxWarning(UserWarning): # <<<<<<<<<<<<<< | |
| * """Here be dragons""" | |
| */ | |
| __pyx_tuple_ = PyTuple_Pack(1, __pyx_builtin_UserWarning); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 21, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_tuple_); | |
| __Pyx_GIVEREF(__pyx_tuple_); | |
| __pyx_tuple__2 = PyTuple_Pack(1, __pyx_builtin_UserWarning); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 21, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_tuple__2); | |
| __Pyx_GIVEREF(__pyx_tuple__2); | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| __pyx_L1_error:; | |
| __Pyx_RefNannyFinishContext(); | |
| return -1; | |
| } | |
| /* #### Code section: init_constants ### */ | |
| static CYTHON_SMALL_CODE int __Pyx_InitConstants(void) { | |
| if (__Pyx_CreateStringTabAndInitStrings() < 0) __PYX_ERR(0, 1, __pyx_L1_error); | |
| return 0; | |
| __pyx_L1_error:; | |
| return -1; | |
| } | |
| /* #### Code section: init_globals ### */ | |
| static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { | |
| return 0; | |
| } | |
| /* #### Code section: init_module ### */ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ | |
| static int __Pyx_modinit_global_init_code(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); | |
| /*--- Global init code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_variable_export_code(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); | |
| /*--- Variable export code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_function_export_code(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); | |
| /*--- Function export code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_type_init_code(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); | |
| /*--- Type init code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_type_import_code(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); | |
| /*--- Type import code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_variable_import_code(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); | |
| /*--- Variable import code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_function_import_code(void) { | |
| __Pyx_RefNannyDeclarations | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); | |
| /*--- Function import code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ | |
| static int __pyx_pymod_exec_exceptions(PyObject* module); /*proto*/ | |
| static PyModuleDef_Slot __pyx_moduledef_slots[] = { | |
| {Py_mod_create, (void*)__pyx_pymod_create}, | |
| {Py_mod_exec, (void*)__pyx_pymod_exec_exceptions}, | |
| {0, NULL} | |
| }; | |
| namespace { | |
| struct PyModuleDef __pyx_moduledef = | |
| static struct PyModuleDef __pyx_moduledef = | |
| { | |
| PyModuleDef_HEAD_INIT, | |
| "exceptions", | |
| 0, /* m_doc */ | |
| 0, /* m_size */ | |
| sizeof(__pyx_mstate), /* m_size */ | |
| -1, /* m_size */ | |
| __pyx_methods /* m_methods */, | |
| __pyx_moduledef_slots, /* m_slots */ | |
| NULL, /* m_reload */ | |
| __pyx_m_traverse, /* m_traverse */ | |
| __pyx_m_clear, /* m_clear */ | |
| NULL /* m_free */ | |
| NULL, /* m_traverse */ | |
| NULL, /* m_clear */ | |
| NULL /* m_free */ | |
| }; | |
| } /* anonymous namespace */ | |
| __Pyx_PyMODINIT_FUNC initexceptions(void) CYTHON_SMALL_CODE; /*proto*/ | |
| __Pyx_PyMODINIT_FUNC initexceptions(void) | |
| __Pyx_PyMODINIT_FUNC PyInit_exceptions(void) CYTHON_SMALL_CODE; /*proto*/ | |
| __Pyx_PyMODINIT_FUNC PyInit_exceptions(void) | |
| { | |
| return PyModuleDef_Init(&__pyx_moduledef); | |
| } | |
| static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { | |
| static PY_INT64_T main_interpreter_id = -1; | |
| PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); | |
| if (main_interpreter_id == -1) { | |
| main_interpreter_id = current_id; | |
| return (unlikely(current_id == -1)) ? -1 : 0; | |
| } else if (unlikely(main_interpreter_id != current_id)) | |
| static PyInterpreterState *main_interpreter = NULL; | |
| PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; | |
| if (!main_interpreter) { | |
| main_interpreter = current_interpreter; | |
| } else if (unlikely(main_interpreter != current_interpreter)) | |
| { | |
| PyErr_SetString( | |
| PyExc_ImportError, | |
| "Interpreter change detected - this module can only be loaded into one interpreter per process."); | |
| return -1; | |
| } | |
| return 0; | |
| } | |
| static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *module, const char* from_name, const char* to_name, int allow_none) | |
| static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) | |
| { | |
| PyObject *value = PyObject_GetAttrString(spec, from_name); | |
| int result = 0; | |
| if (likely(value)) { | |
| if (allow_none || value != Py_None) { | |
| result = PyModule_AddObject(module, to_name, value); | |
| result = PyDict_SetItemString(moddict, to_name, value); | |
| } | |
| Py_DECREF(value); | |
| } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { | |
| PyErr_Clear(); | |
| } else { | |
| result = -1; | |
| } | |
| return result; | |
| } | |
| static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) { | |
| PyObject *module = NULL, *moddict, *modname; | |
| CYTHON_UNUSED_VAR(def); | |
| if (__Pyx_check_single_interpreter()) | |
| return NULL; | |
| if (__pyx_m) | |
| return __Pyx_NewRef(__pyx_m); | |
| modname = PyObject_GetAttrString(spec, "name"); | |
| if (unlikely(!modname)) goto bad; | |
| module = PyModule_NewObject(modname); | |
| Py_DECREF(modname); | |
| if (unlikely(!module)) goto bad; | |
| moddict = module; | |
| moddict = PyModule_GetDict(module); | |
| if (unlikely(!moddict)) goto bad; | |
| if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; | |
| if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; | |
| if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; | |
| if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; | |
| return module; | |
| bad: | |
| Py_XDECREF(module); | |
| return NULL; | |
| } | |
| static CYTHON_SMALL_CODE int __pyx_pymod_exec_exceptions(PyObject *__pyx_pyinit_module) | |
| { | |
| int stringtab_initialized = 0; | |
| int pystate_addmodule_run = 0; | |
| PyObject *__pyx_t_1 = NULL; | |
| PyObject *__pyx_t_2 = NULL; | |
| PyObject *__pyx_t_3 = NULL; | |
| PyObject *__pyx_t_4 = NULL; | |
| PyObject *__pyx_t_5 = NULL; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannyDeclarations | |
| if (__pyx_m) { | |
| if (__pyx_m == __pyx_pyinit_module) return 0; | |
| PyErr_SetString(PyExc_RuntimeError, "Module 'exceptions' has already been imported. Re-initialisation is not supported."); | |
| return -1; | |
| } | |
| if (__pyx_m) return __Pyx_NewRef(__pyx_m); | |
| /*--- Module creation code ---*/ | |
| __pyx_m = __pyx_pyinit_module; | |
| Py_INCREF(__pyx_m); | |
| __pyx_m = Py_InitModule4("exceptions", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); | |
| if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| { | |
| int add_module_result = PyState_AddModule(__pyx_t_1, &__pyx_moduledef); | |
| __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to exceptions pseudovariable */ | |
| if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error) | |
| pystate_addmodule_run = 1; | |
| } | |
| __pyx_m = PyModule_Create(&__pyx_moduledef); | |
| if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| CYTHON_UNUSED_VAR(__pyx_t_1); | |
| __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| Py_INCREF(__pyx_d); | |
| __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| Py_INCREF(__pyx_b); | |
| __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| Py_INCREF(__pyx_cython_runtime); | |
| if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); | |
| if (!__Pyx_RefNanny) { | |
| PyErr_Clear(); | |
| __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); | |
| if (!__Pyx_RefNanny) | |
| Py_FatalError("failed to import 'refnanny' module"); | |
| } | |
| __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_exceptions(void)", 0); | |
| if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __Pxy_PyFrame_Initialize_Offsets(); | |
| __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_CyFunction_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_FusedFunction_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_Coroutine_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_Generator_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_AsyncGen_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_StopAsyncIteration_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| /*--- Library function declarations ---*/ | |
| /*--- Threads initialization code ---*/ | |
| PyEval_InitThreads(); | |
| /*--- Initialize various global constants etc. ---*/ | |
| if (__Pyx_InitConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| stringtab_initialized = 1; | |
| if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_module_is_main_box__exceptions) { | |
| if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| } | |
| { | |
| PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (!PyDict_GetItemString(modules, "box.exceptions")) { | |
| if (unlikely((PyDict_SetItemString(modules, "box.exceptions", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) | |
| } | |
| } | |
| /*--- Builtin init code ---*/ | |
| if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| /*--- Constants init code ---*/ | |
| if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| /*--- Global type/function init code ---*/ | |
| (void)__Pyx_modinit_global_init_code(); | |
| (void)__Pyx_modinit_variable_export_code(); | |
| (void)__Pyx_modinit_function_export_code(); | |
| (void)__Pyx_modinit_type_init_code(); | |
| (void)__Pyx_modinit_type_import_code(); | |
| (void)__Pyx_modinit_variable_import_code(); | |
| (void)__Pyx_modinit_function_import_code(); | |
| /*--- Execution code ---*/ | |
| if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| /* "box/exceptions.py":5 | |
| * | |
| * | |
| * class BoxError(Exception): # <<<<<<<<<<<<<< | |
| * """Non standard dictionary exceptions""" | |
| * | |
| */ | |
| __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __Pyx_INCREF((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])); | |
| __Pyx_GIVEREF((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])); | |
| PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); | |
| __pyx_t_3 = __Pyx_PEP560_update_bases(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_4 = __Pyx_CalculateMetaclass(NULL, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_5 = __Pyx_Py3MetaclassPrepare(__pyx_t_4, __pyx_t_3, __pyx_n_s_BoxError, __pyx_n_s_BoxError, (PyObject *) NULL, __pyx_n_s_box_exceptions, __pyx_kp_s_Non_standard_dictionary_exceptio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| if (__pyx_t_3 != __pyx_t_2) { | |
| if (unlikely((PyDict_SetItemString(__pyx_t_5, "__orig_bases__", __pyx_t_2) < 0))) __PYX_ERR(0, 5, __pyx_L1_error) | |
| } | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_4, __pyx_n_s_BoxError, __pyx_t_3, __pyx_t_5, NULL, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_BoxError, __pyx_t_2) < 0) __PYX_ERR(0, 5, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; | |
| /* "box/exceptions.py":9 | |
| * | |
| * | |
| * class BoxKeyError(BoxError, KeyError, AttributeError): # <<<<<<<<<<<<<< | |
| * """Key does not exist""" | |
| * | |
| */ | |
| __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_BoxError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 9, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __Pyx_GIVEREF(__pyx_t_3); | |
| PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); | |
| __Pyx_INCREF(__pyx_builtin_KeyError); | |
| __Pyx_GIVEREF(__pyx_builtin_KeyError); | |
| PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_builtin_KeyError); | |
| __Pyx_INCREF(__pyx_builtin_AttributeError); | |
| __Pyx_GIVEREF(__pyx_builtin_AttributeError); | |
| PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_builtin_AttributeError); | |
| __pyx_t_3 = 0; | |
| __pyx_t_3 = __Pyx_PEP560_update_bases(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_5 = __Pyx_CalculateMetaclass(NULL, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_5, __pyx_t_3, __pyx_n_s_BoxKeyError, __pyx_n_s_BoxKeyError, (PyObject *) NULL, __pyx_n_s_box_exceptions, __pyx_kp_s_Key_does_not_exist); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| if (__pyx_t_3 != __pyx_t_4) { | |
| if (unlikely((PyDict_SetItemString(__pyx_t_2, "__orig_bases__", __pyx_t_4) < 0))) __PYX_ERR(0, 9, __pyx_L1_error) | |
| } | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_5, __pyx_n_s_BoxKeyError, __pyx_t_3, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 9, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_BoxKeyError, __pyx_t_4) < 0) __PYX_ERR(0, 9, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; | |
| /* "box/exceptions.py":13 | |
| * | |
| * | |
| * class BoxTypeError(BoxError, TypeError): # <<<<<<<<<<<<<< | |
| * """Cannot handle that instance's type""" | |
| * | |
| */ | |
| __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_BoxError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 13, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 13, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| __Pyx_GIVEREF(__pyx_t_3); | |
| PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); | |
| __Pyx_INCREF(__pyx_builtin_TypeError); | |
| __Pyx_GIVEREF(__pyx_builtin_TypeError); | |
| PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_builtin_TypeError); | |
| __pyx_t_3 = 0; | |
| __pyx_t_3 = __Pyx_PEP560_update_bases(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 13, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __pyx_t_4 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_3, __pyx_n_s_BoxTypeError, __pyx_n_s_BoxTypeError, (PyObject *) NULL, __pyx_n_s_box_exceptions, __pyx_kp_s_Cannot_handle_that_instance_s_ty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 13, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| if (__pyx_t_3 != __pyx_t_5) { | |
| if (unlikely((PyDict_SetItemString(__pyx_t_4, "__orig_bases__", __pyx_t_5) < 0))) __PYX_ERR(0, 13, __pyx_L1_error) | |
| } | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| __pyx_t_5 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_BoxTypeError, __pyx_t_3, __pyx_t_4, NULL, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 13, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_BoxTypeError, __pyx_t_5) < 0) __PYX_ERR(0, 13, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; | |
| /* "box/exceptions.py":17 | |
| * | |
| * | |
| * class BoxValueError(BoxError, ValueError): # <<<<<<<<<<<<<< | |
| * """Issue doing something with that value""" | |
| * | |
| */ | |
| __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_BoxError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 17, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| __Pyx_GIVEREF(__pyx_t_3); | |
| PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); | |
| __Pyx_INCREF(__pyx_builtin_ValueError); | |
| __Pyx_GIVEREF(__pyx_builtin_ValueError); | |
| PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_builtin_ValueError); | |
| __pyx_t_3 = 0; | |
| __pyx_t_3 = __Pyx_PEP560_update_bases(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 17, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_4 = __Pyx_CalculateMetaclass(NULL, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 17, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_5 = __Pyx_Py3MetaclassPrepare(__pyx_t_4, __pyx_t_3, __pyx_n_s_BoxValueError, __pyx_n_s_BoxValueError, (PyObject *) NULL, __pyx_n_s_box_exceptions, __pyx_kp_s_Issue_doing_something_with_that); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 17, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| if (__pyx_t_3 != __pyx_t_2) { | |
| if (unlikely((PyDict_SetItemString(__pyx_t_5, "__orig_bases__", __pyx_t_2) < 0))) __PYX_ERR(0, 17, __pyx_L1_error) | |
| } | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_4, __pyx_n_s_BoxValueError, __pyx_t_3, __pyx_t_5, NULL, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_BoxValueError, __pyx_t_2) < 0) __PYX_ERR(0, 17, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; | |
| /* "box/exceptions.py":21 | |
| * | |
| * | |
| * class BoxWarning(UserWarning): # <<<<<<<<<<<<<< | |
| * """Here be dragons""" | |
| */ | |
| __pyx_t_3 = __Pyx_PEP560_update_bases(__pyx_tuple__2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 21, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| __pyx_t_4 = __Pyx_CalculateMetaclass(NULL, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 21, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_4); | |
| __pyx_t_5 = __Pyx_Py3MetaclassPrepare(__pyx_t_4, __pyx_t_3, __pyx_n_s_BoxWarning, __pyx_n_s_BoxWarning, (PyObject *) NULL, __pyx_n_s_box_exceptions, __pyx_kp_s_Here_be_dragons); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 21, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_5); | |
| if (__pyx_t_3 != __pyx_tuple__2) { | |
| if (unlikely((PyDict_SetItemString(__pyx_t_5, "__orig_bases__", __pyx_tuple__2) < 0))) __PYX_ERR(0, 21, __pyx_L1_error) | |
| } | |
| __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_4, __pyx_n_s_BoxWarning, __pyx_t_3, __pyx_t_5, NULL, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_BoxWarning, __pyx_t_2) < 0) __PYX_ERR(0, 21, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; | |
| __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; | |
| __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; | |
| /* "box/exceptions.py":1 | |
| * #!/usr/bin/env python # <<<<<<<<<<<<<< | |
| * # -*- coding: utf-8 -*- | |
| * | |
| */ | |
| __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_3); | |
| if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; | |
| /*--- Wrapped vars code ---*/ | |
| goto __pyx_L0; | |
| __pyx_L1_error:; | |
| __Pyx_XDECREF(__pyx_t_2); | |
| __Pyx_XDECREF(__pyx_t_3); | |
| __Pyx_XDECREF(__pyx_t_4); | |
| __Pyx_XDECREF(__pyx_t_5); | |
| if (__pyx_m) { | |
| if (__pyx_d && stringtab_initialized) { | |
| __Pyx_AddTraceback("init box.exceptions", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| } | |
| Py_CLEAR(__pyx_m); | |
| Py_DECREF(__pyx_m); | |
| if (pystate_addmodule_run) { | |
| PyObject *tp, *value, *tb; | |
| PyErr_Fetch(&tp, &value, &tb); | |
| PyState_RemoveModule(&__pyx_moduledef); | |
| PyErr_Restore(tp, value, tb); | |
| } | |
| } else if (!PyErr_Occurred()) { | |
| PyErr_SetString(PyExc_ImportError, "init box.exceptions"); | |
| } | |
| __pyx_L0:; | |
| __Pyx_RefNannyFinishContext(); | |
| return (__pyx_m != NULL) ? 0 : -1; | |
| return __pyx_m; | |
| return; | |
| } | |
| /* #### Code section: cleanup_globals ### */ | |
| /* #### Code section: cleanup_module ### */ | |
| /* #### Code section: main_method ### */ | |
| /* #### Code section: utility_code_pragmas ### */ | |
| /* Warning 4127: conditional expression is constant | |
| * Cython uses constant conditional expressions to allow in inline functions to be optimized at | |
| * compile-time, so this warning is not useful | |
| */ | |
| /* #### Code section: utility_code_def ### */ | |
| /* --- Runtime support code --- */ | |
| /* Refnanny */ | |
| static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { | |
| PyObject *m = NULL, *p = NULL; | |
| void *r = NULL; | |
| m = PyImport_ImportModule(modname); | |
| if (!m) goto end; | |
| p = PyObject_GetAttrString(m, "RefNannyAPI"); | |
| if (!p) goto end; | |
| r = PyLong_AsVoidPtr(p); | |
| end: | |
| Py_XDECREF(p); | |
| Py_XDECREF(m); | |
| return (__Pyx_RefNannyAPIStruct *)r; | |
| } | |
| /* PyErrExceptionMatches */ | |
| static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { | |
| Py_ssize_t i, n; | |
| n = PyTuple_GET_SIZE(tuple); | |
| for (i=0; i<n; i++) { | |
| if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1; | |
| } | |
| for (i=0; i<n; i++) { | |
| if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1; | |
| } | |
| return 0; | |
| } | |
| static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) { | |
| int result; | |
| PyObject *exc_type; | |
| PyObject *current_exception = tstate->current_exception; | |
| if (unlikely(!current_exception)) return 0; | |
| exc_type = (PyObject*) Py_TYPE(current_exception); | |
| if (exc_type == err) return 1; | |
| exc_type = tstate->curexc_type; | |
| if (exc_type == err) return 1; | |
| if (unlikely(!exc_type)) return 0; | |
| Py_INCREF(exc_type); | |
| if (unlikely(PyTuple_Check(err))) { | |
| result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); | |
| } else { | |
| result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err); | |
| } | |
| Py_DECREF(exc_type); | |
| return result; | |
| } | |
| /* PyErrFetchRestore */ | |
| static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { | |
| PyObject *tmp_value; | |
| assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value))); | |
| if (value) { | |
| if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb)) | |
| PyException_SetTraceback(value, tb); | |
| } | |
| tmp_value = tstate->current_exception; | |
| tstate->current_exception = value; | |
| Py_XDECREF(tmp_value); | |
| PyObject *tmp_type, *tmp_value, *tmp_tb; | |
| tmp_type = tstate->curexc_type; | |
| tmp_value = tstate->curexc_value; | |
| tmp_tb = tstate->curexc_traceback; | |
| tstate->curexc_type = type; | |
| tstate->curexc_value = value; | |
| tstate->curexc_traceback = tb; | |
| Py_XDECREF(tmp_type); | |
| Py_XDECREF(tmp_value); | |
| Py_XDECREF(tmp_tb); | |
| } | |
| static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { | |
| PyObject* exc_value; | |
| exc_value = tstate->current_exception; | |
| tstate->current_exception = 0; | |
| *value = exc_value; | |
| *type = NULL; | |
| *tb = NULL; | |
| if (exc_value) { | |
| *type = (PyObject*) Py_TYPE(exc_value); | |
| Py_INCREF(*type); | |
| *tb = ((PyBaseExceptionObject*) exc_value)->traceback; | |
| Py_XINCREF(*tb); | |
| *tb = PyException_GetTraceback(exc_value); | |
| } | |
| *type = tstate->curexc_type; | |
| *value = tstate->curexc_value; | |
| *tb = tstate->curexc_traceback; | |
| tstate->curexc_type = 0; | |
| tstate->curexc_value = 0; | |
| tstate->curexc_traceback = 0; | |
| } | |
| /* PyObjectGetAttrStr */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { | |
| PyTypeObject* tp = Py_TYPE(obj); | |
| if (likely(tp->tp_getattro)) | |
| return tp->tp_getattro(obj, attr_name); | |
| if (likely(tp->tp_getattr)) | |
| return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); | |
| return PyObject_GetAttr(obj, attr_name); | |
| } | |
| /* PyObjectGetAttrStrNoError */ | |
| static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { | |
| __Pyx_PyThreadState_declare | |
| __Pyx_PyThreadState_assign | |
| if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) | |
| __Pyx_PyErr_Clear(); | |
| } | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { | |
| PyObject *result; | |
| PyTypeObject* tp = Py_TYPE(obj); | |
| if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { | |
| return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); | |
| } | |
| result = __Pyx_PyObject_GetAttrStr(obj, attr_name); | |
| if (unlikely(!result)) { | |
| __Pyx_PyObject_GetAttrStr_ClearAttributeError(); | |
| } | |
| return result; | |
| } | |
| /* GetBuiltinName */ | |
| static PyObject *__Pyx_GetBuiltinName(PyObject *name) { | |
| PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_b, name); | |
| if (unlikely(!result) && !PyErr_Occurred()) { | |
| PyErr_Format(PyExc_NameError, | |
| "name '%U' is not defined", name); | |
| "name '%.200s' is not defined", PyString_AS_STRING(name)); | |
| } | |
| return result; | |
| } | |
| /* PyFunctionFastCall */ | |
| static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, | |
| PyObject *globals) { | |
| PyFrameObject *f; | |
| PyThreadState *tstate = __Pyx_PyThreadState_Current; | |
| PyObject **fastlocals; | |
| Py_ssize_t i; | |
| PyObject *result; | |
| assert(globals != NULL); | |
| /* XXX Perhaps we should create a specialized | |
| PyFrame_New() that doesn't take locals, but does | |
| take builtins without sanity checking them. | |
| */ | |
| assert(tstate != NULL); | |
| f = PyFrame_New(tstate, co, globals, NULL); | |
| if (f == NULL) { | |
| return NULL; | |
| } | |
| fastlocals = __Pyx_PyFrame_GetLocalsplus(f); | |
| for (i = 0; i < na; i++) { | |
| Py_INCREF(*args); | |
| fastlocals[i] = *args++; | |
| } | |
| result = PyEval_EvalFrameEx(f,0); | |
| ++tstate->recursion_depth; | |
| Py_DECREF(f); | |
| --tstate->recursion_depth; | |
| return result; | |
| } | |
| static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { | |
| PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); | |
| PyObject *globals = PyFunction_GET_GLOBALS(func); | |
| PyObject *argdefs = PyFunction_GET_DEFAULTS(func); | |
| PyObject *closure; | |
| PyObject *kwdefs; | |
| PyObject *kwtuple, **k; | |
| PyObject **d; | |
| Py_ssize_t nd; | |
| Py_ssize_t nk; | |
| PyObject *result; | |
| assert(kwargs == NULL || PyDict_Check(kwargs)); | |
| nk = kwargs ? PyDict_Size(kwargs) : 0; | |
| if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) { | |
| return NULL; | |
| } | |
| if ( | |
| co->co_kwonlyargcount == 0 && | |
| likely(kwargs == NULL || nk == 0) && | |
| co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { | |
| if (argdefs == NULL && co->co_argcount == nargs) { | |
| result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); | |
| goto done; | |
| } | |
| else if (nargs == 0 && argdefs != NULL | |
| && co->co_argcount == Py_SIZE(argdefs)) { | |
| /* function called with no arguments, but all parameters have | |
| a default value: use default values as arguments .*/ | |
| args = &PyTuple_GET_ITEM(argdefs, 0); | |
| result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); | |
| goto done; | |
| } | |
| } | |
| if (kwargs != NULL) { | |
| Py_ssize_t pos, i; | |
| kwtuple = PyTuple_New(2 * nk); | |
| if (kwtuple == NULL) { | |
| result = NULL; | |
| goto done; | |
| } | |
| k = &PyTuple_GET_ITEM(kwtuple, 0); | |
| pos = i = 0; | |
| while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { | |
| Py_INCREF(k[i]); | |
| Py_INCREF(k[i+1]); | |
| i += 2; | |
| } | |
| nk = i / 2; | |
| } | |
| else { | |
| kwtuple = NULL; | |
| k = NULL; | |
| } | |
| closure = PyFunction_GET_CLOSURE(func); | |
| kwdefs = PyFunction_GET_KW_DEFAULTS(func); | |
| if (argdefs != NULL) { | |
| d = &PyTuple_GET_ITEM(argdefs, 0); | |
| nd = Py_SIZE(argdefs); | |
| } | |
| else { | |
| d = NULL; | |
| nd = 0; | |
| } | |
| result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, | |
| args, (int)nargs, | |
| k, (int)nk, | |
| d, (int)nd, kwdefs, closure); | |
| result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, | |
| args, (int)nargs, | |
| k, (int)nk, | |
| d, (int)nd, closure); | |
| Py_XDECREF(kwtuple); | |
| done: | |
| Py_LeaveRecursiveCall(); | |
| return result; | |
| } | |
| /* PyObjectCall */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { | |
| PyObject *result; | |
| ternaryfunc call = Py_TYPE(func)->tp_call; | |
| if (unlikely(!call)) | |
| return PyObject_Call(func, arg, kw); | |
| if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) | |
| return NULL; | |
| result = (*call)(func, arg, kw); | |
| Py_LeaveRecursiveCall(); | |
| if (unlikely(!result) && unlikely(!PyErr_Occurred())) { | |
| PyErr_SetString( | |
| PyExc_SystemError, | |
| "NULL result without error in PyObject_Call"); | |
| } | |
| return result; | |
| } | |
| /* PyObjectCallMethO */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { | |
| PyObject *self, *result; | |
| PyCFunction cfunc; | |
| cfunc = PyCFunction_GET_FUNCTION(func); | |
| self = PyCFunction_GET_SELF(func); | |
| if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) | |
| return NULL; | |
| result = cfunc(self, arg); | |
| Py_LeaveRecursiveCall(); | |
| if (unlikely(!result) && unlikely(!PyErr_Occurred())) { | |
| PyErr_SetString( | |
| PyExc_SystemError, | |
| "NULL result without error in PyObject_Call"); | |
| } | |
| return result; | |
| } | |
| /* PyObjectFastCall */ | |
| static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject **args, size_t nargs, PyObject *kwargs) { | |
| PyObject *argstuple; | |
| PyObject *result; | |
| size_t i; | |
| argstuple = PyTuple_New((Py_ssize_t)nargs); | |
| if (unlikely(!argstuple)) return NULL; | |
| for (i = 0; i < nargs; i++) { | |
| Py_INCREF(args[i]); | |
| PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]); | |
| } | |
| result = __Pyx_PyObject_Call(func, argstuple, kwargs); | |
| Py_DECREF(argstuple); | |
| return result; | |
| } | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject **args, size_t _nargs, PyObject *kwargs) { | |
| Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs); | |
| if (nargs == 0 && kwargs == NULL) { | |
| if (__Pyx_IsCyOrPyCFunction(func)) | |
| if (PyCFunction_Check(func)) | |
| { | |
| if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { | |
| return __Pyx_PyObject_CallMethO(func, NULL); | |
| } | |
| } | |
| } | |
| else if (nargs == 1 && kwargs == NULL) { | |
| if (PyCFunction_Check(func)) | |
| { | |
| if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { | |
| return __Pyx_PyObject_CallMethO(func, args[0]); | |
| } | |
| } | |
| } | |
| if (PyCFunction_Check(func)) { | |
| if (kwargs) { | |
| return _PyCFunction_FastCallDict(func, args, nargs, kwargs); | |
| } else { | |
| return _PyCFunction_FastCallKeywords(func, args, nargs, NULL); | |
| } | |
| } | |
| if (!kwargs && __Pyx_IS_TYPE(func, &PyMethodDescr_Type)) { | |
| return _PyMethodDescr_FastCallKeywords(func, args, nargs, NULL); | |
| } | |
| if (PyFunction_Check(func)) { | |
| return __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs); | |
| } | |
| vectorcallfunc f = _PyVectorcall_Function(func); | |
| if (f) { | |
| return f(func, args, (size_t)nargs, kwargs); | |
| } | |
| if (__Pyx_CyFunction_CheckExact(func)) { | |
| __pyx_vectorcallfunc f = __Pyx_CyFunction_func_vectorcall(func); | |
| if (f) return f(func, args, (size_t)nargs, kwargs); | |
| } | |
| if (nargs == 0) { | |
| return __Pyx_PyObject_Call(func, __pyx_empty_tuple, kwargs); | |
| } | |
| return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs); | |
| } | |
| /* PyObjectCallOneArg */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { | |
| PyObject *args[2] = {NULL, arg}; | |
| return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); | |
| } | |
| /* Py3UpdateBases */ | |
| static PyObject* | |
| __Pyx_PEP560_update_bases(PyObject *bases) | |
| { | |
| Py_ssize_t i, j, size_bases; | |
| PyObject *base, *meth, *new_base, *result, *new_bases = NULL; | |
| size_bases = PyTuple_GET_SIZE(bases); | |
| for (i = 0; i < size_bases; i++) { | |
| base = PyTuple_GET_ITEM(bases, i); | |
| if (PyType_Check(base)) { | |
| if (new_bases) { | |
| if (PyList_Append(new_bases, base) < 0) { | |
| goto error; | |
| } | |
| } | |
| continue; | |
| } | |
| meth = __Pyx_PyObject_GetAttrStrNoError(base, __pyx_n_s_mro_entries); | |
| if (!meth && PyErr_Occurred()) { | |
| goto error; | |
| } | |
| if (!meth) { | |
| if (new_bases) { | |
| if (PyList_Append(new_bases, base) < 0) { | |
| goto error; | |
| } | |
| } | |
| continue; | |
| } | |
| new_base = __Pyx_PyObject_CallOneArg(meth, bases); | |
| Py_DECREF(meth); | |
| if (!new_base) { | |
| goto error; | |
| } | |
| if (!PyTuple_Check(new_base)) { | |
| PyErr_SetString(PyExc_TypeError, | |
| "__mro_entries__ must return a tuple"); | |
| Py_DECREF(new_base); | |
| goto error; | |
| } | |
| if (!new_bases) { | |
| if (!(new_bases = PyList_New(i))) { | |
| goto error; | |
| } | |
| for (j = 0; j < i; j++) { | |
| base = PyTuple_GET_ITEM(bases, j); | |
| PyList_SET_ITEM(new_bases, j, base); | |
| Py_INCREF(base); | |
| } | |
| } | |
| j = PyList_GET_SIZE(new_bases); | |
| if (PyList_SetSlice(new_bases, j, j, new_base) < 0) { | |
| goto error; | |
| } | |
| Py_DECREF(new_base); | |
| } | |
| if (!new_bases) { | |
| Py_INCREF(bases); | |
| return bases; | |
| } | |
| result = PyList_AsTuple(new_bases); | |
| Py_DECREF(new_bases); | |
| return result; | |
| error: | |
| Py_XDECREF(new_bases); | |
| return NULL; | |
| } | |
| /* CalculateMetaclass */ | |
| static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) { | |
| Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases); | |
| for (i=0; i < nbases; i++) { | |
| PyTypeObject *tmptype; | |
| PyObject *tmp = PyTuple_GET_ITEM(bases, i); | |
| tmptype = Py_TYPE(tmp); | |
| if (tmptype == &PyClass_Type) | |
| continue; | |
| if (!metaclass) { | |
| metaclass = tmptype; | |
| continue; | |
| } | |
| if (PyType_IsSubtype(metaclass, tmptype)) | |
| continue; | |
| if (PyType_IsSubtype(tmptype, metaclass)) { | |
| metaclass = tmptype; | |
| continue; | |
| } | |
| PyErr_SetString(PyExc_TypeError, | |
| "metaclass conflict: " | |
| "the metaclass of a derived class " | |
| "must be a (non-strict) subclass " | |
| "of the metaclasses of all its bases"); | |
| return NULL; | |
| } | |
| if (!metaclass) { | |
| metaclass = &PyClass_Type; | |
| metaclass = &PyType_Type; | |
| } | |
| Py_INCREF((PyObject*) metaclass); | |
| return (PyObject*) metaclass; | |
| } | |
| /* PyObjectCall2Args */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { | |
| PyObject *args[3] = {NULL, arg1, arg2}; | |
| return __Pyx_PyObject_FastCall(function, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); | |
| } | |
| /* PyObjectLookupSpecial */ | |
| static CYTHON_INLINE PyObject* __Pyx__PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name, int with_error) { | |
| PyObject *res; | |
| PyTypeObject *tp = Py_TYPE(obj); | |
| if (unlikely(PyInstance_Check(obj))) | |
| return with_error ? __Pyx_PyObject_GetAttrStr(obj, attr_name) : __Pyx_PyObject_GetAttrStrNoError(obj, attr_name); | |
| res = _PyType_Lookup(tp, attr_name); | |
| if (likely(res)) { | |
| descrgetfunc f = Py_TYPE(res)->tp_descr_get; | |
| if (!f) { | |
| Py_INCREF(res); | |
| } else { | |
| res = f(res, obj, (PyObject *)tp); | |
| } | |
| } else if (with_error) { | |
| PyErr_SetObject(PyExc_AttributeError, attr_name); | |
| } | |
| return res; | |
| } | |
| /* Py3ClassCreate */ | |
| static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, | |
| PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) { | |
| PyObject *ns; | |
| if (metaclass) { | |
| PyObject *prep = __Pyx_PyObject_GetAttrStrNoError(metaclass, __pyx_n_s_prepare); | |
| if (prep) { | |
| PyObject *pargs[3] = {NULL, name, bases}; | |
| ns = __Pyx_PyObject_FastCallDict(prep, pargs+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, mkw); | |
| Py_DECREF(prep); | |
| } else { | |
| if (unlikely(PyErr_Occurred())) | |
| return NULL; | |
| ns = PyDict_New(); | |
| } | |
| } else { | |
| ns = PyDict_New(); | |
| } | |
| if (unlikely(!ns)) | |
| return NULL; | |
| if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad; | |
| if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad; | |
| CYTHON_MAYBE_UNUSED_VAR(qualname); | |
| if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad; | |
| return ns; | |
| bad: | |
| Py_DECREF(ns); | |
| return NULL; | |
| } | |
| static int __Pyx_SetNamesPEP487(PyObject *type_obj) { | |
| PyTypeObject *type = (PyTypeObject*) type_obj; | |
| PyObject *names_to_set, *key, *value, *set_name, *tmp; | |
| Py_ssize_t i = 0; | |
| names_to_set = PyDict_Copy(type->tp_dict); | |
| { | |
| PyObject *d = PyObject_GetAttr(type_obj, __pyx_n_s_dict); | |
| names_to_set = NULL; | |
| if (likely(d)) { | |
| PyObject *names_to_set = PyDict_New(); | |
| int ret = likely(names_to_set) ? PyDict_Update(names_to_set, d) : -1; | |
| Py_DECREF(d); | |
| if (unlikely(ret < 0)) | |
| Py_CLEAR(names_to_set); | |
| } | |
| } | |
| if (unlikely(names_to_set == NULL)) | |
| goto bad; | |
| while (PyDict_Next(names_to_set, &i, &key, &value)) { | |
| set_name = __Pyx_PyObject_LookupSpecialNoError(value, __pyx_n_s_set_name); | |
| if (unlikely(set_name != NULL)) { | |
| tmp = __Pyx_PyObject_Call2Args(set_name, type_obj, key); | |
| Py_DECREF(set_name); | |
| if (unlikely(tmp == NULL)) { | |
| __Pyx_TypeName value_type_name = | |
| __Pyx_PyType_GetName(Py_TYPE(value)); | |
| __Pyx_TypeName type_name = __Pyx_PyType_GetName(type); | |
| PyErr_Format(PyExc_RuntimeError, | |
| "Error calling __set_name__ on '" __Pyx_FMT_TYPENAME "' instance %R " "in '" __Pyx_FMT_TYPENAME "'", | |
| value_type_name, key, type_name); | |
| "Error calling __set_name__ on '" __Pyx_FMT_TYPENAME "' instance %.100s in '" __Pyx_FMT_TYPENAME "'", | |
| value_type_name, | |
| PyString_Check(key) ? PyString_AS_STRING(key) : "?", | |
| type_name); | |
| goto bad; | |
| } else { | |
| Py_DECREF(tmp); | |
| } | |
| } | |
| else if (unlikely(PyErr_Occurred())) { | |
| goto bad; | |
| } | |
| } | |
| Py_DECREF(names_to_set); | |
| return 0; | |
| bad: | |
| Py_XDECREF(names_to_set); | |
| return -1; | |
| } | |
| static PyObject *__Pyx_InitSubclassPEP487(PyObject *type_obj, PyObject *mkw) { | |
| PyTypeObject *type = (PyTypeObject*) type_obj; | |
| PyObject *mro = type->tp_mro; | |
| Py_ssize_t i, nbases; | |
| if (unlikely(!mro)) goto done; | |
| (void) &__Pyx_GetBuiltinName; | |
| Py_INCREF(mro); | |
| nbases = PyTuple_GET_SIZE(mro); | |
| assert(PyTuple_GET_ITEM(mro, 0) == type_obj); | |
| for (i = 1; i < nbases-1; i++) { | |
| PyObject *base, *dict, *meth; | |
| base = PyTuple_GET_ITEM(mro, i); | |
| dict = ((PyTypeObject *)base)->tp_dict; | |
| meth = __Pyx_PyDict_GetItemStrWithError(dict, __pyx_n_s_init_subclass); | |
| if (unlikely(meth)) { | |
| descrgetfunc f = Py_TYPE(meth)->tp_descr_get; | |
| PyObject *res; | |
| Py_INCREF(meth); | |
| if (likely(f)) { | |
| res = f(meth, NULL, type_obj); | |
| Py_DECREF(meth); | |
| if (unlikely(!res)) goto bad; | |
| meth = res; | |
| } | |
| res = __Pyx_PyObject_FastCallDict(meth, NULL, 0, mkw); | |
| Py_DECREF(meth); | |
| if (unlikely(!res)) goto bad; | |
| Py_DECREF(res); | |
| goto done; | |
| } else if (unlikely(PyErr_Occurred())) { | |
| goto bad; | |
| } | |
| } | |
| done: | |
| Py_XDECREF(mro); | |
| return type_obj; | |
| bad: | |
| Py_XDECREF(mro); | |
| Py_DECREF(type_obj); | |
| return NULL; | |
| PyObject *super_type, *super, *func, *res; | |
| super_type = __Pyx_GetBuiltinName(__pyx_n_s_super); | |
| super_type = (PyObject*) &PySuper_Type; | |
| (void) &__Pyx_GetBuiltinName; | |
| super = likely(super_type) ? __Pyx_PyObject_Call2Args(super_type, type_obj, type_obj) : NULL; | |
| Py_XDECREF(super_type); | |
| if (unlikely(!super)) { | |
| Py_CLEAR(type_obj); | |
| goto done; | |
| } | |
| func = __Pyx_PyObject_GetAttrStrNoError(super, __pyx_n_s_init_subclass); | |
| Py_DECREF(super); | |
| if (likely(!func)) { | |
| if (unlikely(PyErr_Occurred())) | |
| Py_CLEAR(type_obj); | |
| goto done; | |
| } | |
| res = __Pyx_PyObject_FastCallDict(func, NULL, 0, mkw); | |
| Py_DECREF(func); | |
| if (unlikely(!res)) | |
| Py_CLEAR(type_obj); | |
| Py_XDECREF(res); | |
| done: | |
| return type_obj; | |
| } | |
| static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, | |
| PyObject *dict, PyObject *mkw, | |
| int calculate_metaclass, int allow_py2_metaclass) { | |
| PyObject *result; | |
| PyObject *owned_metaclass = NULL; | |
| PyObject *margs[4] = {NULL, name, bases, dict}; | |
| if (allow_py2_metaclass) { | |
| owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass); | |
| if (owned_metaclass) { | |
| metaclass = owned_metaclass; | |
| } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) { | |
| PyErr_Clear(); | |
| } else { | |
| return NULL; | |
| } | |
| } | |
| if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) { | |
| metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases); | |
| Py_XDECREF(owned_metaclass); | |
| if (unlikely(!metaclass)) | |
| return NULL; | |
| owned_metaclass = metaclass; | |
| } | |
| result = __Pyx_PyObject_FastCallDict(metaclass, margs+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, | |
| (metaclass == (PyObject*)&PyType_Type) ? NULL : mkw | |
| mkw | |
| ); | |
| Py_XDECREF(owned_metaclass); | |
| if (likely(result) && likely(PyType_Check(result))) { | |
| if (unlikely(__Pyx_SetNamesPEP487(result) < 0)) { | |
| Py_CLEAR(result); | |
| } else { | |
| result = __Pyx_InitSubclassPEP487(result, mkw); | |
| } | |
| } | |
| (void) &__Pyx_GetBuiltinName; | |
| return result; | |
| } | |
| /* PyDictVersioning */ | |
| static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { | |
| PyObject *dict = Py_TYPE(obj)->tp_dict; | |
| return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; | |
| } | |
| static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { | |
| PyObject **dictptr = NULL; | |
| Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; | |
| if (offset) { | |
| dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); | |
| dictptr = _PyObject_GetDictPtr(obj); | |
| } | |
| return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; | |
| } | |
| static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { | |
| PyObject *dict = Py_TYPE(obj)->tp_dict; | |
| if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) | |
| return 0; | |
| return obj_dict_version == __Pyx_get_object_dict_version(obj); | |
| } | |
| /* GetModuleGlobalName */ | |
| static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) | |
| static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) | |
| { | |
| PyObject *result; | |
| result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); | |
| __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) | |
| if (likely(result)) { | |
| return __Pyx_NewRef(result); | |
| } else if (unlikely(PyErr_Occurred())) { | |
| return NULL; | |
| } | |
| if (unlikely(!__pyx_m)) { | |
| return NULL; | |
| } | |
| result = PyObject_GetAttr(__pyx_m, name); | |
| if (likely(result)) { | |
| return result; | |
| } | |
| result = PyDict_GetItem(__pyx_d, name); | |
| __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) | |
| if (likely(result)) { | |
| return __Pyx_NewRef(result); | |
| } | |
| result = PyObject_GetItem(__pyx_d, name); | |
| __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) | |
| if (likely(result)) { | |
| return __Pyx_NewRef(result); | |
| } | |
| PyErr_Clear(); | |
| return __Pyx_GetBuiltinName(name); | |
| } | |
| /* CLineInTraceback */ | |
| static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) { | |
| PyObject *use_cline; | |
| PyObject *ptype, *pvalue, *ptraceback; | |
| PyObject **cython_runtime_dict; | |
| CYTHON_MAYBE_UNUSED_VAR(tstate); | |
| if (unlikely(!__pyx_cython_runtime)) { | |
| return c_line; | |
| } | |
| __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); | |
| cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); | |
| if (likely(cython_runtime_dict)) { | |
| __PYX_PY_DICT_LOOKUP_IF_MODIFIED( | |
| use_cline, *cython_runtime_dict, | |
| __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) | |
| } else | |
| { | |
| PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStrNoError(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); | |
| if (use_cline_obj) { | |
| use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; | |
| Py_DECREF(use_cline_obj); | |
| } else { | |
| PyErr_Clear(); | |
| use_cline = NULL; | |
| } | |
| } | |
| if (!use_cline) { | |
| c_line = 0; | |
| (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); | |
| } | |
| else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { | |
| c_line = 0; | |
| } | |
| __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); | |
| return c_line; | |
| } | |
| /* CodeObjectCache */ | |
| static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { | |
| int start = 0, mid = 0, end = count - 1; | |
| if (end >= 0 && code_line > entries[end].code_line) { | |
| return count; | |
| } | |
| while (start < end) { | |
| mid = start + (end - start) / 2; | |
| if (code_line < entries[mid].code_line) { | |
| end = mid; | |
| } else if (code_line > entries[mid].code_line) { | |
| start = mid + 1; | |
| } else { | |
| return mid; | |
| } | |
| } | |
| if (code_line <= entries[mid].code_line) { | |
| return mid; | |
| } else { | |
| return mid + 1; | |
| } | |
| } | |
| static PyCodeObject *__pyx_find_code_object(int code_line) { | |
| PyCodeObject* code_object; | |
| int pos; | |
| if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { | |
| return NULL; | |
| } | |
| pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); | |
| if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { | |
| return NULL; | |
| } | |
| code_object = __pyx_code_cache.entries[pos].code_object; | |
| Py_INCREF(code_object); | |
| return code_object; | |
| } | |
| static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { | |
| int pos, i; | |
| __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; | |
| if (unlikely(!code_line)) { | |
| return; | |
| } | |
| if (unlikely(!entries)) { | |
| entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); | |
| if (likely(entries)) { | |
| __pyx_code_cache.entries = entries; | |
| __pyx_code_cache.max_count = 64; | |
| __pyx_code_cache.count = 1; | |
| entries[0].code_line = code_line; | |
| entries[0].code_object = code_object; | |
| Py_INCREF(code_object); | |
| } | |
| return; | |
| } | |
| pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); | |
| if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { | |
| PyCodeObject* tmp = entries[pos].code_object; | |
| entries[pos].code_object = code_object; | |
| Py_DECREF(tmp); | |
| return; | |
| } | |
| if (__pyx_code_cache.count == __pyx_code_cache.max_count) { | |
| int new_max = __pyx_code_cache.max_count + 64; | |
| entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( | |
| __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); | |
| if (unlikely(!entries)) { | |
| return; | |
| } | |
| __pyx_code_cache.entries = entries; | |
| __pyx_code_cache.max_count = new_max; | |
| } | |
| for (i=__pyx_code_cache.count; i>pos; i--) { | |
| entries[i] = entries[i-1]; | |
| } | |
| entries[pos].code_line = code_line; | |
| entries[pos].code_object = code_object; | |
| __pyx_code_cache.count++; | |
| Py_INCREF(code_object); | |
| } | |
| /* AddTraceback */ | |
| static void __Pyx_AddTraceback(const char *funcname, int c_line, | |
| int py_line, const char *filename) { | |
| if (c_line) { | |
| (void) __pyx_cfilenm; | |
| (void) __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line); | |
| } | |
| _PyTraceback_Add(funcname, filename, py_line); | |
| } | |
| static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( | |
| const char *funcname, int c_line, | |
| int py_line, const char *filename) { | |
| PyCodeObject *py_code = NULL; | |
| PyObject *py_funcname = NULL; | |
| PyObject *py_srcfile = NULL; | |
| py_srcfile = PyString_FromString(filename); | |
| if (!py_srcfile) goto bad; | |
| if (c_line) { | |
| py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); | |
| if (!py_funcname) goto bad; | |
| py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); | |
| if (!py_funcname) goto bad; | |
| funcname = PyUnicode_AsUTF8(py_funcname); | |
| if (!funcname) goto bad; | |
| } | |
| else { | |
| py_funcname = PyString_FromString(funcname); | |
| if (!py_funcname) goto bad; | |
| } | |
| py_code = __Pyx_PyCode_New( | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| 0, | |
| __pyx_empty_bytes, /*PyObject *code,*/ | |
| __pyx_empty_tuple, /*PyObject *consts,*/ | |
| __pyx_empty_tuple, /*PyObject *names,*/ | |
| __pyx_empty_tuple, /*PyObject *varnames,*/ | |
| __pyx_empty_tuple, /*PyObject *freevars,*/ | |
| __pyx_empty_tuple, /*PyObject *cellvars,*/ | |
| py_srcfile, /*PyObject *filename,*/ | |
| py_funcname, /*PyObject *name,*/ | |
| py_line, | |
| __pyx_empty_bytes /*PyObject *lnotab*/ | |
| ); | |
| Py_DECREF(py_srcfile); | |
| py_code = PyCode_NewEmpty(filename, funcname, py_line); | |
| Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline | |
| return py_code; | |
| bad: | |
| Py_XDECREF(py_funcname); | |
| Py_XDECREF(py_srcfile); | |
| return NULL; | |
| } | |
| static void __Pyx_AddTraceback(const char *funcname, int c_line, | |
| int py_line, const char *filename) { | |
| PyCodeObject *py_code = 0; | |
| PyFrameObject *py_frame = 0; | |
| PyThreadState *tstate = __Pyx_PyThreadState_Current; | |
| PyObject *ptype, *pvalue, *ptraceback; | |
| if (c_line) { | |
| c_line = __Pyx_CLineForTraceback(tstate, c_line); | |
| } | |
| py_code = __pyx_find_code_object(c_line ? -c_line : py_line); | |
| if (!py_code) { | |
| __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); | |
| py_code = __Pyx_CreateCodeObjectForTraceback( | |
| funcname, c_line, py_line, filename); | |
| if (!py_code) { | |
| /* If the code object creation fails, then we should clear the | |
| fetched exception references and propagate the new exception */ | |
| Py_XDECREF(ptype); | |
| Py_XDECREF(pvalue); | |
| Py_XDECREF(ptraceback); | |
| goto bad; | |
| } | |
| __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); | |
| __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); | |
| } | |
| py_frame = PyFrame_New( | |
| tstate, /*PyThreadState *tstate,*/ | |
| py_code, /*PyCodeObject *code,*/ | |
| __pyx_d, /*PyObject *globals,*/ | |
| 0 /*PyObject *locals*/ | |
| ); | |
| if (!py_frame) goto bad; | |
| __Pyx_PyFrame_SetLineNumber(py_frame, py_line); | |
| PyTraceBack_Here(py_frame); | |
| bad: | |
| Py_XDECREF(py_code); | |
| Py_XDECREF(py_frame); | |
| } | |
| /* FormatTypeName */ | |
| static __Pyx_TypeName | |
| __Pyx_PyType_GetName(PyTypeObject* tp) | |
| { | |
| PyObject *name = __Pyx_PyObject_GetAttrStr((PyObject *)tp, | |
| __pyx_n_s_name); | |
| if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) { | |
| PyErr_Clear(); | |
| Py_XSETREF(name, __Pyx_NewRef(__pyx_n_s__3)); | |
| } | |
| return name; | |
| } | |
| /* CIntToPy */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { | |
| const long neg_one = (long) -1, const_zero = (long) 0; | |
| const int is_unsigned = neg_one > const_zero; | |
| if (is_unsigned) { | |
| if (sizeof(long) < sizeof(long)) { | |
| return PyInt_FromLong((long) value); | |
| } else if (sizeof(long) <= sizeof(unsigned long)) { | |
| return PyLong_FromUnsignedLong((unsigned long) value); | |
| } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { | |
| return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); | |
| } | |
| } else { | |
| if (sizeof(long) <= sizeof(long)) { | |
| return PyInt_FromLong((long) value); | |
| } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { | |
| return PyLong_FromLongLong((PY_LONG_LONG) value); | |
| } | |
| } | |
| { | |
| int one = 1; int little = (int)*(unsigned char *)&one; | |
| unsigned char *bytes = (unsigned char *)&value; | |
| return _PyLong_FromByteArray(bytes, sizeof(long), | |
| little, !is_unsigned); | |
| } | |
| } | |
| /* CIntFromPyVerify */ | |
| /* CIntFromPy */ | |
| static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { | |
| const long neg_one = (long) -1, const_zero = (long) 0; | |
| const int is_unsigned = neg_one > const_zero; | |
| if (likely(PyInt_Check(x))) { | |
| if ((sizeof(long) < sizeof(long))) { | |
| __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) | |
| } else { | |
| long val = PyInt_AS_LONG(x); | |
| if (is_unsigned && unlikely(val < 0)) { | |
| goto raise_neg_overflow; | |
| } | |
| return (long) val; | |
| } | |
| } else | |
| if (likely(PyLong_Check(x))) { | |
| if (is_unsigned) { | |
| if (unlikely(__Pyx_PyLong_IsNeg(x))) { | |
| goto raise_neg_overflow; | |
| } else if (__Pyx_PyLong_IsCompact(x)) { | |
| __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) | |
| } else { | |
| const digit* digits = __Pyx_PyLong_Digits(x); | |
| assert(__Pyx_PyLong_DigitCount(x) > 1); | |
| switch (__Pyx_PyLong_DigitCount(x)) { | |
| case 2: | |
| if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) { | |
| return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); | |
| } | |
| } | |
| break; | |
| case 3: | |
| if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) { | |
| return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); | |
| } | |
| } | |
| break; | |
| case 4: | |
| if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { | |
| __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]))) | |
| } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) { | |
| return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); | |
| } | |
| } | |
| break; | |
| } | |
| } | |
| if (unlikely(Py_SIZE(x) < 0)) { | |
| goto raise_neg_overflow; | |
| } | |
| { | |
| int result = PyObject_RichCompareBool(x, Py_False, Py_LT); | |
| if (unlikely(result < 0)) | |
| return (long) -1; | |
| if (unlikely(result == 1)) | |
| goto raise_neg_overflow; | |
| } | |
| if ((sizeof(long) <= sizeof(unsigned long))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) | |
| } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) | |
| } | |
| } else { | |
| if (__Pyx_PyLong_IsCompact(x)) { | |
| __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) | |
| } else { | |
| const digit* digits = __Pyx_PyLong_Digits(x); | |
| assert(__Pyx_PyLong_DigitCount(x) > 1); | |
| switch (__Pyx_PyLong_SignedDigitCount(x)) { | |
| case -2: | |
| if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { | |
| return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 2: | |
| if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { | |
| return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| case -3: | |
| if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { | |
| return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 3: | |
| if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { | |
| return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| case -4: | |
| if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { | |
| __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]))) | |
| } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { | |
| return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 4: | |
| if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { | |
| __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]))) | |
| } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { | |
| return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| } | |
| } | |
| if ((sizeof(long) <= sizeof(long))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) | |
| } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) | |
| } | |
| } | |
| { | |
| long val; | |
| PyObject *v = __Pyx_PyNumber_IntOrLong(x); | |
| if (likely(v) && !PyLong_Check(v)) { | |
| PyObject *tmp = v; | |
| v = PyNumber_Long(tmp); | |
| Py_DECREF(tmp); | |
| } | |
| if (likely(v)) { | |
| int ret = -1; | |
| int one = 1; int is_little = (int)*(unsigned char *)&one; | |
| unsigned char *bytes = (unsigned char *)&val; | |
| ret = _PyLong_AsByteArray((PyLongObject *)v, | |
| bytes, sizeof(val), | |
| is_little, !is_unsigned); | |
| PyObject *stepval = NULL, *mask = NULL, *shift = NULL; | |
| int bits, remaining_bits, is_negative = 0; | |
| long idigit; | |
| int chunk_size = (sizeof(long) < 8) ? 30 : 62; | |
| if (unlikely(!PyLong_CheckExact(v))) { | |
| PyObject *tmp = v; | |
| v = PyNumber_Long(v); | |
| assert(PyLong_CheckExact(v)); | |
| Py_DECREF(tmp); | |
| if (unlikely(!v)) return (long) -1; | |
| } | |
| if (Py_SIZE(x) == 0) | |
| return (long) 0; | |
| is_negative = Py_SIZE(x) < 0; | |
| { | |
| int result = PyObject_RichCompareBool(x, Py_False, Py_LT); | |
| if (unlikely(result < 0)) | |
| return (long) -1; | |
| is_negative = result == 1; | |
| } | |
| if (is_unsigned && unlikely(is_negative)) { | |
| goto raise_neg_overflow; | |
| } else if (is_negative) { | |
| stepval = PyNumber_Invert(v); | |
| if (unlikely(!stepval)) | |
| return (long) -1; | |
| } else { | |
| stepval = __Pyx_NewRef(v); | |
| } | |
| val = (long) 0; | |
| mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; | |
| shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; | |
| for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) { | |
| PyObject *tmp, *digit; | |
| digit = PyNumber_And(stepval, mask); | |
| if (unlikely(!digit)) goto done; | |
| idigit = PyLong_AsLong(digit); | |
| Py_DECREF(digit); | |
| if (unlikely(idigit < 0)) goto done; | |
| tmp = PyNumber_Rshift(stepval, shift); | |
| if (unlikely(!tmp)) goto done; | |
| Py_DECREF(stepval); stepval = tmp; | |
| val |= ((long) idigit) << bits; | |
| if (Py_SIZE(stepval) == 0) | |
| goto unpacking_done; | |
| } | |
| idigit = PyLong_AsLong(stepval); | |
| if (unlikely(idigit < 0)) goto done; | |
| remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1); | |
| if (unlikely(idigit >= (1L << remaining_bits))) | |
| goto raise_overflow; | |
| val |= ((long) idigit) << bits; | |
| unpacking_done: | |
| if (!is_unsigned) { | |
| if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1)))) | |
| goto raise_overflow; | |
| if (is_negative) | |
| val = ~val; | |
| } | |
| ret = 0; | |
| done: | |
| Py_XDECREF(shift); | |
| Py_XDECREF(mask); | |
| Py_XDECREF(stepval); | |
| Py_DECREF(v); | |
| if (likely(!ret)) | |
| return val; | |
| } | |
| return (long) -1; | |
| } | |
| } else { | |
| long val; | |
| PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); | |
| if (!tmp) return (long) -1; | |
| val = __Pyx_PyInt_As_long(tmp); | |
| Py_DECREF(tmp); | |
| return val; | |
| } | |
| raise_overflow: | |
| PyErr_SetString(PyExc_OverflowError, | |
| "value too large to convert to long"); | |
| return (long) -1; | |
| raise_neg_overflow: | |
| PyErr_SetString(PyExc_OverflowError, | |
| "can't convert negative value to long"); | |
| return (long) -1; | |
| } | |
| /* CIntFromPy */ | |
| static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { | |
| const int neg_one = (int) -1, const_zero = (int) 0; | |
| const int is_unsigned = neg_one > const_zero; | |
| if (likely(PyInt_Check(x))) { | |
| if ((sizeof(int) < sizeof(long))) { | |
| __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) | |
| } else { | |
| long val = PyInt_AS_LONG(x); | |
| if (is_unsigned && unlikely(val < 0)) { | |
| goto raise_neg_overflow; | |
| } | |
| return (int) val; | |
| } | |
| } else | |
| if (likely(PyLong_Check(x))) { | |
| if (is_unsigned) { | |
| if (unlikely(__Pyx_PyLong_IsNeg(x))) { | |
| goto raise_neg_overflow; | |
| } else if (__Pyx_PyLong_IsCompact(x)) { | |
| __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) | |
| } else { | |
| const digit* digits = __Pyx_PyLong_Digits(x); | |
| assert(__Pyx_PyLong_DigitCount(x) > 1); | |
| switch (__Pyx_PyLong_DigitCount(x)) { | |
| case 2: | |
| if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) { | |
| return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); | |
| } | |
| } | |
| break; | |
| case 3: | |
| if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) { | |
| return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); | |
| } | |
| } | |
| break; | |
| case 4: | |
| if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { | |
| __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]))) | |
| } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) { | |
| return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); | |
| } | |
| } | |
| break; | |
| } | |
| } | |
| if (unlikely(Py_SIZE(x) < 0)) { | |
| goto raise_neg_overflow; | |
| } | |
| { | |
| int result = PyObject_RichCompareBool(x, Py_False, Py_LT); | |
| if (unlikely(result < 0)) | |
| return (int) -1; | |
| if (unlikely(result == 1)) | |
| goto raise_neg_overflow; | |
| } | |
| if ((sizeof(int) <= sizeof(unsigned long))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) | |
| } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) | |
| } | |
| } else { | |
| if (__Pyx_PyLong_IsCompact(x)) { | |
| __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) | |
| } else { | |
| const digit* digits = __Pyx_PyLong_Digits(x); | |
| assert(__Pyx_PyLong_DigitCount(x) > 1); | |
| switch (__Pyx_PyLong_SignedDigitCount(x)) { | |
| case -2: | |
| if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { | |
| return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 2: | |
| if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { | |
| return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| case -3: | |
| if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { | |
| return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 3: | |
| if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { | |
| return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| case -4: | |
| if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { | |
| __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]))) | |
| } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { | |
| return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 4: | |
| if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { | |
| __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]))) | |
| } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { | |
| return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| } | |
| } | |
| if ((sizeof(int) <= sizeof(long))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) | |
| } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) | |
| } | |
| } | |
| { | |
| int val; | |
| PyObject *v = __Pyx_PyNumber_IntOrLong(x); | |
| if (likely(v) && !PyLong_Check(v)) { | |
| PyObject *tmp = v; | |
| v = PyNumber_Long(tmp); | |
| Py_DECREF(tmp); | |
| } | |
| if (likely(v)) { | |
| int ret = -1; | |
| int one = 1; int is_little = (int)*(unsigned char *)&one; | |
| unsigned char *bytes = (unsigned char *)&val; | |
| ret = _PyLong_AsByteArray((PyLongObject *)v, | |
| bytes, sizeof(val), | |
| is_little, !is_unsigned); | |
| PyObject *stepval = NULL, *mask = NULL, *shift = NULL; | |
| int bits, remaining_bits, is_negative = 0; | |
| long idigit; | |
| int chunk_size = (sizeof(long) < 8) ? 30 : 62; | |
| if (unlikely(!PyLong_CheckExact(v))) { | |
| PyObject *tmp = v; | |
| v = PyNumber_Long(v); | |
| assert(PyLong_CheckExact(v)); | |
| Py_DECREF(tmp); | |
| if (unlikely(!v)) return (int) -1; | |
| } | |
| if (Py_SIZE(x) == 0) | |
| return (int) 0; | |
| is_negative = Py_SIZE(x) < 0; | |
| { | |
| int result = PyObject_RichCompareBool(x, Py_False, Py_LT); | |
| if (unlikely(result < 0)) | |
| return (int) -1; | |
| is_negative = result == 1; | |
| } | |
| if (is_unsigned && unlikely(is_negative)) { | |
| goto raise_neg_overflow; | |
| } else if (is_negative) { | |
| stepval = PyNumber_Invert(v); | |
| if (unlikely(!stepval)) | |
| return (int) -1; | |
| } else { | |
| stepval = __Pyx_NewRef(v); | |
| } | |
| val = (int) 0; | |
| mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; | |
| shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; | |
| for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) { | |
| PyObject *tmp, *digit; | |
| digit = PyNumber_And(stepval, mask); | |
| if (unlikely(!digit)) goto done; | |
| idigit = PyLong_AsLong(digit); | |
| Py_DECREF(digit); | |
| if (unlikely(idigit < 0)) goto done; | |
| tmp = PyNumber_Rshift(stepval, shift); | |
| if (unlikely(!tmp)) goto done; | |
| Py_DECREF(stepval); stepval = tmp; | |
| val |= ((int) idigit) << bits; | |
| if (Py_SIZE(stepval) == 0) | |
| goto unpacking_done; | |
| } | |
| idigit = PyLong_AsLong(stepval); | |
| if (unlikely(idigit < 0)) goto done; | |
| remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1); | |
| if (unlikely(idigit >= (1L << remaining_bits))) | |
| goto raise_overflow; | |
| val |= ((int) idigit) << bits; | |
| unpacking_done: | |
| if (!is_unsigned) { | |
| if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1)))) | |
| goto raise_overflow; | |
| if (is_negative) | |
| val = ~val; | |
| } | |
| ret = 0; | |
| done: | |
| Py_XDECREF(shift); | |
| Py_XDECREF(mask); | |
| Py_XDECREF(stepval); | |
| Py_DECREF(v); | |
| if (likely(!ret)) | |
| return val; | |
| } | |
| return (int) -1; | |
| } | |
| } else { | |
| int val; | |
| PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); | |
| if (!tmp) return (int) -1; | |
| val = __Pyx_PyInt_As_int(tmp); | |
| Py_DECREF(tmp); | |
| return val; | |
| } | |
| raise_overflow: | |
| PyErr_SetString(PyExc_OverflowError, | |
| "value too large to convert to int"); | |
| return (int) -1; | |
| raise_neg_overflow: | |
| PyErr_SetString(PyExc_OverflowError, | |
| "can't convert negative value to int"); | |
| return (int) -1; | |
| } | |
| /* FastTypeChecks */ | |
| static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { | |
| while (a) { | |
| a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*); | |
| if (a == b) | |
| return 1; | |
| } | |
| return b == &PyBaseObject_Type; | |
| } | |
| static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { | |
| PyObject *mro; | |
| if (a == b) return 1; | |
| mro = a->tp_mro; | |
| if (likely(mro)) { | |
| Py_ssize_t i, n; | |
| n = PyTuple_GET_SIZE(mro); | |
| for (i = 0; i < n; i++) { | |
| if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) | |
| return 1; | |
| } | |
| return 0; | |
| } | |
| return __Pyx_InBases(a, b); | |
| } | |
| static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) { | |
| PyObject *mro; | |
| if (cls == a || cls == b) return 1; | |
| mro = cls->tp_mro; | |
| if (likely(mro)) { | |
| Py_ssize_t i, n; | |
| n = PyTuple_GET_SIZE(mro); | |
| for (i = 0; i < n; i++) { | |
| PyObject *base = PyTuple_GET_ITEM(mro, i); | |
| if (base == (PyObject *)a || base == (PyObject *)b) | |
| return 1; | |
| } | |
| return 0; | |
| } | |
| return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b); | |
| } | |
| static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { | |
| PyObject *exception, *value, *tb; | |
| int res; | |
| __Pyx_PyThreadState_declare | |
| __Pyx_PyThreadState_assign | |
| __Pyx_ErrFetch(&exception, &value, &tb); | |
| res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; | |
| if (unlikely(res == -1)) { | |
| PyErr_WriteUnraisable(err); | |
| res = 0; | |
| } | |
| if (!res) { | |
| res = PyObject_IsSubclass(err, exc_type2); | |
| if (unlikely(res == -1)) { | |
| PyErr_WriteUnraisable(err); | |
| res = 0; | |
| } | |
| } | |
| __Pyx_ErrRestore(exception, value, tb); | |
| return res; | |
| } | |
| static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { | |
| if (exc_type1) { | |
| return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2); | |
| } else { | |
| return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); | |
| } | |
| } | |
| static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { | |
| Py_ssize_t i, n; | |
| assert(PyExceptionClass_Check(exc_type)); | |
| n = PyTuple_GET_SIZE(tuple); | |
| for (i=0; i<n; i++) { | |
| if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1; | |
| } | |
| for (i=0; i<n; i++) { | |
| PyObject *t = PyTuple_GET_ITEM(tuple, i); | |
| if (likely(exc_type == t)) return 1; | |
| if (likely(PyExceptionClass_Check(t))) { | |
| if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1; | |
| } else { | |
| } | |
| } | |
| return 0; | |
| } | |
| static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { | |
| if (likely(err == exc_type)) return 1; | |
| if (likely(PyExceptionClass_Check(err))) { | |
| if (likely(PyExceptionClass_Check(exc_type))) { | |
| return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); | |
| } else if (likely(PyTuple_Check(exc_type))) { | |
| return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type); | |
| } else { | |
| } | |
| } | |
| return PyErr_GivenExceptionMatches(err, exc_type); | |
| } | |
| static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { | |
| assert(PyExceptionClass_Check(exc_type1)); | |
| assert(PyExceptionClass_Check(exc_type2)); | |
| if (likely(err == exc_type1 || err == exc_type2)) return 1; | |
| if (likely(PyExceptionClass_Check(err))) { | |
| return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); | |
| } | |
| return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); | |
| } | |
| /* CheckBinaryVersion */ | |
| static int __Pyx_check_binary_version(void) { | |
| char ctversion[5]; | |
| int same=1, i, found_dot; | |
| const char* rt_from_call = Py_GetVersion(); | |
| PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); | |
| found_dot = 0; | |
| for (i = 0; i < 4; i++) { | |
| if (!ctversion[i]) { | |
| same = (rt_from_call[i] < '0' || rt_from_call[i] > '9'); | |
| break; | |
| } | |
| if (rt_from_call[i] != ctversion[i]) { | |
| same = 0; | |
| break; | |
| } | |
| } | |
| if (!same) { | |
| char rtversion[5] = {'\0'}; | |
| char message[200]; | |
| for (i=0; i<4; ++i) { | |
| if (rt_from_call[i] == '.') { | |
| if (found_dot) break; | |
| found_dot = 1; | |
| } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') { | |
| break; | |
| } | |
| rtversion[i] = rt_from_call[i]; | |
| } | |
| PyOS_snprintf(message, sizeof(message), | |
| "compile time version %s of module '%.100s' " | |
| "does not match runtime version %s", | |
| ctversion, __Pyx_MODULE_NAME, rtversion); | |
| return PyErr_WarnEx(NULL, message, 1); | |
| } | |
| return 0; | |
| } | |
| /* InitStrings */ | |
| static int __Pyx_InitString(__Pyx_StringTabEntry t, PyObject **str) { | |
| if (t.is_unicode | t.is_str) { | |
| if (t.intern) { | |
| *str = PyUnicode_InternFromString(t.s); | |
| } else if (t.encoding) { | |
| *str = PyUnicode_Decode(t.s, t.n - 1, t.encoding, NULL); | |
| } else { | |
| *str = PyUnicode_FromStringAndSize(t.s, t.n - 1); | |
| } | |
| } else { | |
| *str = PyBytes_FromStringAndSize(t.s, t.n - 1); | |
| } | |
| if (!*str) | |
| return -1; | |
| if (PyObject_Hash(*str) == -1) | |
| return -1; | |
| return 0; | |
| } | |
| static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { | |
| while (t->p) { | |
| __Pyx_InitString(*t, t->p); | |
| if (t->is_unicode) { | |
| *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); | |
| } else if (t->intern) { | |
| *t->p = PyString_InternFromString(t->s); | |
| } else { | |
| *t->p = PyString_FromStringAndSize(t->s, t->n - 1); | |
| } | |
| if (!*t->p) | |
| return -1; | |
| if (PyObject_Hash(*t->p) == -1) | |
| return -1; | |
| ++t; | |
| } | |
| return 0; | |
| } | |
| static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { | |
| return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); | |
| } | |
| static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { | |
| Py_ssize_t ignore; | |
| return __Pyx_PyObject_AsStringAndSize(o, &ignore); | |
| } | |
| static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { | |
| char* defenc_c; | |
| PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); | |
| if (!defenc) return NULL; | |
| defenc_c = PyBytes_AS_STRING(defenc); | |
| { | |
| char* end = defenc_c + PyBytes_GET_SIZE(defenc); | |
| char* c; | |
| for (c = defenc_c; c < end; c++) { | |
| if ((unsigned char) (*c) >= 128) { | |
| PyUnicode_AsASCIIString(o); | |
| return NULL; | |
| } | |
| } | |
| } | |
| *length = PyBytes_GET_SIZE(defenc); | |
| return defenc_c; | |
| } | |
| static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { | |
| if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; | |
| if (likely(PyUnicode_IS_ASCII(o))) { | |
| *length = PyUnicode_GET_LENGTH(o); | |
| return PyUnicode_AsUTF8(o); | |
| } else { | |
| PyUnicode_AsASCIIString(o); | |
| return NULL; | |
| } | |
| return PyUnicode_AsUTF8AndSize(o, length); | |
| } | |
| static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { | |
| if ( | |
| __Pyx_sys_getdefaultencoding_not_ascii && | |
| PyUnicode_Check(o)) { | |
| return __Pyx_PyUnicode_AsStringAndSize(o, length); | |
| } else | |
| if (PyByteArray_Check(o)) { | |
| *length = PyByteArray_GET_SIZE(o); | |
| return PyByteArray_AS_STRING(o); | |
| } else | |
| { | |
| char* result; | |
| int r = PyBytes_AsStringAndSize(o, &result, length); | |
| if (unlikely(r < 0)) { | |
| return NULL; | |
| } else { | |
| return result; | |
| } | |
| } | |
| } | |
| static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { | |
| int is_true = x == Py_True; | |
| if (is_true | (x == Py_False) | (x == Py_None)) return is_true; | |
| else return PyObject_IsTrue(x); | |
| } | |
| static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { | |
| int retval; | |
| if (unlikely(!x)) return -1; | |
| retval = __Pyx_PyObject_IsTrue(x); | |
| Py_DECREF(x); | |
| return retval; | |
| } | |
| static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { | |
| __Pyx_TypeName result_type_name = __Pyx_PyType_GetName(Py_TYPE(result)); | |
| if (PyLong_Check(result)) { | |
| if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, | |
| "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). " | |
| "The ability to return an instance of a strict subclass of int is deprecated, " | |
| "and may be removed in a future version of Python.", | |
| result_type_name)) { | |
| __Pyx_DECREF_TypeName(result_type_name); | |
| Py_DECREF(result); | |
| return NULL; | |
| } | |
| __Pyx_DECREF_TypeName(result_type_name); | |
| return result; | |
| } | |
| PyErr_Format(PyExc_TypeError, | |
| "__%.4s__ returned non-%.4s (type " __Pyx_FMT_TYPENAME ")", | |
| type_name, type_name, result_type_name); | |
| __Pyx_DECREF_TypeName(result_type_name); | |
| Py_DECREF(result); | |
| return NULL; | |
| } | |
| static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { | |
| PyNumberMethods *m; | |
| const char *name = NULL; | |
| PyObject *res = NULL; | |
| if (likely(PyInt_Check(x) || PyLong_Check(x))) | |
| if (likely(PyLong_Check(x))) | |
| return __Pyx_NewRef(x); | |
| m = Py_TYPE(x)->tp_as_number; | |
| if (m && m->nb_int) { | |
| name = "int"; | |
| res = m->nb_int(x); | |
| } | |
| else if (m && m->nb_long) { | |
| name = "long"; | |
| res = m->nb_long(x); | |
| } | |
| if (likely(m && m->nb_int)) { | |
| name = "int"; | |
| res = m->nb_int(x); | |
| } | |
| if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { | |
| res = PyNumber_Int(x); | |
| } | |
| if (likely(res)) { | |
| if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { | |
| if (unlikely(!PyLong_CheckExact(res))) { | |
| return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); | |
| } | |
| } | |
| else if (!PyErr_Occurred()) { | |
| PyErr_SetString(PyExc_TypeError, | |
| "an integer is required"); | |
| } | |
| return res; | |
| } | |
| static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { | |
| Py_ssize_t ival; | |
| PyObject *x; | |
| if (likely(PyInt_CheckExact(b))) { | |
| if (sizeof(Py_ssize_t) >= sizeof(long)) | |
| return PyInt_AS_LONG(b); | |
| else | |
| return PyInt_AsSsize_t(b); | |
| } | |
| if (likely(PyLong_CheckExact(b))) { | |
| if (likely(__Pyx_PyLong_IsCompact(b))) { | |
| return __Pyx_PyLong_CompactValue(b); | |
| } else { | |
| const digit* digits = __Pyx_PyLong_Digits(b); | |
| const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b); | |
| switch (size) { | |
| case 2: | |
| if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { | |
| return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); | |
| } | |
| break; | |
| case -2: | |
| if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { | |
| return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); | |
| } | |
| break; | |
| case 3: | |
| if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { | |
| return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); | |
| } | |
| break; | |
| case -3: | |
| if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { | |
| return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); | |
| } | |
| break; | |
| case 4: | |
| if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { | |
| 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])); | |
| } | |
| break; | |
| case -4: | |
| if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { | |
| 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])); | |
| } | |
| break; | |
| } | |
| } | |
| return PyLong_AsSsize_t(b); | |
| } | |
| x = PyNumber_Index(b); | |
| if (!x) return -1; | |
| ival = PyInt_AsSsize_t(x); | |
| Py_DECREF(x); | |
| return ival; | |
| } | |
| static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { | |
| if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { | |
| return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); | |
| } else if (likely(PyInt_CheckExact(o))) { | |
| return PyInt_AS_LONG(o); | |
| } else { | |
| Py_ssize_t ival; | |
| PyObject *x; | |
| x = PyNumber_Index(o); | |
| if (!x) return -1; | |
| ival = PyInt_AsLong(x); | |
| Py_DECREF(x); | |
| return ival; | |
| } | |
| } | |
| static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { | |
| return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); | |
| } | |
| static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { | |
| return PyInt_FromSize_t(ival); | |
| } | |
| /* #### Code section: utility_code_pragmas_end ### */ | |
| /* #### Code section: end ### */ | |