From 6f002940ad0bb0d866f7c83b1adedd3720c39b7a Mon Sep 17 00:00:00 2001 From: Pan Date: Fri, 16 Mar 2018 21:15:45 +0100 Subject: [PATCH] Migrated session userauth_* functions to specific error handling code for exceptions, updated tests. Migrated handshake and startup functions to error handling code. Added handshake in non-blocking mode test. --- Changelog.rst | 4 +- ssh2/session.c | 2982 +++++++++++++---------------------------- ssh2/session.pyx | 58 +- tests/test_session.py | 16 +- 4 files changed, 950 insertions(+), 2110 deletions(-) diff --git a/Changelog.rst b/Changelog.rst index 04311258..0b336141 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -8,13 +8,15 @@ Changes --------- * Upgrade embedded ``libssh2`` in binary wheels to latest version plus enhancements. -* Adds support for ECDSA host and client keys. +* Adds support for ECDSA host keys. * Adds support for SHA-256 host key fingerprints. * Added SSH agent forwarding implementation. * Windows wheels switched to OpenSSL back end. * Windows wheels include zlib and have compression enabled. * Windows wheels no MAC and no encryption options enabled, same as posix wheels. * SCP functions now raise appropriate exception for all known libssh2 error codes. +* ``ssh2.session.Session.disconnect`` now returns ``0`` on success and raises exceptions on errors. +* All session ``userauth_*`` functions now raise specific exceptions. Fixes ------- diff --git a/ssh2/session.c b/ssh2/session.c index bdc77e05..df73af47 100644 --- a/ssh2/session.c +++ b/ssh2/session.c @@ -999,27 +999,6 @@ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, /* KeywordStringCheck.proto */ static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); -/* GetModuleGlobalName.proto */ -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); - -/* PyFunctionFastCall.proto */ -#if CYTHON_FAST_PYCALL -#define __Pyx_PyFunction_FastCall(func, args, nargs)\ - __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); -#else -#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) -#endif -#endif - -/* PyCFunctionFastCall.proto */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); -#else -#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) -#endif - /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); @@ -1027,6 +1006,23 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif +/* RaiseDoubleKeywords.proto */ +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); + +/* ParseKeywords.proto */ +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ + const char* function_name); + +/* ArgTypeTest.proto */ +#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); + +/* GetModuleGlobalName.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); + /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; @@ -1066,20 +1062,6 @@ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject /* RaiseException.proto */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); -/* RaiseDoubleKeywords.proto */ -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); - -/* ParseKeywords.proto */ -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ - const char* function_name); - -/* ArgTypeTest.proto */ -#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); @@ -1363,34 +1345,18 @@ static const char __pyx_k_publickeyfiledata[] = "publickeyfiledata"; static const char __pyx_k_PublicKeyInitError[] = "PublicKeyInitError"; static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; static const char __pyx_k_privatekeyfiledata[] = "privatekeyfiledata"; -static const char __pyx_k_AuthenticationError[] = "AuthenticationError"; static const char __pyx_k_SessionHostKeyError[] = "SessionHostKeyError"; -static const char __pyx_k_SessionStartupError[] = "SessionStartupError"; -static const char __pyx_k_SessionHandshakeError[] = "SessionHandshakeError"; static const char __pyx_k_LIBSSH2_HOSTKEY_HASH_MD5[] = "LIBSSH2_HOSTKEY_HASH_MD5"; static const char __pyx_k_LIBSSH2_HOSTKEY_TYPE_DSS[] = "LIBSSH2_HOSTKEY_TYPE_DSS"; static const char __pyx_k_LIBSSH2_HOSTKEY_TYPE_RSA[] = "LIBSSH2_HOSTKEY_TYPE_RSA"; static const char __pyx_k_LIBSSH2_HOSTKEY_HASH_SHA1[] = "LIBSSH2_HOSTKEY_HASH_SHA1"; -static const char __pyx_k_Error_authenticating_user_s[] = "Error authenticating user %s"; static const char __pyx_k_LIBSSH2_HOSTKEY_TYPE_UNKNOWN[] = "LIBSSH2_HOSTKEY_TYPE_UNKNOWN"; 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_Error_retrieving_server_host_key[] = "Error retrieving server host key for session"; -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"; -static const char __pyx_k_Error_authenticating_user_s_with_3[] = "Error authenticating user %s with private key %s andpublic key %s for host %s"; -static const char __pyx_k_Error_authenticating_user_s_with_4[] = "Error authenticating user %s with password"; static PyObject *__pyx_kp_s_; -static PyObject *__pyx_n_s_AuthenticationError; static PyObject *__pyx_n_s_ChannelError; -static PyObject *__pyx_kp_s_Error_authenticating_user_s; -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_retrieving_server_host_key; static PyObject *__pyx_n_s_KnownHostError; static PyObject *__pyx_n_s_LIBSSH2_HOSTKEY_HASH_MD5; @@ -1402,11 +1368,7 @@ 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_n_s_PublicKeyInitError; -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_SessionHandshakeError; static PyObject *__pyx_n_s_SessionHostKeyError; -static PyObject *__pyx_n_s_SessionStartupError; static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_kp_b__3; static PyObject *__pyx_n_s_atime; @@ -1490,7 +1452,7 @@ static PyObject *__pyx_tuple__4; static PyObject *__pyx_tuple__5; static PyObject *__pyx_tuple__6; -/* "ssh2/session.pyx":53 +/* "ssh2/session.pyx":52 * """LibSSH2 Session class providing session functions""" * * def __cinit__(self): # <<<<<<<<<<<<<< @@ -1520,7 +1482,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":54 + /* "ssh2/session.pyx":53 * * def __cinit__(self): * self._session = c_ssh2.libssh2_session_init() # <<<<<<<<<<<<<< @@ -1529,7 +1491,7 @@ static int __pyx_pf_4ssh2_7session_7Session___cinit__(struct __pyx_obj_4ssh2_7se */ __pyx_v_self->_session = libssh2_session_init(); - /* "ssh2/session.pyx":55 + /* "ssh2/session.pyx":54 * def __cinit__(self): * self._session = c_ssh2.libssh2_session_init() * if self._session is NULL: # <<<<<<<<<<<<<< @@ -1539,16 +1501,16 @@ static int __pyx_pf_4ssh2_7session_7Session___cinit__(struct __pyx_obj_4ssh2_7se __pyx_t_1 = ((__pyx_v_self->_session == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/session.pyx":56 + /* "ssh2/session.pyx":55 * self._session = c_ssh2.libssh2_session_init() * if self._session is NULL: * raise MemoryError # <<<<<<<<<<<<<< * self._sock = 0 * self.sock = None */ - PyErr_NoMemory(); __PYX_ERR(0, 56, __pyx_L1_error) + PyErr_NoMemory(); __PYX_ERR(0, 55, __pyx_L1_error) - /* "ssh2/session.pyx":55 + /* "ssh2/session.pyx":54 * def __cinit__(self): * self._session = c_ssh2.libssh2_session_init() * if self._session is NULL: # <<<<<<<<<<<<<< @@ -1557,7 +1519,7 @@ static int __pyx_pf_4ssh2_7session_7Session___cinit__(struct __pyx_obj_4ssh2_7se */ } - /* "ssh2/session.pyx":57 + /* "ssh2/session.pyx":56 * if self._session is NULL: * raise MemoryError * self._sock = 0 # <<<<<<<<<<<<<< @@ -1566,7 +1528,7 @@ static int __pyx_pf_4ssh2_7session_7Session___cinit__(struct __pyx_obj_4ssh2_7se */ __pyx_v_self->_sock = 0; - /* "ssh2/session.pyx":58 + /* "ssh2/session.pyx":57 * raise MemoryError * self._sock = 0 * self.sock = None # <<<<<<<<<<<<<< @@ -1579,7 +1541,7 @@ static int __pyx_pf_4ssh2_7session_7Session___cinit__(struct __pyx_obj_4ssh2_7se __Pyx_DECREF(__pyx_v_self->sock); __pyx_v_self->sock = Py_None; - /* "ssh2/session.pyx":53 + /* "ssh2/session.pyx":52 * """LibSSH2 Session class providing session functions""" * * def __cinit__(self): # <<<<<<<<<<<<<< @@ -1598,7 +1560,7 @@ static int __pyx_pf_4ssh2_7session_7Session___cinit__(struct __pyx_obj_4ssh2_7se return __pyx_r; } -/* "ssh2/session.pyx":60 +/* "ssh2/session.pyx":59 * self.sock = None * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -1622,7 +1584,7 @@ static void __pyx_pf_4ssh2_7session_7Session_2__dealloc__(struct __pyx_obj_4ssh2 int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "ssh2/session.pyx":61 + /* "ssh2/session.pyx":60 * * def __dealloc__(self): * if self._session is not NULL: # <<<<<<<<<<<<<< @@ -1632,12 +1594,12 @@ static void __pyx_pf_4ssh2_7session_7Session_2__dealloc__(struct __pyx_obj_4ssh2 __pyx_t_1 = ((__pyx_v_self->_session != NULL) != 0); if (__pyx_t_1) { - /* "ssh2/session.pyx":62 + /* "ssh2/session.pyx":61 * def __dealloc__(self): * if self._session is not NULL: * with nogil: # <<<<<<<<<<<<<< * c_ssh2.libssh2_session_disconnect( - * self._session, "end") + * self._session, b"end") */ { #ifdef WITH_THREAD @@ -1647,18 +1609,18 @@ static void __pyx_pf_4ssh2_7session_7Session_2__dealloc__(struct __pyx_obj_4ssh2 #endif /*try:*/ { - /* "ssh2/session.pyx":63 + /* "ssh2/session.pyx":62 * if self._session is not NULL: * with nogil: * c_ssh2.libssh2_session_disconnect( # <<<<<<<<<<<<<< - * self._session, "end") + * self._session, b"end") * c_ssh2.libssh2_session_free(self._session) */ libssh2_session_disconnect(__pyx_v_self->_session, ((char const *)"end")); - /* "ssh2/session.pyx":65 + /* "ssh2/session.pyx":64 * c_ssh2.libssh2_session_disconnect( - * self._session, "end") + * self._session, b"end") * c_ssh2.libssh2_session_free(self._session) # <<<<<<<<<<<<<< * self._session = NULL * @@ -1666,12 +1628,12 @@ static void __pyx_pf_4ssh2_7session_7Session_2__dealloc__(struct __pyx_obj_4ssh2 libssh2_session_free(__pyx_v_self->_session); } - /* "ssh2/session.pyx":62 + /* "ssh2/session.pyx":61 * def __dealloc__(self): * if self._session is not NULL: * with nogil: # <<<<<<<<<<<<<< * c_ssh2.libssh2_session_disconnect( - * self._session, "end") + * self._session, b"end") */ /*finally:*/ { /*normal exit:*/{ @@ -1685,7 +1647,7 @@ static void __pyx_pf_4ssh2_7session_7Session_2__dealloc__(struct __pyx_obj_4ssh2 } } - /* "ssh2/session.pyx":61 + /* "ssh2/session.pyx":60 * * def __dealloc__(self): * if self._session is not NULL: # <<<<<<<<<<<<<< @@ -1694,8 +1656,8 @@ static void __pyx_pf_4ssh2_7session_7Session_2__dealloc__(struct __pyx_obj_4ssh2 */ } - /* "ssh2/session.pyx":66 - * self._session, "end") + /* "ssh2/session.pyx":65 + * self._session, b"end") * c_ssh2.libssh2_session_free(self._session) * self._session = NULL # <<<<<<<<<<<<<< * @@ -1703,7 +1665,7 @@ static void __pyx_pf_4ssh2_7session_7Session_2__dealloc__(struct __pyx_obj_4ssh2 */ __pyx_v_self->_session = NULL; - /* "ssh2/session.pyx":60 + /* "ssh2/session.pyx":59 * self.sock = None * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -1715,12 +1677,12 @@ static void __pyx_pf_4ssh2_7session_7Session_2__dealloc__(struct __pyx_obj_4ssh2 __Pyx_RefNannyFinishContext(); } -/* "ssh2/session.pyx":68 +/* "ssh2/session.pyx":67 * self._session = NULL * * def disconnect(self): # <<<<<<<<<<<<<< + * cdef int rc * with nogil: - * c_ssh2.libssh2_session_disconnect(self._session, "end") */ /* Python wrapper */ @@ -1738,16 +1700,19 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_5disconnect(PyObject *__pyx_v_ } static PyObject *__pyx_pf_4ssh2_7session_7Session_4disconnect(struct __pyx_obj_4ssh2_7session_Session *__pyx_v_self) { + int __pyx_v_rc; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("disconnect", 0); /* "ssh2/session.pyx":69 - * * def disconnect(self): + * cdef int rc * with nogil: # <<<<<<<<<<<<<< - * c_ssh2.libssh2_session_disconnect(self._session, "end") - * + * rc = c_ssh2.libssh2_session_disconnect(self._session, b"end") + * return handle_error_codes(rc) */ { #ifdef WITH_THREAD @@ -1758,21 +1723,21 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_4disconnect(struct __pyx_obj_4 /*try:*/ { /* "ssh2/session.pyx":70 - * def disconnect(self): + * cdef int rc * with nogil: - * c_ssh2.libssh2_session_disconnect(self._session, "end") # <<<<<<<<<<<<<< + * rc = c_ssh2.libssh2_session_disconnect(self._session, b"end") # <<<<<<<<<<<<<< + * return handle_error_codes(rc) * - * def handshake(self, sock not None): */ - libssh2_session_disconnect(__pyx_v_self->_session, ((char const *)"end")); + __pyx_v_rc = libssh2_session_disconnect(__pyx_v_self->_session, ((char const *)"end")); } /* "ssh2/session.pyx":69 - * * def disconnect(self): + * cdef int rc * with nogil: # <<<<<<<<<<<<<< - * c_ssh2.libssh2_session_disconnect(self._session, "end") - * + * rc = c_ssh2.libssh2_session_disconnect(self._session, b"end") + * return handle_error_codes(rc) */ /*finally:*/ { /*normal exit:*/{ @@ -1786,23 +1751,42 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_4disconnect(struct __pyx_obj_4 } } - /* "ssh2/session.pyx":68 + /* "ssh2/session.pyx":71 + * with nogil: + * rc = c_ssh2.libssh2_session_disconnect(self._session, b"end") + * return handle_error_codes(rc) # <<<<<<<<<<<<<< + * + * def handshake(self, sock not None): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "ssh2/session.pyx":67 * self._session = NULL * * def disconnect(self): # <<<<<<<<<<<<<< + * cdef int rc * with nogil: - * c_ssh2.libssh2_session_disconnect(self._session, "end") */ /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("ssh2.session.Session.disconnect", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "ssh2/session.pyx":72 - * c_ssh2.libssh2_session_disconnect(self._session, "end") +/* "ssh2/session.pyx":73 + * return handle_error_codes(rc) * * def handshake(self, sock not None): # <<<<<<<<<<<<<< * """Perform SSH handshake. @@ -1817,7 +1801,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, 72, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "sock"); __PYX_ERR(0, 73, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_6handshake(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), ((PyObject *)__pyx_v_sock)); @@ -1836,30 +1820,25 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("handshake", 0); - /* "ssh2/session.pyx":76 + /* "ssh2/session.pyx":77 * * 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 == ((int)-1))) __PYX_ERR(0, 76, __pyx_L1_error) + __pyx_t_1 = PyObject_AsFileDescriptor(__pyx_v_sock); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 77, __pyx_L1_error) __pyx_v__sock = __pyx_t_1; - /* "ssh2/session.pyx":78 + /* "ssh2/session.pyx":79 * cdef int _sock = PyObject_AsFileDescriptor(sock) * cdef int rc * with nogil: # <<<<<<<<<<<<<< * rc = c_ssh2.libssh2_session_handshake(self._session, _sock) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * self._sock = _sock */ { #ifdef WITH_THREAD @@ -1869,159 +1848,31 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s #endif /*try:*/ { - /* "ssh2/session.pyx":79 + /* "ssh2/session.pyx":80 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_session_handshake(self._session, _sock) # <<<<<<<<<<<<<< - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * with gil: - */ - __pyx_v_rc = libssh2_session_handshake(__pyx_v_self->_session, __pyx_v__sock); - - /* "ssh2/session.pyx":80 - * with nogil: - * rc = c_ssh2.libssh2_session_handshake(self._session, _sock) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< - * with gil: - * raise SessionHandshakeError( - */ - switch (__pyx_v_rc) { - case 0: - case LIBSSH2_ERROR_EAGAIN: - __pyx_t_2 = 0; - break; - default: - __pyx_t_2 = 1; - break; - } - if (__pyx_t_2) { - - /* "ssh2/session.pyx":81 - * rc = c_ssh2.libssh2_session_handshake(self._session, _sock) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * with gil: # <<<<<<<<<<<<<< - * raise SessionHandshakeError( - * "SSH session handshake failed with error code %s", - */ - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - /*try:*/ { - - /* "ssh2/session.pyx":82 - * 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 = __Pyx_GetModuleGlobalName(__pyx_n_s_SessionHandshakeError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 82, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_4); - - /* "ssh2/session.pyx":84 - * raise SessionHandshakeError( - * "SSH session handshake failed with error code %s", - * rc) # <<<<<<<<<<<<<< * self._sock = _sock * self.sock = sock */ - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 84, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = NULL; - __pyx_t_1 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_1 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_SSH_session_handshake_failed_wit, __pyx_t_5}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_SSH_session_handshake_failed_wit, __pyx_t_5}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - { - __pyx_t_7 = PyTuple_New(2+__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 82, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_7); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_SSH_session_handshake_failed_wit); - __Pyx_GIVEREF(__pyx_kp_s_SSH_session_handshake_failed_wit); - PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_1, __pyx_kp_s_SSH_session_handshake_failed_wit); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_1, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - __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_L8_error) - } - - /* "ssh2/session.pyx":81 - * rc = c_ssh2.libssh2_session_handshake(self._session, _sock) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * with gil: # <<<<<<<<<<<<<< - * raise SessionHandshakeError( - * "SSH session handshake failed with error code %s", - */ - /*finally:*/ { - __pyx_L8_error: { - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - goto __pyx_L4_error; - } - } - } + __pyx_v_rc = libssh2_session_handshake(__pyx_v_self->_session, __pyx_v__sock); - /* "ssh2/session.pyx":80 + /* "ssh2/session.pyx":81 * with nogil: * rc = c_ssh2.libssh2_session_handshake(self._session, _sock) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< - * with gil: - * raise SessionHandshakeError( - */ - } - - /* "ssh2/session.pyx":85 - * "SSH session handshake failed with error code %s", - * rc) * self._sock = _sock # <<<<<<<<<<<<<< * self.sock = sock - * return rc + * return handle_error_codes(rc) */ __pyx_v_self->_sock = __pyx_v__sock; } - /* "ssh2/session.pyx":78 + /* "ssh2/session.pyx":79 * cdef int _sock = PyObject_AsFileDescriptor(sock) * cdef int rc * with nogil: # <<<<<<<<<<<<<< * rc = c_ssh2.libssh2_session_handshake(self._session, _sock) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * self._sock = _sock */ /*finally:*/ { /*normal exit:*/{ @@ -2031,22 +1882,15 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s #endif goto __pyx_L5; } - __pyx_L4_error: { - #ifdef WITH_THREAD - __Pyx_FastGIL_Forget(); - Py_BLOCK_THREADS - #endif - goto __pyx_L1_error; - } __pyx_L5:; } } - /* "ssh2/session.pyx":86 - * rc) + /* "ssh2/session.pyx":82 + * rc = c_ssh2.libssh2_session_handshake(self._session, _sock) * self._sock = _sock * self.sock = sock # <<<<<<<<<<<<<< - * return rc + * return handle_error_codes(rc) * */ __Pyx_INCREF(__pyx_v_sock); @@ -2055,22 +1899,23 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s __Pyx_DECREF(__pyx_v_self->sock); __pyx_v_self->sock = __pyx_v_sock; - /* "ssh2/session.pyx":87 + /* "ssh2/session.pyx":83 * self._sock = _sock * self.sock = sock - * return rc # <<<<<<<<<<<<<< + * return handle_error_codes(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, 87, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; + __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":72 - * c_ssh2.libssh2_session_disconnect(self._session, "end") + /* "ssh2/session.pyx":73 + * return handle_error_codes(rc) * * def handshake(self, sock not None): # <<<<<<<<<<<<<< * """Perform SSH handshake. @@ -2079,11 +1924,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("ssh2.session.Session.handshake", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -2092,8 +1933,8 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_6handshake(struct __pyx_obj_4s return __pyx_r; } -/* "ssh2/session.pyx":89 - * return rc +/* "ssh2/session.pyx":85 + * return handle_error_codes(rc) * * def startup(self, sock): # <<<<<<<<<<<<<< * """Deprecated - use self.handshake""" @@ -2120,146 +1961,45 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_8startup(struct __pyx_obj_4ssh PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("startup", 0); - /* "ssh2/session.pyx":91 + /* "ssh2/session.pyx":87 * 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 == ((int)-1))) __PYX_ERR(0, 91, __pyx_L1_error) + __pyx_t_1 = PyObject_AsFileDescriptor(__pyx_v_sock); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 87, __pyx_L1_error) __pyx_v__sock = __pyx_t_1; - /* "ssh2/session.pyx":93 + /* "ssh2/session.pyx":89 * cdef int _sock = PyObject_AsFileDescriptor(sock) * cdef int rc * rc = c_ssh2.libssh2_session_startup(self._session, _sock) # <<<<<<<<<<<<<< - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * raise SessionStartupError( - */ - __pyx_v_rc = libssh2_session_startup(__pyx_v_self->_session, __pyx_v__sock); - - /* "ssh2/session.pyx":94 - * cdef int rc - * 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", - */ - switch (__pyx_v_rc) { - case 0: - case LIBSSH2_ERROR_EAGAIN: - __pyx_t_2 = 0; - break; - default: - __pyx_t_2 = 1; - break; - } - if (__pyx_t_2) { - - /* "ssh2/session.pyx":95 - * 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 = __Pyx_GetModuleGlobalName(__pyx_n_s_SessionStartupError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 95, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - - /* "ssh2/session.pyx":97 - * raise SessionStartupError( - * "SSH session startup failed with error code %s", - * rc) # <<<<<<<<<<<<<< - * return rc + * return handle_error_codes(rc) * */ - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 97, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = NULL; - __pyx_t_1 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_1 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_SSH_session_startup_failed_with, __pyx_t_5}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_SSH_session_startup_failed_with, __pyx_t_5}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - { - __pyx_t_7 = PyTuple_New(2+__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 95, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_SSH_session_startup_failed_with); - __Pyx_GIVEREF(__pyx_kp_s_SSH_session_startup_failed_with); - PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_1, __pyx_kp_s_SSH_session_startup_failed_with); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_1, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - __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, 95, __pyx_L1_error) + __pyx_v_rc = libssh2_session_startup(__pyx_v_self->_session, __pyx_v__sock); - /* "ssh2/session.pyx":94 + /* "ssh2/session.pyx":90 * cdef int rc * 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", - */ - } - - /* "ssh2/session.pyx":98 - * "SSH session startup failed with error code %s", - * rc) - * return rc # <<<<<<<<<<<<<< + * return handle_error_codes(rc) # <<<<<<<<<<<<<< * * 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, 98, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; + __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 90, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":89 - * return rc + /* "ssh2/session.pyx":85 + * return handle_error_codes(rc) * * def startup(self, sock): # <<<<<<<<<<<<<< * """Deprecated - use self.handshake""" @@ -2268,11 +2008,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_8startup(struct __pyx_obj_4ssh /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("ssh2.session.Session.startup", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -2281,8 +2017,8 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_8startup(struct __pyx_obj_4ssh return __pyx_r; } -/* "ssh2/session.pyx":100 - * return rc +/* "ssh2/session.pyx":92 + * return handle_error_codes(rc) * * def set_blocking(self, bint blocking): # <<<<<<<<<<<<<< * """Set session blocking mode on/off. @@ -2298,7 +2034,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, 100, __pyx_L3_error) + __pyx_v_blocking = __Pyx_PyObject_IsTrue(__pyx_arg_blocking); if (unlikely((__pyx_v_blocking == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 92, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -2318,7 +2054,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_10set_blocking(struct __pyx_ob __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_blocking", 0); - /* "ssh2/session.pyx":106 + /* "ssh2/session.pyx":98 * Session default is blocking unless set otherwise. * :type blocking: bool""" * with nogil: # <<<<<<<<<<<<<< @@ -2333,7 +2069,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_10set_blocking(struct __pyx_ob #endif /*try:*/ { - /* "ssh2/session.pyx":107 + /* "ssh2/session.pyx":99 * :type blocking: bool""" * with nogil: * c_ssh2.libssh2_session_set_blocking( # <<<<<<<<<<<<<< @@ -2343,7 +2079,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":106 + /* "ssh2/session.pyx":98 * Session default is blocking unless set otherwise. * :type blocking: bool""" * with nogil: # <<<<<<<<<<<<<< @@ -2362,8 +2098,8 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_10set_blocking(struct __pyx_ob } } - /* "ssh2/session.pyx":100 - * return rc + /* "ssh2/session.pyx":92 + * return handle_error_codes(rc) * * def set_blocking(self, bint blocking): # <<<<<<<<<<<<<< * """Set session blocking mode on/off. @@ -2377,7 +2113,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_10set_blocking(struct __pyx_ob return __pyx_r; } -/* "ssh2/session.pyx":110 +/* "ssh2/session.pyx":102 * self._session, blocking) * * def get_blocking(self): # <<<<<<<<<<<<<< @@ -2407,7 +2143,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":115 + /* "ssh2/session.pyx":107 * :rtype: bool""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -2422,7 +2158,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_12get_blocking(struct __pyx_ob #endif /*try:*/ { - /* "ssh2/session.pyx":116 + /* "ssh2/session.pyx":108 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_session_get_blocking(self._session) # <<<<<<<<<<<<<< @@ -2432,7 +2168,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":115 + /* "ssh2/session.pyx":107 * :rtype: bool""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -2451,7 +2187,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_12get_blocking(struct __pyx_ob } } - /* "ssh2/session.pyx":117 + /* "ssh2/session.pyx":109 * with nogil: * rc = c_ssh2.libssh2_session_get_blocking(self._session) * return bool(rc) # <<<<<<<<<<<<<< @@ -2459,17 +2195,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, 117, __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_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 117, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 109, __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, 117, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyBool_FromLong((!(!__pyx_t_2))); 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/session.pyx":110 + /* "ssh2/session.pyx":102 * self._session, blocking) * * def get_blocking(self): # <<<<<<<<<<<<<< @@ -2488,7 +2224,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_12get_blocking(struct __pyx_ob return __pyx_r; } -/* "ssh2/session.pyx":119 +/* "ssh2/session.pyx":111 * return bool(rc) * * def set_timeout(self, long timeout): # <<<<<<<<<<<<<< @@ -2505,7 +2241,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, 119, __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, 111, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -2525,7 +2261,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_14set_timeout(struct __pyx_obj __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_timeout", 0); - /* "ssh2/session.pyx":127 + /* "ssh2/session.pyx":119 * time out. * :param timeout: Milliseconds to wait before timeout.""" * with nogil: # <<<<<<<<<<<<<< @@ -2540,7 +2276,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_14set_timeout(struct __pyx_obj #endif /*try:*/ { - /* "ssh2/session.pyx":128 + /* "ssh2/session.pyx":120 * :param timeout: Milliseconds to wait before timeout.""" * with nogil: * c_ssh2.libssh2_session_set_timeout(self._session, timeout) # <<<<<<<<<<<<<< @@ -2550,7 +2286,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":127 + /* "ssh2/session.pyx":119 * time out. * :param timeout: Milliseconds to wait before timeout.""" * with nogil: # <<<<<<<<<<<<<< @@ -2569,7 +2305,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_14set_timeout(struct __pyx_obj } } - /* "ssh2/session.pyx":119 + /* "ssh2/session.pyx":111 * return bool(rc) * * def set_timeout(self, long timeout): # <<<<<<<<<<<<<< @@ -2584,7 +2320,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_14set_timeout(struct __pyx_obj return __pyx_r; } -/* "ssh2/session.pyx":130 +/* "ssh2/session.pyx":122 * c_ssh2.libssh2_session_set_timeout(self._session, timeout) * * def get_timeout(self): # <<<<<<<<<<<<<< @@ -2613,7 +2349,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":133 + /* "ssh2/session.pyx":125 * """Get current session timeout setting""" * cdef long timeout * with nogil: # <<<<<<<<<<<<<< @@ -2628,7 +2364,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_16get_timeout(struct __pyx_obj #endif /*try:*/ { - /* "ssh2/session.pyx":134 + /* "ssh2/session.pyx":126 * cdef long timeout * with nogil: * timeout = c_ssh2.libssh2_session_get_timeout(self._session) # <<<<<<<<<<<<<< @@ -2638,7 +2374,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":133 + /* "ssh2/session.pyx":125 * """Get current session timeout setting""" * cdef long timeout * with nogil: # <<<<<<<<<<<<<< @@ -2657,7 +2393,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_16get_timeout(struct __pyx_obj } } - /* "ssh2/session.pyx":135 + /* "ssh2/session.pyx":127 * with nogil: * timeout = c_ssh2.libssh2_session_get_timeout(self._session) * return timeout # <<<<<<<<<<<<<< @@ -2665,13 +2401,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, 135, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_timeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":130 + /* "ssh2/session.pyx":122 * c_ssh2.libssh2_session_set_timeout(self._session, timeout) * * def get_timeout(self): # <<<<<<<<<<<<<< @@ -2690,7 +2426,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_16get_timeout(struct __pyx_obj return __pyx_r; } -/* "ssh2/session.pyx":137 +/* "ssh2/session.pyx":129 * return timeout * * def userauth_authenticated(self): # <<<<<<<<<<<<<< @@ -2720,7 +2456,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_18userauth_authenticated(struc PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("userauth_authenticated", 0); - /* "ssh2/session.pyx":142 + /* "ssh2/session.pyx":134 * :rtype: bool""" * cdef bint rc * with nogil: # <<<<<<<<<<<<<< @@ -2735,7 +2471,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_18userauth_authenticated(struc #endif /*try:*/ { - /* "ssh2/session.pyx":143 + /* "ssh2/session.pyx":135 * cdef bint rc * with nogil: * rc = c_ssh2.libssh2_userauth_authenticated(self._session) # <<<<<<<<<<<<<< @@ -2745,7 +2481,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_18userauth_authenticated(struc __pyx_v_rc = libssh2_userauth_authenticated(__pyx_v_self->_session); } - /* "ssh2/session.pyx":142 + /* "ssh2/session.pyx":134 * :rtype: bool""" * cdef bint rc * with nogil: # <<<<<<<<<<<<<< @@ -2764,7 +2500,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_18userauth_authenticated(struc } } - /* "ssh2/session.pyx":144 + /* "ssh2/session.pyx":136 * with nogil: * rc = c_ssh2.libssh2_userauth_authenticated(self._session) * return bool(rc) # <<<<<<<<<<<<<< @@ -2773,13 +2509,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, 144, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBool_FromLong((!(!__pyx_t_1))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":137 + /* "ssh2/session.pyx":129 * return timeout * * def userauth_authenticated(self): # <<<<<<<<<<<<<< @@ -2798,7 +2534,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_18userauth_authenticated(struc return __pyx_r; } -/* "ssh2/session.pyx":146 +/* "ssh2/session.pyx":138 * return bool(rc) * * def userauth_list(self, username not None): # <<<<<<<<<<<<<< @@ -2814,7 +2550,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, 146, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 138, __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)); @@ -2842,19 +2578,19 @@ 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":150 + /* "ssh2/session.pyx":142 * * :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, 150, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_username = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":151 + /* "ssh2/session.pyx":143 * :rtype: list""" * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username # <<<<<<<<<<<<<< @@ -2863,12 +2599,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, "expected bytes, NoneType found"); - __PYX_ERR(0, 151, __pyx_L1_error) + __PYX_ERR(0, 143, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 151, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error) __pyx_v__username = __pyx_t_2; - /* "ssh2/session.pyx":152 + /* "ssh2/session.pyx":144 * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username * cdef size_t username_len = len(b_username) # <<<<<<<<<<<<<< @@ -2877,12 +2613,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, 152, __pyx_L1_error) + __PYX_ERR(0, 144, __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, 152, __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, 144, __pyx_L1_error) __pyx_v_username_len = __pyx_t_3; - /* "ssh2/session.pyx":155 + /* "ssh2/session.pyx":147 * cdef char *_auth * cdef str auth * with nogil: # <<<<<<<<<<<<<< @@ -2897,7 +2633,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_20userauth_list(struct __pyx_o #endif /*try:*/ { - /* "ssh2/session.pyx":156 + /* "ssh2/session.pyx":148 * cdef str auth * with nogil: * _auth = c_ssh2.libssh2_userauth_list( # <<<<<<<<<<<<<< @@ -2907,7 +2643,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":155 + /* "ssh2/session.pyx":147 * cdef char *_auth * cdef str auth * with nogil: # <<<<<<<<<<<<<< @@ -2926,7 +2662,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_20userauth_list(struct __pyx_o } } - /* "ssh2/session.pyx":158 + /* "ssh2/session.pyx":150 * _auth = c_ssh2.libssh2_userauth_list( * self._session, _username, username_len) * if _auth is NULL: # <<<<<<<<<<<<<< @@ -2936,7 +2672,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":159 + /* "ssh2/session.pyx":151 * self._session, _username, username_len) * if _auth is NULL: * return # <<<<<<<<<<<<<< @@ -2947,7 +2683,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":158 + /* "ssh2/session.pyx":150 * _auth = c_ssh2.libssh2_userauth_list( * self._session, _username, username_len) * if _auth is NULL: # <<<<<<<<<<<<<< @@ -2956,20 +2692,20 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_20userauth_list(struct __pyx_o */ } - /* "ssh2/session.pyx":160 + /* "ssh2/session.pyx":152 * 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, 160, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_str(__pyx_v__auth); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __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, 160, __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, 152, __pyx_L1_error) __pyx_v_auth = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":161 + /* "ssh2/session.pyx":153 * return * auth = to_str(_auth) * return auth.split(',') # <<<<<<<<<<<<<< @@ -2977,16 +2713,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, 161, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_auth, __pyx_n_s_split); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __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, 161, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 153, __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":146 + /* "ssh2/session.pyx":138 * return bool(rc) * * def userauth_list(self, username not None): # <<<<<<<<<<<<<< @@ -3008,7 +2744,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_20userauth_list(struct __pyx_o return __pyx_r; } -/* "ssh2/session.pyx":163 +/* "ssh2/session.pyx":155 * return auth.split(',') * * def userauth_publickey_fromfile(self, username not None, # <<<<<<<<<<<<<< @@ -3054,23 +2790,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, 163, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey_fromfile", 1, 4, 4, 1); __PYX_ERR(0, 155, __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, 163, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey_fromfile", 1, 4, 4, 2); __PYX_ERR(0, 155, __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, 163, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey_fromfile", 1, 4, 4, 3); __PYX_ERR(0, 155, __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, 163, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth_publickey_fromfile") < 0)) __PYX_ERR(0, 155, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -3087,23 +2823,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, 163, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey_fromfile", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 155, __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, 163, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 155, __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, 164, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "publickey"); __PYX_ERR(0, 156, __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, 165, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "privatekey"); __PYX_ERR(0, 157, __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, 166, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "passphrase"); __PYX_ERR(0, 158, __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); @@ -3131,61 +2867,57 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( PyObject *__pyx_t_1 = NULL; char *__pyx_t_2; int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_t_6; - PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("userauth_publickey_fromfile", 0); - /* "ssh2/session.pyx":171 + /* "ssh2/session.pyx":163 * :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, 171, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_username = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":172 + /* "ssh2/session.pyx":164 * 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, 172, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_publickey); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 164, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_publickey = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":173 + /* "ssh2/session.pyx":165 * 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, 173, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_privatekey); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_privatekey = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":174 + /* "ssh2/session.pyx":166 * 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, 174, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_passphrase); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_passphrase = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":175 + /* "ssh2/session.pyx":167 * cdef bytes b_privatekey = to_bytes(privatekey) * cdef bytes b_passphrase = to_bytes(passphrase) * cdef char *_username = b_username # <<<<<<<<<<<<<< @@ -3194,12 +2926,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( */ if (unlikely(__pyx_v_b_username == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 175, __pyx_L1_error) + __PYX_ERR(0, 167, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 175, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 167, __pyx_L1_error) __pyx_v__username = __pyx_t_2; - /* "ssh2/session.pyx":176 + /* "ssh2/session.pyx":168 * cdef bytes b_passphrase = to_bytes(passphrase) * cdef char *_username = b_username * cdef char *_publickey = b_publickey # <<<<<<<<<<<<<< @@ -3208,12 +2940,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( */ if (unlikely(__pyx_v_b_publickey == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 176, __pyx_L1_error) + __PYX_ERR(0, 168, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_publickey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 176, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_publickey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 168, __pyx_L1_error) __pyx_v__publickey = __pyx_t_2; - /* "ssh2/session.pyx":177 + /* "ssh2/session.pyx":169 * cdef char *_username = b_username * cdef char *_publickey = b_publickey * cdef char *_privatekey = b_privatekey # <<<<<<<<<<<<<< @@ -3222,12 +2954,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( */ if (unlikely(__pyx_v_b_privatekey == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 177, __pyx_L1_error) + __PYX_ERR(0, 169, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_privatekey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 177, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_privatekey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 169, __pyx_L1_error) __pyx_v__privatekey = __pyx_t_2; - /* "ssh2/session.pyx":178 + /* "ssh2/session.pyx":170 * cdef char *_publickey = b_publickey * cdef char *_privatekey = b_privatekey * cdef char *_passphrase = b_passphrase # <<<<<<<<<<<<<< @@ -3236,12 +2968,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( */ if (unlikely(__pyx_v_b_passphrase == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 178, __pyx_L1_error) + __PYX_ERR(0, 170, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_passphrase); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 178, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_passphrase); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 170, __pyx_L1_error) __pyx_v__passphrase = __pyx_t_2; - /* "ssh2/session.pyx":179 + /* "ssh2/session.pyx":171 * cdef char *_privatekey = b_privatekey * cdef char *_passphrase = b_passphrase * with nogil: # <<<<<<<<<<<<<< @@ -3256,147 +2988,17 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( #endif /*try:*/ { - /* "ssh2/session.pyx":180 + /* "ssh2/session.pyx":172 * cdef char *_passphrase = b_passphrase * with nogil: * rc = c_ssh2.libssh2_userauth_publickey_fromfile( # <<<<<<<<<<<<<< * self._session, _username, _publickey, _privatekey, _passphrase) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * return handle_error_codes(rc) */ __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":182 - * rc = c_ssh2.libssh2_userauth_publickey_fromfile( - * self._session, _username, _publickey, _privatekey, _passphrase) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< - * with gil: - * raise AuthenticationError( - */ - 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/session.pyx":183 - * self._session, _username, _publickey, _privatekey, _passphrase) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * with gil: # <<<<<<<<<<<<<< - * raise AuthenticationError( - * "Error authenticating user %s with private key %s and" - */ - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - /*try:*/ { - - /* "ssh2/session.pyx":184 - * 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_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_AuthenticationError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_4); - - /* "ssh2/session.pyx":187 - * "Error authenticating user %s with private key %s and" - * "public key %s", - * username, privatekey, publickey) # <<<<<<<<<<<<<< - * return rc - * - */ - __pyx_t_5 = NULL; - __pyx_t_6 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_6 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_kp_s_Error_authenticating_user_s_with, __pyx_v_username, __pyx_v_privatekey, __pyx_v_publickey}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_kp_s_Error_authenticating_user_s_with, __pyx_v_username, __pyx_v_privatekey, __pyx_v_publickey}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_7 = PyTuple_New(4+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 184, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_7); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_Error_authenticating_user_s_with); - __Pyx_GIVEREF(__pyx_kp_s_Error_authenticating_user_s_with); - PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_s_Error_authenticating_user_s_with); - __Pyx_INCREF(__pyx_v_username); - __Pyx_GIVEREF(__pyx_v_username); - PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_username); - __Pyx_INCREF(__pyx_v_privatekey); - __Pyx_GIVEREF(__pyx_v_privatekey); - PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_privatekey); - __Pyx_INCREF(__pyx_v_publickey); - __Pyx_GIVEREF(__pyx_v_publickey); - PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_v_publickey); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - __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, 184, __pyx_L8_error) - } - - /* "ssh2/session.pyx":183 - * self._session, _username, _publickey, _privatekey, _passphrase) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * with gil: # <<<<<<<<<<<<<< - * raise AuthenticationError( - * "Error authenticating user %s with private key %s and" - */ - /*finally:*/ { - __pyx_L8_error: { - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - goto __pyx_L4_error; - } - } - } - - /* "ssh2/session.pyx":182 - * rc = c_ssh2.libssh2_userauth_publickey_fromfile( - * self._session, _username, _publickey, _privatekey, _passphrase) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< - * with gil: - * raise AuthenticationError( - */ - } } - /* "ssh2/session.pyx":179 + /* "ssh2/session.pyx":171 * cdef char *_privatekey = b_privatekey * cdef char *_passphrase = b_passphrase * with nogil: # <<<<<<<<<<<<<< @@ -3411,32 +3013,26 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( #endif goto __pyx_L5; } - __pyx_L4_error: { - #ifdef WITH_THREAD - __Pyx_FastGIL_Forget(); - Py_BLOCK_THREADS - #endif - goto __pyx_L1_error; - } __pyx_L5:; } } - /* "ssh2/session.pyx":188 - * "public key %s", - * username, privatekey, publickey) - * return rc # <<<<<<<<<<<<<< + /* "ssh2/session.pyx":174 + * rc = c_ssh2.libssh2_userauth_publickey_fromfile( + * self._session, _username, _publickey, _privatekey, _passphrase) + * return handle_error_codes(rc) # <<<<<<<<<<<<<< * * def userauth_publickey(self, username not None, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 174, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":163 + /* "ssh2/session.pyx":155 * return auth.split(',') * * def userauth_publickey_fromfile(self, username not None, # <<<<<<<<<<<<<< @@ -3447,9 +3043,6 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("ssh2.session.Session.userauth_publickey_fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -3462,8 +3055,8 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_22userauth_publickey_fromfile( return __pyx_r; } -/* "ssh2/session.pyx":190 - * return rc +/* "ssh2/session.pyx":176 + * return handle_error_codes(rc) * * def userauth_publickey(self, username not None, # <<<<<<<<<<<<<< * bytes pubkeydata not None): @@ -3502,11 +3095,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, 190, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey", 1, 2, 2, 1); __PYX_ERR(0, 176, __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, 190, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth_publickey") < 0)) __PYX_ERR(0, 176, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -3519,16 +3112,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, 190, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 176, __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, 190, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 176, __pyx_L1_error) } - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pubkeydata), (&PyBytes_Type), 0, "pubkeydata", 1))) __PYX_ERR(0, 191, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pubkeydata), (&PyBytes_Type), 0, "pubkeydata", 1))) __PYX_ERR(0, 177, __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 */ @@ -3553,25 +3146,21 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ unsigned char *__pyx_t_3; Py_ssize_t __pyx_t_4; int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - int __pyx_t_8; - PyObject *__pyx_t_9 = NULL; __Pyx_RefNannySetupContext("userauth_publickey", 0); - /* "ssh2/session.pyx":201 + /* "ssh2/session.pyx":187 * :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, 201, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_username = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":202 + /* "ssh2/session.pyx":188 * cdef int rc * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username # <<<<<<<<<<<<<< @@ -3580,32 +3169,32 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ */ if (unlikely(__pyx_v_b_username == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 202, __pyx_L1_error) + __PYX_ERR(0, 188, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 202, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 188, __pyx_L1_error) __pyx_v__username = __pyx_t_2; - /* "ssh2/session.pyx":203 + /* "ssh2/session.pyx":189 * 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_PyBytes_AsWritableUString(__pyx_v_pubkeydata); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 203, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyBytes_AsWritableUString(__pyx_v_pubkeydata); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 189, __pyx_L1_error) __pyx_v__pubkeydata = __pyx_t_3; - /* "ssh2/session.pyx":204 + /* "ssh2/session.pyx":190 * 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 == ((Py_ssize_t)-1))) __PYX_ERR(0, 204, __pyx_L1_error) + __pyx_t_4 = PyBytes_GET_SIZE(__pyx_v_pubkeydata); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 190, __pyx_L1_error) __pyx_v_pubkeydata_len = __pyx_t_4; - /* "ssh2/session.pyx":205 + /* "ssh2/session.pyx":191 * cdef unsigned char *_pubkeydata = pubkeydata * cdef size_t pubkeydata_len = len(pubkeydata) * with nogil: # <<<<<<<<<<<<<< @@ -3620,7 +3209,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ #endif /*try:*/ { - /* "ssh2/session.pyx":206 + /* "ssh2/session.pyx":192 * cdef size_t pubkeydata_len = len(pubkeydata) * with nogil: * rc = c_ssh2.libssh2_userauth_publickey( # <<<<<<<<<<<<<< @@ -3628,133 +3217,9 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ * pubkeydata_len, NULL, NULL) */ __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":209 - * self._session, _username, _pubkeydata, - * pubkeydata_len, NULL, NULL) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< - * with gil: - * raise AuthenticationError( - */ - switch (__pyx_v_rc) { - case 0: - case LIBSSH2_ERROR_EAGAIN: - __pyx_t_5 = 0; - break; - default: - __pyx_t_5 = 1; - break; - } - if (__pyx_t_5) { - - /* "ssh2/session.pyx":210 - * pubkeydata_len, NULL, NULL) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * with gil: # <<<<<<<<<<<<<< - * raise AuthenticationError( - * "Error authenticating user %s with public key data", - */ - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - /*try:*/ { - - /* "ssh2/session.pyx":211 - * 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_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_AuthenticationError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 211, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - - /* "ssh2/session.pyx":213 - * raise AuthenticationError( - * "Error authenticating user %s with public key data", - * username) # <<<<<<<<<<<<<< - * return rc - * - */ - __pyx_t_7 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { - __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); - if (likely(__pyx_t_7)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_6, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_Error_authenticating_user_s_with_2, __pyx_v_username}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_Error_authenticating_user_s_with_2, __pyx_v_username}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 211, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_7) { - __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_Error_authenticating_user_s_with_2); - __Pyx_GIVEREF(__pyx_kp_s_Error_authenticating_user_s_with_2); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_kp_s_Error_authenticating_user_s_with_2); - __Pyx_INCREF(__pyx_v_username); - __Pyx_GIVEREF(__pyx_v_username); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_username); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 211, __pyx_L8_error) - } - - /* "ssh2/session.pyx":210 - * pubkeydata_len, NULL, NULL) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * with gil: # <<<<<<<<<<<<<< - * raise AuthenticationError( - * "Error authenticating user %s with public key data", - */ - /*finally:*/ { - __pyx_L8_error: { - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - goto __pyx_L4_error; - } - } - } - - /* "ssh2/session.pyx":209 - * self._session, _username, _pubkeydata, - * pubkeydata_len, NULL, NULL) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< - * with gil: - * raise AuthenticationError( - */ - } } - /* "ssh2/session.pyx":205 + /* "ssh2/session.pyx":191 * cdef unsigned char *_pubkeydata = pubkeydata * cdef size_t pubkeydata_len = len(pubkeydata) * with nogil: # <<<<<<<<<<<<<< @@ -3769,33 +3234,27 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ #endif goto __pyx_L5; } - __pyx_L4_error: { - #ifdef WITH_THREAD - __Pyx_FastGIL_Forget(); - Py_BLOCK_THREADS - #endif - goto __pyx_L1_error; - } __pyx_L5:; } } - /* "ssh2/session.pyx":214 - * "Error authenticating user %s with public key data", - * username) - * return rc # <<<<<<<<<<<<<< + /* "ssh2/session.pyx":195 + * self._session, _username, _pubkeydata, + * pubkeydata_len, NULL, NULL) + * return handle_error_codes(rc) # <<<<<<<<<<<<<< * * def userauth_hostbased_fromfile(self, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 214, __pyx_L1_error) + __pyx_t_5 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 195, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":190 - * return rc + /* "ssh2/session.pyx":176 + * return handle_error_codes(rc) * * def userauth_publickey(self, username not None, # <<<<<<<<<<<<<< * bytes pubkeydata not None): @@ -3805,9 +3264,6 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("ssh2.session.Session.userauth_publickey", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -3817,8 +3273,8 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_24userauth_publickey(struct __ return __pyx_r; } -/* "ssh2/session.pyx":216 - * return rc +/* "ssh2/session.pyx":197 + * return handle_error_codes(rc) * * def userauth_hostbased_fromfile(self, # <<<<<<<<<<<<<< * username not None, @@ -3866,29 +3322,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, 216, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_hostbased_fromfile", 1, 5, 5, 1); __PYX_ERR(0, 197, __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, 216, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_hostbased_fromfile", 1, 5, 5, 2); __PYX_ERR(0, 197, __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, 216, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_hostbased_fromfile", 1, 5, 5, 3); __PYX_ERR(0, 197, __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, 216, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_hostbased_fromfile", 1, 5, 5, 4); __PYX_ERR(0, 197, __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, 216, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth_hostbased_fromfile") < 0)) __PYX_ERR(0, 197, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; @@ -3907,26 +3363,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, 216, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_hostbased_fromfile", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 197, __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, 217, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 198, __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, 218, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "publickey"); __PYX_ERR(0, 199, __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, 219, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "privatekey"); __PYX_ERR(0, 200, __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, 220, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "passphrase"); __PYX_ERR(0, 201, __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, 221, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "hostname"); __PYX_ERR(0, 202, __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); @@ -3956,73 +3412,69 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( PyObject *__pyx_t_1 = NULL; char *__pyx_t_2; int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_t_6; - PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("userauth_hostbased_fromfile", 0); - /* "ssh2/session.pyx":223 + /* "ssh2/session.pyx":204 * 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, 223, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_username = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":224 + /* "ssh2/session.pyx":205 * 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, 224, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_publickey); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_publickey = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":225 + /* "ssh2/session.pyx":206 * 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, 225, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_privatekey); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_privatekey = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":226 + /* "ssh2/session.pyx":207 * 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, 226, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_passphrase); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_passphrase = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":227 + /* "ssh2/session.pyx":208 * 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, 227, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_hostname); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_hostname = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":228 + /* "ssh2/session.pyx":209 * cdef bytes b_passphrase = to_bytes(passphrase) * cdef bytes b_hostname = to_bytes(hostname) * cdef char *_username = b_username # <<<<<<<<<<<<<< @@ -4031,12 +3483,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( */ if (unlikely(__pyx_v_b_username == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 228, __pyx_L1_error) + __PYX_ERR(0, 209, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 228, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 209, __pyx_L1_error) __pyx_v__username = __pyx_t_2; - /* "ssh2/session.pyx":229 + /* "ssh2/session.pyx":210 * cdef bytes b_hostname = to_bytes(hostname) * cdef char *_username = b_username * cdef char *_publickey = b_publickey # <<<<<<<<<<<<<< @@ -4045,12 +3497,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( */ if (unlikely(__pyx_v_b_publickey == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 229, __pyx_L1_error) + __PYX_ERR(0, 210, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_publickey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 229, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_publickey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 210, __pyx_L1_error) __pyx_v__publickey = __pyx_t_2; - /* "ssh2/session.pyx":230 + /* "ssh2/session.pyx":211 * cdef char *_username = b_username * cdef char *_publickey = b_publickey * cdef char *_privatekey = b_privatekey # <<<<<<<<<<<<<< @@ -4059,12 +3511,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( */ if (unlikely(__pyx_v_b_privatekey == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 230, __pyx_L1_error) + __PYX_ERR(0, 211, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_privatekey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 230, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_privatekey); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 211, __pyx_L1_error) __pyx_v__privatekey = __pyx_t_2; - /* "ssh2/session.pyx":231 + /* "ssh2/session.pyx":212 * cdef char *_publickey = b_publickey * cdef char *_privatekey = b_privatekey * cdef char *_passphrase = b_passphrase # <<<<<<<<<<<<<< @@ -4073,12 +3525,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( */ if (unlikely(__pyx_v_b_passphrase == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 231, __pyx_L1_error) + __PYX_ERR(0, 212, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_passphrase); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 231, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_passphrase); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 212, __pyx_L1_error) __pyx_v__passphrase = __pyx_t_2; - /* "ssh2/session.pyx":232 + /* "ssh2/session.pyx":213 * cdef char *_privatekey = b_privatekey * cdef char *_passphrase = b_passphrase * cdef char *_hostname = b_hostname # <<<<<<<<<<<<<< @@ -4087,12 +3539,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( */ if (unlikely(__pyx_v_b_hostname == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 232, __pyx_L1_error) + __PYX_ERR(0, 213, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_hostname); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 232, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_hostname); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 213, __pyx_L1_error) __pyx_v__hostname = __pyx_t_2; - /* "ssh2/session.pyx":233 + /* "ssh2/session.pyx":214 * cdef char *_passphrase = b_passphrase * cdef char *_hostname = b_hostname * with nogil: # <<<<<<<<<<<<<< @@ -4107,7 +3559,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( #endif /*try:*/ { - /* "ssh2/session.pyx":234 + /* "ssh2/session.pyx":215 * cdef char *_hostname = b_hostname * with nogil: * rc = c_ssh2.libssh2_userauth_hostbased_fromfile( # <<<<<<<<<<<<<< @@ -4115,142 +3567,9 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( * _privatekey, _passphrase, _hostname) */ __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":237 - * self._session, _username, _publickey, - * _privatekey, _passphrase, _hostname) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< - * with gil: - * raise AuthenticationError( - */ - 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/session.pyx":238 - * _privatekey, _passphrase, _hostname) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * with gil: # <<<<<<<<<<<<<< - * raise AuthenticationError( - * "Error authenticating user %s with private key %s and" - */ - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - /*try:*/ { - - /* "ssh2/session.pyx":239 - * 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_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_AuthenticationError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 239, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_4); - - /* "ssh2/session.pyx":242 - * "Error authenticating user %s with private key %s and" - * "public key %s for host %s", - * username, privatekey, publickey, hostname) # <<<<<<<<<<<<<< - * return rc - * - */ - __pyx_t_5 = NULL; - __pyx_t_6 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_6 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[6] = {__pyx_t_5, __pyx_kp_s_Error_authenticating_user_s_with_3, __pyx_v_username, __pyx_v_privatekey, __pyx_v_publickey, __pyx_v_hostname}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[6] = {__pyx_t_5, __pyx_kp_s_Error_authenticating_user_s_with_3, __pyx_v_username, __pyx_v_privatekey, __pyx_v_publickey, __pyx_v_hostname}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_7 = PyTuple_New(5+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 239, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_7); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_Error_authenticating_user_s_with_3); - __Pyx_GIVEREF(__pyx_kp_s_Error_authenticating_user_s_with_3); - PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_s_Error_authenticating_user_s_with_3); - __Pyx_INCREF(__pyx_v_username); - __Pyx_GIVEREF(__pyx_v_username); - PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_username); - __Pyx_INCREF(__pyx_v_privatekey); - __Pyx_GIVEREF(__pyx_v_privatekey); - PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_privatekey); - __Pyx_INCREF(__pyx_v_publickey); - __Pyx_GIVEREF(__pyx_v_publickey); - PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_v_publickey); - __Pyx_INCREF(__pyx_v_hostname); - __Pyx_GIVEREF(__pyx_v_hostname); - PyTuple_SET_ITEM(__pyx_t_7, 4+__pyx_t_6, __pyx_v_hostname); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - __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, 239, __pyx_L8_error) - } - - /* "ssh2/session.pyx":238 - * _privatekey, _passphrase, _hostname) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * with gil: # <<<<<<<<<<<<<< - * raise AuthenticationError( - * "Error authenticating user %s with private key %s and" - */ - /*finally:*/ { - __pyx_L8_error: { - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - goto __pyx_L4_error; - } - } - } - - /* "ssh2/session.pyx":237 - * self._session, _username, _publickey, - * _privatekey, _passphrase, _hostname) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< - * with gil: - * raise AuthenticationError( - */ - } } - /* "ssh2/session.pyx":233 + /* "ssh2/session.pyx":214 * cdef char *_passphrase = b_passphrase * cdef char *_hostname = b_hostname * with nogil: # <<<<<<<<<<<<<< @@ -4265,33 +3584,27 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( #endif goto __pyx_L5; } - __pyx_L4_error: { - #ifdef WITH_THREAD - __Pyx_FastGIL_Forget(); - Py_BLOCK_THREADS - #endif - goto __pyx_L1_error; - } __pyx_L5:; } } - /* "ssh2/session.pyx":243 - * "public key %s for host %s", - * username, privatekey, publickey, hostname) - * return rc # <<<<<<<<<<<<<< + /* "ssh2/session.pyx":218 + * self._session, _username, _publickey, + * _privatekey, _passphrase, _hostname) + * return handle_error_codes(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, 243, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 218, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":216 - * return rc + /* "ssh2/session.pyx":197 + * return handle_error_codes(rc) * * def userauth_hostbased_fromfile(self, # <<<<<<<<<<<<<< * username not None, @@ -4301,9 +3614,6 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("ssh2.session.Session.userauth_hostbased_fromfile", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -4317,7 +3627,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_26userauth_hostbased_fromfile( return __pyx_r; } -/* "ssh2/session.pyx":246 +/* "ssh2/session.pyx":221 * * IF EMBEDDED_LIB: * def userauth_publickey_frommemory(self, # <<<<<<<<<<<<<< @@ -4363,23 +3673,23 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_29userauth_publickey_frommemor case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_publickeyfiledata)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("userauth_publickey_frommemory", 1, 4, 4, 1); __PYX_ERR(0, 246, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey_frommemory", 1, 4, 4, 1); __PYX_ERR(0, 221, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_privatekeyfiledata)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("userauth_publickey_frommemory", 1, 4, 4, 2); __PYX_ERR(0, 246, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey_frommemory", 1, 4, 4, 2); __PYX_ERR(0, 221, __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_frommemory", 1, 4, 4, 3); __PYX_ERR(0, 246, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey_frommemory", 1, 4, 4, 3); __PYX_ERR(0, 221, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth_publickey_frommemory") < 0)) __PYX_ERR(0, 246, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth_publickey_frommemory") < 0)) __PYX_ERR(0, 221, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -4396,14 +3706,14 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_29userauth_publickey_frommemor } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("userauth_publickey_frommemory", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 246, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_publickey_frommemory", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 221, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.session.Session.userauth_publickey_frommemory", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_publickeyfiledata), (&PyBytes_Type), 1, "publickeyfiledata", 1))) __PYX_ERR(0, 248, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_privatekeyfiledata), (&PyBytes_Type), 1, "privatekeyfiledata", 1))) __PYX_ERR(0, 249, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_publickeyfiledata), (&PyBytes_Type), 1, "publickeyfiledata", 1))) __PYX_ERR(0, 223, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_privatekeyfiledata), (&PyBytes_Type), 1, "privatekeyfiledata", 1))) __PYX_ERR(0, 224, __pyx_L1_error) __pyx_r = __pyx_pf_4ssh2_7session_7Session_28userauth_publickey_frommemory(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_username, __pyx_v_publickeyfiledata, __pyx_v_privatekeyfiledata, __pyx_v_passphrase); /* function exit code */ @@ -4434,37 +3744,33 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_publickey_frommemor Py_ssize_t __pyx_t_4; Py_ssize_t __pyx_t_5; int __pyx_t_6; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_t_9; - PyObject *__pyx_t_10 = NULL; __Pyx_RefNannySetupContext("userauth_publickey_frommemory", 0); - /* "ssh2/session.pyx":252 + /* "ssh2/session.pyx":227 * passphrase): * cdef int rc * cdef bytes b_username = to_bytes(username) # <<<<<<<<<<<<<< * cdef bytes b_passphrase = to_bytes(passphrase) * cdef char *_username = b_username */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 227, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_username = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":253 + /* "ssh2/session.pyx":228 * cdef int rc * cdef bytes b_username = to_bytes(username) * cdef bytes b_passphrase = to_bytes(passphrase) # <<<<<<<<<<<<<< * cdef char *_username = b_username * cdef char *_passphrase = b_passphrase */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_passphrase); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_passphrase); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_passphrase = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":254 + /* "ssh2/session.pyx":229 * cdef bytes b_username = to_bytes(username) * cdef bytes b_passphrase = to_bytes(passphrase) * cdef char *_username = b_username # <<<<<<<<<<<<<< @@ -4473,12 +3779,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_publickey_frommemor */ if (unlikely(__pyx_v_b_username == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 254, __pyx_L1_error) + __PYX_ERR(0, 229, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 254, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 229, __pyx_L1_error) __pyx_v__username = __pyx_t_2; - /* "ssh2/session.pyx":255 + /* "ssh2/session.pyx":230 * cdef bytes b_passphrase = to_bytes(passphrase) * cdef char *_username = b_username * cdef char *_passphrase = b_passphrase # <<<<<<<<<<<<<< @@ -4487,12 +3793,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_publickey_frommemor */ if (unlikely(__pyx_v_b_passphrase == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 255, __pyx_L1_error) + __PYX_ERR(0, 230, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_passphrase); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 255, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_passphrase); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 230, __pyx_L1_error) __pyx_v__passphrase = __pyx_t_2; - /* "ssh2/session.pyx":256 + /* "ssh2/session.pyx":231 * cdef char *_username = b_username * cdef char *_passphrase = b_passphrase * cdef char *_publickeyfiledata = publickeyfiledata # <<<<<<<<<<<<<< @@ -4501,12 +3807,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_publickey_frommemor */ if (unlikely(__pyx_v_publickeyfiledata == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 256, __pyx_L1_error) + __PYX_ERR(0, 231, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_publickeyfiledata); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 256, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_publickeyfiledata); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 231, __pyx_L1_error) __pyx_v__publickeyfiledata = __pyx_t_2; - /* "ssh2/session.pyx":257 + /* "ssh2/session.pyx":232 * cdef char *_passphrase = b_passphrase * cdef char *_publickeyfiledata = publickeyfiledata * cdef char *_privatekeyfiledata = privatekeyfiledata # <<<<<<<<<<<<<< @@ -4515,12 +3821,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_publickey_frommemor */ if (unlikely(__pyx_v_privatekeyfiledata == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 257, __pyx_L1_error) + __PYX_ERR(0, 232, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_privatekeyfiledata); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 257, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_privatekeyfiledata); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 232, __pyx_L1_error) __pyx_v__privatekeyfiledata = __pyx_t_2; - /* "ssh2/session.pyx":260 + /* "ssh2/session.pyx":235 * cdef size_t username_len, pubkeydata_len, privatekeydata_len * username_len, pubkeydata_len, privatekeydata_len = \ * len(b_username), len(publickeyfiledata), \ # <<<<<<<<<<<<<< @@ -4529,16 +3835,16 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_publickey_frommemor */ if (unlikely(__pyx_v_b_username == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 260, __pyx_L1_error) + __PYX_ERR(0, 235, __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, 260, __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, 235, __pyx_L1_error) if (unlikely(__pyx_v_publickeyfiledata == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 260, __pyx_L1_error) + __PYX_ERR(0, 235, __pyx_L1_error) } - __pyx_t_4 = PyBytes_GET_SIZE(__pyx_v_publickeyfiledata); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 260, __pyx_L1_error) + __pyx_t_4 = PyBytes_GET_SIZE(__pyx_v_publickeyfiledata); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 235, __pyx_L1_error) - /* "ssh2/session.pyx":261 + /* "ssh2/session.pyx":236 * username_len, pubkeydata_len, privatekeydata_len = \ * len(b_username), len(publickeyfiledata), \ * len(privatekeyfiledata) # <<<<<<<<<<<<<< @@ -4547,14 +3853,14 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_publickey_frommemor */ if (unlikely(__pyx_v_privatekeyfiledata == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 261, __pyx_L1_error) + __PYX_ERR(0, 236, __pyx_L1_error) } - __pyx_t_5 = PyBytes_GET_SIZE(__pyx_v_privatekeyfiledata); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 261, __pyx_L1_error) + __pyx_t_5 = PyBytes_GET_SIZE(__pyx_v_privatekeyfiledata); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 236, __pyx_L1_error) __pyx_v_username_len = __pyx_t_3; __pyx_v_pubkeydata_len = __pyx_t_4; __pyx_v_privatekeydata_len = __pyx_t_5; - /* "ssh2/session.pyx":262 + /* "ssh2/session.pyx":237 * len(b_username), len(publickeyfiledata), \ * len(privatekeyfiledata) * with nogil: # <<<<<<<<<<<<<< @@ -4569,7 +3875,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_publickey_frommemor #endif /*try:*/ { - /* "ssh2/session.pyx":263 + /* "ssh2/session.pyx":238 * len(privatekeyfiledata) * with nogil: * rc = c_ssh2.libssh2_userauth_publickey_frommemory( # <<<<<<<<<<<<<< @@ -4577,133 +3883,9 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_publickey_frommemor * pubkeydata_len, _privatekeyfiledata, */ __pyx_v_rc = libssh2_userauth_publickey_frommemory(__pyx_v_self->_session, __pyx_v__username, __pyx_v_username_len, __pyx_v__publickeyfiledata, __pyx_v_pubkeydata_len, __pyx_v__privatekeyfiledata, __pyx_v_privatekeydata_len, __pyx_v__passphrase); - - /* "ssh2/session.pyx":267 - * pubkeydata_len, _privatekeyfiledata, - * privatekeydata_len, _passphrase) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< - * with gil: - * raise AuthenticationError( - */ - switch (__pyx_v_rc) { - case 0: - case LIBSSH2_ERROR_EAGAIN: - __pyx_t_6 = 0; - break; - default: - __pyx_t_6 = 1; - break; - } - if (__pyx_t_6) { - - /* "ssh2/session.pyx":268 - * privatekeydata_len, _passphrase) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * with gil: # <<<<<<<<<<<<<< - * raise AuthenticationError( - * "Error authenticating user %s", username) - */ - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - /*try:*/ { - - /* "ssh2/session.pyx":269 - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * with gil: - * raise AuthenticationError( # <<<<<<<<<<<<<< - * "Error authenticating user %s", username) - * return rc - */ - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_AuthenticationError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 269, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_7); - - /* "ssh2/session.pyx":270 - * with gil: - * raise AuthenticationError( - * "Error authenticating user %s", username) # <<<<<<<<<<<<<< - * return rc - * - */ - __pyx_t_8 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_7, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_Error_authenticating_user_s, __pyx_v_username}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_Error_authenticating_user_s, __pyx_v_username}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 269, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_10); - if (__pyx_t_8) { - __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_Error_authenticating_user_s); - __Pyx_GIVEREF(__pyx_kp_s_Error_authenticating_user_s); - PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_kp_s_Error_authenticating_user_s); - __Pyx_INCREF(__pyx_v_username); - __Pyx_GIVEREF(__pyx_v_username); - PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_username); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 269, __pyx_L8_error) - } - - /* "ssh2/session.pyx":268 - * privatekeydata_len, _passphrase) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * with gil: # <<<<<<<<<<<<<< - * raise AuthenticationError( - * "Error authenticating user %s", username) - */ - /*finally:*/ { - __pyx_L8_error: { - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - goto __pyx_L4_error; - } - } - } - - /* "ssh2/session.pyx":267 - * pubkeydata_len, _privatekeyfiledata, - * privatekeydata_len, _passphrase) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< - * with gil: - * raise AuthenticationError( - */ - } } - /* "ssh2/session.pyx":262 + /* "ssh2/session.pyx":237 * len(b_username), len(publickeyfiledata), \ * len(privatekeyfiledata) * with nogil: # <<<<<<<<<<<<<< @@ -4718,32 +3900,26 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_publickey_frommemor #endif goto __pyx_L5; } - __pyx_L4_error: { - #ifdef WITH_THREAD - __Pyx_FastGIL_Forget(); - Py_BLOCK_THREADS - #endif - goto __pyx_L1_error; - } __pyx_L5:; } } - /* "ssh2/session.pyx":271 - * raise AuthenticationError( - * "Error authenticating user %s", username) - * return rc # <<<<<<<<<<<<<< + /* "ssh2/session.pyx":242 + * pubkeydata_len, _privatekeyfiledata, + * privatekeydata_len, _passphrase) + * return handle_error_codes(rc) # <<<<<<<<<<<<<< * * def userauth_password(self, username not None, password not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L1_error) + __pyx_t_6 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 242, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":246 + /* "ssh2/session.pyx":221 * * IF EMBEDDED_LIB: * def userauth_publickey_frommemory(self, # <<<<<<<<<<<<<< @@ -4754,9 +3930,6 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_publickey_frommemor /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("ssh2.session.Session.userauth_publickey_frommemory", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -4767,8 +3940,8 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_28userauth_publickey_frommemor return __pyx_r; } -/* "ssh2/session.pyx":273 - * return rc +/* "ssh2/session.pyx":244 + * return handle_error_codes(rc) * * def userauth_password(self, username not None, password not None): # <<<<<<<<<<<<<< * """Perform password authentication @@ -4807,11 +3980,11 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_31userauth_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, 273, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_password", 1, 2, 2, 1); __PYX_ERR(0, 244, __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, 273, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "userauth_password") < 0)) __PYX_ERR(0, 244, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -4824,17 +3997,17 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_31userauth_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, 273, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("userauth_password", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 244, __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, 273, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 244, __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, 273, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "password"); __PYX_ERR(0, 244, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_30userauth_password(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_username, __pyx_v_password); @@ -4859,37 +4032,33 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_30userauth_password(struct __p char const *__pyx_t_2; char const *__pyx_t_3; int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("userauth_password", 0); - /* "ssh2/session.pyx":281 + /* "ssh2/session.pyx":252 * :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, 281, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_username = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":282 + /* "ssh2/session.pyx":253 * 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, 282, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_password); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_password = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":283 + /* "ssh2/session.pyx":254 * cdef bytes b_username = to_bytes(username) * cdef bytes b_password = to_bytes(password) * cdef const char *_username = b_username # <<<<<<<<<<<<<< @@ -4898,12 +4067,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_30userauth_password(struct __p */ if (unlikely(__pyx_v_b_username == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 283, __pyx_L1_error) + __PYX_ERR(0, 254, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 283, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 254, __pyx_L1_error) __pyx_v__username = __pyx_t_2; - /* "ssh2/session.pyx":284 + /* "ssh2/session.pyx":255 * cdef bytes b_password = to_bytes(password) * cdef const char *_username = b_username * cdef const char *_password = b_password # <<<<<<<<<<<<<< @@ -4912,12 +4081,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_30userauth_password(struct __p */ if (unlikely(__pyx_v_b_password == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 284, __pyx_L1_error) + __PYX_ERR(0, 255, __pyx_L1_error) } - __pyx_t_3 = __Pyx_PyBytes_AsString(__pyx_v_b_password); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 284, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyBytes_AsString(__pyx_v_b_password); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 255, __pyx_L1_error) __pyx_v__password = __pyx_t_3; - /* "ssh2/session.pyx":285 + /* "ssh2/session.pyx":256 * cdef const char *_username = b_username * cdef const char *_password = b_password * with nogil: # <<<<<<<<<<<<<< @@ -4932,141 +4101,17 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_30userauth_password(struct __p #endif /*try:*/ { - /* "ssh2/session.pyx":286 + /* "ssh2/session.pyx":257 * cdef const char *_password = b_password * with nogil: * rc = c_ssh2.libssh2_userauth_password( # <<<<<<<<<<<<<< * self._session, _username, _password) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * return handle_error_codes(rc) */ __pyx_v_rc = libssh2_userauth_password(__pyx_v_self->_session, __pyx_v__username, __pyx_v__password); - - /* "ssh2/session.pyx":288 - * rc = c_ssh2.libssh2_userauth_password( - * self._session, _username, _password) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< - * with gil: - * raise AuthenticationError( - */ - switch (__pyx_v_rc) { - case 0: - case LIBSSH2_ERROR_EAGAIN: - __pyx_t_4 = 0; - break; - default: - __pyx_t_4 = 1; - break; - } - if (__pyx_t_4) { - - /* "ssh2/session.pyx":289 - * self._session, _username, _password) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * with gil: # <<<<<<<<<<<<<< - * raise AuthenticationError( - * "Error authenticating user %s with password", - */ - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - /*try:*/ { - - /* "ssh2/session.pyx":290 - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * with gil: - * raise AuthenticationError( # <<<<<<<<<<<<<< - * "Error authenticating user %s with password", - * username) - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_AuthenticationError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 290, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_5); - - /* "ssh2/session.pyx":292 - * raise AuthenticationError( - * "Error authenticating user %s with password", - * username) # <<<<<<<<<<<<<< - * return rc - * - */ - __pyx_t_6 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_Error_authenticating_user_s_with_4, __pyx_v_username}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_Error_authenticating_user_s_with_4, __pyx_v_username}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 290, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_Error_authenticating_user_s_with_4); - __Pyx_GIVEREF(__pyx_kp_s_Error_authenticating_user_s_with_4); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_Error_authenticating_user_s_with_4); - __Pyx_INCREF(__pyx_v_username); - __Pyx_GIVEREF(__pyx_v_username); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_username); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 290, __pyx_L8_error) - } - - /* "ssh2/session.pyx":289 - * self._session, _username, _password) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - * with gil: # <<<<<<<<<<<<<< - * raise AuthenticationError( - * "Error authenticating user %s with password", - */ - /*finally:*/ { - __pyx_L8_error: { - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - goto __pyx_L4_error; - } - } - } - - /* "ssh2/session.pyx":288 - * rc = c_ssh2.libssh2_userauth_password( - * self._session, _username, _password) - * if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< - * with gil: - * raise AuthenticationError( - */ - } } - /* "ssh2/session.pyx":285 + /* "ssh2/session.pyx":256 * cdef const char *_username = b_username * cdef const char *_password = b_password * with nogil: # <<<<<<<<<<<<<< @@ -5081,33 +4126,27 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_30userauth_password(struct __p #endif goto __pyx_L5; } - __pyx_L4_error: { - #ifdef WITH_THREAD - __Pyx_FastGIL_Forget(); - Py_BLOCK_THREADS - #endif - goto __pyx_L1_error; - } __pyx_L5:; } } - /* "ssh2/session.pyx":293 - * "Error authenticating user %s with password", - * username) - * return rc # <<<<<<<<<<<<<< + /* "ssh2/session.pyx":259 + * rc = c_ssh2.libssh2_userauth_password( + * self._session, _username, _password) + * return handle_error_codes(rc) # <<<<<<<<<<<<<< * * def agent_init(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error) + __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 259, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":273 - * return rc + /* "ssh2/session.pyx":244 + * return handle_error_codes(rc) * * def userauth_password(self, username not None, password not None): # <<<<<<<<<<<<<< * """Perform password authentication @@ -5117,9 +4156,6 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_30userauth_password(struct __p /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("ssh2.session.Session.userauth_password", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -5130,8 +4166,8 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_30userauth_password(struct __p return __pyx_r; } -/* "ssh2/session.pyx":295 - * return rc +/* "ssh2/session.pyx":261 + * return handle_error_codes(rc) * * def agent_init(self): # <<<<<<<<<<<<<< * """Initialise SSH agent. @@ -5160,7 +4196,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_32agent_init(struct __pyx_obj_ PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("agent_init", 0); - /* "ssh2/session.pyx":301 + /* "ssh2/session.pyx":267 * """ * cdef c_ssh2.LIBSSH2_AGENT *agent * with nogil: # <<<<<<<<<<<<<< @@ -5175,18 +4211,18 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_32agent_init(struct __pyx_obj_ #endif /*try:*/ { - /* "ssh2/session.pyx":302 + /* "ssh2/session.pyx":268 * cdef c_ssh2.LIBSSH2_AGENT *agent * with nogil: * agent = agent_init(self._session) # <<<<<<<<<<<<<< * return PyAgent(agent, self) * */ - __pyx_t_1 = __pyx_f_4ssh2_5agent_agent_init(__pyx_v_self->_session); if (unlikely(__pyx_t_1 == ((LIBSSH2_AGENT *)NULL))) __PYX_ERR(0, 302, __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, 268, __pyx_L4_error) __pyx_v_agent = __pyx_t_1; } - /* "ssh2/session.pyx":301 + /* "ssh2/session.pyx":267 * """ * cdef c_ssh2.LIBSSH2_AGENT *agent * with nogil: # <<<<<<<<<<<<<< @@ -5212,7 +4248,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_32agent_init(struct __pyx_obj_ } } - /* "ssh2/session.pyx":303 + /* "ssh2/session.pyx":269 * with nogil: * agent = agent_init(self._session) * return PyAgent(agent, self) # <<<<<<<<<<<<<< @@ -5220,14 +4256,14 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_32agent_init(struct __pyx_obj_ * 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, 303, __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, 269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":295 - * return rc + /* "ssh2/session.pyx":261 + * return handle_error_codes(rc) * * def agent_init(self): # <<<<<<<<<<<<<< * """Initialise SSH agent. @@ -5245,7 +4281,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_32agent_init(struct __pyx_obj_ return __pyx_r; } -/* "ssh2/session.pyx":305 +/* "ssh2/session.pyx":271 * return PyAgent(agent, self) * * def agent_auth(self, username not None): # <<<<<<<<<<<<<< @@ -5261,7 +4297,7 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_35agent_auth(PyObject *__pyx_v __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, 305, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "username"); __PYX_ERR(0, 271, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_34agent_auth(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), ((PyObject *)__pyx_v_username)); @@ -5288,19 +4324,19 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34agent_auth(struct __pyx_obj_ int __pyx_t_4; __Pyx_RefNannySetupContext("agent_auth", 0); - /* "ssh2/session.pyx":331 + /* "ssh2/session.pyx":297 * * :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, 331, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_username); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_username = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":332 + /* "ssh2/session.pyx":298 * :rtype: None""" * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username # <<<<<<<<<<<<<< @@ -5309,12 +4345,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34agent_auth(struct __pyx_obj_ */ if (unlikely(__pyx_v_b_username == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 332, __pyx_L1_error) + __PYX_ERR(0, 298, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 332, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_username); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 298, __pyx_L1_error) __pyx_v__username = __pyx_t_2; - /* "ssh2/session.pyx":333 + /* "ssh2/session.pyx":299 * cdef bytes b_username = to_bytes(username) * cdef char *_username = b_username * cdef c_ssh2.LIBSSH2_AGENT *agent = NULL # <<<<<<<<<<<<<< @@ -5323,7 +4359,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34agent_auth(struct __pyx_obj_ */ __pyx_v_agent = NULL; - /* "ssh2/session.pyx":334 + /* "ssh2/session.pyx":300 * cdef char *_username = b_username * cdef c_ssh2.LIBSSH2_AGENT *agent = NULL * cdef c_ssh2.libssh2_agent_publickey *identity = NULL # <<<<<<<<<<<<<< @@ -5332,7 +4368,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34agent_auth(struct __pyx_obj_ */ __pyx_v_identity = NULL; - /* "ssh2/session.pyx":335 + /* "ssh2/session.pyx":301 * cdef c_ssh2.LIBSSH2_AGENT *agent = NULL * cdef c_ssh2.libssh2_agent_publickey *identity = NULL * cdef c_ssh2.libssh2_agent_publickey *prev = NULL # <<<<<<<<<<<<<< @@ -5341,17 +4377,17 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34agent_auth(struct __pyx_obj_ */ __pyx_v_prev = NULL; - /* "ssh2/session.pyx":336 + /* "ssh2/session.pyx":302 * cdef c_ssh2.libssh2_agent_publickey *identity = NULL * cdef c_ssh2.libssh2_agent_publickey *prev = NULL * agent = init_connect_agent(self._session) # <<<<<<<<<<<<<< * with nogil: * agent_auth(_username, agent) */ - __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, 336, __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, 302, __pyx_L1_error) __pyx_v_agent = __pyx_t_3; - /* "ssh2/session.pyx":337 + /* "ssh2/session.pyx":303 * cdef c_ssh2.libssh2_agent_publickey *prev = NULL * agent = init_connect_agent(self._session) * with nogil: # <<<<<<<<<<<<<< @@ -5366,17 +4402,17 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34agent_auth(struct __pyx_obj_ #endif /*try:*/ { - /* "ssh2/session.pyx":338 + /* "ssh2/session.pyx":304 * agent = init_connect_agent(self._session) * with nogil: * agent_auth(_username, agent) # <<<<<<<<<<<<<< * * def open_session(self): */ - __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, 338, __pyx_L4_error) + __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, 304, __pyx_L4_error) } - /* "ssh2/session.pyx":337 + /* "ssh2/session.pyx":303 * cdef c_ssh2.libssh2_agent_publickey *prev = NULL * agent = init_connect_agent(self._session) * with nogil: # <<<<<<<<<<<<<< @@ -5402,7 +4438,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34agent_auth(struct __pyx_obj_ } } - /* "ssh2/session.pyx":305 + /* "ssh2/session.pyx":271 * return PyAgent(agent, self) * * def agent_auth(self, username not None): # <<<<<<<<<<<<<< @@ -5424,7 +4460,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_34agent_auth(struct __pyx_obj_ return __pyx_r; } -/* "ssh2/session.pyx":340 +/* "ssh2/session.pyx":306 * agent_auth(_username, agent) * * def open_session(self): # <<<<<<<<<<<<<< @@ -5455,7 +4491,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36open_session(struct __pyx_ob PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("open_session", 0); - /* "ssh2/session.pyx":346 + /* "ssh2/session.pyx":312 * """ * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -5470,7 +4506,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36open_session(struct __pyx_ob #endif /*try:*/ { - /* "ssh2/session.pyx":347 + /* "ssh2/session.pyx":313 * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: * channel = c_ssh2.libssh2_channel_open_session( # <<<<<<<<<<<<<< @@ -5480,7 +4516,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36open_session(struct __pyx_ob __pyx_v_channel = libssh2_channel_open_session(__pyx_v_self->_session); } - /* "ssh2/session.pyx":346 + /* "ssh2/session.pyx":312 * """ * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -5499,7 +4535,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36open_session(struct __pyx_ob } } - /* "ssh2/session.pyx":349 + /* "ssh2/session.pyx":315 * channel = c_ssh2.libssh2_channel_open_session( * self._session) * if channel is NULL: # <<<<<<<<<<<<<< @@ -5509,7 +4545,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36open_session(struct __pyx_ob __pyx_t_1 = ((__pyx_v_channel == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/session.pyx":350 + /* "ssh2/session.pyx":316 * self._session) * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< @@ -5518,29 +4554,29 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36open_session(struct __pyx_ob */ __Pyx_XDECREF(__pyx_r); - /* "ssh2/session.pyx":351 + /* "ssh2/session.pyx":317 * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) # <<<<<<<<<<<<<< * return PyChannel(channel, self) * */ - __pyx_t_2 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 350, __pyx_L1_error) + __pyx_t_2 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 316, __pyx_L1_error) - /* "ssh2/session.pyx":350 + /* "ssh2/session.pyx":316 * self._session) * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< * self._session)) * return PyChannel(channel, self) */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 350, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":349 + /* "ssh2/session.pyx":315 * channel = c_ssh2.libssh2_channel_open_session( * self._session) * if channel is NULL: # <<<<<<<<<<<<<< @@ -5549,7 +4585,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36open_session(struct __pyx_ob */ } - /* "ssh2/session.pyx":352 + /* "ssh2/session.pyx":318 * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) * return PyChannel(channel, self) # <<<<<<<<<<<<<< @@ -5557,13 +4593,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36open_session(struct __pyx_ob * def direct_tcpip_ex(self, host not None, int port, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_f_4ssh2_7channel_PyChannel(__pyx_v_channel, __pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 352, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_7channel_PyChannel(__pyx_v_channel, __pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":340 + /* "ssh2/session.pyx":306 * agent_auth(_username, agent) * * def open_session(self): # <<<<<<<<<<<<<< @@ -5582,7 +4618,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_36open_session(struct __pyx_ob return __pyx_r; } -/* "ssh2/session.pyx":354 +/* "ssh2/session.pyx":320 * return PyChannel(channel, self) * * def direct_tcpip_ex(self, host not None, int port, # <<<<<<<<<<<<<< @@ -5628,23 +4664,23 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_39direct_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, 354, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("direct_tcpip_ex", 1, 4, 4, 1); __PYX_ERR(0, 320, __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, 354, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("direct_tcpip_ex", 1, 4, 4, 2); __PYX_ERR(0, 320, __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, 354, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("direct_tcpip_ex", 1, 4, 4, 3); __PYX_ERR(0, 320, __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, 354, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "direct_tcpip_ex") < 0)) __PYX_ERR(0, 320, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -5655,23 +4691,23 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_39direct_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, 354, __pyx_L3_error) + __pyx_v_port = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_port == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 320, __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, 355, __pyx_L3_error) + __pyx_v_sport = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_sport == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 321, __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, 354, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("direct_tcpip_ex", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 320, __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, 354, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "host"); __PYX_ERR(0, 320, __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, 355, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "shost"); __PYX_ERR(0, 321, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_38direct_tcpip_ex(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_host, __pyx_v_port, __pyx_v_shost, __pyx_v_sport); @@ -5698,31 +4734,31 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip_ex(struct __pyx int __pyx_t_4; __Pyx_RefNannySetupContext("direct_tcpip_ex", 0); - /* "ssh2/session.pyx":357 + /* "ssh2/session.pyx":323 * 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, 357, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_host); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_host = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":358 + /* "ssh2/session.pyx":324 * 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, 358, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_shost); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_shost = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":359 + /* "ssh2/session.pyx":325 * cdef bytes b_host = to_bytes(host) * cdef bytes b_shost = to_bytes(shost) * cdef char *_host = b_host # <<<<<<<<<<<<<< @@ -5731,12 +4767,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip_ex(struct __pyx */ if (unlikely(__pyx_v_b_host == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 359, __pyx_L1_error) + __PYX_ERR(0, 325, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_host); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 359, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_host); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 325, __pyx_L1_error) __pyx_v__host = __pyx_t_2; - /* "ssh2/session.pyx":360 + /* "ssh2/session.pyx":326 * cdef bytes b_shost = to_bytes(shost) * cdef char *_host = b_host * cdef char *_shost = b_shost # <<<<<<<<<<<<<< @@ -5745,12 +4781,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip_ex(struct __pyx */ if (unlikely(__pyx_v_b_shost == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 360, __pyx_L1_error) + __PYX_ERR(0, 326, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_shost); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 360, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_shost); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 326, __pyx_L1_error) __pyx_v__shost = __pyx_t_2; - /* "ssh2/session.pyx":361 + /* "ssh2/session.pyx":327 * cdef char *_host = b_host * cdef char *_shost = b_shost * with nogil: # <<<<<<<<<<<<<< @@ -5765,7 +4801,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip_ex(struct __pyx #endif /*try:*/ { - /* "ssh2/session.pyx":362 + /* "ssh2/session.pyx":328 * cdef char *_shost = b_shost * with nogil: * channel = c_ssh2.libssh2_channel_direct_tcpip_ex( # <<<<<<<<<<<<<< @@ -5775,7 +4811,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_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":361 + /* "ssh2/session.pyx":327 * cdef char *_host = b_host * cdef char *_shost = b_shost * with nogil: # <<<<<<<<<<<<<< @@ -5794,7 +4830,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip_ex(struct __pyx } } - /* "ssh2/session.pyx":364 + /* "ssh2/session.pyx":330 * channel = c_ssh2.libssh2_channel_direct_tcpip_ex( * self._session, _host, port, _shost, sport) * if channel is NULL: # <<<<<<<<<<<<<< @@ -5804,7 +4840,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip_ex(struct __pyx __pyx_t_3 = ((__pyx_v_channel == NULL) != 0); if (__pyx_t_3) { - /* "ssh2/session.pyx":365 + /* "ssh2/session.pyx":331 * self._session, _host, port, _shost, sport) * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< @@ -5813,29 +4849,29 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip_ex(struct __pyx */ __Pyx_XDECREF(__pyx_r); - /* "ssh2/session.pyx":366 + /* "ssh2/session.pyx":332 * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) # <<<<<<<<<<<<<< * return PyChannel(channel, self) * */ - __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 331, __pyx_L1_error) - /* "ssh2/session.pyx":365 + /* "ssh2/session.pyx":331 * self._session, _host, port, _shost, sport) * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< * self._session)) * return PyChannel(channel, self) */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":364 + /* "ssh2/session.pyx":330 * channel = c_ssh2.libssh2_channel_direct_tcpip_ex( * self._session, _host, port, _shost, sport) * if channel is NULL: # <<<<<<<<<<<<<< @@ -5844,7 +4880,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip_ex(struct __pyx */ } - /* "ssh2/session.pyx":367 + /* "ssh2/session.pyx":333 * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) * return PyChannel(channel, self) # <<<<<<<<<<<<<< @@ -5852,13 +4888,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_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, 367, __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, 333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":354 + /* "ssh2/session.pyx":320 * return PyChannel(channel, self) * * def direct_tcpip_ex(self, host not None, int port, # <<<<<<<<<<<<<< @@ -5879,7 +4915,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_38direct_tcpip_ex(struct __pyx return __pyx_r; } -/* "ssh2/session.pyx":369 +/* "ssh2/session.pyx":335 * return PyChannel(channel, self) * * def direct_tcpip(self, host not None, int port): # <<<<<<<<<<<<<< @@ -5919,11 +4955,11 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_41direct_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, 369, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("direct_tcpip", 1, 2, 2, 1); __PYX_ERR(0, 335, __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, 369, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "direct_tcpip") < 0)) __PYX_ERR(0, 335, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -5932,18 +4968,18 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_41direct_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, 369, __pyx_L3_error) + __pyx_v_port = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_port == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 335, __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, 369, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("direct_tcpip", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 335, __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, 369, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "host"); __PYX_ERR(0, 335, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_40direct_tcpip(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_host, __pyx_v_port); @@ -5968,19 +5004,19 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40direct_tcpip(struct __pyx_ob int __pyx_t_4; __Pyx_RefNannySetupContext("direct_tcpip", 0); - /* "ssh2/session.pyx":376 + /* "ssh2/session.pyx":342 * """ * 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, 376, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_host); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 342, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_host = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":377 + /* "ssh2/session.pyx":343 * cdef c_ssh2.LIBSSH2_CHANNEL *channel * cdef bytes b_host = to_bytes(host) * cdef char *_host = b_host # <<<<<<<<<<<<<< @@ -5989,12 +5025,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40direct_tcpip(struct __pyx_ob */ if (unlikely(__pyx_v_b_host == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 377, __pyx_L1_error) + __PYX_ERR(0, 343, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_host); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 377, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_host); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 343, __pyx_L1_error) __pyx_v__host = __pyx_t_2; - /* "ssh2/session.pyx":378 + /* "ssh2/session.pyx":344 * cdef bytes b_host = to_bytes(host) * cdef char *_host = b_host * with nogil: # <<<<<<<<<<<<<< @@ -6009,7 +5045,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40direct_tcpip(struct __pyx_ob #endif /*try:*/ { - /* "ssh2/session.pyx":379 + /* "ssh2/session.pyx":345 * cdef char *_host = b_host * with nogil: * channel = c_ssh2.libssh2_channel_direct_tcpip( # <<<<<<<<<<<<<< @@ -6019,7 +5055,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40direct_tcpip(struct __pyx_ob __pyx_v_channel = libssh2_channel_direct_tcpip(__pyx_v_self->_session, __pyx_v__host, __pyx_v_port); } - /* "ssh2/session.pyx":378 + /* "ssh2/session.pyx":344 * cdef bytes b_host = to_bytes(host) * cdef char *_host = b_host * with nogil: # <<<<<<<<<<<<<< @@ -6038,7 +5074,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40direct_tcpip(struct __pyx_ob } } - /* "ssh2/session.pyx":381 + /* "ssh2/session.pyx":347 * channel = c_ssh2.libssh2_channel_direct_tcpip( * self._session, _host, port) * if channel is NULL: # <<<<<<<<<<<<<< @@ -6048,7 +5084,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40direct_tcpip(struct __pyx_ob __pyx_t_3 = ((__pyx_v_channel == NULL) != 0); if (__pyx_t_3) { - /* "ssh2/session.pyx":382 + /* "ssh2/session.pyx":348 * self._session, _host, port) * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< @@ -6057,29 +5093,29 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40direct_tcpip(struct __pyx_ob */ __Pyx_XDECREF(__pyx_r); - /* "ssh2/session.pyx":383 + /* "ssh2/session.pyx":349 * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) # <<<<<<<<<<<<<< * return PyChannel(channel, self) * */ - __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 382, __pyx_L1_error) + __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 348, __pyx_L1_error) - /* "ssh2/session.pyx":382 + /* "ssh2/session.pyx":348 * self._session, _host, port) * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< * self._session)) * return PyChannel(channel, self) */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 382, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 348, __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":347 * channel = c_ssh2.libssh2_channel_direct_tcpip( * self._session, _host, port) * if channel is NULL: # <<<<<<<<<<<<<< @@ -6088,7 +5124,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40direct_tcpip(struct __pyx_ob */ } - /* "ssh2/session.pyx":384 + /* "ssh2/session.pyx":350 * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) * return PyChannel(channel, self) # <<<<<<<<<<<<<< @@ -6096,13 +5132,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40direct_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, 384, __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, 350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":369 + /* "ssh2/session.pyx":335 * return PyChannel(channel, self) * * def direct_tcpip(self, host not None, int port): # <<<<<<<<<<<<<< @@ -6122,7 +5158,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_40direct_tcpip(struct __pyx_ob return __pyx_r; } -/* "ssh2/session.pyx":386 +/* "ssh2/session.pyx":352 * return PyChannel(channel, self) * * def block_directions(self): # <<<<<<<<<<<<<< @@ -6151,7 +5187,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42block_directions(struct __py PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("block_directions", 0); - /* "ssh2/session.pyx":408 + /* "ssh2/session.pyx":374 * :rtype: int""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6166,7 +5202,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42block_directions(struct __py #endif /*try:*/ { - /* "ssh2/session.pyx":409 + /* "ssh2/session.pyx":375 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_session_block_directions( # <<<<<<<<<<<<<< @@ -6176,7 +5212,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42block_directions(struct __py __pyx_v_rc = libssh2_session_block_directions(__pyx_v_self->_session); } - /* "ssh2/session.pyx":408 + /* "ssh2/session.pyx":374 * :rtype: int""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6195,7 +5231,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42block_directions(struct __py } } - /* "ssh2/session.pyx":411 + /* "ssh2/session.pyx":377 * rc = c_ssh2.libssh2_session_block_directions( * self._session) * return rc # <<<<<<<<<<<<<< @@ -6203,13 +5239,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42block_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, 411, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 377, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":386 + /* "ssh2/session.pyx":352 * return PyChannel(channel, self) * * def block_directions(self): # <<<<<<<<<<<<<< @@ -6228,7 +5264,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_42block_directions(struct __py return __pyx_r; } -/* "ssh2/session.pyx":413 +/* "ssh2/session.pyx":379 * return rc * * def forward_listen(self, int port): # <<<<<<<<<<<<<< @@ -6245,7 +5281,7 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_45forward_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, 413, __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, 379, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -6269,7 +5305,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen(struct __pyx_ PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("forward_listen", 0); - /* "ssh2/session.pyx":421 + /* "ssh2/session.pyx":387 * :rtype: :py:class:`ssh2.listener.Listener` or None""" * cdef c_ssh2.LIBSSH2_LISTENER *listener * with nogil: # <<<<<<<<<<<<<< @@ -6284,7 +5320,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen(struct __pyx_ #endif /*try:*/ { - /* "ssh2/session.pyx":422 + /* "ssh2/session.pyx":388 * cdef c_ssh2.LIBSSH2_LISTENER *listener * with nogil: * listener = c_ssh2.libssh2_channel_forward_listen( # <<<<<<<<<<<<<< @@ -6294,7 +5330,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen(struct __pyx_ __pyx_v_listener = libssh2_channel_forward_listen(__pyx_v_self->_session, __pyx_v_port); } - /* "ssh2/session.pyx":421 + /* "ssh2/session.pyx":387 * :rtype: :py:class:`ssh2.listener.Listener` or None""" * cdef c_ssh2.LIBSSH2_LISTENER *listener * with nogil: # <<<<<<<<<<<<<< @@ -6313,7 +5349,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen(struct __pyx_ } } - /* "ssh2/session.pyx":424 + /* "ssh2/session.pyx":390 * listener = c_ssh2.libssh2_channel_forward_listen( * self._session, port) * if listener is NULL: # <<<<<<<<<<<<<< @@ -6323,7 +5359,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen(struct __pyx_ __pyx_t_1 = ((__pyx_v_listener == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/session.pyx":425 + /* "ssh2/session.pyx":391 * self._session, port) * if listener is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< @@ -6332,29 +5368,29 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen(struct __pyx_ */ __Pyx_XDECREF(__pyx_r); - /* "ssh2/session.pyx":426 + /* "ssh2/session.pyx":392 * if listener is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) # <<<<<<<<<<<<<< * return PyListener(listener, self) * */ - __pyx_t_2 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 425, __pyx_L1_error) + __pyx_t_2 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 391, __pyx_L1_error) - /* "ssh2/session.pyx":425 + /* "ssh2/session.pyx":391 * self._session, port) * if listener is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< * self._session)) * return PyListener(listener, self) */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 425, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":424 + /* "ssh2/session.pyx":390 * listener = c_ssh2.libssh2_channel_forward_listen( * self._session, port) * if listener is NULL: # <<<<<<<<<<<<<< @@ -6363,7 +5399,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen(struct __pyx_ */ } - /* "ssh2/session.pyx":427 + /* "ssh2/session.pyx":393 * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) * return PyListener(listener, self) # <<<<<<<<<<<<<< @@ -6371,13 +5407,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen(struct __pyx_ * def forward_listen_ex(self, host not None, int port, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_f_4ssh2_8listener_PyListener(__pyx_v_listener, __pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 427, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_8listener_PyListener(__pyx_v_listener, __pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":413 + /* "ssh2/session.pyx":379 * return rc * * def forward_listen(self, int port): # <<<<<<<<<<<<<< @@ -6396,7 +5432,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_44forward_listen(struct __pyx_ return __pyx_r; } -/* "ssh2/session.pyx":429 +/* "ssh2/session.pyx":395 * return PyListener(listener, self) * * def forward_listen_ex(self, host not None, int port, # <<<<<<<<<<<<<< @@ -6442,23 +5478,23 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_47forward_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, 429, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("forward_listen_ex", 1, 4, 4, 1); __PYX_ERR(0, 395, __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, 429, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("forward_listen_ex", 1, 4, 4, 2); __PYX_ERR(0, 395, __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, 429, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("forward_listen_ex", 1, 4, 4, 3); __PYX_ERR(0, 395, __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, 429, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "forward_listen_ex") < 0)) __PYX_ERR(0, 395, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -6469,20 +5505,20 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_47forward_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, 429, __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, 430, __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, 430, __pyx_L3_error) + __pyx_v_port = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_port == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 395, __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, 396, __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, 396, __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, 429, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("forward_listen_ex", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 395, __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, 429, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "host"); __PYX_ERR(0, 395, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_46forward_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); @@ -6507,19 +5543,19 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46forward_listen_ex(struct __p int __pyx_t_4; __Pyx_RefNannySetupContext("forward_listen_ex", 0); - /* "ssh2/session.pyx":432 + /* "ssh2/session.pyx":398 * 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, 432, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_host); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_host = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":433 + /* "ssh2/session.pyx":399 * cdef c_ssh2.LIBSSH2_LISTENER *listener * cdef bytes b_host = to_bytes(host) * cdef char *_host = b_host # <<<<<<<<<<<<<< @@ -6528,12 +5564,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46forward_listen_ex(struct __p */ if (unlikely(__pyx_v_b_host == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 433, __pyx_L1_error) + __PYX_ERR(0, 399, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_host); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 433, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_host); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 399, __pyx_L1_error) __pyx_v__host = __pyx_t_2; - /* "ssh2/session.pyx":434 + /* "ssh2/session.pyx":400 * cdef bytes b_host = to_bytes(host) * cdef char *_host = b_host * with nogil: # <<<<<<<<<<<<<< @@ -6548,7 +5584,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46forward_listen_ex(struct __p #endif /*try:*/ { - /* "ssh2/session.pyx":435 + /* "ssh2/session.pyx":401 * cdef char *_host = b_host * with nogil: * listener = c_ssh2.libssh2_channel_forward_listen_ex( # <<<<<<<<<<<<<< @@ -6558,7 +5594,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46forward_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":434 + /* "ssh2/session.pyx":400 * cdef bytes b_host = to_bytes(host) * cdef char *_host = b_host * with nogil: # <<<<<<<<<<<<<< @@ -6577,7 +5613,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46forward_listen_ex(struct __p } } - /* "ssh2/session.pyx":437 + /* "ssh2/session.pyx":403 * listener = c_ssh2.libssh2_channel_forward_listen_ex( * self._session, _host, port, &bound_port, queue_maxsize) * if listener is NULL: # <<<<<<<<<<<<<< @@ -6587,7 +5623,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46forward_listen_ex(struct __p __pyx_t_3 = ((__pyx_v_listener == NULL) != 0); if (__pyx_t_3) { - /* "ssh2/session.pyx":438 + /* "ssh2/session.pyx":404 * self._session, _host, port, &bound_port, queue_maxsize) * if listener is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< @@ -6596,29 +5632,29 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46forward_listen_ex(struct __p */ __Pyx_XDECREF(__pyx_r); - /* "ssh2/session.pyx":439 + /* "ssh2/session.pyx":405 * if listener is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) # <<<<<<<<<<<<<< * return PyListener(listener, self) * */ - __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 438, __pyx_L1_error) + __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 404, __pyx_L1_error) - /* "ssh2/session.pyx":438 + /* "ssh2/session.pyx":404 * self._session, _host, port, &bound_port, queue_maxsize) * if listener is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< * self._session)) * return PyListener(listener, self) */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":437 + /* "ssh2/session.pyx":403 * listener = c_ssh2.libssh2_channel_forward_listen_ex( * self._session, _host, port, &bound_port, queue_maxsize) * if listener is NULL: # <<<<<<<<<<<<<< @@ -6627,7 +5663,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46forward_listen_ex(struct __p */ } - /* "ssh2/session.pyx":440 + /* "ssh2/session.pyx":406 * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) * return PyListener(listener, self) # <<<<<<<<<<<<<< @@ -6635,13 +5671,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46forward_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, 440, __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, 406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":429 + /* "ssh2/session.pyx":395 * return PyListener(listener, self) * * def forward_listen_ex(self, host not None, int port, # <<<<<<<<<<<<<< @@ -6661,7 +5697,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_46forward_listen_ex(struct __p return __pyx_r; } -/* "ssh2/session.pyx":442 +/* "ssh2/session.pyx":408 * return PyListener(listener, self) * * def sftp_init(self): # <<<<<<<<<<<<<< @@ -6692,7 +5728,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_48sftp_init(struct __pyx_obj_4 PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("sftp_init", 0); - /* "ssh2/session.pyx":448 + /* "ssh2/session.pyx":414 * """ * cdef c_sftp.LIBSSH2_SFTP *_sftp * with nogil: # <<<<<<<<<<<<<< @@ -6707,7 +5743,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_48sftp_init(struct __pyx_obj_4 #endif /*try:*/ { - /* "ssh2/session.pyx":449 + /* "ssh2/session.pyx":415 * cdef c_sftp.LIBSSH2_SFTP *_sftp * with nogil: * _sftp = c_sftp.libssh2_sftp_init(self._session) # <<<<<<<<<<<<<< @@ -6717,7 +5753,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_48sftp_init(struct __pyx_obj_4 __pyx_v__sftp = libssh2_sftp_init(__pyx_v_self->_session); } - /* "ssh2/session.pyx":448 + /* "ssh2/session.pyx":414 * """ * cdef c_sftp.LIBSSH2_SFTP *_sftp * with nogil: # <<<<<<<<<<<<<< @@ -6736,7 +5772,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_48sftp_init(struct __pyx_obj_4 } } - /* "ssh2/session.pyx":450 + /* "ssh2/session.pyx":416 * with nogil: * _sftp = c_sftp.libssh2_sftp_init(self._session) * if _sftp is NULL: # <<<<<<<<<<<<<< @@ -6746,7 +5782,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_48sftp_init(struct __pyx_obj_4 __pyx_t_1 = ((__pyx_v__sftp == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/session.pyx":451 + /* "ssh2/session.pyx":417 * _sftp = c_sftp.libssh2_sftp_init(self._session) * if _sftp is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< @@ -6755,29 +5791,29 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_48sftp_init(struct __pyx_obj_4 */ __Pyx_XDECREF(__pyx_r); - /* "ssh2/session.pyx":452 + /* "ssh2/session.pyx":418 * if _sftp is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) # <<<<<<<<<<<<<< * return PySFTP(_sftp, self) * */ - __pyx_t_2 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 451, __pyx_L1_error) + __pyx_t_2 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 417, __pyx_L1_error) - /* "ssh2/session.pyx":451 + /* "ssh2/session.pyx":417 * _sftp = c_sftp.libssh2_sftp_init(self._session) * if _sftp is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< * self._session)) * return PySFTP(_sftp, self) */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 451, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":450 + /* "ssh2/session.pyx":416 * with nogil: * _sftp = c_sftp.libssh2_sftp_init(self._session) * if _sftp is NULL: # <<<<<<<<<<<<<< @@ -6786,7 +5822,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_48sftp_init(struct __pyx_obj_4 */ } - /* "ssh2/session.pyx":453 + /* "ssh2/session.pyx":419 * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) * return PySFTP(_sftp, self) # <<<<<<<<<<<<<< @@ -6794,13 +5830,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_48sftp_init(struct __pyx_obj_4 * def last_error(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_f_4ssh2_4sftp_PySFTP(__pyx_v__sftp, __pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 453, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_4sftp_PySFTP(__pyx_v__sftp, __pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":442 + /* "ssh2/session.pyx":408 * return PyListener(listener, self) * * def sftp_init(self): # <<<<<<<<<<<<<< @@ -6819,7 +5855,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_48sftp_init(struct __pyx_obj_4 return __pyx_r; } -/* "ssh2/session.pyx":455 +/* "ssh2/session.pyx":421 * return PySFTP(_sftp, self) * * def last_error(self): # <<<<<<<<<<<<<< @@ -6858,7 +5894,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50last_error(struct __pyx_obj_ PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("last_error", 0); - /* "ssh2/session.pyx":461 + /* "ssh2/session.pyx":427 * :rtype: str * """ * cdef char **_error_msg = NULL # <<<<<<<<<<<<<< @@ -6867,7 +5903,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50last_error(struct __pyx_obj_ */ __pyx_v__error_msg = NULL; - /* "ssh2/session.pyx":462 + /* "ssh2/session.pyx":428 * """ * cdef char **_error_msg = NULL * cdef bytes msg = b'' # <<<<<<<<<<<<<< @@ -6877,7 +5913,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50last_error(struct __pyx_obj_ __Pyx_INCREF(__pyx_kp_b__3); __pyx_v_msg = __pyx_kp_b__3; - /* "ssh2/session.pyx":463 + /* "ssh2/session.pyx":429 * cdef char **_error_msg = NULL * cdef bytes msg = b'' * cdef int errmsg_len = 0 # <<<<<<<<<<<<<< @@ -6886,7 +5922,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50last_error(struct __pyx_obj_ */ __pyx_v_errmsg_len = 0; - /* "ssh2/session.pyx":465 + /* "ssh2/session.pyx":431 * cdef int errmsg_len = 0 * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6901,7 +5937,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50last_error(struct __pyx_obj_ #endif /*try:*/ { - /* "ssh2/session.pyx":466 + /* "ssh2/session.pyx":432 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_session_last_error( # <<<<<<<<<<<<<< @@ -6911,7 +5947,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50last_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":465 + /* "ssh2/session.pyx":431 * cdef int errmsg_len = 0 * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6930,7 +5966,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50last_error(struct __pyx_obj_ } } - /* "ssh2/session.pyx":468 + /* "ssh2/session.pyx":434 * rc = c_ssh2.libssh2_session_last_error( * self._session, _error_msg, &errmsg_len, 0) * if errmsg_len > 0 and _error_msg is not NULL: # <<<<<<<<<<<<<< @@ -6948,7 +5984,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50last_error(struct __pyx_obj_ __pyx_L7_bool_binop_done:; if (__pyx_t_1) { - /* "ssh2/session.pyx":469 + /* "ssh2/session.pyx":435 * self._session, _error_msg, &errmsg_len, 0) * if errmsg_len > 0 and _error_msg is not NULL: * for line in _error_msg[:errmsg_len]: # <<<<<<<<<<<<<< @@ -6960,23 +5996,23 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50last_error(struct __pyx_obj_ __pyx_t_3 = __pyx_t_5; __pyx_v_line = (__pyx_t_3[0]); - /* "ssh2/session.pyx":470 + /* "ssh2/session.pyx":436 * if errmsg_len > 0 and _error_msg is not NULL: * for line in _error_msg[:errmsg_len]: * msg += line # <<<<<<<<<<<<<< * return msg * */ - __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_line); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 470, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_line); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 436, __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, 470, __pyx_L1_error) + __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 436, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_msg, ((PyObject*)__pyx_t_7)); __pyx_t_7 = 0; } - /* "ssh2/session.pyx":468 + /* "ssh2/session.pyx":434 * rc = c_ssh2.libssh2_session_last_error( * self._session, _error_msg, &errmsg_len, 0) * if errmsg_len > 0 and _error_msg is not NULL: # <<<<<<<<<<<<<< @@ -6985,7 +6021,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50last_error(struct __pyx_obj_ */ } - /* "ssh2/session.pyx":471 + /* "ssh2/session.pyx":437 * for line in _error_msg[:errmsg_len]: * msg += line * return msg # <<<<<<<<<<<<<< @@ -6997,7 +6033,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50last_error(struct __pyx_obj_ __pyx_r = __pyx_v_msg; goto __pyx_L0; - /* "ssh2/session.pyx":455 + /* "ssh2/session.pyx":421 * return PySFTP(_sftp, self) * * def last_error(self): # <<<<<<<<<<<<<< @@ -7018,7 +6054,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_50last_error(struct __pyx_obj_ return __pyx_r; } -/* "ssh2/session.pyx":473 +/* "ssh2/session.pyx":439 * return msg * * def last_errno(self): # <<<<<<<<<<<<<< @@ -7047,7 +6083,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_52last_errno(struct __pyx_obj_ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("last_errno", 0); - /* "ssh2/session.pyx":480 + /* "ssh2/session.pyx":446 * """ * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -7062,7 +6098,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_52last_errno(struct __pyx_obj_ #endif /*try:*/ { - /* "ssh2/session.pyx":481 + /* "ssh2/session.pyx":447 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< @@ -7072,7 +6108,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_52last_errno(struct __pyx_obj_ __pyx_v_rc = libssh2_session_last_errno(__pyx_v_self->_session); } - /* "ssh2/session.pyx":480 + /* "ssh2/session.pyx":446 * """ * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -7091,7 +6127,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_52last_errno(struct __pyx_obj_ } } - /* "ssh2/session.pyx":483 + /* "ssh2/session.pyx":449 * rc = c_ssh2.libssh2_session_last_errno( * self._session) * return rc # <<<<<<<<<<<<<< @@ -7099,13 +6135,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_52last_errno(struct __pyx_obj_ * 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, 483, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":473 + /* "ssh2/session.pyx":439 * return msg * * def last_errno(self): # <<<<<<<<<<<<<< @@ -7124,7 +6160,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_52last_errno(struct __pyx_obj_ return __pyx_r; } -/* "ssh2/session.pyx":486 +/* "ssh2/session.pyx":452 * * IF EMBEDDED_LIB: * def set_last_error(self, int errcode, errmsg not None): # <<<<<<<<<<<<<< @@ -7164,11 +6200,11 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_55set_last_error(PyObject *__p case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_errmsg)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("set_last_error", 1, 2, 2, 1); __PYX_ERR(0, 486, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("set_last_error", 1, 2, 2, 1); __PYX_ERR(0, 452, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_last_error") < 0)) __PYX_ERR(0, 486, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_last_error") < 0)) __PYX_ERR(0, 452, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -7176,19 +6212,19 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_55set_last_error(PyObject *__p values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } - __pyx_v_errcode = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_errcode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 486, __pyx_L3_error) + __pyx_v_errcode = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_errcode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 452, __pyx_L3_error) __pyx_v_errmsg = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("set_last_error", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 486, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("set_last_error", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 452, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.session.Session.set_last_error", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_errmsg) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "errmsg"); __PYX_ERR(0, 486, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "errmsg"); __PYX_ERR(0, 452, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_54set_last_error(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_errcode, __pyx_v_errmsg); @@ -7211,19 +6247,19 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_54set_last_error(struct __pyx_ char *__pyx_t_2; __Pyx_RefNannySetupContext("set_last_error", 0); - /* "ssh2/session.pyx":487 + /* "ssh2/session.pyx":453 * 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 */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_errmsg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 487, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_errmsg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_errmsg = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":488 + /* "ssh2/session.pyx":454 * def set_last_error(self, int errcode, errmsg not None): * cdef bytes b_errmsg = to_bytes(errmsg) * cdef char *_errmsg = b_errmsg # <<<<<<<<<<<<<< @@ -7232,12 +6268,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_54set_last_error(struct __pyx_ */ if (unlikely(__pyx_v_b_errmsg == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 488, __pyx_L1_error) + __PYX_ERR(0, 454, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_errmsg); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 488, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_errmsg); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 454, __pyx_L1_error) __pyx_v__errmsg = __pyx_t_2; - /* "ssh2/session.pyx":490 + /* "ssh2/session.pyx":456 * cdef char *_errmsg = b_errmsg * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -7252,7 +6288,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_54set_last_error(struct __pyx_ #endif /*try:*/ { - /* "ssh2/session.pyx":491 + /* "ssh2/session.pyx":457 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_session_set_last_error( # <<<<<<<<<<<<<< @@ -7262,7 +6298,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_54set_last_error(struct __pyx_ __pyx_v_rc = libssh2_session_set_last_error(__pyx_v_self->_session, __pyx_v_errcode, __pyx_v__errmsg); } - /* "ssh2/session.pyx":490 + /* "ssh2/session.pyx":456 * cdef char *_errmsg = b_errmsg * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -7281,7 +6317,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_54set_last_error(struct __pyx_ } } - /* "ssh2/session.pyx":493 + /* "ssh2/session.pyx":459 * rc = c_ssh2.libssh2_session_set_last_error( * self._session, errcode, _errmsg) * return rc # <<<<<<<<<<<<<< @@ -7289,13 +6325,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_54set_last_error(struct __pyx_ * def scp_recv(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, 493, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 459, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":486 + /* "ssh2/session.pyx":452 * * IF EMBEDDED_LIB: * def set_last_error(self, int errcode, errmsg not None): # <<<<<<<<<<<<<< @@ -7315,7 +6351,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_54set_last_error(struct __pyx_ return __pyx_r; } -/* "ssh2/session.pyx":495 +/* "ssh2/session.pyx":461 * return rc * * def scp_recv(self, path not None): # <<<<<<<<<<<<<< @@ -7331,7 +6367,7 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_57scp_recv(PyObject *__pyx_v_s __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, 495, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 461, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_56scp_recv(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), ((PyObject *)__pyx_v_path)); @@ -7358,19 +6394,19 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_56scp_recv(struct __pyx_obj_4s PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("scp_recv", 0); - /* "ssh2/session.pyx":505 + /* "ssh2/session.pyx":471 * :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, 505, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":506 + /* "ssh2/session.pyx":472 * :py:class:`ssh2.statinfo.StatInfo`) or None""" * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< @@ -7379,24 +6415,24 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_56scp_recv(struct __pyx_obj_4s */ if (unlikely(__pyx_v_b_path == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 506, __pyx_L1_error) + __PYX_ERR(0, 472, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 506, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 472, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/session.pyx":507 + /* "ssh2/session.pyx":473 * 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, 507, __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, 473, __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":509 + /* "ssh2/session.pyx":475 * cdef StatInfo statinfo = StatInfo() * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -7411,7 +6447,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_56scp_recv(struct __pyx_obj_4s #endif /*try:*/ { - /* "ssh2/session.pyx":510 + /* "ssh2/session.pyx":476 * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: * channel = c_ssh2.libssh2_scp_recv( # <<<<<<<<<<<<<< @@ -7421,7 +6457,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_56scp_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":509 + /* "ssh2/session.pyx":475 * cdef StatInfo statinfo = StatInfo() * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -7440,7 +6476,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_56scp_recv(struct __pyx_obj_4s } } - /* "ssh2/session.pyx":512 + /* "ssh2/session.pyx":478 * channel = c_ssh2.libssh2_scp_recv( * self._session, _path, statinfo._stat) * if channel is NULL: # <<<<<<<<<<<<<< @@ -7450,7 +6486,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_56scp_recv(struct __pyx_obj_4s __pyx_t_3 = ((__pyx_v_channel == NULL) != 0); if (__pyx_t_3) { - /* "ssh2/session.pyx":513 + /* "ssh2/session.pyx":479 * self._session, _path, statinfo._stat) * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< @@ -7459,29 +6495,29 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_56scp_recv(struct __pyx_obj_4s */ __Pyx_XDECREF(__pyx_r); - /* "ssh2/session.pyx":514 + /* "ssh2/session.pyx":480 * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) # <<<<<<<<<<<<<< * return PyChannel(channel, self), statinfo * */ - __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 513, __pyx_L1_error) + __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 479, __pyx_L1_error) - /* "ssh2/session.pyx":513 + /* "ssh2/session.pyx":479 * self._session, _path, statinfo._stat) * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< * self._session)) * return PyChannel(channel, self), statinfo */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 513, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 479, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":512 + /* "ssh2/session.pyx":478 * channel = c_ssh2.libssh2_scp_recv( * self._session, _path, statinfo._stat) * if channel is NULL: # <<<<<<<<<<<<<< @@ -7490,7 +6526,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_56scp_recv(struct __pyx_obj_4s */ } - /* "ssh2/session.pyx":515 + /* "ssh2/session.pyx":481 * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) * return PyChannel(channel, self), statinfo # <<<<<<<<<<<<<< @@ -7498,9 +6534,9 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_56scp_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, 515, __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, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 515, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); @@ -7512,7 +6548,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_56scp_recv(struct __pyx_obj_4s __pyx_t_5 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":495 + /* "ssh2/session.pyx":461 * return rc * * def scp_recv(self, path not None): # <<<<<<<<<<<<<< @@ -7534,7 +6570,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_56scp_recv(struct __pyx_obj_4s return __pyx_r; } -/* "ssh2/session.pyx":518 +/* "ssh2/session.pyx":484 * * IF EMBEDDED_LIB: * def scp_recv2(self, path not None): # <<<<<<<<<<<<<< @@ -7550,7 +6586,7 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_59scp_recv2(PyObject *__pyx_v_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("scp_recv2 (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 518, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 484, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_58scp_recv2(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), ((PyObject *)__pyx_v_path)); @@ -7577,31 +6613,31 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_58scp_recv2(struct __pyx_obj_4 PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("scp_recv2", 0); - /* "ssh2/session.pyx":528 + /* "ssh2/session.pyx":494 * :rtype: tuple(:py:class:`ssh2.channel.Channel`, * :py:class:`ssh2.fileinfo.FileInfo`) or ``None``""" * cdef FileInfo fileinfo = FileInfo() # <<<<<<<<<<<<<< * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_8fileinfo_FileInfo), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 528, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4ssh2_8fileinfo_FileInfo), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 494, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_fileinfo = ((struct __pyx_obj_4ssh2_8fileinfo_FileInfo *)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":529 + /* "ssh2/session.pyx":495 * :py:class:`ssh2.fileinfo.FileInfo`) or ``None``""" * cdef FileInfo fileinfo = FileInfo() * 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, 529, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":530 + /* "ssh2/session.pyx":496 * cdef FileInfo fileinfo = FileInfo() * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< @@ -7610,12 +6646,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_58scp_recv2(struct __pyx_obj_4 */ if (unlikely(__pyx_v_b_path == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 530, __pyx_L1_error) + __PYX_ERR(0, 496, __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_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 496, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/session.pyx":532 + /* "ssh2/session.pyx":498 * cdef char *_path = b_path * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -7630,7 +6666,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_58scp_recv2(struct __pyx_obj_4 #endif /*try:*/ { - /* "ssh2/session.pyx":533 + /* "ssh2/session.pyx":499 * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: * channel = c_ssh2.libssh2_scp_recv2( # <<<<<<<<<<<<<< @@ -7640,7 +6676,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_58scp_recv2(struct __pyx_obj_4 __pyx_v_channel = libssh2_scp_recv2(__pyx_v_self->_session, __pyx_v__path, __pyx_v_fileinfo->_stat); } - /* "ssh2/session.pyx":532 + /* "ssh2/session.pyx":498 * cdef char *_path = b_path * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -7659,7 +6695,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_58scp_recv2(struct __pyx_obj_4 } } - /* "ssh2/session.pyx":535 + /* "ssh2/session.pyx":501 * channel = c_ssh2.libssh2_scp_recv2( * self._session, _path, fileinfo._stat) * if channel is NULL: # <<<<<<<<<<<<<< @@ -7669,7 +6705,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_58scp_recv2(struct __pyx_obj_4 __pyx_t_3 = ((__pyx_v_channel == NULL) != 0); if (__pyx_t_3) { - /* "ssh2/session.pyx":536 + /* "ssh2/session.pyx":502 * self._session, _path, fileinfo._stat) * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< @@ -7678,29 +6714,29 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_58scp_recv2(struct __pyx_obj_4 */ __Pyx_XDECREF(__pyx_r); - /* "ssh2/session.pyx":537 + /* "ssh2/session.pyx":503 * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) # <<<<<<<<<<<<<< * return PyChannel(channel, self), fileinfo * */ - __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 536, __pyx_L1_error) + __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 502, __pyx_L1_error) - /* "ssh2/session.pyx":536 + /* "ssh2/session.pyx":502 * self._session, _path, fileinfo._stat) * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< * self._session)) * return PyChannel(channel, self), fileinfo */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 536, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 502, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":535 + /* "ssh2/session.pyx":501 * channel = c_ssh2.libssh2_scp_recv2( * self._session, _path, fileinfo._stat) * if channel is NULL: # <<<<<<<<<<<<<< @@ -7709,7 +6745,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_58scp_recv2(struct __pyx_obj_4 */ } - /* "ssh2/session.pyx":538 + /* "ssh2/session.pyx":504 * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) * return PyChannel(channel, self), fileinfo # <<<<<<<<<<<<<< @@ -7717,9 +6753,9 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_58scp_recv2(struct __pyx_obj_4 * def scp_send(self, path not None, int mode, size_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, 504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 538, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); @@ -7731,7 +6767,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_58scp_recv2(struct __pyx_obj_4 __pyx_t_5 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":518 + /* "ssh2/session.pyx":484 * * IF EMBEDDED_LIB: * def scp_recv2(self, path not None): # <<<<<<<<<<<<<< @@ -7753,7 +6789,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_58scp_recv2(struct __pyx_obj_4 return __pyx_r; } -/* "ssh2/session.pyx":540 +/* "ssh2/session.pyx":506 * return PyChannel(channel, self), fileinfo * * def scp_send(self, path not None, int mode, size_t size): # <<<<<<<<<<<<<< @@ -7796,17 +6832,17 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_61scp_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, 540, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send", 1, 3, 3, 1); __PYX_ERR(0, 506, __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, 540, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send", 1, 3, 3, 2); __PYX_ERR(0, 506, __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, 540, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scp_send") < 0)) __PYX_ERR(0, 506, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; @@ -7816,19 +6852,19 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_61scp_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, 540, __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, 540, __pyx_L3_error) + __pyx_v_mode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 506, __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, 506, __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, 540, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 506, __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, 540, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 506, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_60scp_send(((struct __pyx_obj_4ssh2_7session_Session *)__pyx_v_self), __pyx_v_path, __pyx_v_mode, __pyx_v_size); @@ -7853,19 +6889,19 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_60scp_send(struct __pyx_obj_4s int __pyx_t_4; __Pyx_RefNannySetupContext("scp_send", 0); - /* "ssh2/session.pyx":551 + /* "ssh2/session.pyx":517 * * :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, 551, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":552 + /* "ssh2/session.pyx":518 * :rtype: :py:class:`ssh2.channel.Channel`""" * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< @@ -7874,12 +6910,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_60scp_send(struct __pyx_obj_4s */ if (unlikely(__pyx_v_b_path == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 552, __pyx_L1_error) + __PYX_ERR(0, 518, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 552, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 518, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/session.pyx":554 + /* "ssh2/session.pyx":520 * cdef char *_path = b_path * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -7894,7 +6930,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_60scp_send(struct __pyx_obj_4s #endif /*try:*/ { - /* "ssh2/session.pyx":555 + /* "ssh2/session.pyx":521 * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: * channel = c_ssh2.libssh2_scp_send( # <<<<<<<<<<<<<< @@ -7904,7 +6940,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_60scp_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":554 + /* "ssh2/session.pyx":520 * cdef char *_path = b_path * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -7923,7 +6959,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_60scp_send(struct __pyx_obj_4s } } - /* "ssh2/session.pyx":557 + /* "ssh2/session.pyx":523 * channel = c_ssh2.libssh2_scp_send( * self._session, _path, mode, size) * if channel is NULL: # <<<<<<<<<<<<<< @@ -7933,7 +6969,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_60scp_send(struct __pyx_obj_4s __pyx_t_3 = ((__pyx_v_channel == NULL) != 0); if (__pyx_t_3) { - /* "ssh2/session.pyx":558 + /* "ssh2/session.pyx":524 * self._session, _path, mode, size) * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< @@ -7942,29 +6978,29 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_60scp_send(struct __pyx_obj_4s */ __Pyx_XDECREF(__pyx_r); - /* "ssh2/session.pyx":559 + /* "ssh2/session.pyx":525 * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) # <<<<<<<<<<<<<< * return PyChannel(channel, self) * */ - __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 558, __pyx_L1_error) + __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 524, __pyx_L1_error) - /* "ssh2/session.pyx":558 + /* "ssh2/session.pyx":524 * self._session, _path, mode, size) * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< * self._session)) * return PyChannel(channel, self) */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 558, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":557 + /* "ssh2/session.pyx":523 * channel = c_ssh2.libssh2_scp_send( * self._session, _path, mode, size) * if channel is NULL: # <<<<<<<<<<<<<< @@ -7973,7 +7009,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_60scp_send(struct __pyx_obj_4s */ } - /* "ssh2/session.pyx":560 + /* "ssh2/session.pyx":526 * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) * return PyChannel(channel, self) # <<<<<<<<<<<<<< @@ -7981,13 +7017,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_60scp_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, 560, __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, 526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":540 + /* "ssh2/session.pyx":506 * return PyChannel(channel, self), fileinfo * * def scp_send(self, path not None, int mode, size_t size): # <<<<<<<<<<<<<< @@ -8007,7 +7043,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_60scp_send(struct __pyx_obj_4s return __pyx_r; } -/* "ssh2/session.pyx":562 +/* "ssh2/session.pyx":528 * return PyChannel(channel, self) * * def scp_send64(self, path not None, int mode, c_ssh2.libssh2_uint64_t size, # <<<<<<<<<<<<<< @@ -8056,29 +7092,29 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_63scp_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, 562, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send64", 1, 5, 5, 1); __PYX_ERR(0, 528, __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, 562, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send64", 1, 5, 5, 2); __PYX_ERR(0, 528, __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, 562, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send64", 1, 5, 5, 3); __PYX_ERR(0, 528, __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, 562, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send64", 1, 5, 5, 4); __PYX_ERR(0, 528, __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, 562, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scp_send64") < 0)) __PYX_ERR(0, 528, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; @@ -8090,21 +7126,21 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_63scp_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, 562, __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, 562, __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, 563, __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, 563, __pyx_L3_error) + __pyx_v_mode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 528, __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, 528, __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, 529, __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, 529, __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, 562, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("scp_send64", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 528, __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, 562, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 528, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7session_7Session_62scp_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); @@ -8129,19 +7165,19 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_62scp_send64(struct __pyx_obj_ int __pyx_t_4; __Pyx_RefNannySetupContext("scp_send64", 0); - /* "ssh2/session.pyx":574 + /* "ssh2/session.pyx":540 * * :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, 574, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 540, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/session.pyx":575 + /* "ssh2/session.pyx":541 * :rtype: :py:class:`ssh2.channel.Channel`""" * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< @@ -8150,12 +7186,12 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_62scp_send64(struct __pyx_obj_ */ if (unlikely(__pyx_v_b_path == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 575, __pyx_L1_error) + __PYX_ERR(0, 541, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 575, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 541, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/session.pyx":577 + /* "ssh2/session.pyx":543 * cdef char *_path = b_path * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -8170,7 +7206,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_62scp_send64(struct __pyx_obj_ #endif /*try:*/ { - /* "ssh2/session.pyx":578 + /* "ssh2/session.pyx":544 * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: * channel = c_ssh2.libssh2_scp_send64( # <<<<<<<<<<<<<< @@ -8180,7 +7216,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_62scp_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":577 + /* "ssh2/session.pyx":543 * cdef char *_path = b_path * cdef c_ssh2.LIBSSH2_CHANNEL *channel * with nogil: # <<<<<<<<<<<<<< @@ -8199,7 +7235,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_62scp_send64(struct __pyx_obj_ } } - /* "ssh2/session.pyx":580 + /* "ssh2/session.pyx":546 * channel = c_ssh2.libssh2_scp_send64( * self._session, _path, mode, size, mtime, atime) * if channel is NULL: # <<<<<<<<<<<<<< @@ -8209,7 +7245,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_62scp_send64(struct __pyx_obj_ __pyx_t_3 = ((__pyx_v_channel == NULL) != 0); if (__pyx_t_3) { - /* "ssh2/session.pyx":581 + /* "ssh2/session.pyx":547 * self._session, _path, mode, size, mtime, atime) * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< @@ -8218,29 +7254,29 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_62scp_send64(struct __pyx_obj_ */ __Pyx_XDECREF(__pyx_r); - /* "ssh2/session.pyx":582 + /* "ssh2/session.pyx":548 * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) # <<<<<<<<<<<<<< * return PyChannel(channel, self) * */ - __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 581, __pyx_L1_error) + __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 547, __pyx_L1_error) - /* "ssh2/session.pyx":581 + /* "ssh2/session.pyx":547 * self._session, _path, mode, size, mtime, atime) * if channel is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< * self._session)) * return PyChannel(channel, self) */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 581, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 547, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":580 + /* "ssh2/session.pyx":546 * channel = c_ssh2.libssh2_scp_send64( * self._session, _path, mode, size, mtime, atime) * if channel is NULL: # <<<<<<<<<<<<<< @@ -8249,7 +7285,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_62scp_send64(struct __pyx_obj_ */ } - /* "ssh2/session.pyx":583 + /* "ssh2/session.pyx":549 * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session)) * return PyChannel(channel, self) # <<<<<<<<<<<<<< @@ -8257,13 +7293,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_62scp_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, 583, __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, 549, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":562 + /* "ssh2/session.pyx":528 * return PyChannel(channel, self) * * def scp_send64(self, path not None, int mode, c_ssh2.libssh2_uint64_t size, # <<<<<<<<<<<<<< @@ -8283,7 +7319,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_62scp_send64(struct __pyx_obj_ return __pyx_r; } -/* "ssh2/session.pyx":585 +/* "ssh2/session.pyx":551 * return PyChannel(channel, self) * * def publickey_init(self): # <<<<<<<<<<<<<< @@ -8313,7 +7349,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_64publickey_init(struct __pyx_ PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("publickey_init", 0); - /* "ssh2/session.pyx":589 + /* "ssh2/session.pyx":555 * public keys""" * cdef c_pkey.LIBSSH2_PUBLICKEY *_pkey * with nogil: # <<<<<<<<<<<<<< @@ -8328,7 +7364,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_64publickey_init(struct __pyx_ #endif /*try:*/ { - /* "ssh2/session.pyx":590 + /* "ssh2/session.pyx":556 * cdef c_pkey.LIBSSH2_PUBLICKEY *_pkey * with nogil: * _pkey = c_pkey.libssh2_publickey_init(self._session) # <<<<<<<<<<<<<< @@ -8338,7 +7374,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_64publickey_init(struct __pyx_ __pyx_v__pkey = libssh2_publickey_init(__pyx_v_self->_session); } - /* "ssh2/session.pyx":589 + /* "ssh2/session.pyx":555 * public keys""" * cdef c_pkey.LIBSSH2_PUBLICKEY *_pkey * with nogil: # <<<<<<<<<<<<<< @@ -8357,7 +7393,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_64publickey_init(struct __pyx_ } } - /* "ssh2/session.pyx":591 + /* "ssh2/session.pyx":557 * with nogil: * _pkey = c_pkey.libssh2_publickey_init(self._session) * if _pkey is NULL: # <<<<<<<<<<<<<< @@ -8367,20 +7403,20 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_64publickey_init(struct __pyx_ __pyx_t_1 = ((__pyx_v__pkey == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/session.pyx":592 + /* "ssh2/session.pyx":558 * _pkey = c_pkey.libssh2_publickey_init(self._session) * if _pkey is NULL: * raise PublicKeyInitError # <<<<<<<<<<<<<< * return PyPublicKeySystem(_pkey, self) * */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PublicKeyInitError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 592, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PublicKeyInitError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 558, __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, 592, __pyx_L1_error) + __PYX_ERR(0, 558, __pyx_L1_error) - /* "ssh2/session.pyx":591 + /* "ssh2/session.pyx":557 * with nogil: * _pkey = c_pkey.libssh2_publickey_init(self._session) * if _pkey is NULL: # <<<<<<<<<<<<<< @@ -8389,7 +7425,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_64publickey_init(struct __pyx_ */ } - /* "ssh2/session.pyx":593 + /* "ssh2/session.pyx":559 * if _pkey is NULL: * raise PublicKeyInitError * return PyPublicKeySystem(_pkey, self) # <<<<<<<<<<<<<< @@ -8397,13 +7433,13 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_64publickey_init(struct __pyx_ * 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, 593, __pyx_L1_error) + __pyx_t_2 = __pyx_f_4ssh2_9publickey_PyPublicKeySystem(__pyx_v__pkey, __pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 559, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":585 + /* "ssh2/session.pyx":551 * return PyChannel(channel, self) * * def publickey_init(self): # <<<<<<<<<<<<<< @@ -8422,7 +7458,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_64publickey_init(struct __pyx_ return __pyx_r; } -/* "ssh2/session.pyx":595 +/* "ssh2/session.pyx":561 * return PyPublicKeySystem(_pkey, self) * * def hostkey_hash(self, int hash_type): # <<<<<<<<<<<<<< @@ -8439,7 +7475,7 @@ static PyObject *__pyx_pw_4ssh2_7session_7Session_67hostkey_hash(PyObject *__pyx __Pyx_RefNannyDeclarations __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, 595, __pyx_L3_error) + __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, 561, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -8463,7 +7499,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_66hostkey_hash(struct __pyx_ob PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("hostkey_hash", 0); - /* "ssh2/session.pyx":605 + /* "ssh2/session.pyx":571 * cdef const char *_hash * cdef bytes b_hash * with nogil: # <<<<<<<<<<<<<< @@ -8478,7 +7514,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_66hostkey_hash(struct __pyx_ob #endif /*try:*/ { - /* "ssh2/session.pyx":606 + /* "ssh2/session.pyx":572 * cdef bytes b_hash * with nogil: * _hash = c_ssh2.libssh2_hostkey_hash(self._session, hash_type) # <<<<<<<<<<<<<< @@ -8488,7 +7524,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_66hostkey_hash(struct __pyx_ob __pyx_v__hash = libssh2_hostkey_hash(__pyx_v_self->_session, __pyx_v_hash_type); } - /* "ssh2/session.pyx":605 + /* "ssh2/session.pyx":571 * cdef const char *_hash * cdef bytes b_hash * with nogil: # <<<<<<<<<<<<<< @@ -8507,7 +7543,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_66hostkey_hash(struct __pyx_ob } } - /* "ssh2/session.pyx":607 + /* "ssh2/session.pyx":573 * with nogil: * _hash = c_ssh2.libssh2_hostkey_hash(self._session, hash_type) * if _hash is NULL: # <<<<<<<<<<<<<< @@ -8517,7 +7553,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_66hostkey_hash(struct __pyx_ob __pyx_t_1 = ((__pyx_v__hash == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/session.pyx":608 + /* "ssh2/session.pyx":574 * _hash = c_ssh2.libssh2_hostkey_hash(self._session, hash_type) * if _hash is NULL: * return # <<<<<<<<<<<<<< @@ -8528,7 +7564,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_66hostkey_hash(struct __pyx_ob __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - /* "ssh2/session.pyx":607 + /* "ssh2/session.pyx":573 * with nogil: * _hash = c_ssh2.libssh2_hostkey_hash(self._session, hash_type) * if _hash is NULL: # <<<<<<<<<<<<<< @@ -8537,19 +7573,19 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_66hostkey_hash(struct __pyx_ob */ } - /* "ssh2/session.pyx":609 + /* "ssh2/session.pyx":575 * 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, 609, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v__hash); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 575, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_b_hash = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "ssh2/session.pyx":610 + /* "ssh2/session.pyx":576 * return * b_hash = _hash * return b_hash # <<<<<<<<<<<<<< @@ -8561,7 +7597,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_66hostkey_hash(struct __pyx_ob __pyx_r = __pyx_v_b_hash; goto __pyx_L0; - /* "ssh2/session.pyx":595 + /* "ssh2/session.pyx":561 * return PyPublicKeySystem(_pkey, self) * * def hostkey_hash(self, int hash_type): # <<<<<<<<<<<<<< @@ -8581,7 +7617,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_66hostkey_hash(struct __pyx_ob return __pyx_r; } -/* "ssh2/session.pyx":612 +/* "ssh2/session.pyx":578 * return b_hash * * def hostkey(self): # <<<<<<<<<<<<<< @@ -8615,7 +7651,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_68hostkey(struct __pyx_obj_4ss PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("hostkey", 0); - /* "ssh2/session.pyx":621 + /* "ssh2/session.pyx":587 * * :rtype: tuple(bytes, int)""" * cdef bytes key = b"" # <<<<<<<<<<<<<< @@ -8625,7 +7661,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_68hostkey(struct __pyx_obj_4ss __Pyx_INCREF(__pyx_kp_b__3); __pyx_v_key = __pyx_kp_b__3; - /* "ssh2/session.pyx":623 + /* "ssh2/session.pyx":589 * cdef bytes key = b"" * cdef const char *_key * cdef size_t key_len = 0 # <<<<<<<<<<<<<< @@ -8634,7 +7670,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_68hostkey(struct __pyx_obj_4ss */ __pyx_v_key_len = 0; - /* "ssh2/session.pyx":624 + /* "ssh2/session.pyx":590 * cdef const char *_key * cdef size_t key_len = 0 * cdef int key_type = 0 # <<<<<<<<<<<<<< @@ -8643,7 +7679,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_68hostkey(struct __pyx_obj_4ss */ __pyx_v_key_type = 0; - /* "ssh2/session.pyx":625 + /* "ssh2/session.pyx":591 * cdef size_t key_len = 0 * cdef int key_type = 0 * with nogil: # <<<<<<<<<<<<<< @@ -8658,7 +7694,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_68hostkey(struct __pyx_obj_4ss #endif /*try:*/ { - /* "ssh2/session.pyx":626 + /* "ssh2/session.pyx":592 * cdef int key_type = 0 * with nogil: * _key = c_ssh2.libssh2_session_hostkey( # <<<<<<<<<<<<<< @@ -8668,7 +7704,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_68hostkey(struct __pyx_obj_4ss __pyx_v__key = libssh2_session_hostkey(__pyx_v_self->_session, (&__pyx_v_key_len), (&__pyx_v_key_type)); } - /* "ssh2/session.pyx":625 + /* "ssh2/session.pyx":591 * cdef size_t key_len = 0 * cdef int key_type = 0 * with nogil: # <<<<<<<<<<<<<< @@ -8687,7 +7723,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_68hostkey(struct __pyx_obj_4ss } } - /* "ssh2/session.pyx":628 + /* "ssh2/session.pyx":594 * _key = c_ssh2.libssh2_session_hostkey( * self._session, &key_len, &key_type) * if _key is NULL: # <<<<<<<<<<<<<< @@ -8697,23 +7733,23 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_68hostkey(struct __pyx_obj_4ss __pyx_t_1 = ((__pyx_v__key == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/session.pyx":629 + /* "ssh2/session.pyx":595 * self._session, &key_len, &key_type) * if _key is NULL: * raise SessionHostKeyError( # <<<<<<<<<<<<<< * "Error retrieving server host key for session") * key = _key[:key_len] */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_SessionHostKeyError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 629, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_SessionHostKeyError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 595, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 629, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 595, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 629, __pyx_L1_error) + __PYX_ERR(0, 595, __pyx_L1_error) - /* "ssh2/session.pyx":628 + /* "ssh2/session.pyx":594 * _key = c_ssh2.libssh2_session_hostkey( * self._session, &key_len, &key_type) * if _key is NULL: # <<<<<<<<<<<<<< @@ -8722,19 +7758,19 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_68hostkey(struct __pyx_obj_4ss */ } - /* "ssh2/session.pyx":631 + /* "ssh2/session.pyx":597 * raise SessionHostKeyError( * "Error retrieving server host key for session") * key = _key[:key_len] # <<<<<<<<<<<<<< * return key, key_type * */ - __pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(__pyx_v__key + 0, __pyx_v_key_len - 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 631, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(__pyx_v__key + 0, __pyx_v_key_len - 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 597, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_key, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; - /* "ssh2/session.pyx":632 + /* "ssh2/session.pyx":598 * "Error retrieving server host key for session") * key = _key[:key_len] * return key, key_type # <<<<<<<<<<<<<< @@ -8742,9 +7778,9 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_68hostkey(struct __pyx_obj_4ss * def knownhost_init(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_key_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 632, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_key_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 598, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 632, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 598, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_key); __Pyx_GIVEREF(__pyx_v_key); @@ -8756,7 +7792,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_68hostkey(struct __pyx_obj_4ss __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":612 + /* "ssh2/session.pyx":578 * return b_hash * * def hostkey(self): # <<<<<<<<<<<<<< @@ -8777,7 +7813,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_68hostkey(struct __pyx_obj_4ss return __pyx_r; } -/* "ssh2/session.pyx":634 +/* "ssh2/session.pyx":600 * return key, key_type * * def knownhost_init(self): # <<<<<<<<<<<<<< @@ -8807,7 +7843,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_70knownhost_init(struct __pyx_ PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("knownhost_init", 0); - /* "ssh2/session.pyx":639 + /* "ssh2/session.pyx":605 * :rtype: :py:class:`ssh2.knownhost.KnownHost`""" * cdef c_ssh2.LIBSSH2_KNOWNHOSTS *known_hosts * with nogil: # <<<<<<<<<<<<<< @@ -8822,7 +7858,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_70knownhost_init(struct __pyx_ #endif /*try:*/ { - /* "ssh2/session.pyx":640 + /* "ssh2/session.pyx":606 * cdef c_ssh2.LIBSSH2_KNOWNHOSTS *known_hosts * with nogil: * known_hosts = c_ssh2.libssh2_knownhost_init( # <<<<<<<<<<<<<< @@ -8832,7 +7868,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_70knownhost_init(struct __pyx_ __pyx_v_known_hosts = libssh2_knownhost_init(__pyx_v_self->_session); } - /* "ssh2/session.pyx":639 + /* "ssh2/session.pyx":605 * :rtype: :py:class:`ssh2.knownhost.KnownHost`""" * cdef c_ssh2.LIBSSH2_KNOWNHOSTS *known_hosts * with nogil: # <<<<<<<<<<<<<< @@ -8851,7 +7887,7 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_70knownhost_init(struct __pyx_ } } - /* "ssh2/session.pyx":642 + /* "ssh2/session.pyx":608 * known_hosts = c_ssh2.libssh2_knownhost_init( * self._session) * if known_hosts is NULL: # <<<<<<<<<<<<<< @@ -8861,19 +7897,19 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_70knownhost_init(struct __pyx_ __pyx_t_1 = ((__pyx_v_known_hosts == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/session.pyx":643 + /* "ssh2/session.pyx":609 * self._session) * if known_hosts is NULL: * raise KnownHostError # <<<<<<<<<<<<<< * return PyKnownHost(self, known_hosts) */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_KnownHostError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 643, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_KnownHostError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 609, __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, 643, __pyx_L1_error) + __PYX_ERR(0, 609, __pyx_L1_error) - /* "ssh2/session.pyx":642 + /* "ssh2/session.pyx":608 * known_hosts = c_ssh2.libssh2_knownhost_init( * self._session) * if known_hosts is NULL: # <<<<<<<<<<<<<< @@ -8882,19 +7918,19 @@ static PyObject *__pyx_pf_4ssh2_7session_7Session_70knownhost_init(struct __pyx_ */ } - /* "ssh2/session.pyx":644 + /* "ssh2/session.pyx":610 * if known_hosts is NULL: * raise KnownHostError * return PyKnownHost(self, known_hosts) # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = ((PyObject *)__pyx_f_4ssh2_9knownhost_PyKnownHost(__pyx_v_self, __pyx_v_known_hosts)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 644, __pyx_L1_error) + __pyx_t_2 = ((PyObject *)__pyx_f_4ssh2_9knownhost_PyKnownHost(__pyx_v_self, __pyx_v_known_hosts)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 610, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/session.pyx":634 + /* "ssh2/session.pyx":600 * return key, key_type * * def knownhost_init(self): # <<<<<<<<<<<<<< @@ -9214,13 +8250,7 @@ static struct PyModuleDef __pyx_moduledef = { static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 0}, - {&__pyx_n_s_AuthenticationError, __pyx_k_AuthenticationError, sizeof(__pyx_k_AuthenticationError), 0, 0, 1, 1}, {&__pyx_n_s_ChannelError, __pyx_k_ChannelError, sizeof(__pyx_k_ChannelError), 0, 0, 1, 1}, - {&__pyx_kp_s_Error_authenticating_user_s, __pyx_k_Error_authenticating_user_s, sizeof(__pyx_k_Error_authenticating_user_s), 0, 0, 1, 0}, - {&__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_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_retrieving_server_host_key, __pyx_k_Error_retrieving_server_host_key, sizeof(__pyx_k_Error_retrieving_server_host_key), 0, 0, 1, 0}, {&__pyx_n_s_KnownHostError, __pyx_k_KnownHostError, sizeof(__pyx_k_KnownHostError), 0, 0, 1, 1}, {&__pyx_n_s_LIBSSH2_HOSTKEY_HASH_MD5, __pyx_k_LIBSSH2_HOSTKEY_HASH_MD5, sizeof(__pyx_k_LIBSSH2_HOSTKEY_HASH_MD5), 0, 0, 1, 1}, @@ -9232,11 +8262,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__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_n_s_PublicKeyInitError, __pyx_k_PublicKeyInitError, sizeof(__pyx_k_PublicKeyInitError), 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_SessionHandshakeError, __pyx_k_SessionHandshakeError, sizeof(__pyx_k_SessionHandshakeError), 0, 0, 1, 1}, {&__pyx_n_s_SessionHostKeyError, __pyx_k_SessionHostKeyError, sizeof(__pyx_k_SessionHostKeyError), 0, 0, 1, 1}, - {&__pyx_n_s_SessionStartupError, __pyx_k_SessionStartupError, sizeof(__pyx_k_SessionStartupError), 0, 0, 1, 1}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, {&__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}, @@ -9279,7 +8305,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, 56, __pyx_L1_error) + __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 55, __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:; @@ -9290,25 +8316,25 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "ssh2/session.pyx":161 + /* "ssh2/session.pyx":153 * 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, 161, __pyx_L1_error) + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); - /* "ssh2/session.pyx":629 + /* "ssh2/session.pyx":595 * self._session, &key_len, &key_type) * if _key is NULL: * raise SessionHostKeyError( # <<<<<<<<<<<<<< * "Error retrieving server host key for session") * key = _key[:key_len] */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_Error_retrieving_server_host_key); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 629, __pyx_L1_error) + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_Error_retrieving_server_host_key); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 595, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); @@ -9489,10 +8515,10 @@ static int __pyx_pymod_exec_session(PyObject *__pyx_pyinit_module) /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ - if (PyType_Ready(&__pyx_type_4ssh2_7session_Session) < 0) __PYX_ERR(0, 49, __pyx_L1_error) + if (PyType_Ready(&__pyx_type_4ssh2_7session_Session) < 0) __PYX_ERR(0, 48, __pyx_L1_error) __pyx_type_4ssh2_7session_Session.tp_print = 0; - if (PyObject_SetAttrString(__pyx_m, "Session", (PyObject *)&__pyx_type_4ssh2_7session_Session) < 0) __PYX_ERR(0, 49, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_7session_Session) < 0) __PYX_ERR(0, 49, __pyx_L1_error) + if (PyObject_SetAttrString(__pyx_m, "Session", (PyObject *)&__pyx_type_4ssh2_7session_Session) < 0) __PYX_ERR(0, 48, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_7session_Session) < 0) __PYX_ERR(0, 48, __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", @@ -9549,148 +8575,127 @@ static int __pyx_pymod_exec_session(PyObject *__pyx_pyinit_module) /* "ssh2/session.pyx":22 * from agent cimport PyAgent, agent_auth, agent_init, init_connect_agent * from channel cimport PyChannel - * from exceptions import SessionHandshakeError, SessionStartupError, \ # <<<<<<<<<<<<<< - * AuthenticationError, SessionHostKeyError, KnownHostError, \ + * from exceptions import SessionHostKeyError, KnownHostError, \ # <<<<<<<<<<<<<< * PublicKeyInitError, ChannelError + * from listener cimport PyListener */ - __pyx_t_8 = PyList_New(7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 22, __pyx_L1_error) + __pyx_t_8 = PyList_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - __Pyx_INCREF(__pyx_n_s_SessionHandshakeError); - __Pyx_GIVEREF(__pyx_n_s_SessionHandshakeError); - PyList_SET_ITEM(__pyx_t_8, 0, __pyx_n_s_SessionHandshakeError); - __Pyx_INCREF(__pyx_n_s_SessionStartupError); - __Pyx_GIVEREF(__pyx_n_s_SessionStartupError); - PyList_SET_ITEM(__pyx_t_8, 1, __pyx_n_s_SessionStartupError); - __Pyx_INCREF(__pyx_n_s_AuthenticationError); - __Pyx_GIVEREF(__pyx_n_s_AuthenticationError); - PyList_SET_ITEM(__pyx_t_8, 2, __pyx_n_s_AuthenticationError); __Pyx_INCREF(__pyx_n_s_SessionHostKeyError); __Pyx_GIVEREF(__pyx_n_s_SessionHostKeyError); - PyList_SET_ITEM(__pyx_t_8, 3, __pyx_n_s_SessionHostKeyError); + PyList_SET_ITEM(__pyx_t_8, 0, __pyx_n_s_SessionHostKeyError); __Pyx_INCREF(__pyx_n_s_KnownHostError); __Pyx_GIVEREF(__pyx_n_s_KnownHostError); - PyList_SET_ITEM(__pyx_t_8, 4, __pyx_n_s_KnownHostError); + PyList_SET_ITEM(__pyx_t_8, 1, __pyx_n_s_KnownHostError); __Pyx_INCREF(__pyx_n_s_PublicKeyInitError); __Pyx_GIVEREF(__pyx_n_s_PublicKeyInitError); - PyList_SET_ITEM(__pyx_t_8, 5, __pyx_n_s_PublicKeyInitError); + PyList_SET_ITEM(__pyx_t_8, 2, __pyx_n_s_PublicKeyInitError); __Pyx_INCREF(__pyx_n_s_ChannelError); __Pyx_GIVEREF(__pyx_n_s_ChannelError); - PyList_SET_ITEM(__pyx_t_8, 6, __pyx_n_s_ChannelError); + PyList_SET_ITEM(__pyx_t_8, 3, __pyx_n_s_ChannelError); __pyx_t_9 = __Pyx_Import(__pyx_n_s_exceptions, __pyx_t_8, -1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_SessionHandshakeError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_SessionHandshakeError, __pyx_t_8) < 0) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_SessionStartupError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_SessionStartupError, __pyx_t_8) < 0) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_AuthenticationError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_AuthenticationError, __pyx_t_8) < 0) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_SessionHostKeyError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_SessionHostKeyError, __pyx_t_8) < 0) __PYX_ERR(0, 23, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_SessionHostKeyError, __pyx_t_8) < 0) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_KnownHostError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_KnownHostError, __pyx_t_8) < 0) __PYX_ERR(0, 23, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_KnownHostError, __pyx_t_8) < 0) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_PublicKeyInitError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_PublicKeyInitError, __pyx_t_8) < 0) __PYX_ERR(0, 24, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_PublicKeyInitError, __pyx_t_8) < 0) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_ChannelError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_ChannelError, __pyx_t_8) < 0) __PYX_ERR(0, 24, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ChannelError, __pyx_t_8) < 0) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "ssh2/session.pyx":40 + /* "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 */ - __pyx_t_9 = __Pyx_PyInt_From_int(LIBSSH2_SESSION_BLOCK_INBOUND); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 40, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyInt_From_int(LIBSSH2_SESSION_BLOCK_INBOUND); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_SESSION_BLOCK_INBOUND, __pyx_t_9) < 0) __PYX_ERR(0, 40, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_SESSION_BLOCK_INBOUND, __pyx_t_9) < 0) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "ssh2/session.pyx":41 + /* "ssh2/session.pyx":40 * * 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_9 = __Pyx_PyInt_From_int(LIBSSH2_SESSION_BLOCK_OUTBOUND); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 41, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyInt_From_int(LIBSSH2_SESSION_BLOCK_OUTBOUND); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_SESSION_BLOCK_OUTBOUND, __pyx_t_9) < 0) __PYX_ERR(0, 41, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_SESSION_BLOCK_OUTBOUND, __pyx_t_9) < 0) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "ssh2/session.pyx":42 + /* "ssh2/session.pyx":41 * 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 * LIBSSH2_HOSTKEY_TYPE_UNKNOWN = c_ssh2.LIBSSH2_HOSTKEY_TYPE_UNKNOWN */ - __pyx_t_9 = __Pyx_PyInt_From_int(LIBSSH2_HOSTKEY_HASH_MD5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 42, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyInt_From_int(LIBSSH2_HOSTKEY_HASH_MD5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_HOSTKEY_HASH_MD5, __pyx_t_9) < 0) __PYX_ERR(0, 42, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_HOSTKEY_HASH_MD5, __pyx_t_9) < 0) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "ssh2/session.pyx":43 + /* "ssh2/session.pyx":42 * 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 # <<<<<<<<<<<<<< * LIBSSH2_HOSTKEY_TYPE_UNKNOWN = c_ssh2.LIBSSH2_HOSTKEY_TYPE_UNKNOWN * LIBSSH2_HOSTKEY_TYPE_RSA = c_ssh2.LIBSSH2_HOSTKEY_TYPE_RSA */ - __pyx_t_9 = __Pyx_PyInt_From_int(LIBSSH2_HOSTKEY_HASH_SHA1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 43, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyInt_From_int(LIBSSH2_HOSTKEY_HASH_SHA1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_HOSTKEY_HASH_SHA1, __pyx_t_9) < 0) __PYX_ERR(0, 43, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_HOSTKEY_HASH_SHA1, __pyx_t_9) < 0) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "ssh2/session.pyx":44 + /* "ssh2/session.pyx":43 * LIBSSH2_HOSTKEY_HASH_MD5 = c_ssh2.LIBSSH2_HOSTKEY_HASH_MD5 * LIBSSH2_HOSTKEY_HASH_SHA1 = c_ssh2.LIBSSH2_HOSTKEY_HASH_SHA1 * LIBSSH2_HOSTKEY_TYPE_UNKNOWN = c_ssh2.LIBSSH2_HOSTKEY_TYPE_UNKNOWN # <<<<<<<<<<<<<< * LIBSSH2_HOSTKEY_TYPE_RSA = c_ssh2.LIBSSH2_HOSTKEY_TYPE_RSA * LIBSSH2_HOSTKEY_TYPE_DSS = c_ssh2.LIBSSH2_HOSTKEY_TYPE_DSS */ - __pyx_t_9 = __Pyx_PyInt_From_int(LIBSSH2_HOSTKEY_TYPE_UNKNOWN); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 44, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyInt_From_int(LIBSSH2_HOSTKEY_TYPE_UNKNOWN); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_HOSTKEY_TYPE_UNKNOWN, __pyx_t_9) < 0) __PYX_ERR(0, 44, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_HOSTKEY_TYPE_UNKNOWN, __pyx_t_9) < 0) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "ssh2/session.pyx":45 + /* "ssh2/session.pyx":44 * LIBSSH2_HOSTKEY_HASH_SHA1 = c_ssh2.LIBSSH2_HOSTKEY_HASH_SHA1 * LIBSSH2_HOSTKEY_TYPE_UNKNOWN = c_ssh2.LIBSSH2_HOSTKEY_TYPE_UNKNOWN * LIBSSH2_HOSTKEY_TYPE_RSA = c_ssh2.LIBSSH2_HOSTKEY_TYPE_RSA # <<<<<<<<<<<<<< * LIBSSH2_HOSTKEY_TYPE_DSS = c_ssh2.LIBSSH2_HOSTKEY_TYPE_DSS * */ - __pyx_t_9 = __Pyx_PyInt_From_int(LIBSSH2_HOSTKEY_TYPE_RSA); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 45, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyInt_From_int(LIBSSH2_HOSTKEY_TYPE_RSA); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_HOSTKEY_TYPE_RSA, __pyx_t_9) < 0) __PYX_ERR(0, 45, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_HOSTKEY_TYPE_RSA, __pyx_t_9) < 0) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "ssh2/session.pyx":46 + /* "ssh2/session.pyx":45 * LIBSSH2_HOSTKEY_TYPE_UNKNOWN = c_ssh2.LIBSSH2_HOSTKEY_TYPE_UNKNOWN * LIBSSH2_HOSTKEY_TYPE_RSA = c_ssh2.LIBSSH2_HOSTKEY_TYPE_RSA * LIBSSH2_HOSTKEY_TYPE_DSS = c_ssh2.LIBSSH2_HOSTKEY_TYPE_DSS # <<<<<<<<<<<<<< * * */ - __pyx_t_9 = __Pyx_PyInt_From_int(LIBSSH2_HOSTKEY_TYPE_DSS); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 46, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyInt_From_int(LIBSSH2_HOSTKEY_TYPE_DSS); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_HOSTKEY_TYPE_DSS, __pyx_t_9) < 0) __PYX_ERR(0, 46, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LIBSSH2_HOSTKEY_TYPE_DSS, __pyx_t_9) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "ssh2/session.pyx":1 @@ -9833,186 +8838,180 @@ static int __Pyx_CheckKeywordStrings( return 0; } -/* GetModuleGlobalName */ -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { - PyObject *result; -#if !CYTHON_AVOID_BORROWED_REFS - result = PyDict_GetItem(__pyx_d, name); - if (likely(result)) { - Py_INCREF(result); - } else { -#else - result = PyObject_GetItem(__pyx_d, name); - if (!result) { - PyErr_Clear(); -#endif - result = __Pyx_GetBuiltinName(name); - } - return result; -} - -/* PyFunctionFastCall */ - #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 = __Pyx_PyThreadState_Current; - PyObject **fastlocals; - Py_ssize_t i; +/* PyObjectCall */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; - assert(globals != NULL); - /* XXX Perhaps we should create a specialized - PyFrame_New() that doesn't take locals, but does - take builtins without sanity checking them. - */ - assert(tstate != NULL); - f = PyFrame_New(tstate, co, globals, NULL); - if (f == NULL) { + ternaryfunc call = func->ob_type->tp_call; + if (unlikely(!call)) + return PyObject_Call(func, arg, kw); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; + result = (*call)(func, arg, kw); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); } - fastlocals = f->f_localsplus; - for (i = 0; i < na; i++) { - Py_INCREF(*args); - fastlocals[i] = *args++; - } - result = PyEval_EvalFrameEx(f,0); - ++tstate->recursion_depth; - Py_DECREF(f); - --tstate->recursion_depth; return result; } -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { - PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); - PyObject *globals = PyFunction_GET_GLOBALS(func); - PyObject *argdefs = PyFunction_GET_DEFAULTS(func); - PyObject *closure; -#if PY_MAJOR_VERSION >= 3 - PyObject *kwdefs; -#endif - PyObject *kwtuple, **k; - PyObject **d; - Py_ssize_t nd; - Py_ssize_t nk; - PyObject *result; - assert(kwargs == NULL || PyDict_Check(kwargs)); - nk = kwargs ? PyDict_Size(kwargs) : 0; - if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { - return NULL; - } - if ( -#if PY_MAJOR_VERSION >= 3 - co->co_kwonlyargcount == 0 && #endif - likely(kwargs == NULL || nk == 0) && - co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { - if (argdefs == NULL && co->co_argcount == nargs) { - result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); - goto done; - } - else if (nargs == 0 && argdefs != NULL - && co->co_argcount == Py_SIZE(argdefs)) { - /* function called with no arguments, but all parameters have - a default value: use default values as arguments .*/ - args = &PyTuple_GET_ITEM(argdefs, 0); - result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); - goto done; - } - } - if (kwargs != NULL) { - Py_ssize_t pos, i; - kwtuple = PyTuple_New(2 * nk); - if (kwtuple == NULL) { - result = NULL; - goto done; + +/* RaiseDoubleKeywords */ +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +/* ParseKeywords */ +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; } - k = &PyTuple_GET_ITEM(kwtuple, 0); - pos = i = 0; - while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { - Py_INCREF(k[i]); - Py_INCREF(k[i+1]); - i += 2; + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; } - nk = i / 2; } - else { - kwtuple = NULL; - k = NULL; + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +/* ArgTypeTest */ +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; } - closure = PyFunction_GET_CLOSURE(func); -#if PY_MAJOR_VERSION >= 3 - kwdefs = PyFunction_GET_KW_DEFAULTS(func); -#endif - if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_SIZE(argdefs); + else if (exact) { + #if PY_MAJOR_VERSION == 2 + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + #endif } else { - d = NULL; - nd = 0; + if (likely(__Pyx_TypeCheck(obj, type))) return 1; } -#if PY_MAJOR_VERSION >= 3 - result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, - args, nargs, - k, (int)nk, - d, (int)nd, kwdefs, closure); -#else - result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, - args, nargs, - k, (int)nk, - d, (int)nd, closure); -#endif - Py_XDECREF(kwtuple); -done: - Py_LeaveRecursiveCall(); - return result; + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); + return 0; } -#endif -#endif -/* PyCFunctionFastCall */ - #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); - PyObject *self = PyCFunction_GET_SELF(func); - int flags = PyCFunction_GET_FLAGS(func); - assert(PyCFunction_Check(func)); - assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))); - assert(nargs >= 0); - assert(nargs == 0 || args != NULL); - /* _PyCFunction_FastCallDict() must not be called with an exception set, - because it may clear it (directly or indirectly) and so the - caller loses its exception */ - assert(!PyErr_Occurred()); - if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { - return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL); +/* GetModuleGlobalName */ +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { + PyObject *result; +#if !CYTHON_AVOID_BORROWED_REFS + result = PyDict_GetItem(__pyx_d, name); + if (likely(result)) { + Py_INCREF(result); } else { - return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs); - } -} +#else + result = PyObject_GetItem(__pyx_d, name); + if (!result) { + PyErr_Clear(); #endif - -/* PyObjectCall */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { - PyObject *result; - ternaryfunc call = func->ob_type->tp_call; - if (unlikely(!call)) - return PyObject_Call(func, arg, kw); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = (*call)(func, arg, kw); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); + result = __Pyx_GetBuiltinName(name); } return result; } -#endif /* PyErrFetchRestore */ #if CYTHON_FAST_THREAD_STATE @@ -10197,143 +9196,6 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } #endif -/* RaiseDoubleKeywords */ - static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) -{ - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AsString(kw_name)); - #endif -} - -/* ParseKeywords */ - static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) -{ - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - while (PyDict_Next(kwds, &pos, &key, &value)) { - name = first_kw_arg; - while (*name && (**name != key)) name++; - if (*name) { - values[name-argnames] = value; - continue; - } - name = first_kw_arg; - #if PY_MAJOR_VERSION < 3 - if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { - while (*name) { - if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) - && _PyString_Eq(**name, key)) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - if ((**argname == key) || ( - (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) - && _PyString_Eq(**argname, key))) { - goto arg_passed_twice; - } - argname++; - } - } - } else - #endif - if (likely(PyUnicode_Check(key))) { - while (*name) { - int cmp = (**name == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**name, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - int cmp = (**argname == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**argname, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) goto arg_passed_twice; - argname++; - } - } - } else - goto invalid_keyword_type; - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; - } - } - return 0; -arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, key); - goto bad; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", function_name); - goto bad; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; -} - -/* ArgTypeTest */ - 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; - } - else if (exact) { - #if PY_MAJOR_VERSION == 2 - if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; - #endif - } - else { - if (likely(__Pyx_TypeCheck(obj, type))) return 1; - } - 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 */ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { int ret; diff --git a/ssh2/session.pyx b/ssh2/session.pyx index cdde0a0a..4154b218 100644 --- a/ssh2/session.pyx +++ b/ssh2/session.pyx @@ -19,8 +19,7 @@ from libc.time cimport time_t from agent cimport PyAgent, agent_auth, agent_init, init_connect_agent from channel cimport PyChannel -from exceptions import SessionHandshakeError, SessionStartupError, \ - AuthenticationError, SessionHostKeyError, KnownHostError, \ +from exceptions import SessionHostKeyError, KnownHostError, \ PublicKeyInitError, ChannelError from listener cimport PyListener from sftp cimport PySFTP @@ -61,13 +60,15 @@ cdef class Session: if self._session is not NULL: with nogil: c_ssh2.libssh2_session_disconnect( - self._session, "end") + self._session, b"end") c_ssh2.libssh2_session_free(self._session) self._session = NULL def disconnect(self): + cdef int rc with nogil: - c_ssh2.libssh2_session_disconnect(self._session, "end") + rc = c_ssh2.libssh2_session_disconnect(self._session, b"end") + return handle_error_codes(rc) def handshake(self, sock not None): """Perform SSH handshake. @@ -77,25 +78,16 @@ cdef class Session: cdef int rc with nogil: rc = c_ssh2.libssh2_session_handshake(self._session, _sock) - if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - with gil: - raise SessionHandshakeError( - "SSH session handshake failed with error code %s", - rc) self._sock = _sock self.sock = sock - return rc + return handle_error_codes(rc) 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) - if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - raise SessionStartupError( - "SSH session startup failed with error code %s", - rc) - return rc + return handle_error_codes(rc) def set_blocking(self, bint blocking): """Set session blocking mode on/off. @@ -179,13 +171,7 @@ cdef class Session: with nogil: rc = c_ssh2.libssh2_userauth_publickey_fromfile( self._session, _username, _publickey, _privatekey, _passphrase) - 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", - username, privatekey, publickey) - return rc + return handle_error_codes(rc) def userauth_publickey(self, username not None, bytes pubkeydata not None): @@ -206,12 +192,7 @@ cdef class Session: rc = c_ssh2.libssh2_userauth_publickey( self._session, _username, _pubkeydata, pubkeydata_len, NULL, NULL) - if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - with gil: - raise AuthenticationError( - "Error authenticating user %s with public key data", - username) - return rc + return handle_error_codes(rc) def userauth_hostbased_fromfile(self, username not None, @@ -234,13 +215,7 @@ cdef class Session: rc = c_ssh2.libssh2_userauth_hostbased_fromfile( self._session, _username, _publickey, _privatekey, _passphrase, _hostname) - 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", - username, privatekey, publickey, hostname) - return rc + return handle_error_codes(rc) IF EMBEDDED_LIB: def userauth_publickey_frommemory(self, @@ -264,11 +239,7 @@ cdef class Session: self._session, _username, username_len, _publickeyfiledata, pubkeydata_len, _privatekeyfiledata, privatekeydata_len, _passphrase) - if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - with gil: - raise AuthenticationError( - "Error authenticating user %s", username) - return rc + return handle_error_codes(rc) def userauth_password(self, username not None, password not None): """Perform password authentication @@ -285,12 +256,7 @@ cdef class Session: with nogil: rc = c_ssh2.libssh2_userauth_password( self._session, _username, _password) - if rc != 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: - with gil: - raise AuthenticationError( - "Error authenticating user %s with password", - username) - return rc + return handle_error_codes(rc) def agent_init(self): """Initialise SSH agent. diff --git a/tests/test_session.py b/tests/test_session.py index 84ed59ee..c651ce8f 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -1,4 +1,5 @@ import os +import socket from unittest import skipUnless from .base_test import SSH2TestCase @@ -8,7 +9,8 @@ from ssh2.channel import Channel from ssh2.error_codes import LIBSSH2_ERROR_EAGAIN from ssh2.exceptions import AuthenticationError, AgentAuthenticationError, \ - SCPProtocolError, RequestDeniedError, InvalidRequestError, SocketSendError + SCPProtocolError, RequestDeniedError, InvalidRequestError, \ + SocketSendError, FileError from ssh2.utils import wait_socket @@ -52,7 +54,7 @@ def test_failed_pkey_auth(self): self.session.userauth_publickey_fromfile, 'FAKE USER', self.user_pub_key, self.user_key, '') - self.assertRaises(AuthenticationError, + self.assertRaises(FileError, self.session.userauth_publickey_fromfile, self.user, 'FAKE FILE', 'EVEN MORE FAKE FILE', '') @@ -76,8 +78,8 @@ def test_scp_recv2(self): size, data = file_chan.read(size=fileinfo.st_size) total += size while total < fileinfo.st_size: - total += size size, data = file_chan.read() + total += size self.assertEqual(total, fileinfo.st_size) except Exception: raise @@ -194,6 +196,14 @@ def test_non_blocking(self): chan = self.session.open_session() self.assertIsInstance(chan, Channel) + def test_non_blocking_handshake(self): + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect((self.host, self.port)) + session = Session() + session.set_blocking(0) + while session.handshake(sock) == LIBSSH2_ERROR_EAGAIN: + continue + def test_hostkey(self): self.assertEqual(self._auth(), 0) for _type in [LIBSSH2_HOSTKEY_HASH_MD5, LIBSSH2_HOSTKEY_HASH_SHA1]: