diff --git a/Changelog.rst b/Changelog.rst index 0bc8544b..b6e2c62b 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -1,11 +1,28 @@ Change Log ============= +0.6.0 +++++++ + +Changes +--------- + +* Implemented `last_errno` and `set_last_error` session functions +* Agent authentication errors raise exceptions +* C-API refactor +* SFTP IO errors raise exceptions + +Fixes +------- + +* Crash on de-allocation of channel in certain cases +* SFTP ``readdir_ex`` directory listing (long entry) was not returned correctly + 0.5.5 ++++++ Changes --------- +--------- * Accept both bytes and unicode parameters in authentication with public key from memory. diff --git a/ci/build-ssh2.sh b/ci/build-ssh2.sh new file mode 100755 index 00000000..08807c09 --- /dev/null +++ b/ci/build-ssh2.sh @@ -0,0 +1,6 @@ +#!/bin/bash -xe + +mkdir -p src && cd src +cmake ../libssh2 -DBUILD_SHARED_LIBS=ON -DENABLE_ZLIB_COMPRESSION=ON \ + -DENABLE_CRYPT_NONE=ON -DENABLE_MAC_NONE=ON -DCRYPTO_BACKEND=OpenSSL +cmake --build . --config Release diff --git a/setup.py b/setup.py index c7285280..36c4d233 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,8 @@ ext = 'pyx' if USING_CYTHON else 'c' sources = glob('ssh2/*.%s' % (ext,)) _libs = ['ssh2'] if platform.system() != 'Windows' else [ + # For libssh2 OpenSSL backend on Windows. + # Windows native WinCNG is used by default. # 'libeay32', 'ssleay32', 'Ws2_32', 'libssh2', 'user32'] diff --git a/ssh2/agent.c b/ssh2/agent.c index cdf5057b..b127ebdc 100644 --- a/ssh2/agent.c +++ b/ssh2/agent.c @@ -1,13 +1,14 @@ -/* Generated by Cython 0.26 */ +/* Generated by Cython 0.27.1 */ #define PY_SSIZE_T_CLEAN #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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_26" +#define CYTHON_ABI "0_27_1" +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -31,7 +32,7 @@ #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif @@ -47,8 +48,14 @@ #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS @@ -67,6 +74,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -74,6 +85,8 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS @@ -98,6 +111,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -105,6 +122,12 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 @@ -144,6 +167,12 @@ #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -199,6 +228,27 @@ #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ @@ -282,7 +332,6 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject @@ -333,15 +382,17 @@ #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct 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)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) @@ -451,14 +502,6 @@ static CYTHON_INLINE float __PYX_NAN() { __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) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -478,7 +521,7 @@ static CYTHON_INLINE float __PYX_NAN() { #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif @@ -509,8 +552,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #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 (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -532,6 +575,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) @@ -542,16 +591,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #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) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #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 @@ -560,6 +604,8 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) #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_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS @@ -660,7 +706,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime; @@ -680,6 +726,18 @@ static const char *__pyx_f[] = { "ssh2/pkey.pxd", "ssh2/exceptions.pxd", }; +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + +/* NoFastGil.proto */ +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + /*--- Type declarations ---*/ struct __pyx_obj_4ssh2_7session_Session; @@ -695,19 +753,21 @@ struct __pyx_obj_4ssh2_10exceptions_SessionHandshakeError; struct __pyx_obj_4ssh2_10exceptions_ChannelError; struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError; struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall; +struct __pyx_obj_4ssh2_10exceptions_SFTPIOError; struct __pyx_obj_4ssh2_5agent_Agent; -/* "session.pxd":20 - * +/* "session.pxd":19 + * cimport c_ssh2 * * cdef class Session: # <<<<<<<<<<<<<< * cdef c_ssh2.LIBSSH2_SESSION *_session - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL + * cdef int _sock */ struct __pyx_obj_4ssh2_7session_Session { PyObject_HEAD - struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtab; LIBSSH2_SESSION *_session; + int _sock; + PyObject *sock; }; @@ -848,12 +908,24 @@ struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError { * * cdef class SFTPBufferTooSmall(Exception): # <<<<<<<<<<<<<< * pass + * */ struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall { PyBaseExceptionObject __pyx_base; }; +/* "exceptions.pxd":62 + * + * + * cdef class SFTPIOError(Exception): # <<<<<<<<<<<<<< + * pass + */ +struct __pyx_obj_4ssh2_10exceptions_SFTPIOError { + PyBaseExceptionObject __pyx_base; +}; + + /* "ssh2/agent.pxd":24 * * @@ -868,21 +940,6 @@ struct __pyx_obj_4ssh2_5agent_Agent { }; - -/* "session.pxd":20 - * - * - * cdef class Session: # <<<<<<<<<<<<<< - * cdef c_ssh2.LIBSSH2_SESSION *_session - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL - */ - -struct __pyx_vtabstruct_4ssh2_7session_Session { - LIBSSH2_AGENT *(*init_connect_agent)(struct __pyx_obj_4ssh2_7session_Session *); - LIBSSH2_AGENT *(*_agent_init)(struct __pyx_obj_4ssh2_7session_Session *); -}; -static struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtabptr_4ssh2_7session_Session; - /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY @@ -966,18 +1023,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject /* GetBuiltinName.proto */ static PyObject *__Pyx_GetBuiltinName(PyObject *name); -/* ForceInitThreads.proto */ -#ifndef __PYX_FORCE_INIT_THREADS - #define __PYX_FORCE_INIT_THREADS 0 -#endif - -/* NoFastGil.proto */ -#define __Pyx_PyGILState_Ensure PyGILState_Ensure -#define __Pyx_PyGILState_Release PyGILState_Release -#define __Pyx_FastGIL_Remember() -#define __Pyx_FastGIL_Forget() -#define __Pyx_FastGilFuncInit() - /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); @@ -988,21 +1033,31 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #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); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #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) @@ -1025,8 +1080,10 @@ 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); /* ArgTypeTest.proto */ -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); +#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ + ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ + __Pyx__ArgTypeTest(obj, type, name, exact)) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* ListAppend.proto */ #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS @@ -1048,9 +1105,6 @@ static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { /* SetupReduce.proto */ static int __Pyx_setup_reduce(PyObject* type_obj); -/* GetVTable.proto */ -static void* __Pyx_GetVtable(PyObject *dict); - /* CLineInTraceback.proto */ static int __Pyx_CLineForTraceback(int c_line); @@ -1085,6 +1139,18 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif + /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); @@ -1142,12 +1208,14 @@ static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SessionHandshakeError = 0; static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_ChannelError = 0; static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPHandleError = 0; static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPIOError = 0; /* Module declarations from 'ssh2.utils' */ static PyObject *(*__pyx_f_4ssh2_5utils_to_bytes)(PyObject *); /*proto*/ /* Module declarations from 'ssh2.agent' */ static PyTypeObject *__pyx_ptype_4ssh2_5agent_Agent = 0; +static int __pyx_f_4ssh2_5agent_auth_identity(char const *, LIBSSH2_AGENT *, struct libssh2_agent_publickey **, struct libssh2_agent_publickey *); /*proto*/ static void __pyx_f_4ssh2_5agent_clear_agent(LIBSSH2_AGENT *); /*proto*/ #define __Pyx_MODULE_NAME "ssh2.agent" int __pyx_module_is_main_ssh2__agent = 0; @@ -1155,34 +1223,46 @@ int __pyx_module_is_main_ssh2__agent = 0; /* Implementation of 'ssh2.agent' */ static PyObject *__pyx_builtin_TypeError; static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_pkey[] = "pkey"; static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_reduce[] = "__reduce__"; static const char __pyx_k_session[] = "session"; +static const char __pyx_k_getstate[] = "__getstate__"; +static const char __pyx_k_setstate[] = "__setstate__"; static const char __pyx_k_username[] = "username"; static const char __pyx_k_TypeError[] = "TypeError"; -static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; +static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; +static const char __pyx_k_Error_initialising_agent[] = "Error initialising agent"; static const char __pyx_k_Unable_to_connect_to_agent[] = "Unable to connect to agent"; static const char __pyx_k_No_identities_match_for_user_s[] = "No identities match for user %s"; static const char __pyx_k_Error_authenticating_user_s_with[] = "Error authenticating user %s with provided public key"; static const char __pyx_k_Failure_getting_identity_for_use[] = "Failure getting identity for user %s from agent"; -static const char __pyx_k_Failure_requesting_identities_fr[] = "Failure requesting identities from agent.Agent must be connected first"; +static const char __pyx_k_Failure_requesting_identities_fr[] = "Failure requesting identities from agent"; static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; +static const char __pyx_k_Failure_requesting_identities_fr_2[] = "Failure requesting identities from agent.Agent must be connected first"; static PyObject *__pyx_kp_s_Error_authenticating_user_s_with; +static PyObject *__pyx_kp_s_Error_initialising_agent; static PyObject *__pyx_kp_s_Failure_getting_identity_for_use; static PyObject *__pyx_kp_s_Failure_requesting_identities_fr; +static PyObject *__pyx_kp_s_Failure_requesting_identities_fr_2; static PyObject *__pyx_kp_s_No_identities_match_for_user_s; static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_kp_s_Unable_to_connect_to_agent; static PyObject *__pyx_n_s_cline_in_traceback; +static PyObject *__pyx_n_s_getstate; static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_name; static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; static PyObject *__pyx_n_s_pkey; -static PyObject *__pyx_n_s_pyx_vtable; +static PyObject *__pyx_n_s_reduce; static PyObject *__pyx_n_s_reduce_cython; +static PyObject *__pyx_n_s_reduce_ex; static PyObject *__pyx_n_s_session; +static PyObject *__pyx_n_s_setstate; static PyObject *__pyx_n_s_setstate_cython; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_username; @@ -1200,8 +1280,328 @@ static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__3; static PyObject *__pyx_tuple__4; +static PyObject *__pyx_tuple__5; +static PyObject *__pyx_tuple__6; +static PyObject *__pyx_tuple__7; /* "ssh2/agent.pyx":24 + * + * + * cdef int agent_auth(char * _username, # <<<<<<<<<<<<<< + * c_ssh2.LIBSSH2_AGENT * agent) nogil except 1: + * cdef c_ssh2.libssh2_agent_publickey *identity = NULL + */ + +static int __pyx_f_4ssh2_5agent_agent_auth(char *__pyx_v__username, LIBSSH2_AGENT *__pyx_v_agent) { + struct libssh2_agent_publickey *__pyx_v_identity; + struct libssh2_agent_publickey *__pyx_v_prev; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save; + #endif + __Pyx_RefNannySetupContext("agent_auth", 1); + + /* "ssh2/agent.pyx":26 + * cdef int agent_auth(char * _username, + * c_ssh2.LIBSSH2_AGENT * agent) nogil except 1: + * cdef c_ssh2.libssh2_agent_publickey *identity = NULL # <<<<<<<<<<<<<< + * cdef c_ssh2.libssh2_agent_publickey *prev = NULL + * if c_ssh2.libssh2_agent_list_identities(agent) != 0: + */ + /*try:*/ { + __pyx_v_identity = NULL; + + /* "ssh2/agent.pyx":27 + * c_ssh2.LIBSSH2_AGENT * agent) nogil except 1: + * cdef c_ssh2.libssh2_agent_publickey *identity = NULL + * cdef c_ssh2.libssh2_agent_publickey *prev = NULL # <<<<<<<<<<<<<< + * if c_ssh2.libssh2_agent_list_identities(agent) != 0: + * clear_agent(agent) + */ + __pyx_v_prev = NULL; + + /* "ssh2/agent.pyx":28 + * cdef c_ssh2.libssh2_agent_publickey *identity = NULL + * cdef c_ssh2.libssh2_agent_publickey *prev = NULL + * if c_ssh2.libssh2_agent_list_identities(agent) != 0: # <<<<<<<<<<<<<< + * clear_agent(agent) + * with gil: + */ + __pyx_t_1 = ((libssh2_agent_list_identities(__pyx_v_agent) != 0) != 0); + if (__pyx_t_1) { + + /* "ssh2/agent.pyx":29 + * cdef c_ssh2.libssh2_agent_publickey *prev = NULL + * if c_ssh2.libssh2_agent_list_identities(agent) != 0: + * clear_agent(agent) # <<<<<<<<<<<<<< + * with gil: + * raise AgentListIdentitiesError( + */ + __pyx_f_4ssh2_5agent_clear_agent(__pyx_v_agent); + + /* "ssh2/agent.pyx":30 + * if c_ssh2.libssh2_agent_list_identities(agent) != 0: + * clear_agent(agent) + * with gil: # <<<<<<<<<<<<<< + * raise AgentListIdentitiesError( + * "Failure requesting identities from agent") + */ + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + /*try:*/ { + + /* "ssh2/agent.pyx":31 + * clear_agent(agent) + * with gil: + * raise AgentListIdentitiesError( # <<<<<<<<<<<<<< + * "Failure requesting identities from agent") + * return 1 + */ + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentListIdentitiesError), __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 31, __pyx_L8_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(1, 31, __pyx_L8_error) + } + + /* "ssh2/agent.pyx":30 + * if c_ssh2.libssh2_agent_list_identities(agent) != 0: + * clear_agent(agent) + * with gil: # <<<<<<<<<<<<<< + * raise AgentListIdentitiesError( + * "Failure requesting identities from agent") + */ + /*finally:*/ { + __pyx_L8_error: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L4_error; + } + } + } + + /* "ssh2/agent.pyx":28 + * cdef c_ssh2.libssh2_agent_publickey *identity = NULL + * cdef c_ssh2.libssh2_agent_publickey *prev = NULL + * if c_ssh2.libssh2_agent_list_identities(agent) != 0: # <<<<<<<<<<<<<< + * clear_agent(agent) + * with gil: + */ + } + + /* "ssh2/agent.pyx":34 + * "Failure requesting identities from agent") + * return 1 + * while 1: # <<<<<<<<<<<<<< + * if auth_identity(_username, agent, &identity, prev) == 1: + * with gil: + */ + while (1) { + + /* "ssh2/agent.pyx":35 + * return 1 + * while 1: + * if auth_identity(_username, agent, &identity, prev) == 1: # <<<<<<<<<<<<<< + * with gil: + * raise AgentAuthenticationError( + */ + __pyx_t_3 = __pyx_f_4ssh2_5agent_auth_identity(__pyx_v__username, __pyx_v_agent, (&__pyx_v_identity), __pyx_v_prev); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 35, __pyx_L4_error) + __pyx_t_1 = ((__pyx_t_3 == 1) != 0); + if (__pyx_t_1) { + + /* "ssh2/agent.pyx":36 + * while 1: + * if auth_identity(_username, agent, &identity, prev) == 1: + * with gil: # <<<<<<<<<<<<<< + * raise AgentAuthenticationError( + * "No identities match for user %s", + */ + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + /*try:*/ { + + /* "ssh2/agent.pyx":39 + * raise AgentAuthenticationError( + * "No identities match for user %s", + * _username) # <<<<<<<<<<<<<< + * return 1 + * if c_ssh2.libssh2_agent_userauth( + */ + __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v__username); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 39, __pyx_L16_error) + __Pyx_GOTREF(__pyx_t_2); + + /* "ssh2/agent.pyx":37 + * if auth_identity(_username, agent, &identity, prev) == 1: + * with gil: + * raise AgentAuthenticationError( # <<<<<<<<<<<<<< + * "No identities match for user %s", + * _username) + */ + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 37, __pyx_L16_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_kp_s_No_identities_match_for_user_s); + __Pyx_GIVEREF(__pyx_kp_s_No_identities_match_for_user_s); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_s_No_identities_match_for_user_s); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentAuthenticationError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 37, __pyx_L16_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(1, 37, __pyx_L16_error) + } + + /* "ssh2/agent.pyx":36 + * while 1: + * if auth_identity(_username, agent, &identity, prev) == 1: + * with gil: # <<<<<<<<<<<<<< + * raise AgentAuthenticationError( + * "No identities match for user %s", + */ + /*finally:*/ { + __pyx_L16_error: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L4_error; + } + } + } + + /* "ssh2/agent.pyx":35 + * return 1 + * while 1: + * if auth_identity(_username, agent, &identity, prev) == 1: # <<<<<<<<<<<<<< + * with gil: + * raise AgentAuthenticationError( + */ + } + + /* "ssh2/agent.pyx":42 + * return 1 + * if c_ssh2.libssh2_agent_userauth( + * agent, _username, identity) == 0: # <<<<<<<<<<<<<< + * clear_agent(agent) + * return 0 + */ + __pyx_t_1 = ((libssh2_agent_userauth(__pyx_v_agent, __pyx_v__username, __pyx_v_identity) == 0) != 0); + + /* "ssh2/agent.pyx":41 + * _username) + * return 1 + * if c_ssh2.libssh2_agent_userauth( # <<<<<<<<<<<<<< + * agent, _username, identity) == 0: + * clear_agent(agent) + */ + if (__pyx_t_1) { + + /* "ssh2/agent.pyx":43 + * if c_ssh2.libssh2_agent_userauth( + * agent, _username, identity) == 0: + * clear_agent(agent) # <<<<<<<<<<<<<< + * return 0 + * prev = identity + */ + __pyx_f_4ssh2_5agent_clear_agent(__pyx_v_agent); + + /* "ssh2/agent.pyx":44 + * agent, _username, identity) == 0: + * clear_agent(agent) + * return 0 # <<<<<<<<<<<<<< + * prev = identity + * return 1 + */ + __pyx_r = 0; + goto __pyx_L3_return; + + /* "ssh2/agent.pyx":41 + * _username) + * return 1 + * if c_ssh2.libssh2_agent_userauth( # <<<<<<<<<<<<<< + * agent, _username, identity) == 0: + * clear_agent(agent) + */ + } + + /* "ssh2/agent.pyx":45 + * clear_agent(agent) + * return 0 + * prev = identity # <<<<<<<<<<<<<< + * return 1 + * + */ + __pyx_v_prev = __pyx_v_identity; + } + + /* "ssh2/agent.pyx":46 + * return 0 + * prev = identity + * return 1 # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = 1; + goto __pyx_L3_return; + } + + /* "ssh2/agent.pyx":26 + * cdef int agent_auth(char * _username, + * c_ssh2.LIBSSH2_AGENT * agent) nogil except 1: + * cdef c_ssh2.libssh2_agent_publickey *identity = NULL # <<<<<<<<<<<<<< + * cdef c_ssh2.libssh2_agent_publickey *prev = NULL + * if c_ssh2.libssh2_agent_list_identities(agent) != 0: + */ + /*finally:*/ { + __pyx_L3_return: { + #ifdef WITH_THREAD + __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + goto __pyx_L0; + } + __pyx_L4_error: { + #ifdef WITH_THREAD + __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + goto __pyx_L1_error; + } + } + + /* "ssh2/agent.pyx":24 + * + * + * cdef int agent_auth(char * _username, # <<<<<<<<<<<<<< + * c_ssh2.LIBSSH2_AGENT * agent) nogil except 1: + * cdef c_ssh2.libssh2_agent_publickey *identity = NULL + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("ssh2.agent.agent_auth", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 1; + __pyx_L0:; + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + return __pyx_r; +} + +/* "ssh2/agent.pyx":49 * * * cdef int auth_identity(const char *username, # <<<<<<<<<<<<<< @@ -1221,7 +1621,7 @@ static int __pyx_f_4ssh2_5agent_auth_identity(char const *__pyx_v_username, LIBS #endif __Pyx_RefNannySetupContext("auth_identity", 1); - /* "ssh2/agent.pyx":28 + /* "ssh2/agent.pyx":53 * c_ssh2.libssh2_agent_publickey **identity, * c_ssh2.libssh2_agent_publickey *prev) nogil except -1: * cdef int rc # <<<<<<<<<<<<<< @@ -1230,7 +1630,7 @@ static int __pyx_f_4ssh2_5agent_auth_identity(char const *__pyx_v_username, LIBS */ /*try:*/ { - /* "ssh2/agent.pyx":29 + /* "ssh2/agent.pyx":54 * c_ssh2.libssh2_agent_publickey *prev) nogil except -1: * cdef int rc * rc = c_ssh2.libssh2_agent_get_identity( # <<<<<<<<<<<<<< @@ -1239,31 +1639,60 @@ static int __pyx_f_4ssh2_5agent_auth_identity(char const *__pyx_v_username, LIBS */ __pyx_v_rc = libssh2_agent_get_identity(__pyx_v_agent, __pyx_v_identity, __pyx_v_prev); - /* "ssh2/agent.pyx":31 + /* "ssh2/agent.pyx":56 * rc = c_ssh2.libssh2_agent_get_identity( * agent, identity, prev) * if rc == 1: # <<<<<<<<<<<<<< * clear_agent(agent) - * with gil: + * elif rc < 0: */ __pyx_t_1 = ((__pyx_v_rc == 1) != 0); if (__pyx_t_1) { - /* "ssh2/agent.pyx":32 + /* "ssh2/agent.pyx":57 * agent, identity, prev) * if rc == 1: * clear_agent(agent) # <<<<<<<<<<<<<< - * with gil: - * raise AgentAuthenticationError( + * elif rc < 0: + * clear_agent(agent) */ __pyx_f_4ssh2_5agent_clear_agent(__pyx_v_agent); - /* "ssh2/agent.pyx":33 + /* "ssh2/agent.pyx":56 + * rc = c_ssh2.libssh2_agent_get_identity( + * agent, identity, prev) + * if rc == 1: # <<<<<<<<<<<<<< + * clear_agent(agent) + * elif rc < 0: + */ + goto __pyx_L6; + } + + /* "ssh2/agent.pyx":58 * if rc == 1: * clear_agent(agent) + * elif rc < 0: # <<<<<<<<<<<<<< + * clear_agent(agent) + * with gil: + */ + __pyx_t_1 = ((__pyx_v_rc < 0) != 0); + if (__pyx_t_1) { + + /* "ssh2/agent.pyx":59 + * clear_agent(agent) + * elif rc < 0: + * clear_agent(agent) # <<<<<<<<<<<<<< + * with gil: + * raise AgentGetIdentityError( + */ + __pyx_f_4ssh2_5agent_clear_agent(__pyx_v_agent); + + /* "ssh2/agent.pyx":60 + * elif rc < 0: + * clear_agent(agent) * with gil: # <<<<<<<<<<<<<< - * raise AgentAuthenticationError( - * "No identities match for user %s", + * raise AgentGetIdentityError( + * "Failure getting identity for user %s from agent", */ { #ifdef WITH_THREAD @@ -1271,90 +1700,339 @@ static int __pyx_f_4ssh2_5agent_auth_identity(char const *__pyx_v_username, LIBS #endif /*try:*/ { - /* "ssh2/agent.pyx":36 - * raise AgentAuthenticationError( - * "No identities match for user %s", + /* "ssh2/agent.pyx":63 + * raise AgentGetIdentityError( + * "Failure getting identity for user %s from agent", * username) # <<<<<<<<<<<<<< - * elif rc < 0: - * clear_agent(agent) + * return rc + * */ - __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_username); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 36, __pyx_L8_error) + __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_username); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 63, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); - /* "ssh2/agent.pyx":34 + /* "ssh2/agent.pyx":61 * clear_agent(agent) * with gil: - * raise AgentAuthenticationError( # <<<<<<<<<<<<<< - * "No identities match for user %s", + * raise AgentGetIdentityError( # <<<<<<<<<<<<<< + * "Failure getting identity for user %s from agent", * username) */ - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 34, __pyx_L8_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 61, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_kp_s_No_identities_match_for_user_s); - __Pyx_GIVEREF(__pyx_kp_s_No_identities_match_for_user_s); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_s_No_identities_match_for_user_s); + __Pyx_INCREF(__pyx_kp_s_Failure_getting_identity_for_use); + __Pyx_GIVEREF(__pyx_kp_s_Failure_getting_identity_for_use); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_s_Failure_getting_identity_for_use); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentAuthenticationError), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 34, __pyx_L8_error) + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentGetIdentityError), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 61, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(1, 34, __pyx_L8_error) + __PYX_ERR(1, 61, __pyx_L8_error) + } + + /* "ssh2/agent.pyx":60 + * elif rc < 0: + * clear_agent(agent) + * with gil: # <<<<<<<<<<<<<< + * raise AgentGetIdentityError( + * "Failure getting identity for user %s from agent", + */ + /*finally:*/ { + __pyx_L8_error: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L4_error; + } } + } - /* "ssh2/agent.pyx":33 + /* "ssh2/agent.pyx":58 * if rc == 1: * clear_agent(agent) + * elif rc < 0: # <<<<<<<<<<<<<< + * clear_agent(agent) + * with gil: + */ + } + __pyx_L6:; + + /* "ssh2/agent.pyx":64 + * "Failure getting identity for user %s from agent", + * username) + * return rc # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_rc; + goto __pyx_L3_return; + } + + /* "ssh2/agent.pyx":53 + * c_ssh2.libssh2_agent_publickey **identity, + * c_ssh2.libssh2_agent_publickey *prev) nogil except -1: + * cdef int rc # <<<<<<<<<<<<<< + * rc = c_ssh2.libssh2_agent_get_identity( + * agent, identity, prev) + */ + /*finally:*/ { + __pyx_L3_return: { + #ifdef WITH_THREAD + __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + goto __pyx_L0; + } + __pyx_L4_error: { + #ifdef WITH_THREAD + __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + goto __pyx_L1_error; + } + } + + /* "ssh2/agent.pyx":49 + * + * + * cdef int auth_identity(const char *username, # <<<<<<<<<<<<<< + * c_ssh2.LIBSSH2_AGENT *agent, + * c_ssh2.libssh2_agent_publickey **identity, + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("ssh2.agent.auth_identity", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + return __pyx_r; +} + +/* "ssh2/agent.pyx":67 + * + * + * cdef c_ssh2.LIBSSH2_AGENT * agent_init( # <<<<<<<<<<<<<< + * c_ssh2.LIBSSH2_SESSION *_session) nogil except NULL: + * cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( + */ + +static LIBSSH2_AGENT *__pyx_f_4ssh2_5agent_agent_init(LIBSSH2_SESSION *__pyx_v__session) { + LIBSSH2_AGENT *__pyx_v_agent; + LIBSSH2_AGENT *__pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save; + #endif + __Pyx_RefNannySetupContext("agent_init", 1); + + /* "ssh2/agent.pyx":69 + * cdef c_ssh2.LIBSSH2_AGENT * agent_init( + * c_ssh2.LIBSSH2_SESSION *_session) nogil except NULL: + * cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( # <<<<<<<<<<<<<< + * _session) + * if agent is NULL: + */ + /*try:*/ { + + /* "ssh2/agent.pyx":70 + * c_ssh2.LIBSSH2_SESSION *_session) nogil except NULL: + * cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( + * _session) # <<<<<<<<<<<<<< + * if agent is NULL: + * with gil: + */ + __pyx_v_agent = libssh2_agent_init(__pyx_v__session); + + /* "ssh2/agent.pyx":71 + * cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( + * _session) + * if agent is NULL: # <<<<<<<<<<<<<< + * with gil: + * raise AgentError("Error initialising agent") + */ + __pyx_t_1 = ((__pyx_v_agent == NULL) != 0); + if (__pyx_t_1) { + + /* "ssh2/agent.pyx":72 + * _session) + * if agent is NULL: + * with gil: # <<<<<<<<<<<<<< + * raise AgentError("Error initialising agent") + * return agent + */ + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + /*try:*/ { + + /* "ssh2/agent.pyx":73 + * if agent is NULL: + * with gil: + * raise AgentError("Error initialising agent") # <<<<<<<<<<<<<< + * return agent + * + */ + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentError), __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 73, __pyx_L8_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(1, 73, __pyx_L8_error) + } + + /* "ssh2/agent.pyx":72 + * _session) + * if agent is NULL: * with gil: # <<<<<<<<<<<<<< - * raise AgentAuthenticationError( - * "No identities match for user %s", + * raise AgentError("Error initialising agent") + * return agent + */ + /*finally:*/ { + __pyx_L8_error: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L4_error; + } + } + } + + /* "ssh2/agent.pyx":71 + * cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( + * _session) + * if agent is NULL: # <<<<<<<<<<<<<< + * with gil: + * raise AgentError("Error initialising agent") + */ + } + + /* "ssh2/agent.pyx":74 + * with gil: + * raise AgentError("Error initialising agent") + * return agent # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_agent; + goto __pyx_L3_return; + } + + /* "ssh2/agent.pyx":69 + * cdef c_ssh2.LIBSSH2_AGENT * agent_init( + * c_ssh2.LIBSSH2_SESSION *_session) nogil except NULL: + * cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( # <<<<<<<<<<<<<< + * _session) + * if agent is NULL: + */ + /*finally:*/ { + __pyx_L3_return: { + #ifdef WITH_THREAD + __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + goto __pyx_L0; + } + __pyx_L4_error: { + #ifdef WITH_THREAD + __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + goto __pyx_L1_error; + } + } + + /* "ssh2/agent.pyx":67 + * + * + * cdef c_ssh2.LIBSSH2_AGENT * agent_init( # <<<<<<<<<<<<<< + * c_ssh2.LIBSSH2_SESSION *_session) nogil except NULL: + * cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("ssh2.agent.agent_init", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + return __pyx_r; +} + +/* "ssh2/agent.pyx":77 + * + * + * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent( # <<<<<<<<<<<<<< + * c_ssh2.LIBSSH2_SESSION *_session) nogil except NULL: + * cdef c_ssh2.LIBSSH2_AGENT *agent + */ + +static LIBSSH2_AGENT *__pyx_f_4ssh2_5agent_init_connect_agent(LIBSSH2_SESSION *__pyx_v__session) { + LIBSSH2_AGENT *__pyx_v_agent; + LIBSSH2_AGENT *__pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save; + #endif + __Pyx_RefNannySetupContext("init_connect_agent", 1); + + /* "ssh2/agent.pyx":79 + * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent( + * c_ssh2.LIBSSH2_SESSION *_session) nogil except NULL: + * cdef c_ssh2.LIBSSH2_AGENT *agent # <<<<<<<<<<<<<< + * agent = c_ssh2.libssh2_agent_init(_session) + * if c_ssh2.libssh2_agent_connect(agent) != 0: */ - /*finally:*/ { - __pyx_L8_error: { - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - goto __pyx_L4_error; - } - } - } + /*try:*/ { - /* "ssh2/agent.pyx":31 - * rc = c_ssh2.libssh2_agent_get_identity( - * agent, identity, prev) - * if rc == 1: # <<<<<<<<<<<<<< - * clear_agent(agent) - * with gil: + /* "ssh2/agent.pyx":80 + * c_ssh2.LIBSSH2_SESSION *_session) nogil except NULL: + * cdef c_ssh2.LIBSSH2_AGENT *agent + * agent = c_ssh2.libssh2_agent_init(_session) # <<<<<<<<<<<<<< + * if c_ssh2.libssh2_agent_connect(agent) != 0: + * c_ssh2.libssh2_agent_free(agent) */ - } + __pyx_v_agent = libssh2_agent_init(__pyx_v__session); - /* "ssh2/agent.pyx":37 - * "No identities match for user %s", - * username) - * elif rc < 0: # <<<<<<<<<<<<<< - * clear_agent(agent) + /* "ssh2/agent.pyx":81 + * cdef c_ssh2.LIBSSH2_AGENT *agent + * agent = c_ssh2.libssh2_agent_init(_session) + * if c_ssh2.libssh2_agent_connect(agent) != 0: # <<<<<<<<<<<<<< + * c_ssh2.libssh2_agent_free(agent) * with gil: */ - __pyx_t_1 = ((__pyx_v_rc < 0) != 0); + __pyx_t_1 = ((libssh2_agent_connect(__pyx_v_agent) != 0) != 0); if (__pyx_t_1) { - /* "ssh2/agent.pyx":38 - * username) - * elif rc < 0: - * clear_agent(agent) # <<<<<<<<<<<<<< + /* "ssh2/agent.pyx":82 + * agent = c_ssh2.libssh2_agent_init(_session) + * if c_ssh2.libssh2_agent_connect(agent) != 0: + * c_ssh2.libssh2_agent_free(agent) # <<<<<<<<<<<<<< * with gil: - * raise AgentGetIdentityError( + * raise AgentConnectionError("Unable to connect to agent") */ - __pyx_f_4ssh2_5agent_clear_agent(__pyx_v_agent); + libssh2_agent_free(__pyx_v_agent); - /* "ssh2/agent.pyx":39 - * elif rc < 0: - * clear_agent(agent) + /* "ssh2/agent.pyx":83 + * if c_ssh2.libssh2_agent_connect(agent) != 0: + * c_ssh2.libssh2_agent_free(agent) * with gil: # <<<<<<<<<<<<<< - * raise AgentGetIdentityError( - * "Failure getting identity for user %s from agent", + * raise AgentConnectionError("Unable to connect to agent") + * return agent */ { #ifdef WITH_THREAD @@ -1362,48 +2040,29 @@ static int __pyx_f_4ssh2_5agent_auth_identity(char const *__pyx_v_username, LIBS #endif /*try:*/ { - /* "ssh2/agent.pyx":42 - * raise AgentGetIdentityError( - * "Failure getting identity for user %s from agent", - * username) # <<<<<<<<<<<<<< - * return rc - * - */ - __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_username); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 42, __pyx_L11_error) - __Pyx_GOTREF(__pyx_t_2); - - /* "ssh2/agent.pyx":40 - * clear_agent(agent) + /* "ssh2/agent.pyx":84 + * c_ssh2.libssh2_agent_free(agent) * with gil: - * raise AgentGetIdentityError( # <<<<<<<<<<<<<< - * "Failure getting identity for user %s from agent", - * username) + * raise AgentConnectionError("Unable to connect to agent") # <<<<<<<<<<<<<< + * return agent + * */ - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 40, __pyx_L11_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_kp_s_Failure_getting_identity_for_use); - __Pyx_GIVEREF(__pyx_kp_s_Failure_getting_identity_for_use); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_s_Failure_getting_identity_for_use); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentGetIdentityError), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 40, __pyx_L11_error) + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentConnectionError), __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 84, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(1, 40, __pyx_L11_error) + __PYX_ERR(1, 84, __pyx_L8_error) } - /* "ssh2/agent.pyx":39 - * elif rc < 0: - * clear_agent(agent) + /* "ssh2/agent.pyx":83 + * if c_ssh2.libssh2_agent_connect(agent) != 0: + * c_ssh2.libssh2_agent_free(agent) * with gil: # <<<<<<<<<<<<<< - * raise AgentGetIdentityError( - * "Failure getting identity for user %s from agent", + * raise AgentConnectionError("Unable to connect to agent") + * return agent */ /*finally:*/ { - __pyx_L11_error: { + __pyx_L8_error: { #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif @@ -1412,32 +2071,32 @@ static int __pyx_f_4ssh2_5agent_auth_identity(char const *__pyx_v_username, LIBS } } - /* "ssh2/agent.pyx":37 - * "No identities match for user %s", - * username) - * elif rc < 0: # <<<<<<<<<<<<<< - * clear_agent(agent) + /* "ssh2/agent.pyx":81 + * cdef c_ssh2.LIBSSH2_AGENT *agent + * agent = c_ssh2.libssh2_agent_init(_session) + * if c_ssh2.libssh2_agent_connect(agent) != 0: # <<<<<<<<<<<<<< + * c_ssh2.libssh2_agent_free(agent) * with gil: */ } - /* "ssh2/agent.pyx":43 - * "Failure getting identity for user %s from agent", - * username) - * return rc # <<<<<<<<<<<<<< + /* "ssh2/agent.pyx":85 + * with gil: + * raise AgentConnectionError("Unable to connect to agent") + * return agent # <<<<<<<<<<<<<< * * */ - __pyx_r = __pyx_v_rc; + __pyx_r = __pyx_v_agent; goto __pyx_L3_return; } - /* "ssh2/agent.pyx":28 - * c_ssh2.libssh2_agent_publickey **identity, - * c_ssh2.libssh2_agent_publickey *prev) nogil except -1: - * cdef int rc # <<<<<<<<<<<<<< - * rc = c_ssh2.libssh2_agent_get_identity( - * agent, identity, prev) + /* "ssh2/agent.pyx":79 + * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent( + * c_ssh2.LIBSSH2_SESSION *_session) nogil except NULL: + * cdef c_ssh2.LIBSSH2_AGENT *agent # <<<<<<<<<<<<<< + * agent = c_ssh2.libssh2_agent_init(_session) + * if c_ssh2.libssh2_agent_connect(agent) != 0: */ /*finally:*/ { __pyx_L3_return: { @@ -1454,12 +2113,12 @@ static int __pyx_f_4ssh2_5agent_auth_identity(char const *__pyx_v_username, LIBS } } - /* "ssh2/agent.pyx":24 + /* "ssh2/agent.pyx":77 * * - * cdef int auth_identity(const char *username, # <<<<<<<<<<<<<< - * c_ssh2.LIBSSH2_AGENT *agent, - * c_ssh2.libssh2_agent_publickey **identity, + * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent( # <<<<<<<<<<<<<< + * c_ssh2.LIBSSH2_SESSION *_session) nogil except NULL: + * cdef c_ssh2.LIBSSH2_AGENT *agent */ /* function exit code */ @@ -1467,9 +2126,8 @@ static int __pyx_f_4ssh2_5agent_auth_identity(char const *__pyx_v_username, LIBS goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("ssh2.agent.auth_identity", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; + __Pyx_AddTraceback("ssh2.agent.init_connect_agent", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; __pyx_L0:; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); @@ -1477,7 +2135,7 @@ static int __pyx_f_4ssh2_5agent_auth_identity(char const *__pyx_v_username, LIBS return __pyx_r; } -/* "ssh2/agent.pyx":46 +/* "ssh2/agent.pyx":88 * * * cdef void clear_agent(c_ssh2.LIBSSH2_AGENT *agent) nogil: # <<<<<<<<<<<<<< @@ -1487,7 +2145,7 @@ static int __pyx_f_4ssh2_5agent_auth_identity(char const *__pyx_v_username, LIBS static void __pyx_f_4ssh2_5agent_clear_agent(LIBSSH2_AGENT *__pyx_v_agent) { - /* "ssh2/agent.pyx":47 + /* "ssh2/agent.pyx":89 * * cdef void clear_agent(c_ssh2.LIBSSH2_AGENT *agent) nogil: * c_ssh2.libssh2_agent_disconnect(agent) # <<<<<<<<<<<<<< @@ -1496,7 +2154,7 @@ static void __pyx_f_4ssh2_5agent_clear_agent(LIBSSH2_AGENT *__pyx_v_agent) { */ libssh2_agent_disconnect(__pyx_v_agent); - /* "ssh2/agent.pyx":48 + /* "ssh2/agent.pyx":90 * cdef void clear_agent(c_ssh2.LIBSSH2_AGENT *agent) nogil: * c_ssh2.libssh2_agent_disconnect(agent) * c_ssh2.libssh2_agent_free(agent) # <<<<<<<<<<<<<< @@ -1505,7 +2163,7 @@ static void __pyx_f_4ssh2_5agent_clear_agent(LIBSSH2_AGENT *__pyx_v_agent) { */ libssh2_agent_free(__pyx_v_agent); - /* "ssh2/agent.pyx":46 + /* "ssh2/agent.pyx":88 * * * cdef void clear_agent(c_ssh2.LIBSSH2_AGENT *agent) nogil: # <<<<<<<<<<<<<< @@ -1516,7 +2174,7 @@ static void __pyx_f_4ssh2_5agent_clear_agent(LIBSSH2_AGENT *__pyx_v_agent) { /* function exit code */ } -/* "ssh2/agent.pyx":51 +/* "ssh2/agent.pyx":93 * * * cdef object PyAgent(c_ssh2.LIBSSH2_AGENT *agent, Session session): # <<<<<<<<<<<<<< @@ -1532,25 +2190,25 @@ static PyObject *__pyx_f_4ssh2_5agent_PyAgent(LIBSSH2_AGENT *__pyx_v_agent, stru PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("PyAgent", 0); - /* "ssh2/agent.pyx":52 + /* "ssh2/agent.pyx":94 * * cdef object PyAgent(c_ssh2.LIBSSH2_AGENT *agent, Session session): * cdef Agent _agent = Agent(session) # <<<<<<<<<<<<<< * _agent._agent = agent * return _agent */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 52, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_session)); __Pyx_GIVEREF(((PyObject *)__pyx_v_session)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_session)); - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_5agent_Agent), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 52, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_5agent_Agent), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v__agent = ((struct __pyx_obj_4ssh2_5agent_Agent *)__pyx_t_2); __pyx_t_2 = 0; - /* "ssh2/agent.pyx":53 + /* "ssh2/agent.pyx":95 * cdef object PyAgent(c_ssh2.LIBSSH2_AGENT *agent, Session session): * cdef Agent _agent = Agent(session) * _agent._agent = agent # <<<<<<<<<<<<<< @@ -1559,7 +2217,7 @@ static PyObject *__pyx_f_4ssh2_5agent_PyAgent(LIBSSH2_AGENT *__pyx_v_agent, stru */ __pyx_v__agent->_agent = __pyx_v_agent; - /* "ssh2/agent.pyx":54 + /* "ssh2/agent.pyx":96 * cdef Agent _agent = Agent(session) * _agent._agent = agent * return _agent # <<<<<<<<<<<<<< @@ -1571,7 +2229,7 @@ static PyObject *__pyx_f_4ssh2_5agent_PyAgent(LIBSSH2_AGENT *__pyx_v_agent, stru __pyx_r = ((PyObject *)__pyx_v__agent); goto __pyx_L0; - /* "ssh2/agent.pyx":51 + /* "ssh2/agent.pyx":93 * * * cdef object PyAgent(c_ssh2.LIBSSH2_AGENT *agent, Session session): # <<<<<<<<<<<<<< @@ -1592,7 +2250,7 @@ static PyObject *__pyx_f_4ssh2_5agent_PyAgent(LIBSSH2_AGENT *__pyx_v_agent, stru return __pyx_r; } -/* "ssh2/agent.pyx":59 +/* "ssh2/agent.pyx":101 * cdef class Agent: * * def __cinit__(self, Session session): # <<<<<<<<<<<<<< @@ -1626,7 +2284,7 @@ static int __pyx_pw_4ssh2_5agent_5Agent_1__cinit__(PyObject *__pyx_v_self, PyObj else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(1, 59, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(1, 101, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -1637,13 +2295,13 @@ static int __pyx_pw_4ssh2_5agent_5Agent_1__cinit__(PyObject *__pyx_v_self, PyObj } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 59, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 101, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.agent.Agent.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_session), __pyx_ptype_4ssh2_7session_Session, 1, "session", 0))) __PYX_ERR(1, 59, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_session), __pyx_ptype_4ssh2_7session_Session, 1, "session", 0))) __PYX_ERR(1, 101, __pyx_L1_error) __pyx_r = __pyx_pf_4ssh2_5agent_5Agent___cinit__(((struct __pyx_obj_4ssh2_5agent_Agent *)__pyx_v_self), __pyx_v_session); /* function exit code */ @@ -1660,7 +2318,7 @@ static int __pyx_pf_4ssh2_5agent_5Agent___cinit__(struct __pyx_obj_4ssh2_5agent_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__", 0); - /* "ssh2/agent.pyx":60 + /* "ssh2/agent.pyx":102 * * def __cinit__(self, Session session): * self._agent = NULL # <<<<<<<<<<<<<< @@ -1669,7 +2327,7 @@ static int __pyx_pf_4ssh2_5agent_5Agent___cinit__(struct __pyx_obj_4ssh2_5agent_ */ __pyx_v_self->_agent = NULL; - /* "ssh2/agent.pyx":61 + /* "ssh2/agent.pyx":103 * def __cinit__(self, Session session): * self._agent = NULL * self._session = session # <<<<<<<<<<<<<< @@ -1682,7 +2340,7 @@ static int __pyx_pf_4ssh2_5agent_5Agent___cinit__(struct __pyx_obj_4ssh2_5agent_ __Pyx_DECREF(((PyObject *)__pyx_v_self->_session)); __pyx_v_self->_session = __pyx_v_session; - /* "ssh2/agent.pyx":59 + /* "ssh2/agent.pyx":101 * cdef class Agent: * * def __cinit__(self, Session session): # <<<<<<<<<<<<<< @@ -1696,7 +2354,7 @@ static int __pyx_pf_4ssh2_5agent_5Agent___cinit__(struct __pyx_obj_4ssh2_5agent_ return __pyx_r; } -/* "ssh2/agent.pyx":63 +/* "ssh2/agent.pyx":105 * self._session = session * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -1719,7 +2377,7 @@ static void __pyx_pf_4ssh2_5agent_5Agent_2__dealloc__(struct __pyx_obj_4ssh2_5ag __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "ssh2/agent.pyx":64 + /* "ssh2/agent.pyx":106 * * def __dealloc__(self): * with nogil: # <<<<<<<<<<<<<< @@ -1734,7 +2392,7 @@ static void __pyx_pf_4ssh2_5agent_5Agent_2__dealloc__(struct __pyx_obj_4ssh2_5ag #endif /*try:*/ { - /* "ssh2/agent.pyx":65 + /* "ssh2/agent.pyx":107 * def __dealloc__(self): * with nogil: * clear_agent(self._agent) # <<<<<<<<<<<<<< @@ -1744,7 +2402,7 @@ static void __pyx_pf_4ssh2_5agent_5Agent_2__dealloc__(struct __pyx_obj_4ssh2_5ag __pyx_f_4ssh2_5agent_clear_agent(__pyx_v_self->_agent); } - /* "ssh2/agent.pyx":64 + /* "ssh2/agent.pyx":106 * * def __dealloc__(self): * with nogil: # <<<<<<<<<<<<<< @@ -1763,7 +2421,7 @@ static void __pyx_pf_4ssh2_5agent_5Agent_2__dealloc__(struct __pyx_obj_4ssh2_5ag } } - /* "ssh2/agent.pyx":63 + /* "ssh2/agent.pyx":105 * self._session = session * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -1775,7 +2433,7 @@ static void __pyx_pf_4ssh2_5agent_5Agent_2__dealloc__(struct __pyx_obj_4ssh2_5ag __Pyx_RefNannyFinishContext(); } -/* "ssh2/agent.pyx":67 +/* "ssh2/agent.pyx":109 * clear_agent(self._agent) * * def list_identities(self): # <<<<<<<<<<<<<< @@ -1809,7 +2467,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_4list_identities(CYTHON_UNUSED str return __pyx_r; } -/* "ssh2/agent.pyx":73 +/* "ssh2/agent.pyx":115 * pass * * def get_identities(self): # <<<<<<<<<<<<<< @@ -1842,19 +2500,19 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 int __pyx_t_3; __Pyx_RefNannySetupContext("get_identities", 0); - /* "ssh2/agent.pyx":78 + /* "ssh2/agent.pyx":120 * :rtype: list(:py:class:`ssh2.pkey.PublicKey`)""" * cdef int rc * cdef list identities = [] # <<<<<<<<<<<<<< * cdef c_ssh2.libssh2_agent_publickey *identity = NULL * cdef c_ssh2.libssh2_agent_publickey *prev = NULL */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 78, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_identities = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/agent.pyx":79 + /* "ssh2/agent.pyx":121 * cdef int rc * cdef list identities = [] * cdef c_ssh2.libssh2_agent_publickey *identity = NULL # <<<<<<<<<<<<<< @@ -1863,7 +2521,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 */ __pyx_v_identity = NULL; - /* "ssh2/agent.pyx":80 + /* "ssh2/agent.pyx":122 * cdef list identities = [] * cdef c_ssh2.libssh2_agent_publickey *identity = NULL * cdef c_ssh2.libssh2_agent_publickey *prev = NULL # <<<<<<<<<<<<<< @@ -1872,7 +2530,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 */ __pyx_v_prev = NULL; - /* "ssh2/agent.pyx":81 + /* "ssh2/agent.pyx":123 * cdef c_ssh2.libssh2_agent_publickey *identity = NULL * cdef c_ssh2.libssh2_agent_publickey *prev = NULL * if c_ssh2.libssh2_agent_list_identities(self._agent) != 0: # <<<<<<<<<<<<<< @@ -1882,20 +2540,20 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 __pyx_t_2 = ((libssh2_agent_list_identities(__pyx_v_self->_agent) != 0) != 0); if (__pyx_t_2) { - /* "ssh2/agent.pyx":82 + /* "ssh2/agent.pyx":124 * cdef c_ssh2.libssh2_agent_publickey *prev = NULL * if c_ssh2.libssh2_agent_list_identities(self._agent) != 0: * raise AgentListIdentitiesError( # <<<<<<<<<<<<<< * "Failure requesting identities from agent." * "Agent must be connected first") */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentListIdentitiesError), __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 82, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentListIdentitiesError), __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(1, 82, __pyx_L1_error) + __PYX_ERR(1, 124, __pyx_L1_error) - /* "ssh2/agent.pyx":81 + /* "ssh2/agent.pyx":123 * cdef c_ssh2.libssh2_agent_publickey *identity = NULL * cdef c_ssh2.libssh2_agent_publickey *prev = NULL * if c_ssh2.libssh2_agent_list_identities(self._agent) != 0: # <<<<<<<<<<<<<< @@ -1904,7 +2562,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 */ } - /* "ssh2/agent.pyx":85 + /* "ssh2/agent.pyx":127 * "Failure requesting identities from agent." * "Agent must be connected first") * while c_ssh2.libssh2_agent_get_identity( # <<<<<<<<<<<<<< @@ -1913,7 +2571,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 */ while (1) { - /* "ssh2/agent.pyx":86 + /* "ssh2/agent.pyx":128 * "Agent must be connected first") * while c_ssh2.libssh2_agent_get_identity( * self._agent, &identity, prev) == 0: # <<<<<<<<<<<<<< @@ -1923,19 +2581,19 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 __pyx_t_2 = ((libssh2_agent_get_identity(__pyx_v_self->_agent, (&__pyx_v_identity), __pyx_v_prev) == 0) != 0); if (!__pyx_t_2) break; - /* "ssh2/agent.pyx":87 + /* "ssh2/agent.pyx":129 * while c_ssh2.libssh2_agent_get_identity( * self._agent, &identity, prev) == 0: * identities.append(PyPublicKey(identity)) # <<<<<<<<<<<<<< * prev = identity * return identities */ - __pyx_t_1 = __pyx_f_4ssh2_4pkey_PyPublicKey(__pyx_v_identity); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_4pkey_PyPublicKey(__pyx_v_identity); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyList_Append(__pyx_v_identities, __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(1, 87, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyList_Append(__pyx_v_identities, __pyx_t_1); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 129, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/agent.pyx":88 + /* "ssh2/agent.pyx":130 * self._agent, &identity, prev) == 0: * identities.append(PyPublicKey(identity)) * prev = identity # <<<<<<<<<<<<<< @@ -1945,7 +2603,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 __pyx_v_prev = __pyx_v_identity; } - /* "ssh2/agent.pyx":89 + /* "ssh2/agent.pyx":131 * identities.append(PyPublicKey(identity)) * prev = identity * return identities # <<<<<<<<<<<<<< @@ -1957,7 +2615,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 __pyx_r = __pyx_v_identities; goto __pyx_L0; - /* "ssh2/agent.pyx":73 + /* "ssh2/agent.pyx":115 * pass * * def get_identities(self): # <<<<<<<<<<<<<< @@ -1977,7 +2635,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_6get_identities(struct __pyx_obj_4 return __pyx_r; } -/* "ssh2/agent.pyx":91 +/* "ssh2/agent.pyx":133 * return identities * * def userauth(self, username not None, # <<<<<<<<<<<<<< @@ -2017,11 +2675,11 @@ static PyObject *__pyx_pw_4ssh2_5agent_5Agent_9userauth(PyObject *__pyx_v_self, case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pkey)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("userauth", 1, 2, 2, 1); __PYX_ERR(1, 91, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth", 1, 2, 2, 1); __PYX_ERR(1, 133, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth") < 0)) __PYX_ERR(1, 91, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth") < 0)) __PYX_ERR(1, 133, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -2034,16 +2692,16 @@ static PyObject *__pyx_pw_4ssh2_5agent_5Agent_9userauth(PyObject *__pyx_v_self, } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("userauth", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 91, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 133, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.agent.Agent.userauth", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_username) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(1, 91, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(1, 133, __pyx_L1_error) } - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pkey), __pyx_ptype_4ssh2_4pkey_PublicKey, 1, "pkey", 0))) __PYX_ERR(1, 92, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pkey), __pyx_ptype_4ssh2_4pkey_PublicKey, 1, "pkey", 0))) __PYX_ERR(1, 134, __pyx_L1_error) __pyx_r = __pyx_pf_4ssh2_5agent_5Agent_8userauth(((struct __pyx_obj_4ssh2_5agent_Agent *)__pyx_v_self), __pyx_v_username, __pyx_v_pkey); /* function exit code */ @@ -2067,29 +2725,33 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("userauth", 0); - /* "ssh2/agent.pyx":105 + /* "ssh2/agent.pyx":147 * :rtype: int""" * cdef int rc * cdef bytes b_username = to_bytes(username) # <<<<<<<<<<<<<< * cdef char *_username = b_username * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 105, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_username = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/agent.pyx":106 + /* "ssh2/agent.pyx":148 * cdef int rc * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username # <<<<<<<<<<<<<< * with nogil: * rc = c_ssh2.libssh2_agent_userauth( */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(1, 106, __pyx_L1_error) + if (unlikely(__pyx_v_b_username == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(1, 148, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(1, 148, __pyx_L1_error) __pyx_v__username = __pyx_t_2; - /* "ssh2/agent.pyx":107 + /* "ssh2/agent.pyx":149 * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username * with nogil: # <<<<<<<<<<<<<< @@ -2104,7 +2766,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 #endif /*try:*/ { - /* "ssh2/agent.pyx":108 + /* "ssh2/agent.pyx":150 * cdef char *_username = b_username * with nogil: * rc = c_ssh2.libssh2_agent_userauth( # <<<<<<<<<<<<<< @@ -2113,7 +2775,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 */ __pyx_v_rc = libssh2_agent_userauth(__pyx_v_self->_agent, __pyx_v__username, __pyx_v_pkey->_pkey); - /* "ssh2/agent.pyx":110 + /* "ssh2/agent.pyx":152 * rc = c_ssh2.libssh2_agent_userauth( * self._agent, _username, pkey._pkey) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -2131,7 +2793,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 } if (__pyx_t_3) { - /* "ssh2/agent.pyx":111 + /* "ssh2/agent.pyx":153 * self._agent, _username, pkey._pkey) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -2144,14 +2806,14 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 #endif /*try:*/ { - /* "ssh2/agent.pyx":112 + /* "ssh2/agent.pyx":154 * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: * raise AgentAuthenticationError( # <<<<<<<<<<<<<< * "Error authenticating user %s with provided public key", * username) */ - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 112, __pyx_L8_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 154, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_kp_s_Error_authenticating_user_s_with); __Pyx_GIVEREF(__pyx_kp_s_Error_authenticating_user_s_with); @@ -2159,15 +2821,15 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 __Pyx_INCREF(__pyx_v_username); __Pyx_GIVEREF(__pyx_v_username); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_username); - __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentAuthenticationError), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 112, __pyx_L8_error) + __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentAuthenticationError), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 154, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(1, 112, __pyx_L8_error) + __PYX_ERR(1, 154, __pyx_L8_error) } - /* "ssh2/agent.pyx":111 + /* "ssh2/agent.pyx":153 * self._agent, _username, pkey._pkey) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -2184,7 +2846,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 } } - /* "ssh2/agent.pyx":110 + /* "ssh2/agent.pyx":152 * rc = c_ssh2.libssh2_agent_userauth( * self._agent, _username, pkey._pkey) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -2194,7 +2856,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 } } - /* "ssh2/agent.pyx":107 + /* "ssh2/agent.pyx":149 * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username * with nogil: # <<<<<<<<<<<<<< @@ -2220,7 +2882,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 } } - /* "ssh2/agent.pyx":115 + /* "ssh2/agent.pyx":157 * "Error authenticating user %s with provided public key", * username) * return rc # <<<<<<<<<<<<<< @@ -2228,13 +2890,13 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 * def disconnect(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 115, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; - /* "ssh2/agent.pyx":91 + /* "ssh2/agent.pyx":133 * return identities * * def userauth(self, username not None, # <<<<<<<<<<<<<< @@ -2255,7 +2917,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_8userauth(struct __pyx_obj_4ssh2_5 return __pyx_r; } -/* "ssh2/agent.pyx":117 +/* "ssh2/agent.pyx":159 * return rc * * def disconnect(self): # <<<<<<<<<<<<<< @@ -2284,7 +2946,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_10disconnect(struct __pyx_obj_4ssh PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("disconnect", 0); - /* "ssh2/agent.pyx":122 + /* "ssh2/agent.pyx":164 * :rtype: int""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -2299,7 +2961,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_10disconnect(struct __pyx_obj_4ssh #endif /*try:*/ { - /* "ssh2/agent.pyx":123 + /* "ssh2/agent.pyx":165 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_agent_disconnect(self._agent) # <<<<<<<<<<<<<< @@ -2309,7 +2971,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_10disconnect(struct __pyx_obj_4ssh __pyx_v_rc = libssh2_agent_disconnect(__pyx_v_self->_agent); } - /* "ssh2/agent.pyx":122 + /* "ssh2/agent.pyx":164 * :rtype: int""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -2328,7 +2990,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_10disconnect(struct __pyx_obj_4ssh } } - /* "ssh2/agent.pyx":124 + /* "ssh2/agent.pyx":166 * with nogil: * rc = c_ssh2.libssh2_agent_disconnect(self._agent) * return rc # <<<<<<<<<<<<<< @@ -2336,13 +2998,13 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_10disconnect(struct __pyx_obj_4ssh * def connect(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 124, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 166, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/agent.pyx":117 + /* "ssh2/agent.pyx":159 * return rc * * def disconnect(self): # <<<<<<<<<<<<<< @@ -2361,7 +3023,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_10disconnect(struct __pyx_obj_4ssh return __pyx_r; } -/* "ssh2/agent.pyx":126 +/* "ssh2/agent.pyx":168 * return rc * * def connect(self): # <<<<<<<<<<<<<< @@ -2391,7 +3053,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_12connect(struct __pyx_obj_4ssh2_5 PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("connect", 0); - /* "ssh2/agent.pyx":134 + /* "ssh2/agent.pyx":176 * :rtype: int""" * cdef int rc * rc = c_ssh2.libssh2_agent_connect(self._agent) # <<<<<<<<<<<<<< @@ -2400,7 +3062,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_12connect(struct __pyx_obj_4ssh2_5 */ __pyx_v_rc = libssh2_agent_connect(__pyx_v_self->_agent); - /* "ssh2/agent.pyx":135 + /* "ssh2/agent.pyx":177 * cdef int rc * rc = c_ssh2.libssh2_agent_connect(self._agent) * if rc != 0: # <<<<<<<<<<<<<< @@ -2410,19 +3072,19 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_12connect(struct __pyx_obj_4ssh2_5 __pyx_t_1 = ((__pyx_v_rc != 0) != 0); if (__pyx_t_1) { - /* "ssh2/agent.pyx":136 + /* "ssh2/agent.pyx":178 * rc = c_ssh2.libssh2_agent_connect(self._agent) * if rc != 0: * raise AgentConnectionError("Unable to connect to agent") # <<<<<<<<<<<<<< * return rc */ - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentConnectionError), __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 136, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentConnectionError), __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 178, __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_ERR(1, 136, __pyx_L1_error) + __PYX_ERR(1, 178, __pyx_L1_error) - /* "ssh2/agent.pyx":135 + /* "ssh2/agent.pyx":177 * cdef int rc * rc = c_ssh2.libssh2_agent_connect(self._agent) * if rc != 0: # <<<<<<<<<<<<<< @@ -2431,19 +3093,19 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_12connect(struct __pyx_obj_4ssh2_5 */ } - /* "ssh2/agent.pyx":137 + /* "ssh2/agent.pyx":179 * if rc != 0: * raise AgentConnectionError("Unable to connect to agent") * return rc # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 137, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/agent.pyx":126 + /* "ssh2/agent.pyx":168 * return rc * * def connect(self): # <<<<<<<<<<<<<< @@ -2494,7 +3156,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_14__reduce_cython__(CYTHON_UNUSED * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2548,7 +3210,7 @@ static PyObject *__pyx_pf_4ssh2_5agent_5Agent_16__setstate_cython__(CYTHON_UNUSE * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2591,7 +3253,7 @@ static PyObject *__pyx_tp_new_4ssh2_5agent_Agent(PyTypeObject *t, PyObject *a, P static void __pyx_tp_dealloc_4ssh2_5agent_Agent(PyObject *o) { struct __pyx_obj_4ssh2_5agent_Agent *p = (struct __pyx_obj_4ssh2_5agent_Agent *)o; - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -2701,17 +3363,31 @@ static PyMethodDef __pyx_methods[] = { }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_agent(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_agent}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "agent", 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ @@ -2720,18 +3396,24 @@ static struct PyModuleDef __pyx_moduledef = { static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_Error_authenticating_user_s_with, __pyx_k_Error_authenticating_user_s_with, sizeof(__pyx_k_Error_authenticating_user_s_with), 0, 0, 1, 0}, + {&__pyx_kp_s_Error_initialising_agent, __pyx_k_Error_initialising_agent, sizeof(__pyx_k_Error_initialising_agent), 0, 0, 1, 0}, {&__pyx_kp_s_Failure_getting_identity_for_use, __pyx_k_Failure_getting_identity_for_use, sizeof(__pyx_k_Failure_getting_identity_for_use), 0, 0, 1, 0}, {&__pyx_kp_s_Failure_requesting_identities_fr, __pyx_k_Failure_requesting_identities_fr, sizeof(__pyx_k_Failure_requesting_identities_fr), 0, 0, 1, 0}, + {&__pyx_kp_s_Failure_requesting_identities_fr_2, __pyx_k_Failure_requesting_identities_fr_2, sizeof(__pyx_k_Failure_requesting_identities_fr_2), 0, 0, 1, 0}, {&__pyx_kp_s_No_identities_match_for_user_s, __pyx_k_No_identities_match_for_user_s, sizeof(__pyx_k_No_identities_match_for_user_s), 0, 0, 1, 0}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, {&__pyx_kp_s_Unable_to_connect_to_agent, __pyx_k_Unable_to_connect_to_agent, sizeof(__pyx_k_Unable_to_connect_to_agent), 0, 0, 1, 0}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, + {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, {&__pyx_n_s_pkey, __pyx_k_pkey, sizeof(__pyx_k_pkey), 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_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, {&__pyx_n_s_session, __pyx_k_session, sizeof(__pyx_k_session), 0, 0, 1, 1}, + {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_username, __pyx_k_username, sizeof(__pyx_k_username), 0, 0, 1, 1}, @@ -2748,26 +3430,59 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "ssh2/agent.pyx":82 + /* "ssh2/agent.pyx":31 + * clear_agent(agent) + * with gil: + * raise AgentListIdentitiesError( # <<<<<<<<<<<<<< + * "Failure requesting identities from agent") + * return 1 + */ + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Failure_requesting_identities_fr); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 31, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple_); + __Pyx_GIVEREF(__pyx_tuple_); + + /* "ssh2/agent.pyx":73 + * if agent is NULL: + * with gil: + * raise AgentError("Error initialising agent") # <<<<<<<<<<<<<< + * return agent + * + */ + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_Error_initialising_agent); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 73, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__2); + __Pyx_GIVEREF(__pyx_tuple__2); + + /* "ssh2/agent.pyx":84 + * c_ssh2.libssh2_agent_free(agent) + * with gil: + * raise AgentConnectionError("Unable to connect to agent") # <<<<<<<<<<<<<< + * return agent + * + */ + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_connect_to_agent); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 84, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__3); + __Pyx_GIVEREF(__pyx_tuple__3); + + /* "ssh2/agent.pyx":124 * cdef c_ssh2.libssh2_agent_publickey *prev = NULL * if c_ssh2.libssh2_agent_list_identities(self._agent) != 0: * raise AgentListIdentitiesError( # <<<<<<<<<<<<<< * "Failure requesting identities from agent." * "Agent must be connected first") */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Failure_requesting_identities_fr); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 82, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple_); - __Pyx_GIVEREF(__pyx_tuple_); + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_Failure_requesting_identities_fr_2); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); - /* "ssh2/agent.pyx":136 + /* "ssh2/agent.pyx":178 * rc = c_ssh2.libssh2_agent_connect(self._agent) * if rc != 0: * raise AgentConnectionError("Unable to connect to agent") # <<<<<<<<<<<<<< * return rc */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_connect_to_agent); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__2); - __Pyx_GIVEREF(__pyx_tuple__2); + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_connect_to_agent); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 178, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); /* "(tree fragment)":2 * def __reduce_cython__(self): @@ -2775,18 +3490,18 @@ static int __Pyx_InitCachedConstants(void) { * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__3); - __Pyx_GIVEREF(__pyx_tuple__3); + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); /* "(tree fragment)":4 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -2807,12 +3522,56 @@ PyMODINIT_FUNC initagent(void) #else PyMODINIT_FUNC PyInit_agent(void); /*proto*/ PyMODINIT_FUNC PyInit_agent(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec_agent(PyObject *__pyx_pyinit_module) +#endif #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { @@ -2839,6 +3598,9 @@ PyMODINIT_FUNC PyInit_agent(void) #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) #endif @@ -2850,12 +3612,17 @@ PyMODINIT_FUNC PyInit_agent(void) #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("agent", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(1, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(1, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(1, 1, __pyx_L1_error) @@ -2890,15 +3657,17 @@ PyMODINIT_FUNC PyInit_agent(void) if (__Pyx_ExportFunction("PyAgent", (void (*)(void))__pyx_f_4ssh2_5agent_PyAgent, "PyObject *(LIBSSH2_AGENT *, struct __pyx_obj_4ssh2_7session_Session *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error) if (__Pyx_ExportFunction("auth_identity", (void (*)(void))__pyx_f_4ssh2_5agent_auth_identity, "int (char const *, LIBSSH2_AGENT *, struct libssh2_agent_publickey **, struct libssh2_agent_publickey *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error) if (__Pyx_ExportFunction("clear_agent", (void (*)(void))__pyx_f_4ssh2_5agent_clear_agent, "void (LIBSSH2_AGENT *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error) + if (__Pyx_ExportFunction("agent_auth", (void (*)(void))__pyx_f_4ssh2_5agent_agent_auth, "int (char *, LIBSSH2_AGENT *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error) + if (__Pyx_ExportFunction("init_connect_agent", (void (*)(void))__pyx_f_4ssh2_5agent_init_connect_agent, "LIBSSH2_AGENT *(LIBSSH2_SESSION *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error) + if (__Pyx_ExportFunction("agent_init", (void (*)(void))__pyx_f_4ssh2_5agent_agent_init, "LIBSSH2_AGENT *(LIBSSH2_SESSION *)") < 0) __PYX_ERR(1, 1, __pyx_L1_error) /*--- Type init code ---*/ - if (PyType_Ready(&__pyx_type_4ssh2_5agent_Agent) < 0) __PYX_ERR(1, 57, __pyx_L1_error) + if (PyType_Ready(&__pyx_type_4ssh2_5agent_Agent) < 0) __PYX_ERR(1, 99, __pyx_L1_error) __pyx_type_4ssh2_5agent_Agent.tp_print = 0; - if (PyObject_SetAttrString(__pyx_m, "Agent", (PyObject *)&__pyx_type_4ssh2_5agent_Agent) < 0) __PYX_ERR(1, 57, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_5agent_Agent) < 0) __PYX_ERR(1, 57, __pyx_L1_error) + if (PyObject_SetAttrString(__pyx_m, "Agent", (PyObject *)&__pyx_type_4ssh2_5agent_Agent) < 0) __PYX_ERR(1, 99, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_5agent_Agent) < 0) __PYX_ERR(1, 99, __pyx_L1_error) __pyx_ptype_4ssh2_5agent_Agent = &__pyx_type_4ssh2_5agent_Agent; /*--- Type import code ---*/ - __pyx_ptype_4ssh2_7session_Session = __Pyx_ImportType("ssh2.session", "Session", sizeof(struct __pyx_obj_4ssh2_7session_Session), 1); if (unlikely(!__pyx_ptype_4ssh2_7session_Session)) __PYX_ERR(2, 20, __pyx_L1_error) - __pyx_vtabptr_4ssh2_7session_Session = (struct __pyx_vtabstruct_4ssh2_7session_Session*)__Pyx_GetVtable(__pyx_ptype_4ssh2_7session_Session->tp_dict); if (unlikely(!__pyx_vtabptr_4ssh2_7session_Session)) __PYX_ERR(2, 20, __pyx_L1_error) + __pyx_ptype_4ssh2_7session_Session = __Pyx_ImportType("ssh2.session", "Session", sizeof(struct __pyx_obj_4ssh2_7session_Session), 1); if (unlikely(!__pyx_ptype_4ssh2_7session_Session)) __PYX_ERR(2, 19, __pyx_L1_error) __pyx_ptype_4ssh2_4pkey_PublicKey = __Pyx_ImportType("ssh2.pkey", "PublicKey", sizeof(struct __pyx_obj_4ssh2_4pkey_PublicKey), 1); if (unlikely(!__pyx_ptype_4ssh2_4pkey_PublicKey)) __PYX_ERR(3, 23, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_AgentError = __Pyx_ImportType("ssh2.exceptions", "AgentError", sizeof(struct __pyx_obj_4ssh2_10exceptions_AgentError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_AgentError)) __PYX_ERR(4, 18, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_AuthenticationError = __Pyx_ImportType("ssh2.exceptions", "AuthenticationError", sizeof(struct __pyx_obj_4ssh2_10exceptions_AuthenticationError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_AuthenticationError)) __PYX_ERR(4, 22, __pyx_L1_error) @@ -2911,6 +3680,7 @@ PyMODINIT_FUNC PyInit_agent(void) __pyx_ptype_4ssh2_10exceptions_ChannelError = __Pyx_ImportType("ssh2.exceptions", "ChannelError", sizeof(struct __pyx_obj_4ssh2_10exceptions_ChannelError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_ChannelError)) __PYX_ERR(4, 50, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_SFTPHandleError = __Pyx_ImportType("ssh2.exceptions", "SFTPHandleError", sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SFTPHandleError)) __PYX_ERR(4, 54, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall = __Pyx_ImportType("ssh2.exceptions", "SFTPBufferTooSmall", sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall)) __PYX_ERR(4, 58, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_SFTPIOError = __Pyx_ImportType("ssh2.exceptions", "SFTPIOError", sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPIOError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SFTPIOError)) __PYX_ERR(4, 62, __pyx_L1_error) /*--- Variable import code ---*/ /*--- Function import code ---*/ __pyx_t_1 = __Pyx_ImportModule("ssh2.pkey"); if (!__pyx_t_1) __PYX_ERR(1, 1, __pyx_L1_error) @@ -2929,7 +3699,7 @@ PyMODINIT_FUNC PyInit_agent(void) * # Copyright (C) 2017 Panos Kittenis * */ - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -2951,10 +3721,12 @@ PyMODINIT_FUNC PyInit_agent(void) } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -3150,11 +3922,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject "raise: exception class must be a subclass of BaseException"); goto bad; } -#if PY_VERSION_HEX >= 0x03030000 if (cause) { -#else - if (cause && cause != Py_None) { -#endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; @@ -3182,7 +3950,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else - PyThreadState *tstate = PyThreadState_GET(); + PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); @@ -3198,7 +3966,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject #endif /* RaiseDoubleKeywords */ - static void __Pyx_RaiseDoubleKeywordsError( +static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { @@ -3212,7 +3980,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* ParseKeywords */ - static int __Pyx_ParseOptionalKeywords( +static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, @@ -3314,7 +4082,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* RaiseArgTupleInvalid */ - static void __Pyx_RaiseArgtupleInvalid( +static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, @@ -3340,44 +4108,37 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* 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); -} -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } - if (none_allowed && obj == Py_None) return 1; else if (exact) { - if (likely(Py_TYPE(obj) == type)) return 1; #if PY_MAJOR_VERSION == 2 - else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { - if (likely(PyObject_TypeCheck(obj, type))) return 1; + if (likely(__Pyx_TypeCheck(obj, type))) return 1; } - __Pyx_RaiseArgumentTypeInvalid(name, obj, type); + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); return 0; } /* SetupReduce */ - #define __Pyx_setup_reduce_GET_ATTR_OR_BAD(res, obj, name) res = PyObject_GetAttrString(obj, name); if (res == NULL) goto BAD; static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { int ret; PyObject *name_attr; - name_attr = PyObject_GetAttrString(meth, "__name__"); - if (name_attr) { + name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name); + if (likely(name_attr)) { ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); } else { ret = -1; } - if (ret < 0) { + if (unlikely(ret < 0)) { PyErr_Clear(); ret = 0; } @@ -3386,43 +4147,55 @@ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { } static int __Pyx_setup_reduce(PyObject* type_obj) { int ret = 0; - PyObject* builtin_object = NULL; - static PyObject *object_reduce = NULL; - static PyObject *object_reduce_ex = NULL; + PyObject *object_reduce = NULL; + PyObject *object_reduce_ex = NULL; PyObject *reduce = NULL; PyObject *reduce_ex = NULL; PyObject *reduce_cython = NULL; PyObject *setstate = NULL; PyObject *setstate_cython = NULL; - if (PyObject_HasAttrString(type_obj, "__getstate__")) goto GOOD; - if (object_reduce_ex == NULL) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(builtin_object, __pyx_b, "object"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce, builtin_object, "__reduce__"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce_ex, builtin_object, "__reduce_ex__"); - } - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_ex, type_obj, "__reduce_ex__"); +#if CYTHON_USE_PYTYPE_LOOKUP + if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD; +#else + if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD; +#endif +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#else + object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#endif + reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD; if (reduce_ex == object_reduce_ex) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce, type_obj, "__reduce__"); - if (object_reduce == reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_cython, type_obj, "__reduce_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce__", reduce_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce_cython__"); if (ret < 0) goto BAD; - setstate = PyObject_GetAttrString(type_obj, "__setstate__"); +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#else + object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#endif + reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD; + if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { + reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD; + setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); if (!setstate) PyErr_Clear(); if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(setstate_cython, type_obj, "__setstate_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate__", setstate_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate_cython__"); if (ret < 0) goto BAD; + setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD; } PyType_Modified((PyTypeObject*)type_obj); } } goto GOOD; BAD: - if (!PyErr_Occurred()) PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); + if (!PyErr_Occurred()) + PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); ret = -1; GOOD: - Py_XDECREF(builtin_object); +#if !CYTHON_USE_PYTYPE_LOOKUP + Py_XDECREF(object_reduce); + Py_XDECREF(object_reduce_ex); +#endif Py_XDECREF(reduce); Py_XDECREF(reduce_ex); Py_XDECREF(reduce_cython); @@ -3431,35 +4204,19 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { return ret; } -/* GetVTable */ - static void* __Pyx_GetVtable(PyObject *dict) { - void* ptr; - PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable); - if (!ob) - goto bad; -#if PY_VERSION_HEX >= 0x02070000 - ptr = PyCapsule_GetPointer(ob, 0); -#else - ptr = PyCObject_AsVoidPtr(ob); -#endif - if (!ptr && !PyErr_Occurred()) - PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); - Py_DECREF(ob); - return ptr; -bad: - Py_XDECREF(ob); - return NULL; -} - /* CLineInTraceback */ - static int __Pyx_CLineForTraceback(int c_line) { +static int __Pyx_CLineForTraceback(int c_line) { #ifdef CYTHON_CLINE_IN_TRACEBACK return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; #else - PyObject **cython_runtime_dict; PyObject *use_cline; - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (unlikely(!cython_runtime_dict)) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { PyObject *ptype, *pvalue, *ptraceback; PyObject *use_cline_obj; PyErr_Fetch(&ptype, &pvalue, &ptraceback); @@ -3471,8 +4228,6 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { use_cline = NULL; } PyErr_Restore(ptype, pvalue, ptraceback); - } else { - use_cline = PyDict_GetItem(*_PyObject_GetDictPtr(__pyx_cython_runtime), __pyx_n_s_cline_in_traceback); } if (!use_cline) { c_line = 0; @@ -3486,7 +4241,7 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { } /* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { +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; @@ -3566,7 +4321,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { } /* AddTraceback */ - #include "compile.h" +#include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( @@ -3636,10 +4391,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, __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*/ + __Pyx_PyThreadState_Current, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); @@ -3650,7 +4405,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -3681,7 +4436,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { +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) { @@ -3712,7 +4467,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ +#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) @@ -3734,7 +4489,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { +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 @@ -3923,7 +4678,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { +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 @@ -4111,8 +4866,80 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, return (int) -1; } +/* FastTypeChecks */ +#if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + /* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { +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()); @@ -4128,7 +4955,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* FunctionExport */ - static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { +static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { PyObject *d = 0; PyObject *cobj = 0; union { @@ -4165,7 +4992,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* ModuleImport */ - #ifndef __PYX_HAVE_RT_ImportModule +#ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; @@ -4183,7 +5010,7 @@ static PyObject *__Pyx_ImportModule(const char *name) { #endif /* TypeImport */ - #ifndef __PYX_HAVE_RT_ImportType +#ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) @@ -4248,7 +5075,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class #endif /* FunctionImport */ - #ifndef __PYX_HAVE_RT_ImportFunction +#ifndef __PYX_HAVE_RT_ImportFunction #define __PYX_HAVE_RT_ImportFunction static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { PyObject *d = 0; @@ -4302,7 +5129,7 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (** #endif /* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { @@ -4341,46 +5168,53 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#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 && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); #endif +} +#endif +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __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 && #endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -4404,6 +5238,26 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; @@ -4411,9 +5265,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS @@ -4421,32 +5275,30 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } #else - if (m && m->nb_int) { + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); } #endif #else - res = PyNumber_Int(x); + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { diff --git a/ssh2/agent.pxd b/ssh2/agent.pxd index 98089643..d98536b3 100644 --- a/ssh2/agent.pxd +++ b/ssh2/agent.pxd @@ -31,5 +31,13 @@ cdef int auth_identity(const char *username, c_ssh2.libssh2_agent_publickey **identity, c_ssh2.libssh2_agent_publickey *prev) nogil except -1 - cdef void clear_agent(c_ssh2.LIBSSH2_AGENT *agent) nogil + +cdef int agent_auth(char * _username, + c_ssh2.LIBSSH2_AGENT * agent) nogil except 1 + +cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent( + c_ssh2.LIBSSH2_SESSION *_session) nogil except NULL + +cdef c_ssh2.LIBSSH2_AGENT * agent_init( + c_ssh2.LIBSSH2_SESSION *_session) nogil except NULL diff --git a/ssh2/agent.pyx b/ssh2/agent.pyx index af7272c8..e75c2722 100644 --- a/ssh2/agent.pyx +++ b/ssh2/agent.pyx @@ -16,11 +16,36 @@ from pkey cimport PublicKey, PyPublicKey from exceptions cimport AgentConnectionError, AgentListIdentitiesError, \ - AgentGetIdentityError, AgentAuthenticationError + AgentGetIdentityError, AgentAuthenticationError, AgentError from utils cimport to_bytes cimport c_ssh2 +cdef int agent_auth(char * _username, + c_ssh2.LIBSSH2_AGENT * agent) nogil except 1: + cdef c_ssh2.libssh2_agent_publickey *identity = NULL + cdef c_ssh2.libssh2_agent_publickey *prev = NULL + if c_ssh2.libssh2_agent_list_identities(agent) != 0: + clear_agent(agent) + with gil: + raise AgentListIdentitiesError( + "Failure requesting identities from agent") + return 1 + while 1: + if auth_identity(_username, agent, &identity, prev) == 1: + with gil: + raise AgentAuthenticationError( + "No identities match for user %s", + _username) + return 1 + if c_ssh2.libssh2_agent_userauth( + agent, _username, identity) == 0: + clear_agent(agent) + return 0 + prev = identity + return 1 + + cdef int auth_identity(const char *username, c_ssh2.LIBSSH2_AGENT *agent, c_ssh2.libssh2_agent_publickey **identity, @@ -30,10 +55,6 @@ cdef int auth_identity(const char *username, agent, identity, prev) if rc == 1: clear_agent(agent) - with gil: - raise AgentAuthenticationError( - "No identities match for user %s", - username) elif rc < 0: clear_agent(agent) with gil: @@ -43,6 +64,27 @@ cdef int auth_identity(const char *username, return rc +cdef c_ssh2.LIBSSH2_AGENT * agent_init( + c_ssh2.LIBSSH2_SESSION *_session) nogil except NULL: + cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( + _session) + if agent is NULL: + with gil: + raise AgentError("Error initialising agent") + return agent + + +cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent( + c_ssh2.LIBSSH2_SESSION *_session) nogil except NULL: + cdef c_ssh2.LIBSSH2_AGENT *agent + agent = c_ssh2.libssh2_agent_init(_session) + if c_ssh2.libssh2_agent_connect(agent) != 0: + c_ssh2.libssh2_agent_free(agent) + with gil: + raise AgentConnectionError("Unable to connect to agent") + return agent + + cdef void clear_agent(c_ssh2.LIBSSH2_AGENT *agent) nogil: c_ssh2.libssh2_agent_disconnect(agent) c_ssh2.libssh2_agent_free(agent) diff --git a/ssh2/c_ssh2.pxd b/ssh2/c_ssh2.pxd index c60c0413..532fadb3 100644 --- a/ssh2/c_ssh2.pxd +++ b/ssh2/c_ssh2.pxd @@ -34,6 +34,8 @@ cdef extern from "libssh2.h" nogil: LIBSSH2_VERSION_PATCH LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA LIBSSH2_CHANNEL_FLUSH_ALL + LIBSSH2_HOSTKEY_HASH_MD5 + LIBSSH2_HOSTKEY_HASH_SHA1 # ctypedef libssh2_uint64_t libssh2_struct_stat_size ctypedef struct libssh2_struct_stat: dev_t st_dev diff --git a/ssh2/channel.c b/ssh2/channel.c index d63c1ca4..fe0d13a1 100644 --- a/ssh2/channel.c +++ b/ssh2/channel.c @@ -1,13 +1,14 @@ -/* Generated by Cython 0.26 */ +/* Generated by Cython 0.27.1 */ #define PY_SSIZE_T_CLEAN #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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_26" +#define CYTHON_ABI "0_27_1" +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -31,7 +32,7 @@ #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif @@ -47,8 +48,14 @@ #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS @@ -67,6 +74,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -74,6 +85,8 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS @@ -98,6 +111,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -105,6 +122,12 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 @@ -144,6 +167,12 @@ #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -199,6 +228,27 @@ #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ @@ -282,7 +332,6 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject @@ -333,15 +382,17 @@ #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct 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)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) @@ -451,14 +502,6 @@ static CYTHON_INLINE float __PYX_NAN() { __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) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -481,7 +524,7 @@ static CYTHON_INLINE float __PYX_NAN() { #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif @@ -512,8 +555,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #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 (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -535,6 +578,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) @@ -545,16 +594,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #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) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #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 @@ -563,6 +607,8 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) #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_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS @@ -663,7 +709,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime; @@ -683,6 +729,18 @@ static const char *__pyx_f[] = { "ssh2/exceptions.pxd", "ssh2/sftp.pxd", }; +/* NoFastGil.proto */ +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + /*--- Type declarations ---*/ struct __pyx_obj_4ssh2_7session_Session; @@ -697,20 +755,22 @@ struct __pyx_obj_4ssh2_10exceptions_SessionHandshakeError; struct __pyx_obj_4ssh2_10exceptions_ChannelError; struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError; struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall; +struct __pyx_obj_4ssh2_10exceptions_SFTPIOError; struct __pyx_obj_4ssh2_4sftp_SFTP; struct __pyx_obj_4ssh2_7channel_Channel; -/* "session.pxd":20 - * +/* "session.pxd":19 + * cimport c_ssh2 * * cdef class Session: # <<<<<<<<<<<<<< * cdef c_ssh2.LIBSSH2_SESSION *_session - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL + * cdef int _sock */ struct __pyx_obj_4ssh2_7session_Session { PyObject_HEAD - struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtab; LIBSSH2_SESSION *_session; + int _sock; + PyObject *sock; }; @@ -839,12 +899,24 @@ struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError { * * cdef class SFTPBufferTooSmall(Exception): # <<<<<<<<<<<<<< * pass + * */ struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall { PyBaseExceptionObject __pyx_base; }; +/* "exceptions.pxd":62 + * + * + * cdef class SFTPIOError(Exception): # <<<<<<<<<<<<<< + * pass + */ +struct __pyx_obj_4ssh2_10exceptions_SFTPIOError { + PyBaseExceptionObject __pyx_base; +}; + + /* "sftp.pxd":26 * * @@ -873,21 +945,6 @@ struct __pyx_obj_4ssh2_7channel_Channel { }; - -/* "session.pxd":20 - * - * - * cdef class Session: # <<<<<<<<<<<<<< - * cdef c_ssh2.LIBSSH2_SESSION *_session - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL - */ - -struct __pyx_vtabstruct_4ssh2_7session_Session { - LIBSSH2_AGENT *(*init_connect_agent)(struct __pyx_obj_4ssh2_7session_Session *); - LIBSSH2_AGENT *(*_agent_init)(struct __pyx_obj_4ssh2_7session_Session *); -}; -static struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtabptr_4ssh2_7session_Session; - /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY @@ -991,39 +1048,39 @@ 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); /* ArgTypeTest.proto */ -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); - -/* NoFastGil.proto */ -#define __Pyx_PyGILState_Ensure PyGILState_Ensure -#define __Pyx_PyGILState_Release PyGILState_Release -#define __Pyx_FastGIL_Remember() -#define __Pyx_FastGIL_Forget() -#define __Pyx_FastGilFuncInit() - -/* ForceInitThreads.proto */ -#ifndef __PYX_FORCE_INIT_THREADS - #define __PYX_FORCE_INIT_THREADS 0 -#endif +#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ + ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ + __Pyx__ArgTypeTest(obj, type, name, exact)) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #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); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif #else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #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) @@ -1063,9 +1120,6 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject /* SetupReduce.proto */ static int __Pyx_setup_reduce(PyObject* type_obj); -/* GetVTable.proto */ -static void* __Pyx_GetVtable(PyObject *dict); - /* CLineInTraceback.proto */ static int __Pyx_CLineForTraceback(int c_line); @@ -1109,6 +1163,18 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif + /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); @@ -1166,6 +1232,7 @@ static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SessionHandshakeError = 0; static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_ChannelError = 0; static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPHandleError = 0; static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPIOError = 0; /* Module declarations from 'ssh2.utils' */ static PyObject *(*__pyx_f_4ssh2_5utils_to_bytes)(PyObject *); /*proto*/ @@ -1188,22 +1255,26 @@ static PyObject *__pyx_builtin_TypeError; static const char __pyx_k_[] = ""; static const char __pyx_k_buf[] = "buf"; static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_size[] = "size"; static const char __pyx_k_term[] = "term"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_force[] = "force"; static const char __pyx_k_value[] = "value"; static const char __pyx_k_vt100[] = "vt100"; +static const char __pyx_k_reduce[] = "__reduce__"; static const char __pyx_k_message[] = "message"; static const char __pyx_k_read_ex[] = "read_ex"; static const char __pyx_k_request[] = "request"; static const char __pyx_k_session[] = "session"; static const char __pyx_k_varname[] = "varname"; +static const char __pyx_k_getstate[] = "__getstate__"; +static const char __pyx_k_setstate[] = "__setstate__"; static const char __pyx_k_TypeError[] = "TypeError"; +static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; static const char __pyx_k_stream_id[] = "stream_id"; static const char __pyx_k_adjustment[] = "adjustment"; static const char __pyx_k_auth_proto[] = "auth_proto"; -static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; static const char __pyx_k_read_avail[] = "read_avail"; static const char __pyx_k_MemoryError[] = "MemoryError"; static const char __pyx_k_auth_cookie[] = "auth_cookie"; @@ -1229,16 +1300,20 @@ static PyObject *__pyx_n_s_auth_proto; static PyObject *__pyx_n_s_buf; static PyObject *__pyx_n_s_cline_in_traceback; static PyObject *__pyx_n_s_force; +static PyObject *__pyx_n_s_getstate; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_message; +static PyObject *__pyx_n_s_name; static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; -static PyObject *__pyx_n_s_pyx_vtable; static PyObject *__pyx_n_s_read_avail; static PyObject *__pyx_n_s_read_ex; +static PyObject *__pyx_n_s_reduce; static PyObject *__pyx_n_s_reduce_cython; +static PyObject *__pyx_n_s_reduce_ex; static PyObject *__pyx_n_s_request; static PyObject *__pyx_n_s_screen_number; static PyObject *__pyx_n_s_session; +static PyObject *__pyx_n_s_setstate; static PyObject *__pyx_n_s_setstate_cython; static PyObject *__pyx_n_s_single_connection; static PyObject *__pyx_n_s_size; @@ -1251,6 +1326,7 @@ static PyObject *__pyx_n_s_vt100; static PyObject *__pyx_n_s_window_size_initial; static int __pyx_pf_4ssh2_7channel_7Channel___cinit__(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, struct __pyx_obj_4ssh2_7session_Session *__pyx_v_session); /* proto */ static void __pyx_pf_4ssh2_7channel_7Channel_2__dealloc__(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_4ssh2_7channel_7Channel_7session___get__(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_4pty(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, PyObject *__pyx_v_term); /* proto */ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_6execute(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, PyObject *__pyx_v_command); /* proto */ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_8subsystem(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, PyObject *__pyx_v_subsystem); /* proto */ @@ -1476,7 +1552,7 @@ static int __pyx_pf_4ssh2_7channel_7Channel___cinit__(struct __pyx_obj_4ssh2_7ch * * def __dealloc__(self): # <<<<<<<<<<<<<< * with nogil: - * c_ssh2.libssh2_channel_close(self._channel) + * if self._channel is not NULL and self._session is not None: */ /* Python wrapper */ @@ -1492,14 +1568,17 @@ static void __pyx_pw_4ssh2_7channel_7Channel_3__dealloc__(PyObject *__pyx_v_self static void __pyx_pf_4ssh2_7channel_7Channel_2__dealloc__(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self) { __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; __Pyx_RefNannySetupContext("__dealloc__", 0); /* "ssh2/channel.pyx":40 * * def __dealloc__(self): * with nogil: # <<<<<<<<<<<<<< - * c_ssh2.libssh2_channel_close(self._channel) - * c_ssh2.libssh2_channel_free(self._channel) + * if self._channel is not NULL and self._session is not None: + * c_ssh2.libssh2_channel_close(self._channel) */ { #ifdef WITH_THREAD @@ -1512,28 +1591,65 @@ static void __pyx_pf_4ssh2_7channel_7Channel_2__dealloc__(struct __pyx_obj_4ssh2 /* "ssh2/channel.pyx":41 * def __dealloc__(self): * with nogil: - * c_ssh2.libssh2_channel_close(self._channel) # <<<<<<<<<<<<<< - * c_ssh2.libssh2_channel_free(self._channel) - * + * if self._channel is not NULL and self._session is not None: # <<<<<<<<<<<<<< + * c_ssh2.libssh2_channel_close(self._channel) + * c_ssh2.libssh2_channel_free(self._channel) */ - libssh2_channel_close(__pyx_v_self->_channel); + __pyx_t_2 = ((__pyx_v_self->_channel != NULL) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L7_bool_binop_done; + } + __pyx_t_2 = (((PyObject *)__pyx_v_self->_session) != Py_None); + __pyx_t_3 = (__pyx_t_2 != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L7_bool_binop_done:; + if (__pyx_t_1) { - /* "ssh2/channel.pyx":42 + /* "ssh2/channel.pyx":42 * with nogil: - * c_ssh2.libssh2_channel_close(self._channel) - * c_ssh2.libssh2_channel_free(self._channel) # <<<<<<<<<<<<<< + * if self._channel is not NULL and self._session is not None: + * c_ssh2.libssh2_channel_close(self._channel) # <<<<<<<<<<<<<< + * c_ssh2.libssh2_channel_free(self._channel) + * self._channel = NULL + */ + libssh2_channel_close(__pyx_v_self->_channel); + + /* "ssh2/channel.pyx":43 + * if self._channel is not NULL and self._session is not None: + * c_ssh2.libssh2_channel_close(self._channel) + * c_ssh2.libssh2_channel_free(self._channel) # <<<<<<<<<<<<<< + * self._channel = NULL * - * def pty(self, term="vt100"): */ - libssh2_channel_free(__pyx_v_self->_channel); + libssh2_channel_free(__pyx_v_self->_channel); + + /* "ssh2/channel.pyx":44 + * c_ssh2.libssh2_channel_close(self._channel) + * c_ssh2.libssh2_channel_free(self._channel) + * self._channel = NULL # <<<<<<<<<<<<<< + * + * @property + */ + __pyx_v_self->_channel = NULL; + + /* "ssh2/channel.pyx":41 + * def __dealloc__(self): + * with nogil: + * if self._channel is not NULL and self._session is not None: # <<<<<<<<<<<<<< + * c_ssh2.libssh2_channel_close(self._channel) + * c_ssh2.libssh2_channel_free(self._channel) + */ + } } /* "ssh2/channel.pyx":40 * * def __dealloc__(self): * with nogil: # <<<<<<<<<<<<<< - * c_ssh2.libssh2_channel_close(self._channel) - * c_ssh2.libssh2_channel_free(self._channel) + * if self._channel is not NULL and self._session is not None: + * c_ssh2.libssh2_channel_close(self._channel) */ /*finally:*/ { /*normal exit:*/{ @@ -1552,24 +1668,77 @@ static void __pyx_pf_4ssh2_7channel_7Channel_2__dealloc__(struct __pyx_obj_4ssh2 * * def __dealloc__(self): # <<<<<<<<<<<<<< * with nogil: - * c_ssh2.libssh2_channel_close(self._channel) + * if self._channel is not NULL and self._session is not None: */ /* function exit code */ __Pyx_RefNannyFinishContext(); } -/* "ssh2/channel.pyx":44 - * c_ssh2.libssh2_channel_free(self._channel) +/* "ssh2/channel.pyx":47 + * + * @property + * def session(self): # <<<<<<<<<<<<<< + * return self._session + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_4ssh2_7channel_7Channel_7session_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_4ssh2_7channel_7Channel_7session_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_7session___get__(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_4ssh2_7channel_7Channel_7session___get__(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + /* "ssh2/channel.pyx":48 + * @property + * def session(self): + * return self._session # <<<<<<<<<<<<<< + * + * def pty(self, term="vt100"): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->_session)); + __pyx_r = ((PyObject *)__pyx_v_self->_session); + goto __pyx_L0; + + /* "ssh2/channel.pyx":47 + * + * @property + * def session(self): # <<<<<<<<<<<<<< + * return self._session + * + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "ssh2/channel.pyx":50 + * return self._session * * def pty(self, term="vt100"): # <<<<<<<<<<<<<< - * cdef bytes b_term = to_bytes(term) - * cdef const char *_term = b_term + * """Request a PTY (physical terminal emulation) on the channel. + * */ /* Python wrapper */ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_5pty(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_4ssh2_7channel_7Channel_4pty[] = "Channel.pty(self, term='vt100')"; +static char __pyx_doc_4ssh2_7channel_7Channel_4pty[] = "Channel.pty(self, term='vt100')\nRequest a PTY (physical terminal emulation) on the channel.\n\n :param term: Terminal type to emulate.\n :type term: str\n "; static PyObject *__pyx_pw_4ssh2_7channel_7Channel_5pty(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_term = 0; PyObject *__pyx_r = 0; @@ -1597,7 +1766,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_5pty(PyObject *__pyx_v_self, P } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "pty") < 0)) __PYX_ERR(0, 44, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "pty") < 0)) __PYX_ERR(0, 50, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -1611,7 +1780,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_5pty(PyObject *__pyx_v_self, P } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("pty", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 44, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("pty", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 50, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.channel.Channel.pty", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -1636,29 +1805,33 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_4pty(struct __pyx_obj_4ssh2_7c PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("pty", 0); - /* "ssh2/channel.pyx":45 - * - * def pty(self, term="vt100"): + /* "ssh2/channel.pyx":56 + * :type term: str + * """ * cdef bytes b_term = to_bytes(term) # <<<<<<<<<<<<<< * cdef const char *_term = b_term * cdef int rc */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_term); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_term); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_term = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/channel.pyx":46 - * def pty(self, term="vt100"): + /* "ssh2/channel.pyx":57 + * """ * cdef bytes b_term = to_bytes(term) * cdef const char *_term = b_term # <<<<<<<<<<<<<< * cdef int rc * with nogil: */ - __pyx_t_2 = __Pyx_PyObject_AsString(__pyx_v_b_term); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L1_error) + if (unlikely(__pyx_v_b_term == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 57, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_term); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 57, __pyx_L1_error) __pyx_v__term = __pyx_t_2; - /* "ssh2/channel.pyx":48 + /* "ssh2/channel.pyx":59 * cdef const char *_term = b_term * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -1673,7 +1846,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_4pty(struct __pyx_obj_4ssh2_7c #endif /*try:*/ { - /* "ssh2/channel.pyx":49 + /* "ssh2/channel.pyx":60 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_request_pty( # <<<<<<<<<<<<<< @@ -1682,7 +1855,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_4pty(struct __pyx_obj_4ssh2_7c */ __pyx_v_rc = libssh2_channel_request_pty(__pyx_v_self->_channel, __pyx_v__term); - /* "ssh2/channel.pyx":51 + /* "ssh2/channel.pyx":62 * rc = c_ssh2.libssh2_channel_request_pty( * self._channel, _term) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -1700,7 +1873,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_4pty(struct __pyx_obj_4ssh2_7c } if (__pyx_t_3) { - /* "ssh2/channel.pyx":52 + /* "ssh2/channel.pyx":63 * self._channel, _term) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -1713,24 +1886,24 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_4pty(struct __pyx_obj_4ssh2_7c #endif /*try:*/ { - /* "ssh2/channel.pyx":55 + /* "ssh2/channel.pyx":66 * raise ChannelError( * "Error requesting PTY with error code %s", * rc) # <<<<<<<<<<<<<< * return rc * */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L8_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); - /* "ssh2/channel.pyx":53 + /* "ssh2/channel.pyx":64 * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: * raise ChannelError( # <<<<<<<<<<<<<< * "Error requesting PTY with error code %s", * rc) */ - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 53, __pyx_L8_error) + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 64, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_kp_s_Error_requesting_PTY_with_error); __Pyx_GIVEREF(__pyx_kp_s_Error_requesting_PTY_with_error); @@ -1738,15 +1911,15 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_4pty(struct __pyx_obj_4ssh2_7c __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_ChannelError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L8_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_ChannelError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 53, __pyx_L8_error) + __PYX_ERR(0, 64, __pyx_L8_error) } - /* "ssh2/channel.pyx":52 + /* "ssh2/channel.pyx":63 * self._channel, _term) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -1763,7 +1936,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_4pty(struct __pyx_obj_4ssh2_7c } } - /* "ssh2/channel.pyx":51 + /* "ssh2/channel.pyx":62 * rc = c_ssh2.libssh2_channel_request_pty( * self._channel, _term) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -1773,7 +1946,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_4pty(struct __pyx_obj_4ssh2_7c } } - /* "ssh2/channel.pyx":48 + /* "ssh2/channel.pyx":59 * cdef const char *_term = b_term * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -1799,7 +1972,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_4pty(struct __pyx_obj_4ssh2_7c } } - /* "ssh2/channel.pyx":56 + /* "ssh2/channel.pyx":67 * "Error requesting PTY with error code %s", * rc) * return rc # <<<<<<<<<<<<<< @@ -1807,18 +1980,18 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_4pty(struct __pyx_obj_4ssh2_7c * def execute(self, command not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":44 - * c_ssh2.libssh2_channel_free(self._channel) + /* "ssh2/channel.pyx":50 + * return self._session * * def pty(self, term="vt100"): # <<<<<<<<<<<<<< - * cdef bytes b_term = to_bytes(term) - * cdef const char *_term = b_term + * """Request a PTY (physical terminal emulation) on the channel. + * */ /* function exit code */ @@ -1834,7 +2007,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_4pty(struct __pyx_obj_4ssh2_7c return __pyx_r; } -/* "ssh2/channel.pyx":58 +/* "ssh2/channel.pyx":69 * return rc * * def execute(self, command not None): # <<<<<<<<<<<<<< @@ -1850,7 +2023,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_7execute(PyObject *__pyx_v_sel __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("execute (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_command) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "command"); __PYX_ERR(0, 58, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "command"); __PYX_ERR(0, 69, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_6execute(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self), ((PyObject *)__pyx_v_command)); @@ -1875,29 +2048,33 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_6execute(struct __pyx_obj_4ssh PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("execute", 0); - /* "ssh2/channel.pyx":70 + /* "ssh2/channel.pyx":81 * """ * cdef int rc * cdef bytes b_command = to_bytes(command) # <<<<<<<<<<<<<< * cdef char *_command = b_command * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_command); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_command); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_command = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/channel.pyx":71 + /* "ssh2/channel.pyx":82 * cdef int rc * cdef bytes b_command = to_bytes(command) * cdef char *_command = b_command # <<<<<<<<<<<<<< * with nogil: * rc = c_ssh2.libssh2_channel_exec( */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_command); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 71, __pyx_L1_error) + if (unlikely(__pyx_v_b_command == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 82, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_command); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 82, __pyx_L1_error) __pyx_v__command = __pyx_t_2; - /* "ssh2/channel.pyx":72 + /* "ssh2/channel.pyx":83 * cdef bytes b_command = to_bytes(command) * cdef char *_command = b_command * with nogil: # <<<<<<<<<<<<<< @@ -1912,7 +2089,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_6execute(struct __pyx_obj_4ssh #endif /*try:*/ { - /* "ssh2/channel.pyx":73 + /* "ssh2/channel.pyx":84 * cdef char *_command = b_command * with nogil: * rc = c_ssh2.libssh2_channel_exec( # <<<<<<<<<<<<<< @@ -1921,7 +2098,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_6execute(struct __pyx_obj_4ssh */ __pyx_v_rc = libssh2_channel_exec(__pyx_v_self->_channel, __pyx_v__command); - /* "ssh2/channel.pyx":75 + /* "ssh2/channel.pyx":86 * rc = c_ssh2.libssh2_channel_exec( * self._channel, _command) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -1939,7 +2116,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_6execute(struct __pyx_obj_4ssh } if (__pyx_t_3) { - /* "ssh2/channel.pyx":76 + /* "ssh2/channel.pyx":87 * self._channel, _command) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -1952,24 +2129,24 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_6execute(struct __pyx_obj_4ssh #endif /*try:*/ { - /* "ssh2/channel.pyx":79 + /* "ssh2/channel.pyx":90 * raise ChannelError( * "Error executing command %s - error code %s", * command, rc) # <<<<<<<<<<<<<< * return rc * */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L8_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); - /* "ssh2/channel.pyx":77 + /* "ssh2/channel.pyx":88 * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: * raise ChannelError( # <<<<<<<<<<<<<< * "Error executing command %s - error code %s", * command, rc) */ - __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 77, __pyx_L8_error) + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_kp_s_Error_executing_command_s_error); __Pyx_GIVEREF(__pyx_kp_s_Error_executing_command_s_error); @@ -1980,15 +2157,15 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_6execute(struct __pyx_obj_4ssh __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_ChannelError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L8_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_ChannelError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 77, __pyx_L8_error) + __PYX_ERR(0, 88, __pyx_L8_error) } - /* "ssh2/channel.pyx":76 + /* "ssh2/channel.pyx":87 * self._channel, _command) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -2005,7 +2182,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_6execute(struct __pyx_obj_4ssh } } - /* "ssh2/channel.pyx":75 + /* "ssh2/channel.pyx":86 * rc = c_ssh2.libssh2_channel_exec( * self._channel, _command) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -2015,7 +2192,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_6execute(struct __pyx_obj_4ssh } } - /* "ssh2/channel.pyx":72 + /* "ssh2/channel.pyx":83 * cdef bytes b_command = to_bytes(command) * cdef char *_command = b_command * with nogil: # <<<<<<<<<<<<<< @@ -2041,7 +2218,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_6execute(struct __pyx_obj_4ssh } } - /* "ssh2/channel.pyx":80 + /* "ssh2/channel.pyx":91 * "Error executing command %s - error code %s", * command, rc) * return rc # <<<<<<<<<<<<<< @@ -2049,13 +2226,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_6execute(struct __pyx_obj_4ssh * def subsystem(self, subsystem not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":58 + /* "ssh2/channel.pyx":69 * return rc * * def execute(self, command not None): # <<<<<<<<<<<<<< @@ -2076,7 +2253,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_6execute(struct __pyx_obj_4ssh return __pyx_r; } -/* "ssh2/channel.pyx":82 +/* "ssh2/channel.pyx":93 * return rc * * def subsystem(self, subsystem not None): # <<<<<<<<<<<<<< @@ -2092,7 +2269,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_9subsystem(PyObject *__pyx_v_s __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("subsystem (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_subsystem) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "subsystem"); __PYX_ERR(0, 82, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "subsystem"); __PYX_ERR(0, 93, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_8subsystem(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self), ((PyObject *)__pyx_v_subsystem)); @@ -2117,29 +2294,33 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_8subsystem(struct __pyx_obj_4s PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("subsystem", 0); - /* "ssh2/channel.pyx":88 + /* "ssh2/channel.pyx":99 * :type subsystem: str""" * cdef int rc * cdef bytes b_subsystem = to_bytes(subsystem) # <<<<<<<<<<<<<< * cdef char *_subsystem = b_subsystem * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_subsystem); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_subsystem); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_subsystem = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/channel.pyx":89 + /* "ssh2/channel.pyx":100 * cdef int rc * cdef bytes b_subsystem = to_bytes(subsystem) * cdef char *_subsystem = b_subsystem # <<<<<<<<<<<<<< * with nogil: * rc = c_ssh2.libssh2_channel_subsystem( */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_subsystem); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 89, __pyx_L1_error) + if (unlikely(__pyx_v_b_subsystem == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 100, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_subsystem); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 100, __pyx_L1_error) __pyx_v__subsystem = __pyx_t_2; - /* "ssh2/channel.pyx":90 + /* "ssh2/channel.pyx":101 * cdef bytes b_subsystem = to_bytes(subsystem) * cdef char *_subsystem = b_subsystem * with nogil: # <<<<<<<<<<<<<< @@ -2154,7 +2335,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_8subsystem(struct __pyx_obj_4s #endif /*try:*/ { - /* "ssh2/channel.pyx":91 + /* "ssh2/channel.pyx":102 * cdef char *_subsystem = b_subsystem * with nogil: * rc = c_ssh2.libssh2_channel_subsystem( # <<<<<<<<<<<<<< @@ -2163,7 +2344,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_8subsystem(struct __pyx_obj_4s */ __pyx_v_rc = libssh2_channel_subsystem(__pyx_v_self->_channel, __pyx_v__subsystem); - /* "ssh2/channel.pyx":93 + /* "ssh2/channel.pyx":104 * rc = c_ssh2.libssh2_channel_subsystem( * self._channel, _subsystem) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -2181,7 +2362,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_8subsystem(struct __pyx_obj_4s } if (__pyx_t_3) { - /* "ssh2/channel.pyx":94 + /* "ssh2/channel.pyx":105 * self._channel, _subsystem) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -2194,24 +2375,24 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_8subsystem(struct __pyx_obj_4s #endif /*try:*/ { - /* "ssh2/channel.pyx":97 + /* "ssh2/channel.pyx":108 * raise ChannelError( * "Error requesting subsystem %s - error code %s", * subsystem, rc) # <<<<<<<<<<<<<< * return rc * */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L8_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); - /* "ssh2/channel.pyx":95 + /* "ssh2/channel.pyx":106 * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: * raise ChannelError( # <<<<<<<<<<<<<< * "Error requesting subsystem %s - error code %s", * subsystem, rc) */ - __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 95, __pyx_L8_error) + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 106, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_kp_s_Error_requesting_subsystem_s_err); __Pyx_GIVEREF(__pyx_kp_s_Error_requesting_subsystem_s_err); @@ -2222,15 +2403,15 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_8subsystem(struct __pyx_obj_4s __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_ChannelError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L8_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_ChannelError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 95, __pyx_L8_error) + __PYX_ERR(0, 106, __pyx_L8_error) } - /* "ssh2/channel.pyx":94 + /* "ssh2/channel.pyx":105 * self._channel, _subsystem) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -2247,7 +2428,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_8subsystem(struct __pyx_obj_4s } } - /* "ssh2/channel.pyx":93 + /* "ssh2/channel.pyx":104 * rc = c_ssh2.libssh2_channel_subsystem( * self._channel, _subsystem) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -2257,7 +2438,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_8subsystem(struct __pyx_obj_4s } } - /* "ssh2/channel.pyx":90 + /* "ssh2/channel.pyx":101 * cdef bytes b_subsystem = to_bytes(subsystem) * cdef char *_subsystem = b_subsystem * with nogil: # <<<<<<<<<<<<<< @@ -2283,7 +2464,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_8subsystem(struct __pyx_obj_4s } } - /* "ssh2/channel.pyx":98 + /* "ssh2/channel.pyx":109 * "Error requesting subsystem %s - error code %s", * subsystem, rc) * return rc # <<<<<<<<<<<<<< @@ -2291,13 +2472,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_8subsystem(struct __pyx_obj_4s * def read(self, size_t size=1024): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":82 + /* "ssh2/channel.pyx":93 * return rc * * def subsystem(self, subsystem not None): # <<<<<<<<<<<<<< @@ -2318,7 +2499,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_8subsystem(struct __pyx_obj_4s return __pyx_r; } -/* "ssh2/channel.pyx":100 +/* "ssh2/channel.pyx":111 * return rc * * def read(self, size_t size=1024): # <<<<<<<<<<<<<< @@ -2328,7 +2509,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_8subsystem(struct __pyx_obj_4s /* Python wrapper */ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_11read(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_4ssh2_7channel_7Channel_10read[] = "Channel.read(self, size_t size=1024)\nRead the stdout stream.\n Returns return code and output buffer tuple.\n\n Return code is the size of the buffer when positive.\n Negative values are error codes.\n\n :rtype: (int, bytes)"; +static char __pyx_doc_4ssh2_7channel_7Channel_10read[] = "Channel.read(self, size_t size=1024)\nRead the stdout stream.\n Returns return code and output buffer tuple.\n\n Return code is the size of the buffer when positive.\n Negative values are error codes.\n\n :param size: Max buffer size to read.\n :type size: int\n\n :rtype: (int, bytes)"; static PyObject *__pyx_pw_4ssh2_7channel_7Channel_11read(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { size_t __pyx_v_size; PyObject *__pyx_r = 0; @@ -2355,7 +2536,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_11read(PyObject *__pyx_v_self, } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read") < 0)) __PYX_ERR(0, 100, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read") < 0)) __PYX_ERR(0, 111, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -2366,14 +2547,14 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_11read(PyObject *__pyx_v_self, } } if (values[0]) { - __pyx_v_size = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_size == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 100, __pyx_L3_error) + __pyx_v_size = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_size == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 111, __pyx_L3_error) } else { __pyx_v_size = ((size_t)0x400); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("read", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 100, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("read", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 111, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.channel.Channel.read", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -2394,7 +2575,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_10read(struct __pyx_obj_4ssh2_ PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("read", 0); - /* "ssh2/channel.pyx":108 + /* "ssh2/channel.pyx":122 * * :rtype: (int, bytes)""" * return self.read_ex(size=size, stream_id=0) # <<<<<<<<<<<<<< @@ -2402,16 +2583,16 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_10read(struct __pyx_obj_4ssh2_ * def read_ex(self, size_t size=1024, int stream_id=0): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_ex); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_ex); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 108, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_size, __pyx_t_3) < 0) __PYX_ERR(0, 108, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_size, __pyx_t_3) < 0) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_stream_id, __pyx_int_0) < 0) __PYX_ERR(0, 108, __pyx_L1_error) - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 108, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_stream_id, __pyx_int_0) < 0) __PYX_ERR(0, 122, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -2419,7 +2600,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_10read(struct __pyx_obj_4ssh2_ __pyx_t_3 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":100 + /* "ssh2/channel.pyx":111 * return rc * * def read(self, size_t size=1024): # <<<<<<<<<<<<<< @@ -2440,7 +2621,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_10read(struct __pyx_obj_4ssh2_ return __pyx_r; } -/* "ssh2/channel.pyx":110 +/* "ssh2/channel.pyx":124 * return self.read_ex(size=size, stream_id=0) * * def read_ex(self, size_t size=1024, int stream_id=0): # <<<<<<<<<<<<<< @@ -2450,7 +2631,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_10read(struct __pyx_obj_4ssh2_ /* Python wrapper */ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_13read_ex(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_4ssh2_7channel_7Channel_12read_ex[] = "Channel.read_ex(self, size_t size=1024, int stream_id=0)\nRead the stream with given id.\n Returns return code and output buffer tuple.\n\n Return code is the size of the buffer when positive.\n Negative values are error codes.\n\n :rtype: (int, bytes)"; +static char __pyx_doc_4ssh2_7channel_7Channel_12read_ex[] = "Channel.read_ex(self, size_t size=1024, int stream_id=0)\nRead the stream with given id.\n Returns return code and output buffer tuple.\n\n Return code is the size of the buffer when positive.\n Negative values are error codes.\n\n :param size: Max buffer size to read.\n :type size: int\n\n :rtype: (int, bytes)"; static PyObject *__pyx_pw_4ssh2_7channel_7Channel_13read_ex(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { size_t __pyx_v_size; int __pyx_v_stream_id; @@ -2486,7 +2667,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_13read_ex(PyObject *__pyx_v_se } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_ex") < 0)) __PYX_ERR(0, 110, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_ex") < 0)) __PYX_ERR(0, 124, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -2499,19 +2680,19 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_13read_ex(PyObject *__pyx_v_se } } if (values[0]) { - __pyx_v_size = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_size == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 110, __pyx_L3_error) + __pyx_v_size = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_size == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 124, __pyx_L3_error) } else { __pyx_v_size = ((size_t)0x400); } if (values[1]) { - __pyx_v_stream_id = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_stream_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 110, __pyx_L3_error) + __pyx_v_stream_id = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_stream_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 124, __pyx_L3_error) } else { __pyx_v_stream_id = ((int)0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("read_ex", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 110, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("read_ex", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 124, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.channel.Channel.read_ex", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -2544,9 +2725,19 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_12read_ex(struct __pyx_obj_4ss PyObject *__pyx_t_12 = NULL; __Pyx_RefNannySetupContext("read_ex", 0); - /* "ssh2/channel.pyx":120 - * cdef bytes buf + /* "ssh2/channel.pyx":135 + * + * :rtype: (int, bytes)""" + * cdef bytes buf = b'' # <<<<<<<<<<<<<< + * cdef char *cbuf + * cdef ssize_t rc + */ + __Pyx_INCREF(__pyx_kp_b_); + __pyx_v_buf = __pyx_kp_b_; + + /* "ssh2/channel.pyx":138 * cdef char *cbuf + * cdef ssize_t rc * with nogil: # <<<<<<<<<<<<<< * cbuf = malloc(sizeof(char)*size) * if cbuf is NULL: @@ -2559,8 +2750,8 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_12read_ex(struct __pyx_obj_4ss #endif /*try:*/ { - /* "ssh2/channel.pyx":121 - * cdef char *cbuf + /* "ssh2/channel.pyx":139 + * cdef ssize_t rc * with nogil: * cbuf = malloc(sizeof(char)*size) # <<<<<<<<<<<<<< * if cbuf is NULL: @@ -2568,7 +2759,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_12read_ex(struct __pyx_obj_4ss */ __pyx_v_cbuf = ((char *)malloc(((sizeof(char)) * __pyx_v_size))); - /* "ssh2/channel.pyx":122 + /* "ssh2/channel.pyx":140 * with nogil: * cbuf = malloc(sizeof(char)*size) * if cbuf is NULL: # <<<<<<<<<<<<<< @@ -2578,7 +2769,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_12read_ex(struct __pyx_obj_4ss __pyx_t_1 = ((__pyx_v_cbuf == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/channel.pyx":123 + /* "ssh2/channel.pyx":141 * cbuf = malloc(sizeof(char)*size) * if cbuf is NULL: * with gil: # <<<<<<<<<<<<<< @@ -2591,17 +2782,17 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_12read_ex(struct __pyx_obj_4ss #endif /*try:*/ { - /* "ssh2/channel.pyx":124 + /* "ssh2/channel.pyx":142 * if cbuf is NULL: * with gil: * raise MemoryError # <<<<<<<<<<<<<< * rc = c_ssh2.libssh2_channel_read_ex( * self._channel, stream_id, cbuf, size) */ - PyErr_NoMemory(); __PYX_ERR(0, 124, __pyx_L8_error) + PyErr_NoMemory(); __PYX_ERR(0, 142, __pyx_L8_error) } - /* "ssh2/channel.pyx":123 + /* "ssh2/channel.pyx":141 * cbuf = malloc(sizeof(char)*size) * if cbuf is NULL: * with gil: # <<<<<<<<<<<<<< @@ -2618,7 +2809,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_12read_ex(struct __pyx_obj_4ss } } - /* "ssh2/channel.pyx":122 + /* "ssh2/channel.pyx":140 * with nogil: * cbuf = malloc(sizeof(char)*size) * if cbuf is NULL: # <<<<<<<<<<<<<< @@ -2627,7 +2818,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_12read_ex(struct __pyx_obj_4ss */ } - /* "ssh2/channel.pyx":125 + /* "ssh2/channel.pyx":143 * with gil: * raise MemoryError * rc = c_ssh2.libssh2_channel_read_ex( # <<<<<<<<<<<<<< @@ -2637,9 +2828,9 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_12read_ex(struct __pyx_obj_4ss __pyx_v_rc = libssh2_channel_read_ex(__pyx_v_self->_channel, __pyx_v_stream_id, __pyx_v_cbuf, __pyx_v_size); } - /* "ssh2/channel.pyx":120 - * cdef bytes buf + /* "ssh2/channel.pyx":138 * cdef char *cbuf + * cdef ssize_t rc * with nogil: # <<<<<<<<<<<<<< * cbuf = malloc(sizeof(char)*size) * if cbuf is NULL: @@ -2663,7 +2854,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_12read_ex(struct __pyx_obj_4ss } } - /* "ssh2/channel.pyx":127 + /* "ssh2/channel.pyx":145 * rc = c_ssh2.libssh2_channel_read_ex( * self._channel, stream_id, cbuf, size) * try: # <<<<<<<<<<<<<< @@ -2672,54 +2863,40 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_12read_ex(struct __pyx_obj_4ss */ /*try:*/ { - /* "ssh2/channel.pyx":128 + /* "ssh2/channel.pyx":146 * self._channel, stream_id, cbuf, size) * try: * if rc > 0: # <<<<<<<<<<<<<< * buf = cbuf[:rc] - * else: + * finally: */ __pyx_t_1 = ((__pyx_v_rc > 0) != 0); if (__pyx_t_1) { - /* "ssh2/channel.pyx":129 + /* "ssh2/channel.pyx":147 * try: * if rc > 0: * buf = cbuf[:rc] # <<<<<<<<<<<<<< - * else: - * buf = b'' + * finally: + * free(cbuf) */ - __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_cbuf + 0, __pyx_v_rc - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L11_error) + __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_cbuf + 0, __pyx_v_rc - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_v_buf = ((PyObject*)__pyx_t_2); + __Pyx_DECREF_SET(__pyx_v_buf, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0; - /* "ssh2/channel.pyx":128 + /* "ssh2/channel.pyx":146 * self._channel, stream_id, cbuf, size) * try: * if rc > 0: # <<<<<<<<<<<<<< * buf = cbuf[:rc] - * else: - */ - goto __pyx_L13; - } - - /* "ssh2/channel.pyx":131 - * buf = cbuf[:rc] - * else: - * buf = b'' # <<<<<<<<<<<<<< * finally: - * free(cbuf) */ - /*else*/ { - __Pyx_INCREF(__pyx_kp_b_); - __pyx_v_buf = __pyx_kp_b_; } - __pyx_L13:; } - /* "ssh2/channel.pyx":133 - * buf = b'' + /* "ssh2/channel.pyx":149 + * buf = cbuf[:rc] * finally: * free(cbuf) # <<<<<<<<<<<<<< * return rc, buf @@ -2748,7 +2925,6 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_12read_ex(struct __pyx_obj_4ss { free(__pyx_v_cbuf); } - __Pyx_PyThreadState_assign if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); @@ -2766,7 +2942,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_12read_ex(struct __pyx_obj_4ss __pyx_L12:; } - /* "ssh2/channel.pyx":134 + /* "ssh2/channel.pyx":150 * finally: * free(cbuf) * return rc, buf # <<<<<<<<<<<<<< @@ -2774,9 +2950,9 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_12read_ex(struct __pyx_obj_4ss * def read_stderr(self, size_t size=1024): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 134, __pyx_L1_error) + __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2); @@ -2788,7 +2964,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_12read_ex(struct __pyx_obj_4ss __pyx_t_12 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":110 + /* "ssh2/channel.pyx":124 * return self.read_ex(size=size, stream_id=0) * * def read_ex(self, size_t size=1024, int stream_id=0): # <<<<<<<<<<<<<< @@ -2809,7 +2985,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_12read_ex(struct __pyx_obj_4ss return __pyx_r; } -/* "ssh2/channel.pyx":136 +/* "ssh2/channel.pyx":152 * return rc, buf * * def read_stderr(self, size_t size=1024): # <<<<<<<<<<<<<< @@ -2846,7 +3022,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_15read_stderr(PyObject *__pyx_ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_stderr") < 0)) __PYX_ERR(0, 136, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_stderr") < 0)) __PYX_ERR(0, 152, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -2857,14 +3033,14 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_15read_stderr(PyObject *__pyx_ } } if (values[0]) { - __pyx_v_size = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_size == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 136, __pyx_L3_error) + __pyx_v_size = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_size == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 152, __pyx_L3_error) } else { __pyx_v_size = ((size_t)0x400); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("read_stderr", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 136, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("read_stderr", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 152, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.channel.Channel.read_stderr", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -2885,7 +3061,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_14read_stderr(struct __pyx_obj PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("read_stderr", 0); - /* "ssh2/channel.pyx":144 + /* "ssh2/channel.pyx":160 * * :rtype: (int, bytes)""" * return self.read_ex( # <<<<<<<<<<<<<< @@ -2893,35 +3069,35 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_14read_stderr(struct __pyx_obj * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_ex); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_ex); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - /* "ssh2/channel.pyx":145 + /* "ssh2/channel.pyx":161 * :rtype: (int, bytes)""" * return self.read_ex( * size=size, stream_id=c_ssh2.SSH_EXTENDED_DATA_STDERR) # <<<<<<<<<<<<<< * * def eof(self): */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 145, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_size, __pyx_t_3) < 0) __PYX_ERR(0, 145, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_size, __pyx_t_3) < 0) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyInt_From_int(SSH_EXTENDED_DATA_STDERR); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 145, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(SSH_EXTENDED_DATA_STDERR); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_stream_id, __pyx_t_3) < 0) __PYX_ERR(0, 145, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_stream_id, __pyx_t_3) < 0) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "ssh2/channel.pyx":144 + /* "ssh2/channel.pyx":160 * * :rtype: (int, bytes)""" * return self.read_ex( # <<<<<<<<<<<<<< * size=size, stream_id=c_ssh2.SSH_EXTENDED_DATA_STDERR) * */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 144, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -2929,7 +3105,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_14read_stderr(struct __pyx_obj __pyx_t_3 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":136 + /* "ssh2/channel.pyx":152 * return rc, buf * * def read_stderr(self, size_t size=1024): # <<<<<<<<<<<<<< @@ -2950,7 +3126,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_14read_stderr(struct __pyx_obj return __pyx_r; } -/* "ssh2/channel.pyx":147 +/* "ssh2/channel.pyx":163 * size=size, stream_id=c_ssh2.SSH_EXTENDED_DATA_STDERR) * * def eof(self): # <<<<<<<<<<<<<< @@ -2980,7 +3156,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_16eof(struct __pyx_obj_4ssh2_7 int __pyx_t_2; __Pyx_RefNannySetupContext("eof", 0); - /* "ssh2/channel.pyx":152 + /* "ssh2/channel.pyx":168 * :rtype: bool""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -2995,7 +3171,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_16eof(struct __pyx_obj_4ssh2_7 #endif /*try:*/ { - /* "ssh2/channel.pyx":153 + /* "ssh2/channel.pyx":169 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_eof(self._channel) # <<<<<<<<<<<<<< @@ -3005,7 +3181,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_16eof(struct __pyx_obj_4ssh2_7 __pyx_v_rc = libssh2_channel_eof(__pyx_v_self->_channel); } - /* "ssh2/channel.pyx":152 + /* "ssh2/channel.pyx":168 * :rtype: bool""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3024,7 +3200,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_16eof(struct __pyx_obj_4ssh2_7 } } - /* "ssh2/channel.pyx":154 + /* "ssh2/channel.pyx":170 * with nogil: * rc = c_ssh2.libssh2_channel_eof(self._channel) * return bool(rc) # <<<<<<<<<<<<<< @@ -3032,17 +3208,17 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_16eof(struct __pyx_obj_4ssh2_7 * def send_eof(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyBool_FromLong((!(!__pyx_t_2))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyBool_FromLong((!(!__pyx_t_2))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":147 + /* "ssh2/channel.pyx":163 * size=size, stream_id=c_ssh2.SSH_EXTENDED_DATA_STDERR) * * def eof(self): # <<<<<<<<<<<<<< @@ -3061,7 +3237,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_16eof(struct __pyx_obj_4ssh2_7 return __pyx_r; } -/* "ssh2/channel.pyx":156 +/* "ssh2/channel.pyx":172 * return bool(rc) * * def send_eof(self): # <<<<<<<<<<<<<< @@ -3071,7 +3247,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_16eof(struct __pyx_obj_4ssh2_7 /* Python wrapper */ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_19send_eof(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_4ssh2_7channel_7Channel_18send_eof[] = "Channel.send_eof(self)\nTell the remote host that no further data will be sent on the\n specified channel. Processes typically interpret this as a closed stdin\n descriptor.\n\n Return 0 on success or negative on failure.\n It returns LIBSSH2_ERROR_EAGAIN when it would otherwise block.\n\n :rtype: int\n "; +static char __pyx_doc_4ssh2_7channel_7Channel_18send_eof[] = "Channel.send_eof(self)\nTell the remote host that no further data will be sent on the\n specified channel. Processes typically interpret this as a closed stdin\n descriptor.\n\n Returns 0 on success or negative on failure.\n It returns ``LIBSSH2_ERROR_EAGAIN`` when it would otherwise block.\n\n :rtype: int\n "; static PyObject *__pyx_pw_4ssh2_7channel_7Channel_19send_eof(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -3090,7 +3266,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_18send_eof(struct __pyx_obj_4s PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("send_eof", 0); - /* "ssh2/channel.pyx":167 + /* "ssh2/channel.pyx":183 * """ * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3105,7 +3281,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_18send_eof(struct __pyx_obj_4s #endif /*try:*/ { - /* "ssh2/channel.pyx":168 + /* "ssh2/channel.pyx":184 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_send_eof(self._channel) # <<<<<<<<<<<<<< @@ -3115,7 +3291,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_18send_eof(struct __pyx_obj_4s __pyx_v_rc = libssh2_channel_send_eof(__pyx_v_self->_channel); } - /* "ssh2/channel.pyx":167 + /* "ssh2/channel.pyx":183 * """ * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3134,7 +3310,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_18send_eof(struct __pyx_obj_4s } } - /* "ssh2/channel.pyx":169 + /* "ssh2/channel.pyx":185 * with nogil: * rc = c_ssh2.libssh2_channel_send_eof(self._channel) * return rc # <<<<<<<<<<<<<< @@ -3142,13 +3318,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_18send_eof(struct __pyx_obj_4s * def wait_eof(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":156 + /* "ssh2/channel.pyx":172 * return bool(rc) * * def send_eof(self): # <<<<<<<<<<<<<< @@ -3167,17 +3343,17 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_18send_eof(struct __pyx_obj_4s return __pyx_r; } -/* "ssh2/channel.pyx":171 +/* "ssh2/channel.pyx":187 * return rc * * def wait_eof(self): # <<<<<<<<<<<<<< - * """Wait for the remote end to acknowledge an EOF request + * """Wait for the remote end to acknowledge an EOF request. * */ /* Python wrapper */ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_21wait_eof(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_4ssh2_7channel_7Channel_20wait_eof[] = "Channel.wait_eof(self)\nWait for the remote end to acknowledge an EOF request\n\n Return 0 on success or negative on failure. It returns\n :py:class:`ssh2.error_codes.LIBSSH2_ERROR_EAGAIN` when it\n would otherwise block.\n\n :rtype: int\n "; +static char __pyx_doc_4ssh2_7channel_7Channel_20wait_eof[] = "Channel.wait_eof(self)\nWait for the remote end to acknowledge an EOF request.\n\n Returns 0 on success or negative on failure. It returns\n :py:class:`ssh2.error_codes.LIBSSH2_ERROR_EAGAIN` when it\n would otherwise block.\n\n :rtype: int\n "; static PyObject *__pyx_pw_4ssh2_7channel_7Channel_21wait_eof(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -3196,7 +3372,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_20wait_eof(struct __pyx_obj_4s PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("wait_eof", 0); - /* "ssh2/channel.pyx":181 + /* "ssh2/channel.pyx":197 * """ * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3211,7 +3387,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_20wait_eof(struct __pyx_obj_4s #endif /*try:*/ { - /* "ssh2/channel.pyx":182 + /* "ssh2/channel.pyx":198 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_wait_eof(self._channel) # <<<<<<<<<<<<<< @@ -3221,7 +3397,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_20wait_eof(struct __pyx_obj_4s __pyx_v_rc = libssh2_channel_wait_eof(__pyx_v_self->_channel); } - /* "ssh2/channel.pyx":181 + /* "ssh2/channel.pyx":197 * """ * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3240,7 +3416,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_20wait_eof(struct __pyx_obj_4s } } - /* "ssh2/channel.pyx":183 + /* "ssh2/channel.pyx":199 * with nogil: * rc = c_ssh2.libssh2_channel_wait_eof(self._channel) * return rc # <<<<<<<<<<<<<< @@ -3248,17 +3424,17 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_20wait_eof(struct __pyx_obj_4s * def close(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":171 + /* "ssh2/channel.pyx":187 * return rc * * def wait_eof(self): # <<<<<<<<<<<<<< - * """Wait for the remote end to acknowledge an EOF request + * """Wait for the remote end to acknowledge an EOF request. * */ @@ -3273,7 +3449,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_20wait_eof(struct __pyx_obj_4s return __pyx_r; } -/* "ssh2/channel.pyx":185 +/* "ssh2/channel.pyx":201 * return rc * * def close(self): # <<<<<<<<<<<<<< @@ -3302,7 +3478,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_22close(struct __pyx_obj_4ssh2 PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("close", 0); - /* "ssh2/channel.pyx":188 + /* "ssh2/channel.pyx":204 * """Close channel. Typically done to be able to get exit status.""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3317,7 +3493,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_22close(struct __pyx_obj_4ssh2 #endif /*try:*/ { - /* "ssh2/channel.pyx":189 + /* "ssh2/channel.pyx":205 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_close(self._channel) # <<<<<<<<<<<<<< @@ -3327,7 +3503,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_22close(struct __pyx_obj_4ssh2 __pyx_v_rc = libssh2_channel_close(__pyx_v_self->_channel); } - /* "ssh2/channel.pyx":188 + /* "ssh2/channel.pyx":204 * """Close channel. Typically done to be able to get exit status.""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3346,7 +3522,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_22close(struct __pyx_obj_4ssh2 } } - /* "ssh2/channel.pyx":190 + /* "ssh2/channel.pyx":206 * with nogil: * rc = c_ssh2.libssh2_channel_close(self._channel) * return rc # <<<<<<<<<<<<<< @@ -3354,13 +3530,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_22close(struct __pyx_obj_4ssh2 * def flush(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":185 + /* "ssh2/channel.pyx":201 * return rc * * def close(self): # <<<<<<<<<<<<<< @@ -3379,7 +3555,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_22close(struct __pyx_obj_4ssh2 return __pyx_r; } -/* "ssh2/channel.pyx":192 +/* "ssh2/channel.pyx":208 * return rc * * def flush(self): # <<<<<<<<<<<<<< @@ -3408,7 +3584,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_24flush(struct __pyx_obj_4ssh2 PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("flush", 0); - /* "ssh2/channel.pyx":195 + /* "ssh2/channel.pyx":211 * """Flush stdout stream""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3423,7 +3599,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_24flush(struct __pyx_obj_4ssh2 #endif /*try:*/ { - /* "ssh2/channel.pyx":196 + /* "ssh2/channel.pyx":212 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_flush(self._channel) # <<<<<<<<<<<<<< @@ -3433,7 +3609,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_24flush(struct __pyx_obj_4ssh2 __pyx_v_rc = libssh2_channel_flush(__pyx_v_self->_channel); } - /* "ssh2/channel.pyx":195 + /* "ssh2/channel.pyx":211 * """Flush stdout stream""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3452,7 +3628,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_24flush(struct __pyx_obj_4ssh2 } } - /* "ssh2/channel.pyx":197 + /* "ssh2/channel.pyx":213 * with nogil: * rc = c_ssh2.libssh2_channel_flush(self._channel) * return rc # <<<<<<<<<<<<<< @@ -3460,13 +3636,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_24flush(struct __pyx_obj_4ssh2 * def flush_ex(self, int stream_id): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":192 + /* "ssh2/channel.pyx":208 * return rc * * def flush(self): # <<<<<<<<<<<<<< @@ -3485,7 +3661,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_24flush(struct __pyx_obj_4ssh2 return __pyx_r; } -/* "ssh2/channel.pyx":199 +/* "ssh2/channel.pyx":215 * return rc * * def flush_ex(self, int stream_id): # <<<<<<<<<<<<<< @@ -3502,7 +3678,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_27flush_ex(PyObject *__pyx_v_s __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("flush_ex (wrapper)", 0); assert(__pyx_arg_stream_id); { - __pyx_v_stream_id = __Pyx_PyInt_As_int(__pyx_arg_stream_id); if (unlikely((__pyx_v_stream_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 199, __pyx_L3_error) + __pyx_v_stream_id = __Pyx_PyInt_As_int(__pyx_arg_stream_id); if (unlikely((__pyx_v_stream_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -3524,7 +3700,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_26flush_ex(struct __pyx_obj_4s PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("flush_ex", 0); - /* "ssh2/channel.pyx":202 + /* "ssh2/channel.pyx":218 * """Flush stream with id""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3539,7 +3715,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_26flush_ex(struct __pyx_obj_4s #endif /*try:*/ { - /* "ssh2/channel.pyx":203 + /* "ssh2/channel.pyx":219 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_flush_ex(self._channel, stream_id) # <<<<<<<<<<<<<< @@ -3549,7 +3725,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_26flush_ex(struct __pyx_obj_4s __pyx_v_rc = libssh2_channel_flush_ex(__pyx_v_self->_channel, __pyx_v_stream_id); } - /* "ssh2/channel.pyx":202 + /* "ssh2/channel.pyx":218 * """Flush stream with id""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3568,7 +3744,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_26flush_ex(struct __pyx_obj_4s } } - /* "ssh2/channel.pyx":204 + /* "ssh2/channel.pyx":220 * with nogil: * rc = c_ssh2.libssh2_channel_flush_ex(self._channel, stream_id) * return rc # <<<<<<<<<<<<<< @@ -3576,13 +3752,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_26flush_ex(struct __pyx_obj_4s * def flush_stderr(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 220, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":199 + /* "ssh2/channel.pyx":215 * return rc * * def flush_ex(self, int stream_id): # <<<<<<<<<<<<<< @@ -3601,7 +3777,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_26flush_ex(struct __pyx_obj_4s return __pyx_r; } -/* "ssh2/channel.pyx":206 +/* "ssh2/channel.pyx":222 * return rc * * def flush_stderr(self): # <<<<<<<<<<<<<< @@ -3630,7 +3806,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_28flush_stderr(struct __pyx_ob PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("flush_stderr", 0); - /* "ssh2/channel.pyx":209 + /* "ssh2/channel.pyx":225 * """Flush stderr stream""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3645,7 +3821,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_28flush_stderr(struct __pyx_ob #endif /*try:*/ { - /* "ssh2/channel.pyx":210 + /* "ssh2/channel.pyx":226 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_flush_stderr(self._channel) # <<<<<<<<<<<<<< @@ -3655,7 +3831,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_28flush_stderr(struct __pyx_ob __pyx_v_rc = libssh2_channel_flush_stderr(__pyx_v_self->_channel); } - /* "ssh2/channel.pyx":209 + /* "ssh2/channel.pyx":225 * """Flush stderr stream""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3674,7 +3850,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_28flush_stderr(struct __pyx_ob } } - /* "ssh2/channel.pyx":211 + /* "ssh2/channel.pyx":227 * with nogil: * rc = c_ssh2.libssh2_channel_flush_stderr(self._channel) * return rc # <<<<<<<<<<<<<< @@ -3682,13 +3858,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_28flush_stderr(struct __pyx_ob * def wait_closed(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 227, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":206 + /* "ssh2/channel.pyx":222 * return rc * * def flush_stderr(self): # <<<<<<<<<<<<<< @@ -3707,7 +3883,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_28flush_stderr(struct __pyx_ob return __pyx_r; } -/* "ssh2/channel.pyx":213 +/* "ssh2/channel.pyx":229 * return rc * * def wait_closed(self): # <<<<<<<<<<<<<< @@ -3736,7 +3912,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_30wait_closed(struct __pyx_obj PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("wait_closed", 0); - /* "ssh2/channel.pyx":216 + /* "ssh2/channel.pyx":232 * """Wait for server to acknowledge channel close command.""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3751,7 +3927,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_30wait_closed(struct __pyx_obj #endif /*try:*/ { - /* "ssh2/channel.pyx":217 + /* "ssh2/channel.pyx":233 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_wait_closed(self._channel) # <<<<<<<<<<<<<< @@ -3761,7 +3937,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_30wait_closed(struct __pyx_obj __pyx_v_rc = libssh2_channel_wait_closed(__pyx_v_self->_channel); } - /* "ssh2/channel.pyx":216 + /* "ssh2/channel.pyx":232 * """Wait for server to acknowledge channel close command.""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3780,7 +3956,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_30wait_closed(struct __pyx_obj } } - /* "ssh2/channel.pyx":218 + /* "ssh2/channel.pyx":234 * with nogil: * rc = c_ssh2.libssh2_channel_wait_closed(self._channel) * return rc # <<<<<<<<<<<<<< @@ -3788,13 +3964,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_30wait_closed(struct __pyx_obj * def get_exit_status(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 234, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":213 + /* "ssh2/channel.pyx":229 * return rc * * def wait_closed(self): # <<<<<<<<<<<<<< @@ -3813,7 +3989,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_30wait_closed(struct __pyx_obj return __pyx_r; } -/* "ssh2/channel.pyx":220 +/* "ssh2/channel.pyx":236 * return rc * * def get_exit_status(self): # <<<<<<<<<<<<<< @@ -3842,7 +4018,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_32get_exit_status(struct __pyx PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("get_exit_status", 0); - /* "ssh2/channel.pyx":228 + /* "ssh2/channel.pyx":244 * ``0`` indicates failure or an actual exit status of ``0``""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3857,7 +4033,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_32get_exit_status(struct __pyx #endif /*try:*/ { - /* "ssh2/channel.pyx":229 + /* "ssh2/channel.pyx":245 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_get_exit_status(self._channel) # <<<<<<<<<<<<<< @@ -3867,7 +4043,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_32get_exit_status(struct __pyx __pyx_v_rc = libssh2_channel_get_exit_status(__pyx_v_self->_channel); } - /* "ssh2/channel.pyx":228 + /* "ssh2/channel.pyx":244 * ``0`` indicates failure or an actual exit status of ``0``""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -3886,7 +4062,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_32get_exit_status(struct __pyx } } - /* "ssh2/channel.pyx":230 + /* "ssh2/channel.pyx":246 * with nogil: * rc = c_ssh2.libssh2_channel_get_exit_status(self._channel) * return rc # <<<<<<<<<<<<<< @@ -3894,13 +4070,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_32get_exit_status(struct __pyx * def get_exit_signal(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":220 + /* "ssh2/channel.pyx":236 * return rc * * def get_exit_status(self): # <<<<<<<<<<<<<< @@ -3919,7 +4095,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_32get_exit_status(struct __pyx return __pyx_r; } -/* "ssh2/channel.pyx":232 +/* "ssh2/channel.pyx":248 * return rc * * def get_exit_signal(self): # <<<<<<<<<<<<<< @@ -3962,7 +4138,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("get_exit_signal", 0); - /* "ssh2/channel.pyx":238 + /* "ssh2/channel.pyx":254 * * :rtype: tuple(int, bytes, bytes, bytes)""" * cdef char *exitsignal = b'none' # <<<<<<<<<<<<<< @@ -3971,7 +4147,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ __pyx_v_exitsignal = ((char *)((char *)"none")); - /* "ssh2/channel.pyx":239 + /* "ssh2/channel.pyx":255 * :rtype: tuple(int, bytes, bytes, bytes)""" * cdef char *exitsignal = b'none' * cdef size_t *exitsignal_len = 0 # <<<<<<<<<<<<<< @@ -3980,7 +4156,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ __pyx_v_exitsignal_len = ((size_t *)0); - /* "ssh2/channel.pyx":240 + /* "ssh2/channel.pyx":256 * cdef char *exitsignal = b'none' * cdef size_t *exitsignal_len = 0 * cdef char *errmsg = b'none' # <<<<<<<<<<<<<< @@ -3989,7 +4165,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ __pyx_v_errmsg = ((char *)((char *)"none")); - /* "ssh2/channel.pyx":241 + /* "ssh2/channel.pyx":257 * cdef size_t *exitsignal_len = 0 * cdef char *errmsg = b'none' * cdef size_t *errmsg_len = 0 # <<<<<<<<<<<<<< @@ -3998,7 +4174,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ __pyx_v_errmsg_len = ((size_t *)0); - /* "ssh2/channel.pyx":242 + /* "ssh2/channel.pyx":258 * cdef char *errmsg = b'none' * cdef size_t *errmsg_len = 0 * cdef char *langtag = b'none' # <<<<<<<<<<<<<< @@ -4007,7 +4183,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ __pyx_v_langtag = ((char *)((char *)"none")); - /* "ssh2/channel.pyx":243 + /* "ssh2/channel.pyx":259 * cdef size_t *errmsg_len = 0 * cdef char *langtag = b'none' * cdef size_t *langtag_len = 0 # <<<<<<<<<<<<<< @@ -4016,7 +4192,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ __pyx_v_langtag_len = ((size_t *)0); - /* "ssh2/channel.pyx":245 + /* "ssh2/channel.pyx":261 * cdef size_t *langtag_len = 0 * cdef int rc * cdef bytes py_exitsignal = None # <<<<<<<<<<<<<< @@ -4026,7 +4202,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx __Pyx_INCREF(Py_None); __pyx_v_py_exitsignal = ((PyObject*)Py_None); - /* "ssh2/channel.pyx":246 + /* "ssh2/channel.pyx":262 * cdef int rc * cdef bytes py_exitsignal = None * cdef bytes py_errmsg = None # <<<<<<<<<<<<<< @@ -4036,7 +4212,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx __Pyx_INCREF(Py_None); __pyx_v_py_errmsg = ((PyObject*)Py_None); - /* "ssh2/channel.pyx":247 + /* "ssh2/channel.pyx":263 * cdef bytes py_exitsignal = None * cdef bytes py_errmsg = None * cdef bytes py_langtag = None # <<<<<<<<<<<<<< @@ -4046,7 +4222,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx __Pyx_INCREF(Py_None); __pyx_v_py_langtag = ((PyObject*)Py_None); - /* "ssh2/channel.pyx":248 + /* "ssh2/channel.pyx":264 * cdef bytes py_errmsg = None * cdef bytes py_langtag = None * cdef size_t py_siglen = 0 # <<<<<<<<<<<<<< @@ -4055,7 +4231,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ __pyx_v_py_siglen = 0; - /* "ssh2/channel.pyx":249 + /* "ssh2/channel.pyx":265 * cdef bytes py_langtag = None * cdef size_t py_siglen = 0 * cdef size_t py_errlen = 0 # <<<<<<<<<<<<<< @@ -4064,7 +4240,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ __pyx_v_py_errlen = 0; - /* "ssh2/channel.pyx":250 + /* "ssh2/channel.pyx":266 * cdef size_t py_siglen = 0 * cdef size_t py_errlen = 0 * cdef size_t py_langlen = 0 # <<<<<<<<<<<<<< @@ -4073,7 +4249,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ __pyx_v_py_langlen = 0; - /* "ssh2/channel.pyx":251 + /* "ssh2/channel.pyx":267 * cdef size_t py_errlen = 0 * cdef size_t py_langlen = 0 * with nogil: # <<<<<<<<<<<<<< @@ -4088,7 +4264,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx #endif /*try:*/ { - /* "ssh2/channel.pyx":252 + /* "ssh2/channel.pyx":268 * cdef size_t py_langlen = 0 * with nogil: * rc = c_ssh2.libssh2_channel_get_exit_signal( # <<<<<<<<<<<<<< @@ -4097,7 +4273,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ __pyx_v_rc = libssh2_channel_get_exit_signal(__pyx_v_self->_channel, (&__pyx_v_exitsignal), __pyx_v_exitsignal_len, (&__pyx_v_errmsg), __pyx_v_errmsg_len, (&__pyx_v_langtag), __pyx_v_langtag_len); - /* "ssh2/channel.pyx":255 + /* "ssh2/channel.pyx":271 * self._channel, &exitsignal, exitsignal_len, &errmsg, * errmsg_len, &langtag, langtag_len) * if exitsignal_len is not NULL: # <<<<<<<<<<<<<< @@ -4107,7 +4283,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx __pyx_t_1 = ((__pyx_v_exitsignal_len != NULL) != 0); if (__pyx_t_1) { - /* "ssh2/channel.pyx":256 + /* "ssh2/channel.pyx":272 * errmsg_len, &langtag, langtag_len) * if exitsignal_len is not NULL: * py_siglen = exitsignal_len # <<<<<<<<<<<<<< @@ -4116,7 +4292,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ __pyx_v_py_siglen = ((size_t)__pyx_v_exitsignal_len); - /* "ssh2/channel.pyx":255 + /* "ssh2/channel.pyx":271 * self._channel, &exitsignal, exitsignal_len, &errmsg, * errmsg_len, &langtag, langtag_len) * if exitsignal_len is not NULL: # <<<<<<<<<<<<<< @@ -4125,7 +4301,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ } - /* "ssh2/channel.pyx":257 + /* "ssh2/channel.pyx":273 * if exitsignal_len is not NULL: * py_siglen = exitsignal_len * if errmsg_len is not NULL: # <<<<<<<<<<<<<< @@ -4135,7 +4311,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx __pyx_t_1 = ((__pyx_v_errmsg_len != NULL) != 0); if (__pyx_t_1) { - /* "ssh2/channel.pyx":258 + /* "ssh2/channel.pyx":274 * py_siglen = exitsignal_len * if errmsg_len is not NULL: * py_errlen = errmsg_len # <<<<<<<<<<<<<< @@ -4144,7 +4320,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ __pyx_v_py_errlen = ((size_t)__pyx_v_errmsg_len); - /* "ssh2/channel.pyx":257 + /* "ssh2/channel.pyx":273 * if exitsignal_len is not NULL: * py_siglen = exitsignal_len * if errmsg_len is not NULL: # <<<<<<<<<<<<<< @@ -4153,7 +4329,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ } - /* "ssh2/channel.pyx":259 + /* "ssh2/channel.pyx":275 * if errmsg_len is not NULL: * py_errlen = errmsg_len * if langtag_len is not NULL: # <<<<<<<<<<<<<< @@ -4163,7 +4339,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx __pyx_t_1 = ((__pyx_v_langtag_len != NULL) != 0); if (__pyx_t_1) { - /* "ssh2/channel.pyx":260 + /* "ssh2/channel.pyx":276 * py_errlen = errmsg_len * if langtag_len is not NULL: * py_langlen = langtag_len # <<<<<<<<<<<<<< @@ -4172,7 +4348,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ __pyx_v_py_langlen = ((size_t)__pyx_v_langtag_len); - /* "ssh2/channel.pyx":259 + /* "ssh2/channel.pyx":275 * if errmsg_len is not NULL: * py_errlen = errmsg_len * if langtag_len is not NULL: # <<<<<<<<<<<<<< @@ -4182,7 +4358,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx } } - /* "ssh2/channel.pyx":251 + /* "ssh2/channel.pyx":267 * cdef size_t py_errlen = 0 * cdef size_t py_langlen = 0 * with nogil: # <<<<<<<<<<<<<< @@ -4201,7 +4377,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx } } - /* "ssh2/channel.pyx":261 + /* "ssh2/channel.pyx":277 * if langtag_len is not NULL: * py_langlen = langtag_len * if py_siglen > 0: # <<<<<<<<<<<<<< @@ -4211,19 +4387,19 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx __pyx_t_1 = ((__pyx_v_py_siglen > 0) != 0); if (__pyx_t_1) { - /* "ssh2/channel.pyx":262 + /* "ssh2/channel.pyx":278 * py_langlen = langtag_len * if py_siglen > 0: * py_exitsignal = exitsignal[:py_siglen] # <<<<<<<<<<<<<< * if py_errlen > 0: * py_errmsg = errmsg[:py_errlen] */ - __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_exitsignal + 0, __pyx_v_py_siglen - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 262, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_exitsignal + 0, __pyx_v_py_siglen - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_py_exitsignal, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0; - /* "ssh2/channel.pyx":261 + /* "ssh2/channel.pyx":277 * if langtag_len is not NULL: * py_langlen = langtag_len * if py_siglen > 0: # <<<<<<<<<<<<<< @@ -4232,7 +4408,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ } - /* "ssh2/channel.pyx":263 + /* "ssh2/channel.pyx":279 * if py_siglen > 0: * py_exitsignal = exitsignal[:py_siglen] * if py_errlen > 0: # <<<<<<<<<<<<<< @@ -4242,19 +4418,19 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx __pyx_t_1 = ((__pyx_v_py_errlen > 0) != 0); if (__pyx_t_1) { - /* "ssh2/channel.pyx":264 + /* "ssh2/channel.pyx":280 * py_exitsignal = exitsignal[:py_siglen] * if py_errlen > 0: * py_errmsg = errmsg[:py_errlen] # <<<<<<<<<<<<<< * if py_langlen > 0: * py_langtag = langtag[:py_langlen] */ - __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_errmsg + 0, __pyx_v_py_errlen - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_errmsg + 0, __pyx_v_py_errlen - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_py_errmsg, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0; - /* "ssh2/channel.pyx":263 + /* "ssh2/channel.pyx":279 * if py_siglen > 0: * py_exitsignal = exitsignal[:py_siglen] * if py_errlen > 0: # <<<<<<<<<<<<<< @@ -4263,7 +4439,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ } - /* "ssh2/channel.pyx":265 + /* "ssh2/channel.pyx":281 * if py_errlen > 0: * py_errmsg = errmsg[:py_errlen] * if py_langlen > 0: # <<<<<<<<<<<<<< @@ -4273,19 +4449,19 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx __pyx_t_1 = ((__pyx_v_py_langlen > 0) != 0); if (__pyx_t_1) { - /* "ssh2/channel.pyx":266 + /* "ssh2/channel.pyx":282 * py_errmsg = errmsg[:py_errlen] * if py_langlen > 0: * py_langtag = langtag[:py_langlen] # <<<<<<<<<<<<<< * return rc, py_exitsignal, py_errmsg, py_langtag * */ - __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_langtag + 0, __pyx_v_py_langlen - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 266, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_langtag + 0, __pyx_v_py_langlen - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_py_langtag, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0; - /* "ssh2/channel.pyx":265 + /* "ssh2/channel.pyx":281 * if py_errlen > 0: * py_errmsg = errmsg[:py_errlen] * if py_langlen > 0: # <<<<<<<<<<<<<< @@ -4294,7 +4470,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx */ } - /* "ssh2/channel.pyx":267 + /* "ssh2/channel.pyx":283 * if py_langlen > 0: * py_langtag = langtag[:py_langlen] * return rc, py_exitsignal, py_errmsg, py_langtag # <<<<<<<<<<<<<< @@ -4302,9 +4478,9 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx * def setenv(self, varname not None, value not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); @@ -4322,7 +4498,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx __pyx_t_3 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":232 + /* "ssh2/channel.pyx":248 * return rc * * def get_exit_signal(self): # <<<<<<<<<<<<<< @@ -4345,7 +4521,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_34get_exit_signal(struct __pyx return __pyx_r; } -/* "ssh2/channel.pyx":269 +/* "ssh2/channel.pyx":285 * return rc, py_exitsignal, py_errmsg, py_langtag * * def setenv(self, varname not None, value not None): # <<<<<<<<<<<<<< @@ -4385,11 +4561,11 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_37setenv(PyObject *__pyx_v_sel case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("setenv", 1, 2, 2, 1); __PYX_ERR(0, 269, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("setenv", 1, 2, 2, 1); __PYX_ERR(0, 285, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "setenv") < 0)) __PYX_ERR(0, 269, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "setenv") < 0)) __PYX_ERR(0, 285, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -4402,17 +4578,17 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_37setenv(PyObject *__pyx_v_sel } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("setenv", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 269, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("setenv", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 285, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.channel.Channel.setenv", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_varname) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "varname"); __PYX_ERR(0, 269, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "varname"); __PYX_ERR(0, 285, __pyx_L1_error) } if (unlikely(((PyObject *)__pyx_v_value) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "value"); __PYX_ERR(0, 269, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "value"); __PYX_ERR(0, 285, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_36setenv(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self), __pyx_v_varname, __pyx_v_value); @@ -4437,51 +4613,59 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_36setenv(struct __pyx_obj_4ssh char *__pyx_t_2; __Pyx_RefNannySetupContext("setenv", 0); - /* "ssh2/channel.pyx":279 + /* "ssh2/channel.pyx":295 * :rtype: int""" * cdef int rc * cdef bytes b_varname = to_bytes(varname) # <<<<<<<<<<<<<< * cdef bytes b_value = to_bytes(value) * cdef char *_varname = b_varname */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_varname); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_varname); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_varname = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/channel.pyx":280 + /* "ssh2/channel.pyx":296 * cdef int rc * cdef bytes b_varname = to_bytes(varname) * cdef bytes b_value = to_bytes(value) # <<<<<<<<<<<<<< * cdef char *_varname = b_varname * cdef char *_value = b_value */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_value = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/channel.pyx":281 + /* "ssh2/channel.pyx":297 * cdef bytes b_varname = to_bytes(varname) * cdef bytes b_value = to_bytes(value) * cdef char *_varname = b_varname # <<<<<<<<<<<<<< * cdef char *_value = b_value * with nogil: */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_varname); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 281, __pyx_L1_error) + if (unlikely(__pyx_v_b_varname == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 297, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_varname); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 297, __pyx_L1_error) __pyx_v__varname = __pyx_t_2; - /* "ssh2/channel.pyx":282 + /* "ssh2/channel.pyx":298 * cdef bytes b_value = to_bytes(value) * cdef char *_varname = b_varname * cdef char *_value = b_value # <<<<<<<<<<<<<< * with nogil: * rc = c_ssh2.libssh2_channel_setenv( */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_value); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 282, __pyx_L1_error) + if (unlikely(__pyx_v_b_value == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 298, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_value); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 298, __pyx_L1_error) __pyx_v__value = __pyx_t_2; - /* "ssh2/channel.pyx":283 + /* "ssh2/channel.pyx":299 * cdef char *_varname = b_varname * cdef char *_value = b_value * with nogil: # <<<<<<<<<<<<<< @@ -4496,7 +4680,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_36setenv(struct __pyx_obj_4ssh #endif /*try:*/ { - /* "ssh2/channel.pyx":284 + /* "ssh2/channel.pyx":300 * cdef char *_value = b_value * with nogil: * rc = c_ssh2.libssh2_channel_setenv( # <<<<<<<<<<<<<< @@ -4506,7 +4690,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_36setenv(struct __pyx_obj_4ssh __pyx_v_rc = libssh2_channel_setenv(__pyx_v_self->_channel, __pyx_v__varname, __pyx_v__value); } - /* "ssh2/channel.pyx":283 + /* "ssh2/channel.pyx":299 * cdef char *_varname = b_varname * cdef char *_value = b_value * with nogil: # <<<<<<<<<<<<<< @@ -4525,7 +4709,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_36setenv(struct __pyx_obj_4ssh } } - /* "ssh2/channel.pyx":286 + /* "ssh2/channel.pyx":302 * rc = c_ssh2.libssh2_channel_setenv( * self._channel, _varname, _value) * return rc # <<<<<<<<<<<<<< @@ -4533,13 +4717,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_36setenv(struct __pyx_obj_4ssh * def window_read_ex(self, unsigned long read_avail, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":269 + /* "ssh2/channel.pyx":285 * return rc, py_exitsignal, py_errmsg, py_langtag * * def setenv(self, varname not None, value not None): # <<<<<<<<<<<<<< @@ -4560,7 +4744,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_36setenv(struct __pyx_obj_4ssh return __pyx_r; } -/* "ssh2/channel.pyx":288 +/* "ssh2/channel.pyx":304 * return rc * * def window_read_ex(self, unsigned long read_avail, # <<<<<<<<<<<<<< @@ -4600,11 +4784,11 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_39window_read_ex(PyObject *__p case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_window_size_initial)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("window_read_ex", 1, 2, 2, 1); __PYX_ERR(0, 288, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("window_read_ex", 1, 2, 2, 1); __PYX_ERR(0, 304, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "window_read_ex") < 0)) __PYX_ERR(0, 288, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "window_read_ex") < 0)) __PYX_ERR(0, 304, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -4612,12 +4796,12 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_39window_read_ex(PyObject *__p values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } - __pyx_v_read_avail = __Pyx_PyInt_As_unsigned_long(values[0]); if (unlikely((__pyx_v_read_avail == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 288, __pyx_L3_error) - __pyx_v_window_size_initial = __Pyx_PyInt_As_unsigned_long(values[1]); if (unlikely((__pyx_v_window_size_initial == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 289, __pyx_L3_error) + __pyx_v_read_avail = __Pyx_PyInt_As_unsigned_long(values[0]); if (unlikely((__pyx_v_read_avail == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 304, __pyx_L3_error) + __pyx_v_window_size_initial = __Pyx_PyInt_As_unsigned_long(values[1]); if (unlikely((__pyx_v_window_size_initial == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 305, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("window_read_ex", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 288, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("window_read_ex", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 304, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.channel.Channel.window_read_ex", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -4637,7 +4821,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_38window_read_ex(struct __pyx_ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("window_read_ex", 0); - /* "ssh2/channel.pyx":291 + /* "ssh2/channel.pyx":307 * unsigned long window_size_initial): * cdef unsigned long rc * with nogil: # <<<<<<<<<<<<<< @@ -4652,7 +4836,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_38window_read_ex(struct __pyx_ #endif /*try:*/ { - /* "ssh2/channel.pyx":292 + /* "ssh2/channel.pyx":308 * cdef unsigned long rc * with nogil: * rc = c_ssh2.libssh2_channel_window_read_ex( # <<<<<<<<<<<<<< @@ -4662,7 +4846,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_38window_read_ex(struct __pyx_ __pyx_v_rc = libssh2_channel_window_read_ex(__pyx_v_self->_channel, (&__pyx_v_read_avail), (&__pyx_v_window_size_initial)); } - /* "ssh2/channel.pyx":291 + /* "ssh2/channel.pyx":307 * unsigned long window_size_initial): * cdef unsigned long rc * with nogil: # <<<<<<<<<<<<<< @@ -4681,7 +4865,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_38window_read_ex(struct __pyx_ } } - /* "ssh2/channel.pyx":294 + /* "ssh2/channel.pyx":310 * rc = c_ssh2.libssh2_channel_window_read_ex( * self._channel, &read_avail, &window_size_initial) * return rc # <<<<<<<<<<<<<< @@ -4689,13 +4873,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_38window_read_ex(struct __pyx_ * def window_read(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":288 + /* "ssh2/channel.pyx":304 * return rc * * def window_read_ex(self, unsigned long read_avail, # <<<<<<<<<<<<<< @@ -4714,7 +4898,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_38window_read_ex(struct __pyx_ return __pyx_r; } -/* "ssh2/channel.pyx":296 +/* "ssh2/channel.pyx":312 * return rc * * def window_read(self): # <<<<<<<<<<<<<< @@ -4743,7 +4927,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_40window_read(struct __pyx_obj PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("window_read", 0); - /* "ssh2/channel.pyx":298 + /* "ssh2/channel.pyx":314 * def window_read(self): * cdef unsigned long rc * with nogil: # <<<<<<<<<<<<<< @@ -4758,7 +4942,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_40window_read(struct __pyx_obj #endif /*try:*/ { - /* "ssh2/channel.pyx":299 + /* "ssh2/channel.pyx":315 * cdef unsigned long rc * with nogil: * rc = c_ssh2.libssh2_channel_window_read(self._channel) # <<<<<<<<<<<<<< @@ -4768,7 +4952,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_40window_read(struct __pyx_obj __pyx_v_rc = libssh2_channel_window_read(__pyx_v_self->_channel); } - /* "ssh2/channel.pyx":298 + /* "ssh2/channel.pyx":314 * def window_read(self): * cdef unsigned long rc * with nogil: # <<<<<<<<<<<<<< @@ -4787,7 +4971,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_40window_read(struct __pyx_obj } } - /* "ssh2/channel.pyx":300 + /* "ssh2/channel.pyx":316 * with nogil: * rc = c_ssh2.libssh2_channel_window_read(self._channel) * return rc # <<<<<<<<<<<<<< @@ -4795,13 +4979,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_40window_read(struct __pyx_obj * def window_write_ex(self, unsigned long window_size_initial): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":296 + /* "ssh2/channel.pyx":312 * return rc * * def window_read(self): # <<<<<<<<<<<<<< @@ -4820,7 +5004,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_40window_read(struct __pyx_obj return __pyx_r; } -/* "ssh2/channel.pyx":302 +/* "ssh2/channel.pyx":318 * return rc * * def window_write_ex(self, unsigned long window_size_initial): # <<<<<<<<<<<<<< @@ -4837,7 +5021,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_43window_write_ex(PyObject *__ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("window_write_ex (wrapper)", 0); assert(__pyx_arg_window_size_initial); { - __pyx_v_window_size_initial = __Pyx_PyInt_As_unsigned_long(__pyx_arg_window_size_initial); if (unlikely((__pyx_v_window_size_initial == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 302, __pyx_L3_error) + __pyx_v_window_size_initial = __Pyx_PyInt_As_unsigned_long(__pyx_arg_window_size_initial); if (unlikely((__pyx_v_window_size_initial == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 318, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -4859,7 +5043,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_42window_write_ex(struct __pyx PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("window_write_ex", 0); - /* "ssh2/channel.pyx":304 + /* "ssh2/channel.pyx":320 * def window_write_ex(self, unsigned long window_size_initial): * cdef unsigned long rc * with nogil: # <<<<<<<<<<<<<< @@ -4874,7 +5058,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_42window_write_ex(struct __pyx #endif /*try:*/ { - /* "ssh2/channel.pyx":305 + /* "ssh2/channel.pyx":321 * cdef unsigned long rc * with nogil: * rc = c_ssh2.libssh2_channel_window_write_ex( # <<<<<<<<<<<<<< @@ -4884,7 +5068,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_42window_write_ex(struct __pyx __pyx_v_rc = libssh2_channel_window_write_ex(__pyx_v_self->_channel, (&__pyx_v_window_size_initial)); } - /* "ssh2/channel.pyx":304 + /* "ssh2/channel.pyx":320 * def window_write_ex(self, unsigned long window_size_initial): * cdef unsigned long rc * with nogil: # <<<<<<<<<<<<<< @@ -4903,7 +5087,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_42window_write_ex(struct __pyx } } - /* "ssh2/channel.pyx":307 + /* "ssh2/channel.pyx":323 * rc = c_ssh2.libssh2_channel_window_write_ex( * self._channel, &window_size_initial) * return rc # <<<<<<<<<<<<<< @@ -4911,13 +5095,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_42window_write_ex(struct __pyx * def window_write(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":302 + /* "ssh2/channel.pyx":318 * return rc * * def window_write_ex(self, unsigned long window_size_initial): # <<<<<<<<<<<<<< @@ -4936,7 +5120,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_42window_write_ex(struct __pyx return __pyx_r; } -/* "ssh2/channel.pyx":309 +/* "ssh2/channel.pyx":325 * return rc * * def window_write(self): # <<<<<<<<<<<<<< @@ -4965,7 +5149,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_44window_write(struct __pyx_ob PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("window_write", 0); - /* "ssh2/channel.pyx":311 + /* "ssh2/channel.pyx":327 * def window_write(self): * cdef unsigned long rc * with nogil: # <<<<<<<<<<<<<< @@ -4980,7 +5164,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_44window_write(struct __pyx_ob #endif /*try:*/ { - /* "ssh2/channel.pyx":312 + /* "ssh2/channel.pyx":328 * cdef unsigned long rc * with nogil: * rc = c_ssh2.libssh2_channel_window_write(self._channel) # <<<<<<<<<<<<<< @@ -4990,7 +5174,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_44window_write(struct __pyx_ob __pyx_v_rc = libssh2_channel_window_write(__pyx_v_self->_channel); } - /* "ssh2/channel.pyx":311 + /* "ssh2/channel.pyx":327 * def window_write(self): * cdef unsigned long rc * with nogil: # <<<<<<<<<<<<<< @@ -5009,7 +5193,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_44window_write(struct __pyx_ob } } - /* "ssh2/channel.pyx":313 + /* "ssh2/channel.pyx":329 * with nogil: * rc = c_ssh2.libssh2_channel_window_write(self._channel) * return rc # <<<<<<<<<<<<<< @@ -5017,13 +5201,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_44window_write(struct __pyx_ob * def receive_window_adjust(self, unsigned long adjustment, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 329, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":309 + /* "ssh2/channel.pyx":325 * return rc * * def window_write(self): # <<<<<<<<<<<<<< @@ -5042,7 +5226,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_44window_write(struct __pyx_ob return __pyx_r; } -/* "ssh2/channel.pyx":315 +/* "ssh2/channel.pyx":331 * return rc * * def receive_window_adjust(self, unsigned long adjustment, # <<<<<<<<<<<<<< @@ -5082,11 +5266,11 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_47receive_window_adjust(PyObje case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_force)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("receive_window_adjust", 1, 2, 2, 1); __PYX_ERR(0, 315, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("receive_window_adjust", 1, 2, 2, 1); __PYX_ERR(0, 331, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "receive_window_adjust") < 0)) __PYX_ERR(0, 315, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "receive_window_adjust") < 0)) __PYX_ERR(0, 331, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -5094,12 +5278,12 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_47receive_window_adjust(PyObje values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } - __pyx_v_adjustment = __Pyx_PyInt_As_unsigned_long(values[0]); if (unlikely((__pyx_v_adjustment == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 315, __pyx_L3_error) - __pyx_v_force = __Pyx_PyInt_As_unsigned_long(values[1]); if (unlikely((__pyx_v_force == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 316, __pyx_L3_error) + __pyx_v_adjustment = __Pyx_PyInt_As_unsigned_long(values[0]); if (unlikely((__pyx_v_adjustment == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 331, __pyx_L3_error) + __pyx_v_force = __Pyx_PyInt_As_unsigned_long(values[1]); if (unlikely((__pyx_v_force == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 332, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("receive_window_adjust", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 315, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("receive_window_adjust", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 331, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.channel.Channel.receive_window_adjust", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -5119,7 +5303,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_46receive_window_adjust(struct PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("receive_window_adjust", 0); - /* "ssh2/channel.pyx":318 + /* "ssh2/channel.pyx":334 * unsigned long force): * cdef unsigned long rc * with nogil: # <<<<<<<<<<<<<< @@ -5134,7 +5318,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_46receive_window_adjust(struct #endif /*try:*/ { - /* "ssh2/channel.pyx":319 + /* "ssh2/channel.pyx":335 * cdef unsigned long rc * with nogil: * rc = c_ssh2.libssh2_channel_receive_window_adjust( # <<<<<<<<<<<<<< @@ -5144,7 +5328,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_46receive_window_adjust(struct __pyx_v_rc = libssh2_channel_receive_window_adjust(__pyx_v_self->_channel, __pyx_v_adjustment, __pyx_v_force); } - /* "ssh2/channel.pyx":318 + /* "ssh2/channel.pyx":334 * unsigned long force): * cdef unsigned long rc * with nogil: # <<<<<<<<<<<<<< @@ -5163,7 +5347,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_46receive_window_adjust(struct } } - /* "ssh2/channel.pyx":321 + /* "ssh2/channel.pyx":337 * rc = c_ssh2.libssh2_channel_receive_window_adjust( * self._channel, adjustment, force) * return rc # <<<<<<<<<<<<<< @@ -5171,13 +5355,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_46receive_window_adjust(struct * def receive_window_adjust2(self, unsigned long adjustment, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 321, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":315 + /* "ssh2/channel.pyx":331 * return rc * * def receive_window_adjust(self, unsigned long adjustment, # <<<<<<<<<<<<<< @@ -5196,7 +5380,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_46receive_window_adjust(struct return __pyx_r; } -/* "ssh2/channel.pyx":323 +/* "ssh2/channel.pyx":339 * return rc * * def receive_window_adjust2(self, unsigned long adjustment, # <<<<<<<<<<<<<< @@ -5236,11 +5420,11 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_49receive_window_adjust2(PyObj case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_force)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("receive_window_adjust2", 1, 2, 2, 1); __PYX_ERR(0, 323, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("receive_window_adjust2", 1, 2, 2, 1); __PYX_ERR(0, 339, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "receive_window_adjust2") < 0)) __PYX_ERR(0, 323, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "receive_window_adjust2") < 0)) __PYX_ERR(0, 339, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -5248,12 +5432,12 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_49receive_window_adjust2(PyObj values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } - __pyx_v_adjustment = __Pyx_PyInt_As_unsigned_long(values[0]); if (unlikely((__pyx_v_adjustment == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 323, __pyx_L3_error) - __pyx_v_force = __Pyx_PyInt_As_unsigned_long(values[1]); if (unlikely((__pyx_v_force == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 324, __pyx_L3_error) + __pyx_v_adjustment = __Pyx_PyInt_As_unsigned_long(values[0]); if (unlikely((__pyx_v_adjustment == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 339, __pyx_L3_error) + __pyx_v_force = __Pyx_PyInt_As_unsigned_long(values[1]); if (unlikely((__pyx_v_force == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 340, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("receive_window_adjust2", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 323, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("receive_window_adjust2", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 339, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.channel.Channel.receive_window_adjust2", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -5274,7 +5458,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_48receive_window_adjust2(struc PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("receive_window_adjust2", 0); - /* "ssh2/channel.pyx":326 + /* "ssh2/channel.pyx":342 * unsigned long force): * cdef unsigned long rc * cdef unsigned int storewindow = 0 # <<<<<<<<<<<<<< @@ -5283,7 +5467,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_48receive_window_adjust2(struc */ __pyx_v_storewindow = 0; - /* "ssh2/channel.pyx":327 + /* "ssh2/channel.pyx":343 * cdef unsigned long rc * cdef unsigned int storewindow = 0 * with nogil: # <<<<<<<<<<<<<< @@ -5298,7 +5482,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_48receive_window_adjust2(struc #endif /*try:*/ { - /* "ssh2/channel.pyx":328 + /* "ssh2/channel.pyx":344 * cdef unsigned int storewindow = 0 * with nogil: * rc = c_ssh2.libssh2_channel_receive_window_adjust2( # <<<<<<<<<<<<<< @@ -5308,7 +5492,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_48receive_window_adjust2(struc __pyx_v_rc = libssh2_channel_receive_window_adjust2(__pyx_v_self->_channel, __pyx_v_adjustment, __pyx_v_force, (&__pyx_v_storewindow)); } - /* "ssh2/channel.pyx":327 + /* "ssh2/channel.pyx":343 * cdef unsigned long rc * cdef unsigned int storewindow = 0 * with nogil: # <<<<<<<<<<<<<< @@ -5327,7 +5511,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_48receive_window_adjust2(struc } } - /* "ssh2/channel.pyx":330 + /* "ssh2/channel.pyx":346 * rc = c_ssh2.libssh2_channel_receive_window_adjust2( * self._channel, adjustment, force, &storewindow) * return rc # <<<<<<<<<<<<<< @@ -5335,13 +5519,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_48receive_window_adjust2(struc * def write(self, buf not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":323 + /* "ssh2/channel.pyx":339 * return rc * * def receive_window_adjust2(self, unsigned long adjustment, # <<<<<<<<<<<<<< @@ -5360,7 +5544,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_48receive_window_adjust2(struc return __pyx_r; } -/* "ssh2/channel.pyx":332 +/* "ssh2/channel.pyx":348 * return rc * * def write(self, buf not None): # <<<<<<<<<<<<<< @@ -5376,7 +5560,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_51write(PyObject *__pyx_v_self __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_buf) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "buf"); __PYX_ERR(0, 332, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "buf"); __PYX_ERR(0, 348, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_50write(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self), ((PyObject *)__pyx_v_buf)); @@ -5401,29 +5585,33 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_50write(struct __pyx_obj_4ssh2 Py_ssize_t __pyx_t_3; __Pyx_RefNannySetupContext("write", 0); - /* "ssh2/channel.pyx":339 + /* "ssh2/channel.pyx":355 * * :rtype: int""" * cdef bytes b_buf = to_bytes(buf) # <<<<<<<<<<<<<< * cdef const char *_buf = b_buf * cdef size_t buflen = len(b_buf) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 339, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_buf = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/channel.pyx":340 + /* "ssh2/channel.pyx":356 * :rtype: int""" * cdef bytes b_buf = to_bytes(buf) * cdef const char *_buf = b_buf # <<<<<<<<<<<<<< * cdef size_t buflen = len(b_buf) * cdef ssize_t rc */ - __pyx_t_2 = __Pyx_PyObject_AsString(__pyx_v_b_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 340, __pyx_L1_error) + if (unlikely(__pyx_v_b_buf == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 356, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 356, __pyx_L1_error) __pyx_v__buf = __pyx_t_2; - /* "ssh2/channel.pyx":341 + /* "ssh2/channel.pyx":357 * cdef bytes b_buf = to_bytes(buf) * cdef const char *_buf = b_buf * cdef size_t buflen = len(b_buf) # <<<<<<<<<<<<<< @@ -5432,12 +5620,12 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_50write(struct __pyx_obj_4ssh2 */ if (unlikely(__pyx_v_b_buf == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 341, __pyx_L1_error) + __PYX_ERR(0, 357, __pyx_L1_error) } - __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_buf); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 341, __pyx_L1_error) + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_buf); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 357, __pyx_L1_error) __pyx_v_buflen = __pyx_t_3; - /* "ssh2/channel.pyx":343 + /* "ssh2/channel.pyx":359 * cdef size_t buflen = len(b_buf) * cdef ssize_t rc * with nogil: # <<<<<<<<<<<<<< @@ -5452,7 +5640,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_50write(struct __pyx_obj_4ssh2 #endif /*try:*/ { - /* "ssh2/channel.pyx":344 + /* "ssh2/channel.pyx":360 * cdef ssize_t rc * with nogil: * rc = c_ssh2.libssh2_channel_write(self._channel, _buf, buflen) # <<<<<<<<<<<<<< @@ -5462,7 +5650,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_50write(struct __pyx_obj_4ssh2 __pyx_v_rc = libssh2_channel_write(__pyx_v_self->_channel, __pyx_v__buf, __pyx_v_buflen); } - /* "ssh2/channel.pyx":343 + /* "ssh2/channel.pyx":359 * cdef size_t buflen = len(b_buf) * cdef ssize_t rc * with nogil: # <<<<<<<<<<<<<< @@ -5481,7 +5669,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_50write(struct __pyx_obj_4ssh2 } } - /* "ssh2/channel.pyx":345 + /* "ssh2/channel.pyx":361 * with nogil: * rc = c_ssh2.libssh2_channel_write(self._channel, _buf, buflen) * return rc # <<<<<<<<<<<<<< @@ -5489,13 +5677,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_50write(struct __pyx_obj_4ssh2 * def write_ex(self, int stream_id, buf not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L1_error) + __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":332 + /* "ssh2/channel.pyx":348 * return rc * * def write(self, buf not None): # <<<<<<<<<<<<<< @@ -5515,7 +5703,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_50write(struct __pyx_obj_4ssh2 return __pyx_r; } -/* "ssh2/channel.pyx":347 +/* "ssh2/channel.pyx":363 * return rc * * def write_ex(self, int stream_id, buf not None): # <<<<<<<<<<<<<< @@ -5555,11 +5743,11 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_53write_ex(PyObject *__pyx_v_s case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("write_ex", 1, 2, 2, 1); __PYX_ERR(0, 347, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("write_ex", 1, 2, 2, 1); __PYX_ERR(0, 363, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_ex") < 0)) __PYX_ERR(0, 347, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_ex") < 0)) __PYX_ERR(0, 363, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -5567,19 +5755,19 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_53write_ex(PyObject *__pyx_v_s values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } - __pyx_v_stream_id = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_stream_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 347, __pyx_L3_error) + __pyx_v_stream_id = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_stream_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 363, __pyx_L3_error) __pyx_v_buf = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("write_ex", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 347, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("write_ex", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 363, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.channel.Channel.write_ex", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_buf) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "buf"); __PYX_ERR(0, 347, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "buf"); __PYX_ERR(0, 363, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_52write_ex(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self), __pyx_v_stream_id, __pyx_v_buf); @@ -5604,29 +5792,33 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_52write_ex(struct __pyx_obj_4s Py_ssize_t __pyx_t_3; __Pyx_RefNannySetupContext("write_ex", 0); - /* "ssh2/channel.pyx":356 + /* "ssh2/channel.pyx":372 * * :rtype: int""" * cdef bytes b_buf = to_bytes(buf) # <<<<<<<<<<<<<< * cdef const char *_buf = b_buf * cdef size_t buflen = len(b_buf) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_buf = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/channel.pyx":357 + /* "ssh2/channel.pyx":373 * :rtype: int""" * cdef bytes b_buf = to_bytes(buf) * cdef const char *_buf = b_buf # <<<<<<<<<<<<<< * cdef size_t buflen = len(b_buf) * cdef ssize_t rc */ - __pyx_t_2 = __Pyx_PyObject_AsString(__pyx_v_b_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 357, __pyx_L1_error) + if (unlikely(__pyx_v_b_buf == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 373, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 373, __pyx_L1_error) __pyx_v__buf = __pyx_t_2; - /* "ssh2/channel.pyx":358 + /* "ssh2/channel.pyx":374 * cdef bytes b_buf = to_bytes(buf) * cdef const char *_buf = b_buf * cdef size_t buflen = len(b_buf) # <<<<<<<<<<<<<< @@ -5635,12 +5827,12 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_52write_ex(struct __pyx_obj_4s */ if (unlikely(__pyx_v_b_buf == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 358, __pyx_L1_error) + __PYX_ERR(0, 374, __pyx_L1_error) } - __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_buf); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 358, __pyx_L1_error) + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_buf); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 374, __pyx_L1_error) __pyx_v_buflen = __pyx_t_3; - /* "ssh2/channel.pyx":360 + /* "ssh2/channel.pyx":376 * cdef size_t buflen = len(b_buf) * cdef ssize_t rc * with nogil: # <<<<<<<<<<<<<< @@ -5655,7 +5847,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_52write_ex(struct __pyx_obj_4s #endif /*try:*/ { - /* "ssh2/channel.pyx":361 + /* "ssh2/channel.pyx":377 * cdef ssize_t rc * with nogil: * rc = c_ssh2.libssh2_channel_write_ex( # <<<<<<<<<<<<<< @@ -5665,7 +5857,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_52write_ex(struct __pyx_obj_4s __pyx_v_rc = libssh2_channel_write_ex(__pyx_v_self->_channel, __pyx_v_stream_id, __pyx_v__buf, __pyx_v_buflen); } - /* "ssh2/channel.pyx":360 + /* "ssh2/channel.pyx":376 * cdef size_t buflen = len(b_buf) * cdef ssize_t rc * with nogil: # <<<<<<<<<<<<<< @@ -5684,7 +5876,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_52write_ex(struct __pyx_obj_4s } } - /* "ssh2/channel.pyx":363 + /* "ssh2/channel.pyx":379 * rc = c_ssh2.libssh2_channel_write_ex( * self._channel, stream_id, _buf, buflen) * return rc # <<<<<<<<<<<<<< @@ -5692,13 +5884,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_52write_ex(struct __pyx_obj_4s * def write_stderr(self, buf not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 363, __pyx_L1_error) + __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":347 + /* "ssh2/channel.pyx":363 * return rc * * def write_ex(self, int stream_id, buf not None): # <<<<<<<<<<<<<< @@ -5718,7 +5910,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_52write_ex(struct __pyx_obj_4s return __pyx_r; } -/* "ssh2/channel.pyx":365 +/* "ssh2/channel.pyx":381 * return rc * * def write_stderr(self, buf not None): # <<<<<<<<<<<<<< @@ -5734,7 +5926,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_55write_stderr(PyObject *__pyx __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_stderr (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_buf) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "buf"); __PYX_ERR(0, 365, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "buf"); __PYX_ERR(0, 381, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_54write_stderr(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self), ((PyObject *)__pyx_v_buf)); @@ -5759,29 +5951,33 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_54write_stderr(struct __pyx_ob Py_ssize_t __pyx_t_3; __Pyx_RefNannySetupContext("write_stderr", 0); - /* "ssh2/channel.pyx":372 + /* "ssh2/channel.pyx":388 * * :rtype: int""" * cdef bytes b_buf = to_bytes(buf) # <<<<<<<<<<<<<< * cdef const char *_buf = b_buf * cdef size_t buflen = len(b_buf) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_buf = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/channel.pyx":373 + /* "ssh2/channel.pyx":389 * :rtype: int""" * cdef bytes b_buf = to_bytes(buf) * cdef const char *_buf = b_buf # <<<<<<<<<<<<<< * cdef size_t buflen = len(b_buf) * cdef ssize_t rc */ - __pyx_t_2 = __Pyx_PyObject_AsString(__pyx_v_b_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 373, __pyx_L1_error) + if (unlikely(__pyx_v_b_buf == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 389, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 389, __pyx_L1_error) __pyx_v__buf = __pyx_t_2; - /* "ssh2/channel.pyx":374 + /* "ssh2/channel.pyx":390 * cdef bytes b_buf = to_bytes(buf) * cdef const char *_buf = b_buf * cdef size_t buflen = len(b_buf) # <<<<<<<<<<<<<< @@ -5790,12 +5986,12 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_54write_stderr(struct __pyx_ob */ if (unlikely(__pyx_v_b_buf == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 374, __pyx_L1_error) + __PYX_ERR(0, 390, __pyx_L1_error) } - __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_buf); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 374, __pyx_L1_error) + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_buf); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 390, __pyx_L1_error) __pyx_v_buflen = __pyx_t_3; - /* "ssh2/channel.pyx":376 + /* "ssh2/channel.pyx":392 * cdef size_t buflen = len(b_buf) * cdef ssize_t rc * with nogil: # <<<<<<<<<<<<<< @@ -5810,7 +6006,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_54write_stderr(struct __pyx_ob #endif /*try:*/ { - /* "ssh2/channel.pyx":377 + /* "ssh2/channel.pyx":393 * cdef ssize_t rc * with nogil: * rc = c_ssh2.libssh2_channel_write_stderr( # <<<<<<<<<<<<<< @@ -5820,7 +6016,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_54write_stderr(struct __pyx_ob __pyx_v_rc = libssh2_channel_write_stderr(__pyx_v_self->_channel, __pyx_v__buf, __pyx_v_buflen); } - /* "ssh2/channel.pyx":376 + /* "ssh2/channel.pyx":392 * cdef size_t buflen = len(b_buf) * cdef ssize_t rc * with nogil: # <<<<<<<<<<<<<< @@ -5839,7 +6035,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_54write_stderr(struct __pyx_ob } } - /* "ssh2/channel.pyx":379 + /* "ssh2/channel.pyx":395 * rc = c_ssh2.libssh2_channel_write_stderr( * self._channel, _buf, buflen) * return rc # <<<<<<<<<<<<<< @@ -5847,13 +6043,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_54write_stderr(struct __pyx_ob * def x11_req(self, int screen_number): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 379, __pyx_L1_error) + __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":365 + /* "ssh2/channel.pyx":381 * return rc * * def write_stderr(self, buf not None): # <<<<<<<<<<<<<< @@ -5873,7 +6069,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_54write_stderr(struct __pyx_ob return __pyx_r; } -/* "ssh2/channel.pyx":381 +/* "ssh2/channel.pyx":397 * return rc * * def x11_req(self, int screen_number): # <<<<<<<<<<<<<< @@ -5890,7 +6086,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_57x11_req(PyObject *__pyx_v_se __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("x11_req (wrapper)", 0); assert(__pyx_arg_screen_number); { - __pyx_v_screen_number = __Pyx_PyInt_As_int(__pyx_arg_screen_number); if (unlikely((__pyx_v_screen_number == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 381, __pyx_L3_error) + __pyx_v_screen_number = __Pyx_PyInt_As_int(__pyx_arg_screen_number); if (unlikely((__pyx_v_screen_number == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 397, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -5912,7 +6108,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_56x11_req(struct __pyx_obj_4ss PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("x11_req", 0); - /* "ssh2/channel.pyx":383 + /* "ssh2/channel.pyx":399 * def x11_req(self, int screen_number): * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -5927,7 +6123,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_56x11_req(struct __pyx_obj_4ss #endif /*try:*/ { - /* "ssh2/channel.pyx":384 + /* "ssh2/channel.pyx":400 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_x11_req( # <<<<<<<<<<<<<< @@ -5937,7 +6133,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_56x11_req(struct __pyx_obj_4ss __pyx_v_rc = libssh2_channel_x11_req(__pyx_v_self->_channel, __pyx_v_screen_number); } - /* "ssh2/channel.pyx":383 + /* "ssh2/channel.pyx":399 * def x11_req(self, int screen_number): * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -5956,7 +6152,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_56x11_req(struct __pyx_obj_4ss } } - /* "ssh2/channel.pyx":386 + /* "ssh2/channel.pyx":402 * rc = c_ssh2.libssh2_channel_x11_req( * self._channel, screen_number) * return rc # <<<<<<<<<<<<<< @@ -5964,13 +6160,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_56x11_req(struct __pyx_obj_4ss * def x11_req_ex(self, int single_connection, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 386, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":381 + /* "ssh2/channel.pyx":397 * return rc * * def x11_req(self, int screen_number): # <<<<<<<<<<<<<< @@ -5989,7 +6185,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_56x11_req(struct __pyx_obj_4ss return __pyx_r; } -/* "ssh2/channel.pyx":388 +/* "ssh2/channel.pyx":404 * return rc * * def x11_req_ex(self, int single_connection, # <<<<<<<<<<<<<< @@ -6035,23 +6231,23 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_59x11_req_ex(PyObject *__pyx_v case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_auth_proto)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, 1); __PYX_ERR(0, 388, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, 1); __PYX_ERR(0, 404, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_auth_cookie)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, 2); __PYX_ERR(0, 388, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, 2); __PYX_ERR(0, 404, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_screen_number)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, 3); __PYX_ERR(0, 388, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, 3); __PYX_ERR(0, 404, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "x11_req_ex") < 0)) __PYX_ERR(0, 388, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "x11_req_ex") < 0)) __PYX_ERR(0, 404, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -6061,14 +6257,14 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_59x11_req_ex(PyObject *__pyx_v values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } - __pyx_v_single_connection = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_single_connection == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 388, __pyx_L3_error) - __pyx_v_auth_proto = __Pyx_PyObject_AsString(values[1]); if (unlikely((!__pyx_v_auth_proto) && PyErr_Occurred())) __PYX_ERR(0, 389, __pyx_L3_error) - __pyx_v_auth_cookie = __Pyx_PyObject_AsString(values[2]); if (unlikely((!__pyx_v_auth_cookie) && PyErr_Occurred())) __PYX_ERR(0, 390, __pyx_L3_error) - __pyx_v_screen_number = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_screen_number == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 391, __pyx_L3_error) + __pyx_v_single_connection = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_single_connection == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 404, __pyx_L3_error) + __pyx_v_auth_proto = __Pyx_PyObject_AsString(values[1]); if (unlikely((!__pyx_v_auth_proto) && PyErr_Occurred())) __PYX_ERR(0, 405, __pyx_L3_error) + __pyx_v_auth_cookie = __Pyx_PyObject_AsString(values[2]); if (unlikely((!__pyx_v_auth_cookie) && PyErr_Occurred())) __PYX_ERR(0, 406, __pyx_L3_error) + __pyx_v_screen_number = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_screen_number == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 388, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 404, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.channel.Channel.x11_req_ex", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -6088,7 +6284,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_58x11_req_ex(struct __pyx_obj_ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("x11_req_ex", 0); - /* "ssh2/channel.pyx":393 + /* "ssh2/channel.pyx":409 * int screen_number): * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6103,7 +6299,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_58x11_req_ex(struct __pyx_obj_ #endif /*try:*/ { - /* "ssh2/channel.pyx":394 + /* "ssh2/channel.pyx":410 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_x11_req_ex( # <<<<<<<<<<<<<< @@ -6113,7 +6309,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_58x11_req_ex(struct __pyx_obj_ __pyx_v_rc = libssh2_channel_x11_req_ex(__pyx_v_self->_channel, __pyx_v_single_connection, __pyx_v_auth_proto, __pyx_v_auth_cookie, __pyx_v_screen_number); } - /* "ssh2/channel.pyx":393 + /* "ssh2/channel.pyx":409 * int screen_number): * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6132,7 +6328,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_58x11_req_ex(struct __pyx_obj_ } } - /* "ssh2/channel.pyx":397 + /* "ssh2/channel.pyx":413 * self._channel, single_connection, * auth_proto, auth_cookie, screen_number) * return rc # <<<<<<<<<<<<<< @@ -6140,13 +6336,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_58x11_req_ex(struct __pyx_obj_ * def process_startup(self, request, message): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 397, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":388 + /* "ssh2/channel.pyx":404 * return rc * * def x11_req_ex(self, int single_connection, # <<<<<<<<<<<<<< @@ -6165,7 +6361,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_58x11_req_ex(struct __pyx_obj_ return __pyx_r; } -/* "ssh2/channel.pyx":399 +/* "ssh2/channel.pyx":415 * return rc * * def process_startup(self, request, message): # <<<<<<<<<<<<<< @@ -6205,11 +6401,11 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_61process_startup(PyObject *__ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("process_startup", 1, 2, 2, 1); __PYX_ERR(0, 399, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("process_startup", 1, 2, 2, 1); __PYX_ERR(0, 415, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "process_startup") < 0)) __PYX_ERR(0, 399, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "process_startup") < 0)) __PYX_ERR(0, 415, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -6222,7 +6418,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_61process_startup(PyObject *__ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("process_startup", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 399, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("process_startup", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 415, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.channel.Channel.process_startup", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -6250,51 +6446,59 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_60process_startup(struct __pyx Py_ssize_t __pyx_t_3; __Pyx_RefNannySetupContext("process_startup", 0); - /* "ssh2/channel.pyx":404 + /* "ssh2/channel.pyx":420 * Request is a supported SSH subsystem and clients would typically use * one of execute/shell/subsystem functions depending on request type.""" * cdef bytes b_request = to_bytes(request) # <<<<<<<<<<<<<< * cdef bytes b_message = to_bytes(message) * cdef char *_request = b_request */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_request); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 404, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_request); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_request = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/channel.pyx":405 + /* "ssh2/channel.pyx":421 * one of execute/shell/subsystem functions depending on request type.""" * cdef bytes b_request = to_bytes(request) * cdef bytes b_message = to_bytes(message) # <<<<<<<<<<<<<< * cdef char *_request = b_request * cdef char *_message = b_message */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_message); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 405, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_message); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_message = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/channel.pyx":406 + /* "ssh2/channel.pyx":422 * cdef bytes b_request = to_bytes(request) * cdef bytes b_message = to_bytes(message) * cdef char *_request = b_request # <<<<<<<<<<<<<< * cdef char *_message = b_message * cdef size_t r_len = len(b_request) */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_request); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 406, __pyx_L1_error) + if (unlikely(__pyx_v_b_request == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 422, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_request); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 422, __pyx_L1_error) __pyx_v__request = __pyx_t_2; - /* "ssh2/channel.pyx":407 + /* "ssh2/channel.pyx":423 * cdef bytes b_message = to_bytes(message) * cdef char *_request = b_request * cdef char *_message = b_message # <<<<<<<<<<<<<< * cdef size_t r_len = len(b_request) * cdef size_t m_len = len(b_message) */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_message); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L1_error) + if (unlikely(__pyx_v_b_message == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 423, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_message); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 423, __pyx_L1_error) __pyx_v__message = __pyx_t_2; - /* "ssh2/channel.pyx":408 + /* "ssh2/channel.pyx":424 * cdef char *_request = b_request * cdef char *_message = b_message * cdef size_t r_len = len(b_request) # <<<<<<<<<<<<<< @@ -6303,12 +6507,12 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_60process_startup(struct __pyx */ if (unlikely(__pyx_v_b_request == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 408, __pyx_L1_error) + __PYX_ERR(0, 424, __pyx_L1_error) } - __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_request); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 408, __pyx_L1_error) + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_request); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 424, __pyx_L1_error) __pyx_v_r_len = __pyx_t_3; - /* "ssh2/channel.pyx":409 + /* "ssh2/channel.pyx":425 * cdef char *_message = b_message * cdef size_t r_len = len(b_request) * cdef size_t m_len = len(b_message) # <<<<<<<<<<<<<< @@ -6317,12 +6521,12 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_60process_startup(struct __pyx */ if (unlikely(__pyx_v_b_message == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 409, __pyx_L1_error) + __PYX_ERR(0, 425, __pyx_L1_error) } - __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_message); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 409, __pyx_L1_error) + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_message); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 425, __pyx_L1_error) __pyx_v_m_len = __pyx_t_3; - /* "ssh2/channel.pyx":411 + /* "ssh2/channel.pyx":427 * cdef size_t m_len = len(b_message) * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6337,7 +6541,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_60process_startup(struct __pyx #endif /*try:*/ { - /* "ssh2/channel.pyx":412 + /* "ssh2/channel.pyx":428 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_process_startup( # <<<<<<<<<<<<<< @@ -6347,7 +6551,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_60process_startup(struct __pyx __pyx_v_rc = libssh2_channel_process_startup(__pyx_v_self->_channel, __pyx_v__request, __pyx_v_r_len, __pyx_v__message, __pyx_v_m_len); } - /* "ssh2/channel.pyx":411 + /* "ssh2/channel.pyx":427 * cdef size_t m_len = len(b_message) * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6366,7 +6570,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_60process_startup(struct __pyx } } - /* "ssh2/channel.pyx":414 + /* "ssh2/channel.pyx":430 * rc = c_ssh2.libssh2_channel_process_startup( * self._channel, _request, r_len, _message, m_len) * return rc # <<<<<<<<<<<<<< @@ -6374,13 +6578,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_60process_startup(struct __pyx * def poll_channel_read(self, int extended): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 430, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":399 + /* "ssh2/channel.pyx":415 * return rc * * def process_startup(self, request, message): # <<<<<<<<<<<<<< @@ -6401,24 +6605,24 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_60process_startup(struct __pyx return __pyx_r; } -/* "ssh2/channel.pyx":416 +/* "ssh2/channel.pyx":432 * return rc * * def poll_channel_read(self, int extended): # <<<<<<<<<<<<<< - * """Deprecated - use blockdirections and socket polling instead""" - * cdef int rc + * """Deprecated - use session.block_directions and socket polling + * instead""" */ /* Python wrapper */ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_63poll_channel_read(PyObject *__pyx_v_self, PyObject *__pyx_arg_extended); /*proto*/ -static char __pyx_doc_4ssh2_7channel_7Channel_62poll_channel_read[] = "Channel.poll_channel_read(self, int extended)\nDeprecated - use blockdirections and socket polling instead"; +static char __pyx_doc_4ssh2_7channel_7Channel_62poll_channel_read[] = "Channel.poll_channel_read(self, int extended)\nDeprecated - use session.block_directions and socket polling\n instead"; static PyObject *__pyx_pw_4ssh2_7channel_7Channel_63poll_channel_read(PyObject *__pyx_v_self, PyObject *__pyx_arg_extended) { int __pyx_v_extended; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("poll_channel_read (wrapper)", 0); assert(__pyx_arg_extended); { - __pyx_v_extended = __Pyx_PyInt_As_int(__pyx_arg_extended); if (unlikely((__pyx_v_extended == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 416, __pyx_L3_error) + __pyx_v_extended = __Pyx_PyInt_As_int(__pyx_arg_extended); if (unlikely((__pyx_v_extended == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 432, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -6440,8 +6644,8 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62poll_channel_read(struct __p PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("poll_channel_read", 0); - /* "ssh2/channel.pyx":419 - * """Deprecated - use blockdirections and socket polling instead""" + /* "ssh2/channel.pyx":436 + * instead""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< * rc = c_ssh2.libssh2_poll_channel_read(self._channel, extended) @@ -6455,7 +6659,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62poll_channel_read(struct __p #endif /*try:*/ { - /* "ssh2/channel.pyx":420 + /* "ssh2/channel.pyx":437 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_poll_channel_read(self._channel, extended) # <<<<<<<<<<<<<< @@ -6465,8 +6669,8 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62poll_channel_read(struct __p __pyx_v_rc = libssh2_poll_channel_read(__pyx_v_self->_channel, __pyx_v_extended); } - /* "ssh2/channel.pyx":419 - * """Deprecated - use blockdirections and socket polling instead""" + /* "ssh2/channel.pyx":436 + * instead""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< * rc = c_ssh2.libssh2_poll_channel_read(self._channel, extended) @@ -6484,7 +6688,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62poll_channel_read(struct __p } } - /* "ssh2/channel.pyx":421 + /* "ssh2/channel.pyx":438 * with nogil: * rc = c_ssh2.libssh2_poll_channel_read(self._channel, extended) * return rc # <<<<<<<<<<<<<< @@ -6492,18 +6696,18 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62poll_channel_read(struct __p * def handle_extended_data(self, int ignore_mode): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":416 + /* "ssh2/channel.pyx":432 * return rc * * def poll_channel_read(self, int extended): # <<<<<<<<<<<<<< - * """Deprecated - use blockdirections and socket polling instead""" - * cdef int rc + * """Deprecated - use session.block_directions and socket polling + * instead""" */ /* function exit code */ @@ -6517,7 +6721,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62poll_channel_read(struct __p return __pyx_r; } -/* "ssh2/channel.pyx":423 +/* "ssh2/channel.pyx":440 * return rc * * def handle_extended_data(self, int ignore_mode): # <<<<<<<<<<<<<< @@ -6534,7 +6738,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_65handle_extended_data(PyObjec __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("handle_extended_data (wrapper)", 0); assert(__pyx_arg_ignore_mode); { - __pyx_v_ignore_mode = __Pyx_PyInt_As_int(__pyx_arg_ignore_mode); if (unlikely((__pyx_v_ignore_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 423, __pyx_L3_error) + __pyx_v_ignore_mode = __Pyx_PyInt_As_int(__pyx_arg_ignore_mode); if (unlikely((__pyx_v_ignore_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 440, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -6554,7 +6758,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_64handle_extended_data(struct __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("handle_extended_data", 0); - /* "ssh2/channel.pyx":425 + /* "ssh2/channel.pyx":442 * def handle_extended_data(self, int ignore_mode): * """Deprecated, use handle_extended_data2""" * with nogil: # <<<<<<<<<<<<<< @@ -6569,7 +6773,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_64handle_extended_data(struct #endif /*try:*/ { - /* "ssh2/channel.pyx":426 + /* "ssh2/channel.pyx":443 * """Deprecated, use handle_extended_data2""" * with nogil: * c_ssh2.libssh2_channel_handle_extended_data( # <<<<<<<<<<<<<< @@ -6579,7 +6783,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_64handle_extended_data(struct libssh2_channel_handle_extended_data(__pyx_v_self->_channel, __pyx_v_ignore_mode); } - /* "ssh2/channel.pyx":425 + /* "ssh2/channel.pyx":442 * def handle_extended_data(self, int ignore_mode): * """Deprecated, use handle_extended_data2""" * with nogil: # <<<<<<<<<<<<<< @@ -6598,7 +6802,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_64handle_extended_data(struct } } - /* "ssh2/channel.pyx":423 + /* "ssh2/channel.pyx":440 * return rc * * def handle_extended_data(self, int ignore_mode): # <<<<<<<<<<<<<< @@ -6613,7 +6817,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_64handle_extended_data(struct return __pyx_r; } -/* "ssh2/channel.pyx":429 +/* "ssh2/channel.pyx":446 * self._channel, ignore_mode) * * def handle_extended_data2(self, int ignore_mode): # <<<<<<<<<<<<<< @@ -6630,7 +6834,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_67handle_extended_data2(PyObje __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("handle_extended_data2 (wrapper)", 0); assert(__pyx_arg_ignore_mode); { - __pyx_v_ignore_mode = __Pyx_PyInt_As_int(__pyx_arg_ignore_mode); if (unlikely((__pyx_v_ignore_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 429, __pyx_L3_error) + __pyx_v_ignore_mode = __Pyx_PyInt_As_int(__pyx_arg_ignore_mode); if (unlikely((__pyx_v_ignore_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 446, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -6652,7 +6856,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_66handle_extended_data2(struct PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("handle_extended_data2", 0); - /* "ssh2/channel.pyx":431 + /* "ssh2/channel.pyx":448 * def handle_extended_data2(self, int ignore_mode): * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6667,7 +6871,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_66handle_extended_data2(struct #endif /*try:*/ { - /* "ssh2/channel.pyx":432 + /* "ssh2/channel.pyx":449 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_handle_extended_data2( # <<<<<<<<<<<<<< @@ -6677,7 +6881,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_66handle_extended_data2(struct __pyx_v_rc = libssh2_channel_handle_extended_data2(__pyx_v_self->_channel, __pyx_v_ignore_mode); } - /* "ssh2/channel.pyx":431 + /* "ssh2/channel.pyx":448 * def handle_extended_data2(self, int ignore_mode): * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6696,7 +6900,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_66handle_extended_data2(struct } } - /* "ssh2/channel.pyx":434 + /* "ssh2/channel.pyx":451 * rc = c_ssh2.libssh2_channel_handle_extended_data2( * self._channel, ignore_mode) * return rc # <<<<<<<<<<<<<< @@ -6704,13 +6908,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_66handle_extended_data2(struct * def ignore_extended_data(self, int ignore_mode): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 434, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 451, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":429 + /* "ssh2/channel.pyx":446 * self._channel, ignore_mode) * * def handle_extended_data2(self, int ignore_mode): # <<<<<<<<<<<<<< @@ -6729,7 +6933,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_66handle_extended_data2(struct return __pyx_r; } -/* "ssh2/channel.pyx":436 +/* "ssh2/channel.pyx":453 * return rc * * def ignore_extended_data(self, int ignore_mode): # <<<<<<<<<<<<<< @@ -6746,7 +6950,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_69ignore_extended_data(PyObjec __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ignore_extended_data (wrapper)", 0); assert(__pyx_arg_ignore_mode); { - __pyx_v_ignore_mode = __Pyx_PyInt_As_int(__pyx_arg_ignore_mode); if (unlikely((__pyx_v_ignore_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 436, __pyx_L3_error) + __pyx_v_ignore_mode = __Pyx_PyInt_As_int(__pyx_arg_ignore_mode); if (unlikely((__pyx_v_ignore_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 453, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -6766,7 +6970,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_68ignore_extended_data(struct __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ignore_extended_data", 0); - /* "ssh2/channel.pyx":438 + /* "ssh2/channel.pyx":455 * def ignore_extended_data(self, int ignore_mode): * """Deprecated, use handle_extended_data2""" * with nogil: # <<<<<<<<<<<<<< @@ -6781,7 +6985,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_68ignore_extended_data(struct #endif /*try:*/ { - /* "ssh2/channel.pyx":439 + /* "ssh2/channel.pyx":456 * """Deprecated, use handle_extended_data2""" * with nogil: * c_ssh2.libssh2_channel_handle_extended_data( # <<<<<<<<<<<<<< @@ -6790,7 +6994,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_68ignore_extended_data(struct libssh2_channel_handle_extended_data(__pyx_v_self->_channel, __pyx_v_ignore_mode); } - /* "ssh2/channel.pyx":438 + /* "ssh2/channel.pyx":455 * def ignore_extended_data(self, int ignore_mode): * """Deprecated, use handle_extended_data2""" * with nogil: # <<<<<<<<<<<<<< @@ -6809,7 +7013,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_68ignore_extended_data(struct } } - /* "ssh2/channel.pyx":436 + /* "ssh2/channel.pyx":453 * return rc * * def ignore_extended_data(self, int ignore_mode): # <<<<<<<<<<<<<< @@ -6953,7 +7157,7 @@ static PyObject *__pyx_tp_new_4ssh2_7channel_Channel(PyTypeObject *t, PyObject * static void __pyx_tp_dealloc_4ssh2_7channel_Channel(PyObject *o) { struct __pyx_obj_4ssh2_7channel_Channel *p = (struct __pyx_obj_4ssh2_7channel_Channel *)o; - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -6989,6 +7193,10 @@ static int __pyx_tp_clear_4ssh2_7channel_Channel(PyObject *o) { return 0; } +static PyObject *__pyx_getprop_4ssh2_7channel_7Channel_session(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_4ssh2_7channel_7Channel_7session_1__get__(o); +} + static PyMethodDef __pyx_methods_4ssh2_7channel_Channel[] = { {"pty", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_5pty, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4ssh2_7channel_7Channel_4pty}, {"execute", (PyCFunction)__pyx_pw_4ssh2_7channel_7Channel_7execute, METH_O, __pyx_doc_4ssh2_7channel_7Channel_6execute}, @@ -7028,6 +7236,11 @@ static PyMethodDef __pyx_methods_4ssh2_7channel_Channel[] = { {0, 0, 0, 0} }; +static struct PyGetSetDef __pyx_getsets_4ssh2_7channel_Channel[] = { + {(char *)"session", __pyx_getprop_4ssh2_7channel_7Channel_session, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + static PyTypeObject __pyx_type_4ssh2_7channel_Channel = { PyVarObject_HEAD_INIT(0, 0) "ssh2.channel.Channel", /*tp_name*/ @@ -7063,7 +7276,7 @@ static PyTypeObject __pyx_type_4ssh2_7channel_Channel = { 0, /*tp_iternext*/ __pyx_methods_4ssh2_7channel_Channel, /*tp_methods*/ 0, /*tp_members*/ - 0, /*tp_getset*/ + __pyx_getsets_4ssh2_7channel_Channel, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ @@ -7091,17 +7304,31 @@ static PyMethodDef __pyx_methods[] = { }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_channel(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_channel}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "channel", 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ @@ -7121,16 +7348,20 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_buf, __pyx_k_buf, sizeof(__pyx_k_buf), 0, 0, 1, 1}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, {&__pyx_n_s_force, __pyx_k_force, sizeof(__pyx_k_force), 0, 0, 1, 1}, + {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_message, __pyx_k_message, sizeof(__pyx_k_message), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, - {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, {&__pyx_n_s_read_avail, __pyx_k_read_avail, sizeof(__pyx_k_read_avail), 0, 0, 1, 1}, {&__pyx_n_s_read_ex, __pyx_k_read_ex, sizeof(__pyx_k_read_ex), 0, 0, 1, 1}, + {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, {&__pyx_n_s_request, __pyx_k_request, sizeof(__pyx_k_request), 0, 0, 1, 1}, {&__pyx_n_s_screen_number, __pyx_k_screen_number, sizeof(__pyx_k_screen_number), 0, 0, 1, 1}, {&__pyx_n_s_session, __pyx_k_session, sizeof(__pyx_k_session), 0, 0, 1, 1}, + {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_single_connection, __pyx_k_single_connection, sizeof(__pyx_k_single_connection), 0, 0, 1, 1}, {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1}, @@ -7144,7 +7375,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 124, __pyx_L1_error) + __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 142, __pyx_L1_error) __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error) return 0; __pyx_L1_error:; @@ -7194,11 +7425,55 @@ PyMODINIT_FUNC initchannel(void) #else PyMODINIT_FUNC PyInit_channel(void); /*proto*/ PyMODINIT_FUNC PyInit_channel(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec_channel(PyObject *__pyx_pyinit_module) +#endif #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { @@ -7225,6 +7500,9 @@ PyMODINIT_FUNC PyInit_channel(void) #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_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 @@ -7236,12 +7514,17 @@ PyMODINIT_FUNC PyInit_channel(void) #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("channel", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -7281,8 +7564,7 @@ PyMODINIT_FUNC PyInit_channel(void) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_7channel_Channel) < 0) __PYX_ERR(0, 33, __pyx_L1_error) __pyx_ptype_4ssh2_7channel_Channel = &__pyx_type_4ssh2_7channel_Channel; /*--- Type import code ---*/ - __pyx_ptype_4ssh2_7session_Session = __Pyx_ImportType("ssh2.session", "Session", sizeof(struct __pyx_obj_4ssh2_7session_Session), 1); if (unlikely(!__pyx_ptype_4ssh2_7session_Session)) __PYX_ERR(2, 20, __pyx_L1_error) - __pyx_vtabptr_4ssh2_7session_Session = (struct __pyx_vtabstruct_4ssh2_7session_Session*)__Pyx_GetVtable(__pyx_ptype_4ssh2_7session_Session->tp_dict); if (unlikely(!__pyx_vtabptr_4ssh2_7session_Session)) __PYX_ERR(2, 20, __pyx_L1_error) + __pyx_ptype_4ssh2_7session_Session = __Pyx_ImportType("ssh2.session", "Session", sizeof(struct __pyx_obj_4ssh2_7session_Session), 1); if (unlikely(!__pyx_ptype_4ssh2_7session_Session)) __PYX_ERR(2, 19, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_AgentError = __Pyx_ImportType("ssh2.exceptions", "AgentError", sizeof(struct __pyx_obj_4ssh2_10exceptions_AgentError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_AgentError)) __PYX_ERR(3, 18, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_AuthenticationError = __Pyx_ImportType("ssh2.exceptions", "AuthenticationError", sizeof(struct __pyx_obj_4ssh2_10exceptions_AuthenticationError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_AuthenticationError)) __PYX_ERR(3, 22, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_AgentConnectionError = __Pyx_ImportType("ssh2.exceptions", "AgentConnectionError", sizeof(struct __pyx_obj_4ssh2_10exceptions_AgentConnectionError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_AgentConnectionError)) __PYX_ERR(3, 26, __pyx_L1_error) @@ -7294,6 +7576,7 @@ PyMODINIT_FUNC PyInit_channel(void) __pyx_ptype_4ssh2_10exceptions_ChannelError = __Pyx_ImportType("ssh2.exceptions", "ChannelError", sizeof(struct __pyx_obj_4ssh2_10exceptions_ChannelError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_ChannelError)) __PYX_ERR(3, 50, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_SFTPHandleError = __Pyx_ImportType("ssh2.exceptions", "SFTPHandleError", sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SFTPHandleError)) __PYX_ERR(3, 54, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall = __Pyx_ImportType("ssh2.exceptions", "SFTPBufferTooSmall", sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall)) __PYX_ERR(3, 58, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_SFTPIOError = __Pyx_ImportType("ssh2.exceptions", "SFTPIOError", sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPIOError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SFTPIOError)) __PYX_ERR(3, 62, __pyx_L1_error) __pyx_ptype_4ssh2_4sftp_SFTP = __Pyx_ImportType("ssh2.sftp", "SFTP", sizeof(struct __pyx_obj_4ssh2_4sftp_SFTP), 1); if (unlikely(!__pyx_ptype_4ssh2_4sftp_SFTP)) __PYX_ERR(4, 26, __pyx_L1_error) /*--- Variable import code ---*/ /*--- Function import code ---*/ @@ -7310,7 +7593,7 @@ PyMODINIT_FUNC PyInit_channel(void) * # Copyright (C) 2017 Panos Kittenis * */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -7331,10 +7614,12 @@ PyMODINIT_FUNC PyInit_channel(void) } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -7533,29 +7818,23 @@ static void __Pyx_RaiseArgtupleInvalid( } /* 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); -} -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } - if (none_allowed && obj == Py_None) return 1; else if (exact) { - if (likely(Py_TYPE(obj) == type)) return 1; #if PY_MAJOR_VERSION == 2 - else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { - if (likely(PyObject_TypeCheck(obj, type))) return 1; + if (likely(__Pyx_TypeCheck(obj, type))) return 1; } - __Pyx_RaiseArgumentTypeInvalid(name, obj, type); + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); return 0; } @@ -7699,11 +7978,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject "raise: exception class must be a subclass of BaseException"); goto bad; } -#if PY_VERSION_HEX >= 0x03030000 if (cause) { -#else - if (cause && cause != Py_None) { -#endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; @@ -7731,7 +8006,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else - PyThreadState *tstate = PyThreadState_GET(); + PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); @@ -7747,7 +8022,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject #endif /* GetException */ - #if CYTHON_FAST_THREAD_STATE +#if CYTHON_FAST_THREAD_STATE static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { @@ -7808,7 +8083,7 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) } /* SwapException */ - #if CYTHON_FAST_THREAD_STATE + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->exc_type; @@ -7833,7 +8108,7 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, #endif /* SaveResetException */ - #if CYTHON_FAST_THREAD_STATE + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { *type = tstate->exc_type; *value = tstate->exc_value; @@ -7857,17 +8132,16 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject #endif /* SetupReduce */ - #define __Pyx_setup_reduce_GET_ATTR_OR_BAD(res, obj, name) res = PyObject_GetAttrString(obj, name); if (res == NULL) goto BAD; -static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { + static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { int ret; PyObject *name_attr; - name_attr = PyObject_GetAttrString(meth, "__name__"); - if (name_attr) { + name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name); + if (likely(name_attr)) { ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); } else { ret = -1; } - if (ret < 0) { + if (unlikely(ret < 0)) { PyErr_Clear(); ret = 0; } @@ -7876,43 +8150,55 @@ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { } static int __Pyx_setup_reduce(PyObject* type_obj) { int ret = 0; - PyObject* builtin_object = NULL; - static PyObject *object_reduce = NULL; - static PyObject *object_reduce_ex = NULL; + PyObject *object_reduce = NULL; + PyObject *object_reduce_ex = NULL; PyObject *reduce = NULL; PyObject *reduce_ex = NULL; PyObject *reduce_cython = NULL; PyObject *setstate = NULL; PyObject *setstate_cython = NULL; - if (PyObject_HasAttrString(type_obj, "__getstate__")) goto GOOD; - if (object_reduce_ex == NULL) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(builtin_object, __pyx_b, "object"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce, builtin_object, "__reduce__"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce_ex, builtin_object, "__reduce_ex__"); - } - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_ex, type_obj, "__reduce_ex__"); +#if CYTHON_USE_PYTYPE_LOOKUP + if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD; +#else + if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD; +#endif +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#else + object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#endif + reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD; if (reduce_ex == object_reduce_ex) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce, type_obj, "__reduce__"); - if (object_reduce == reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_cython, type_obj, "__reduce_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce__", reduce_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce_cython__"); if (ret < 0) goto BAD; - setstate = PyObject_GetAttrString(type_obj, "__setstate__"); +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#else + object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#endif + reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD; + if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { + reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD; + setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); if (!setstate) PyErr_Clear(); if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(setstate_cython, type_obj, "__setstate_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate__", setstate_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate_cython__"); if (ret < 0) goto BAD; + setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD; } PyType_Modified((PyTypeObject*)type_obj); } } goto GOOD; BAD: - if (!PyErr_Occurred()) PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); + if (!PyErr_Occurred()) + PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); ret = -1; GOOD: - Py_XDECREF(builtin_object); +#if !CYTHON_USE_PYTYPE_LOOKUP + Py_XDECREF(object_reduce); + Py_XDECREF(object_reduce_ex); +#endif Py_XDECREF(reduce); Py_XDECREF(reduce_ex); Py_XDECREF(reduce_cython); @@ -7921,35 +8207,19 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { return ret; } -/* GetVTable */ - static void* __Pyx_GetVtable(PyObject *dict) { - void* ptr; - PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable); - if (!ob) - goto bad; -#if PY_VERSION_HEX >= 0x02070000 - ptr = PyCapsule_GetPointer(ob, 0); -#else - ptr = PyCObject_AsVoidPtr(ob); -#endif - if (!ptr && !PyErr_Occurred()) - PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); - Py_DECREF(ob); - return ptr; -bad: - Py_XDECREF(ob); - return NULL; -} - /* CLineInTraceback */ - static int __Pyx_CLineForTraceback(int c_line) { + static int __Pyx_CLineForTraceback(int c_line) { #ifdef CYTHON_CLINE_IN_TRACEBACK return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; #else - PyObject **cython_runtime_dict; PyObject *use_cline; - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (unlikely(!cython_runtime_dict)) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { PyObject *ptype, *pvalue, *ptraceback; PyObject *use_cline_obj; PyErr_Fetch(&ptype, &pvalue, &ptraceback); @@ -7961,8 +8231,6 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { use_cline = NULL; } PyErr_Restore(ptype, pvalue, ptraceback); - } else { - use_cline = PyDict_GetItem(*_PyObject_GetDictPtr(__pyx_cython_runtime), __pyx_n_s_cline_in_traceback); } if (!use_cline) { c_line = 0; @@ -7976,7 +8244,7 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { } /* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + 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; @@ -8056,7 +8324,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { } /* AddTraceback */ - #include "compile.h" + #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( @@ -8126,10 +8394,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, __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*/ + __Pyx_PyThreadState_Current, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); @@ -8140,7 +8408,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + #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) @@ -8162,7 +8430,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -8193,7 +8461,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value) { const unsigned long neg_one = (unsigned long) -1, const_zero = (unsigned long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -8224,7 +8492,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { + static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { const size_t neg_one = (size_t) -1, const_zero = (size_t) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -8413,7 +8681,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + 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 @@ -8602,7 +8870,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE unsigned long __Pyx_PyInt_As_unsigned_long(PyObject *x) { + static CYTHON_INLINE unsigned long __Pyx_PyInt_As_unsigned_long(PyObject *x) { const unsigned long neg_one = (unsigned long) -1, const_zero = (unsigned long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -8791,7 +9059,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + 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) { @@ -8822,7 +9090,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + 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 @@ -9010,8 +9278,80 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, return (long) -1; } +/* FastTypeChecks */ + #if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + /* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { + 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()); @@ -9027,7 +9367,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* FunctionExport */ - static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { + static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { PyObject *d = 0; PyObject *cobj = 0; union { @@ -9064,7 +9404,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* ModuleImport */ - #ifndef __PYX_HAVE_RT_ImportModule + #ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; @@ -9082,7 +9422,7 @@ static PyObject *__Pyx_ImportModule(const char *name) { #endif /* TypeImport */ - #ifndef __PYX_HAVE_RT_ImportType + #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) @@ -9147,7 +9487,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class #endif /* FunctionImport */ - #ifndef __PYX_HAVE_RT_ImportFunction + #ifndef __PYX_HAVE_RT_ImportFunction #define __PYX_HAVE_RT_ImportFunction static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { PyObject *d = 0; @@ -9201,7 +9541,7 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (** #endif /* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { @@ -9240,46 +9580,53 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#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 && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} +#endif #endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __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 && #endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -9303,6 +9650,26 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; @@ -9310,9 +9677,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS @@ -9320,32 +9687,30 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } #else - if (m && m->nb_int) { + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); } #endif #else - res = PyNumber_Int(x); + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { diff --git a/ssh2/channel.pyx b/ssh2/channel.pyx index 700443e3..7e891dc2 100644 --- a/ssh2/channel.pyx +++ b/ssh2/channel.pyx @@ -38,10 +38,21 @@ cdef class Channel: def __dealloc__(self): with nogil: - c_ssh2.libssh2_channel_close(self._channel) - c_ssh2.libssh2_channel_free(self._channel) + if self._channel is not NULL and self._session is not None: + c_ssh2.libssh2_channel_close(self._channel) + c_ssh2.libssh2_channel_free(self._channel) + self._channel = NULL + + @property + def session(self): + return self._session def pty(self, term="vt100"): + """Request a PTY (physical terminal emulation) on the channel. + + :param term: Terminal type to emulate. + :type term: str + """ cdef bytes b_term = to_bytes(term) cdef const char *_term = b_term cdef int rc @@ -104,6 +115,9 @@ cdef class Channel: Return code is the size of the buffer when positive. Negative values are error codes. + :param size: Max buffer size to read. + :type size: int + :rtype: (int, bytes)""" return self.read_ex(size=size, stream_id=0) @@ -114,9 +128,13 @@ cdef class Channel: Return code is the size of the buffer when positive. Negative values are error codes. + :param size: Max buffer size to read. + :type size: int + :rtype: (int, bytes)""" - cdef bytes buf + cdef bytes buf = b'' cdef char *cbuf + cdef ssize_t rc with nogil: cbuf = malloc(sizeof(char)*size) if cbuf is NULL: @@ -127,8 +145,6 @@ cdef class Channel: try: if rc > 0: buf = cbuf[:rc] - else: - buf = b'' finally: free(cbuf) return rc, buf @@ -158,8 +174,8 @@ cdef class Channel: specified channel. Processes typically interpret this as a closed stdin descriptor. - Return 0 on success or negative on failure. - It returns LIBSSH2_ERROR_EAGAIN when it would otherwise block. + Returns 0 on success or negative on failure. + It returns ``LIBSSH2_ERROR_EAGAIN`` when it would otherwise block. :rtype: int """ @@ -169,9 +185,9 @@ cdef class Channel: return rc def wait_eof(self): - """Wait for the remote end to acknowledge an EOF request + """Wait for the remote end to acknowledge an EOF request. - Return 0 on success or negative on failure. It returns + Returns 0 on success or negative on failure. It returns :py:class:`ssh2.error_codes.LIBSSH2_ERROR_EAGAIN` when it would otherwise block. @@ -414,7 +430,8 @@ cdef class Channel: return rc def poll_channel_read(self, int extended): - """Deprecated - use blockdirections and socket polling instead""" + """Deprecated - use session.block_directions and socket polling + instead""" cdef int rc with nogil: rc = c_ssh2.libssh2_poll_channel_read(self._channel, extended) diff --git a/ssh2/error_codes.c b/ssh2/error_codes.c index 7f9dad99..533a2eb2 100644 --- a/ssh2/error_codes.c +++ b/ssh2/error_codes.c @@ -1,13 +1,14 @@ -/* Generated by Cython 0.26 */ +/* Generated by Cython 0.27.1 */ #define PY_SSIZE_T_CLEAN #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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_26" +#define CYTHON_ABI "0_27_1" +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -31,7 +32,7 @@ #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif @@ -47,8 +48,14 @@ #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS @@ -67,6 +74,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -74,6 +85,8 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS @@ -98,6 +111,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -105,6 +122,12 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 @@ -144,6 +167,12 @@ #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -199,6 +228,27 @@ #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ @@ -282,7 +332,6 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject @@ -333,15 +382,17 @@ #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct 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)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) @@ -451,14 +502,6 @@ static CYTHON_INLINE float __PYX_NAN() { __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) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -478,7 +521,7 @@ static CYTHON_INLINE float __PYX_NAN() { #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif @@ -509,8 +552,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #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 (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -532,6 +575,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) @@ -542,16 +591,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #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) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #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 @@ -560,6 +604,8 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) #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_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS @@ -660,7 +706,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime; @@ -793,6 +839,52 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); +/* PyThreadStateGet.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() +#endif + +/* PyErrFetchRestore.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) +#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); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#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 + +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif + /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); @@ -915,17 +1007,31 @@ static PyMethodDef __pyx_methods[] = { }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_error_codes(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_error_codes}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "error_codes", 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ @@ -1006,10 +1112,54 @@ PyMODINIT_FUNC initerror_codes(void) #else PyMODINIT_FUNC PyInit_error_codes(void); /*proto*/ PyMODINIT_FUNC PyInit_error_codes(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec_error_codes(PyObject *__pyx_pyinit_module) +#endif #endif { PyObject *__pyx_t_1 = NULL; __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { @@ -1036,6 +1186,9 @@ PyMODINIT_FUNC PyInit_error_codes(void) #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_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 @@ -1047,12 +1200,17 @@ PyMODINIT_FUNC PyInit_error_codes(void) #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("error_codes", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -1150,7 +1308,7 @@ PyMODINIT_FUNC PyInit_error_codes(void) */ __pyx_t_1 = __Pyx_PyInt_From_int(LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_KEY_EXCHANGE_FAILU, __pyx_t_1) < 0) __PYX_ERR(0, 26, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_KEY_EXCHANGE_FAILU, __pyx_t_1) < 0) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "ssh2/error_codes.pyx":27 @@ -1258,7 +1416,7 @@ PyMODINIT_FUNC PyInit_error_codes(void) */ __pyx_t_1 = __Pyx_PyInt_From_int(LIBSSH2_ERROR_METHOD_NONE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_METHOD_NONE, __pyx_t_1) < 0) __PYX_ERR(0, 36, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_METHOD_NONE, __pyx_t_1) < 0) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "ssh2/error_codes.pyx":38 @@ -1270,7 +1428,7 @@ PyMODINIT_FUNC PyInit_error_codes(void) */ __pyx_t_1 = __Pyx_PyInt_From_int(LIBSSH2_ERROR_AUTHENTICATION_FAILED); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_AUTHENTICATION_FAI, __pyx_t_1) < 0) __PYX_ERR(0, 38, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_AUTHENTICATION_FAI, __pyx_t_1) < 0) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "ssh2/error_codes.pyx":40 @@ -1282,7 +1440,7 @@ PyMODINIT_FUNC PyInit_error_codes(void) */ __pyx_t_1 = __Pyx_PyInt_From_int(LIBSSH2_ERROR_AUTHENTICATION_FAILED); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_PUBLICKEY_UNRECOGN, __pyx_t_1) < 0) __PYX_ERR(0, 40, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_PUBLICKEY_UNRECOGN, __pyx_t_1) < 0) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "ssh2/error_codes.pyx":42 @@ -1294,7 +1452,7 @@ PyMODINIT_FUNC PyInit_error_codes(void) */ __pyx_t_1 = __Pyx_PyInt_From_int(LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_PUBLICKEY_UNVERIFI, __pyx_t_1) < 0) __PYX_ERR(0, 42, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_PUBLICKEY_UNVERIFI, __pyx_t_1) < 0) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "ssh2/error_codes.pyx":43 @@ -1330,7 +1488,7 @@ PyMODINIT_FUNC PyInit_error_codes(void) */ __pyx_t_1 = __Pyx_PyInt_From_int(LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_CHANNEL_REQUEST_DE, __pyx_t_1) < 0) __PYX_ERR(0, 46, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_CHANNEL_REQUEST_DE, __pyx_t_1) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "ssh2/error_codes.pyx":47 @@ -1354,7 +1512,7 @@ PyMODINIT_FUNC PyInit_error_codes(void) */ __pyx_t_1 = __Pyx_PyInt_From_int(LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_CHANNEL_WINDOW_EXC, __pyx_t_1) < 0) __PYX_ERR(0, 49, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_CHANNEL_WINDOW_EXC, __pyx_t_1) < 0) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "ssh2/error_codes.pyx":51 @@ -1366,7 +1524,7 @@ PyMODINIT_FUNC PyInit_error_codes(void) */ __pyx_t_1 = __Pyx_PyInt_From_int(LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_CHANNEL_PACKET_EXC, __pyx_t_1) < 0) __PYX_ERR(0, 51, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_CHANNEL_PACKET_EXC, __pyx_t_1) < 0) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "ssh2/error_codes.pyx":52 @@ -1462,7 +1620,7 @@ PyMODINIT_FUNC PyInit_error_codes(void) */ __pyx_t_1 = __Pyx_PyInt_From_int(LIBSSH2_ERROR_METHOD_NOT_SUPPORTED); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_METHOD_NOT_SUPPORT, __pyx_t_1) < 0) __PYX_ERR(0, 60, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_ERROR_METHOD_NOT_SUPPORT, __pyx_t_1) < 0) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "ssh2/error_codes.pyx":61 @@ -1626,7 +1784,7 @@ PyMODINIT_FUNC PyInit_error_codes(void) * # Copyright (C) 2017 Panos Kittenis * */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); 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_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1646,10 +1804,12 @@ PyMODINIT_FUNC PyInit_error_codes(void) } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -1676,10 +1836,14 @@ static int __Pyx_CLineForTraceback(int c_line) { #ifdef CYTHON_CLINE_IN_TRACEBACK return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; #else - PyObject **cython_runtime_dict; PyObject *use_cline; - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (unlikely(!cython_runtime_dict)) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { PyObject *ptype, *pvalue, *ptraceback; PyObject *use_cline_obj; PyErr_Fetch(&ptype, &pvalue, &ptraceback); @@ -1691,8 +1855,6 @@ static int __Pyx_CLineForTraceback(int c_line) { use_cline = NULL; } PyErr_Restore(ptype, pvalue, ptraceback); - } else { - use_cline = PyDict_GetItem(*_PyObject_GetDictPtr(__pyx_cython_runtime), __pyx_n_s_cline_in_traceback); } if (!use_cline) { c_line = 0; @@ -1856,10 +2018,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, __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*/ + __Pyx_PyThreadState_Current, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); @@ -2331,6 +2493,102 @@ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { return (int) -1; } +/* PyErrFetchRestore */ +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +} +#endif + +/* FastTypeChecks */ +#if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + /* CheckBinaryVersion */ static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; @@ -2387,46 +2645,53 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#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 && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); #endif +} #endif +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __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 && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -2450,6 +2715,26 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; @@ -2457,9 +2742,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS @@ -2467,32 +2752,30 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } #else - if (m && m->nb_int) { + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); } #endif #else - res = PyNumber_Int(x); + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { diff --git a/ssh2/exceptions.c b/ssh2/exceptions.c index 2cc73995..0d4fd8f7 100644 --- a/ssh2/exceptions.c +++ b/ssh2/exceptions.c @@ -1,13 +1,14 @@ -/* Generated by Cython 0.26 */ +/* Generated by Cython 0.27.1 */ #define PY_SSIZE_T_CLEAN #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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_26" +#define CYTHON_ABI "0_27_1" +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -31,7 +32,7 @@ #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif @@ -47,8 +48,14 @@ #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS @@ -67,6 +74,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -74,6 +85,8 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS @@ -98,6 +111,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -105,6 +122,12 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 @@ -144,6 +167,12 @@ #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -199,6 +228,27 @@ #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ @@ -282,7 +332,6 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject @@ -333,15 +382,17 @@ #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct 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)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) @@ -451,14 +502,6 @@ static CYTHON_INLINE float __PYX_NAN() { __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) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -473,7 +516,7 @@ static CYTHON_INLINE float __PYX_NAN() { #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif @@ -504,8 +547,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #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 (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -527,6 +570,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) @@ -537,16 +586,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #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) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #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 @@ -555,6 +599,8 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) #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_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS @@ -655,7 +701,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime; @@ -685,6 +731,7 @@ struct __pyx_obj_4ssh2_10exceptions_SessionHandshakeError; struct __pyx_obj_4ssh2_10exceptions_ChannelError; struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError; struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall; +struct __pyx_obj_4ssh2_10exceptions_SFTPIOError; /* "ssh2/exceptions.pxd":18 * @@ -811,12 +858,24 @@ struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError { * * cdef class SFTPBufferTooSmall(Exception): # <<<<<<<<<<<<<< * pass + * */ struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall { PyBaseExceptionObject __pyx_base; }; +/* "ssh2/exceptions.pxd":62 + * + * + * cdef class SFTPIOError(Exception): # <<<<<<<<<<<<<< + * pass + */ +struct __pyx_obj_4ssh2_10exceptions_SFTPIOError { + PyBaseExceptionObject __pyx_base; +}; + + /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY @@ -928,6 +987,52 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); +/* PyThreadStateGet.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() +#endif + +/* PyErrFetchRestore.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) +#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); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#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 + +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif + /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); @@ -947,6 +1052,7 @@ static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SessionHandshakeError = 0; static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_ChannelError = 0; static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPHandleError = 0; static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPIOError = 0; #define __Pyx_MODULE_NAME "ssh2.exceptions" int __pyx_module_is_main_ssh2__exceptions = 0; @@ -968,6 +1074,7 @@ static PyObject *__pyx_tp_new_4ssh2_10exceptions_SessionHandshakeError(PyTypeObj static PyObject *__pyx_tp_new_4ssh2_10exceptions_ChannelError(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_4ssh2_10exceptions_SFTPHandleError(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_4ssh2_10exceptions_SFTPBufferTooSmall(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_4ssh2_10exceptions_SFTPIOError(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_4ssh2_10exceptions_AgentError(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (&((PyTypeObject*)PyExc_Exception)[0])->tp_new(t, a, k); @@ -976,7 +1083,7 @@ static PyObject *__pyx_tp_new_4ssh2_10exceptions_AgentError(PyTypeObject *t, PyO } static void __pyx_tp_dealloc_4ssh2_10exceptions_AgentError(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -1062,7 +1169,7 @@ static PyObject *__pyx_tp_new_4ssh2_10exceptions_AuthenticationError(PyTypeObjec } static void __pyx_tp_dealloc_4ssh2_10exceptions_AuthenticationError(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -1404,7 +1511,7 @@ static PyObject *__pyx_tp_new_4ssh2_10exceptions_SessionStartupError(PyTypeObjec } static void __pyx_tp_dealloc_4ssh2_10exceptions_SessionStartupError(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -1490,7 +1597,7 @@ static PyObject *__pyx_tp_new_4ssh2_10exceptions_SessionHandshakeError(PyTypeObj } static void __pyx_tp_dealloc_4ssh2_10exceptions_SessionHandshakeError(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -1576,7 +1683,7 @@ static PyObject *__pyx_tp_new_4ssh2_10exceptions_ChannelError(PyTypeObject *t, P } static void __pyx_tp_dealloc_4ssh2_10exceptions_ChannelError(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -1662,7 +1769,7 @@ static PyObject *__pyx_tp_new_4ssh2_10exceptions_SFTPHandleError(PyTypeObject *t } static void __pyx_tp_dealloc_4ssh2_10exceptions_SFTPHandleError(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -1748,7 +1855,7 @@ static PyObject *__pyx_tp_new_4ssh2_10exceptions_SFTPBufferTooSmall(PyTypeObject } static void __pyx_tp_dealloc_4ssh2_10exceptions_SFTPBufferTooSmall(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -1827,22 +1934,122 @@ static PyTypeObject __pyx_type_4ssh2_10exceptions_SFTPBufferTooSmall = { #endif }; +static PyObject *__pyx_tp_new_4ssh2_10exceptions_SFTPIOError(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (&((PyTypeObject*)PyExc_Exception)[0])->tp_new(t, a, k); + if (unlikely(!o)) return 0; + return o; +} + +static void __pyx_tp_dealloc_4ssh2_10exceptions_SFTPIOError(PyObject *o) { + #if CYTHON_USE_TP_FINALIZE + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + PyObject_GC_Track(o); + (&((PyTypeObject*)PyExc_Exception)[0])->tp_dealloc(o); +} + +static int __pyx_tp_traverse_4ssh2_10exceptions_SFTPIOError(PyObject *o, visitproc v, void *a) { + int e; + if (!(&((PyTypeObject*)PyExc_Exception)[0])->tp_traverse); else { e = (&((PyTypeObject*)PyExc_Exception)[0])->tp_traverse(o,v,a); if (e) return e; } + return 0; +} + +static int __pyx_tp_clear_4ssh2_10exceptions_SFTPIOError(PyObject *o) { + if (!(&((PyTypeObject*)PyExc_Exception)[0])->tp_clear); else (&((PyTypeObject*)PyExc_Exception)[0])->tp_clear(o); + return 0; +} + +static PyTypeObject __pyx_type_4ssh2_10exceptions_SFTPIOError = { + PyVarObject_HEAD_INIT(0, 0) + "ssh2.exceptions.SFTPIOError", /*tp_name*/ + sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPIOError), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_4ssh2_10exceptions_SFTPIOError, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_4ssh2_10exceptions_SFTPIOError, /*tp_traverse*/ + __pyx_tp_clear_4ssh2_10exceptions_SFTPIOError, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + 0, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_4ssh2_10exceptions_SFTPIOError, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_exceptions(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_exceptions}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "exceptions", 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ @@ -1879,10 +2086,54 @@ PyMODINIT_FUNC initexceptions(void) #else PyMODINIT_FUNC PyInit_exceptions(void); /*proto*/ PyMODINIT_FUNC PyInit_exceptions(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec_exceptions(PyObject *__pyx_pyinit_module) +#endif #endif { PyObject *__pyx_t_1 = NULL; __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { @@ -1909,6 +2160,9 @@ PyMODINIT_FUNC PyInit_exceptions(void) #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_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 @@ -1920,12 +2174,17 @@ PyMODINIT_FUNC PyInit_exceptions(void) #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("exceptions", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -2013,6 +2272,11 @@ PyMODINIT_FUNC PyInit_exceptions(void) __pyx_type_4ssh2_10exceptions_SFTPBufferTooSmall.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "SFTPBufferTooSmall", (PyObject *)&__pyx_type_4ssh2_10exceptions_SFTPBufferTooSmall) < 0) __PYX_ERR(1, 58, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall = &__pyx_type_4ssh2_10exceptions_SFTPBufferTooSmall; + __pyx_type_4ssh2_10exceptions_SFTPIOError.tp_base = (&((PyTypeObject*)PyExc_Exception)[0]); + if (PyType_Ready(&__pyx_type_4ssh2_10exceptions_SFTPIOError) < 0) __PYX_ERR(1, 62, __pyx_L1_error) + __pyx_type_4ssh2_10exceptions_SFTPIOError.tp_print = 0; + if (PyObject_SetAttrString(__pyx_m, "SFTPIOError", (PyObject *)&__pyx_type_4ssh2_10exceptions_SFTPIOError) < 0) __PYX_ERR(1, 62, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_SFTPIOError = &__pyx_type_4ssh2_10exceptions_SFTPIOError; /*--- Type import code ---*/ /*--- Variable import code ---*/ /*--- Function import code ---*/ @@ -2024,7 +2288,7 @@ PyMODINIT_FUNC PyInit_exceptions(void) /* "ssh2/exceptions.pyx":1 # <<<<<<<<<<<<<< */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); 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_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2044,10 +2308,12 @@ PyMODINIT_FUNC PyInit_exceptions(void) } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -2074,10 +2340,14 @@ static int __Pyx_CLineForTraceback(int c_line) { #ifdef CYTHON_CLINE_IN_TRACEBACK return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; #else - PyObject **cython_runtime_dict; PyObject *use_cline; - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (unlikely(!cython_runtime_dict)) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { PyObject *ptype, *pvalue, *ptraceback; PyObject *use_cline_obj; PyErr_Fetch(&ptype, &pvalue, &ptraceback); @@ -2089,8 +2359,6 @@ static int __Pyx_CLineForTraceback(int c_line) { use_cline = NULL; } PyErr_Restore(ptype, pvalue, ptraceback); - } else { - use_cline = PyDict_GetItem(*_PyObject_GetDictPtr(__pyx_cython_runtime), __pyx_n_s_cline_in_traceback); } if (!use_cline) { c_line = 0; @@ -2254,10 +2522,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, __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*/ + __Pyx_PyThreadState_Current, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); @@ -2698,6 +2966,102 @@ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { return (int) -1; } +/* PyErrFetchRestore */ +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +} +#endif + +/* FastTypeChecks */ +#if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + /* CheckBinaryVersion */ static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; @@ -2754,46 +3118,53 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#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 && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} #endif #endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __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 && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -2817,6 +3188,26 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; @@ -2824,9 +3215,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS @@ -2834,32 +3225,30 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } #else - if (m && m->nb_int) { + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); } #endif #else - res = PyNumber_Int(x); + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { diff --git a/ssh2/exceptions.pxd b/ssh2/exceptions.pxd index 01a87528..c96c7ed6 100644 --- a/ssh2/exceptions.pxd +++ b/ssh2/exceptions.pxd @@ -57,3 +57,7 @@ cdef class SFTPHandleError(Exception): cdef class SFTPBufferTooSmall(Exception): pass + + +cdef class SFTPIOError(Exception): + pass diff --git a/ssh2/fileinfo.c b/ssh2/fileinfo.c index 1d228c29..9c662f0a 100644 --- a/ssh2/fileinfo.c +++ b/ssh2/fileinfo.c @@ -1,13 +1,14 @@ -/* Generated by Cython 0.26 */ +/* Generated by Cython 0.27.1 */ #define PY_SSIZE_T_CLEAN #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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_26" +#define CYTHON_ABI "0_27_1" +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -31,7 +32,7 @@ #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif @@ -47,8 +48,14 @@ #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS @@ -67,6 +74,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -74,6 +85,8 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS @@ -98,6 +111,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -105,6 +122,12 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 @@ -144,6 +167,12 @@ #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -199,6 +228,27 @@ #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ @@ -282,7 +332,6 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject @@ -333,15 +382,17 @@ #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct 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)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) @@ -451,14 +502,6 @@ static CYTHON_INLINE float __PYX_NAN() { __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) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -480,7 +523,7 @@ static CYTHON_INLINE float __PYX_NAN() { #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif @@ -511,8 +554,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #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 (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -534,6 +577,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) @@ -544,16 +593,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #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) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #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 @@ -562,6 +606,8 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) #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_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS @@ -662,7 +708,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime; @@ -792,6 +838,52 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); +/* PyThreadStateGet.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() +#endif + +/* PyErrFetchRestore.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) +#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); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#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 + +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif + /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); @@ -831,17 +923,31 @@ static PyMethodDef __pyx_methods[] = { }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_fileinfo(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_fileinfo}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "fileinfo", __pyx_k_Available_only_when_built_on_lib, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ @@ -878,10 +984,54 @@ PyMODINIT_FUNC initfileinfo(void) #else PyMODINIT_FUNC PyInit_fileinfo(void); /*proto*/ PyMODINIT_FUNC PyInit_fileinfo(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec_fileinfo(PyObject *__pyx_pyinit_module) +#endif #endif { PyObject *__pyx_t_1 = NULL; __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { @@ -908,6 +1058,9 @@ PyMODINIT_FUNC PyInit_fileinfo(void) #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_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 @@ -919,12 +1072,17 @@ PyMODINIT_FUNC PyInit_fileinfo(void) #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("fileinfo", __pyx_methods, __pyx_k_Available_only_when_built_on_lib, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -970,7 +1128,7 @@ PyMODINIT_FUNC PyInit_fileinfo(void) * # Copyright (C) 2017 Panos Kittenis * */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); 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_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -990,10 +1148,12 @@ PyMODINIT_FUNC PyInit_fileinfo(void) } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -1020,10 +1180,14 @@ static int __Pyx_CLineForTraceback(int c_line) { #ifdef CYTHON_CLINE_IN_TRACEBACK return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; #else - PyObject **cython_runtime_dict; PyObject *use_cline; - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (unlikely(!cython_runtime_dict)) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { PyObject *ptype, *pvalue, *ptraceback; PyObject *use_cline_obj; PyErr_Fetch(&ptype, &pvalue, &ptraceback); @@ -1035,8 +1199,6 @@ static int __Pyx_CLineForTraceback(int c_line) { use_cline = NULL; } PyErr_Restore(ptype, pvalue, ptraceback); - } else { - use_cline = PyDict_GetItem(*_PyObject_GetDictPtr(__pyx_cython_runtime), __pyx_n_s_cline_in_traceback); } if (!use_cline) { c_line = 0; @@ -1200,10 +1362,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, __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*/ + __Pyx_PyThreadState_Current, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); @@ -1644,6 +1806,102 @@ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { return (int) -1; } +/* PyErrFetchRestore */ +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +} +#endif + +/* FastTypeChecks */ +#if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + /* CheckBinaryVersion */ static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; @@ -1700,46 +1958,53 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#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 && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); #endif +} #endif +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __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 && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -1763,6 +2028,26 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; @@ -1770,9 +2055,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS @@ -1780,32 +2065,30 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } #else - if (m && m->nb_int) { + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); } #endif #else - res = PyNumber_Int(x); + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { diff --git a/ssh2/listener.c b/ssh2/listener.c index 47daf652..ad35b146 100644 --- a/ssh2/listener.c +++ b/ssh2/listener.c @@ -1,13 +1,14 @@ -/* Generated by Cython 0.26 */ +/* Generated by Cython 0.27.1 */ #define PY_SSIZE_T_CLEAN #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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_26" +#define CYTHON_ABI "0_27_1" +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -31,7 +32,7 @@ #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif @@ -47,8 +48,14 @@ #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS @@ -67,6 +74,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -74,6 +85,8 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS @@ -98,6 +111,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -105,6 +122,12 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 @@ -144,6 +167,12 @@ #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -199,6 +228,27 @@ #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ @@ -282,7 +332,6 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject @@ -333,15 +382,17 @@ #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct 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)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) @@ -451,14 +502,6 @@ static CYTHON_INLINE float __PYX_NAN() { __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) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -478,7 +521,7 @@ static CYTHON_INLINE float __PYX_NAN() { #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif @@ -509,8 +552,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #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 (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -532,6 +575,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) @@ -542,16 +591,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #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) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #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 @@ -560,6 +604,8 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) #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_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS @@ -660,7 +706,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime; @@ -679,23 +725,36 @@ static const char *__pyx_f[] = { "ssh2/session.pxd", "ssh2/channel.pxd", }; +/* NoFastGil.proto */ +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + /*--- Type declarations ---*/ struct __pyx_obj_4ssh2_7session_Session; struct __pyx_obj_4ssh2_7channel_Channel; struct __pyx_obj_4ssh2_8listener_Listener; -/* "session.pxd":20 - * +/* "session.pxd":19 + * cimport c_ssh2 * * cdef class Session: # <<<<<<<<<<<<<< * cdef c_ssh2.LIBSSH2_SESSION *_session - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL + * cdef int _sock */ struct __pyx_obj_4ssh2_7session_Session { PyObject_HEAD - struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtab; LIBSSH2_SESSION *_session; + int _sock; + PyObject *sock; }; @@ -727,21 +786,6 @@ struct __pyx_obj_4ssh2_8listener_Listener { }; - -/* "session.pxd":20 - * - * - * cdef class Session: # <<<<<<<<<<<<<< - * cdef c_ssh2.LIBSSH2_SESSION *_session - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL - */ - -struct __pyx_vtabstruct_4ssh2_7session_Session { - LIBSSH2_AGENT *(*init_connect_agent)(struct __pyx_obj_4ssh2_7session_Session *); - LIBSSH2_AGENT *(*_agent_init)(struct __pyx_obj_4ssh2_7session_Session *); -}; -static struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtabptr_4ssh2_7session_Session; - /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY @@ -847,31 +891,34 @@ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, /* ExtTypeTest.proto */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); -/* NoFastGil.proto */ -#define __Pyx_PyGILState_Ensure PyGILState_Ensure -#define __Pyx_PyGILState_Release PyGILState_Release -#define __Pyx_FastGIL_Remember() -#define __Pyx_FastGIL_Forget() -#define __Pyx_FastGilFuncInit() - /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #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); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif #else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #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) @@ -884,9 +931,6 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject /* SetupReduce.proto */ static int __Pyx_setup_reduce(PyObject* type_obj); -/* GetVTable.proto */ -static void* __Pyx_GetVtable(PyObject *dict); - /* CLineInTraceback.proto */ static int __Pyx_CLineForTraceback(int c_line); @@ -909,11 +953,6 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); -/* ForceInitThreads.proto */ -#ifndef __PYX_FORCE_INIT_THREADS - #define __PYX_FORCE_INIT_THREADS 0 -#endif - /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); @@ -926,6 +965,18 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif + /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); @@ -979,21 +1030,29 @@ int __pyx_module_is_main_ssh2__listener = 0; /* Implementation of 'ssh2.listener' */ static PyObject *__pyx_builtin_TypeError; static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_reduce[] = "__reduce__"; static const char __pyx_k_session[] = "session"; +static const char __pyx_k_getstate[] = "__getstate__"; +static const char __pyx_k_setstate[] = "__setstate__"; static const char __pyx_k_TypeError[] = "TypeError"; -static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; +static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_n_s_cline_in_traceback; +static PyObject *__pyx_n_s_getstate; static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_name; static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; -static PyObject *__pyx_n_s_pyx_vtable; +static PyObject *__pyx_n_s_reduce; static PyObject *__pyx_n_s_reduce_cython; +static PyObject *__pyx_n_s_reduce_ex; static PyObject *__pyx_n_s_session; +static PyObject *__pyx_n_s_setstate; static PyObject *__pyx_n_s_setstate_cython; static PyObject *__pyx_n_s_test; static int __pyx_pf_4ssh2_8listener_8Listener___cinit__(struct __pyx_obj_4ssh2_8listener_Listener *__pyx_v_self, PyObject *__pyx_v_session); /* proto */ @@ -1565,7 +1624,7 @@ static PyObject *__pyx_tp_new_4ssh2_8listener_Listener(PyTypeObject *t, PyObject static void __pyx_tp_dealloc_4ssh2_8listener_Listener(PyObject *o) { struct __pyx_obj_4ssh2_8listener_Listener *p = (struct __pyx_obj_4ssh2_8listener_Listener *)o; - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -1664,17 +1723,31 @@ static PyMethodDef __pyx_methods[] = { }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_listener(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_listener}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "listener", 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ @@ -1684,11 +1757,15 @@ static struct PyModuleDef __pyx_moduledef = { static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, + {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, - {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, + {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, {&__pyx_n_s_session, __pyx_k_session, sizeof(__pyx_k_session), 0, 0, 1, 1}, + {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} @@ -1742,11 +1819,55 @@ PyMODINIT_FUNC initlistener(void) #else PyMODINIT_FUNC PyInit_listener(void); /*proto*/ PyMODINIT_FUNC PyInit_listener(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec_listener(PyObject *__pyx_pyinit_module) +#endif #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { @@ -1773,6 +1894,9 @@ PyMODINIT_FUNC PyInit_listener(void) #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) #endif @@ -1784,12 +1908,17 @@ PyMODINIT_FUNC PyInit_listener(void) #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("listener", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(1, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(1, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(1, 1, __pyx_L1_error) @@ -1829,8 +1958,7 @@ PyMODINIT_FUNC PyInit_listener(void) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_8listener_Listener) < 0) __PYX_ERR(1, 29, __pyx_L1_error) __pyx_ptype_4ssh2_8listener_Listener = &__pyx_type_4ssh2_8listener_Listener; /*--- Type import code ---*/ - __pyx_ptype_4ssh2_7session_Session = __Pyx_ImportType("ssh2.session", "Session", sizeof(struct __pyx_obj_4ssh2_7session_Session), 1); if (unlikely(!__pyx_ptype_4ssh2_7session_Session)) __PYX_ERR(2, 20, __pyx_L1_error) - __pyx_vtabptr_4ssh2_7session_Session = (struct __pyx_vtabstruct_4ssh2_7session_Session*)__Pyx_GetVtable(__pyx_ptype_4ssh2_7session_Session->tp_dict); if (unlikely(!__pyx_vtabptr_4ssh2_7session_Session)) __PYX_ERR(2, 20, __pyx_L1_error) + __pyx_ptype_4ssh2_7session_Session = __Pyx_ImportType("ssh2.session", "Session", sizeof(struct __pyx_obj_4ssh2_7session_Session), 1); if (unlikely(!__pyx_ptype_4ssh2_7session_Session)) __PYX_ERR(2, 19, __pyx_L1_error) __pyx_ptype_4ssh2_7channel_Channel = __Pyx_ImportType("ssh2.channel", "Channel", sizeof(struct __pyx_obj_4ssh2_7channel_Channel), 1); if (unlikely(!__pyx_ptype_4ssh2_7channel_Channel)) __PYX_ERR(3, 24, __pyx_L1_error) /*--- Variable import code ---*/ /*--- Function import code ---*/ @@ -1847,7 +1975,7 @@ PyMODINIT_FUNC PyInit_listener(void) * # Copyright (C) 2017 Panos Kittenis * */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -1868,10 +1996,12 @@ PyMODINIT_FUNC PyInit_listener(void) } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -2075,7 +2205,7 @@ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } - if (likely(PyObject_TypeCheck(obj, type))) + if (likely(__Pyx_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); @@ -2222,11 +2352,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject "raise: exception class must be a subclass of BaseException"); goto bad; } -#if PY_VERSION_HEX >= 0x03030000 if (cause) { -#else - if (cause && cause != Py_None) { -#endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; @@ -2254,7 +2380,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else - PyThreadState *tstate = PyThreadState_GET(); + PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); @@ -2270,17 +2396,16 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject #endif /* SetupReduce */ - #define __Pyx_setup_reduce_GET_ATTR_OR_BAD(res, obj, name) res = PyObject_GetAttrString(obj, name); if (res == NULL) goto BAD; static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { int ret; PyObject *name_attr; - name_attr = PyObject_GetAttrString(meth, "__name__"); - if (name_attr) { + name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name); + if (likely(name_attr)) { ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); } else { ret = -1; } - if (ret < 0) { + if (unlikely(ret < 0)) { PyErr_Clear(); ret = 0; } @@ -2289,43 +2414,55 @@ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { } static int __Pyx_setup_reduce(PyObject* type_obj) { int ret = 0; - PyObject* builtin_object = NULL; - static PyObject *object_reduce = NULL; - static PyObject *object_reduce_ex = NULL; + PyObject *object_reduce = NULL; + PyObject *object_reduce_ex = NULL; PyObject *reduce = NULL; PyObject *reduce_ex = NULL; PyObject *reduce_cython = NULL; PyObject *setstate = NULL; PyObject *setstate_cython = NULL; - if (PyObject_HasAttrString(type_obj, "__getstate__")) goto GOOD; - if (object_reduce_ex == NULL) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(builtin_object, __pyx_b, "object"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce, builtin_object, "__reduce__"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce_ex, builtin_object, "__reduce_ex__"); - } - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_ex, type_obj, "__reduce_ex__"); +#if CYTHON_USE_PYTYPE_LOOKUP + if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD; +#else + if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD; +#endif +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#else + object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#endif + reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD; if (reduce_ex == object_reduce_ex) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce, type_obj, "__reduce__"); - if (object_reduce == reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_cython, type_obj, "__reduce_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce__", reduce_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce_cython__"); if (ret < 0) goto BAD; - setstate = PyObject_GetAttrString(type_obj, "__setstate__"); +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#else + object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#endif + reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD; + if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { + reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD; + setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); if (!setstate) PyErr_Clear(); if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(setstate_cython, type_obj, "__setstate_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate__", setstate_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate_cython__"); if (ret < 0) goto BAD; + setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD; } PyType_Modified((PyTypeObject*)type_obj); } } goto GOOD; BAD: - if (!PyErr_Occurred()) PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); + if (!PyErr_Occurred()) + PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); ret = -1; GOOD: - Py_XDECREF(builtin_object); +#if !CYTHON_USE_PYTYPE_LOOKUP + Py_XDECREF(object_reduce); + Py_XDECREF(object_reduce_ex); +#endif Py_XDECREF(reduce); Py_XDECREF(reduce_ex); Py_XDECREF(reduce_cython); @@ -2334,35 +2471,19 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { return ret; } -/* GetVTable */ - static void* __Pyx_GetVtable(PyObject *dict) { - void* ptr; - PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable); - if (!ob) - goto bad; -#if PY_VERSION_HEX >= 0x02070000 - ptr = PyCapsule_GetPointer(ob, 0); -#else - ptr = PyCObject_AsVoidPtr(ob); -#endif - if (!ptr && !PyErr_Occurred()) - PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); - Py_DECREF(ob); - return ptr; -bad: - Py_XDECREF(ob); - return NULL; -} - /* CLineInTraceback */ - static int __Pyx_CLineForTraceback(int c_line) { +static int __Pyx_CLineForTraceback(int c_line) { #ifdef CYTHON_CLINE_IN_TRACEBACK return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; #else - PyObject **cython_runtime_dict; PyObject *use_cline; - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (unlikely(!cython_runtime_dict)) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { PyObject *ptype, *pvalue, *ptraceback; PyObject *use_cline_obj; PyErr_Fetch(&ptype, &pvalue, &ptraceback); @@ -2374,8 +2495,6 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { use_cline = NULL; } PyErr_Restore(ptype, pvalue, ptraceback); - } else { - use_cline = PyDict_GetItem(*_PyObject_GetDictPtr(__pyx_cython_runtime), __pyx_n_s_cline_in_traceback); } if (!use_cline) { c_line = 0; @@ -2389,7 +2508,7 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { } /* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { +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; @@ -2469,7 +2588,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { } /* AddTraceback */ - #include "compile.h" +#include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( @@ -2539,10 +2658,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, __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*/ + __Pyx_PyThreadState_Current, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); @@ -2553,7 +2672,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -2584,7 +2703,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { +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) { @@ -2615,7 +2734,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ +#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) @@ -2637,7 +2756,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { +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 @@ -2826,7 +2945,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { +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 @@ -3014,8 +3133,80 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, return (int) -1; } +/* FastTypeChecks */ +#if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + /* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { +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()); @@ -3031,7 +3222,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* FunctionExport */ - static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { +static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { PyObject *d = 0; PyObject *cobj = 0; union { @@ -3068,7 +3259,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* ModuleImport */ - #ifndef __PYX_HAVE_RT_ImportModule +#ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; @@ -3086,7 +3277,7 @@ static PyObject *__Pyx_ImportModule(const char *name) { #endif /* TypeImport */ - #ifndef __PYX_HAVE_RT_ImportType +#ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) @@ -3151,7 +3342,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class #endif /* FunctionImport */ - #ifndef __PYX_HAVE_RT_ImportFunction +#ifndef __PYX_HAVE_RT_ImportFunction #define __PYX_HAVE_RT_ImportFunction static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { PyObject *d = 0; @@ -3205,7 +3396,7 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (** #endif /* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { @@ -3244,46 +3435,53 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#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 && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} #endif #endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __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 && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -3307,6 +3505,26 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; @@ -3314,9 +3532,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS @@ -3324,32 +3542,30 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } #else - if (m && m->nb_int) { + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); } #endif #else - res = PyNumber_Int(x); + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { diff --git a/ssh2/pkey.c b/ssh2/pkey.c index 3986d75f..c75cb84c 100644 --- a/ssh2/pkey.c +++ b/ssh2/pkey.c @@ -1,13 +1,14 @@ -/* Generated by Cython 0.26 */ +/* Generated by Cython 0.27.1 */ #define PY_SSIZE_T_CLEAN #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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_26" +#define CYTHON_ABI "0_27_1" +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -31,7 +32,7 @@ #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif @@ -47,8 +48,14 @@ #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS @@ -67,6 +74,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -74,6 +85,8 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS @@ -98,6 +111,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -105,6 +122,12 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 @@ -144,6 +167,12 @@ #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -199,6 +228,27 @@ #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ @@ -282,7 +332,6 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject @@ -333,15 +382,17 @@ #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct 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)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) @@ -451,14 +502,6 @@ static CYTHON_INLINE float __PYX_NAN() { __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) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -478,7 +521,7 @@ static CYTHON_INLINE float __PYX_NAN() { #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif @@ -509,8 +552,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #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 (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -532,6 +575,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) @@ -542,16 +591,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #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) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #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 @@ -560,6 +604,8 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) #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_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS @@ -660,7 +706,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime; @@ -788,26 +834,36 @@ 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); /* KeywordStringCheck.proto */ -static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); +static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #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); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #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) @@ -854,6 +910,18 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif + /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); @@ -882,17 +950,27 @@ int __pyx_module_is_main_ssh2__pkey = 0; /* Implementation of 'ssh2.pkey' */ static PyObject *__pyx_builtin_TypeError; static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_reduce[] = "__reduce__"; +static const char __pyx_k_getstate[] = "__getstate__"; +static const char __pyx_k_setstate[] = "__setstate__"; static const char __pyx_k_TypeError[] = "TypeError"; +static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_n_s_cline_in_traceback; +static PyObject *__pyx_n_s_getstate; static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_name; static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; +static PyObject *__pyx_n_s_reduce; static PyObject *__pyx_n_s_reduce_cython; +static PyObject *__pyx_n_s_reduce_ex; +static PyObject *__pyx_n_s_setstate; static PyObject *__pyx_n_s_setstate_cython; static PyObject *__pyx_n_s_test; static int __pyx_pf_4ssh2_4pkey_9PublicKey___cinit__(struct __pyx_obj_4ssh2_4pkey_PublicKey *__pyx_v_self); /* proto */ @@ -1512,7 +1590,7 @@ static PyObject *__pyx_tp_new_4ssh2_4pkey_PublicKey(PyTypeObject *t, CYTHON_UNUS } static void __pyx_tp_dealloc_4ssh2_4pkey_PublicKey(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -1613,17 +1691,31 @@ static PyMethodDef __pyx_methods[] = { }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_pkey(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_pkey}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "pkey", 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ @@ -1633,9 +1725,14 @@ static struct PyModuleDef __pyx_moduledef = { static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, + {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, + {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, + {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} @@ -1689,10 +1786,54 @@ PyMODINIT_FUNC initpkey(void) #else PyMODINIT_FUNC PyInit_pkey(void); /*proto*/ PyMODINIT_FUNC PyInit_pkey(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec_pkey(PyObject *__pyx_pyinit_module) +#endif #endif { PyObject *__pyx_t_1 = NULL; __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { @@ -1719,6 +1860,9 @@ PyMODINIT_FUNC PyInit_pkey(void) #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) #endif @@ -1730,12 +1874,17 @@ PyMODINIT_FUNC PyInit_pkey(void) #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("pkey", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(1, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(1, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(1, 1, __pyx_L1_error) @@ -1787,7 +1936,7 @@ PyMODINIT_FUNC PyInit_pkey(void) * # Copyright (C) 2017 Panos Kittenis * */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -1807,10 +1956,12 @@ PyMODINIT_FUNC PyInit_pkey(void) } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -1893,7 +2044,7 @@ static void __Pyx_RaiseArgtupleInvalid( } /* KeywordStringCheck */ -static CYTHON_INLINE int __Pyx_CheckKeywordStrings( +static int __Pyx_CheckKeywordStrings( PyObject *kwdict, const char* function_name, int kw_allowed) @@ -1907,7 +2058,7 @@ static CYTHON_INLINE int __Pyx_CheckKeywordStrings( #else while (PyDict_Next(kwdict, &pos, &key, 0)) { #if PY_MAJOR_VERSION < 3 - if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) + if (unlikely(!PyString_Check(key))) #endif if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type; @@ -2072,11 +2223,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject "raise: exception class must be a subclass of BaseException"); goto bad; } -#if PY_VERSION_HEX >= 0x03030000 if (cause) { -#else - if (cause && cause != Py_None) { -#endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; @@ -2104,7 +2251,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else - PyThreadState *tstate = PyThreadState_GET(); + PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); @@ -2120,17 +2267,16 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject #endif /* SetupReduce */ - #define __Pyx_setup_reduce_GET_ATTR_OR_BAD(res, obj, name) res = PyObject_GetAttrString(obj, name); if (res == NULL) goto BAD; static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { int ret; PyObject *name_attr; - name_attr = PyObject_GetAttrString(meth, "__name__"); - if (name_attr) { + name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name); + if (likely(name_attr)) { ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); } else { ret = -1; } - if (ret < 0) { + if (unlikely(ret < 0)) { PyErr_Clear(); ret = 0; } @@ -2139,43 +2285,55 @@ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { } static int __Pyx_setup_reduce(PyObject* type_obj) { int ret = 0; - PyObject* builtin_object = NULL; - static PyObject *object_reduce = NULL; - static PyObject *object_reduce_ex = NULL; + PyObject *object_reduce = NULL; + PyObject *object_reduce_ex = NULL; PyObject *reduce = NULL; PyObject *reduce_ex = NULL; PyObject *reduce_cython = NULL; PyObject *setstate = NULL; PyObject *setstate_cython = NULL; - if (PyObject_HasAttrString(type_obj, "__getstate__")) goto GOOD; - if (object_reduce_ex == NULL) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(builtin_object, __pyx_b, "object"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce, builtin_object, "__reduce__"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce_ex, builtin_object, "__reduce_ex__"); - } - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_ex, type_obj, "__reduce_ex__"); +#if CYTHON_USE_PYTYPE_LOOKUP + if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD; +#else + if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD; +#endif +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#else + object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#endif + reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD; if (reduce_ex == object_reduce_ex) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce, type_obj, "__reduce__"); - if (object_reduce == reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_cython, type_obj, "__reduce_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce__", reduce_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce_cython__"); if (ret < 0) goto BAD; - setstate = PyObject_GetAttrString(type_obj, "__setstate__"); +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#else + object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#endif + reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD; + if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { + reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD; + setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); if (!setstate) PyErr_Clear(); if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(setstate_cython, type_obj, "__setstate_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate__", setstate_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate_cython__"); if (ret < 0) goto BAD; + setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD; } PyType_Modified((PyTypeObject*)type_obj); } } goto GOOD; BAD: - if (!PyErr_Occurred()) PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); + if (!PyErr_Occurred()) + PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); ret = -1; GOOD: - Py_XDECREF(builtin_object); +#if !CYTHON_USE_PYTYPE_LOOKUP + Py_XDECREF(object_reduce); + Py_XDECREF(object_reduce_ex); +#endif Py_XDECREF(reduce); Py_XDECREF(reduce_ex); Py_XDECREF(reduce_cython); @@ -2185,14 +2343,18 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { } /* CLineInTraceback */ - static int __Pyx_CLineForTraceback(int c_line) { +static int __Pyx_CLineForTraceback(int c_line) { #ifdef CYTHON_CLINE_IN_TRACEBACK return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; #else - PyObject **cython_runtime_dict; PyObject *use_cline; - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (unlikely(!cython_runtime_dict)) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { PyObject *ptype, *pvalue, *ptraceback; PyObject *use_cline_obj; PyErr_Fetch(&ptype, &pvalue, &ptraceback); @@ -2204,8 +2366,6 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { use_cline = NULL; } PyErr_Restore(ptype, pvalue, ptraceback); - } else { - use_cline = PyDict_GetItem(*_PyObject_GetDictPtr(__pyx_cython_runtime), __pyx_n_s_cline_in_traceback); } if (!use_cline) { c_line = 0; @@ -2219,7 +2379,7 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { } /* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { +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; @@ -2299,7 +2459,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { } /* AddTraceback */ - #include "compile.h" +#include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( @@ -2369,10 +2529,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, __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*/ + __Pyx_PyThreadState_Current, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); @@ -2383,7 +2543,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) { +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) { @@ -2414,7 +2574,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { +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) { @@ -2445,7 +2605,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ +#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) @@ -2467,7 +2627,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { +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 @@ -2656,7 +2816,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { +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 @@ -2844,8 +3004,80 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, return (int) -1; } +/* FastTypeChecks */ +#if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + /* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { +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()); @@ -2861,7 +3093,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* FunctionExport */ - static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { +static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { PyObject *d = 0; PyObject *cobj = 0; union { @@ -2898,7 +3130,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { @@ -2937,46 +3169,53 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#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 && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); #endif +} #endif +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __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 && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -3000,6 +3239,26 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; @@ -3007,9 +3266,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS @@ -3017,32 +3276,30 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } #else - if (m && m->nb_int) { + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); } #endif #else - res = PyNumber_Int(x); + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { diff --git a/ssh2/publickey.c b/ssh2/publickey.c index 75c856dc..498e5ffe 100644 --- a/ssh2/publickey.c +++ b/ssh2/publickey.c @@ -1,13 +1,14 @@ -/* Generated by Cython 0.26 */ +/* Generated by Cython 0.27.1 */ #define PY_SSIZE_T_CLEAN #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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_26" +#define CYTHON_ABI "0_27_1" +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -31,7 +32,7 @@ #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif @@ -47,8 +48,14 @@ #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS @@ -67,6 +74,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -74,6 +85,8 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS @@ -98,6 +111,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -105,6 +122,12 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 @@ -144,6 +167,12 @@ #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -199,6 +228,27 @@ #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ @@ -282,7 +332,6 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject @@ -333,15 +382,17 @@ #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct 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)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) @@ -451,14 +502,6 @@ static CYTHON_INLINE float __PYX_NAN() { __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) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -481,7 +524,7 @@ static CYTHON_INLINE float __PYX_NAN() { #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif @@ -512,8 +555,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #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 (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -535,6 +578,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) @@ -545,16 +594,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #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) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #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 @@ -563,6 +607,8 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) #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_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS @@ -663,7 +709,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime; @@ -681,6 +727,18 @@ static const char *__pyx_f[] = { "ssh2/publickey.pyx", "ssh2/session.pxd", }; +/* NoFastGil.proto */ +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + /*--- Type declarations ---*/ struct __pyx_obj_4ssh2_7session_Session; @@ -688,17 +746,18 @@ struct __pyx_obj_4ssh2_9publickey_PublicKeyList; struct __pyx_obj_4ssh2_9publickey_PublicKeyAttribute; struct __pyx_obj_4ssh2_9publickey_PublicKeySystem; -/* "session.pxd":20 - * +/* "session.pxd":19 + * cimport c_ssh2 * * cdef class Session: # <<<<<<<<<<<<<< * cdef c_ssh2.LIBSSH2_SESSION *_session - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL + * cdef int _sock */ struct __pyx_obj_4ssh2_7session_Session { PyObject_HEAD - struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtab; LIBSSH2_SESSION *_session; + int _sock; + PyObject *sock; }; @@ -743,21 +802,6 @@ struct __pyx_obj_4ssh2_9publickey_PublicKeySystem { }; - -/* "session.pxd":20 - * - * - * cdef class Session: # <<<<<<<<<<<<<< - * cdef c_ssh2.LIBSSH2_SESSION *_session - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL - */ - -struct __pyx_vtabstruct_4ssh2_7session_Session { - LIBSSH2_AGENT *(*init_connect_agent)(struct __pyx_obj_4ssh2_7session_Session *); - LIBSSH2_AGENT *(*_agent_init)(struct __pyx_obj_4ssh2_7session_Session *); -}; -static struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtabptr_4ssh2_7session_Session; - /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY @@ -861,34 +905,39 @@ 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); /* ArgTypeTest.proto */ -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); - -/* NoFastGil.proto */ -#define __Pyx_PyGILState_Ensure PyGILState_Ensure -#define __Pyx_PyGILState_Release PyGILState_Release -#define __Pyx_FastGIL_Remember() -#define __Pyx_FastGIL_Forget() -#define __Pyx_FastGilFuncInit() +#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ + ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ + __Pyx__ArgTypeTest(obj, type, name, exact)) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #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); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif #else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #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) @@ -898,11 +947,6 @@ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject /* RaiseException.proto */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); -/* ForceInitThreads.proto */ -#ifndef __PYX_FORCE_INIT_THREADS - #define __PYX_FORCE_INIT_THREADS 0 -#endif - /* WriteUnraisableException.proto */ static void __Pyx_WriteUnraisable(const char *name, int clineno, int lineno, const char *filename, @@ -955,9 +999,6 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /* SetupReduce.proto */ static int __Pyx_setup_reduce(PyObject* type_obj); -/* GetVTable.proto */ -static void* __Pyx_GetVtable(PyObject *dict); - /* CLineInTraceback.proto */ static int __Pyx_CLineForTraceback(int c_line); @@ -1007,6 +1048,18 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif + /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); @@ -1081,18 +1134,22 @@ static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_attrs[] = "attrs"; static const char __pyx_k_range[] = "range"; static const char __pyx_k_value[] = "value"; +static const char __pyx_k_name_2[] = "__name__"; static const char __pyx_k_pkey_s[] = "pkey_s"; +static const char __pyx_k_reduce[] = "__reduce__"; static const char __pyx_k_session[] = "session"; static const char __pyx_k_KeyError[] = "KeyError"; static const char __pyx_k_blob_len[] = "blob_len"; +static const char __pyx_k_getstate[] = "__getstate__"; static const char __pyx_k_name_len[] = "name_len"; +static const char __pyx_k_setstate[] = "__setstate__"; static const char __pyx_k_TypeError[] = "TypeError"; static const char __pyx_k_mandatory[] = "mandatory"; static const char __pyx_k_num_attrs[] = "num_attrs"; static const char __pyx_k_overwrite[] = "overwrite"; +static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; static const char __pyx_k_value_len[] = "value_len"; static const char __pyx_k_ValueError[] = "ValueError"; -static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; static const char __pyx_k_MemoryError[] = "MemoryError"; static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; @@ -1117,18 +1174,22 @@ static PyObject *__pyx_n_s_attrs; static PyObject *__pyx_n_s_blob; static PyObject *__pyx_n_s_blob_len; static PyObject *__pyx_n_s_cline_in_traceback; +static PyObject *__pyx_n_s_getstate; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_mandatory; static PyObject *__pyx_n_s_name; +static PyObject *__pyx_n_s_name_2; static PyObject *__pyx_n_s_name_len; static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; static PyObject *__pyx_n_s_num_attrs; static PyObject *__pyx_n_s_overwrite; static PyObject *__pyx_n_s_pkey_s; -static PyObject *__pyx_n_s_pyx_vtable; static PyObject *__pyx_n_s_range; +static PyObject *__pyx_n_s_reduce; static PyObject *__pyx_n_s_reduce_cython; +static PyObject *__pyx_n_s_reduce_ex; static PyObject *__pyx_n_s_session; +static PyObject *__pyx_n_s_setstate; static PyObject *__pyx_n_s_setstate_cython; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_value; @@ -1964,7 +2025,11 @@ static int __pyx_pf_4ssh2_9publickey_18PublicKeyAttribute___cinit__(struct __pyx * cdef char *_value = value * cdef unsigned long name_len = len(name) */ - __pyx_t_1 = __Pyx_PyObject_AsWritableString(__pyx_v_name); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(1, 69, __pyx_L1_error) + if (unlikely(__pyx_v_name == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(1, 69, __pyx_L1_error) + } + __pyx_t_1 = __Pyx_PyBytes_AsWritableString(__pyx_v_name); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(1, 69, __pyx_L1_error) __pyx_v__name = __pyx_t_1; /* "ssh2/publickey.pyx":70 @@ -1974,7 +2039,11 @@ static int __pyx_pf_4ssh2_9publickey_18PublicKeyAttribute___cinit__(struct __pyx * cdef unsigned long name_len = len(name) * cdef unsigned long value_len = len(value) */ - __pyx_t_1 = __Pyx_PyObject_AsWritableString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(1, 70, __pyx_L1_error) + if (unlikely(__pyx_v_value == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(1, 70, __pyx_L1_error) + } + __pyx_t_1 = __Pyx_PyBytes_AsWritableString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(1, 70, __pyx_L1_error) __pyx_v__value = __pyx_t_1; /* "ssh2/publickey.pyx":71 @@ -1988,7 +2057,7 @@ static int __pyx_pf_4ssh2_9publickey_18PublicKeyAttribute___cinit__(struct __pyx PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(1, 71, __pyx_L1_error) } - __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v_name); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(1, 71, __pyx_L1_error) + __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v_name); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(1, 71, __pyx_L1_error) __pyx_v_name_len = __pyx_t_2; /* "ssh2/publickey.pyx":72 @@ -2002,7 +2071,7 @@ static int __pyx_pf_4ssh2_9publickey_18PublicKeyAttribute___cinit__(struct __pyx PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(1, 72, __pyx_L1_error) } - __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v_value); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(1, 72, __pyx_L1_error) + __pyx_t_2 = PyBytes_GET_SIZE(__pyx_v_value); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(1, 72, __pyx_L1_error) __pyx_v_value_len = __pyx_t_2; /* "ssh2/publickey.pyx":74 @@ -2489,7 +2558,7 @@ static libssh2_publickey_attribute *__pyx_f_4ssh2_9publickey_to_c_attr(PyObject PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(1, 99, __pyx_L1_error) } - __pyx_t_1 = PyList_GET_SIZE(__pyx_v_attrs); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 99, __pyx_L1_error) + __pyx_t_1 = PyList_GET_SIZE(__pyx_v_attrs); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 99, __pyx_L1_error) __pyx_v_size = __pyx_t_1; /* "ssh2/publickey.pyx":101 @@ -3089,7 +3158,7 @@ static PyObject *__pyx_pf_4ssh2_9publickey_15PublicKeySystem_4add(struct __pyx_o PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(1, 139, __pyx_L1_error) } - __pyx_t_1 = PyBytes_GET_SIZE(__pyx_v_name); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 139, __pyx_L1_error) + __pyx_t_1 = PyBytes_GET_SIZE(__pyx_v_name); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 139, __pyx_L1_error) __pyx_v_name_len = __pyx_t_1; /* "ssh2/publickey.pyx":140 @@ -3103,7 +3172,7 @@ static PyObject *__pyx_pf_4ssh2_9publickey_15PublicKeySystem_4add(struct __pyx_o PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(1, 140, __pyx_L1_error) } - __pyx_t_1 = PyList_GET_SIZE(__pyx_v_attrs); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 140, __pyx_L1_error) + __pyx_t_1 = PyList_GET_SIZE(__pyx_v_attrs); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 140, __pyx_L1_error) __pyx_v_num_attrs = __pyx_t_1; /* "ssh2/publickey.pyx":141 @@ -3150,7 +3219,11 @@ static PyObject *__pyx_pf_4ssh2_9publickey_15PublicKeySystem_4add(struct __pyx_o * cdef size_t blob_len = len(blob) * cdef const unsigned char *_blob = blob */ - __pyx_t_3 = __Pyx_PyObject_AsUString(__pyx_v_name); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(1, 144, __pyx_L1_error) + if (unlikely(__pyx_v_name == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(1, 144, __pyx_L1_error) + } + __pyx_t_3 = __Pyx_PyBytes_AsUString(__pyx_v_name); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(1, 144, __pyx_L1_error) __pyx_v__name = __pyx_t_3; /* "ssh2/publickey.pyx":145 @@ -3164,7 +3237,7 @@ static PyObject *__pyx_pf_4ssh2_9publickey_15PublicKeySystem_4add(struct __pyx_o PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(1, 145, __pyx_L1_error) } - __pyx_t_1 = PyBytes_GET_SIZE(__pyx_v_blob); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 145, __pyx_L1_error) + __pyx_t_1 = PyBytes_GET_SIZE(__pyx_v_blob); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 145, __pyx_L1_error) __pyx_v_blob_len = __pyx_t_1; /* "ssh2/publickey.pyx":146 @@ -3174,7 +3247,11 @@ static PyObject *__pyx_pf_4ssh2_9publickey_15PublicKeySystem_4add(struct __pyx_o * with nogil: * rc = c_pkey.libssh2_publickey_add_ex( */ - __pyx_t_4 = __Pyx_PyObject_AsUString(__pyx_v_blob); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(1, 146, __pyx_L1_error) + if (unlikely(__pyx_v_blob == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(1, 146, __pyx_L1_error) + } + __pyx_t_4 = __Pyx_PyBytes_AsUString(__pyx_v_blob); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(1, 146, __pyx_L1_error) __pyx_v__blob = __pyx_t_4; /* "ssh2/publickey.pyx":147 @@ -3383,7 +3460,7 @@ static PyObject *__pyx_pf_4ssh2_9publickey_15PublicKeySystem_6remove(struct __py PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(1, 156, __pyx_L1_error) } - __pyx_t_1 = PyBytes_GET_SIZE(__pyx_v_name); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 156, __pyx_L1_error) + __pyx_t_1 = PyBytes_GET_SIZE(__pyx_v_name); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 156, __pyx_L1_error) __pyx_v_name_len = __pyx_t_1; /* "ssh2/publickey.pyx":157 @@ -3397,7 +3474,7 @@ static PyObject *__pyx_pf_4ssh2_9publickey_15PublicKeySystem_6remove(struct __py PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(1, 157, __pyx_L1_error) } - __pyx_t_1 = PyBytes_GET_SIZE(__pyx_v_blob); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 157, __pyx_L1_error) + __pyx_t_1 = PyBytes_GET_SIZE(__pyx_v_blob); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 157, __pyx_L1_error) __pyx_v_blob_len = __pyx_t_1; /* "ssh2/publickey.pyx":158 @@ -3407,7 +3484,11 @@ static PyObject *__pyx_pf_4ssh2_9publickey_15PublicKeySystem_6remove(struct __py * cdef const unsigned char *_blob = blob * with nogil: */ - __pyx_t_2 = __Pyx_PyObject_AsUString(__pyx_v_name); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(1, 158, __pyx_L1_error) + if (unlikely(__pyx_v_name == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(1, 158, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsUString(__pyx_v_name); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(1, 158, __pyx_L1_error) __pyx_v__name = __pyx_t_2; /* "ssh2/publickey.pyx":159 @@ -3417,7 +3498,11 @@ static PyObject *__pyx_pf_4ssh2_9publickey_15PublicKeySystem_6remove(struct __py * with nogil: * rc = c_pkey.libssh2_publickey_remove_ex( */ - __pyx_t_3 = __Pyx_PyObject_AsUString(__pyx_v_blob); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(1, 159, __pyx_L1_error) + if (unlikely(__pyx_v_blob == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(1, 159, __pyx_L1_error) + } + __pyx_t_3 = __Pyx_PyBytes_AsUString(__pyx_v_blob); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(1, 159, __pyx_L1_error) __pyx_v__blob = __pyx_t_3; /* "ssh2/publickey.pyx":160 @@ -4060,7 +4145,6 @@ static libssh2_publickey_attribute __pyx_convert__from_py_libssh2_publickey_attr __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L9_try_end; __pyx_L4_error:; - __Pyx_PyThreadState_assign __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; /* "FromPyStructUtility":18 @@ -4101,7 +4185,6 @@ static libssh2_publickey_attribute __pyx_convert__from_py_libssh2_publickey_attr * value = obj['name'] * except KeyError: */ - __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); @@ -4161,7 +4244,6 @@ static libssh2_publickey_attribute __pyx_convert__from_py_libssh2_publickey_attr __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L17_try_end; __pyx_L12_error:; - __Pyx_PyThreadState_assign __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; @@ -4205,7 +4287,6 @@ static libssh2_publickey_attribute __pyx_convert__from_py_libssh2_publickey_attr * value = obj['name_len'] * except KeyError: */ - __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); @@ -4265,7 +4346,6 @@ static libssh2_publickey_attribute __pyx_convert__from_py_libssh2_publickey_attr __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L25_try_end; __pyx_L20_error:; - __Pyx_PyThreadState_assign __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; @@ -4309,7 +4389,6 @@ static libssh2_publickey_attribute __pyx_convert__from_py_libssh2_publickey_attr * value = obj['value'] * except KeyError: */ - __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); @@ -4369,7 +4448,6 @@ static libssh2_publickey_attribute __pyx_convert__from_py_libssh2_publickey_attr __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L33_try_end; __pyx_L28_error:; - __Pyx_PyThreadState_assign __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; @@ -4413,7 +4491,6 @@ static libssh2_publickey_attribute __pyx_convert__from_py_libssh2_publickey_attr * value = obj['value_len'] * except KeyError: */ - __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); @@ -4473,7 +4550,6 @@ static libssh2_publickey_attribute __pyx_convert__from_py_libssh2_publickey_attr __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L41_try_end; __pyx_L36_error:; - __Pyx_PyThreadState_assign __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; @@ -4517,7 +4593,6 @@ static libssh2_publickey_attribute __pyx_convert__from_py_libssh2_publickey_attr * value = obj['mandatory'] * except KeyError: */ - __Pyx_PyThreadState_assign __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); @@ -4588,7 +4663,7 @@ static PyObject *__pyx_tp_new_4ssh2_9publickey_PublicKeyList(PyTypeObject *t, Py static void __pyx_tp_dealloc_4ssh2_9publickey_PublicKeyList(PyObject *o) { struct __pyx_obj_4ssh2_9publickey_PublicKeyList *p = (struct __pyx_obj_4ssh2_9publickey_PublicKeyList *)o; - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -4733,7 +4808,7 @@ static PyObject *__pyx_tp_new_4ssh2_9publickey_PublicKeyAttribute(PyTypeObject * } static void __pyx_tp_dealloc_4ssh2_9publickey_PublicKeyAttribute(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -4854,7 +4929,7 @@ static PyObject *__pyx_tp_new_4ssh2_9publickey_PublicKeySystem(PyTypeObject *t, static void __pyx_tp_dealloc_4ssh2_9publickey_PublicKeySystem(PyObject *o) { struct __pyx_obj_4ssh2_9publickey_PublicKeySystem *p = (struct __pyx_obj_4ssh2_9publickey_PublicKeySystem *)o; - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -4964,17 +5039,31 @@ static PyMethodDef __pyx_methods[] = { }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_publickey(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_publickey}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "publickey", 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ @@ -4996,18 +5085,22 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_blob, __pyx_k_blob, sizeof(__pyx_k_blob), 0, 0, 1, 1}, {&__pyx_n_s_blob_len, __pyx_k_blob_len, sizeof(__pyx_k_blob_len), 0, 0, 1, 1}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, + {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_mandatory, __pyx_k_mandatory, sizeof(__pyx_k_mandatory), 0, 0, 1, 1}, {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, + {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1}, {&__pyx_n_s_name_len, __pyx_k_name_len, sizeof(__pyx_k_name_len), 0, 0, 1, 1}, {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, {&__pyx_n_s_num_attrs, __pyx_k_num_attrs, sizeof(__pyx_k_num_attrs), 0, 0, 1, 1}, {&__pyx_n_s_overwrite, __pyx_k_overwrite, sizeof(__pyx_k_overwrite), 0, 0, 1, 1}, {&__pyx_n_s_pkey_s, __pyx_k_pkey_s, sizeof(__pyx_k_pkey_s), 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_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, + {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, {&__pyx_n_s_session, __pyx_k_session, sizeof(__pyx_k_session), 0, 0, 1, 1}, + {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1}, @@ -5160,11 +5253,55 @@ PyMODINIT_FUNC initpublickey(void) #else PyMODINIT_FUNC PyInit_publickey(void); /*proto*/ PyMODINIT_FUNC PyInit_publickey(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec_publickey(PyObject *__pyx_pyinit_module) +#endif #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { @@ -5191,6 +5328,9 @@ PyMODINIT_FUNC PyInit_publickey(void) #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) #endif @@ -5202,12 +5342,17 @@ PyMODINIT_FUNC PyInit_publickey(void) #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("publickey", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(1, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(1, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(1, 1, __pyx_L1_error) @@ -5258,8 +5403,7 @@ PyMODINIT_FUNC PyInit_publickey(void) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_9publickey_PublicKeySystem) < 0) __PYX_ERR(1, 121, __pyx_L1_error) __pyx_ptype_4ssh2_9publickey_PublicKeySystem = &__pyx_type_4ssh2_9publickey_PublicKeySystem; /*--- Type import code ---*/ - __pyx_ptype_4ssh2_7session_Session = __Pyx_ImportType("ssh2.session", "Session", sizeof(struct __pyx_obj_4ssh2_7session_Session), 1); if (unlikely(!__pyx_ptype_4ssh2_7session_Session)) __PYX_ERR(2, 20, __pyx_L1_error) - __pyx_vtabptr_4ssh2_7session_Session = (struct __pyx_vtabstruct_4ssh2_7session_Session*)__Pyx_GetVtable(__pyx_ptype_4ssh2_7session_Session->tp_dict); if (unlikely(!__pyx_vtabptr_4ssh2_7session_Session)) __PYX_ERR(2, 20, __pyx_L1_error) + __pyx_ptype_4ssh2_7session_Session = __Pyx_ImportType("ssh2.session", "Session", sizeof(struct __pyx_obj_4ssh2_7session_Session), 1); if (unlikely(!__pyx_ptype_4ssh2_7session_Session)) __PYX_ERR(2, 19, __pyx_L1_error) /*--- Variable import code ---*/ /*--- Function import code ---*/ __pyx_t_1 = __Pyx_ImportModule("ssh2.utils"); if (!__pyx_t_1) __PYX_ERR(1, 1, __pyx_L1_error) @@ -5275,7 +5419,7 @@ PyMODINIT_FUNC PyInit_publickey(void) * # Copyright (C) 2017 Panos Kittenis * */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -5304,10 +5448,12 @@ PyMODINIT_FUNC PyInit_publickey(void) } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -5506,29 +5652,23 @@ static void __Pyx_RaiseArgtupleInvalid( } /* 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); -} -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } - if (none_allowed && obj == Py_None) return 1; else if (exact) { - if (likely(Py_TYPE(obj) == type)) return 1; #if PY_MAJOR_VERSION == 2 - else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { - if (likely(PyObject_TypeCheck(obj, type))) return 1; + if (likely(__Pyx_TypeCheck(obj, type))) return 1; } - __Pyx_RaiseArgumentTypeInvalid(name, obj, type); + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); return 0; } @@ -5672,11 +5812,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject "raise: exception class must be a subclass of BaseException"); goto bad; } -#if PY_VERSION_HEX >= 0x03030000 if (cause) { -#else - if (cause && cause != Py_None) { -#endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; @@ -5704,7 +5840,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else - PyThreadState *tstate = PyThreadState_GET(); + PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); @@ -5720,7 +5856,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject #endif /* WriteUnraisableException */ - static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, +static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, int full_traceback, CYTHON_UNUSED int nogil) { PyObject *old_exc, *old_val, *old_tb; @@ -5762,7 +5898,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* SaveResetException */ - #if CYTHON_FAST_THREAD_STATE +#if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { *type = tstate->exc_type; *value = tstate->exc_value; @@ -5786,17 +5922,32 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject #endif /* PyErrExceptionMatches */ - #if CYTHON_FAST_THREAD_STATE +#if CYTHON_FAST_THREAD_STATE +static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; icurexc_type; if (exc_type == err) return 1; if (unlikely(!exc_type)) return 0; - return PyErr_GivenExceptionMatches(exc_type, err); + if (unlikely(PyTuple_Check(err))) + return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); + return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); } #endif /* GetException */ - #if CYTHON_FAST_THREAD_STATE +#if CYTHON_FAST_THREAD_STATE static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { @@ -5857,17 +6008,16 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) } /* SetupReduce */ - #define __Pyx_setup_reduce_GET_ATTR_OR_BAD(res, obj, name) res = PyObject_GetAttrString(obj, name); if (res == NULL) goto BAD; -static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { + static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { int ret; PyObject *name_attr; - name_attr = PyObject_GetAttrString(meth, "__name__"); - if (name_attr) { + name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2); + if (likely(name_attr)) { ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); } else { ret = -1; } - if (ret < 0) { + if (unlikely(ret < 0)) { PyErr_Clear(); ret = 0; } @@ -5876,43 +6026,55 @@ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { } static int __Pyx_setup_reduce(PyObject* type_obj) { int ret = 0; - PyObject* builtin_object = NULL; - static PyObject *object_reduce = NULL; - static PyObject *object_reduce_ex = NULL; + PyObject *object_reduce = NULL; + PyObject *object_reduce_ex = NULL; PyObject *reduce = NULL; PyObject *reduce_ex = NULL; PyObject *reduce_cython = NULL; PyObject *setstate = NULL; PyObject *setstate_cython = NULL; - if (PyObject_HasAttrString(type_obj, "__getstate__")) goto GOOD; - if (object_reduce_ex == NULL) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(builtin_object, __pyx_b, "object"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce, builtin_object, "__reduce__"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce_ex, builtin_object, "__reduce_ex__"); - } - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_ex, type_obj, "__reduce_ex__"); +#if CYTHON_USE_PYTYPE_LOOKUP + if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD; +#else + if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD; +#endif +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#else + object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#endif + reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD; if (reduce_ex == object_reduce_ex) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce, type_obj, "__reduce__"); - if (object_reduce == reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_cython, type_obj, "__reduce_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce__", reduce_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce_cython__"); if (ret < 0) goto BAD; - setstate = PyObject_GetAttrString(type_obj, "__setstate__"); +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#else + object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#endif + reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD; + if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { + reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD; + setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); if (!setstate) PyErr_Clear(); if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(setstate_cython, type_obj, "__setstate_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate__", setstate_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate_cython__"); if (ret < 0) goto BAD; + setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD; } PyType_Modified((PyTypeObject*)type_obj); } } goto GOOD; BAD: - if (!PyErr_Occurred()) PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); + if (!PyErr_Occurred()) + PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); ret = -1; GOOD: - Py_XDECREF(builtin_object); +#if !CYTHON_USE_PYTYPE_LOOKUP + Py_XDECREF(object_reduce); + Py_XDECREF(object_reduce_ex); +#endif Py_XDECREF(reduce); Py_XDECREF(reduce_ex); Py_XDECREF(reduce_cython); @@ -5921,35 +6083,19 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { return ret; } -/* GetVTable */ - static void* __Pyx_GetVtable(PyObject *dict) { - void* ptr; - PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable); - if (!ob) - goto bad; -#if PY_VERSION_HEX >= 0x02070000 - ptr = PyCapsule_GetPointer(ob, 0); -#else - ptr = PyCObject_AsVoidPtr(ob); -#endif - if (!ptr && !PyErr_Occurred()) - PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); - Py_DECREF(ob); - return ptr; -bad: - Py_XDECREF(ob); - return NULL; -} - /* CLineInTraceback */ - static int __Pyx_CLineForTraceback(int c_line) { + static int __Pyx_CLineForTraceback(int c_line) { #ifdef CYTHON_CLINE_IN_TRACEBACK return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; #else - PyObject **cython_runtime_dict; PyObject *use_cline; - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (unlikely(!cython_runtime_dict)) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { PyObject *ptype, *pvalue, *ptraceback; PyObject *use_cline_obj; PyErr_Fetch(&ptype, &pvalue, &ptraceback); @@ -5961,8 +6107,6 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { use_cline = NULL; } PyErr_Restore(ptype, pvalue, ptraceback); - } else { - use_cline = PyDict_GetItem(*_PyObject_GetDictPtr(__pyx_cython_runtime), __pyx_n_s_cline_in_traceback); } if (!use_cline) { c_line = 0; @@ -5976,7 +6120,7 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { } /* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + 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; @@ -6056,7 +6200,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { } /* AddTraceback */ - #include "compile.h" + #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( @@ -6126,10 +6270,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, __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*/ + __Pyx_PyThreadState_Current, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); @@ -6140,7 +6284,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + #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) @@ -6162,7 +6306,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value) { const unsigned long neg_one = (unsigned long) -1, const_zero = (unsigned long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -6193,7 +6337,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_char(char value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_char(char value) { const char neg_one = (char) -1, const_zero = (char) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -6224,7 +6368,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -6255,7 +6399,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) { + static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) { const char neg_one = (char) -1, const_zero = (char) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -6444,7 +6588,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { + static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { const size_t neg_one = (size_t) -1, const_zero = (size_t) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -6633,7 +6777,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE unsigned long __Pyx_PyInt_As_unsigned_long(PyObject *x) { + static CYTHON_INLINE unsigned long __Pyx_PyInt_As_unsigned_long(PyObject *x) { const unsigned long neg_one = (unsigned long) -1, const_zero = (unsigned long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -6822,7 +6966,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + 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) { @@ -6853,7 +6997,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + 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 @@ -7042,7 +7186,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + 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 @@ -7230,8 +7374,80 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, return (int) -1; } +/* FastTypeChecks */ + #if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + /* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { + 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()); @@ -7247,7 +7463,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* FunctionExport */ - static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { + static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { PyObject *d = 0; PyObject *cobj = 0; union { @@ -7284,7 +7500,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* ModuleImport */ - #ifndef __PYX_HAVE_RT_ImportModule + #ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; @@ -7302,7 +7518,7 @@ static PyObject *__Pyx_ImportModule(const char *name) { #endif /* TypeImport */ - #ifndef __PYX_HAVE_RT_ImportType + #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) @@ -7367,7 +7583,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class #endif /* FunctionImport */ - #ifndef __PYX_HAVE_RT_ImportFunction + #ifndef __PYX_HAVE_RT_ImportFunction #define __PYX_HAVE_RT_ImportFunction static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { PyObject *d = 0; @@ -7421,7 +7637,7 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (** #endif /* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { @@ -7460,46 +7676,53 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#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 && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} #endif #endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __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 && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -7523,6 +7746,26 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; @@ -7530,9 +7773,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS @@ -7540,32 +7783,30 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } #else - if (m && m->nb_int) { + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); } #endif #else - res = PyNumber_Int(x); + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { diff --git a/ssh2/session.c b/ssh2/session.c index 0bf557ba..a68f0bd5 100644 --- a/ssh2/session.c +++ b/ssh2/session.c @@ -1,13 +1,14 @@ -/* Generated by Cython 0.26 */ +/* Generated by Cython 0.27.1 */ #define PY_SSIZE_T_CLEAN #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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_26" +#define CYTHON_ABI "0_27_1" +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -31,7 +32,7 @@ #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif @@ -47,8 +48,14 @@ #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS @@ -67,6 +74,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -74,6 +85,8 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS @@ -98,6 +111,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -105,6 +122,12 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 @@ -144,6 +167,12 @@ #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -199,6 +228,27 @@ #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ @@ -282,7 +332,6 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject @@ -333,15 +382,17 @@ #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct 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)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) @@ -451,14 +502,6 @@ static CYTHON_INLINE float __PYX_NAN() { __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) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -483,7 +526,7 @@ static CYTHON_INLINE float __PYX_NAN() { #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif @@ -514,8 +557,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #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 (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -537,6 +580,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) @@ -547,16 +596,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #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) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #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 @@ -565,6 +609,8 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) #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_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS @@ -665,7 +711,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime; @@ -681,9 +727,9 @@ static const char *__pyx_filename; static const char *__pyx_f[] = { "ssh2/session.pyx", "stringsource", - "env3/lib/python3.4/site-packages/Cython/Includes/cpython/type.pxd", - "env3/lib/python3.4/site-packages/Cython/Includes/cpython/bool.pxd", - "env3/lib/python3.4/site-packages/Cython/Includes/cpython/complex.pxd", + "type.pxd", + "bool.pxd", + "complex.pxd", "ssh2/agent.pxd", "ssh2/channel.pxd", "ssh2/exceptions.pxd", @@ -691,6 +737,18 @@ static const char *__pyx_f[] = { "ssh2/sftp.pxd", "ssh2/statinfo.pxd", }; +/* NoFastGil.proto */ +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + /*--- Type declarations ---*/ struct __pyx_obj_4ssh2_5agent_Agent; @@ -706,6 +764,7 @@ struct __pyx_obj_4ssh2_10exceptions_SessionHandshakeError; struct __pyx_obj_4ssh2_10exceptions_ChannelError; struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError; struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall; +struct __pyx_obj_4ssh2_10exceptions_SFTPIOError; struct __pyx_obj_4ssh2_8listener_Listener; struct __pyx_obj_4ssh2_4sftp_SFTP; struct __pyx_obj_4ssh2_8statinfo_StatInfo; @@ -864,12 +923,24 @@ struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError { * * cdef class SFTPBufferTooSmall(Exception): # <<<<<<<<<<<<<< * pass + * */ struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall { PyBaseExceptionObject __pyx_base; }; +/* "exceptions.pxd":62 + * + * + * cdef class SFTPIOError(Exception): # <<<<<<<<<<<<<< + * pass + */ +struct __pyx_obj_4ssh2_10exceptions_SFTPIOError { + PyBaseExceptionObject __pyx_base; +}; + + /* "listener.pxd":24 * * @@ -911,35 +982,21 @@ struct __pyx_obj_4ssh2_8statinfo_StatInfo { }; -/* "ssh2/session.pxd":20 - * +/* "ssh2/session.pxd":19 + * cimport c_ssh2 * * cdef class Session: # <<<<<<<<<<<<<< * cdef c_ssh2.LIBSSH2_SESSION *_session - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL + * cdef int _sock */ struct __pyx_obj_4ssh2_7session_Session { PyObject_HEAD - struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtab; LIBSSH2_SESSION *_session; + int _sock; + PyObject *sock; }; - -/* "ssh2/session.pyx":42 - * - * - * cdef class Session: # <<<<<<<<<<<<<< - * - * """LibSSH2 Session class providing session functions""" - */ - -struct __pyx_vtabstruct_4ssh2_7session_Session { - LIBSSH2_AGENT *(*init_connect_agent)(struct __pyx_obj_4ssh2_7session_Session *); - LIBSSH2_AGENT *(*_agent_init)(struct __pyx_obj_4ssh2_7session_Session *); -}; -static struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtabptr_4ssh2_7session_Session; - /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY @@ -1028,19 +1085,7 @@ 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); /* KeywordStringCheck.proto */ -static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); - -/* NoFastGil.proto */ -#define __Pyx_PyGILState_Ensure PyGILState_Ensure -#define __Pyx_PyGILState_Release PyGILState_Release -#define __Pyx_FastGIL_Remember() -#define __Pyx_FastGIL_Forget() -#define __Pyx_FastGilFuncInit() - -/* ForceInitThreads.proto */ -#ifndef __PYX_FORCE_INIT_THREADS - #define __PYX_FORCE_INIT_THREADS 0 -#endif +static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON @@ -1052,21 +1097,31 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #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); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #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) @@ -1085,14 +1140,10 @@ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ const char* function_name); /* ArgTypeTest.proto */ -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); - -/* None.proto */ -static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); - -/* SetVTable.proto */ -static int __Pyx_SetVtable(PyObject *dict, void *vtable); +#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ + ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ + __Pyx__ArgTypeTest(obj, type, name, exact)) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* SetupReduce.proto */ static int __Pyx_setup_reduce(PyObject* type_obj); @@ -1140,6 +1191,18 @@ static CYTHON_INLINE libssh2_uint64_t __Pyx_PyInt_As_libssh2_uint64_t(PyObject * /* CIntFromPy.proto */ static CYTHON_INLINE time_t __Pyx_PyInt_As_time_t(PyObject *); +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif + /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); @@ -1164,8 +1227,6 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (** /* InitStrings.proto */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); -static LIBSSH2_AGENT *__pyx_f_4ssh2_7session_7Session__agent_init(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self); /* proto*/ -static LIBSSH2_AGENT *__pyx_f_4ssh2_7session_7Session_init_connect_agent(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self); /* proto*/ /* Module declarations from 'libc.stddef' */ @@ -1263,8 +1324,9 @@ static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0; /* Module declarations from 'ssh2.agent' */ static PyTypeObject *__pyx_ptype_4ssh2_5agent_Agent = 0; static PyObject *(*__pyx_f_4ssh2_5agent_PyAgent)(LIBSSH2_AGENT *, struct __pyx_obj_4ssh2_7session_Session *); /*proto*/ -static int (*__pyx_f_4ssh2_5agent_auth_identity)(char const *, LIBSSH2_AGENT *, struct libssh2_agent_publickey **, struct libssh2_agent_publickey *); /*proto*/ -static void (*__pyx_f_4ssh2_5agent_clear_agent)(LIBSSH2_AGENT *); /*proto*/ +static int (*__pyx_f_4ssh2_5agent_agent_auth)(char *, LIBSSH2_AGENT *); /*proto*/ +static LIBSSH2_AGENT *(*__pyx_f_4ssh2_5agent_init_connect_agent)(LIBSSH2_SESSION *); /*proto*/ +static LIBSSH2_AGENT *(*__pyx_f_4ssh2_5agent_agent_init)(LIBSSH2_SESSION *); /*proto*/ /* Module declarations from 'ssh2.channel' */ static PyTypeObject *__pyx_ptype_4ssh2_7channel_Channel = 0; @@ -1282,6 +1344,7 @@ static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SessionHandshakeError = 0; static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_ChannelError = 0; static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPHandleError = 0; static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPIOError = 0; /* Module declarations from 'ssh2.listener' */ static PyTypeObject *__pyx_ptype_4ssh2_8listener_Listener = 0; @@ -1314,10 +1377,11 @@ int __pyx_module_is_main_ssh2__session = 0; static PyObject *__pyx_builtin_MemoryError; static PyObject *__pyx_builtin_TypeError; static const char __pyx_k_[] = ","; -static const char __pyx_k__6[] = ""; +static const char __pyx_k__3[] = ""; static const char __pyx_k_host[] = "host"; static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_mode[] = "mode"; +static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_path[] = "path"; static const char __pyx_k_port[] = "port"; static const char __pyx_k_size[] = "size"; @@ -1327,28 +1391,30 @@ static const char __pyx_k_mtime[] = "mtime"; static const char __pyx_k_shost[] = "shost"; static const char __pyx_k_split[] = "split"; static const char __pyx_k_sport[] = "sport"; +static const char __pyx_k_reduce[] = "__reduce__"; +static const char __pyx_k_getstate[] = "__getstate__"; static const char __pyx_k_hostname[] = "hostname"; static const char __pyx_k_password[] = "password"; +static const char __pyx_k_setstate[] = "__setstate__"; static const char __pyx_k_username[] = "username"; static const char __pyx_k_TypeError[] = "TypeError"; static const char __pyx_k_publickey[] = "publickey"; +static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; static const char __pyx_k_bound_port[] = "bound_port"; static const char __pyx_k_passphrase[] = "passphrase"; static const char __pyx_k_privatekey[] = "privatekey"; static const char __pyx_k_pubkeydata[] = "pubkeydata"; -static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; static const char __pyx_k_MemoryError[] = "MemoryError"; static const char __pyx_k_queue_maxsize[] = "queue_maxsize"; static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; -static const char __pyx_k_Error_initialising_agent[] = "Error initialising agent"; -static const char __pyx_k_Unable_to_connect_to_agent[] = "Unable to connect to agent"; +static const char __pyx_k_LIBSSH2_HOSTKEY_HASH_MD5[] = "LIBSSH2_HOSTKEY_HASH_MD5"; +static const char __pyx_k_LIBSSH2_HOSTKEY_HASH_SHA1[] = "LIBSSH2_HOSTKEY_HASH_SHA1"; static const char __pyx_k_LIBSSH2_SESSION_BLOCK_INBOUND[] = "LIBSSH2_SESSION_BLOCK_INBOUND"; static const char __pyx_k_LIBSSH2_SESSION_BLOCK_OUTBOUND[] = "LIBSSH2_SESSION_BLOCK_OUTBOUND"; static const char __pyx_k_SSH_session_startup_failed_with[] = "SSH session startup failed with error code %s"; static const char __pyx_k_Error_authenticating_user_s_with[] = "Error authenticating user %s with private key %s andpublic key %s"; -static const char __pyx_k_Failure_requesting_identities_fr[] = "Failure requesting identities from agent"; static const char __pyx_k_SSH_session_handshake_failed_wit[] = "SSH session handshake failed with error code %s"; static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; static const char __pyx_k_Error_authenticating_user_s_with_2[] = "Error authenticating user %s with public key data"; @@ -1359,24 +1425,25 @@ static PyObject *__pyx_kp_s_Error_authenticating_user_s_with; static PyObject *__pyx_kp_s_Error_authenticating_user_s_with_2; static PyObject *__pyx_kp_s_Error_authenticating_user_s_with_3; static PyObject *__pyx_kp_s_Error_authenticating_user_s_with_4; -static PyObject *__pyx_kp_s_Error_initialising_agent; -static PyObject *__pyx_kp_s_Failure_requesting_identities_fr; +static PyObject *__pyx_n_s_LIBSSH2_HOSTKEY_HASH_MD5; +static PyObject *__pyx_n_s_LIBSSH2_HOSTKEY_HASH_SHA1; static PyObject *__pyx_n_s_LIBSSH2_SESSION_BLOCK_INBOUND; static PyObject *__pyx_n_s_LIBSSH2_SESSION_BLOCK_OUTBOUND; static PyObject *__pyx_n_s_MemoryError; static PyObject *__pyx_kp_s_SSH_session_handshake_failed_wit; static PyObject *__pyx_kp_s_SSH_session_startup_failed_with; static PyObject *__pyx_n_s_TypeError; -static PyObject *__pyx_kp_s_Unable_to_connect_to_agent; -static PyObject *__pyx_kp_b__6; +static PyObject *__pyx_kp_b__3; static PyObject *__pyx_n_s_atime; static PyObject *__pyx_n_s_bound_port; static PyObject *__pyx_n_s_cline_in_traceback; +static PyObject *__pyx_n_s_getstate; static PyObject *__pyx_n_s_host; static PyObject *__pyx_n_s_hostname; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_mode; static PyObject *__pyx_n_s_mtime; +static PyObject *__pyx_n_s_name; static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; static PyObject *__pyx_n_s_passphrase; static PyObject *__pyx_n_s_password; @@ -1385,9 +1452,11 @@ static PyObject *__pyx_n_s_port; static PyObject *__pyx_n_s_privatekey; static PyObject *__pyx_n_s_pubkeydata; static PyObject *__pyx_n_s_publickey; -static PyObject *__pyx_n_s_pyx_vtable; static PyObject *__pyx_n_s_queue_maxsize; +static PyObject *__pyx_n_s_reduce; static PyObject *__pyx_n_s_reduce_cython; +static PyObject *__pyx_n_s_reduce_ex; +static PyObject *__pyx_n_s_setstate; static PyObject *__pyx_n_s_setstate_cython; static PyObject *__pyx_n_s_shost; static PyObject *__pyx_n_s_size; @@ -1420,21 +1489,20 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42forward_listen(struct __pyx_ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen_ex(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, PyObject *__pyx_v_host, int __pyx_v_port, int __pyx_v_bound_port, int __pyx_v_queue_maxsize); /* proto */ static PyObject *__pyx_pf_4ssh2_7session_7Session_46sftp_init(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4ssh2_7session_7Session_48last_error(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_4ssh2_7session_7Session_50scp_recv(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, PyObject *__pyx_v_path); /* proto */ -static PyObject *__pyx_pf_4ssh2_7session_7Session_52scp_send(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, PyObject *__pyx_v_path, int __pyx_v_mode, size_t __pyx_v_size); /* proto */ -static PyObject *__pyx_pf_4ssh2_7session_7Session_54scp_send64(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, PyObject *__pyx_v_path, int __pyx_v_mode, libssh2_uint64_t __pyx_v_size, time_t __pyx_v_mtime, time_t __pyx_v_atime); /* proto */ -static PyObject *__pyx_pf_4ssh2_7session_7Session_56publickey_init(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_4ssh2_7session_7Session_58__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_4ssh2_7session_7Session_60__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static PyObject *__pyx_pf_4ssh2_7session_7Session_50last_errno(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_4ssh2_7session_7Session_52scp_recv(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, PyObject *__pyx_v_path); /* proto */ +static PyObject *__pyx_pf_4ssh2_7session_7Session_54scp_send(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, PyObject *__pyx_v_path, int __pyx_v_mode, size_t __pyx_v_size); /* proto */ +static PyObject *__pyx_pf_4ssh2_7session_7Session_56scp_send64(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, PyObject *__pyx_v_path, int __pyx_v_mode, libssh2_uint64_t __pyx_v_size, time_t __pyx_v_mtime, time_t __pyx_v_atime); /* proto */ +static PyObject *__pyx_pf_4ssh2_7session_7Session_58publickey_init(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_4ssh2_7session_7Session_60hostkey_hash(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, int __pyx_v_hash_type); /* proto */ +static PyObject *__pyx_pf_4ssh2_7session_7Session_62__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_4ssh2_7session_7Session_64__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_tp_new_4ssh2_7session_Session(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tuple__2; -static PyObject *__pyx_tuple__3; static PyObject *__pyx_tuple__4; static PyObject *__pyx_tuple__5; -static PyObject *__pyx_tuple__7; -static PyObject *__pyx_tuple__8; -/* "ssh2/session.pyx":46 +/* "ssh2/session.pyx":47 * """LibSSH2 Session class providing session functions""" * * def __cinit__(self): # <<<<<<<<<<<<<< @@ -1464,7 +1532,7 @@ static int __pyx_pf_4ssh2_7session_7Session___cinit__(struct __pyx_obj_4ssh2_7se int __pyx_t_1; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "ssh2/session.pyx":47 + /* "ssh2/session.pyx":48 * * def __cinit__(self): * self._session = c_ssh2.libssh2_session_init() # <<<<<<<<<<<<<< @@ -1473,35 +1541,57 @@ static int __pyx_pf_4ssh2_7session_7Session___cinit__(struct __pyx_obj_4ssh2_7se */ __pyx_v_self->_session = libssh2_session_init(); - /* "ssh2/session.pyx":48 + /* "ssh2/session.pyx":49 * def __cinit__(self): * self._session = c_ssh2.libssh2_session_init() * if self._session is NULL: # <<<<<<<<<<<<<< * raise MemoryError - * + * self._sock = 0 */ __pyx_t_1 = ((__pyx_v_self->_session == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/session.pyx":49 + /* "ssh2/session.pyx":50 * self._session = c_ssh2.libssh2_session_init() * if self._session is NULL: * raise MemoryError # <<<<<<<<<<<<<< - * - * def __dealloc__(self): + * self._sock = 0 + * self.sock = None */ - PyErr_NoMemory(); __PYX_ERR(0, 49, __pyx_L1_error) + PyErr_NoMemory(); __PYX_ERR(0, 50, __pyx_L1_error) - /* "ssh2/session.pyx":48 + /* "ssh2/session.pyx":49 * def __cinit__(self): * self._session = c_ssh2.libssh2_session_init() * if self._session is NULL: # <<<<<<<<<<<<<< * raise MemoryError - * + * self._sock = 0 */ } - /* "ssh2/session.pyx":46 + /* "ssh2/session.pyx":51 + * if self._session is NULL: + * raise MemoryError + * self._sock = 0 # <<<<<<<<<<<<<< + * self.sock = None + * + */ + __pyx_v_self->_sock = 0; + + /* "ssh2/session.pyx":52 + * raise MemoryError + * self._sock = 0 + * self.sock = None # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->sock); + __Pyx_DECREF(__pyx_v_self->sock); + __pyx_v_self->sock = Py_None; + + /* "ssh2/session.pyx":47 * """LibSSH2 Session class providing session functions""" * * def __cinit__(self): # <<<<<<<<<<<<<< @@ -1520,12 +1610,12 @@ static int __pyx_pf_4ssh2_7session_7Session___cinit__(struct __pyx_obj_4ssh2_7se return __pyx_r; } -/* "ssh2/session.pyx":51 - * raise MemoryError +/* "ssh2/session.pyx":54 + * self.sock = None * * def __dealloc__(self): # <<<<<<<<<<<<<< * with nogil: - * c_ssh2.libssh2_session_disconnect( + * if self._session is not NULL: */ /* Python wrapper */ @@ -1541,14 +1631,15 @@ static void __pyx_pw_4ssh2_7session_7Session_3__dealloc__(PyObject *__pyx_v_self static void __pyx_pf_4ssh2_7session_7Session_2__dealloc__(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self) { __Pyx_RefNannyDeclarations + int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "ssh2/session.pyx":52 + /* "ssh2/session.pyx":55 * * def __dealloc__(self): * with nogil: # <<<<<<<<<<<<<< - * c_ssh2.libssh2_session_disconnect( - * self._session, "end") + * if self._session is not NULL: + * c_ssh2.libssh2_session_disconnect( */ { #ifdef WITH_THREAD @@ -1558,31 +1649,59 @@ static void __pyx_pf_4ssh2_7session_7Session_2__dealloc__(struct __pyx_obj_4ssh2 #endif /*try:*/ { - /* "ssh2/session.pyx":53 + /* "ssh2/session.pyx":56 * def __dealloc__(self): * with nogil: - * c_ssh2.libssh2_session_disconnect( # <<<<<<<<<<<<<< - * self._session, "end") - * c_ssh2.libssh2_session_free(self._session) + * if self._session is not NULL: # <<<<<<<<<<<<<< + * c_ssh2.libssh2_session_disconnect( + * self._session, "end") */ - libssh2_session_disconnect(__pyx_v_self->_session, ((char const *)"end")); + __pyx_t_1 = ((__pyx_v_self->_session != NULL) != 0); + if (__pyx_t_1) { + + /* "ssh2/session.pyx":57 + * with nogil: + * if self._session is not NULL: + * c_ssh2.libssh2_session_disconnect( # <<<<<<<<<<<<<< + * self._session, "end") + * c_ssh2.libssh2_session_free(self._session) + */ + libssh2_session_disconnect(__pyx_v_self->_session, ((char const *)"end")); + + /* "ssh2/session.pyx":59 + * c_ssh2.libssh2_session_disconnect( + * self._session, "end") + * c_ssh2.libssh2_session_free(self._session) # <<<<<<<<<<<<<< + * self._session = NULL + * + */ + libssh2_session_free(__pyx_v_self->_session); - /* "ssh2/session.pyx":55 - * c_ssh2.libssh2_session_disconnect( - * self._session, "end") - * c_ssh2.libssh2_session_free(self._session) # <<<<<<<<<<<<<< + /* "ssh2/session.pyx":60 + * self._session, "end") + * c_ssh2.libssh2_session_free(self._session) + * self._session = NULL # <<<<<<<<<<<<<< * * def disconnect(self): */ - libssh2_session_free(__pyx_v_self->_session); + __pyx_v_self->_session = NULL; + + /* "ssh2/session.pyx":56 + * def __dealloc__(self): + * with nogil: + * if self._session is not NULL: # <<<<<<<<<<<<<< + * c_ssh2.libssh2_session_disconnect( + * self._session, "end") + */ + } } - /* "ssh2/session.pyx":52 + /* "ssh2/session.pyx":55 * * def __dealloc__(self): * with nogil: # <<<<<<<<<<<<<< - * c_ssh2.libssh2_session_disconnect( - * self._session, "end") + * if self._session is not NULL: + * c_ssh2.libssh2_session_disconnect( */ /*finally:*/ { /*normal exit:*/{ @@ -1596,20 +1715,20 @@ static void __pyx_pf_4ssh2_7session_7Session_2__dealloc__(struct __pyx_obj_4ssh2 } } - /* "ssh2/session.pyx":51 - * raise MemoryError + /* "ssh2/session.pyx":54 + * self.sock = None * * def __dealloc__(self): # <<<<<<<<<<<<<< * with nogil: - * c_ssh2.libssh2_session_disconnect( + * if self._session is not NULL: */ /* function exit code */ __Pyx_RefNannyFinishContext(); } -/* "ssh2/session.pyx":57 - * c_ssh2.libssh2_session_free(self._session) +/* "ssh2/session.pyx":62 + * self._session = NULL * * def disconnect(self): # <<<<<<<<<<<<<< * with nogil: @@ -1635,7 +1754,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_4disconnect(struct __pyx_obj_4 __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("disconnect", 0); - /* "ssh2/session.pyx":58 + /* "ssh2/session.pyx":63 * * def disconnect(self): * with nogil: # <<<<<<<<<<<<<< @@ -1650,7 +1769,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_4disconnect(struct __pyx_obj_4 #endif /*try:*/ { - /* "ssh2/session.pyx":59 + /* "ssh2/session.pyx":64 * def disconnect(self): * with nogil: * c_ssh2.libssh2_session_disconnect(self._session, "end") # <<<<<<<<<<<<<< @@ -1660,7 +1779,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_4disconnect(struct __pyx_obj_4 libssh2_session_disconnect(__pyx_v_self->_session, ((char const *)"end")); } - /* "ssh2/session.pyx":58 + /* "ssh2/session.pyx":63 * * def disconnect(self): * with nogil: # <<<<<<<<<<<<<< @@ -1679,8 +1798,8 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_4disconnect(struct __pyx_obj_4 } } - /* "ssh2/session.pyx":57 - * c_ssh2.libssh2_session_free(self._session) + /* "ssh2/session.pyx":62 + * self._session = NULL * * def disconnect(self): # <<<<<<<<<<<<<< * with nogil: @@ -1694,7 +1813,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_4disconnect(struct __pyx_obj_4 return __pyx_r; } -/* "ssh2/session.pyx":61 +/* "ssh2/session.pyx":66 * c_ssh2.libssh2_session_disconnect(self._session, "end") * * def handshake(self, sock not None): # <<<<<<<<<<<<<< @@ -1710,7 +1829,7 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_7handshake(PyObject *__pyx_v_s __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("handshake (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_sock) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "sock"); __PYX_ERR(0, 61, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "sock"); __PYX_ERR(0, 66, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_6handshake(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), ((PyObject *)__pyx_v_sock)); @@ -1734,17 +1853,17 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("handshake", 0); - /* "ssh2/session.pyx":65 + /* "ssh2/session.pyx":70 * * Must be called after Session initialisation.""" * cdef int _sock = PyObject_AsFileDescriptor(sock) # <<<<<<<<<<<<<< * cdef int rc * with nogil: */ - __pyx_t_1 = PyObject_AsFileDescriptor(__pyx_v_sock); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 65, __pyx_L1_error) + __pyx_t_1 = PyObject_AsFileDescriptor(__pyx_v_sock); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 70, __pyx_L1_error) __pyx_v__sock = __pyx_t_1; - /* "ssh2/session.pyx":67 + /* "ssh2/session.pyx":72 * cdef int _sock = PyObject_AsFileDescriptor(sock) * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -1759,7 +1878,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s #endif /*try:*/ { - /* "ssh2/session.pyx":68 + /* "ssh2/session.pyx":73 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_session_handshake(self._session, _sock) # <<<<<<<<<<<<<< @@ -1768,7 +1887,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s */ __pyx_v_rc = libssh2_session_handshake(__pyx_v_self->_session, __pyx_v__sock); - /* "ssh2/session.pyx":69 + /* "ssh2/session.pyx":74 * with nogil: * rc = c_ssh2.libssh2_session_handshake(self._session, _sock) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -1786,7 +1905,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s } if (__pyx_t_2) { - /* "ssh2/session.pyx":70 + /* "ssh2/session.pyx":75 * rc = c_ssh2.libssh2_session_handshake(self._session, _sock) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -1799,24 +1918,24 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s #endif /*try:*/ { - /* "ssh2/session.pyx":73 + /* "ssh2/session.pyx":78 * raise SessionHandshakeError( * "SSH session handshake failed with error code %s", * rc) # <<<<<<<<<<<<<< - * return rc - * + * self._sock = _sock + * self.sock = sock */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 73, __pyx_L8_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); - /* "ssh2/session.pyx":71 + /* "ssh2/session.pyx":76 * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: * raise SessionHandshakeError( # <<<<<<<<<<<<<< * "SSH session handshake failed with error code %s", * rc) */ - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 71, __pyx_L8_error) + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 76, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_kp_s_SSH_session_handshake_failed_wit); __Pyx_GIVEREF(__pyx_kp_s_SSH_session_handshake_failed_wit); @@ -1824,15 +1943,15 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_SessionHandshakeError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L8_error) + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_SessionHandshakeError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 71, __pyx_L8_error) + __PYX_ERR(0, 76, __pyx_L8_error) } - /* "ssh2/session.pyx":70 + /* "ssh2/session.pyx":75 * rc = c_ssh2.libssh2_session_handshake(self._session, _sock) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -1849,7 +1968,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s } } - /* "ssh2/session.pyx":69 + /* "ssh2/session.pyx":74 * with nogil: * rc = c_ssh2.libssh2_session_handshake(self._session, _sock) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -1857,9 +1976,18 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s * raise SessionHandshakeError( */ } + + /* "ssh2/session.pyx":79 + * "SSH session handshake failed with error code %s", + * rc) + * self._sock = _sock # <<<<<<<<<<<<<< + * self.sock = sock + * return rc + */ + __pyx_v_self->_sock = __pyx_v__sock; } - /* "ssh2/session.pyx":67 + /* "ssh2/session.pyx":72 * cdef int _sock = PyObject_AsFileDescriptor(sock) * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -1885,21 +2013,34 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s } } - /* "ssh2/session.pyx":74 - * "SSH session handshake failed with error code %s", + /* "ssh2/session.pyx":80 * rc) + * self._sock = _sock + * self.sock = sock # <<<<<<<<<<<<<< + * return rc + * + */ + __Pyx_INCREF(__pyx_v_sock); + __Pyx_GIVEREF(__pyx_v_sock); + __Pyx_GOTREF(__pyx_v_self->sock); + __Pyx_DECREF(__pyx_v_self->sock); + __pyx_v_self->sock = __pyx_v_sock; + + /* "ssh2/session.pyx":81 + * self._sock = _sock + * self.sock = sock * return rc # <<<<<<<<<<<<<< * * def startup(self, sock): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 74, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":61 + /* "ssh2/session.pyx":66 * c_ssh2.libssh2_session_disconnect(self._session, "end") * * def handshake(self, sock not None): # <<<<<<<<<<<<<< @@ -1919,7 +2060,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s return __pyx_r; } -/* "ssh2/session.pyx":76 +/* "ssh2/session.pyx":83 * return rc * * def startup(self, sock): # <<<<<<<<<<<<<< @@ -1952,17 +2093,17 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_8startup(struct __pyx_obj_4ssh PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("startup", 0); - /* "ssh2/session.pyx":78 + /* "ssh2/session.pyx":85 * def startup(self, sock): * """Deprecated - use self.handshake""" * cdef int _sock = PyObject_AsFileDescriptor(sock) # <<<<<<<<<<<<<< * cdef int rc * rc = c_ssh2.libssh2_session_startup(self._session, _sock) */ - __pyx_t_1 = PyObject_AsFileDescriptor(__pyx_v_sock); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 78, __pyx_L1_error) + __pyx_t_1 = PyObject_AsFileDescriptor(__pyx_v_sock); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 85, __pyx_L1_error) __pyx_v__sock = __pyx_t_1; - /* "ssh2/session.pyx":80 + /* "ssh2/session.pyx":87 * cdef int _sock = PyObject_AsFileDescriptor(sock) * cdef int rc * rc = c_ssh2.libssh2_session_startup(self._session, _sock) # <<<<<<<<<<<<<< @@ -1971,7 +2112,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_8startup(struct __pyx_obj_4ssh */ __pyx_v_rc = libssh2_session_startup(__pyx_v_self->_session, __pyx_v__sock); - /* "ssh2/session.pyx":81 + /* "ssh2/session.pyx":88 * cdef int rc * rc = c_ssh2.libssh2_session_startup(self._session, _sock) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -1989,24 +2130,24 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_8startup(struct __pyx_obj_4ssh } if (__pyx_t_2) { - /* "ssh2/session.pyx":84 + /* "ssh2/session.pyx":91 * raise SessionStartupError( * "SSH session startup failed with error code %s", * rc) # <<<<<<<<<<<<<< * return rc * */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - /* "ssh2/session.pyx":82 + /* "ssh2/session.pyx":89 * rc = c_ssh2.libssh2_session_startup(self._session, _sock) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * raise SessionStartupError( # <<<<<<<<<<<<<< * "SSH session startup failed with error code %s", * rc) */ - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 82, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_kp_s_SSH_session_startup_failed_with); __Pyx_GIVEREF(__pyx_kp_s_SSH_session_startup_failed_with); @@ -2014,14 +2155,14 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_8startup(struct __pyx_obj_4ssh __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_SessionStartupError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_SessionStartupError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 82, __pyx_L1_error) + __PYX_ERR(0, 89, __pyx_L1_error) - /* "ssh2/session.pyx":81 + /* "ssh2/session.pyx":88 * cdef int rc * rc = c_ssh2.libssh2_session_startup(self._session, _sock) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -2030,7 +2171,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_8startup(struct __pyx_obj_4ssh */ } - /* "ssh2/session.pyx":85 + /* "ssh2/session.pyx":92 * "SSH session startup failed with error code %s", * rc) * return rc # <<<<<<<<<<<<<< @@ -2038,13 +2179,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_8startup(struct __pyx_obj_4ssh * def set_blocking(self, bint blocking): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":76 + /* "ssh2/session.pyx":83 * return rc * * def startup(self, sock): # <<<<<<<<<<<<<< @@ -2064,7 +2205,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_8startup(struct __pyx_obj_4ssh return __pyx_r; } -/* "ssh2/session.pyx":87 +/* "ssh2/session.pyx":94 * return rc * * def set_blocking(self, bint blocking): # <<<<<<<<<<<<<< @@ -2081,7 +2222,7 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_11set_blocking(PyObject *__pyx __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_blocking (wrapper)", 0); assert(__pyx_arg_blocking); { - __pyx_v_blocking = __Pyx_PyObject_IsTrue(__pyx_arg_blocking); if (unlikely((__pyx_v_blocking == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 87, __pyx_L3_error) + __pyx_v_blocking = __Pyx_PyObject_IsTrue(__pyx_arg_blocking); if (unlikely((__pyx_v_blocking == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 94, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -2101,7 +2242,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_10set_blocking(struct __pyx_ob __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_blocking", 0); - /* "ssh2/session.pyx":93 + /* "ssh2/session.pyx":100 * Session default is blocking unless set otherwise. * :type blocking: bool""" * with nogil: # <<<<<<<<<<<<<< @@ -2116,7 +2257,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_10set_blocking(struct __pyx_ob #endif /*try:*/ { - /* "ssh2/session.pyx":94 + /* "ssh2/session.pyx":101 * :type blocking: bool""" * with nogil: * c_ssh2.libssh2_session_set_blocking( # <<<<<<<<<<<<<< @@ -2126,7 +2267,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_10set_blocking(struct __pyx_ob libssh2_session_set_blocking(__pyx_v_self->_session, __pyx_v_blocking); } - /* "ssh2/session.pyx":93 + /* "ssh2/session.pyx":100 * Session default is blocking unless set otherwise. * :type blocking: bool""" * with nogil: # <<<<<<<<<<<<<< @@ -2145,7 +2286,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_10set_blocking(struct __pyx_ob } } - /* "ssh2/session.pyx":87 + /* "ssh2/session.pyx":94 * return rc * * def set_blocking(self, bint blocking): # <<<<<<<<<<<<<< @@ -2160,7 +2301,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_10set_blocking(struct __pyx_ob return __pyx_r; } -/* "ssh2/session.pyx":97 +/* "ssh2/session.pyx":104 * self._session, blocking) * * def get_blocking(self): # <<<<<<<<<<<<<< @@ -2190,7 +2331,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_12get_blocking(struct __pyx_ob int __pyx_t_2; __Pyx_RefNannySetupContext("get_blocking", 0); - /* "ssh2/session.pyx":102 + /* "ssh2/session.pyx":109 * :rtype: bool""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -2205,7 +2346,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_12get_blocking(struct __pyx_ob #endif /*try:*/ { - /* "ssh2/session.pyx":103 + /* "ssh2/session.pyx":110 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_session_get_blocking(self._session) # <<<<<<<<<<<<<< @@ -2215,7 +2356,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_12get_blocking(struct __pyx_ob __pyx_v_rc = libssh2_session_get_blocking(__pyx_v_self->_session); } - /* "ssh2/session.pyx":102 + /* "ssh2/session.pyx":109 * :rtype: bool""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -2234,7 +2375,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_12get_blocking(struct __pyx_ob } } - /* "ssh2/session.pyx":104 + /* "ssh2/session.pyx":111 * with nogil: * rc = c_ssh2.libssh2_session_get_blocking(self._session) * return bool(rc) # <<<<<<<<<<<<<< @@ -2242,17 +2383,17 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_12get_blocking(struct __pyx_ob * def set_timeout(self, long timeout): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 104, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyBool_FromLong((!(!__pyx_t_2))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyBool_FromLong((!(!__pyx_t_2))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":97 + /* "ssh2/session.pyx":104 * self._session, blocking) * * def get_blocking(self): # <<<<<<<<<<<<<< @@ -2271,7 +2412,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_12get_blocking(struct __pyx_ob return __pyx_r; } -/* "ssh2/session.pyx":106 +/* "ssh2/session.pyx":113 * return bool(rc) * * def set_timeout(self, long timeout): # <<<<<<<<<<<<<< @@ -2288,7 +2429,7 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_15set_timeout(PyObject *__pyx_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_timeout (wrapper)", 0); assert(__pyx_arg_timeout); { - __pyx_v_timeout = __Pyx_PyInt_As_long(__pyx_arg_timeout); if (unlikely((__pyx_v_timeout == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 106, __pyx_L3_error) + __pyx_v_timeout = __Pyx_PyInt_As_long(__pyx_arg_timeout); if (unlikely((__pyx_v_timeout == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 113, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -2308,7 +2449,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_14set_timeout(struct __pyx_obj __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_timeout", 0); - /* "ssh2/session.pyx":114 + /* "ssh2/session.pyx":121 * for blocking functions. * :param timeout: Milliseconds to wait before timeout.""" * with nogil: # <<<<<<<<<<<<<< @@ -2323,7 +2464,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_14set_timeout(struct __pyx_obj #endif /*try:*/ { - /* "ssh2/session.pyx":115 + /* "ssh2/session.pyx":122 * :param timeout: Milliseconds to wait before timeout.""" * with nogil: * c_ssh2.libssh2_session_set_timeout(self._session, timeout) # <<<<<<<<<<<<<< @@ -2333,7 +2474,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_14set_timeout(struct __pyx_obj libssh2_session_set_timeout(__pyx_v_self->_session, __pyx_v_timeout); } - /* "ssh2/session.pyx":114 + /* "ssh2/session.pyx":121 * for blocking functions. * :param timeout: Milliseconds to wait before timeout.""" * with nogil: # <<<<<<<<<<<<<< @@ -2352,7 +2493,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_14set_timeout(struct __pyx_obj } } - /* "ssh2/session.pyx":106 + /* "ssh2/session.pyx":113 * return bool(rc) * * def set_timeout(self, long timeout): # <<<<<<<<<<<<<< @@ -2367,7 +2508,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_14set_timeout(struct __pyx_obj return __pyx_r; } -/* "ssh2/session.pyx":117 +/* "ssh2/session.pyx":124 * c_ssh2.libssh2_session_set_timeout(self._session, timeout) * * def get_timeout(self): # <<<<<<<<<<<<<< @@ -2396,7 +2537,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_16get_timeout(struct __pyx_obj PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("get_timeout", 0); - /* "ssh2/session.pyx":120 + /* "ssh2/session.pyx":127 * """Get current session timeout setting""" * cdef long timeout * with nogil: # <<<<<<<<<<<<<< @@ -2411,7 +2552,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_16get_timeout(struct __pyx_obj #endif /*try:*/ { - /* "ssh2/session.pyx":121 + /* "ssh2/session.pyx":128 * cdef long timeout * with nogil: * timeout = c_ssh2.libssh2_session_get_timeout(self._session) # <<<<<<<<<<<<<< @@ -2421,7 +2562,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_16get_timeout(struct __pyx_obj __pyx_v_timeout = libssh2_session_get_timeout(__pyx_v_self->_session); } - /* "ssh2/session.pyx":120 + /* "ssh2/session.pyx":127 * """Get current session timeout setting""" * cdef long timeout * with nogil: # <<<<<<<<<<<<<< @@ -2440,7 +2581,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_16get_timeout(struct __pyx_obj } } - /* "ssh2/session.pyx":122 + /* "ssh2/session.pyx":129 * with nogil: * timeout = c_ssh2.libssh2_session_get_timeout(self._session) * return timeout # <<<<<<<<<<<<<< @@ -2448,13 +2589,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_16get_timeout(struct __pyx_obj * def userauth_authenticated(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 122, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":117 + /* "ssh2/session.pyx":124 * c_ssh2.libssh2_session_set_timeout(self._session, timeout) * * def get_timeout(self): # <<<<<<<<<<<<<< @@ -2473,7 +2614,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_16get_timeout(struct __pyx_obj return __pyx_r; } -/* "ssh2/session.pyx":124 +/* "ssh2/session.pyx":131 * return timeout * * def userauth_authenticated(self): # <<<<<<<<<<<<<< @@ -2503,7 +2644,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_18userauth_authenticated(struc PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("userauth_authenticated", 0); - /* "ssh2/session.pyx":129 + /* "ssh2/session.pyx":136 * :rtype: bool""" * cdef bint rc * with nogil: # <<<<<<<<<<<<<< @@ -2518,7 +2659,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_18userauth_authenticated(struc #endif /*try:*/ { - /* "ssh2/session.pyx":130 + /* "ssh2/session.pyx":137 * cdef bint rc * with nogil: * rc = c_ssh2.libssh2_userauth_authenticated(self._session) # <<<<<<<<<<<<<< @@ -2528,7 +2669,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_18userauth_authenticated(struc __pyx_v_rc = libssh2_userauth_authenticated(__pyx_v_self->_session); } - /* "ssh2/session.pyx":129 + /* "ssh2/session.pyx":136 * :rtype: bool""" * cdef bint rc * with nogil: # <<<<<<<<<<<<<< @@ -2547,7 +2688,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_18userauth_authenticated(struc } } - /* "ssh2/session.pyx":131 + /* "ssh2/session.pyx":138 * with nogil: * rc = c_ssh2.libssh2_userauth_authenticated(self._session) * return bool(rc) # <<<<<<<<<<<<<< @@ -2556,13 +2697,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_18userauth_authenticated(struc */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_v_rc; - __pyx_t_2 = __Pyx_PyBool_FromLong((!(!__pyx_t_1))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBool_FromLong((!(!__pyx_t_1))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":124 + /* "ssh2/session.pyx":131 * return timeout * * def userauth_authenticated(self): # <<<<<<<<<<<<<< @@ -2581,7 +2722,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_18userauth_authenticated(struc return __pyx_r; } -/* "ssh2/session.pyx":133 +/* "ssh2/session.pyx":140 * return bool(rc) * * def userauth_list(self, username not None): # <<<<<<<<<<<<<< @@ -2597,7 +2738,7 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_21userauth_list(PyObject *__py __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("userauth_list (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_username) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 133, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 140, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_20userauth_list(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), ((PyObject *)__pyx_v_username)); @@ -2625,29 +2766,33 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_20userauth_list(struct __pyx_o PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("userauth_list", 0); - /* "ssh2/session.pyx":137 + /* "ssh2/session.pyx":144 * * :rtype: list""" * cdef bytes b_username = to_bytes(username) # <<<<<<<<<<<<<< * cdef char *_username = b_username * cdef size_t username_len = len(b_username) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_username = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":138 + /* "ssh2/session.pyx":145 * :rtype: list""" * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username # <<<<<<<<<<<<<< * cdef size_t username_len = len(b_username) * cdef char *_auth */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 138, __pyx_L1_error) + if (unlikely(__pyx_v_b_username == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 145, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 145, __pyx_L1_error) __pyx_v__username = __pyx_t_2; - /* "ssh2/session.pyx":139 + /* "ssh2/session.pyx":146 * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username * cdef size_t username_len = len(b_username) # <<<<<<<<<<<<<< @@ -2656,12 +2801,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_20userauth_list(struct __pyx_o */ if (unlikely(__pyx_v_b_username == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 139, __pyx_L1_error) + __PYX_ERR(0, 146, __pyx_L1_error) } - __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_username); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 139, __pyx_L1_error) + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_username); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 146, __pyx_L1_error) __pyx_v_username_len = __pyx_t_3; - /* "ssh2/session.pyx":142 + /* "ssh2/session.pyx":149 * cdef char *_auth * cdef str auth * with nogil: # <<<<<<<<<<<<<< @@ -2676,7 +2821,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_20userauth_list(struct __pyx_o #endif /*try:*/ { - /* "ssh2/session.pyx":143 + /* "ssh2/session.pyx":150 * cdef str auth * with nogil: * _auth = c_ssh2.libssh2_userauth_list( # <<<<<<<<<<<<<< @@ -2686,7 +2831,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_20userauth_list(struct __pyx_o __pyx_v__auth = libssh2_userauth_list(__pyx_v_self->_session, __pyx_v__username, __pyx_v_username_len); } - /* "ssh2/session.pyx":142 + /* "ssh2/session.pyx":149 * cdef char *_auth * cdef str auth * with nogil: # <<<<<<<<<<<<<< @@ -2705,7 +2850,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_20userauth_list(struct __pyx_o } } - /* "ssh2/session.pyx":145 + /* "ssh2/session.pyx":152 * _auth = c_ssh2.libssh2_userauth_list( * self._session, _username, username_len) * if _auth is NULL: # <<<<<<<<<<<<<< @@ -2715,7 +2860,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_20userauth_list(struct __pyx_o __pyx_t_4 = ((__pyx_v__auth == NULL) != 0); if (__pyx_t_4) { - /* "ssh2/session.pyx":146 + /* "ssh2/session.pyx":153 * self._session, _username, username_len) * if _auth is NULL: * return # <<<<<<<<<<<<<< @@ -2726,7 +2871,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_20userauth_list(struct __pyx_o __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - /* "ssh2/session.pyx":145 + /* "ssh2/session.pyx":152 * _auth = c_ssh2.libssh2_userauth_list( * self._session, _username, username_len) * if _auth is NULL: # <<<<<<<<<<<<<< @@ -2735,20 +2880,20 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_20userauth_list(struct __pyx_o */ } - /* "ssh2/session.pyx":147 + /* "ssh2/session.pyx":154 * if _auth is NULL: * return * auth = to_str(_auth) # <<<<<<<<<<<<<< * return auth.split(',') * */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_str(__pyx_v__auth); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_str(__pyx_v__auth); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 147, __pyx_L1_error) + if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 154, __pyx_L1_error) __pyx_v_auth = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":148 + /* "ssh2/session.pyx":155 * return * auth = to_str(_auth) * return auth.split(',') # <<<<<<<<<<<<<< @@ -2756,16 +2901,16 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_20userauth_list(struct __pyx_o * def userauth_publickey_fromfile(self, username not None, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_auth, __pyx_n_s_split); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_auth, __pyx_n_s_split); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 148, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":133 + /* "ssh2/session.pyx":140 * return bool(rc) * * def userauth_list(self, username not None): # <<<<<<<<<<<<<< @@ -2787,7 +2932,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_20userauth_list(struct __pyx_o return __pyx_r; } -/* "ssh2/session.pyx":150 +/* "ssh2/session.pyx":157 * return auth.split(',') * * def userauth_publickey_fromfile(self, username not None, # <<<<<<<<<<<<<< @@ -2833,23 +2978,23 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_23userauth_publickey_fromfile( case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_publickey)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("userauth_publickey_fromfile", 1, 4, 4, 1); __PYX_ERR(0, 150, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey_fromfile", 1, 4, 4, 1); __PYX_ERR(0, 157, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_privatekey)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("userauth_publickey_fromfile", 1, 4, 4, 2); __PYX_ERR(0, 150, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey_fromfile", 1, 4, 4, 2); __PYX_ERR(0, 157, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_passphrase)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("userauth_publickey_fromfile", 1, 4, 4, 3); __PYX_ERR(0, 150, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey_fromfile", 1, 4, 4, 3); __PYX_ERR(0, 157, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth_publickey_fromfile") < 0)) __PYX_ERR(0, 150, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth_publickey_fromfile") < 0)) __PYX_ERR(0, 157, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -2866,23 +3011,23 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_23userauth_publickey_fromfile( } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("userauth_publickey_fromfile", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 150, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey_fromfile", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 157, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.session.Session.userauth_publickey_fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_username) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 150, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 157, __pyx_L1_error) } if (unlikely(((PyObject *)__pyx_v_publickey) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "publickey"); __PYX_ERR(0, 151, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "publickey"); __PYX_ERR(0, 158, __pyx_L1_error) } if (unlikely(((PyObject *)__pyx_v_privatekey) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "privatekey"); __PYX_ERR(0, 152, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "privatekey"); __PYX_ERR(0, 159, __pyx_L1_error) } if (unlikely(((PyObject *)__pyx_v_passphrase) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "passphrase"); __PYX_ERR(0, 153, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "passphrase"); __PYX_ERR(0, 160, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_username, __pyx_v_publickey, __pyx_v_privatekey, __pyx_v_passphrase); @@ -2913,95 +3058,111 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("userauth_publickey_fromfile", 0); - /* "ssh2/session.pyx":158 + /* "ssh2/session.pyx":165 * :rtype: int""" * cdef int rc * cdef bytes b_username = to_bytes(username) # <<<<<<<<<<<<<< * cdef bytes b_publickey = to_bytes(publickey) * cdef bytes b_privatekey = to_bytes(privatekey) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_username = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":159 + /* "ssh2/session.pyx":166 * cdef int rc * cdef bytes b_username = to_bytes(username) * cdef bytes b_publickey = to_bytes(publickey) # <<<<<<<<<<<<<< * cdef bytes b_privatekey = to_bytes(privatekey) * cdef bytes b_passphrase = to_bytes(passphrase) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_publickey); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_publickey); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_publickey = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":160 + /* "ssh2/session.pyx":167 * cdef bytes b_username = to_bytes(username) * cdef bytes b_publickey = to_bytes(publickey) * cdef bytes b_privatekey = to_bytes(privatekey) # <<<<<<<<<<<<<< * cdef bytes b_passphrase = to_bytes(passphrase) * cdef char *_username = b_username */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_privatekey); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_privatekey); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_privatekey = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":161 + /* "ssh2/session.pyx":168 * cdef bytes b_publickey = to_bytes(publickey) * cdef bytes b_privatekey = to_bytes(privatekey) * cdef bytes b_passphrase = to_bytes(passphrase) # <<<<<<<<<<<<<< * cdef char *_username = b_username * cdef char *_publickey = b_publickey */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_passphrase); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_passphrase); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_passphrase = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":162 + /* "ssh2/session.pyx":169 * cdef bytes b_privatekey = to_bytes(privatekey) * cdef bytes b_passphrase = to_bytes(passphrase) * cdef char *_username = b_username # <<<<<<<<<<<<<< * cdef char *_publickey = b_publickey * cdef char *_privatekey = b_privatekey */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 162, __pyx_L1_error) + if (unlikely(__pyx_v_b_username == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 169, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 169, __pyx_L1_error) __pyx_v__username = __pyx_t_2; - /* "ssh2/session.pyx":163 + /* "ssh2/session.pyx":170 * cdef bytes b_passphrase = to_bytes(passphrase) * cdef char *_username = b_username * cdef char *_publickey = b_publickey # <<<<<<<<<<<<<< * cdef char *_privatekey = b_privatekey * cdef char *_passphrase = b_passphrase */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_publickey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 163, __pyx_L1_error) + if (unlikely(__pyx_v_b_publickey == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 170, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_publickey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 170, __pyx_L1_error) __pyx_v__publickey = __pyx_t_2; - /* "ssh2/session.pyx":164 + /* "ssh2/session.pyx":171 * cdef char *_username = b_username * cdef char *_publickey = b_publickey * cdef char *_privatekey = b_privatekey # <<<<<<<<<<<<<< * cdef char *_passphrase = b_passphrase * with nogil: */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_privatekey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L1_error) + if (unlikely(__pyx_v_b_privatekey == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 171, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_privatekey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 171, __pyx_L1_error) __pyx_v__privatekey = __pyx_t_2; - /* "ssh2/session.pyx":165 + /* "ssh2/session.pyx":172 * cdef char *_publickey = b_publickey * cdef char *_privatekey = b_privatekey * cdef char *_passphrase = b_passphrase # <<<<<<<<<<<<<< * with nogil: * rc = c_ssh2.libssh2_userauth_publickey_fromfile( */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_passphrase); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L1_error) + if (unlikely(__pyx_v_b_passphrase == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 172, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_passphrase); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 172, __pyx_L1_error) __pyx_v__passphrase = __pyx_t_2; - /* "ssh2/session.pyx":166 + /* "ssh2/session.pyx":173 * cdef char *_privatekey = b_privatekey * cdef char *_passphrase = b_passphrase * with nogil: # <<<<<<<<<<<<<< @@ -3016,7 +3177,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( #endif /*try:*/ { - /* "ssh2/session.pyx":167 + /* "ssh2/session.pyx":174 * cdef char *_passphrase = b_passphrase * with nogil: * rc = c_ssh2.libssh2_userauth_publickey_fromfile( # <<<<<<<<<<<<<< @@ -3025,7 +3186,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( */ __pyx_v_rc = libssh2_userauth_publickey_fromfile(__pyx_v_self->_session, __pyx_v__username, __pyx_v__publickey, __pyx_v__privatekey, __pyx_v__passphrase); - /* "ssh2/session.pyx":169 + /* "ssh2/session.pyx":176 * rc = c_ssh2.libssh2_userauth_publickey_fromfile( * self._session, _username, _publickey, _privatekey, _passphrase) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -3043,7 +3204,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( } if (__pyx_t_3) { - /* "ssh2/session.pyx":170 + /* "ssh2/session.pyx":177 * self._session, _username, _publickey, _privatekey, _passphrase) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -3056,14 +3217,14 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( #endif /*try:*/ { - /* "ssh2/session.pyx":171 + /* "ssh2/session.pyx":178 * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: * raise AuthenticationError( # <<<<<<<<<<<<<< * "Error authenticating user %s with private key %s and" * "public key %s", */ - __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L8_error) + __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_kp_s_Error_authenticating_user_s_with); __Pyx_GIVEREF(__pyx_kp_s_Error_authenticating_user_s_with); @@ -3077,15 +3238,15 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( __Pyx_INCREF(__pyx_v_publickey); __Pyx_GIVEREF(__pyx_v_publickey); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_publickey); - __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AuthenticationError), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 171, __pyx_L8_error) + __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AuthenticationError), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 171, __pyx_L8_error) + __PYX_ERR(0, 178, __pyx_L8_error) } - /* "ssh2/session.pyx":170 + /* "ssh2/session.pyx":177 * self._session, _username, _publickey, _privatekey, _passphrase) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -3102,7 +3263,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( } } - /* "ssh2/session.pyx":169 + /* "ssh2/session.pyx":176 * rc = c_ssh2.libssh2_userauth_publickey_fromfile( * self._session, _username, _publickey, _privatekey, _passphrase) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -3112,7 +3273,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( } } - /* "ssh2/session.pyx":166 + /* "ssh2/session.pyx":173 * cdef char *_privatekey = b_privatekey * cdef char *_passphrase = b_passphrase * with nogil: # <<<<<<<<<<<<<< @@ -3138,7 +3299,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( } } - /* "ssh2/session.pyx":175 + /* "ssh2/session.pyx":182 * "public key %s", * username, privatekey, publickey) * return rc # <<<<<<<<<<<<<< @@ -3146,13 +3307,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( * def userauth_publickey(self, username not None, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 175, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 182, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":150 + /* "ssh2/session.pyx":157 * return auth.split(',') * * def userauth_publickey_fromfile(self, username not None, # <<<<<<<<<<<<<< @@ -3176,7 +3337,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( return __pyx_r; } -/* "ssh2/session.pyx":177 +/* "ssh2/session.pyx":184 * return rc * * def userauth_publickey(self, username not None, # <<<<<<<<<<<<<< @@ -3216,11 +3377,11 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_25userauth_publickey(PyObject case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pubkeydata)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("userauth_publickey", 1, 2, 2, 1); __PYX_ERR(0, 177, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey", 1, 2, 2, 1); __PYX_ERR(0, 184, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth_publickey") < 0)) __PYX_ERR(0, 177, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth_publickey") < 0)) __PYX_ERR(0, 184, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -3233,16 +3394,16 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_25userauth_publickey(PyObject } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("userauth_publickey", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 177, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 184, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.session.Session.userauth_publickey", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_username) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 177, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 184, __pyx_L1_error) } - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pubkeydata), (&PyBytes_Type), 0, "pubkeydata", 1))) __PYX_ERR(0, 178, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pubkeydata), (&PyBytes_Type), 0, "pubkeydata", 1))) __PYX_ERR(0, 185, __pyx_L1_error) __pyx_r = __pyx_pf_4ssh2_7session_7Session_24userauth_publickey(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_username, __pyx_v_pubkeydata); /* function exit code */ @@ -3270,49 +3431,53 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ PyObject *__pyx_t_6 = NULL; __Pyx_RefNannySetupContext("userauth_publickey", 0); - /* "ssh2/session.pyx":188 + /* "ssh2/session.pyx":195 * :rtype: int""" * cdef int rc * cdef bytes b_username = to_bytes(username) # <<<<<<<<<<<<<< * cdef char *_username = b_username * cdef unsigned char *_pubkeydata = pubkeydata */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_username = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":189 + /* "ssh2/session.pyx":196 * cdef int rc * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username # <<<<<<<<<<<<<< * cdef unsigned char *_pubkeydata = pubkeydata * cdef size_t pubkeydata_len = len(pubkeydata) */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 189, __pyx_L1_error) + if (unlikely(__pyx_v_b_username == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 196, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 196, __pyx_L1_error) __pyx_v__username = __pyx_t_2; - /* "ssh2/session.pyx":190 + /* "ssh2/session.pyx":197 * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username * cdef unsigned char *_pubkeydata = pubkeydata # <<<<<<<<<<<<<< * cdef size_t pubkeydata_len = len(pubkeydata) * with nogil: */ - __pyx_t_3 = __Pyx_PyObject_AsWritableUString(__pyx_v_pubkeydata); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 190, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyBytes_AsWritableUString(__pyx_v_pubkeydata); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 197, __pyx_L1_error) __pyx_v__pubkeydata = __pyx_t_3; - /* "ssh2/session.pyx":191 + /* "ssh2/session.pyx":198 * cdef char *_username = b_username * cdef unsigned char *_pubkeydata = pubkeydata * cdef size_t pubkeydata_len = len(pubkeydata) # <<<<<<<<<<<<<< * with nogil: * rc = c_ssh2.libssh2_userauth_publickey( */ - __pyx_t_4 = PyBytes_GET_SIZE(__pyx_v_pubkeydata); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 191, __pyx_L1_error) + __pyx_t_4 = PyBytes_GET_SIZE(__pyx_v_pubkeydata); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 198, __pyx_L1_error) __pyx_v_pubkeydata_len = __pyx_t_4; - /* "ssh2/session.pyx":192 + /* "ssh2/session.pyx":199 * cdef unsigned char *_pubkeydata = pubkeydata * cdef size_t pubkeydata_len = len(pubkeydata) * with nogil: # <<<<<<<<<<<<<< @@ -3327,7 +3492,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ #endif /*try:*/ { - /* "ssh2/session.pyx":193 + /* "ssh2/session.pyx":200 * cdef size_t pubkeydata_len = len(pubkeydata) * with nogil: * rc = c_ssh2.libssh2_userauth_publickey( # <<<<<<<<<<<<<< @@ -3336,7 +3501,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ */ __pyx_v_rc = libssh2_userauth_publickey(__pyx_v_self->_session, __pyx_v__username, __pyx_v__pubkeydata, __pyx_v_pubkeydata_len, NULL, NULL); - /* "ssh2/session.pyx":196 + /* "ssh2/session.pyx":203 * self._session, _username, _pubkeydata, * pubkeydata_len, NULL, NULL) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -3354,7 +3519,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ } if (__pyx_t_5) { - /* "ssh2/session.pyx":197 + /* "ssh2/session.pyx":204 * pubkeydata_len, NULL, NULL) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -3367,14 +3532,14 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ #endif /*try:*/ { - /* "ssh2/session.pyx":198 + /* "ssh2/session.pyx":205 * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: * raise AuthenticationError( # <<<<<<<<<<<<<< * "Error authenticating user %s with public key data", * username) */ - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L8_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_kp_s_Error_authenticating_user_s_with_2); __Pyx_GIVEREF(__pyx_kp_s_Error_authenticating_user_s_with_2); @@ -3382,15 +3547,15 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ __Pyx_INCREF(__pyx_v_username); __Pyx_GIVEREF(__pyx_v_username); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_username); - __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AuthenticationError), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 198, __pyx_L8_error) + __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AuthenticationError), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 205, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(0, 198, __pyx_L8_error) + __PYX_ERR(0, 205, __pyx_L8_error) } - /* "ssh2/session.pyx":197 + /* "ssh2/session.pyx":204 * pubkeydata_len, NULL, NULL) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -3407,7 +3572,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ } } - /* "ssh2/session.pyx":196 + /* "ssh2/session.pyx":203 * self._session, _username, _pubkeydata, * pubkeydata_len, NULL, NULL) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -3417,7 +3582,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ } } - /* "ssh2/session.pyx":192 + /* "ssh2/session.pyx":199 * cdef unsigned char *_pubkeydata = pubkeydata * cdef size_t pubkeydata_len = len(pubkeydata) * with nogil: # <<<<<<<<<<<<<< @@ -3443,7 +3608,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ } } - /* "ssh2/session.pyx":201 + /* "ssh2/session.pyx":208 * "Error authenticating user %s with public key data", * username) * return rc # <<<<<<<<<<<<<< @@ -3451,13 +3616,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ * def userauth_hostbased_fromfile(self, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 201, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":177 + /* "ssh2/session.pyx":184 * return rc * * def userauth_publickey(self, username not None, # <<<<<<<<<<<<<< @@ -3478,7 +3643,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ return __pyx_r; } -/* "ssh2/session.pyx":203 +/* "ssh2/session.pyx":210 * return rc * * def userauth_hostbased_fromfile(self, # <<<<<<<<<<<<<< @@ -3527,29 +3692,29 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_27userauth_hostbased_fromfile( case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_publickey)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("userauth_hostbased_fromfile", 1, 5, 5, 1); __PYX_ERR(0, 203, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_hostbased_fromfile", 1, 5, 5, 1); __PYX_ERR(0, 210, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_privatekey)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("userauth_hostbased_fromfile", 1, 5, 5, 2); __PYX_ERR(0, 203, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_hostbased_fromfile", 1, 5, 5, 2); __PYX_ERR(0, 210, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_passphrase)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("userauth_hostbased_fromfile", 1, 5, 5, 3); __PYX_ERR(0, 203, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_hostbased_fromfile", 1, 5, 5, 3); __PYX_ERR(0, 210, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_hostname)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("userauth_hostbased_fromfile", 1, 5, 5, 4); __PYX_ERR(0, 203, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_hostbased_fromfile", 1, 5, 5, 4); __PYX_ERR(0, 210, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth_hostbased_fromfile") < 0)) __PYX_ERR(0, 203, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth_hostbased_fromfile") < 0)) __PYX_ERR(0, 210, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; @@ -3568,26 +3733,26 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_27userauth_hostbased_fromfile( } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("userauth_hostbased_fromfile", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 203, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_hostbased_fromfile", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 210, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.session.Session.userauth_hostbased_fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_username) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 204, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 211, __pyx_L1_error) } if (unlikely(((PyObject *)__pyx_v_publickey) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "publickey"); __PYX_ERR(0, 205, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "publickey"); __PYX_ERR(0, 212, __pyx_L1_error) } if (unlikely(((PyObject *)__pyx_v_privatekey) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "privatekey"); __PYX_ERR(0, 206, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "privatekey"); __PYX_ERR(0, 213, __pyx_L1_error) } if (unlikely(((PyObject *)__pyx_v_passphrase) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "passphrase"); __PYX_ERR(0, 207, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "passphrase"); __PYX_ERR(0, 214, __pyx_L1_error) } if (unlikely(((PyObject *)__pyx_v_hostname) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "hostname"); __PYX_ERR(0, 208, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "hostname"); __PYX_ERR(0, 215, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_username, __pyx_v_publickey, __pyx_v_privatekey, __pyx_v_passphrase, __pyx_v_hostname); @@ -3620,117 +3785,137 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("userauth_hostbased_fromfile", 0); - /* "ssh2/session.pyx":210 + /* "ssh2/session.pyx":217 * hostname not None): * cdef int rc * cdef bytes b_username = to_bytes(username) # <<<<<<<<<<<<<< * cdef bytes b_publickey = to_bytes(publickey) * cdef bytes b_privatekey = to_bytes(privatekey) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_username = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":211 + /* "ssh2/session.pyx":218 * cdef int rc * cdef bytes b_username = to_bytes(username) * cdef bytes b_publickey = to_bytes(publickey) # <<<<<<<<<<<<<< * cdef bytes b_privatekey = to_bytes(privatekey) * cdef bytes b_passphrase = to_bytes(passphrase) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_publickey); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_publickey); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_publickey = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":212 + /* "ssh2/session.pyx":219 * cdef bytes b_username = to_bytes(username) * cdef bytes b_publickey = to_bytes(publickey) * cdef bytes b_privatekey = to_bytes(privatekey) # <<<<<<<<<<<<<< * cdef bytes b_passphrase = to_bytes(passphrase) * cdef bytes b_hostname = to_bytes(hostname) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_privatekey); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_privatekey); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_privatekey = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":213 + /* "ssh2/session.pyx":220 * cdef bytes b_publickey = to_bytes(publickey) * cdef bytes b_privatekey = to_bytes(privatekey) * cdef bytes b_passphrase = to_bytes(passphrase) # <<<<<<<<<<<<<< * cdef bytes b_hostname = to_bytes(hostname) * cdef char *_username = b_username */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_passphrase); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 213, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_passphrase); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 220, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_passphrase = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":214 + /* "ssh2/session.pyx":221 * cdef bytes b_privatekey = to_bytes(privatekey) * cdef bytes b_passphrase = to_bytes(passphrase) * cdef bytes b_hostname = to_bytes(hostname) # <<<<<<<<<<<<<< * cdef char *_username = b_username * cdef char *_publickey = b_publickey */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_hostname); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 214, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_hostname); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_hostname = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":215 + /* "ssh2/session.pyx":222 * cdef bytes b_passphrase = to_bytes(passphrase) * cdef bytes b_hostname = to_bytes(hostname) * cdef char *_username = b_username # <<<<<<<<<<<<<< * cdef char *_publickey = b_publickey * cdef char *_privatekey = b_privatekey */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L1_error) + if (unlikely(__pyx_v_b_username == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 222, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 222, __pyx_L1_error) __pyx_v__username = __pyx_t_2; - /* "ssh2/session.pyx":216 + /* "ssh2/session.pyx":223 * cdef bytes b_hostname = to_bytes(hostname) * cdef char *_username = b_username * cdef char *_publickey = b_publickey # <<<<<<<<<<<<<< * cdef char *_privatekey = b_privatekey * cdef char *_passphrase = b_passphrase */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_publickey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 216, __pyx_L1_error) + if (unlikely(__pyx_v_b_publickey == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 223, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_publickey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 223, __pyx_L1_error) __pyx_v__publickey = __pyx_t_2; - /* "ssh2/session.pyx":217 + /* "ssh2/session.pyx":224 * cdef char *_username = b_username * cdef char *_publickey = b_publickey * cdef char *_privatekey = b_privatekey # <<<<<<<<<<<<<< * cdef char *_passphrase = b_passphrase * cdef char *_hostname = b_hostname */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_privatekey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 217, __pyx_L1_error) + if (unlikely(__pyx_v_b_privatekey == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 224, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_privatekey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 224, __pyx_L1_error) __pyx_v__privatekey = __pyx_t_2; - /* "ssh2/session.pyx":218 + /* "ssh2/session.pyx":225 * cdef char *_publickey = b_publickey * cdef char *_privatekey = b_privatekey * cdef char *_passphrase = b_passphrase # <<<<<<<<<<<<<< * cdef char *_hostname = b_hostname * with nogil: */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_passphrase); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L1_error) + if (unlikely(__pyx_v_b_passphrase == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 225, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_passphrase); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 225, __pyx_L1_error) __pyx_v__passphrase = __pyx_t_2; - /* "ssh2/session.pyx":219 + /* "ssh2/session.pyx":226 * cdef char *_privatekey = b_privatekey * cdef char *_passphrase = b_passphrase * cdef char *_hostname = b_hostname # <<<<<<<<<<<<<< * with nogil: * rc = c_ssh2.libssh2_userauth_hostbased_fromfile( */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_hostname); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 219, __pyx_L1_error) + if (unlikely(__pyx_v_b_hostname == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 226, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_hostname); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 226, __pyx_L1_error) __pyx_v__hostname = __pyx_t_2; - /* "ssh2/session.pyx":220 + /* "ssh2/session.pyx":227 * cdef char *_passphrase = b_passphrase * cdef char *_hostname = b_hostname * with nogil: # <<<<<<<<<<<<<< @@ -3745,7 +3930,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( #endif /*try:*/ { - /* "ssh2/session.pyx":221 + /* "ssh2/session.pyx":228 * cdef char *_hostname = b_hostname * with nogil: * rc = c_ssh2.libssh2_userauth_hostbased_fromfile( # <<<<<<<<<<<<<< @@ -3754,7 +3939,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( */ __pyx_v_rc = libssh2_userauth_hostbased_fromfile(__pyx_v_self->_session, __pyx_v__username, __pyx_v__publickey, __pyx_v__privatekey, __pyx_v__passphrase, __pyx_v__hostname); - /* "ssh2/session.pyx":224 + /* "ssh2/session.pyx":231 * self._session, _username, _publickey, * _privatekey, _passphrase, _hostname) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -3772,7 +3957,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( } if (__pyx_t_3) { - /* "ssh2/session.pyx":225 + /* "ssh2/session.pyx":232 * _privatekey, _passphrase, _hostname) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -3785,14 +3970,14 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( #endif /*try:*/ { - /* "ssh2/session.pyx":226 + /* "ssh2/session.pyx":233 * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: * raise AuthenticationError( # <<<<<<<<<<<<<< * "Error authenticating user %s with private key %s and" * "public key %s for host %s", */ - __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L8_error) + __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 233, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_kp_s_Error_authenticating_user_s_with_3); __Pyx_GIVEREF(__pyx_kp_s_Error_authenticating_user_s_with_3); @@ -3809,15 +3994,15 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( __Pyx_INCREF(__pyx_v_hostname); __Pyx_GIVEREF(__pyx_v_hostname); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_v_hostname); - __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AuthenticationError), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 226, __pyx_L8_error) + __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AuthenticationError), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 233, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 226, __pyx_L8_error) + __PYX_ERR(0, 233, __pyx_L8_error) } - /* "ssh2/session.pyx":225 + /* "ssh2/session.pyx":232 * _privatekey, _passphrase, _hostname) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -3834,7 +4019,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( } } - /* "ssh2/session.pyx":224 + /* "ssh2/session.pyx":231 * self._session, _username, _publickey, * _privatekey, _passphrase, _hostname) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -3844,7 +4029,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( } } - /* "ssh2/session.pyx":220 + /* "ssh2/session.pyx":227 * cdef char *_passphrase = b_passphrase * cdef char *_hostname = b_hostname * with nogil: # <<<<<<<<<<<<<< @@ -3870,7 +4055,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( } } - /* "ssh2/session.pyx":230 + /* "ssh2/session.pyx":237 * "public key %s for host %s", * username, privatekey, publickey, hostname) * return rc # <<<<<<<<<<<<<< @@ -3878,13 +4063,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( * IF EMBEDDED_LIB: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 230, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":203 + /* "ssh2/session.pyx":210 * return rc * * def userauth_hostbased_fromfile(self, # <<<<<<<<<<<<<< @@ -3909,7 +4094,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( return __pyx_r; } -/* "ssh2/session.pyx":256 +/* "ssh2/session.pyx":263 * return rc * * def userauth_password(self, username not None, password not None): # <<<<<<<<<<<<<< @@ -3949,11 +4134,11 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_29userauth_password(PyObject * case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_password)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("userauth_password", 1, 2, 2, 1); __PYX_ERR(0, 256, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_password", 1, 2, 2, 1); __PYX_ERR(0, 263, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth_password") < 0)) __PYX_ERR(0, 256, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth_password") < 0)) __PYX_ERR(0, 263, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -3966,17 +4151,17 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_29userauth_password(PyObject * } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("userauth_password", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 256, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_password", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 263, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.session.Session.userauth_password", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_username) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 256, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 263, __pyx_L1_error) } if (unlikely(((PyObject *)__pyx_v_password) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "password"); __PYX_ERR(0, 256, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "password"); __PYX_ERR(0, 263, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_28userauth_password(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_username, __pyx_v_password); @@ -4004,51 +4189,59 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_password(struct __p PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("userauth_password", 0); - /* "ssh2/session.pyx":264 + /* "ssh2/session.pyx":271 * :type password: str""" * cdef int rc * cdef bytes b_username = to_bytes(username) # <<<<<<<<<<<<<< * cdef bytes b_password = to_bytes(password) * cdef const char *_username = b_username */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_username = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":265 + /* "ssh2/session.pyx":272 * cdef int rc * cdef bytes b_username = to_bytes(username) * cdef bytes b_password = to_bytes(password) # <<<<<<<<<<<<<< * cdef const char *_username = b_username * cdef const char *_password = b_password */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_password); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 265, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_password); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_password = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":266 + /* "ssh2/session.pyx":273 * cdef bytes b_username = to_bytes(username) * cdef bytes b_password = to_bytes(password) * cdef const char *_username = b_username # <<<<<<<<<<<<<< * cdef const char *_password = b_password * with nogil: */ - __pyx_t_2 = __Pyx_PyObject_AsString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 266, __pyx_L1_error) + if (unlikely(__pyx_v_b_username == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 273, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 273, __pyx_L1_error) __pyx_v__username = __pyx_t_2; - /* "ssh2/session.pyx":267 + /* "ssh2/session.pyx":274 * cdef bytes b_password = to_bytes(password) * cdef const char *_username = b_username * cdef const char *_password = b_password # <<<<<<<<<<<<<< * with nogil: * rc = c_ssh2.libssh2_userauth_password( */ - __pyx_t_3 = __Pyx_PyObject_AsString(__pyx_v_b_password); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 267, __pyx_L1_error) + if (unlikely(__pyx_v_b_password == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 274, __pyx_L1_error) + } + __pyx_t_3 = __Pyx_PyBytes_AsString(__pyx_v_b_password); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 274, __pyx_L1_error) __pyx_v__password = __pyx_t_3; - /* "ssh2/session.pyx":268 + /* "ssh2/session.pyx":275 * cdef const char *_username = b_username * cdef const char *_password = b_password * with nogil: # <<<<<<<<<<<<<< @@ -4063,7 +4256,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_password(struct __p #endif /*try:*/ { - /* "ssh2/session.pyx":269 + /* "ssh2/session.pyx":276 * cdef const char *_password = b_password * with nogil: * rc = c_ssh2.libssh2_userauth_password( # <<<<<<<<<<<<<< @@ -4072,7 +4265,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_password(struct __p */ __pyx_v_rc = libssh2_userauth_password(__pyx_v_self->_session, __pyx_v__username, __pyx_v__password); - /* "ssh2/session.pyx":271 + /* "ssh2/session.pyx":278 * rc = c_ssh2.libssh2_userauth_password( * self._session, _username, _password) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -4090,7 +4283,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_password(struct __p } if (__pyx_t_4) { - /* "ssh2/session.pyx":272 + /* "ssh2/session.pyx":279 * self._session, _username, _password) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -4103,14 +4296,14 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_password(struct __p #endif /*try:*/ { - /* "ssh2/session.pyx":273 + /* "ssh2/session.pyx":280 * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: * raise AuthenticationError( # <<<<<<<<<<<<<< * "Error authenticating user %s with password", * username) */ - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 273, __pyx_L8_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_kp_s_Error_authenticating_user_s_with_4); __Pyx_GIVEREF(__pyx_kp_s_Error_authenticating_user_s_with_4); @@ -4118,15 +4311,15 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_password(struct __p __Pyx_INCREF(__pyx_v_username); __Pyx_GIVEREF(__pyx_v_username); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_username); - __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AuthenticationError), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 273, __pyx_L8_error) + __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AuthenticationError), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 280, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __PYX_ERR(0, 273, __pyx_L8_error) + __PYX_ERR(0, 280, __pyx_L8_error) } - /* "ssh2/session.pyx":272 + /* "ssh2/session.pyx":279 * self._session, _username, _password) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -4143,7 +4336,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_password(struct __p } } - /* "ssh2/session.pyx":271 + /* "ssh2/session.pyx":278 * rc = c_ssh2.libssh2_userauth_password( * self._session, _username, _password) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -4153,7 +4346,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_password(struct __p } } - /* "ssh2/session.pyx":268 + /* "ssh2/session.pyx":275 * cdef const char *_username = b_username * cdef const char *_password = b_password * with nogil: # <<<<<<<<<<<<<< @@ -4179,7 +4372,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_password(struct __p } } - /* "ssh2/session.pyx":276 + /* "ssh2/session.pyx":283 * "Error authenticating user %s with password", * username) * return rc # <<<<<<<<<<<<<< @@ -4187,13 +4380,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_password(struct __p * def agent_init(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 276, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":256 + /* "ssh2/session.pyx":263 * return rc * * def userauth_password(self, username not None, password not None): # <<<<<<<<<<<<<< @@ -4215,7 +4408,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_password(struct __p return __pyx_r; } -/* "ssh2/session.pyx":278 +/* "ssh2/session.pyx":285 * return rc * * def agent_init(self): # <<<<<<<<<<<<<< @@ -4245,11 +4438,11 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_30agent_init(struct __pyx_obj_ PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("agent_init", 0); - /* "ssh2/session.pyx":284 + /* "ssh2/session.pyx":291 * """ * cdef c_ssh2.LIBSSH2_AGENT *agent * with nogil: # <<<<<<<<<<<<<< - * agent = self._agent_init() + * agent = agent_init(self._session) * return PyAgent(agent, self) */ { @@ -4260,22 +4453,22 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_30agent_init(struct __pyx_obj_ #endif /*try:*/ { - /* "ssh2/session.pyx":285 + /* "ssh2/session.pyx":292 * cdef c_ssh2.LIBSSH2_AGENT *agent * with nogil: - * agent = self._agent_init() # <<<<<<<<<<<<<< + * agent = agent_init(self._session) # <<<<<<<<<<<<<< * return PyAgent(agent, self) * */ - __pyx_t_1 = ((struct __pyx_vtabstruct_4ssh2_7session_Session *)__pyx_v_self->__pyx_vtab)->_agent_init(__pyx_v_self); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(0, 285, __pyx_L4_error) + __pyx_t_1 = __pyx_f_4ssh2_5agent_agent_init(__pyx_v_self->_session); if (unlikely(__pyx_t_1 == ((LIBSSH2_AGENT *)NULL))) __PYX_ERR(0, 292, __pyx_L4_error) __pyx_v_agent = __pyx_t_1; } - /* "ssh2/session.pyx":284 + /* "ssh2/session.pyx":291 * """ * cdef c_ssh2.LIBSSH2_AGENT *agent * with nogil: # <<<<<<<<<<<<<< - * agent = self._agent_init() + * agent = agent_init(self._session) * return PyAgent(agent, self) */ /*finally:*/ { @@ -4297,21 +4490,21 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_30agent_init(struct __pyx_obj_ } } - /* "ssh2/session.pyx":286 + /* "ssh2/session.pyx":293 * with nogil: - * agent = self._agent_init() + * agent = agent_init(self._session) * return PyAgent(agent, self) # <<<<<<<<<<<<<< * - * cdef c_ssh2.LIBSSH2_AGENT * _agent_init(self) nogil except NULL: + * def agent_auth(self, username not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_f_4ssh2_5agent_PyAgent(__pyx_v_agent, __pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_2 = __pyx_f_4ssh2_5agent_PyAgent(__pyx_v_agent, __pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":278 + /* "ssh2/session.pyx":285 * return rc * * def agent_init(self): # <<<<<<<<<<<<<< @@ -4330,395 +4523,76 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_30agent_init(struct __pyx_obj_ return __pyx_r; } -/* "ssh2/session.pyx":288 +/* "ssh2/session.pyx":295 * return PyAgent(agent, self) * - * cdef c_ssh2.LIBSSH2_AGENT * _agent_init(self) nogil except NULL: # <<<<<<<<<<<<<< - * cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( - * self._session) + * def agent_auth(self, username not None): # <<<<<<<<<<<<<< + * """Convenience function for performing user authentication via SSH Agent. + * */ -static LIBSSH2_AGENT *__pyx_f_4ssh2_7session_7Session__agent_init(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self) { +/* Python wrapper */ +static PyObject *__pyx_pw_4ssh2_7session_7Session_33agent_auth(PyObject *__pyx_v_self, PyObject *__pyx_v_username); /*proto*/ +static char __pyx_doc_4ssh2_7session_7Session_32agent_auth[] = "Session.agent_auth(self, username)\nConvenience function for performing user authentication via SSH Agent.\n\n Initialises, connects to, gets list of identities from and attempts\n authentication with each identity from SSH agent.\n\n Note that agent connections cannot be used in non-blocking mode -\n clients should call `set_blocking(0)` *after* calling this function.\n\n On completion, or any errors, agent is disconnected and resources freed.\n\n All steps are performed in C space which makes this function perform\n better than calling the individual Agent class functions from\n Python.\n\n :raises: :py:class:`MemoryError` on error initialising agent\n :raises: :py:class:`ssh2.exceptions.AgentConnectionError` on error\n connecting to agent\n :raises: :py:class:`ssh2.exceptions.AgentListIdentitiesError` on error\n getting identities from agent\n :raises: :py:class:`ssh2.exceptions.AgentAuthenticationFailure` on no\n successful authentication with all available identities.\n :raises: :py:class:`ssh2.exceptions.AgentGetIdentityError` on error\n getting known identity from agent\n\n :rtype: None"; +static PyObject *__pyx_pw_4ssh2_7session_7Session_33agent_auth(PyObject *__pyx_v_self, PyObject *__pyx_v_username) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("agent_auth (wrapper)", 0); + if (unlikely(((PyObject *)__pyx_v_username) == Py_None)) { + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 295, __pyx_L1_error) + } + __pyx_r = __pyx_pf_4ssh2_7session_7Session_32agent_auth(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), ((PyObject *)__pyx_v_username)); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_4ssh2_7session_7Session_32agent_auth(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, PyObject *__pyx_v_username) { + PyObject *__pyx_v_b_username = 0; + char *__pyx_v__username; LIBSSH2_AGENT *__pyx_v_agent; - LIBSSH2_AGENT *__pyx_r; + CYTHON_UNUSED struct libssh2_agent_publickey *__pyx_v_identity; + CYTHON_UNUSED struct libssh2_agent_publickey *__pyx_v_prev; + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - __Pyx_RefNannySetupContext("_agent_init", 0); - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif + PyObject *__pyx_t_1 = NULL; + char *__pyx_t_2; + LIBSSH2_AGENT *__pyx_t_3; + int __pyx_t_4; + __Pyx_RefNannySetupContext("agent_auth", 0); - /* "ssh2/session.pyx":289 + /* "ssh2/session.pyx":321 * - * cdef c_ssh2.LIBSSH2_AGENT * _agent_init(self) nogil except NULL: - * cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( # <<<<<<<<<<<<<< - * self._session) - * if agent is NULL: - */ - /*try:*/ { - - /* "ssh2/session.pyx":290 - * cdef c_ssh2.LIBSSH2_AGENT * _agent_init(self) nogil except NULL: - * cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( - * self._session) # <<<<<<<<<<<<<< - * if agent is NULL: - * with gil: + * :rtype: None""" + * cdef bytes b_username = to_bytes(username) # <<<<<<<<<<<<<< + * cdef char *_username = b_username + * cdef c_ssh2.LIBSSH2_AGENT *agent = NULL */ - __pyx_v_agent = libssh2_agent_init(__pyx_v_self->_session); + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 321, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_b_username = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; - /* "ssh2/session.pyx":291 - * cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( - * self._session) - * if agent is NULL: # <<<<<<<<<<<<<< - * with gil: - * raise AgentError("Error initialising agent") + /* "ssh2/session.pyx":322 + * :rtype: None""" + * cdef bytes b_username = to_bytes(username) + * cdef char *_username = b_username # <<<<<<<<<<<<<< + * cdef c_ssh2.LIBSSH2_AGENT *agent = NULL + * cdef c_ssh2.libssh2_agent_publickey *identity = NULL */ - __pyx_t_1 = ((__pyx_v_agent == NULL) != 0); - if (__pyx_t_1) { - - /* "ssh2/session.pyx":292 - * self._session) - * if agent is NULL: - * with gil: # <<<<<<<<<<<<<< - * raise AgentError("Error initialising agent") - * return agent - */ - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - /*try:*/ { - - /* "ssh2/session.pyx":293 - * if agent is NULL: - * with gil: - * raise AgentError("Error initialising agent") # <<<<<<<<<<<<<< - * return agent - * - */ - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentError), __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 293, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 293, __pyx_L8_error) - } - - /* "ssh2/session.pyx":292 - * self._session) - * if agent is NULL: - * with gil: # <<<<<<<<<<<<<< - * raise AgentError("Error initialising agent") - * return agent - */ - /*finally:*/ { - __pyx_L8_error: { - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - goto __pyx_L4_error; - } - } - } - - /* "ssh2/session.pyx":291 - * cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( - * self._session) - * if agent is NULL: # <<<<<<<<<<<<<< - * with gil: - * raise AgentError("Error initialising agent") - */ - } - - /* "ssh2/session.pyx":294 - * with gil: - * raise AgentError("Error initialising agent") - * return agent # <<<<<<<<<<<<<< - * - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL: - */ - __pyx_r = __pyx_v_agent; - goto __pyx_L3_return; - } - - /* "ssh2/session.pyx":289 - * - * cdef c_ssh2.LIBSSH2_AGENT * _agent_init(self) nogil except NULL: - * cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( # <<<<<<<<<<<<<< - * self._session) - * if agent is NULL: - */ - /*finally:*/ { - __pyx_L3_return: { - #ifdef WITH_THREAD - __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - goto __pyx_L0; - } - __pyx_L4_error: { - #ifdef WITH_THREAD - __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - goto __pyx_L1_error; - } - } - - /* "ssh2/session.pyx":288 - * return PyAgent(agent, self) - * - * cdef c_ssh2.LIBSSH2_AGENT * _agent_init(self) nogil except NULL: # <<<<<<<<<<<<<< - * cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( - * self._session) - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("ssh2.session.Session._agent_init", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - return __pyx_r; -} - -/* "ssh2/session.pyx":296 - * return agent - * - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL: # <<<<<<<<<<<<<< - * cdef c_ssh2.LIBSSH2_AGENT *agent - * with nogil: - */ - -static LIBSSH2_AGENT *__pyx_f_4ssh2_7session_7Session_init_connect_agent(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self) { - LIBSSH2_AGENT *__pyx_v_agent; - LIBSSH2_AGENT *__pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannySetupContext("init_connect_agent", 0); - - /* "ssh2/session.pyx":298 - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL: - * cdef c_ssh2.LIBSSH2_AGENT *agent - * with nogil: # <<<<<<<<<<<<<< - * agent = c_ssh2.libssh2_agent_init(self._session) - * if c_ssh2.libssh2_agent_connect(agent) != 0: - */ - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - __Pyx_FastGIL_Remember(); - #endif - /*try:*/ { - - /* "ssh2/session.pyx":299 - * cdef c_ssh2.LIBSSH2_AGENT *agent - * with nogil: - * agent = c_ssh2.libssh2_agent_init(self._session) # <<<<<<<<<<<<<< - * if c_ssh2.libssh2_agent_connect(agent) != 0: - * with nogil: - */ - __pyx_v_agent = libssh2_agent_init(__pyx_v_self->_session); - } - - /* "ssh2/session.pyx":298 - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL: - * cdef c_ssh2.LIBSSH2_AGENT *agent - * with nogil: # <<<<<<<<<<<<<< - * agent = c_ssh2.libssh2_agent_init(self._session) - * if c_ssh2.libssh2_agent_connect(agent) != 0: - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - __Pyx_FastGIL_Forget(); - Py_BLOCK_THREADS - #endif - goto __pyx_L5; - } - __pyx_L5:; - } - } - - /* "ssh2/session.pyx":300 - * with nogil: - * agent = c_ssh2.libssh2_agent_init(self._session) - * if c_ssh2.libssh2_agent_connect(agent) != 0: # <<<<<<<<<<<<<< - * with nogil: - * c_ssh2.libssh2_agent_free(agent) - */ - __pyx_t_1 = ((libssh2_agent_connect(__pyx_v_agent) != 0) != 0); - if (__pyx_t_1) { - - /* "ssh2/session.pyx":301 - * agent = c_ssh2.libssh2_agent_init(self._session) - * if c_ssh2.libssh2_agent_connect(agent) != 0: - * with nogil: # <<<<<<<<<<<<<< - * c_ssh2.libssh2_agent_free(agent) - * raise AgentConnectionError("Unable to connect to agent") - */ - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - __Pyx_FastGIL_Remember(); - #endif - /*try:*/ { - - /* "ssh2/session.pyx":302 - * if c_ssh2.libssh2_agent_connect(agent) != 0: - * with nogil: - * c_ssh2.libssh2_agent_free(agent) # <<<<<<<<<<<<<< - * raise AgentConnectionError("Unable to connect to agent") - * return agent - */ - libssh2_agent_free(__pyx_v_agent); - } - - /* "ssh2/session.pyx":301 - * agent = c_ssh2.libssh2_agent_init(self._session) - * if c_ssh2.libssh2_agent_connect(agent) != 0: - * with nogil: # <<<<<<<<<<<<<< - * c_ssh2.libssh2_agent_free(agent) - * raise AgentConnectionError("Unable to connect to agent") - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - __Pyx_FastGIL_Forget(); - Py_BLOCK_THREADS - #endif - goto __pyx_L9; - } - __pyx_L9:; - } - } - - /* "ssh2/session.pyx":303 - * with nogil: - * c_ssh2.libssh2_agent_free(agent) - * raise AgentConnectionError("Unable to connect to agent") # <<<<<<<<<<<<<< - * return agent - * - */ - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentConnectionError), __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 303, __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_ERR(0, 303, __pyx_L1_error) - - /* "ssh2/session.pyx":300 - * with nogil: - * agent = c_ssh2.libssh2_agent_init(self._session) - * if c_ssh2.libssh2_agent_connect(agent) != 0: # <<<<<<<<<<<<<< - * with nogil: - * c_ssh2.libssh2_agent_free(agent) - */ - } - - /* "ssh2/session.pyx":304 - * c_ssh2.libssh2_agent_free(agent) - * raise AgentConnectionError("Unable to connect to agent") - * return agent # <<<<<<<<<<<<<< - * - * def agent_auth(self, username not None): - */ - __pyx_r = __pyx_v_agent; - goto __pyx_L0; - - /* "ssh2/session.pyx":296 - * return agent - * - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL: # <<<<<<<<<<<<<< - * cdef c_ssh2.LIBSSH2_AGENT *agent - * with nogil: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("ssh2.session.Session.init_connect_agent", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "ssh2/session.pyx":306 - * return agent - * - * def agent_auth(self, username not None): # <<<<<<<<<<<<<< - * """Convenience function for performing user authentication via SSH Agent. - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_7session_7Session_33agent_auth(PyObject *__pyx_v_self, PyObject *__pyx_v_username); /*proto*/ -static char __pyx_doc_4ssh2_7session_7Session_32agent_auth[] = "Session.agent_auth(self, username)\nConvenience function for performing user authentication via SSH Agent.\n\n Initialises, connects to, gets list of identities from and attempts\n authentication with each identity from SSH agent.\n\n Note that agent connections cannot be used in non-blocking mode -\n clients should call `set_blocking(0)` *after* calling this function.\n\n On completion, or any errors, agent is disconnected and resources freed.\n\n All steps are performed in C space which makes this function perform\n better than calling the individual Agent class functions from\n Python.\n\n :raises: :py:class:`MemoryError` on error initialising agent\n :raises: :py:class:`ssh2.exceptions.AgentConnectionError` on error\n connecting to agent\n :raises: :py:class:`ssh2.exceptions.AgentListIdentitiesError` on error\n getting identities from agent\n :raises: :py:class:`ssh2.exceptions.AgentAuthenticationFailure` on no\n successful authentication with all available identities.\n :raises: :py:class:`ssh2.exceptions.AgentGetIdentityError` on error\n getting known identity from agent\n\n :rtype: None"; -static PyObject *__pyx_pw_4ssh2_7session_7Session_33agent_auth(PyObject *__pyx_v_self, PyObject *__pyx_v_username) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("agent_auth (wrapper)", 0); - if (unlikely(((PyObject *)__pyx_v_username) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 306, __pyx_L1_error) + if (unlikely(__pyx_v_b_username == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 322, __pyx_L1_error) } - __pyx_r = __pyx_pf_4ssh2_7session_7Session_32agent_auth(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), ((PyObject *)__pyx_v_username)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_4ssh2_7session_7Session_32agent_auth(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, PyObject *__pyx_v_username) { - PyObject *__pyx_v_b_username = 0; - char *__pyx_v__username; - LIBSSH2_AGENT *__pyx_v_agent; - struct libssh2_agent_publickey *__pyx_v_identity; - struct libssh2_agent_publickey *__pyx_v_prev; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - char *__pyx_t_2; - LIBSSH2_AGENT *__pyx_t_3; - int __pyx_t_4; - int __pyx_t_5; - __Pyx_RefNannySetupContext("agent_auth", 0); - - /* "ssh2/session.pyx":332 - * - * :rtype: None""" - * cdef bytes b_username = to_bytes(username) # <<<<<<<<<<<<<< - * cdef char *_username = b_username - * cdef c_ssh2.LIBSSH2_AGENT *agent = NULL - */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_b_username = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "ssh2/session.pyx":333 - * :rtype: None""" - * cdef bytes b_username = to_bytes(username) - * cdef char *_username = b_username # <<<<<<<<<<<<<< - * cdef c_ssh2.LIBSSH2_AGENT *agent = NULL - * cdef c_ssh2.libssh2_agent_publickey *identity = NULL - */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 333, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 322, __pyx_L1_error) __pyx_v__username = __pyx_t_2; - /* "ssh2/session.pyx":334 + /* "ssh2/session.pyx":323 * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username * cdef c_ssh2.LIBSSH2_AGENT *agent = NULL # <<<<<<<<<<<<<< @@ -4727,40 +4601,40 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_32agent_auth(struct __pyx_obj_ */ __pyx_v_agent = NULL; - /* "ssh2/session.pyx":335 + /* "ssh2/session.pyx":324 * cdef char *_username = b_username * cdef c_ssh2.LIBSSH2_AGENT *agent = NULL * cdef c_ssh2.libssh2_agent_publickey *identity = NULL # <<<<<<<<<<<<<< * cdef c_ssh2.libssh2_agent_publickey *prev = NULL - * agent = self.init_connect_agent() + * agent = init_connect_agent(self._session) */ __pyx_v_identity = NULL; - /* "ssh2/session.pyx":336 + /* "ssh2/session.pyx":325 * cdef c_ssh2.LIBSSH2_AGENT *agent = NULL * cdef c_ssh2.libssh2_agent_publickey *identity = NULL * cdef c_ssh2.libssh2_agent_publickey *prev = NULL # <<<<<<<<<<<<<< - * agent = self.init_connect_agent() + * agent = init_connect_agent(self._session) * with nogil: */ __pyx_v_prev = NULL; - /* "ssh2/session.pyx":337 + /* "ssh2/session.pyx":326 * cdef c_ssh2.libssh2_agent_publickey *identity = NULL * cdef c_ssh2.libssh2_agent_publickey *prev = NULL - * agent = self.init_connect_agent() # <<<<<<<<<<<<<< + * agent = init_connect_agent(self._session) # <<<<<<<<<<<<<< * with nogil: - * if c_ssh2.libssh2_agent_list_identities(agent) != 0: + * agent_auth(_username, agent) */ - __pyx_t_3 = ((struct __pyx_vtabstruct_4ssh2_7session_Session *)__pyx_v_self->__pyx_vtab)->init_connect_agent(__pyx_v_self); if (unlikely(__pyx_t_3 == NULL)) __PYX_ERR(0, 337, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_5agent_init_connect_agent(__pyx_v_self->_session); if (unlikely(__pyx_t_3 == ((LIBSSH2_AGENT *)NULL))) __PYX_ERR(0, 326, __pyx_L1_error) __pyx_v_agent = __pyx_t_3; - /* "ssh2/session.pyx":338 + /* "ssh2/session.pyx":327 * cdef c_ssh2.libssh2_agent_publickey *prev = NULL - * agent = self.init_connect_agent() + * agent = init_connect_agent(self._session) * with nogil: # <<<<<<<<<<<<<< - * if c_ssh2.libssh2_agent_list_identities(agent) != 0: - * clear_agent(agent) + * agent_auth(_username, agent) + * */ { #ifdef WITH_THREAD @@ -4770,159 +4644,22 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_32agent_auth(struct __pyx_obj_ #endif /*try:*/ { - /* "ssh2/session.pyx":339 - * agent = self.init_connect_agent() + /* "ssh2/session.pyx":328 + * agent = init_connect_agent(self._session) * with nogil: - * if c_ssh2.libssh2_agent_list_identities(agent) != 0: # <<<<<<<<<<<<<< - * clear_agent(agent) - * with gil: - */ - __pyx_t_4 = ((libssh2_agent_list_identities(__pyx_v_agent) != 0) != 0); - if (__pyx_t_4) { - - /* "ssh2/session.pyx":340 - * with nogil: - * if c_ssh2.libssh2_agent_list_identities(agent) != 0: - * clear_agent(agent) # <<<<<<<<<<<<<< - * with gil: - * raise AgentListIdentitiesError( - */ - __pyx_f_4ssh2_5agent_clear_agent(__pyx_v_agent); - - /* "ssh2/session.pyx":341 - * if c_ssh2.libssh2_agent_list_identities(agent) != 0: - * clear_agent(agent) - * with gil: # <<<<<<<<<<<<<< - * raise AgentListIdentitiesError( - * "Failure requesting identities from agent") - */ - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - /*try:*/ { - - /* "ssh2/session.pyx":342 - * clear_agent(agent) - * with gil: - * raise AgentListIdentitiesError( # <<<<<<<<<<<<<< - * "Failure requesting identities from agent") - * while 1: - */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_AgentListIdentitiesError), __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 342, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 342, __pyx_L8_error) - } - - /* "ssh2/session.pyx":341 - * if c_ssh2.libssh2_agent_list_identities(agent) != 0: - * clear_agent(agent) - * with gil: # <<<<<<<<<<<<<< - * raise AgentListIdentitiesError( - * "Failure requesting identities from agent") - */ - /*finally:*/ { - __pyx_L8_error: { - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - goto __pyx_L4_error; - } - } - } - - /* "ssh2/session.pyx":339 - * agent = self.init_connect_agent() - * with nogil: - * if c_ssh2.libssh2_agent_list_identities(agent) != 0: # <<<<<<<<<<<<<< - * clear_agent(agent) - * with gil: - */ - } - - /* "ssh2/session.pyx":344 - * raise AgentListIdentitiesError( - * "Failure requesting identities from agent") - * while 1: # <<<<<<<<<<<<<< - * auth_identity(_username, agent, &identity, prev) - * if c_ssh2.libssh2_agent_userauth( - */ - while (1) { - - /* "ssh2/session.pyx":345 - * "Failure requesting identities from agent") - * while 1: - * auth_identity(_username, agent, &identity, prev) # <<<<<<<<<<<<<< - * if c_ssh2.libssh2_agent_userauth( - * agent, _username, identity) == 0: - */ - __pyx_t_5 = __pyx_f_4ssh2_5agent_auth_identity(__pyx_v__username, __pyx_v_agent, (&__pyx_v_identity), __pyx_v_prev); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 345, __pyx_L4_error) - - /* "ssh2/session.pyx":347 - * auth_identity(_username, agent, &identity, prev) - * if c_ssh2.libssh2_agent_userauth( - * agent, _username, identity) == 0: # <<<<<<<<<<<<<< - * clear_agent(agent) - * break - */ - __pyx_t_4 = ((libssh2_agent_userauth(__pyx_v_agent, __pyx_v__username, __pyx_v_identity) == 0) != 0); - - /* "ssh2/session.pyx":346 - * while 1: - * auth_identity(_username, agent, &identity, prev) - * if c_ssh2.libssh2_agent_userauth( # <<<<<<<<<<<<<< - * agent, _username, identity) == 0: - * clear_agent(agent) - */ - if (__pyx_t_4) { - - /* "ssh2/session.pyx":348 - * if c_ssh2.libssh2_agent_userauth( - * agent, _username, identity) == 0: - * clear_agent(agent) # <<<<<<<<<<<<<< - * break - * prev = identity - */ - __pyx_f_4ssh2_5agent_clear_agent(__pyx_v_agent); - - /* "ssh2/session.pyx":349 - * agent, _username, identity) == 0: - * clear_agent(agent) - * break # <<<<<<<<<<<<<< - * prev = identity - * - */ - goto __pyx_L11_break; - - /* "ssh2/session.pyx":346 - * while 1: - * auth_identity(_username, agent, &identity, prev) - * if c_ssh2.libssh2_agent_userauth( # <<<<<<<<<<<<<< - * agent, _username, identity) == 0: - * clear_agent(agent) - */ - } - - /* "ssh2/session.pyx":350 - * clear_agent(agent) - * break - * prev = identity # <<<<<<<<<<<<<< + * agent_auth(_username, agent) # <<<<<<<<<<<<<< * * def open_session(self): */ - __pyx_v_prev = __pyx_v_identity; - } - __pyx_L11_break:; + __pyx_t_4 = __pyx_f_4ssh2_5agent_agent_auth(__pyx_v__username, __pyx_v_agent); if (unlikely(__pyx_t_4 == ((int)1))) __PYX_ERR(0, 328, __pyx_L4_error) } - /* "ssh2/session.pyx":338 + /* "ssh2/session.pyx":327 * cdef c_ssh2.libssh2_agent_publickey *prev = NULL - * agent = self.init_connect_agent() + * agent = init_connect_agent(self._session) * with nogil: # <<<<<<<<<<<<<< - * if c_ssh2.libssh2_agent_list_identities(agent) != 0: - * clear_agent(agent) + * agent_auth(_username, agent) + * */ /*finally:*/ { /*normal exit:*/{ @@ -4943,8 +4680,8 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_32agent_auth(struct __pyx_obj_ } } - /* "ssh2/session.pyx":306 - * return agent + /* "ssh2/session.pyx":295 + * return PyAgent(agent, self) * * def agent_auth(self, username not None): # <<<<<<<<<<<<<< * """Convenience function for performing user authentication via SSH Agent. @@ -4965,8 +4702,8 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_32agent_auth(struct __pyx_obj_ return __pyx_r; } -/* "ssh2/session.pyx":352 - * prev = identity +/* "ssh2/session.pyx":330 + * agent_auth(_username, agent) * * def open_session(self): # <<<<<<<<<<<<<< * """Open new channel session. @@ -4995,7 +4732,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34open_session(struct __pyx_ob PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("open_session", 0); - /* "ssh2/session.pyx":358 + /* "ssh2/session.pyx":336 * """ * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -5010,7 +4747,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34open_session(struct __pyx_ob #endif /*try:*/ { - /* "ssh2/session.pyx":359 + /* "ssh2/session.pyx":337 * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: * channel = c_ssh2.libssh2_channel_open_session( # <<<<<<<<<<<<<< @@ -5019,7 +4756,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34open_session(struct __pyx_ob */ __pyx_v_channel = libssh2_channel_open_session(__pyx_v_self->_session); - /* "ssh2/session.pyx":361 + /* "ssh2/session.pyx":339 * channel = c_ssh2.libssh2_channel_open_session( * self._session) * if channel is NULL: # <<<<<<<<<<<<<< @@ -5029,7 +4766,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34open_session(struct __pyx_ob __pyx_t_1 = ((__pyx_v_channel == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/session.pyx":362 + /* "ssh2/session.pyx":340 * self._session) * if channel is NULL: * with gil: # <<<<<<<<<<<<<< @@ -5042,7 +4779,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34open_session(struct __pyx_ob #endif /*try:*/ { - /* "ssh2/session.pyx":363 + /* "ssh2/session.pyx":341 * if channel is NULL: * with gil: * return None # <<<<<<<<<<<<<< @@ -5055,7 +4792,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34open_session(struct __pyx_ob goto __pyx_L7_return; } - /* "ssh2/session.pyx":362 + /* "ssh2/session.pyx":340 * self._session) * if channel is NULL: * with gil: # <<<<<<<<<<<<<< @@ -5072,7 +4809,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34open_session(struct __pyx_ob } } - /* "ssh2/session.pyx":361 + /* "ssh2/session.pyx":339 * channel = c_ssh2.libssh2_channel_open_session( * self._session) * if channel is NULL: # <<<<<<<<<<<<<< @@ -5082,7 +4819,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34open_session(struct __pyx_ob } } - /* "ssh2/session.pyx":358 + /* "ssh2/session.pyx":336 * """ * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -5108,7 +4845,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34open_session(struct __pyx_ob } } - /* "ssh2/session.pyx":364 + /* "ssh2/session.pyx":342 * with gil: * return None * return PyChannel(channel, self) # <<<<<<<<<<<<<< @@ -5116,14 +4853,14 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34open_session(struct __pyx_ob * def direct_tcpip_ex(self, host not None, int port, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_f_4ssh2_7channel_PyChannel(__pyx_v_channel, __pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 364, __pyx_L1_error) + __pyx_t_2 = __pyx_f_4ssh2_7channel_PyChannel(__pyx_v_channel, __pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":352 - * prev = identity + /* "ssh2/session.pyx":330 + * agent_auth(_username, agent) * * def open_session(self): # <<<<<<<<<<<<<< * """Open new channel session. @@ -5141,7 +4878,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34open_session(struct __pyx_ob return __pyx_r; } -/* "ssh2/session.pyx":366 +/* "ssh2/session.pyx":344 * return PyChannel(channel, self) * * def direct_tcpip_ex(self, host not None, int port, # <<<<<<<<<<<<<< @@ -5187,23 +4924,23 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_37direct_tcpip_ex(PyObject *__ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_port)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("direct_tcpip_ex", 1, 4, 4, 1); __PYX_ERR(0, 366, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("direct_tcpip_ex", 1, 4, 4, 1); __PYX_ERR(0, 344, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shost)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("direct_tcpip_ex", 1, 4, 4, 2); __PYX_ERR(0, 366, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("direct_tcpip_ex", 1, 4, 4, 2); __PYX_ERR(0, 344, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sport)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("direct_tcpip_ex", 1, 4, 4, 3); __PYX_ERR(0, 366, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("direct_tcpip_ex", 1, 4, 4, 3); __PYX_ERR(0, 344, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "direct_tcpip_ex") < 0)) __PYX_ERR(0, 366, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "direct_tcpip_ex") < 0)) __PYX_ERR(0, 344, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -5214,23 +4951,23 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_37direct_tcpip_ex(PyObject *__ values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } __pyx_v_host = values[0]; - __pyx_v_port = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_port == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 366, __pyx_L3_error) + __pyx_v_port = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_port == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 344, __pyx_L3_error) __pyx_v_shost = values[2]; - __pyx_v_sport = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_sport == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 367, __pyx_L3_error) + __pyx_v_sport = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_sport == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 345, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("direct_tcpip_ex", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 366, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("direct_tcpip_ex", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 344, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.session.Session.direct_tcpip_ex", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_host) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "host"); __PYX_ERR(0, 366, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "host"); __PYX_ERR(0, 344, __pyx_L1_error) } if (unlikely(((PyObject *)__pyx_v_shost) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "shost"); __PYX_ERR(0, 367, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "shost"); __PYX_ERR(0, 345, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_36direct_tcpip_ex(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_host, __pyx_v_port, __pyx_v_shost, __pyx_v_sport); @@ -5256,51 +4993,59 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36direct_tcpip_ex(struct __pyx int __pyx_t_3; __Pyx_RefNannySetupContext("direct_tcpip_ex", 0); - /* "ssh2/session.pyx":369 + /* "ssh2/session.pyx":347 * shost not None, int sport): * cdef c_ssh2.LIBSSH2_CHANNEL *channel * cdef bytes b_host = to_bytes(host) # <<<<<<<<<<<<<< * cdef bytes b_shost = to_bytes(shost) * cdef char *_host = b_host */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_host); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 369, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_host); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_host = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":370 + /* "ssh2/session.pyx":348 * cdef c_ssh2.LIBSSH2_CHANNEL *channel * cdef bytes b_host = to_bytes(host) * cdef bytes b_shost = to_bytes(shost) # <<<<<<<<<<<<<< * cdef char *_host = b_host * cdef char *_shost = b_shost */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_shost); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 370, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_shost); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_shost = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":371 + /* "ssh2/session.pyx":349 * cdef bytes b_host = to_bytes(host) * cdef bytes b_shost = to_bytes(shost) * cdef char *_host = b_host # <<<<<<<<<<<<<< * cdef char *_shost = b_shost * with nogil: */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_host); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 371, __pyx_L1_error) + if (unlikely(__pyx_v_b_host == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 349, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_host); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 349, __pyx_L1_error) __pyx_v__host = __pyx_t_2; - /* "ssh2/session.pyx":372 + /* "ssh2/session.pyx":350 * cdef bytes b_shost = to_bytes(shost) * cdef char *_host = b_host * cdef char *_shost = b_shost # <<<<<<<<<<<<<< * with nogil: * channel = c_ssh2.libssh2_channel_direct_tcpip_ex( */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_shost); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 372, __pyx_L1_error) + if (unlikely(__pyx_v_b_shost == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 350, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_shost); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 350, __pyx_L1_error) __pyx_v__shost = __pyx_t_2; - /* "ssh2/session.pyx":373 + /* "ssh2/session.pyx":351 * cdef char *_host = b_host * cdef char *_shost = b_shost * with nogil: # <<<<<<<<<<<<<< @@ -5315,7 +5060,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36direct_tcpip_ex(struct __pyx #endif /*try:*/ { - /* "ssh2/session.pyx":374 + /* "ssh2/session.pyx":352 * cdef char *_shost = b_shost * with nogil: * channel = c_ssh2.libssh2_channel_direct_tcpip_ex( # <<<<<<<<<<<<<< @@ -5324,7 +5069,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36direct_tcpip_ex(struct __pyx */ __pyx_v_channel = libssh2_channel_direct_tcpip_ex(__pyx_v_self->_session, __pyx_v__host, __pyx_v_port, __pyx_v__shost, __pyx_v_sport); - /* "ssh2/session.pyx":376 + /* "ssh2/session.pyx":354 * channel = c_ssh2.libssh2_channel_direct_tcpip_ex( * self._session, _host, port, _shost, sport) * if channel is NULL: # <<<<<<<<<<<<<< @@ -5334,7 +5079,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36direct_tcpip_ex(struct __pyx __pyx_t_3 = ((__pyx_v_channel == NULL) != 0); if (__pyx_t_3) { - /* "ssh2/session.pyx":377 + /* "ssh2/session.pyx":355 * self._session, _host, port, _shost, sport) * if channel is NULL: * with gil: # <<<<<<<<<<<<<< @@ -5347,7 +5092,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36direct_tcpip_ex(struct __pyx #endif /*try:*/ { - /* "ssh2/session.pyx":378 + /* "ssh2/session.pyx":356 * if channel is NULL: * with gil: * return # <<<<<<<<<<<<<< @@ -5359,7 +5104,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36direct_tcpip_ex(struct __pyx goto __pyx_L7_return; } - /* "ssh2/session.pyx":377 + /* "ssh2/session.pyx":355 * self._session, _host, port, _shost, sport) * if channel is NULL: * with gil: # <<<<<<<<<<<<<< @@ -5376,7 +5121,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36direct_tcpip_ex(struct __pyx } } - /* "ssh2/session.pyx":376 + /* "ssh2/session.pyx":354 * channel = c_ssh2.libssh2_channel_direct_tcpip_ex( * self._session, _host, port, _shost, sport) * if channel is NULL: # <<<<<<<<<<<<<< @@ -5386,7 +5131,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36direct_tcpip_ex(struct __pyx } } - /* "ssh2/session.pyx":373 + /* "ssh2/session.pyx":351 * cdef char *_host = b_host * cdef char *_shost = b_shost * with nogil: # <<<<<<<<<<<<<< @@ -5412,7 +5157,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36direct_tcpip_ex(struct __pyx } } - /* "ssh2/session.pyx":379 + /* "ssh2/session.pyx":357 * with gil: * return * return PyChannel(channel, self) # <<<<<<<<<<<<<< @@ -5420,13 +5165,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36direct_tcpip_ex(struct __pyx * def direct_tcpip(self, host not None, int port): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_7channel_PyChannel(__pyx_v_channel, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 379, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_7channel_PyChannel(__pyx_v_channel, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 357, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":366 + /* "ssh2/session.pyx":344 * return PyChannel(channel, self) * * def direct_tcpip_ex(self, host not None, int port, # <<<<<<<<<<<<<< @@ -5447,7 +5192,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36direct_tcpip_ex(struct __pyx return __pyx_r; } -/* "ssh2/session.pyx":381 +/* "ssh2/session.pyx":359 * return PyChannel(channel, self) * * def direct_tcpip(self, host not None, int port): # <<<<<<<<<<<<<< @@ -5487,11 +5232,11 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_39direct_tcpip(PyObject *__pyx case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_port)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("direct_tcpip", 1, 2, 2, 1); __PYX_ERR(0, 381, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("direct_tcpip", 1, 2, 2, 1); __PYX_ERR(0, 359, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "direct_tcpip") < 0)) __PYX_ERR(0, 381, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "direct_tcpip") < 0)) __PYX_ERR(0, 359, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -5500,18 +5245,18 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_39direct_tcpip(PyObject *__pyx values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_host = values[0]; - __pyx_v_port = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_port == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 381, __pyx_L3_error) + __pyx_v_port = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_port == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 359, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("direct_tcpip", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 381, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("direct_tcpip", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 359, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.session.Session.direct_tcpip", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_host) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "host"); __PYX_ERR(0, 381, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "host"); __PYX_ERR(0, 359, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_38direct_tcpip(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_host, __pyx_v_port); @@ -5535,29 +5280,33 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip(struct __pyx_ob int __pyx_t_3; __Pyx_RefNannySetupContext("direct_tcpip", 0); - /* "ssh2/session.pyx":383 + /* "ssh2/session.pyx":361 * def direct_tcpip(self, host not None, int port): * cdef c_ssh2.LIBSSH2_CHANNEL *channel * cdef bytes b_host = to_bytes(host) # <<<<<<<<<<<<<< * cdef char *_host = b_host * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_host); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_host); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_host = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":384 + /* "ssh2/session.pyx":362 * cdef c_ssh2.LIBSSH2_CHANNEL *channel * cdef bytes b_host = to_bytes(host) * cdef char *_host = b_host # <<<<<<<<<<<<<< * with nogil: * channel = c_ssh2.libssh2_channel_direct_tcpip( */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_host); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 384, __pyx_L1_error) + if (unlikely(__pyx_v_b_host == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 362, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_host); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 362, __pyx_L1_error) __pyx_v__host = __pyx_t_2; - /* "ssh2/session.pyx":385 + /* "ssh2/session.pyx":363 * cdef bytes b_host = to_bytes(host) * cdef char *_host = b_host * with nogil: # <<<<<<<<<<<<<< @@ -5572,7 +5321,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip(struct __pyx_ob #endif /*try:*/ { - /* "ssh2/session.pyx":386 + /* "ssh2/session.pyx":364 * cdef char *_host = b_host * with nogil: * channel = c_ssh2.libssh2_channel_direct_tcpip( # <<<<<<<<<<<<<< @@ -5581,7 +5330,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip(struct __pyx_ob */ __pyx_v_channel = libssh2_channel_direct_tcpip(__pyx_v_self->_session, __pyx_v__host, __pyx_v_port); - /* "ssh2/session.pyx":388 + /* "ssh2/session.pyx":366 * channel = c_ssh2.libssh2_channel_direct_tcpip( * self._session, _host, port) * if channel is NULL: # <<<<<<<<<<<<<< @@ -5591,7 +5340,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip(struct __pyx_ob __pyx_t_3 = ((__pyx_v_channel == NULL) != 0); if (__pyx_t_3) { - /* "ssh2/session.pyx":389 + /* "ssh2/session.pyx":367 * self._session, _host, port) * if channel is NULL: * with gil: # <<<<<<<<<<<<<< @@ -5604,7 +5353,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip(struct __pyx_ob #endif /*try:*/ { - /* "ssh2/session.pyx":390 + /* "ssh2/session.pyx":368 * if channel is NULL: * with gil: * return # <<<<<<<<<<<<<< @@ -5616,7 +5365,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip(struct __pyx_ob goto __pyx_L7_return; } - /* "ssh2/session.pyx":389 + /* "ssh2/session.pyx":367 * self._session, _host, port) * if channel is NULL: * with gil: # <<<<<<<<<<<<<< @@ -5633,7 +5382,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip(struct __pyx_ob } } - /* "ssh2/session.pyx":388 + /* "ssh2/session.pyx":366 * channel = c_ssh2.libssh2_channel_direct_tcpip( * self._session, _host, port) * if channel is NULL: # <<<<<<<<<<<<<< @@ -5643,7 +5392,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip(struct __pyx_ob } } - /* "ssh2/session.pyx":385 + /* "ssh2/session.pyx":363 * cdef bytes b_host = to_bytes(host) * cdef char *_host = b_host * with nogil: # <<<<<<<<<<<<<< @@ -5669,7 +5418,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip(struct __pyx_ob } } - /* "ssh2/session.pyx":391 + /* "ssh2/session.pyx":369 * with gil: * return * return PyChannel(channel, self) # <<<<<<<<<<<<<< @@ -5677,13 +5426,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip(struct __pyx_ob * def block_directions(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_7channel_PyChannel(__pyx_v_channel, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 391, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_7channel_PyChannel(__pyx_v_channel, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":381 + /* "ssh2/session.pyx":359 * return PyChannel(channel, self) * * def direct_tcpip(self, host not None, int port): # <<<<<<<<<<<<<< @@ -5703,7 +5452,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip(struct __pyx_ob return __pyx_r; } -/* "ssh2/session.pyx":393 +/* "ssh2/session.pyx":371 * return PyChannel(channel, self) * * def block_directions(self): # <<<<<<<<<<<<<< @@ -5732,7 +5481,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40block_directions(struct __py PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("block_directions", 0); - /* "ssh2/session.pyx":415 + /* "ssh2/session.pyx":393 * :rtype: int""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -5747,7 +5496,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40block_directions(struct __py #endif /*try:*/ { - /* "ssh2/session.pyx":416 + /* "ssh2/session.pyx":394 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_session_block_directions( # <<<<<<<<<<<<<< @@ -5757,7 +5506,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40block_directions(struct __py __pyx_v_rc = libssh2_session_block_directions(__pyx_v_self->_session); } - /* "ssh2/session.pyx":415 + /* "ssh2/session.pyx":393 * :rtype: int""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -5776,7 +5525,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40block_directions(struct __py } } - /* "ssh2/session.pyx":418 + /* "ssh2/session.pyx":396 * rc = c_ssh2.libssh2_session_block_directions( * self._session) * return rc # <<<<<<<<<<<<<< @@ -5784,13 +5533,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40block_directions(struct __py * def forward_listen(self, int port): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 418, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":393 + /* "ssh2/session.pyx":371 * return PyChannel(channel, self) * * def block_directions(self): # <<<<<<<<<<<<<< @@ -5809,7 +5558,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40block_directions(struct __py return __pyx_r; } -/* "ssh2/session.pyx":420 +/* "ssh2/session.pyx":398 * return rc * * def forward_listen(self, int port): # <<<<<<<<<<<<<< @@ -5826,7 +5575,7 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_43forward_listen(PyObject *__p __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("forward_listen (wrapper)", 0); assert(__pyx_arg_port); { - __pyx_v_port = __Pyx_PyInt_As_int(__pyx_arg_port); if (unlikely((__pyx_v_port == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 420, __pyx_L3_error) + __pyx_v_port = __Pyx_PyInt_As_int(__pyx_arg_port); if (unlikely((__pyx_v_port == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 398, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -5849,7 +5598,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42forward_listen(struct __pyx_ PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("forward_listen", 0); - /* "ssh2/session.pyx":428 + /* "ssh2/session.pyx":406 * :rtype: :py:class:`ssh2.listener.Listener` or None""" * cdef c_ssh2.LIBSSH2_LISTENER *listener * with nogil: # <<<<<<<<<<<<<< @@ -5864,7 +5613,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42forward_listen(struct __pyx_ #endif /*try:*/ { - /* "ssh2/session.pyx":429 + /* "ssh2/session.pyx":407 * cdef c_ssh2.LIBSSH2_LISTENER *listener * with nogil: * listener = c_ssh2.libssh2_channel_forward_listen( # <<<<<<<<<<<<<< @@ -5874,7 +5623,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42forward_listen(struct __pyx_ __pyx_v_listener = libssh2_channel_forward_listen(__pyx_v_self->_session, __pyx_v_port); } - /* "ssh2/session.pyx":428 + /* "ssh2/session.pyx":406 * :rtype: :py:class:`ssh2.listener.Listener` or None""" * cdef c_ssh2.LIBSSH2_LISTENER *listener * with nogil: # <<<<<<<<<<<<<< @@ -5893,7 +5642,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42forward_listen(struct __pyx_ } } - /* "ssh2/session.pyx":431 + /* "ssh2/session.pyx":409 * listener = c_ssh2.libssh2_channel_forward_listen( * self._session, port) * if listener is NULL: # <<<<<<<<<<<<<< @@ -5903,7 +5652,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42forward_listen(struct __pyx_ __pyx_t_1 = ((__pyx_v_listener == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/session.pyx":432 + /* "ssh2/session.pyx":410 * self._session, port) * if listener is NULL: * return # <<<<<<<<<<<<<< @@ -5914,7 +5663,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42forward_listen(struct __pyx_ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - /* "ssh2/session.pyx":431 + /* "ssh2/session.pyx":409 * listener = c_ssh2.libssh2_channel_forward_listen( * self._session, port) * if listener is NULL: # <<<<<<<<<<<<<< @@ -5923,7 +5672,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42forward_listen(struct __pyx_ */ } - /* "ssh2/session.pyx":433 + /* "ssh2/session.pyx":411 * if listener is NULL: * return * return PyListener(listener, self) # <<<<<<<<<<<<<< @@ -5931,13 +5680,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42forward_listen(struct __pyx_ * def forward_listen_ex(self, host not None, int port, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_f_4ssh2_8listener_PyListener(__pyx_v_listener, __pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 433, __pyx_L1_error) + __pyx_t_2 = __pyx_f_4ssh2_8listener_PyListener(__pyx_v_listener, __pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":420 + /* "ssh2/session.pyx":398 * return rc * * def forward_listen(self, int port): # <<<<<<<<<<<<<< @@ -5956,7 +5705,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42forward_listen(struct __pyx_ return __pyx_r; } -/* "ssh2/session.pyx":435 +/* "ssh2/session.pyx":413 * return PyListener(listener, self) * * def forward_listen_ex(self, host not None, int port, # <<<<<<<<<<<<<< @@ -6002,23 +5751,23 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_45forward_listen_ex(PyObject * case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_port)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("forward_listen_ex", 1, 4, 4, 1); __PYX_ERR(0, 435, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("forward_listen_ex", 1, 4, 4, 1); __PYX_ERR(0, 413, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_bound_port)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("forward_listen_ex", 1, 4, 4, 2); __PYX_ERR(0, 435, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("forward_listen_ex", 1, 4, 4, 2); __PYX_ERR(0, 413, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_queue_maxsize)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("forward_listen_ex", 1, 4, 4, 3); __PYX_ERR(0, 435, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("forward_listen_ex", 1, 4, 4, 3); __PYX_ERR(0, 413, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "forward_listen_ex") < 0)) __PYX_ERR(0, 435, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "forward_listen_ex") < 0)) __PYX_ERR(0, 413, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -6029,20 +5778,20 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_45forward_listen_ex(PyObject * values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } __pyx_v_host = values[0]; - __pyx_v_port = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_port == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 435, __pyx_L3_error) - __pyx_v_bound_port = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_bound_port == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 436, __pyx_L3_error) - __pyx_v_queue_maxsize = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_queue_maxsize == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 436, __pyx_L3_error) + __pyx_v_port = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_port == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 413, __pyx_L3_error) + __pyx_v_bound_port = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_bound_port == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 414, __pyx_L3_error) + __pyx_v_queue_maxsize = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_queue_maxsize == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 414, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("forward_listen_ex", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 435, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("forward_listen_ex", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 413, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.session.Session.forward_listen_ex", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_host) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "host"); __PYX_ERR(0, 435, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "host"); __PYX_ERR(0, 413, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_44forward_listen_ex(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_host, __pyx_v_port, __pyx_v_bound_port, __pyx_v_queue_maxsize); @@ -6066,29 +5815,33 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen_ex(struct __p int __pyx_t_3; __Pyx_RefNannySetupContext("forward_listen_ex", 0); - /* "ssh2/session.pyx":438 + /* "ssh2/session.pyx":416 * int bound_port, int queue_maxsize): * cdef c_ssh2.LIBSSH2_LISTENER *listener * cdef bytes b_host = to_bytes(host) # <<<<<<<<<<<<<< * cdef char *_host = b_host * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_host); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_host); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_host = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":439 + /* "ssh2/session.pyx":417 * cdef c_ssh2.LIBSSH2_LISTENER *listener * cdef bytes b_host = to_bytes(host) * cdef char *_host = b_host # <<<<<<<<<<<<<< * with nogil: * listener = c_ssh2.libssh2_channel_forward_listen_ex( */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_host); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 439, __pyx_L1_error) + if (unlikely(__pyx_v_b_host == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 417, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_host); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 417, __pyx_L1_error) __pyx_v__host = __pyx_t_2; - /* "ssh2/session.pyx":440 + /* "ssh2/session.pyx":418 * cdef bytes b_host = to_bytes(host) * cdef char *_host = b_host * with nogil: # <<<<<<<<<<<<<< @@ -6103,7 +5856,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen_ex(struct __p #endif /*try:*/ { - /* "ssh2/session.pyx":441 + /* "ssh2/session.pyx":419 * cdef char *_host = b_host * with nogil: * listener = c_ssh2.libssh2_channel_forward_listen_ex( # <<<<<<<<<<<<<< @@ -6113,7 +5866,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen_ex(struct __p __pyx_v_listener = libssh2_channel_forward_listen_ex(__pyx_v_self->_session, __pyx_v__host, __pyx_v_port, (&__pyx_v_bound_port), __pyx_v_queue_maxsize); } - /* "ssh2/session.pyx":440 + /* "ssh2/session.pyx":418 * cdef bytes b_host = to_bytes(host) * cdef char *_host = b_host * with nogil: # <<<<<<<<<<<<<< @@ -6132,7 +5885,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen_ex(struct __p } } - /* "ssh2/session.pyx":443 + /* "ssh2/session.pyx":421 * listener = c_ssh2.libssh2_channel_forward_listen_ex( * self._session, _host, port, &bound_port, queue_maxsize) * if listener is NULL: # <<<<<<<<<<<<<< @@ -6142,7 +5895,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen_ex(struct __p __pyx_t_3 = ((__pyx_v_listener == NULL) != 0); if (__pyx_t_3) { - /* "ssh2/session.pyx":444 + /* "ssh2/session.pyx":422 * self._session, _host, port, &bound_port, queue_maxsize) * if listener is NULL: * return # <<<<<<<<<<<<<< @@ -6153,7 +5906,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen_ex(struct __p __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - /* "ssh2/session.pyx":443 + /* "ssh2/session.pyx":421 * listener = c_ssh2.libssh2_channel_forward_listen_ex( * self._session, _host, port, &bound_port, queue_maxsize) * if listener is NULL: # <<<<<<<<<<<<<< @@ -6162,7 +5915,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen_ex(struct __p */ } - /* "ssh2/session.pyx":445 + /* "ssh2/session.pyx":423 * if listener is NULL: * return * return PyListener(listener, self) # <<<<<<<<<<<<<< @@ -6170,13 +5923,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen_ex(struct __p * def sftp_init(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_8listener_PyListener(__pyx_v_listener, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 445, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_8listener_PyListener(__pyx_v_listener, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":435 + /* "ssh2/session.pyx":413 * return PyListener(listener, self) * * def forward_listen_ex(self, host not None, int port, # <<<<<<<<<<<<<< @@ -6196,7 +5949,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen_ex(struct __p return __pyx_r; } -/* "ssh2/session.pyx":447 +/* "ssh2/session.pyx":425 * return PyListener(listener, self) * * def sftp_init(self): # <<<<<<<<<<<<<< @@ -6226,7 +5979,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46sftp_init(struct __pyx_obj_4 PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("sftp_init", 0); - /* "ssh2/session.pyx":453 + /* "ssh2/session.pyx":431 * """ * cdef c_sftp.LIBSSH2_SFTP *_sftp * with nogil: # <<<<<<<<<<<<<< @@ -6241,7 +5994,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46sftp_init(struct __pyx_obj_4 #endif /*try:*/ { - /* "ssh2/session.pyx":454 + /* "ssh2/session.pyx":432 * cdef c_sftp.LIBSSH2_SFTP *_sftp * with nogil: * _sftp = c_sftp.libssh2_sftp_init(self._session) # <<<<<<<<<<<<<< @@ -6251,7 +6004,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46sftp_init(struct __pyx_obj_4 __pyx_v__sftp = libssh2_sftp_init(__pyx_v_self->_session); } - /* "ssh2/session.pyx":453 + /* "ssh2/session.pyx":431 * """ * cdef c_sftp.LIBSSH2_SFTP *_sftp * with nogil: # <<<<<<<<<<<<<< @@ -6270,7 +6023,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46sftp_init(struct __pyx_obj_4 } } - /* "ssh2/session.pyx":455 + /* "ssh2/session.pyx":433 * with nogil: * _sftp = c_sftp.libssh2_sftp_init(self._session) * if _sftp is NULL: # <<<<<<<<<<<<<< @@ -6280,7 +6033,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46sftp_init(struct __pyx_obj_4 __pyx_t_1 = ((__pyx_v__sftp == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/session.pyx":456 + /* "ssh2/session.pyx":434 * _sftp = c_sftp.libssh2_sftp_init(self._session) * if _sftp is NULL: * return # <<<<<<<<<<<<<< @@ -6291,7 +6044,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46sftp_init(struct __pyx_obj_4 __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - /* "ssh2/session.pyx":455 + /* "ssh2/session.pyx":433 * with nogil: * _sftp = c_sftp.libssh2_sftp_init(self._session) * if _sftp is NULL: # <<<<<<<<<<<<<< @@ -6300,7 +6053,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46sftp_init(struct __pyx_obj_4 */ } - /* "ssh2/session.pyx":457 + /* "ssh2/session.pyx":435 * if _sftp is NULL: * return * return PySFTP(_sftp, self) # <<<<<<<<<<<<<< @@ -6308,13 +6061,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46sftp_init(struct __pyx_obj_4 * def last_error(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_f_4ssh2_4sftp_PySFTP(__pyx_v__sftp, __pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error) + __pyx_t_2 = __pyx_f_4ssh2_4sftp_PySFTP(__pyx_v__sftp, __pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":447 + /* "ssh2/session.pyx":425 * return PyListener(listener, self) * * def sftp_init(self): # <<<<<<<<<<<<<< @@ -6333,7 +6086,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46sftp_init(struct __pyx_obj_4 return __pyx_r; } -/* "ssh2/session.pyx":459 +/* "ssh2/session.pyx":437 * return PySFTP(_sftp, self) * * def last_error(self): # <<<<<<<<<<<<<< @@ -6372,25 +6125,35 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_48last_error(struct __pyx_obj_ PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("last_error", 0); - /* "ssh2/session.pyx":465 + /* "ssh2/session.pyx":443 * :rtype: str * """ * cdef char **_error_msg = NULL # <<<<<<<<<<<<<< - * cdef bytes msg + * cdef bytes msg = b'' * cdef int errmsg_len = 0 */ __pyx_v__error_msg = NULL; - /* "ssh2/session.pyx":467 + /* "ssh2/session.pyx":444 + * """ + * cdef char **_error_msg = NULL + * cdef bytes msg = b'' # <<<<<<<<<<<<<< + * cdef int errmsg_len = 0 + * cdef int rc + */ + __Pyx_INCREF(__pyx_kp_b__3); + __pyx_v_msg = __pyx_kp_b__3; + + /* "ssh2/session.pyx":445 * cdef char **_error_msg = NULL - * cdef bytes msg + * cdef bytes msg = b'' * cdef int errmsg_len = 0 # <<<<<<<<<<<<<< * cdef int rc * with nogil: */ __pyx_v_errmsg_len = 0; - /* "ssh2/session.pyx":469 + /* "ssh2/session.pyx":447 * cdef int errmsg_len = 0 * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6405,7 +6168,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_48last_error(struct __pyx_obj_ #endif /*try:*/ { - /* "ssh2/session.pyx":470 + /* "ssh2/session.pyx":448 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_session_last_error( # <<<<<<<<<<<<<< @@ -6415,7 +6178,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_48last_error(struct __pyx_obj_ __pyx_v_rc = libssh2_session_last_error(__pyx_v_self->_session, __pyx_v__error_msg, (&__pyx_v_errmsg_len), 0); } - /* "ssh2/session.pyx":469 + /* "ssh2/session.pyx":447 * cdef int errmsg_len = 0 * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6434,7 +6197,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_48last_error(struct __pyx_obj_ } } - /* "ssh2/session.pyx":472 + /* "ssh2/session.pyx":450 * rc = c_ssh2.libssh2_session_last_error( * self._session, _error_msg, &errmsg_len, 0) * if errmsg_len > 0 and _error_msg is not NULL: # <<<<<<<<<<<<<< @@ -6452,72 +6215,56 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_48last_error(struct __pyx_obj_ __pyx_L7_bool_binop_done:; if (__pyx_t_1) { - /* "ssh2/session.pyx":473 + /* "ssh2/session.pyx":451 * self._session, _error_msg, &errmsg_len, 0) * if errmsg_len > 0 and _error_msg is not NULL: * for line in _error_msg[:errmsg_len]: # <<<<<<<<<<<<<< * msg += line - * else: + * return msg */ __pyx_t_4 = (__pyx_v__error_msg + __pyx_v_errmsg_len); for (__pyx_t_5 = __pyx_v__error_msg; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) { __pyx_t_3 = __pyx_t_5; __pyx_v_line = (__pyx_t_3[0]); - /* "ssh2/session.pyx":474 + /* "ssh2/session.pyx":452 * if errmsg_len > 0 and _error_msg is not NULL: * for line in _error_msg[:errmsg_len]: * msg += line # <<<<<<<<<<<<<< - * else: - * msg = b'' + * return msg + * */ - if (unlikely(!__pyx_v_msg)) { __Pyx_RaiseUnboundLocalError("msg"); __PYX_ERR(0, 474, __pyx_L1_error) } - __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_line); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 474, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_line); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 452, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 474, __pyx_L1_error) + __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 452, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_XDECREF_SET(__pyx_v_msg, ((PyObject*)__pyx_t_7)); + __Pyx_DECREF_SET(__pyx_v_msg, ((PyObject*)__pyx_t_7)); __pyx_t_7 = 0; } - /* "ssh2/session.pyx":472 + /* "ssh2/session.pyx":450 * rc = c_ssh2.libssh2_session_last_error( * self._session, _error_msg, &errmsg_len, 0) * if errmsg_len > 0 and _error_msg is not NULL: # <<<<<<<<<<<<<< * for line in _error_msg[:errmsg_len]: * msg += line */ - goto __pyx_L6; } - /* "ssh2/session.pyx":476 + /* "ssh2/session.pyx":453 + * for line in _error_msg[:errmsg_len]: * msg += line - * else: - * msg = b'' # <<<<<<<<<<<<<< - * return msg - * - */ - /*else*/ { - __Pyx_INCREF(__pyx_kp_b__6); - __pyx_v_msg = __pyx_kp_b__6; - } - __pyx_L6:; - - /* "ssh2/session.pyx":477 - * else: - * msg = b'' * return msg # <<<<<<<<<<<<<< * - * def scp_recv(self, path not None): + * def last_errno(self): */ __Pyx_XDECREF(__pyx_r); - if (unlikely(!__pyx_v_msg)) { __Pyx_RaiseUnboundLocalError("msg"); __PYX_ERR(0, 477, __pyx_L1_error) } __Pyx_INCREF(__pyx_v_msg); __pyx_r = __pyx_v_msg; goto __pyx_L0; - /* "ssh2/session.pyx":459 + /* "ssh2/session.pyx":437 * return PySFTP(_sftp, self) * * def last_error(self): # <<<<<<<<<<<<<< @@ -6538,25 +6285,131 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_48last_error(struct __pyx_obj_ return __pyx_r; } -/* "ssh2/session.pyx":479 +/* "ssh2/session.pyx":455 + * return msg + * + * def last_errno(self): # <<<<<<<<<<<<<< + * """Retrieve last error message from libssh2, if any. + * Returns empty string on no error message. + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_4ssh2_7session_7Session_51last_errno(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_4ssh2_7session_7Session_50last_errno[] = "Session.last_errno(self)\nRetrieve last error message from libssh2, if any.\n Returns empty string on no error message.\n\n :rtype: str\n "; +static PyObject *__pyx_pw_4ssh2_7session_7Session_51last_errno(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("last_errno (wrapper)", 0); + __pyx_r = __pyx_pf_4ssh2_7session_7Session_50last_errno(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_4ssh2_7session_7Session_50last_errno(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self) { + int __pyx_v_rc; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("last_errno", 0); + + /* "ssh2/session.pyx":462 + * """ + * cdef int rc + * with nogil: # <<<<<<<<<<<<<< + * rc = c_ssh2.libssh2_session_last_errno( + * self._session) + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); + #endif + /*try:*/ { + + /* "ssh2/session.pyx":463 + * cdef int rc + * with nogil: + * rc = c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< + * self._session) + * return rc + */ + __pyx_v_rc = libssh2_session_last_errno(__pyx_v_self->_session); + } + + /* "ssh2/session.pyx":462 + * """ + * cdef int rc + * with nogil: # <<<<<<<<<<<<<< + * rc = c_ssh2.libssh2_session_last_errno( + * self._session) + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "ssh2/session.pyx":465 + * rc = c_ssh2.libssh2_session_last_errno( + * self._session) + * return rc # <<<<<<<<<<<<<< + * + * IF EMBEDDED_LIB: + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 465, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "ssh2/session.pyx":455 * return msg * + * def last_errno(self): # <<<<<<<<<<<<<< + * """Retrieve last error message from libssh2, if any. + * Returns empty string on no error message. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("ssh2.session.Session.last_errno", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "ssh2/session.pyx":477 + * return rc + * * def scp_recv(self, path not None): # <<<<<<<<<<<<<< * """Receive file via SCP. * */ /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_7session_7Session_51scp_recv(PyObject *__pyx_v_self, PyObject *__pyx_v_path); /*proto*/ -static char __pyx_doc_4ssh2_7session_7Session_50scp_recv[] = "Session.scp_recv(self, path)\nReceive file via SCP.\n\n Deprecated in favour or recv2 (requires libssh2 >= 1.7).\n\n :param path: File path to receive.\n :type path: str\n\n :rtype: tuple(:py:class:`ssh2.channel.Channel`,\n :py:class:`ssh2.statinfo.StatInfo`) or None"; -static PyObject *__pyx_pw_4ssh2_7session_7Session_51scp_recv(PyObject *__pyx_v_self, PyObject *__pyx_v_path) { +static PyObject *__pyx_pw_4ssh2_7session_7Session_53scp_recv(PyObject *__pyx_v_self, PyObject *__pyx_v_path); /*proto*/ +static char __pyx_doc_4ssh2_7session_7Session_52scp_recv[] = "Session.scp_recv(self, path)\nReceive file via SCP.\n\n Deprecated in favour or recv2 (requires libssh2 >= 1.7).\n\n :param path: File path to receive.\n :type path: str\n\n :rtype: tuple(:py:class:`ssh2.channel.Channel`,\n :py:class:`ssh2.statinfo.StatInfo`) or None"; +static PyObject *__pyx_pw_4ssh2_7session_7Session_53scp_recv(PyObject *__pyx_v_self, PyObject *__pyx_v_path) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("scp_recv (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 479, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 477, __pyx_L1_error) } - __pyx_r = __pyx_pf_4ssh2_7session_7Session_50scp_recv(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), ((PyObject *)__pyx_v_path)); + __pyx_r = __pyx_pf_4ssh2_7session_7Session_52scp_recv(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), ((PyObject *)__pyx_v_path)); /* function exit code */ goto __pyx_L0; @@ -6567,7 +6420,7 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_51scp_recv(PyObject *__pyx_v_s return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_7session_7Session_50scp_recv(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, PyObject *__pyx_v_path) { +static PyObject *__pyx_pf_4ssh2_7session_7Session_52scp_recv(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, PyObject *__pyx_v_path) { PyObject *__pyx_v_b_path = 0; char *__pyx_v__path; struct __pyx_obj_4ssh2_8statinfo_StatInfo *__pyx_v_statinfo = 0; @@ -6580,41 +6433,45 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50scp_recv(struct __pyx_obj_4s PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("scp_recv", 0); - /* "ssh2/session.pyx":489 + /* "ssh2/session.pyx":487 * :rtype: tuple(:py:class:`ssh2.channel.Channel`, * :py:class:`ssh2.statinfo.StatInfo`) or None""" * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * cdef StatInfo statinfo = StatInfo() */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 489, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":490 + /* "ssh2/session.pyx":488 * :py:class:`ssh2.statinfo.StatInfo`) or None""" * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< * cdef StatInfo statinfo = StatInfo() * cdef c_ssh2.LIBSSH2_CHANNEL *channel */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 490, __pyx_L1_error) + if (unlikely(__pyx_v_b_path == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 488, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 488, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/session.pyx":491 + /* "ssh2/session.pyx":489 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * cdef StatInfo statinfo = StatInfo() # <<<<<<<<<<<<<< * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_8statinfo_StatInfo), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 491, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_8statinfo_StatInfo), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_statinfo = ((struct __pyx_obj_4ssh2_8statinfo_StatInfo *)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":493 + /* "ssh2/session.pyx":491 * cdef StatInfo statinfo = StatInfo() * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -6629,7 +6486,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50scp_recv(struct __pyx_obj_4s #endif /*try:*/ { - /* "ssh2/session.pyx":494 + /* "ssh2/session.pyx":492 * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: * channel = c_ssh2.libssh2_scp_recv( # <<<<<<<<<<<<<< @@ -6639,7 +6496,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50scp_recv(struct __pyx_obj_4s __pyx_v_channel = libssh2_scp_recv(__pyx_v_self->_session, __pyx_v__path, __pyx_v_statinfo->_stat); } - /* "ssh2/session.pyx":493 + /* "ssh2/session.pyx":491 * cdef StatInfo statinfo = StatInfo() * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -6658,7 +6515,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50scp_recv(struct __pyx_obj_4s } } - /* "ssh2/session.pyx":496 + /* "ssh2/session.pyx":494 * channel = c_ssh2.libssh2_scp_recv( * self._session, _path, statinfo._stat) * if channel is not NULL: # <<<<<<<<<<<<<< @@ -6668,7 +6525,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50scp_recv(struct __pyx_obj_4s __pyx_t_3 = ((__pyx_v_channel != NULL) != 0); if (__pyx_t_3) { - /* "ssh2/session.pyx":497 + /* "ssh2/session.pyx":495 * self._session, _path, statinfo._stat) * if channel is not NULL: * return PyChannel(channel, self), statinfo # <<<<<<<<<<<<<< @@ -6676,9 +6533,9 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50scp_recv(struct __pyx_obj_4s * IF EMBEDDED_LIB: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_7channel_PyChannel(__pyx_v_channel, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 497, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_7channel_PyChannel(__pyx_v_channel, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 497, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 495, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); @@ -6690,7 +6547,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50scp_recv(struct __pyx_obj_4s __pyx_t_4 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":496 + /* "ssh2/session.pyx":494 * channel = c_ssh2.libssh2_scp_recv( * self._session, _path, statinfo._stat) * if channel is not NULL: # <<<<<<<<<<<<<< @@ -6699,8 +6556,8 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50scp_recv(struct __pyx_obj_4s */ } - /* "ssh2/session.pyx":479 - * return msg + /* "ssh2/session.pyx":477 + * return rc * * def scp_recv(self, path not None): # <<<<<<<<<<<<<< * """Receive file via SCP. @@ -6723,7 +6580,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50scp_recv(struct __pyx_obj_4s return __pyx_r; } -/* "ssh2/session.pyx":520 +/* "ssh2/session.pyx":518 * return PyChannel(channel, self), fileinfo * * def scp_send(self, path not None, int mode, size_t size): # <<<<<<<<<<<<<< @@ -6732,9 +6589,9 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50scp_recv(struct __pyx_obj_4s */ /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_7session_7Session_53scp_send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_4ssh2_7session_7Session_52scp_send[] = "Session.scp_send(self, path, int mode, size_t size)\nDeprecated in favour of scp_send64. Send file via SCP.\n\n :param path: Local file path to send.\n :type path: str\n :param mode: File mode.\n :type mode: int\n :param size: size of file\n :type size: int\n\n :rtype: :py:class:`ssh2.channel.Channel`"; -static PyObject *__pyx_pw_4ssh2_7session_7Session_53scp_send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_4ssh2_7session_7Session_55scp_send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_4ssh2_7session_7Session_54scp_send[] = "Session.scp_send(self, path, int mode, size_t size)\nDeprecated in favour of scp_send64. Send file via SCP.\n\n :param path: Local file path to send.\n :type path: str\n :param mode: File mode.\n :type mode: int\n :param size: size of file\n :type size: int\n\n :rtype: :py:class:`ssh2.channel.Channel`"; +static PyObject *__pyx_pw_4ssh2_7session_7Session_55scp_send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_path = 0; int __pyx_v_mode; size_t __pyx_v_size; @@ -6766,17 +6623,17 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_53scp_send(PyObject *__pyx_v_s case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mode)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("scp_send", 1, 3, 3, 1); __PYX_ERR(0, 520, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send", 1, 3, 3, 1); __PYX_ERR(0, 518, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_size)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("scp_send", 1, 3, 3, 2); __PYX_ERR(0, 520, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send", 1, 3, 3, 2); __PYX_ERR(0, 518, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scp_send") < 0)) __PYX_ERR(0, 520, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scp_send") < 0)) __PYX_ERR(0, 518, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; @@ -6786,21 +6643,21 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_53scp_send(PyObject *__pyx_v_s values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_path = values[0]; - __pyx_v_mode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 520, __pyx_L3_error) - __pyx_v_size = __Pyx_PyInt_As_size_t(values[2]); if (unlikely((__pyx_v_size == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 520, __pyx_L3_error) + __pyx_v_mode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 518, __pyx_L3_error) + __pyx_v_size = __Pyx_PyInt_As_size_t(values[2]); if (unlikely((__pyx_v_size == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 518, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("scp_send", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 520, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 518, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.session.Session.scp_send", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 520, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 518, __pyx_L1_error) } - __pyx_r = __pyx_pf_4ssh2_7session_7Session_52scp_send(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_path, __pyx_v_mode, __pyx_v_size); + __pyx_r = __pyx_pf_4ssh2_7session_7Session_54scp_send(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_path, __pyx_v_mode, __pyx_v_size); /* function exit code */ goto __pyx_L0; @@ -6811,7 +6668,7 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_53scp_send(PyObject *__pyx_v_s return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_7session_7Session_52scp_send(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, PyObject *__pyx_v_path, int __pyx_v_mode, size_t __pyx_v_size) { +static PyObject *__pyx_pf_4ssh2_7session_7Session_54scp_send(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, PyObject *__pyx_v_path, int __pyx_v_mode, size_t __pyx_v_size) { PyObject *__pyx_v_b_path = 0; char *__pyx_v__path; LIBSSH2_CHANNEL *__pyx_v_channel; @@ -6822,29 +6679,33 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_52scp_send(struct __pyx_obj_4s int __pyx_t_3; __Pyx_RefNannySetupContext("scp_send", 0); - /* "ssh2/session.pyx":531 + /* "ssh2/session.pyx":529 * * :rtype: :py:class:`ssh2.channel.Channel`""" * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * cdef c_ssh2.LIBSSH2_CHANNEL *channel */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 531, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 529, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":532 + /* "ssh2/session.pyx":530 * :rtype: :py:class:`ssh2.channel.Channel`""" * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 532, __pyx_L1_error) + if (unlikely(__pyx_v_b_path == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 530, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 530, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/session.pyx":534 + /* "ssh2/session.pyx":532 * cdef char *_path = b_path * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -6859,7 +6720,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_52scp_send(struct __pyx_obj_4s #endif /*try:*/ { - /* "ssh2/session.pyx":535 + /* "ssh2/session.pyx":533 * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: * channel = c_ssh2.libssh2_scp_send( # <<<<<<<<<<<<<< @@ -6869,7 +6730,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_52scp_send(struct __pyx_obj_4s __pyx_v_channel = libssh2_scp_send(__pyx_v_self->_session, __pyx_v__path, __pyx_v_mode, __pyx_v_size); } - /* "ssh2/session.pyx":534 + /* "ssh2/session.pyx":532 * cdef char *_path = b_path * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -6888,7 +6749,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_52scp_send(struct __pyx_obj_4s } } - /* "ssh2/session.pyx":537 + /* "ssh2/session.pyx":535 * channel = c_ssh2.libssh2_scp_send( * self._session, _path, mode, size) * if channel is not NULL: # <<<<<<<<<<<<<< @@ -6898,7 +6759,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_52scp_send(struct __pyx_obj_4s __pyx_t_3 = ((__pyx_v_channel != NULL) != 0); if (__pyx_t_3) { - /* "ssh2/session.pyx":538 + /* "ssh2/session.pyx":536 * self._session, _path, mode, size) * if channel is not NULL: * return PyChannel(channel, self) # <<<<<<<<<<<<<< @@ -6906,13 +6767,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_52scp_send(struct __pyx_obj_4s * def scp_send64(self, path not None, int mode, c_ssh2.libssh2_uint64_t size, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_7channel_PyChannel(__pyx_v_channel, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 538, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_7channel_PyChannel(__pyx_v_channel, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 536, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":537 + /* "ssh2/session.pyx":535 * channel = c_ssh2.libssh2_scp_send( * self._session, _path, mode, size) * if channel is not NULL: # <<<<<<<<<<<<<< @@ -6921,7 +6782,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_52scp_send(struct __pyx_obj_4s */ } - /* "ssh2/session.pyx":520 + /* "ssh2/session.pyx":518 * return PyChannel(channel, self), fileinfo * * def scp_send(self, path not None, int mode, size_t size): # <<<<<<<<<<<<<< @@ -6943,7 +6804,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_52scp_send(struct __pyx_obj_4s return __pyx_r; } -/* "ssh2/session.pyx":540 +/* "ssh2/session.pyx":538 * return PyChannel(channel, self) * * def scp_send64(self, path not None, int mode, c_ssh2.libssh2_uint64_t size, # <<<<<<<<<<<<<< @@ -6952,9 +6813,9 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_52scp_send(struct __pyx_obj_4s */ /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_7session_7Session_55scp_send64(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_4ssh2_7session_7Session_54scp_send64[] = "Session.scp_send64(self, path, int mode, libssh2_uint64_t size, time_t mtime, time_t atime)\nSend file via SCP.\n\n :param path: Local file path to send.\n :type path: str\n :param mode: File mode.\n :type mode: int\n :param size: size of file\n :type size: int\n\n :rtype: :py:class:`ssh2.channel.Channel`"; -static PyObject *__pyx_pw_4ssh2_7session_7Session_55scp_send64(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_4ssh2_7session_7Session_57scp_send64(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_4ssh2_7session_7Session_56scp_send64[] = "Session.scp_send64(self, path, int mode, libssh2_uint64_t size, time_t mtime, time_t atime)\nSend file via SCP.\n\n :param path: Local file path to send.\n :type path: str\n :param mode: File mode.\n :type mode: int\n :param size: size of file\n :type size: int\n\n :rtype: :py:class:`ssh2.channel.Channel`"; +static PyObject *__pyx_pw_4ssh2_7session_7Session_57scp_send64(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_path = 0; int __pyx_v_mode; libssh2_uint64_t __pyx_v_size; @@ -6992,29 +6853,29 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_55scp_send64(PyObject *__pyx_v case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mode)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("scp_send64", 1, 5, 5, 1); __PYX_ERR(0, 540, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send64", 1, 5, 5, 1); __PYX_ERR(0, 538, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_size)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("scp_send64", 1, 5, 5, 2); __PYX_ERR(0, 540, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send64", 1, 5, 5, 2); __PYX_ERR(0, 538, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mtime)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("scp_send64", 1, 5, 5, 3); __PYX_ERR(0, 540, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send64", 1, 5, 5, 3); __PYX_ERR(0, 538, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_atime)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("scp_send64", 1, 5, 5, 4); __PYX_ERR(0, 540, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send64", 1, 5, 5, 4); __PYX_ERR(0, 538, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scp_send64") < 0)) __PYX_ERR(0, 540, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scp_send64") < 0)) __PYX_ERR(0, 538, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; @@ -7026,23 +6887,23 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_55scp_send64(PyObject *__pyx_v values[4] = PyTuple_GET_ITEM(__pyx_args, 4); } __pyx_v_path = values[0]; - __pyx_v_mode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 540, __pyx_L3_error) - __pyx_v_size = __Pyx_PyInt_As_libssh2_uint64_t(values[2]); if (unlikely((__pyx_v_size == ((libssh2_uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 540, __pyx_L3_error) - __pyx_v_mtime = __Pyx_PyInt_As_time_t(values[3]); if (unlikely((__pyx_v_mtime == ((time_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 541, __pyx_L3_error) - __pyx_v_atime = __Pyx_PyInt_As_time_t(values[4]); if (unlikely((__pyx_v_atime == ((time_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 541, __pyx_L3_error) + __pyx_v_mode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 538, __pyx_L3_error) + __pyx_v_size = __Pyx_PyInt_As_libssh2_uint64_t(values[2]); if (unlikely((__pyx_v_size == ((libssh2_uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 538, __pyx_L3_error) + __pyx_v_mtime = __Pyx_PyInt_As_time_t(values[3]); if (unlikely((__pyx_v_mtime == ((time_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 539, __pyx_L3_error) + __pyx_v_atime = __Pyx_PyInt_As_time_t(values[4]); if (unlikely((__pyx_v_atime == ((time_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 539, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("scp_send64", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 540, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send64", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 538, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.session.Session.scp_send64", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 540, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 538, __pyx_L1_error) } - __pyx_r = __pyx_pf_4ssh2_7session_7Session_54scp_send64(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_path, __pyx_v_mode, __pyx_v_size, __pyx_v_mtime, __pyx_v_atime); + __pyx_r = __pyx_pf_4ssh2_7session_7Session_56scp_send64(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_path, __pyx_v_mode, __pyx_v_size, __pyx_v_mtime, __pyx_v_atime); /* function exit code */ goto __pyx_L0; @@ -7053,7 +6914,7 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_55scp_send64(PyObject *__pyx_v return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_7session_7Session_54scp_send64(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, PyObject *__pyx_v_path, int __pyx_v_mode, libssh2_uint64_t __pyx_v_size, time_t __pyx_v_mtime, time_t __pyx_v_atime) { +static PyObject *__pyx_pf_4ssh2_7session_7Session_56scp_send64(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, PyObject *__pyx_v_path, int __pyx_v_mode, libssh2_uint64_t __pyx_v_size, time_t __pyx_v_mtime, time_t __pyx_v_atime) { PyObject *__pyx_v_b_path = 0; char *__pyx_v__path; LIBSSH2_CHANNEL *__pyx_v_channel; @@ -7064,29 +6925,33 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_54scp_send64(struct __pyx_obj_ int __pyx_t_3; __Pyx_RefNannySetupContext("scp_send64", 0); - /* "ssh2/session.pyx":552 + /* "ssh2/session.pyx":550 * * :rtype: :py:class:`ssh2.channel.Channel`""" * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * cdef c_ssh2.LIBSSH2_CHANNEL *channel */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 552, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 550, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":553 + /* "ssh2/session.pyx":551 * :rtype: :py:class:`ssh2.channel.Channel`""" * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 553, __pyx_L1_error) + if (unlikely(__pyx_v_b_path == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 551, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 551, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/session.pyx":555 + /* "ssh2/session.pyx":553 * cdef char *_path = b_path * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -7101,7 +6966,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_54scp_send64(struct __pyx_obj_ #endif /*try:*/ { - /* "ssh2/session.pyx":556 + /* "ssh2/session.pyx":554 * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: * channel = c_ssh2.libssh2_scp_send64( # <<<<<<<<<<<<<< @@ -7111,7 +6976,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_54scp_send64(struct __pyx_obj_ __pyx_v_channel = libssh2_scp_send64(__pyx_v_self->_session, __pyx_v__path, __pyx_v_mode, __pyx_v_size, __pyx_v_mtime, __pyx_v_atime); } - /* "ssh2/session.pyx":555 + /* "ssh2/session.pyx":553 * cdef char *_path = b_path * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -7130,7 +6995,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_54scp_send64(struct __pyx_obj_ } } - /* "ssh2/session.pyx":558 + /* "ssh2/session.pyx":556 * channel = c_ssh2.libssh2_scp_send64( * self._session, _path, mode, size, mtime, atime) * if channel is not NULL: # <<<<<<<<<<<<<< @@ -7140,7 +7005,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_54scp_send64(struct __pyx_obj_ __pyx_t_3 = ((__pyx_v_channel != NULL) != 0); if (__pyx_t_3) { - /* "ssh2/session.pyx":559 + /* "ssh2/session.pyx":557 * self._session, _path, mode, size, mtime, atime) * if channel is not NULL: * return PyChannel(channel, self) # <<<<<<<<<<<<<< @@ -7148,79 +7013,218 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_54scp_send64(struct __pyx_obj_ * def publickey_init(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_7channel_PyChannel(__pyx_v_channel, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 559, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_7channel_PyChannel(__pyx_v_channel, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 557, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":558 - * channel = c_ssh2.libssh2_scp_send64( - * self._session, _path, mode, size, mtime, atime) - * if channel is not NULL: # <<<<<<<<<<<<<< - * return PyChannel(channel, self) + /* "ssh2/session.pyx":556 + * channel = c_ssh2.libssh2_scp_send64( + * self._session, _path, mode, size, mtime, atime) + * if channel is not NULL: # <<<<<<<<<<<<<< + * return PyChannel(channel, self) + * + */ + } + + /* "ssh2/session.pyx":538 + * return PyChannel(channel, self) + * + * def scp_send64(self, path not None, int mode, c_ssh2.libssh2_uint64_t size, # <<<<<<<<<<<<<< + * time_t mtime, time_t atime): + * """Send file via SCP. + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("ssh2.session.Session.scp_send64", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_b_path); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "ssh2/session.pyx":559 + * return PyChannel(channel, self) + * + * def publickey_init(self): # <<<<<<<<<<<<<< + * """Initialise public key subsystem for managing remote server + * public keys""" + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_4ssh2_7session_7Session_59publickey_init(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_4ssh2_7session_7Session_58publickey_init[] = "Session.publickey_init(self)\nInitialise public key subsystem for managing remote server\n public keys"; +static PyObject *__pyx_pw_4ssh2_7session_7Session_59publickey_init(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("publickey_init (wrapper)", 0); + __pyx_r = __pyx_pf_4ssh2_7session_7Session_58publickey_init(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_4ssh2_7session_7Session_58publickey_init(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self) { + LIBSSH2_PUBLICKEY *__pyx_v__pkey; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("publickey_init", 0); + + /* "ssh2/session.pyx":563 + * public keys""" + * cdef c_pkey.LIBSSH2_PUBLICKEY *_pkey + * with nogil: # <<<<<<<<<<<<<< + * _pkey= c_pkey.libssh2_publickey_init(self._session) + * if _pkey is not NULL: + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); + #endif + /*try:*/ { + + /* "ssh2/session.pyx":564 + * cdef c_pkey.LIBSSH2_PUBLICKEY *_pkey + * with nogil: + * _pkey= c_pkey.libssh2_publickey_init(self._session) # <<<<<<<<<<<<<< + * if _pkey is not NULL: + * return PyPublicKeySystem(_pkey, self) + */ + __pyx_v__pkey = libssh2_publickey_init(__pyx_v_self->_session); + } + + /* "ssh2/session.pyx":563 + * public keys""" + * cdef c_pkey.LIBSSH2_PUBLICKEY *_pkey + * with nogil: # <<<<<<<<<<<<<< + * _pkey= c_pkey.libssh2_publickey_init(self._session) + * if _pkey is not NULL: + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "ssh2/session.pyx":565 + * with nogil: + * _pkey= c_pkey.libssh2_publickey_init(self._session) + * if _pkey is not NULL: # <<<<<<<<<<<<<< + * return PyPublicKeySystem(_pkey, self) + * + */ + __pyx_t_1 = ((__pyx_v__pkey != NULL) != 0); + if (__pyx_t_1) { + + /* "ssh2/session.pyx":566 + * _pkey= c_pkey.libssh2_publickey_init(self._session) + * if _pkey is not NULL: + * return PyPublicKeySystem(_pkey, self) # <<<<<<<<<<<<<< + * + * def hostkey_hash(self, int hash_type): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_f_4ssh2_9publickey_PyPublicKeySystem(__pyx_v__pkey, __pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 566, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "ssh2/session.pyx":565 + * with nogil: + * _pkey= c_pkey.libssh2_publickey_init(self._session) + * if _pkey is not NULL: # <<<<<<<<<<<<<< + * return PyPublicKeySystem(_pkey, self) * */ } - /* "ssh2/session.pyx":540 + /* "ssh2/session.pyx":559 * return PyChannel(channel, self) * - * def scp_send64(self, path not None, int mode, c_ssh2.libssh2_uint64_t size, # <<<<<<<<<<<<<< - * time_t mtime, time_t atime): - * """Send file via SCP. + * def publickey_init(self): # <<<<<<<<<<<<<< + * """Initialise public key subsystem for managing remote server + * public keys""" */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("ssh2.session.Session.scp_send64", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("ssh2.session.Session.publickey_init", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_b_path); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "ssh2/session.pyx":561 - * return PyChannel(channel, self) +/* "ssh2/session.pyx":568 + * return PyPublicKeySystem(_pkey, self) + * + * def hostkey_hash(self, int hash_type): # <<<<<<<<<<<<<< + * """Get computed digest of the remote system's host key. * - * def publickey_init(self): # <<<<<<<<<<<<<< - * """Initialise public key subsystem for managing remote server - * public keys""" */ /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_7session_7Session_57publickey_init(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_4ssh2_7session_7Session_56publickey_init[] = "Session.publickey_init(self)\nInitialise public key subsystem for managing remote server\n public keys"; -static PyObject *__pyx_pw_4ssh2_7session_7Session_57publickey_init(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_4ssh2_7session_7Session_61hostkey_hash(PyObject *__pyx_v_self, PyObject *__pyx_arg_hash_type); /*proto*/ +static char __pyx_doc_4ssh2_7session_7Session_60hostkey_hash[] = "Session.hostkey_hash(self, int hash_type)\nGet computed digest of the remote system's host key.\n\n :param hash_type: One of ``ssh2.session.LIBSSH2_HOSTKEY_HASH_MD5`` or\n ``ssh2.session.LIBSSH2_HOSTKEY_HASH_SHA1``\n :type hash_type: int\n\n :rtype: bytes"; +static PyObject *__pyx_pw_4ssh2_7session_7Session_61hostkey_hash(PyObject *__pyx_v_self, PyObject *__pyx_arg_hash_type) { + int __pyx_v_hash_type; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("publickey_init (wrapper)", 0); - __pyx_r = __pyx_pf_4ssh2_7session_7Session_56publickey_init(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self)); + __Pyx_RefNannySetupContext("hostkey_hash (wrapper)", 0); + assert(__pyx_arg_hash_type); { + __pyx_v_hash_type = __Pyx_PyInt_As_int(__pyx_arg_hash_type); if (unlikely((__pyx_v_hash_type == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 568, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("ssh2.session.Session.hostkey_hash", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_4ssh2_7session_7Session_60hostkey_hash(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), ((int)__pyx_v_hash_type)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_7session_7Session_56publickey_init(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self) { - LIBSSH2_PUBLICKEY *__pyx_v__pkey; +static PyObject *__pyx_pf_4ssh2_7session_7Session_60hostkey_hash(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, int __pyx_v_hash_type) { + char const *__pyx_v__hash; + PyObject *__pyx_v_b_hash = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannySetupContext("publickey_init", 0); + __Pyx_RefNannySetupContext("hostkey_hash", 0); - /* "ssh2/session.pyx":565 - * public keys""" - * cdef c_pkey.LIBSSH2_PUBLICKEY *_pkey + /* "ssh2/session.pyx":578 + * cdef const char *_hash + * cdef bytes b_hash * with nogil: # <<<<<<<<<<<<<< - * _pkey= c_pkey.libssh2_publickey_init(self._session) - * if _pkey is not NULL: + * _hash = c_ssh2.libssh2_hostkey_hash(self._session, hash_type) + * if _hash is NULL: */ { #ifdef WITH_THREAD @@ -7230,22 +7234,22 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_56publickey_init(struct __pyx_ #endif /*try:*/ { - /* "ssh2/session.pyx":566 - * cdef c_pkey.LIBSSH2_PUBLICKEY *_pkey + /* "ssh2/session.pyx":579 + * cdef bytes b_hash * with nogil: - * _pkey= c_pkey.libssh2_publickey_init(self._session) # <<<<<<<<<<<<<< - * if _pkey is not NULL: - * return PyPublicKeySystem(_pkey, self) + * _hash = c_ssh2.libssh2_hostkey_hash(self._session, hash_type) # <<<<<<<<<<<<<< + * if _hash is NULL: + * return */ - __pyx_v__pkey = libssh2_publickey_init(__pyx_v_self->_session); + __pyx_v__hash = libssh2_hostkey_hash(__pyx_v_self->_session, __pyx_v_hash_type); } - /* "ssh2/session.pyx":565 - * public keys""" - * cdef c_pkey.LIBSSH2_PUBLICKEY *_pkey + /* "ssh2/session.pyx":578 + * cdef const char *_hash + * cdef bytes b_hash * with nogil: # <<<<<<<<<<<<<< - * _pkey= c_pkey.libssh2_publickey_init(self._session) - * if _pkey is not NULL: + * _hash = c_ssh2.libssh2_hostkey_hash(self._session, hash_type) + * if _hash is NULL: */ /*finally:*/ { /*normal exit:*/{ @@ -7259,51 +7263,72 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_56publickey_init(struct __pyx_ } } - /* "ssh2/session.pyx":567 + /* "ssh2/session.pyx":580 * with nogil: - * _pkey= c_pkey.libssh2_publickey_init(self._session) - * if _pkey is not NULL: # <<<<<<<<<<<<<< - * return PyPublicKeySystem(_pkey, self) + * _hash = c_ssh2.libssh2_hostkey_hash(self._session, hash_type) + * if _hash is NULL: # <<<<<<<<<<<<<< + * return + * b_hash = _hash */ - __pyx_t_1 = ((__pyx_v__pkey != NULL) != 0); + __pyx_t_1 = ((__pyx_v__hash == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/session.pyx":568 - * _pkey= c_pkey.libssh2_publickey_init(self._session) - * if _pkey is not NULL: - * return PyPublicKeySystem(_pkey, self) # <<<<<<<<<<<<<< + /* "ssh2/session.pyx":581 + * _hash = c_ssh2.libssh2_hostkey_hash(self._session, hash_type) + * if _hash is NULL: + * return # <<<<<<<<<<<<<< + * b_hash = _hash + * return b_hash */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_f_4ssh2_9publickey_PyPublicKeySystem(__pyx_v__pkey, __pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 568, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - /* "ssh2/session.pyx":567 + /* "ssh2/session.pyx":580 * with nogil: - * _pkey= c_pkey.libssh2_publickey_init(self._session) - * if _pkey is not NULL: # <<<<<<<<<<<<<< - * return PyPublicKeySystem(_pkey, self) + * _hash = c_ssh2.libssh2_hostkey_hash(self._session, hash_type) + * if _hash is NULL: # <<<<<<<<<<<<<< + * return + * b_hash = _hash */ } - /* "ssh2/session.pyx":561 - * return PyChannel(channel, self) + /* "ssh2/session.pyx":582 + * if _hash is NULL: + * return + * b_hash = _hash # <<<<<<<<<<<<<< + * return b_hash + */ + __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v__hash); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 582, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_v_b_hash = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; + + /* "ssh2/session.pyx":583 + * return + * b_hash = _hash + * return b_hash # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_b_hash); + __pyx_r = __pyx_v_b_hash; + goto __pyx_L0; + + /* "ssh2/session.pyx":568 + * return PyPublicKeySystem(_pkey, self) + * + * def hostkey_hash(self, int hash_type): # <<<<<<<<<<<<<< + * """Get computed digest of the remote system's host key. * - * def publickey_init(self): # <<<<<<<<<<<<<< - * """Initialise public key subsystem for managing remote server - * public keys""" */ /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("ssh2.session.Session.publickey_init", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("ssh2.session.Session.hostkey_hash", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_b_hash); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; @@ -7316,20 +7341,20 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_56publickey_init(struct __pyx_ */ /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_7session_7Session_59__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_4ssh2_7session_7Session_58__reduce_cython__[] = "Session.__reduce_cython__(self)"; -static PyObject *__pyx_pw_4ssh2_7session_7Session_59__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_4ssh2_7session_7Session_63__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_4ssh2_7session_7Session_62__reduce_cython__[] = "Session.__reduce_cython__(self)"; +static PyObject *__pyx_pw_4ssh2_7session_7Session_63__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_4ssh2_7session_7Session_58__reduce_cython__(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self)); + __pyx_r = __pyx_pf_4ssh2_7session_7Session_62__reduce_cython__(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_7session_7Session_58__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self) { +static PyObject *__pyx_pf_4ssh2_7session_7Session_62__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -7341,7 +7366,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_58__reduce_cython__(CYTHON_UNU * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -7371,20 +7396,20 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_58__reduce_cython__(CYTHON_UNU */ /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_7session_7Session_61__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static char __pyx_doc_4ssh2_7session_7Session_60__setstate_cython__[] = "Session.__setstate_cython__(self, __pyx_state)"; -static PyObject *__pyx_pw_4ssh2_7session_7Session_61__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { +static PyObject *__pyx_pw_4ssh2_7session_7Session_65__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static char __pyx_doc_4ssh2_7session_7Session_64__setstate_cython__[] = "Session.__setstate_cython__(self, __pyx_state)"; +static PyObject *__pyx_pw_4ssh2_7session_7Session_65__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_4ssh2_7session_7Session_60__setstate_cython__(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + __pyx_r = __pyx_pf_4ssh2_7session_7Session_64__setstate_cython__(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_7session_7Session_60__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { +static PyObject *__pyx_pf_4ssh2_7session_7Session_64__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -7395,7 +7420,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_60__setstate_cython__(CYTHON_U * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -7417,7 +7442,6 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_60__setstate_cython__(CYTHON_U __Pyx_RefNannyFinishContext(); return __pyx_r; } -static struct __pyx_vtabstruct_4ssh2_7session_Session __pyx_vtable_4ssh2_7session_Session; static PyObject *__pyx_tp_new_4ssh2_7session_Session(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_4ssh2_7session_Session *p; @@ -7429,7 +7453,7 @@ static PyObject *__pyx_tp_new_4ssh2_7session_Session(PyTypeObject *t, CYTHON_UNU } if (unlikely(!o)) return 0; p = ((struct __pyx_obj_4ssh2_7session_Session *)o); - p->__pyx_vtab = __pyx_vtabptr_4ssh2_7session_Session; + p->sock = Py_None; Py_INCREF(Py_None); if (unlikely(__pyx_pw_4ssh2_7session_7Session_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad; return o; bad: @@ -7438,11 +7462,13 @@ static PyObject *__pyx_tp_new_4ssh2_7session_Session(PyTypeObject *t, CYTHON_UNU } static void __pyx_tp_dealloc_4ssh2_7session_Session(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 - if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { + struct __pyx_obj_4ssh2_7session_Session *p = (struct __pyx_obj_4ssh2_7session_Session *)o; + #if CYTHON_USE_TP_FINALIZE + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif + PyObject_GC_UnTrack(o); { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); @@ -7451,9 +7477,28 @@ static void __pyx_tp_dealloc_4ssh2_7session_Session(PyObject *o) { --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); } + Py_CLEAR(p->sock); (*Py_TYPE(o)->tp_free)(o); } +static int __pyx_tp_traverse_4ssh2_7session_Session(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_4ssh2_7session_Session *p = (struct __pyx_obj_4ssh2_7session_Session *)o; + if (p->sock) { + e = (*v)(p->sock, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_4ssh2_7session_Session(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_4ssh2_7session_Session *p = (struct __pyx_obj_4ssh2_7session_Session *)o; + tmp = ((PyObject*)p->sock); + p->sock = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + static PyMethodDef __pyx_methods_4ssh2_7session_Session[] = { {"disconnect", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_5disconnect, METH_NOARGS, __pyx_doc_4ssh2_7session_7Session_4disconnect}, {"handshake", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_7handshake, METH_O, __pyx_doc_4ssh2_7session_7Session_6handshake}, @@ -7478,12 +7523,14 @@ static PyMethodDef __pyx_methods_4ssh2_7session_Session[] = { {"forward_listen_ex", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_45forward_listen_ex, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4ssh2_7session_7Session_44forward_listen_ex}, {"sftp_init", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_47sftp_init, METH_NOARGS, __pyx_doc_4ssh2_7session_7Session_46sftp_init}, {"last_error", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_49last_error, METH_NOARGS, __pyx_doc_4ssh2_7session_7Session_48last_error}, - {"scp_recv", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_51scp_recv, METH_O, __pyx_doc_4ssh2_7session_7Session_50scp_recv}, - {"scp_send", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_53scp_send, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4ssh2_7session_7Session_52scp_send}, - {"scp_send64", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_55scp_send64, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4ssh2_7session_7Session_54scp_send64}, - {"publickey_init", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_57publickey_init, METH_NOARGS, __pyx_doc_4ssh2_7session_7Session_56publickey_init}, - {"__reduce_cython__", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_59__reduce_cython__, METH_NOARGS, __pyx_doc_4ssh2_7session_7Session_58__reduce_cython__}, - {"__setstate_cython__", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_61__setstate_cython__, METH_O, __pyx_doc_4ssh2_7session_7Session_60__setstate_cython__}, + {"last_errno", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_51last_errno, METH_NOARGS, __pyx_doc_4ssh2_7session_7Session_50last_errno}, + {"scp_recv", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_53scp_recv, METH_O, __pyx_doc_4ssh2_7session_7Session_52scp_recv}, + {"scp_send", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_55scp_send, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4ssh2_7session_7Session_54scp_send}, + {"scp_send64", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_57scp_send64, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4ssh2_7session_7Session_56scp_send64}, + {"publickey_init", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_59publickey_init, METH_NOARGS, __pyx_doc_4ssh2_7session_7Session_58publickey_init}, + {"hostkey_hash", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_61hostkey_hash, METH_O, __pyx_doc_4ssh2_7session_7Session_60hostkey_hash}, + {"__reduce_cython__", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_63__reduce_cython__, METH_NOARGS, __pyx_doc_4ssh2_7session_7Session_62__reduce_cython__}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_4ssh2_7session_7Session_65__setstate_cython__, METH_O, __pyx_doc_4ssh2_7session_7Session_64__setstate_cython__}, {0, 0, 0, 0} }; @@ -7512,10 +7559,10 @@ static PyTypeObject __pyx_type_4ssh2_7session_Session = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ "LibSSH2 Session class providing session functions", /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ + __pyx_tp_traverse_4ssh2_7session_Session, /*tp_traverse*/ + __pyx_tp_clear_4ssh2_7session_Session, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ @@ -7550,17 +7597,31 @@ static PyMethodDef __pyx_methods[] = { }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_session(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_session}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "session", 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ @@ -7573,24 +7634,25 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_Error_authenticating_user_s_with_2, __pyx_k_Error_authenticating_user_s_with_2, sizeof(__pyx_k_Error_authenticating_user_s_with_2), 0, 0, 1, 0}, {&__pyx_kp_s_Error_authenticating_user_s_with_3, __pyx_k_Error_authenticating_user_s_with_3, sizeof(__pyx_k_Error_authenticating_user_s_with_3), 0, 0, 1, 0}, {&__pyx_kp_s_Error_authenticating_user_s_with_4, __pyx_k_Error_authenticating_user_s_with_4, sizeof(__pyx_k_Error_authenticating_user_s_with_4), 0, 0, 1, 0}, - {&__pyx_kp_s_Error_initialising_agent, __pyx_k_Error_initialising_agent, sizeof(__pyx_k_Error_initialising_agent), 0, 0, 1, 0}, - {&__pyx_kp_s_Failure_requesting_identities_fr, __pyx_k_Failure_requesting_identities_fr, sizeof(__pyx_k_Failure_requesting_identities_fr), 0, 0, 1, 0}, + {&__pyx_n_s_LIBSSH2_HOSTKEY_HASH_MD5, __pyx_k_LIBSSH2_HOSTKEY_HASH_MD5, sizeof(__pyx_k_LIBSSH2_HOSTKEY_HASH_MD5), 0, 0, 1, 1}, + {&__pyx_n_s_LIBSSH2_HOSTKEY_HASH_SHA1, __pyx_k_LIBSSH2_HOSTKEY_HASH_SHA1, sizeof(__pyx_k_LIBSSH2_HOSTKEY_HASH_SHA1), 0, 0, 1, 1}, {&__pyx_n_s_LIBSSH2_SESSION_BLOCK_INBOUND, __pyx_k_LIBSSH2_SESSION_BLOCK_INBOUND, sizeof(__pyx_k_LIBSSH2_SESSION_BLOCK_INBOUND), 0, 0, 1, 1}, {&__pyx_n_s_LIBSSH2_SESSION_BLOCK_OUTBOUND, __pyx_k_LIBSSH2_SESSION_BLOCK_OUTBOUND, sizeof(__pyx_k_LIBSSH2_SESSION_BLOCK_OUTBOUND), 0, 0, 1, 1}, {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1}, {&__pyx_kp_s_SSH_session_handshake_failed_wit, __pyx_k_SSH_session_handshake_failed_wit, sizeof(__pyx_k_SSH_session_handshake_failed_wit), 0, 0, 1, 0}, {&__pyx_kp_s_SSH_session_startup_failed_with, __pyx_k_SSH_session_startup_failed_with, sizeof(__pyx_k_SSH_session_startup_failed_with), 0, 0, 1, 0}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, - {&__pyx_kp_s_Unable_to_connect_to_agent, __pyx_k_Unable_to_connect_to_agent, sizeof(__pyx_k_Unable_to_connect_to_agent), 0, 0, 1, 0}, - {&__pyx_kp_b__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 0, 0, 0}, + {&__pyx_kp_b__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 0, 0}, {&__pyx_n_s_atime, __pyx_k_atime, sizeof(__pyx_k_atime), 0, 0, 1, 1}, {&__pyx_n_s_bound_port, __pyx_k_bound_port, sizeof(__pyx_k_bound_port), 0, 0, 1, 1}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, + {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, {&__pyx_n_s_host, __pyx_k_host, sizeof(__pyx_k_host), 0, 0, 1, 1}, {&__pyx_n_s_hostname, __pyx_k_hostname, sizeof(__pyx_k_hostname), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1}, {&__pyx_n_s_mtime, __pyx_k_mtime, sizeof(__pyx_k_mtime), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, {&__pyx_n_s_passphrase, __pyx_k_passphrase, sizeof(__pyx_k_passphrase), 0, 0, 1, 1}, {&__pyx_n_s_password, __pyx_k_password, sizeof(__pyx_k_password), 0, 0, 1, 1}, @@ -7599,9 +7661,11 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_privatekey, __pyx_k_privatekey, sizeof(__pyx_k_privatekey), 0, 0, 1, 1}, {&__pyx_n_s_pubkeydata, __pyx_k_pubkeydata, sizeof(__pyx_k_pubkeydata), 0, 0, 1, 1}, {&__pyx_n_s_publickey, __pyx_k_publickey, sizeof(__pyx_k_publickey), 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_queue_maxsize, __pyx_k_queue_maxsize, sizeof(__pyx_k_queue_maxsize), 0, 0, 1, 1}, + {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, + {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_shost, __pyx_k_shost, sizeof(__pyx_k_shost), 0, 0, 1, 1}, {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1}, @@ -7612,7 +7676,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 49, __pyx_L1_error) + __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 50, __pyx_L1_error) __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error) return 0; __pyx_L1_error:; @@ -7623,68 +7687,35 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "ssh2/session.pyx":148 + /* "ssh2/session.pyx":155 * return * auth = to_str(_auth) * return auth.split(',') # <<<<<<<<<<<<<< * * def userauth_publickey_fromfile(self, username not None, */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 148, __pyx_L1_error) + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); - /* "ssh2/session.pyx":293 - * if agent is NULL: - * with gil: - * raise AgentError("Error initialising agent") # <<<<<<<<<<<<<< - * return agent - * - */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_Error_initialising_agent); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__3); - __Pyx_GIVEREF(__pyx_tuple__3); - - /* "ssh2/session.pyx":303 - * with nogil: - * c_ssh2.libssh2_agent_free(agent) - * raise AgentConnectionError("Unable to connect to agent") # <<<<<<<<<<<<<< - * return agent - * - */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_connect_to_agent); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 303, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); - - /* "ssh2/session.pyx":342 - * clear_agent(agent) - * with gil: - * raise AgentListIdentitiesError( # <<<<<<<<<<<<<< - * "Failure requesting identities from agent") - * while 1: - */ - __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_Failure_requesting_identities_fr); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 342, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__5); - __Pyx_GIVEREF(__pyx_tuple__5); - /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); /* "(tree fragment)":4 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -7705,6 +7736,47 @@ PyMODINIT_FUNC initsession(void) #else PyMODINIT_FUNC PyInit_session(void); /*proto*/ PyMODINIT_FUNC PyInit_session(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec_session(PyObject *__pyx_pyinit_module) +#endif #endif { PyObject *__pyx_t_1 = NULL; @@ -7715,6 +7787,9 @@ PyMODINIT_FUNC PyInit_session(void) PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { @@ -7741,6 +7816,9 @@ PyMODINIT_FUNC PyInit_session(void) #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_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 @@ -7752,12 +7830,17 @@ PyMODINIT_FUNC PyInit_session(void) #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("session", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -7790,14 +7873,10 @@ PyMODINIT_FUNC PyInit_session(void) /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ - __pyx_vtabptr_4ssh2_7session_Session = &__pyx_vtable_4ssh2_7session_Session; - __pyx_vtable_4ssh2_7session_Session.init_connect_agent = (LIBSSH2_AGENT *(*)(struct __pyx_obj_4ssh2_7session_Session *))__pyx_f_4ssh2_7session_7Session_init_connect_agent; - __pyx_vtable_4ssh2_7session_Session._agent_init = (LIBSSH2_AGENT *(*)(struct __pyx_obj_4ssh2_7session_Session *))__pyx_f_4ssh2_7session_7Session__agent_init; - if (PyType_Ready(&__pyx_type_4ssh2_7session_Session) < 0) __PYX_ERR(0, 42, __pyx_L1_error) + if (PyType_Ready(&__pyx_type_4ssh2_7session_Session) < 0) __PYX_ERR(0, 43, __pyx_L1_error) __pyx_type_4ssh2_7session_Session.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type_4ssh2_7session_Session.tp_dict, __pyx_vtabptr_4ssh2_7session_Session) < 0) __PYX_ERR(0, 42, __pyx_L1_error) - if (PyObject_SetAttrString(__pyx_m, "Session", (PyObject *)&__pyx_type_4ssh2_7session_Session) < 0) __PYX_ERR(0, 42, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_7session_Session) < 0) __PYX_ERR(0, 42, __pyx_L1_error) + if (PyObject_SetAttrString(__pyx_m, "Session", (PyObject *)&__pyx_type_4ssh2_7session_Session) < 0) __PYX_ERR(0, 43, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_7session_Session) < 0) __PYX_ERR(0, 43, __pyx_L1_error) __pyx_ptype_4ssh2_7session_Session = &__pyx_type_4ssh2_7session_Session; /*--- Type import code ---*/ __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", @@ -7822,6 +7901,7 @@ PyMODINIT_FUNC PyInit_session(void) __pyx_ptype_4ssh2_10exceptions_ChannelError = __Pyx_ImportType("ssh2.exceptions", "ChannelError", sizeof(struct __pyx_obj_4ssh2_10exceptions_ChannelError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_ChannelError)) __PYX_ERR(7, 50, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_SFTPHandleError = __Pyx_ImportType("ssh2.exceptions", "SFTPHandleError", sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SFTPHandleError)) __PYX_ERR(7, 54, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall = __Pyx_ImportType("ssh2.exceptions", "SFTPBufferTooSmall", sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall)) __PYX_ERR(7, 58, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_SFTPIOError = __Pyx_ImportType("ssh2.exceptions", "SFTPIOError", sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPIOError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SFTPIOError)) __PYX_ERR(7, 62, __pyx_L1_error) __pyx_ptype_4ssh2_8listener_Listener = __Pyx_ImportType("ssh2.listener", "Listener", sizeof(struct __pyx_obj_4ssh2_8listener_Listener), 1); if (unlikely(!__pyx_ptype_4ssh2_8listener_Listener)) __PYX_ERR(8, 24, __pyx_L1_error) __pyx_ptype_4ssh2_4sftp_SFTP = __Pyx_ImportType("ssh2.sftp", "SFTP", sizeof(struct __pyx_obj_4ssh2_4sftp_SFTP), 1); if (unlikely(!__pyx_ptype_4ssh2_4sftp_SFTP)) __PYX_ERR(9, 26, __pyx_L1_error) __pyx_ptype_4ssh2_8statinfo_StatInfo = __Pyx_ImportType("ssh2.statinfo", "StatInfo", sizeof(struct __pyx_obj_4ssh2_8statinfo_StatInfo), 1); if (unlikely(!__pyx_ptype_4ssh2_8statinfo_StatInfo)) __PYX_ERR(10, 20, __pyx_L1_error) @@ -7829,8 +7909,9 @@ PyMODINIT_FUNC PyInit_session(void) /*--- Function import code ---*/ __pyx_t_1 = __Pyx_ImportModule("ssh2.agent"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportFunction(__pyx_t_1, "PyAgent", (void (**)(void))&__pyx_f_4ssh2_5agent_PyAgent, "PyObject *(LIBSSH2_AGENT *, struct __pyx_obj_4ssh2_7session_Session *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) - if (__Pyx_ImportFunction(__pyx_t_1, "auth_identity", (void (**)(void))&__pyx_f_4ssh2_5agent_auth_identity, "int (char const *, LIBSSH2_AGENT *, struct libssh2_agent_publickey **, struct libssh2_agent_publickey *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) - if (__Pyx_ImportFunction(__pyx_t_1, "clear_agent", (void (**)(void))&__pyx_f_4ssh2_5agent_clear_agent, "void (LIBSSH2_AGENT *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) + if (__Pyx_ImportFunction(__pyx_t_1, "agent_auth", (void (**)(void))&__pyx_f_4ssh2_5agent_agent_auth, "int (char *, LIBSSH2_AGENT *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) + if (__Pyx_ImportFunction(__pyx_t_1, "init_connect_agent", (void (**)(void))&__pyx_f_4ssh2_5agent_init_connect_agent, "LIBSSH2_AGENT *(LIBSSH2_SESSION *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) + if (__Pyx_ImportFunction(__pyx_t_1, "agent_init", (void (**)(void))&__pyx_f_4ssh2_5agent_agent_init, "LIBSSH2_AGENT *(LIBSSH2_SESSION *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) Py_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __Pyx_ImportModule("ssh2.channel"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportFunction(__pyx_t_2, "PyChannel", (void (**)(void))&__pyx_f_4ssh2_7channel_PyChannel, "PyObject *(LIBSSH2_CHANNEL *, struct __pyx_obj_4ssh2_7session_Session *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) @@ -7853,28 +7934,52 @@ PyMODINIT_FUNC PyInit_session(void) if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif - /* "ssh2/session.pyx":38 + /* "ssh2/session.pyx":37 * * * LIBSSH2_SESSION_BLOCK_INBOUND = c_ssh2.LIBSSH2_SESSION_BLOCK_INBOUND # <<<<<<<<<<<<<< * LIBSSH2_SESSION_BLOCK_OUTBOUND = c_ssh2.LIBSSH2_SESSION_BLOCK_OUTBOUND - * + * LIBSSH2_HOSTKEY_HASH_MD5 = c_ssh2.LIBSSH2_HOSTKEY_HASH_MD5 */ - __pyx_t_7 = __Pyx_PyInt_From_int(LIBSSH2_SESSION_BLOCK_INBOUND); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 38, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_int(LIBSSH2_SESSION_BLOCK_INBOUND); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_SESSION_BLOCK_INBOUND, __pyx_t_7) < 0) __PYX_ERR(0, 38, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_SESSION_BLOCK_INBOUND, __pyx_t_7) < 0) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - /* "ssh2/session.pyx":39 + /* "ssh2/session.pyx":38 * * LIBSSH2_SESSION_BLOCK_INBOUND = c_ssh2.LIBSSH2_SESSION_BLOCK_INBOUND * LIBSSH2_SESSION_BLOCK_OUTBOUND = c_ssh2.LIBSSH2_SESSION_BLOCK_OUTBOUND # <<<<<<<<<<<<<< + * LIBSSH2_HOSTKEY_HASH_MD5 = c_ssh2.LIBSSH2_HOSTKEY_HASH_MD5 + * LIBSSH2_HOSTKEY_HASH_SHA1 = c_ssh2.LIBSSH2_HOSTKEY_HASH_SHA1 + */ + __pyx_t_7 = __Pyx_PyInt_From_int(LIBSSH2_SESSION_BLOCK_OUTBOUND); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 38, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_SESSION_BLOCK_OUTBOUND, __pyx_t_7) < 0) __PYX_ERR(0, 38, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "ssh2/session.pyx":39 + * LIBSSH2_SESSION_BLOCK_INBOUND = c_ssh2.LIBSSH2_SESSION_BLOCK_INBOUND + * LIBSSH2_SESSION_BLOCK_OUTBOUND = c_ssh2.LIBSSH2_SESSION_BLOCK_OUTBOUND + * LIBSSH2_HOSTKEY_HASH_MD5 = c_ssh2.LIBSSH2_HOSTKEY_HASH_MD5 # <<<<<<<<<<<<<< + * LIBSSH2_HOSTKEY_HASH_SHA1 = c_ssh2.LIBSSH2_HOSTKEY_HASH_SHA1 + * + */ + __pyx_t_7 = __Pyx_PyInt_From_int(LIBSSH2_HOSTKEY_HASH_MD5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 39, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_HOSTKEY_HASH_MD5, __pyx_t_7) < 0) __PYX_ERR(0, 39, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "ssh2/session.pyx":40 + * LIBSSH2_SESSION_BLOCK_OUTBOUND = c_ssh2.LIBSSH2_SESSION_BLOCK_OUTBOUND + * LIBSSH2_HOSTKEY_HASH_MD5 = c_ssh2.LIBSSH2_HOSTKEY_HASH_MD5 + * LIBSSH2_HOSTKEY_HASH_SHA1 = c_ssh2.LIBSSH2_HOSTKEY_HASH_SHA1 # <<<<<<<<<<<<<< * * */ - __pyx_t_7 = __Pyx_PyInt_From_int(LIBSSH2_SESSION_BLOCK_OUTBOUND); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 39, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_int(LIBSSH2_HOSTKEY_HASH_SHA1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_SESSION_BLOCK_OUTBOUND, __pyx_t_7) < 0) __PYX_ERR(0, 39, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_HOSTKEY_HASH_SHA1, __pyx_t_7) < 0) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "ssh2/session.pyx":1 @@ -7882,7 +7987,7 @@ PyMODINIT_FUNC PyInit_session(void) * # Copyright (C) 2017 Panos Kittenis * */ - __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_7) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; @@ -7908,10 +8013,12 @@ PyMODINIT_FUNC PyInit_session(void) } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -7974,7 +8081,7 @@ static void __Pyx_RaiseArgtupleInvalid( } /* KeywordStringCheck */ -static CYTHON_INLINE int __Pyx_CheckKeywordStrings( +static int __Pyx_CheckKeywordStrings( PyObject *kwdict, const char* function_name, int kw_allowed) @@ -7988,7 +8095,7 @@ static CYTHON_INLINE int __Pyx_CheckKeywordStrings( #else while (PyDict_Next(kwdict, &pos, &key, 0)) { #if PY_MAJOR_VERSION < 3 - if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) + if (unlikely(!PyString_Check(key))) #endif if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type; @@ -8173,11 +8280,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject "raise: exception class must be a subclass of BaseException"); goto bad; } -#if PY_VERSION_HEX >= 0x03030000 if (cause) { -#else - if (cause && cause != Py_None) { -#endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; @@ -8205,7 +8308,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else - PyThreadState *tstate = PyThreadState_GET(); + PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); @@ -8221,7 +8324,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject #endif /* RaiseDoubleKeywords */ - static void __Pyx_RaiseDoubleKeywordsError( +static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { @@ -8235,7 +8338,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* ParseKeywords */ - static int __Pyx_ParseOptionalKeywords( +static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, @@ -8337,67 +8440,37 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* 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); -} -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } - if (none_allowed && obj == Py_None) return 1; else if (exact) { - if (likely(Py_TYPE(obj) == type)) return 1; #if PY_MAJOR_VERSION == 2 - else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { - if (likely(PyObject_TypeCheck(obj, type))) return 1; + if (likely(__Pyx_TypeCheck(obj, type))) return 1; } - __Pyx_RaiseArgumentTypeInvalid(name, obj, type); - return 0; -} - -/* None */ - static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { - PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); -} - -/* 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); -#endif - if (!ob) - goto bad; - if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) - goto bad; - Py_DECREF(ob); + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); return 0; -bad: - Py_XDECREF(ob); - return -1; } /* SetupReduce */ - #define __Pyx_setup_reduce_GET_ATTR_OR_BAD(res, obj, name) res = PyObject_GetAttrString(obj, name); if (res == NULL) goto BAD; static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { int ret; PyObject *name_attr; - name_attr = PyObject_GetAttrString(meth, "__name__"); - if (name_attr) { + name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name); + if (likely(name_attr)) { ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); } else { ret = -1; } - if (ret < 0) { + if (unlikely(ret < 0)) { PyErr_Clear(); ret = 0; } @@ -8406,43 +8479,55 @@ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { } static int __Pyx_setup_reduce(PyObject* type_obj) { int ret = 0; - PyObject* builtin_object = NULL; - static PyObject *object_reduce = NULL; - static PyObject *object_reduce_ex = NULL; + PyObject *object_reduce = NULL; + PyObject *object_reduce_ex = NULL; PyObject *reduce = NULL; PyObject *reduce_ex = NULL; PyObject *reduce_cython = NULL; PyObject *setstate = NULL; PyObject *setstate_cython = NULL; - if (PyObject_HasAttrString(type_obj, "__getstate__")) goto GOOD; - if (object_reduce_ex == NULL) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(builtin_object, __pyx_b, "object"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce, builtin_object, "__reduce__"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce_ex, builtin_object, "__reduce_ex__"); - } - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_ex, type_obj, "__reduce_ex__"); +#if CYTHON_USE_PYTYPE_LOOKUP + if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD; +#else + if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD; +#endif +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#else + object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#endif + reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD; if (reduce_ex == object_reduce_ex) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce, type_obj, "__reduce__"); - if (object_reduce == reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_cython, type_obj, "__reduce_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce__", reduce_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce_cython__"); if (ret < 0) goto BAD; - setstate = PyObject_GetAttrString(type_obj, "__setstate__"); +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#else + object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#endif + reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD; + if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { + reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD; + setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); if (!setstate) PyErr_Clear(); if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(setstate_cython, type_obj, "__setstate_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate__", setstate_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate_cython__"); if (ret < 0) goto BAD; + setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD; } PyType_Modified((PyTypeObject*)type_obj); } } goto GOOD; BAD: - if (!PyErr_Occurred()) PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); + if (!PyErr_Occurred()) + PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); ret = -1; GOOD: - Py_XDECREF(builtin_object); +#if !CYTHON_USE_PYTYPE_LOOKUP + Py_XDECREF(object_reduce); + Py_XDECREF(object_reduce_ex); +#endif Py_XDECREF(reduce); Py_XDECREF(reduce_ex); Py_XDECREF(reduce_cython); @@ -8452,14 +8537,18 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { } /* CLineInTraceback */ - static int __Pyx_CLineForTraceback(int c_line) { +static int __Pyx_CLineForTraceback(int c_line) { #ifdef CYTHON_CLINE_IN_TRACEBACK return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; #else - PyObject **cython_runtime_dict; PyObject *use_cline; - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (unlikely(!cython_runtime_dict)) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { PyObject *ptype, *pvalue, *ptraceback; PyObject *use_cline_obj; PyErr_Fetch(&ptype, &pvalue, &ptraceback); @@ -8471,8 +8560,6 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { use_cline = NULL; } PyErr_Restore(ptype, pvalue, ptraceback); - } else { - use_cline = PyDict_GetItem(*_PyObject_GetDictPtr(__pyx_cython_runtime), __pyx_n_s_cline_in_traceback); } if (!use_cline) { c_line = 0; @@ -8486,7 +8573,7 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { } /* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { +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; @@ -8566,7 +8653,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { } /* AddTraceback */ - #include "compile.h" +#include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( @@ -8636,10 +8723,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, __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*/ + __Pyx_PyThreadState_Current, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); @@ -8650,7 +8737,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -8681,7 +8768,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ +#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) @@ -8703,7 +8790,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { +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) { @@ -8734,7 +8821,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { +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 @@ -8923,7 +9010,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { +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 @@ -9112,7 +9199,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { +static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { const size_t neg_one = (size_t) -1, const_zero = (size_t) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -9301,7 +9388,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE libssh2_uint64_t __Pyx_PyInt_As_libssh2_uint64_t(PyObject *x) { +static CYTHON_INLINE libssh2_uint64_t __Pyx_PyInt_As_libssh2_uint64_t(PyObject *x) { const libssh2_uint64_t neg_one = (libssh2_uint64_t) -1, const_zero = (libssh2_uint64_t) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -9490,7 +9577,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE time_t __Pyx_PyInt_As_time_t(PyObject *x) { +static CYTHON_INLINE time_t __Pyx_PyInt_As_time_t(PyObject *x) { const time_t neg_one = (time_t) -1, const_zero = (time_t) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -9678,8 +9765,80 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, return (time_t) -1; } +/* FastTypeChecks */ +#if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + /* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { +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()); @@ -9695,7 +9854,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* ModuleImport */ - #ifndef __PYX_HAVE_RT_ImportModule +#ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; @@ -9713,7 +9872,7 @@ static PyObject *__Pyx_ImportModule(const char *name) { #endif /* TypeImport */ - #ifndef __PYX_HAVE_RT_ImportType +#ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) @@ -9778,7 +9937,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class #endif /* FunctionImport */ - #ifndef __PYX_HAVE_RT_ImportFunction +#ifndef __PYX_HAVE_RT_ImportFunction #define __PYX_HAVE_RT_ImportFunction static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { PyObject *d = 0; @@ -9832,7 +9991,7 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (** #endif /* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { @@ -9871,46 +10030,53 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#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 && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); #endif +} +#endif +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __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 && #endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -9934,6 +10100,26 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; @@ -9941,9 +10127,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS @@ -9951,32 +10137,30 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } #else - if (m && m->nb_int) { + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); } #endif #else - res = PyNumber_Int(x); + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { diff --git a/ssh2/session.pxd b/ssh2/session.pxd index c7861864..b6bf6cc8 100644 --- a/ssh2/session.pxd +++ b/ssh2/session.pxd @@ -16,8 +16,7 @@ cimport c_ssh2 - cdef class Session: cdef c_ssh2.LIBSSH2_SESSION *_session - cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL - cdef c_ssh2.LIBSSH2_AGENT * _agent_init(self) nogil except NULL + cdef int _sock + cdef object sock diff --git a/ssh2/session.pyx b/ssh2/session.pyx index a70e0b05..13ac571f 100644 --- a/ssh2/session.pyx +++ b/ssh2/session.pyx @@ -17,11 +17,10 @@ from cpython cimport PyObject_AsFileDescriptor from libc.time cimport time_t -from agent cimport PyAgent, auth_identity, clear_agent +from agent cimport PyAgent, agent_auth, agent_init, init_connect_agent from channel cimport PyChannel from exceptions cimport SessionHandshakeError, SessionStartupError, \ - AgentConnectionError, AgentListIdentitiesError, AgentGetIdentityError, \ - AuthenticationError, AgentError + AuthenticationError from listener cimport PyListener from sftp cimport PySFTP from publickey cimport PyPublicKeySystem @@ -37,6 +36,8 @@ cimport c_pkey LIBSSH2_SESSION_BLOCK_INBOUND = c_ssh2.LIBSSH2_SESSION_BLOCK_INBOUND LIBSSH2_SESSION_BLOCK_OUTBOUND = c_ssh2.LIBSSH2_SESSION_BLOCK_OUTBOUND +LIBSSH2_HOSTKEY_HASH_MD5 = c_ssh2.LIBSSH2_HOSTKEY_HASH_MD5 +LIBSSH2_HOSTKEY_HASH_SHA1 = c_ssh2.LIBSSH2_HOSTKEY_HASH_SHA1 cdef class Session: @@ -47,12 +48,16 @@ cdef class Session: self._session = c_ssh2.libssh2_session_init() if self._session is NULL: raise MemoryError + self._sock = 0 + self.sock = None def __dealloc__(self): with nogil: - c_ssh2.libssh2_session_disconnect( - self._session, "end") - c_ssh2.libssh2_session_free(self._session) + if self._session is not NULL: + c_ssh2.libssh2_session_disconnect( + self._session, "end") + c_ssh2.libssh2_session_free(self._session) + self._session = NULL def disconnect(self): with nogil: @@ -71,6 +76,8 @@ cdef class Session: raise SessionHandshakeError( "SSH session handshake failed with error code %s", rc) + self._sock = _sock + self.sock = sock return rc def startup(self, sock): @@ -282,27 +289,9 @@ cdef class Session: """ cdef c_ssh2.LIBSSH2_AGENT *agent with nogil: - agent = self._agent_init() + agent = agent_init(self._session) return PyAgent(agent, self) - cdef c_ssh2.LIBSSH2_AGENT * _agent_init(self) nogil except NULL: - cdef c_ssh2.LIBSSH2_AGENT *agent = c_ssh2.libssh2_agent_init( - self._session) - if agent is NULL: - with gil: - raise AgentError("Error initialising agent") - return agent - - cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL: - cdef c_ssh2.LIBSSH2_AGENT *agent - with nogil: - agent = c_ssh2.libssh2_agent_init(self._session) - if c_ssh2.libssh2_agent_connect(agent) != 0: - with nogil: - c_ssh2.libssh2_agent_free(agent) - raise AgentConnectionError("Unable to connect to agent") - return agent - def agent_auth(self, username not None): """Convenience function for performing user authentication via SSH Agent. @@ -334,20 +323,9 @@ cdef class Session: cdef c_ssh2.LIBSSH2_AGENT *agent = NULL cdef c_ssh2.libssh2_agent_publickey *identity = NULL cdef c_ssh2.libssh2_agent_publickey *prev = NULL - agent = self.init_connect_agent() + agent = init_connect_agent(self._session) with nogil: - if c_ssh2.libssh2_agent_list_identities(agent) != 0: - clear_agent(agent) - with gil: - raise AgentListIdentitiesError( - "Failure requesting identities from agent") - while 1: - auth_identity(_username, agent, &identity, prev) - if c_ssh2.libssh2_agent_userauth( - agent, _username, identity) == 0: - clear_agent(agent) - break - prev = identity + agent_auth(_username, agent) def open_session(self): """Open new channel session. @@ -463,7 +441,7 @@ cdef class Session: :rtype: str """ cdef char **_error_msg = NULL - cdef bytes msg + cdef bytes msg = b'' cdef int errmsg_len = 0 cdef int rc with nogil: @@ -472,10 +450,30 @@ cdef class Session: if errmsg_len > 0 and _error_msg is not NULL: for line in _error_msg[:errmsg_len]: msg += line - else: - msg = b'' return msg + def last_errno(self): + """Retrieve last error message from libssh2, if any. + Returns empty string on no error message. + + :rtype: str + """ + cdef int rc + with nogil: + rc = c_ssh2.libssh2_session_last_errno( + self._session) + return rc + + IF EMBEDDED_LIB: + def set_last_error(self, int errcode, errmsg not None): + cdef bytes b_errmsg = to_bytes(errmsg) + cdef char *_errmsg = b_errmsg + cdef int rc + with nogil: + rc = c_ssh2.libssh2_session_set_last_error( + self._session, errcode, _errmsg) + return rc + def scp_recv(self, path not None): """Receive file via SCP. @@ -566,3 +564,20 @@ cdef class Session: _pkey= c_pkey.libssh2_publickey_init(self._session) if _pkey is not NULL: return PyPublicKeySystem(_pkey, self) + + def hostkey_hash(self, int hash_type): + """Get computed digest of the remote system's host key. + + :param hash_type: One of ``ssh2.session.LIBSSH2_HOSTKEY_HASH_MD5`` or + ``ssh2.session.LIBSSH2_HOSTKEY_HASH_SHA1`` + :type hash_type: int + + :rtype: bytes""" + cdef const char *_hash + cdef bytes b_hash + with nogil: + _hash = c_ssh2.libssh2_hostkey_hash(self._session, hash_type) + if _hash is NULL: + return + b_hash = _hash + return b_hash diff --git a/ssh2/sftp.c b/ssh2/sftp.c index 052bbc22..1ff4de3e 100644 --- a/ssh2/sftp.c +++ b/ssh2/sftp.c @@ -1,13 +1,14 @@ -/* Generated by Cython 0.26 */ +/* Generated by Cython 0.27.1 */ #define PY_SSIZE_T_CLEAN #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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_26" +#define CYTHON_ABI "0_27_1" +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -31,7 +32,7 @@ #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif @@ -47,8 +48,14 @@ #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS @@ -67,6 +74,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -74,6 +85,8 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS @@ -98,6 +111,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -105,6 +122,12 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 @@ -144,6 +167,12 @@ #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -199,6 +228,27 @@ #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ @@ -282,7 +332,6 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject @@ -333,15 +382,17 @@ #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct 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)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) @@ -451,14 +502,6 @@ static CYTHON_INLINE float __PYX_NAN() { __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) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -481,7 +524,7 @@ static CYTHON_INLINE float __PYX_NAN() { #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif @@ -512,8 +555,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #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 (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -535,6 +578,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) @@ -545,16 +594,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #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) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #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 @@ -563,6 +607,8 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) #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_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS @@ -663,7 +709,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime; @@ -684,6 +730,18 @@ static const char *__pyx_f[] = { "ssh2/exceptions.pxd", "ssh2/sftp_handle.pxd", }; +/* NoFastGil.proto */ +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + /*--- Type declarations ---*/ struct __pyx_obj_4ssh2_7session_Session; @@ -699,22 +757,24 @@ struct __pyx_obj_4ssh2_10exceptions_SessionHandshakeError; struct __pyx_obj_4ssh2_10exceptions_ChannelError; struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError; struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall; +struct __pyx_obj_4ssh2_10exceptions_SFTPIOError; struct __pyx_obj_4ssh2_11sftp_handle_SFTPHandle; struct __pyx_obj_4ssh2_11sftp_handle_SFTPAttributes; struct __pyx_obj_4ssh2_11sftp_handle_SFTPStatVFS; struct __pyx_obj_4ssh2_4sftp_SFTP; -/* "session.pxd":20 - * +/* "session.pxd":19 + * cimport c_ssh2 * * cdef class Session: # <<<<<<<<<<<<<< * cdef c_ssh2.LIBSSH2_SESSION *_session - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL + * cdef int _sock */ struct __pyx_obj_4ssh2_7session_Session { PyObject_HEAD - struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtab; LIBSSH2_SESSION *_session; + int _sock; + PyObject *sock; }; @@ -857,12 +917,24 @@ struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError { * * cdef class SFTPBufferTooSmall(Exception): # <<<<<<<<<<<<<< * pass + * */ struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall { PyBaseExceptionObject __pyx_base; }; +/* "exceptions.pxd":62 + * + * + * cdef class SFTPIOError(Exception): # <<<<<<<<<<<<<< + * pass + */ +struct __pyx_obj_4ssh2_10exceptions_SFTPIOError { + PyBaseExceptionObject __pyx_base; +}; + + /* "sftp_handle.pxd":25 * * @@ -919,21 +991,6 @@ struct __pyx_obj_4ssh2_4sftp_SFTP { }; - -/* "session.pxd":20 - * - * - * cdef class Session: # <<<<<<<<<<<<<< - * cdef c_ssh2.LIBSSH2_SESSION *_session - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL - */ - -struct __pyx_vtabstruct_4ssh2_7session_Session { - LIBSSH2_AGENT *(*init_connect_agent)(struct __pyx_obj_4ssh2_7session_Session *); - LIBSSH2_AGENT *(*_agent_init)(struct __pyx_obj_4ssh2_7session_Session *); -}; -static struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtabptr_4ssh2_7session_Session; - /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY @@ -1039,36 +1096,34 @@ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, /* ExtTypeTest.proto */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); -/* NoFastGil.proto */ -#define __Pyx_PyGILState_Ensure PyGILState_Ensure -#define __Pyx_PyGILState_Release PyGILState_Release -#define __Pyx_FastGIL_Remember() -#define __Pyx_FastGIL_Forget() -#define __Pyx_FastGilFuncInit() - -/* ForceInitThreads.proto */ -#ifndef __PYX_FORCE_INIT_THREADS - #define __PYX_FORCE_INIT_THREADS 0 -#endif - /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #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); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif #else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #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) @@ -1079,8 +1134,10 @@ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /* ArgTypeTest.proto */ -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); +#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ + ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ + __Pyx__ArgTypeTest(obj, type, name, exact)) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* GetException.proto */ #if CYTHON_FAST_THREAD_STATE @@ -1112,9 +1169,6 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject /* SetupReduce.proto */ static int __Pyx_setup_reduce(PyObject* type_obj); -/* GetVTable.proto */ -static void* __Pyx_GetVtable(PyObject *dict); - /* CLineInTraceback.proto */ static int __Pyx_CLineForTraceback(int c_line); @@ -1161,6 +1215,18 @@ static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif + /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); @@ -1230,6 +1296,7 @@ static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SessionHandshakeError = 0; static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_ChannelError = 0; static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPHandleError = 0; static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPIOError = 0; /* Module declarations from 'ssh2.sftp_handle' */ static PyTypeObject *__pyx_ptype_4ssh2_11sftp_handle_SFTPHandle = 0; @@ -1247,17 +1314,21 @@ static PyObject *__pyx_builtin_MemoryError; static PyObject *__pyx_builtin_TypeError; static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_mode[] = "mode"; +static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_path[] = "path"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_attrs[] = "attrs"; static const char __pyx_k_flags[] = "flags"; +static const char __pyx_k_reduce[] = "__reduce__"; static const char __pyx_k_target[] = "target"; static const char __pyx_k_max_len[] = "max_len"; static const char __pyx_k_session[] = "session"; static const char __pyx_k_filename[] = "filename"; +static const char __pyx_k_getstate[] = "__getstate__"; +static const char __pyx_k_setstate[] = "__setstate__"; static const char __pyx_k_TypeError[] = "TypeError"; static const char __pyx_k_open_type[] = "open_type"; -static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; +static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; static const char __pyx_k_MemoryError[] = "MemoryError"; static const char __pyx_k_filename_len[] = "filename_len"; static const char __pyx_k_dest_filename[] = "dest_filename"; @@ -1289,10 +1360,12 @@ static const char __pyx_k_LIBSSH2_SFTP_ST_NOSUID[] = "LIBSSH2_SFTP_ST_NOSUID"; static const char __pyx_k_LIBSSH2_SFTP_ST_RDONLY[] = "LIBSSH2_SFTP_ST_RDONLY"; static const char __pyx_k_SFTP_channel_handle_and_attribu[] = "\nSFTP channel, handle and attributes classes and related SFTP flags.\n\nFile transfer flags\n--------------------\n:var LIBSSH2_FXF_READ: File read flag\n:var LIBSSH2_FXF_WRITE: File write flag\n:var LIBSSH2_FXF_APPEND: File append flag\n:var LIBSSH2_FXF_CREAT: File create flag\n:var LIBSSH2_FXF_TRUNC: File truncate flag\n:var LIBSSH2_FXF_EXCL: Exclusive file flag\n\nFile mode masks\n-----------------\n\nOwner masks\n_____________\n\n:var LIBSSH2_SFTP_S_IRWXU: Read/write/execute\n:var LIBSSH2_SFTP_S_IRUSR: Read\n:var LIBSSH2_SFTP_S_IWUSR: Write\n:var LIBSSH2_SFTP_S_IXUSR: Execute\n\nGroup masks\n____________\n\n:var LIBSSH2_SFTP_S_IRWXG: Read/write/execute\n:var LIBSSH2_SFTP_S_IRGRP: Read\n:var LIBSSH2_SFTP_S_IWUSR: Write\n:var LIBSSH2_SFTP_S_IXUSR: Execute\n\nOther masks\n____________\n\n:var LIBSSH2_SFTP_S_IRWXO: Read/write/execute\n:var LIBSSH2_SFTP_S_IROTH: Read\n:var LIBSSH2_SFTP_S_IWOTH: Write\n:var LIBSSH2_SFTP_S_IXOTH: Execute\n"; static const char __pyx_k_Buffer_too_small_to_fit_realpath[] = "Buffer too small to fit realpath for %s - max size %s. Error code %s"; +static const char __pyx_k_Error_creating_directory_s_error[] = "Error creating directory %s - error code %s"; static const char __pyx_k_Error_getting_real_path_for_s_er[] = "Error getting real path for %s - error code %s"; static const char __pyx_k_Error_with_stat_on_file_s_code_s[] = "Error with stat on file %s - code %s"; static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; static PyObject *__pyx_kp_s_Buffer_too_small_to_fit_realpath; +static PyObject *__pyx_kp_s_Error_creating_directory_s_error; static PyObject *__pyx_kp_s_Error_getting_real_path_for_s_er; static PyObject *__pyx_kp_s_Error_with_stat_on_file_s_code_s; static PyObject *__pyx_n_s_LIBSSH2_FXF_APPEND; @@ -1324,15 +1397,19 @@ static PyObject *__pyx_n_s_dest_filename_len; static PyObject *__pyx_n_s_filename; static PyObject *__pyx_n_s_filename_len; static PyObject *__pyx_n_s_flags; +static PyObject *__pyx_n_s_getstate; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_max_len; static PyObject *__pyx_n_s_mode; +static PyObject *__pyx_n_s_name; static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; static PyObject *__pyx_n_s_open_type; static PyObject *__pyx_n_s_path; -static PyObject *__pyx_n_s_pyx_vtable; +static PyObject *__pyx_n_s_reduce; static PyObject *__pyx_n_s_reduce_cython; +static PyObject *__pyx_n_s_reduce_ex; static PyObject *__pyx_n_s_session; +static PyObject *__pyx_n_s_setstate; static PyObject *__pyx_n_s_setstate_cython; static PyObject *__pyx_n_s_source_filename; static PyObject *__pyx_n_s_source_filename_len; @@ -2117,7 +2194,11 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_8open(struct __pyx_obj_4ssh2_4sftp_S * with nogil: * _handle = c_sftp.libssh2_sftp_open( */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 182, __pyx_L1_error) + if (unlikely(__pyx_v_b_filename == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 182, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 182, __pyx_L1_error) __pyx_v__filename = __pyx_t_2; /* "ssh2/sftp.pyx":183 @@ -2287,7 +2368,11 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_10opendir(struct __pyx_obj_4ssh2_4sf * with nogil: * _handle = c_sftp.libssh2_sftp_opendir(self._sftp, _path) */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 199, __pyx_L1_error) + if (unlikely(__pyx_v_b_path == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 199, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 199, __pyx_L1_error) __pyx_v__path = __pyx_t_2; /* "ssh2/sftp.pyx":200 @@ -2708,7 +2793,11 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_14rename(struct __pyx_obj_4ssh2_4sft * cdef char *_dest_filename = b_dest_filename * with nogil: */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_source_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 228, __pyx_L1_error) + if (unlikely(__pyx_v_b_source_filename == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 228, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_source_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 228, __pyx_L1_error) __pyx_v__source_filename = __pyx_t_2; /* "ssh2/sftp.pyx":229 @@ -2718,7 +2807,11 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_14rename(struct __pyx_obj_4ssh2_4sft * with nogil: * rc = c_sftp.libssh2_sftp_rename( */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_dest_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 229, __pyx_L1_error) + if (unlikely(__pyx_v_b_dest_filename == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 229, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_dest_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 229, __pyx_L1_error) __pyx_v__dest_filename = __pyx_t_2; /* "ssh2/sftp.pyx":230 @@ -2858,7 +2951,11 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_16unlink(struct __pyx_obj_4ssh2_4sft * with nogil: * rc = c_sftp.libssh2_sftp_unlink(self._sftp, _filename) */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 242, __pyx_L1_error) + if (unlikely(__pyx_v_b_filename == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 242, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 242, __pyx_L1_error) __pyx_v__filename = __pyx_t_2; /* "ssh2/sftp.pyx":243 @@ -3013,7 +3110,11 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_18statvfs(struct __pyx_obj_4ssh2_4sf * cdef size_t path_len = len(b_path) * with nogil: */ - __pyx_t_3 = __Pyx_PyObject_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 253, __pyx_L1_error) + if (unlikely(__pyx_v_b_path == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 253, __pyx_L1_error) + } + __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 253, __pyx_L1_error) __pyx_v__path = __pyx_t_3; /* "ssh2/sftp.pyx":254 @@ -3027,7 +3128,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_18statvfs(struct __pyx_obj_4ssh2_4sf PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 254, __pyx_L1_error) } - __pyx_t_4 = PyBytes_GET_SIZE(__pyx_v_b_path); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 254, __pyx_L1_error) + __pyx_t_4 = PyBytes_GET_SIZE(__pyx_v_b_path); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 254, __pyx_L1_error) __pyx_v_path_len = __pyx_t_4; /* "ssh2/sftp.pyx":255 @@ -3220,29 +3321,48 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_21mkdir(PyObject *__pyx_v_self, PyOb static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_20mkdir(struct __pyx_obj_4ssh2_4sftp_SFTP *__pyx_v_self, PyObject *__pyx_v_path, long __pyx_v_mode) { int __pyx_v_rc; + PyObject *__pyx_v_b_path = 0; char *__pyx_v__path; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - char *__pyx_t_1; - PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_1 = NULL; + char *__pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("mkdir", 0); /* "ssh2/sftp.pyx":272 * :rtype: int""" * cdef int rc - * cdef char *_path = path # <<<<<<<<<<<<<< + * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< + * cdef char *_path = b_path * with nogil: - * rc = c_sftp.libssh2_sftp_mkdir(self._sftp, _path, mode) */ - __pyx_t_1 = __Pyx_PyObject_AsWritableString(__pyx_v_path); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 272, __pyx_L1_error) - __pyx_v__path = __pyx_t_1; + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_b_path = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; /* "ssh2/sftp.pyx":273 * cdef int rc - * cdef char *_path = path + * cdef bytes b_path = to_bytes(path) + * cdef char *_path = b_path # <<<<<<<<<<<<<< + * with nogil: + * rc = c_sftp.libssh2_sftp_mkdir(self._sftp, _path, mode) + */ + if (unlikely(__pyx_v_b_path == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 273, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 273, __pyx_L1_error) + __pyx_v__path = __pyx_t_2; + + /* "ssh2/sftp.pyx":274 + * cdef bytes b_path = to_bytes(path) + * cdef char *_path = b_path * with nogil: # <<<<<<<<<<<<<< * rc = c_sftp.libssh2_sftp_mkdir(self._sftp, _path, mode) - * return rc + * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: */ { #ifdef WITH_THREAD @@ -3252,22 +3372,115 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_20mkdir(struct __pyx_obj_4ssh2_4sftp #endif /*try:*/ { - /* "ssh2/sftp.pyx":274 - * cdef char *_path = path + /* "ssh2/sftp.pyx":275 + * cdef char *_path = b_path * with nogil: * rc = c_sftp.libssh2_sftp_mkdir(self._sftp, _path, mode) # <<<<<<<<<<<<<< + * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * with gil: + */ + __pyx_v_rc = libssh2_sftp_mkdir(__pyx_v_self->_sftp, __pyx_v__path, __pyx_v_mode); + + /* "ssh2/sftp.pyx":276 + * with nogil: + * rc = c_sftp.libssh2_sftp_mkdir(self._sftp, _path, mode) + * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * with gil: + * raise SFTPIOError( + */ + switch (__pyx_v_rc) { + case 0: + case LIBSSH2_ERROR_EAGAIN: + __pyx_t_3 = 0; + break; + default: + __pyx_t_3 = 1; + break; + } + if (__pyx_t_3) { + + /* "ssh2/sftp.pyx":277 + * rc = c_sftp.libssh2_sftp_mkdir(self._sftp, _path, mode) + * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * with gil: # <<<<<<<<<<<<<< + * raise SFTPIOError( + * "Error creating directory %s - error code %s", + */ + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + /*try:*/ { + + /* "ssh2/sftp.pyx":280 + * raise SFTPIOError( + * "Error creating directory %s - error code %s", + * path, rc) # <<<<<<<<<<<<<< * return rc * */ - __pyx_v_rc = libssh2_sftp_mkdir(__pyx_v_self->_sftp, __pyx_v__path, __pyx_v_mode); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L8_error) + __Pyx_GOTREF(__pyx_t_1); + + /* "ssh2/sftp.pyx":278 + * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * with gil: + * raise SFTPIOError( # <<<<<<<<<<<<<< + * "Error creating directory %s - error code %s", + * path, rc) + */ + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L8_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_kp_s_Error_creating_directory_s_error); + __Pyx_GIVEREF(__pyx_kp_s_Error_creating_directory_s_error); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_s_Error_creating_directory_s_error); + __Pyx_INCREF(__pyx_v_path); + __Pyx_GIVEREF(__pyx_v_path); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_path); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_SFTPIOError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L8_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(0, 278, __pyx_L8_error) + } + + /* "ssh2/sftp.pyx":277 + * rc = c_sftp.libssh2_sftp_mkdir(self._sftp, _path, mode) + * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * with gil: # <<<<<<<<<<<<<< + * raise SFTPIOError( + * "Error creating directory %s - error code %s", + */ + /*finally:*/ { + __pyx_L8_error: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L4_error; + } + } + } + + /* "ssh2/sftp.pyx":276 + * with nogil: + * rc = c_sftp.libssh2_sftp_mkdir(self._sftp, _path, mode) + * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * with gil: + * raise SFTPIOError( + */ + } } - /* "ssh2/sftp.pyx":273 - * cdef int rc - * cdef char *_path = path + /* "ssh2/sftp.pyx":274 + * cdef bytes b_path = to_bytes(path) + * cdef char *_path = b_path * with nogil: # <<<<<<<<<<<<<< * rc = c_sftp.libssh2_sftp_mkdir(self._sftp, _path, mode) - * return rc + * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: */ /*finally:*/ { /*normal exit:*/{ @@ -3277,22 +3490,29 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_20mkdir(struct __pyx_obj_4ssh2_4sftp #endif goto __pyx_L5; } + __pyx_L4_error: { + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L1_error; + } __pyx_L5:; } } - /* "ssh2/sftp.pyx":275 - * with nogil: - * rc = c_sftp.libssh2_sftp_mkdir(self._sftp, _path, mode) + /* "ssh2/sftp.pyx":281 + * "Error creating directory %s - error code %s", + * path, rc) * return rc # <<<<<<<<<<<<<< * * def rmdir(self, path not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 275, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; goto __pyx_L0; /* "ssh2/sftp.pyx":262 @@ -3305,16 +3525,18 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_20mkdir(struct __pyx_obj_4ssh2_4sftp /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("ssh2.sftp.SFTP.mkdir", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_b_path); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "ssh2/sftp.pyx":277 +/* "ssh2/sftp.pyx":283 * return rc * * def rmdir(self, path not None): # <<<<<<<<<<<<<< @@ -3330,7 +3552,7 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_23rmdir(PyObject *__pyx_v_self, PyOb __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rmdir (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 277, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 283, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_22rmdir(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), ((PyObject *)__pyx_v_path)); @@ -3353,29 +3575,33 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_22rmdir(struct __pyx_obj_4ssh2_4sftp char *__pyx_t_2; __Pyx_RefNannySetupContext("rmdir", 0); - /* "ssh2/sftp.pyx":285 + /* "ssh2/sftp.pyx":291 * :rtype: int""" * cdef int rc * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":286 + /* "ssh2/sftp.pyx":292 * cdef int rc * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< * with nogil: * rc = c_sftp.libssh2_sftp_rmdir(self._sftp, _path) */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 286, __pyx_L1_error) + if (unlikely(__pyx_v_b_path == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 292, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 292, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/sftp.pyx":287 + /* "ssh2/sftp.pyx":293 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * with nogil: # <<<<<<<<<<<<<< @@ -3390,7 +3616,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_22rmdir(struct __pyx_obj_4ssh2_4sftp #endif /*try:*/ { - /* "ssh2/sftp.pyx":288 + /* "ssh2/sftp.pyx":294 * cdef char *_path = b_path * with nogil: * rc = c_sftp.libssh2_sftp_rmdir(self._sftp, _path) # <<<<<<<<<<<<<< @@ -3400,7 +3626,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_22rmdir(struct __pyx_obj_4ssh2_4sftp __pyx_v_rc = libssh2_sftp_rmdir(__pyx_v_self->_sftp, __pyx_v__path); } - /* "ssh2/sftp.pyx":287 + /* "ssh2/sftp.pyx":293 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * with nogil: # <<<<<<<<<<<<<< @@ -3419,7 +3645,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_22rmdir(struct __pyx_obj_4ssh2_4sftp } } - /* "ssh2/sftp.pyx":289 + /* "ssh2/sftp.pyx":295 * with nogil: * rc = c_sftp.libssh2_sftp_rmdir(self._sftp, _path) * return rc # <<<<<<<<<<<<<< @@ -3427,13 +3653,13 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_22rmdir(struct __pyx_obj_4ssh2_4sftp * def stat(self, path not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":277 + /* "ssh2/sftp.pyx":283 * return rc * * def rmdir(self, path not None): # <<<<<<<<<<<<<< @@ -3453,7 +3679,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_22rmdir(struct __pyx_obj_4ssh2_4sftp return __pyx_r; } -/* "ssh2/sftp.pyx":291 +/* "ssh2/sftp.pyx":297 * return rc * * def stat(self, path not None): # <<<<<<<<<<<<<< @@ -3469,7 +3695,7 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_25stat(PyObject *__pyx_v_self, PyObj __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stat (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 291, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 297, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_24stat(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), ((PyObject *)__pyx_v_path)); @@ -3495,41 +3721,45 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("stat", 0); - /* "ssh2/sftp.pyx":299 + /* "ssh2/sftp.pyx":305 * :rtype: :py:class:`ssh2.sftp.SFTPAttributes` or LIBSSH2_ERROR_EAGAIN""" * cdef int rc * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":300 + /* "ssh2/sftp.pyx":306 * cdef int rc * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 300, __pyx_L1_error) + if (unlikely(__pyx_v_b_path == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 306, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 306, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/sftp.pyx":301 + /* "ssh2/sftp.pyx":307 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() # <<<<<<<<<<<<<< * with nogil: * rc = c_sftp.libssh2_sftp_stat( */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_attrs = ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPAttributes *)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":302 + /* "ssh2/sftp.pyx":308 * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: # <<<<<<<<<<<<<< @@ -3544,7 +3774,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ #endif /*try:*/ { - /* "ssh2/sftp.pyx":303 + /* "ssh2/sftp.pyx":309 * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: * rc = c_sftp.libssh2_sftp_stat( # <<<<<<<<<<<<<< @@ -3553,7 +3783,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ */ __pyx_v_rc = libssh2_sftp_stat(__pyx_v_self->_sftp, __pyx_v__path, __pyx_v_attrs->_attrs); - /* "ssh2/sftp.pyx":305 + /* "ssh2/sftp.pyx":311 * rc = c_sftp.libssh2_sftp_stat( * self._sftp, _path, attrs._attrs) * if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc != 0: # <<<<<<<<<<<<<< @@ -3571,7 +3801,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ } if (__pyx_t_3) { - /* "ssh2/sftp.pyx":306 + /* "ssh2/sftp.pyx":312 * self._sftp, _path, attrs._attrs) * if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc != 0: * with gil: # <<<<<<<<<<<<<< @@ -3584,24 +3814,24 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ #endif /*try:*/ { - /* "ssh2/sftp.pyx":309 + /* "ssh2/sftp.pyx":315 * raise SFTPHandleError( * "Error with stat on file %s - code %s", * path, rc) # <<<<<<<<<<<<<< * if rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: * return rc */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L8_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 315, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); - /* "ssh2/sftp.pyx":307 + /* "ssh2/sftp.pyx":313 * if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc != 0: * with gil: * raise SFTPHandleError( # <<<<<<<<<<<<<< * "Error with stat on file %s - code %s", * path, rc) */ - __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 307, __pyx_L8_error) + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 313, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_kp_s_Error_with_stat_on_file_s_code_s); __Pyx_GIVEREF(__pyx_kp_s_Error_with_stat_on_file_s_code_s); @@ -3612,15 +3842,15 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_SFTPHandleError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L8_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_SFTPHandleError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 307, __pyx_L8_error) + __PYX_ERR(0, 313, __pyx_L8_error) } - /* "ssh2/sftp.pyx":306 + /* "ssh2/sftp.pyx":312 * self._sftp, _path, attrs._attrs) * if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc != 0: * with gil: # <<<<<<<<<<<<<< @@ -3637,7 +3867,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ } } - /* "ssh2/sftp.pyx":305 + /* "ssh2/sftp.pyx":311 * rc = c_sftp.libssh2_sftp_stat( * self._sftp, _path, attrs._attrs) * if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc != 0: # <<<<<<<<<<<<<< @@ -3647,7 +3877,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ } } - /* "ssh2/sftp.pyx":302 + /* "ssh2/sftp.pyx":308 * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: # <<<<<<<<<<<<<< @@ -3673,7 +3903,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ } } - /* "ssh2/sftp.pyx":310 + /* "ssh2/sftp.pyx":316 * "Error with stat on file %s - code %s", * path, rc) * if rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -3683,7 +3913,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ __pyx_t_3 = ((__pyx_v_rc == LIBSSH2_ERROR_EAGAIN) != 0); if (__pyx_t_3) { - /* "ssh2/sftp.pyx":311 + /* "ssh2/sftp.pyx":317 * path, rc) * if rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: * return rc # <<<<<<<<<<<<<< @@ -3691,13 +3921,13 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 311, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":310 + /* "ssh2/sftp.pyx":316 * "Error with stat on file %s - code %s", * path, rc) * if rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -3706,7 +3936,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ */ } - /* "ssh2/sftp.pyx":312 + /* "ssh2/sftp.pyx":318 * if rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: * return rc * return attrs # <<<<<<<<<<<<<< @@ -3718,7 +3948,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ __pyx_r = ((PyObject *)__pyx_v_attrs); goto __pyx_L0; - /* "ssh2/sftp.pyx":291 + /* "ssh2/sftp.pyx":297 * return rc * * def stat(self, path not None): # <<<<<<<<<<<<<< @@ -3740,7 +3970,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ return __pyx_r; } -/* "ssh2/sftp.pyx":314 +/* "ssh2/sftp.pyx":320 * return attrs * * def lstat(self, path not None): # <<<<<<<<<<<<<< @@ -3756,7 +3986,7 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_27lstat(PyObject *__pyx_v_self, PyOb __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("lstat (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 314, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 320, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_26lstat(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), ((PyObject *)__pyx_v_path)); @@ -3782,41 +4012,45 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("lstat", 0); - /* "ssh2/sftp.pyx":317 + /* "ssh2/sftp.pyx":323 * """Link stat a file.""" * cdef int rc * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":318 + /* "ssh2/sftp.pyx":324 * cdef int rc * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 318, __pyx_L1_error) + if (unlikely(__pyx_v_b_path == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 324, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 324, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/sftp.pyx":319 + /* "ssh2/sftp.pyx":325 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() # <<<<<<<<<<<<<< * with nogil: * rc = c_sftp.libssh2_sftp_lstat( */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 319, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_attrs = ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPAttributes *)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":320 + /* "ssh2/sftp.pyx":326 * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: # <<<<<<<<<<<<<< @@ -3831,7 +4065,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp #endif /*try:*/ { - /* "ssh2/sftp.pyx":321 + /* "ssh2/sftp.pyx":327 * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: * rc = c_sftp.libssh2_sftp_lstat( # <<<<<<<<<<<<<< @@ -3840,7 +4074,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp */ __pyx_v_rc = libssh2_sftp_lstat(__pyx_v_self->_sftp, __pyx_v__path, __pyx_v_attrs->_attrs); - /* "ssh2/sftp.pyx":323 + /* "ssh2/sftp.pyx":329 * rc = c_sftp.libssh2_sftp_lstat( * self._sftp, _path, attrs._attrs) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -3858,7 +4092,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp } if (__pyx_t_3) { - /* "ssh2/sftp.pyx":324 + /* "ssh2/sftp.pyx":330 * self._sftp, _path, attrs._attrs) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -3871,24 +4105,24 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp #endif /*try:*/ { - /* "ssh2/sftp.pyx":327 + /* "ssh2/sftp.pyx":333 * raise SFTPHandleError( * "Error with stat on file %s - code %s", * path, rc) # <<<<<<<<<<<<<< * if rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: * return rc */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 327, __pyx_L8_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); - /* "ssh2/sftp.pyx":325 + /* "ssh2/sftp.pyx":331 * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: * raise SFTPHandleError( # <<<<<<<<<<<<<< * "Error with stat on file %s - code %s", * path, rc) */ - __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 325, __pyx_L8_error) + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 331, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_kp_s_Error_with_stat_on_file_s_code_s); __Pyx_GIVEREF(__pyx_kp_s_Error_with_stat_on_file_s_code_s); @@ -3899,15 +4133,15 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_SFTPHandleError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L8_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_SFTPHandleError), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 325, __pyx_L8_error) + __PYX_ERR(0, 331, __pyx_L8_error) } - /* "ssh2/sftp.pyx":324 + /* "ssh2/sftp.pyx":330 * self._sftp, _path, attrs._attrs) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -3924,7 +4158,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp } } - /* "ssh2/sftp.pyx":323 + /* "ssh2/sftp.pyx":329 * rc = c_sftp.libssh2_sftp_lstat( * self._sftp, _path, attrs._attrs) * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -3934,7 +4168,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp } } - /* "ssh2/sftp.pyx":320 + /* "ssh2/sftp.pyx":326 * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: # <<<<<<<<<<<<<< @@ -3960,7 +4194,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp } } - /* "ssh2/sftp.pyx":328 + /* "ssh2/sftp.pyx":334 * "Error with stat on file %s - code %s", * path, rc) * if rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -3970,7 +4204,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp __pyx_t_3 = ((__pyx_v_rc == LIBSSH2_ERROR_EAGAIN) != 0); if (__pyx_t_3) { - /* "ssh2/sftp.pyx":329 + /* "ssh2/sftp.pyx":335 * path, rc) * if rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: * return rc # <<<<<<<<<<<<<< @@ -3978,13 +4212,13 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 329, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 335, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":328 + /* "ssh2/sftp.pyx":334 * "Error with stat on file %s - code %s", * path, rc) * if rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -3993,7 +4227,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp */ } - /* "ssh2/sftp.pyx":330 + /* "ssh2/sftp.pyx":336 * if rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: * return rc * return attrs # <<<<<<<<<<<<<< @@ -4005,7 +4239,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp __pyx_r = ((PyObject *)__pyx_v_attrs); goto __pyx_L0; - /* "ssh2/sftp.pyx":314 + /* "ssh2/sftp.pyx":320 * return attrs * * def lstat(self, path not None): # <<<<<<<<<<<<<< @@ -4027,7 +4261,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp return __pyx_r; } -/* "ssh2/sftp.pyx":332 +/* "ssh2/sftp.pyx":338 * return attrs * * def setstat(self, path not None, SFTPAttributes attrs): # <<<<<<<<<<<<<< @@ -4067,11 +4301,11 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_29setstat(PyObject *__pyx_v_self, Py case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_attrs)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("setstat", 1, 2, 2, 1); __PYX_ERR(0, 332, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("setstat", 1, 2, 2, 1); __PYX_ERR(0, 338, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "setstat") < 0)) __PYX_ERR(0, 332, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "setstat") < 0)) __PYX_ERR(0, 338, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -4084,16 +4318,16 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_29setstat(PyObject *__pyx_v_self, Py } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("setstat", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 332, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("setstat", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 338, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp.SFTP.setstat", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 332, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 338, __pyx_L1_error) } - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_attrs), __pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes, 1, "attrs", 0))) __PYX_ERR(0, 332, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_attrs), __pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes, 1, "attrs", 0))) __PYX_ERR(0, 338, __pyx_L1_error) __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_28setstat(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), __pyx_v_path, __pyx_v_attrs); /* function exit code */ @@ -4115,29 +4349,33 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_28setstat(struct __pyx_obj_4ssh2_4sf char *__pyx_t_2; __Pyx_RefNannySetupContext("setstat", 0); - /* "ssh2/sftp.pyx":342 + /* "ssh2/sftp.pyx":348 * :rtype: int""" * cdef int rc * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 342, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":343 + /* "ssh2/sftp.pyx":349 * cdef int rc * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< * with nogil: * rc = c_sftp.libssh2_sftp_setstat( */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 343, __pyx_L1_error) + if (unlikely(__pyx_v_b_path == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 349, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 349, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/sftp.pyx":344 + /* "ssh2/sftp.pyx":350 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * with nogil: # <<<<<<<<<<<<<< @@ -4152,7 +4390,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_28setstat(struct __pyx_obj_4ssh2_4sf #endif /*try:*/ { - /* "ssh2/sftp.pyx":345 + /* "ssh2/sftp.pyx":351 * cdef char *_path = b_path * with nogil: * rc = c_sftp.libssh2_sftp_setstat( # <<<<<<<<<<<<<< @@ -4162,7 +4400,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_28setstat(struct __pyx_obj_4ssh2_4sf __pyx_v_rc = libssh2_sftp_setstat(__pyx_v_self->_sftp, __pyx_v__path, __pyx_v_attrs->_attrs); } - /* "ssh2/sftp.pyx":344 + /* "ssh2/sftp.pyx":350 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * with nogil: # <<<<<<<<<<<<<< @@ -4181,7 +4419,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_28setstat(struct __pyx_obj_4ssh2_4sf } } - /* "ssh2/sftp.pyx":347 + /* "ssh2/sftp.pyx":353 * rc = c_sftp.libssh2_sftp_setstat( * self._sftp, _path, attrs._attrs) * return rc # <<<<<<<<<<<<<< @@ -4189,13 +4427,13 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_28setstat(struct __pyx_obj_4ssh2_4sf * def symlink(self, path not None, target not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":332 + /* "ssh2/sftp.pyx":338 * return attrs * * def setstat(self, path not None, SFTPAttributes attrs): # <<<<<<<<<<<<<< @@ -4215,7 +4453,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_28setstat(struct __pyx_obj_4ssh2_4sf return __pyx_r; } -/* "ssh2/sftp.pyx":349 +/* "ssh2/sftp.pyx":355 * return rc * * def symlink(self, path not None, target not None): # <<<<<<<<<<<<<< @@ -4255,11 +4493,11 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_31symlink(PyObject *__pyx_v_self, Py case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_target)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("symlink", 1, 2, 2, 1); __PYX_ERR(0, 349, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("symlink", 1, 2, 2, 1); __PYX_ERR(0, 355, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "symlink") < 0)) __PYX_ERR(0, 349, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "symlink") < 0)) __PYX_ERR(0, 355, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -4272,17 +4510,17 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_31symlink(PyObject *__pyx_v_self, Py } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("symlink", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 349, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("symlink", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 355, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp.SFTP.symlink", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 349, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 355, __pyx_L1_error) } if (unlikely(((PyObject *)__pyx_v_target) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "target"); __PYX_ERR(0, 349, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "target"); __PYX_ERR(0, 355, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_30symlink(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), __pyx_v_path, __pyx_v_target); @@ -4307,51 +4545,59 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_30symlink(struct __pyx_obj_4ssh2_4sf char *__pyx_t_2; __Pyx_RefNannySetupContext("symlink", 0); - /* "ssh2/sftp.pyx":359 + /* "ssh2/sftp.pyx":365 * :rtype: int""" * cdef int rc * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * cdef bytes b_target = to_bytes(target) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":360 + /* "ssh2/sftp.pyx":366 * cdef int rc * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< * cdef bytes b_target = to_bytes(target) * cdef char *_target = b_target */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 360, __pyx_L1_error) + if (unlikely(__pyx_v_b_path == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 366, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 366, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/sftp.pyx":361 + /* "ssh2/sftp.pyx":367 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * cdef bytes b_target = to_bytes(target) # <<<<<<<<<<<<<< * cdef char *_target = b_target * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_target); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_target); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_target = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":362 + /* "ssh2/sftp.pyx":368 * cdef char *_path = b_path * cdef bytes b_target = to_bytes(target) * cdef char *_target = b_target # <<<<<<<<<<<<<< * with nogil: * rc = c_sftp.libssh2_sftp_symlink(self._sftp, _path, _target) */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_b_target); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 362, __pyx_L1_error) + if (unlikely(__pyx_v_b_target == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 368, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_target); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 368, __pyx_L1_error) __pyx_v__target = __pyx_t_2; - /* "ssh2/sftp.pyx":363 + /* "ssh2/sftp.pyx":369 * cdef bytes b_target = to_bytes(target) * cdef char *_target = b_target * with nogil: # <<<<<<<<<<<<<< @@ -4366,7 +4612,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_30symlink(struct __pyx_obj_4ssh2_4sf #endif /*try:*/ { - /* "ssh2/sftp.pyx":364 + /* "ssh2/sftp.pyx":370 * cdef char *_target = b_target * with nogil: * rc = c_sftp.libssh2_sftp_symlink(self._sftp, _path, _target) # <<<<<<<<<<<<<< @@ -4376,7 +4622,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_30symlink(struct __pyx_obj_4ssh2_4sf __pyx_v_rc = libssh2_sftp_symlink(__pyx_v_self->_sftp, __pyx_v__path, __pyx_v__target); } - /* "ssh2/sftp.pyx":363 + /* "ssh2/sftp.pyx":369 * cdef bytes b_target = to_bytes(target) * cdef char *_target = b_target * with nogil: # <<<<<<<<<<<<<< @@ -4395,7 +4641,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_30symlink(struct __pyx_obj_4ssh2_4sf } } - /* "ssh2/sftp.pyx":365 + /* "ssh2/sftp.pyx":371 * with nogil: * rc = c_sftp.libssh2_sftp_symlink(self._sftp, _path, _target) * return rc # <<<<<<<<<<<<<< @@ -4403,13 +4649,13 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_30symlink(struct __pyx_obj_4ssh2_4sf * def realpath(self, path not None, size_t max_len=256): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":349 + /* "ssh2/sftp.pyx":355 * return rc * * def symlink(self, path not None, target not None): # <<<<<<<<<<<<<< @@ -4430,7 +4676,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_30symlink(struct __pyx_obj_4ssh2_4sf return __pyx_r; } -/* "ssh2/sftp.pyx":367 +/* "ssh2/sftp.pyx":373 * return rc * * def realpath(self, path not None, size_t max_len=256): # <<<<<<<<<<<<<< @@ -4474,7 +4720,7 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_33realpath(PyObject *__pyx_v_self, P } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "realpath") < 0)) __PYX_ERR(0, 367, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "realpath") < 0)) __PYX_ERR(0, 373, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -4487,21 +4733,21 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_33realpath(PyObject *__pyx_v_self, P } __pyx_v_path = values[0]; if (values[1]) { - __pyx_v_max_len = __Pyx_PyInt_As_size_t(values[1]); if (unlikely((__pyx_v_max_len == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 367, __pyx_L3_error) + __pyx_v_max_len = __Pyx_PyInt_As_size_t(values[1]); if (unlikely((__pyx_v_max_len == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 373, __pyx_L3_error) } else { __pyx_v_max_len = ((size_t)0x100); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("realpath", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 367, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("realpath", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 373, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp.SFTP.realpath", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 367, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 373, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_32realpath(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), __pyx_v_path, __pyx_v_max_len); @@ -4539,7 +4785,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s PyObject *__pyx_t_15 = NULL; __Pyx_RefNannySetupContext("realpath", 0); - /* "ssh2/sftp.pyx":379 + /* "ssh2/sftp.pyx":385 * :raises: :py:class:`ssh2.exceptions.SFTPBufferTooSmall` on max_len less * than real path length.""" * cdef char *_target = malloc(sizeof(char)*max_len) # <<<<<<<<<<<<<< @@ -4548,7 +4794,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s */ __pyx_v__target = ((char *)malloc(((sizeof(char)) * __pyx_v_max_len))); - /* "ssh2/sftp.pyx":380 + /* "ssh2/sftp.pyx":386 * than real path length.""" * cdef char *_target = malloc(sizeof(char)*max_len) * if _target is NULL: # <<<<<<<<<<<<<< @@ -4558,16 +4804,16 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s __pyx_t_1 = ((__pyx_v__target == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/sftp.pyx":381 + /* "ssh2/sftp.pyx":387 * cdef char *_target = malloc(sizeof(char)*max_len) * if _target is NULL: * raise MemoryError # <<<<<<<<<<<<<< * cdef int rc * cdef bytes b_path = to_bytes(path) */ - PyErr_NoMemory(); __PYX_ERR(0, 381, __pyx_L1_error) + PyErr_NoMemory(); __PYX_ERR(0, 387, __pyx_L1_error) - /* "ssh2/sftp.pyx":380 + /* "ssh2/sftp.pyx":386 * than real path length.""" * cdef char *_target = malloc(sizeof(char)*max_len) * if _target is NULL: # <<<<<<<<<<<<<< @@ -4576,29 +4822,33 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s */ } - /* "ssh2/sftp.pyx":383 + /* "ssh2/sftp.pyx":389 * raise MemoryError * cdef int rc * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * cdef bytes realpath */ - __pyx_t_2 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_t_2 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_b_path = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "ssh2/sftp.pyx":384 + /* "ssh2/sftp.pyx":390 * cdef int rc * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< * cdef bytes realpath * try: */ - __pyx_t_3 = __Pyx_PyObject_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 384, __pyx_L1_error) + if (unlikely(__pyx_v_b_path == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 390, __pyx_L1_error) + } + __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 390, __pyx_L1_error) __pyx_v__path = __pyx_t_3; - /* "ssh2/sftp.pyx":386 + /* "ssh2/sftp.pyx":392 * cdef char *_path = b_path * cdef bytes realpath * try: # <<<<<<<<<<<<<< @@ -4607,7 +4857,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s */ /*try:*/ { - /* "ssh2/sftp.pyx":387 + /* "ssh2/sftp.pyx":393 * cdef bytes realpath * try: * with nogil: # <<<<<<<<<<<<<< @@ -4622,7 +4872,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s #endif /*try:*/ { - /* "ssh2/sftp.pyx":388 + /* "ssh2/sftp.pyx":394 * try: * with nogil: * rc = c_sftp.libssh2_sftp_realpath( # <<<<<<<<<<<<<< @@ -4631,7 +4881,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s */ __pyx_v_rc = libssh2_sftp_realpath(__pyx_v_self->_sftp, __pyx_v__path, __pyx_v__target, __pyx_v_max_len); - /* "ssh2/sftp.pyx":390 + /* "ssh2/sftp.pyx":396 * rc = c_sftp.libssh2_sftp_realpath( * self._sftp, _path, _target, max_len) * if rc == _LIBSSH2_ERROR_BUFFER_TOO_SMALL: # <<<<<<<<<<<<<< @@ -4641,7 +4891,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s __pyx_t_1 = ((__pyx_v_rc == LIBSSH2_ERROR_BUFFER_TOO_SMALL) != 0); if (__pyx_t_1) { - /* "ssh2/sftp.pyx":391 + /* "ssh2/sftp.pyx":397 * self._sftp, _path, _target, max_len) * if rc == _LIBSSH2_ERROR_BUFFER_TOO_SMALL: * with gil: # <<<<<<<<<<<<<< @@ -4654,26 +4904,26 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s #endif /*try:*/ { - /* "ssh2/sftp.pyx":395 + /* "ssh2/sftp.pyx":401 * "Buffer too small to fit realpath for %s " * "- max size %s. Error code %s", * path, max_len, rc) # <<<<<<<<<<<<<< * elif rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc < 0: * with gil: */ - __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_max_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L12_error) + __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_max_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 401, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 395, __pyx_L12_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 401, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_4); - /* "ssh2/sftp.pyx":392 + /* "ssh2/sftp.pyx":398 * if rc == _LIBSSH2_ERROR_BUFFER_TOO_SMALL: * with gil: * raise SFTPBufferTooSmall( # <<<<<<<<<<<<<< * "Buffer too small to fit realpath for %s " * "- max size %s. Error code %s", */ - __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 392, __pyx_L12_error) + __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 398, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_kp_s_Buffer_too_small_to_fit_realpath); __Pyx_GIVEREF(__pyx_kp_s_Buffer_too_small_to_fit_realpath); @@ -4687,15 +4937,15 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4); __pyx_t_2 = 0; __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 392, __pyx_L12_error) + __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 392, __pyx_L12_error) + __PYX_ERR(0, 398, __pyx_L12_error) } - /* "ssh2/sftp.pyx":391 + /* "ssh2/sftp.pyx":397 * self._sftp, _path, _target, max_len) * if rc == _LIBSSH2_ERROR_BUFFER_TOO_SMALL: * with gil: # <<<<<<<<<<<<<< @@ -4712,7 +4962,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s } } - /* "ssh2/sftp.pyx":390 + /* "ssh2/sftp.pyx":396 * rc = c_sftp.libssh2_sftp_realpath( * self._sftp, _path, _target, max_len) * if rc == _LIBSSH2_ERROR_BUFFER_TOO_SMALL: # <<<<<<<<<<<<<< @@ -4721,7 +4971,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s */ } - /* "ssh2/sftp.pyx":396 + /* "ssh2/sftp.pyx":402 * "- max size %s. Error code %s", * path, max_len, rc) * elif rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc < 0: # <<<<<<<<<<<<<< @@ -4739,7 +4989,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s __pyx_L14_bool_binop_done:; if (__pyx_t_1) { - /* "ssh2/sftp.pyx":397 + /* "ssh2/sftp.pyx":403 * path, max_len, rc) * elif rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc < 0: * with gil: # <<<<<<<<<<<<<< @@ -4752,24 +5002,24 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s #endif /*try:*/ { - /* "ssh2/sftp.pyx":400 + /* "ssh2/sftp.pyx":406 * raise SFTPHandleError( * "Error getting real path for %s - error code %s", * path, rc) # <<<<<<<<<<<<<< * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: */ - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 400, __pyx_L17_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 406, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_4); - /* "ssh2/sftp.pyx":398 + /* "ssh2/sftp.pyx":404 * elif rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc < 0: * with gil: * raise SFTPHandleError( # <<<<<<<<<<<<<< * "Error getting real path for %s - error code %s", * path, rc) */ - __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 398, __pyx_L17_error) + __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 404, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_kp_s_Error_getting_real_path_for_s_er); __Pyx_GIVEREF(__pyx_kp_s_Error_getting_real_path_for_s_er); @@ -4780,15 +5030,15 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_SFTPHandleError), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L17_error) + __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_SFTPHandleError), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 404, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 398, __pyx_L17_error) + __PYX_ERR(0, 404, __pyx_L17_error) } - /* "ssh2/sftp.pyx":397 + /* "ssh2/sftp.pyx":403 * path, max_len, rc) * elif rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc < 0: * with gil: # <<<<<<<<<<<<<< @@ -4805,7 +5055,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s } } - /* "ssh2/sftp.pyx":396 + /* "ssh2/sftp.pyx":402 * "- max size %s. Error code %s", * path, max_len, rc) * elif rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc < 0: # <<<<<<<<<<<<<< @@ -4814,7 +5064,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s */ } - /* "ssh2/sftp.pyx":401 + /* "ssh2/sftp.pyx":407 * "Error getting real path for %s - error code %s", * path, rc) * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -4824,7 +5074,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s __pyx_t_1 = ((__pyx_v_rc == LIBSSH2_ERROR_EAGAIN) != 0); if (__pyx_t_1) { - /* "ssh2/sftp.pyx":402 + /* "ssh2/sftp.pyx":408 * path, rc) * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -4837,7 +5087,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s #endif /*try:*/ { - /* "ssh2/sftp.pyx":403 + /* "ssh2/sftp.pyx":409 * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: * return rc # <<<<<<<<<<<<<< @@ -4845,14 +5095,14 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s * return to_str(realpath) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 403, __pyx_L20_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 409, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L19_return; } - /* "ssh2/sftp.pyx":402 + /* "ssh2/sftp.pyx":408 * path, rc) * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: * with gil: # <<<<<<<<<<<<<< @@ -4875,7 +5125,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s } } - /* "ssh2/sftp.pyx":401 + /* "ssh2/sftp.pyx":407 * "Error getting real path for %s - error code %s", * path, rc) * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -4885,7 +5135,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s } } - /* "ssh2/sftp.pyx":387 + /* "ssh2/sftp.pyx":393 * cdef bytes realpath * try: * with nogil: # <<<<<<<<<<<<<< @@ -4918,19 +5168,19 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s } } - /* "ssh2/sftp.pyx":404 + /* "ssh2/sftp.pyx":410 * with gil: * return rc * realpath = _target[:rc] # <<<<<<<<<<<<<< * return to_str(realpath) * finally: */ - __pyx_t_4 = __Pyx_PyBytes_FromStringAndSize(__pyx_v__target + 0, __pyx_v_rc - 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 404, __pyx_L5_error) + __pyx_t_4 = __Pyx_PyBytes_FromStringAndSize(__pyx_v__target + 0, __pyx_v_rc - 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 410, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_realpath = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "ssh2/sftp.pyx":405 + /* "ssh2/sftp.pyx":411 * return rc * realpath = _target[:rc] * return to_str(realpath) # <<<<<<<<<<<<<< @@ -4938,15 +5188,15 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s * free(_target) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_PyObject_AsWritableString(__pyx_v_realpath); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 405, __pyx_L5_error) - __pyx_t_4 = __pyx_f_4ssh2_5utils_to_str(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 405, __pyx_L5_error) + __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v_realpath); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 411, __pyx_L5_error) + __pyx_t_4 = __pyx_f_4ssh2_5utils_to_str(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 411, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L4_return; } - /* "ssh2/sftp.pyx":407 + /* "ssh2/sftp.pyx":413 * return to_str(realpath) * finally: * free(_target) # <<<<<<<<<<<<<< @@ -4974,7 +5224,6 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s { free(__pyx_v__target); } - __Pyx_PyThreadState_assign if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); @@ -4999,7 +5248,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s } } - /* "ssh2/sftp.pyx":367 + /* "ssh2/sftp.pyx":373 * return rc * * def realpath(self, path not None, size_t max_len=256): # <<<<<<<<<<<<<< @@ -5022,7 +5271,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s return __pyx_r; } -/* "ssh2/sftp.pyx":409 +/* "ssh2/sftp.pyx":415 * free(_target) * * def last_error(self): # <<<<<<<<<<<<<< @@ -5051,7 +5300,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_34last_error(struct __pyx_obj_4ssh2_ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("last_error", 0); - /* "ssh2/sftp.pyx":414 + /* "ssh2/sftp.pyx":420 * :rtype: int""" * cdef unsigned long rc * with nogil: # <<<<<<<<<<<<<< @@ -5066,7 +5315,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_34last_error(struct __pyx_obj_4ssh2_ #endif /*try:*/ { - /* "ssh2/sftp.pyx":415 + /* "ssh2/sftp.pyx":421 * cdef unsigned long rc * with nogil: * rc = c_sftp.libssh2_sftp_last_error(self._sftp) # <<<<<<<<<<<<<< @@ -5075,7 +5324,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_34last_error(struct __pyx_obj_4ssh2_ __pyx_v_rc = libssh2_sftp_last_error(__pyx_v_self->_sftp); } - /* "ssh2/sftp.pyx":414 + /* "ssh2/sftp.pyx":420 * :rtype: int""" * cdef unsigned long rc * with nogil: # <<<<<<<<<<<<<< @@ -5094,19 +5343,19 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_34last_error(struct __pyx_obj_4ssh2_ } } - /* "ssh2/sftp.pyx":416 + /* "ssh2/sftp.pyx":422 * with nogil: * rc = c_sftp.libssh2_sftp_last_error(self._sftp) * return rc # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 416, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":409 + /* "ssh2/sftp.pyx":415 * free(_target) * * def last_error(self): # <<<<<<<<<<<<<< @@ -5254,7 +5503,7 @@ static PyObject *__pyx_tp_new_4ssh2_4sftp_SFTP(PyTypeObject *t, PyObject *a, PyO static void __pyx_tp_dealloc_4ssh2_4sftp_SFTP(PyObject *o) { struct __pyx_obj_4ssh2_4sftp_SFTP *p = (struct __pyx_obj_4ssh2_4sftp_SFTP *)o; - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -5375,17 +5624,31 @@ static PyMethodDef __pyx_methods[] = { }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_sftp(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_sftp}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "sftp", __pyx_k_SFTP_channel_handle_and_attribu, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ @@ -5394,6 +5657,7 @@ static struct PyModuleDef __pyx_moduledef = { static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_Buffer_too_small_to_fit_realpath, __pyx_k_Buffer_too_small_to_fit_realpath, sizeof(__pyx_k_Buffer_too_small_to_fit_realpath), 0, 0, 1, 0}, + {&__pyx_kp_s_Error_creating_directory_s_error, __pyx_k_Error_creating_directory_s_error, sizeof(__pyx_k_Error_creating_directory_s_error), 0, 0, 1, 0}, {&__pyx_kp_s_Error_getting_real_path_for_s_er, __pyx_k_Error_getting_real_path_for_s_er, sizeof(__pyx_k_Error_getting_real_path_for_s_er), 0, 0, 1, 0}, {&__pyx_kp_s_Error_with_stat_on_file_s_code_s, __pyx_k_Error_with_stat_on_file_s_code_s, sizeof(__pyx_k_Error_with_stat_on_file_s_code_s), 0, 0, 1, 0}, {&__pyx_n_s_LIBSSH2_FXF_APPEND, __pyx_k_LIBSSH2_FXF_APPEND, sizeof(__pyx_k_LIBSSH2_FXF_APPEND), 0, 0, 1, 1}, @@ -5425,15 +5689,19 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_filename, __pyx_k_filename, sizeof(__pyx_k_filename), 0, 0, 1, 1}, {&__pyx_n_s_filename_len, __pyx_k_filename_len, sizeof(__pyx_k_filename_len), 0, 0, 1, 1}, {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1}, + {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_max_len, __pyx_k_max_len, sizeof(__pyx_k_max_len), 0, 0, 1, 1}, {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, {&__pyx_n_s_open_type, __pyx_k_open_type, sizeof(__pyx_k_open_type), 0, 0, 1, 1}, {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 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_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, {&__pyx_n_s_session, __pyx_k_session, sizeof(__pyx_k_session), 0, 0, 1, 1}, + {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_source_filename, __pyx_k_source_filename, sizeof(__pyx_k_source_filename), 0, 0, 1, 1}, {&__pyx_n_s_source_filename_len, __pyx_k_source_filename_len, sizeof(__pyx_k_source_filename_len), 0, 0, 1, 1}, @@ -5442,7 +5710,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 381, __pyx_L1_error) + __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 387, __pyx_L1_error) __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error) return 0; __pyx_L1_error:; @@ -5491,6 +5759,47 @@ PyMODINIT_FUNC initsftp(void) #else PyMODINIT_FUNC PyInit_sftp(void); /*proto*/ PyMODINIT_FUNC PyInit_sftp(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec_sftp(PyObject *__pyx_pyinit_module) +#endif #endif { PyObject *__pyx_t_1 = NULL; @@ -5498,6 +5807,9 @@ PyMODINIT_FUNC PyInit_sftp(void) PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { @@ -5524,6 +5836,9 @@ PyMODINIT_FUNC PyInit_sftp(void) #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_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 @@ -5535,12 +5850,17 @@ PyMODINIT_FUNC PyInit_sftp(void) #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("sftp", __pyx_methods, __pyx_k_SFTP_channel_handle_and_attribu, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -5580,8 +5900,7 @@ PyMODINIT_FUNC PyInit_sftp(void) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_4sftp_SFTP) < 0) __PYX_ERR(0, 112, __pyx_L1_error) __pyx_ptype_4ssh2_4sftp_SFTP = &__pyx_type_4ssh2_4sftp_SFTP; /*--- Type import code ---*/ - __pyx_ptype_4ssh2_7session_Session = __Pyx_ImportType("ssh2.session", "Session", sizeof(struct __pyx_obj_4ssh2_7session_Session), 1); if (unlikely(!__pyx_ptype_4ssh2_7session_Session)) __PYX_ERR(2, 20, __pyx_L1_error) - __pyx_vtabptr_4ssh2_7session_Session = (struct __pyx_vtabstruct_4ssh2_7session_Session*)__Pyx_GetVtable(__pyx_ptype_4ssh2_7session_Session->tp_dict); if (unlikely(!__pyx_vtabptr_4ssh2_7session_Session)) __PYX_ERR(2, 20, __pyx_L1_error) + __pyx_ptype_4ssh2_7session_Session = __Pyx_ImportType("ssh2.session", "Session", sizeof(struct __pyx_obj_4ssh2_7session_Session), 1); if (unlikely(!__pyx_ptype_4ssh2_7session_Session)) __PYX_ERR(2, 19, __pyx_L1_error) __pyx_ptype_4ssh2_7channel_Channel = __Pyx_ImportType("ssh2.channel", "Channel", sizeof(struct __pyx_obj_4ssh2_7channel_Channel), 1); if (unlikely(!__pyx_ptype_4ssh2_7channel_Channel)) __PYX_ERR(3, 24, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_AgentError = __Pyx_ImportType("ssh2.exceptions", "AgentError", sizeof(struct __pyx_obj_4ssh2_10exceptions_AgentError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_AgentError)) __PYX_ERR(4, 18, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_AuthenticationError = __Pyx_ImportType("ssh2.exceptions", "AuthenticationError", sizeof(struct __pyx_obj_4ssh2_10exceptions_AuthenticationError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_AuthenticationError)) __PYX_ERR(4, 22, __pyx_L1_error) @@ -5594,6 +5913,7 @@ PyMODINIT_FUNC PyInit_sftp(void) __pyx_ptype_4ssh2_10exceptions_ChannelError = __Pyx_ImportType("ssh2.exceptions", "ChannelError", sizeof(struct __pyx_obj_4ssh2_10exceptions_ChannelError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_ChannelError)) __PYX_ERR(4, 50, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_SFTPHandleError = __Pyx_ImportType("ssh2.exceptions", "SFTPHandleError", sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SFTPHandleError)) __PYX_ERR(4, 54, __pyx_L1_error) __pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall = __Pyx_ImportType("ssh2.exceptions", "SFTPBufferTooSmall", sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall)) __PYX_ERR(4, 58, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_SFTPIOError = __Pyx_ImportType("ssh2.exceptions", "SFTPIOError", sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPIOError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SFTPIOError)) __PYX_ERR(4, 62, __pyx_L1_error) __pyx_ptype_4ssh2_11sftp_handle_SFTPHandle = __Pyx_ImportType("ssh2.sftp_handle", "SFTPHandle", sizeof(struct __pyx_obj_4ssh2_11sftp_handle_SFTPHandle), 1); if (unlikely(!__pyx_ptype_4ssh2_11sftp_handle_SFTPHandle)) __PYX_ERR(5, 25, __pyx_L1_error) __pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes = __Pyx_ImportType("ssh2.sftp_handle", "SFTPAttributes", sizeof(struct __pyx_obj_4ssh2_11sftp_handle_SFTPAttributes), 1); if (unlikely(!__pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes)) __PYX_ERR(5, 31, __pyx_L1_error) __pyx_ptype_4ssh2_11sftp_handle_SFTPStatVFS = __Pyx_ImportType("ssh2.sftp_handle", "SFTPStatVFS", sizeof(struct __pyx_obj_4ssh2_11sftp_handle_SFTPStatVFS), 1); if (unlikely(!__pyx_ptype_4ssh2_11sftp_handle_SFTPStatVFS)) __PYX_ERR(5, 35, __pyx_L1_error) @@ -5859,7 +6179,7 @@ PyMODINIT_FUNC PyInit_sftp(void) * # Copyright (C) 2017 Panos Kittenis * */ - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_4) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -5882,10 +6202,12 @@ PyMODINIT_FUNC PyInit_sftp(void) } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -6089,7 +6411,7 @@ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } - if (likely(PyObject_TypeCheck(obj, type))) + if (likely(__Pyx_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); @@ -6236,11 +6558,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject "raise: exception class must be a subclass of BaseException"); goto bad; } -#if PY_VERSION_HEX >= 0x03030000 if (cause) { -#else - if (cause && cause != Py_None) { -#endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; @@ -6268,7 +6586,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else - PyThreadState *tstate = PyThreadState_GET(); + PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); @@ -6284,34 +6602,28 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject #endif /* 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); -} -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } - if (none_allowed && obj == Py_None) return 1; else if (exact) { - if (likely(Py_TYPE(obj) == type)) return 1; #if PY_MAJOR_VERSION == 2 - else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { - if (likely(PyObject_TypeCheck(obj, type))) return 1; + if (likely(__Pyx_TypeCheck(obj, type))) return 1; } - __Pyx_RaiseArgumentTypeInvalid(name, obj, type); + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); return 0; } /* GetException */ - #if CYTHON_FAST_THREAD_STATE +#if CYTHON_FAST_THREAD_STATE static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { @@ -6372,7 +6684,7 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) } /* SwapException */ - #if CYTHON_FAST_THREAD_STATE + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->exc_type; @@ -6397,7 +6709,7 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, #endif /* SaveResetException */ - #if CYTHON_FAST_THREAD_STATE + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { *type = tstate->exc_type; *value = tstate->exc_value; @@ -6421,17 +6733,16 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject #endif /* SetupReduce */ - #define __Pyx_setup_reduce_GET_ATTR_OR_BAD(res, obj, name) res = PyObject_GetAttrString(obj, name); if (res == NULL) goto BAD; -static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { + static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { int ret; PyObject *name_attr; - name_attr = PyObject_GetAttrString(meth, "__name__"); - if (name_attr) { + name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name); + if (likely(name_attr)) { ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); } else { ret = -1; } - if (ret < 0) { + if (unlikely(ret < 0)) { PyErr_Clear(); ret = 0; } @@ -6440,43 +6751,55 @@ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { } static int __Pyx_setup_reduce(PyObject* type_obj) { int ret = 0; - PyObject* builtin_object = NULL; - static PyObject *object_reduce = NULL; - static PyObject *object_reduce_ex = NULL; + PyObject *object_reduce = NULL; + PyObject *object_reduce_ex = NULL; PyObject *reduce = NULL; PyObject *reduce_ex = NULL; PyObject *reduce_cython = NULL; PyObject *setstate = NULL; PyObject *setstate_cython = NULL; - if (PyObject_HasAttrString(type_obj, "__getstate__")) goto GOOD; - if (object_reduce_ex == NULL) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(builtin_object, __pyx_b, "object"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce, builtin_object, "__reduce__"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce_ex, builtin_object, "__reduce_ex__"); - } - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_ex, type_obj, "__reduce_ex__"); +#if CYTHON_USE_PYTYPE_LOOKUP + if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD; +#else + if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD; +#endif +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#else + object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#endif + reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD; if (reduce_ex == object_reduce_ex) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce, type_obj, "__reduce__"); - if (object_reduce == reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_cython, type_obj, "__reduce_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce__", reduce_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce_cython__"); if (ret < 0) goto BAD; - setstate = PyObject_GetAttrString(type_obj, "__setstate__"); +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#else + object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#endif + reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD; + if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { + reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD; + setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); if (!setstate) PyErr_Clear(); if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(setstate_cython, type_obj, "__setstate_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate__", setstate_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate_cython__"); if (ret < 0) goto BAD; + setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD; } PyType_Modified((PyTypeObject*)type_obj); } } goto GOOD; BAD: - if (!PyErr_Occurred()) PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); + if (!PyErr_Occurred()) + PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); ret = -1; GOOD: - Py_XDECREF(builtin_object); +#if !CYTHON_USE_PYTYPE_LOOKUP + Py_XDECREF(object_reduce); + Py_XDECREF(object_reduce_ex); +#endif Py_XDECREF(reduce); Py_XDECREF(reduce_ex); Py_XDECREF(reduce_cython); @@ -6485,35 +6808,19 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { return ret; } -/* GetVTable */ - static void* __Pyx_GetVtable(PyObject *dict) { - void* ptr; - PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable); - if (!ob) - goto bad; -#if PY_VERSION_HEX >= 0x02070000 - ptr = PyCapsule_GetPointer(ob, 0); -#else - ptr = PyCObject_AsVoidPtr(ob); -#endif - if (!ptr && !PyErr_Occurred()) - PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); - Py_DECREF(ob); - return ptr; -bad: - Py_XDECREF(ob); - return NULL; -} - /* CLineInTraceback */ - static int __Pyx_CLineForTraceback(int c_line) { + static int __Pyx_CLineForTraceback(int c_line) { #ifdef CYTHON_CLINE_IN_TRACEBACK return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; #else - PyObject **cython_runtime_dict; PyObject *use_cline; - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (unlikely(!cython_runtime_dict)) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { PyObject *ptype, *pvalue, *ptraceback; PyObject *use_cline_obj; PyErr_Fetch(&ptype, &pvalue, &ptraceback); @@ -6525,8 +6832,6 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { use_cline = NULL; } PyErr_Restore(ptype, pvalue, ptraceback); - } else { - use_cline = PyDict_GetItem(*_PyObject_GetDictPtr(__pyx_cython_runtime), __pyx_n_s_cline_in_traceback); } if (!use_cline) { c_line = 0; @@ -6540,7 +6845,7 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { } /* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + 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; @@ -6620,7 +6925,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { } /* AddTraceback */ - #include "compile.h" + #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( @@ -6690,10 +6995,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, __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*/ + __Pyx_PyThreadState_Current, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); @@ -6704,7 +7009,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -6735,7 +7040,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + #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) @@ -6757,7 +7062,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value) { const unsigned long neg_one = (unsigned long) -1, const_zero = (unsigned long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -6788,7 +7093,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) { + 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 @@ -6977,7 +7282,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE unsigned long __Pyx_PyInt_As_unsigned_long(PyObject *x) { + static CYTHON_INLINE unsigned long __Pyx_PyInt_As_unsigned_long(PyObject *x) { const unsigned long neg_one = (unsigned long) -1, const_zero = (unsigned long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -7166,7 +7471,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + 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 @@ -7355,7 +7660,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + 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 @@ -7544,7 +7849,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { + static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { const size_t neg_one = (size_t) -1, const_zero = (size_t) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -7733,7 +8038,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + 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) { @@ -7763,8 +8068,80 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } } +/* FastTypeChecks */ + #if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + /* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { + 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()); @@ -7780,7 +8157,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* FunctionExport */ - static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { + static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { PyObject *d = 0; PyObject *cobj = 0; union { @@ -7817,7 +8194,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* ModuleImport */ - #ifndef __PYX_HAVE_RT_ImportModule + #ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; @@ -7835,7 +8212,7 @@ static PyObject *__Pyx_ImportModule(const char *name) { #endif /* TypeImport */ - #ifndef __PYX_HAVE_RT_ImportType + #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) @@ -7900,7 +8277,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class #endif /* FunctionImport */ - #ifndef __PYX_HAVE_RT_ImportFunction + #ifndef __PYX_HAVE_RT_ImportFunction #define __PYX_HAVE_RT_ImportFunction static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { PyObject *d = 0; @@ -7954,7 +8331,7 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (** #endif /* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { @@ -7993,46 +8370,53 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#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 && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} #endif #endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __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 && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -8056,6 +8440,26 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; @@ -8063,9 +8467,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS @@ -8073,32 +8477,30 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } #else - if (m && m->nb_int) { + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); } #endif #else - res = PyNumber_Int(x); + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { diff --git a/ssh2/sftp.pyx b/ssh2/sftp.pyx index 258040c3..31018152 100644 --- a/ssh2/sftp.pyx +++ b/ssh2/sftp.pyx @@ -61,7 +61,7 @@ from session cimport Session from error_codes cimport _LIBSSH2_ERROR_BUFFER_TOO_SMALL from channel cimport Channel, PyChannel from utils cimport to_bytes, to_str -from exceptions cimport SFTPHandleError, SFTPBufferTooSmall +from exceptions cimport SFTPHandleError, SFTPBufferTooSmall, SFTPIOError from sftp_handle cimport SFTPHandle, PySFTPHandle, SFTPAttributes, SFTPStatVFS cimport c_ssh2 @@ -269,9 +269,15 @@ cdef class SFTP: :rtype: int""" cdef int rc - cdef char *_path = path + cdef bytes b_path = to_bytes(path) + cdef char *_path = b_path with nogil: rc = c_sftp.libssh2_sftp_mkdir(self._sftp, _path, mode) + if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + with gil: + raise SFTPIOError( + "Error creating directory %s - error code %s", + path, rc) return rc def rmdir(self, path not None): diff --git a/ssh2/sftp_handle.c b/ssh2/sftp_handle.c index 0473ecd9..36d7d3c3 100644 --- a/ssh2/sftp_handle.c +++ b/ssh2/sftp_handle.c @@ -1,13 +1,14 @@ -/* Generated by Cython 0.26 */ +/* Generated by Cython 0.27.1 */ #define PY_SSIZE_T_CLEAN #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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_26" +#define CYTHON_ABI "0_27_1" +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -31,7 +32,7 @@ #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif @@ -47,8 +48,14 @@ #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS @@ -67,6 +74,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -74,6 +85,8 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS @@ -98,6 +111,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -105,6 +122,12 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 @@ -144,6 +167,12 @@ #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -199,6 +228,27 @@ #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ @@ -282,7 +332,6 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject @@ -333,15 +382,17 @@ #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct 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)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) @@ -451,14 +502,6 @@ static CYTHON_INLINE float __PYX_NAN() { __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) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -481,7 +524,7 @@ static CYTHON_INLINE float __PYX_NAN() { #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif @@ -512,8 +555,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #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 (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -535,6 +578,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) @@ -545,16 +594,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #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) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #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 @@ -563,6 +607,8 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) #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_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS @@ -663,7 +709,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime; @@ -681,28 +727,54 @@ static const char *__pyx_f[] = { "stringsource", "ssh2/session.pxd", "ssh2/sftp.pxd", + "ssh2/exceptions.pxd", }; +/* NoFastGil.proto */ +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + /*--- Type declarations ---*/ struct __pyx_obj_4ssh2_7session_Session; struct __pyx_obj_4ssh2_4sftp_SFTP; +struct __pyx_obj_4ssh2_10exceptions_AgentError; +struct __pyx_obj_4ssh2_10exceptions_AuthenticationError; +struct __pyx_obj_4ssh2_10exceptions_AgentConnectionError; +struct __pyx_obj_4ssh2_10exceptions_AgentAuthenticationError; +struct __pyx_obj_4ssh2_10exceptions_AgentListIdentitiesError; +struct __pyx_obj_4ssh2_10exceptions_AgentGetIdentityError; +struct __pyx_obj_4ssh2_10exceptions_SessionStartupError; +struct __pyx_obj_4ssh2_10exceptions_SessionHandshakeError; +struct __pyx_obj_4ssh2_10exceptions_ChannelError; +struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError; +struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall; +struct __pyx_obj_4ssh2_10exceptions_SFTPIOError; struct __pyx_obj_4ssh2_11sftp_handle_SFTPHandle; struct __pyx_obj_4ssh2_11sftp_handle_SFTPAttributes; struct __pyx_obj_4ssh2_11sftp_handle_SFTPStatVFS; struct __pyx_obj_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex; struct __pyx_obj_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir; -/* "session.pxd":20 - * +/* "session.pxd":19 + * cimport c_ssh2 * * cdef class Session: # <<<<<<<<<<<<<< * cdef c_ssh2.LIBSSH2_SESSION *_session - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL + * cdef int _sock */ struct __pyx_obj_4ssh2_7session_Session { PyObject_HEAD - struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtab; LIBSSH2_SESSION *_session; + int _sock; + PyObject *sock; }; @@ -720,6 +792,149 @@ struct __pyx_obj_4ssh2_4sftp_SFTP { }; +/* "exceptions.pxd":18 + * + * + * cdef class AgentError(Exception): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_4ssh2_10exceptions_AgentError { + PyBaseExceptionObject __pyx_base; +}; + + +/* "exceptions.pxd":22 + * + * + * cdef class AuthenticationError(Exception): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_4ssh2_10exceptions_AuthenticationError { + PyBaseExceptionObject __pyx_base; +}; + + +/* "exceptions.pxd":26 + * + * + * cdef class AgentConnectionError(AgentError): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_4ssh2_10exceptions_AgentConnectionError { + struct __pyx_obj_4ssh2_10exceptions_AgentError __pyx_base; +}; + + +/* "exceptions.pxd":30 + * + * + * cdef class AgentAuthenticationError(AuthenticationError): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_4ssh2_10exceptions_AgentAuthenticationError { + struct __pyx_obj_4ssh2_10exceptions_AuthenticationError __pyx_base; +}; + + +/* "exceptions.pxd":34 + * + * + * cdef class AgentListIdentitiesError(AgentError): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_4ssh2_10exceptions_AgentListIdentitiesError { + struct __pyx_obj_4ssh2_10exceptions_AgentError __pyx_base; +}; + + +/* "exceptions.pxd":38 + * + * + * cdef class AgentGetIdentityError(AgentError): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_4ssh2_10exceptions_AgentGetIdentityError { + struct __pyx_obj_4ssh2_10exceptions_AgentError __pyx_base; +}; + + +/* "exceptions.pxd":42 + * + * + * cdef class SessionStartupError(Exception): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_4ssh2_10exceptions_SessionStartupError { + PyBaseExceptionObject __pyx_base; +}; + + +/* "exceptions.pxd":46 + * + * + * cdef class SessionHandshakeError(Exception): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_4ssh2_10exceptions_SessionHandshakeError { + PyBaseExceptionObject __pyx_base; +}; + + +/* "exceptions.pxd":50 + * + * + * cdef class ChannelError(Exception): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_4ssh2_10exceptions_ChannelError { + PyBaseExceptionObject __pyx_base; +}; + + +/* "exceptions.pxd":54 + * + * + * cdef class SFTPHandleError(Exception): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError { + PyBaseExceptionObject __pyx_base; +}; + + +/* "exceptions.pxd":58 + * + * + * cdef class SFTPBufferTooSmall(Exception): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall { + PyBaseExceptionObject __pyx_base; +}; + + +/* "exceptions.pxd":62 + * + * + * cdef class SFTPIOError(Exception): # <<<<<<<<<<<<<< + * pass + */ +struct __pyx_obj_4ssh2_10exceptions_SFTPIOError { + PyBaseExceptionObject __pyx_base; +}; + + /* "ssh2/sftp_handle.pxd":25 * * @@ -783,7 +998,7 @@ struct __pyx_obj_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex { /* "ssh2/sftp_handle.pyx":226 - * return rc, buf, longentry, attrs + * return rc, buf, b_longentry, attrs * * def readdir(self, size_t buffer_maxlen=1024): # <<<<<<<<<<<<<< * """Get directory listing from file handle, if any. @@ -799,21 +1014,6 @@ struct __pyx_obj_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir { }; - -/* "session.pxd":20 - * - * - * cdef class Session: # <<<<<<<<<<<<<< - * cdef c_ssh2.LIBSSH2_SESSION *_session - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL - */ - -struct __pyx_vtabstruct_4ssh2_7session_Session { - LIBSSH2_AGENT *(*init_connect_agent)(struct __pyx_obj_4ssh2_7session_Session *); - LIBSSH2_AGENT *(*_agent_init)(struct __pyx_obj_4ssh2_7session_Session *); -}; -static struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtabptr_4ssh2_7session_Session; - /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY @@ -909,38 +1109,36 @@ 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); /* KeywordStringCheck.proto */ -static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); - -/* NoFastGil.proto */ -#define __Pyx_PyGILState_Ensure PyGILState_Ensure -#define __Pyx_PyGILState_Release PyGILState_Release -#define __Pyx_FastGIL_Remember() -#define __Pyx_FastGIL_Forget() -#define __Pyx_FastGilFuncInit() - -/* ForceInitThreads.proto */ -#ifndef __PYX_FORCE_INIT_THREADS - #define __PYX_FORCE_INIT_THREADS 0 -#endif +static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #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); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif #else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #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) @@ -1034,8 +1232,10 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject #endif /* ArgTypeTest.proto */ -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); +#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ + ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ + __Pyx__ArgTypeTest(obj, type, name, exact)) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* IncludeStringH.proto */ #include @@ -1043,9 +1243,6 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in /* SetupReduce.proto */ static int __Pyx_setup_reduce(PyObject* type_obj); -/* GetVTable.proto */ -static void* __Pyx_GetVtable(PyObject *dict); - /* CLineInTraceback.proto */ static int __Pyx_CLineForTraceback(int c_line); @@ -1095,14 +1292,27 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif + /* FetchCommonType.proto */ static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); /* PyObjectCallMethod1.proto */ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); +static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg); /* CoroutineBase.proto */ -typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyObject *); +typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *); typedef struct { PyObject_HEAD __pyx_coroutine_body_t body; @@ -1122,12 +1332,30 @@ typedef struct { static __pyx_CoroutineObject *__Pyx__Coroutine_New( PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *closure, PyObject *name, PyObject *qualname, PyObject *module_name); +static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit( + __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name); static int __Pyx_Coroutine_clear(PyObject *self); -#if 1 || PY_VERSION_HEX < 0x030300B0 -static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue); +static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value); +static PyObject *__Pyx_Coroutine_Close(PyObject *self); +static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args); +#define __Pyx_Coroutine_SwapException(self) {\ + __Pyx_ExceptionSwap(&(self)->exc_type, &(self)->exc_value, &(self)->exc_traceback);\ + __Pyx_Coroutine_ResetFrameBackpointer(self);\ + } +#define __Pyx_Coroutine_ResetAndClearException(self) {\ + __Pyx_ExceptionReset((self)->exc_type, (self)->exc_value, (self)->exc_traceback);\ + (self)->exc_type = (self)->exc_value = (self)->exc_traceback = NULL;\ + } +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\ + __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue) #else -#define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue) +#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\ + __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue) #endif +static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue); +static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self); /* PatchModuleWithCoroutine.proto */ static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code); @@ -1187,6 +1415,20 @@ static PyTypeObject *__pyx_ptype_4ssh2_7session_Session = 0; /* Module declarations from 'ssh2.sftp' */ static PyTypeObject *__pyx_ptype_4ssh2_4sftp_SFTP = 0; +/* Module declarations from 'ssh2.exceptions' */ +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_AgentError = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_AuthenticationError = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_AgentConnectionError = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_AgentAuthenticationError = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_AgentListIdentitiesError = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_AgentGetIdentityError = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SessionStartupError = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SessionHandshakeError = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_ChannelError = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPHandleError = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall = 0; +static PyTypeObject *__pyx_ptype_4ssh2_10exceptions_SFTPIOError = 0; + /* Module declarations from 'libc.string' */ /* Module declarations from 'libc.stdlib' */ @@ -1207,6 +1449,7 @@ static PyObject *__pyx_builtin_StopIteration; static const char __pyx_k__4[] = ""; static const char __pyx_k_args[] = "args"; static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_read[] = "read"; static const char __pyx_k_send[] = "send"; static const char __pyx_k_sftp[] = "sftp"; @@ -1214,12 +1457,15 @@ static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_attrs[] = "attrs"; static const char __pyx_k_close[] = "close"; static const char __pyx_k_throw[] = "throw"; +static const char __pyx_k_reduce[] = "__reduce__"; static const char __pyx_k_readdir[] = "readdir"; static const char __pyx_k_setstat[] = "setstat"; +static const char __pyx_k_getstate[] = "__getstate__"; +static const char __pyx_k_setstate[] = "__setstate__"; static const char __pyx_k_sftp_ref[] = "_sftp_ref"; static const char __pyx_k_TypeError[] = "TypeError"; static const char __pyx_k_readdir_2[] = "_readdir"; -static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; +static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; static const char __pyx_k_readdir_ex[] = "readdir_ex"; static const char __pyx_k_MemoryError[] = "MemoryError"; static const char __pyx_k_readdir_ex_2[] = "_readdir_ex"; @@ -1232,7 +1478,9 @@ static const char __pyx_k_ssh2_sftp_handle[] = "ssh2.sftp_handle"; static const char __pyx_k_SFTPHandle_readdir[] = "SFTPHandle.readdir"; static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; static const char __pyx_k_SFTPHandle_readdir_ex[] = "SFTPHandle.readdir_ex"; +static const char __pyx_k_Error_writing_to_file_via_SFTP[] = "Error writing to file via SFTP"; static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; +static PyObject *__pyx_kp_s_Error_writing_to_file_via_SFTP; static PyObject *__pyx_n_s_MemoryError; static PyObject *__pyx_n_s_SFTPHandle_readdir; static PyObject *__pyx_n_s_SFTPHandle_readdir_ex; @@ -1244,18 +1492,22 @@ static PyObject *__pyx_n_s_attrs; static PyObject *__pyx_n_s_buffer_maxlen; static PyObject *__pyx_n_s_cline_in_traceback; static PyObject *__pyx_n_s_close; +static PyObject *__pyx_n_s_getstate; static PyObject *__pyx_n_s_longentry_maxlen; static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_name; static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; -static PyObject *__pyx_n_s_pyx_vtable; static PyObject *__pyx_n_s_read; static PyObject *__pyx_n_s_readdir; static PyObject *__pyx_n_s_readdir_2; static PyObject *__pyx_n_s_readdir_ex; static PyObject *__pyx_n_s_readdir_ex_2; +static PyObject *__pyx_n_s_reduce; static PyObject *__pyx_n_s_reduce_cython; +static PyObject *__pyx_n_s_reduce_ex; static PyObject *__pyx_n_s_send; static PyObject *__pyx_n_s_setstat; +static PyObject *__pyx_n_s_setstate; static PyObject *__pyx_n_s_setstate_cython; static PyObject *__pyx_n_s_sftp; static PyObject *__pyx_n_s_sftp_ref; @@ -1324,6 +1576,7 @@ static PyObject *__pyx_tp_new_4ssh2_11sftp_handle_SFTPAttributes(PyTypeObject *t static PyObject *__pyx_tp_new_4ssh2_11sftp_handle_SFTPStatVFS(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_int_0; static size_t __pyx_k__3; static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; @@ -1331,8 +1584,9 @@ static PyObject *__pyx_tuple__5; static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; static PyObject *__pyx_tuple__8; +static PyObject *__pyx_tuple__9; -/* "ssh2/sftp_handle.pyx":23 +/* "ssh2/sftp_handle.pyx":25 * * * cdef object PySFTPHandle(c_sftp.LIBSSH2_SFTP_HANDLE *handle, SFTP sftp): # <<<<<<<<<<<<<< @@ -1348,25 +1602,25 @@ static PyObject *__pyx_f_4ssh2_11sftp_handle_PySFTPHandle(LIBSSH2_SFTP_HANDLE *_ PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("PySFTPHandle", 0); - /* "ssh2/sftp_handle.pyx":24 + /* "ssh2/sftp_handle.pyx":26 * * cdef object PySFTPHandle(c_sftp.LIBSSH2_SFTP_HANDLE *handle, SFTP sftp): * cdef SFTPHandle _handle = SFTPHandle(sftp) # <<<<<<<<<<<<<< * _handle._handle = handle * return _handle */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_sftp)); __Pyx_GIVEREF(((PyObject *)__pyx_v_sftp)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_sftp)); - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPHandle), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPHandle), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v__handle = ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPHandle *)__pyx_t_2); __pyx_t_2 = 0; - /* "ssh2/sftp_handle.pyx":25 + /* "ssh2/sftp_handle.pyx":27 * cdef object PySFTPHandle(c_sftp.LIBSSH2_SFTP_HANDLE *handle, SFTP sftp): * cdef SFTPHandle _handle = SFTPHandle(sftp) * _handle._handle = handle # <<<<<<<<<<<<<< @@ -1375,7 +1629,7 @@ static PyObject *__pyx_f_4ssh2_11sftp_handle_PySFTPHandle(LIBSSH2_SFTP_HANDLE *_ */ __pyx_v__handle->_handle = __pyx_v_handle; - /* "ssh2/sftp_handle.pyx":26 + /* "ssh2/sftp_handle.pyx":28 * cdef SFTPHandle _handle = SFTPHandle(sftp) * _handle._handle = handle * return _handle # <<<<<<<<<<<<<< @@ -1387,7 +1641,7 @@ static PyObject *__pyx_f_4ssh2_11sftp_handle_PySFTPHandle(LIBSSH2_SFTP_HANDLE *_ __pyx_r = ((PyObject *)__pyx_v__handle); goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":23 + /* "ssh2/sftp_handle.pyx":25 * * * cdef object PySFTPHandle(c_sftp.LIBSSH2_SFTP_HANDLE *handle, SFTP sftp): # <<<<<<<<<<<<<< @@ -1408,7 +1662,7 @@ static PyObject *__pyx_f_4ssh2_11sftp_handle_PySFTPHandle(LIBSSH2_SFTP_HANDLE *_ return __pyx_r; } -/* "ssh2/sftp_handle.pyx":31 +/* "ssh2/sftp_handle.pyx":33 * cdef class SFTPAttributes: * * def __cinit__(self): # <<<<<<<<<<<<<< @@ -1438,7 +1692,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ int __pyx_t_1; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "ssh2/sftp_handle.pyx":32 + /* "ssh2/sftp_handle.pyx":34 * * def __cinit__(self): * with nogil: # <<<<<<<<<<<<<< @@ -1453,7 +1707,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":33 + /* "ssh2/sftp_handle.pyx":35 * def __cinit__(self): * with nogil: * self._attrs = malloc( # <<<<<<<<<<<<<< @@ -1462,7 +1716,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ */ __pyx_v_self->_attrs = ((LIBSSH2_SFTP_ATTRIBUTES *)malloc((sizeof(LIBSSH2_SFTP_ATTRIBUTES)))); - /* "ssh2/sftp_handle.pyx":35 + /* "ssh2/sftp_handle.pyx":37 * self._attrs = malloc( * sizeof(c_sftp.LIBSSH2_SFTP_ATTRIBUTES)) * if self._attrs is NULL: # <<<<<<<<<<<<<< @@ -1472,7 +1726,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ __pyx_t_1 = ((__pyx_v_self->_attrs == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/sftp_handle.pyx":36 + /* "ssh2/sftp_handle.pyx":38 * sizeof(c_sftp.LIBSSH2_SFTP_ATTRIBUTES)) * if self._attrs is NULL: * with gil: # <<<<<<<<<<<<<< @@ -1485,17 +1739,17 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":37 + /* "ssh2/sftp_handle.pyx":39 * if self._attrs is NULL: * with gil: * raise MemoryError # <<<<<<<<<<<<<< * self._attrs.flags = 0 * self._attrs.filesize = 0 */ - PyErr_NoMemory(); __PYX_ERR(0, 37, __pyx_L8_error) + PyErr_NoMemory(); __PYX_ERR(0, 39, __pyx_L8_error) } - /* "ssh2/sftp_handle.pyx":36 + /* "ssh2/sftp_handle.pyx":38 * sizeof(c_sftp.LIBSSH2_SFTP_ATTRIBUTES)) * if self._attrs is NULL: * with gil: # <<<<<<<<<<<<<< @@ -1512,7 +1766,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ } } - /* "ssh2/sftp_handle.pyx":35 + /* "ssh2/sftp_handle.pyx":37 * self._attrs = malloc( * sizeof(c_sftp.LIBSSH2_SFTP_ATTRIBUTES)) * if self._attrs is NULL: # <<<<<<<<<<<<<< @@ -1521,7 +1775,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ */ } - /* "ssh2/sftp_handle.pyx":38 + /* "ssh2/sftp_handle.pyx":40 * with gil: * raise MemoryError * self._attrs.flags = 0 # <<<<<<<<<<<<<< @@ -1530,7 +1784,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ */ __pyx_v_self->_attrs->flags = 0; - /* "ssh2/sftp_handle.pyx":39 + /* "ssh2/sftp_handle.pyx":41 * raise MemoryError * self._attrs.flags = 0 * self._attrs.filesize = 0 # <<<<<<<<<<<<<< @@ -1539,7 +1793,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ */ __pyx_v_self->_attrs->filesize = 0; - /* "ssh2/sftp_handle.pyx":40 + /* "ssh2/sftp_handle.pyx":42 * self._attrs.flags = 0 * self._attrs.filesize = 0 * self._attrs.uid = 0 # <<<<<<<<<<<<<< @@ -1548,7 +1802,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ */ __pyx_v_self->_attrs->uid = 0; - /* "ssh2/sftp_handle.pyx":41 + /* "ssh2/sftp_handle.pyx":43 * self._attrs.filesize = 0 * self._attrs.uid = 0 * self._attrs.gid = 0 # <<<<<<<<<<<<<< @@ -1557,7 +1811,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ */ __pyx_v_self->_attrs->gid = 0; - /* "ssh2/sftp_handle.pyx":42 + /* "ssh2/sftp_handle.pyx":44 * self._attrs.uid = 0 * self._attrs.gid = 0 * self._attrs.permissions = 0 # <<<<<<<<<<<<<< @@ -1566,7 +1820,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ */ __pyx_v_self->_attrs->permissions = 0; - /* "ssh2/sftp_handle.pyx":43 + /* "ssh2/sftp_handle.pyx":45 * self._attrs.gid = 0 * self._attrs.permissions = 0 * self._attrs.atime = 0 # <<<<<<<<<<<<<< @@ -1575,7 +1829,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ */ __pyx_v_self->_attrs->atime = 0; - /* "ssh2/sftp_handle.pyx":44 + /* "ssh2/sftp_handle.pyx":46 * self._attrs.permissions = 0 * self._attrs.atime = 0 * self._attrs.mtime = 0 # <<<<<<<<<<<<<< @@ -1585,7 +1839,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ __pyx_v_self->_attrs->mtime = 0; } - /* "ssh2/sftp_handle.pyx":32 + /* "ssh2/sftp_handle.pyx":34 * * def __cinit__(self): * with nogil: # <<<<<<<<<<<<<< @@ -1611,7 +1865,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ } } - /* "ssh2/sftp_handle.pyx":31 + /* "ssh2/sftp_handle.pyx":33 * cdef class SFTPAttributes: * * def __cinit__(self): # <<<<<<<<<<<<<< @@ -1630,7 +1884,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes___cinit__(struct __pyx_ return __pyx_r; } -/* "ssh2/sftp_handle.pyx":46 +/* "ssh2/sftp_handle.pyx":48 * self._attrs.mtime = 0 * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -1653,7 +1907,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_2__dealloc__(struct __ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "ssh2/sftp_handle.pyx":47 + /* "ssh2/sftp_handle.pyx":49 * * def __dealloc__(self): * with nogil: # <<<<<<<<<<<<<< @@ -1668,7 +1922,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_2__dealloc__(struct __ #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":48 + /* "ssh2/sftp_handle.pyx":50 * def __dealloc__(self): * with nogil: * free(self._attrs) # <<<<<<<<<<<<<< @@ -1678,7 +1932,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_2__dealloc__(struct __ free(__pyx_v_self->_attrs); } - /* "ssh2/sftp_handle.pyx":47 + /* "ssh2/sftp_handle.pyx":49 * * def __dealloc__(self): * with nogil: # <<<<<<<<<<<<<< @@ -1697,7 +1951,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_2__dealloc__(struct __ } } - /* "ssh2/sftp_handle.pyx":46 + /* "ssh2/sftp_handle.pyx":48 * self._attrs.mtime = 0 * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -1709,7 +1963,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_2__dealloc__(struct __ __Pyx_RefNannyFinishContext(); } -/* "ssh2/sftp_handle.pyx":51 +/* "ssh2/sftp_handle.pyx":53 * * @property * def flags(self): # <<<<<<<<<<<<<< @@ -1736,7 +1990,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5flags___get__(st PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":52 + /* "ssh2/sftp_handle.pyx":54 * @property * def flags(self): * return self._attrs.flags # <<<<<<<<<<<<<< @@ -1744,13 +1998,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5flags___get__(st * @flags.setter */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->_attrs->flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->_attrs->flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":51 + /* "ssh2/sftp_handle.pyx":53 * * @property * def flags(self): # <<<<<<<<<<<<<< @@ -1769,7 +2023,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5flags___get__(st return __pyx_r; } -/* "ssh2/sftp_handle.pyx":55 +/* "ssh2/sftp_handle.pyx":57 * * @flags.setter * def flags(self, unsigned long flags): # <<<<<<<<<<<<<< @@ -1785,7 +2039,7 @@ static int __pyx_pw_4ssh2_11sftp_handle_14SFTPAttributes_5flags_3__set__(PyObjec __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_flags); { - __pyx_v_flags = __Pyx_PyInt_As_unsigned_long(__pyx_arg_flags); if (unlikely((__pyx_v_flags == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 55, __pyx_L3_error) + __pyx_v_flags = __Pyx_PyInt_As_unsigned_long(__pyx_arg_flags); if (unlikely((__pyx_v_flags == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 57, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -1805,7 +2059,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5flags_2__set__(struct __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); - /* "ssh2/sftp_handle.pyx":56 + /* "ssh2/sftp_handle.pyx":58 * @flags.setter * def flags(self, unsigned long flags): * self._attrs.flags = flags # <<<<<<<<<<<<<< @@ -1814,7 +2068,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5flags_2__set__(struct */ __pyx_v_self->_attrs->flags = __pyx_v_flags; - /* "ssh2/sftp_handle.pyx":55 + /* "ssh2/sftp_handle.pyx":57 * * @flags.setter * def flags(self, unsigned long flags): # <<<<<<<<<<<<<< @@ -1828,7 +2082,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5flags_2__set__(struct return __pyx_r; } -/* "ssh2/sftp_handle.pyx":59 +/* "ssh2/sftp_handle.pyx":61 * * @property * def filesize(self): # <<<<<<<<<<<<<< @@ -1855,7 +2109,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_8filesize___get__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":60 + /* "ssh2/sftp_handle.pyx":62 * @property * def filesize(self): * return self._attrs.filesize # <<<<<<<<<<<<<< @@ -1863,13 +2117,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_8filesize___get__ * @filesize.setter */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_attrs->filesize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_attrs->filesize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":59 + /* "ssh2/sftp_handle.pyx":61 * * @property * def filesize(self): # <<<<<<<<<<<<<< @@ -1888,7 +2142,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_8filesize___get__ return __pyx_r; } -/* "ssh2/sftp_handle.pyx":63 +/* "ssh2/sftp_handle.pyx":65 * * @filesize.setter * def filesize(self, c_ssh2.libssh2_uint64_t filesize): # <<<<<<<<<<<<<< @@ -1904,7 +2158,7 @@ static int __pyx_pw_4ssh2_11sftp_handle_14SFTPAttributes_8filesize_3__set__(PyOb __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_filesize); { - __pyx_v_filesize = __Pyx_PyInt_As_libssh2_uint64_t(__pyx_arg_filesize); if (unlikely((__pyx_v_filesize == ((libssh2_uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 63, __pyx_L3_error) + __pyx_v_filesize = __Pyx_PyInt_As_libssh2_uint64_t(__pyx_arg_filesize); if (unlikely((__pyx_v_filesize == ((libssh2_uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 65, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -1924,7 +2178,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_8filesize_2__set__(stru __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); - /* "ssh2/sftp_handle.pyx":64 + /* "ssh2/sftp_handle.pyx":66 * @filesize.setter * def filesize(self, c_ssh2.libssh2_uint64_t filesize): * self._attrs.filesize = filesize # <<<<<<<<<<<<<< @@ -1933,7 +2187,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_8filesize_2__set__(stru */ __pyx_v_self->_attrs->filesize = __pyx_v_filesize; - /* "ssh2/sftp_handle.pyx":63 + /* "ssh2/sftp_handle.pyx":65 * * @filesize.setter * def filesize(self, c_ssh2.libssh2_uint64_t filesize): # <<<<<<<<<<<<<< @@ -1947,7 +2201,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_8filesize_2__set__(stru return __pyx_r; } -/* "ssh2/sftp_handle.pyx":67 +/* "ssh2/sftp_handle.pyx":69 * * @property * def uid(self): # <<<<<<<<<<<<<< @@ -1974,7 +2228,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_3uid___get__(stru PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":68 + /* "ssh2/sftp_handle.pyx":70 * @property * def uid(self): * return self._attrs.uid # <<<<<<<<<<<<<< @@ -1982,13 +2236,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_3uid___get__(stru * @uid.setter */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->_attrs->uid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->_attrs->uid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":67 + /* "ssh2/sftp_handle.pyx":69 * * @property * def uid(self): # <<<<<<<<<<<<<< @@ -2007,7 +2261,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_3uid___get__(stru return __pyx_r; } -/* "ssh2/sftp_handle.pyx":71 +/* "ssh2/sftp_handle.pyx":73 * * @uid.setter * def uid(self, unsigned long uid): # <<<<<<<<<<<<<< @@ -2023,7 +2277,7 @@ static int __pyx_pw_4ssh2_11sftp_handle_14SFTPAttributes_3uid_3__set__(PyObject __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_uid); { - __pyx_v_uid = __Pyx_PyInt_As_unsigned_long(__pyx_arg_uid); if (unlikely((__pyx_v_uid == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 71, __pyx_L3_error) + __pyx_v_uid = __Pyx_PyInt_As_unsigned_long(__pyx_arg_uid); if (unlikely((__pyx_v_uid == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 73, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -2043,7 +2297,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_3uid_2__set__(struct __ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); - /* "ssh2/sftp_handle.pyx":72 + /* "ssh2/sftp_handle.pyx":74 * @uid.setter * def uid(self, unsigned long uid): * self._attrs.uid = uid # <<<<<<<<<<<<<< @@ -2052,7 +2306,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_3uid_2__set__(struct __ */ __pyx_v_self->_attrs->uid = __pyx_v_uid; - /* "ssh2/sftp_handle.pyx":71 + /* "ssh2/sftp_handle.pyx":73 * * @uid.setter * def uid(self, unsigned long uid): # <<<<<<<<<<<<<< @@ -2066,7 +2320,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_3uid_2__set__(struct __ return __pyx_r; } -/* "ssh2/sftp_handle.pyx":75 +/* "ssh2/sftp_handle.pyx":77 * * @property * def gid(self): # <<<<<<<<<<<<<< @@ -2093,7 +2347,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_3gid___get__(stru PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":76 + /* "ssh2/sftp_handle.pyx":78 * @property * def gid(self): * return self._attrs.gid # <<<<<<<<<<<<<< @@ -2101,13 +2355,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_3gid___get__(stru * @gid.setter */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->_attrs->gid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->_attrs->gid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":75 + /* "ssh2/sftp_handle.pyx":77 * * @property * def gid(self): # <<<<<<<<<<<<<< @@ -2126,7 +2380,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_3gid___get__(stru return __pyx_r; } -/* "ssh2/sftp_handle.pyx":79 +/* "ssh2/sftp_handle.pyx":81 * * @gid.setter * def gid(self, unsigned long gid): # <<<<<<<<<<<<<< @@ -2142,7 +2396,7 @@ static int __pyx_pw_4ssh2_11sftp_handle_14SFTPAttributes_3gid_3__set__(PyObject __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_gid); { - __pyx_v_gid = __Pyx_PyInt_As_unsigned_long(__pyx_arg_gid); if (unlikely((__pyx_v_gid == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 79, __pyx_L3_error) + __pyx_v_gid = __Pyx_PyInt_As_unsigned_long(__pyx_arg_gid); if (unlikely((__pyx_v_gid == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 81, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -2162,7 +2416,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_3gid_2__set__(struct __ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); - /* "ssh2/sftp_handle.pyx":80 + /* "ssh2/sftp_handle.pyx":82 * @gid.setter * def gid(self, unsigned long gid): * self._attrs.gid = gid # <<<<<<<<<<<<<< @@ -2171,7 +2425,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_3gid_2__set__(struct __ */ __pyx_v_self->_attrs->gid = __pyx_v_gid; - /* "ssh2/sftp_handle.pyx":79 + /* "ssh2/sftp_handle.pyx":81 * * @gid.setter * def gid(self, unsigned long gid): # <<<<<<<<<<<<<< @@ -2185,7 +2439,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_3gid_2__set__(struct __ return __pyx_r; } -/* "ssh2/sftp_handle.pyx":83 +/* "ssh2/sftp_handle.pyx":85 * * @property * def permissions(self): # <<<<<<<<<<<<<< @@ -2212,7 +2466,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_11permissions___g PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":84 + /* "ssh2/sftp_handle.pyx":86 * @property * def permissions(self): * return self._attrs.permissions # <<<<<<<<<<<<<< @@ -2220,13 +2474,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_11permissions___g * @permissions.setter */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->_attrs->permissions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->_attrs->permissions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":83 + /* "ssh2/sftp_handle.pyx":85 * * @property * def permissions(self): # <<<<<<<<<<<<<< @@ -2245,7 +2499,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_11permissions___g return __pyx_r; } -/* "ssh2/sftp_handle.pyx":87 +/* "ssh2/sftp_handle.pyx":89 * * @permissions.setter * def permissions(self, unsigned long permissions): # <<<<<<<<<<<<<< @@ -2261,7 +2515,7 @@ static int __pyx_pw_4ssh2_11sftp_handle_14SFTPAttributes_11permissions_3__set__( __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_permissions); { - __pyx_v_permissions = __Pyx_PyInt_As_unsigned_long(__pyx_arg_permissions); if (unlikely((__pyx_v_permissions == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 87, __pyx_L3_error) + __pyx_v_permissions = __Pyx_PyInt_As_unsigned_long(__pyx_arg_permissions); if (unlikely((__pyx_v_permissions == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 89, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -2281,7 +2535,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_11permissions_2__set__( __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); - /* "ssh2/sftp_handle.pyx":88 + /* "ssh2/sftp_handle.pyx":90 * @permissions.setter * def permissions(self, unsigned long permissions): * self._attrs.permissions = permissions # <<<<<<<<<<<<<< @@ -2290,7 +2544,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_11permissions_2__set__( */ __pyx_v_self->_attrs->permissions = __pyx_v_permissions; - /* "ssh2/sftp_handle.pyx":87 + /* "ssh2/sftp_handle.pyx":89 * * @permissions.setter * def permissions(self, unsigned long permissions): # <<<<<<<<<<<<<< @@ -2304,7 +2558,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_11permissions_2__set__( return __pyx_r; } -/* "ssh2/sftp_handle.pyx":91 +/* "ssh2/sftp_handle.pyx":93 * * @property * def atime(self): # <<<<<<<<<<<<<< @@ -2331,7 +2585,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5atime___get__(st PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":92 + /* "ssh2/sftp_handle.pyx":94 * @property * def atime(self): * return self._attrs.atime # <<<<<<<<<<<<<< @@ -2339,13 +2593,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5atime___get__(st * @atime.setter */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->_attrs->atime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->_attrs->atime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":91 + /* "ssh2/sftp_handle.pyx":93 * * @property * def atime(self): # <<<<<<<<<<<<<< @@ -2364,7 +2618,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5atime___get__(st return __pyx_r; } -/* "ssh2/sftp_handle.pyx":95 +/* "ssh2/sftp_handle.pyx":97 * * @atime.setter * def atime(self, unsigned long atime): # <<<<<<<<<<<<<< @@ -2380,7 +2634,7 @@ static int __pyx_pw_4ssh2_11sftp_handle_14SFTPAttributes_5atime_3__set__(PyObjec __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_atime); { - __pyx_v_atime = __Pyx_PyInt_As_unsigned_long(__pyx_arg_atime); if (unlikely((__pyx_v_atime == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 95, __pyx_L3_error) + __pyx_v_atime = __Pyx_PyInt_As_unsigned_long(__pyx_arg_atime); if (unlikely((__pyx_v_atime == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 97, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -2400,7 +2654,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5atime_2__set__(struct __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); - /* "ssh2/sftp_handle.pyx":96 + /* "ssh2/sftp_handle.pyx":98 * @atime.setter * def atime(self, unsigned long atime): * self._attrs.atime = atime # <<<<<<<<<<<<<< @@ -2409,7 +2663,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5atime_2__set__(struct */ __pyx_v_self->_attrs->atime = __pyx_v_atime; - /* "ssh2/sftp_handle.pyx":95 + /* "ssh2/sftp_handle.pyx":97 * * @atime.setter * def atime(self, unsigned long atime): # <<<<<<<<<<<<<< @@ -2423,7 +2677,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5atime_2__set__(struct return __pyx_r; } -/* "ssh2/sftp_handle.pyx":99 +/* "ssh2/sftp_handle.pyx":101 * * @property * def mtime(self): # <<<<<<<<<<<<<< @@ -2450,7 +2704,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5mtime___get__(st PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":100 + /* "ssh2/sftp_handle.pyx":102 * @property * def mtime(self): * return self._attrs.mtime # <<<<<<<<<<<<<< @@ -2458,13 +2712,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5mtime___get__(st * @mtime.setter */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->_attrs->mtime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->_attrs->mtime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":99 + /* "ssh2/sftp_handle.pyx":101 * * @property * def mtime(self): # <<<<<<<<<<<<<< @@ -2483,7 +2737,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5mtime___get__(st return __pyx_r; } -/* "ssh2/sftp_handle.pyx":103 +/* "ssh2/sftp_handle.pyx":105 * * @mtime.setter * def mtime(self, unsigned long mtime): # <<<<<<<<<<<<<< @@ -2499,7 +2753,7 @@ static int __pyx_pw_4ssh2_11sftp_handle_14SFTPAttributes_5mtime_3__set__(PyObjec __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); assert(__pyx_arg_mtime); { - __pyx_v_mtime = __Pyx_PyInt_As_unsigned_long(__pyx_arg_mtime); if (unlikely((__pyx_v_mtime == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 103, __pyx_L3_error) + __pyx_v_mtime = __Pyx_PyInt_As_unsigned_long(__pyx_arg_mtime); if (unlikely((__pyx_v_mtime == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 105, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -2519,7 +2773,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5mtime_2__set__(struct __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__", 0); - /* "ssh2/sftp_handle.pyx":104 + /* "ssh2/sftp_handle.pyx":106 * @mtime.setter * def mtime(self, unsigned long mtime): * self._attrs.mtime = mtime # <<<<<<<<<<<<<< @@ -2528,7 +2782,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_5mtime_2__set__(struct */ __pyx_v_self->_attrs->mtime = __pyx_v_mtime; - /* "ssh2/sftp_handle.pyx":103 + /* "ssh2/sftp_handle.pyx":105 * * @mtime.setter * def mtime(self, unsigned long mtime): # <<<<<<<<<<<<<< @@ -2651,7 +2905,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_14SFTPAttributes_6__setstate_cytho return __pyx_r; } -/* "ssh2/sftp_handle.pyx":109 +/* "ssh2/sftp_handle.pyx":111 * cdef class SFTPHandle: * * def __cinit__(self, sftp): # <<<<<<<<<<<<<< @@ -2685,7 +2939,7 @@ static int __pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_1__cinit__(PyObject *__pyx_ else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 109, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 111, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -2696,7 +2950,7 @@ static int __pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_1__cinit__(PyObject *__pyx_ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 109, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 111, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp_handle.SFTPHandle.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -2715,7 +2969,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle___cinit__(struct __pyx_obj_ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "ssh2/sftp_handle.pyx":110 + /* "ssh2/sftp_handle.pyx":112 * * def __cinit__(self, sftp): * self._handle = NULL # <<<<<<<<<<<<<< @@ -2724,14 +2978,14 @@ static int __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle___cinit__(struct __pyx_obj_ */ __pyx_v_self->_handle = NULL; - /* "ssh2/sftp_handle.pyx":111 + /* "ssh2/sftp_handle.pyx":113 * def __cinit__(self, sftp): * self._handle = NULL * self._sftp = sftp # <<<<<<<<<<<<<< * self.closed = 0 * */ - if (!(likely(((__pyx_v_sftp) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_sftp, __pyx_ptype_4ssh2_4sftp_SFTP))))) __PYX_ERR(0, 111, __pyx_L1_error) + if (!(likely(((__pyx_v_sftp) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_sftp, __pyx_ptype_4ssh2_4sftp_SFTP))))) __PYX_ERR(0, 113, __pyx_L1_error) __pyx_t_1 = __pyx_v_sftp; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -2740,7 +2994,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle___cinit__(struct __pyx_obj_ __pyx_v_self->_sftp = ((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp_handle.pyx":112 + /* "ssh2/sftp_handle.pyx":114 * self._handle = NULL * self._sftp = sftp * self.closed = 0 # <<<<<<<<<<<<<< @@ -2749,7 +3003,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle___cinit__(struct __pyx_obj_ */ __pyx_v_self->closed = 0; - /* "ssh2/sftp_handle.pyx":109 + /* "ssh2/sftp_handle.pyx":111 * cdef class SFTPHandle: * * def __cinit__(self, sftp): # <<<<<<<<<<<<<< @@ -2769,7 +3023,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle___cinit__(struct __pyx_obj_ return __pyx_r; } -/* "ssh2/sftp_handle.pyx":114 +/* "ssh2/sftp_handle.pyx":116 * self.closed = 0 * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -2793,7 +3047,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_2__dealloc__(struct __pyx_ int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "ssh2/sftp_handle.pyx":115 + /* "ssh2/sftp_handle.pyx":117 * * def __dealloc__(self): * if self.closed == 0: # <<<<<<<<<<<<<< @@ -2803,7 +3057,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_2__dealloc__(struct __pyx_ __pyx_t_1 = ((__pyx_v_self->closed == 0) != 0); if (__pyx_t_1) { - /* "ssh2/sftp_handle.pyx":116 + /* "ssh2/sftp_handle.pyx":118 * def __dealloc__(self): * if self.closed == 0: * with nogil: # <<<<<<<<<<<<<< @@ -2818,7 +3072,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_2__dealloc__(struct __pyx_ #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":117 + /* "ssh2/sftp_handle.pyx":119 * if self.closed == 0: * with nogil: * c_sftp.libssh2_sftp_close_handle(self._handle) # <<<<<<<<<<<<<< @@ -2828,7 +3082,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_2__dealloc__(struct __pyx_ libssh2_sftp_close_handle(__pyx_v_self->_handle); } - /* "ssh2/sftp_handle.pyx":116 + /* "ssh2/sftp_handle.pyx":118 * def __dealloc__(self): * if self.closed == 0: * with nogil: # <<<<<<<<<<<<<< @@ -2847,7 +3101,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_2__dealloc__(struct __pyx_ } } - /* "ssh2/sftp_handle.pyx":118 + /* "ssh2/sftp_handle.pyx":120 * with nogil: * c_sftp.libssh2_sftp_close_handle(self._handle) * self.closed = 1 # <<<<<<<<<<<<<< @@ -2856,7 +3110,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_2__dealloc__(struct __pyx_ */ __pyx_v_self->closed = 1; - /* "ssh2/sftp_handle.pyx":115 + /* "ssh2/sftp_handle.pyx":117 * * def __dealloc__(self): * if self.closed == 0: # <<<<<<<<<<<<<< @@ -2865,7 +3119,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_2__dealloc__(struct __pyx_ */ } - /* "ssh2/sftp_handle.pyx":114 + /* "ssh2/sftp_handle.pyx":116 * self.closed = 0 * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -2877,7 +3131,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_2__dealloc__(struct __pyx_ __Pyx_RefNannyFinishContext(); } -/* "ssh2/sftp_handle.pyx":120 +/* "ssh2/sftp_handle.pyx":122 * self.closed = 1 * * def __iter__(self): # <<<<<<<<<<<<<< @@ -2903,7 +3157,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_4__iter__(struct __py __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__iter__", 0); - /* "ssh2/sftp_handle.pyx":121 + /* "ssh2/sftp_handle.pyx":123 * * def __iter__(self): * return self # <<<<<<<<<<<<<< @@ -2915,7 +3169,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_4__iter__(struct __py __pyx_r = ((PyObject *)__pyx_v_self); goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":120 + /* "ssh2/sftp_handle.pyx":122 * self.closed = 1 * * def __iter__(self): # <<<<<<<<<<<<<< @@ -2930,7 +3184,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_4__iter__(struct __py return __pyx_r; } -/* "ssh2/sftp_handle.pyx":123 +/* "ssh2/sftp_handle.pyx":125 * return self * * def __next__(self): # <<<<<<<<<<<<<< @@ -2964,17 +3218,16 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_6__next__(struct __py int __pyx_t_6; int __pyx_t_7; int __pyx_t_8; - Py_ssize_t __pyx_t_9; __Pyx_RefNannySetupContext("__next__", 0); - /* "ssh2/sftp_handle.pyx":126 + /* "ssh2/sftp_handle.pyx":128 * cdef int rc * cdef bytes data * rc, data = self.read() # <<<<<<<<<<<<<< - * if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and len(data) == 0: + * if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc <= 0: * raise StopIteration */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { @@ -2987,10 +3240,10 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_6__next__(struct __py } } if (__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -3004,7 +3257,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_6__next__(struct __py if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 126, __pyx_L1_error) + __PYX_ERR(0, 128, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { @@ -3017,15 +3270,15 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_6__next__(struct __py __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else - __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; - __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext; @@ -3033,7 +3286,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_6__next__(struct __py __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(0, 126, __pyx_L1_error) + if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(0, 128, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L4_unpacking_done; @@ -3041,20 +3294,20 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_6__next__(struct __py __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 126, __pyx_L1_error) + __PYX_ERR(0, 128, __pyx_L1_error) __pyx_L4_unpacking_done:; } - __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 126, __pyx_L1_error) + if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 128, __pyx_L1_error) __pyx_v_rc = __pyx_t_6; __pyx_v_data = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; - /* "ssh2/sftp_handle.pyx":127 + /* "ssh2/sftp_handle.pyx":129 * cdef bytes data * rc, data = self.read() - * if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and len(data) == 0: # <<<<<<<<<<<<<< + * if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc <= 0: # <<<<<<<<<<<<<< * raise StopIteration * return rc, data */ @@ -3064,46 +3317,41 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_6__next__(struct __py __pyx_t_7 = __pyx_t_8; goto __pyx_L6_bool_binop_done; } - if (unlikely(__pyx_v_data == Py_None)) { - PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 127, __pyx_L1_error) - } - __pyx_t_9 = PyBytes_GET_SIZE(__pyx_v_data); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 127, __pyx_L1_error) - __pyx_t_8 = ((__pyx_t_9 == 0) != 0); + __pyx_t_8 = ((__pyx_v_rc <= 0) != 0); __pyx_t_7 = __pyx_t_8; __pyx_L6_bool_binop_done:; if (__pyx_t_7) { - /* "ssh2/sftp_handle.pyx":128 + /* "ssh2/sftp_handle.pyx":130 * rc, data = self.read() - * if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and len(data) == 0: + * if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc <= 0: * raise StopIteration # <<<<<<<<<<<<<< * return rc, data * */ __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0); - __PYX_ERR(0, 128, __pyx_L1_error) + __PYX_ERR(0, 130, __pyx_L1_error) - /* "ssh2/sftp_handle.pyx":127 + /* "ssh2/sftp_handle.pyx":129 * cdef bytes data * rc, data = self.read() - * if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and len(data) == 0: # <<<<<<<<<<<<<< + * if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc <= 0: # <<<<<<<<<<<<<< * raise StopIteration * return rc, data */ } - /* "ssh2/sftp_handle.pyx":129 - * if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and len(data) == 0: + /* "ssh2/sftp_handle.pyx":131 + * if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc <= 0: * raise StopIteration * return rc, data # <<<<<<<<<<<<<< * * def __enter__(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 129, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); @@ -3115,7 +3363,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_6__next__(struct __py __pyx_t_3 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":123 + /* "ssh2/sftp_handle.pyx":125 * return self * * def __next__(self): # <<<<<<<<<<<<<< @@ -3138,7 +3386,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_6__next__(struct __py return __pyx_r; } -/* "ssh2/sftp_handle.pyx":131 +/* "ssh2/sftp_handle.pyx":133 * return rc, data * * def __enter__(self): # <<<<<<<<<<<<<< @@ -3165,7 +3413,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_8__enter__(struct __p __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__enter__", 0); - /* "ssh2/sftp_handle.pyx":132 + /* "ssh2/sftp_handle.pyx":134 * * def __enter__(self): * return self # <<<<<<<<<<<<<< @@ -3177,7 +3425,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_8__enter__(struct __p __pyx_r = ((PyObject *)__pyx_v_self); goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":131 + /* "ssh2/sftp_handle.pyx":133 * return rc, data * * def __enter__(self): # <<<<<<<<<<<<<< @@ -3192,7 +3440,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_8__enter__(struct __p return __pyx_r; } -/* "ssh2/sftp_handle.pyx":134 +/* "ssh2/sftp_handle.pyx":136 * return self * * def __exit__(self, *args): # <<<<<<<<<<<<<< @@ -3227,14 +3475,14 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_10__exit__(struct __p PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("__exit__", 0); - /* "ssh2/sftp_handle.pyx":135 + /* "ssh2/sftp_handle.pyx":137 * * def __exit__(self, *args): * self.close() # <<<<<<<<<<<<<< * * def close(self): */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_close); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_close); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { @@ -3247,16 +3495,16 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_10__exit__(struct __p } } if (__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp_handle.pyx":134 + /* "ssh2/sftp_handle.pyx":136 * return self * * def __exit__(self, *args): # <<<<<<<<<<<<<< @@ -3279,7 +3527,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_10__exit__(struct __p return __pyx_r; } -/* "ssh2/sftp_handle.pyx":137 +/* "ssh2/sftp_handle.pyx":139 * self.close() * * def close(self): # <<<<<<<<<<<<<< @@ -3309,7 +3557,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_12close(struct __pyx_ PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("close", 0); - /* "ssh2/sftp_handle.pyx":143 + /* "ssh2/sftp_handle.pyx":145 * :rtype: int""" * cdef int rc * if self.closed == 0: # <<<<<<<<<<<<<< @@ -3319,7 +3567,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_12close(struct __pyx_ __pyx_t_1 = ((__pyx_v_self->closed == 0) != 0); if (__pyx_t_1) { - /* "ssh2/sftp_handle.pyx":144 + /* "ssh2/sftp_handle.pyx":146 * cdef int rc * if self.closed == 0: * with nogil: # <<<<<<<<<<<<<< @@ -3334,7 +3582,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_12close(struct __pyx_ #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":145 + /* "ssh2/sftp_handle.pyx":147 * if self.closed == 0: * with nogil: * rc = c_sftp.libssh2_sftp_close_handle(self._handle) # <<<<<<<<<<<<<< @@ -3344,7 +3592,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_12close(struct __pyx_ __pyx_v_rc = libssh2_sftp_close_handle(__pyx_v_self->_handle); } - /* "ssh2/sftp_handle.pyx":144 + /* "ssh2/sftp_handle.pyx":146 * cdef int rc * if self.closed == 0: * with nogil: # <<<<<<<<<<<<<< @@ -3363,7 +3611,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_12close(struct __pyx_ } } - /* "ssh2/sftp_handle.pyx":146 + /* "ssh2/sftp_handle.pyx":148 * with nogil: * rc = c_sftp.libssh2_sftp_close_handle(self._handle) * self.closed = 1 # <<<<<<<<<<<<<< @@ -3372,7 +3620,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_12close(struct __pyx_ */ __pyx_v_self->closed = 1; - /* "ssh2/sftp_handle.pyx":143 + /* "ssh2/sftp_handle.pyx":145 * :rtype: int""" * cdef int rc * if self.closed == 0: # <<<<<<<<<<<<<< @@ -3382,7 +3630,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_12close(struct __pyx_ goto __pyx_L3; } - /* "ssh2/sftp_handle.pyx":148 + /* "ssh2/sftp_handle.pyx":150 * self.closed = 1 * else: * return # <<<<<<<<<<<<<< @@ -3396,7 +3644,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_12close(struct __pyx_ } __pyx_L3:; - /* "ssh2/sftp_handle.pyx":149 + /* "ssh2/sftp_handle.pyx":151 * else: * return * return rc # <<<<<<<<<<<<<< @@ -3404,13 +3652,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_12close(struct __pyx_ * def read(self, size_t buffer_maxlen=c_ssh2.LIBSSH2_CHANNEL_WINDOW_DEFAULT): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":137 + /* "ssh2/sftp_handle.pyx":139 * self.close() * * def close(self): # <<<<<<<<<<<<<< @@ -3429,7 +3677,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_12close(struct __pyx_ return __pyx_r; } -/* "ssh2/sftp_handle.pyx":151 +/* "ssh2/sftp_handle.pyx":153 * return rc * * def read(self, size_t buffer_maxlen=c_ssh2.LIBSSH2_CHANNEL_WINDOW_DEFAULT): # <<<<<<<<<<<<<< @@ -3466,7 +3714,7 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_15read(PyObject *__py } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read") < 0)) __PYX_ERR(0, 151, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read") < 0)) __PYX_ERR(0, 153, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -3477,14 +3725,14 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_15read(PyObject *__py } } if (values[0]) { - __pyx_v_buffer_maxlen = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_buffer_maxlen == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 151, __pyx_L3_error) + __pyx_v_buffer_maxlen = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_buffer_maxlen == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 153, __pyx_L3_error) } else { __pyx_v_buffer_maxlen = __pyx_k__3; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("read", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 151, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("read", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 153, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp_handle.SFTPHandle.read", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -3518,7 +3766,17 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_14read(struct __pyx_o __Pyx_RefNannySetupContext("read", 0); /* "ssh2/sftp_handle.pyx":161 - * cdef bytes buf + * :rtype: bytes""" + * cdef ssize_t rc + * cdef bytes buf = b'' # <<<<<<<<<<<<<< + * cdef char *cbuf + * with nogil: + */ + __Pyx_INCREF(__pyx_kp_b__4); + __pyx_v_buf = __pyx_kp_b__4; + + /* "ssh2/sftp_handle.pyx":163 + * cdef bytes buf = b'' * cdef char *cbuf * with nogil: # <<<<<<<<<<<<<< * cbuf = malloc(sizeof(char)*buffer_maxlen) @@ -3532,7 +3790,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_14read(struct __pyx_o #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":162 + /* "ssh2/sftp_handle.pyx":164 * cdef char *cbuf * with nogil: * cbuf = malloc(sizeof(char)*buffer_maxlen) # <<<<<<<<<<<<<< @@ -3541,7 +3799,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_14read(struct __pyx_o */ __pyx_v_cbuf = ((char *)malloc(((sizeof(char)) * __pyx_v_buffer_maxlen))); - /* "ssh2/sftp_handle.pyx":163 + /* "ssh2/sftp_handle.pyx":165 * with nogil: * cbuf = malloc(sizeof(char)*buffer_maxlen) * if cbuf is NULL: # <<<<<<<<<<<<<< @@ -3551,7 +3809,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_14read(struct __pyx_o __pyx_t_1 = ((__pyx_v_cbuf == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/sftp_handle.pyx":164 + /* "ssh2/sftp_handle.pyx":166 * cbuf = malloc(sizeof(char)*buffer_maxlen) * if cbuf is NULL: * with gil: # <<<<<<<<<<<<<< @@ -3564,17 +3822,17 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_14read(struct __pyx_o #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":165 + /* "ssh2/sftp_handle.pyx":167 * if cbuf is NULL: * with gil: * raise MemoryError # <<<<<<<<<<<<<< * rc = c_sftp.libssh2_sftp_read( * self._handle, cbuf, buffer_maxlen) */ - PyErr_NoMemory(); __PYX_ERR(0, 165, __pyx_L8_error) + PyErr_NoMemory(); __PYX_ERR(0, 167, __pyx_L8_error) } - /* "ssh2/sftp_handle.pyx":164 + /* "ssh2/sftp_handle.pyx":166 * cbuf = malloc(sizeof(char)*buffer_maxlen) * if cbuf is NULL: * with gil: # <<<<<<<<<<<<<< @@ -3591,7 +3849,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_14read(struct __pyx_o } } - /* "ssh2/sftp_handle.pyx":163 + /* "ssh2/sftp_handle.pyx":165 * with nogil: * cbuf = malloc(sizeof(char)*buffer_maxlen) * if cbuf is NULL: # <<<<<<<<<<<<<< @@ -3600,7 +3858,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_14read(struct __pyx_o */ } - /* "ssh2/sftp_handle.pyx":166 + /* "ssh2/sftp_handle.pyx":168 * with gil: * raise MemoryError * rc = c_sftp.libssh2_sftp_read( # <<<<<<<<<<<<<< @@ -3610,8 +3868,8 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_14read(struct __pyx_o __pyx_v_rc = libssh2_sftp_read(__pyx_v_self->_handle, __pyx_v_cbuf, __pyx_v_buffer_maxlen); } - /* "ssh2/sftp_handle.pyx":161 - * cdef bytes buf + /* "ssh2/sftp_handle.pyx":163 + * cdef bytes buf = b'' * cdef char *cbuf * with nogil: # <<<<<<<<<<<<<< * cbuf = malloc(sizeof(char)*buffer_maxlen) @@ -3636,7 +3894,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_14read(struct __pyx_o } } - /* "ssh2/sftp_handle.pyx":168 + /* "ssh2/sftp_handle.pyx":170 * rc = c_sftp.libssh2_sftp_read( * self._handle, cbuf, buffer_maxlen) * try: # <<<<<<<<<<<<<< @@ -3645,54 +3903,40 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_14read(struct __pyx_o */ /*try:*/ { - /* "ssh2/sftp_handle.pyx":169 + /* "ssh2/sftp_handle.pyx":171 * self._handle, cbuf, buffer_maxlen) * try: * if rc > 0: # <<<<<<<<<<<<<< * buf = cbuf[:rc] - * else: + * finally: */ __pyx_t_1 = ((__pyx_v_rc > 0) != 0); if (__pyx_t_1) { - /* "ssh2/sftp_handle.pyx":170 + /* "ssh2/sftp_handle.pyx":172 * try: * if rc > 0: * buf = cbuf[:rc] # <<<<<<<<<<<<<< - * else: - * buf = b'' + * finally: + * free(cbuf) */ - __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_cbuf + 0, __pyx_v_rc - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 170, __pyx_L11_error) + __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_cbuf + 0, __pyx_v_rc - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_v_buf = ((PyObject*)__pyx_t_2); + __Pyx_DECREF_SET(__pyx_v_buf, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0; - /* "ssh2/sftp_handle.pyx":169 + /* "ssh2/sftp_handle.pyx":171 * self._handle, cbuf, buffer_maxlen) * try: * if rc > 0: # <<<<<<<<<<<<<< * buf = cbuf[:rc] - * else: - */ - goto __pyx_L13; - } - - /* "ssh2/sftp_handle.pyx":172 - * buf = cbuf[:rc] - * else: - * buf = b'' # <<<<<<<<<<<<<< * finally: - * free(cbuf) */ - /*else*/ { - __Pyx_INCREF(__pyx_kp_b__4); - __pyx_v_buf = __pyx_kp_b__4; } - __pyx_L13:; } /* "ssh2/sftp_handle.pyx":174 - * buf = b'' + * buf = cbuf[:rc] * finally: * free(cbuf) # <<<<<<<<<<<<<< * return rc, buf @@ -3721,7 +3965,6 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_14read(struct __pyx_o { free(__pyx_v_cbuf); } - __Pyx_PyThreadState_assign if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); @@ -3761,7 +4004,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_14read(struct __pyx_o __pyx_t_12 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":151 + /* "ssh2/sftp_handle.pyx":153 * return rc * * def read(self, size_t buffer_maxlen=c_ssh2.LIBSSH2_CHANNEL_WINDOW_DEFAULT): # <<<<<<<<<<<<<< @@ -3781,7 +4024,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_14read(struct __pyx_o __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* "ssh2/sftp_handle.pyx":177 * return rc, buf @@ -3793,7 +4036,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor /* Python wrapper */ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_17readdir_ex(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_4ssh2_11sftp_handle_10SFTPHandle_16readdir_ex[] = "SFTPHandle.readdir_ex(self, size_t longentry_maxlen=1024, size_t buffer_maxlen=1024)\nGet directory listing from file handle, if any.\n\n File handle *must* be opened with :py:func:`ssh2.sftp.SFTP.readdir()`\n\n This function is a generator and should be iterated on.\n\n :param buffer_maxlen: Max length of returned buffer.\n :param longentry_maxlen: Max length of filename in listing.\n\n :rtype: bytes"; +static char __pyx_doc_4ssh2_11sftp_handle_10SFTPHandle_16readdir_ex[] = "SFTPHandle.readdir_ex(self, size_t longentry_maxlen=1024, size_t buffer_maxlen=1024)\nGet directory listing from file handle, if any.\n\n File handle *must* be opened with :py:func:`ssh2.sftp.SFTP.readdir()`\n\n This function is a generator and should be iterated on.\n\n :param buffer_maxlen: Max length of returned buffer.\n :param longentry_maxlen: Max length of file list entry.\n\n :rtype: bytes\n "; static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_17readdir_ex(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { size_t __pyx_v_longentry_maxlen; size_t __pyx_v_buffer_maxlen; @@ -3902,7 +4145,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_16readdir_ex(struct _ return __pyx_r; } -static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ { struct __pyx_obj_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex *__pyx_cur_scope = ((struct __pyx_obj_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex *)__pyx_generator->closure); PyObject *__pyx_r = NULL; @@ -3915,9 +4158,8 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor PyObject *(*__pyx_t_7)(PyObject *); int __pyx_t_8; int __pyx_t_9; - Py_ssize_t __pyx_t_10; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("None", 0); + __Pyx_RefNannySetupContext("readdir_ex", 0); switch (__pyx_generator->resume_label) { case 0: goto __pyx_L3_first_run; case 1: goto __pyx_L10_resume_from_yield; @@ -3928,50 +4170,50 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 177, __pyx_L1_error) - /* "ssh2/sftp_handle.pyx":190 - * - * :rtype: bytes""" + /* "ssh2/sftp_handle.pyx":191 + * :rtype: bytes + * """ * rc, buf, entry, attrs = self._readdir_ex( # <<<<<<<<<<<<<< * longentry_maxlen=longentry_maxlen, * buffer_maxlen=buffer_maxlen) */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_readdir_ex_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_readdir_ex_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - /* "ssh2/sftp_handle.pyx":191 - * :rtype: bytes""" + /* "ssh2/sftp_handle.pyx":192 + * """ * rc, buf, entry, attrs = self._readdir_ex( * longentry_maxlen=longentry_maxlen, # <<<<<<<<<<<<<< * buffer_maxlen=buffer_maxlen) - * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or len(buf) > 0: + * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or rc > 0: */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_cur_scope->__pyx_v_longentry_maxlen); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 191, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_cur_scope->__pyx_v_longentry_maxlen); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_longentry_maxlen, __pyx_t_3) < 0) __PYX_ERR(0, 191, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_longentry_maxlen, __pyx_t_3) < 0) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "ssh2/sftp_handle.pyx":192 + /* "ssh2/sftp_handle.pyx":193 * rc, buf, entry, attrs = self._readdir_ex( * longentry_maxlen=longentry_maxlen, * buffer_maxlen=buffer_maxlen) # <<<<<<<<<<<<<< - * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or len(buf) > 0: + * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or rc > 0: * yield rc, buf, entry, attrs */ - __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_cur_scope->__pyx_v_buffer_maxlen); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_cur_scope->__pyx_v_buffer_maxlen); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_buffer_maxlen, __pyx_t_3) < 0) __PYX_ERR(0, 191, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_buffer_maxlen, __pyx_t_3) < 0) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "ssh2/sftp_handle.pyx":190 - * - * :rtype: bytes""" + /* "ssh2/sftp_handle.pyx":191 + * :rtype: bytes + * """ * rc, buf, entry, attrs = self._readdir_ex( # <<<<<<<<<<<<<< * longentry_maxlen=longentry_maxlen, * buffer_maxlen=buffer_maxlen) */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -3985,7 +4227,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor if (unlikely(size != 4)) { if (size > 4) __Pyx_RaiseTooManyValuesError(4); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 190, __pyx_L1_error) + __PYX_ERR(0, 191, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { @@ -4008,7 +4250,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor Py_ssize_t i; PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_1,&__pyx_t_4,&__pyx_t_5}; for (i=0; i < 4; i++) { - PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 190, __pyx_L1_error) + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(item); *(temps[i]) = item; } @@ -4018,7 +4260,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor } else { Py_ssize_t index = -1; PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_1,&__pyx_t_4,&__pyx_t_5}; - __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 190, __pyx_L1_error) + __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext; @@ -4027,7 +4269,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor __Pyx_GOTREF(item); *(temps[index]) = item; } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 190, __pyx_L1_error) + if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 191, __pyx_L1_error) __pyx_t_7 = NULL; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L5_unpacking_done; @@ -4035,7 +4277,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 190, __pyx_L1_error) + __PYX_ERR(0, 191, __pyx_L1_error) __pyx_L5_unpacking_done:; } __Pyx_GIVEREF(__pyx_t_2); @@ -4051,39 +4293,40 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor __pyx_cur_scope->__pyx_v_attrs = __pyx_t_5; __pyx_t_5 = 0; - /* "ssh2/sftp_handle.pyx":193 + /* "ssh2/sftp_handle.pyx":194 * longentry_maxlen=longentry_maxlen, * buffer_maxlen=buffer_maxlen) - * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or len(buf) > 0: # <<<<<<<<<<<<<< + * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or rc > 0: # <<<<<<<<<<<<<< * yield rc, buf, entry, attrs * rc, buf, entryb, attrs = self._readdir_ex( */ while (1) { - __pyx_t_3 = __Pyx_PyInt_From_int(LIBSSH2_ERROR_EAGAIN); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(LIBSSH2_ERROR_EAGAIN); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_rc, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 193, __pyx_L1_error) + __pyx_t_5 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_rc, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 193, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (!__pyx_t_9) { } else { __pyx_t_8 = __pyx_t_9; goto __pyx_L8_bool_binop_done; } - __pyx_t_10 = PyObject_Length(__pyx_cur_scope->__pyx_v_buf); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 193, __pyx_L1_error) - __pyx_t_9 = ((__pyx_t_10 > 0) != 0); + __pyx_t_5 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_rc, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 194, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 194, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_8 = __pyx_t_9; __pyx_L8_bool_binop_done:; if (!__pyx_t_8) break; - /* "ssh2/sftp_handle.pyx":194 + /* "ssh2/sftp_handle.pyx":195 * buffer_maxlen=buffer_maxlen) - * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or len(buf) > 0: + * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or rc > 0: * yield rc, buf, entry, attrs # <<<<<<<<<<<<<< * rc, buf, entryb, attrs = self._readdir_ex( * longentry_maxlen=longentry_maxlen, */ - __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 194, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_rc); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_rc); @@ -4101,56 +4344,57 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor __pyx_t_5 = 0; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); + __Pyx_Coroutine_ResetAndClearException(__pyx_generator); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L10_resume_from_yield:; - if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 194, __pyx_L1_error) + if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 195, __pyx_L1_error) - /* "ssh2/sftp_handle.pyx":195 - * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or len(buf) > 0: + /* "ssh2/sftp_handle.pyx":196 + * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or rc > 0: * yield rc, buf, entry, attrs * rc, buf, entryb, attrs = self._readdir_ex( # <<<<<<<<<<<<<< * longentry_maxlen=longentry_maxlen, * buffer_maxlen=buffer_maxlen) */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_readdir_ex_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 195, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_readdir_ex_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - /* "ssh2/sftp_handle.pyx":196 + /* "ssh2/sftp_handle.pyx":197 * yield rc, buf, entry, attrs * rc, buf, entryb, attrs = self._readdir_ex( * longentry_maxlen=longentry_maxlen, # <<<<<<<<<<<<<< * buffer_maxlen=buffer_maxlen) * */ - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 196, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 197, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_cur_scope->__pyx_v_longentry_maxlen); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 196, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_cur_scope->__pyx_v_longentry_maxlen); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 197, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_longentry_maxlen, __pyx_t_4) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_longentry_maxlen, __pyx_t_4) < 0) __PYX_ERR(0, 197, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "ssh2/sftp_handle.pyx":197 + /* "ssh2/sftp_handle.pyx":198 * rc, buf, entryb, attrs = self._readdir_ex( * longentry_maxlen=longentry_maxlen, * buffer_maxlen=buffer_maxlen) # <<<<<<<<<<<<<< * * def _readdir_ex(self, */ - __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_cur_scope->__pyx_v_buffer_maxlen); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 197, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_cur_scope->__pyx_v_buffer_maxlen); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_buffer_maxlen, __pyx_t_4) < 0) __PYX_ERR(0, 196, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_buffer_maxlen, __pyx_t_4) < 0) __PYX_ERR(0, 197, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "ssh2/sftp_handle.pyx":195 - * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or len(buf) > 0: + /* "ssh2/sftp_handle.pyx":196 + * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or rc > 0: * yield rc, buf, entry, attrs * rc, buf, entryb, attrs = self._readdir_ex( # <<<<<<<<<<<<<< * longentry_maxlen=longentry_maxlen, * buffer_maxlen=buffer_maxlen) */ - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 195, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -4164,7 +4408,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor if (unlikely(size != 4)) { if (size > 4) __Pyx_RaiseTooManyValuesError(4); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 195, __pyx_L1_error) + __PYX_ERR(0, 196, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { @@ -4187,7 +4431,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor Py_ssize_t i; PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_5,&__pyx_t_1,&__pyx_t_2}; for (i=0; i < 4; i++) { - PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 195, __pyx_L1_error) + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(item); *(temps[i]) = item; } @@ -4197,7 +4441,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor } else { Py_ssize_t index = -1; PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_5,&__pyx_t_1,&__pyx_t_2}; - __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 195, __pyx_L1_error) + __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext; @@ -4206,7 +4450,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor __Pyx_GOTREF(item); *(temps[index]) = item; } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 195, __pyx_L1_error) + if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 196, __pyx_L1_error) __pyx_t_7 = NULL; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L12_unpacking_done; @@ -4214,7 +4458,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 195, __pyx_L1_error) + __PYX_ERR(0, 196, __pyx_L1_error) __pyx_L12_unpacking_done:; } __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_rc); @@ -4257,13 +4501,14 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_18generator(__pyx_Cor __Pyx_AddTraceback("readdir_ex", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); __pyx_r = 0; + __Pyx_Coroutine_ResetAndClearException(__pyx_generator); __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "ssh2/sftp_handle.pyx":199 +/* "ssh2/sftp_handle.pyx":200 * buffer_maxlen=buffer_maxlen) * * def _readdir_ex(self, # <<<<<<<<<<<<<< @@ -4309,7 +4554,7 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_20_readdir_ex(PyObjec } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_readdir_ex") < 0)) __PYX_ERR(0, 199, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_readdir_ex") < 0)) __PYX_ERR(0, 200, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -4322,19 +4567,19 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_20_readdir_ex(PyObjec } } if (values[0]) { - __pyx_v_longentry_maxlen = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_longentry_maxlen == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L3_error) + __pyx_v_longentry_maxlen = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_longentry_maxlen == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 201, __pyx_L3_error) } else { __pyx_v_longentry_maxlen = ((size_t)0x400); } if (values[1]) { - __pyx_v_buffer_maxlen = __Pyx_PyInt_As_size_t(values[1]); if (unlikely((__pyx_v_buffer_maxlen == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 201, __pyx_L3_error) + __pyx_v_buffer_maxlen = __Pyx_PyInt_As_size_t(values[1]); if (unlikely((__pyx_v_buffer_maxlen == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 202, __pyx_L3_error) } else { __pyx_v_buffer_maxlen = ((size_t)0x400); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_readdir_ex", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 199, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_readdir_ex", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 200, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp_handle.SFTPHandle._readdir_ex", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -4349,6 +4594,7 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_20_readdir_ex(PyObjec static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct __pyx_obj_4ssh2_11sftp_handle_SFTPHandle *__pyx_v_self, size_t __pyx_v_longentry_maxlen, size_t __pyx_v_buffer_maxlen) { PyObject *__pyx_v_buf = 0; + PyObject *__pyx_v_b_longentry = 0; char *__pyx_v_cbuf; char *__pyx_v_longentry; struct __pyx_obj_4ssh2_11sftp_handle_SFTPAttributes *__pyx_v_attrs = 0; @@ -4368,22 +4614,41 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; - PyObject *__pyx_t_14 = NULL; __Pyx_RefNannySetupContext("_readdir_ex", 0); - /* "ssh2/sftp_handle.pyx":206 + /* "ssh2/sftp_handle.pyx":203 + * size_t longentry_maxlen=1024, + * size_t buffer_maxlen=1024): + * cdef bytes buf = b'' # <<<<<<<<<<<<<< + * cdef bytes b_longentry = b'' + * cdef char *cbuf + */ + __Pyx_INCREF(__pyx_kp_b__4); + __pyx_v_buf = __pyx_kp_b__4; + + /* "ssh2/sftp_handle.pyx":204 + * size_t buffer_maxlen=1024): + * cdef bytes buf = b'' + * cdef bytes b_longentry = b'' # <<<<<<<<<<<<<< + * cdef char *cbuf + * cdef char *longentry + */ + __Pyx_INCREF(__pyx_kp_b__4); + __pyx_v_b_longentry = __pyx_kp_b__4; + + /* "ssh2/sftp_handle.pyx":207 * cdef char *cbuf * cdef char *longentry * cdef SFTPAttributes attrs = SFTPAttributes() # <<<<<<<<<<<<<< * with nogil: * cbuf = malloc(sizeof(char)*buffer_maxlen) */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_attrs = ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPAttributes *)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp_handle.pyx":207 + /* "ssh2/sftp_handle.pyx":208 * cdef char *longentry * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: # <<<<<<<<<<<<<< @@ -4398,7 +4663,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":208 + /* "ssh2/sftp_handle.pyx":209 * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: * cbuf = malloc(sizeof(char)*buffer_maxlen) # <<<<<<<<<<<<<< @@ -4407,7 +4672,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct */ __pyx_v_cbuf = ((char *)malloc(((sizeof(char)) * __pyx_v_buffer_maxlen))); - /* "ssh2/sftp_handle.pyx":209 + /* "ssh2/sftp_handle.pyx":210 * with nogil: * cbuf = malloc(sizeof(char)*buffer_maxlen) * longentry = malloc(sizeof(char)*longentry_maxlen) # <<<<<<<<<<<<<< @@ -4416,7 +4681,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct */ __pyx_v_longentry = ((char *)malloc(((sizeof(char)) * __pyx_v_longentry_maxlen))); - /* "ssh2/sftp_handle.pyx":210 + /* "ssh2/sftp_handle.pyx":211 * cbuf = malloc(sizeof(char)*buffer_maxlen) * longentry = malloc(sizeof(char)*longentry_maxlen) * if cbuf is NULL or longentry is NULL: # <<<<<<<<<<<<<< @@ -4434,7 +4699,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct __pyx_L7_bool_binop_done:; if (__pyx_t_2) { - /* "ssh2/sftp_handle.pyx":211 + /* "ssh2/sftp_handle.pyx":212 * longentry = malloc(sizeof(char)*longentry_maxlen) * if cbuf is NULL or longentry is NULL: * with gil: # <<<<<<<<<<<<<< @@ -4447,17 +4712,17 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":212 + /* "ssh2/sftp_handle.pyx":213 * if cbuf is NULL or longentry is NULL: * with gil: * raise MemoryError # <<<<<<<<<<<<<< * rc = c_sftp.libssh2_sftp_readdir_ex( * self._handle, cbuf, buffer_maxlen, longentry, */ - PyErr_NoMemory(); __PYX_ERR(0, 212, __pyx_L10_error) + PyErr_NoMemory(); __PYX_ERR(0, 213, __pyx_L10_error) } - /* "ssh2/sftp_handle.pyx":211 + /* "ssh2/sftp_handle.pyx":212 * longentry = malloc(sizeof(char)*longentry_maxlen) * if cbuf is NULL or longentry is NULL: * with gil: # <<<<<<<<<<<<<< @@ -4474,7 +4739,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct } } - /* "ssh2/sftp_handle.pyx":210 + /* "ssh2/sftp_handle.pyx":211 * cbuf = malloc(sizeof(char)*buffer_maxlen) * longentry = malloc(sizeof(char)*longentry_maxlen) * if cbuf is NULL or longentry is NULL: # <<<<<<<<<<<<<< @@ -4483,7 +4748,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct */ } - /* "ssh2/sftp_handle.pyx":213 + /* "ssh2/sftp_handle.pyx":214 * with gil: * raise MemoryError * rc = c_sftp.libssh2_sftp_readdir_ex( # <<<<<<<<<<<<<< @@ -4493,7 +4758,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct __pyx_v_rc = libssh2_sftp_readdir_ex(__pyx_v_self->_handle, __pyx_v_cbuf, __pyx_v_buffer_maxlen, __pyx_v_longentry, __pyx_v_longentry_maxlen, __pyx_v_attrs->_attrs); } - /* "ssh2/sftp_handle.pyx":207 + /* "ssh2/sftp_handle.pyx":208 * cdef char *longentry * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: # <<<<<<<<<<<<<< @@ -4519,7 +4784,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct } } - /* "ssh2/sftp_handle.pyx":216 + /* "ssh2/sftp_handle.pyx":217 * self._handle, cbuf, buffer_maxlen, longentry, * longentry_maxlen, attrs._attrs) * try: # <<<<<<<<<<<<<< @@ -4528,58 +4793,56 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct */ /*try:*/ { - /* "ssh2/sftp_handle.pyx":217 + /* "ssh2/sftp_handle.pyx":218 * longentry_maxlen, attrs._attrs) * try: * if rc > 0: # <<<<<<<<<<<<<< * buf = cbuf[:rc] - * else: + * b_longentry = longentry */ __pyx_t_2 = ((__pyx_v_rc > 0) != 0); if (__pyx_t_2) { - /* "ssh2/sftp_handle.pyx":218 + /* "ssh2/sftp_handle.pyx":219 * try: * if rc > 0: * buf = cbuf[:rc] # <<<<<<<<<<<<<< - * else: - * buf = b'' + * b_longentry = longentry + * finally: */ - __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_cbuf + 0, __pyx_v_rc - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L13_error) + __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_cbuf + 0, __pyx_v_rc - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 219, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_v_buf = ((PyObject*)__pyx_t_1); + __Pyx_DECREF_SET(__pyx_v_buf, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0; - /* "ssh2/sftp_handle.pyx":217 - * longentry_maxlen, attrs._attrs) - * try: - * if rc > 0: # <<<<<<<<<<<<<< + /* "ssh2/sftp_handle.pyx":220 + * if rc > 0: * buf = cbuf[:rc] - * else: + * b_longentry = longentry # <<<<<<<<<<<<<< + * finally: + * free(cbuf) */ - goto __pyx_L15; - } + __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_longentry); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 220, __pyx_L13_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF_SET(__pyx_v_b_longentry, ((PyObject*)__pyx_t_1)); + __pyx_t_1 = 0; - /* "ssh2/sftp_handle.pyx":220 + /* "ssh2/sftp_handle.pyx":218 + * longentry_maxlen, attrs._attrs) + * try: + * if rc > 0: # <<<<<<<<<<<<<< * buf = cbuf[:rc] - * else: - * buf = b'' # <<<<<<<<<<<<<< - * finally: - * free(cbuf) + * b_longentry = longentry */ - /*else*/ { - __Pyx_INCREF(__pyx_kp_b__4); - __pyx_v_buf = __pyx_kp_b__4; } - __pyx_L15:; } /* "ssh2/sftp_handle.pyx":222 - * buf = b'' + * b_longentry = longentry * finally: * free(cbuf) # <<<<<<<<<<<<<< * free(longentry) - * return rc, buf, longentry, attrs + * return rc, buf, b_longentry, attrs */ /*finally:*/ { /*normal exit:*/{ @@ -4589,7 +4852,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct * finally: * free(cbuf) * free(longentry) # <<<<<<<<<<<<<< - * return rc, buf, longentry, attrs + * return rc, buf, b_longentry, attrs * */ free(__pyx_v_longentry); @@ -4613,11 +4876,11 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct { /* "ssh2/sftp_handle.pyx":222 - * buf = b'' + * b_longentry = longentry * finally: * free(cbuf) # <<<<<<<<<<<<<< * free(longentry) - * return rc, buf, longentry, attrs + * return rc, buf, b_longentry, attrs */ free(__pyx_v_cbuf); @@ -4625,12 +4888,11 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct * finally: * free(cbuf) * free(longentry) # <<<<<<<<<<<<<< - * return rc, buf, longentry, attrs + * return rc, buf, b_longentry, attrs * */ free(__pyx_v_longentry); } - __Pyx_PyThreadState_assign if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); @@ -4651,34 +4913,32 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct /* "ssh2/sftp_handle.pyx":224 * free(cbuf) * free(longentry) - * return rc, buf, longentry, attrs # <<<<<<<<<<<<<< + * return rc, buf, b_longentry, attrs # <<<<<<<<<<<<<< * * def readdir(self, size_t buffer_maxlen=1024): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_13 = __Pyx_PyBytes_FromString(__pyx_v_longentry); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 224, __pyx_L1_error) + __pyx_t_13 = PyTuple_New(4); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); - __pyx_t_14 = PyTuple_New(4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 224, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_1); __Pyx_INCREF(__pyx_v_buf); __Pyx_GIVEREF(__pyx_v_buf); - PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_v_buf); - __Pyx_GIVEREF(__pyx_t_13); - PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_buf); + __Pyx_INCREF(__pyx_v_b_longentry); + __Pyx_GIVEREF(__pyx_v_b_longentry); + PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_v_b_longentry); __Pyx_INCREF(((PyObject *)__pyx_v_attrs)); __Pyx_GIVEREF(((PyObject *)__pyx_v_attrs)); - PyTuple_SET_ITEM(__pyx_t_14, 3, ((PyObject *)__pyx_v_attrs)); + PyTuple_SET_ITEM(__pyx_t_13, 3, ((PyObject *)__pyx_v_attrs)); __pyx_t_1 = 0; + __pyx_r = __pyx_t_13; __pyx_t_13 = 0; - __pyx_r = __pyx_t_14; - __pyx_t_14 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":199 + /* "ssh2/sftp_handle.pyx":200 * buffer_maxlen=buffer_maxlen) * * def _readdir_ex(self, # <<<<<<<<<<<<<< @@ -4690,20 +4950,20 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_19_readdir_ex(struct __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_13); - __Pyx_XDECREF(__pyx_t_14); __Pyx_AddTraceback("ssh2.sftp_handle.SFTPHandle._readdir_ex", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_buf); + __Pyx_XDECREF(__pyx_v_b_longentry); __Pyx_XDECREF((PyObject *)__pyx_v_attrs); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_23generator1(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_23generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* "ssh2/sftp_handle.pyx":226 - * return rc, buf, longentry, attrs + * return rc, buf, b_longentry, attrs * * def readdir(self, size_t buffer_maxlen=1024): # <<<<<<<<<<<<<< * """Get directory listing from file handle, if any. @@ -4804,7 +5064,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_21readdir(struct __py return __pyx_r; } -static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_23generator1(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_23generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ { struct __pyx_obj_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir *__pyx_cur_scope = ((struct __pyx_obj_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir *)__pyx_generator->closure); PyObject *__pyx_r = NULL; @@ -4816,9 +5076,8 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_23generator1(__pyx_Co PyObject *(*__pyx_t_6)(PyObject *); int __pyx_t_7; int __pyx_t_8; - Py_ssize_t __pyx_t_9; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("None", 0); + __Pyx_RefNannySetupContext("readdir", 0); switch (__pyx_generator->resume_label) { case 0: goto __pyx_L3_first_run; case 1: goto __pyx_L10_resume_from_yield; @@ -4833,7 +5092,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_23generator1(__pyx_Co * * :rtype: iter(bytes)""" * rc, buf, attrs = self._readdir(buffer_maxlen) # <<<<<<<<<<<<<< - * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or len(buf) > 0: + * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or rc > 0: * yield rc, buf, attrs */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_readdir_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 236, __pyx_L1_error) @@ -4956,7 +5215,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_23generator1(__pyx_Co /* "ssh2/sftp_handle.pyx":237 * :rtype: iter(bytes)""" * rc, buf, attrs = self._readdir(buffer_maxlen) - * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or len(buf) > 0: # <<<<<<<<<<<<<< + * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or rc > 0: # <<<<<<<<<<<<<< * yield rc, buf, attrs * rc, buf, attrs = self._readdir(buffer_maxlen) */ @@ -4972,15 +5231,16 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_23generator1(__pyx_Co __pyx_t_7 = __pyx_t_8; goto __pyx_L8_bool_binop_done; } - __pyx_t_9 = PyObject_Length(__pyx_cur_scope->__pyx_v_buf); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 237, __pyx_L1_error) - __pyx_t_8 = ((__pyx_t_9 > 0) != 0); + __pyx_t_3 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_rc, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 237, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 237, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = __pyx_t_8; __pyx_L8_bool_binop_done:; if (!__pyx_t_7) break; /* "ssh2/sftp_handle.pyx":238 * rc, buf, attrs = self._readdir(buffer_maxlen) - * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or len(buf) > 0: + * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or rc > 0: * yield rc, buf, attrs # <<<<<<<<<<<<<< * rc, buf, attrs = self._readdir(buffer_maxlen) * @@ -5000,6 +5260,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_23generator1(__pyx_Co __pyx_t_3 = 0; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); + __Pyx_Coroutine_ResetAndClearException(__pyx_generator); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; @@ -5007,7 +5268,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_23generator1(__pyx_Co if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 238, __pyx_L1_error) /* "ssh2/sftp_handle.pyx":239 - * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or len(buf) > 0: + * while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or rc > 0: * yield rc, buf, attrs * rc, buf, attrs = self._readdir(buffer_maxlen) # <<<<<<<<<<<<<< * @@ -5136,7 +5397,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_23generator1(__pyx_Co CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); /* "ssh2/sftp_handle.pyx":226 - * return rc, buf, longentry, attrs + * return rc, buf, b_longentry, attrs * * def readdir(self, size_t buffer_maxlen=1024): # <<<<<<<<<<<<<< * """Get directory listing from file handle, if any. @@ -5155,6 +5416,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_23generator1(__pyx_Co __Pyx_AddTraceback("readdir", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); __pyx_r = 0; + __Pyx_Coroutine_ResetAndClearException(__pyx_generator); __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_RefNannyFinishContext(); @@ -5166,7 +5428,7 @@ static PyObject *__pyx_gb_4ssh2_11sftp_handle_10SFTPHandle_23generator1(__pyx_Co * * def _readdir(self, # <<<<<<<<<<<<<< * size_t buffer_maxlen=1024): - * cdef bytes buf + * cdef bytes buf = b'' */ /* Python wrapper */ @@ -5250,8 +5512,18 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_24_readdir(struct __p PyObject *__pyx_t_12 = NULL; __Pyx_RefNannySetupContext("_readdir", 0); + /* "ssh2/sftp_handle.pyx":243 + * def _readdir(self, + * size_t buffer_maxlen=1024): + * cdef bytes buf = b'' # <<<<<<<<<<<<<< + * cdef char *cbuf + * cdef SFTPAttributes attrs = SFTPAttributes() + */ + __Pyx_INCREF(__pyx_kp_b__4); + __pyx_v_buf = __pyx_kp_b__4; + /* "ssh2/sftp_handle.pyx":245 - * cdef bytes buf + * cdef bytes buf = b'' * cdef char *cbuf * cdef SFTPAttributes attrs = SFTPAttributes() # <<<<<<<<<<<<<< * with nogil: @@ -5395,7 +5667,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_24_readdir(struct __p * try: * if rc > 0: # <<<<<<<<<<<<<< * buf = cbuf[:rc] - * else: + * finally: */ __pyx_t_2 = ((__pyx_v_rc > 0) != 0); if (__pyx_t_2) { @@ -5404,12 +5676,12 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_24_readdir(struct __p * try: * if rc > 0: * buf = cbuf[:rc] # <<<<<<<<<<<<<< - * else: - * buf = b'' + * finally: + * free(cbuf) */ __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_cbuf + 0, __pyx_v_rc - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_v_buf = ((PyObject*)__pyx_t_1); + __Pyx_DECREF_SET(__pyx_v_buf, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0; /* "ssh2/sftp_handle.pyx":254 @@ -5417,27 +5689,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_24_readdir(struct __p * try: * if rc > 0: # <<<<<<<<<<<<<< * buf = cbuf[:rc] - * else: - */ - goto __pyx_L13; - } - - /* "ssh2/sftp_handle.pyx":257 - * buf = cbuf[:rc] - * else: - * buf = b'' # <<<<<<<<<<<<<< * finally: - * free(cbuf) */ - /*else*/ { - __Pyx_INCREF(__pyx_kp_b__4); - __pyx_v_buf = __pyx_kp_b__4; } - __pyx_L13:; } - /* "ssh2/sftp_handle.pyx":259 - * buf = b'' + /* "ssh2/sftp_handle.pyx":257 + * buf = cbuf[:rc] * finally: * free(cbuf) # <<<<<<<<<<<<<< * return rc, buf, attrs @@ -5466,7 +5724,6 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_24_readdir(struct __p { free(__pyx_v_cbuf); } - __Pyx_PyThreadState_assign if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); @@ -5484,7 +5741,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_24_readdir(struct __p __pyx_L12:; } - /* "ssh2/sftp_handle.pyx":260 + /* "ssh2/sftp_handle.pyx":258 * finally: * free(cbuf) * return rc, buf, attrs # <<<<<<<<<<<<<< @@ -5492,9 +5749,9 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_24_readdir(struct __p * def write(self, bytes buf): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 260, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 260, __pyx_L1_error) + __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_1); @@ -5514,7 +5771,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_24_readdir(struct __p * * def _readdir(self, # <<<<<<<<<<<<<< * size_t buffer_maxlen=1024): - * cdef bytes buf + * cdef bytes buf = b'' */ /* function exit code */ @@ -5531,7 +5788,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_24_readdir(struct __p return __pyx_r; } -/* "ssh2/sftp_handle.pyx":262 +/* "ssh2/sftp_handle.pyx":260 * return rc, buf, attrs * * def write(self, bytes buf): # <<<<<<<<<<<<<< @@ -5546,7 +5803,7 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_27write(PyObject *__p PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_buf), (&PyBytes_Type), 1, "buf", 1))) __PYX_ERR(0, 262, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_buf), (&PyBytes_Type), 1, "buf", 1))) __PYX_ERR(0, 260, __pyx_L1_error) __pyx_r = __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_26write(((struct __pyx_obj_4ssh2_11sftp_handle_SFTPHandle *)__pyx_v_self), ((PyObject*)__pyx_v_buf)); /* function exit code */ @@ -5566,10 +5823,12 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_26write(struct __pyx_ __Pyx_RefNannyDeclarations Py_ssize_t __pyx_t_1; char *__pyx_t_2; - PyObject *__pyx_t_3 = NULL; + int __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("write", 0); - /* "ssh2/sftp_handle.pyx":269 + /* "ssh2/sftp_handle.pyx":267 * * :rtype: int""" * cdef size_t _size = len(buf) # <<<<<<<<<<<<<< @@ -5578,27 +5837,31 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_26write(struct __pyx_ */ if (unlikely(__pyx_v_buf == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 269, __pyx_L1_error) + __PYX_ERR(0, 267, __pyx_L1_error) } - __pyx_t_1 = PyBytes_GET_SIZE(__pyx_v_buf); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 269, __pyx_L1_error) + __pyx_t_1 = PyBytes_GET_SIZE(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 267, __pyx_L1_error) __pyx_v__size = __pyx_t_1; - /* "ssh2/sftp_handle.pyx":270 + /* "ssh2/sftp_handle.pyx":268 * :rtype: int""" * cdef size_t _size = len(buf) * cdef char *cbuf = buf # <<<<<<<<<<<<<< * cdef ssize_t rc * with nogil: */ - __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_v_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 270, __pyx_L1_error) + if (unlikely(__pyx_v_buf == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 268, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 268, __pyx_L1_error) __pyx_v_cbuf = __pyx_t_2; - /* "ssh2/sftp_handle.pyx":272 + /* "ssh2/sftp_handle.pyx":270 * cdef char *cbuf = buf * cdef ssize_t rc * with nogil: # <<<<<<<<<<<<<< * rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) - * return rc + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: */ { #ifdef WITH_THREAD @@ -5608,22 +5871,93 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_26write(struct __pyx_ #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":273 + /* "ssh2/sftp_handle.pyx":271 * cdef ssize_t rc * with nogil: * rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) # <<<<<<<<<<<<<< + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * with gil: + */ + __pyx_v_rc = libssh2_sftp_write(__pyx_v_self->_handle, __pyx_v_cbuf, __pyx_v__size); + + /* "ssh2/sftp_handle.pyx":272 + * with nogil: + * rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * with gil: + * raise SFTPIOError("Error writing to file via SFTP") + */ + __pyx_t_4 = ((__pyx_v_rc < 0) != 0); + if (__pyx_t_4) { + } else { + __pyx_t_3 = __pyx_t_4; + goto __pyx_L7_bool_binop_done; + } + __pyx_t_4 = ((__pyx_v_rc != LIBSSH2_ERROR_EAGAIN) != 0); + __pyx_t_3 = __pyx_t_4; + __pyx_L7_bool_binop_done:; + if (__pyx_t_3) { + + /* "ssh2/sftp_handle.pyx":273 + * rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * with gil: # <<<<<<<<<<<<<< + * raise SFTPIOError("Error writing to file via SFTP") + * return rc + */ + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + /*try:*/ { + + /* "ssh2/sftp_handle.pyx":274 + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * with gil: + * raise SFTPIOError("Error writing to file via SFTP") # <<<<<<<<<<<<<< * return rc * */ - __pyx_v_rc = libssh2_sftp_write(__pyx_v_self->_handle, __pyx_v_cbuf, __pyx_v__size); + __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_10exceptions_SFTPIOError), __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 274, __pyx_L10_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(0, 274, __pyx_L10_error) + } + + /* "ssh2/sftp_handle.pyx":273 + * rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * with gil: # <<<<<<<<<<<<<< + * raise SFTPIOError("Error writing to file via SFTP") + * return rc + */ + /*finally:*/ { + __pyx_L10_error: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L4_error; + } + } + } + + /* "ssh2/sftp_handle.pyx":272 + * with nogil: + * rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * with gil: + * raise SFTPIOError("Error writing to file via SFTP") + */ + } } - /* "ssh2/sftp_handle.pyx":272 + /* "ssh2/sftp_handle.pyx":270 * cdef char *cbuf = buf * cdef ssize_t rc * with nogil: # <<<<<<<<<<<<<< * rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) - * return rc + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: */ /*finally:*/ { /*normal exit:*/{ @@ -5633,25 +5967,32 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_26write(struct __pyx_ #endif goto __pyx_L5; } + __pyx_L4_error: { + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L1_error; + } __pyx_L5:; } } - /* "ssh2/sftp_handle.pyx":274 - * with nogil: - * rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) + /* "ssh2/sftp_handle.pyx":275 + * with gil: + * raise SFTPIOError("Error writing to file via SFTP") * return rc # <<<<<<<<<<<<<< * * IF EMBEDDED_LIB: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_rc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; + __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_rc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 275, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":262 + /* "ssh2/sftp_handle.pyx":260 * return rc, buf, attrs * * def write(self, bytes buf): # <<<<<<<<<<<<<< @@ -5661,7 +6002,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_26write(struct __pyx_ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("ssh2.sftp_handle.SFTPHandle.write", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -5670,7 +6011,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_26write(struct __pyx_ return __pyx_r; } -/* "ssh2/sftp_handle.pyx":288 +/* "ssh2/sftp_handle.pyx":289 * return rc * * def seek(self, size_t offset): # <<<<<<<<<<<<<< @@ -5687,7 +6028,7 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_29seek(PyObject *__py __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("seek (wrapper)", 0); assert(__pyx_arg_offset); { - __pyx_v_offset = __Pyx_PyInt_As_size_t(__pyx_arg_offset); if (unlikely((__pyx_v_offset == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 288, __pyx_L3_error) + __pyx_v_offset = __Pyx_PyInt_As_size_t(__pyx_arg_offset); if (unlikely((__pyx_v_offset == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 289, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -5707,7 +6048,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_28seek(struct __pyx_o __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("seek", 0); - /* "ssh2/sftp_handle.pyx":297 + /* "ssh2/sftp_handle.pyx":298 * * :rtype: None""" * with nogil: # <<<<<<<<<<<<<< @@ -5722,7 +6063,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_28seek(struct __pyx_o #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":298 + /* "ssh2/sftp_handle.pyx":299 * :rtype: None""" * with nogil: * c_sftp.libssh2_sftp_seek(self._handle, offset) # <<<<<<<<<<<<<< @@ -5732,7 +6073,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_28seek(struct __pyx_o libssh2_sftp_seek(__pyx_v_self->_handle, __pyx_v_offset); } - /* "ssh2/sftp_handle.pyx":297 + /* "ssh2/sftp_handle.pyx":298 * * :rtype: None""" * with nogil: # <<<<<<<<<<<<<< @@ -5751,7 +6092,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_28seek(struct __pyx_o } } - /* "ssh2/sftp_handle.pyx":288 + /* "ssh2/sftp_handle.pyx":289 * return rc * * def seek(self, size_t offset): # <<<<<<<<<<<<<< @@ -5766,7 +6107,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_28seek(struct __pyx_o return __pyx_r; } -/* "ssh2/sftp_handle.pyx":300 +/* "ssh2/sftp_handle.pyx":301 * c_sftp.libssh2_sftp_seek(self._handle, offset) * * def seek64(self, c_ssh2.libssh2_uint64_t offset): # <<<<<<<<<<<<<< @@ -5783,7 +6124,7 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_31seek64(PyObject *__ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("seek64 (wrapper)", 0); assert(__pyx_arg_offset); { - __pyx_v_offset = __Pyx_PyInt_As_libssh2_uint64_t(__pyx_arg_offset); if (unlikely((__pyx_v_offset == ((libssh2_uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 300, __pyx_L3_error) + __pyx_v_offset = __Pyx_PyInt_As_libssh2_uint64_t(__pyx_arg_offset); if (unlikely((__pyx_v_offset == ((libssh2_uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 301, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -5803,7 +6144,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_30seek64(struct __pyx __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("seek64", 0); - /* "ssh2/sftp_handle.pyx":307 + /* "ssh2/sftp_handle.pyx":308 * * :rtype: None""" * with nogil: # <<<<<<<<<<<<<< @@ -5818,7 +6159,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_30seek64(struct __pyx #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":308 + /* "ssh2/sftp_handle.pyx":309 * :rtype: None""" * with nogil: * c_sftp.libssh2_sftp_seek64(self._handle, offset) # <<<<<<<<<<<<<< @@ -5828,7 +6169,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_30seek64(struct __pyx libssh2_sftp_seek64(__pyx_v_self->_handle, __pyx_v_offset); } - /* "ssh2/sftp_handle.pyx":307 + /* "ssh2/sftp_handle.pyx":308 * * :rtype: None""" * with nogil: # <<<<<<<<<<<<<< @@ -5847,7 +6188,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_30seek64(struct __pyx } } - /* "ssh2/sftp_handle.pyx":300 + /* "ssh2/sftp_handle.pyx":301 * c_sftp.libssh2_sftp_seek(self._handle, offset) * * def seek64(self, c_ssh2.libssh2_uint64_t offset): # <<<<<<<<<<<<<< @@ -5862,7 +6203,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_30seek64(struct __pyx return __pyx_r; } -/* "ssh2/sftp_handle.pyx":310 +/* "ssh2/sftp_handle.pyx":311 * c_sftp.libssh2_sftp_seek64(self._handle, offset) * * def rewind(self): # <<<<<<<<<<<<<< @@ -5889,7 +6230,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_32rewind(struct __pyx __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rewind", 0); - /* "ssh2/sftp_handle.pyx":314 + /* "ssh2/sftp_handle.pyx":315 * * :rtype: None""" * with nogil: # <<<<<<<<<<<<<< @@ -5904,7 +6245,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_32rewind(struct __pyx #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":315 + /* "ssh2/sftp_handle.pyx":316 * :rtype: None""" * with nogil: * c_sftp.libssh2_sftp_rewind(self._handle) # <<<<<<<<<<<<<< @@ -5914,7 +6255,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_32rewind(struct __pyx libssh2_sftp_rewind(__pyx_v_self->_handle); } - /* "ssh2/sftp_handle.pyx":314 + /* "ssh2/sftp_handle.pyx":315 * * :rtype: None""" * with nogil: # <<<<<<<<<<<<<< @@ -5933,7 +6274,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_32rewind(struct __pyx } } - /* "ssh2/sftp_handle.pyx":310 + /* "ssh2/sftp_handle.pyx":311 * c_sftp.libssh2_sftp_seek64(self._handle, offset) * * def rewind(self): # <<<<<<<<<<<<<< @@ -5948,7 +6289,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_32rewind(struct __pyx return __pyx_r; } -/* "ssh2/sftp_handle.pyx":317 +/* "ssh2/sftp_handle.pyx":318 * c_sftp.libssh2_sftp_rewind(self._handle) * * def tell(self): # <<<<<<<<<<<<<< @@ -5977,7 +6318,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_34tell(struct __pyx_o PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("tell", 0); - /* "ssh2/sftp_handle.pyx":324 + /* "ssh2/sftp_handle.pyx":325 * :rtype: int""" * cdef size_t rc * with nogil: # <<<<<<<<<<<<<< @@ -5992,7 +6333,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_34tell(struct __pyx_o #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":325 + /* "ssh2/sftp_handle.pyx":326 * cdef size_t rc * with nogil: * rc = c_sftp.libssh2_sftp_tell(self._handle) # <<<<<<<<<<<<<< @@ -6002,7 +6343,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_34tell(struct __pyx_o __pyx_v_rc = libssh2_sftp_tell(__pyx_v_self->_handle); } - /* "ssh2/sftp_handle.pyx":324 + /* "ssh2/sftp_handle.pyx":325 * :rtype: int""" * cdef size_t rc * with nogil: # <<<<<<<<<<<<<< @@ -6021,7 +6362,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_34tell(struct __pyx_o } } - /* "ssh2/sftp_handle.pyx":326 + /* "ssh2/sftp_handle.pyx":327 * with nogil: * rc = c_sftp.libssh2_sftp_tell(self._handle) * return rc # <<<<<<<<<<<<<< @@ -6029,13 +6370,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_34tell(struct __pyx_o * def tell64(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 327, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":317 + /* "ssh2/sftp_handle.pyx":318 * c_sftp.libssh2_sftp_rewind(self._handle) * * def tell(self): # <<<<<<<<<<<<<< @@ -6054,7 +6395,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_34tell(struct __pyx_o return __pyx_r; } -/* "ssh2/sftp_handle.pyx":328 +/* "ssh2/sftp_handle.pyx":329 * return rc * * def tell64(self): # <<<<<<<<<<<<<< @@ -6083,7 +6424,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_36tell64(struct __pyx PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("tell64", 0); - /* "ssh2/sftp_handle.pyx":333 + /* "ssh2/sftp_handle.pyx":334 * :rtype: int""" * cdef c_ssh2.libssh2_uint64_t rc * with nogil: # <<<<<<<<<<<<<< @@ -6098,7 +6439,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_36tell64(struct __pyx #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":334 + /* "ssh2/sftp_handle.pyx":335 * cdef c_ssh2.libssh2_uint64_t rc * with nogil: * rc = c_sftp.libssh2_sftp_tell(self._handle) # <<<<<<<<<<<<<< @@ -6108,7 +6449,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_36tell64(struct __pyx __pyx_v_rc = libssh2_sftp_tell(__pyx_v_self->_handle); } - /* "ssh2/sftp_handle.pyx":333 + /* "ssh2/sftp_handle.pyx":334 * :rtype: int""" * cdef c_ssh2.libssh2_uint64_t rc * with nogil: # <<<<<<<<<<<<<< @@ -6127,7 +6468,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_36tell64(struct __pyx } } - /* "ssh2/sftp_handle.pyx":335 + /* "ssh2/sftp_handle.pyx":336 * with nogil: * rc = c_sftp.libssh2_sftp_tell(self._handle) * return rc # <<<<<<<<<<<<<< @@ -6135,13 +6476,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_36tell64(struct __pyx * def fstat_ex(self, SFTPAttributes attrs, int setstat): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 335, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":328 + /* "ssh2/sftp_handle.pyx":329 * return rc * * def tell64(self): # <<<<<<<<<<<<<< @@ -6160,7 +6501,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_36tell64(struct __pyx return __pyx_r; } -/* "ssh2/sftp_handle.pyx":337 +/* "ssh2/sftp_handle.pyx":338 * return rc * * def fstat_ex(self, SFTPAttributes attrs, int setstat): # <<<<<<<<<<<<<< @@ -6200,11 +6541,11 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_39fstat_ex(PyObject * case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_setstat)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fstat_ex", 1, 2, 2, 1); __PYX_ERR(0, 337, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fstat_ex", 1, 2, 2, 1); __PYX_ERR(0, 338, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fstat_ex") < 0)) __PYX_ERR(0, 337, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fstat_ex") < 0)) __PYX_ERR(0, 338, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -6213,17 +6554,17 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_39fstat_ex(PyObject * values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_attrs = ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPAttributes *)values[0]); - __pyx_v_setstat = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_setstat == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 337, __pyx_L3_error) + __pyx_v_setstat = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_setstat == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 338, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("fstat_ex", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 337, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fstat_ex", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 338, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp_handle.SFTPHandle.fstat_ex", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_attrs), __pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes, 1, "attrs", 0))) __PYX_ERR(0, 337, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_attrs), __pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes, 1, "attrs", 0))) __PYX_ERR(0, 338, __pyx_L1_error) __pyx_r = __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_38fstat_ex(((struct __pyx_obj_4ssh2_11sftp_handle_SFTPHandle *)__pyx_v_self), __pyx_v_attrs, __pyx_v_setstat); /* function exit code */ @@ -6242,7 +6583,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_38fstat_ex(struct __p PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("fstat_ex", 0); - /* "ssh2/sftp_handle.pyx":341 + /* "ssh2/sftp_handle.pyx":342 * fstat or fsetstat functions instead""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6257,7 +6598,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_38fstat_ex(struct __p #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":342 + /* "ssh2/sftp_handle.pyx":343 * cdef int rc * with nogil: * rc = c_sftp.libssh2_sftp_fstat_ex( # <<<<<<<<<<<<<< @@ -6267,7 +6608,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_38fstat_ex(struct __p __pyx_v_rc = libssh2_sftp_fstat_ex(__pyx_v_self->_handle, __pyx_v_attrs->_attrs, __pyx_v_setstat); } - /* "ssh2/sftp_handle.pyx":341 + /* "ssh2/sftp_handle.pyx":342 * fstat or fsetstat functions instead""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6286,7 +6627,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_38fstat_ex(struct __p } } - /* "ssh2/sftp_handle.pyx":344 + /* "ssh2/sftp_handle.pyx":345 * rc = c_sftp.libssh2_sftp_fstat_ex( * self._handle, attrs._attrs, setstat) * return rc # <<<<<<<<<<<<<< @@ -6294,13 +6635,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_38fstat_ex(struct __p * def fstat(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 344, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":337 + /* "ssh2/sftp_handle.pyx":338 * return rc * * def fstat_ex(self, SFTPAttributes attrs, int setstat): # <<<<<<<<<<<<<< @@ -6319,7 +6660,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_38fstat_ex(struct __p return __pyx_r; } -/* "ssh2/sftp_handle.pyx":346 +/* "ssh2/sftp_handle.pyx":347 * return rc * * def fstat(self): # <<<<<<<<<<<<<< @@ -6350,19 +6691,19 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat(struct __pyx_ int __pyx_t_2; __Pyx_RefNannySetupContext("fstat", 0); - /* "ssh2/sftp_handle.pyx":351 + /* "ssh2/sftp_handle.pyx":352 * :rtype: tuple(int, :py:class:`ssh2.sftp.SFTPAttributes`)""" * cdef int rc * cdef SFTPAttributes attrs = SFTPAttributes() # <<<<<<<<<<<<<< * with nogil: * rc = c_sftp.libssh2_sftp_fstat(self._handle, attrs._attrs) */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 351, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_attrs = ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPAttributes *)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp_handle.pyx":352 + /* "ssh2/sftp_handle.pyx":353 * cdef int rc * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: # <<<<<<<<<<<<<< @@ -6377,7 +6718,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat(struct __pyx_ #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":353 + /* "ssh2/sftp_handle.pyx":354 * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: * rc = c_sftp.libssh2_sftp_fstat(self._handle, attrs._attrs) # <<<<<<<<<<<<<< @@ -6387,7 +6728,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat(struct __pyx_ __pyx_v_rc = libssh2_sftp_fstat(__pyx_v_self->_handle, __pyx_v_attrs->_attrs); } - /* "ssh2/sftp_handle.pyx":352 + /* "ssh2/sftp_handle.pyx":353 * cdef int rc * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: # <<<<<<<<<<<<<< @@ -6406,7 +6747,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat(struct __pyx_ } } - /* "ssh2/sftp_handle.pyx":354 + /* "ssh2/sftp_handle.pyx":355 * with nogil: * rc = c_sftp.libssh2_sftp_fstat(self._handle, attrs._attrs) * if rc != 0: # <<<<<<<<<<<<<< @@ -6416,7 +6757,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat(struct __pyx_ __pyx_t_2 = ((__pyx_v_rc != 0) != 0); if (__pyx_t_2) { - /* "ssh2/sftp_handle.pyx":355 + /* "ssh2/sftp_handle.pyx":356 * rc = c_sftp.libssh2_sftp_fstat(self._handle, attrs._attrs) * if rc != 0: * return rc # <<<<<<<<<<<<<< @@ -6424,13 +6765,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat(struct __pyx_ * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 355, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":354 + /* "ssh2/sftp_handle.pyx":355 * with nogil: * rc = c_sftp.libssh2_sftp_fstat(self._handle, attrs._attrs) * if rc != 0: # <<<<<<<<<<<<<< @@ -6439,7 +6780,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat(struct __pyx_ */ } - /* "ssh2/sftp_handle.pyx":356 + /* "ssh2/sftp_handle.pyx":357 * if rc != 0: * return rc * return attrs # <<<<<<<<<<<<<< @@ -6451,7 +6792,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat(struct __pyx_ __pyx_r = ((PyObject *)__pyx_v_attrs); goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":346 + /* "ssh2/sftp_handle.pyx":347 * return rc * * def fstat(self): # <<<<<<<<<<<<<< @@ -6471,7 +6812,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat(struct __pyx_ return __pyx_r; } -/* "ssh2/sftp_handle.pyx":358 +/* "ssh2/sftp_handle.pyx":359 * return attrs * * def fsetstat(self, SFTPAttributes attrs): # <<<<<<<<<<<<<< @@ -6486,7 +6827,7 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_43fsetstat(PyObject * PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fsetstat (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_attrs), __pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes, 1, "attrs", 0))) __PYX_ERR(0, 358, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_attrs), __pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes, 1, "attrs", 0))) __PYX_ERR(0, 359, __pyx_L1_error) __pyx_r = __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fsetstat(((struct __pyx_obj_4ssh2_11sftp_handle_SFTPHandle *)__pyx_v_self), ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPAttributes *)__pyx_v_attrs)); /* function exit code */ @@ -6505,7 +6846,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fsetstat(struct __p PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("fsetstat", 0); - /* "ssh2/sftp_handle.pyx":364 + /* "ssh2/sftp_handle.pyx":365 * :type attrs: :py:class:`ssh2.sftp.SFTPAttributes`""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6520,7 +6861,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fsetstat(struct __p #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":365 + /* "ssh2/sftp_handle.pyx":366 * cdef int rc * with nogil: * rc = c_sftp.libssh2_sftp_fsetstat(self._handle, attrs._attrs) # <<<<<<<<<<<<<< @@ -6530,7 +6871,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fsetstat(struct __p __pyx_v_rc = libssh2_sftp_fsetstat(__pyx_v_self->_handle, __pyx_v_attrs->_attrs); } - /* "ssh2/sftp_handle.pyx":364 + /* "ssh2/sftp_handle.pyx":365 * :type attrs: :py:class:`ssh2.sftp.SFTPAttributes`""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6549,7 +6890,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fsetstat(struct __p } } - /* "ssh2/sftp_handle.pyx":366 + /* "ssh2/sftp_handle.pyx":367 * with nogil: * rc = c_sftp.libssh2_sftp_fsetstat(self._handle, attrs._attrs) * return rc # <<<<<<<<<<<<<< @@ -6557,13 +6898,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fsetstat(struct __p * def fstatvfs(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":358 + /* "ssh2/sftp_handle.pyx":359 * return attrs * * def fsetstat(self, SFTPAttributes attrs): # <<<<<<<<<<<<<< @@ -6582,7 +6923,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fsetstat(struct __p return __pyx_r; } -/* "ssh2/sftp_handle.pyx":368 +/* "ssh2/sftp_handle.pyx":369 * return rc * * def fstatvfs(self): # <<<<<<<<<<<<<< @@ -6614,27 +6955,27 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_44fstatvfs(struct __p int __pyx_t_3; __Pyx_RefNannySetupContext("fstatvfs", 0); - /* "ssh2/sftp_handle.pyx":372 + /* "ssh2/sftp_handle.pyx":373 * * :rtype: `ssh2.sftp.SFTPStatVFS` or int of error code""" * cdef SFTPStatVFS vfs = SFTPStatVFS(self) # <<<<<<<<<<<<<< + * cdef int rc * with nogil: - * rc = c_sftp.libssh2_sftp_fstatvfs(self._handle, vfs._ptr) */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPStatVFS), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 372, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPStatVFS), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_vfs = ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPStatVFS *)__pyx_t_2); __pyx_t_2 = 0; - /* "ssh2/sftp_handle.pyx":373 - * :rtype: `ssh2.sftp.SFTPStatVFS` or int of error code""" + /* "ssh2/sftp_handle.pyx":375 * cdef SFTPStatVFS vfs = SFTPStatVFS(self) + * cdef int rc * with nogil: # <<<<<<<<<<<<<< * rc = c_sftp.libssh2_sftp_fstatvfs(self._handle, vfs._ptr) * if rc != 0: @@ -6647,8 +6988,8 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_44fstatvfs(struct __p #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":374 - * cdef SFTPStatVFS vfs = SFTPStatVFS(self) + /* "ssh2/sftp_handle.pyx":376 + * cdef int rc * with nogil: * rc = c_sftp.libssh2_sftp_fstatvfs(self._handle, vfs._ptr) # <<<<<<<<<<<<<< * if rc != 0: @@ -6657,9 +6998,9 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_44fstatvfs(struct __p __pyx_v_rc = libssh2_sftp_fstatvfs(__pyx_v_self->_handle, __pyx_v_vfs->_ptr); } - /* "ssh2/sftp_handle.pyx":373 - * :rtype: `ssh2.sftp.SFTPStatVFS` or int of error code""" + /* "ssh2/sftp_handle.pyx":375 * cdef SFTPStatVFS vfs = SFTPStatVFS(self) + * cdef int rc * with nogil: # <<<<<<<<<<<<<< * rc = c_sftp.libssh2_sftp_fstatvfs(self._handle, vfs._ptr) * if rc != 0: @@ -6676,7 +7017,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_44fstatvfs(struct __p } } - /* "ssh2/sftp_handle.pyx":375 + /* "ssh2/sftp_handle.pyx":377 * with nogil: * rc = c_sftp.libssh2_sftp_fstatvfs(self._handle, vfs._ptr) * if rc != 0: # <<<<<<<<<<<<<< @@ -6686,7 +7027,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_44fstatvfs(struct __p __pyx_t_3 = ((__pyx_v_rc != 0) != 0); if (__pyx_t_3) { - /* "ssh2/sftp_handle.pyx":376 + /* "ssh2/sftp_handle.pyx":378 * rc = c_sftp.libssh2_sftp_fstatvfs(self._handle, vfs._ptr) * if rc != 0: * return rc # <<<<<<<<<<<<<< @@ -6694,13 +7035,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_44fstatvfs(struct __p * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 376, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":375 + /* "ssh2/sftp_handle.pyx":377 * with nogil: * rc = c_sftp.libssh2_sftp_fstatvfs(self._handle, vfs._ptr) * if rc != 0: # <<<<<<<<<<<<<< @@ -6709,7 +7050,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_44fstatvfs(struct __p */ } - /* "ssh2/sftp_handle.pyx":377 + /* "ssh2/sftp_handle.pyx":379 * if rc != 0: * return rc * return vfs # <<<<<<<<<<<<<< @@ -6721,7 +7062,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_44fstatvfs(struct __p __pyx_r = ((PyObject *)__pyx_v_vfs); goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":368 + /* "ssh2/sftp_handle.pyx":369 * return rc * * def fstatvfs(self): # <<<<<<<<<<<<<< @@ -6774,7 +7115,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_46__reduce_cython__(C * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -6828,7 +7169,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_48__setstate_cython__ * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -6851,7 +7192,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_48__setstate_cython__ return __pyx_r; } -/* "ssh2/sftp_handle.pyx":383 +/* "ssh2/sftp_handle.pyx":385 * """File system statistics""" * * def __cinit__(self, _sftp_ref): # <<<<<<<<<<<<<< @@ -6885,7 +7226,7 @@ static int __pyx_pw_4ssh2_11sftp_handle_11SFTPStatVFS_1__cinit__(PyObject *__pyx else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 383, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 385, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -6896,7 +7237,7 @@ static int __pyx_pw_4ssh2_11sftp_handle_11SFTPStatVFS_1__cinit__(PyObject *__pyx } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 383, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 385, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp_handle.SFTPStatVFS.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -6915,7 +7256,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj int __pyx_t_1; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "ssh2/sftp_handle.pyx":384 + /* "ssh2/sftp_handle.pyx":386 * * def __cinit__(self, _sftp_ref): * self._sftp_ref = _sftp_ref # <<<<<<<<<<<<<< @@ -6928,7 +7269,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj __Pyx_DECREF(__pyx_v_self->_sftp_ref); __pyx_v_self->_sftp_ref = __pyx_v__sftp_ref; - /* "ssh2/sftp_handle.pyx":385 + /* "ssh2/sftp_handle.pyx":387 * def __cinit__(self, _sftp_ref): * self._sftp_ref = _sftp_ref * with nogil: # <<<<<<<<<<<<<< @@ -6943,7 +7284,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":386 + /* "ssh2/sftp_handle.pyx":388 * self._sftp_ref = _sftp_ref * with nogil: * self._ptr = malloc( # <<<<<<<<<<<<<< @@ -6952,7 +7293,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr = ((LIBSSH2_SFTP_STATVFS *)malloc((sizeof(LIBSSH2_SFTP_STATVFS)))); - /* "ssh2/sftp_handle.pyx":388 + /* "ssh2/sftp_handle.pyx":390 * self._ptr = malloc( * sizeof(c_sftp.LIBSSH2_SFTP_STATVFS)) * if self._ptr is NULL: # <<<<<<<<<<<<<< @@ -6962,7 +7303,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj __pyx_t_1 = ((__pyx_v_self->_ptr == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/sftp_handle.pyx":389 + /* "ssh2/sftp_handle.pyx":391 * sizeof(c_sftp.LIBSSH2_SFTP_STATVFS)) * if self._ptr is NULL: * with gil: # <<<<<<<<<<<<<< @@ -6975,17 +7316,17 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":390 + /* "ssh2/sftp_handle.pyx":392 * if self._ptr is NULL: * with gil: * raise MemoryError # <<<<<<<<<<<<<< * self._ptr.f_bsize = 0 * self._ptr.f_frsize = 0 */ - PyErr_NoMemory(); __PYX_ERR(0, 390, __pyx_L8_error) + PyErr_NoMemory(); __PYX_ERR(0, 392, __pyx_L8_error) } - /* "ssh2/sftp_handle.pyx":389 + /* "ssh2/sftp_handle.pyx":391 * sizeof(c_sftp.LIBSSH2_SFTP_STATVFS)) * if self._ptr is NULL: * with gil: # <<<<<<<<<<<<<< @@ -7002,7 +7343,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj } } - /* "ssh2/sftp_handle.pyx":388 + /* "ssh2/sftp_handle.pyx":390 * self._ptr = malloc( * sizeof(c_sftp.LIBSSH2_SFTP_STATVFS)) * if self._ptr is NULL: # <<<<<<<<<<<<<< @@ -7011,7 +7352,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ } - /* "ssh2/sftp_handle.pyx":391 + /* "ssh2/sftp_handle.pyx":393 * with gil: * raise MemoryError * self._ptr.f_bsize = 0 # <<<<<<<<<<<<<< @@ -7020,7 +7361,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_bsize = 0; - /* "ssh2/sftp_handle.pyx":392 + /* "ssh2/sftp_handle.pyx":394 * raise MemoryError * self._ptr.f_bsize = 0 * self._ptr.f_frsize = 0 # <<<<<<<<<<<<<< @@ -7029,7 +7370,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_frsize = 0; - /* "ssh2/sftp_handle.pyx":393 + /* "ssh2/sftp_handle.pyx":395 * self._ptr.f_bsize = 0 * self._ptr.f_frsize = 0 * self._ptr.f_blocks = 0 # <<<<<<<<<<<<<< @@ -7038,7 +7379,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_blocks = 0; - /* "ssh2/sftp_handle.pyx":394 + /* "ssh2/sftp_handle.pyx":396 * self._ptr.f_frsize = 0 * self._ptr.f_blocks = 0 * self._ptr.f_bfree = 0 # <<<<<<<<<<<<<< @@ -7047,7 +7388,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_bfree = 0; - /* "ssh2/sftp_handle.pyx":395 + /* "ssh2/sftp_handle.pyx":397 * self._ptr.f_blocks = 0 * self._ptr.f_bfree = 0 * self._ptr.f_bavail = 0 # <<<<<<<<<<<<<< @@ -7056,7 +7397,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_bavail = 0; - /* "ssh2/sftp_handle.pyx":396 + /* "ssh2/sftp_handle.pyx":398 * self._ptr.f_bfree = 0 * self._ptr.f_bavail = 0 * self._ptr.f_files = 0 # <<<<<<<<<<<<<< @@ -7065,7 +7406,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_files = 0; - /* "ssh2/sftp_handle.pyx":397 + /* "ssh2/sftp_handle.pyx":399 * self._ptr.f_bavail = 0 * self._ptr.f_files = 0 * self._ptr.f_ffree = 0 # <<<<<<<<<<<<<< @@ -7074,7 +7415,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_ffree = 0; - /* "ssh2/sftp_handle.pyx":398 + /* "ssh2/sftp_handle.pyx":400 * self._ptr.f_files = 0 * self._ptr.f_ffree = 0 * self._ptr.f_favail = 0 # <<<<<<<<<<<<<< @@ -7083,7 +7424,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_favail = 0; - /* "ssh2/sftp_handle.pyx":399 + /* "ssh2/sftp_handle.pyx":401 * self._ptr.f_ffree = 0 * self._ptr.f_favail = 0 * self._ptr.f_fsid = 0 # <<<<<<<<<<<<<< @@ -7092,7 +7433,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_fsid = 0; - /* "ssh2/sftp_handle.pyx":400 + /* "ssh2/sftp_handle.pyx":402 * self._ptr.f_favail = 0 * self._ptr.f_fsid = 0 * self._ptr.f_flag = 0 # <<<<<<<<<<<<<< @@ -7101,7 +7442,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_flag = 0; - /* "ssh2/sftp_handle.pyx":401 + /* "ssh2/sftp_handle.pyx":403 * self._ptr.f_fsid = 0 * self._ptr.f_flag = 0 * self._ptr.f_namemax = 0 # <<<<<<<<<<<<<< @@ -7111,7 +7452,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj __pyx_v_self->_ptr->f_namemax = 0; } - /* "ssh2/sftp_handle.pyx":385 + /* "ssh2/sftp_handle.pyx":387 * def __cinit__(self, _sftp_ref): * self._sftp_ref = _sftp_ref * with nogil: # <<<<<<<<<<<<<< @@ -7137,7 +7478,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj } } - /* "ssh2/sftp_handle.pyx":383 + /* "ssh2/sftp_handle.pyx":385 * """File system statistics""" * * def __cinit__(self, _sftp_ref): # <<<<<<<<<<<<<< @@ -7156,7 +7497,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj return __pyx_r; } -/* "ssh2/sftp_handle.pyx":403 +/* "ssh2/sftp_handle.pyx":405 * self._ptr.f_namemax = 0 * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -7179,7 +7520,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_2__dealloc__(struct __pyx __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "ssh2/sftp_handle.pyx":404 + /* "ssh2/sftp_handle.pyx":406 * * def __dealloc__(self): * with nogil: # <<<<<<<<<<<<<< @@ -7194,7 +7535,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_2__dealloc__(struct __pyx #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":405 + /* "ssh2/sftp_handle.pyx":407 * def __dealloc__(self): * with nogil: * free(self._ptr) # <<<<<<<<<<<<<< @@ -7204,7 +7545,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_2__dealloc__(struct __pyx free(__pyx_v_self->_ptr); } - /* "ssh2/sftp_handle.pyx":404 + /* "ssh2/sftp_handle.pyx":406 * * def __dealloc__(self): * with nogil: # <<<<<<<<<<<<<< @@ -7223,7 +7564,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_2__dealloc__(struct __pyx } } - /* "ssh2/sftp_handle.pyx":403 + /* "ssh2/sftp_handle.pyx":405 * self._ptr.f_namemax = 0 * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -7235,7 +7576,7 @@ static void __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_2__dealloc__(struct __pyx __Pyx_RefNannyFinishContext(); } -/* "ssh2/sftp_handle.pyx":408 +/* "ssh2/sftp_handle.pyx":410 * * @property * def f_bsize(self): # <<<<<<<<<<<<<< @@ -7262,7 +7603,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_bsize___get__(str PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":410 + /* "ssh2/sftp_handle.pyx":412 * def f_bsize(self): * """File system block size""" * return self._ptr.f_bsize # <<<<<<<<<<<<<< @@ -7270,13 +7611,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_bsize___get__(str * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_bsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 410, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_bsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":408 + /* "ssh2/sftp_handle.pyx":410 * * @property * def f_bsize(self): # <<<<<<<<<<<<<< @@ -7295,7 +7636,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_bsize___get__(str return __pyx_r; } -/* "ssh2/sftp_handle.pyx":413 +/* "ssh2/sftp_handle.pyx":415 * * @property * def f_frsize(self): # <<<<<<<<<<<<<< @@ -7322,7 +7663,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_frsize___get__(st PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":415 + /* "ssh2/sftp_handle.pyx":417 * def f_frsize(self): * """Fragment size""" * return self._ptr.f_frsize # <<<<<<<<<<<<<< @@ -7330,13 +7671,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_frsize___get__(st * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_frsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 415, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_frsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":413 + /* "ssh2/sftp_handle.pyx":415 * * @property * def f_frsize(self): # <<<<<<<<<<<<<< @@ -7355,7 +7696,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_frsize___get__(st return __pyx_r; } -/* "ssh2/sftp_handle.pyx":418 +/* "ssh2/sftp_handle.pyx":420 * * @property * def f_blocks(self): # <<<<<<<<<<<<<< @@ -7382,7 +7723,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_blocks___get__(st PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":420 + /* "ssh2/sftp_handle.pyx":422 * def f_blocks(self): * """Size of fs in f_frsize units""" * return self._ptr.f_blocks # <<<<<<<<<<<<<< @@ -7390,13 +7731,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_blocks___get__(st * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_blocks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_blocks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":418 + /* "ssh2/sftp_handle.pyx":420 * * @property * def f_blocks(self): # <<<<<<<<<<<<<< @@ -7415,7 +7756,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_blocks___get__(st return __pyx_r; } -/* "ssh2/sftp_handle.pyx":423 +/* "ssh2/sftp_handle.pyx":425 * * @property * def f_bfree(self): # <<<<<<<<<<<<<< @@ -7442,7 +7783,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_bfree___get__(str PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":425 + /* "ssh2/sftp_handle.pyx":427 * def f_bfree(self): * """Free blocks""" * return self._ptr.f_bfree # <<<<<<<<<<<<<< @@ -7450,13 +7791,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_bfree___get__(str * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_bfree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 425, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_bfree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":423 + /* "ssh2/sftp_handle.pyx":425 * * @property * def f_bfree(self): # <<<<<<<<<<<<<< @@ -7475,7 +7816,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_bfree___get__(str return __pyx_r; } -/* "ssh2/sftp_handle.pyx":428 +/* "ssh2/sftp_handle.pyx":430 * * @property * def f_bavail(self): # <<<<<<<<<<<<<< @@ -7502,7 +7843,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_bavail___get__(st PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":430 + /* "ssh2/sftp_handle.pyx":432 * def f_bavail(self): * """Free blocks for non-root""" * return self._ptr.f_bavail # <<<<<<<<<<<<<< @@ -7510,13 +7851,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_bavail___get__(st * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_bavail); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 430, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_bavail); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 432, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":428 + /* "ssh2/sftp_handle.pyx":430 * * @property * def f_bavail(self): # <<<<<<<<<<<<<< @@ -7535,7 +7876,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_bavail___get__(st return __pyx_r; } -/* "ssh2/sftp_handle.pyx":433 +/* "ssh2/sftp_handle.pyx":435 * * @property * def f_files(self): # <<<<<<<<<<<<<< @@ -7562,7 +7903,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_files___get__(str PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":435 + /* "ssh2/sftp_handle.pyx":437 * def f_files(self): * """Inodes""" * return self._ptr.f_files # <<<<<<<<<<<<<< @@ -7570,13 +7911,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_files___get__(str * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_files); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_files); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 437, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":433 + /* "ssh2/sftp_handle.pyx":435 * * @property * def f_files(self): # <<<<<<<<<<<<<< @@ -7595,7 +7936,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_files___get__(str return __pyx_r; } -/* "ssh2/sftp_handle.pyx":438 +/* "ssh2/sftp_handle.pyx":440 * * @property * def f_ffree(self): # <<<<<<<<<<<<<< @@ -7622,7 +7963,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_ffree___get__(str PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":440 + /* "ssh2/sftp_handle.pyx":442 * def f_ffree(self): * """Free inodes""" * return self._ptr.f_ffree # <<<<<<<<<<<<<< @@ -7630,13 +7971,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_ffree___get__(str * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_ffree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 440, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_ffree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":438 + /* "ssh2/sftp_handle.pyx":440 * * @property * def f_ffree(self): # <<<<<<<<<<<<<< @@ -7655,7 +7996,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_ffree___get__(str return __pyx_r; } -/* "ssh2/sftp_handle.pyx":443 +/* "ssh2/sftp_handle.pyx":445 * * @property * def f_favail(self): # <<<<<<<<<<<<<< @@ -7682,7 +8023,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_favail___get__(st PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":445 + /* "ssh2/sftp_handle.pyx":447 * def f_favail(self): * """Free inodes for non-root""" * return self._ptr.f_favail # <<<<<<<<<<<<<< @@ -7690,13 +8031,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_favail___get__(st * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_favail); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 445, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_favail); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 447, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":443 + /* "ssh2/sftp_handle.pyx":445 * * @property * def f_favail(self): # <<<<<<<<<<<<<< @@ -7715,7 +8056,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_favail___get__(st return __pyx_r; } -/* "ssh2/sftp_handle.pyx":448 +/* "ssh2/sftp_handle.pyx":450 * * @property * def f_fsid(self): # <<<<<<<<<<<<<< @@ -7742,7 +8083,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_6f_fsid___get__(stru PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":450 + /* "ssh2/sftp_handle.pyx":452 * def f_fsid(self): * """File system ID""" * return self._ptr.f_fsid # <<<<<<<<<<<<<< @@ -7750,13 +8091,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_6f_fsid___get__(stru * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_fsid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_fsid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":448 + /* "ssh2/sftp_handle.pyx":450 * * @property * def f_fsid(self): # <<<<<<<<<<<<<< @@ -7775,7 +8116,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_6f_fsid___get__(stru return __pyx_r; } -/* "ssh2/sftp_handle.pyx":453 +/* "ssh2/sftp_handle.pyx":455 * * @property * def f_flag(self): # <<<<<<<<<<<<<< @@ -7802,7 +8143,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_6f_flag___get__(stru PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":458 + /* "ssh2/sftp_handle.pyx":460 * This property is a bit mask with defined bits * ``LIBSSH2_SFTP_ST_RDONLY`` and ``LIBSSH2_SFTP_ST_NOSUID``""" * return self._ptr.f_flag # <<<<<<<<<<<<<< @@ -7810,13 +8151,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_6f_flag___get__(stru * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_flag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 458, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_flag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":453 + /* "ssh2/sftp_handle.pyx":455 * * @property * def f_flag(self): # <<<<<<<<<<<<<< @@ -7835,7 +8176,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_6f_flag___get__(stru return __pyx_r; } -/* "ssh2/sftp_handle.pyx":461 +/* "ssh2/sftp_handle.pyx":463 * * @property * def f_namemax(self): # <<<<<<<<<<<<<< @@ -7862,19 +8203,19 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_9f_namemax___get__(s PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":463 + /* "ssh2/sftp_handle.pyx":465 * def f_namemax(self): * """Maximum filename length""" * return self._ptr.f_namemax # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_namemax); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 463, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_namemax); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":461 + /* "ssh2/sftp_handle.pyx":463 * * @property * def f_namemax(self): # <<<<<<<<<<<<<< @@ -7925,7 +8266,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_4__reduce_cython__(C * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -7979,7 +8320,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_6__setstate_cython__ * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -8022,7 +8363,7 @@ static PyObject *__pyx_tp_new_4ssh2_11sftp_handle_SFTPHandle(PyTypeObject *t, Py static void __pyx_tp_dealloc_4ssh2_11sftp_handle_SFTPHandle(PyObject *o) { struct __pyx_obj_4ssh2_11sftp_handle_SFTPHandle *p = (struct __pyx_obj_4ssh2_11sftp_handle_SFTPHandle *)o; - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -8157,7 +8498,7 @@ static PyObject *__pyx_tp_new_4ssh2_11sftp_handle_SFTPAttributes(PyTypeObject *t } static void __pyx_tp_dealloc_4ssh2_11sftp_handle_SFTPAttributes(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -8366,7 +8707,7 @@ static PyObject *__pyx_tp_new_4ssh2_11sftp_handle_SFTPStatVFS(PyTypeObject *t, P static void __pyx_tp_dealloc_4ssh2_11sftp_handle_SFTPStatVFS(PyObject *o) { struct __pyx_obj_4ssh2_11sftp_handle_SFTPStatVFS *p = (struct __pyx_obj_4ssh2_11sftp_handle_SFTPStatVFS *)o; - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -8582,30 +8923,6 @@ static int __pyx_tp_traverse_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex( return 0; } -static int __pyx_tp_clear_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex(PyObject *o) { - PyObject* tmp; - struct __pyx_obj_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex *p = (struct __pyx_obj_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex *)o; - tmp = ((PyObject*)p->__pyx_v_attrs); - p->__pyx_v_attrs = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_buf); - p->__pyx_v_buf = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_entry); - p->__pyx_v_entry = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_entryb); - p->__pyx_v_entryb = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_rc); - p->__pyx_v_rc = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_self); - p->__pyx_v_self = ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPHandle *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - static PyTypeObject __pyx_type_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex = { PyVarObject_HEAD_INIT(0, 0) "ssh2.sftp_handle.__pyx_scope_struct__readdir_ex", /*tp_name*/ @@ -8634,7 +8951,7 @@ static PyTypeObject __pyx_type_4ssh2_11sftp_handle___pyx_scope_struct__readdir_e Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex, /*tp_traverse*/ - __pyx_tp_clear_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex, /*tp_clear*/ + 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ @@ -8713,24 +9030,6 @@ static int __pyx_tp_traverse_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir(Py return 0; } -static int __pyx_tp_clear_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir(PyObject *o) { - PyObject* tmp; - struct __pyx_obj_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir *p = (struct __pyx_obj_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir *)o; - tmp = ((PyObject*)p->__pyx_v_attrs); - p->__pyx_v_attrs = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_buf); - p->__pyx_v_buf = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_rc); - p->__pyx_v_rc = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_self); - p->__pyx_v_self = ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPHandle *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - static PyTypeObject __pyx_type_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir = { PyVarObject_HEAD_INIT(0, 0) "ssh2.sftp_handle.__pyx_scope_struct_1_readdir", /*tp_name*/ @@ -8759,7 +9058,7 @@ static PyTypeObject __pyx_type_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir, /*tp_traverse*/ - __pyx_tp_clear_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir, /*tp_clear*/ + 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ @@ -8794,17 +9093,31 @@ static PyMethodDef __pyx_methods[] = { }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_sftp_handle(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_sftp_handle}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "sftp_handle", 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ @@ -8812,6 +9125,7 @@ static struct PyModuleDef __pyx_moduledef = { #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_kp_s_Error_writing_to_file_via_SFTP, __pyx_k_Error_writing_to_file_via_SFTP, sizeof(__pyx_k_Error_writing_to_file_via_SFTP), 0, 0, 1, 0}, {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1}, {&__pyx_n_s_SFTPHandle_readdir, __pyx_k_SFTPHandle_readdir, sizeof(__pyx_k_SFTPHandle_readdir), 0, 0, 1, 1}, {&__pyx_n_s_SFTPHandle_readdir_ex, __pyx_k_SFTPHandle_readdir_ex, sizeof(__pyx_k_SFTPHandle_readdir_ex), 0, 0, 1, 1}, @@ -8823,18 +9137,22 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_buffer_maxlen, __pyx_k_buffer_maxlen, sizeof(__pyx_k_buffer_maxlen), 0, 0, 1, 1}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1}, + {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, {&__pyx_n_s_longentry_maxlen, __pyx_k_longentry_maxlen, sizeof(__pyx_k_longentry_maxlen), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, - {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1}, {&__pyx_n_s_readdir, __pyx_k_readdir, sizeof(__pyx_k_readdir), 0, 0, 1, 1}, {&__pyx_n_s_readdir_2, __pyx_k_readdir_2, sizeof(__pyx_k_readdir_2), 0, 0, 1, 1}, {&__pyx_n_s_readdir_ex, __pyx_k_readdir_ex, sizeof(__pyx_k_readdir_ex), 0, 0, 1, 1}, {&__pyx_n_s_readdir_ex_2, __pyx_k_readdir_ex_2, sizeof(__pyx_k_readdir_ex_2), 0, 0, 1, 1}, + {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1}, {&__pyx_n_s_setstat, __pyx_k_setstat, sizeof(__pyx_k_setstat), 0, 0, 1, 1}, + {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_sftp, __pyx_k_sftp, sizeof(__pyx_k_sftp), 0, 0, 1, 1}, {&__pyx_n_s_sftp_ref, __pyx_k_sftp_ref, sizeof(__pyx_k_sftp_ref), 0, 0, 1, 1}, @@ -8844,9 +9162,9 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 37, __pyx_L1_error) + __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 39, __pyx_L1_error) __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error) - __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) __PYX_ERR(0, 130, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; @@ -8875,24 +9193,35 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); + /* "ssh2/sftp_handle.pyx":274 + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * with gil: + * raise SFTPIOError("Error writing to file via SFTP") # <<<<<<<<<<<<<< + * return rc + * + */ + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_Error_writing_to_file_via_SFTP); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 274, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); + /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ - __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__5); - __Pyx_GIVEREF(__pyx_tuple__5); + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); /* "(tree fragment)":4 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__6); - __Pyx_GIVEREF(__pyx_tuple__6); + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); /* "(tree fragment)":2 * def __reduce_cython__(self): @@ -8900,18 +9229,18 @@ static int __Pyx_InitCachedConstants(void) { * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); /* "(tree fragment)":4 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__9); + __Pyx_GIVEREF(__pyx_tuple__9); __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -8921,6 +9250,7 @@ static int __Pyx_InitCachedConstants(void) { static int __Pyx_InitGlobals(void) { 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) return 0; __pyx_L1_error:; return -1; @@ -8932,10 +9262,54 @@ PyMODINIT_FUNC initsftp_handle(void) #else PyMODINIT_FUNC PyInit_sftp_handle(void); /*proto*/ PyMODINIT_FUNC PyInit_sftp_handle(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec_sftp_handle(PyObject *__pyx_pyinit_module) +#endif #endif { PyObject *__pyx_t_1 = NULL; __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { @@ -8962,6 +9336,9 @@ PyMODINIT_FUNC PyInit_sftp_handle(void) #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_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 @@ -8973,12 +9350,17 @@ PyMODINIT_FUNC PyInit_sftp_handle(void) #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("sftp_handle", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -9012,20 +9394,20 @@ PyMODINIT_FUNC PyInit_sftp_handle(void) /*--- Function export code ---*/ if (__Pyx_ExportFunction("PySFTPHandle", (void (*)(void))__pyx_f_4ssh2_11sftp_handle_PySFTPHandle, "PyObject *(LIBSSH2_SFTP_HANDLE *, struct __pyx_obj_4ssh2_4sftp_SFTP *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Type init code ---*/ - if (PyType_Ready(&__pyx_type_4ssh2_11sftp_handle_SFTPHandle) < 0) __PYX_ERR(0, 107, __pyx_L1_error) + if (PyType_Ready(&__pyx_type_4ssh2_11sftp_handle_SFTPHandle) < 0) __PYX_ERR(0, 109, __pyx_L1_error) __pyx_type_4ssh2_11sftp_handle_SFTPHandle.tp_print = 0; - if (PyObject_SetAttrString(__pyx_m, "SFTPHandle", (PyObject *)&__pyx_type_4ssh2_11sftp_handle_SFTPHandle) < 0) __PYX_ERR(0, 107, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_11sftp_handle_SFTPHandle) < 0) __PYX_ERR(0, 107, __pyx_L1_error) + if (PyObject_SetAttrString(__pyx_m, "SFTPHandle", (PyObject *)&__pyx_type_4ssh2_11sftp_handle_SFTPHandle) < 0) __PYX_ERR(0, 109, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_11sftp_handle_SFTPHandle) < 0) __PYX_ERR(0, 109, __pyx_L1_error) __pyx_ptype_4ssh2_11sftp_handle_SFTPHandle = &__pyx_type_4ssh2_11sftp_handle_SFTPHandle; - if (PyType_Ready(&__pyx_type_4ssh2_11sftp_handle_SFTPAttributes) < 0) __PYX_ERR(0, 29, __pyx_L1_error) + if (PyType_Ready(&__pyx_type_4ssh2_11sftp_handle_SFTPAttributes) < 0) __PYX_ERR(0, 31, __pyx_L1_error) __pyx_type_4ssh2_11sftp_handle_SFTPAttributes.tp_print = 0; - if (PyObject_SetAttrString(__pyx_m, "SFTPAttributes", (PyObject *)&__pyx_type_4ssh2_11sftp_handle_SFTPAttributes) < 0) __PYX_ERR(0, 29, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_11sftp_handle_SFTPAttributes) < 0) __PYX_ERR(0, 29, __pyx_L1_error) + if (PyObject_SetAttrString(__pyx_m, "SFTPAttributes", (PyObject *)&__pyx_type_4ssh2_11sftp_handle_SFTPAttributes) < 0) __PYX_ERR(0, 31, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_11sftp_handle_SFTPAttributes) < 0) __PYX_ERR(0, 31, __pyx_L1_error) __pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes = &__pyx_type_4ssh2_11sftp_handle_SFTPAttributes; - if (PyType_Ready(&__pyx_type_4ssh2_11sftp_handle_SFTPStatVFS) < 0) __PYX_ERR(0, 380, __pyx_L1_error) + if (PyType_Ready(&__pyx_type_4ssh2_11sftp_handle_SFTPStatVFS) < 0) __PYX_ERR(0, 382, __pyx_L1_error) __pyx_type_4ssh2_11sftp_handle_SFTPStatVFS.tp_print = 0; - if (PyObject_SetAttrString(__pyx_m, "SFTPStatVFS", (PyObject *)&__pyx_type_4ssh2_11sftp_handle_SFTPStatVFS) < 0) __PYX_ERR(0, 380, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_11sftp_handle_SFTPStatVFS) < 0) __PYX_ERR(0, 380, __pyx_L1_error) + if (PyObject_SetAttrString(__pyx_m, "SFTPStatVFS", (PyObject *)&__pyx_type_4ssh2_11sftp_handle_SFTPStatVFS) < 0) __PYX_ERR(0, 382, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_11sftp_handle_SFTPStatVFS) < 0) __PYX_ERR(0, 382, __pyx_L1_error) __pyx_ptype_4ssh2_11sftp_handle_SFTPStatVFS = &__pyx_type_4ssh2_11sftp_handle_SFTPStatVFS; if (PyType_Ready(&__pyx_type_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex) < 0) __PYX_ERR(0, 177, __pyx_L1_error) __pyx_type_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex.tp_print = 0; @@ -9034,9 +9416,20 @@ PyMODINIT_FUNC PyInit_sftp_handle(void) __pyx_type_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir.tp_print = 0; __pyx_ptype_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir = &__pyx_type_4ssh2_11sftp_handle___pyx_scope_struct_1_readdir; /*--- Type import code ---*/ - __pyx_ptype_4ssh2_7session_Session = __Pyx_ImportType("ssh2.session", "Session", sizeof(struct __pyx_obj_4ssh2_7session_Session), 1); if (unlikely(!__pyx_ptype_4ssh2_7session_Session)) __PYX_ERR(2, 20, __pyx_L1_error) - __pyx_vtabptr_4ssh2_7session_Session = (struct __pyx_vtabstruct_4ssh2_7session_Session*)__Pyx_GetVtable(__pyx_ptype_4ssh2_7session_Session->tp_dict); if (unlikely(!__pyx_vtabptr_4ssh2_7session_Session)) __PYX_ERR(2, 20, __pyx_L1_error) + __pyx_ptype_4ssh2_7session_Session = __Pyx_ImportType("ssh2.session", "Session", sizeof(struct __pyx_obj_4ssh2_7session_Session), 1); if (unlikely(!__pyx_ptype_4ssh2_7session_Session)) __PYX_ERR(2, 19, __pyx_L1_error) __pyx_ptype_4ssh2_4sftp_SFTP = __Pyx_ImportType("ssh2.sftp", "SFTP", sizeof(struct __pyx_obj_4ssh2_4sftp_SFTP), 1); if (unlikely(!__pyx_ptype_4ssh2_4sftp_SFTP)) __PYX_ERR(3, 26, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_AgentError = __Pyx_ImportType("ssh2.exceptions", "AgentError", sizeof(struct __pyx_obj_4ssh2_10exceptions_AgentError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_AgentError)) __PYX_ERR(4, 18, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_AuthenticationError = __Pyx_ImportType("ssh2.exceptions", "AuthenticationError", sizeof(struct __pyx_obj_4ssh2_10exceptions_AuthenticationError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_AuthenticationError)) __PYX_ERR(4, 22, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_AgentConnectionError = __Pyx_ImportType("ssh2.exceptions", "AgentConnectionError", sizeof(struct __pyx_obj_4ssh2_10exceptions_AgentConnectionError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_AgentConnectionError)) __PYX_ERR(4, 26, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_AgentAuthenticationError = __Pyx_ImportType("ssh2.exceptions", "AgentAuthenticationError", sizeof(struct __pyx_obj_4ssh2_10exceptions_AgentAuthenticationError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_AgentAuthenticationError)) __PYX_ERR(4, 30, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_AgentListIdentitiesError = __Pyx_ImportType("ssh2.exceptions", "AgentListIdentitiesError", sizeof(struct __pyx_obj_4ssh2_10exceptions_AgentListIdentitiesError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_AgentListIdentitiesError)) __PYX_ERR(4, 34, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_AgentGetIdentityError = __Pyx_ImportType("ssh2.exceptions", "AgentGetIdentityError", sizeof(struct __pyx_obj_4ssh2_10exceptions_AgentGetIdentityError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_AgentGetIdentityError)) __PYX_ERR(4, 38, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_SessionStartupError = __Pyx_ImportType("ssh2.exceptions", "SessionStartupError", sizeof(struct __pyx_obj_4ssh2_10exceptions_SessionStartupError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SessionStartupError)) __PYX_ERR(4, 42, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_SessionHandshakeError = __Pyx_ImportType("ssh2.exceptions", "SessionHandshakeError", sizeof(struct __pyx_obj_4ssh2_10exceptions_SessionHandshakeError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SessionHandshakeError)) __PYX_ERR(4, 46, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_ChannelError = __Pyx_ImportType("ssh2.exceptions", "ChannelError", sizeof(struct __pyx_obj_4ssh2_10exceptions_ChannelError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_ChannelError)) __PYX_ERR(4, 50, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_SFTPHandleError = __Pyx_ImportType("ssh2.exceptions", "SFTPHandleError", sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPHandleError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SFTPHandleError)) __PYX_ERR(4, 54, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall = __Pyx_ImportType("ssh2.exceptions", "SFTPBufferTooSmall", sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPBufferTooSmall), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SFTPBufferTooSmall)) __PYX_ERR(4, 58, __pyx_L1_error) + __pyx_ptype_4ssh2_10exceptions_SFTPIOError = __Pyx_ImportType("ssh2.exceptions", "SFTPIOError", sizeof(struct __pyx_obj_4ssh2_10exceptions_SFTPIOError), 1); if (unlikely(!__pyx_ptype_4ssh2_10exceptions_SFTPIOError)) __PYX_ERR(4, 62, __pyx_L1_error) /*--- Variable import code ---*/ /*--- Function import code ---*/ /*--- Execution code ---*/ @@ -9044,7 +9437,7 @@ PyMODINIT_FUNC PyInit_sftp_handle(void) if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif - /* "ssh2/sftp_handle.pyx":151 + /* "ssh2/sftp_handle.pyx":153 * return rc * * def read(self, size_t buffer_maxlen=c_ssh2.LIBSSH2_CHANNEL_WINDOW_DEFAULT): # <<<<<<<<<<<<<< @@ -9058,7 +9451,7 @@ PyMODINIT_FUNC PyInit_sftp_handle(void) * # Copyright (C) 2017 Panos Kittenis * */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); 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_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -9078,10 +9471,12 @@ PyMODINIT_FUNC PyInit_sftp_handle(void) } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -9164,7 +9559,7 @@ static void __Pyx_RaiseArgtupleInvalid( } /* KeywordStringCheck */ -static CYTHON_INLINE int __Pyx_CheckKeywordStrings( +static int __Pyx_CheckKeywordStrings( PyObject *kwdict, const char* function_name, int kw_allowed) @@ -9178,7 +9573,7 @@ static CYTHON_INLINE int __Pyx_CheckKeywordStrings( #else while (PyDict_Next(kwdict, &pos, &key, 0)) { #if PY_MAJOR_VERSION < 3 - if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) + if (unlikely(!PyString_Check(key))) #endif if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type; @@ -9343,11 +9738,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject "raise: exception class must be a subclass of BaseException"); goto bad; } -#if PY_VERSION_HEX >= 0x03030000 if (cause) { -#else - if (cause && cause != Py_None) { -#endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; @@ -9375,7 +9766,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else - PyThreadState *tstate = PyThreadState_GET(); + PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); @@ -9391,7 +9782,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject #endif /* RaiseDoubleKeywords */ - static void __Pyx_RaiseDoubleKeywordsError( +static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { @@ -9405,7 +9796,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* ParseKeywords */ - static int __Pyx_ParseOptionalKeywords( +static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, @@ -9507,12 +9898,12 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* ExtTypeTest */ - static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } - if (likely(PyObject_TypeCheck(obj, type))) + if (likely(__Pyx_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); @@ -9520,7 +9911,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* PyCFunctionFastCall */ - #if CYTHON_FAST_PYCCALL +#if CYTHON_FAST_PYCCALL static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { PyCFunctionObject *func = (PyCFunctionObject*)func_obj; PyCFunction meth = PyCFunction_GET_FUNCTION(func); @@ -9543,12 +9934,12 @@ static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, P #endif /* PyFunctionFastCall */ - #if CYTHON_FAST_PYCALL +#if CYTHON_FAST_PYCALL #include "frameobject.h" static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, PyObject *globals) { PyFrameObject *f; - PyThreadState *tstate = PyThreadState_GET(); + PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject **fastlocals; Py_ssize_t i; PyObject *result; @@ -9663,7 +10054,7 @@ static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, #endif /* PyObjectCallMethO */ - #if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; @@ -9683,7 +10074,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject #endif /* PyObjectCallOneArg */ - #if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_COMPILING_IN_CPYTHON static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_New(1); @@ -9723,7 +10114,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObjec #endif /* PyObjectCallNoArg */ - #if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { #if CYTHON_FAST_PYCALL if (PyFunction_Check(func)) { @@ -9731,7 +10122,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { } #endif #ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { + if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) { #else if (likely(PyCFunction_Check(func))) { #endif @@ -9744,25 +10135,25 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { #endif /* RaiseTooManyValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } /* RaiseNeedMoreValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } /* IterFinish */ - static CYTHON_INLINE int __Pyx_IterFinish(void) { + static CYTHON_INLINE int __Pyx_IterFinish(void) { #if CYTHON_FAST_THREAD_STATE - PyThreadState *tstate = PyThreadState_GET(); + PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* exc_type = tstate->curexc_type; if (unlikely(exc_type)) { - if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) { PyObject *exc_value, *exc_tb; exc_value = tstate->curexc_value; exc_tb = tstate->curexc_traceback; @@ -9792,7 +10183,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { } /* UnpackItemEndCheck */ - static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { + static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { if (unlikely(retval)) { Py_DECREF(retval); __Pyx_RaiseTooManyValuesError(expected); @@ -9804,7 +10195,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { } /* GetException */ - #if CYTHON_FAST_THREAD_STATE + #if CYTHON_FAST_THREAD_STATE static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { @@ -9865,7 +10256,7 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) } /* SwapException */ - #if CYTHON_FAST_THREAD_STATE + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->exc_type; @@ -9890,7 +10281,7 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, #endif /* SaveResetException */ - #if CYTHON_FAST_THREAD_STATE + #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { *type = tstate->exc_type; *value = tstate->exc_value; @@ -9914,44 +10305,37 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject #endif /* 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); -} -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact) + static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } - if (none_allowed && obj == Py_None) return 1; else if (exact) { - if (likely(Py_TYPE(obj) == type)) return 1; #if PY_MAJOR_VERSION == 2 - else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { - if (likely(PyObject_TypeCheck(obj, type))) return 1; + if (likely(__Pyx_TypeCheck(obj, type))) return 1; } - __Pyx_RaiseArgumentTypeInvalid(name, obj, type); + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); return 0; } /* SetupReduce */ - #define __Pyx_setup_reduce_GET_ATTR_OR_BAD(res, obj, name) res = PyObject_GetAttrString(obj, name); if (res == NULL) goto BAD; -static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { + static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { int ret; PyObject *name_attr; - name_attr = PyObject_GetAttrString(meth, "__name__"); - if (name_attr) { + name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name); + if (likely(name_attr)) { ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); } else { ret = -1; } - if (ret < 0) { + if (unlikely(ret < 0)) { PyErr_Clear(); ret = 0; } @@ -9960,43 +10344,55 @@ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { } static int __Pyx_setup_reduce(PyObject* type_obj) { int ret = 0; - PyObject* builtin_object = NULL; - static PyObject *object_reduce = NULL; - static PyObject *object_reduce_ex = NULL; + PyObject *object_reduce = NULL; + PyObject *object_reduce_ex = NULL; PyObject *reduce = NULL; PyObject *reduce_ex = NULL; PyObject *reduce_cython = NULL; PyObject *setstate = NULL; PyObject *setstate_cython = NULL; - if (PyObject_HasAttrString(type_obj, "__getstate__")) goto GOOD; - if (object_reduce_ex == NULL) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(builtin_object, __pyx_b, "object"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce, builtin_object, "__reduce__"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce_ex, builtin_object, "__reduce_ex__"); - } - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_ex, type_obj, "__reduce_ex__"); +#if CYTHON_USE_PYTYPE_LOOKUP + if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD; +#else + if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD; +#endif +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#else + object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#endif + reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD; if (reduce_ex == object_reduce_ex) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce, type_obj, "__reduce__"); - if (object_reduce == reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_cython, type_obj, "__reduce_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce__", reduce_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce_cython__"); if (ret < 0) goto BAD; - setstate = PyObject_GetAttrString(type_obj, "__setstate__"); +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#else + object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#endif + reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD; + if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { + reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD; + setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); if (!setstate) PyErr_Clear(); if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(setstate_cython, type_obj, "__setstate_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate__", setstate_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate_cython__"); if (ret < 0) goto BAD; + setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD; } PyType_Modified((PyTypeObject*)type_obj); } } goto GOOD; BAD: - if (!PyErr_Occurred()) PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); + if (!PyErr_Occurred()) + PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); ret = -1; GOOD: - Py_XDECREF(builtin_object); +#if !CYTHON_USE_PYTYPE_LOOKUP + Py_XDECREF(object_reduce); + Py_XDECREF(object_reduce_ex); +#endif Py_XDECREF(reduce); Py_XDECREF(reduce_ex); Py_XDECREF(reduce_cython); @@ -10005,35 +10401,19 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { return ret; } -/* GetVTable */ - static void* __Pyx_GetVtable(PyObject *dict) { - void* ptr; - PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable); - if (!ob) - goto bad; -#if PY_VERSION_HEX >= 0x02070000 - ptr = PyCapsule_GetPointer(ob, 0); -#else - ptr = PyCObject_AsVoidPtr(ob); -#endif - if (!ptr && !PyErr_Occurred()) - PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); - Py_DECREF(ob); - return ptr; -bad: - Py_XDECREF(ob); - return NULL; -} - /* CLineInTraceback */ - static int __Pyx_CLineForTraceback(int c_line) { + static int __Pyx_CLineForTraceback(int c_line) { #ifdef CYTHON_CLINE_IN_TRACEBACK return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; #else - PyObject **cython_runtime_dict; PyObject *use_cline; - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (unlikely(!cython_runtime_dict)) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { PyObject *ptype, *pvalue, *ptraceback; PyObject *use_cline_obj; PyErr_Fetch(&ptype, &pvalue, &ptraceback); @@ -10045,8 +10425,6 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { use_cline = NULL; } PyErr_Restore(ptype, pvalue, ptraceback); - } else { - use_cline = PyDict_GetItem(*_PyObject_GetDictPtr(__pyx_cython_runtime), __pyx_n_s_cline_in_traceback); } if (!use_cline) { c_line = 0; @@ -10060,7 +10438,7 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { } /* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + 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; @@ -10140,7 +10518,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { } /* AddTraceback */ - #include "compile.h" + #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( @@ -10210,10 +10588,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, __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*/ + __Pyx_PyThreadState_Current, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); @@ -10224,7 +10602,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + #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) @@ -10246,7 +10624,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value) { const unsigned long neg_one = (unsigned long) -1, const_zero = (unsigned long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -10277,7 +10655,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_libssh2_uint64_t(libssh2_uint64_t value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_libssh2_uint64_t(libssh2_uint64_t value) { const libssh2_uint64_t neg_one = (libssh2_uint64_t) -1, const_zero = (libssh2_uint64_t) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -10308,7 +10686,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -10339,7 +10717,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE unsigned long __Pyx_PyInt_As_unsigned_long(PyObject *x) { + static CYTHON_INLINE unsigned long __Pyx_PyInt_As_unsigned_long(PyObject *x) { const unsigned long neg_one = (unsigned long) -1, const_zero = (unsigned long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -10528,7 +10906,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE libssh2_uint64_t __Pyx_PyInt_As_libssh2_uint64_t(PyObject *x) { + static CYTHON_INLINE libssh2_uint64_t __Pyx_PyInt_As_libssh2_uint64_t(PyObject *x) { const libssh2_uint64_t neg_one = (libssh2_uint64_t) -1, const_zero = (libssh2_uint64_t) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -10717,7 +11095,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { + static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { const size_t neg_one = (size_t) -1, const_zero = (size_t) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -10906,7 +11284,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + 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 @@ -11095,7 +11473,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + 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) { @@ -11126,7 +11504,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + 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 @@ -11314,8 +11692,80 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, return (long) -1; } +/* FastTypeChecks */ + #if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + /* FetchCommonType */ - static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { + static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { PyObject* fake_module; PyTypeObject* cached_type = NULL; fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); @@ -11354,10 +11804,8 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* PyObjectCallMethod1 */ - static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { - PyObject *method, *result = NULL; - method = __Pyx_PyObject_GetAttrStr(obj, method_name); - if (unlikely(!method)) goto done; + static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) { + PyObject *result = NULL; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(method))) { PyObject *self = PyMethod_GET_SELF(method); @@ -11385,7 +11833,6 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, Py_INCREF(arg); PyTuple_SET_ITEM(args, 1, arg); Py_INCREF(function); - Py_DECREF(method); method = NULL; result = __Pyx_PyObject_Call(function, args, NULL); Py_DECREF(args); Py_DECREF(function); @@ -11394,24 +11841,27 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } #endif result = __Pyx_PyObject_CallOneArg(method, arg); + goto done; +done: + return result; +} +static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { + PyObject *method, *result = NULL; + method = __Pyx_PyObject_GetAttrStr(obj, method_name); + if (unlikely(!method)) goto done; + result = __Pyx__PyObject_CallMethod1(method, arg); done: Py_XDECREF(method); return result; } /* CoroutineBase */ - #include + #include #include -static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value); -static PyObject *__Pyx_Coroutine_Close(PyObject *self); -static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args); #define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom) -#if 1 || PY_VERSION_HEX < 0x030300B0 -static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) { +static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) { PyObject *et, *ev, *tb; PyObject *value = NULL; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign __Pyx_ErrFetch(&et, &ev, &tb); if (!et) { Py_XDECREF(tb); @@ -11446,7 +11896,7 @@ static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) { } Py_DECREF(ev); } - else if (!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) { + else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) { value = ev; } if (likely(value)) { @@ -11455,7 +11905,7 @@ static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) { *pvalue = value; return 0; } - } else if (!PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) { + } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) { __Pyx_ErrRestore(et, ev, tb); return -1; } @@ -11488,7 +11938,6 @@ static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) { *pvalue = value; return 0; } -#endif static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) { PyObject *exc_type = self->exc_type; @@ -11501,72 +11950,121 @@ void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) { Py_XDECREF(exc_value); Py_XDECREF(exc_traceback); } -static CYTHON_INLINE -int __Pyx_Coroutine_CheckRunning(__pyx_CoroutineObject *gen) { - if (unlikely(gen->is_running)) { - PyErr_SetString(PyExc_ValueError, - "generator already executing"); - return 1; +#define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL) +static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) { + const char *msg; + if (0) { + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_Coroutine_CheckExact((PyObject*)gen)) { + msg = "coroutine already executing"; + #endif + #ifdef __Pyx_AsyncGen_USED + } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) { + msg = "async generator already executing"; + #endif + } else { + msg = "generator already executing"; } - return 0; + PyErr_SetString(PyExc_ValueError, msg); } -static CYTHON_INLINE -PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) { - PyObject *retval; +#define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL) +static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) { + const char *msg; + if (0) { + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_Coroutine_CheckExact(gen)) { + msg = "can't send non-None value to a just-started coroutine"; + #endif + #ifdef __Pyx_AsyncGen_USED + } else if (__Pyx_AsyncGen_CheckExact(gen)) { + msg = "can't send non-None value to a just-started async generator"; + #endif + } else { + msg = "can't send non-None value to a just-started generator"; + } + PyErr_SetString(PyExc_TypeError, msg); +} +#define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing) (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL) +static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) { + #ifdef __Pyx_Coroutine_USED + if (!closing && __Pyx_Coroutine_CheckExact(gen)) { + PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine"); + } else + #endif + if (value) { + #ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(gen)) + PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration); + else + #endif + PyErr_SetNone(PyExc_StopIteration); + } +} +static +PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) { __Pyx_PyThreadState_declare + PyThreadState *tstate; + PyObject *retval; assert(!self->is_running); if (unlikely(self->resume_label == 0)) { if (unlikely(value && value != Py_None)) { - PyErr_SetString(PyExc_TypeError, - "can't send non-None value to a " - "just-started generator"); - return NULL; + return __Pyx_Coroutine_NotStartedError((PyObject*)self); } } if (unlikely(self->resume_label == -1)) { - PyErr_SetNone(PyExc_StopIteration); - return NULL; + return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing); } +#if CYTHON_FAST_THREAD_STATE __Pyx_PyThreadState_assign - if (value) { + tstate = __pyx_tstate; +#else + tstate = __Pyx_PyThreadState_Current; +#endif + if (self->exc_type) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON #else if (self->exc_traceback) { PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback; PyFrameObject *f = tb->tb_frame; - Py_XINCREF(__pyx_tstate->frame); + Py_XINCREF(tstate->frame); assert(f->f_back == NULL); - f->f_back = __pyx_tstate->frame; + f->f_back = tstate->frame; } #endif __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, &self->exc_traceback); } else { __Pyx_Coroutine_ExceptionClear(self); + __Pyx_ExceptionSave(&self->exc_type, &self->exc_value, &self->exc_traceback); } self->is_running = 1; - retval = self->body((PyObject *) self, value); + retval = self->body((PyObject *) self, tstate, value); self->is_running = 0; - if (retval) { - __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, - &self->exc_traceback); + return retval; +} +static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__pyx_CoroutineObject *self) { + if (likely(self->exc_traceback)) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON #else - if (self->exc_traceback) { - PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback; - PyFrameObject *f = tb->tb_frame; - Py_CLEAR(f->f_back); - } + PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback; + PyFrameObject *f = tb->tb_frame; + Py_CLEAR(f->f_back); #endif - } else { - __Pyx_Coroutine_ExceptionClear(self); } - return retval; } static CYTHON_INLINE -PyObject *__Pyx_Coroutine_MethodReturn(PyObject *retval) { - if (unlikely(!retval && !PyErr_Occurred())) { - PyErr_SetNone(PyExc_StopIteration); +PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) { + if (unlikely(!retval)) { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + if (!__Pyx_PyErr_Occurred()) { + PyObject *exc = PyExc_StopIteration; + #ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(gen)) + exc = __Pyx_PyExc_StopAsyncIteration; + #endif + __Pyx_PyErr_SetNone(exc); + } } return retval; } @@ -11575,8 +12073,8 @@ PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) { PyObject *ret; PyObject *val = NULL; __Pyx_Coroutine_Undelegate(gen); - __Pyx_PyGen_FetchStopIterationValue(&val); - ret = __Pyx_Coroutine_SendEx(gen, val); + __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val); + ret = __Pyx_Coroutine_SendEx(gen, val, 0); Py_XDECREF(val); return ret; } @@ -11584,8 +12082,8 @@ static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) { PyObject *retval; __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; PyObject *yf = gen->yieldfrom; - if (unlikely(__Pyx_Coroutine_CheckRunning(gen))) - return NULL; + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); if (yf) { PyObject *ret; gen->is_running = 1; @@ -11599,6 +12097,21 @@ static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) { ret = __Pyx_Coroutine_Send(yf, value); } else #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_PyAsyncGenASend_CheckExact(yf)) { + ret = __Pyx_async_gen_asend_send(yf, value); + } else + #endif + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (!defined(_MSC_VER) || PY_VERSION_HEX >= 0x03060000) + if (PyGen_CheckExact(yf)) { + ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value); + } else + #endif + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (!defined(_MSC_VER) || PY_VERSION_HEX >= 0x03060000) + if (PyCoro_CheckExact(yf)) { + ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value); + } else + #endif { if (value == Py_None) ret = Py_TYPE(yf)->tp_iternext(yf); @@ -11611,9 +12124,9 @@ static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) { } retval = __Pyx_Coroutine_FinishDelegation(gen); } else { - retval = __Pyx_Coroutine_SendEx(gen, value); + retval = __Pyx_Coroutine_SendEx(gen, value, 0); } - return __Pyx_Coroutine_MethodReturn(retval); + return __Pyx_Coroutine_MethodReturn(self, retval); } static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) { PyObject *retval = NULL; @@ -11631,6 +12144,19 @@ static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) { if (!retval) return -1; } else + if (__Pyx_CoroutineAwait_CheckExact(yf)) { + retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf); + if (!retval) + return -1; + } else + #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_PyAsyncGenASend_CheckExact(yf)) { + retval = __Pyx_async_gen_asend_close(yf, NULL); + } else + if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) { + retval = __Pyx_async_gen_athrow_close(yf, NULL); + } else #endif { PyObject *meth; @@ -11655,8 +12181,8 @@ static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) { static PyObject *__Pyx_Generator_Next(PyObject *self) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; PyObject *yf = gen->yieldfrom; - if (unlikely(__Pyx_Coroutine_CheckRunning(gen))) - return NULL; + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); if (yf) { PyObject *ret; gen->is_running = 1; @@ -11664,6 +12190,11 @@ static PyObject *__Pyx_Generator_Next(PyObject *self) { if (__Pyx_Generator_CheckExact(yf)) { ret = __Pyx_Generator_Next(yf); } else + #endif + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (!defined(_MSC_VER) || PY_VERSION_HEX >= 0x03060000) + if (PyGen_CheckExact(yf)) { + ret = _PyGen_Send((PyGenObject*)yf, NULL); + } else #endif ret = Py_TYPE(yf)->tp_iternext(yf); gen->is_running = 0; @@ -11672,15 +12203,15 @@ static PyObject *__Pyx_Generator_Next(PyObject *self) { } return __Pyx_Coroutine_FinishDelegation(gen); } - return __Pyx_Coroutine_SendEx(gen, Py_None); + return __Pyx_Coroutine_SendEx(gen, Py_None, 0); } static PyObject *__Pyx_Coroutine_Close(PyObject *self) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; PyObject *retval, *raised_exception; PyObject *yf = gen->yieldfrom; int err = 0; - if (unlikely(__Pyx_Coroutine_CheckRunning(gen))) - return NULL; + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); if (yf) { Py_INCREF(yf); err = __Pyx_Coroutine_CloseIter(gen, yf); @@ -11689,59 +12220,69 @@ static PyObject *__Pyx_Coroutine_Close(PyObject *self) { } if (err == 0) PyErr_SetNone(PyExc_GeneratorExit); - retval = __Pyx_Coroutine_SendEx(gen, NULL); - if (retval) { + retval = __Pyx_Coroutine_SendEx(gen, NULL, 1); + if (unlikely(retval)) { + const char *msg; Py_DECREF(retval); - PyErr_SetString(PyExc_RuntimeError, - "generator ignored GeneratorExit"); + if ((0)) { + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_Coroutine_CheckExact(self)) { + msg = "coroutine ignored GeneratorExit"; + #endif + #ifdef __Pyx_AsyncGen_USED + } else if (__Pyx_AsyncGen_CheckExact(self)) { +#if PY_VERSION_HEX < 0x03060000 + msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)"; +#else + msg = "async generator ignored GeneratorExit"; +#endif + #endif + } else { + msg = "generator ignored GeneratorExit"; + } + PyErr_SetString(PyExc_RuntimeError, msg); return NULL; } raised_exception = PyErr_Occurred(); - if (!raised_exception - || raised_exception == PyExc_StopIteration - || raised_exception == PyExc_GeneratorExit - || PyErr_GivenExceptionMatches(raised_exception, PyExc_GeneratorExit) - || PyErr_GivenExceptionMatches(raised_exception, PyExc_StopIteration)) - { + if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) { if (raised_exception) PyErr_Clear(); Py_INCREF(Py_None); return Py_None; } return NULL; } -static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) { +static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb, + PyObject *args, int close_on_genexit) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; - PyObject *typ; - PyObject *tb = NULL; - PyObject *val = NULL; PyObject *yf = gen->yieldfrom; - if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb)) - return NULL; - if (unlikely(__Pyx_Coroutine_CheckRunning(gen))) - return NULL; + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); if (yf) { PyObject *ret; Py_INCREF(yf); - if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) { + if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) { int err = __Pyx_Coroutine_CloseIter(gen, yf); Py_DECREF(yf); __Pyx_Coroutine_Undelegate(gen); if (err < 0) - return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL)); + return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0)); goto throw_here; } gen->is_running = 1; + if (0 #ifdef __Pyx_Generator_USED - if (__Pyx_Generator_CheckExact(yf)) { - ret = __Pyx_Coroutine_Throw(yf, args); - } else + || __Pyx_Generator_CheckExact(yf) #endif #ifdef __Pyx_Coroutine_USED - if (__Pyx_Coroutine_CheckExact(yf)) { - ret = __Pyx_Coroutine_Throw(yf, args); - } else + || __Pyx_Coroutine_CheckExact(yf) #endif - { + ) { + ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit); + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_CoroutineAwait_CheckExact(yf)) { + ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit); + #endif + } else { PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw); if (unlikely(!meth)) { Py_DECREF(yf); @@ -11754,7 +12295,11 @@ static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) { gen->is_running = 0; goto throw_here; } - ret = PyObject_CallObject(meth, args); + if (likely(args)) { + ret = PyObject_CallObject(meth, args); + } else { + ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL); + } Py_DECREF(meth); } gen->is_running = 0; @@ -11762,14 +12307,21 @@ static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) { if (!ret) { ret = __Pyx_Coroutine_FinishDelegation(gen); } - return __Pyx_Coroutine_MethodReturn(ret); + return __Pyx_Coroutine_MethodReturn(self, ret); } throw_here: __Pyx_Raise(typ, val, tb, NULL); - return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL)); + return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0)); } -static int __Pyx_Coroutine_traverse(PyObject *self, visitproc visit, void *arg) { - __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; +static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) { + PyObject *typ; + PyObject *val = NULL; + PyObject *tb = NULL; + if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb)) + return NULL; + return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1); +} +static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) { Py_VISIT(gen->closure); Py_VISIT(gen->classobj); Py_VISIT(gen->yieldfrom); @@ -11786,6 +12338,11 @@ static int __Pyx_Coroutine_clear(PyObject *self) { Py_CLEAR(gen->exc_type); Py_CLEAR(gen->exc_value); Py_CLEAR(gen->exc_traceback); +#ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(self)) { + Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer); + } +#endif Py_CLEAR(gen->gi_name); Py_CLEAR(gen->gi_qualname); return 0; @@ -11795,9 +12352,9 @@ static void __Pyx_Coroutine_dealloc(PyObject *self) { PyObject_GC_UnTrack(gen); if (gen->gi_weakreflist != NULL) PyObject_ClearWeakRefs(self); - if (gen->resume_label > 0) { + if (gen->resume_label >= 0) { PyObject_GC_Track(self); -#if PY_VERSION_HEX >= 0x030400a1 +#if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE if (PyObject_CallFinalizerFromDealloc(self)) #else Py_TYPE(gen)->tp_del(self); @@ -11808,29 +12365,93 @@ static void __Pyx_Coroutine_dealloc(PyObject *self) { } PyObject_GC_UnTrack(self); } +#ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(self)) { + /* We have to handle this case for asynchronous generators + right here, because this code has to be between UNTRACK + and GC_Del. */ + Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer); + } +#endif __Pyx_Coroutine_clear(self); PyObject_GC_Del(gen); } static void __Pyx_Coroutine_del(PyObject *self) { - PyObject *res; PyObject *error_type, *error_value, *error_traceback; __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; __Pyx_PyThreadState_declare - if (gen->resume_label <= 0) - return ; -#if PY_VERSION_HEX < 0x030400a1 + if (gen->resume_label < 0) { + return; + } +#if !CYTHON_USE_TP_FINALIZE assert(self->ob_refcnt == 0); self->ob_refcnt = 1; #endif __Pyx_PyThreadState_assign __Pyx_ErrFetch(&error_type, &error_value, &error_traceback); - res = __Pyx_Coroutine_Close(self); - if (res == NULL) - PyErr_WriteUnraisable(self); - else - Py_DECREF(res); +#ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(self)) { + __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self; + PyObject *finalizer = agen->ag_finalizer; + if (finalizer && !agen->ag_closed) { + PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self); + if (unlikely(!res)) { + PyErr_WriteUnraisable(self); + } else { + Py_DECREF(res); + } + __Pyx_ErrRestore(error_type, error_value, error_traceback); + return; + } + } +#endif + if (unlikely(gen->resume_label == 0 && !error_value)) { +#ifdef __Pyx_Coroutine_USED +#ifdef __Pyx_Generator_USED + if (!__Pyx_Generator_CheckExact(self)) +#endif + { + PyObject_GC_UnTrack(self); +#if PY_MAJOR_VERSION >= 3 || defined(PyErr_WarnFormat) + if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0)) + PyErr_WriteUnraisable(self); +#else + {PyObject *msg; + char *cmsg; + #if CYTHON_COMPILING_IN_PYPY + msg = NULL; + cmsg = (char*) "coroutine was never awaited"; + #else + char *cname; + PyObject *qualname; + qualname = gen->gi_qualname; + cname = PyString_AS_STRING(qualname); + msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname); + if (unlikely(!msg)) { + PyErr_Clear(); + cmsg = (char*) "coroutine was never awaited"; + } else { + cmsg = PyString_AS_STRING(msg); + } + #endif + if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0)) + PyErr_WriteUnraisable(self); + Py_XDECREF(msg);} +#endif + PyObject_GC_Track(self); + } +#endif + } else { + PyObject *res = __Pyx_Coroutine_Close(self); + if (unlikely(!res)) { + if (PyErr_Occurred()) + PyErr_WriteUnraisable(self); + } else { + Py_DECREF(res); + } + } __Pyx_ErrRestore(error_type, error_value, error_traceback); -#if PY_VERSION_HEX < 0x030400a1 +#if !CYTHON_USE_TP_FINALIZE assert(self->ob_refcnt > 0); if (--self->ob_refcnt == 0) { return; @@ -11909,8 +12530,13 @@ static __pyx_CoroutineObject *__Pyx__Coroutine_New( PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *closure, PyObject *name, PyObject *qualname, PyObject *module_name) { __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type); - if (gen == NULL) + if (unlikely(!gen)) return NULL; + return __Pyx__Coroutine_NewInit(gen, body, closure, name, qualname, module_name); +} +static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit( + __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name) { gen->body = body; gen->closure = closure; Py_XINCREF(closure); @@ -11933,7 +12559,7 @@ static __pyx_CoroutineObject *__Pyx__Coroutine_New( } /* PatchModuleWithCoroutine */ - static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) { + static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) { #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) int result; PyObject *globals, *result_obj; @@ -11973,7 +12599,10 @@ static __pyx_CoroutineObject *__Pyx__Coroutine_New( } /* PatchGeneratorABC */ - #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + #ifndef CYTHON_REGISTER_ABCS +#define CYTHON_REGISTER_ABCS 1 +#endif +#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) static PyObject* __Pyx_patch_abc_module(PyObject *module); static PyObject* __Pyx_patch_abc_module(PyObject *module) { module = __Pyx_Coroutine_patch_module( @@ -11993,13 +12622,13 @@ static PyObject* __Pyx_patch_abc_module(PyObject *module) { static int __Pyx_patch_abc(void) { #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) static int abc_patched = 0; - if (!abc_patched) { + if (CYTHON_REGISTER_ABCS && !abc_patched) { PyObject *module; - module = PyImport_ImportModule((PY_VERSION_HEX >= 0x03030000) ? "collections.abc" : "collections"); + module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections"); if (!module) { PyErr_WriteUnraisable(NULL); if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, - ((PY_VERSION_HEX >= 0x03030000) ? + ((PY_MAJOR_VERSION >= 3) ? "Cython module failed to register with collections.abc module" : "Cython module failed to register with collections module"), 1) < 0)) { return -1; @@ -12021,13 +12650,13 @@ static int __Pyx_patch_abc(void) { } } #else - if (0) __Pyx_Coroutine_patch_module(NULL, NULL); + if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL); #endif return 0; } /* Generator */ - static PyMethodDef __pyx_Generator_methods[] = { + static PyMethodDef __pyx_Generator_methods[] = { {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O, (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")}, {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS, @@ -12095,14 +12724,16 @@ static PyTypeObject __pyx_GeneratorType_type = { 0, 0, 0, -#if PY_VERSION_HEX >= 0x030400a1 +#if CYTHON_USE_TP_FINALIZE 0, #else __Pyx_Coroutine_del, #endif 0, -#if PY_VERSION_HEX >= 0x030400a1 +#if CYTHON_USE_TP_FINALIZE __Pyx_Coroutine_del, +#elif PY_VERSION_HEX >= 0x030400a1 + 0, #endif }; static int __pyx_Generator_init(void) { @@ -12116,7 +12747,7 @@ static int __pyx_Generator_init(void) { } /* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { + 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()); @@ -12132,7 +12763,7 @@ static int __pyx_Generator_init(void) { } /* FunctionExport */ - static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { + static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { PyObject *d = 0; PyObject *cobj = 0; union { @@ -12169,7 +12800,7 @@ static int __pyx_Generator_init(void) { } /* ModuleImport */ - #ifndef __PYX_HAVE_RT_ImportModule + #ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; @@ -12187,7 +12818,7 @@ static PyObject *__Pyx_ImportModule(const char *name) { #endif /* TypeImport */ - #ifndef __PYX_HAVE_RT_ImportType + #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) @@ -12252,7 +12883,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class #endif /* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { @@ -12291,46 +12922,53 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#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 && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} #endif #endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __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 && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -12354,6 +12992,26 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; @@ -12361,9 +13019,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS @@ -12371,32 +13029,30 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } #else - if (m && m->nb_int) { + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); } #endif #else - res = PyNumber_Int(x); + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { diff --git a/ssh2/sftp_handle.pyx b/ssh2/sftp_handle.pyx index 6ce80c36..b621ebf6 100644 --- a/ssh2/sftp_handle.pyx +++ b/ssh2/sftp_handle.pyx @@ -14,6 +14,8 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +from .exceptions cimport SFTPIOError + from libc.stdlib cimport malloc, free cimport c_ssh2 @@ -124,7 +126,7 @@ cdef class SFTPHandle: cdef int rc cdef bytes data rc, data = self.read() - if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and len(data) == 0: + if rc != c_ssh2.LIBSSH2_ERROR_EAGAIN and rc <= 0: raise StopIteration return rc, data @@ -156,7 +158,7 @@ cdef class SFTPHandle: :rtype: bytes""" cdef ssize_t rc - cdef bytes buf + cdef bytes buf = b'' cdef char *cbuf with nogil: cbuf = malloc(sizeof(char)*buffer_maxlen) @@ -168,8 +170,6 @@ cdef class SFTPHandle: try: if rc > 0: buf = cbuf[:rc] - else: - buf = b'' finally: free(cbuf) return rc, buf @@ -184,13 +184,14 @@ cdef class SFTPHandle: This function is a generator and should be iterated on. :param buffer_maxlen: Max length of returned buffer. - :param longentry_maxlen: Max length of filename in listing. + :param longentry_maxlen: Max length of file list entry. - :rtype: bytes""" + :rtype: bytes + """ rc, buf, entry, attrs = self._readdir_ex( longentry_maxlen=longentry_maxlen, buffer_maxlen=buffer_maxlen) - while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or len(buf) > 0: + while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or rc > 0: yield rc, buf, entry, attrs rc, buf, entryb, attrs = self._readdir_ex( longentry_maxlen=longentry_maxlen, @@ -199,8 +200,8 @@ cdef class SFTPHandle: def _readdir_ex(self, size_t longentry_maxlen=1024, size_t buffer_maxlen=1024): - cdef bytes buf - cdef bytes filename + cdef bytes buf = b'' + cdef bytes b_longentry = b'' cdef char *cbuf cdef char *longentry cdef SFTPAttributes attrs = SFTPAttributes() @@ -216,12 +217,11 @@ cdef class SFTPHandle: try: if rc > 0: buf = cbuf[:rc] - else: - buf = b'' + b_longentry = longentry finally: free(cbuf) free(longentry) - return rc, buf, longentry, attrs + return rc, buf, b_longentry, attrs def readdir(self, size_t buffer_maxlen=1024): """Get directory listing from file handle, if any. @@ -234,13 +234,13 @@ cdef class SFTPHandle: :rtype: iter(bytes)""" rc, buf, attrs = self._readdir(buffer_maxlen) - while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or len(buf) > 0: + while rc == c_ssh2.LIBSSH2_ERROR_EAGAIN or rc > 0: yield rc, buf, attrs rc, buf, attrs = self._readdir(buffer_maxlen) def _readdir(self, size_t buffer_maxlen=1024): - cdef bytes buf + cdef bytes buf = b'' cdef char *cbuf cdef SFTPAttributes attrs = SFTPAttributes() with nogil: @@ -253,8 +253,6 @@ cdef class SFTPHandle: try: if rc > 0: buf = cbuf[:rc] - else: - buf = b'' finally: free(cbuf) return rc, buf, attrs @@ -271,6 +269,9 @@ cdef class SFTPHandle: cdef ssize_t rc with nogil: rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) + if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + with gil: + raise SFTPIOError("Error writing to file via SFTP") return rc IF EMBEDDED_LIB: @@ -370,6 +371,7 @@ cdef class SFTPHandle: :rtype: `ssh2.sftp.SFTPStatVFS` or int of error code""" cdef SFTPStatVFS vfs = SFTPStatVFS(self) + cdef int rc with nogil: rc = c_sftp.libssh2_sftp_fstatvfs(self._handle, vfs._ptr) if rc != 0: diff --git a/ssh2/statinfo.c b/ssh2/statinfo.c index 8485435c..85885e4e 100644 --- a/ssh2/statinfo.c +++ b/ssh2/statinfo.c @@ -1,13 +1,14 @@ -/* Generated by Cython 0.26 */ +/* Generated by Cython 0.27.1 */ #define PY_SSIZE_T_CLEAN #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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_26" +#define CYTHON_ABI "0_27_1" +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -31,7 +32,7 @@ #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif @@ -47,8 +48,14 @@ #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS @@ -67,6 +74,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -74,6 +85,8 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS @@ -98,6 +111,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -105,6 +122,12 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 @@ -144,6 +167,12 @@ #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -199,6 +228,27 @@ #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ @@ -282,7 +332,6 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject @@ -333,15 +382,17 @@ #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct 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)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) @@ -451,14 +502,6 @@ static CYTHON_INLINE float __PYX_NAN() { __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) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -479,7 +522,7 @@ static CYTHON_INLINE float __PYX_NAN() { #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif @@ -510,8 +553,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #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 (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -533,6 +576,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) @@ -543,16 +592,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #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) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #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 @@ -561,6 +605,8 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) #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_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS @@ -661,7 +707,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime; @@ -678,6 +724,18 @@ static const char *__pyx_f[] = { "ssh2/statinfo.pyx", "stringsource", }; +/* NoFastGil.proto */ +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + /*--- Type declarations ---*/ struct __pyx_obj_4ssh2_8statinfo_StatInfo; @@ -783,19 +841,7 @@ 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); /* KeywordStringCheck.proto */ -static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); - -/* NoFastGil.proto */ -#define __Pyx_PyGILState_Ensure PyGILState_Ensure -#define __Pyx_PyGILState_Release PyGILState_Release -#define __Pyx_FastGIL_Remember() -#define __Pyx_FastGIL_Forget() -#define __Pyx_FastGilFuncInit() - -/* ForceInitThreads.proto */ -#ifndef __PYX_FORCE_INIT_THREADS - #define __PYX_FORCE_INIT_THREADS 0 -#endif +static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON @@ -807,21 +853,31 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #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); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #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) @@ -895,6 +951,18 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif + /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); @@ -923,8 +991,13 @@ int __pyx_module_is_main_ssh2__statinfo = 0; static PyObject *__pyx_builtin_MemoryError; static PyObject *__pyx_builtin_TypeError; static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_reduce[] = "__reduce__"; +static const char __pyx_k_getstate[] = "__getstate__"; +static const char __pyx_k_setstate[] = "__setstate__"; static const char __pyx_k_TypeError[] = "TypeError"; +static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; static const char __pyx_k_MemoryError[] = "MemoryError"; static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; @@ -933,9 +1006,14 @@ static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __red static PyObject *__pyx_n_s_MemoryError; static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_n_s_cline_in_traceback; +static PyObject *__pyx_n_s_getstate; static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_name; static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; +static PyObject *__pyx_n_s_reduce; static PyObject *__pyx_n_s_reduce_cython; +static PyObject *__pyx_n_s_reduce_ex; +static PyObject *__pyx_n_s_setstate; static PyObject *__pyx_n_s_setstate_cython; static PyObject *__pyx_n_s_test; static int __pyx_pf_4ssh2_8statinfo_8StatInfo___cinit__(struct __pyx_obj_4ssh2_8statinfo_StatInfo *__pyx_v_self); /* proto */ @@ -2002,7 +2080,7 @@ static PyObject *__pyx_tp_new_4ssh2_8statinfo_StatInfo(PyTypeObject *t, CYTHON_U } static void __pyx_tp_dealloc_4ssh2_8statinfo_StatInfo(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 + #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { if (PyObject_CallFinalizerFromDealloc(o)) return; } @@ -2151,17 +2229,31 @@ static PyMethodDef __pyx_methods[] = { }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_statinfo(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_statinfo}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "statinfo", 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ @@ -2172,9 +2264,14 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, + {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, + {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, + {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} @@ -2229,10 +2326,54 @@ PyMODINIT_FUNC initstatinfo(void) #else PyMODINIT_FUNC PyInit_statinfo(void); /*proto*/ PyMODINIT_FUNC PyInit_statinfo(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec_statinfo(PyObject *__pyx_pyinit_module) +#endif #endif { PyObject *__pyx_t_1 = NULL; __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { @@ -2259,6 +2400,9 @@ PyMODINIT_FUNC PyInit_statinfo(void) #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_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 @@ -2270,12 +2414,17 @@ PyMODINIT_FUNC PyInit_statinfo(void) #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("statinfo", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -2326,7 +2475,7 @@ PyMODINIT_FUNC PyInit_statinfo(void) * # Copyright (C) 2017 Panos Kittenis * */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); 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_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -2346,10 +2495,12 @@ PyMODINIT_FUNC PyInit_statinfo(void) } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -2412,7 +2563,7 @@ static void __Pyx_RaiseArgtupleInvalid( } /* KeywordStringCheck */ -static CYTHON_INLINE int __Pyx_CheckKeywordStrings( +static int __Pyx_CheckKeywordStrings( PyObject *kwdict, const char* function_name, int kw_allowed) @@ -2426,7 +2577,7 @@ static CYTHON_INLINE int __Pyx_CheckKeywordStrings( #else while (PyDict_Next(kwdict, &pos, &key, 0)) { #if PY_MAJOR_VERSION < 3 - if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) + if (unlikely(!PyString_Check(key))) #endif if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type; @@ -2611,11 +2762,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject "raise: exception class must be a subclass of BaseException"); goto bad; } -#if PY_VERSION_HEX >= 0x03030000 if (cause) { -#else - if (cause && cause != Py_None) { -#endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; @@ -2643,7 +2790,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else - PyThreadState *tstate = PyThreadState_GET(); + PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); @@ -2659,17 +2806,16 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject #endif /* SetupReduce */ - #define __Pyx_setup_reduce_GET_ATTR_OR_BAD(res, obj, name) res = PyObject_GetAttrString(obj, name); if (res == NULL) goto BAD; static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { int ret; PyObject *name_attr; - name_attr = PyObject_GetAttrString(meth, "__name__"); - if (name_attr) { + name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name); + if (likely(name_attr)) { ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); } else { ret = -1; } - if (ret < 0) { + if (unlikely(ret < 0)) { PyErr_Clear(); ret = 0; } @@ -2678,43 +2824,55 @@ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { } static int __Pyx_setup_reduce(PyObject* type_obj) { int ret = 0; - PyObject* builtin_object = NULL; - static PyObject *object_reduce = NULL; - static PyObject *object_reduce_ex = NULL; + PyObject *object_reduce = NULL; + PyObject *object_reduce_ex = NULL; PyObject *reduce = NULL; PyObject *reduce_ex = NULL; PyObject *reduce_cython = NULL; PyObject *setstate = NULL; PyObject *setstate_cython = NULL; - if (PyObject_HasAttrString(type_obj, "__getstate__")) goto GOOD; - if (object_reduce_ex == NULL) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(builtin_object, __pyx_b, "object"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce, builtin_object, "__reduce__"); - __Pyx_setup_reduce_GET_ATTR_OR_BAD(object_reduce_ex, builtin_object, "__reduce_ex__"); - } - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_ex, type_obj, "__reduce_ex__"); +#if CYTHON_USE_PYTYPE_LOOKUP + if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD; +#else + if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD; +#endif +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#else + object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#endif + reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD; if (reduce_ex == object_reduce_ex) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce, type_obj, "__reduce__"); - if (object_reduce == reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(reduce_cython, type_obj, "__reduce_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce__", reduce_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__reduce_cython__"); if (ret < 0) goto BAD; - setstate = PyObject_GetAttrString(type_obj, "__setstate__"); +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#else + object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#endif + reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD; + if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { + reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD; + setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); if (!setstate) PyErr_Clear(); if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { - __Pyx_setup_reduce_GET_ATTR_OR_BAD(setstate_cython, type_obj, "__setstate_cython__"); - ret = PyDict_SetItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate__", setstate_cython); if (ret < 0) goto BAD; - ret = PyDict_DelItemString(((PyTypeObject*)type_obj)->tp_dict, "__setstate_cython__"); if (ret < 0) goto BAD; + setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD; } PyType_Modified((PyTypeObject*)type_obj); } } goto GOOD; BAD: - if (!PyErr_Occurred()) PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); + if (!PyErr_Occurred()) + PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); ret = -1; GOOD: - Py_XDECREF(builtin_object); +#if !CYTHON_USE_PYTYPE_LOOKUP + Py_XDECREF(object_reduce); + Py_XDECREF(object_reduce_ex); +#endif Py_XDECREF(reduce); Py_XDECREF(reduce_ex); Py_XDECREF(reduce_cython); @@ -2724,14 +2882,18 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { } /* CLineInTraceback */ - static int __Pyx_CLineForTraceback(int c_line) { +static int __Pyx_CLineForTraceback(int c_line) { #ifdef CYTHON_CLINE_IN_TRACEBACK return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; #else - PyObject **cython_runtime_dict; PyObject *use_cline; - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (unlikely(!cython_runtime_dict)) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { PyObject *ptype, *pvalue, *ptraceback; PyObject *use_cline_obj; PyErr_Fetch(&ptype, &pvalue, &ptraceback); @@ -2743,8 +2905,6 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { use_cline = NULL; } PyErr_Restore(ptype, pvalue, ptraceback); - } else { - use_cline = PyDict_GetItem(*_PyObject_GetDictPtr(__pyx_cython_runtime), __pyx_n_s_cline_in_traceback); } if (!use_cline) { c_line = 0; @@ -2758,7 +2918,7 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { } /* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { +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; @@ -2838,7 +2998,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { } /* AddTraceback */ - #include "compile.h" +#include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( @@ -2908,10 +3068,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, __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*/ + __Pyx_PyThreadState_Current, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); @@ -2922,7 +3082,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_off_t(off_t value) { +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_off_t(off_t value) { const off_t neg_one = (off_t) -1, const_zero = (off_t) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -2953,7 +3113,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_ino_t(ino_t value) { +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_ino_t(ino_t value) { const ino_t neg_one = (ino_t) -1, const_zero = (ino_t) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -2984,7 +3144,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_mode_t(mode_t value) { +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_mode_t(mode_t value) { const mode_t neg_one = (mode_t) -1, const_zero = (mode_t) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -3015,7 +3175,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_nlink_t(nlink_t value) { +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_nlink_t(nlink_t value) { const nlink_t neg_one = (nlink_t) -1, const_zero = (nlink_t) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -3046,7 +3206,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uid_t(uid_t value) { +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uid_t(uid_t value) { const uid_t neg_one = (uid_t) -1, const_zero = (uid_t) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -3077,7 +3237,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_gid_t(gid_t value) { +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_gid_t(gid_t value) { const gid_t neg_one = (gid_t) -1, const_zero = (gid_t) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -3108,7 +3268,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_dev_t(dev_t value) { +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_dev_t(dev_t value) { const dev_t neg_one = (dev_t) -1, const_zero = (dev_t) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -3139,7 +3299,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_blksize_t(blksize_t value) { +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_blksize_t(blksize_t value) { const blksize_t neg_one = (blksize_t) -1, const_zero = (blksize_t) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -3170,7 +3330,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_blkcnt_t(blkcnt_t value) { +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_blkcnt_t(blkcnt_t value) { const blkcnt_t neg_one = (blkcnt_t) -1, const_zero = (blkcnt_t) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -3201,7 +3361,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_time_t(time_t value) { +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_time_t(time_t value) { const time_t neg_one = (time_t) -1, const_zero = (time_t) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -3232,7 +3392,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { +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) { @@ -3263,7 +3423,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ +#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) @@ -3285,7 +3445,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { +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 @@ -3474,7 +3634,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { +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 @@ -3662,8 +3822,80 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, return (int) -1; } +/* FastTypeChecks */ +#if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + /* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { +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()); @@ -3679,7 +3911,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { @@ -3718,46 +3950,53 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#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 && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} #endif #endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __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 && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -3781,6 +4020,26 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; @@ -3788,9 +4047,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS @@ -3798,32 +4057,30 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } #else - if (m && m->nb_int) { + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); } #endif #else - res = PyNumber_Int(x); + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { diff --git a/ssh2/utils.c b/ssh2/utils.c index 7a046882..eca103d6 100644 --- a/ssh2/utils.c +++ b/ssh2/utils.c @@ -1,13 +1,14 @@ -/* Generated by Cython 0.26 */ +/* Generated by Cython 0.27.1 */ #define PY_SSIZE_T_CLEAN #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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_26" +#define CYTHON_ABI "0_27_1" +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -31,7 +32,7 @@ #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) + #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif @@ -47,8 +48,14 @@ #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS @@ -67,6 +74,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 @@ -74,6 +85,8 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS @@ -98,6 +111,10 @@ #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 @@ -105,6 +122,12 @@ #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 @@ -144,6 +167,12 @@ #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) @@ -199,6 +228,27 @@ #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ @@ -282,7 +332,6 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject @@ -333,15 +382,17 @@ #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct 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)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) @@ -451,14 +502,6 @@ static CYTHON_INLINE float __PYX_NAN() { __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) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -478,7 +521,7 @@ static CYTHON_INLINE float __PYX_NAN() { #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif @@ -509,8 +552,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #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 (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -532,6 +575,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) @@ -542,16 +591,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #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) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #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 @@ -560,6 +604,8 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) #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_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS @@ -660,7 +706,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime; @@ -677,31 +723,37 @@ static const char *__pyx_f[] = { "ssh2/utils.pyx", "ssh2/session.pxd", }; +/* NoFastGil.proto */ +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + /*--- Type declarations ---*/ struct __pyx_obj_4ssh2_7session_Session; -/* "session.pxd":20 - * +/* "session.pxd":19 + * cimport c_ssh2 * * cdef class Session: # <<<<<<<<<<<<<< * cdef c_ssh2.LIBSSH2_SESSION *_session - * cdef c_ssh2.LIBSSH2_AGENT * init_connect_agent(self) except NULL + * cdef int _sock */ struct __pyx_obj_4ssh2_7session_Session { PyObject_HEAD - struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtab; LIBSSH2_SESSION *_session; + int _sock; + PyObject *sock; }; - -struct __pyx_vtabstruct_4ssh2_7session_Session { - LIBSSH2_AGENT *(*init_connect_agent)(struct __pyx_obj_4ssh2_7session_Session *); - LIBSSH2_AGENT *(*_agent_init)(struct __pyx_obj_4ssh2_7session_Session *); -}; -static struct __pyx_vtabstruct_4ssh2_7session_Session *__pyx_vtabptr_4ssh2_7session_Session; - /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY @@ -836,16 +888,11 @@ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ 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); -/* NoFastGil.proto */ -#define __Pyx_PyGILState_Ensure PyGILState_Ensure -#define __Pyx_PyGILState_Release PyGILState_Release -#define __Pyx_FastGIL_Remember() -#define __Pyx_FastGIL_Forget() -#define __Pyx_FastGilFuncInit() - /* ArgTypeTest.proto */ -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); +#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ + ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ + __Pyx__ArgTypeTest(obj, type, name, exact)) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* PyObjectCallNoArg.proto */ #if CYTHON_COMPILING_IN_CPYTHON @@ -854,9 +901,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) #endif -/* GetVTable.proto */ -static void* __Pyx_GetVtable(PyObject *dict); - /* Import.proto */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); @@ -885,11 +929,6 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); -/* ForceInitThreads.proto */ -#ifndef __PYX_FORCE_INIT_THREADS - #define __PYX_FORCE_INIT_THREADS 0 -#endif - /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); @@ -899,6 +938,52 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); +/* PyThreadStateGet.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() +#endif + +/* PyErrFetchRestore.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) +#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); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#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 + +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif + /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); @@ -960,7 +1045,6 @@ static const char __pyx_k_ENCODING[] = "ENCODING"; static const char __pyx_k_writefds[] = "writefds"; static const char __pyx_k_ssh2_exit[] = "ssh2_exit"; static const char __pyx_k_directions[] = "directions"; -static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; static const char __pyx_k_ssh2_utils[] = "ssh2.utils"; static const char __pyx_k_wait_socket[] = "wait_socket"; static const char __pyx_k_ssh2_utils_pyx[] = "ssh2/utils.pyx"; @@ -975,7 +1059,6 @@ static PyObject *__pyx_n_s_directions; static PyObject *__pyx_n_s_encode; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_main; -static PyObject *__pyx_n_s_pyx_vtable; static PyObject *__pyx_n_s_readfds; static PyObject *__pyx_n_s_required_version; static PyObject *__pyx_n_s_select; @@ -1897,17 +1980,31 @@ static PyMethodDef __pyx_methods[] = { }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_utils(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_utils}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "utils", 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ @@ -1923,7 +2020,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 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_readfds, __pyx_k_readfds, sizeof(__pyx_k_readfds), 0, 0, 1, 1}, {&__pyx_n_s_required_version, __pyx_k_required_version, sizeof(__pyx_k_required_version), 0, 0, 1, 1}, {&__pyx_n_s_select, __pyx_k_select, sizeof(__pyx_k_select), 0, 0, 1, 1}, @@ -1958,7 +2054,7 @@ static int __Pyx_InitCachedConstants(void) { __pyx_tuple_ = PyTuple_Pack(2, __pyx_n_s_required_version, __pyx_n_s_version); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); - __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_ssh2_utils_pyx, __pyx_n_s_version, 42, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 42, __pyx_L1_error) + __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_ssh2_utils_pyx, __pyx_n_s_version, 42, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 42, __pyx_L1_error) /* "ssh2/utils.pyx":59 * @@ -1967,7 +2063,7 @@ static int __Pyx_InitCachedConstants(void) { * """Call libssh2_exit""" * c_ssh2.libssh2_exit() */ - __pyx_codeobj__3 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_ssh2_utils_pyx, __pyx_n_s_ssh2_exit, 59, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 59, __pyx_L1_error) + __pyx_codeobj__3 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_ssh2_utils_pyx, __pyx_n_s_ssh2_exit, 59, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 59, __pyx_L1_error) /* "ssh2/utils.pyx":64 * @@ -1979,7 +2075,7 @@ static int __Pyx_InitCachedConstants(void) { __pyx_tuple__4 = PyTuple_Pack(6, __pyx_n_s_socket, __pyx_n_s_session, __pyx_n_s_timeout, __pyx_n_s_directions, __pyx_n_s_readfds, __pyx_n_s_writefds); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); - __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(3, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_ssh2_utils_pyx, __pyx_n_s_wait_socket, 64, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(3, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_ssh2_utils_pyx, __pyx_n_s_wait_socket, 64, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -2002,11 +2098,55 @@ PyMODINIT_FUNC initutils(void) #else PyMODINIT_FUNC PyInit_utils(void); /*proto*/ PyMODINIT_FUNC PyInit_utils(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec_utils(PyObject *__pyx_pyinit_module) +#endif #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { @@ -2033,6 +2173,9 @@ PyMODINIT_FUNC PyInit_utils(void) #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_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 @@ -2044,12 +2187,17 @@ PyMODINIT_FUNC PyInit_utils(void) #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("utils", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -2085,8 +2233,7 @@ PyMODINIT_FUNC PyInit_utils(void) if (__Pyx_ExportFunction("to_str", (void (*)(void))__pyx_f_4ssh2_5utils_to_str, "PyObject *(char *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Type init code ---*/ /*--- Type import code ---*/ - __pyx_ptype_4ssh2_7session_Session = __Pyx_ImportType("ssh2.session", "Session", sizeof(struct __pyx_obj_4ssh2_7session_Session), 1); if (unlikely(!__pyx_ptype_4ssh2_7session_Session)) __PYX_ERR(1, 20, __pyx_L1_error) - __pyx_vtabptr_4ssh2_7session_Session = (struct __pyx_vtabstruct_4ssh2_7session_Session*)__Pyx_GetVtable(__pyx_ptype_4ssh2_7session_Session->tp_dict); if (unlikely(!__pyx_vtabptr_4ssh2_7session_Session)) __PYX_ERR(1, 20, __pyx_L1_error) + __pyx_ptype_4ssh2_7session_Session = __Pyx_ImportType("ssh2.session", "Session", sizeof(struct __pyx_obj_4ssh2_7session_Session), 1); if (unlikely(!__pyx_ptype_4ssh2_7session_Session)) __PYX_ERR(1, 19, __pyx_L1_error) /*--- Variable import code ---*/ /*--- Function import code ---*/ /*--- Execution code ---*/ @@ -2165,7 +2312,7 @@ PyMODINIT_FUNC PyInit_utils(void) * # Copyright (C) 2017 Panos Kittenis * */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -2186,10 +2333,12 @@ PyMODINIT_FUNC PyInit_utils(void) } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -2272,7 +2421,7 @@ static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, P static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, PyObject *globals) { PyFrameObject *f; - PyThreadState *tstate = PyThreadState_GET(); + PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject **fastlocals; Py_ssize_t i; PyObject *result; @@ -2609,29 +2758,23 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObjec } /* 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); -} -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact) + static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } - if (none_allowed && obj == Py_None) return 1; else if (exact) { - if (likely(Py_TYPE(obj) == type)) return 1; #if PY_MAJOR_VERSION == 2 - else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { - if (likely(PyObject_TypeCheck(obj, type))) return 1; + if (likely(__Pyx_TypeCheck(obj, type))) return 1; } - __Pyx_RaiseArgumentTypeInvalid(name, obj, type); + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); return 0; } @@ -2644,7 +2787,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { } #endif #ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { + if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) { #else if (likely(PyCFunction_Check(func))) { #endif @@ -2656,26 +2799,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { } #endif -/* GetVTable */ - static void* __Pyx_GetVtable(PyObject *dict) { - void* ptr; - PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable); - if (!ob) - goto bad; -#if PY_VERSION_HEX >= 0x02070000 - ptr = PyCapsule_GetPointer(ob, 0); -#else - ptr = PyCObject_AsVoidPtr(ob); -#endif - if (!ptr && !PyErr_Occurred()) - PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); - Py_DECREF(ob); - return ptr; -bad: - Py_XDECREF(ob); - return NULL; -} - /* Import */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; @@ -2683,7 +2806,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; - #if PY_VERSION_HEX < 0x03030000 + #if PY_MAJOR_VERSION < 3 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) @@ -2707,17 +2830,8 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.')) { - #if PY_VERSION_HEX < 0x03030000 - PyObject *py_level = PyInt_FromLong(1); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); - #endif if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; @@ -2728,7 +2842,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { } #endif if (!module) { - #if PY_VERSION_HEX < 0x03030000 + #if PY_MAJOR_VERSION < 3 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; @@ -2742,7 +2856,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { } } bad: - #if PY_VERSION_HEX < 0x03030000 + #if PY_MAJOR_VERSION < 3 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); @@ -2769,10 +2883,14 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { #ifdef CYTHON_CLINE_IN_TRACEBACK return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0; #else - PyObject **cython_runtime_dict; PyObject *use_cline; - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (unlikely(!cython_runtime_dict)) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { PyObject *ptype, *pvalue, *ptraceback; PyObject *use_cline_obj; PyErr_Fetch(&ptype, &pvalue, &ptraceback); @@ -2784,8 +2902,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { use_cline = NULL; } PyErr_Restore(ptype, pvalue, ptraceback); - } else { - use_cline = PyDict_GetItem(*_PyObject_GetDictPtr(__pyx_cython_runtime), __pyx_n_s_cline_in_traceback); } if (!use_cline) { c_line = 0; @@ -2949,10 +3065,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, __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*/ + __Pyx_PyThreadState_Current, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); @@ -3393,6 +3509,102 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, return (long) -1; } +/* PyErrFetchRestore */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +} +#endif + +/* FastTypeChecks */ + #if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + /* CheckBinaryVersion */ static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; @@ -3569,46 +3781,53 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#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 && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} #endif #endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __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 && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -3632,6 +3851,26 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; @@ -3639,9 +3878,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS @@ -3649,32 +3888,30 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } #else - if (m && m->nb_int) { + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); } #endif #else - res = PyNumber_Int(x); + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { diff --git a/tests/embedded_server/openssh.py b/tests/embedded_server/openssh.py index fac65ae8..09c3c5f4 100644 --- a/tests/embedded_server/openssh.py +++ b/tests/embedded_server/openssh.py @@ -23,6 +23,8 @@ from jinja2 import Template DIR_NAME = os.path.dirname(__file__) +PDIR_NAME = os.path.dirname(DIR_NAME) +PPDIR_NAME = os.path.dirname(PDIR_NAME) SERVER_KEY = os.path.abspath(os.path.sep.join([DIR_NAME, 'rsa.key'])) SSHD_CONFIG_TMPL = os.path.abspath(os.path.sep.join( [DIR_NAME, 'sshd_config.tmpl'])) @@ -34,9 +36,15 @@ class OpenSSHServer(object): def __init__(self, port=2222): self.port = port self.server_proc = None + self._fix_masks() + self.make_config() + + def _fix_masks(self): _mask = int('0600') if version_info <= (2,) else 0o600 + dir_mask = int('0755') if version_info <= (2,) else 0o755 os.chmod(SERVER_KEY, _mask) - self.make_config() + for _dir in [DIR_NAME, PDIR_NAME, PPDIR_NAME]: + os.chmod(_dir, dir_mask) def make_config(self): with open(SSHD_CONFIG_TMPL) as fh: @@ -57,7 +65,6 @@ def _wait_for_port(self): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) while sock.connect_ex(('127.0.0.1', self.port)) != 0: sleep(.1) - sleep(.3) del sock def stop(self): diff --git a/tests/test_session.py b/tests/test_session.py index 53afd366..bceb157d 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -2,7 +2,9 @@ from unittest import skipUnless from .base_test import SSH2TestCase -from ssh2.session import Session +from ssh2.session import Session, LIBSSH2_HOSTKEY_HASH_MD5, \ + LIBSSH2_HOSTKEY_HASH_SHA1 +from ssh2.exceptions import AuthenticationError, AgentAuthenticationError class SessionTestCase(SSH2TestCase): @@ -31,6 +33,20 @@ def test_session_get_set(self): self.session.set_blocking(1) self.assertEqual(self.session.get_blocking(), 1) + def test_failed_agent_auth(self): + self.assertRaises(AgentAuthenticationError, + self.session.agent_auth, 'FAKE USER') + + def test_failed_pkey_auth(self): + self.assertRaises(AuthenticationError, + self.session.userauth_publickey_fromfile, + 'FAKE USER', self.user_pub_key, self.user_key, + '') + self.assertRaises(AuthenticationError, + self.session.userauth_publickey_fromfile, + self.user, 'FAKE FILE', 'EVEN MORE FAKE FILE', + '') + @skipUnless(hasattr(Session, 'scp_recv64'), "Function not supported by libssh2") def test_scp_recv2(self): @@ -109,3 +125,9 @@ def test_scp_send(self): finally: os.unlink(remote_filename) os.unlink(to_copy) + + def test_hostkey(self): + self.assertEqual(self._auth(), 0) + for _type in [LIBSSH2_HOSTKEY_HASH_MD5, LIBSSH2_HOSTKEY_HASH_SHA1]: + hostkey = self.session.hostkey_hash(_type) + self.assertTrue(len(hostkey) > 0) diff --git a/tests/test_sftp.py b/tests/test_sftp.py index 7573764a..9eee33ba 100644 --- a/tests/test_sftp.py +++ b/tests/test_sftp.py @@ -3,6 +3,7 @@ import stat from sys import version_info from unittest import skipUnless +import shutil from .base_test import SSH2TestCase from ssh2.error_codes import LIBSSH2_ERROR_EAGAIN @@ -11,7 +12,7 @@ from ssh2.exceptions import SFTPHandleError, SFTPBufferTooSmall from ssh2.sftp import LIBSSH2_FXF_CREAT, LIBSSH2_FXF_WRITE, \ LIBSSH2_SFTP_S_IRUSR, LIBSSH2_SFTP_S_IRGRP, LIBSSH2_SFTP_S_IWUSR, \ - LIBSSH2_SFTP_S_IROTH + LIBSSH2_SFTP_S_IROTH, LIBSSH2_SFTP_S_IXUSR class SFTPTestCase(SSH2TestCase): @@ -187,6 +188,15 @@ def test_readdir(self): self.assertTrue(len(dir_data) > 0) self.assertTrue(b'..' in (_ls for (_, _ls, _) in dir_data)) + def test_readdir_ex(self): + self.assertEqual(self._auth(), 0) + sftp = self.session.sftp_init() + with sftp.opendir('.') as fh: + dir_data = list(fh.readdir_ex()) + self.assertTrue(len(dir_data) > 0) + self.assertTrue(b'..' in (_ls for (_, _ls, _, _) in dir_data)) + self.assertTrue(len(dir_data[0][2].split(b' ')) > 0) + @skipUnless(hasattr(SFTPHandle, 'fsync'), "Function not supported by libssh2") def test_fsync(self): @@ -249,3 +259,23 @@ def test_readdir_nonblocking(self): dir_data.append(buf) self.assertTrue(len(dir_data) > 0) self.assertTrue(b'..' in dir_data) + + def test_mkdir(self): + mode = LIBSSH2_SFTP_S_IRUSR | \ + LIBSSH2_SFTP_S_IWUSR | \ + LIBSSH2_SFTP_S_IRGRP | \ + LIBSSH2_SFTP_S_IROTH | \ + LIBSSH2_SFTP_S_IXUSR + _path = 'tmp' + abspath = os.path.join(os.path.expanduser('~'), _path) + self._auth() + sftp = self.session.sftp_init() + try: + shutil.rmtree(abspath) + except OSError: + pass + sftp.mkdir(_path, mode) + try: + self.assertTrue(os.path.isdir(abspath)) + finally: + shutil.rmtree(abspath)