From 5ebdd893d622f68740cae288691747ef5d05a924 Mon Sep 17 00:00:00 2001 From: Pan Date: Thu, 1 Nov 2018 18:16:13 +0000 Subject: [PATCH] Handle EAGAIN for channel and sftp writes correctly and return rc, bytes_written tuple so clients can resume from last written byte on next call to write. Updated docstrings for channel write functions, tests, travis cfg, flake8 configuration for sftp. --- .travis.yml | 1 - Changelog.rst | 11 + ssh2/channel.c | 1036 ++++++++++++++++++++++++++++++++--------- ssh2/channel.pyx | 128 ++++- ssh2/sftp.c | 512 ++++++++++---------- ssh2/sftp.pyx | 4 +- ssh2/sftp_handle.c | 596 +++++++++++++++--------- ssh2/sftp_handle.pyx | 28 +- tests/test_channel.py | 9 +- 9 files changed, 1594 insertions(+), 731 deletions(-) diff --git a/.travis.yml b/.travis.yml index ae6ef129..dcbe06ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,6 @@ install: - python setup.py build_ext --inplace - eval "$(ssh-agent -s)" script: - - export LD_LIBRARY_PATH=/usr/local/lib/x86_64-linux-gnu - nosetests - flake8 ssh2 # Test source distribution builds diff --git a/Changelog.rst b/Changelog.rst index aae7f66e..0c3713aa 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -1,6 +1,17 @@ Change Log ============= +0.17.0 ++++++++ + +Changes +-------- + +* ``SFTPHandle.write`` function changed to return tuple of ``return_code, bytes_written`` for non-blocking applications to be able to handle partial writes within an SFTP write resulting from a blocked socket. +* ``Channel.write*`` functions changed to return tuple of ``return_code, bytes_written`` as above. + +Behaviour in blocking mode has not changed. Non-blocking applications will now need to handle these functions returning a tuple and resume writes from last written offset of given data. + 0.16.0 +++++++ diff --git a/ssh2/channel.c b/ssh2/channel.c index 4aec88ff..ba8c71bf 100644 --- a/ssh2/channel.c +++ b/ssh2/channel.c @@ -5346,13 +5346,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_50receive_window_adjust2(struc * return handle_error_codes(rc) * * def write(self, buf not None): # <<<<<<<<<<<<<< - * """Write buffer to stdin + * """Write buffer to stdin. * */ /* Python wrapper */ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_53write(PyObject *__pyx_v_self, PyObject *__pyx_v_buf); /*proto*/ -static char __pyx_doc_4ssh2_7channel_7Channel_52write[] = "Channel.write(self, buf)\nWrite buffer to stdin\n\n :param buf: Buffer to write\n :type buf: str\n\n :rtype: int"; +static char __pyx_doc_4ssh2_7channel_7Channel_52write[] = "Channel.write(self, buf)\nWrite buffer to stdin.\n\n Returns tuple of (``return_code``, ``bytes_written``).\n\n In blocking mode ``bytes_written`` will always equal ``len(buf)`` if no\n errors have occurred which would raise exception.\n\n In non-blocking mode ``return_code`` can be LIBSSH2_ERROR_EAGAIN and\n ``bytes_written`` *can be less than* ``len(buf)``.\n\n Clients should resume from that point on next call to ``write``, ie\n ``buf[bytes_written_in_last_call:]``.\n\n .. note::\n While this function handles unicode strings for ``buf``\n argument, ``bytes_written`` offset will always be for the *bytes*\n representation thereof as returned by the C function calls which only\n handle byte strings.\n\n :param buf: Buffer to write\n :type buf: str\n\n :rtype: tuple(int, int)\n "; static PyObject *__pyx_pw_4ssh2_7channel_7Channel_53write(PyObject *__pyx_v_self, PyObject *__pyx_v_buf) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -5374,62 +5374,86 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_53write(PyObject *__pyx_v_self static PyObject *__pyx_pf_4ssh2_7channel_7Channel_52write(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, PyObject *__pyx_v_buf) { PyObject *__pyx_v_b_buf = 0; char const *__pyx_v__buf; - size_t __pyx_v_buflen; + size_t __pyx_v_buf_remainder; + size_t __pyx_v_buf_tot_size; Py_ssize_t __pyx_v_rc; + size_t __pyx_v_bytes_written; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; char const *__pyx_t_2; Py_ssize_t __pyx_t_3; int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("write", 0); - /* "ssh2/channel.pyx":354 - * - * :rtype: int""" + /* "ssh2/channel.pyx":372 + * :rtype: tuple(int, int) + * """ * cdef bytes b_buf = to_bytes(buf) # <<<<<<<<<<<<<< * cdef const char *_buf = b_buf - * cdef size_t buflen = len(b_buf) + * cdef size_t buf_remainder = len(b_buf) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 354, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_buf = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/channel.pyx":355 - * :rtype: int""" + /* "ssh2/channel.pyx":373 + * """ * cdef bytes b_buf = to_bytes(buf) * cdef const char *_buf = b_buf # <<<<<<<<<<<<<< - * cdef size_t buflen = len(b_buf) - * cdef ssize_t rc + * cdef size_t buf_remainder = len(b_buf) + * cdef size_t buf_tot_size = buf_remainder */ if (unlikely(__pyx_v_b_buf == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 355, __pyx_L1_error) + __PYX_ERR(0, 373, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 355, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 373, __pyx_L1_error) __pyx_v__buf = __pyx_t_2; - /* "ssh2/channel.pyx":356 + /* "ssh2/channel.pyx":374 * cdef bytes b_buf = to_bytes(buf) * cdef const char *_buf = b_buf - * cdef size_t buflen = len(b_buf) # <<<<<<<<<<<<<< + * cdef size_t buf_remainder = len(b_buf) # <<<<<<<<<<<<<< + * cdef size_t buf_tot_size = buf_remainder * cdef ssize_t rc - * with nogil: */ if (unlikely(__pyx_v_b_buf == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 356, __pyx_L1_error) + __PYX_ERR(0, 374, __pyx_L1_error) } - __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_buf); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 356, __pyx_L1_error) - __pyx_v_buflen = __pyx_t_3; + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_buf); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 374, __pyx_L1_error) + __pyx_v_buf_remainder = __pyx_t_3; - /* "ssh2/channel.pyx":358 - * cdef size_t buflen = len(b_buf) + /* "ssh2/channel.pyx":375 + * cdef const char *_buf = b_buf + * cdef size_t buf_remainder = len(b_buf) + * cdef size_t buf_tot_size = buf_remainder # <<<<<<<<<<<<<< + * cdef ssize_t rc + * cdef size_t bytes_written = 0 + */ + __pyx_v_buf_tot_size = __pyx_v_buf_remainder; + + /* "ssh2/channel.pyx":377 + * cdef size_t buf_tot_size = buf_remainder + * cdef ssize_t rc + * cdef size_t bytes_written = 0 # <<<<<<<<<<<<<< + * with nogil: + * while buf_remainder > 0: + */ + __pyx_v_bytes_written = 0; + + /* "ssh2/channel.pyx":378 * cdef ssize_t rc + * cdef size_t bytes_written = 0 * with nogil: # <<<<<<<<<<<<<< - * rc = c_ssh2.libssh2_channel_write(self._channel, _buf, buflen) - * return handle_error_codes(rc) + * while buf_remainder > 0: + * rc = c_ssh2.libssh2_channel_write( */ { #ifdef WITH_THREAD @@ -5439,22 +5463,169 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_52write(struct __pyx_obj_4ssh2 #endif /*try:*/ { - /* "ssh2/channel.pyx":359 - * cdef ssize_t rc + /* "ssh2/channel.pyx":379 + * cdef size_t bytes_written = 0 * with nogil: - * rc = c_ssh2.libssh2_channel_write(self._channel, _buf, buflen) # <<<<<<<<<<<<<< - * return handle_error_codes(rc) + * while buf_remainder > 0: # <<<<<<<<<<<<<< + * rc = c_ssh2.libssh2_channel_write( + * self._channel, _buf, buf_remainder) + */ + while (1) { + __pyx_t_4 = ((__pyx_v_buf_remainder > 0) != 0); + if (!__pyx_t_4) break; + + /* "ssh2/channel.pyx":380 + * with nogil: + * while buf_remainder > 0: + * rc = c_ssh2.libssh2_channel_write( # <<<<<<<<<<<<<< + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + */ + __pyx_v_rc = libssh2_channel_write(__pyx_v_self->_channel, __pyx_v__buf, __pyx_v_buf_remainder); + + /* "ssh2/channel.pyx":382 + * rc = c_ssh2.libssh2_channel_write( + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * # Error that will raise exception + * with gil: + */ + __pyx_t_5 = ((__pyx_v_rc < 0) != 0); + if (__pyx_t_5) { + } else { + __pyx_t_4 = __pyx_t_5; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_5 = ((__pyx_v_rc != LIBSSH2_ERROR_EAGAIN) != 0); + __pyx_t_4 = __pyx_t_5; + __pyx_L9_bool_binop_done:; + if (__pyx_t_4) { + + /* "ssh2/channel.pyx":384 + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * # Error that will raise exception + * with gil: # <<<<<<<<<<<<<< + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + */ + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + /*try:*/ { + + /* "ssh2/channel.pyx":385 + * # Error that will raise exception + * with gil: + * return handle_error_codes(rc) # <<<<<<<<<<<<<< + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + * break + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_6 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 385, __pyx_L14_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L14_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L13_return; + } + + /* "ssh2/channel.pyx":384 + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * # Error that will raise exception + * with gil: # <<<<<<<<<<<<<< + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + */ + /*finally:*/ { + __pyx_L13_return: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L3_return; + } + __pyx_L14_error: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L4_error; + } + } + } + + /* "ssh2/channel.pyx":382 + * rc = c_ssh2.libssh2_channel_write( + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * # Error that will raise exception + * with gil: + */ + } + + /* "ssh2/channel.pyx":386 + * with gil: + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * break + * _buf += rc + */ + __pyx_t_4 = ((__pyx_v_rc == LIBSSH2_ERROR_EAGAIN) != 0); + if (__pyx_t_4) { + + /* "ssh2/channel.pyx":387 + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + * break # <<<<<<<<<<<<<< + * _buf += rc + * buf_remainder -= rc + */ + goto __pyx_L7_break; + + /* "ssh2/channel.pyx":386 + * with gil: + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * break + * _buf += rc + */ + } + + /* "ssh2/channel.pyx":388 + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + * break + * _buf += rc # <<<<<<<<<<<<<< + * buf_remainder -= rc + * bytes_written = buf_tot_size - buf_remainder + */ + __pyx_v__buf = (__pyx_v__buf + __pyx_v_rc); + + /* "ssh2/channel.pyx":389 + * break + * _buf += rc + * buf_remainder -= rc # <<<<<<<<<<<<<< + * bytes_written = buf_tot_size - buf_remainder + * return rc, bytes_written + */ + __pyx_v_buf_remainder = (__pyx_v_buf_remainder - __pyx_v_rc); + } + __pyx_L7_break:; + + /* "ssh2/channel.pyx":390 + * _buf += rc + * buf_remainder -= rc + * bytes_written = buf_tot_size - buf_remainder # <<<<<<<<<<<<<< + * return rc, bytes_written * */ - __pyx_v_rc = libssh2_channel_write(__pyx_v_self->_channel, __pyx_v__buf, __pyx_v_buflen); + __pyx_v_bytes_written = (__pyx_v_buf_tot_size - __pyx_v_buf_remainder); } - /* "ssh2/channel.pyx":358 - * cdef size_t buflen = len(b_buf) + /* "ssh2/channel.pyx":378 * cdef ssize_t rc + * cdef size_t bytes_written = 0 * with nogil: # <<<<<<<<<<<<<< - * rc = c_ssh2.libssh2_channel_write(self._channel, _buf, buflen) - * return handle_error_codes(rc) + * while buf_remainder > 0: + * rc = c_ssh2.libssh2_channel_write( */ /*finally:*/ { /*normal exit:*/{ @@ -5464,36 +5635,61 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_52write(struct __pyx_obj_4ssh2 #endif goto __pyx_L5; } + __pyx_L3_return: { + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L0; + } + __pyx_L4_error: { + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L1_error; + } __pyx_L5:; } } - /* "ssh2/channel.pyx":360 - * with nogil: - * rc = c_ssh2.libssh2_channel_write(self._channel, _buf, buflen) - * return handle_error_codes(rc) # <<<<<<<<<<<<<< + /* "ssh2/channel.pyx":391 + * buf_remainder -= rc + * bytes_written = buf_tot_size - buf_remainder + * return rc, bytes_written # <<<<<<<<<<<<<< * * def write_ex(self, int stream_id, buf not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 360, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error) + __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; + __pyx_t_7 = __Pyx_PyInt_FromSize_t(__pyx_v_bytes_written); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 391, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 391, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); __pyx_t_1 = 0; + __pyx_t_7 = 0; + __pyx_r = __pyx_t_8; + __pyx_t_8 = 0; goto __pyx_L0; /* "ssh2/channel.pyx":347 * return handle_error_codes(rc) * * def write(self, buf not None): # <<<<<<<<<<<<<< - * """Write buffer to stdin + * """Write buffer to stdin. * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("ssh2.channel.Channel.write", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -5503,8 +5699,8 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_52write(struct __pyx_obj_4ssh2 return __pyx_r; } -/* "ssh2/channel.pyx":362 - * return handle_error_codes(rc) +/* "ssh2/channel.pyx":393 + * return rc, bytes_written * * def write_ex(self, int stream_id, buf not None): # <<<<<<<<<<<<<< * """Write buffer to specified stream id. @@ -5513,7 +5709,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_52write(struct __pyx_obj_4ssh2 /* Python wrapper */ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_55write_ex(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_4ssh2_7channel_7Channel_54write_ex[] = "Channel.write_ex(self, int stream_id, buf)\nWrite buffer to specified stream id.\n\n :param stream_id: Id of stream to write to\n :type stream_id: int\n :param buf: Buffer to write\n :type buf: str\n\n :rtype: int"; +static char __pyx_doc_4ssh2_7channel_7Channel_54write_ex[] = "Channel.write_ex(self, int stream_id, buf)\nWrite buffer to specified stream id.\n\n Returns tuple of (``return_code``, ``bytes_written``).\n\n In blocking mode ``bytes_written`` will always equal ``len(buf)`` if no\n errors have occurred which would raise exception.\n\n In non-blocking mode ``return_code`` can be LIBSSH2_ERROR_EAGAIN and\n ``bytes_written`` *can be less than* ``len(buf)``.\n\n Clients should resume from that point on next call to the function, ie\n ``buf[bytes_written_in_last_call:]``.\n\n .. note::\n While this function handles unicode strings for ``buf``\n argument, ``bytes_written`` offset will always be for the *bytes*\n representation thereof as returned by the C function calls which only\n handle byte strings.\n\n :param stream_id: Id of stream to write to\n :type stream_id: int\n :param buf: Buffer to write\n :type buf: str\n\n :rtype: tuple(int, int)\n "; static PyObject *__pyx_pw_4ssh2_7channel_7Channel_55write_ex(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_stream_id; PyObject *__pyx_v_buf = 0; @@ -5543,11 +5739,11 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_55write_ex(PyObject *__pyx_v_s case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("write_ex", 1, 2, 2, 1); __PYX_ERR(0, 362, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("write_ex", 1, 2, 2, 1); __PYX_ERR(0, 393, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_ex") < 0)) __PYX_ERR(0, 362, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_ex") < 0)) __PYX_ERR(0, 393, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -5555,19 +5751,19 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_55write_ex(PyObject *__pyx_v_s values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } - __pyx_v_stream_id = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_stream_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 362, __pyx_L3_error) + __pyx_v_stream_id = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_stream_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 393, __pyx_L3_error) __pyx_v_buf = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("write_ex", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 362, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("write_ex", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 393, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.channel.Channel.write_ex", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_buf) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "buf"); __PYX_ERR(0, 362, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "buf"); __PYX_ERR(0, 393, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_54write_ex(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self), __pyx_v_stream_id, __pyx_v_buf); @@ -5583,62 +5779,86 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_55write_ex(PyObject *__pyx_v_s static PyObject *__pyx_pf_4ssh2_7channel_7Channel_54write_ex(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, int __pyx_v_stream_id, PyObject *__pyx_v_buf) { PyObject *__pyx_v_b_buf = 0; char const *__pyx_v__buf; - size_t __pyx_v_buflen; + size_t __pyx_v_buf_remainder; + size_t __pyx_v_buf_tot_size; Py_ssize_t __pyx_v_rc; + size_t __pyx_v_bytes_written; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; char const *__pyx_t_2; Py_ssize_t __pyx_t_3; int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("write_ex", 0); - /* "ssh2/channel.pyx":371 - * - * :rtype: int""" + /* "ssh2/channel.pyx":420 + * :rtype: tuple(int, int) + * """ * cdef bytes b_buf = to_bytes(buf) # <<<<<<<<<<<<<< * cdef const char *_buf = b_buf - * cdef size_t buflen = len(b_buf) + * cdef size_t buf_remainder = len(b_buf) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 371, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_buf = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/channel.pyx":372 - * :rtype: int""" + /* "ssh2/channel.pyx":421 + * """ * cdef bytes b_buf = to_bytes(buf) * cdef const char *_buf = b_buf # <<<<<<<<<<<<<< - * cdef size_t buflen = len(b_buf) - * cdef ssize_t rc + * cdef size_t buf_remainder = len(b_buf) + * cdef size_t buf_tot_size = buf_remainder */ if (unlikely(__pyx_v_b_buf == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 372, __pyx_L1_error) + __PYX_ERR(0, 421, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 372, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 421, __pyx_L1_error) __pyx_v__buf = __pyx_t_2; - /* "ssh2/channel.pyx":373 + /* "ssh2/channel.pyx":422 * cdef bytes b_buf = to_bytes(buf) * cdef const char *_buf = b_buf - * cdef size_t buflen = len(b_buf) # <<<<<<<<<<<<<< + * cdef size_t buf_remainder = len(b_buf) # <<<<<<<<<<<<<< + * cdef size_t buf_tot_size = buf_remainder * cdef ssize_t rc - * with nogil: */ if (unlikely(__pyx_v_b_buf == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 373, __pyx_L1_error) + __PYX_ERR(0, 422, __pyx_L1_error) } - __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_buf); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 373, __pyx_L1_error) - __pyx_v_buflen = __pyx_t_3; + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_buf); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_v_buf_remainder = __pyx_t_3; - /* "ssh2/channel.pyx":375 - * cdef size_t buflen = len(b_buf) + /* "ssh2/channel.pyx":423 + * cdef const char *_buf = b_buf + * cdef size_t buf_remainder = len(b_buf) + * cdef size_t buf_tot_size = buf_remainder # <<<<<<<<<<<<<< * cdef ssize_t rc + * cdef size_t bytes_written = 0 + */ + __pyx_v_buf_tot_size = __pyx_v_buf_remainder; + + /* "ssh2/channel.pyx":425 + * cdef size_t buf_tot_size = buf_remainder + * cdef ssize_t rc + * cdef size_t bytes_written = 0 # <<<<<<<<<<<<<< + * with nogil: + * # Write until buffer has been fully written or socket is blocked + */ + __pyx_v_bytes_written = 0; + + /* "ssh2/channel.pyx":426 + * cdef ssize_t rc + * cdef size_t bytes_written = 0 * with nogil: # <<<<<<<<<<<<<< - * rc = c_ssh2.libssh2_channel_write_ex( - * self._channel, stream_id, _buf, buflen) + * # Write until buffer has been fully written or socket is blocked + * while buf_remainder > 0: */ { #ifdef WITH_THREAD @@ -5648,22 +5868,169 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_54write_ex(struct __pyx_obj_4s #endif /*try:*/ { - /* "ssh2/channel.pyx":376 - * cdef ssize_t rc + /* "ssh2/channel.pyx":428 * with nogil: - * rc = c_ssh2.libssh2_channel_write_ex( # <<<<<<<<<<<<<< - * self._channel, stream_id, _buf, buflen) - * return handle_error_codes(rc) + * # Write until buffer has been fully written or socket is blocked + * while buf_remainder > 0: # <<<<<<<<<<<<<< + * rc = c_ssh2.libssh2_channel_write_ex( + * self._channel, stream_id, _buf, buf_remainder) + */ + while (1) { + __pyx_t_4 = ((__pyx_v_buf_remainder > 0) != 0); + if (!__pyx_t_4) break; + + /* "ssh2/channel.pyx":429 + * # Write until buffer has been fully written or socket is blocked + * while buf_remainder > 0: + * rc = c_ssh2.libssh2_channel_write_ex( # <<<<<<<<<<<<<< + * self._channel, stream_id, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + */ + __pyx_v_rc = libssh2_channel_write_ex(__pyx_v_self->_channel, __pyx_v_stream_id, __pyx_v__buf, __pyx_v_buf_remainder); + + /* "ssh2/channel.pyx":431 + * rc = c_ssh2.libssh2_channel_write_ex( + * self._channel, stream_id, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * # Error that will raise exception + * with gil: + */ + __pyx_t_5 = ((__pyx_v_rc < 0) != 0); + if (__pyx_t_5) { + } else { + __pyx_t_4 = __pyx_t_5; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_5 = ((__pyx_v_rc != LIBSSH2_ERROR_EAGAIN) != 0); + __pyx_t_4 = __pyx_t_5; + __pyx_L9_bool_binop_done:; + if (__pyx_t_4) { + + /* "ssh2/channel.pyx":433 + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * # Error that will raise exception + * with gil: # <<<<<<<<<<<<<< + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + */ + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + /*try:*/ { + + /* "ssh2/channel.pyx":434 + * # Error that will raise exception + * with gil: + * return handle_error_codes(rc) # <<<<<<<<<<<<<< + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + * break + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_6 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 434, __pyx_L14_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 434, __pyx_L14_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L13_return; + } + + /* "ssh2/channel.pyx":433 + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * # Error that will raise exception + * with gil: # <<<<<<<<<<<<<< + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + */ + /*finally:*/ { + __pyx_L13_return: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L3_return; + } + __pyx_L14_error: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L4_error; + } + } + } + + /* "ssh2/channel.pyx":431 + * rc = c_ssh2.libssh2_channel_write_ex( + * self._channel, stream_id, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * # Error that will raise exception + * with gil: + */ + } + + /* "ssh2/channel.pyx":435 + * with gil: + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * break + * _buf += rc + */ + __pyx_t_4 = ((__pyx_v_rc == LIBSSH2_ERROR_EAGAIN) != 0); + if (__pyx_t_4) { + + /* "ssh2/channel.pyx":436 + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + * break # <<<<<<<<<<<<<< + * _buf += rc + * buf_remainder -= rc + */ + goto __pyx_L7_break; + + /* "ssh2/channel.pyx":435 + * with gil: + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * break + * _buf += rc + */ + } + + /* "ssh2/channel.pyx":437 + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + * break + * _buf += rc # <<<<<<<<<<<<<< + * buf_remainder -= rc + * bytes_written = buf_tot_size - buf_remainder + */ + __pyx_v__buf = (__pyx_v__buf + __pyx_v_rc); + + /* "ssh2/channel.pyx":438 + * break + * _buf += rc + * buf_remainder -= rc # <<<<<<<<<<<<<< + * bytes_written = buf_tot_size - buf_remainder + * return rc, bytes_written + */ + __pyx_v_buf_remainder = (__pyx_v_buf_remainder - __pyx_v_rc); + } + __pyx_L7_break:; + + /* "ssh2/channel.pyx":439 + * _buf += rc + * buf_remainder -= rc + * bytes_written = buf_tot_size - buf_remainder # <<<<<<<<<<<<<< + * return rc, bytes_written + * */ - __pyx_v_rc = libssh2_channel_write_ex(__pyx_v_self->_channel, __pyx_v_stream_id, __pyx_v__buf, __pyx_v_buflen); + __pyx_v_bytes_written = (__pyx_v_buf_tot_size - __pyx_v_buf_remainder); } - /* "ssh2/channel.pyx":375 - * cdef size_t buflen = len(b_buf) + /* "ssh2/channel.pyx":426 * cdef ssize_t rc + * cdef size_t bytes_written = 0 * with nogil: # <<<<<<<<<<<<<< - * rc = c_ssh2.libssh2_channel_write_ex( - * self._channel, stream_id, _buf, buflen) + * # Write until buffer has been fully written or socket is blocked + * while buf_remainder > 0: */ /*finally:*/ { /*normal exit:*/{ @@ -5673,27 +6040,50 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_54write_ex(struct __pyx_obj_4s #endif goto __pyx_L5; } + __pyx_L3_return: { + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L0; + } + __pyx_L4_error: { + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L1_error; + } __pyx_L5:; } } - /* "ssh2/channel.pyx":378 - * rc = c_ssh2.libssh2_channel_write_ex( - * self._channel, stream_id, _buf, buflen) - * return handle_error_codes(rc) # <<<<<<<<<<<<<< + /* "ssh2/channel.pyx":440 + * buf_remainder -= rc + * bytes_written = buf_tot_size - buf_remainder + * return rc, bytes_written # <<<<<<<<<<<<<< * * def write_stderr(self, buf not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 378, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 378, __pyx_L1_error) + __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; + __pyx_t_7 = __Pyx_PyInt_FromSize_t(__pyx_v_bytes_written); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 440, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 440, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); __pyx_t_1 = 0; + __pyx_t_7 = 0; + __pyx_r = __pyx_t_8; + __pyx_t_8 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":362 - * return handle_error_codes(rc) + /* "ssh2/channel.pyx":393 + * return rc, bytes_written * * def write_ex(self, int stream_id, buf not None): # <<<<<<<<<<<<<< * """Write buffer to specified stream id. @@ -5703,6 +6093,8 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_54write_ex(struct __pyx_obj_4s /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("ssh2.channel.Channel.write_ex", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -5712,8 +6104,8 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_54write_ex(struct __pyx_obj_4s return __pyx_r; } -/* "ssh2/channel.pyx":380 - * return handle_error_codes(rc) +/* "ssh2/channel.pyx":442 + * return rc, bytes_written * * def write_stderr(self, buf not None): # <<<<<<<<<<<<<< * """Write buffer to stderr. @@ -5722,13 +6114,13 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_54write_ex(struct __pyx_obj_4s /* Python wrapper */ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_57write_stderr(PyObject *__pyx_v_self, PyObject *__pyx_v_buf); /*proto*/ -static char __pyx_doc_4ssh2_7channel_7Channel_56write_stderr[] = "Channel.write_stderr(self, buf)\nWrite buffer to stderr.\n\n :param buf: Buffer to write\n :type buf: str\n\n :rtype: int"; +static char __pyx_doc_4ssh2_7channel_7Channel_56write_stderr[] = "Channel.write_stderr(self, buf)\nWrite buffer to stderr.\n\n Returns tuple of (``return_code``, ``bytes_written``).\n\n In blocking mode ``bytes_written`` will always equal ``len(buf)`` if no\n errors have occurred which would raise exception.\n\n In non-blocking mode ``return_code`` can be LIBSSH2_ERROR_EAGAIN and\n ``bytes_written`` *can be less than* ``len(buf)``.\n\n Clients should resume from that point on next call to ``write``, ie\n ``buf[bytes_written_in_last_call:]``.\n\n .. note::\n While this function handles unicode strings for ``buf``\n argument, ``bytes_written`` offset will always be for the *bytes*\n representation thereof as returned by the C function calls which only\n handle byte strings.\n\n :param buf: Buffer to write\n :type buf: str\n\n :rtype: tuple(int, int)\n "; static PyObject *__pyx_pw_4ssh2_7channel_7Channel_57write_stderr(PyObject *__pyx_v_self, PyObject *__pyx_v_buf) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_stderr (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_buf) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "buf"); __PYX_ERR(0, 380, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "buf"); __PYX_ERR(0, 442, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_7channel_7Channel_56write_stderr(((struct __pyx_obj_4ssh2_7channel_Channel *)__pyx_v_self), ((PyObject *)__pyx_v_buf)); @@ -5744,62 +6136,86 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_57write_stderr(PyObject *__pyx static PyObject *__pyx_pf_4ssh2_7channel_7Channel_56write_stderr(struct __pyx_obj_4ssh2_7channel_Channel *__pyx_v_self, PyObject *__pyx_v_buf) { PyObject *__pyx_v_b_buf = 0; char const *__pyx_v__buf; - size_t __pyx_v_buflen; + size_t __pyx_v_buf_remainder; + size_t __pyx_v_buf_tot_size; Py_ssize_t __pyx_v_rc; + size_t __pyx_v_bytes_written; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; char const *__pyx_t_2; Py_ssize_t __pyx_t_3; int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("write_stderr", 0); - /* "ssh2/channel.pyx":387 - * - * :rtype: int""" + /* "ssh2/channel.pyx":467 + * :rtype: tuple(int, int) + * """ * cdef bytes b_buf = to_bytes(buf) # <<<<<<<<<<<<<< * cdef const char *_buf = b_buf - * cdef size_t buflen = len(b_buf) + * cdef size_t buf_remainder = len(b_buf) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 387, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_buf); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_buf = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/channel.pyx":388 - * :rtype: int""" + /* "ssh2/channel.pyx":468 + * """ * cdef bytes b_buf = to_bytes(buf) * cdef const char *_buf = b_buf # <<<<<<<<<<<<<< - * cdef size_t buflen = len(b_buf) - * cdef ssize_t rc + * cdef size_t buf_remainder = len(b_buf) + * cdef size_t buf_tot_size = buf_remainder */ if (unlikely(__pyx_v_b_buf == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 388, __pyx_L1_error) + __PYX_ERR(0, 468, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 388, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 468, __pyx_L1_error) __pyx_v__buf = __pyx_t_2; - /* "ssh2/channel.pyx":389 + /* "ssh2/channel.pyx":469 * cdef bytes b_buf = to_bytes(buf) * cdef const char *_buf = b_buf - * cdef size_t buflen = len(b_buf) # <<<<<<<<<<<<<< + * cdef size_t buf_remainder = len(b_buf) # <<<<<<<<<<<<<< + * cdef size_t buf_tot_size = buf_remainder * cdef ssize_t rc - * with nogil: */ if (unlikely(__pyx_v_b_buf == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 389, __pyx_L1_error) + __PYX_ERR(0, 469, __pyx_L1_error) } - __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_buf); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 389, __pyx_L1_error) - __pyx_v_buflen = __pyx_t_3; + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_buf); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 469, __pyx_L1_error) + __pyx_v_buf_remainder = __pyx_t_3; - /* "ssh2/channel.pyx":391 - * cdef size_t buflen = len(b_buf) + /* "ssh2/channel.pyx":470 + * cdef const char *_buf = b_buf + * cdef size_t buf_remainder = len(b_buf) + * cdef size_t buf_tot_size = buf_remainder # <<<<<<<<<<<<<< + * cdef ssize_t rc + * cdef size_t bytes_written = 0 + */ + __pyx_v_buf_tot_size = __pyx_v_buf_remainder; + + /* "ssh2/channel.pyx":472 + * cdef size_t buf_tot_size = buf_remainder + * cdef ssize_t rc + * cdef size_t bytes_written = 0 # <<<<<<<<<<<<<< + * with nogil: + * while buf_remainder > 0: + */ + __pyx_v_bytes_written = 0; + + /* "ssh2/channel.pyx":473 * cdef ssize_t rc + * cdef size_t bytes_written = 0 * with nogil: # <<<<<<<<<<<<<< - * rc = c_ssh2.libssh2_channel_write_stderr( - * self._channel, _buf, buflen) + * while buf_remainder > 0: + * rc = c_ssh2.libssh2_channel_write_stderr( */ { #ifdef WITH_THREAD @@ -5809,22 +6225,169 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_56write_stderr(struct __pyx_ob #endif /*try:*/ { - /* "ssh2/channel.pyx":392 - * cdef ssize_t rc + /* "ssh2/channel.pyx":474 + * cdef size_t bytes_written = 0 * with nogil: - * rc = c_ssh2.libssh2_channel_write_stderr( # <<<<<<<<<<<<<< - * self._channel, _buf, buflen) - * return handle_error_codes(rc) + * while buf_remainder > 0: # <<<<<<<<<<<<<< + * rc = c_ssh2.libssh2_channel_write_stderr( + * self._channel, _buf, buf_remainder) + */ + while (1) { + __pyx_t_4 = ((__pyx_v_buf_remainder > 0) != 0); + if (!__pyx_t_4) break; + + /* "ssh2/channel.pyx":475 + * with nogil: + * while buf_remainder > 0: + * rc = c_ssh2.libssh2_channel_write_stderr( # <<<<<<<<<<<<<< + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + */ + __pyx_v_rc = libssh2_channel_write_stderr(__pyx_v_self->_channel, __pyx_v__buf, __pyx_v_buf_remainder); + + /* "ssh2/channel.pyx":477 + * rc = c_ssh2.libssh2_channel_write_stderr( + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * # Error that will raise exception + * with gil: + */ + __pyx_t_5 = ((__pyx_v_rc < 0) != 0); + if (__pyx_t_5) { + } else { + __pyx_t_4 = __pyx_t_5; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_5 = ((__pyx_v_rc != LIBSSH2_ERROR_EAGAIN) != 0); + __pyx_t_4 = __pyx_t_5; + __pyx_L9_bool_binop_done:; + if (__pyx_t_4) { + + /* "ssh2/channel.pyx":479 + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * # Error that will raise exception + * with gil: # <<<<<<<<<<<<<< + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + */ + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + /*try:*/ { + + /* "ssh2/channel.pyx":480 + * # Error that will raise exception + * with gil: + * return handle_error_codes(rc) # <<<<<<<<<<<<<< + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + * break + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_6 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 480, __pyx_L14_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 480, __pyx_L14_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L13_return; + } + + /* "ssh2/channel.pyx":479 + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * # Error that will raise exception + * with gil: # <<<<<<<<<<<<<< + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + */ + /*finally:*/ { + __pyx_L13_return: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L3_return; + } + __pyx_L14_error: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L4_error; + } + } + } + + /* "ssh2/channel.pyx":477 + * rc = c_ssh2.libssh2_channel_write_stderr( + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * # Error that will raise exception + * with gil: + */ + } + + /* "ssh2/channel.pyx":481 + * with gil: + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * break + * _buf += rc + */ + __pyx_t_4 = ((__pyx_v_rc == LIBSSH2_ERROR_EAGAIN) != 0); + if (__pyx_t_4) { + + /* "ssh2/channel.pyx":482 + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + * break # <<<<<<<<<<<<<< + * _buf += rc + * buf_remainder -= rc + */ + goto __pyx_L7_break; + + /* "ssh2/channel.pyx":481 + * with gil: + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * break + * _buf += rc */ - __pyx_v_rc = libssh2_channel_write_stderr(__pyx_v_self->_channel, __pyx_v__buf, __pyx_v_buflen); + } + + /* "ssh2/channel.pyx":483 + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + * break + * _buf += rc # <<<<<<<<<<<<<< + * buf_remainder -= rc + * bytes_written = buf_tot_size - buf_remainder + */ + __pyx_v__buf = (__pyx_v__buf + __pyx_v_rc); + + /* "ssh2/channel.pyx":484 + * break + * _buf += rc + * buf_remainder -= rc # <<<<<<<<<<<<<< + * bytes_written = buf_tot_size - buf_remainder + * return rc, bytes_written + */ + __pyx_v_buf_remainder = (__pyx_v_buf_remainder - __pyx_v_rc); + } + __pyx_L7_break:; + + /* "ssh2/channel.pyx":485 + * _buf += rc + * buf_remainder -= rc + * bytes_written = buf_tot_size - buf_remainder # <<<<<<<<<<<<<< + * return rc, bytes_written + * + */ + __pyx_v_bytes_written = (__pyx_v_buf_tot_size - __pyx_v_buf_remainder); } - /* "ssh2/channel.pyx":391 - * cdef size_t buflen = len(b_buf) + /* "ssh2/channel.pyx":473 * cdef ssize_t rc + * cdef size_t bytes_written = 0 * with nogil: # <<<<<<<<<<<<<< - * rc = c_ssh2.libssh2_channel_write_stderr( - * self._channel, _buf, buflen) + * while buf_remainder > 0: + * rc = c_ssh2.libssh2_channel_write_stderr( */ /*finally:*/ { /*normal exit:*/{ @@ -5834,27 +6397,50 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_56write_stderr(struct __pyx_ob #endif goto __pyx_L5; } + __pyx_L3_return: { + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L0; + } + __pyx_L4_error: { + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L1_error; + } __pyx_L5:; } } - /* "ssh2/channel.pyx":394 - * rc = c_ssh2.libssh2_channel_write_stderr( - * self._channel, _buf, buflen) - * return handle_error_codes(rc) # <<<<<<<<<<<<<< + /* "ssh2/channel.pyx":486 + * buf_remainder -= rc + * bytes_written = buf_tot_size - buf_remainder + * return rc, bytes_written # <<<<<<<<<<<<<< * * def x11_req(self, int screen_number): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 394, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 394, __pyx_L1_error) + __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; + __pyx_t_7 = __Pyx_PyInt_FromSize_t(__pyx_v_bytes_written); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 486, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 486, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); __pyx_t_1 = 0; + __pyx_t_7 = 0; + __pyx_r = __pyx_t_8; + __pyx_t_8 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":380 - * return handle_error_codes(rc) + /* "ssh2/channel.pyx":442 + * return rc, bytes_written * * def write_stderr(self, buf not None): # <<<<<<<<<<<<<< * """Write buffer to stderr. @@ -5864,6 +6450,8 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_56write_stderr(struct __pyx_ob /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("ssh2.channel.Channel.write_stderr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -5873,8 +6461,8 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_56write_stderr(struct __pyx_ob return __pyx_r; } -/* "ssh2/channel.pyx":396 - * return handle_error_codes(rc) +/* "ssh2/channel.pyx":488 + * return rc, bytes_written * * def x11_req(self, int screen_number): # <<<<<<<<<<<<<< * cdef int rc @@ -5890,7 +6478,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_59x11_req(PyObject *__pyx_v_se __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("x11_req (wrapper)", 0); assert(__pyx_arg_screen_number); { - __pyx_v_screen_number = __Pyx_PyInt_As_int(__pyx_arg_screen_number); if (unlikely((__pyx_v_screen_number == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 396, __pyx_L3_error) + __pyx_v_screen_number = __Pyx_PyInt_As_int(__pyx_arg_screen_number); if (unlikely((__pyx_v_screen_number == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 488, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -5913,7 +6501,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_58x11_req(struct __pyx_obj_4ss PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("x11_req", 0); - /* "ssh2/channel.pyx":398 + /* "ssh2/channel.pyx":490 * def x11_req(self, int screen_number): * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -5928,7 +6516,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_58x11_req(struct __pyx_obj_4ss #endif /*try:*/ { - /* "ssh2/channel.pyx":399 + /* "ssh2/channel.pyx":491 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_x11_req( # <<<<<<<<<<<<<< @@ -5938,7 +6526,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_58x11_req(struct __pyx_obj_4ss __pyx_v_rc = libssh2_channel_x11_req(__pyx_v_self->_channel, __pyx_v_screen_number); } - /* "ssh2/channel.pyx":398 + /* "ssh2/channel.pyx":490 * def x11_req(self, int screen_number): * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -5957,7 +6545,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_58x11_req(struct __pyx_obj_4ss } } - /* "ssh2/channel.pyx":401 + /* "ssh2/channel.pyx":493 * rc = c_ssh2.libssh2_channel_x11_req( * self._channel, screen_number) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -5965,15 +6553,15 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_58x11_req(struct __pyx_obj_4ss * def x11_req_ex(self, int single_connection, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 401, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 401, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 493, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 493, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":396 - * return handle_error_codes(rc) + /* "ssh2/channel.pyx":488 + * return rc, bytes_written * * def x11_req(self, int screen_number): # <<<<<<<<<<<<<< * cdef int rc @@ -5991,7 +6579,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_58x11_req(struct __pyx_obj_4ss return __pyx_r; } -/* "ssh2/channel.pyx":403 +/* "ssh2/channel.pyx":495 * return handle_error_codes(rc) * * def x11_req_ex(self, int single_connection, # <<<<<<<<<<<<<< @@ -6037,23 +6625,23 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_61x11_req_ex(PyObject *__pyx_v case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_auth_proto)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, 1); __PYX_ERR(0, 403, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, 1); __PYX_ERR(0, 495, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_auth_cookie)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, 2); __PYX_ERR(0, 403, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, 2); __PYX_ERR(0, 495, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_screen_number)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, 3); __PYX_ERR(0, 403, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, 3); __PYX_ERR(0, 495, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "x11_req_ex") < 0)) __PYX_ERR(0, 403, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "x11_req_ex") < 0)) __PYX_ERR(0, 495, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -6063,14 +6651,14 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_61x11_req_ex(PyObject *__pyx_v values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } - __pyx_v_single_connection = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_single_connection == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 403, __pyx_L3_error) - __pyx_v_auth_proto = __Pyx_PyObject_AsString(values[1]); if (unlikely((!__pyx_v_auth_proto) && PyErr_Occurred())) __PYX_ERR(0, 404, __pyx_L3_error) - __pyx_v_auth_cookie = __Pyx_PyObject_AsString(values[2]); if (unlikely((!__pyx_v_auth_cookie) && PyErr_Occurred())) __PYX_ERR(0, 405, __pyx_L3_error) - __pyx_v_screen_number = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_screen_number == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 406, __pyx_L3_error) + __pyx_v_single_connection = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_single_connection == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 495, __pyx_L3_error) + __pyx_v_auth_proto = __Pyx_PyObject_AsString(values[1]); if (unlikely((!__pyx_v_auth_proto) && PyErr_Occurred())) __PYX_ERR(0, 496, __pyx_L3_error) + __pyx_v_auth_cookie = __Pyx_PyObject_AsString(values[2]); if (unlikely((!__pyx_v_auth_cookie) && PyErr_Occurred())) __PYX_ERR(0, 497, __pyx_L3_error) + __pyx_v_screen_number = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_screen_number == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 498, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 403, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("x11_req_ex", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 495, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.channel.Channel.x11_req_ex", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -6091,7 +6679,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_60x11_req_ex(struct __pyx_obj_ PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("x11_req_ex", 0); - /* "ssh2/channel.pyx":408 + /* "ssh2/channel.pyx":500 * int screen_number): * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6106,7 +6694,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_60x11_req_ex(struct __pyx_obj_ #endif /*try:*/ { - /* "ssh2/channel.pyx":409 + /* "ssh2/channel.pyx":501 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_x11_req_ex( # <<<<<<<<<<<<<< @@ -6116,7 +6704,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_60x11_req_ex(struct __pyx_obj_ __pyx_v_rc = libssh2_channel_x11_req_ex(__pyx_v_self->_channel, __pyx_v_single_connection, __pyx_v_auth_proto, __pyx_v_auth_cookie, __pyx_v_screen_number); } - /* "ssh2/channel.pyx":408 + /* "ssh2/channel.pyx":500 * int screen_number): * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6135,7 +6723,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_60x11_req_ex(struct __pyx_obj_ } } - /* "ssh2/channel.pyx":412 + /* "ssh2/channel.pyx":504 * self._channel, single_connection, * auth_proto, auth_cookie, screen_number) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -6143,14 +6731,14 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_60x11_req_ex(struct __pyx_obj_ * def process_startup(self, request, message=None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 412, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 412, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 504, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":403 + /* "ssh2/channel.pyx":495 * return handle_error_codes(rc) * * def x11_req_ex(self, int single_connection, # <<<<<<<<<<<<<< @@ -6169,7 +6757,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_60x11_req_ex(struct __pyx_obj_ return __pyx_r; } -/* "ssh2/channel.pyx":414 +/* "ssh2/channel.pyx":506 * return handle_error_codes(rc) * * def process_startup(self, request, message=None): # <<<<<<<<<<<<<< @@ -6214,7 +6802,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_63process_startup(PyObject *__ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "process_startup") < 0)) __PYX_ERR(0, 414, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "process_startup") < 0)) __PYX_ERR(0, 506, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -6230,7 +6818,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_63process_startup(PyObject *__ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("process_startup", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 414, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("process_startup", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 506, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.channel.Channel.process_startup", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -6261,19 +6849,19 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62process_startup(struct __pyx int __pyx_t_6; __Pyx_RefNannySetupContext("process_startup", 0); - /* "ssh2/channel.pyx":426 + /* "ssh2/channel.pyx":518 * :type message: str or ``None`` * """ * cdef bytes b_request = to_bytes(request) # <<<<<<<<<<<<<< * cdef bytes b_message = None * cdef char *_request = b_request */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_request); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 426, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_request); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_request = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/channel.pyx":427 + /* "ssh2/channel.pyx":519 * """ * cdef bytes b_request = to_bytes(request) * cdef bytes b_message = None # <<<<<<<<<<<<<< @@ -6283,7 +6871,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62process_startup(struct __pyx __Pyx_INCREF(Py_None); __pyx_v_b_message = ((PyObject*)Py_None); - /* "ssh2/channel.pyx":428 + /* "ssh2/channel.pyx":520 * cdef bytes b_request = to_bytes(request) * cdef bytes b_message = None * cdef char *_request = b_request # <<<<<<<<<<<<<< @@ -6292,12 +6880,12 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62process_startup(struct __pyx */ if (unlikely(__pyx_v_b_request == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 428, __pyx_L1_error) + __PYX_ERR(0, 520, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_request); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 428, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_request); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 520, __pyx_L1_error) __pyx_v__request = __pyx_t_2; - /* "ssh2/channel.pyx":429 + /* "ssh2/channel.pyx":521 * cdef bytes b_message = None * cdef char *_request = b_request * cdef char *_message = NULL # <<<<<<<<<<<<<< @@ -6306,7 +6894,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62process_startup(struct __pyx */ __pyx_v__message = NULL; - /* "ssh2/channel.pyx":430 + /* "ssh2/channel.pyx":522 * cdef char *_request = b_request * cdef char *_message = NULL * cdef size_t r_len = len(b_request) # <<<<<<<<<<<<<< @@ -6315,12 +6903,12 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62process_startup(struct __pyx */ if (unlikely(__pyx_v_b_request == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 430, __pyx_L1_error) + __PYX_ERR(0, 522, __pyx_L1_error) } - __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_request); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 430, __pyx_L1_error) + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_request); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 522, __pyx_L1_error) __pyx_v_r_len = __pyx_t_3; - /* "ssh2/channel.pyx":431 + /* "ssh2/channel.pyx":523 * cdef char *_message = NULL * cdef size_t r_len = len(b_request) * cdef size_t m_len = 0 # <<<<<<<<<<<<<< @@ -6329,7 +6917,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62process_startup(struct __pyx */ __pyx_v_m_len = 0; - /* "ssh2/channel.pyx":432 + /* "ssh2/channel.pyx":524 * cdef size_t r_len = len(b_request) * cdef size_t m_len = 0 * if message is not None: # <<<<<<<<<<<<<< @@ -6340,19 +6928,19 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62process_startup(struct __pyx __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { - /* "ssh2/channel.pyx":433 + /* "ssh2/channel.pyx":525 * cdef size_t m_len = 0 * if message is not None: * b_message = to_bytes(message) # <<<<<<<<<<<<<< * _message = b_message * m_len = len(b_message) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_message); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_message); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_b_message, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0; - /* "ssh2/channel.pyx":434 + /* "ssh2/channel.pyx":526 * if message is not None: * b_message = to_bytes(message) * _message = b_message # <<<<<<<<<<<<<< @@ -6361,12 +6949,12 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62process_startup(struct __pyx */ if (unlikely(__pyx_v_b_message == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 434, __pyx_L1_error) + __PYX_ERR(0, 526, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_message); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 434, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_message); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 526, __pyx_L1_error) __pyx_v__message = __pyx_t_2; - /* "ssh2/channel.pyx":435 + /* "ssh2/channel.pyx":527 * b_message = to_bytes(message) * _message = b_message * m_len = len(b_message) # <<<<<<<<<<<<<< @@ -6375,12 +6963,12 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62process_startup(struct __pyx */ if (unlikely(__pyx_v_b_message == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 435, __pyx_L1_error) + __PYX_ERR(0, 527, __pyx_L1_error) } - __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_message); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 435, __pyx_L1_error) + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_message); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 527, __pyx_L1_error) __pyx_v_m_len = __pyx_t_3; - /* "ssh2/channel.pyx":432 + /* "ssh2/channel.pyx":524 * cdef size_t r_len = len(b_request) * cdef size_t m_len = 0 * if message is not None: # <<<<<<<<<<<<<< @@ -6389,7 +6977,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62process_startup(struct __pyx */ } - /* "ssh2/channel.pyx":437 + /* "ssh2/channel.pyx":529 * m_len = len(b_message) * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6404,7 +6992,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62process_startup(struct __pyx #endif /*try:*/ { - /* "ssh2/channel.pyx":438 + /* "ssh2/channel.pyx":530 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_process_startup( # <<<<<<<<<<<<<< @@ -6414,7 +7002,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62process_startup(struct __pyx __pyx_v_rc = libssh2_channel_process_startup(__pyx_v_self->_channel, __pyx_v__request, __pyx_v_r_len, __pyx_v__message, __pyx_v_m_len); } - /* "ssh2/channel.pyx":437 + /* "ssh2/channel.pyx":529 * m_len = len(b_message) * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6433,7 +7021,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62process_startup(struct __pyx } } - /* "ssh2/channel.pyx":440 + /* "ssh2/channel.pyx":532 * rc = c_ssh2.libssh2_channel_process_startup( * self._channel, _request, r_len, _message, m_len) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -6441,14 +7029,14 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62process_startup(struct __pyx * def poll_channel_read(self, int extended): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_6 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 440, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 440, __pyx_L1_error) + __pyx_t_6 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 532, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 532, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":414 + /* "ssh2/channel.pyx":506 * return handle_error_codes(rc) * * def process_startup(self, request, message=None): # <<<<<<<<<<<<<< @@ -6469,7 +7057,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_62process_startup(struct __pyx return __pyx_r; } -/* "ssh2/channel.pyx":442 +/* "ssh2/channel.pyx":534 * return handle_error_codes(rc) * * def poll_channel_read(self, int extended): # <<<<<<<<<<<<<< @@ -6486,7 +7074,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_65poll_channel_read(PyObject * __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("poll_channel_read (wrapper)", 0); assert(__pyx_arg_extended); { - __pyx_v_extended = __Pyx_PyInt_As_int(__pyx_arg_extended); if (unlikely((__pyx_v_extended == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 442, __pyx_L3_error) + __pyx_v_extended = __Pyx_PyInt_As_int(__pyx_arg_extended); if (unlikely((__pyx_v_extended == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 534, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -6509,7 +7097,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_64poll_channel_read(struct __p PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("poll_channel_read", 0); - /* "ssh2/channel.pyx":446 + /* "ssh2/channel.pyx":538 * instead""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6524,7 +7112,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_64poll_channel_read(struct __p #endif /*try:*/ { - /* "ssh2/channel.pyx":447 + /* "ssh2/channel.pyx":539 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_poll_channel_read(self._channel, extended) # <<<<<<<<<<<<<< @@ -6534,7 +7122,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_64poll_channel_read(struct __p __pyx_v_rc = libssh2_poll_channel_read(__pyx_v_self->_channel, __pyx_v_extended); } - /* "ssh2/channel.pyx":446 + /* "ssh2/channel.pyx":538 * instead""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6553,7 +7141,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_64poll_channel_read(struct __p } } - /* "ssh2/channel.pyx":448 + /* "ssh2/channel.pyx":540 * with nogil: * rc = c_ssh2.libssh2_poll_channel_read(self._channel, extended) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -6561,14 +7149,14 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_64poll_channel_read(struct __p * def handle_extended_data(self, int ignore_mode): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 448, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 448, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 540, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 540, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":442 + /* "ssh2/channel.pyx":534 * return handle_error_codes(rc) * * def poll_channel_read(self, int extended): # <<<<<<<<<<<<<< @@ -6587,7 +7175,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_64poll_channel_read(struct __p return __pyx_r; } -/* "ssh2/channel.pyx":450 +/* "ssh2/channel.pyx":542 * return handle_error_codes(rc) * * def handle_extended_data(self, int ignore_mode): # <<<<<<<<<<<<<< @@ -6604,7 +7192,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_67handle_extended_data(PyObjec __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("handle_extended_data (wrapper)", 0); assert(__pyx_arg_ignore_mode); { - __pyx_v_ignore_mode = __Pyx_PyInt_As_int(__pyx_arg_ignore_mode); if (unlikely((__pyx_v_ignore_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 450, __pyx_L3_error) + __pyx_v_ignore_mode = __Pyx_PyInt_As_int(__pyx_arg_ignore_mode); if (unlikely((__pyx_v_ignore_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 542, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -6624,7 +7212,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_66handle_extended_data(struct __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("handle_extended_data", 0); - /* "ssh2/channel.pyx":452 + /* "ssh2/channel.pyx":544 * def handle_extended_data(self, int ignore_mode): * """Deprecated, use handle_extended_data2""" * with nogil: # <<<<<<<<<<<<<< @@ -6639,7 +7227,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_66handle_extended_data(struct #endif /*try:*/ { - /* "ssh2/channel.pyx":453 + /* "ssh2/channel.pyx":545 * """Deprecated, use handle_extended_data2""" * with nogil: * c_ssh2.libssh2_channel_handle_extended_data( # <<<<<<<<<<<<<< @@ -6649,7 +7237,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_66handle_extended_data(struct libssh2_channel_handle_extended_data(__pyx_v_self->_channel, __pyx_v_ignore_mode); } - /* "ssh2/channel.pyx":452 + /* "ssh2/channel.pyx":544 * def handle_extended_data(self, int ignore_mode): * """Deprecated, use handle_extended_data2""" * with nogil: # <<<<<<<<<<<<<< @@ -6668,7 +7256,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_66handle_extended_data(struct } } - /* "ssh2/channel.pyx":450 + /* "ssh2/channel.pyx":542 * return handle_error_codes(rc) * * def handle_extended_data(self, int ignore_mode): # <<<<<<<<<<<<<< @@ -6683,7 +7271,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_66handle_extended_data(struct return __pyx_r; } -/* "ssh2/channel.pyx":456 +/* "ssh2/channel.pyx":548 * self._channel, ignore_mode) * * def handle_extended_data2(self, int ignore_mode): # <<<<<<<<<<<<<< @@ -6700,7 +7288,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_69handle_extended_data2(PyObje __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("handle_extended_data2 (wrapper)", 0); assert(__pyx_arg_ignore_mode); { - __pyx_v_ignore_mode = __Pyx_PyInt_As_int(__pyx_arg_ignore_mode); if (unlikely((__pyx_v_ignore_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 456, __pyx_L3_error) + __pyx_v_ignore_mode = __Pyx_PyInt_As_int(__pyx_arg_ignore_mode); if (unlikely((__pyx_v_ignore_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 548, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -6723,7 +7311,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_68handle_extended_data2(struct PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("handle_extended_data2", 0); - /* "ssh2/channel.pyx":458 + /* "ssh2/channel.pyx":550 * def handle_extended_data2(self, int ignore_mode): * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6738,7 +7326,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_68handle_extended_data2(struct #endif /*try:*/ { - /* "ssh2/channel.pyx":459 + /* "ssh2/channel.pyx":551 * cdef int rc * with nogil: * rc = c_ssh2.libssh2_channel_handle_extended_data2( # <<<<<<<<<<<<<< @@ -6748,7 +7336,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_68handle_extended_data2(struct __pyx_v_rc = libssh2_channel_handle_extended_data2(__pyx_v_self->_channel, __pyx_v_ignore_mode); } - /* "ssh2/channel.pyx":458 + /* "ssh2/channel.pyx":550 * def handle_extended_data2(self, int ignore_mode): * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6767,7 +7355,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_68handle_extended_data2(struct } } - /* "ssh2/channel.pyx":461 + /* "ssh2/channel.pyx":553 * rc = c_ssh2.libssh2_channel_handle_extended_data2( * self._channel, ignore_mode) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -6775,14 +7363,14 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_68handle_extended_data2(struct * def ignore_extended_data(self, int ignore_mode): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 461, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 461, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 553, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 553, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/channel.pyx":456 + /* "ssh2/channel.pyx":548 * self._channel, ignore_mode) * * def handle_extended_data2(self, int ignore_mode): # <<<<<<<<<<<<<< @@ -6801,7 +7389,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_68handle_extended_data2(struct return __pyx_r; } -/* "ssh2/channel.pyx":463 +/* "ssh2/channel.pyx":555 * return handle_error_codes(rc) * * def ignore_extended_data(self, int ignore_mode): # <<<<<<<<<<<<<< @@ -6818,7 +7406,7 @@ static PyObject *__pyx_pw_4ssh2_7channel_7Channel_71ignore_extended_data(PyObjec __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ignore_extended_data (wrapper)", 0); assert(__pyx_arg_ignore_mode); { - __pyx_v_ignore_mode = __Pyx_PyInt_As_int(__pyx_arg_ignore_mode); if (unlikely((__pyx_v_ignore_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 463, __pyx_L3_error) + __pyx_v_ignore_mode = __Pyx_PyInt_As_int(__pyx_arg_ignore_mode); if (unlikely((__pyx_v_ignore_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 555, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -6838,7 +7426,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_70ignore_extended_data(struct __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ignore_extended_data", 0); - /* "ssh2/channel.pyx":465 + /* "ssh2/channel.pyx":557 * def ignore_extended_data(self, int ignore_mode): * """Deprecated, use handle_extended_data2""" * with nogil: # <<<<<<<<<<<<<< @@ -6853,7 +7441,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_70ignore_extended_data(struct #endif /*try:*/ { - /* "ssh2/channel.pyx":466 + /* "ssh2/channel.pyx":558 * """Deprecated, use handle_extended_data2""" * with nogil: * c_ssh2.libssh2_channel_handle_extended_data( # <<<<<<<<<<<<<< @@ -6863,7 +7451,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_70ignore_extended_data(struct libssh2_channel_handle_extended_data(__pyx_v_self->_channel, __pyx_v_ignore_mode); } - /* "ssh2/channel.pyx":465 + /* "ssh2/channel.pyx":557 * def ignore_extended_data(self, int ignore_mode): * """Deprecated, use handle_extended_data2""" * with nogil: # <<<<<<<<<<<<<< @@ -6882,7 +7470,7 @@ static PyObject *__pyx_pf_4ssh2_7channel_7Channel_70ignore_extended_data(struct } } - /* "ssh2/channel.pyx":463 + /* "ssh2/channel.pyx":555 * return handle_error_codes(rc) * * def ignore_extended_data(self, int ignore_mode): # <<<<<<<<<<<<<< diff --git a/ssh2/channel.pyx b/ssh2/channel.pyx index c2ebabab..66bfb56f 100644 --- a/ssh2/channel.pyx +++ b/ssh2/channel.pyx @@ -345,53 +345,145 @@ cdef class Channel: return handle_error_codes(rc) def write(self, buf not None): - """Write buffer to stdin + """Write buffer to stdin. + + Returns tuple of (``return_code``, ``bytes_written``). + + In blocking mode ``bytes_written`` will always equal ``len(buf)`` if no + errors have occurred which would raise exception. + + In non-blocking mode ``return_code`` can be LIBSSH2_ERROR_EAGAIN and + ``bytes_written`` *can be less than* ``len(buf)``. + + Clients should resume from that point on next call to ``write``, ie + ``buf[bytes_written_in_last_call:]``. + + .. note:: + While this function handles unicode strings for ``buf`` + argument, ``bytes_written`` offset will always be for the *bytes* + representation thereof as returned by the C function calls which only + handle byte strings. :param buf: Buffer to write :type buf: str - :rtype: int""" + :rtype: tuple(int, int) + """ cdef bytes b_buf = to_bytes(buf) cdef const char *_buf = b_buf - cdef size_t buflen = len(b_buf) + cdef size_t buf_remainder = len(b_buf) + cdef size_t buf_tot_size = buf_remainder cdef ssize_t rc - with nogil: - rc = c_ssh2.libssh2_channel_write(self._channel, _buf, buflen) - return handle_error_codes(rc) + cdef size_t bytes_written = 0 + with nogil: + while buf_remainder > 0: + rc = c_ssh2.libssh2_channel_write( + self._channel, _buf, buf_remainder) + if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + # Error that will raise exception + with gil: + return handle_error_codes(rc) + elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + break + _buf += rc + buf_remainder -= rc + bytes_written = buf_tot_size - buf_remainder + return rc, bytes_written def write_ex(self, int stream_id, buf not None): """Write buffer to specified stream id. + Returns tuple of (``return_code``, ``bytes_written``). + + In blocking mode ``bytes_written`` will always equal ``len(buf)`` if no + errors have occurred which would raise exception. + + In non-blocking mode ``return_code`` can be LIBSSH2_ERROR_EAGAIN and + ``bytes_written`` *can be less than* ``len(buf)``. + + Clients should resume from that point on next call to the function, ie + ``buf[bytes_written_in_last_call:]``. + + .. note:: + While this function handles unicode strings for ``buf`` + argument, ``bytes_written`` offset will always be for the *bytes* + representation thereof as returned by the C function calls which only + handle byte strings. + :param stream_id: Id of stream to write to :type stream_id: int :param buf: Buffer to write :type buf: str - :rtype: int""" + :rtype: tuple(int, int) + """ cdef bytes b_buf = to_bytes(buf) cdef const char *_buf = b_buf - cdef size_t buflen = len(b_buf) + cdef size_t buf_remainder = len(b_buf) + cdef size_t buf_tot_size = buf_remainder cdef ssize_t rc - with nogil: - rc = c_ssh2.libssh2_channel_write_ex( - self._channel, stream_id, _buf, buflen) - return handle_error_codes(rc) + cdef size_t bytes_written = 0 + with nogil: + # Write until buffer has been fully written or socket is blocked + while buf_remainder > 0: + rc = c_ssh2.libssh2_channel_write_ex( + self._channel, stream_id, _buf, buf_remainder) + if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + # Error that will raise exception + with gil: + return handle_error_codes(rc) + elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + break + _buf += rc + buf_remainder -= rc + bytes_written = buf_tot_size - buf_remainder + return rc, bytes_written def write_stderr(self, buf not None): """Write buffer to stderr. + Returns tuple of (``return_code``, ``bytes_written``). + + In blocking mode ``bytes_written`` will always equal ``len(buf)`` if no + errors have occurred which would raise exception. + + In non-blocking mode ``return_code`` can be LIBSSH2_ERROR_EAGAIN and + ``bytes_written`` *can be less than* ``len(buf)``. + + Clients should resume from that point on next call to ``write``, ie + ``buf[bytes_written_in_last_call:]``. + + .. note:: + While this function handles unicode strings for ``buf`` + argument, ``bytes_written`` offset will always be for the *bytes* + representation thereof as returned by the C function calls which only + handle byte strings. + :param buf: Buffer to write :type buf: str - :rtype: int""" + :rtype: tuple(int, int) + """ cdef bytes b_buf = to_bytes(buf) cdef const char *_buf = b_buf - cdef size_t buflen = len(b_buf) + cdef size_t buf_remainder = len(b_buf) + cdef size_t buf_tot_size = buf_remainder cdef ssize_t rc - with nogil: - rc = c_ssh2.libssh2_channel_write_stderr( - self._channel, _buf, buflen) - return handle_error_codes(rc) + cdef size_t bytes_written = 0 + with nogil: + while buf_remainder > 0: + rc = c_ssh2.libssh2_channel_write_stderr( + self._channel, _buf, buf_remainder) + if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + # Error that will raise exception + with gil: + return handle_error_codes(rc) + elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + break + _buf += rc + buf_remainder -= rc + bytes_written = buf_tot_size - buf_remainder + return rc, bytes_written def x11_req(self, int screen_number): cdef int rc diff --git a/ssh2/sftp.c b/ssh2/sftp.c index a8c52033..e93c2a85 100644 --- a/ssh2/sftp.c +++ b/ssh2/sftp.c @@ -2178,7 +2178,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_6open_ex(struct __pyx_obj_4ssh2_4sft /* Python wrapper */ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_9open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_4ssh2_4sftp_4SFTP_8open[] = "SFTP.open(self, filename, unsigned long flags, long mode)\nOpen file handle for file name.\n\n :param filename: Name of file to open.\n :type filename: str\n :param flags: One or more LIBSSH2_FXF_* flags.\n\n Eg for reading flags is ``LIBSSH2_FXF_READ``,\n\n for writing ``LIBSSH2_FXF_WRITE``,\n\n for both ``LIBSSH2_FXF_READ`` | ``LIBSSH2_FXF_WRITE``.\n :type flags: int\n :param mode: File permissions mode. ``LIBSSH2_SFTP_S_IRUSR`` for\n reading.\n\n For writing one or more ``LIBSSH2_SFTP_S_*`` flags.\n\n Eg, for 664 permission mask (read/write owner/group, read other),\n\n mode is\n\n ``LIBSSH2_SFTP_S_IRUSR | LIBSSH2_SFTP_S_IWUSR | \\``\n\n ``LIBSSH2_SFTP_S_IRGRP | LIBSSH2_SFTP_S_IWGRP | \\``\n\n ``LIBSSH2_SFTP_S_IROTH``\n :type mode: int\n\n :raises: :py:class:`ssh2.exceptions.SFTPHandleError` on errors opening\n file.\n "; +static char __pyx_doc_4ssh2_4sftp_4SFTP_8open[] = "SFTP.open(self, filename, unsigned long flags, long mode)\nOpen file handle for file name.\n\n :param filename: Name of file to open.\n :type filename: str\n :param flags: One or more LIBSSH2_FXF_* flags.\n\n Eg for reading flags is ``LIBSSH2_FXF_READ``,\n\n for writing ``LIBSSH2_FXF_WRITE``,\n\n for both ``LIBSSH2_FXF_READ`` | ``LIBSSH2_FXF_WRITE``.\n :type flags: int\n :param mode: File permissions mode. ``LIBSSH2_SFTP_S_IRUSR`` for\n reading.\n\n For writing one or more ``LIBSSH2_SFTP_S_*`` flags.\n\n Eg, for 664 permission mask (read/write owner/group, read other),\n\n mode is\n\n ``LIBSSH2_SFTP_S_IRUSR | LIBSSH2_SFTP_S_IWUSR | \\``\n ``LIBSSH2_SFTP_S_IRGRP | LIBSSH2_SFTP_S_IWGRP | \\``\n ``LIBSSH2_SFTP_S_IROTH``\n :type mode: int\n\n :raises: :py:class:`ssh2.exceptions.SFTPHandleError` on errors opening\n file.\n "; static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_9open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_filename = 0; unsigned long __pyx_v_flags; @@ -2268,19 +2268,19 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_8open(struct __pyx_obj_4ssh2_4sftp_S int __pyx_t_4; __Pyx_RefNannySetupContext("open", 0); - /* "ssh2/sftp.pyx":226 - * """ + /* "ssh2/sftp.pyx":224 + * """ # noqa: W605 * cdef c_sftp.LIBSSH2_SFTP_HANDLE *_handle * cdef bytes b_filename = to_bytes(filename) # <<<<<<<<<<<<<< * cdef char *_filename = b_filename * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_filename); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_filename); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_filename = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":227 + /* "ssh2/sftp.pyx":225 * cdef c_sftp.LIBSSH2_SFTP_HANDLE *_handle * cdef bytes b_filename = to_bytes(filename) * cdef char *_filename = b_filename # <<<<<<<<<<<<<< @@ -2289,12 +2289,12 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_8open(struct __pyx_obj_4ssh2_4sftp_S */ if (unlikely(__pyx_v_b_filename == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 227, __pyx_L1_error) + __PYX_ERR(0, 225, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 227, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 225, __pyx_L1_error) __pyx_v__filename = __pyx_t_2; - /* "ssh2/sftp.pyx":228 + /* "ssh2/sftp.pyx":226 * cdef bytes b_filename = to_bytes(filename) * cdef char *_filename = b_filename * with nogil: # <<<<<<<<<<<<<< @@ -2309,7 +2309,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_8open(struct __pyx_obj_4ssh2_4sftp_S #endif /*try:*/ { - /* "ssh2/sftp.pyx":229 + /* "ssh2/sftp.pyx":227 * cdef char *_filename = b_filename * with nogil: * _handle = c_sftp.libssh2_sftp_open( # <<<<<<<<<<<<<< @@ -2319,7 +2319,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_8open(struct __pyx_obj_4ssh2_4sftp_S __pyx_v__handle = libssh2_sftp_open(__pyx_v_self->_sftp, __pyx_v__filename, __pyx_v_flags, __pyx_v_mode); } - /* "ssh2/sftp.pyx":228 + /* "ssh2/sftp.pyx":226 * cdef bytes b_filename = to_bytes(filename) * cdef char *_filename = b_filename * with nogil: # <<<<<<<<<<<<<< @@ -2338,7 +2338,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_8open(struct __pyx_obj_4ssh2_4sftp_S } } - /* "ssh2/sftp.pyx":231 + /* "ssh2/sftp.pyx":229 * _handle = c_sftp.libssh2_sftp_open( * self._sftp, _filename, flags, mode) * if _handle is NULL: # <<<<<<<<<<<<<< @@ -2348,7 +2348,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_8open(struct __pyx_obj_4ssh2_4sftp_S __pyx_t_3 = ((__pyx_v__handle == NULL) != 0); if (__pyx_t_3) { - /* "ssh2/sftp.pyx":232 + /* "ssh2/sftp.pyx":230 * self._sftp, _filename, flags, mode) * if _handle is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< @@ -2357,29 +2357,29 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_8open(struct __pyx_obj_4ssh2_4sftp_S */ __Pyx_XDECREF(__pyx_r); - /* "ssh2/sftp.pyx":233 + /* "ssh2/sftp.pyx":231 * if _handle is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session._session)) # <<<<<<<<<<<<<< * return PySFTPHandle(_handle, self) * */ - __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 232, __pyx_L1_error) + __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 230, __pyx_L1_error) - /* "ssh2/sftp.pyx":232 + /* "ssh2/sftp.pyx":230 * self._sftp, _filename, flags, mode) * if _handle is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< * self._session._session)) * return PySFTPHandle(_handle, self) */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 232, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":231 + /* "ssh2/sftp.pyx":229 * _handle = c_sftp.libssh2_sftp_open( * self._sftp, _filename, flags, mode) * if _handle is NULL: # <<<<<<<<<<<<<< @@ -2388,7 +2388,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_8open(struct __pyx_obj_4ssh2_4sftp_S */ } - /* "ssh2/sftp.pyx":234 + /* "ssh2/sftp.pyx":232 * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session._session)) * return PySFTPHandle(_handle, self) # <<<<<<<<<<<<<< @@ -2396,7 +2396,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_8open(struct __pyx_obj_4ssh2_4sftp_S * def opendir(self, path not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_11sftp_handle_PySFTPHandle(__pyx_v__handle, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 234, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_11sftp_handle_PySFTPHandle(__pyx_v__handle, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2422,7 +2422,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_8open(struct __pyx_obj_4ssh2_4sftp_S return __pyx_r; } -/* "ssh2/sftp.pyx":236 +/* "ssh2/sftp.pyx":234 * return PySFTPHandle(_handle, self) * * def opendir(self, path not None): # <<<<<<<<<<<<<< @@ -2438,7 +2438,7 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_11opendir(PyObject *__pyx_v_self, Py __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("opendir (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 236, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 234, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_10opendir(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), ((PyObject *)__pyx_v_path)); @@ -2463,19 +2463,19 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_10opendir(struct __pyx_obj_4ssh2_4sf int __pyx_t_4; __Pyx_RefNannySetupContext("opendir", 0); - /* "ssh2/sftp.pyx":248 + /* "ssh2/sftp.pyx":246 * """ * cdef c_sftp.LIBSSH2_SFTP_HANDLE *_handle * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":249 + /* "ssh2/sftp.pyx":247 * cdef c_sftp.LIBSSH2_SFTP_HANDLE *_handle * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< @@ -2484,12 +2484,12 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_10opendir(struct __pyx_obj_4ssh2_4sf */ if (unlikely(__pyx_v_b_path == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 249, __pyx_L1_error) + __PYX_ERR(0, 247, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 249, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 247, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/sftp.pyx":250 + /* "ssh2/sftp.pyx":248 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * with nogil: # <<<<<<<<<<<<<< @@ -2504,7 +2504,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_10opendir(struct __pyx_obj_4ssh2_4sf #endif /*try:*/ { - /* "ssh2/sftp.pyx":251 + /* "ssh2/sftp.pyx":249 * cdef char *_path = b_path * with nogil: * _handle = c_sftp.libssh2_sftp_opendir(self._sftp, _path) # <<<<<<<<<<<<<< @@ -2514,7 +2514,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_10opendir(struct __pyx_obj_4ssh2_4sf __pyx_v__handle = libssh2_sftp_opendir(__pyx_v_self->_sftp, __pyx_v__path); } - /* "ssh2/sftp.pyx":250 + /* "ssh2/sftp.pyx":248 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * with nogil: # <<<<<<<<<<<<<< @@ -2533,7 +2533,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_10opendir(struct __pyx_obj_4ssh2_4sf } } - /* "ssh2/sftp.pyx":252 + /* "ssh2/sftp.pyx":250 * with nogil: * _handle = c_sftp.libssh2_sftp_opendir(self._sftp, _path) * if _handle is NULL: # <<<<<<<<<<<<<< @@ -2543,7 +2543,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_10opendir(struct __pyx_obj_4ssh2_4sf __pyx_t_3 = ((__pyx_v__handle == NULL) != 0); if (__pyx_t_3) { - /* "ssh2/sftp.pyx":253 + /* "ssh2/sftp.pyx":251 * _handle = c_sftp.libssh2_sftp_opendir(self._sftp, _path) * if _handle is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< @@ -2552,29 +2552,29 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_10opendir(struct __pyx_obj_4ssh2_4sf */ __Pyx_XDECREF(__pyx_r); - /* "ssh2/sftp.pyx":254 + /* "ssh2/sftp.pyx":252 * if _handle is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session._session)) # <<<<<<<<<<<<<< * return PySFTPHandle(_handle, self) * */ - __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 253, __pyx_L1_error) + __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(libssh2_session_last_errno(__pyx_v_self->_session->_session), 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 251, __pyx_L1_error) - /* "ssh2/sftp.pyx":253 + /* "ssh2/sftp.pyx":251 * _handle = c_sftp.libssh2_sftp_opendir(self._sftp, _path) * if _handle is NULL: * return handle_error_codes(c_ssh2.libssh2_session_last_errno( # <<<<<<<<<<<<<< * self._session._session)) * return PySFTPHandle(_handle, self) */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":252 + /* "ssh2/sftp.pyx":250 * with nogil: * _handle = c_sftp.libssh2_sftp_opendir(self._sftp, _path) * if _handle is NULL: # <<<<<<<<<<<<<< @@ -2583,7 +2583,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_10opendir(struct __pyx_obj_4ssh2_4sf */ } - /* "ssh2/sftp.pyx":255 + /* "ssh2/sftp.pyx":253 * return handle_error_codes(c_ssh2.libssh2_session_last_errno( * self._session._session)) * return PySFTPHandle(_handle, self) # <<<<<<<<<<<<<< @@ -2591,13 +2591,13 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_10opendir(struct __pyx_obj_4ssh2_4sf * def rename_ex(self, const char *source_filename, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_11sftp_handle_PySFTPHandle(__pyx_v__handle, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_11sftp_handle_PySFTPHandle(__pyx_v__handle, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":236 + /* "ssh2/sftp.pyx":234 * return PySFTPHandle(_handle, self) * * def opendir(self, path not None): # <<<<<<<<<<<<<< @@ -2617,7 +2617,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_10opendir(struct __pyx_obj_4ssh2_4sf return __pyx_r; } -/* "ssh2/sftp.pyx":257 +/* "ssh2/sftp.pyx":255 * return PySFTPHandle(_handle, self) * * def rename_ex(self, const char *source_filename, # <<<<<<<<<<<<<< @@ -2666,29 +2666,29 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_13rename_ex(PyObject *__pyx_v_self, case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_source_filename_len)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rename_ex", 1, 5, 5, 1); __PYX_ERR(0, 257, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rename_ex", 1, 5, 5, 1); __PYX_ERR(0, 255, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dest_filename)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rename_ex", 1, 5, 5, 2); __PYX_ERR(0, 257, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rename_ex", 1, 5, 5, 2); __PYX_ERR(0, 255, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dest_filename_len)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rename_ex", 1, 5, 5, 3); __PYX_ERR(0, 257, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rename_ex", 1, 5, 5, 3); __PYX_ERR(0, 255, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rename_ex", 1, 5, 5, 4); __PYX_ERR(0, 257, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rename_ex", 1, 5, 5, 4); __PYX_ERR(0, 255, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rename_ex") < 0)) __PYX_ERR(0, 257, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rename_ex") < 0)) __PYX_ERR(0, 255, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; @@ -2699,15 +2699,15 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_13rename_ex(PyObject *__pyx_v_self, values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[4] = PyTuple_GET_ITEM(__pyx_args, 4); } - __pyx_v_source_filename = __Pyx_PyObject_AsString(values[0]); if (unlikely((!__pyx_v_source_filename) && PyErr_Occurred())) __PYX_ERR(0, 257, __pyx_L3_error) - __pyx_v_source_filename_len = __Pyx_PyInt_As_unsigned_int(values[1]); if (unlikely((__pyx_v_source_filename_len == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 258, __pyx_L3_error) - __pyx_v_dest_filename = __Pyx_PyObject_AsString(values[2]); if (unlikely((!__pyx_v_dest_filename) && PyErr_Occurred())) __PYX_ERR(0, 259, __pyx_L3_error) - __pyx_v_dest_filename_len = __Pyx_PyInt_As_unsigned_int(values[3]); if (unlikely((__pyx_v_dest_filename_len == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 260, __pyx_L3_error) - __pyx_v_flags = __Pyx_PyInt_As_long(values[4]); if (unlikely((__pyx_v_flags == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 261, __pyx_L3_error) + __pyx_v_source_filename = __Pyx_PyObject_AsString(values[0]); if (unlikely((!__pyx_v_source_filename) && PyErr_Occurred())) __PYX_ERR(0, 255, __pyx_L3_error) + __pyx_v_source_filename_len = __Pyx_PyInt_As_unsigned_int(values[1]); if (unlikely((__pyx_v_source_filename_len == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 256, __pyx_L3_error) + __pyx_v_dest_filename = __Pyx_PyObject_AsString(values[2]); if (unlikely((!__pyx_v_dest_filename) && PyErr_Occurred())) __PYX_ERR(0, 257, __pyx_L3_error) + __pyx_v_dest_filename_len = __Pyx_PyInt_As_unsigned_int(values[3]); if (unlikely((__pyx_v_dest_filename_len == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 258, __pyx_L3_error) + __pyx_v_flags = __Pyx_PyInt_As_long(values[4]); if (unlikely((__pyx_v_flags == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 259, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("rename_ex", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 257, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rename_ex", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 255, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp.SFTP.rename_ex", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -2728,7 +2728,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_12rename_ex(struct __pyx_obj_4ssh2_4 PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("rename_ex", 0); - /* "ssh2/sftp.pyx":263 + /* "ssh2/sftp.pyx":261 * long flags): * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -2743,7 +2743,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_12rename_ex(struct __pyx_obj_4ssh2_4 #endif /*try:*/ { - /* "ssh2/sftp.pyx":264 + /* "ssh2/sftp.pyx":262 * cdef int rc * with nogil: * rc = c_sftp.libssh2_sftp_rename_ex( # <<<<<<<<<<<<<< @@ -2753,7 +2753,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_12rename_ex(struct __pyx_obj_4ssh2_4 __pyx_v_rc = libssh2_sftp_rename_ex(__pyx_v_self->_sftp, __pyx_v_source_filename, __pyx_v_source_filename_len, __pyx_v_dest_filename, __pyx_v_dest_filename_len, __pyx_v_flags); } - /* "ssh2/sftp.pyx":263 + /* "ssh2/sftp.pyx":261 * long flags): * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -2772,7 +2772,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_12rename_ex(struct __pyx_obj_4ssh2_4 } } - /* "ssh2/sftp.pyx":267 + /* "ssh2/sftp.pyx":265 * self._sftp, source_filename, source_filename_len, * dest_filename, dest_filename_len, flags) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -2780,14 +2780,14 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_12rename_ex(struct __pyx_obj_4ssh2_4 * def rename(self, source_filename not None, dest_filename not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 267, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 265, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":257 + /* "ssh2/sftp.pyx":255 * return PySFTPHandle(_handle, self) * * def rename_ex(self, const char *source_filename, # <<<<<<<<<<<<<< @@ -2806,7 +2806,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_12rename_ex(struct __pyx_obj_4ssh2_4 return __pyx_r; } -/* "ssh2/sftp.pyx":269 +/* "ssh2/sftp.pyx":267 * return handle_error_codes(rc) * * def rename(self, source_filename not None, dest_filename not None): # <<<<<<<<<<<<<< @@ -2846,11 +2846,11 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_15rename(PyObject *__pyx_v_self, PyO case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dest_filename)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rename", 1, 2, 2, 1); __PYX_ERR(0, 269, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rename", 1, 2, 2, 1); __PYX_ERR(0, 267, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rename") < 0)) __PYX_ERR(0, 269, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rename") < 0)) __PYX_ERR(0, 267, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -2863,17 +2863,17 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_15rename(PyObject *__pyx_v_self, PyO } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("rename", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 269, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rename", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 267, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp.SFTP.rename", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_source_filename) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "source_filename"); __PYX_ERR(0, 269, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "source_filename"); __PYX_ERR(0, 267, __pyx_L1_error) } if (unlikely(((PyObject *)__pyx_v_dest_filename) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "dest_filename"); __PYX_ERR(0, 269, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "dest_filename"); __PYX_ERR(0, 267, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_14rename(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), __pyx_v_source_filename, __pyx_v_dest_filename); @@ -2899,31 +2899,31 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_14rename(struct __pyx_obj_4ssh2_4sft int __pyx_t_3; __Pyx_RefNannySetupContext("rename", 0); - /* "ssh2/sftp.pyx":277 + /* "ssh2/sftp.pyx":275 * :type dest_filename: str""" * cdef int rc * cdef bytes b_source_filename = to_bytes(source_filename) # <<<<<<<<<<<<<< * cdef bytes b_dest_filename = to_bytes(dest_filename) * cdef char *_source_filename = b_source_filename */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_source_filename); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 277, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_source_filename); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_source_filename = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":278 + /* "ssh2/sftp.pyx":276 * cdef int rc * cdef bytes b_source_filename = to_bytes(source_filename) * cdef bytes b_dest_filename = to_bytes(dest_filename) # <<<<<<<<<<<<<< * cdef char *_source_filename = b_source_filename * cdef char *_dest_filename = b_dest_filename */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_dest_filename); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_dest_filename); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_dest_filename = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":279 + /* "ssh2/sftp.pyx":277 * cdef bytes b_source_filename = to_bytes(source_filename) * cdef bytes b_dest_filename = to_bytes(dest_filename) * cdef char *_source_filename = b_source_filename # <<<<<<<<<<<<<< @@ -2932,12 +2932,12 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_14rename(struct __pyx_obj_4ssh2_4sft */ if (unlikely(__pyx_v_b_source_filename == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 279, __pyx_L1_error) + __PYX_ERR(0, 277, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_source_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 279, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_source_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 277, __pyx_L1_error) __pyx_v__source_filename = __pyx_t_2; - /* "ssh2/sftp.pyx":280 + /* "ssh2/sftp.pyx":278 * cdef bytes b_dest_filename = to_bytes(dest_filename) * cdef char *_source_filename = b_source_filename * cdef char *_dest_filename = b_dest_filename # <<<<<<<<<<<<<< @@ -2946,12 +2946,12 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_14rename(struct __pyx_obj_4ssh2_4sft */ if (unlikely(__pyx_v_b_dest_filename == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 280, __pyx_L1_error) + __PYX_ERR(0, 278, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_dest_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 280, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_dest_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 278, __pyx_L1_error) __pyx_v__dest_filename = __pyx_t_2; - /* "ssh2/sftp.pyx":281 + /* "ssh2/sftp.pyx":279 * cdef char *_source_filename = b_source_filename * cdef char *_dest_filename = b_dest_filename * with nogil: # <<<<<<<<<<<<<< @@ -2966,7 +2966,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_14rename(struct __pyx_obj_4ssh2_4sft #endif /*try:*/ { - /* "ssh2/sftp.pyx":282 + /* "ssh2/sftp.pyx":280 * cdef char *_dest_filename = b_dest_filename * with nogil: * rc = c_sftp.libssh2_sftp_rename( # <<<<<<<<<<<<<< @@ -2976,7 +2976,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_14rename(struct __pyx_obj_4ssh2_4sft __pyx_v_rc = libssh2_sftp_rename(__pyx_v_self->_sftp, __pyx_v__source_filename, __pyx_v__dest_filename); } - /* "ssh2/sftp.pyx":281 + /* "ssh2/sftp.pyx":279 * cdef char *_source_filename = b_source_filename * cdef char *_dest_filename = b_dest_filename * with nogil: # <<<<<<<<<<<<<< @@ -2995,7 +2995,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_14rename(struct __pyx_obj_4ssh2_4sft } } - /* "ssh2/sftp.pyx":284 + /* "ssh2/sftp.pyx":282 * rc = c_sftp.libssh2_sftp_rename( * self._sftp, _source_filename, _dest_filename) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -3003,14 +3003,14 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_14rename(struct __pyx_obj_4ssh2_4sft * def unlink(self, filename not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 284, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 282, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":269 + /* "ssh2/sftp.pyx":267 * return handle_error_codes(rc) * * def rename(self, source_filename not None, dest_filename not None): # <<<<<<<<<<<<<< @@ -3031,7 +3031,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_14rename(struct __pyx_obj_4ssh2_4sft return __pyx_r; } -/* "ssh2/sftp.pyx":286 +/* "ssh2/sftp.pyx":284 * return handle_error_codes(rc) * * def unlink(self, filename not None): # <<<<<<<<<<<<<< @@ -3047,7 +3047,7 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_17unlink(PyObject *__pyx_v_self, PyO __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("unlink (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_filename) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "filename"); __PYX_ERR(0, 286, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "filename"); __PYX_ERR(0, 284, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_16unlink(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), ((PyObject *)__pyx_v_filename)); @@ -3071,19 +3071,19 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_16unlink(struct __pyx_obj_4ssh2_4sft int __pyx_t_3; __Pyx_RefNannySetupContext("unlink", 0); - /* "ssh2/sftp.pyx":292 + /* "ssh2/sftp.pyx":290 * :type filename: str""" * cdef int rc * cdef bytes b_filename = to_bytes(filename) # <<<<<<<<<<<<<< * cdef char *_filename = b_filename * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_filename); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 292, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_filename); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_filename = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":293 + /* "ssh2/sftp.pyx":291 * cdef int rc * cdef bytes b_filename = to_bytes(filename) * cdef char *_filename = b_filename # <<<<<<<<<<<<<< @@ -3092,12 +3092,12 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_16unlink(struct __pyx_obj_4ssh2_4sft */ if (unlikely(__pyx_v_b_filename == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 293, __pyx_L1_error) + __PYX_ERR(0, 291, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 293, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 291, __pyx_L1_error) __pyx_v__filename = __pyx_t_2; - /* "ssh2/sftp.pyx":294 + /* "ssh2/sftp.pyx":292 * cdef bytes b_filename = to_bytes(filename) * cdef char *_filename = b_filename * with nogil: # <<<<<<<<<<<<<< @@ -3112,7 +3112,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_16unlink(struct __pyx_obj_4ssh2_4sft #endif /*try:*/ { - /* "ssh2/sftp.pyx":295 + /* "ssh2/sftp.pyx":293 * cdef char *_filename = b_filename * with nogil: * rc = c_sftp.libssh2_sftp_unlink(self._sftp, _filename) # <<<<<<<<<<<<<< @@ -3122,7 +3122,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_16unlink(struct __pyx_obj_4ssh2_4sft __pyx_v_rc = libssh2_sftp_unlink(__pyx_v_self->_sftp, __pyx_v__filename); } - /* "ssh2/sftp.pyx":294 + /* "ssh2/sftp.pyx":292 * cdef bytes b_filename = to_bytes(filename) * cdef char *_filename = b_filename * with nogil: # <<<<<<<<<<<<<< @@ -3141,7 +3141,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_16unlink(struct __pyx_obj_4ssh2_4sft } } - /* "ssh2/sftp.pyx":296 + /* "ssh2/sftp.pyx":294 * with nogil: * rc = c_sftp.libssh2_sftp_unlink(self._sftp, _filename) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -3149,14 +3149,14 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_16unlink(struct __pyx_obj_4ssh2_4sft * def statvfs(self, path): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 296, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 294, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":286 + /* "ssh2/sftp.pyx":284 * return handle_error_codes(rc) * * def unlink(self, filename not None): # <<<<<<<<<<<<<< @@ -3176,7 +3176,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_16unlink(struct __pyx_obj_4ssh2_4sft return __pyx_r; } -/* "ssh2/sftp.pyx":298 +/* "ssh2/sftp.pyx":296 * return handle_error_codes(rc) * * def statvfs(self, path): # <<<<<<<<<<<<<< @@ -3213,31 +3213,31 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_18statvfs(struct __pyx_obj_4ssh2_4sf PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("statvfs", 0); - /* "ssh2/sftp.pyx":302 + /* "ssh2/sftp.pyx":300 * * :rtype: `ssh2.sftp.SFTPStatVFS` or int of error code""" * cdef SFTPStatVFS vfs = SFTPStatVFS(self) # <<<<<<<<<<<<<< * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path */ - __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPStatVFS), ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPStatVFS), ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_vfs = ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPStatVFS *)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":303 + /* "ssh2/sftp.pyx":301 * :rtype: `ssh2.sftp.SFTPStatVFS` or int of error code""" * cdef SFTPStatVFS vfs = SFTPStatVFS(self) * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * cdef size_t path_len = len(b_path) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":304 + /* "ssh2/sftp.pyx":302 * cdef SFTPStatVFS vfs = SFTPStatVFS(self) * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< @@ -3246,12 +3246,12 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_18statvfs(struct __pyx_obj_4ssh2_4sf */ if (unlikely(__pyx_v_b_path == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 304, __pyx_L1_error) + __PYX_ERR(0, 302, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 304, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 302, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/sftp.pyx":305 + /* "ssh2/sftp.pyx":303 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * cdef size_t path_len = len(b_path) # <<<<<<<<<<<<<< @@ -3260,12 +3260,12 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_18statvfs(struct __pyx_obj_4ssh2_4sf */ if (unlikely(__pyx_v_b_path == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 305, __pyx_L1_error) + __PYX_ERR(0, 303, __pyx_L1_error) } - __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_path); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 305, __pyx_L1_error) + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_path); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 303, __pyx_L1_error) __pyx_v_path_len = __pyx_t_3; - /* "ssh2/sftp.pyx":306 + /* "ssh2/sftp.pyx":304 * cdef char *_path = b_path * cdef size_t path_len = len(b_path) * with nogil: # <<<<<<<<<<<<<< @@ -3280,7 +3280,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_18statvfs(struct __pyx_obj_4ssh2_4sf #endif /*try:*/ { - /* "ssh2/sftp.pyx":307 + /* "ssh2/sftp.pyx":305 * cdef size_t path_len = len(b_path) * with nogil: * rc = c_sftp.libssh2_sftp_statvfs( # <<<<<<<<<<<<<< @@ -3290,7 +3290,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_18statvfs(struct __pyx_obj_4ssh2_4sf __pyx_v_rc = libssh2_sftp_statvfs(__pyx_v_self->_sftp, __pyx_v__path, __pyx_v_path_len, __pyx_v_vfs->_ptr); } - /* "ssh2/sftp.pyx":306 + /* "ssh2/sftp.pyx":304 * cdef char *_path = b_path * cdef size_t path_len = len(b_path) * with nogil: # <<<<<<<<<<<<<< @@ -3309,7 +3309,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_18statvfs(struct __pyx_obj_4ssh2_4sf } } - /* "ssh2/sftp.pyx":309 + /* "ssh2/sftp.pyx":307 * rc = c_sftp.libssh2_sftp_statvfs( * self._sftp, _path, path_len, vfs._ptr) * return handle_error_codes(rc) if rc != 0 else vfs # <<<<<<<<<<<<<< @@ -3318,8 +3318,8 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_18statvfs(struct __pyx_obj_4ssh2_4sf */ __Pyx_XDECREF(__pyx_r); if (((__pyx_v_rc != 0) != 0)) { - __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 309, __pyx_L1_error) - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 309, __pyx_L1_error) + __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 307, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __pyx_t_5; __pyx_t_5 = 0; @@ -3331,7 +3331,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_18statvfs(struct __pyx_obj_4ssh2_4sf __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":298 + /* "ssh2/sftp.pyx":296 * return handle_error_codes(rc) * * def statvfs(self, path): # <<<<<<<<<<<<<< @@ -3353,7 +3353,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_18statvfs(struct __pyx_obj_4ssh2_4sf return __pyx_r; } -/* "ssh2/sftp.pyx":311 +/* "ssh2/sftp.pyx":309 * return handle_error_codes(rc) if rc != 0 else vfs * * def mkdir(self, path not None, long mode): # <<<<<<<<<<<<<< @@ -3393,11 +3393,11 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_21mkdir(PyObject *__pyx_v_self, PyOb case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("mkdir", 1, 2, 2, 1); __PYX_ERR(0, 311, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("mkdir", 1, 2, 2, 1); __PYX_ERR(0, 309, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "mkdir") < 0)) __PYX_ERR(0, 311, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "mkdir") < 0)) __PYX_ERR(0, 309, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -3406,18 +3406,18 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_21mkdir(PyObject *__pyx_v_self, PyOb values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_path = values[0]; - __pyx_v_mode = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v_mode == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 311, __pyx_L3_error) + __pyx_v_mode = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v_mode == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 309, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("mkdir", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 311, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("mkdir", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 309, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp.SFTP.mkdir", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 311, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 309, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_20mkdir(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), __pyx_v_path, __pyx_v_mode); @@ -3441,19 +3441,19 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_20mkdir(struct __pyx_obj_4ssh2_4sftp int __pyx_t_3; __Pyx_RefNannySetupContext("mkdir", 0); - /* "ssh2/sftp.pyx":324 + /* "ssh2/sftp.pyx":322 * """ * cdef int rc * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":325 + /* "ssh2/sftp.pyx":323 * cdef int rc * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< @@ -3462,12 +3462,12 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_20mkdir(struct __pyx_obj_4ssh2_4sftp */ if (unlikely(__pyx_v_b_path == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 325, __pyx_L1_error) + __PYX_ERR(0, 323, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 325, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 323, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/sftp.pyx":326 + /* "ssh2/sftp.pyx":324 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * with nogil: # <<<<<<<<<<<<<< @@ -3482,7 +3482,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_20mkdir(struct __pyx_obj_4ssh2_4sftp #endif /*try:*/ { - /* "ssh2/sftp.pyx":327 + /* "ssh2/sftp.pyx":325 * cdef char *_path = b_path * with nogil: * rc = c_sftp.libssh2_sftp_mkdir(self._sftp, _path, mode) # <<<<<<<<<<<<<< @@ -3492,7 +3492,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_20mkdir(struct __pyx_obj_4ssh2_4sftp __pyx_v_rc = libssh2_sftp_mkdir(__pyx_v_self->_sftp, __pyx_v__path, __pyx_v_mode); } - /* "ssh2/sftp.pyx":326 + /* "ssh2/sftp.pyx":324 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * with nogil: # <<<<<<<<<<<<<< @@ -3511,7 +3511,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_20mkdir(struct __pyx_obj_4ssh2_4sftp } } - /* "ssh2/sftp.pyx":328 + /* "ssh2/sftp.pyx":326 * with nogil: * rc = c_sftp.libssh2_sftp_mkdir(self._sftp, _path, mode) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -3519,14 +3519,14 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_20mkdir(struct __pyx_obj_4ssh2_4sftp * def rmdir(self, path not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 328, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 328, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 326, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":311 + /* "ssh2/sftp.pyx":309 * return handle_error_codes(rc) if rc != 0 else vfs * * def mkdir(self, path not None, long mode): # <<<<<<<<<<<<<< @@ -3546,7 +3546,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_20mkdir(struct __pyx_obj_4ssh2_4sftp return __pyx_r; } -/* "ssh2/sftp.pyx":330 +/* "ssh2/sftp.pyx":328 * return handle_error_codes(rc) * * def rmdir(self, path not None): # <<<<<<<<<<<<<< @@ -3562,7 +3562,7 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_23rmdir(PyObject *__pyx_v_self, PyOb __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rmdir (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 330, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 328, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_22rmdir(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), ((PyObject *)__pyx_v_path)); @@ -3586,19 +3586,19 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_22rmdir(struct __pyx_obj_4ssh2_4sftp int __pyx_t_3; __Pyx_RefNannySetupContext("rmdir", 0); - /* "ssh2/sftp.pyx":338 + /* "ssh2/sftp.pyx":336 * :rtype: int""" * cdef int rc * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 338, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":339 + /* "ssh2/sftp.pyx":337 * cdef int rc * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< @@ -3607,12 +3607,12 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_22rmdir(struct __pyx_obj_4ssh2_4sftp */ if (unlikely(__pyx_v_b_path == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 339, __pyx_L1_error) + __PYX_ERR(0, 337, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 339, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 337, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/sftp.pyx":340 + /* "ssh2/sftp.pyx":338 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * with nogil: # <<<<<<<<<<<<<< @@ -3627,7 +3627,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_22rmdir(struct __pyx_obj_4ssh2_4sftp #endif /*try:*/ { - /* "ssh2/sftp.pyx":341 + /* "ssh2/sftp.pyx":339 * cdef char *_path = b_path * with nogil: * rc = c_sftp.libssh2_sftp_rmdir(self._sftp, _path) # <<<<<<<<<<<<<< @@ -3637,7 +3637,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_22rmdir(struct __pyx_obj_4ssh2_4sftp __pyx_v_rc = libssh2_sftp_rmdir(__pyx_v_self->_sftp, __pyx_v__path); } - /* "ssh2/sftp.pyx":340 + /* "ssh2/sftp.pyx":338 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * with nogil: # <<<<<<<<<<<<<< @@ -3656,7 +3656,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_22rmdir(struct __pyx_obj_4ssh2_4sftp } } - /* "ssh2/sftp.pyx":342 + /* "ssh2/sftp.pyx":340 * with nogil: * rc = c_sftp.libssh2_sftp_rmdir(self._sftp, _path) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -3664,14 +3664,14 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_22rmdir(struct __pyx_obj_4ssh2_4sftp * def stat(self, path not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 342, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 342, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 340, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":330 + /* "ssh2/sftp.pyx":328 * return handle_error_codes(rc) * * def rmdir(self, path not None): # <<<<<<<<<<<<<< @@ -3691,7 +3691,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_22rmdir(struct __pyx_obj_4ssh2_4sftp return __pyx_r; } -/* "ssh2/sftp.pyx":344 +/* "ssh2/sftp.pyx":342 * return handle_error_codes(rc) * * def stat(self, path not None): # <<<<<<<<<<<<<< @@ -3707,7 +3707,7 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_25stat(PyObject *__pyx_v_self, PyObj __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stat (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 344, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 342, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_24stat(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), ((PyObject *)__pyx_v_path)); @@ -3733,19 +3733,19 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("stat", 0); - /* "ssh2/sftp.pyx":353 + /* "ssh2/sftp.pyx":351 * LIBSSH2_ERROR_EAGAIN""" * cdef int rc * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 353, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":354 + /* "ssh2/sftp.pyx":352 * cdef int rc * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< @@ -3754,24 +3754,24 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ */ if (unlikely(__pyx_v_b_path == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 354, __pyx_L1_error) + __PYX_ERR(0, 352, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 354, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 352, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/sftp.pyx":355 + /* "ssh2/sftp.pyx":353 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() # <<<<<<<<<<<<<< * with nogil: * rc = c_sftp.libssh2_sftp_stat( */ - __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 355, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_attrs = ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPAttributes *)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":356 + /* "ssh2/sftp.pyx":354 * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: # <<<<<<<<<<<<<< @@ -3786,7 +3786,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ #endif /*try:*/ { - /* "ssh2/sftp.pyx":357 + /* "ssh2/sftp.pyx":355 * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: * rc = c_sftp.libssh2_sftp_stat( # <<<<<<<<<<<<<< @@ -3796,7 +3796,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ __pyx_v_rc = libssh2_sftp_stat(__pyx_v_self->_sftp, __pyx_v__path, __pyx_v_attrs->_attrs); } - /* "ssh2/sftp.pyx":356 + /* "ssh2/sftp.pyx":354 * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: # <<<<<<<<<<<<<< @@ -3815,7 +3815,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ } } - /* "ssh2/sftp.pyx":359 + /* "ssh2/sftp.pyx":357 * rc = c_sftp.libssh2_sftp_stat( * self._sftp, _path, attrs._attrs) * return handle_error_codes(rc) if rc != 0 else attrs # <<<<<<<<<<<<<< @@ -3824,8 +3824,8 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ */ __Pyx_XDECREF(__pyx_r); if (((__pyx_v_rc != 0) != 0)) { - __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 359, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 359, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 357, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 357, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; @@ -3837,7 +3837,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":344 + /* "ssh2/sftp.pyx":342 * return handle_error_codes(rc) * * def stat(self, path not None): # <<<<<<<<<<<<<< @@ -3859,7 +3859,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_24stat(struct __pyx_obj_4ssh2_4sftp_ return __pyx_r; } -/* "ssh2/sftp.pyx":361 +/* "ssh2/sftp.pyx":359 * return handle_error_codes(rc) if rc != 0 else attrs * * def lstat(self, path not None): # <<<<<<<<<<<<<< @@ -3875,7 +3875,7 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_27lstat(PyObject *__pyx_v_self, PyOb __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("lstat (wrapper)", 0); if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 361, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 359, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_26lstat(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), ((PyObject *)__pyx_v_path)); @@ -3901,19 +3901,19 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("lstat", 0); - /* "ssh2/sftp.pyx":364 + /* "ssh2/sftp.pyx":362 * """Link stat a file.""" * cdef int rc * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 364, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":365 + /* "ssh2/sftp.pyx":363 * cdef int rc * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< @@ -3922,24 +3922,24 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp */ if (unlikely(__pyx_v_b_path == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 365, __pyx_L1_error) + __PYX_ERR(0, 363, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 363, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/sftp.pyx":366 + /* "ssh2/sftp.pyx":364 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() # <<<<<<<<<<<<<< * with nogil: * rc = c_sftp.libssh2_sftp_lstat( */ - __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 364, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_attrs = ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPAttributes *)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":367 + /* "ssh2/sftp.pyx":365 * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: # <<<<<<<<<<<<<< @@ -3954,7 +3954,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp #endif /*try:*/ { - /* "ssh2/sftp.pyx":368 + /* "ssh2/sftp.pyx":366 * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: * rc = c_sftp.libssh2_sftp_lstat( # <<<<<<<<<<<<<< @@ -3964,7 +3964,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp __pyx_v_rc = libssh2_sftp_lstat(__pyx_v_self->_sftp, __pyx_v__path, __pyx_v_attrs->_attrs); } - /* "ssh2/sftp.pyx":367 + /* "ssh2/sftp.pyx":365 * cdef char *_path = b_path * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: # <<<<<<<<<<<<<< @@ -3983,7 +3983,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp } } - /* "ssh2/sftp.pyx":370 + /* "ssh2/sftp.pyx":368 * rc = c_sftp.libssh2_sftp_lstat( * self._sftp, _path, attrs._attrs) * return handle_error_codes(rc) if rc != 0 else attrs # <<<<<<<<<<<<<< @@ -3992,8 +3992,8 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp */ __Pyx_XDECREF(__pyx_r); if (((__pyx_v_rc != 0) != 0)) { - __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 370, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 370, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 368, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; @@ -4005,7 +4005,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":361 + /* "ssh2/sftp.pyx":359 * return handle_error_codes(rc) if rc != 0 else attrs * * def lstat(self, path not None): # <<<<<<<<<<<<<< @@ -4027,7 +4027,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_26lstat(struct __pyx_obj_4ssh2_4sftp return __pyx_r; } -/* "ssh2/sftp.pyx":372 +/* "ssh2/sftp.pyx":370 * return handle_error_codes(rc) if rc != 0 else attrs * * def setstat(self, path not None, SFTPAttributes attrs): # <<<<<<<<<<<<<< @@ -4067,11 +4067,11 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_29setstat(PyObject *__pyx_v_self, Py case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_attrs)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("setstat", 1, 2, 2, 1); __PYX_ERR(0, 372, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("setstat", 1, 2, 2, 1); __PYX_ERR(0, 370, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "setstat") < 0)) __PYX_ERR(0, 372, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "setstat") < 0)) __PYX_ERR(0, 370, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -4084,16 +4084,16 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_29setstat(PyObject *__pyx_v_self, Py } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("setstat", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 372, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("setstat", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 370, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp.SFTP.setstat", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 372, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 370, __pyx_L1_error) } - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_attrs), __pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes, 1, "attrs", 0))) __PYX_ERR(0, 372, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_attrs), __pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes, 1, "attrs", 0))) __PYX_ERR(0, 370, __pyx_L1_error) __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_28setstat(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), __pyx_v_path, __pyx_v_attrs); /* function exit code */ @@ -4116,19 +4116,19 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_28setstat(struct __pyx_obj_4ssh2_4sf int __pyx_t_3; __Pyx_RefNannySetupContext("setstat", 0); - /* "ssh2/sftp.pyx":382 + /* "ssh2/sftp.pyx":380 * :rtype: int""" * cdef int rc * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 382, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 380, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":383 + /* "ssh2/sftp.pyx":381 * cdef int rc * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< @@ -4137,12 +4137,12 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_28setstat(struct __pyx_obj_4ssh2_4sf */ if (unlikely(__pyx_v_b_path == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 383, __pyx_L1_error) + __PYX_ERR(0, 381, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 381, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/sftp.pyx":384 + /* "ssh2/sftp.pyx":382 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * with nogil: # <<<<<<<<<<<<<< @@ -4157,7 +4157,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_28setstat(struct __pyx_obj_4ssh2_4sf #endif /*try:*/ { - /* "ssh2/sftp.pyx":385 + /* "ssh2/sftp.pyx":383 * cdef char *_path = b_path * with nogil: * rc = c_sftp.libssh2_sftp_setstat( # <<<<<<<<<<<<<< @@ -4167,7 +4167,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_28setstat(struct __pyx_obj_4ssh2_4sf __pyx_v_rc = libssh2_sftp_setstat(__pyx_v_self->_sftp, __pyx_v__path, __pyx_v_attrs->_attrs); } - /* "ssh2/sftp.pyx":384 + /* "ssh2/sftp.pyx":382 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * with nogil: # <<<<<<<<<<<<<< @@ -4186,7 +4186,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_28setstat(struct __pyx_obj_4ssh2_4sf } } - /* "ssh2/sftp.pyx":387 + /* "ssh2/sftp.pyx":385 * rc = c_sftp.libssh2_sftp_setstat( * self._sftp, _path, attrs._attrs) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -4194,14 +4194,14 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_28setstat(struct __pyx_obj_4ssh2_4sf * def symlink(self, path not None, target not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 387, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 387, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 385, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":372 + /* "ssh2/sftp.pyx":370 * return handle_error_codes(rc) if rc != 0 else attrs * * def setstat(self, path not None, SFTPAttributes attrs): # <<<<<<<<<<<<<< @@ -4221,7 +4221,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_28setstat(struct __pyx_obj_4ssh2_4sf return __pyx_r; } -/* "ssh2/sftp.pyx":389 +/* "ssh2/sftp.pyx":387 * return handle_error_codes(rc) * * def symlink(self, path not None, target not None): # <<<<<<<<<<<<<< @@ -4261,11 +4261,11 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_31symlink(PyObject *__pyx_v_self, Py case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_target)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("symlink", 1, 2, 2, 1); __PYX_ERR(0, 389, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("symlink", 1, 2, 2, 1); __PYX_ERR(0, 387, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "symlink") < 0)) __PYX_ERR(0, 389, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "symlink") < 0)) __PYX_ERR(0, 387, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -4278,17 +4278,17 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_31symlink(PyObject *__pyx_v_self, Py } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("symlink", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 389, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("symlink", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 387, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp.SFTP.symlink", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 389, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 387, __pyx_L1_error) } if (unlikely(((PyObject *)__pyx_v_target) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "target"); __PYX_ERR(0, 389, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "target"); __PYX_ERR(0, 387, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_30symlink(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), __pyx_v_path, __pyx_v_target); @@ -4314,19 +4314,19 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_30symlink(struct __pyx_obj_4ssh2_4sf int __pyx_t_3; __Pyx_RefNannySetupContext("symlink", 0); - /* "ssh2/sftp.pyx":399 + /* "ssh2/sftp.pyx":397 * :rtype: int""" * cdef int rc * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * cdef bytes b_target = to_bytes(target) */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 399, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_path = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":400 + /* "ssh2/sftp.pyx":398 * cdef int rc * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< @@ -4335,24 +4335,24 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_30symlink(struct __pyx_obj_4ssh2_4sf */ if (unlikely(__pyx_v_b_path == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 400, __pyx_L1_error) + __PYX_ERR(0, 398, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 398, __pyx_L1_error) __pyx_v__path = __pyx_t_2; - /* "ssh2/sftp.pyx":401 + /* "ssh2/sftp.pyx":399 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * cdef bytes b_target = to_bytes(target) # <<<<<<<<<<<<<< * cdef char *_target = b_target * with nogil: */ - __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_target); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 401, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_target); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 399, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_b_target = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp.pyx":402 + /* "ssh2/sftp.pyx":400 * cdef char *_path = b_path * cdef bytes b_target = to_bytes(target) * cdef char *_target = b_target # <<<<<<<<<<<<<< @@ -4361,12 +4361,12 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_30symlink(struct __pyx_obj_4ssh2_4sf */ if (unlikely(__pyx_v_b_target == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 402, __pyx_L1_error) + __PYX_ERR(0, 400, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_target); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 402, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_target); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L1_error) __pyx_v__target = __pyx_t_2; - /* "ssh2/sftp.pyx":403 + /* "ssh2/sftp.pyx":401 * cdef bytes b_target = to_bytes(target) * cdef char *_target = b_target * with nogil: # <<<<<<<<<<<<<< @@ -4381,7 +4381,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_30symlink(struct __pyx_obj_4ssh2_4sf #endif /*try:*/ { - /* "ssh2/sftp.pyx":404 + /* "ssh2/sftp.pyx":402 * cdef char *_target = b_target * with nogil: * rc = c_sftp.libssh2_sftp_symlink(self._sftp, _path, _target) # <<<<<<<<<<<<<< @@ -4391,7 +4391,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_30symlink(struct __pyx_obj_4ssh2_4sf __pyx_v_rc = libssh2_sftp_symlink(__pyx_v_self->_sftp, __pyx_v__path, __pyx_v__target); } - /* "ssh2/sftp.pyx":403 + /* "ssh2/sftp.pyx":401 * cdef bytes b_target = to_bytes(target) * cdef char *_target = b_target * with nogil: # <<<<<<<<<<<<<< @@ -4410,7 +4410,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_30symlink(struct __pyx_obj_4ssh2_4sf } } - /* "ssh2/sftp.pyx":405 + /* "ssh2/sftp.pyx":403 * with nogil: * rc = c_sftp.libssh2_sftp_symlink(self._sftp, _path, _target) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -4418,14 +4418,14 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_30symlink(struct __pyx_obj_4ssh2_4sf * def realpath(self, path not None, size_t max_len=256): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 405, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 405, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 403, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":389 + /* "ssh2/sftp.pyx":387 * return handle_error_codes(rc) * * def symlink(self, path not None, target not None): # <<<<<<<<<<<<<< @@ -4446,7 +4446,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_30symlink(struct __pyx_obj_4ssh2_4sf return __pyx_r; } -/* "ssh2/sftp.pyx":407 +/* "ssh2/sftp.pyx":405 * return handle_error_codes(rc) * * def realpath(self, path not None, size_t max_len=256): # <<<<<<<<<<<<<< @@ -4490,7 +4490,7 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_33realpath(PyObject *__pyx_v_self, P } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "realpath") < 0)) __PYX_ERR(0, 407, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "realpath") < 0)) __PYX_ERR(0, 405, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -4503,21 +4503,21 @@ static PyObject *__pyx_pw_4ssh2_4sftp_4SFTP_33realpath(PyObject *__pyx_v_self, P } __pyx_v_path = values[0]; if (values[1]) { - __pyx_v_max_len = __Pyx_PyInt_As_size_t(values[1]); if (unlikely((__pyx_v_max_len == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L3_error) + __pyx_v_max_len = __Pyx_PyInt_As_size_t(values[1]); if (unlikely((__pyx_v_max_len == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 405, __pyx_L3_error) } else { __pyx_v_max_len = ((size_t)0x100); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("realpath", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 407, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("realpath", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 405, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp.SFTP.realpath", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_path) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 407, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "path"); __PYX_ERR(0, 405, __pyx_L1_error) } __pyx_r = __pyx_pf_4ssh2_4sftp_4SFTP_32realpath(((struct __pyx_obj_4ssh2_4sftp_SFTP *)__pyx_v_self), __pyx_v_path, __pyx_v_max_len); @@ -4551,7 +4551,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s PyObject *__pyx_t_12 = NULL; __Pyx_RefNannySetupContext("realpath", 0); - /* "ssh2/sftp.pyx":419 + /* "ssh2/sftp.pyx":417 * :raises: :py:class:`ssh2.exceptions.SFTPBufferTooSmall` on max_len less * than real path length.""" * cdef char *_target = malloc(sizeof(char)*max_len) # <<<<<<<<<<<<<< @@ -4560,7 +4560,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s */ __pyx_v__target = ((char *)malloc(((sizeof(char)) * __pyx_v_max_len))); - /* "ssh2/sftp.pyx":420 + /* "ssh2/sftp.pyx":418 * than real path length.""" * cdef char *_target = malloc(sizeof(char)*max_len) * if _target is NULL: # <<<<<<<<<<<<<< @@ -4570,16 +4570,16 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s __pyx_t_1 = ((__pyx_v__target == NULL) != 0); if (unlikely(__pyx_t_1)) { - /* "ssh2/sftp.pyx":421 + /* "ssh2/sftp.pyx":419 * cdef char *_target = malloc(sizeof(char)*max_len) * if _target is NULL: * raise MemoryError # <<<<<<<<<<<<<< * cdef int rc * cdef bytes b_path = to_bytes(path) */ - PyErr_NoMemory(); __PYX_ERR(0, 421, __pyx_L1_error) + PyErr_NoMemory(); __PYX_ERR(0, 419, __pyx_L1_error) - /* "ssh2/sftp.pyx":420 + /* "ssh2/sftp.pyx":418 * than real path length.""" * cdef char *_target = malloc(sizeof(char)*max_len) * if _target is NULL: # <<<<<<<<<<<<<< @@ -4588,19 +4588,19 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s */ } - /* "ssh2/sftp.pyx":423 + /* "ssh2/sftp.pyx":421 * raise MemoryError * cdef int rc * cdef bytes b_path = to_bytes(path) # <<<<<<<<<<<<<< * cdef char *_path = b_path * try: */ - __pyx_t_2 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 423, __pyx_L1_error) + __pyx_t_2 = __pyx_f_4ssh2_5utils_to_bytes(__pyx_v_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_b_path = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "ssh2/sftp.pyx":424 + /* "ssh2/sftp.pyx":422 * cdef int rc * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path # <<<<<<<<<<<<<< @@ -4609,12 +4609,12 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s */ if (unlikely(__pyx_v_b_path == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 424, __pyx_L1_error) + __PYX_ERR(0, 422, __pyx_L1_error) } - __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 424, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v_b_path); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 422, __pyx_L1_error) __pyx_v__path = __pyx_t_3; - /* "ssh2/sftp.pyx":425 + /* "ssh2/sftp.pyx":423 * cdef bytes b_path = to_bytes(path) * cdef char *_path = b_path * try: # <<<<<<<<<<<<<< @@ -4623,7 +4623,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s */ /*try:*/ { - /* "ssh2/sftp.pyx":426 + /* "ssh2/sftp.pyx":424 * cdef char *_path = b_path * try: * with nogil: # <<<<<<<<<<<<<< @@ -4638,7 +4638,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s #endif /*try:*/ { - /* "ssh2/sftp.pyx":427 + /* "ssh2/sftp.pyx":425 * try: * with nogil: * rc = c_sftp.libssh2_sftp_realpath( # <<<<<<<<<<<<<< @@ -4647,7 +4647,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s */ __pyx_v_rc = libssh2_sftp_realpath(__pyx_v_self->_sftp, __pyx_v__path, __pyx_v__target, __pyx_v_max_len); - /* "ssh2/sftp.pyx":429 + /* "ssh2/sftp.pyx":427 * rc = c_sftp.libssh2_sftp_realpath( * self._sftp, _path, _target, max_len) * if rc < 0: # <<<<<<<<<<<<<< @@ -4657,7 +4657,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s __pyx_t_1 = ((__pyx_v_rc < 0) != 0); if (__pyx_t_1) { - /* "ssh2/sftp.pyx":430 + /* "ssh2/sftp.pyx":428 * self._sftp, _path, _target, max_len) * if rc < 0: * with gil: # <<<<<<<<<<<<<< @@ -4670,7 +4670,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s #endif /*try:*/ { - /* "ssh2/sftp.pyx":431 + /* "ssh2/sftp.pyx":429 * if rc < 0: * with gil: * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -4678,15 +4678,15 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s * finally: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 431, __pyx_L12_error) - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 431, __pyx_L12_error) + __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 429, __pyx_L12_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 429, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L11_return; } - /* "ssh2/sftp.pyx":430 + /* "ssh2/sftp.pyx":428 * self._sftp, _path, _target, max_len) * if rc < 0: * with gil: # <<<<<<<<<<<<<< @@ -4709,7 +4709,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s } } - /* "ssh2/sftp.pyx":429 + /* "ssh2/sftp.pyx":427 * rc = c_sftp.libssh2_sftp_realpath( * self._sftp, _path, _target, max_len) * if rc < 0: # <<<<<<<<<<<<<< @@ -4719,7 +4719,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s } } - /* "ssh2/sftp.pyx":426 + /* "ssh2/sftp.pyx":424 * cdef char *_path = b_path * try: * with nogil: # <<<<<<<<<<<<<< @@ -4752,7 +4752,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s } } - /* "ssh2/sftp.pyx":432 + /* "ssh2/sftp.pyx":430 * with gil: * return handle_error_codes(rc) * return to_str_len(_target, rc) # <<<<<<<<<<<<<< @@ -4760,14 +4760,14 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s * free(_target) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_f_4ssh2_5utils_to_str_len(__pyx_v__target, __pyx_v_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 432, __pyx_L5_error) + __pyx_t_2 = __pyx_f_4ssh2_5utils_to_str_len(__pyx_v__target, __pyx_v_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 430, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L4_return; } - /* "ssh2/sftp.pyx":434 + /* "ssh2/sftp.pyx":432 * return to_str_len(_target, rc) * finally: * free(_target) # <<<<<<<<<<<<<< @@ -4817,7 +4817,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s } } - /* "ssh2/sftp.pyx":407 + /* "ssh2/sftp.pyx":405 * return handle_error_codes(rc) * * def realpath(self, path not None, size_t max_len=256): # <<<<<<<<<<<<<< @@ -4837,7 +4837,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_32realpath(struct __pyx_obj_4ssh2_4s return __pyx_r; } -/* "ssh2/sftp.pyx":436 +/* "ssh2/sftp.pyx":434 * free(_target) * * def last_error(self): # <<<<<<<<<<<<<< @@ -4866,7 +4866,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_34last_error(struct __pyx_obj_4ssh2_ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("last_error", 0); - /* "ssh2/sftp.pyx":441 + /* "ssh2/sftp.pyx":439 * :rtype: int""" * cdef unsigned long rc * with nogil: # <<<<<<<<<<<<<< @@ -4881,7 +4881,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_34last_error(struct __pyx_obj_4ssh2_ #endif /*try:*/ { - /* "ssh2/sftp.pyx":442 + /* "ssh2/sftp.pyx":440 * cdef unsigned long rc * with nogil: * rc = c_sftp.libssh2_sftp_last_error(self._sftp) # <<<<<<<<<<<<<< @@ -4890,7 +4890,7 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_34last_error(struct __pyx_obj_4ssh2_ __pyx_v_rc = libssh2_sftp_last_error(__pyx_v_self->_sftp); } - /* "ssh2/sftp.pyx":441 + /* "ssh2/sftp.pyx":439 * :rtype: int""" * cdef unsigned long rc * with nogil: # <<<<<<<<<<<<<< @@ -4909,19 +4909,19 @@ static PyObject *__pyx_pf_4ssh2_4sftp_4SFTP_34last_error(struct __pyx_obj_4ssh2_ } } - /* "ssh2/sftp.pyx":443 + /* "ssh2/sftp.pyx":441 * with nogil: * rc = c_sftp.libssh2_sftp_last_error(self._sftp) * return rc # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 443, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp.pyx":436 + /* "ssh2/sftp.pyx":434 * free(_target) * * def last_error(self): # <<<<<<<<<<<<<< @@ -5299,7 +5299,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 421, __pyx_L1_error) + __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 419, __pyx_L1_error) __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error) return 0; __pyx_L1_error:; diff --git a/ssh2/sftp.pyx b/ssh2/sftp.pyx index 07b336b3..db6c93a8 100644 --- a/ssh2/sftp.pyx +++ b/ssh2/sftp.pyx @@ -213,15 +213,13 @@ cdef class SFTP: mode is ``LIBSSH2_SFTP_S_IRUSR | LIBSSH2_SFTP_S_IWUSR | \`` - ``LIBSSH2_SFTP_S_IRGRP | LIBSSH2_SFTP_S_IWGRP | \`` - ``LIBSSH2_SFTP_S_IROTH`` :type mode: int :raises: :py:class:`ssh2.exceptions.SFTPHandleError` on errors opening file. - """ + """ # noqa: W605 cdef c_sftp.LIBSSH2_SFTP_HANDLE *_handle cdef bytes b_filename = to_bytes(filename) cdef char *_filename = b_filename diff --git a/ssh2/sftp_handle.c b/ssh2/sftp_handle.c index 2a471943..02078c33 100644 --- a/ssh2/sftp_handle.c +++ b/ssh2/sftp_handle.c @@ -5700,7 +5700,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_24_readdir(struct __p /* Python wrapper */ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_27write(PyObject *__pyx_v_self, PyObject *__pyx_v_buf); /*proto*/ -static char __pyx_doc_4ssh2_11sftp_handle_10SFTPHandle_26write[] = "SFTPHandle.write(self, bytes buf)\nWrite buffer to file handle.\n\n :param buf: Buffer to write.\n :type buf: bytes\n\n :rtype: int"; +static char __pyx_doc_4ssh2_11sftp_handle_10SFTPHandle_26write[] = "SFTPHandle.write(self, bytes buf)\nWrite buffer to file handle.\n\n Returns tuple of (``error code``, ``bytes written``).\n\n In blocking mode ``bytes_written`` will always equal ``len(buf)`` if no\n errors have occurred which would raise exception.\n\n In non-blocking mode ``error_code`` can be LIBSSH2_ERROR_EAGAIN and\n ``bytes_written`` *can be less than* ``len(buf)``.\n\n Clients should resume from that point on next call to ``write``, ie\n ``buf[bytes_written_in_last_call:]``.\n\n :param buf: Buffer to write.\n :type buf: bytes\n\n :rtype: tuple(int, int)"; static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_27write(PyObject *__pyx_v_self, PyObject *__pyx_v_buf) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -5719,6 +5719,8 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_27write(PyObject *__p static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_26write(struct __pyx_obj_4ssh2_11sftp_handle_SFTPHandle *__pyx_v_self, PyObject *__pyx_v_buf) { size_t __pyx_v__size; + size_t __pyx_v_tot_size; + size_t __pyx_v_bytes_written; char *__pyx_v_cbuf; Py_ssize_t __pyx_v_rc; PyObject *__pyx_r = NULL; @@ -5727,39 +5729,60 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_26write(struct __pyx_ char *__pyx_t_2; int __pyx_t_3; int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("write", 0); - /* "ssh2/sftp_handle.pyx":269 + /* "ssh2/sftp_handle.pyx":280 * - * :rtype: int""" + * :rtype: tuple(int, int)""" * cdef size_t _size = len(buf) # <<<<<<<<<<<<<< - * cdef char *cbuf = buf - * cdef ssize_t rc = 0 + * cdef size_t tot_size = _size + * cdef size_t bytes_written = 0 */ if (unlikely(__pyx_v_buf == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 269, __pyx_L1_error) + __PYX_ERR(0, 280, __pyx_L1_error) } - __pyx_t_1 = PyBytes_GET_SIZE(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 269, __pyx_L1_error) + __pyx_t_1 = PyBytes_GET_SIZE(__pyx_v_buf); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 280, __pyx_L1_error) __pyx_v__size = __pyx_t_1; - /* "ssh2/sftp_handle.pyx":270 - * :rtype: int""" + /* "ssh2/sftp_handle.pyx":281 + * :rtype: tuple(int, int)""" + * cdef size_t _size = len(buf) + * cdef size_t tot_size = _size # <<<<<<<<<<<<<< + * cdef size_t bytes_written = 0 + * cdef char *cbuf = buf + */ + __pyx_v_tot_size = __pyx_v__size; + + /* "ssh2/sftp_handle.pyx":282 * cdef size_t _size = len(buf) + * cdef size_t tot_size = _size + * cdef size_t bytes_written = 0 # <<<<<<<<<<<<<< + * cdef char *cbuf = buf + * cdef ssize_t rc = 0 + */ + __pyx_v_bytes_written = 0; + + /* "ssh2/sftp_handle.pyx":283 + * cdef size_t tot_size = _size + * cdef size_t bytes_written = 0 * cdef char *cbuf = buf # <<<<<<<<<<<<<< * cdef ssize_t rc = 0 * with nogil: */ if (unlikely(__pyx_v_buf == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 270, __pyx_L1_error) + __PYX_ERR(0, 283, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 270, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 283, __pyx_L1_error) __pyx_v_cbuf = __pyx_t_2; - /* "ssh2/sftp_handle.pyx":271 - * cdef size_t _size = len(buf) + /* "ssh2/sftp_handle.pyx":284 + * cdef size_t bytes_written = 0 * cdef char *cbuf = buf * cdef ssize_t rc = 0 # <<<<<<<<<<<<<< * with nogil: @@ -5767,7 +5790,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_26write(struct __pyx_ */ __pyx_v_rc = 0; - /* "ssh2/sftp_handle.pyx":272 + /* "ssh2/sftp_handle.pyx":285 * cdef char *cbuf = buf * cdef ssize_t rc = 0 * with nogil: # <<<<<<<<<<<<<< @@ -5782,76 +5805,164 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_26write(struct __pyx_ #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":273 + /* "ssh2/sftp_handle.pyx":286 * cdef ssize_t rc = 0 * with nogil: * while _size > 0: # <<<<<<<<<<<<<< * rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) - * if rc < 0: + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: */ while (1) { __pyx_t_3 = ((__pyx_v__size > 0) != 0); if (!__pyx_t_3) break; - /* "ssh2/sftp_handle.pyx":274 + /* "ssh2/sftp_handle.pyx":287 * with nogil: * while _size > 0: * rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) # <<<<<<<<<<<<<< - * if rc < 0: - * break + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * # Error we cannot resume from, exception will be raised */ __pyx_v_rc = libssh2_sftp_write(__pyx_v_self->_handle, __pyx_v_cbuf, __pyx_v__size); - /* "ssh2/sftp_handle.pyx":275 + /* "ssh2/sftp_handle.pyx":288 + * while _size > 0: + * rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * # Error we cannot resume from, exception will be raised + * with gil: + */ + __pyx_t_4 = ((__pyx_v_rc < 0) != 0); + if (__pyx_t_4) { + } else { + __pyx_t_3 = __pyx_t_4; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_4 = ((__pyx_v_rc != LIBSSH2_ERROR_EAGAIN) != 0); + __pyx_t_3 = __pyx_t_4; + __pyx_L9_bool_binop_done:; + if (__pyx_t_3) { + + /* "ssh2/sftp_handle.pyx":290 + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * # Error we cannot resume from, exception will be raised + * with gil: # <<<<<<<<<<<<<< + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + */ + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + /*try:*/ { + + /* "ssh2/sftp_handle.pyx":291 + * # Error we cannot resume from, exception will be raised + * with gil: + * return handle_error_codes(rc) # <<<<<<<<<<<<<< + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + * break + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_5 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 291, __pyx_L14_error) + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 291, __pyx_L14_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_r = __pyx_t_6; + __pyx_t_6 = 0; + goto __pyx_L13_return; + } + + /* "ssh2/sftp_handle.pyx":290 + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + * # Error we cannot resume from, exception will be raised + * with gil: # <<<<<<<<<<<<<< + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: + */ + /*finally:*/ { + __pyx_L13_return: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L3_return; + } + __pyx_L14_error: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L4_error; + } + } + } + + /* "ssh2/sftp_handle.pyx":288 * while _size > 0: * rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) - * if rc < 0: # <<<<<<<<<<<<<< + * if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< + * # Error we cannot resume from, exception will be raised + * with gil: + */ + } + + /* "ssh2/sftp_handle.pyx":292 + * with gil: + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< * break * cbuf += rc */ - __pyx_t_3 = ((__pyx_v_rc < 0) != 0); + __pyx_t_3 = ((__pyx_v_rc == LIBSSH2_ERROR_EAGAIN) != 0); if (__pyx_t_3) { - /* "ssh2/sftp_handle.pyx":276 - * rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) - * if rc < 0: + /* "ssh2/sftp_handle.pyx":293 + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: * break # <<<<<<<<<<<<<< * cbuf += rc * _size -= rc */ goto __pyx_L7_break; - /* "ssh2/sftp_handle.pyx":275 - * while _size > 0: - * rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) - * if rc < 0: # <<<<<<<<<<<<<< + /* "ssh2/sftp_handle.pyx":292 + * with gil: + * return handle_error_codes(rc) + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: # <<<<<<<<<<<<<< * break * cbuf += rc */ } - /* "ssh2/sftp_handle.pyx":277 - * if rc < 0: + /* "ssh2/sftp_handle.pyx":294 + * elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: * break * cbuf += rc # <<<<<<<<<<<<<< * _size -= rc - * + * bytes_written = tot_size - _size */ __pyx_v_cbuf = (__pyx_v_cbuf + __pyx_v_rc); - /* "ssh2/sftp_handle.pyx":278 + /* "ssh2/sftp_handle.pyx":295 * break * cbuf += rc * _size -= rc # <<<<<<<<<<<<<< - * - * return handle_error_codes(rc) + * bytes_written = tot_size - _size + * return rc, bytes_written */ __pyx_v__size = (__pyx_v__size - __pyx_v_rc); } __pyx_L7_break:; + + /* "ssh2/sftp_handle.pyx":296 + * cbuf += rc + * _size -= rc + * bytes_written = tot_size - _size # <<<<<<<<<<<<<< + * return rc, bytes_written + * + */ + __pyx_v_bytes_written = (__pyx_v_tot_size - __pyx_v__size); } - /* "ssh2/sftp_handle.pyx":272 + /* "ssh2/sftp_handle.pyx":285 * cdef char *cbuf = buf * cdef ssize_t rc = 0 * with nogil: # <<<<<<<<<<<<<< @@ -5866,23 +5977,46 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_26write(struct __pyx_ #endif goto __pyx_L5; } + __pyx_L3_return: { + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L0; + } + __pyx_L4_error: { + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L1_error; + } __pyx_L5:; } } - /* "ssh2/sftp_handle.pyx":280 + /* "ssh2/sftp_handle.pyx":297 * _size -= rc - * - * return handle_error_codes(rc) # <<<<<<<<<<<<<< + * bytes_written = tot_size - _size + * return rc, bytes_written # <<<<<<<<<<<<<< * * IF EMBEDDED_LIB: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 280, __pyx_L1_error) - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 280, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; + __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_rc); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 297, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = __Pyx_PyInt_FromSize_t(__pyx_v_bytes_written); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 297, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 297, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); + __pyx_t_6 = 0; + __pyx_t_7 = 0; + __pyx_r = __pyx_t_8; + __pyx_t_8 = 0; goto __pyx_L0; /* "ssh2/sftp_handle.pyx":262 @@ -5895,7 +6029,9 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_26write(struct __pyx_ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("ssh2.sftp_handle.SFTPHandle.write", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -5904,7 +6040,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_26write(struct __pyx_ return __pyx_r; } -/* "ssh2/sftp_handle.pyx":283 +/* "ssh2/sftp_handle.pyx":300 * * IF EMBEDDED_LIB: * def fsync(self): # <<<<<<<<<<<<<< @@ -5934,7 +6070,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_28fsync(struct __pyx_ PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("fsync", 0); - /* "ssh2/sftp_handle.pyx":290 + /* "ssh2/sftp_handle.pyx":307 * :rtype: int""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -5949,7 +6085,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_28fsync(struct __pyx_ #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":291 + /* "ssh2/sftp_handle.pyx":308 * cdef int rc * with nogil: * rc = c_sftp.libssh2_sftp_fsync(self._handle) # <<<<<<<<<<<<<< @@ -5959,7 +6095,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_28fsync(struct __pyx_ __pyx_v_rc = libssh2_sftp_fsync(__pyx_v_self->_handle); } - /* "ssh2/sftp_handle.pyx":290 + /* "ssh2/sftp_handle.pyx":307 * :rtype: int""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -5978,7 +6114,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_28fsync(struct __pyx_ } } - /* "ssh2/sftp_handle.pyx":292 + /* "ssh2/sftp_handle.pyx":309 * with nogil: * rc = c_sftp.libssh2_sftp_fsync(self._handle) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -5986,14 +6122,14 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_28fsync(struct __pyx_ * def seek(self, size_t offset): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 292, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 292, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 309, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 309, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":283 + /* "ssh2/sftp_handle.pyx":300 * * IF EMBEDDED_LIB: * def fsync(self): # <<<<<<<<<<<<<< @@ -6012,7 +6148,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_28fsync(struct __pyx_ return __pyx_r; } -/* "ssh2/sftp_handle.pyx":294 +/* "ssh2/sftp_handle.pyx":311 * return handle_error_codes(rc) * * def seek(self, size_t offset): # <<<<<<<<<<<<<< @@ -6029,7 +6165,7 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_31seek(PyObject *__py __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("seek (wrapper)", 0); assert(__pyx_arg_offset); { - __pyx_v_offset = __Pyx_PyInt_As_size_t(__pyx_arg_offset); if (unlikely((__pyx_v_offset == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 294, __pyx_L3_error) + __pyx_v_offset = __Pyx_PyInt_As_size_t(__pyx_arg_offset); if (unlikely((__pyx_v_offset == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 311, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -6049,7 +6185,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_30seek(struct __pyx_o __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("seek", 0); - /* "ssh2/sftp_handle.pyx":303 + /* "ssh2/sftp_handle.pyx":320 * * :rtype: None""" * with nogil: # <<<<<<<<<<<<<< @@ -6064,7 +6200,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_30seek(struct __pyx_o #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":304 + /* "ssh2/sftp_handle.pyx":321 * :rtype: None""" * with nogil: * c_sftp.libssh2_sftp_seek(self._handle, offset) # <<<<<<<<<<<<<< @@ -6074,7 +6210,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_30seek(struct __pyx_o libssh2_sftp_seek(__pyx_v_self->_handle, __pyx_v_offset); } - /* "ssh2/sftp_handle.pyx":303 + /* "ssh2/sftp_handle.pyx":320 * * :rtype: None""" * with nogil: # <<<<<<<<<<<<<< @@ -6093,7 +6229,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_30seek(struct __pyx_o } } - /* "ssh2/sftp_handle.pyx":294 + /* "ssh2/sftp_handle.pyx":311 * return handle_error_codes(rc) * * def seek(self, size_t offset): # <<<<<<<<<<<<<< @@ -6108,7 +6244,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_30seek(struct __pyx_o return __pyx_r; } -/* "ssh2/sftp_handle.pyx":306 +/* "ssh2/sftp_handle.pyx":323 * c_sftp.libssh2_sftp_seek(self._handle, offset) * * def seek64(self, c_ssh2.libssh2_uint64_t offset): # <<<<<<<<<<<<<< @@ -6125,7 +6261,7 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_33seek64(PyObject *__ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("seek64 (wrapper)", 0); assert(__pyx_arg_offset); { - __pyx_v_offset = __Pyx_PyInt_As_libssh2_uint64_t(__pyx_arg_offset); if (unlikely((__pyx_v_offset == ((libssh2_uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 306, __pyx_L3_error) + __pyx_v_offset = __Pyx_PyInt_As_libssh2_uint64_t(__pyx_arg_offset); if (unlikely((__pyx_v_offset == ((libssh2_uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 323, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -6145,7 +6281,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_32seek64(struct __pyx __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("seek64", 0); - /* "ssh2/sftp_handle.pyx":313 + /* "ssh2/sftp_handle.pyx":330 * * :rtype: None""" * with nogil: # <<<<<<<<<<<<<< @@ -6160,7 +6296,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_32seek64(struct __pyx #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":314 + /* "ssh2/sftp_handle.pyx":331 * :rtype: None""" * with nogil: * c_sftp.libssh2_sftp_seek64(self._handle, offset) # <<<<<<<<<<<<<< @@ -6170,7 +6306,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_32seek64(struct __pyx libssh2_sftp_seek64(__pyx_v_self->_handle, __pyx_v_offset); } - /* "ssh2/sftp_handle.pyx":313 + /* "ssh2/sftp_handle.pyx":330 * * :rtype: None""" * with nogil: # <<<<<<<<<<<<<< @@ -6189,7 +6325,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_32seek64(struct __pyx } } - /* "ssh2/sftp_handle.pyx":306 + /* "ssh2/sftp_handle.pyx":323 * c_sftp.libssh2_sftp_seek(self._handle, offset) * * def seek64(self, c_ssh2.libssh2_uint64_t offset): # <<<<<<<<<<<<<< @@ -6204,7 +6340,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_32seek64(struct __pyx return __pyx_r; } -/* "ssh2/sftp_handle.pyx":316 +/* "ssh2/sftp_handle.pyx":333 * c_sftp.libssh2_sftp_seek64(self._handle, offset) * * def rewind(self): # <<<<<<<<<<<<<< @@ -6231,7 +6367,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_34rewind(struct __pyx __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rewind", 0); - /* "ssh2/sftp_handle.pyx":320 + /* "ssh2/sftp_handle.pyx":337 * * :rtype: None""" * with nogil: # <<<<<<<<<<<<<< @@ -6246,7 +6382,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_34rewind(struct __pyx #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":321 + /* "ssh2/sftp_handle.pyx":338 * :rtype: None""" * with nogil: * c_sftp.libssh2_sftp_rewind(self._handle) # <<<<<<<<<<<<<< @@ -6256,7 +6392,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_34rewind(struct __pyx libssh2_sftp_rewind(__pyx_v_self->_handle); } - /* "ssh2/sftp_handle.pyx":320 + /* "ssh2/sftp_handle.pyx":337 * * :rtype: None""" * with nogil: # <<<<<<<<<<<<<< @@ -6275,7 +6411,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_34rewind(struct __pyx } } - /* "ssh2/sftp_handle.pyx":316 + /* "ssh2/sftp_handle.pyx":333 * c_sftp.libssh2_sftp_seek64(self._handle, offset) * * def rewind(self): # <<<<<<<<<<<<<< @@ -6290,7 +6426,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_34rewind(struct __pyx return __pyx_r; } -/* "ssh2/sftp_handle.pyx":323 +/* "ssh2/sftp_handle.pyx":340 * c_sftp.libssh2_sftp_rewind(self._handle) * * def tell(self): # <<<<<<<<<<<<<< @@ -6320,7 +6456,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_36tell(struct __pyx_o PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("tell", 0); - /* "ssh2/sftp_handle.pyx":330 + /* "ssh2/sftp_handle.pyx":347 * :rtype: int""" * cdef size_t rc * with nogil: # <<<<<<<<<<<<<< @@ -6335,7 +6471,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_36tell(struct __pyx_o #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":331 + /* "ssh2/sftp_handle.pyx":348 * cdef size_t rc * with nogil: * rc = c_sftp.libssh2_sftp_tell(self._handle) # <<<<<<<<<<<<<< @@ -6345,7 +6481,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_36tell(struct __pyx_o __pyx_v_rc = libssh2_sftp_tell(__pyx_v_self->_handle); } - /* "ssh2/sftp_handle.pyx":330 + /* "ssh2/sftp_handle.pyx":347 * :rtype: int""" * cdef size_t rc * with nogil: # <<<<<<<<<<<<<< @@ -6364,7 +6500,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_36tell(struct __pyx_o } } - /* "ssh2/sftp_handle.pyx":332 + /* "ssh2/sftp_handle.pyx":349 * with nogil: * rc = c_sftp.libssh2_sftp_tell(self._handle) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -6372,14 +6508,14 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_36tell(struct __pyx_o * def tell64(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 332, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 332, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 349, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":323 + /* "ssh2/sftp_handle.pyx":340 * c_sftp.libssh2_sftp_rewind(self._handle) * * def tell(self): # <<<<<<<<<<<<<< @@ -6398,7 +6534,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_36tell(struct __pyx_o return __pyx_r; } -/* "ssh2/sftp_handle.pyx":334 +/* "ssh2/sftp_handle.pyx":351 * return handle_error_codes(rc) * * def tell64(self): # <<<<<<<<<<<<<< @@ -6428,7 +6564,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_38tell64(struct __pyx PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("tell64", 0); - /* "ssh2/sftp_handle.pyx":339 + /* "ssh2/sftp_handle.pyx":356 * :rtype: int""" * cdef c_ssh2.libssh2_uint64_t rc * with nogil: # <<<<<<<<<<<<<< @@ -6443,7 +6579,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_38tell64(struct __pyx #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":340 + /* "ssh2/sftp_handle.pyx":357 * cdef c_ssh2.libssh2_uint64_t rc * with nogil: * rc = c_sftp.libssh2_sftp_tell(self._handle) # <<<<<<<<<<<<<< @@ -6453,7 +6589,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_38tell64(struct __pyx __pyx_v_rc = libssh2_sftp_tell(__pyx_v_self->_handle); } - /* "ssh2/sftp_handle.pyx":339 + /* "ssh2/sftp_handle.pyx":356 * :rtype: int""" * cdef c_ssh2.libssh2_uint64_t rc * with nogil: # <<<<<<<<<<<<<< @@ -6472,7 +6608,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_38tell64(struct __pyx } } - /* "ssh2/sftp_handle.pyx":341 + /* "ssh2/sftp_handle.pyx":358 * with nogil: * rc = c_sftp.libssh2_sftp_tell(self._handle) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -6480,14 +6616,14 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_38tell64(struct __pyx * def fstat_ex(self, SFTPAttributes attrs, int setstat): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 341, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 341, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 358, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":334 + /* "ssh2/sftp_handle.pyx":351 * return handle_error_codes(rc) * * def tell64(self): # <<<<<<<<<<<<<< @@ -6506,7 +6642,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_38tell64(struct __pyx return __pyx_r; } -/* "ssh2/sftp_handle.pyx":343 +/* "ssh2/sftp_handle.pyx":360 * return handle_error_codes(rc) * * def fstat_ex(self, SFTPAttributes attrs, int setstat): # <<<<<<<<<<<<<< @@ -6546,11 +6682,11 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_41fstat_ex(PyObject * case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_setstat)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("fstat_ex", 1, 2, 2, 1); __PYX_ERR(0, 343, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fstat_ex", 1, 2, 2, 1); __PYX_ERR(0, 360, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fstat_ex") < 0)) __PYX_ERR(0, 343, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fstat_ex") < 0)) __PYX_ERR(0, 360, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -6559,17 +6695,17 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_41fstat_ex(PyObject * values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_attrs = ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPAttributes *)values[0]); - __pyx_v_setstat = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_setstat == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 343, __pyx_L3_error) + __pyx_v_setstat = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_setstat == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 360, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("fstat_ex", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 343, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("fstat_ex", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 360, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp_handle.SFTPHandle.fstat_ex", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_attrs), __pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes, 1, "attrs", 0))) __PYX_ERR(0, 343, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_attrs), __pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes, 1, "attrs", 0))) __PYX_ERR(0, 360, __pyx_L1_error) __pyx_r = __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat_ex(((struct __pyx_obj_4ssh2_11sftp_handle_SFTPHandle *)__pyx_v_self), __pyx_v_attrs, __pyx_v_setstat); /* function exit code */ @@ -6589,7 +6725,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat_ex(struct __p PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("fstat_ex", 0); - /* "ssh2/sftp_handle.pyx":347 + /* "ssh2/sftp_handle.pyx":364 * fstat or fsetstat functions instead""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6604,7 +6740,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat_ex(struct __p #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":348 + /* "ssh2/sftp_handle.pyx":365 * cdef int rc * with nogil: * rc = c_sftp.libssh2_sftp_fstat_ex( # <<<<<<<<<<<<<< @@ -6614,7 +6750,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat_ex(struct __p __pyx_v_rc = libssh2_sftp_fstat_ex(__pyx_v_self->_handle, __pyx_v_attrs->_attrs, __pyx_v_setstat); } - /* "ssh2/sftp_handle.pyx":347 + /* "ssh2/sftp_handle.pyx":364 * fstat or fsetstat functions instead""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6633,7 +6769,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat_ex(struct __p } } - /* "ssh2/sftp_handle.pyx":350 + /* "ssh2/sftp_handle.pyx":367 * rc = c_sftp.libssh2_sftp_fstat_ex( * self._handle, attrs._attrs, setstat) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -6641,14 +6777,14 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat_ex(struct __p * def fstat(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 350, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 350, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 367, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":343 + /* "ssh2/sftp_handle.pyx":360 * return handle_error_codes(rc) * * def fstat_ex(self, SFTPAttributes attrs, int setstat): # <<<<<<<<<<<<<< @@ -6667,7 +6803,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_40fstat_ex(struct __p return __pyx_r; } -/* "ssh2/sftp_handle.pyx":352 +/* "ssh2/sftp_handle.pyx":369 * return handle_error_codes(rc) * * def fstat(self): # <<<<<<<<<<<<<< @@ -6699,19 +6835,19 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fstat(struct __pyx_ int __pyx_t_3; __Pyx_RefNannySetupContext("fstat", 0); - /* "ssh2/sftp_handle.pyx":357 + /* "ssh2/sftp_handle.pyx":374 * :rtype: tuple(int, :py:class:`ssh2.sftp.SFTPAttributes`)""" * cdef int rc * cdef SFTPAttributes attrs = SFTPAttributes() # <<<<<<<<<<<<<< * with nogil: * rc = c_sftp.libssh2_sftp_fstat(self._handle, attrs._attrs) */ - __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 357, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 374, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_attrs = ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPAttributes *)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp_handle.pyx":358 + /* "ssh2/sftp_handle.pyx":375 * cdef int rc * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: # <<<<<<<<<<<<<< @@ -6726,7 +6862,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fstat(struct __pyx_ #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":359 + /* "ssh2/sftp_handle.pyx":376 * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: * rc = c_sftp.libssh2_sftp_fstat(self._handle, attrs._attrs) # <<<<<<<<<<<<<< @@ -6736,7 +6872,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fstat(struct __pyx_ __pyx_v_rc = libssh2_sftp_fstat(__pyx_v_self->_handle, __pyx_v_attrs->_attrs); } - /* "ssh2/sftp_handle.pyx":358 + /* "ssh2/sftp_handle.pyx":375 * cdef int rc * cdef SFTPAttributes attrs = SFTPAttributes() * with nogil: # <<<<<<<<<<<<<< @@ -6755,7 +6891,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fstat(struct __pyx_ } } - /* "ssh2/sftp_handle.pyx":360 + /* "ssh2/sftp_handle.pyx":377 * with nogil: * rc = c_sftp.libssh2_sftp_fstat(self._handle, attrs._attrs) * if rc != 0: # <<<<<<<<<<<<<< @@ -6765,7 +6901,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fstat(struct __pyx_ __pyx_t_2 = ((__pyx_v_rc != 0) != 0); if (__pyx_t_2) { - /* "ssh2/sftp_handle.pyx":361 + /* "ssh2/sftp_handle.pyx":378 * rc = c_sftp.libssh2_sftp_fstat(self._handle, attrs._attrs) * if rc != 0: * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -6773,14 +6909,14 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fstat(struct __pyx_ * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 361, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 378, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":360 + /* "ssh2/sftp_handle.pyx":377 * with nogil: * rc = c_sftp.libssh2_sftp_fstat(self._handle, attrs._attrs) * if rc != 0: # <<<<<<<<<<<<<< @@ -6789,7 +6925,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fstat(struct __pyx_ */ } - /* "ssh2/sftp_handle.pyx":362 + /* "ssh2/sftp_handle.pyx":379 * if rc != 0: * return handle_error_codes(rc) * return attrs # <<<<<<<<<<<<<< @@ -6801,7 +6937,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fstat(struct __pyx_ __pyx_r = ((PyObject *)__pyx_v_attrs); goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":352 + /* "ssh2/sftp_handle.pyx":369 * return handle_error_codes(rc) * * def fstat(self): # <<<<<<<<<<<<<< @@ -6821,7 +6957,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_42fstat(struct __pyx_ return __pyx_r; } -/* "ssh2/sftp_handle.pyx":364 +/* "ssh2/sftp_handle.pyx":381 * return attrs * * def fsetstat(self, SFTPAttributes attrs): # <<<<<<<<<<<<<< @@ -6836,7 +6972,7 @@ static PyObject *__pyx_pw_4ssh2_11sftp_handle_10SFTPHandle_45fsetstat(PyObject * PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fsetstat (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_attrs), __pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes, 1, "attrs", 0))) __PYX_ERR(0, 364, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_attrs), __pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes, 1, "attrs", 0))) __PYX_ERR(0, 381, __pyx_L1_error) __pyx_r = __pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_44fsetstat(((struct __pyx_obj_4ssh2_11sftp_handle_SFTPHandle *)__pyx_v_self), ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPAttributes *)__pyx_v_attrs)); /* function exit code */ @@ -6856,7 +6992,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_44fsetstat(struct __p PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("fsetstat", 0); - /* "ssh2/sftp_handle.pyx":370 + /* "ssh2/sftp_handle.pyx":387 * :type attrs: :py:class:`ssh2.sftp.SFTPAttributes`""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6871,7 +7007,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_44fsetstat(struct __p #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":371 + /* "ssh2/sftp_handle.pyx":388 * cdef int rc * with nogil: * rc = c_sftp.libssh2_sftp_fsetstat(self._handle, attrs._attrs) # <<<<<<<<<<<<<< @@ -6881,7 +7017,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_44fsetstat(struct __p __pyx_v_rc = libssh2_sftp_fsetstat(__pyx_v_self->_handle, __pyx_v_attrs->_attrs); } - /* "ssh2/sftp_handle.pyx":370 + /* "ssh2/sftp_handle.pyx":387 * :type attrs: :py:class:`ssh2.sftp.SFTPAttributes`""" * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6900,7 +7036,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_44fsetstat(struct __p } } - /* "ssh2/sftp_handle.pyx":372 + /* "ssh2/sftp_handle.pyx":389 * with nogil: * rc = c_sftp.libssh2_sftp_fsetstat(self._handle, attrs._attrs) * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -6908,14 +7044,14 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_44fsetstat(struct __p * def fstatvfs(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 372, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 372, __pyx_L1_error) + __pyx_t_1 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 389, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":364 + /* "ssh2/sftp_handle.pyx":381 * return attrs * * def fsetstat(self, SFTPAttributes attrs): # <<<<<<<<<<<<<< @@ -6934,7 +7070,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_44fsetstat(struct __p return __pyx_r; } -/* "ssh2/sftp_handle.pyx":374 +/* "ssh2/sftp_handle.pyx":391 * return handle_error_codes(rc) * * def fstatvfs(self): # <<<<<<<<<<<<<< @@ -6966,19 +7102,19 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_46fstatvfs(struct __p int __pyx_t_3; __Pyx_RefNannySetupContext("fstatvfs", 0); - /* "ssh2/sftp_handle.pyx":378 + /* "ssh2/sftp_handle.pyx":395 * * :rtype: `ssh2.sftp.SFTPStatVFS`""" * cdef SFTPStatVFS vfs = SFTPStatVFS(self) # <<<<<<<<<<<<<< * cdef int rc * with nogil: */ - __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPStatVFS), ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 378, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4ssh2_11sftp_handle_SFTPStatVFS), ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_vfs = ((struct __pyx_obj_4ssh2_11sftp_handle_SFTPStatVFS *)__pyx_t_1); __pyx_t_1 = 0; - /* "ssh2/sftp_handle.pyx":380 + /* "ssh2/sftp_handle.pyx":397 * cdef SFTPStatVFS vfs = SFTPStatVFS(self) * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -6993,7 +7129,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_46fstatvfs(struct __p #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":381 + /* "ssh2/sftp_handle.pyx":398 * cdef int rc * with nogil: * rc = c_sftp.libssh2_sftp_fstatvfs(self._handle, vfs._ptr) # <<<<<<<<<<<<<< @@ -7003,7 +7139,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_46fstatvfs(struct __p __pyx_v_rc = libssh2_sftp_fstatvfs(__pyx_v_self->_handle, __pyx_v_vfs->_ptr); } - /* "ssh2/sftp_handle.pyx":380 + /* "ssh2/sftp_handle.pyx":397 * cdef SFTPStatVFS vfs = SFTPStatVFS(self) * cdef int rc * with nogil: # <<<<<<<<<<<<<< @@ -7022,7 +7158,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_46fstatvfs(struct __p } } - /* "ssh2/sftp_handle.pyx":382 + /* "ssh2/sftp_handle.pyx":399 * with nogil: * rc = c_sftp.libssh2_sftp_fstatvfs(self._handle, vfs._ptr) * if rc != 0: # <<<<<<<<<<<<<< @@ -7032,7 +7168,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_46fstatvfs(struct __p __pyx_t_2 = ((__pyx_v_rc != 0) != 0); if (__pyx_t_2) { - /* "ssh2/sftp_handle.pyx":383 + /* "ssh2/sftp_handle.pyx":400 * rc = c_sftp.libssh2_sftp_fstatvfs(self._handle, vfs._ptr) * if rc != 0: * return handle_error_codes(rc) # <<<<<<<<<<<<<< @@ -7040,14 +7176,14 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_46fstatvfs(struct __p * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 383, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_t_3 = __pyx_f_4ssh2_5utils_handle_error_codes(__pyx_v_rc, 0); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 400, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":382 + /* "ssh2/sftp_handle.pyx":399 * with nogil: * rc = c_sftp.libssh2_sftp_fstatvfs(self._handle, vfs._ptr) * if rc != 0: # <<<<<<<<<<<<<< @@ -7056,7 +7192,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_46fstatvfs(struct __p */ } - /* "ssh2/sftp_handle.pyx":384 + /* "ssh2/sftp_handle.pyx":401 * if rc != 0: * return handle_error_codes(rc) * return vfs # <<<<<<<<<<<<<< @@ -7068,7 +7204,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_46fstatvfs(struct __p __pyx_r = ((PyObject *)__pyx_v_vfs); goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":374 + /* "ssh2/sftp_handle.pyx":391 * return handle_error_codes(rc) * * def fstatvfs(self): # <<<<<<<<<<<<<< @@ -7197,7 +7333,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_10SFTPHandle_50__setstate_cython__ return __pyx_r; } -/* "ssh2/sftp_handle.pyx":390 +/* "ssh2/sftp_handle.pyx":407 * """File system statistics""" * * def __cinit__(self, _sftp_ref): # <<<<<<<<<<<<<< @@ -7231,7 +7367,7 @@ static int __pyx_pw_4ssh2_11sftp_handle_11SFTPStatVFS_1__cinit__(PyObject *__pyx else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 390, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 407, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -7242,7 +7378,7 @@ static int __pyx_pw_4ssh2_11sftp_handle_11SFTPStatVFS_1__cinit__(PyObject *__pyx } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 390, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 407, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh2.sftp_handle.SFTPStatVFS.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -7261,7 +7397,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj int __pyx_t_1; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "ssh2/sftp_handle.pyx":391 + /* "ssh2/sftp_handle.pyx":408 * * def __cinit__(self, _sftp_ref): * self._sftp_ref = _sftp_ref # <<<<<<<<<<<<<< @@ -7274,7 +7410,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj __Pyx_DECREF(__pyx_v_self->_sftp_ref); __pyx_v_self->_sftp_ref = __pyx_v__sftp_ref; - /* "ssh2/sftp_handle.pyx":392 + /* "ssh2/sftp_handle.pyx":409 * def __cinit__(self, _sftp_ref): * self._sftp_ref = _sftp_ref * with nogil: # <<<<<<<<<<<<<< @@ -7289,7 +7425,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":393 + /* "ssh2/sftp_handle.pyx":410 * self._sftp_ref = _sftp_ref * with nogil: * self._ptr = malloc( # <<<<<<<<<<<<<< @@ -7298,7 +7434,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr = ((LIBSSH2_SFTP_STATVFS *)malloc((sizeof(LIBSSH2_SFTP_STATVFS)))); - /* "ssh2/sftp_handle.pyx":395 + /* "ssh2/sftp_handle.pyx":412 * self._ptr = malloc( * sizeof(c_sftp.LIBSSH2_SFTP_STATVFS)) * if self._ptr is NULL: # <<<<<<<<<<<<<< @@ -7308,7 +7444,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj __pyx_t_1 = ((__pyx_v_self->_ptr == NULL) != 0); if (__pyx_t_1) { - /* "ssh2/sftp_handle.pyx":396 + /* "ssh2/sftp_handle.pyx":413 * sizeof(c_sftp.LIBSSH2_SFTP_STATVFS)) * if self._ptr is NULL: * with gil: # <<<<<<<<<<<<<< @@ -7321,17 +7457,17 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":397 + /* "ssh2/sftp_handle.pyx":414 * if self._ptr is NULL: * with gil: * raise MemoryError # <<<<<<<<<<<<<< * self._ptr.f_bsize = 0 * self._ptr.f_frsize = 0 */ - PyErr_NoMemory(); __PYX_ERR(0, 397, __pyx_L8_error) + PyErr_NoMemory(); __PYX_ERR(0, 414, __pyx_L8_error) } - /* "ssh2/sftp_handle.pyx":396 + /* "ssh2/sftp_handle.pyx":413 * sizeof(c_sftp.LIBSSH2_SFTP_STATVFS)) * if self._ptr is NULL: * with gil: # <<<<<<<<<<<<<< @@ -7348,7 +7484,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj } } - /* "ssh2/sftp_handle.pyx":395 + /* "ssh2/sftp_handle.pyx":412 * self._ptr = malloc( * sizeof(c_sftp.LIBSSH2_SFTP_STATVFS)) * if self._ptr is NULL: # <<<<<<<<<<<<<< @@ -7357,7 +7493,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ } - /* "ssh2/sftp_handle.pyx":398 + /* "ssh2/sftp_handle.pyx":415 * with gil: * raise MemoryError * self._ptr.f_bsize = 0 # <<<<<<<<<<<<<< @@ -7366,7 +7502,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_bsize = 0; - /* "ssh2/sftp_handle.pyx":399 + /* "ssh2/sftp_handle.pyx":416 * raise MemoryError * self._ptr.f_bsize = 0 * self._ptr.f_frsize = 0 # <<<<<<<<<<<<<< @@ -7375,7 +7511,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_frsize = 0; - /* "ssh2/sftp_handle.pyx":400 + /* "ssh2/sftp_handle.pyx":417 * self._ptr.f_bsize = 0 * self._ptr.f_frsize = 0 * self._ptr.f_blocks = 0 # <<<<<<<<<<<<<< @@ -7384,7 +7520,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_blocks = 0; - /* "ssh2/sftp_handle.pyx":401 + /* "ssh2/sftp_handle.pyx":418 * self._ptr.f_frsize = 0 * self._ptr.f_blocks = 0 * self._ptr.f_bfree = 0 # <<<<<<<<<<<<<< @@ -7393,7 +7529,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_bfree = 0; - /* "ssh2/sftp_handle.pyx":402 + /* "ssh2/sftp_handle.pyx":419 * self._ptr.f_blocks = 0 * self._ptr.f_bfree = 0 * self._ptr.f_bavail = 0 # <<<<<<<<<<<<<< @@ -7402,7 +7538,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_bavail = 0; - /* "ssh2/sftp_handle.pyx":403 + /* "ssh2/sftp_handle.pyx":420 * self._ptr.f_bfree = 0 * self._ptr.f_bavail = 0 * self._ptr.f_files = 0 # <<<<<<<<<<<<<< @@ -7411,7 +7547,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_files = 0; - /* "ssh2/sftp_handle.pyx":404 + /* "ssh2/sftp_handle.pyx":421 * self._ptr.f_bavail = 0 * self._ptr.f_files = 0 * self._ptr.f_ffree = 0 # <<<<<<<<<<<<<< @@ -7420,7 +7556,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_ffree = 0; - /* "ssh2/sftp_handle.pyx":405 + /* "ssh2/sftp_handle.pyx":422 * self._ptr.f_files = 0 * self._ptr.f_ffree = 0 * self._ptr.f_favail = 0 # <<<<<<<<<<<<<< @@ -7429,7 +7565,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_favail = 0; - /* "ssh2/sftp_handle.pyx":406 + /* "ssh2/sftp_handle.pyx":423 * self._ptr.f_ffree = 0 * self._ptr.f_favail = 0 * self._ptr.f_fsid = 0 # <<<<<<<<<<<<<< @@ -7438,7 +7574,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_fsid = 0; - /* "ssh2/sftp_handle.pyx":407 + /* "ssh2/sftp_handle.pyx":424 * self._ptr.f_favail = 0 * self._ptr.f_fsid = 0 * self._ptr.f_flag = 0 # <<<<<<<<<<<<<< @@ -7447,7 +7583,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj */ __pyx_v_self->_ptr->f_flag = 0; - /* "ssh2/sftp_handle.pyx":408 + /* "ssh2/sftp_handle.pyx":425 * self._ptr.f_fsid = 0 * self._ptr.f_flag = 0 * self._ptr.f_namemax = 0 # <<<<<<<<<<<<<< @@ -7457,7 +7593,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj __pyx_v_self->_ptr->f_namemax = 0; } - /* "ssh2/sftp_handle.pyx":392 + /* "ssh2/sftp_handle.pyx":409 * def __cinit__(self, _sftp_ref): * self._sftp_ref = _sftp_ref * with nogil: # <<<<<<<<<<<<<< @@ -7483,7 +7619,7 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj } } - /* "ssh2/sftp_handle.pyx":390 + /* "ssh2/sftp_handle.pyx":407 * """File system statistics""" * * def __cinit__(self, _sftp_ref): # <<<<<<<<<<<<<< @@ -7502,12 +7638,12 @@ static int __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS___cinit__(struct __pyx_obj return __pyx_r; } -/* "ssh2/sftp_handle.pyx":410 +/* "ssh2/sftp_handle.pyx":427 * self._ptr.f_namemax = 0 * * def __dealloc__(self): # <<<<<<<<<<<<<< * with nogil: - * free(self._ptr) + * if self._ptr is not NULL: */ /* Python wrapper */ @@ -7523,14 +7659,15 @@ static void __pyx_pw_4ssh2_11sftp_handle_11SFTPStatVFS_3__dealloc__(PyObject *__ static void __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_2__dealloc__(struct __pyx_obj_4ssh2_11sftp_handle_SFTPStatVFS *__pyx_v_self) { __Pyx_RefNannyDeclarations + int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "ssh2/sftp_handle.pyx":411 + /* "ssh2/sftp_handle.pyx":428 * * def __dealloc__(self): * with nogil: # <<<<<<<<<<<<<< - * free(self._ptr) - * + * if self._ptr is not NULL: + * free(self._ptr) */ { #ifdef WITH_THREAD @@ -7540,22 +7677,41 @@ static void __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_2__dealloc__(struct __pyx #endif /*try:*/ { - /* "ssh2/sftp_handle.pyx":412 + /* "ssh2/sftp_handle.pyx":429 * def __dealloc__(self): * with nogil: - * free(self._ptr) # <<<<<<<<<<<<<< + * if self._ptr is not NULL: # <<<<<<<<<<<<<< + * free(self._ptr) + * + */ + __pyx_t_1 = ((__pyx_v_self->_ptr != NULL) != 0); + if (__pyx_t_1) { + + /* "ssh2/sftp_handle.pyx":430 + * with nogil: + * if self._ptr is not NULL: + * free(self._ptr) # <<<<<<<<<<<<<< * * @property */ - free(__pyx_v_self->_ptr); + free(__pyx_v_self->_ptr); + + /* "ssh2/sftp_handle.pyx":429 + * def __dealloc__(self): + * with nogil: + * if self._ptr is not NULL: # <<<<<<<<<<<<<< + * free(self._ptr) + * + */ + } } - /* "ssh2/sftp_handle.pyx":411 + /* "ssh2/sftp_handle.pyx":428 * * def __dealloc__(self): * with nogil: # <<<<<<<<<<<<<< - * free(self._ptr) - * + * if self._ptr is not NULL: + * free(self._ptr) */ /*finally:*/ { /*normal exit:*/{ @@ -7569,19 +7725,19 @@ static void __pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_2__dealloc__(struct __pyx } } - /* "ssh2/sftp_handle.pyx":410 + /* "ssh2/sftp_handle.pyx":427 * self._ptr.f_namemax = 0 * * def __dealloc__(self): # <<<<<<<<<<<<<< * with nogil: - * free(self._ptr) + * if self._ptr is not NULL: */ /* function exit code */ __Pyx_RefNannyFinishContext(); } -/* "ssh2/sftp_handle.pyx":415 +/* "ssh2/sftp_handle.pyx":433 * * @property * def f_bsize(self): # <<<<<<<<<<<<<< @@ -7608,7 +7764,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_bsize___get__(str PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":417 + /* "ssh2/sftp_handle.pyx":435 * def f_bsize(self): * """File system block size""" * return self._ptr.f_bsize # <<<<<<<<<<<<<< @@ -7616,13 +7772,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_bsize___get__(str * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_bsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 417, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_bsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":415 + /* "ssh2/sftp_handle.pyx":433 * * @property * def f_bsize(self): # <<<<<<<<<<<<<< @@ -7641,7 +7797,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_bsize___get__(str return __pyx_r; } -/* "ssh2/sftp_handle.pyx":420 +/* "ssh2/sftp_handle.pyx":438 * * @property * def f_frsize(self): # <<<<<<<<<<<<<< @@ -7668,7 +7824,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_frsize___get__(st PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":422 + /* "ssh2/sftp_handle.pyx":440 * def f_frsize(self): * """Fragment size""" * return self._ptr.f_frsize # <<<<<<<<<<<<<< @@ -7676,13 +7832,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_frsize___get__(st * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_frsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_frsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":420 + /* "ssh2/sftp_handle.pyx":438 * * @property * def f_frsize(self): # <<<<<<<<<<<<<< @@ -7701,7 +7857,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_frsize___get__(st return __pyx_r; } -/* "ssh2/sftp_handle.pyx":425 +/* "ssh2/sftp_handle.pyx":443 * * @property * def f_blocks(self): # <<<<<<<<<<<<<< @@ -7728,7 +7884,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_blocks___get__(st PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":427 + /* "ssh2/sftp_handle.pyx":445 * def f_blocks(self): * """Size of fs in f_frsize units""" * return self._ptr.f_blocks # <<<<<<<<<<<<<< @@ -7736,13 +7892,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_blocks___get__(st * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_blocks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_blocks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 445, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":425 + /* "ssh2/sftp_handle.pyx":443 * * @property * def f_blocks(self): # <<<<<<<<<<<<<< @@ -7761,7 +7917,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_blocks___get__(st return __pyx_r; } -/* "ssh2/sftp_handle.pyx":430 +/* "ssh2/sftp_handle.pyx":448 * * @property * def f_bfree(self): # <<<<<<<<<<<<<< @@ -7788,7 +7944,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_bfree___get__(str PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":432 + /* "ssh2/sftp_handle.pyx":450 * def f_bfree(self): * """Free blocks""" * return self._ptr.f_bfree # <<<<<<<<<<<<<< @@ -7796,13 +7952,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_bfree___get__(str * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_bfree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 432, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_bfree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":430 + /* "ssh2/sftp_handle.pyx":448 * * @property * def f_bfree(self): # <<<<<<<<<<<<<< @@ -7821,7 +7977,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_bfree___get__(str return __pyx_r; } -/* "ssh2/sftp_handle.pyx":435 +/* "ssh2/sftp_handle.pyx":453 * * @property * def f_bavail(self): # <<<<<<<<<<<<<< @@ -7848,7 +8004,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_bavail___get__(st PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":437 + /* "ssh2/sftp_handle.pyx":455 * def f_bavail(self): * """Free blocks for non-root""" * return self._ptr.f_bavail # <<<<<<<<<<<<<< @@ -7856,13 +8012,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_bavail___get__(st * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_bavail); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 437, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_bavail); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":435 + /* "ssh2/sftp_handle.pyx":453 * * @property * def f_bavail(self): # <<<<<<<<<<<<<< @@ -7881,7 +8037,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_bavail___get__(st return __pyx_r; } -/* "ssh2/sftp_handle.pyx":440 +/* "ssh2/sftp_handle.pyx":458 * * @property * def f_files(self): # <<<<<<<<<<<<<< @@ -7908,7 +8064,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_files___get__(str PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":442 + /* "ssh2/sftp_handle.pyx":460 * def f_files(self): * """Inodes""" * return self._ptr.f_files # <<<<<<<<<<<<<< @@ -7916,13 +8072,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_files___get__(str * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_files); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_files); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":440 + /* "ssh2/sftp_handle.pyx":458 * * @property * def f_files(self): # <<<<<<<<<<<<<< @@ -7941,7 +8097,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_files___get__(str return __pyx_r; } -/* "ssh2/sftp_handle.pyx":445 +/* "ssh2/sftp_handle.pyx":463 * * @property * def f_ffree(self): # <<<<<<<<<<<<<< @@ -7968,7 +8124,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_ffree___get__(str PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":447 + /* "ssh2/sftp_handle.pyx":465 * def f_ffree(self): * """Free inodes""" * return self._ptr.f_ffree # <<<<<<<<<<<<<< @@ -7976,13 +8132,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_ffree___get__(str * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_ffree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 447, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_ffree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":445 + /* "ssh2/sftp_handle.pyx":463 * * @property * def f_ffree(self): # <<<<<<<<<<<<<< @@ -8001,7 +8157,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_7f_ffree___get__(str return __pyx_r; } -/* "ssh2/sftp_handle.pyx":450 +/* "ssh2/sftp_handle.pyx":468 * * @property * def f_favail(self): # <<<<<<<<<<<<<< @@ -8028,7 +8184,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_favail___get__(st PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":452 + /* "ssh2/sftp_handle.pyx":470 * def f_favail(self): * """Free inodes for non-root""" * return self._ptr.f_favail # <<<<<<<<<<<<<< @@ -8036,13 +8192,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_favail___get__(st * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_favail); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_favail); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":450 + /* "ssh2/sftp_handle.pyx":468 * * @property * def f_favail(self): # <<<<<<<<<<<<<< @@ -8061,7 +8217,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_8f_favail___get__(st return __pyx_r; } -/* "ssh2/sftp_handle.pyx":455 +/* "ssh2/sftp_handle.pyx":473 * * @property * def f_fsid(self): # <<<<<<<<<<<<<< @@ -8088,7 +8244,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_6f_fsid___get__(stru PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":457 + /* "ssh2/sftp_handle.pyx":475 * def f_fsid(self): * """File system ID""" * return self._ptr.f_fsid # <<<<<<<<<<<<<< @@ -8096,13 +8252,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_6f_fsid___get__(stru * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_fsid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 457, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_fsid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":455 + /* "ssh2/sftp_handle.pyx":473 * * @property * def f_fsid(self): # <<<<<<<<<<<<<< @@ -8121,7 +8277,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_6f_fsid___get__(stru return __pyx_r; } -/* "ssh2/sftp_handle.pyx":460 +/* "ssh2/sftp_handle.pyx":478 * * @property * def f_flag(self): # <<<<<<<<<<<<<< @@ -8148,7 +8304,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_6f_flag___get__(stru PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":465 + /* "ssh2/sftp_handle.pyx":483 * This property is a bit mask with defined bits * ``LIBSSH2_SFTP_ST_RDONLY`` and ``LIBSSH2_SFTP_ST_NOSUID``""" * return self._ptr.f_flag # <<<<<<<<<<<<<< @@ -8156,13 +8312,13 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_6f_flag___get__(stru * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_flag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 465, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_flag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 483, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":460 + /* "ssh2/sftp_handle.pyx":478 * * @property * def f_flag(self): # <<<<<<<<<<<<<< @@ -8181,7 +8337,7 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_6f_flag___get__(stru return __pyx_r; } -/* "ssh2/sftp_handle.pyx":468 +/* "ssh2/sftp_handle.pyx":486 * * @property * def f_namemax(self): # <<<<<<<<<<<<<< @@ -8208,19 +8364,19 @@ static PyObject *__pyx_pf_4ssh2_11sftp_handle_11SFTPStatVFS_9f_namemax___get__(s PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); - /* "ssh2/sftp_handle.pyx":470 + /* "ssh2/sftp_handle.pyx":488 * def f_namemax(self): * """Maximum filename length""" * return self._ptr.f_namemax # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_namemax); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 470, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_libssh2_uint64_t(__pyx_v_self->_ptr->f_namemax); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 488, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh2/sftp_handle.pyx":468 + /* "ssh2/sftp_handle.pyx":486 * * @property * def f_namemax(self): # <<<<<<<<<<<<<< @@ -9320,13 +9476,13 @@ static int __Pyx_modinit_type_init_code(void) { if (PyObject_SetAttr(__pyx_m, __pyx_n_s_SFTPAttributes, (PyObject *)&__pyx_type_4ssh2_11sftp_handle_SFTPAttributes) < 0) __PYX_ERR(0, 33, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_11sftp_handle_SFTPAttributes) < 0) __PYX_ERR(0, 33, __pyx_L1_error) __pyx_ptype_4ssh2_11sftp_handle_SFTPAttributes = &__pyx_type_4ssh2_11sftp_handle_SFTPAttributes; - if (PyType_Ready(&__pyx_type_4ssh2_11sftp_handle_SFTPStatVFS) < 0) __PYX_ERR(0, 387, __pyx_L1_error) + if (PyType_Ready(&__pyx_type_4ssh2_11sftp_handle_SFTPStatVFS) < 0) __PYX_ERR(0, 404, __pyx_L1_error) __pyx_type_4ssh2_11sftp_handle_SFTPStatVFS.tp_print = 0; if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4ssh2_11sftp_handle_SFTPStatVFS.tp_dictoffset && __pyx_type_4ssh2_11sftp_handle_SFTPStatVFS.tp_getattro == PyObject_GenericGetAttr)) { __pyx_type_4ssh2_11sftp_handle_SFTPStatVFS.tp_getattro = __Pyx_PyObject_GenericGetAttr; } - if (PyObject_SetAttr(__pyx_m, __pyx_n_s_SFTPStatVFS, (PyObject *)&__pyx_type_4ssh2_11sftp_handle_SFTPStatVFS) < 0) __PYX_ERR(0, 387, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_11sftp_handle_SFTPStatVFS) < 0) __PYX_ERR(0, 387, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_SFTPStatVFS, (PyObject *)&__pyx_type_4ssh2_11sftp_handle_SFTPStatVFS) < 0) __PYX_ERR(0, 404, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4ssh2_11sftp_handle_SFTPStatVFS) < 0) __PYX_ERR(0, 404, __pyx_L1_error) __pyx_ptype_4ssh2_11sftp_handle_SFTPStatVFS = &__pyx_type_4ssh2_11sftp_handle_SFTPStatVFS; if (PyType_Ready(&__pyx_type_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex) < 0) __PYX_ERR(0, 179, __pyx_L1_error) __pyx_type_4ssh2_11sftp_handle___pyx_scope_struct__readdir_ex.tp_print = 0; diff --git a/ssh2/sftp_handle.pyx b/ssh2/sftp_handle.pyx index 770f0d8c..6eaaed1f 100644 --- a/ssh2/sftp_handle.pyx +++ b/ssh2/sftp_handle.pyx @@ -262,22 +262,39 @@ cdef class SFTPHandle: def write(self, bytes buf): """Write buffer to file handle. + Returns tuple of (``error code``, ``bytes written``). + + In blocking mode ``bytes_written`` will always equal ``len(buf)`` if no + errors have occurred which would raise exception. + + In non-blocking mode ``error_code`` can be LIBSSH2_ERROR_EAGAIN and + ``bytes_written`` *can be less than* ``len(buf)``. + + Clients should resume from that point on next call to ``write``, ie + ``buf[bytes_written_in_last_call:]``. + :param buf: Buffer to write. :type buf: bytes - :rtype: int""" + :rtype: tuple(int, int)""" cdef size_t _size = len(buf) + cdef size_t tot_size = _size + cdef size_t bytes_written = 0 cdef char *cbuf = buf cdef ssize_t rc = 0 with nogil: while _size > 0: rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) - if rc < 0: + if rc < 0 and rc != c_ssh2.LIBSSH2_ERROR_EAGAIN: + # Error we cannot resume from, exception will be raised + with gil: + return handle_error_codes(rc) + elif rc == c_ssh2.LIBSSH2_ERROR_EAGAIN: break cbuf += rc _size -= rc - - return handle_error_codes(rc) + bytes_written = tot_size - _size + return rc, bytes_written IF EMBEDDED_LIB: def fsync(self): @@ -409,7 +426,8 @@ cdef class SFTPStatVFS: def __dealloc__(self): with nogil: - free(self._ptr) + if self._ptr is not NULL: + free(self._ptr) @property def f_bsize(self): diff --git a/tests/test_channel.py b/tests/test_channel.py index c0c8dad6..35e99890 100644 --- a/tests/test_channel.py +++ b/tests/test_channel.py @@ -82,13 +82,14 @@ def test_write_stdin(self): chan = self.session.open_session() chan.execute('cat') chan.write(_in + '\n') - self.assertEqual(chan.close(), 0) + self.assertEqual(chan.send_eof(), 0) size, data = chan.read() self.assertTrue(size > 0) lines = [s.decode('utf-8') for s in data.splitlines()] self.assertListEqual([_in], lines) - self.assertEqual(chan.eof(), 0) + chan.close() self.assertEqual(chan.wait_eof(), 0) + self.assertTrue(chan.eof()) self.assertEqual(chan.wait_closed(), 0) def test_write_ex(self): @@ -97,7 +98,7 @@ def test_write_ex(self): chan = self.session.open_session() chan.execute('cat') chan.write_ex(0, _in + '\n') - self.assertEqual(chan.close(), 0) + self.assertEqual(chan.send_eof(), 0) size, data = chan.read() self.assertTrue(size > 0) lines = [s.decode('utf-8') for s in data.splitlines()] @@ -108,7 +109,7 @@ def test_write_stderr(self): chan = self.session.open_session() chan.execute('echo something') _in = u'stderr' - self.assertTrue(chan.write_stderr(_in + '\n') > 0) + self.assertTrue(chan.write_stderr(_in + '\n')[0] > 0) self.assertEqual(chan.close(), 0) def test_setenv(self):