diff -Nru libmacaroons-0.2.0/bindings/python/macaroons.c libmacaroons-0.2.0/bindings/python/macaroons.c --- libmacaroons-0.2.0/bindings/python/macaroons.c 2015-01-21 12:04:48.000000000 +0000 +++ libmacaroons-0.2.0/bindings/python/macaroons.c 2017-01-17 20:05:48.000000000 +0000 @@ -1,28 +1,16 @@ -/* Generated by Cython 0.20.2 (Debian 0.20.2-1) on Wed Jan 21 07:04:47 2015 */ +/* Generated by Cython 0.24.1 */ #define PY_SSIZE_T_CLEAN -#ifndef CYTHON_USE_PYLONG_INTERNALS -#ifdef PYLONG_BITS_IN_DIGIT -#define CYTHON_USE_PYLONG_INTERNALS 0 -#else -#include "pyconfig.h" -#ifdef PYLONG_BITS_IN_DIGIT -#define CYTHON_USE_PYLONG_INTERNALS 1 -#else -#define CYTHON_USE_PYLONG_INTERNALS 0 -#endif -#endif -#endif #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. -#elif PY_VERSION_HEX < 0x02040000 - #error Cython requires Python 2.4+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) + #error Cython requires Python 2.6+ or Python 3.2+. #else -#define CYTHON_ABI "0_20_2" -#include /* For offsetof */ +#define CYTHON_ABI "0_24_1" +#include #ifndef offsetof -#define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) + #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall @@ -48,110 +36,59 @@ #define Py_HUGE_VAL HUGE_VAL #endif #ifdef PYPY_VERSION -#define CYTHON_COMPILING_IN_PYPY 1 -#define CYTHON_COMPILING_IN_CPYTHON 0 + #define CYTHON_COMPILING_IN_PYPY 1 + #define CYTHON_COMPILING_IN_CPYTHON 0 #else -#define CYTHON_COMPILING_IN_PYPY 0 -#define CYTHON_COMPILING_IN_CPYTHON 1 + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_CPYTHON 1 #endif -#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 -#define Py_OptimizeFlag 0 +#if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000 + #define CYTHON_USE_PYLONG_INTERNALS 1 #endif -#if PY_VERSION_HEX < 0x02050000 - typedef int Py_ssize_t; - #define PY_SSIZE_T_MAX INT_MAX - #define PY_SSIZE_T_MIN INT_MIN - #define PY_FORMAT_SIZE_T "" - #define CYTHON_FORMAT_SSIZE_T "" - #define PyInt_FromSsize_t(z) PyInt_FromLong(z) - #define PyInt_AsSsize_t(o) __Pyx_PyInt_As_int(o) - #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \ - (PyErr_Format(PyExc_TypeError, \ - "expected index value, got %.200s", Py_TYPE(o)->tp_name), \ - (PyObject*)0)) - #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \ - !PyComplex_Check(o)) - #define PyIndex_Check __Pyx_PyIndex_Check - #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message) - #define __PYX_BUILD_PY_SSIZE_T "i" -#else - #define __PYX_BUILD_PY_SSIZE_T "n" - #define CYTHON_FORMAT_SSIZE_T "z" - #define __Pyx_PyIndex_Check PyIndex_Check -#endif -#if PY_VERSION_HEX < 0x02060000 - #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) - #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) - #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) - #define PyVarObject_HEAD_INIT(type, size) \ - PyObject_HEAD_INIT(type) size, - #define PyType_Modified(t) - typedef struct { - void *buf; - PyObject *obj; - Py_ssize_t len; - Py_ssize_t itemsize; - int readonly; - int ndim; - char *format; - Py_ssize_t *shape; - Py_ssize_t *strides; - Py_ssize_t *suboffsets; - void *internal; - } Py_buffer; - #define PyBUF_SIMPLE 0 - #define PyBUF_WRITABLE 0x0001 - #define PyBUF_FORMAT 0x0004 - #define PyBUF_ND 0x0008 - #define PyBUF_STRIDES (0x0010 | PyBUF_ND) - #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) - #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) - #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) - #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) - #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE) - #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE) - typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); - typedef void (*releasebufferproc)(PyObject *, Py_buffer *); +#if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #undef SHIFT + #undef BASE + #undef MASK #endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) + #define Py_OptimizeFlag 0 +#endif +#define __PYX_BUILD_PY_SSIZE_T "n" +#define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyType_Type #endif -#if PY_VERSION_HEX < 0x02060000 - #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict") -#endif -#if PY_MAJOR_VERSION >= 3 +#ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 +#endif +#ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif -#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) +#ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif -#if PY_VERSION_HEX < 0x02060000 - #define Py_TPFLAGS_HAVE_VERSION_TAG 0 -#endif -#if PY_VERSION_HEX < 0x02060000 && !defined(Py_TPFLAGS_IS_ABSTRACT) - #define Py_TPFLAGS_IS_ABSTRACT 0 -#endif -#if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE) +#ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 - #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #else #define CYTHON_PEP393_ENABLED 0 #define __Pyx_PyUnicode_READY(op) (0) @@ -160,22 +97,40 @@ #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \ + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif -#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) + #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) + #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) + #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) + #define PyObject_Malloc(s) PyMem_Malloc(s) + #define PyObject_Free(p) PyMem_Free(p) + #define PyObject_Realloc(p) PyMem_Realloc(p) +#endif +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif +#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) + #define PyObject_ASCII(o) PyObject_Repr(o) +#endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject @@ -183,36 +138,13 @@ #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #endif -#if PY_VERSION_HEX < 0x02060000 - #define PyBytesObject PyStringObject - #define PyBytes_Type PyString_Type - #define PyBytes_Check PyString_Check - #define PyBytes_CheckExact PyString_CheckExact - #define PyBytes_FromString PyString_FromString - #define PyBytes_FromStringAndSize PyString_FromStringAndSize - #define PyBytes_FromFormat PyString_FromFormat - #define PyBytes_DecodeEscape PyString_DecodeEscape - #define PyBytes_AsString PyString_AsString - #define PyBytes_AsStringAndSize PyString_AsStringAndSize - #define PyBytes_Size PyString_Size - #define PyBytes_AS_STRING PyString_AS_STRING - #define PyBytes_GET_SIZE PyString_GET_SIZE - #define PyBytes_Repr PyString_Repr - #define PyBytes_Concat PyString_Concat - #define PyBytes_ConcatAndDel PyString_ConcatAndDel -#endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else - #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \ - PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif -#if PY_VERSION_HEX < 0x02060000 - #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) - #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type) -#endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif @@ -237,6 +169,11 @@ #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif +#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY + #ifndef PyUnicode_InternFromString + #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) + #endif +#endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong @@ -245,43 +182,37 @@ #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif -#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300) - #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b) - #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value) - #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b) -#else - #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \ - (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \ - (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \ - (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0))) - #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \ - (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ - (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \ - (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1))) - #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \ - (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ - (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \ - (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1))) -#endif #if PY_MAJOR_VERSION >= 3 - #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) +#else + #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif -#if PY_VERSION_HEX < 0x02050000 - #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n))) - #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a)) - #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n))) -#else - #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n)) - #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a)) - #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n)) -#endif -#if PY_VERSION_HEX < 0x02050000 - #define __Pyx_NAMESTR(n) ((char *)(n)) - #define __Pyx_DOCSTR(n) ((char *)(n)) +#if PY_VERSION_HEX >= 0x030500B1 +#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods +#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) +#elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 +typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; +} __Pyx_PyAsyncMethodsStruct; +#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #else - #define __Pyx_NAMESTR(n) (n) - #define __Pyx_DOCSTR(n) (n) +#define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif #endif +#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) + #ifndef CYTHON_INLINE #if defined(__GNUC__) #define CYTHON_INLINE __inline__ @@ -293,37 +224,32 @@ #define CYTHON_INLINE #endif #endif -#ifndef CYTHON_RESTRICT - #if defined(__GNUC__) - #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) && _MSC_VER >= 1400 - #define CYTHON_RESTRICT __restrict - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_RESTRICT restrict - #else - #define CYTHON_RESTRICT - #endif + +#if defined(WIN32) || defined(MS_WINDOWS) + #define _USE_MATH_DEFINES #endif +#include #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { - /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and - a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is - a quiet NaN. */ float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif -#ifdef __cplusplus -template -void __Pyx_call_destructor(T* x) { - x->~T(); -} +#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) +#define __Pyx_truncl trunc +#else +#define __Pyx_truncl truncl #endif +#define __PYX_ERR(f_index, lineno, Ln_error) \ +{ \ + __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ +} + #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) @@ -340,10 +266,6 @@ #endif #endif -#if defined(WIN32) || defined(MS_WINDOWS) -#define _USE_MATH_DEFINES -#endif -#include #define __PYX_HAVE__macaroons #define __PYX_HAVE_API__macaroons #include "stdlib.h" @@ -369,24 +291,49 @@ # define CYTHON_UNUSED # endif #endif -typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; - const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/ +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif +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; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#define __Pyx_fits_Py_ssize_t(v, type, is_signed) ( \ - (sizeof(type) < sizeof(Py_ssize_t)) || \ - (sizeof(type) > sizeof(Py_ssize_t) && \ - likely(v < (type)PY_SSIZE_T_MAX || \ - v == (type)PY_SSIZE_T_MAX) && \ - (!is_signed || likely(v > (type)PY_SSIZE_T_MIN || \ - v == (type)PY_SSIZE_T_MIN))) || \ - (sizeof(type) == sizeof(Py_ssize_t) && \ - (is_signed || likely(v < (type)PY_SSIZE_T_MAX || \ +#define __Pyx_uchar_cast(c) ((unsigned char)c) +#define __Pyx_long_cast(x) ((long)x) +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ + (sizeof(type) < sizeof(Py_ssize_t)) ||\ + (sizeof(type) > sizeof(Py_ssize_t) &&\ + likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX) &&\ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ + v == (type)PY_SSIZE_T_MIN))) ||\ + (sizeof(type) == sizeof(Py_ssize_t) &&\ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) +#if defined (__cplusplus) && __cplusplus >= 201103L + #include + #define __Pyx_sst_abs(value) std::abs(value) +#elif SIZEOF_INT >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) abs(value) +#elif SIZEOF_LONG >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) labs(value) +#elif defined (_MSC_VER) && defined (_M_X64) + #define __Pyx_sst_abs(value) _abs64(value) +#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define __Pyx_sst_abs(value) llabs(value) +#elif defined (__GNUC__) + #define __Pyx_sst_abs(value) __builtin_llabs(value) +#else + #define __Pyx_sst_abs(value) ((value<0) ? -value : value) +#endif static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) @@ -403,11 +350,11 @@ #endif #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((const char*)s) -#define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((const char*)s) -#define __Pyx_PyByteArray_FromUString(s) __Pyx_PyByteArray_FromString((const char*)s) -#define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((const char*)s) -#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((const char*)s) +#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) +#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) +#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) +#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) +#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #if PY_MAJOR_VERSION < 3 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { @@ -421,10 +368,11 @@ #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode -#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None) -#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) +#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) +#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) +#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); -static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); +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); #if CYTHON_COMPILING_IN_CPYTHON @@ -433,6 +381,12 @@ #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) +#else +#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) +#endif +#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { @@ -443,7 +397,7 @@ const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); @@ -523,6 +477,7 @@ static PyObject *__pyx_b; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; +static PyObject *__pyx_empty_unicode; static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; @@ -530,7 +485,7 @@ static const char *__pyx_f[] = { - "macaroons.pyx", + "bindings/python/macaroons.pyx", }; /*--- Type declarations ---*/ @@ -578,6 +533,9 @@ PyObject *(*assert_not_null)(struct __pyx_obj_9macaroons_Macaroon *); }; static struct __pyx_vtabstruct_9macaroons_Macaroon *__pyx_vtabptr_9macaroons_Macaroon; + +/* --- Runtime support code (head) --- */ +/* Refnanny.proto */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif @@ -591,22 +549,22 @@ void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/ + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD - #define __Pyx_RefNannySetupContext(name, acquire_gil) \ - if (acquire_gil) { \ - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ - PyGILState_Release(__pyx_gilstate_save); \ - } else { \ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + if (acquire_gil) {\ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + PyGILState_Release(__pyx_gilstate_save);\ + } else {\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ } #else - #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) #endif - #define __Pyx_RefNannyFinishContext() \ + #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) @@ -628,18 +586,19 @@ #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) -#endif /* CYTHON_REFNANNY */ -#define __Pyx_XDECREF_SET(r, v) do { \ - PyObject *tmp = (PyObject *) r; \ - r = v; __Pyx_XDECREF(tmp); \ +#endif +#define __Pyx_XDECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_XDECREF(tmp);\ } while (0) -#define __Pyx_DECREF_SET(r, v) do { \ - PyObject *tmp = (PyObject *) r; \ - r = v; __Pyx_DECREF(tmp); \ +#define __Pyx_DECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) +/* PyObjectGetAttrStr.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); @@ -655,38 +614,96 @@ #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif -static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/ +/* GetBuiltinName.proto */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name); -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/ +/* GetModuleGlobalName.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); -static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value); /*proto*/ +/* dict_getitem_default.proto */ +static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value); +/* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); /*proto*/ +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif -static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ -static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ +/* PyObjectCallMethO.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); +#endif + +/* PyObjectCallOneArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); + +/* PyThreadStateGet.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; +#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#endif + +/* PyErrFetchRestore.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) +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); +#else +#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) +#endif -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/ +/* RaiseException.proto */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); +/* RaiseArgTupleInvalid.proto */ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); -static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*proto*/ +/* KeywordStringCheck.proto */ +static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ +/* GetException.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); +#endif -static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ +/* SwapException.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); +#endif -static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ -static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ +/* SaveResetException.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +#else +#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) +#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) +#endif +/* ArgTypeTest.proto */ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); /*proto*/ + const char *name, int exact); +/* ListAppend.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; @@ -703,40 +720,41 @@ #define __Pyx_PyList_Append(L,x) PyList_Append(L,x) #endif -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/ +/* RaiseDoubleKeywords.proto */ +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ - const char* function_name); /*proto*/ +/* ParseKeywords.proto */ +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ + const char* function_name); + +/* PyIntBinop.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace); +#else +#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\ + (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) +#endif -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ +/* ExtTypeTest.proto */ +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); -static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ +/* SetVTable.proto */ +static int __Pyx_SetVtable(PyObject *dict, void *vtable); +/* CalculateMetaclass.proto */ static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases); +/* Py3ClassCreate.proto */ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, - PyObject *mkw, PyObject *modname, PyObject *doc); /*proto*/ + 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); /*proto*/ - -static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name); /*proto*/ - -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value); - -static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *); - -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); - -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); - -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); - -static int __Pyx_check_binary_version(void); + PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); +/* CodeObjectCache.proto */ typedef struct { - int code_line; PyCodeObject* code_object; + int code_line; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; @@ -748,11 +766,35 @@ 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); /*proto*/ + int py_line, const char *filename); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__macaroon_returncode(enum macaroon_returncode value); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value); + +/* CIntFromPy.proto */ +static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ +/* CIntFromPy.proto */ +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); + +/* CIntFromPy.proto */ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); + +/* CheckBinaryVersion.proto */ +static int __Pyx_check_binary_version(void); + +/* InitStrings.proto */ +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); +static PyObject *__pyx_f_9macaroons_8Macaroon_assert_not_null(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto*/ /* Module declarations from 'macaroons' */ static PyTypeObject *__pyx_ptype_9macaroons_Macaroon = 0; @@ -764,86 +806,57 @@ /* Implementation of 'macaroons' */ static PyObject *__pyx_builtin_Exception; -static PyObject *__pyx_builtin_property; static PyObject *__pyx_builtin_MemoryError; static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_enumerate; -static int __pyx_pf_9macaroons_8Macaroon___cinit__(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ -static void __pyx_pf_9macaroons_8Macaroon_2__dealloc__(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Macaroon_4validate(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Macaroon_6location(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Macaroon_8identifier(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Macaroon_10signature(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Macaroon_12copy(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Macaroon_14serialize(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Macaroon_16serialize_json(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Macaroon_18inspect(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Macaroon_20is_same(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, struct __pyx_obj_9macaroons_Macaroon *__pyx_v_M); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Macaroon_22third_party_caveats(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Macaroon_24prepare_for_request(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, struct __pyx_obj_9macaroons_Macaroon *__pyx_v_D); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Macaroon_26add_first_party_caveat(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, PyObject *__pyx_v_predicate); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Macaroon_28add_third_party_caveat(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, PyObject *__pyx_v__location, PyObject *__pyx_v__key, PyObject *__pyx_v__key_id); /* proto */ -static int __pyx_pf_9macaroons_8Verifier___cinit__(struct __pyx_obj_9macaroons_Verifier *__pyx_v_self); /* proto */ -static void __pyx_pf_9macaroons_8Verifier_2__dealloc__(struct __pyx_obj_9macaroons_Verifier *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Verifier_4satisfy_exact(struct __pyx_obj_9macaroons_Verifier *__pyx_v_self, PyObject *__pyx_v_pred); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Verifier_6satisfy_general(struct __pyx_obj_9macaroons_Verifier *__pyx_v_self, PyObject *__pyx_v_func); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Verifier_8verify(struct __pyx_obj_9macaroons_Verifier *__pyx_v_self, struct __pyx_obj_9macaroons_Macaroon *__pyx_v_M, PyObject *__pyx_v_key, PyObject *__pyx_v_MS); /* proto */ -static PyObject *__pyx_pf_9macaroons_8Verifier_10verify_unsafe(struct __pyx_obj_9macaroons_Verifier *__pyx_v_self, struct __pyx_obj_9macaroons_Macaroon *__pyx_v_M, PyObject *__pyx_v_key, PyObject *__pyx_v_MS); /* proto */ -static PyObject *__pyx_pf_9macaroons_create(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v__location, PyObject *__pyx_v__key, PyObject *__pyx_v__key_id); /* proto */ -static PyObject *__pyx_pf_9macaroons_2deserialize(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_m); /* proto */ -static PyObject *__pyx_tp_new_9macaroons_Macaroon(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_9macaroons_Verifier(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static char __pyx_k_M[] = "M"; -static char __pyx_k_m[] = "m"; -static char __pyx_k_MS[] = "MS"; -static char __pyx_k_doc[] = "__doc__"; -static char __pyx_k_err[] = "err"; -static char __pyx_k_get[] = "get"; -static char __pyx_k_hex[] = "hex"; -static char __pyx_k_key[] = "_key"; -static char __pyx_k_main[] = "__main__"; -static char __pyx_k_test[] = "__test__"; -static char __pyx_k_key_2[] = "key"; -static char __pyx_k_range[] = "range"; -static char __pyx_k_create[] = "create"; -static char __pyx_k_encode[] = "encode"; -static char __pyx_k_key_id[] = "_key_id"; -static char __pyx_k_key_sz[] = "key_sz"; -static char __pyx_k_module[] = "__module__"; -static char __pyx_k_prepare[] = "__prepare__"; -static char __pyx_k_key_id_2[] = "key_id"; -static char __pyx_k_location[] = "_location"; -static char __pyx_k_property[] = "property"; -static char __pyx_k_qualname[] = "__qualname__"; -static char __pyx_k_Exception[] = "Exception"; -static char __pyx_k_enumerate[] = "enumerate"; -static char __pyx_k_key_id_sz[] = "key_id_sz"; -static char __pyx_k_macaroons[] = "macaroons"; -static char __pyx_k_metaclass[] = "__metaclass__"; -static char __pyx_k_signature[] = "signature"; -static char __pyx_k_ValueError[] = "ValueError"; -static char __pyx_k_identifier[] = "identifier"; -static char __pyx_k_location_2[] = "location"; -static char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; -static char __pyx_k_MemoryError[] = "MemoryError"; -static char __pyx_k_deserialize[] = "deserialize"; -static char __pyx_k_location_sz[] = "location_sz"; -static char __pyx_k_Unauthorized[] = "Unauthorized"; -static char __pyx_k_MacaroonError[] = "MacaroonError"; -static char __pyx_k_verify_unsafe[] = "verify_unsafe"; -static char __pyx_k_not_authorized[] = "not authorized"; -static char __pyx_k_buffer_too_small[] = "buffer too small"; -static char __pyx_k_macaroon_invalid[] = "macaroon invalid"; -static char __pyx_k_too_many_caveats[] = "too many caveats"; -static char __pyx_k_HMAC_function_failed[] = "HMAC function failed"; -static char __pyx_k_SUGGESTED_SECRET_LENGTH[] = "SUGGESTED_SECRET_LENGTH"; -static char __pyx_k_macaroon_not_authorized[] = "macaroon not authorized"; -static char __pyx_k_macaroon_not_initialized[] = "macaroon not initialized"; -static char __pyx_k_JSON_macaroons_not_supported[] = "JSON macaroons not supported"; -static char __pyx_k_operation_failed_unexpectedly[] = "operation failed unexpectedly"; -static char __pyx_k_discharge_caveats_form_a_cycle[] = "discharge caveats form a cycle"; -static char __pyx_k_home_jrwren_src_debs_libmacaroo[] = "/home/jrwren/src/debs/libmacaroons/bindings/python/macaroons.pyx"; +static const char __pyx_k_M[] = "M"; +static const char __pyx_k_m[] = "m"; +static const char __pyx_k_MS[] = "MS"; +static const char __pyx_k_doc[] = "__doc__"; +static const char __pyx_k_err[] = "err"; +static const char __pyx_k_get[] = "get"; +static const char __pyx_k_hex[] = "hex"; +static const char __pyx_k_key[] = "_key"; +static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_key_2[] = "key"; +static const char __pyx_k_range[] = "range"; +static const char __pyx_k_create[] = "create"; +static const char __pyx_k_encode[] = "encode"; +static const char __pyx_k_key_id[] = "_key_id"; +static const char __pyx_k_key_sz[] = "key_sz"; +static const char __pyx_k_module[] = "__module__"; +static const char __pyx_k_prepare[] = "__prepare__"; +static const char __pyx_k_key_id_2[] = "key_id"; +static const char __pyx_k_location[] = "_location"; +static const char __pyx_k_qualname[] = "__qualname__"; +static const char __pyx_k_Exception[] = "Exception"; +static const char __pyx_k_enumerate[] = "enumerate"; +static const char __pyx_k_key_id_sz[] = "key_id_sz"; +static const char __pyx_k_macaroons[] = "macaroons"; +static const char __pyx_k_metaclass[] = "__metaclass__"; +static const char __pyx_k_ValueError[] = "ValueError"; +static const char __pyx_k_location_2[] = "location"; +static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; +static const char __pyx_k_MemoryError[] = "MemoryError"; +static const char __pyx_k_deserialize[] = "deserialize"; +static const char __pyx_k_location_sz[] = "location_sz"; +static const char __pyx_k_Unauthorized[] = "Unauthorized"; +static const char __pyx_k_MacaroonError[] = "MacaroonError"; +static const char __pyx_k_verify_unsafe[] = "verify_unsafe"; +static const char __pyx_k_not_authorized[] = "not authorized"; +static const char __pyx_k_buffer_too_small[] = "buffer too small"; +static const char __pyx_k_macaroon_invalid[] = "macaroon invalid"; +static const char __pyx_k_too_many_caveats[] = "too many caveats"; +static const char __pyx_k_HMAC_function_failed[] = "HMAC function failed"; +static const char __pyx_k_SUGGESTED_SECRET_LENGTH[] = "SUGGESTED_SECRET_LENGTH"; +static const char __pyx_k_macaroon_not_authorized[] = "macaroon not authorized"; +static const char __pyx_k_macaroon_not_initialized[] = "macaroon not initialized"; +static const char __pyx_k_JSON_macaroons_not_supported[] = "JSON macaroons not supported"; +static const char __pyx_k_operation_failed_unexpectedly[] = "operation failed unexpectedly"; +static const char __pyx_k_discharge_caveats_form_a_cycle[] = "discharge caveats form a cycle"; +static const char __pyx_k_home_bac_git_libmacaroons_bindi[] = "/home/bac/git/libmacaroons/bindings/python/macaroons.pyx"; static PyObject *__pyx_n_s_Exception; static PyObject *__pyx_kp_s_HMAC_function_failed; static PyObject *__pyx_kp_s_JSON_macaroons_not_supported; @@ -864,8 +877,7 @@ static PyObject *__pyx_n_s_err; static PyObject *__pyx_n_s_get; static PyObject *__pyx_n_s_hex; -static PyObject *__pyx_kp_s_home_jrwren_src_debs_libmacaroo; -static PyObject *__pyx_n_s_identifier; +static PyObject *__pyx_kp_s_home_bac_git_libmacaroons_bindi; static PyObject *__pyx_n_s_key; static PyObject *__pyx_n_s_key_2; static PyObject *__pyx_n_s_key_id; @@ -886,14 +898,37 @@ static PyObject *__pyx_kp_s_not_authorized; static PyObject *__pyx_kp_s_operation_failed_unexpectedly; static PyObject *__pyx_n_s_prepare; -static PyObject *__pyx_n_s_property; static PyObject *__pyx_n_s_pyx_vtable; static PyObject *__pyx_n_s_qualname; static PyObject *__pyx_n_s_range; -static PyObject *__pyx_n_s_signature; static PyObject *__pyx_n_s_test; static PyObject *__pyx_kp_s_too_many_caveats; static PyObject *__pyx_n_s_verify_unsafe; +static int __pyx_pf_9macaroons_8Macaroon___cinit__(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ +static void __pyx_pf_9macaroons_8Macaroon_2__dealloc__(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Macaroon_4validate(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Macaroon_8location___get__(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Macaroon_10identifier___get__(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Macaroon_9signature___get__(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Macaroon_6copy(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Macaroon_8serialize(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Macaroon_10serialize_json(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Macaroon_12inspect(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Macaroon_14is_same(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, struct __pyx_obj_9macaroons_Macaroon *__pyx_v_M); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Macaroon_16third_party_caveats(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Macaroon_18prepare_for_request(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, struct __pyx_obj_9macaroons_Macaroon *__pyx_v_D); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Macaroon_20add_first_party_caveat(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, PyObject *__pyx_v_predicate); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Macaroon_22add_third_party_caveat(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, PyObject *__pyx_v__location, PyObject *__pyx_v__key, PyObject *__pyx_v__key_id); /* proto */ +static int __pyx_pf_9macaroons_8Verifier___cinit__(struct __pyx_obj_9macaroons_Verifier *__pyx_v_self); /* proto */ +static void __pyx_pf_9macaroons_8Verifier_2__dealloc__(struct __pyx_obj_9macaroons_Verifier *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Verifier_4satisfy_exact(struct __pyx_obj_9macaroons_Verifier *__pyx_v_self, PyObject *__pyx_v_pred); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Verifier_6satisfy_general(struct __pyx_obj_9macaroons_Verifier *__pyx_v_self, PyObject *__pyx_v_func); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Verifier_8verify(struct __pyx_obj_9macaroons_Verifier *__pyx_v_self, struct __pyx_obj_9macaroons_Macaroon *__pyx_v_M, PyObject *__pyx_v_key, PyObject *__pyx_v_MS); /* proto */ +static PyObject *__pyx_pf_9macaroons_8Verifier_10verify_unsafe(struct __pyx_obj_9macaroons_Verifier *__pyx_v_self, struct __pyx_obj_9macaroons_Macaroon *__pyx_v_M, PyObject *__pyx_v_key, PyObject *__pyx_v_MS); /* proto */ +static PyObject *__pyx_pf_9macaroons_create(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v__location, PyObject *__pyx_v__key, PyObject *__pyx_v__key_id); /* proto */ +static PyObject *__pyx_pf_9macaroons_2deserialize(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_m); /* proto */ +static PyObject *__pyx_tp_new_9macaroons_Macaroon(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_9macaroons_Verifier(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; static PyObject *__pyx_int_32; @@ -921,9 +956,8 @@ PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; __Pyx_RefNannySetupContext("raise_error", 0); /* "macaroons.pyx":88 @@ -943,7 +977,15 @@ * X = {MACAROON_HASH_FAILED: 'HMAC function failed', * MACAROON_INVALID: 'macaroon invalid', */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyErr_NoMemory(); __PYX_ERR(0, 89, __pyx_L1_error) + + /* "macaroons.pyx":88 + * + * cdef raise_error(macaroon_returncode err): + * if err == MACAROON_OUT_OF_MEMORY: # <<<<<<<<<<<<<< + * raise MemoryError + * X = {MACAROON_HASH_FAILED: 'HMAC function failed', + */ } /* "macaroons.pyx":90 @@ -953,11 +995,11 @@ * MACAROON_INVALID: 'macaroon invalid', * MACAROON_TOO_MANY_CAVEATS: 'too many caveats', */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyInt_FromLong(MACAROON_HASH_FAILED); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_From_enum__macaroon_returncode(MACAROON_HASH_FAILED); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_kp_s_HMAC_function_failed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_kp_s_HMAC_function_failed) < 0) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "macaroons.pyx":91 @@ -967,9 +1009,9 @@ * MACAROON_TOO_MANY_CAVEATS: 'too many caveats', * MACAROON_CYCLE: 'discharge caveats form a cycle', */ - __pyx_t_3 = PyInt_FromLong(MACAROON_INVALID); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_From_enum__macaroon_returncode(MACAROON_INVALID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_kp_s_macaroon_invalid) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_kp_s_macaroon_invalid) < 0) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "macaroons.pyx":92 @@ -979,9 +1021,9 @@ * MACAROON_CYCLE: 'discharge caveats form a cycle', * MACAROON_BUF_TOO_SMALL: 'buffer too small', */ - __pyx_t_3 = PyInt_FromLong(MACAROON_TOO_MANY_CAVEATS); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_From_enum__macaroon_returncode(MACAROON_TOO_MANY_CAVEATS); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_kp_s_too_many_caveats) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_kp_s_too_many_caveats) < 0) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "macaroons.pyx":93 @@ -991,9 +1033,9 @@ * MACAROON_BUF_TOO_SMALL: 'buffer too small', * MACAROON_NOT_AUTHORIZED: 'not authorized', */ - __pyx_t_3 = PyInt_FromLong(MACAROON_CYCLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_From_enum__macaroon_returncode(MACAROON_CYCLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_kp_s_discharge_caveats_form_a_cycle) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_kp_s_discharge_caveats_form_a_cycle) < 0) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "macaroons.pyx":94 @@ -1003,9 +1045,9 @@ * MACAROON_NOT_AUTHORIZED: 'not authorized', * MACAROON_NO_JSON_SUPPORT: 'JSON macaroons not supported'} */ - __pyx_t_3 = PyInt_FromLong(MACAROON_BUF_TOO_SMALL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_From_enum__macaroon_returncode(MACAROON_BUF_TOO_SMALL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_kp_s_buffer_too_small) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_kp_s_buffer_too_small) < 0) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "macaroons.pyx":95 @@ -1015,9 +1057,9 @@ * MACAROON_NO_JSON_SUPPORT: 'JSON macaroons not supported'} * raise MacaroonError(X.get(err, 'operation failed unexpectedly')) */ - __pyx_t_3 = PyInt_FromLong(MACAROON_NOT_AUTHORIZED); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_From_enum__macaroon_returncode(MACAROON_NOT_AUTHORIZED); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_kp_s_not_authorized) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_kp_s_not_authorized) < 0) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "macaroons.pyx":96 @@ -1027,9 +1069,9 @@ * raise MacaroonError(X.get(err, 'operation failed unexpectedly')) * */ - __pyx_t_3 = PyInt_FromLong(MACAROON_NO_JSON_SUPPORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_From_enum__macaroon_returncode(MACAROON_NO_JSON_SUPPORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_kp_s_JSON_macaroons_not_supported) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_kp_s_JSON_macaroons_not_supported) < 0) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_X = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; @@ -1041,25 +1083,42 @@ * * */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_MacaroonError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyInt_FromLong(__pyx_v_err); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_MacaroonError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyDict_GetItemDefault(__pyx_v_X, __pyx_t_3, __pyx_kp_s_operation_failed_unexpectedly); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyInt_From_enum__macaroon_returncode(__pyx_v_err); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyDict_GetItemDefault(__pyx_v_X, __pyx_t_4, __pyx_kp_s_operation_failed_unexpectedly); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 97, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (!__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 97, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __PYX_ERR(0, 97, __pyx_L1_error) /* "macaroons.pyx":87 * @@ -1074,6 +1133,8 @@ __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("macaroons.raise_error", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __Pyx_XDECREF(__pyx_v_X); @@ -1185,9 +1246,15 @@ * def validate(self): */ __pyx_v_self->_M = NULL; - goto __pyx_L3; + + /* "macaroons.pyx":107 + * + * def __dealloc__(self): + * if self._M != NULL: # <<<<<<<<<<<<<< + * macaroon_destroy(self._M) + * self._M = NULL + */ } - __pyx_L3:; /* "macaroons.pyx":106 * self._M = NULL @@ -1226,9 +1293,6 @@ PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("validate", 0); /* "macaroons.pyx":112 @@ -1239,7 +1303,7 @@ * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong((macaroon_validate(__pyx_v_self->_M) == 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong((macaroon_validate(__pyx_v_self->_M) == 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1273,28 +1337,25 @@ */ /* Python wrapper */ -static PyObject *__pyx_pw_9macaroons_8Macaroon_7location(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_9macaroons_8Macaroon_7location(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_9macaroons_8Macaroon_8location_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_9macaroons_8Macaroon_8location_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("location (wrapper)", 0); - __pyx_r = __pyx_pf_9macaroons_8Macaroon_6location(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_9macaroons_8Macaroon_8location___get__(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9macaroons_8Macaroon_6location(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { +static PyObject *__pyx_pf_9macaroons_8Macaroon_8location___get__(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { unsigned char const *__pyx_v_location; size_t __pyx_v_location_sz; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("location", 0); + __Pyx_RefNannySetupContext("__get__", 0); /* "macaroons.pyx":116 * @property @@ -1321,7 +1382,7 @@ * macaroon_location(self._M, &location, &location_sz) * return location[:location_sz] */ - __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1342,7 +1403,7 @@ * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_location) + 0, __pyx_v_location_sz - 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_location) + 0, __pyx_v_location_sz - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1359,7 +1420,7 @@ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("macaroons.Macaroon.location", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("macaroons.Macaroon.location.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1376,28 +1437,25 @@ */ /* Python wrapper */ -static PyObject *__pyx_pw_9macaroons_8Macaroon_9identifier(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_9macaroons_8Macaroon_9identifier(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_9macaroons_8Macaroon_10identifier_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_9macaroons_8Macaroon_10identifier_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("identifier (wrapper)", 0); - __pyx_r = __pyx_pf_9macaroons_8Macaroon_8identifier(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_9macaroons_8Macaroon_10identifier___get__(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9macaroons_8Macaroon_8identifier(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { +static PyObject *__pyx_pf_9macaroons_8Macaroon_10identifier___get__(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { unsigned char const *__pyx_v_identifier; size_t __pyx_v_identifier_sz; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("identifier", 0); + __Pyx_RefNannySetupContext("__get__", 0); /* "macaroons.pyx":124 * @property @@ -1424,7 +1482,7 @@ * macaroon_identifier(self._M, &identifier, &identifier_sz) * return identifier[:identifier_sz] */ - __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1445,7 +1503,7 @@ * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_identifier) + 0, __pyx_v_identifier_sz - 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_identifier) + 0, __pyx_v_identifier_sz - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -1462,7 +1520,7 @@ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("macaroons.Macaroon.identifier", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("macaroons.Macaroon.identifier.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1479,29 +1537,26 @@ */ /* Python wrapper */ -static PyObject *__pyx_pw_9macaroons_8Macaroon_11signature(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_9macaroons_8Macaroon_11signature(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_9macaroons_8Macaroon_9signature_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_9macaroons_8Macaroon_9signature_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("signature (wrapper)", 0); - __pyx_r = __pyx_pf_9macaroons_8Macaroon_10signature(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_9macaroons_8Macaroon_9signature___get__(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9macaroons_8Macaroon_10signature(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { +static PyObject *__pyx_pf_9macaroons_8Macaroon_9signature___get__(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { unsigned char const *__pyx_v_signature; size_t __pyx_v_signature_sz; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("signature", 0); + __Pyx_RefNannySetupContext("__get__", 0); /* "macaroons.pyx":132 * @property @@ -1528,7 +1583,7 @@ * macaroon_signature(self._M, &signature, &signature_sz) * return (signature[:signature_sz]).encode('hex') */ - __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1549,12 +1604,12 @@ * def copy(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_signature) + 0, __pyx_v_signature_sz - 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_signature) + 0, __pyx_v_signature_sz - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -1573,7 +1628,7 @@ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("macaroons.Macaroon.signature", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("macaroons.Macaroon.signature.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1590,28 +1645,25 @@ */ /* Python wrapper */ -static PyObject *__pyx_pw_9macaroons_8Macaroon_13copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_9macaroons_8Macaroon_13copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_9macaroons_8Macaroon_7copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_9macaroons_8Macaroon_7copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("copy (wrapper)", 0); - __pyx_r = __pyx_pf_9macaroons_8Macaroon_12copy(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); + __pyx_r = __pyx_pf_9macaroons_8Macaroon_6copy(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9macaroons_8Macaroon_12copy(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { +static PyObject *__pyx_pf_9macaroons_8Macaroon_6copy(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { enum macaroon_returncode __pyx_v_err; struct __pyx_obj_9macaroons_Macaroon *__pyx_v_M = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("copy", 0); /* "macaroons.pyx":139 @@ -1621,7 +1673,7 @@ * cdef macaroon_returncode err * cdef Macaroon M = Macaroon() */ - __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1632,7 +1684,7 @@ * M._M = macaroon_copy(self._M, &err) * if M._M == NULL: */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9macaroons_Macaroon)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9macaroons_Macaroon), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_M = ((struct __pyx_obj_9macaroons_Macaroon *)__pyx_t_1); __pyx_t_1 = 0; @@ -1663,12 +1715,18 @@ * return M * */ - __pyx_t_1 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L3; + + /* "macaroons.pyx":143 + * cdef Macaroon M = Macaroon() + * M._M = macaroon_copy(self._M, &err) + * if M._M == NULL: # <<<<<<<<<<<<<< + * raise_error(err) + * return M + */ } - __pyx_L3:; /* "macaroons.pyx":145 * if M._M == NULL: @@ -1711,19 +1769,19 @@ */ /* Python wrapper */ -static PyObject *__pyx_pw_9macaroons_8Macaroon_15serialize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_9macaroons_8Macaroon_15serialize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_9macaroons_8Macaroon_9serialize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_9macaroons_8Macaroon_9serialize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("serialize (wrapper)", 0); - __pyx_r = __pyx_pf_9macaroons_8Macaroon_14serialize(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); + __pyx_r = __pyx_pf_9macaroons_8Macaroon_8serialize(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9macaroons_8Macaroon_14serialize(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { +static PyObject *__pyx_pf_9macaroons_8Macaroon_8serialize(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { char *__pyx_v_data; size_t __pyx_v_data_sz; enum macaroon_returncode __pyx_v_err; @@ -1741,9 +1799,6 @@ PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("serialize", 0); /* "macaroons.pyx":148 @@ -1771,7 +1826,7 @@ * try: * data_sz = macaroon_serialize_size_hint(self._M) */ - __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1819,7 +1874,15 @@ * if macaroon_serialize(self._M, data, data_sz, &err) < 0: * raise_error(err) */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + PyErr_NoMemory(); __PYX_ERR(0, 156, __pyx_L4_error) + + /* "macaroons.pyx":155 + * data_sz = macaroon_serialize_size_hint(self._M) + * data = malloc(sizeof(unsigned char) * data_sz) + * if data == NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * if macaroon_serialize(self._M, data, data_sz, &err) < 0: + */ } /* "macaroons.pyx":157 @@ -1839,12 +1902,18 @@ * return bytes(data) * finally: */ - __pyx_t_1 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_1 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L7; + + /* "macaroons.pyx":157 + * if data == NULL: + * raise MemoryError + * if macaroon_serialize(self._M, data, data_sz, &err) < 0: # <<<<<<<<<<<<<< + * raise_error(err) + * return bytes(data) + */ } - __pyx_L7:; /* "macaroons.pyx":159 * if macaroon_serialize(self._M, data, data_sz, &err) < 0: @@ -1854,14 +1923,14 @@ * if data != NULL: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 159, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyBytes_Type))), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyBytes_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; @@ -1878,8 +1947,10 @@ */ /*finally:*/ { /*exception exit:*/{ + __Pyx_PyThreadState_declare __pyx_L4_error:; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; + __Pyx_PyThreadState_assign __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); @@ -1903,10 +1974,17 @@ * def serialize_json(self): */ free(__pyx_v_data); - goto __pyx_L10; + + /* "macaroons.pyx":161 + * return bytes(data) + * finally: + * if data != NULL: # <<<<<<<<<<<<<< + * free(data) + * + */ } - __pyx_L10:; } + __Pyx_PyThreadState_assign if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); @@ -1924,14 +2002,6 @@ __pyx_L3_return: { __pyx_t_12 = __pyx_r; __pyx_r = 0; - - /* "macaroons.pyx":161 - * return bytes(data) - * finally: - * if data != NULL: # <<<<<<<<<<<<<< - * free(data) - * - */ __pyx_t_2 = ((__pyx_v_data != NULL) != 0); if (__pyx_t_2) { @@ -1943,9 +2013,15 @@ * def serialize_json(self): */ free(__pyx_v_data); - goto __pyx_L11; + + /* "macaroons.pyx":161 + * return bytes(data) + * finally: + * if data != NULL: # <<<<<<<<<<<<<< + * free(data) + * + */ } - __pyx_L11:; __pyx_r = __pyx_t_12; __pyx_t_12 = 0; goto __pyx_L0; @@ -1981,19 +2057,19 @@ */ /* Python wrapper */ -static PyObject *__pyx_pw_9macaroons_8Macaroon_17serialize_json(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_9macaroons_8Macaroon_17serialize_json(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_9macaroons_8Macaroon_11serialize_json(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_9macaroons_8Macaroon_11serialize_json(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("serialize_json (wrapper)", 0); - __pyx_r = __pyx_pf_9macaroons_8Macaroon_16serialize_json(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); + __pyx_r = __pyx_pf_9macaroons_8Macaroon_10serialize_json(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9macaroons_8Macaroon_16serialize_json(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { +static PyObject *__pyx_pf_9macaroons_8Macaroon_10serialize_json(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { char *__pyx_v_data; size_t __pyx_v_data_sz; enum macaroon_returncode __pyx_v_err; @@ -2011,9 +2087,6 @@ PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("serialize_json", 0); /* "macaroons.pyx":165 @@ -2041,7 +2114,7 @@ * try: * data_sz = macaroon_serialize_json_size_hint(self._M) */ - __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2089,7 +2162,15 @@ * if macaroon_serialize_json(self._M, data, data_sz, &err) < 0: * raise_error(err) */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + PyErr_NoMemory(); __PYX_ERR(0, 173, __pyx_L4_error) + + /* "macaroons.pyx":172 + * data_sz = macaroon_serialize_json_size_hint(self._M) + * data = malloc(sizeof(unsigned char) * data_sz) + * if data == NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * if macaroon_serialize_json(self._M, data, data_sz, &err) < 0: + */ } /* "macaroons.pyx":174 @@ -2109,12 +2190,18 @@ * return bytes(data) * finally: */ - __pyx_t_1 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_1 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L7; + + /* "macaroons.pyx":174 + * if data == NULL: + * raise MemoryError + * if macaroon_serialize_json(self._M, data, data_sz, &err) < 0: # <<<<<<<<<<<<<< + * raise_error(err) + * return bytes(data) + */ } - __pyx_L7:; /* "macaroons.pyx":176 * if macaroon_serialize_json(self._M, data, data_sz, &err) < 0: @@ -2124,14 +2211,14 @@ * if data != NULL: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyBytes_Type))), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyBytes_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; @@ -2148,8 +2235,10 @@ */ /*finally:*/ { /*exception exit:*/{ + __Pyx_PyThreadState_declare __pyx_L4_error:; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; + __Pyx_PyThreadState_assign __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); @@ -2173,10 +2262,17 @@ * def inspect(self): */ free(__pyx_v_data); - goto __pyx_L10; + + /* "macaroons.pyx":178 + * return bytes(data) + * finally: + * if data != NULL: # <<<<<<<<<<<<<< + * free(data) + * + */ } - __pyx_L10:; } + __Pyx_PyThreadState_assign if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); @@ -2194,14 +2290,6 @@ __pyx_L3_return: { __pyx_t_12 = __pyx_r; __pyx_r = 0; - - /* "macaroons.pyx":178 - * return bytes(data) - * finally: - * if data != NULL: # <<<<<<<<<<<<<< - * free(data) - * - */ __pyx_t_2 = ((__pyx_v_data != NULL) != 0); if (__pyx_t_2) { @@ -2213,11 +2301,17 @@ * def inspect(self): */ free(__pyx_v_data); - goto __pyx_L11; - } - __pyx_L11:; - __pyx_r = __pyx_t_12; - __pyx_t_12 = 0; + + /* "macaroons.pyx":178 + * return bytes(data) + * finally: + * if data != NULL: # <<<<<<<<<<<<<< + * free(data) + * + */ + } + __pyx_r = __pyx_t_12; + __pyx_t_12 = 0; goto __pyx_L0; } } @@ -2251,19 +2345,19 @@ */ /* Python wrapper */ -static PyObject *__pyx_pw_9macaroons_8Macaroon_19inspect(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_9macaroons_8Macaroon_19inspect(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_9macaroons_8Macaroon_13inspect(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_9macaroons_8Macaroon_13inspect(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("inspect (wrapper)", 0); - __pyx_r = __pyx_pf_9macaroons_8Macaroon_18inspect(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); + __pyx_r = __pyx_pf_9macaroons_8Macaroon_12inspect(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9macaroons_8Macaroon_18inspect(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { +static PyObject *__pyx_pf_9macaroons_8Macaroon_12inspect(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { char *__pyx_v_data; size_t __pyx_v_data_sz; enum macaroon_returncode __pyx_v_err; @@ -2281,9 +2375,6 @@ PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("inspect", 0); /* "macaroons.pyx":182 @@ -2311,7 +2402,7 @@ * try: * data_sz = macaroon_inspect_size_hint(self._M) */ - __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2359,7 +2450,15 @@ * if macaroon_inspect(self._M, data, data_sz, &err) < 0: * raise_error(err) */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + PyErr_NoMemory(); __PYX_ERR(0, 190, __pyx_L4_error) + + /* "macaroons.pyx":189 + * data_sz = macaroon_inspect_size_hint(self._M) + * data = malloc(sizeof(unsigned char) * data_sz) + * if data == NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * if macaroon_inspect(self._M, data, data_sz, &err) < 0: + */ } /* "macaroons.pyx":191 @@ -2379,12 +2478,18 @@ * return bytes(data) * finally: */ - __pyx_t_1 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_1 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L7; + + /* "macaroons.pyx":191 + * if data == NULL: + * raise MemoryError + * if macaroon_inspect(self._M, data, data_sz, &err) < 0: # <<<<<<<<<<<<<< + * raise_error(err) + * return bytes(data) + */ } - __pyx_L7:; /* "macaroons.pyx":193 * if macaroon_inspect(self._M, data, data_sz, &err) < 0: @@ -2394,14 +2499,14 @@ * if data != NULL: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyBytes_Type))), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyBytes_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; @@ -2418,8 +2523,10 @@ */ /*finally:*/ { /*exception exit:*/{ + __Pyx_PyThreadState_declare __pyx_L4_error:; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; + __Pyx_PyThreadState_assign __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); @@ -2443,10 +2550,17 @@ * def is_same(self, Macaroon M): */ free(__pyx_v_data); - goto __pyx_L10; + + /* "macaroons.pyx":195 + * return bytes(data) + * finally: + * if data != NULL: # <<<<<<<<<<<<<< + * free(data) + * + */ } - __pyx_L10:; } + __Pyx_PyThreadState_assign if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); @@ -2464,14 +2578,6 @@ __pyx_L3_return: { __pyx_t_12 = __pyx_r; __pyx_r = 0; - - /* "macaroons.pyx":195 - * return bytes(data) - * finally: - * if data != NULL: # <<<<<<<<<<<<<< - * free(data) - * - */ __pyx_t_2 = ((__pyx_v_data != NULL) != 0); if (__pyx_t_2) { @@ -2483,9 +2589,15 @@ * def is_same(self, Macaroon M): */ free(__pyx_v_data); - goto __pyx_L11; + + /* "macaroons.pyx":195 + * return bytes(data) + * finally: + * if data != NULL: # <<<<<<<<<<<<<< + * free(data) + * + */ } - __pyx_L11:; __pyx_r = __pyx_t_12; __pyx_t_12 = 0; goto __pyx_L0; @@ -2521,16 +2633,13 @@ */ /* Python wrapper */ -static PyObject *__pyx_pw_9macaroons_8Macaroon_21is_same(PyObject *__pyx_v_self, PyObject *__pyx_v_M); /*proto*/ -static PyObject *__pyx_pw_9macaroons_8Macaroon_21is_same(PyObject *__pyx_v_self, PyObject *__pyx_v_M) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; +static PyObject *__pyx_pw_9macaroons_8Macaroon_15is_same(PyObject *__pyx_v_self, PyObject *__pyx_v_M); /*proto*/ +static PyObject *__pyx_pw_9macaroons_8Macaroon_15is_same(PyObject *__pyx_v_self, PyObject *__pyx_v_M) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_same (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_M), __pyx_ptype_9macaroons_Macaroon, 1, "M", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_9macaroons_8Macaroon_20is_same(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self), ((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_M)); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_M), __pyx_ptype_9macaroons_Macaroon, 1, "M", 0))) __PYX_ERR(0, 198, __pyx_L1_error) + __pyx_r = __pyx_pf_9macaroons_8Macaroon_14is_same(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self), ((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_M)); /* function exit code */ goto __pyx_L0; @@ -2541,13 +2650,10 @@ return __pyx_r; } -static PyObject *__pyx_pf_9macaroons_8Macaroon_20is_same(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, struct __pyx_obj_9macaroons_Macaroon *__pyx_v_M) { +static PyObject *__pyx_pf_9macaroons_8Macaroon_14is_same(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, struct __pyx_obj_9macaroons_Macaroon *__pyx_v_M) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("is_same", 0); /* "macaroons.pyx":199 @@ -2557,7 +2663,7 @@ * M.assert_not_null() * return macaroon_cmp(self._M, M._M) == 0 */ - __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2568,7 +2674,7 @@ * return macaroon_cmp(self._M, M._M) == 0 * */ - __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_M->__pyx_vtab)->assert_not_null(__pyx_v_M); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_M->__pyx_vtab)->assert_not_null(__pyx_v_M); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2580,7 +2686,7 @@ * def third_party_caveats(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong((macaroon_cmp(__pyx_v_self->_M, __pyx_v_M->_M) == 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong((macaroon_cmp(__pyx_v_self->_M, __pyx_v_M->_M) == 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 201, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2614,19 +2720,19 @@ */ /* Python wrapper */ -static PyObject *__pyx_pw_9macaroons_8Macaroon_23third_party_caveats(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_9macaroons_8Macaroon_23third_party_caveats(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_9macaroons_8Macaroon_17third_party_caveats(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_9macaroons_8Macaroon_17third_party_caveats(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("third_party_caveats (wrapper)", 0); - __pyx_r = __pyx_pf_9macaroons_8Macaroon_22third_party_caveats(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); + __pyx_r = __pyx_pf_9macaroons_8Macaroon_16third_party_caveats(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9macaroons_8Macaroon_22third_party_caveats(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { +static PyObject *__pyx_pf_9macaroons_8Macaroon_16third_party_caveats(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self) { unsigned char const *__pyx_v_location; size_t __pyx_v_location_sz; unsigned char const *__pyx_v_identifier; @@ -2643,9 +2749,6 @@ PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("third_party_caveats", 0); /* "macaroons.pyx":204 @@ -2655,7 +2758,7 @@ * cdef const unsigned char* location = NULL * cdef size_t location_sz = 0 */ - __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2711,7 +2814,7 @@ * for i in range(num): * if macaroon_third_party_caveat(self._M, i, */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_ids = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; @@ -2735,6 +2838,14 @@ * ids.append((location[:location_sz], identifier[:identifier_sz])) */ __pyx_t_4 = ((macaroon_third_party_caveat(__pyx_v_self->_M, __pyx_v_i, (&__pyx_v_location), (&__pyx_v_location_sz), (&__pyx_v_identifier), (&__pyx_v_identifier_sz)) < 0) != 0); + + /* "macaroons.pyx":212 + * ids = [] + * for i in range(num): + * if macaroon_third_party_caveat(self._M, i, # <<<<<<<<<<<<<< + * &location, &location_sz, &identifier, &identifier_sz) < 0: + * raise_error(MACAROON_INVALID) + */ if (__pyx_t_4) { /* "macaroons.pyx":214 @@ -2744,12 +2855,18 @@ * ids.append((location[:location_sz], identifier[:identifier_sz])) * return ids */ - __pyx_t_1 = __pyx_f_9macaroons_raise_error(MACAROON_INVALID); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __pyx_f_9macaroons_raise_error(MACAROON_INVALID); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 214, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L5; + + /* "macaroons.pyx":212 + * ids = [] + * for i in range(num): + * if macaroon_third_party_caveat(self._M, i, # <<<<<<<<<<<<<< + * &location, &location_sz, &identifier, &identifier_sz) < 0: + * raise_error(MACAROON_INVALID) + */ } - __pyx_L5:; /* "macaroons.pyx":215 * &location, &location_sz, &identifier, &identifier_sz) < 0: @@ -2758,19 +2875,19 @@ * return ids * */ - __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_location) + 0, __pyx_v_location_sz - 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_location) + 0, __pyx_v_location_sz - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_identifier) + 0, __pyx_v_identifier_sz - 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_identifier) + 0, __pyx_v_identifier_sz - 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); __pyx_t_1 = 0; __pyx_t_5 = 0; - __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_ids, __pyx_t_6); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_ids, __pyx_t_6); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } @@ -2817,16 +2934,13 @@ */ /* Python wrapper */ -static PyObject *__pyx_pw_9macaroons_8Macaroon_25prepare_for_request(PyObject *__pyx_v_self, PyObject *__pyx_v_D); /*proto*/ -static PyObject *__pyx_pw_9macaroons_8Macaroon_25prepare_for_request(PyObject *__pyx_v_self, PyObject *__pyx_v_D) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; +static PyObject *__pyx_pw_9macaroons_8Macaroon_19prepare_for_request(PyObject *__pyx_v_self, PyObject *__pyx_v_D); /*proto*/ +static PyObject *__pyx_pw_9macaroons_8Macaroon_19prepare_for_request(PyObject *__pyx_v_self, PyObject *__pyx_v_D) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("prepare_for_request (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_D), __pyx_ptype_9macaroons_Macaroon, 1, "D", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_9macaroons_8Macaroon_24prepare_for_request(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self), ((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_D)); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_D), __pyx_ptype_9macaroons_Macaroon, 1, "D", 0))) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_r = __pyx_pf_9macaroons_8Macaroon_18prepare_for_request(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self), ((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_D)); /* function exit code */ goto __pyx_L0; @@ -2837,16 +2951,13 @@ return __pyx_r; } -static PyObject *__pyx_pf_9macaroons_8Macaroon_24prepare_for_request(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, struct __pyx_obj_9macaroons_Macaroon *__pyx_v_D) { +static PyObject *__pyx_pf_9macaroons_8Macaroon_18prepare_for_request(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, struct __pyx_obj_9macaroons_Macaroon *__pyx_v_D) { enum macaroon_returncode __pyx_v_err; struct __pyx_obj_9macaroons_Macaroon *__pyx_v_DP = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("prepare_for_request", 0); /* "macaroons.pyx":220 @@ -2856,7 +2967,7 @@ * self.assert_not_null() * D.assert_not_null() */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9macaroons_Macaroon)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9macaroons_Macaroon), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 220, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_DP = ((struct __pyx_obj_9macaroons_Macaroon *)__pyx_t_1); __pyx_t_1 = 0; @@ -2868,7 +2979,7 @@ * D.assert_not_null() * DP._M = macaroon_prepare_for_request(self._M, D._M, &err) */ - __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2879,7 +2990,7 @@ * DP._M = macaroon_prepare_for_request(self._M, D._M, &err) * if DP._M == NULL: */ - __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_D->__pyx_vtab)->assert_not_null(__pyx_v_D); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_D->__pyx_vtab)->assert_not_null(__pyx_v_D); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2909,12 +3020,18 @@ * return DP * */ - __pyx_t_1 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L3; + + /* "macaroons.pyx":224 + * D.assert_not_null() + * DP._M = macaroon_prepare_for_request(self._M, D._M, &err) + * if DP._M == NULL: # <<<<<<<<<<<<<< + * raise_error(err) + * return DP + */ } - __pyx_L3:; /* "macaroons.pyx":226 * if DP._M == NULL: @@ -2957,16 +3074,13 @@ */ /* Python wrapper */ -static PyObject *__pyx_pw_9macaroons_8Macaroon_27add_first_party_caveat(PyObject *__pyx_v_self, PyObject *__pyx_v_predicate); /*proto*/ -static PyObject *__pyx_pw_9macaroons_8Macaroon_27add_first_party_caveat(PyObject *__pyx_v_self, PyObject *__pyx_v_predicate) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; +static PyObject *__pyx_pw_9macaroons_8Macaroon_21add_first_party_caveat(PyObject *__pyx_v_self, PyObject *__pyx_v_predicate); /*proto*/ +static PyObject *__pyx_pw_9macaroons_8Macaroon_21add_first_party_caveat(PyObject *__pyx_v_self, PyObject *__pyx_v_predicate) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("add_first_party_caveat (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_predicate), (&PyBytes_Type), 1, "predicate", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_9macaroons_8Macaroon_26add_first_party_caveat(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self), ((PyObject*)__pyx_v_predicate)); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_predicate), (&PyBytes_Type), 1, "predicate", 1))) __PYX_ERR(0, 228, __pyx_L1_error) + __pyx_r = __pyx_pf_9macaroons_8Macaroon_20add_first_party_caveat(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self), ((PyObject*)__pyx_v_predicate)); /* function exit code */ goto __pyx_L0; @@ -2977,7 +3091,7 @@ return __pyx_r; } -static PyObject *__pyx_pf_9macaroons_8Macaroon_26add_first_party_caveat(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, PyObject *__pyx_v_predicate) { +static PyObject *__pyx_pf_9macaroons_8Macaroon_20add_first_party_caveat(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, PyObject *__pyx_v_predicate) { enum macaroon_returncode __pyx_v_err; struct __pyx_obj_9macaroons_Macaroon *__pyx_v_M = 0; PyObject *__pyx_r = NULL; @@ -2986,9 +3100,6 @@ unsigned char const *__pyx_t_2; Py_ssize_t __pyx_t_3; int __pyx_t_4; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("add_first_party_caveat", 0); /* "macaroons.pyx":229 @@ -2998,7 +3109,7 @@ * cdef macarr * cdef macaroon_returncode err */ - __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -3009,7 +3120,7 @@ * M._M = macaroon_add_first_party_caveat(self._M, * predicate, len(predicate), &err) */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9macaroons_Macaroon)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9macaroons_Macaroon), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_M = ((struct __pyx_obj_9macaroons_Macaroon *)__pyx_t_1); __pyx_t_1 = 0; @@ -3021,12 +3132,12 @@ * if M._M == NULL: * raise_error(err) */ - __pyx_t_2 = __Pyx_PyObject_AsUString(__pyx_v_predicate); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_AsUString(__pyx_v_predicate); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 234, __pyx_L1_error) if (unlikely(__pyx_v_predicate == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __PYX_ERR(0, 234, __pyx_L1_error) } - __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_predicate); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_predicate); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 234, __pyx_L1_error) /* "macaroons.pyx":233 * cdef macaroon_returncode err @@ -3054,12 +3165,18 @@ * return M * */ - __pyx_t_1 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L3; + + /* "macaroons.pyx":235 + * M._M = macaroon_add_first_party_caveat(self._M, + * predicate, len(predicate), &err) + * if M._M == NULL: # <<<<<<<<<<<<<< + * raise_error(err) + * return M + */ } - __pyx_L3:; /* "macaroons.pyx":237 * if M._M == NULL: @@ -3102,14 +3219,11 @@ */ /* Python wrapper */ -static PyObject *__pyx_pw_9macaroons_8Macaroon_29add_third_party_caveat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_9macaroons_8Macaroon_29add_third_party_caveat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_9macaroons_8Macaroon_23add_third_party_caveat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_9macaroons_8Macaroon_23add_third_party_caveat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v__location = 0; PyObject *__pyx_v__key = 0; PyObject *__pyx_v__key_id = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("add_third_party_caveat (wrapper)", 0); @@ -3134,16 +3248,16 @@ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("add_third_party_caveat", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("add_third_party_caveat", 1, 3, 3, 1); __PYX_ERR(0, 239, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_key_id)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("add_third_party_caveat", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("add_third_party_caveat", 1, 3, 3, 2); __PYX_ERR(0, 239, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_third_party_caveat") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_third_party_caveat") < 0)) __PYX_ERR(0, 239, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; @@ -3158,16 +3272,16 @@ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("add_third_party_caveat", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("add_third_party_caveat", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 239, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("macaroons.Macaroon.add_third_party_caveat", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__location), (&PyBytes_Type), 1, "_location", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__key), (&PyBytes_Type), 1, "_key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__key_id), (&PyBytes_Type), 1, "_key_id", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_9macaroons_8Macaroon_28add_third_party_caveat(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self), __pyx_v__location, __pyx_v__key, __pyx_v__key_id); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__location), (&PyBytes_Type), 1, "_location", 1))) __PYX_ERR(0, 239, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__key), (&PyBytes_Type), 1, "_key", 1))) __PYX_ERR(0, 239, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__key_id), (&PyBytes_Type), 1, "_key_id", 1))) __PYX_ERR(0, 239, __pyx_L1_error) + __pyx_r = __pyx_pf_9macaroons_8Macaroon_22add_third_party_caveat(((struct __pyx_obj_9macaroons_Macaroon *)__pyx_v_self), __pyx_v__location, __pyx_v__key, __pyx_v__key_id); /* function exit code */ goto __pyx_L0; @@ -3178,7 +3292,7 @@ return __pyx_r; } -static PyObject *__pyx_pf_9macaroons_8Macaroon_28add_third_party_caveat(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, PyObject *__pyx_v__location, PyObject *__pyx_v__key, PyObject *__pyx_v__key_id) { +static PyObject *__pyx_pf_9macaroons_8Macaroon_22add_third_party_caveat(struct __pyx_obj_9macaroons_Macaroon *__pyx_v_self, PyObject *__pyx_v__location, PyObject *__pyx_v__key, PyObject *__pyx_v__key_id) { unsigned char *__pyx_v_location; size_t __pyx_v_location_sz; unsigned char *__pyx_v_key; @@ -3193,9 +3307,6 @@ Py_ssize_t __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("add_third_party_caveat", 0); /* "macaroons.pyx":240 @@ -3205,7 +3316,7 @@ * cdef size_t location_sz = len(_location) * cdef unsigned char* key = _key */ - __pyx_t_1 = __Pyx_PyObject_AsUString(__pyx_v__location); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_AsUString(__pyx_v__location); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 240, __pyx_L1_error) __pyx_v_location = __pyx_t_1; /* "macaroons.pyx":241 @@ -3217,9 +3328,9 @@ */ if (unlikely(__pyx_v__location == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __PYX_ERR(0, 241, __pyx_L1_error) } - __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v__location); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v__location); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 241, __pyx_L1_error) __pyx_v_location_sz = __pyx_t_2; /* "macaroons.pyx":242 @@ -3229,7 +3340,7 @@ * cdef size_t key_sz = len(_key) * cdef unsigned char* key_id = _key_id */ - __pyx_t_1 = __Pyx_PyObject_AsUString(__pyx_v__key); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_AsUString(__pyx_v__key); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 242, __pyx_L1_error) __pyx_v_key = __pyx_t_1; /* "macaroons.pyx":243 @@ -3241,9 +3352,9 @@ */ if (unlikely(__pyx_v__key == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __PYX_ERR(0, 243, __pyx_L1_error) } - __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v__key); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v__key); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 243, __pyx_L1_error) __pyx_v_key_sz = __pyx_t_2; /* "macaroons.pyx":244 @@ -3253,7 +3364,7 @@ * cdef size_t key_id_sz = len(_key_id) * cdef macaroon_returncode err */ - __pyx_t_1 = __Pyx_PyObject_AsUString(__pyx_v__key_id); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_AsUString(__pyx_v__key_id); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 244, __pyx_L1_error) __pyx_v_key_id = __pyx_t_1; /* "macaroons.pyx":245 @@ -3265,9 +3376,9 @@ */ if (unlikely(__pyx_v__key_id == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __PYX_ERR(0, 245, __pyx_L1_error) } - __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v__key_id); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v__key_id); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 245, __pyx_L1_error) __pyx_v_key_id_sz = __pyx_t_2; /* "macaroons.pyx":247 @@ -3277,7 +3388,7 @@ * self.assert_not_null() * M._M = macaroon_add_third_party_caveat(self._M, */ - __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9macaroons_Macaroon)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9macaroons_Macaroon), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_M = ((struct __pyx_obj_9macaroons_Macaroon *)__pyx_t_3); __pyx_t_3 = 0; @@ -3289,7 +3400,7 @@ * M._M = macaroon_add_third_party_caveat(self._M, * location, location_sz, key, key_sz, key_id, key_id_sz, &err) */ - __pyx_t_3 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_self->__pyx_vtab)->assert_not_null(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -3319,12 +3430,18 @@ * return M * */ - __pyx_t_3 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L3; + + /* "macaroons.pyx":251 + * M._M = macaroon_add_third_party_caveat(self._M, + * location, location_sz, key, key_sz, key_id, key_id_sz, &err) + * if M._M == NULL: # <<<<<<<<<<<<<< + * raise_error(err) + * return M + */ } - __pyx_L3:; /* "macaroons.pyx":253 * if M._M == NULL: @@ -3371,9 +3488,6 @@ __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("assert_not_null", 0); /* "macaroons.pyx":256 @@ -3393,11 +3507,19 @@ * * */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __PYX_ERR(0, 257, __pyx_L1_error) + + /* "macaroons.pyx":256 + * + * cdef assert_not_null(self): + * if self._M == NULL: # <<<<<<<<<<<<<< + * raise ValueError("macaroon not initialized") + * + */ } /* "macaroons.pyx":255 @@ -3437,10 +3559,10 @@ PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; - int __pyx_t_6; - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + int __pyx_t_9; __Pyx_RefNannySetupContext("general_cb", 0); /* "macaroons.pyx":261 @@ -3451,6 +3573,8 @@ * return 0 */ { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); @@ -3464,19 +3588,38 @@ * return 0 * except: pass */ - __pyx_t_4 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_pred) + 0, __pyx_v_pred_sz - 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_t_5 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_pred) + 0, __pyx_v_pred_sz - 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 262, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_v_f), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_INCREF(((PyObject *)__pyx_v_f)); + __pyx_t_6 = ((PyObject *)__pyx_v_f); __pyx_t_7 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) { + __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); + if (likely(__pyx_t_7)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_6, function); + } + } + if (!__pyx_t_7) { + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 262, __pyx_L3_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_4); + } else { + __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 262, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL; + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 262, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 262, __pyx_L3_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_6) { + if (__pyx_t_9) { /* "macaroons.pyx":263 * try: @@ -3487,14 +3630,34 @@ */ __pyx_r = 0; goto __pyx_L7_try_return; + + /* "macaroons.pyx":262 + * cdef int general_cb(void* f, const unsigned char* pred, size_t pred_sz): + * try: + * if (f)(pred[:pred_sz]): # <<<<<<<<<<<<<< + * return 0 + * except: pass + */ } + + /* "macaroons.pyx":261 + * + * cdef int general_cb(void* f, const unsigned char* pred, size_t pred_sz): + * try: # <<<<<<<<<<<<<< + * if (f)(pred[:pred_sz]): + * return 0 + */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L10_try_end; __pyx_L3_error:; + __Pyx_PyThreadState_assign + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* "macaroons.pyx":264 @@ -3505,16 +3668,26 @@ * */ /*except:*/ { - PyErr_Restore(0,0,0); + __Pyx_ErrRestore(0,0,0); goto __pyx_L4_exception_handled; } __pyx_L7_try_return:; + + /* "macaroons.pyx":261 + * + * cdef int general_cb(void* f, const unsigned char* pred, size_t pred_sz): + * try: # <<<<<<<<<<<<<< + * if (f)(pred[:pred_sz]): + * return 0 + */ + __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; __pyx_L4_exception_handled:; + __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); @@ -3575,9 +3748,6 @@ __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); /* "macaroons.pyx":273 @@ -3606,7 +3776,15 @@ * self._funcs = [] * */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyErr_NoMemory(); __PYX_ERR(0, 275, __pyx_L1_error) + + /* "macaroons.pyx":274 + * def __cinit__(self): + * self._V = macaroon_verifier_create() + * if self._V == NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * self._funcs = [] + */ } /* "macaroons.pyx":276 @@ -3616,7 +3794,7 @@ * * def __dealloc__(self): */ - __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 276, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __Pyx_GOTREF(__pyx_v_self->_funcs); @@ -3695,9 +3873,15 @@ * def satisfy_exact(self, pred): */ __pyx_v_self->_V = NULL; - goto __pyx_L3; + + /* "macaroons.pyx":279 + * + * def __dealloc__(self): + * if self._V != NULL: # <<<<<<<<<<<<<< + * macaroon_verifier_destroy(self._V) + * self._V = NULL + */ } - __pyx_L3:; /* "macaroons.pyx":278 * self._funcs = [] @@ -3740,9 +3924,6 @@ Py_ssize_t __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("satisfy_exact", 0); /* "macaroons.pyx":285 @@ -3752,8 +3933,8 @@ * raise_error(err) * */ - __pyx_t_1 = __Pyx_PyObject_AsUString(__pyx_v_pred); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PyObject_Length(__pyx_v_pred); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_AsUString(__pyx_v_pred); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 285, __pyx_L1_error) + __pyx_t_2 = PyObject_Length(__pyx_v_pred); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 285, __pyx_L1_error) __pyx_t_3 = ((macaroon_verifier_satisfy_exact(__pyx_v_self->_V, __pyx_t_1, __pyx_t_2, (&__pyx_v_err)) < 0) != 0); if (__pyx_t_3) { @@ -3764,12 +3945,18 @@ * * def satisfy_general(self, func): */ - __pyx_t_4 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - goto __pyx_L3; + + /* "macaroons.pyx":285 + * def satisfy_exact(self, pred): + * cdef macaroon_returncode err + * if macaroon_verifier_satisfy_exact(self._V, pred, len(pred), &err) < 0: # <<<<<<<<<<<<<< + * raise_error(err) + * + */ } - __pyx_L3:; /* "macaroons.pyx":283 * self._V = NULL @@ -3820,9 +4007,6 @@ int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("satisfy_general", 0); /* "macaroons.pyx":290 @@ -3842,12 +4026,18 @@ * self._funcs.append(func) * */ - __pyx_t_2 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 291, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - goto __pyx_L3; + + /* "macaroons.pyx":290 + * def satisfy_general(self, func): + * cdef macaroon_returncode err + * if macaroon_verifier_satisfy_general(self._V, general_cb, func, &err) < 0: # <<<<<<<<<<<<<< + * raise_error(err) + * self._funcs.append(func) + */ } - __pyx_L3:; /* "macaroons.pyx":292 * if macaroon_verifier_satisfy_general(self._V, general_cb, func, &err) < 0: @@ -3858,9 +4048,9 @@ */ if (unlikely(__pyx_v_self->_funcs == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __PYX_ERR(0, 292, __pyx_L1_error) } - __pyx_t_3 = __Pyx_PyList_Append(__pyx_v_self->_funcs, __pyx_v_func); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyList_Append(__pyx_v_self->_funcs, __pyx_v_func); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 292, __pyx_L1_error) /* "macaroons.pyx":288 * raise_error(err) @@ -3897,9 +4087,6 @@ struct __pyx_obj_9macaroons_Macaroon *__pyx_v_M = 0; PyObject *__pyx_v_key = 0; PyObject *__pyx_v_MS = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("verify (wrapper)", 0); @@ -3925,7 +4112,7 @@ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_key_2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("verify", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("verify", 0, 2, 3, 1); __PYX_ERR(0, 294, __pyx_L3_error) } case 2: if (kw_args > 0) { @@ -3934,7 +4121,7 @@ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "verify") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "verify") < 0)) __PYX_ERR(0, 294, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -3951,14 +4138,14 @@ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("verify", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("verify", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 294, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("macaroons.Verifier.verify", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_M), __pyx_ptype_9macaroons_Macaroon, 1, "M", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyBytes_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_M), __pyx_ptype_9macaroons_Macaroon, 1, "M", 0))) __PYX_ERR(0, 294, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyBytes_Type), 1, "key", 1))) __PYX_ERR(0, 294, __pyx_L1_error) __pyx_r = __pyx_pf_9macaroons_8Verifier_8verify(((struct __pyx_obj_9macaroons_Verifier *)__pyx_v_self), __pyx_v_M, __pyx_v_key, __pyx_v_MS); /* function exit code */ @@ -3976,10 +4163,9 @@ PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; + Py_ssize_t __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; __Pyx_RefNannySetupContext("verify", 0); /* "macaroons.pyx":295 @@ -3989,26 +4175,41 @@ * return True * else: */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_verify_unsafe); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_verify_unsafe); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + __pyx_t_4 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + __pyx_t_4 = 1; + } + } + __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 295, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (__pyx_t_3) { + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; + } __Pyx_INCREF(((PyObject *)__pyx_v_M)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_M)); __Pyx_GIVEREF(((PyObject *)__pyx_v_M)); + PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, ((PyObject *)__pyx_v_M)); __Pyx_INCREF(__pyx_v_key); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_key); __Pyx_GIVEREF(__pyx_v_key); + PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_key); __Pyx_INCREF(__pyx_v_MS); - PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_MS); __Pyx_GIVEREF(__pyx_v_MS); - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_MS); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_4) { + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 295, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_6) { /* "macaroons.pyx":296 * def verify(self, Macaroon M, bytes key, MS=None): @@ -4021,24 +4222,32 @@ __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L0; + + /* "macaroons.pyx":295 + * + * def verify(self, Macaroon M, bytes key, MS=None): + * if self.verify_unsafe(M, key, MS): # <<<<<<<<<<<<<< + * return True + * else: + */ } - /*else*/ { - /* "macaroons.pyx":298 + /* "macaroons.pyx":298 * return True * else: * raise Unauthorized("macaroon not authorized") # <<<<<<<<<<<<<< * * def verify_unsafe(self, Macaroon M, bytes key, MS=None): */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Unauthorized); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*else*/ { + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Unauthorized); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __PYX_ERR(0, 298, __pyx_L1_error) } /* "macaroons.pyx":294 @@ -4054,6 +4263,7 @@ __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("macaroons.Verifier.verify", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -4076,9 +4286,6 @@ struct __pyx_obj_9macaroons_Macaroon *__pyx_v_M = 0; PyObject *__pyx_v_key = 0; PyObject *__pyx_v_MS = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("verify_unsafe (wrapper)", 0); @@ -4104,7 +4311,7 @@ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_key_2)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("verify_unsafe", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("verify_unsafe", 0, 2, 3, 1); __PYX_ERR(0, 300, __pyx_L3_error) } case 2: if (kw_args > 0) { @@ -4113,7 +4320,7 @@ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "verify_unsafe") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "verify_unsafe") < 0)) __PYX_ERR(0, 300, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -4130,14 +4337,14 @@ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("verify_unsafe", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("verify_unsafe", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 300, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("macaroons.Verifier.verify_unsafe", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_M), __pyx_ptype_9macaroons_Macaroon, 1, "M", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyBytes_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_M), __pyx_ptype_9macaroons_Macaroon, 1, "M", 0))) __PYX_ERR(0, 300, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyBytes_Type), 1, "key", 1))) __PYX_ERR(0, 300, __pyx_L1_error) __pyx_r = __pyx_pf_9macaroons_8Verifier_10verify_unsafe(((struct __pyx_obj_9macaroons_Verifier *)__pyx_v_self), __pyx_v_M, __pyx_v_key, __pyx_v_MS); /* function exit code */ @@ -4176,9 +4383,6 @@ PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("verify_unsafe", 0); __Pyx_INCREF(__pyx_v_MS); @@ -4207,7 +4411,7 @@ * MS = MS or [] * discharges = malloc(sizeof(macaroon*) * len(MS)) */ - __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_M->__pyx_vtab)->assert_not_null(__pyx_v_M); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_M->__pyx_vtab)->assert_not_null(__pyx_v_M); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -4218,18 +4422,21 @@ * discharges = malloc(sizeof(macaroon*) * len(MS)) * for i, D in enumerate(MS): */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_MS); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_MS); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 306, __pyx_L4_error) if (!__pyx_t_2) { - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L4_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; - __pyx_t_1 = 0; } else { __Pyx_INCREF(__pyx_v_MS); - __pyx_t_3 = __pyx_v_MS; + __pyx_t_1 = __pyx_v_MS; + goto __pyx_L6_bool_binop_done; } - __Pyx_DECREF_SET(__pyx_v_MS, __pyx_t_3); - __pyx_t_3 = 0; + __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 306, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_3); + __pyx_t_1 = __pyx_t_3; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_L6_bool_binop_done:; + __Pyx_DECREF_SET(__pyx_v_MS, __pyx_t_1); + __pyx_t_1 = 0; /* "macaroons.pyx":307 * M.assert_not_null() @@ -4238,7 +4445,7 @@ * for i, D in enumerate(MS): * tmp = D */ - __pyx_t_4 = PyObject_Length(__pyx_v_MS); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_4 = PyObject_Length(__pyx_v_MS); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 307, __pyx_L4_error) __pyx_v_discharges = ((struct macaroon **)malloc(((sizeof(struct macaroon *)) * __pyx_t_4))); /* "macaroons.pyx":308 @@ -4249,37 +4456,41 @@ * tmp.assert_not_null() */ __Pyx_INCREF(__pyx_int_0); - __pyx_t_3 = __pyx_int_0; - if (PyList_CheckExact(__pyx_v_MS) || PyTuple_CheckExact(__pyx_v_MS)) { - __pyx_t_1 = __pyx_v_MS; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0; + __pyx_t_1 = __pyx_int_0; + if (likely(PyList_CheckExact(__pyx_v_MS)) || PyTuple_CheckExact(__pyx_v_MS)) { + __pyx_t_3 = __pyx_v_MS; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { - __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_MS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L4_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; + __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_MS); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 308, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 308, __pyx_L4_error) } for (;;) { - if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_1)) { - if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L4_error;} - #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L4_error;} - #endif - } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_1)) { - if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L4_error;} - #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L4_error;} - #endif + if (likely(!__pyx_t_5)) { + if (likely(PyList_CheckExact(__pyx_t_3))) { + if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 308, __pyx_L4_error) + #else + __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 308, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_6); + #endif + } else { + if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 308, __pyx_L4_error) + #else + __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 308, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_6); + #endif + } } else { - __pyx_t_6 = __pyx_t_5(__pyx_t_1); + __pyx_t_6 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_6)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + else __PYX_ERR(0, 308, __pyx_L4_error) } break; } @@ -4287,12 +4498,12 @@ } __Pyx_XDECREF_SET(__pyx_v_D, __pyx_t_6); __pyx_t_6 = 0; - __Pyx_INCREF(__pyx_t_3); - __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3); - __pyx_t_6 = PyNumber_Add(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __Pyx_INCREF(__pyx_t_1); + __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1); + __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 308, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_3); - __pyx_t_3 = __pyx_t_6; + __Pyx_DECREF(__pyx_t_1); + __pyx_t_1 = __pyx_t_6; __pyx_t_6 = 0; /* "macaroons.pyx":309 @@ -4302,7 +4513,7 @@ * tmp.assert_not_null() * discharges[i] = tmp._M */ - if (!(likely(((__pyx_v_D) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_D, __pyx_ptype_9macaroons_Macaroon))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + if (!(likely(((__pyx_v_D) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_D, __pyx_ptype_9macaroons_Macaroon))))) __PYX_ERR(0, 309, __pyx_L4_error) __pyx_t_6 = __pyx_v_D; __Pyx_INCREF(__pyx_t_6); __Pyx_XDECREF_SET(__pyx_v_tmp, ((struct __pyx_obj_9macaroons_Macaroon *)__pyx_t_6)); @@ -4315,7 +4526,7 @@ * discharges[i] = tmp._M * rc = macaroon_verify(self._V, M._M, key, len(key), discharges, len(MS), &err) */ - __pyx_t_6 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_tmp->__pyx_vtab)->assert_not_null(__pyx_v_tmp); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_6 = ((struct __pyx_vtabstruct_9macaroons_Macaroon *)__pyx_v_tmp->__pyx_vtab)->assert_not_null(__pyx_v_tmp); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 310, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -4327,11 +4538,19 @@ * if rc == 0: */ __pyx_t_7 = __pyx_v_tmp->_M; - __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 311, __pyx_L4_error) (__pyx_v_discharges[__pyx_t_8]) = __pyx_t_7; + + /* "macaroons.pyx":308 + * MS = MS or [] + * discharges = malloc(sizeof(macaroon*) * len(MS)) + * for i, D in enumerate(MS): # <<<<<<<<<<<<<< + * tmp = D + * tmp.assert_not_null() + */ } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macaroons.pyx":312 * tmp.assert_not_null() @@ -4340,13 +4559,13 @@ * if rc == 0: * return True */ - __pyx_t_9 = __Pyx_PyObject_AsUString(__pyx_v_key); if (unlikely((!__pyx_t_9) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_9 = __Pyx_PyObject_AsUString(__pyx_v_key); if (unlikely((!__pyx_t_9) && PyErr_Occurred())) __PYX_ERR(0, 312, __pyx_L4_error) if (unlikely(__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __PYX_ERR(0, 312, __pyx_L4_error) } - __pyx_t_4 = PyBytes_GET_SIZE(__pyx_v_key); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L4_error;} - __pyx_t_8 = PyObject_Length(__pyx_v_MS); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L4_error;} + __pyx_t_4 = PyBytes_GET_SIZE(__pyx_v_key); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 312, __pyx_L4_error) + __pyx_t_8 = PyObject_Length(__pyx_v_MS); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 312, __pyx_L4_error) __pyx_v_rc = macaroon_verify(__pyx_v_self->_V, __pyx_v_M->_M, __pyx_t_9, __pyx_t_4, __pyx_v_discharges, __pyx_t_8, (&__pyx_v_err)); /* "macaroons.pyx":313 @@ -4370,6 +4589,14 @@ __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L3_return; + + /* "macaroons.pyx":313 + * discharges[i] = tmp._M + * rc = macaroon_verify(self._V, M._M, key, len(key), discharges, len(MS), &err) + * if rc == 0: # <<<<<<<<<<<<<< + * return True + * elif err == MACAROON_NOT_AUTHORIZED: + */ } /* "macaroons.pyx":315 @@ -4393,19 +4620,27 @@ __Pyx_INCREF(Py_False); __pyx_r = Py_False; goto __pyx_L3_return; + + /* "macaroons.pyx":315 + * if rc == 0: + * return True + * elif err == MACAROON_NOT_AUTHORIZED: # <<<<<<<<<<<<<< + * return False + * else: + */ } - /*else*/ { - /* "macaroons.pyx":318 + /* "macaroons.pyx":318 * return False * else: * raise_error(err) # <<<<<<<<<<<<<< * finally: * if discharges: */ - __pyx_t_3 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L4_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + /*else*/ { + __pyx_t_1 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } } @@ -4429,17 +4664,25 @@ * */ free(__pyx_v_discharges); - goto __pyx_L9; + + /* "macaroons.pyx":320 + * raise_error(err) + * finally: + * if discharges: # <<<<<<<<<<<<<< + * free(discharges) + * + */ } - __pyx_L9:; goto __pyx_L5; } /*exception exit:*/{ + __Pyx_PyThreadState_declare __pyx_L4_error:; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; + __Pyx_PyThreadState_assign __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); __Pyx_XGOTREF(__pyx_t_13); @@ -4450,14 +4693,6 @@ __Pyx_XGOTREF(__pyx_t_18); __pyx_t_10 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_12 = __pyx_filename; { - - /* "macaroons.pyx":320 - * raise_error(err) - * finally: - * if discharges: # <<<<<<<<<<<<<< - * free(discharges) - * - */ __pyx_t_2 = (__pyx_v_discharges != 0); if (__pyx_t_2) { @@ -4469,10 +4704,17 @@ * */ free(__pyx_v_discharges); - goto __pyx_L12; + + /* "macaroons.pyx":320 + * raise_error(err) + * finally: + * if discharges: # <<<<<<<<<<<<<< + * free(discharges) + * + */ } - __pyx_L12:; } + __Pyx_PyThreadState_assign if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); @@ -4490,18 +4732,10 @@ __pyx_L3_return: { __pyx_t_18 = __pyx_r; __pyx_r = 0; + __pyx_t_2 = (__pyx_v_discharges != 0); + if (__pyx_t_2) { - /* "macaroons.pyx":320 - * raise_error(err) - * finally: - * if discharges: # <<<<<<<<<<<<<< - * free(discharges) - * - */ - __pyx_t_2 = (__pyx_v_discharges != 0); - if (__pyx_t_2) { - - /* "macaroons.pyx":321 + /* "macaroons.pyx":321 * finally: * if discharges: * free(discharges) # <<<<<<<<<<<<<< @@ -4509,9 +4743,15 @@ * */ free(__pyx_v_discharges); - goto __pyx_L13; + + /* "macaroons.pyx":320 + * raise_error(err) + * finally: + * if discharges: # <<<<<<<<<<<<<< + * free(discharges) + * + */ } - __pyx_L13:; __pyx_r = __pyx_t_18; __pyx_t_18 = 0; goto __pyx_L0; @@ -4556,14 +4796,11 @@ /* Python wrapper */ static PyObject *__pyx_pw_9macaroons_1create(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_9macaroons_1create = {__Pyx_NAMESTR("create"), (PyCFunction)__pyx_pw_9macaroons_1create, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; +static PyMethodDef __pyx_mdef_9macaroons_1create = {"create", (PyCFunction)__pyx_pw_9macaroons_1create, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_9macaroons_1create(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v__location = 0; PyObject *__pyx_v__key = 0; PyObject *__pyx_v__key_id = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("create (wrapper)", 0); @@ -4588,16 +4825,16 @@ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("create", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("create", 1, 3, 3, 1); __PYX_ERR(0, 324, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_key_id)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("create", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("create", 1, 3, 3, 2); __PYX_ERR(0, 324, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create") < 0)) __PYX_ERR(0, 324, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; @@ -4612,15 +4849,15 @@ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("create", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("create", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 324, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("macaroons.create", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__location), (&PyBytes_Type), 1, "_location", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__key), (&PyBytes_Type), 1, "_key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__key_id), (&PyBytes_Type), 1, "_key_id", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__location), (&PyBytes_Type), 1, "_location", 1))) __PYX_ERR(0, 324, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__key), (&PyBytes_Type), 1, "_key", 1))) __PYX_ERR(0, 324, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__key_id), (&PyBytes_Type), 1, "_key_id", 1))) __PYX_ERR(0, 324, __pyx_L1_error) __pyx_r = __pyx_pf_9macaroons_create(__pyx_self, __pyx_v__location, __pyx_v__key, __pyx_v__key_id); /* function exit code */ @@ -4647,9 +4884,6 @@ Py_ssize_t __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("create", 0); /* "macaroons.pyx":325 @@ -4659,7 +4893,7 @@ * cdef size_t location_sz = len(_location) * cdef unsigned char* key = _key */ - __pyx_t_1 = __Pyx_PyObject_AsUString(__pyx_v__location); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_AsUString(__pyx_v__location); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 325, __pyx_L1_error) __pyx_v_location = __pyx_t_1; /* "macaroons.pyx":326 @@ -4671,9 +4905,9 @@ */ if (unlikely(__pyx_v__location == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __PYX_ERR(0, 326, __pyx_L1_error) } - __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v__location); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v__location); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 326, __pyx_L1_error) __pyx_v_location_sz = __pyx_t_2; /* "macaroons.pyx":327 @@ -4683,7 +4917,7 @@ * cdef size_t key_sz = len(_key) * cdef unsigned char* key_id = _key_id */ - __pyx_t_1 = __Pyx_PyObject_AsUString(__pyx_v__key); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_AsUString(__pyx_v__key); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 327, __pyx_L1_error) __pyx_v_key = __pyx_t_1; /* "macaroons.pyx":328 @@ -4695,9 +4929,9 @@ */ if (unlikely(__pyx_v__key == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __PYX_ERR(0, 328, __pyx_L1_error) } - __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v__key); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v__key); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 328, __pyx_L1_error) __pyx_v_key_sz = __pyx_t_2; /* "macaroons.pyx":329 @@ -4707,7 +4941,7 @@ * cdef size_t key_id_sz = len(_key_id) * cdef macaroon_returncode err */ - __pyx_t_1 = __Pyx_PyObject_AsUString(__pyx_v__key_id); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_AsUString(__pyx_v__key_id); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 329, __pyx_L1_error) __pyx_v_key_id = __pyx_t_1; /* "macaroons.pyx":330 @@ -4719,9 +4953,9 @@ */ if (unlikely(__pyx_v__key_id == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __PYX_ERR(0, 330, __pyx_L1_error) } - __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v__key_id); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v__key_id); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 330, __pyx_L1_error) __pyx_v_key_id_sz = __pyx_t_2; /* "macaroons.pyx":332 @@ -4731,7 +4965,7 @@ * M._M = macaroon_create(location, location_sz, * key, key_sz, key_id, key_id_sz, &err) */ - __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9macaroons_Macaroon)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9macaroons_Macaroon), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_M = ((struct __pyx_obj_9macaroons_Macaroon *)__pyx_t_3); __pyx_t_3 = 0; @@ -4762,12 +4996,18 @@ * return M * */ - __pyx_t_3 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 336, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L3; + + /* "macaroons.pyx":335 + * M._M = macaroon_create(location, location_sz, + * key, key_sz, key_id, key_id_sz, &err) + * if M._M == NULL: # <<<<<<<<<<<<<< + * raise_error(err) + * return M + */ } - __pyx_L3:; /* "macaroons.pyx":337 * if M._M == NULL: @@ -4811,15 +5051,12 @@ /* Python wrapper */ static PyObject *__pyx_pw_9macaroons_3deserialize(PyObject *__pyx_self, PyObject *__pyx_v_m); /*proto*/ -static PyMethodDef __pyx_mdef_9macaroons_3deserialize = {__Pyx_NAMESTR("deserialize"), (PyCFunction)__pyx_pw_9macaroons_3deserialize, METH_O, __Pyx_DOCSTR(0)}; +static PyMethodDef __pyx_mdef_9macaroons_3deserialize = {"deserialize", (PyCFunction)__pyx_pw_9macaroons_3deserialize, METH_O, 0}; static PyObject *__pyx_pw_9macaroons_3deserialize(PyObject *__pyx_self, PyObject *__pyx_v_m) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("deserialize (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m), (&PyBytes_Type), 1, "m", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m), (&PyBytes_Type), 1, "m", 1))) __PYX_ERR(0, 340, __pyx_L1_error) __pyx_r = __pyx_pf_9macaroons_2deserialize(__pyx_self, ((PyObject*)__pyx_v_m)); /* function exit code */ @@ -4839,9 +5076,6 @@ PyObject *__pyx_t_1 = NULL; char *__pyx_t_2; int __pyx_t_3; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("deserialize", 0); /* "macaroons.pyx":341 @@ -4851,7 +5085,7 @@ * cdef macaroon_returncode err * M._M = macaroon_deserialize(m, &err) */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9macaroons_Macaroon)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9macaroons_Macaroon), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_M = ((struct __pyx_obj_9macaroons_Macaroon *)__pyx_t_1); __pyx_t_1 = 0; @@ -4863,7 +5097,7 @@ * if M._M == NULL: * raise_error(err) */ - __pyx_t_2 = __Pyx_PyObject_AsString(__pyx_v_m); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_AsString(__pyx_v_m); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 343, __pyx_L1_error) __pyx_v_M->_M = macaroon_deserialize(__pyx_t_2, (&__pyx_v_err)); /* "macaroons.pyx":344 @@ -4882,12 +5116,18 @@ * raise_error(err) # <<<<<<<<<<<<<< * return M */ - __pyx_t_1 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __pyx_f_9macaroons_raise_error(__pyx_v_err); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L3; + + /* "macaroons.pyx":344 + * cdef macaroon_returncode err + * M._M = macaroon_deserialize(m, &err) + * if M._M == NULL: # <<<<<<<<<<<<<< + * raise_error(err) + * return M + */ } - __pyx_L3:; /* "macaroons.pyx":346 * if M._M == NULL: @@ -4954,26 +5194,42 @@ (*Py_TYPE(o)->tp_free)(o); } +static PyObject *__pyx_getprop_9macaroons_8Macaroon_location(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_9macaroons_8Macaroon_8location_1__get__(o); +} + +static PyObject *__pyx_getprop_9macaroons_8Macaroon_identifier(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_9macaroons_8Macaroon_10identifier_1__get__(o); +} + +static PyObject *__pyx_getprop_9macaroons_8Macaroon_signature(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_9macaroons_8Macaroon_9signature_1__get__(o); +} + static PyMethodDef __pyx_methods_9macaroons_Macaroon[] = { - {__Pyx_NAMESTR("validate"), (PyCFunction)__pyx_pw_9macaroons_8Macaroon_5validate, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("location"), (PyCFunction)__pyx_pw_9macaroons_8Macaroon_7location, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("identifier"), (PyCFunction)__pyx_pw_9macaroons_8Macaroon_9identifier, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("signature"), (PyCFunction)__pyx_pw_9macaroons_8Macaroon_11signature, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("copy"), (PyCFunction)__pyx_pw_9macaroons_8Macaroon_13copy, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("serialize"), (PyCFunction)__pyx_pw_9macaroons_8Macaroon_15serialize, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("serialize_json"), (PyCFunction)__pyx_pw_9macaroons_8Macaroon_17serialize_json, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("inspect"), (PyCFunction)__pyx_pw_9macaroons_8Macaroon_19inspect, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("is_same"), (PyCFunction)__pyx_pw_9macaroons_8Macaroon_21is_same, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("third_party_caveats"), (PyCFunction)__pyx_pw_9macaroons_8Macaroon_23third_party_caveats, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("prepare_for_request"), (PyCFunction)__pyx_pw_9macaroons_8Macaroon_25prepare_for_request, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("add_first_party_caveat"), (PyCFunction)__pyx_pw_9macaroons_8Macaroon_27add_first_party_caveat, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("add_third_party_caveat"), (PyCFunction)__pyx_pw_9macaroons_8Macaroon_29add_third_party_caveat, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {"validate", (PyCFunction)__pyx_pw_9macaroons_8Macaroon_5validate, METH_NOARGS, 0}, + {"copy", (PyCFunction)__pyx_pw_9macaroons_8Macaroon_7copy, METH_NOARGS, 0}, + {"serialize", (PyCFunction)__pyx_pw_9macaroons_8Macaroon_9serialize, METH_NOARGS, 0}, + {"serialize_json", (PyCFunction)__pyx_pw_9macaroons_8Macaroon_11serialize_json, METH_NOARGS, 0}, + {"inspect", (PyCFunction)__pyx_pw_9macaroons_8Macaroon_13inspect, METH_NOARGS, 0}, + {"is_same", (PyCFunction)__pyx_pw_9macaroons_8Macaroon_15is_same, METH_O, 0}, + {"third_party_caveats", (PyCFunction)__pyx_pw_9macaroons_8Macaroon_17third_party_caveats, METH_NOARGS, 0}, + {"prepare_for_request", (PyCFunction)__pyx_pw_9macaroons_8Macaroon_19prepare_for_request, METH_O, 0}, + {"add_first_party_caveat", (PyCFunction)__pyx_pw_9macaroons_8Macaroon_21add_first_party_caveat, METH_O, 0}, + {"add_third_party_caveat", (PyCFunction)__pyx_pw_9macaroons_8Macaroon_23add_third_party_caveat, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; +static struct PyGetSetDef __pyx_getsets_9macaroons_Macaroon[] = { + {(char *)"location", __pyx_getprop_9macaroons_8Macaroon_location, 0, (char *)0, 0}, + {(char *)"identifier", __pyx_getprop_9macaroons_8Macaroon_identifier, 0, (char *)0, 0}, + {(char *)"signature", __pyx_getprop_9macaroons_8Macaroon_signature, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + static PyTypeObject __pyx_type_9macaroons_Macaroon = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("macaroons.Macaroon"), /*tp_name*/ + "macaroons.Macaroon", /*tp_name*/ sizeof(struct __pyx_obj_9macaroons_Macaroon), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_9macaroons_Macaroon, /*tp_dealloc*/ @@ -4982,8 +5238,9 @@ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ - #else - 0, /*reserved*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ @@ -5005,7 +5262,7 @@ 0, /*tp_iternext*/ __pyx_methods_9macaroons_Macaroon, /*tp_methods*/ 0, /*tp_members*/ - 0, /*tp_getset*/ + __pyx_getsets_9macaroons_Macaroon, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ @@ -5022,9 +5279,7 @@ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ - #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ - #endif #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif @@ -5086,16 +5341,16 @@ } static PyMethodDef __pyx_methods_9macaroons_Verifier[] = { - {__Pyx_NAMESTR("satisfy_exact"), (PyCFunction)__pyx_pw_9macaroons_8Verifier_5satisfy_exact, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("satisfy_general"), (PyCFunction)__pyx_pw_9macaroons_8Verifier_7satisfy_general, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("verify"), (PyCFunction)__pyx_pw_9macaroons_8Verifier_9verify, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("verify_unsafe"), (PyCFunction)__pyx_pw_9macaroons_8Verifier_11verify_unsafe, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {"satisfy_exact", (PyCFunction)__pyx_pw_9macaroons_8Verifier_5satisfy_exact, METH_O, 0}, + {"satisfy_general", (PyCFunction)__pyx_pw_9macaroons_8Verifier_7satisfy_general, METH_O, 0}, + {"verify", (PyCFunction)__pyx_pw_9macaroons_8Verifier_9verify, METH_VARARGS|METH_KEYWORDS, 0}, + {"verify_unsafe", (PyCFunction)__pyx_pw_9macaroons_8Verifier_11verify_unsafe, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; static PyTypeObject __pyx_type_9macaroons_Verifier = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("macaroons.Verifier"), /*tp_name*/ + "macaroons.Verifier", /*tp_name*/ sizeof(struct __pyx_obj_9macaroons_Verifier), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_9macaroons_Verifier, /*tp_dealloc*/ @@ -5104,8 +5359,9 @@ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ - #else - 0, /*reserved*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ @@ -5144,9 +5400,7 @@ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ - #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ - #endif #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif @@ -5163,7 +5417,7 @@ #else PyModuleDef_HEAD_INIT, #endif - __Pyx_NAMESTR("macaroons"), + "macaroons", 0, /* m_doc */ -1, /* m_size */ __pyx_methods /* m_methods */, @@ -5195,8 +5449,7 @@ {&__pyx_n_s_err, __pyx_k_err, sizeof(__pyx_k_err), 0, 0, 1, 1}, {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1}, {&__pyx_n_s_hex, __pyx_k_hex, sizeof(__pyx_k_hex), 0, 0, 1, 1}, - {&__pyx_kp_s_home_jrwren_src_debs_libmacaroo, __pyx_k_home_jrwren_src_debs_libmacaroo, sizeof(__pyx_k_home_jrwren_src_debs_libmacaroo), 0, 0, 1, 0}, - {&__pyx_n_s_identifier, __pyx_k_identifier, sizeof(__pyx_k_identifier), 0, 0, 1, 1}, + {&__pyx_kp_s_home_bac_git_libmacaroons_bindi, __pyx_k_home_bac_git_libmacaroons_bindi, sizeof(__pyx_k_home_bac_git_libmacaroons_bindi), 0, 0, 1, 0}, {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1}, {&__pyx_n_s_key_2, __pyx_k_key_2, sizeof(__pyx_k_key_2), 0, 0, 1, 1}, {&__pyx_n_s_key_id, __pyx_k_key_id, sizeof(__pyx_k_key_id), 0, 0, 1, 1}, @@ -5217,23 +5470,20 @@ {&__pyx_kp_s_not_authorized, __pyx_k_not_authorized, sizeof(__pyx_k_not_authorized), 0, 0, 1, 0}, {&__pyx_kp_s_operation_failed_unexpectedly, __pyx_k_operation_failed_unexpectedly, sizeof(__pyx_k_operation_failed_unexpectedly), 0, 0, 1, 0}, {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1}, - {&__pyx_n_s_property, __pyx_k_property, sizeof(__pyx_k_property), 0, 0, 1, 1}, {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1}, {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, - {&__pyx_n_s_signature, __pyx_k_signature, sizeof(__pyx_k_signature), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_kp_s_too_many_caveats, __pyx_k_too_many_caveats, sizeof(__pyx_k_too_many_caveats), 0, 0, 1, 0}, {&__pyx_n_s_verify_unsafe, __pyx_k_verify_unsafe, sizeof(__pyx_k_verify_unsafe), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_property = __Pyx_GetBuiltinName(__pyx_n_s_property); if (!__pyx_builtin_property) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 89, __pyx_L1_error) + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 257, __pyx_L1_error) + __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 308, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; @@ -5250,7 +5500,7 @@ * * def copy(self): */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_n_s_hex); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple_ = PyTuple_Pack(1, __pyx_n_s_hex); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); @@ -5261,7 +5511,7 @@ * * */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_macaroon_not_initialized); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_macaroon_not_initialized); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); @@ -5272,7 +5522,7 @@ * * def verify_unsafe(self, Macaroon M, bytes key, MS=None): */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_macaroon_not_authorized); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_macaroon_not_authorized); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); @@ -5283,10 +5533,10 @@ * cdef unsigned char* location = _location * cdef size_t location_sz = len(_location) */ - __pyx_tuple__4 = PyTuple_Pack(11, __pyx_n_s_location, __pyx_n_s_key, __pyx_n_s_key_id, __pyx_n_s_location_2, __pyx_n_s_location_sz, __pyx_n_s_key_2, __pyx_n_s_key_sz, __pyx_n_s_key_id_2, __pyx_n_s_key_id_sz, __pyx_n_s_err, __pyx_n_s_M); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__4 = PyTuple_Pack(11, __pyx_n_s_location, __pyx_n_s_key, __pyx_n_s_key_id, __pyx_n_s_location_2, __pyx_n_s_location_sz, __pyx_n_s_key_2, __pyx_n_s_key_sz, __pyx_n_s_key_id_2, __pyx_n_s_key_id_sz, __pyx_n_s_err, __pyx_n_s_M); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 324, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); - __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(3, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_jrwren_src_debs_libmacaroo, __pyx_n_s_create, 324, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(3, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_bac_git_libmacaroons_bindi, __pyx_n_s_create, 324, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 324, __pyx_L1_error) /* "macaroons.pyx":340 * @@ -5295,10 +5545,10 @@ * cdef Macaroon M = Macaroon() * cdef macaroon_returncode err */ - __pyx_tuple__6 = PyTuple_Pack(3, __pyx_n_s_m, __pyx_n_s_M, __pyx_n_s_err); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__6 = PyTuple_Pack(3, __pyx_n_s_m, __pyx_n_s_M, __pyx_n_s_err); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); - __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_jrwren_src_debs_libmacaroo, __pyx_n_s_deserialize, 340, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_bac_git_libmacaroons_bindi, __pyx_n_s_deserialize, 340, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -5307,10 +5557,10 @@ } static int __Pyx_InitGlobals(void) { - if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_int_32 = PyInt_FromLong(32); if (unlikely(!__pyx_int_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_32 = PyInt_FromLong(32); if (unlikely(!__pyx_int_32)) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; @@ -5328,9 +5578,6 @@ PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); @@ -5342,17 +5589,24 @@ } #endif __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_macaroons(void)", 0); - if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __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) #ifdef __Pyx_CyFunction_USED - if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Coroutine_USED + if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_StopAsyncIteration_USED + if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ @@ -5363,57 +5617,60 @@ #endif /*--- Module creation code ---*/ #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4(__Pyx_NAMESTR("macaroons"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + __pyx_m = Py_InitModule4("macaroons", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif - if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + __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_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); #endif - if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); /*--- Initialize various global constants etc. ---*/ - if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif if (__pyx_module_is_main_macaroons) { - if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) } #if PY_MAJOR_VERSION >= 3 { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) if (!PyDict_GetItemString(modules, "macaroons")) { - if (unlikely(PyDict_SetItemString(modules, "macaroons", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(PyDict_SetItemString(modules, "macaroons", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) } } #endif /*--- Builtin init code ---*/ - if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Constants init code ---*/ - if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Global init code ---*/ /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ __pyx_vtabptr_9macaroons_Macaroon = &__pyx_vtable_9macaroons_Macaroon; __pyx_vtable_9macaroons_Macaroon.assert_not_null = (PyObject *(*)(struct __pyx_obj_9macaroons_Macaroon *))__pyx_f_9macaroons_8Macaroon_assert_not_null; - if (PyType_Ready(&__pyx_type_9macaroons_Macaroon) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_9macaroons_Macaroon) < 0) __PYX_ERR(0, 100, __pyx_L1_error) __pyx_type_9macaroons_Macaroon.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type_9macaroons_Macaroon.tp_dict, __pyx_vtabptr_9macaroons_Macaroon) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Macaroon", (PyObject *)&__pyx_type_9macaroons_Macaroon) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_9macaroons_Macaroon.tp_dict, __pyx_vtabptr_9macaroons_Macaroon) < 0) __PYX_ERR(0, 100, __pyx_L1_error) + if (PyObject_SetAttrString(__pyx_m, "Macaroon", (PyObject *)&__pyx_type_9macaroons_Macaroon) < 0) __PYX_ERR(0, 100, __pyx_L1_error) __pyx_ptype_9macaroons_Macaroon = &__pyx_type_9macaroons_Macaroon; - if (PyType_Ready(&__pyx_type_9macaroons_Verifier) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_9macaroons_Verifier) < 0) __PYX_ERR(0, 268, __pyx_L1_error) __pyx_type_9macaroons_Verifier.tp_print = 0; - if (__Pyx_SetAttrString(__pyx_m, "Verifier", (PyObject *)&__pyx_type_9macaroons_Verifier) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttrString(__pyx_m, "Verifier", (PyObject *)&__pyx_type_9macaroons_Verifier) < 0) __PYX_ERR(0, 268, __pyx_L1_error) __pyx_ptype_9macaroons_Verifier = &__pyx_type_9macaroons_Verifier; /*--- Type import code ---*/ /*--- Variable import code ---*/ /*--- Function import code ---*/ /*--- Execution code ---*/ + #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif /* "macaroons.pyx":80 * @@ -5422,7 +5679,7 @@ * * */ - if (PyDict_SetItem(__pyx_d, __pyx_n_s_SUGGESTED_SECRET_LENGTH, __pyx_int_32) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_SUGGESTED_SECRET_LENGTH, __pyx_int_32) < 0) __PYX_ERR(0, 80, __pyx_L1_error) /* "macaroons.pyx":83 * @@ -5431,18 +5688,18 @@ * class Unauthorized(Exception): pass * */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_builtin_Exception); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_builtin_Exception); __Pyx_GIVEREF(__pyx_builtin_Exception); - __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_builtin_Exception); + __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_MacaroonError, __pyx_n_s_MacaroonError, (PyObject *) NULL, __pyx_n_s_macaroons, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_MacaroonError, __pyx_n_s_MacaroonError, (PyObject *) NULL, __pyx_n_s_macaroons, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_MacaroonError, __pyx_t_1, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_MacaroonError, __pyx_t_1, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_MacaroonError, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_MacaroonError, __pyx_t_4) < 0) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -5455,110 +5712,23 @@ * * */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_builtin_Exception); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_builtin_Exception); __Pyx_GIVEREF(__pyx_builtin_Exception); - __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_builtin_Exception); + __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_Unauthorized, __pyx_n_s_Unauthorized, (PyObject *) NULL, __pyx_n_s_macaroons, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_Unauthorized, __pyx_n_s_Unauthorized, (PyObject *) NULL, __pyx_n_s_macaroons, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_Unauthorized, __pyx_t_1, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_Unauthorized, __pyx_t_1, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_Unauthorized, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_Unauthorized, __pyx_t_4) < 0) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "macaroons.pyx":115 - * - * @property - * def location(self): # <<<<<<<<<<<<<< - * cdef const unsigned char* location = NULL - * cdef size_t location_sz = 0 - */ - __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_9macaroons_Macaroon, __pyx_n_s_location_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - - /* "macaroons.pyx":114 - * return macaroon_validate(self._M) == 0 - * - * @property # <<<<<<<<<<<<<< - * def location(self): - * cdef const unsigned char* location = NULL - */ - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem((PyObject *)__pyx_ptype_9macaroons_Macaroon->tp_dict, __pyx_n_s_location_2, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - PyType_Modified(__pyx_ptype_9macaroons_Macaroon); - - /* "macaroons.pyx":123 - * - * @property - * def identifier(self): # <<<<<<<<<<<<<< - * cdef const unsigned char* identifier = NULL - * cdef size_t identifier_sz = 0 - */ - __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_9macaroons_Macaroon, __pyx_n_s_identifier); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - - /* "macaroons.pyx":122 - * return location[:location_sz] - * - * @property # <<<<<<<<<<<<<< - * def identifier(self): - * cdef const unsigned char* identifier = NULL - */ - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem((PyObject *)__pyx_ptype_9macaroons_Macaroon->tp_dict, __pyx_n_s_identifier, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - PyType_Modified(__pyx_ptype_9macaroons_Macaroon); - - /* "macaroons.pyx":131 - * - * @property - * def signature(self): # <<<<<<<<<<<<<< - * cdef const unsigned char* signature = NULL - * cdef size_t signature_sz = 0 - */ - __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_9macaroons_Macaroon, __pyx_n_s_signature); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - - /* "macaroons.pyx":130 - * return identifier[:identifier_sz] - * - * @property # <<<<<<<<<<<<<< - * def signature(self): - * cdef const unsigned char* signature = NULL - */ - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem((PyObject *)__pyx_ptype_9macaroons_Macaroon->tp_dict, __pyx_n_s_signature, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - PyType_Modified(__pyx_ptype_9macaroons_Macaroon); - /* "macaroons.pyx":324 * * @@ -5566,9 +5736,9 @@ * cdef unsigned char* location = _location * cdef size_t location_sz = len(_location) */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_9macaroons_1create, NULL, __pyx_n_s_macaroons); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_9macaroons_1create, NULL, __pyx_n_s_macaroons); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_create, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_create, __pyx_t_1) < 0) __PYX_ERR(0, 324, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macaroons.pyx":340 @@ -5578,9 +5748,9 @@ * cdef Macaroon M = Macaroon() * cdef macaroon_returncode err */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_9macaroons_3deserialize, NULL, __pyx_n_s_macaroons); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_9macaroons_3deserialize, NULL, __pyx_n_s_macaroons); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_deserialize, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_deserialize, __pyx_t_1) < 0) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "macaroons.pyx":1 @@ -5588,10 +5758,13 @@ * # All rights reserved. * # */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /*--- Wrapped vars code ---*/ + goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); @@ -5599,7 +5772,9 @@ __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); if (__pyx_m) { - __Pyx_AddTraceback("init macaroons", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__pyx_d) { + __Pyx_AddTraceback("init macaroons", __pyx_clineno, __pyx_lineno, __pyx_filename); + } Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init macaroons"); @@ -5613,7 +5788,8 @@ #endif } -/* Runtime support code */ +/* --- Runtime support code --- */ +/* Refnanny */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; @@ -5628,8 +5804,9 @@ Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } -#endif /* CYTHON_REFNANNY */ +#endif +/* GetBuiltinName */ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); if (unlikely(!result)) { @@ -5643,11 +5820,12 @@ return result; } +/* GetModuleGlobalName */ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; #if CYTHON_COMPILING_IN_CPYTHON result = PyDict_GetItem(__pyx_d, name); - if (result) { + if (likely(result)) { Py_INCREF(result); } else { #else @@ -5660,9 +5838,10 @@ return result; } -static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) { +/* dict_getitem_default */ + static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) { PyObject* value; -#if PY_MAJOR_VERSION >= 3 +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (unlikely(PyErr_Occurred())) @@ -5687,20 +5866,37 @@ return value; } -#if CYTHON_COMPILING_IN_CPYTHON +/* PyObjectCall */ + #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = func->ob_type->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); -#if PY_VERSION_HEX >= 0x02060000 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; -#endif result = (*call)(func, arg, kw); -#if PY_VERSION_HEX >= 0x02060000 Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} #endif + +/* PyObjectCallMethO */ + #if CYTHON_COMPILING_IN_CPYTHON +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, @@ -5710,10 +5906,45 @@ } #endif -static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { -#if CYTHON_COMPILING_IN_CPYTHON +/* PyObjectCallOneArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_New(1); + if (unlikely(!args)) return NULL; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { +#else + if (likely(PyCFunction_Check(func))) { +#endif + if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { + return __Pyx_PyObject_CallMethO(func, arg); + } + } + return __Pyx__PyObject_CallOneArg(func, arg); +} +#else +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_Pack(1, arg); + if (unlikely(!args)) return NULL; + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +#endif + +/* PyErrFetchRestore */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; - PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; @@ -5723,27 +5954,22 @@ Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); -#else - PyErr_Restore(type, value, tb); -#endif } -static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { -#if CYTHON_COMPILING_IN_CPYTHON - PyThreadState *tstate = PyThreadState_GET(); +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; -#else - PyErr_Fetch(type, value, tb); -#endif } +#endif -#if PY_MAJOR_VERSION < 3 +/* RaiseException */ + #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { + __Pyx_PyThreadState_declare Py_XINCREF(type); if (!value || value == Py_None) value = NULL; @@ -5759,11 +5985,7 @@ goto raise_error; } } - #if PY_VERSION_HEX < 0x02050000 - if (PyClass_Check(type)) { - #else if (PyType_Check(type)) { - #endif #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); @@ -5778,17 +6000,6 @@ goto raise_error; } value = type; - #if PY_VERSION_HEX < 0x02050000 - if (PyInstance_Check(type)) { - type = (PyObject*) ((PyInstanceObject*)type)->in_class; - Py_INCREF(type); - } else { - type = 0; - PyErr_SetString(PyExc_TypeError, - "raise: exception must be an old-style class or instance"); - goto raise_error; - } - #else type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { @@ -5796,8 +6007,8 @@ "raise: exception class must be a subclass of BaseException"); goto raise_error; } - #endif } + __Pyx_PyThreadState_assign __Pyx_ErrRestore(type, value, tb); return; raise_error: @@ -5806,7 +6017,7 @@ Py_XDECREF(tb); return; } -#else /* Python 3+ */ +#else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { @@ -5831,10 +6042,13 @@ if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { - if (PyObject_IsSubclass(instance_class, type)) { - type = instance_class; - } else { + int is_subclass = PyObject_IsSubclass(instance_class, type); + if (!is_subclass) { instance_class = NULL; + } else if (unlikely(is_subclass == -1)) { + goto bad; + } else { + type = instance_class; } } } @@ -5892,6 +6106,13 @@ } PyErr_SetObject(type, value); if (tb) { +#if CYTHON_COMPILING_IN_PYPY + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); +#else PyThreadState *tstate = PyThreadState_GET(); PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { @@ -5899,6 +6120,7 @@ tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } +#endif } bad: Py_XDECREF(owned_instance); @@ -5906,7 +6128,8 @@ } #endif -static void __Pyx_RaiseArgtupleInvalid( +/* RaiseArgTupleInvalid */ + static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, @@ -5931,7 +6154,8 @@ (num_expected == 1) ? "" : "s", num_found); } -static CYTHON_INLINE int __Pyx_CheckKeywordStrings( +/* KeywordStringCheck */ + static CYTHON_INLINE int __Pyx_CheckKeywordStrings( PyObject *kwdict, const char* function_name, int kw_allowed) @@ -5970,11 +6194,15 @@ return 0; } +/* GetException */ + #if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { +#else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { +#endif PyObject *local_type, *local_value, *local_tb; #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; - PyThreadState *tstate = PyThreadState_GET(); local_type = tstate->curexc_type; local_value = tstate->curexc_value; local_tb = tstate->curexc_traceback; @@ -6027,42 +6255,43 @@ return -1; } -static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { +/* SwapException */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; -#if CYTHON_COMPILING_IN_CPYTHON - PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = *type; tstate->exc_value = *value; tstate->exc_traceback = *tb; + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} #else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); PyErr_SetExcInfo(*type, *value, *tb); -#endif *type = tmp_type; *value = tmp_value; *tb = tmp_tb; } +#endif -static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) { -#if CYTHON_COMPILING_IN_CPYTHON - PyThreadState *tstate = PyThreadState_GET(); +/* SaveResetException */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); -#else - PyErr_GetExcInfo(type, value, tb); -#endif } -static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) { -#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; - PyThreadState *tstate = PyThreadState_GET(); tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; @@ -6072,12 +6301,11 @@ Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); -#else - PyErr_SetExcInfo(type, value, tb); -#endif } +#endif -static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { +/* ArgTypeTest */ + static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { PyErr_Format(PyExc_TypeError, "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", name, type->tp_name, Py_TYPE(obj)->tp_name); @@ -6103,7 +6331,8 @@ return 0; } -static void __Pyx_RaiseDoubleKeywordsError( +/* RaiseDoubleKeywords */ + static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { @@ -6116,7 +6345,8 @@ #endif } -static int __Pyx_ParseOptionalKeywords( +/* ParseKeywords */ + static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, @@ -6217,7 +6447,106 @@ return -1; } -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { +/* PyIntBinop */ + #if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(op1))) { + const long b = intval; + long x; + long a = PyInt_AS_LONG(op1); + x = (long)((unsigned long)a + b); + if (likely((x^a) >= 0 || (x^b) >= 0)) + return PyInt_FromLong(x); + return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + #endif + #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3 + if (likely(PyLong_CheckExact(op1))) { + const long b = intval; + long a, x; + const PY_LONG_LONG llb = intval; + PY_LONG_LONG lla, llx; + const digit* digits = ((PyLongObject*)op1)->ob_digit; + const Py_ssize_t size = Py_SIZE(op1); + if (likely(__Pyx_sst_abs(size) <= 1)) { + a = likely(size) ? digits[0] : 0; + if (size == -1) a = -a; + } else { + switch (size) { + case -2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + } + case 2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + } + case -3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + } + case 3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + } + case -4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + } + case 4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; + } + default: return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + } + x = a + b; + return PyLong_FromLong(x); + long_long: + llx = lla + llb; + return PyLong_FromLongLong(llx); + } + #endif + if (PyFloat_CheckExact(op1)) { + const long b = intval; + double a = PyFloat_AS_DOUBLE(op1); + double result; + PyFPE_START_PROTECT("add", return NULL) + result = ((double)a) + (double)b; + PyFPE_END_PROTECT(result) + return PyFloat_FromDouble(result); + } + return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); +} +#endif + +/* ExtTypeTest */ + static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; @@ -6229,8 +6558,9 @@ return 0; } -static int __Pyx_SetVtable(PyObject *dict, void *vtable) { -#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) +/* SetVTable */ + static int __Pyx_SetVtable(PyObject *dict, void *vtable) { +#if PY_VERSION_HEX >= 0x02070000 PyObject *ob = PyCapsule_New(vtable, 0, 0); #else PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); @@ -6246,7 +6576,8 @@ return -1; } -static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) { +/* 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; @@ -6284,7 +6615,8 @@ return (PyObject*) metaclass; } -static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, +/* Py3ClassCreate */ + static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) { PyObject *ns; if (metaclass) { @@ -6350,74 +6682,255 @@ return result; } -static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) { - PyObject *result; - result = __Pyx_PyObject_GetAttrStr(nmspace, name); - if (!result) - result = __Pyx_GetModuleGlobalName(name); - return result; -} - -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) { - const unsigned int neg_one = (unsigned int) -1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(unsigned int) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(unsigned int) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); - } else if (sizeof(unsigned int) <= sizeof(unsigned long long)) { - return PyLong_FromUnsignedLongLong((unsigned long long) value); - } - } else { - if (sizeof(unsigned int) <= sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(unsigned int) <= sizeof(long long)) { - return PyLong_FromLongLong((long long) value); +/* 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; } } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(unsigned int), - little, !is_unsigned); + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; } } - -#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func) \ - { \ - func_type value = func(x); \ - if (sizeof(target_type) < sizeof(func_type)) { \ - if (unlikely(value != (func_type) (target_type) value)) { \ - func_type zero = 0; \ - PyErr_SetString(PyExc_OverflowError, \ - (is_unsigned && unlikely(value < zero)) ? \ - "can't convert negative value to " #target_type : \ - "value too large to convert to " #target_type); \ - return (target_type) -1; \ - } \ - } \ - return (target_type) value; \ +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; } - -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #endif -#endif -static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) { - const unsigned int neg_one = (unsigned int) -1, const_zero = 0; + 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 */ + #include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + #if PY_MAJOR_VERSION < 3 + py_srcfile = PyString_FromString(filename); + #else + py_srcfile = PyUnicode_FromString(filename); + #endif + if (!py_srcfile) goto bad; + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + #else + py_funcname = PyUnicode_FromString(funcname); + #endif + } + if (!py_funcname) goto bad; + py_code = __Pyx_PyCode_New( + 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_DECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + 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; + py_code = __pyx_find_code_object(c_line ? c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? c_line : py_line, py_code); + } + py_frame = PyFrame_New( + PyThreadState_GET(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + py_frame->f_lineno = py_line; + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__macaroon_returncode(enum macaroon_returncode value) { + const enum macaroon_returncode neg_one = (enum macaroon_returncode) -1, const_zero = (enum macaroon_returncode) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(enum macaroon_returncode) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(enum macaroon_returncode) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); + } else if (sizeof(enum macaroon_returncode) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); + } + } else { + if (sizeof(enum macaroon_returncode) <= sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(enum macaroon_returncode) <= 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(enum macaroon_returncode), + little, !is_unsigned); + } +} + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) { + const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(unsigned int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(unsigned int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); + } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); + } + } else { + if (sizeof(unsigned int) <= sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(unsigned int) <= 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(unsigned int), + little, !is_unsigned); + } +} + +/* CIntFromPyVerify */ + #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) +#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) +#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ + {\ + func_type value = func_value;\ + if (sizeof(target_type) < sizeof(func_type)) {\ + if (unlikely(value != (func_type) (target_type) value)) {\ + func_type zero = 0;\ + if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ + return (target_type) -1;\ + if (is_unsigned && unlikely(value < zero))\ + goto raise_neg_overflow;\ + else\ + goto raise_overflow;\ + }\ + }\ + return (target_type) value;\ + } + +/* CIntFromPy */ + static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) { + const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(unsigned int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG) + __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned int"); - return (unsigned int) -1; + goto raise_neg_overflow; } return (unsigned int) val; } @@ -6425,42 +6938,125 @@ #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(unsigned int)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return (unsigned int) ((PyLongObject*)x)->ob_digit[0]; - } +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (unsigned int) 0; + case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0]) + case 2: + if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) { + return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) { + return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) { + return (unsigned int) (((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); + } + } + break; } - #endif #endif +#if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned int"); - return (unsigned int) -1; + goto raise_neg_overflow; } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (unsigned int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif if (sizeof(unsigned int) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, PyLong_AsUnsignedLong) - } else if (sizeof(unsigned int) <= sizeof(unsigned long long)) { - __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long long, PyLong_AsUnsignedLongLong) + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x)) + } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(unsigned int)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return +(unsigned int) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(unsigned int) ((PyLongObject*)x)->ob_digit[0]; - } +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (unsigned int) 0; + case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, +digits[0]) + case -2: + if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { + return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { + return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { + return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { + return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { + return (unsigned int) (((unsigned int)-1)*(((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { + return (unsigned int) ((((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; } - #endif #endif if (sizeof(unsigned int) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT(unsigned int, long, PyLong_AsLong) - } else if (sizeof(unsigned int) <= sizeof(long long)) { - __PYX_VERIFY_RETURN_INT(unsigned int, long long, PyLong_AsLongLong) + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x)) + } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { @@ -6469,7 +7065,7 @@ "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else unsigned int val; - PyObject *v = __Pyx_PyNumber_Int(x); + PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; @@ -6492,30 +7088,39 @@ } } else { unsigned int val; - PyObject *tmp = __Pyx_PyNumber_Int(x); + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (unsigned int) -1; val = __Pyx_PyInt_As_unsigned_int(tmp); Py_DECREF(tmp); return val; } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to unsigned int"); + return (unsigned int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned int"); + return (unsigned int) -1; } -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { - const long neg_one = (long) -1, const_zero = 0; +/* 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 long long)) { - return PyLong_FromUnsignedLongLong((unsigned long 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(long long)) { - return PyLong_FromLongLong((long long) value); + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); } } { @@ -6526,24 +7131,18 @@ } } -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #endif -#endif -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { - const long neg_one = (long) -1, const_zero = 0; +/* 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 PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(long) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG) + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long) -1; + goto raise_neg_overflow; } return (long) val; } @@ -6551,42 +7150,125 @@ #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(long)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return (long) ((PyLongObject*)x)->ob_digit[0]; - } +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) + 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; } - #endif #endif +#if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long) -1; + goto raise_neg_overflow; } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (long) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif if (sizeof(long) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong) - } else if (sizeof(long) <= sizeof(unsigned long long)) { - __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong) + __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 CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(long)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return +(long) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(long) ((PyLongObject*)x)->ob_digit[0]; - } +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) + 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; } - #endif #endif if (sizeof(long) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong) - } else if (sizeof(long) <= sizeof(long long)) { - __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong) + __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)) } } { @@ -6595,7 +7277,7 @@ "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else long val; - PyObject *v = __Pyx_PyNumber_Int(x); + PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; @@ -6618,32 +7300,34 @@ } } else { long val; - PyObject *tmp = __Pyx_PyNumber_Int(x); + 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; } -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #endif -#endif -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { - const int neg_one = (int) -1, const_zero = 0; +/* 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 PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG) + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int"); - return (int) -1; + goto raise_neg_overflow; } return (int) val; } @@ -6651,42 +7335,125 @@ #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(int)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return (int) ((PyLongObject*)x)->ob_digit[0]; - } +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) + 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; } - #endif #endif +#if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int"); - return (int) -1; + goto raise_neg_overflow; } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif if (sizeof(int) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong) - } else if (sizeof(int) <= sizeof(unsigned long long)) { - __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong) + __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 CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(int)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return +(int) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(int) ((PyLongObject*)x)->ob_digit[0]; - } +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) + 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; } - #endif #endif if (sizeof(int) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong) - } else if (sizeof(int) <= sizeof(long long)) { - __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong) + __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)) } } { @@ -6695,7 +7462,7 @@ "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else int val; - PyObject *v = __Pyx_PyNumber_Int(x); + PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; @@ -6718,15 +7485,24 @@ } } else { int val; - PyObject *tmp = __Pyx_PyNumber_Int(x); + 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; } -static int __Pyx_check_binary_version(void) { +/* CheckBinaryVersion */ + static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); @@ -6736,178 +7512,13 @@ "compiletime version %s of module '%.100s' " "does not match runtime version %s", ctversion, __Pyx_MODULE_NAME, rtversion); - #if PY_VERSION_HEX < 0x02050000 - return PyErr_Warn(NULL, message); - #else return PyErr_WarnEx(NULL, message, 1); - #endif } return 0; } -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) / 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); -} - -#include "compile.h" -#include "frameobject.h" -#include "traceback.h" -static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( - const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_srcfile = 0; - PyObject *py_funcname = 0; - #if PY_MAJOR_VERSION < 3 - py_srcfile = PyString_FromString(filename); - #else - py_srcfile = PyUnicode_FromString(filename); - #endif - if (!py_srcfile) goto bad; - if (c_line) { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #endif - } - else { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromString(funcname); - #else - py_funcname = PyUnicode_FromString(funcname); - #endif - } - if (!py_funcname) goto bad; - py_code = __Pyx_PyCode_New( - 0, /*int argcount,*/ - 0, /*int kwonlyargcount,*/ - 0, /*int nlocals,*/ - 0, /*int stacksize,*/ - 0, /*int flags,*/ - __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, /*int firstlineno,*/ - __pyx_empty_bytes /*PyObject *lnotab*/ - ); - Py_DECREF(py_srcfile); - Py_DECREF(py_funcname); - return py_code; -bad: - Py_XDECREF(py_srcfile); - Py_XDECREF(py_funcname); - return NULL; -} -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_globals = 0; - PyFrameObject *py_frame = 0; - py_code = __pyx_find_code_object(c_line ? c_line : py_line); - if (!py_code) { - py_code = __Pyx_CreateCodeObjectForTraceback( - funcname, c_line, py_line, filename); - if (!py_code) goto bad; - __pyx_insert_code_object(c_line ? c_line : py_line, py_code); - } - py_globals = PyModule_GetDict(__pyx_m); - if (!py_globals) goto bad; - py_frame = PyFrame_New( - PyThreadState_GET(), /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - py_globals, /*PyObject *globals,*/ - 0 /*PyObject *locals*/ - ); - if (!py_frame) goto bad; - py_frame->f_lineno = py_line; - PyTraceBack_Here(py_frame); -bad: - Py_XDECREF(py_code); - Py_XDECREF(py_frame); -} - -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { +/* InitStrings */ + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { @@ -6917,7 +7528,7 @@ } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } - #else /* Python 3+ has unicode identifiers */ + #else if (t->is_unicode | t->is_str) { if (t->intern) { *t->p = PyUnicode_InternFromString(t->s); @@ -6945,7 +7556,7 @@ return __Pyx_PyObject_AsStringAndSize(o, &ignore); } static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && @@ -6967,11 +7578,11 @@ } } } -#endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/ +#endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; -#else /* PY_VERSION_HEX < 0x03030000 */ - if (PyUnicode_READY(o) == -1) return NULL; +#else + if (__Pyx_PyUnicode_READY(o) == -1) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (PyUnicode_IS_ASCII(o)) { *length = PyUnicode_GET_LENGTH(o); @@ -6980,20 +7591,18 @@ PyUnicode_AsASCIIString(o); return NULL; } -#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ +#else return PyUnicode_AsUTF8AndSize(o, length); -#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */ -#endif /* PY_VERSION_HEX < 0x03030000 */ +#endif +#endif } else -#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */ -#if !CYTHON_COMPILING_IN_PYPY -#if PY_VERSION_HEX >= 0x02060000 +#endif +#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif -#endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); @@ -7009,7 +7618,7 @@ if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } -static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { PyNumberMethods *m; const char *name = NULL; PyObject *res = NULL; @@ -7018,7 +7627,7 @@ #else if (PyLong_Check(x)) #endif - return Py_INCREF(x), x; + return __Pyx_NewRef(x); m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { @@ -7054,33 +7663,61 @@ } return res; } -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #endif -#endif static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(b))) - return PyInt_AS_LONG(b); + if (likely(PyInt_CheckExact(b))) { + if (sizeof(Py_ssize_t) >= sizeof(long)) + return PyInt_AS_LONG(b); + else + return PyInt_AsSsize_t(x); + } #endif if (likely(PyLong_CheckExact(b))) { - #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 - #if CYTHON_USE_PYLONG_INTERNALS - switch (Py_SIZE(b)) { - case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0]; - case 0: return 0; - case 1: return ((PyLongObject*)b)->ob_digit[0]; - } - #endif + #if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)b)->ob_digit; + const Py_ssize_t size = Py_SIZE(b); + if (likely(__Pyx_sst_abs(size) <= 1)) { + ival = likely(size) ? digits[0] : 0; + if (size == -1) ival = -ival; + return ival; + } else { + 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; + } + } #endif - #if PY_VERSION_HEX < 0x02060000 - return PyInt_AsSsize_t(b); - #else return PyLong_AsSsize_t(b); - #endif } x = PyNumber_Index(b); if (!x) return -1; @@ -7089,17 +7726,7 @@ return ival; } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { -#if PY_VERSION_HEX < 0x02050000 - if (ival <= LONG_MAX) - return PyInt_FromLong((long)ival); - else { - unsigned char *bytes = (unsigned char *) &ival; - int one = 1; int little = (int)*(unsigned char*)&one; - return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0); - } -#else - return PyInt_FromSize_t(ival); -#endif + return PyInt_FromSize_t(ival); } diff -Nru libmacaroons-0.2.0/configure.ac libmacaroons-0.2.0/configure.ac --- libmacaroons-0.2.0/configure.ac 2015-01-21 11:44:22.000000000 +0000 +++ libmacaroons-0.2.0/configure.ac 2017-01-17 20:05:48.000000000 +0000 @@ -62,7 +62,7 @@ ----------------------------------------]) fi - AC_CHECK_HEADER([json/json.h],,[AC_MSG_ERROR([ + AC_CHECK_HEADER([json-c/json.h],,[AC_MSG_ERROR([ ---------------------------------------- Macaroons rely upon the libjson library. Please install libjson to continue. diff -Nru libmacaroons-0.2.0/debian/changelog libmacaroons-0.2.0/debian/changelog --- libmacaroons-0.2.0/debian/changelog 2015-01-21 15:45:55.000000000 +0000 +++ libmacaroons-0.2.0/debian/changelog 2017-01-17 20:05:48.000000000 +0000 @@ -1,3 +1,9 @@ +libmacaroons (0.2.0-8) yakkety; urgency=medium + + * Build for yakkety. + + -- Bradley A. Crittenden Tue, 17 Jan 2017 16:05:48 -0400 + libmacaroons (0.2.0-7) utopic; urgency=medium * build for utopic diff -Nru libmacaroons-0.2.0/debian/control libmacaroons-0.2.0/debian/control --- libmacaroons-0.2.0/debian/control 2015-01-21 12:14:13.000000000 +0000 +++ libmacaroons-0.2.0/debian/control 2017-01-17 20:05:48.000000000 +0000 @@ -1,7 +1,7 @@ Source: libmacaroons Priority: extra Maintainer: Robert Escriva -Build-Depends: debhelper (>= 8.0.0), pkg-config, dh-autoreconf, pkg-config, python-dev, libsodium-dev, libjson0-dev +Build-Depends: debhelper (>= 8.0.0), pkg-config, dh-autoreconf, pkg-config, python-dev, libsodium-dev, libjson-c-dev Standards-Version: 3.9.3 Section: libs Homepage: http://hyperdex.org diff -Nru libmacaroons-0.2.0/macaroons.c libmacaroons-0.2.0/macaroons.c --- libmacaroons-0.2.0/macaroons.c 2015-01-21 15:43:28.000000000 +0000 +++ libmacaroons-0.2.0/macaroons.c 2017-01-17 20:05:48.000000000 +0000 @@ -37,7 +37,7 @@ /* json */ #ifdef MACAROONS_JSON_SUPPORT -#include +#include #endif /* macaroons */ @@ -1001,7 +1001,7 @@ * responsible for freeing it. */ static int -encode(enum encoding encoding, +encode(enum encoding encoding, const unsigned char* val, size_t val_sz, const unsigned char** result, size_t* result_sz, enum macaroon_returncode* err) @@ -1222,7 +1222,7 @@ return -1; } - rc = json_help_add_strings(obj, jkey, (const char*)enc_val, enc_sz, err); + rc = json_help_add_strings(obj, jkey, (const char*)val, val_sz, err); free(jkey); if (enc_val != val) { @@ -1318,19 +1318,19 @@ * should not include the terminating zero. */ static int -decode(enum encoding encoding, +decode(enum encoding encoding, const unsigned char* str, size_t str_sz, const unsigned char** result, size_t* result_sz, enum macaroon_returncode* err) { unsigned char* dec_val; size_t dec_sz; + switch (encoding) { case ENCODING_RAW: *result = str; *result_sz = str_sz; - break; case ENCODING_BASE64: dec_val = malloc(str_sz); @@ -1339,7 +1339,7 @@ *err = MACAROON_OUT_OF_MEMORY; return -1; } - + dec_sz = b64_pton(str, dec_val, str_sz); if (dec_sz <= 0) { @@ -1347,10 +1347,7 @@ free(dec_val); return -1; } - *result = dec_val; - *result_sz = dec_sz; - break; - + case ENCODING_HEX: dec_sz = str_sz / 2; dec_val = malloc(dec_sz + 1); @@ -1365,9 +1362,6 @@ free(dec_val); return -1; } - *result = dec_val; - *result_sz = dec_sz; - break; default: assert(0); @@ -1389,18 +1383,15 @@ const unsigned char* dec = NULL; size_t dec_sz; size_t str_sz = 0; + if (!json_object_is_type(obj, json_type_object)) { *err = MACAROON_INVALID; return -1; } - if (!json_object_object_get_ex(obj, key, &child)) - { - // The field does not exist in the JSON - ignore it. - return 0; - } - if (!json_object_is_type(child, json_type_string)) + if (!json_object_object_get_ex(obj, key, &child) || + !json_object_is_type(child, json_type_string)) { *err = MACAROON_INVALID; return -1; @@ -1411,7 +1402,7 @@ { return -1; } - + *wptr = f(dec, dec_sz, pkt, *wptr); if (dec != str) { @@ -1513,7 +1504,8 @@ for (idx = 0; idx < (size_t)arr_sz; ++idx) { cav = json_object_array_get_idx(arr, idx); - + + /* TODO deserialize caveat vid and location. */ if (!cav || !json_object_is_type(cav, json_type_object)) { free(M); @@ -1522,28 +1514,12 @@ *err = MACAROON_INVALID; return NULL; } + if (json_help_copy_kv_packet(cav, CID, create_cid_packet, &M->caveats[idx].cid, ENCODING_RAW, &ptr, err) < 0) { free(M); json_object_put(obj); json_tokener_free(tok); - *err = MACAROON_INVALID; - return NULL; - } - if (json_help_copy_kv_packet(cav, VID, create_vid_packet, &M->caveats[idx].vid, ENCODING_BASE64, &ptr, err) < 0) - { - free(M); - json_object_put(obj); - json_tokener_free(tok); - *err = MACAROON_INVALID; - return NULL; - } - if (json_help_copy_kv_packet(cav, CL, create_cl_packet, &M->caveats[idx].cl, ENCODING_RAW, &ptr, err) < 0) - { - free(M); - json_object_put(obj); - json_tokener_free(tok); - *err = MACAROON_INVALID; return NULL; } } diff -Nru libmacaroons-0.2.0/README libmacaroons-0.2.0/README --- libmacaroons-0.2.0/README 2015-01-21 11:54:32.000000000 +0000 +++ libmacaroons-0.2.0/README 2017-01-17 20:02:31.000000000 +0000 @@ -77,21 +77,14 @@ Installing Macaroons -------------------- -This library makes it easy to get started with using macaroons in your -service. To use the library you must first install it. You'll need -to somehow install libsodium[2]. It's packaged in some Linux -distributions, and can be installed from source on most *NIX -platforms. You'll also need to install libtool, cython, and, -optionally libjson0-dev. Once you have these libraries installed, +This library makes it easy to get started with using macaroons in your service. +To use the library you must first install it. You'll need to somehow install +libsodium[2]. It's packaged in some Linux distributions, and can be installed +from source on most *NIX platforms. Once you have libsodium installed, installing macaroons is straight forward: $ autoreconf -i # only when installing from Git - $ ./configure --enable-python-bindings --enable-json-support - - Or if you don't want JSON support, - $ ./configure --enable-python-bindings - $ make # make install