diff --git a/.appveyor.yml b/.appveyor.yml index 4c7f419c..543f2201 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -48,7 +48,6 @@ install: - "%PYTHON_DEF%\\python.exe ci/appveyor/fix_version.py ." - mv -f .git .git.bak - 7z x ci\appveyor\zlib1211.zip - - ps: ls ssh2 build_script: - ci\\appveyor\\build_zlib.bat @@ -56,7 +55,10 @@ build_script: - for %%I in (%PYTHONVERS%) do ls %%I/libs/ - ci\\appveyor\\build_ssh2.bat - for %%I in (%PYTHONVERS%) do cp src/src/libssh2.lib %%I/libs/ || cp src/src/Release/libssh2.lib %%I/libs/ + - mv -f ssh2/find_eol.c . - rm -f ssh2/*.c + - mv -f find_eol.c ssh2/ + - ps: ls ssh2 - for %%I in (%PYTHONVERS%) do %%I\python.exe -V - for %%I in (%PYTHONVERS%) do %%I\python.exe setup.py build_ext - for %%I in (%PYTHONVERS%) do %%I\python.exe setup.py build diff --git a/.gitignore b/.gitignore index a7f486a9..8fc881aa 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ src wheelhouse .idea/ ssh2/libssh2.so* +doc/_build diff --git a/Changelog.rst b/Changelog.rst index 2d44a714..feb8fc9d 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -1,6 +1,15 @@ Change Log ============= +0.20.0 +++++++ + +Changes +-------- + +* Added helper function ``ssh2.utils.find_eol`` for finding end of line characters in buffer. + + 0.19.0 +++++++ diff --git a/MANIFEST.in b/MANIFEST.in index 51500d31..78050b47 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,3 +7,4 @@ exclude .travis.yml include LICENSE include ssh2/*.pyx include ssh2/*.pxd +include ssh2/find_eol* diff --git a/setup.py b/setup.py index e172c47d..d6c40d61 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,3 @@ -from __future__ import print_function - import platform import os import sys @@ -48,7 +46,7 @@ # _comp_args = ["-ggdb"] _fwd_default = 0 -_comp_args = ["-O3"] if not ON_WINDOWS else None +_comp_args = ["-O2"] if not ON_WINDOWS else None _embedded_lib = bool(int(os.environ.get('EMBEDDED_LIB', 1))) _have_agent_fwd = bool(int(os.environ.get('HAVE_AGENT_FWD', _fwd_default))) @@ -87,6 +85,10 @@ ) for i in range(len(sources))] +for ext in extensions: + if ext.name == 'ssh2.utils': + ext.sources.append('ssh2/find_eol.c') + package_data = {'ssh2': ['*.pxd', 'libssh2.so*']} if ON_WINDOWS: diff --git a/ssh2/find_eol.c b/ssh2/find_eol.c new file mode 100644 index 00000000..d1cfd052 --- /dev/null +++ b/ssh2/find_eol.c @@ -0,0 +1,38 @@ +/* +This file is part of ssh2-python. +Copyright (C) 2017-2020 Panos Kittenis + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation, version 2.1. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +static int CR = '\r'; +static int EOL = '\n'; + +int find_eol(char* data, int* new_pos) { + unsigned int index; + char *found; + found = strchr(data, EOL); + if (found == NULL) { + return -1; + } + if (strchr(found-1, CR)) { + found--; + ++*new_pos; + } + index = found - data; + ++*new_pos; + return index; +} diff --git a/ssh2/find_eol.h b/ssh2/find_eol.h new file mode 100644 index 00000000..86352bf0 --- /dev/null +++ b/ssh2/find_eol.h @@ -0,0 +1,19 @@ +/* +This file is part of ssh2-python. +Copyright (C) 2017-2020 Panos Kittenis + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation, version 2.1. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +int find_eol(char* data, int* new_pos); diff --git a/ssh2/utils.c b/ssh2/utils.c index 08db6167..9fca4449 100644 --- a/ssh2/utils.c +++ b/ssh2/utils.c @@ -605,6 +605,7 @@ static CYTHON_INLINE float __PYX_NAN() { #define __PYX_HAVE__ssh2__utils #define __PYX_HAVE_API__ssh2__utils /* Early includes */ +#include "find_eol.h" #include #include #include @@ -1024,6 +1025,10 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObjec /* IncludeStringH.proto */ #include +/* RaiseArgTupleInvalid.proto */ +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); + /* RaiseDoubleKeywords.proto */ static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); @@ -1032,10 +1037,6 @@ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ const char* function_name); -/* RaiseArgTupleInvalid.proto */ -static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); - /* ArgTypeTest.proto */ #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ @@ -1190,9 +1191,13 @@ extern int __pyx_module_is_main_ssh2__utils; int __pyx_module_is_main_ssh2__utils = 0; /* Implementation of 'ssh2.utils' */ +static const char __pyx_k_buf[] = "buf"; +static const char __pyx_k_pos[] = "pos"; static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_c_buf[] = "c_buf"; +static const char __pyx_k_index[] = "index"; static const char __pyx_k_utf_8[] = "utf-8"; static const char __pyx_k_decode[] = "decode"; static const char __pyx_k_encode[] = "encode"; @@ -1200,11 +1205,15 @@ static const char __pyx_k_import[] = "__import__"; static const char __pyx_k_select[] = "select"; static const char __pyx_k_socket[] = "_socket"; static const char __pyx_k_Timeout[] = "Timeout"; +static const char __pyx_k_buf_len[] = "buf_len"; +static const char __pyx_k_cur_buf[] = "cur_buf"; +static const char __pyx_k_new_pos[] = "new_pos"; static const char __pyx_k_readfds[] = "readfds"; static const char __pyx_k_session[] = "session"; static const char __pyx_k_timeout[] = "timeout"; static const char __pyx_k_version[] = "version"; static const char __pyx_k_ENCODING[] = "ENCODING"; +static const char __pyx_k_find_eol[] = "find_eol"; static const char __pyx_k_writefds[] = "writefds"; static const char __pyx_k_FileError[] = "FileError"; static const char __pyx_k_SSH2Error[] = "SSH2Error"; @@ -1304,14 +1313,22 @@ static PyObject *__pyx_n_s_Timeout; static PyObject *__pyx_n_s_UnknownError; static PyObject *__pyx_n_s_ZlibError; static PyObject *__pyx_n_s_block_directions; +static PyObject *__pyx_n_s_buf; +static PyObject *__pyx_n_s_buf_len; +static PyObject *__pyx_n_s_c_buf; static PyObject *__pyx_n_s_cline_in_traceback; +static PyObject *__pyx_n_s_cur_buf; static PyObject *__pyx_n_s_decode; static PyObject *__pyx_n_s_directions; static PyObject *__pyx_n_s_encode; static PyObject *__pyx_n_s_exceptions; +static PyObject *__pyx_n_s_find_eol; static PyObject *__pyx_n_s_import; +static PyObject *__pyx_n_s_index; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_name; +static PyObject *__pyx_n_s_new_pos; +static PyObject *__pyx_n_s_pos; static PyObject *__pyx_n_s_readfds; static PyObject *__pyx_n_s_required_version; static PyObject *__pyx_n_s_select; @@ -1326,17 +1343,21 @@ static PyObject *__pyx_kp_s_utf_8; static PyObject *__pyx_n_s_version; static PyObject *__pyx_n_s_wait_socket; static PyObject *__pyx_n_s_writefds; -static PyObject *__pyx_pf_4ssh2_5utils_version(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_required_version); /* proto */ -static PyObject *__pyx_pf_4ssh2_5utils_2ssh2_exit(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v__socket, struct __pyx_obj_4ssh2_7session_Session *__pyx_v_session, PyObject *__pyx_v_timeout); /* proto */ -static PyObject *__pyx_pf_4ssh2_5utils_6handle_error_codes(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_errcode); /* proto */ +static PyObject *__pyx_pf_4ssh2_5utils_find_eol(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf, Py_ssize_t __pyx_v_pos); /* proto */ +static PyObject *__pyx_pf_4ssh2_5utils_2version(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_required_version); /* proto */ +static PyObject *__pyx_pf_4ssh2_5utils_4ssh2_exit(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_4ssh2_5utils_6wait_socket(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v__socket, struct __pyx_obj_4ssh2_7session_Session *__pyx_v_session, PyObject *__pyx_v_timeout); /* proto */ +static PyObject *__pyx_pf_4ssh2_5utils_8handle_error_codes(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_errcode); /* proto */ static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; +static PyObject *__pyx_int_neg_1; static PyObject *__pyx_tuple_; -static PyObject *__pyx_tuple__4; +static PyObject *__pyx_tuple__3; +static PyObject *__pyx_tuple__6; static PyObject *__pyx_codeobj__2; -static PyObject *__pyx_codeobj__3; +static PyObject *__pyx_codeobj__4; static PyObject *__pyx_codeobj__5; +static PyObject *__pyx_codeobj__7; /* Late includes */ /* "ssh2/utils.pyx":30 @@ -1717,6 +1738,284 @@ static PyObject *__pyx_f_4ssh2_5utils_to_str_len(char *__pyx_v_c_str, int __pyx_ } /* "ssh2/utils.pyx":51 + * + * + * def find_eol(bytes buf, Py_ssize_t pos): # <<<<<<<<<<<<<< + * """Find end-of-line in buffer from position and return end position of + * line and where next find_eol should start from. + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_4ssh2_5utils_1find_eol(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_4ssh2_5utils_find_eol[] = "find_eol(bytes buf, Py_ssize_t pos)\nFind end-of-line in buffer from position and return end position of\n line and where next find_eol should start from.\n\n Eg - find_eol(b'line\nline2', 0) would return (5, 6), next call should be\n find_eol(b'line\nline2', 6) for next line where 6 was added to previous\n position.\n\n :param buf: Data buffer to parse for line.\n :type buf: bytes\n :param pos: Starting position to parse from\n :type pos: int\n\n :rtype: (int, int)"; +static PyMethodDef __pyx_mdef_4ssh2_5utils_1find_eol = {"find_eol", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4ssh2_5utils_1find_eol, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4ssh2_5utils_find_eol}; +static PyObject *__pyx_pw_4ssh2_5utils_1find_eol(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_buf = 0; + Py_ssize_t __pyx_v_pos; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("find_eol (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_buf,&__pyx_n_s_pos,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pos)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("find_eol", 1, 2, 2, 1); __PYX_ERR(0, 51, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "find_eol") < 0)) __PYX_ERR(0, 51, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_buf = ((PyObject*)values[0]); + __pyx_v_pos = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_pos == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 51, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("find_eol", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 51, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("ssh2.utils.find_eol", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_buf), (&PyBytes_Type), 1, "buf", 1))) __PYX_ERR(0, 51, __pyx_L1_error) + __pyx_r = __pyx_pf_4ssh2_5utils_find_eol(__pyx_self, __pyx_v_buf, __pyx_v_pos); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_4ssh2_5utils_find_eol(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_buf, Py_ssize_t __pyx_v_pos) { + Py_ssize_t __pyx_v_buf_len; + PyObject *__pyx_v_cur_buf = 0; + char *__pyx_v_c_buf; + int __pyx_v_index; + int __pyx_v_new_pos; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + char *__pyx_t_5; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("find_eol", 0); + + /* "ssh2/utils.pyx":65 + * + * :rtype: (int, int)""" + * cdef Py_ssize_t buf_len = len(buf) # <<<<<<<<<<<<<< + * if buf_len == 0: + * return -1, pos + */ + if (unlikely(__pyx_v_buf == Py_None)) { + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + __PYX_ERR(0, 65, __pyx_L1_error) + } + __pyx_t_1 = PyBytes_GET_SIZE(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 65, __pyx_L1_error) + __pyx_v_buf_len = __pyx_t_1; + + /* "ssh2/utils.pyx":66 + * :rtype: (int, int)""" + * cdef Py_ssize_t buf_len = len(buf) + * if buf_len == 0: # <<<<<<<<<<<<<< + * return -1, pos + * cdef bytes cur_buf = buf[pos:buf_len] + */ + __pyx_t_2 = ((__pyx_v_buf_len == 0) != 0); + if (__pyx_t_2) { + + /* "ssh2/utils.pyx":67 + * cdef Py_ssize_t buf_len = len(buf) + * if buf_len == 0: + * return -1, pos # <<<<<<<<<<<<<< + * cdef bytes cur_buf = buf[pos:buf_len] + * cdef char* c_buf = cur_buf + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 67, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 67, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_int_neg_1); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + + /* "ssh2/utils.pyx":66 + * :rtype: (int, int)""" + * cdef Py_ssize_t buf_len = len(buf) + * if buf_len == 0: # <<<<<<<<<<<<<< + * return -1, pos + * cdef bytes cur_buf = buf[pos:buf_len] + */ + } + + /* "ssh2/utils.pyx":68 + * if buf_len == 0: + * return -1, pos + * cdef bytes cur_buf = buf[pos:buf_len] # <<<<<<<<<<<<<< + * cdef char* c_buf = cur_buf + * cdef int index + */ + if (unlikely(__pyx_v_buf == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(0, 68, __pyx_L1_error) + } + __pyx_t_4 = PySequence_GetSlice(__pyx_v_buf, __pyx_v_pos, __pyx_v_buf_len); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_v_cur_buf = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; + + /* "ssh2/utils.pyx":69 + * return -1, pos + * cdef bytes cur_buf = buf[pos:buf_len] + * cdef char* c_buf = cur_buf # <<<<<<<<<<<<<< + * cdef int index + * cdef int new_pos + */ + __pyx_t_5 = __Pyx_PyBytes_AsWritableString(__pyx_v_cur_buf); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) __PYX_ERR(0, 69, __pyx_L1_error) + __pyx_v_c_buf = __pyx_t_5; + + /* "ssh2/utils.pyx":72 + * cdef int index + * cdef int new_pos + * with nogil: # <<<<<<<<<<<<<< + * new_pos = 0 + * index = c_find_eol(c_buf, &new_pos) + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); + #endif + /*try:*/ { + + /* "ssh2/utils.pyx":73 + * cdef int new_pos + * with nogil: + * new_pos = 0 # <<<<<<<<<<<<<< + * index = c_find_eol(c_buf, &new_pos) + * return index, new_pos + */ + __pyx_v_new_pos = 0; + + /* "ssh2/utils.pyx":74 + * with nogil: + * new_pos = 0 + * index = c_find_eol(c_buf, &new_pos) # <<<<<<<<<<<<<< + * return index, new_pos + * + */ + __pyx_v_index = find_eol(__pyx_v_c_buf, (&__pyx_v_new_pos)); + } + + /* "ssh2/utils.pyx":72 + * cdef int index + * cdef int new_pos + * with nogil: # <<<<<<<<<<<<<< + * new_pos = 0 + * index = c_find_eol(c_buf, &new_pos) + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L6; + } + __pyx_L6:; + } + } + + /* "ssh2/utils.pyx":75 + * new_pos = 0 + * index = c_find_eol(c_buf, &new_pos) + * return index, new_pos # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 75, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_new_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 75, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 75, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3); + __pyx_t_4 = 0; + __pyx_t_3 = 0; + __pyx_r = __pyx_t_6; + __pyx_t_6 = 0; + goto __pyx_L0; + + /* "ssh2/utils.pyx":51 + * + * + * def find_eol(bytes buf, Py_ssize_t pos): # <<<<<<<<<<<<<< + * """Find end-of-line in buffer from position and return end position of + * line and where next find_eol should start from. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("ssh2.utils.find_eol", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_cur_buf); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "ssh2/utils.pyx":78 * * * def version(int required_version=0): # <<<<<<<<<<<<<< @@ -1725,10 +2024,10 @@ static PyObject *__pyx_f_4ssh2_5utils_to_str_len(char *__pyx_v_c_str, int __pyx_ */ /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_5utils_1version(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_4ssh2_5utils_version[] = "version(int required_version=0)\nGet libssh2 version string.\n\n Passing in a non-zero required_version causes the function to return\n `None` if version is less than required_version\n\n :param required_version: Minimum required version\n :type required_version: int\n "; -static PyMethodDef __pyx_mdef_4ssh2_5utils_1version = {"version", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4ssh2_5utils_1version, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4ssh2_5utils_version}; -static PyObject *__pyx_pw_4ssh2_5utils_1version(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_4ssh2_5utils_3version(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_4ssh2_5utils_2version[] = "version(int required_version=0)\nGet libssh2 version string.\n\n Passing in a non-zero required_version causes the function to return\n `None` if version is less than required_version\n\n :param required_version: Minimum required version\n :type required_version: int\n "; +static PyMethodDef __pyx_mdef_4ssh2_5utils_3version = {"version", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4ssh2_5utils_3version, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4ssh2_5utils_2version}; +static PyObject *__pyx_pw_4ssh2_5utils_3version(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_required_version; int __pyx_lineno = 0; const char *__pyx_filename = NULL; @@ -1757,7 +2056,7 @@ static PyObject *__pyx_pw_4ssh2_5utils_1version(PyObject *__pyx_self, PyObject * } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "version") < 0)) __PYX_ERR(0, 51, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "version") < 0)) __PYX_ERR(0, 78, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -1768,27 +2067,27 @@ static PyObject *__pyx_pw_4ssh2_5utils_1version(PyObject *__pyx_self, PyObject * } } if (values[0]) { - __pyx_v_required_version = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_required_version == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 51, __pyx_L3_error) + __pyx_v_required_version = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_required_version == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 78, __pyx_L3_error) } else { __pyx_v_required_version = ((int)0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("version", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 51, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("version", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 78, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.utils.version", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_4ssh2_5utils_version(__pyx_self, __pyx_v_required_version); + __pyx_r = __pyx_pf_4ssh2_5utils_2version(__pyx_self, __pyx_v_required_version); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_5utils_version(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_required_version) { +static PyObject *__pyx_pf_4ssh2_5utils_2version(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_required_version) { char const *__pyx_v_version; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -1799,7 +2098,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_version(CYTHON_UNUSED PyObject *__pyx_sel int __pyx_clineno = 0; __Pyx_RefNannySetupContext("version", 0); - /* "ssh2/utils.pyx":61 + /* "ssh2/utils.pyx":88 * """ * cdef const char *version * with nogil: # <<<<<<<<<<<<<< @@ -1814,7 +2113,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_version(CYTHON_UNUSED PyObject *__pyx_sel #endif /*try:*/ { - /* "ssh2/utils.pyx":62 + /* "ssh2/utils.pyx":89 * cdef const char *version * with nogil: * version = c_ssh2.libssh2_version(required_version) # <<<<<<<<<<<<<< @@ -1824,7 +2123,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_version(CYTHON_UNUSED PyObject *__pyx_sel __pyx_v_version = libssh2_version(__pyx_v_required_version); } - /* "ssh2/utils.pyx":61 + /* "ssh2/utils.pyx":88 * """ * cdef const char *version * with nogil: # <<<<<<<<<<<<<< @@ -1843,7 +2142,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_version(CYTHON_UNUSED PyObject *__pyx_sel } } - /* "ssh2/utils.pyx":63 + /* "ssh2/utils.pyx":90 * with nogil: * version = c_ssh2.libssh2_version(required_version) * if version is NULL: # <<<<<<<<<<<<<< @@ -1853,7 +2152,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_version(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_1 = ((__pyx_v_version == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/utils.pyx":64 + /* "ssh2/utils.pyx":91 * version = c_ssh2.libssh2_version(required_version) * if version is NULL: * return # <<<<<<<<<<<<<< @@ -1864,7 +2163,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_version(CYTHON_UNUSED PyObject *__pyx_sel __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - /* "ssh2/utils.pyx":63 + /* "ssh2/utils.pyx":90 * with nogil: * version = c_ssh2.libssh2_version(required_version) * if version is NULL: # <<<<<<<<<<<<<< @@ -1873,7 +2172,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_version(CYTHON_UNUSED PyObject *__pyx_sel */ } - /* "ssh2/utils.pyx":65 + /* "ssh2/utils.pyx":92 * if version is NULL: * return * return version # <<<<<<<<<<<<<< @@ -1881,13 +2180,13 @@ static PyObject *__pyx_pf_4ssh2_5utils_version(CYTHON_UNUSED PyObject *__pyx_sel * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_version); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_version); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/utils.pyx":51 + /* "ssh2/utils.pyx":78 * * * def version(int required_version=0): # <<<<<<<<<<<<<< @@ -1906,7 +2205,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_version(CYTHON_UNUSED PyObject *__pyx_sel return __pyx_r; } -/* "ssh2/utils.pyx":68 +/* "ssh2/utils.pyx":95 * * * def ssh2_exit(): # <<<<<<<<<<<<<< @@ -1915,26 +2214,26 @@ static PyObject *__pyx_pf_4ssh2_5utils_version(CYTHON_UNUSED PyObject *__pyx_sel */ /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_5utils_3ssh2_exit(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_4ssh2_5utils_2ssh2_exit[] = "ssh2_exit()\nCall libssh2_exit"; -static PyMethodDef __pyx_mdef_4ssh2_5utils_3ssh2_exit = {"ssh2_exit", (PyCFunction)__pyx_pw_4ssh2_5utils_3ssh2_exit, METH_NOARGS, __pyx_doc_4ssh2_5utils_2ssh2_exit}; -static PyObject *__pyx_pw_4ssh2_5utils_3ssh2_exit(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_4ssh2_5utils_5ssh2_exit(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_4ssh2_5utils_4ssh2_exit[] = "ssh2_exit()\nCall libssh2_exit"; +static PyMethodDef __pyx_mdef_4ssh2_5utils_5ssh2_exit = {"ssh2_exit", (PyCFunction)__pyx_pw_4ssh2_5utils_5ssh2_exit, METH_NOARGS, __pyx_doc_4ssh2_5utils_4ssh2_exit}; +static PyObject *__pyx_pw_4ssh2_5utils_5ssh2_exit(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ssh2_exit (wrapper)", 0); - __pyx_r = __pyx_pf_4ssh2_5utils_2ssh2_exit(__pyx_self); + __pyx_r = __pyx_pf_4ssh2_5utils_4ssh2_exit(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_5utils_2ssh2_exit(CYTHON_UNUSED PyObject *__pyx_self) { +static PyObject *__pyx_pf_4ssh2_5utils_4ssh2_exit(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ssh2_exit", 0); - /* "ssh2/utils.pyx":70 + /* "ssh2/utils.pyx":97 * def ssh2_exit(): * """Call libssh2_exit""" * c_ssh2.libssh2_exit() # <<<<<<<<<<<<<< @@ -1943,7 +2242,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_2ssh2_exit(CYTHON_UNUSED PyObject *__pyx_ */ libssh2_exit(); - /* "ssh2/utils.pyx":68 + /* "ssh2/utils.pyx":95 * * * def ssh2_exit(): # <<<<<<<<<<<<<< @@ -1958,7 +2257,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_2ssh2_exit(CYTHON_UNUSED PyObject *__pyx_ return __pyx_r; } -/* "ssh2/utils.pyx":73 +/* "ssh2/utils.pyx":100 * * * def wait_socket(_socket not None, Session session, timeout=1): # <<<<<<<<<<<<<< @@ -1967,10 +2266,10 @@ static PyObject *__pyx_pf_4ssh2_5utils_2ssh2_exit(CYTHON_UNUSED PyObject *__pyx_ */ /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_5utils_5wait_socket(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_4ssh2_5utils_4wait_socket[] = "wait_socket(_socket, Session session, timeout=1)\nHelper function for testing non-blocking mode.\n\n This function blocks the calling thread for seconds -\n to be used only for testing purposes.\n "; -static PyMethodDef __pyx_mdef_4ssh2_5utils_5wait_socket = {"wait_socket", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4ssh2_5utils_5wait_socket, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4ssh2_5utils_4wait_socket}; -static PyObject *__pyx_pw_4ssh2_5utils_5wait_socket(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_4ssh2_5utils_7wait_socket(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_4ssh2_5utils_6wait_socket[] = "wait_socket(_socket, Session session, timeout=1)\nHelper function for testing non-blocking mode.\n\n This function blocks the calling thread for seconds -\n to be used only for testing purposes.\n "; +static PyMethodDef __pyx_mdef_4ssh2_5utils_7wait_socket = {"wait_socket", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4ssh2_5utils_7wait_socket, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4ssh2_5utils_6wait_socket}; +static PyObject *__pyx_pw_4ssh2_5utils_7wait_socket(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v__socket = 0; struct __pyx_obj_4ssh2_7session_Session *__pyx_v_session = 0; PyObject *__pyx_v_timeout = 0; @@ -2006,7 +2305,7 @@ static PyObject *__pyx_pw_4ssh2_5utils_5wait_socket(PyObject *__pyx_self, PyObje case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_session)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("wait_socket", 0, 2, 3, 1); __PYX_ERR(0, 73, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("wait_socket", 0, 2, 3, 1); __PYX_ERR(0, 100, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: @@ -2016,7 +2315,7 @@ static PyObject *__pyx_pw_4ssh2_5utils_5wait_socket(PyObject *__pyx_self, PyObje } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait_socket") < 0)) __PYX_ERR(0, 73, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait_socket") < 0)) __PYX_ERR(0, 100, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -2034,17 +2333,17 @@ static PyObject *__pyx_pw_4ssh2_5utils_5wait_socket(PyObject *__pyx_self, PyObje } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("wait_socket", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 73, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("wait_socket", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 100, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.utils.wait_socket", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v__socket) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "_socket"); __PYX_ERR(0, 73, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "_socket"); __PYX_ERR(0, 100, __pyx_L1_error) } - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_session), __pyx_ptype_4ssh2_7session_Session, 1, "session", 0))) __PYX_ERR(0, 73, __pyx_L1_error) - __pyx_r = __pyx_pf_4ssh2_5utils_4wait_socket(__pyx_self, __pyx_v__socket, __pyx_v_session, __pyx_v_timeout); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_session), __pyx_ptype_4ssh2_7session_Session, 1, "session", 0))) __PYX_ERR(0, 100, __pyx_L1_error) + __pyx_r = __pyx_pf_4ssh2_5utils_6wait_socket(__pyx_self, __pyx_v__socket, __pyx_v_session, __pyx_v_timeout); /* function exit code */ goto __pyx_L0; @@ -2055,7 +2354,7 @@ static PyObject *__pyx_pw_4ssh2_5utils_5wait_socket(PyObject *__pyx_self, PyObje return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v__socket, struct __pyx_obj_4ssh2_7session_Session *__pyx_v_session, PyObject *__pyx_v_timeout) { +static PyObject *__pyx_pf_4ssh2_5utils_6wait_socket(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v__socket, struct __pyx_obj_4ssh2_7session_Session *__pyx_v_session, PyObject *__pyx_v_timeout) { int __pyx_v_directions; PyObject *__pyx_v_readfds = NULL; PyObject *__pyx_v_writefds = NULL; @@ -2072,14 +2371,14 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py int __pyx_clineno = 0; __Pyx_RefNannySetupContext("wait_socket", 0); - /* "ssh2/utils.pyx":79 + /* "ssh2/utils.pyx":106 * to be used only for testing purposes. * """ * cdef int directions = session.block_directions() # <<<<<<<<<<<<<< * if directions == 0: * return 0 */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_session), __pyx_n_s_block_directions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_session), __pyx_n_s_block_directions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { @@ -2093,14 +2392,14 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 79, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_directions = __pyx_t_4; - /* "ssh2/utils.pyx":80 + /* "ssh2/utils.pyx":107 * """ * cdef int directions = session.block_directions() * if directions == 0: # <<<<<<<<<<<<<< @@ -2110,7 +2409,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py __pyx_t_5 = ((__pyx_v_directions == 0) != 0); if (__pyx_t_5) { - /* "ssh2/utils.pyx":81 + /* "ssh2/utils.pyx":108 * cdef int directions = session.block_directions() * if directions == 0: * return 0 # <<<<<<<<<<<<<< @@ -2122,7 +2421,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py __pyx_r = __pyx_int_0; goto __pyx_L0; - /* "ssh2/utils.pyx":80 + /* "ssh2/utils.pyx":107 * """ * cdef int directions = session.block_directions() * if directions == 0: # <<<<<<<<<<<<<< @@ -2131,7 +2430,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py */ } - /* "ssh2/utils.pyx":83 + /* "ssh2/utils.pyx":110 * return 0 * readfds = [_socket] \ * if (directions & c_ssh2.LIBSSH2_SESSION_BLOCK_INBOUND) else () # <<<<<<<<<<<<<< @@ -2140,14 +2439,14 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py */ if (((__pyx_v_directions & LIBSSH2_SESSION_BLOCK_INBOUND) != 0)) { - /* "ssh2/utils.pyx":82 + /* "ssh2/utils.pyx":109 * if directions == 0: * return 0 * readfds = [_socket] \ # <<<<<<<<<<<<<< * if (directions & c_ssh2.LIBSSH2_SESSION_BLOCK_INBOUND) else () * writefds = [_socket] \ */ - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error) + __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v__socket); __Pyx_GIVEREF(__pyx_v__socket); @@ -2156,7 +2455,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py __pyx_t_2 = 0; } else { - /* "ssh2/utils.pyx":83 + /* "ssh2/utils.pyx":110 * return 0 * readfds = [_socket] \ * if (directions & c_ssh2.LIBSSH2_SESSION_BLOCK_INBOUND) else () # <<<<<<<<<<<<<< @@ -2169,7 +2468,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py __pyx_v_readfds = __pyx_t_1; __pyx_t_1 = 0; - /* "ssh2/utils.pyx":85 + /* "ssh2/utils.pyx":112 * if (directions & c_ssh2.LIBSSH2_SESSION_BLOCK_INBOUND) else () * writefds = [_socket] \ * if (directions & c_ssh2.LIBSSH2_SESSION_BLOCK_OUTBOUND) else () # <<<<<<<<<<<<<< @@ -2178,14 +2477,14 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py */ if (((__pyx_v_directions & LIBSSH2_SESSION_BLOCK_OUTBOUND) != 0)) { - /* "ssh2/utils.pyx":84 + /* "ssh2/utils.pyx":111 * readfds = [_socket] \ * if (directions & c_ssh2.LIBSSH2_SESSION_BLOCK_INBOUND) else () * writefds = [_socket] \ # <<<<<<<<<<<<<< * if (directions & c_ssh2.LIBSSH2_SESSION_BLOCK_OUTBOUND) else () * return select(readfds, writefds, (), timeout) */ - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v__socket); __Pyx_GIVEREF(__pyx_v__socket); @@ -2194,7 +2493,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py __pyx_t_2 = 0; } else { - /* "ssh2/utils.pyx":85 + /* "ssh2/utils.pyx":112 * if (directions & c_ssh2.LIBSSH2_SESSION_BLOCK_INBOUND) else () * writefds = [_socket] \ * if (directions & c_ssh2.LIBSSH2_SESSION_BLOCK_OUTBOUND) else () # <<<<<<<<<<<<<< @@ -2207,7 +2506,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py __pyx_v_writefds = __pyx_t_1; __pyx_t_1 = 0; - /* "ssh2/utils.pyx":86 + /* "ssh2/utils.pyx":113 * writefds = [_socket] \ * if (directions & c_ssh2.LIBSSH2_SESSION_BLOCK_OUTBOUND) else () * return select(readfds, writefds, (), timeout) # <<<<<<<<<<<<<< @@ -2215,7 +2514,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py * */ __Pyx_XDECREF(__pyx_r); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_select); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_select); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; @@ -2232,7 +2531,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_readfds, __pyx_v_writefds, __pyx_empty_tuple, __pyx_v_timeout}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else @@ -2240,13 +2539,13 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_readfds, __pyx_v_writefds, __pyx_empty_tuple, __pyx_v_timeout}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { - __pyx_t_6 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 86, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL; @@ -2263,7 +2562,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py __Pyx_INCREF(__pyx_v_timeout); __Pyx_GIVEREF(__pyx_v_timeout); PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_4, __pyx_v_timeout); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } @@ -2272,7 +2571,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/utils.pyx":73 + /* "ssh2/utils.pyx":100 * * * def wait_socket(_socket not None, Session session, timeout=1): # <<<<<<<<<<<<<< @@ -2296,7 +2595,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py return __pyx_r; } -/* "ssh2/utils.pyx":89 +/* "ssh2/utils.pyx":116 * * * cpdef int handle_error_codes(int errcode) except -1: # <<<<<<<<<<<<<< @@ -2304,7 +2603,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_4wait_socket(CYTHON_UNUSED PyObject *__py * */ -static PyObject *__pyx_pw_4ssh2_5utils_7handle_error_codes(PyObject *__pyx_self, PyObject *__pyx_arg_errcode); /*proto*/ +static PyObject *__pyx_pw_4ssh2_5utils_9handle_error_codes(PyObject *__pyx_self, PyObject *__pyx_arg_errcode); /*proto*/ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_UNUSED int __pyx_skip_dispatch) { int __pyx_r; __Pyx_RefNannyDeclarations @@ -2320,7 +2619,7 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U int __pyx_clineno = 0; __Pyx_RefNannySetupContext("handle_error_codes", 0); - /* "ssh2/utils.pyx":100 + /* "ssh2/utils.pyx":127 * """ * # Cython generates a C switch from this code - only use equality checks * if errcode == 0: # <<<<<<<<<<<<<< @@ -2330,7 +2629,7 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U switch (__pyx_v_errcode) { case 0: - /* "ssh2/utils.pyx":101 + /* "ssh2/utils.pyx":128 * # Cython generates a C switch from this code - only use equality checks * if errcode == 0: * return 0 # <<<<<<<<<<<<<< @@ -2340,7 +2639,7 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U __pyx_r = 0; goto __pyx_L0; - /* "ssh2/utils.pyx":100 + /* "ssh2/utils.pyx":127 * """ * # Cython generates a C switch from this code - only use equality checks * if errcode == 0: # <<<<<<<<<<<<<< @@ -2350,7 +2649,7 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_EAGAIN: - /* "ssh2/utils.pyx":103 + /* "ssh2/utils.pyx":130 * return 0 * elif errcode == error_codes._LIBSSH2_ERROR_EAGAIN: * return errcode # <<<<<<<<<<<<<< @@ -2360,7 +2659,7 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U __pyx_r = __pyx_v_errcode; goto __pyx_L0; - /* "ssh2/utils.pyx":102 + /* "ssh2/utils.pyx":129 * if errcode == 0: * return 0 * elif errcode == error_codes._LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< @@ -2370,23 +2669,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_SOCKET_NONE: - /* "ssh2/utils.pyx":105 + /* "ssh2/utils.pyx":132 * return errcode * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_NONE: * raise exceptions.SSH2Error # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_BANNER_RECV: * raise exceptions.BannerRecvError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 132, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_SSH2Error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 105, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_SSH2Error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 132, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 105, __pyx_L1_error) + __PYX_ERR(0, 132, __pyx_L1_error) - /* "ssh2/utils.pyx":104 + /* "ssh2/utils.pyx":131 * elif errcode == error_codes._LIBSSH2_ERROR_EAGAIN: * return errcode * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_NONE: # <<<<<<<<<<<<<< @@ -2396,23 +2695,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_BANNER_RECV: - /* "ssh2/utils.pyx":107 + /* "ssh2/utils.pyx":134 * raise exceptions.SSH2Error * elif errcode == error_codes._LIBSSH2_ERROR_BANNER_RECV: * raise exceptions.BannerRecvError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_BANNER_SEND: * raise exceptions.BannerSendError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_BannerRecvError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_BannerRecvError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 107, __pyx_L1_error) + __PYX_ERR(0, 134, __pyx_L1_error) - /* "ssh2/utils.pyx":106 + /* "ssh2/utils.pyx":133 * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_NONE: * raise exceptions.SSH2Error * elif errcode == error_codes._LIBSSH2_ERROR_BANNER_RECV: # <<<<<<<<<<<<<< @@ -2422,23 +2721,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_BANNER_SEND: - /* "ssh2/utils.pyx":109 + /* "ssh2/utils.pyx":136 * raise exceptions.BannerRecvError * elif errcode == error_codes._LIBSSH2_ERROR_BANNER_SEND: * raise exceptions.BannerSendError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE: * raise exceptions.KeyExchangeError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_BannerSendError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_BannerSendError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 109, __pyx_L1_error) + __PYX_ERR(0, 136, __pyx_L1_error) - /* "ssh2/utils.pyx":108 + /* "ssh2/utils.pyx":135 * elif errcode == error_codes._LIBSSH2_ERROR_BANNER_RECV: * raise exceptions.BannerRecvError * elif errcode == error_codes._LIBSSH2_ERROR_BANNER_SEND: # <<<<<<<<<<<<<< @@ -2448,23 +2747,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE: - /* "ssh2/utils.pyx":111 + /* "ssh2/utils.pyx":138 * raise exceptions.BannerSendError * elif errcode == error_codes._LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE: * raise exceptions.KeyExchangeError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_TIMEOUT: * raise exceptions.Timeout */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_KeyExchangeError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_KeyExchangeError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 111, __pyx_L1_error) + __PYX_ERR(0, 138, __pyx_L1_error) - /* "ssh2/utils.pyx":110 + /* "ssh2/utils.pyx":137 * elif errcode == error_codes._LIBSSH2_ERROR_BANNER_SEND: * raise exceptions.BannerSendError * elif errcode == error_codes._LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE: # <<<<<<<<<<<<<< @@ -2474,23 +2773,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_TIMEOUT: - /* "ssh2/utils.pyx":113 + /* "ssh2/utils.pyx":140 * raise exceptions.KeyExchangeError * elif errcode == error_codes._LIBSSH2_ERROR_TIMEOUT: * raise exceptions.Timeout # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_HOSTKEY_INIT: * raise exceptions.HostkeyInitError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Timeout); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 113, __pyx_L1_error) + __PYX_ERR(0, 140, __pyx_L1_error) - /* "ssh2/utils.pyx":112 + /* "ssh2/utils.pyx":139 * elif errcode == error_codes._LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE: * raise exceptions.KeyExchangeError * elif errcode == error_codes._LIBSSH2_ERROR_TIMEOUT: # <<<<<<<<<<<<<< @@ -2500,23 +2799,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_HOSTKEY_INIT: - /* "ssh2/utils.pyx":115 + /* "ssh2/utils.pyx":142 * raise exceptions.Timeout * elif errcode == error_codes._LIBSSH2_ERROR_HOSTKEY_INIT: * raise exceptions.HostkeyInitError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_HOSTKEY_SIGN: * raise exceptions.HostkeySignError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_HostkeyInitError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_HostkeyInitError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 115, __pyx_L1_error) + __PYX_ERR(0, 142, __pyx_L1_error) - /* "ssh2/utils.pyx":114 + /* "ssh2/utils.pyx":141 * elif errcode == error_codes._LIBSSH2_ERROR_TIMEOUT: * raise exceptions.Timeout * elif errcode == error_codes._LIBSSH2_ERROR_HOSTKEY_INIT: # <<<<<<<<<<<<<< @@ -2526,23 +2825,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_HOSTKEY_SIGN: - /* "ssh2/utils.pyx":117 + /* "ssh2/utils.pyx":144 * raise exceptions.HostkeyInitError * elif errcode == error_codes._LIBSSH2_ERROR_HOSTKEY_SIGN: * raise exceptions.HostkeySignError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_DECRYPT: * raise exceptions.DecryptError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_HostkeySignError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_HostkeySignError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 117, __pyx_L1_error) + __PYX_ERR(0, 144, __pyx_L1_error) - /* "ssh2/utils.pyx":116 + /* "ssh2/utils.pyx":143 * elif errcode == error_codes._LIBSSH2_ERROR_HOSTKEY_INIT: * raise exceptions.HostkeyInitError * elif errcode == error_codes._LIBSSH2_ERROR_HOSTKEY_SIGN: # <<<<<<<<<<<<<< @@ -2552,23 +2851,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_DECRYPT: - /* "ssh2/utils.pyx":119 + /* "ssh2/utils.pyx":146 * raise exceptions.HostkeySignError * elif errcode == error_codes._LIBSSH2_ERROR_DECRYPT: * raise exceptions.DecryptError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_DISCONNECT: * raise exceptions.SocketDisconnectError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_DecryptError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_DecryptError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 119, __pyx_L1_error) + __PYX_ERR(0, 146, __pyx_L1_error) - /* "ssh2/utils.pyx":118 + /* "ssh2/utils.pyx":145 * elif errcode == error_codes._LIBSSH2_ERROR_HOSTKEY_SIGN: * raise exceptions.HostkeySignError * elif errcode == error_codes._LIBSSH2_ERROR_DECRYPT: # <<<<<<<<<<<<<< @@ -2578,23 +2877,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_SOCKET_DISCONNECT: - /* "ssh2/utils.pyx":121 + /* "ssh2/utils.pyx":148 * raise exceptions.DecryptError * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_DISCONNECT: * raise exceptions.SocketDisconnectError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_PROTO: * raise exceptions.ProtocolError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_SocketDisconnectError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_SocketDisconnectError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 121, __pyx_L1_error) + __PYX_ERR(0, 148, __pyx_L1_error) - /* "ssh2/utils.pyx":120 + /* "ssh2/utils.pyx":147 * elif errcode == error_codes._LIBSSH2_ERROR_DECRYPT: * raise exceptions.DecryptError * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_DISCONNECT: # <<<<<<<<<<<<<< @@ -2604,23 +2903,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_PROTO: - /* "ssh2/utils.pyx":123 + /* "ssh2/utils.pyx":150 * raise exceptions.SocketDisconnectError * elif errcode == error_codes._LIBSSH2_ERROR_PROTO: * raise exceptions.ProtocolError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_PASSWORD_EXPIRED: * raise exceptions.PasswordExpiredError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 123, __pyx_L1_error) + __PYX_ERR(0, 150, __pyx_L1_error) - /* "ssh2/utils.pyx":122 + /* "ssh2/utils.pyx":149 * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_DISCONNECT: * raise exceptions.SocketDisconnectError * elif errcode == error_codes._LIBSSH2_ERROR_PROTO: # <<<<<<<<<<<<<< @@ -2630,23 +2929,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_PASSWORD_EXPIRED: - /* "ssh2/utils.pyx":125 + /* "ssh2/utils.pyx":152 * raise exceptions.ProtocolError * elif errcode == error_codes._LIBSSH2_ERROR_PASSWORD_EXPIRED: * raise exceptions.PasswordExpiredError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_FILE: * raise exceptions.FileError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_PasswordExpiredError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 125, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_PasswordExpiredError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 125, __pyx_L1_error) + __PYX_ERR(0, 152, __pyx_L1_error) - /* "ssh2/utils.pyx":124 + /* "ssh2/utils.pyx":151 * elif errcode == error_codes._LIBSSH2_ERROR_PROTO: * raise exceptions.ProtocolError * elif errcode == error_codes._LIBSSH2_ERROR_PASSWORD_EXPIRED: # <<<<<<<<<<<<<< @@ -2656,23 +2955,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_FILE: - /* "ssh2/utils.pyx":127 + /* "ssh2/utils.pyx":154 * raise exceptions.PasswordExpiredError * elif errcode == error_codes._LIBSSH2_ERROR_FILE: * raise exceptions.FileError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_METHOD_NONE: * raise exceptions.MethodNoneError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_FileError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_FileError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 127, __pyx_L1_error) + __PYX_ERR(0, 154, __pyx_L1_error) - /* "ssh2/utils.pyx":126 + /* "ssh2/utils.pyx":153 * elif errcode == error_codes._LIBSSH2_ERROR_PASSWORD_EXPIRED: * raise exceptions.PasswordExpiredError * elif errcode == error_codes._LIBSSH2_ERROR_FILE: # <<<<<<<<<<<<<< @@ -2682,23 +2981,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_METHOD_NONE: - /* "ssh2/utils.pyx":129 + /* "ssh2/utils.pyx":156 * raise exceptions.FileError * elif errcode == error_codes._LIBSSH2_ERROR_METHOD_NONE: * raise exceptions.MethodNoneError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_AUTHENTICATION_FAILED: * raise exceptions.AuthenticationError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_MethodNoneError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_MethodNoneError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 129, __pyx_L1_error) + __PYX_ERR(0, 156, __pyx_L1_error) - /* "ssh2/utils.pyx":128 + /* "ssh2/utils.pyx":155 * elif errcode == error_codes._LIBSSH2_ERROR_FILE: * raise exceptions.FileError * elif errcode == error_codes._LIBSSH2_ERROR_METHOD_NONE: # <<<<<<<<<<<<<< @@ -2708,23 +3007,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_AUTHENTICATION_FAILED: - /* "ssh2/utils.pyx":131 + /* "ssh2/utils.pyx":158 * raise exceptions.MethodNoneError * elif errcode == error_codes._LIBSSH2_ERROR_AUTHENTICATION_FAILED: * raise exceptions.AuthenticationError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED: * raise exceptions.PublickeyUnverifiedError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_AuthenticationError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_AuthenticationError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 131, __pyx_L1_error) + __PYX_ERR(0, 158, __pyx_L1_error) - /* "ssh2/utils.pyx":130 + /* "ssh2/utils.pyx":157 * elif errcode == error_codes._LIBSSH2_ERROR_METHOD_NONE: * raise exceptions.MethodNoneError * elif errcode == error_codes._LIBSSH2_ERROR_AUTHENTICATION_FAILED: # <<<<<<<<<<<<<< @@ -2734,23 +3033,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED: - /* "ssh2/utils.pyx":133 + /* "ssh2/utils.pyx":160 * raise exceptions.AuthenticationError * elif errcode == error_codes._LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED: * raise exceptions.PublickeyUnverifiedError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_OUTOFORDER: * raise exceptions.ChannelOutOfOrderError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_PublickeyUnverifiedError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_PublickeyUnverifiedError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 133, __pyx_L1_error) + __PYX_ERR(0, 160, __pyx_L1_error) - /* "ssh2/utils.pyx":132 + /* "ssh2/utils.pyx":159 * elif errcode == error_codes._LIBSSH2_ERROR_AUTHENTICATION_FAILED: * raise exceptions.AuthenticationError * elif errcode == error_codes._LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED: # <<<<<<<<<<<<<< @@ -2760,23 +3059,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_CHANNEL_OUTOFORDER: - /* "ssh2/utils.pyx":135 + /* "ssh2/utils.pyx":162 * raise exceptions.PublickeyUnverifiedError * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_OUTOFORDER: * raise exceptions.ChannelOutOfOrderError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_FAILURE: * raise exceptions.ChannelFailure */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ChannelOutOfOrderError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ChannelOutOfOrderError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 135, __pyx_L1_error) + __PYX_ERR(0, 162, __pyx_L1_error) - /* "ssh2/utils.pyx":134 + /* "ssh2/utils.pyx":161 * elif errcode == error_codes._LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED: * raise exceptions.PublickeyUnverifiedError * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_OUTOFORDER: # <<<<<<<<<<<<<< @@ -2786,23 +3085,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_CHANNEL_FAILURE: - /* "ssh2/utils.pyx":137 + /* "ssh2/utils.pyx":164 * raise exceptions.ChannelOutOfOrderError * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_FAILURE: * raise exceptions.ChannelFailure # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED: * raise exceptions.ChannelRequestDenied */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 164, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ChannelFailure); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ChannelFailure); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 164, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 137, __pyx_L1_error) + __PYX_ERR(0, 164, __pyx_L1_error) - /* "ssh2/utils.pyx":136 + /* "ssh2/utils.pyx":163 * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_OUTOFORDER: * raise exceptions.ChannelOutOfOrderError * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_FAILURE: # <<<<<<<<<<<<<< @@ -2812,23 +3111,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED: - /* "ssh2/utils.pyx":139 + /* "ssh2/utils.pyx":166 * raise exceptions.ChannelFailure * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED: * raise exceptions.ChannelRequestDenied # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_UNKNOWN: * raise exceptions.ChannelUnknownError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 166, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ChannelRequestDenied); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ChannelRequestDenied); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 139, __pyx_L1_error) + __PYX_ERR(0, 166, __pyx_L1_error) - /* "ssh2/utils.pyx":138 + /* "ssh2/utils.pyx":165 * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_FAILURE: * raise exceptions.ChannelFailure * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED: # <<<<<<<<<<<<<< @@ -2838,23 +3137,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_CHANNEL_UNKNOWN: - /* "ssh2/utils.pyx":141 + /* "ssh2/utils.pyx":168 * raise exceptions.ChannelRequestDenied * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_UNKNOWN: * raise exceptions.ChannelUnknownError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED: * raise exceptions.ChannelWindowExceeded */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ChannelUnknownError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ChannelUnknownError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 141, __pyx_L1_error) + __PYX_ERR(0, 168, __pyx_L1_error) - /* "ssh2/utils.pyx":140 + /* "ssh2/utils.pyx":167 * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED: * raise exceptions.ChannelRequestDenied * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_UNKNOWN: # <<<<<<<<<<<<<< @@ -2864,23 +3163,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED: - /* "ssh2/utils.pyx":143 + /* "ssh2/utils.pyx":170 * raise exceptions.ChannelUnknownError * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED: * raise exceptions.ChannelWindowExceeded # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED: * raise exceptions.ChannelPacketExceeded */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ChannelWindowExceeded); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ChannelWindowExceeded); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 143, __pyx_L1_error) + __PYX_ERR(0, 170, __pyx_L1_error) - /* "ssh2/utils.pyx":142 + /* "ssh2/utils.pyx":169 * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_UNKNOWN: * raise exceptions.ChannelUnknownError * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED: # <<<<<<<<<<<<<< @@ -2890,23 +3189,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED: - /* "ssh2/utils.pyx":145 + /* "ssh2/utils.pyx":172 * raise exceptions.ChannelWindowExceeded * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED: * raise exceptions.ChannelPacketExceeded # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_CLOSED: * raise exceptions.ChannelClosedError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ChannelPacketExceeded); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ChannelPacketExceeded); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 145, __pyx_L1_error) + __PYX_ERR(0, 172, __pyx_L1_error) - /* "ssh2/utils.pyx":144 + /* "ssh2/utils.pyx":171 * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED: * raise exceptions.ChannelWindowExceeded * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED: # <<<<<<<<<<<<<< @@ -2916,23 +3215,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_CHANNEL_CLOSED: - /* "ssh2/utils.pyx":147 + /* "ssh2/utils.pyx":174 * raise exceptions.ChannelPacketExceeded * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_CLOSED: * raise exceptions.ChannelClosedError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_EOF_SENT: * raise exceptions.ChannelEOFSentError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 174, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ChannelClosedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ChannelClosedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 147, __pyx_L1_error) + __PYX_ERR(0, 174, __pyx_L1_error) - /* "ssh2/utils.pyx":146 + /* "ssh2/utils.pyx":173 * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED: * raise exceptions.ChannelPacketExceeded * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_CLOSED: # <<<<<<<<<<<<<< @@ -2942,23 +3241,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_CHANNEL_EOF_SENT: - /* "ssh2/utils.pyx":149 + /* "ssh2/utils.pyx":176 * raise exceptions.ChannelClosedError * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_EOF_SENT: * raise exceptions.ChannelEOFSentError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_SCP_PROTOCOL: * raise exceptions.SCPProtocolError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ChannelEOFSentError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ChannelEOFSentError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 149, __pyx_L1_error) + __PYX_ERR(0, 176, __pyx_L1_error) - /* "ssh2/utils.pyx":148 + /* "ssh2/utils.pyx":175 * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_CLOSED: * raise exceptions.ChannelClosedError * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_EOF_SENT: # <<<<<<<<<<<<<< @@ -2968,23 +3267,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_SCP_PROTOCOL: - /* "ssh2/utils.pyx":151 + /* "ssh2/utils.pyx":178 * raise exceptions.ChannelEOFSentError * elif errcode == error_codes._LIBSSH2_ERROR_SCP_PROTOCOL: * raise exceptions.SCPProtocolError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_ZLIB: * raise exceptions.ZlibError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 151, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_SCPProtocolError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_SCPProtocolError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 151, __pyx_L1_error) + __PYX_ERR(0, 178, __pyx_L1_error) - /* "ssh2/utils.pyx":150 + /* "ssh2/utils.pyx":177 * elif errcode == error_codes._LIBSSH2_ERROR_CHANNEL_EOF_SENT: * raise exceptions.ChannelEOFSentError * elif errcode == error_codes._LIBSSH2_ERROR_SCP_PROTOCOL: # <<<<<<<<<<<<<< @@ -2994,23 +3293,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_ZLIB: - /* "ssh2/utils.pyx":153 + /* "ssh2/utils.pyx":180 * raise exceptions.SCPProtocolError * elif errcode == error_codes._LIBSSH2_ERROR_ZLIB: * raise exceptions.ZlibError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_TIMEOUT: * raise exceptions.SocketTimeout */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ZlibError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ZlibError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 153, __pyx_L1_error) + __PYX_ERR(0, 180, __pyx_L1_error) - /* "ssh2/utils.pyx":152 + /* "ssh2/utils.pyx":179 * elif errcode == error_codes._LIBSSH2_ERROR_SCP_PROTOCOL: * raise exceptions.SCPProtocolError * elif errcode == error_codes._LIBSSH2_ERROR_ZLIB: # <<<<<<<<<<<<<< @@ -3020,23 +3319,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_SOCKET_TIMEOUT: - /* "ssh2/utils.pyx":155 + /* "ssh2/utils.pyx":182 * raise exceptions.ZlibError * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_TIMEOUT: * raise exceptions.SocketTimeout # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_SFTP_PROTOCOL: * raise exceptions.SFTPProtocolError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 155, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 182, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_SocketTimeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_SocketTimeout); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 182, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 155, __pyx_L1_error) + __PYX_ERR(0, 182, __pyx_L1_error) - /* "ssh2/utils.pyx":154 + /* "ssh2/utils.pyx":181 * elif errcode == error_codes._LIBSSH2_ERROR_ZLIB: * raise exceptions.ZlibError * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_TIMEOUT: # <<<<<<<<<<<<<< @@ -3046,23 +3345,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_SFTP_PROTOCOL: - /* "ssh2/utils.pyx":157 + /* "ssh2/utils.pyx":184 * raise exceptions.SocketTimeout * elif errcode == error_codes._LIBSSH2_ERROR_SFTP_PROTOCOL: * raise exceptions.SFTPProtocolError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_REQUEST_DENIED: * raise exceptions.RequestDeniedError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_SFTPProtocolError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_SFTPProtocolError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 157, __pyx_L1_error) + __PYX_ERR(0, 184, __pyx_L1_error) - /* "ssh2/utils.pyx":156 + /* "ssh2/utils.pyx":183 * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_TIMEOUT: * raise exceptions.SocketTimeout * elif errcode == error_codes._LIBSSH2_ERROR_SFTP_PROTOCOL: # <<<<<<<<<<<<<< @@ -3072,23 +3371,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_REQUEST_DENIED: - /* "ssh2/utils.pyx":159 + /* "ssh2/utils.pyx":186 * raise exceptions.SFTPProtocolError * elif errcode == error_codes._LIBSSH2_ERROR_REQUEST_DENIED: * raise exceptions.RequestDeniedError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_METHOD_NOT_SUPPORTED: * raise exceptions.MethodNotSupported */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_RequestDeniedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_RequestDeniedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 159, __pyx_L1_error) + __PYX_ERR(0, 186, __pyx_L1_error) - /* "ssh2/utils.pyx":158 + /* "ssh2/utils.pyx":185 * elif errcode == error_codes._LIBSSH2_ERROR_SFTP_PROTOCOL: * raise exceptions.SFTPProtocolError * elif errcode == error_codes._LIBSSH2_ERROR_REQUEST_DENIED: # <<<<<<<<<<<<<< @@ -3098,23 +3397,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_METHOD_NOT_SUPPORTED: - /* "ssh2/utils.pyx":161 + /* "ssh2/utils.pyx":188 * raise exceptions.RequestDeniedError * elif errcode == error_codes._LIBSSH2_ERROR_METHOD_NOT_SUPPORTED: * raise exceptions.MethodNotSupported # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_INVAL: * raise exceptions.InvalidRequestError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_MethodNotSupported); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_MethodNotSupported); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 161, __pyx_L1_error) + __PYX_ERR(0, 188, __pyx_L1_error) - /* "ssh2/utils.pyx":160 + /* "ssh2/utils.pyx":187 * elif errcode == error_codes._LIBSSH2_ERROR_REQUEST_DENIED: * raise exceptions.RequestDeniedError * elif errcode == error_codes._LIBSSH2_ERROR_METHOD_NOT_SUPPORTED: # <<<<<<<<<<<<<< @@ -3124,23 +3423,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_INVAL: - /* "ssh2/utils.pyx":163 + /* "ssh2/utils.pyx":190 * raise exceptions.MethodNotSupported * elif errcode == error_codes._LIBSSH2_ERROR_INVAL: * raise exceptions.InvalidRequestError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_INVALID_POLL_TYPE: * raise exceptions.InvalidPollTypeError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_InvalidRequestError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_InvalidRequestError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 163, __pyx_L1_error) + __PYX_ERR(0, 190, __pyx_L1_error) - /* "ssh2/utils.pyx":162 + /* "ssh2/utils.pyx":189 * elif errcode == error_codes._LIBSSH2_ERROR_METHOD_NOT_SUPPORTED: * raise exceptions.MethodNotSupported * elif errcode == error_codes._LIBSSH2_ERROR_INVAL: # <<<<<<<<<<<<<< @@ -3150,23 +3449,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_INVALID_POLL_TYPE: - /* "ssh2/utils.pyx":165 + /* "ssh2/utils.pyx":192 * raise exceptions.InvalidRequestError * elif errcode == error_codes._LIBSSH2_ERROR_INVALID_POLL_TYPE: * raise exceptions.InvalidPollTypeError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_PUBLICKEY_PROTOCOL: * raise exceptions.PublicKeyProtocolError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_InvalidPollTypeError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 165, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_InvalidPollTypeError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 165, __pyx_L1_error) + __PYX_ERR(0, 192, __pyx_L1_error) - /* "ssh2/utils.pyx":164 + /* "ssh2/utils.pyx":191 * elif errcode == error_codes._LIBSSH2_ERROR_INVAL: * raise exceptions.InvalidRequestError * elif errcode == error_codes._LIBSSH2_ERROR_INVALID_POLL_TYPE: # <<<<<<<<<<<<<< @@ -3176,23 +3475,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_PUBLICKEY_PROTOCOL: - /* "ssh2/utils.pyx":167 + /* "ssh2/utils.pyx":194 * raise exceptions.InvalidPollTypeError * elif errcode == error_codes._LIBSSH2_ERROR_PUBLICKEY_PROTOCOL: * raise exceptions.PublicKeyProtocolError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_BUFFER_TOO_SMALL: * raise exceptions.BufferTooSmallError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 167, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_PublicKeyProtocolError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_PublicKeyProtocolError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 167, __pyx_L1_error) + __PYX_ERR(0, 194, __pyx_L1_error) - /* "ssh2/utils.pyx":166 + /* "ssh2/utils.pyx":193 * elif errcode == error_codes._LIBSSH2_ERROR_INVALID_POLL_TYPE: * raise exceptions.InvalidPollTypeError * elif errcode == error_codes._LIBSSH2_ERROR_PUBLICKEY_PROTOCOL: # <<<<<<<<<<<<<< @@ -3202,23 +3501,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_BUFFER_TOO_SMALL: - /* "ssh2/utils.pyx":169 + /* "ssh2/utils.pyx":196 * raise exceptions.PublicKeyProtocolError * elif errcode == error_codes._LIBSSH2_ERROR_BUFFER_TOO_SMALL: * raise exceptions.BufferTooSmallError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_BAD_USE: * raise exceptions.BadUseError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_BufferTooSmallError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_BufferTooSmallError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 169, __pyx_L1_error) + __PYX_ERR(0, 196, __pyx_L1_error) - /* "ssh2/utils.pyx":168 + /* "ssh2/utils.pyx":195 * elif errcode == error_codes._LIBSSH2_ERROR_PUBLICKEY_PROTOCOL: * raise exceptions.PublicKeyProtocolError * elif errcode == error_codes._LIBSSH2_ERROR_BUFFER_TOO_SMALL: # <<<<<<<<<<<<<< @@ -3228,23 +3527,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_BAD_USE: - /* "ssh2/utils.pyx":171 + /* "ssh2/utils.pyx":198 * raise exceptions.BufferTooSmallError * elif errcode == error_codes._LIBSSH2_ERROR_BAD_USE: * raise exceptions.BadUseError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_COMPRESS: * raise exceptions.CompressError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 171, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_BadUseError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_BadUseError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 171, __pyx_L1_error) + __PYX_ERR(0, 198, __pyx_L1_error) - /* "ssh2/utils.pyx":170 + /* "ssh2/utils.pyx":197 * elif errcode == error_codes._LIBSSH2_ERROR_BUFFER_TOO_SMALL: * raise exceptions.BufferTooSmallError * elif errcode == error_codes._LIBSSH2_ERROR_BAD_USE: # <<<<<<<<<<<<<< @@ -3254,23 +3553,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_COMPRESS: - /* "ssh2/utils.pyx":173 + /* "ssh2/utils.pyx":200 * raise exceptions.BadUseError * elif errcode == error_codes._LIBSSH2_ERROR_COMPRESS: * raise exceptions.CompressError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_OUT_OF_BOUNDARY: * raise exceptions.OutOfBoundaryError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 173, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_CompressError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 173, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_CompressError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 200, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 173, __pyx_L1_error) + __PYX_ERR(0, 200, __pyx_L1_error) - /* "ssh2/utils.pyx":172 + /* "ssh2/utils.pyx":199 * elif errcode == error_codes._LIBSSH2_ERROR_BAD_USE: * raise exceptions.BadUseError * elif errcode == error_codes._LIBSSH2_ERROR_COMPRESS: # <<<<<<<<<<<<<< @@ -3280,23 +3579,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_OUT_OF_BOUNDARY: - /* "ssh2/utils.pyx":175 + /* "ssh2/utils.pyx":202 * raise exceptions.CompressError * elif errcode == error_codes._LIBSSH2_ERROR_OUT_OF_BOUNDARY: * raise exceptions.OutOfBoundaryError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_AGENT_PROTOCOL: * raise exceptions.AgentProtocolError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 175, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_OutOfBoundaryError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_OutOfBoundaryError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 175, __pyx_L1_error) + __PYX_ERR(0, 202, __pyx_L1_error) - /* "ssh2/utils.pyx":174 + /* "ssh2/utils.pyx":201 * elif errcode == error_codes._LIBSSH2_ERROR_COMPRESS: * raise exceptions.CompressError * elif errcode == error_codes._LIBSSH2_ERROR_OUT_OF_BOUNDARY: # <<<<<<<<<<<<<< @@ -3306,23 +3605,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_AGENT_PROTOCOL: - /* "ssh2/utils.pyx":177 + /* "ssh2/utils.pyx":204 * raise exceptions.OutOfBoundaryError * elif errcode == error_codes._LIBSSH2_ERROR_AGENT_PROTOCOL: * raise exceptions.AgentProtocolError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_RECV: * raise exceptions.SocketRecvError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_AgentProtocolError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_AgentProtocolError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 177, __pyx_L1_error) + __PYX_ERR(0, 204, __pyx_L1_error) - /* "ssh2/utils.pyx":176 + /* "ssh2/utils.pyx":203 * elif errcode == error_codes._LIBSSH2_ERROR_OUT_OF_BOUNDARY: * raise exceptions.OutOfBoundaryError * elif errcode == error_codes._LIBSSH2_ERROR_AGENT_PROTOCOL: # <<<<<<<<<<<<<< @@ -3332,23 +3631,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_SOCKET_RECV: - /* "ssh2/utils.pyx":179 + /* "ssh2/utils.pyx":206 * raise exceptions.AgentProtocolError * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_RECV: * raise exceptions.SocketRecvError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_SEND: * raise exceptions.SocketSendError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_SocketRecvError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_SocketRecvError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 179, __pyx_L1_error) + __PYX_ERR(0, 206, __pyx_L1_error) - /* "ssh2/utils.pyx":178 + /* "ssh2/utils.pyx":205 * elif errcode == error_codes._LIBSSH2_ERROR_AGENT_PROTOCOL: * raise exceptions.AgentProtocolError * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_RECV: # <<<<<<<<<<<<<< @@ -3358,23 +3657,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_SOCKET_SEND: - /* "ssh2/utils.pyx":181 + /* "ssh2/utils.pyx":208 * raise exceptions.SocketRecvError * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_SEND: * raise exceptions.SocketSendError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_ENCRYPT: * raise exceptions.EncryptError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_SocketSendError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_SocketSendError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 181, __pyx_L1_error) + __PYX_ERR(0, 208, __pyx_L1_error) - /* "ssh2/utils.pyx":180 + /* "ssh2/utils.pyx":207 * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_RECV: * raise exceptions.SocketRecvError * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_SEND: # <<<<<<<<<<<<<< @@ -3384,23 +3683,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_ENCRYPT: - /* "ssh2/utils.pyx":183 + /* "ssh2/utils.pyx":210 * raise exceptions.SocketSendError * elif errcode == error_codes._LIBSSH2_ERROR_ENCRYPT: * raise exceptions.EncryptError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_BAD_SOCKET: * raise exceptions.BadSocketError */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 183, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 210, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_EncryptError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_EncryptError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 183, __pyx_L1_error) + __PYX_ERR(0, 210, __pyx_L1_error) - /* "ssh2/utils.pyx":182 + /* "ssh2/utils.pyx":209 * elif errcode == error_codes._LIBSSH2_ERROR_SOCKET_SEND: * raise exceptions.SocketSendError * elif errcode == error_codes._LIBSSH2_ERROR_ENCRYPT: # <<<<<<<<<<<<<< @@ -3410,23 +3709,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_BAD_SOCKET: - /* "ssh2/utils.pyx":185 + /* "ssh2/utils.pyx":212 * raise exceptions.EncryptError * elif errcode == error_codes._LIBSSH2_ERROR_BAD_SOCKET: * raise exceptions.BadSocketError # <<<<<<<<<<<<<< * elif errcode == error_codes._LIBSSH2_ERROR_KNOWN_HOSTS: * raise exceptions.KnownHostError */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_BadSocketError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 185, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_BadSocketError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 185, __pyx_L1_error) + __PYX_ERR(0, 212, __pyx_L1_error) - /* "ssh2/utils.pyx":184 + /* "ssh2/utils.pyx":211 * elif errcode == error_codes._LIBSSH2_ERROR_ENCRYPT: * raise exceptions.EncryptError * elif errcode == error_codes._LIBSSH2_ERROR_BAD_SOCKET: # <<<<<<<<<<<<<< @@ -3436,23 +3735,23 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; case LIBSSH2_ERROR_KNOWN_HOSTS: - /* "ssh2/utils.pyx":187 + /* "ssh2/utils.pyx":214 * raise exceptions.BadSocketError * elif errcode == error_codes._LIBSSH2_ERROR_KNOWN_HOSTS: * raise exceptions.KnownHostError # <<<<<<<<<<<<<< * else: * # Switch default */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 214, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_KnownHostError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_KnownHostError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 214, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 187, __pyx_L1_error) + __PYX_ERR(0, 214, __pyx_L1_error) - /* "ssh2/utils.pyx":186 + /* "ssh2/utils.pyx":213 * elif errcode == error_codes._LIBSSH2_ERROR_BAD_SOCKET: * raise exceptions.BadSocketError * elif errcode == error_codes._LIBSSH2_ERROR_KNOWN_HOSTS: # <<<<<<<<<<<<<< @@ -3462,7 +3761,7 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; default: - /* "ssh2/utils.pyx":190 + /* "ssh2/utils.pyx":217 * else: * # Switch default * if errcode < 0: # <<<<<<<<<<<<<< @@ -3472,18 +3771,18 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U __pyx_t_3 = ((__pyx_v_errcode < 0) != 0); if (unlikely(__pyx_t_3)) { - /* "ssh2/utils.pyx":191 + /* "ssh2/utils.pyx":218 * # Switch default * if errcode < 0: * raise exceptions.UnknownError("Error code %s not known", errcode) # <<<<<<<<<<<<<< * return errcode */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UnknownError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 191, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UnknownError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_errcode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_errcode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = NULL; __pyx_t_6 = 0; @@ -3500,7 +3799,7 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_Error_code_s_not_known, __pyx_t_2}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -3509,14 +3808,14 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_Error_code_s_not_known, __pyx_t_2}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { - __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 191, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 218, __pyx_L1_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; @@ -3527,16 +3826,16 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_2); __pyx_t_2 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_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, 191, __pyx_L1_error) + __PYX_ERR(0, 218, __pyx_L1_error) - /* "ssh2/utils.pyx":190 + /* "ssh2/utils.pyx":217 * else: * # Switch default * if errcode < 0: # <<<<<<<<<<<<<< @@ -3545,7 +3844,7 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U */ } - /* "ssh2/utils.pyx":192 + /* "ssh2/utils.pyx":219 * if errcode < 0: * raise exceptions.UnknownError("Error code %s not known", errcode) * return errcode # <<<<<<<<<<<<<< @@ -3555,7 +3854,7 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U break; } - /* "ssh2/utils.pyx":89 + /* "ssh2/utils.pyx":116 * * * cpdef int handle_error_codes(int errcode) except -1: # <<<<<<<<<<<<<< @@ -3578,9 +3877,9 @@ static int __pyx_f_4ssh2_5utils_handle_error_codes(int __pyx_v_errcode, CYTHON_U } /* Python wrapper */ -static PyObject *__pyx_pw_4ssh2_5utils_7handle_error_codes(PyObject *__pyx_self, PyObject *__pyx_arg_errcode); /*proto*/ -static char __pyx_doc_4ssh2_5utils_6handle_error_codes[] = "handle_error_codes(int errcode) -> int\nRaise appropriate exception for given error code.\n\n Returns 0 on no error and ``LIBSSH2_ERROR_EAGAIN`` on ``EAGAIN``.\n\n :raises: Appropriate exception from :py:mod:`ssh2.exceptions`.\n\n :param errcode: Error code as returned by\n :py:func:`ssh2.session.Session.last_errno`\n "; -static PyObject *__pyx_pw_4ssh2_5utils_7handle_error_codes(PyObject *__pyx_self, PyObject *__pyx_arg_errcode) { +static PyObject *__pyx_pw_4ssh2_5utils_9handle_error_codes(PyObject *__pyx_self, PyObject *__pyx_arg_errcode); /*proto*/ +static char __pyx_doc_4ssh2_5utils_8handle_error_codes[] = "handle_error_codes(int errcode) -> int\nRaise appropriate exception for given error code.\n\n Returns 0 on no error and ``LIBSSH2_ERROR_EAGAIN`` on ``EAGAIN``.\n\n :raises: Appropriate exception from :py:mod:`ssh2.exceptions`.\n\n :param errcode: Error code as returned by\n :py:func:`ssh2.session.Session.last_errno`\n "; +static PyObject *__pyx_pw_4ssh2_5utils_9handle_error_codes(PyObject *__pyx_self, PyObject *__pyx_arg_errcode) { int __pyx_v_errcode; int __pyx_lineno = 0; const char *__pyx_filename = NULL; @@ -3589,7 +3888,7 @@ static PyObject *__pyx_pw_4ssh2_5utils_7handle_error_codes(PyObject *__pyx_self, __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("handle_error_codes (wrapper)", 0); assert(__pyx_arg_errcode); { - __pyx_v_errcode = __Pyx_PyInt_As_int(__pyx_arg_errcode); if (unlikely((__pyx_v_errcode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 89, __pyx_L3_error) + __pyx_v_errcode = __Pyx_PyInt_As_int(__pyx_arg_errcode); if (unlikely((__pyx_v_errcode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 116, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -3597,14 +3896,14 @@ static PyObject *__pyx_pw_4ssh2_5utils_7handle_error_codes(PyObject *__pyx_self, __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_4ssh2_5utils_6handle_error_codes(__pyx_self, ((int)__pyx_v_errcode)); + __pyx_r = __pyx_pf_4ssh2_5utils_8handle_error_codes(__pyx_self, ((int)__pyx_v_errcode)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_4ssh2_5utils_6handle_error_codes(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_errcode) { +static PyObject *__pyx_pf_4ssh2_5utils_8handle_error_codes(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_errcode) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; @@ -3614,8 +3913,8 @@ static PyObject *__pyx_pf_4ssh2_5utils_6handle_error_codes(CYTHON_UNUSED PyObjec int __pyx_clineno = 0; __Pyx_RefNannySetupContext("handle_error_codes", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_errcode, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 89, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_errcode, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 116, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; @@ -3633,7 +3932,7 @@ static PyObject *__pyx_pf_4ssh2_5utils_6handle_error_codes(CYTHON_UNUSED PyObjec } static PyMethodDef __pyx_methods[] = { - {"handle_error_codes", (PyCFunction)__pyx_pw_4ssh2_5utils_7handle_error_codes, METH_O, __pyx_doc_4ssh2_5utils_6handle_error_codes}, + {"handle_error_codes", (PyCFunction)__pyx_pw_4ssh2_5utils_9handle_error_codes, METH_O, __pyx_doc_4ssh2_5utils_8handle_error_codes}, {0, 0, 0, 0} }; @@ -3725,14 +4024,22 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_UnknownError, __pyx_k_UnknownError, sizeof(__pyx_k_UnknownError), 0, 0, 1, 1}, {&__pyx_n_s_ZlibError, __pyx_k_ZlibError, sizeof(__pyx_k_ZlibError), 0, 0, 1, 1}, {&__pyx_n_s_block_directions, __pyx_k_block_directions, sizeof(__pyx_k_block_directions), 0, 0, 1, 1}, + {&__pyx_n_s_buf, __pyx_k_buf, sizeof(__pyx_k_buf), 0, 0, 1, 1}, + {&__pyx_n_s_buf_len, __pyx_k_buf_len, sizeof(__pyx_k_buf_len), 0, 0, 1, 1}, + {&__pyx_n_s_c_buf, __pyx_k_c_buf, sizeof(__pyx_k_c_buf), 0, 0, 1, 1}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, + {&__pyx_n_s_cur_buf, __pyx_k_cur_buf, sizeof(__pyx_k_cur_buf), 0, 0, 1, 1}, {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1}, {&__pyx_n_s_directions, __pyx_k_directions, sizeof(__pyx_k_directions), 0, 0, 1, 1}, {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, {&__pyx_n_s_exceptions, __pyx_k_exceptions, sizeof(__pyx_k_exceptions), 0, 0, 1, 1}, + {&__pyx_n_s_find_eol, __pyx_k_find_eol, sizeof(__pyx_k_find_eol), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, + {&__pyx_n_s_new_pos, __pyx_k_new_pos, sizeof(__pyx_k_new_pos), 0, 0, 1, 1}, + {&__pyx_n_s_pos, __pyx_k_pos, sizeof(__pyx_k_pos), 0, 0, 1, 1}, {&__pyx_n_s_readfds, __pyx_k_readfds, sizeof(__pyx_k_readfds), 0, 0, 1, 1}, {&__pyx_n_s_required_version, __pyx_k_required_version, sizeof(__pyx_k_required_version), 0, 0, 1, 1}, {&__pyx_n_s_select, __pyx_k_select, sizeof(__pyx_k_select), 0, 0, 1, 1}, @@ -3760,35 +4067,47 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { /* "ssh2/utils.pyx":51 * * + * def find_eol(bytes buf, Py_ssize_t pos): # <<<<<<<<<<<<<< + * """Find end-of-line in buffer from position and return end position of + * line and where next find_eol should start from. + */ + __pyx_tuple_ = PyTuple_Pack(7, __pyx_n_s_buf, __pyx_n_s_pos, __pyx_n_s_buf_len, __pyx_n_s_cur_buf, __pyx_n_s_c_buf, __pyx_n_s_index, __pyx_n_s_new_pos); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 51, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple_); + __Pyx_GIVEREF(__pyx_tuple_); + __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_ssh2_utils_pyx, __pyx_n_s_find_eol, 51, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 51, __pyx_L1_error) + + /* "ssh2/utils.pyx":78 + * + * * def version(int required_version=0): # <<<<<<<<<<<<<< * """Get libssh2 version string. * */ - __pyx_tuple_ = PyTuple_Pack(2, __pyx_n_s_required_version, __pyx_n_s_version); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 51, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple_); - __Pyx_GIVEREF(__pyx_tuple_); - __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_ssh2_utils_pyx, __pyx_n_s_version, 51, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 51, __pyx_L1_error) + __pyx_tuple__3 = PyTuple_Pack(2, __pyx_n_s_required_version, __pyx_n_s_version); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__3); + __Pyx_GIVEREF(__pyx_tuple__3); + __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_ssh2_utils_pyx, __pyx_n_s_version, 78, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 78, __pyx_L1_error) - /* "ssh2/utils.pyx":68 + /* "ssh2/utils.pyx":95 * * * def ssh2_exit(): # <<<<<<<<<<<<<< * """Call libssh2_exit""" * c_ssh2.libssh2_exit() */ - __pyx_codeobj__3 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_ssh2_utils_pyx, __pyx_n_s_ssh2_exit, 68, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 68, __pyx_L1_error) + __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_ssh2_utils_pyx, __pyx_n_s_ssh2_exit, 95, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 95, __pyx_L1_error) - /* "ssh2/utils.pyx":73 + /* "ssh2/utils.pyx":100 * * * def wait_socket(_socket not None, Session session, timeout=1): # <<<<<<<<<<<<<< * """Helper function for testing non-blocking mode. * */ - __pyx_tuple__4 = PyTuple_Pack(6, __pyx_n_s_socket, __pyx_n_s_session, __pyx_n_s_timeout, __pyx_n_s_directions, __pyx_n_s_readfds, __pyx_n_s_writefds); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); - __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(3, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_ssh2_utils_pyx, __pyx_n_s_wait_socket, 73, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 73, __pyx_L1_error) + __pyx_tuple__6 = PyTuple_Pack(6, __pyx_n_s_socket, __pyx_n_s_session, __pyx_n_s_timeout, __pyx_n_s_directions, __pyx_n_s_readfds, __pyx_n_s_writefds); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 100, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); + __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(3, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_ssh2_utils_pyx, __pyx_n_s_wait_socket, 100, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 100, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -3800,6 +4119,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; @@ -4140,43 +4460,55 @@ if (!__Pyx_RefNanny) { /* "ssh2/utils.pyx":51 * * + * def find_eol(bytes buf, Py_ssize_t pos): # <<<<<<<<<<<<<< + * """Find end-of-line in buffer from position and return end position of + * line and where next find_eol should start from. + */ + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4ssh2_5utils_1find_eol, NULL, __pyx_n_s_ssh2_utils); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_find_eol, __pyx_t_2) < 0) __PYX_ERR(0, 51, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "ssh2/utils.pyx":78 + * + * * def version(int required_version=0): # <<<<<<<<<<<<<< * """Get libssh2 version string. * */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4ssh2_5utils_1version, NULL, __pyx_n_s_ssh2_utils); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error) + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4ssh2_5utils_3version, NULL, __pyx_n_s_ssh2_utils); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_version, __pyx_t_2) < 0) __PYX_ERR(0, 51, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_version, __pyx_t_2) < 0) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "ssh2/utils.pyx":68 + /* "ssh2/utils.pyx":95 * * * def ssh2_exit(): # <<<<<<<<<<<<<< * """Call libssh2_exit""" * c_ssh2.libssh2_exit() */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4ssh2_5utils_3ssh2_exit, NULL, __pyx_n_s_ssh2_utils); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error) + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4ssh2_5utils_5ssh2_exit, NULL, __pyx_n_s_ssh2_utils); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_ssh2_exit, __pyx_t_2) < 0) __PYX_ERR(0, 68, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ssh2_exit, __pyx_t_2) < 0) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "ssh2/utils.pyx":73 + /* "ssh2/utils.pyx":100 * * * def wait_socket(_socket not None, Session session, timeout=1): # <<<<<<<<<<<<<< * """Helper function for testing non-blocking mode. * */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4ssh2_5utils_5wait_socket, NULL, __pyx_n_s_ssh2_utils); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error) + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4ssh2_5utils_7wait_socket, NULL, __pyx_n_s_ssh2_utils); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_wait_socket, __pyx_t_2) < 0) __PYX_ERR(0, 73, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_wait_socket, __pyx_t_2) < 0) __PYX_ERR(0, 100, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "ssh2/utils.pyx":1 * # This file is part of ssh2-python. # <<<<<<<<<<<<<< - * # Copyright (C) 2017-2018 Panos Kittenis - * + * # Copyright (C) 2017-2020 Panos Kittenis + * # */ __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); @@ -4566,6 +4898,32 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObjec } #endif +/* RaiseArgTupleInvalid */ +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + /* RaiseDoubleKeywords */ static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, @@ -4682,32 +5040,6 @@ static int __Pyx_ParseOptionalKeywords( return -1; } -/* RaiseArgTupleInvalid */ -static void __Pyx_RaiseArgtupleInvalid( - const char* func_name, - int exact, - Py_ssize_t num_min, - Py_ssize_t num_max, - Py_ssize_t num_found) -{ - Py_ssize_t num_expected; - const char *more_or_less; - if (num_found < num_min) { - num_expected = num_min; - more_or_less = "at least"; - } else { - num_expected = num_max; - more_or_less = "at most"; - } - if (exact) { - more_or_less = "exactly"; - } - PyErr_Format(PyExc_TypeError, - "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", - func_name, more_or_less, num_expected, - (num_expected == 1) ? "" : "s", num_found); -} - /* ArgTypeTest */ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { diff --git a/ssh2/utils.pxd b/ssh2/utils.pxd index 5b31f2df..68bb6821 100644 --- a/ssh2/utils.pxd +++ b/ssh2/utils.pxd @@ -1,3 +1,5 @@ +cdef extern from "find_eol.h" nogil: + int c_find_eol "find_eol" (char* data, int* new_pos) cdef bytes to_bytes(_str) cdef object to_str(char *c_str) cdef object to_str_len(char *c_str, int length) diff --git a/ssh2/utils.pyx b/ssh2/utils.pyx index c43e517e..052e18ea 100644 --- a/ssh2/utils.pyx +++ b/ssh2/utils.pyx @@ -1,15 +1,15 @@ # This file is part of ssh2-python. -# Copyright (C) 2017-2018 Panos Kittenis - +# Copyright (C) 2017-2020 Panos Kittenis +# # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation, version 2.1. - +# # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. - +# # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @@ -48,6 +48,33 @@ cdef object to_str_len(char *c_str, int length): return c_str[:length].decode(ENCODING) +def find_eol(bytes buf, Py_ssize_t pos): + """Find end-of-line in buffer from position and return end position of + line and where next find_eol should start from. + + Eg - find_eol(b'line\nline2', 0) would return (5, 6), next call should be + find_eol(b'line\nline2', 6) for next line where 6 was added to previous + position. + + :param buf: Data buffer to parse for line. + :type buf: bytes + :param pos: Starting position to parse from + :type pos: int + + :rtype: (int, int)""" + cdef Py_ssize_t buf_len = len(buf) + if buf_len == 0: + return -1, pos + cdef bytes cur_buf = buf[pos:buf_len] + cdef char* c_buf = cur_buf + cdef int index + cdef int new_pos + with nogil: + new_pos = 0 + index = c_find_eol(c_buf, &new_pos) + return index, new_pos + + def version(int required_version=0): """Get libssh2 version string. diff --git a/tests/test_channel.py b/tests/test_channel.py index 35e99890..9e616f9e 100644 --- a/tests/test_channel.py +++ b/tests/test_channel.py @@ -1,4 +1,7 @@ +import os + from unittest import skipUnless +from subprocess import check_output from .base_test import SSH2TestCase @@ -22,7 +25,7 @@ def test_execute(self): self.assertTrue(chan is not None) self.assertTrue(chan.execute(self.cmd) == 0) size, data = chan.read() - lines = [s.decode('utf-8') for s in data.splitlines()] + lines = [line.decode('utf-8') for line in data.splitlines()] self.assertTrue(size > 0) self.assertTrue(lines, [self.resp]) self.assertEqual(chan.wait_eof(), 0) @@ -54,7 +57,7 @@ def test_read_stderr(self): chan.execute('echo "stderr output" >&2') size, data = chan.read_stderr() self.assertTrue(size > 0) - lines = [s.decode('utf-8') for s in data.splitlines()] + lines = [line.decode('utf-8') for line in data.splitlines()] self.assertListEqual(expected, lines) def test_pty(self): @@ -67,7 +70,7 @@ def test_pty(self): # stderr output gets redirected to stdout with a PTY size, data = chan.read() self.assertTrue(size > 0) - lines = [s.decode('utf-8') for s in data.splitlines()] + lines = [line.decode('utf-8') for line in data.splitlines()] self.assertListEqual(expected, lines) def test_pty_failure(self): @@ -85,7 +88,7 @@ def test_write_stdin(self): self.assertEqual(chan.send_eof(), 0) size, data = chan.read() self.assertTrue(size > 0) - lines = [s.decode('utf-8') for s in data.splitlines()] + lines = [line.decode('utf-8') for line in data.splitlines()] self.assertListEqual([_in], lines) chan.close() self.assertEqual(chan.wait_eof(), 0) @@ -101,7 +104,7 @@ def test_write_ex(self): self.assertEqual(chan.send_eof(), 0) size, data = chan.read() self.assertTrue(size > 0) - lines = [s.decode('utf-8') for s in data.splitlines()] + lines = [line.decode('utf-8') for line in data.splitlines()] self.assertListEqual([_in], lines) def test_write_stderr(self): @@ -131,7 +134,7 @@ def test_shell(self): self.assertEqual(chan.shell(), 0) chan.write('echo me\n') size, data = chan.read() - lines = [s.decode('utf-8') for s in data.splitlines()] + lines = [line.decode('utf-8') for line in data.splitlines()] self.assertTrue(size > 0) self.assertTrue(lines, [self.resp]) self.assertTrue(chan.close() == 0) @@ -145,7 +148,7 @@ def test_process_startup(self): self.assertEqual(chan.process_startup('shell'), 0) chan.write('echo me\n') size, data = chan.read() - lines = [s.decode('utf-8') for s in data.splitlines()] + lines = [line.decode('utf-8') for line in data.splitlines()] self.assertTrue(size > 0) self.assertTrue(lines, [self.resp]) self.assertTrue(chan.close() == 0) @@ -155,7 +158,7 @@ def test_process_startup(self): self.assertTrue(chan is not None) self.assertEqual(chan.process_startup('exec', self.cmd), 0) size, data = chan.read() - lines = [s.decode('utf-8') for s in data.splitlines()] + lines = [line.decode('utf-8') for line in data.splitlines()] self.assertTrue(size > 0) self.assertTrue(lines, [self.resp]) self.assertTrue(chan.close() == 0) @@ -167,3 +170,19 @@ def test_agent_forwarding(self): self.assertEqual(self._auth(), 0) chan = self.session.open_session() self.assertEqual(chan.request_auth_agent(), 0) + + def test_read_file(self): + self._auth() + wc_output = check_output(['wc', '-l', 'ssh2/sftp_handle.c']).split()[0] + abs_file = os.sep.join([ + os.path.dirname(__file__), '..', 'ssh2', 'sftp_handle.c', + ]) + chan = self.session.open_session() + chan.execute('cat %s' % (abs_file,)) + tot_data = b"" + size, data = chan.read() + while size > 0: + tot_data += data + size, data = chan.read() + lines = [line for line in tot_data.splitlines()] + self.assertEqual(len(lines), int(wc_output)) diff --git a/tests/test_utils.py b/tests/test_utils.py new file mode 100644 index 00000000..34b1601c --- /dev/null +++ b/tests/test_utils.py @@ -0,0 +1,71 @@ +import unittest + +from ssh2.utils import find_eol + +class UtilsTest(unittest.TestCase): + + def test_find_eol_no_lines(self): + buf = b"a buffer" + linepos, new_line_pos = find_eol(buf, 0) + self.assertEqual(linepos, -1) + self.assertEqual(new_line_pos, 0) + + def test_read_line(self): + lines = [b'a line', b'another line', b'third'] + buf = b"\n".join(lines) + pos = 0 + line_num = 0 + linesep, new_line_pos = find_eol(buf, 0) + self.assertTrue(linesep > 0) + self.assertTrue(linesep < len(buf)) + while pos < len(buf): + if linesep < 0: + break + end_of_line = pos + linesep + line = buf[pos:end_of_line] + self.assertEqual(lines[line_num], line) + pos += linesep + new_line_pos + line_num += 1 + linesep, new_line_pos = find_eol(buf, pos) + line = buf[pos:] + self.assertEqual(lines[line_num], line) + + def test_read_line_crnl(self): + lines = [b'a line', b'another line', b'third'] + buf = b"\r\n".join(lines) + pos = 0 + line_num = 0 + linesep, new_line_pos = find_eol(buf, 0) + self.assertTrue(linesep > 0) + self.assertTrue(linesep < len(buf)) + while pos < len(buf): + if linesep < 0: + break + end_of_line = pos + linesep + line = buf[pos:end_of_line] + self.assertEqual(lines[line_num], line) + pos += linesep + new_line_pos + line_num += 1 + linesep, new_line_pos = find_eol(buf, pos) + line = buf[pos:] + self.assertEqual(lines[line_num], line) + + def test_read_line_cr_only(self): + lines = [b'a line', b'another line', b'third'] + buf = b"\r".join(lines) + linesep, new_line_pos = find_eol(buf, 0) + self.assertEqual(linesep, -1) + + def test_read_line_bad_data(self): + linesep, new_line_pos = find_eol(b"", 0) + self.assertEqual(linesep, -1) + self.assertEqual(new_line_pos, 0) + linesep, new_line_pos = find_eol(b'\n', 0) + self.assertEqual(linesep, 0) + self.assertEqual(new_line_pos, 1) + linesep, new_line_pos = find_eol(b'\r\n', 0) + self.assertEqual(linesep, 0) + self.assertEqual(new_line_pos, 2) + linesep, new_line_pos = find_eol(b'\r', 0) + self.assertEqual(linesep, -1) + self.assertEqual(new_line_pos, 0)