Title: Documentation suggesting incorrect flags for sftp.open() · Issue #13 · ParallelSSH/ssh2-python · GitHub
Open Graph Title: Documentation suggesting incorrect flags for sftp.open() · Issue #13 · ParallelSSH/ssh2-python
X Title: Documentation suggesting incorrect flags for sftp.open() · Issue #13 · ParallelSSH/ssh2-python
Description: Steps to reproduce: Simply use the code in the README file to read a file from SFTP: sftp = session.sftp_init() with sftp.open(
Open Graph Description: Steps to reproduce: Simply use the code in the README file to read a file from SFTP: sftp = session.sftp_init() with sftp.open(
X Description: Steps to reproduce: Simply use the code in the README file to read a file from SFTP: sftp = session.sftp_init() with sftp.open(<remote file to read>, 0, 0) as remote_fh, \ open(<file to wr...
Opengraph URL: https://github.com/ParallelSSH/ssh2-python/issues/13
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Documentation suggesting incorrect flags for sftp.open()","articleBody":"__Steps to reproduce:__\r\n\r\nSimply use the code in the README file to read a file from SFTP:\r\n\r\n```python\r\nsftp = session.sftp_init()\r\nwith sftp.open(\u003cremote file to read\u003e, 0, 0) as remote_fh, \\\r\n open(\u003cfile to write\u003e, 'wb') as local_fh:\r\n for size, data in remote_fh:\r\n local_fh.write(data)\r\n```\r\n\r\n__Expected behaviour:__\r\n\r\nData is copied from the remote file to the local file.\r\n\r\n__Actual behaviour:__\r\n\r\nNo data is ever written to `\u003cfile to write\u003e`. The size parameter is set by libssh2 to ``LIBSSH2_ERROR_SFTP_PROTOCOL`` (-31) and the calling `sftp.last_error()` will report ``LIBSSH2_FX_FAILURE`` (4). ``remote_fh.fstat()`` will succeed without issues (reporting correct data).\r\n\r\n__Additional info:__\r\n\r\nVersion ``ssh2-python 0.6.0`` with bundled ``libssh2``.\r\n\r\nThis seems to happen because (at least up to ``libssh2`` 1.8.0) ``0`` and ``LIBSSH2_FXF_READ`` are not synonyms, like it is (in my understanding) incorrectly suggested in the [documentation](https://github.com/ParallelSSH/ssh2-python/blob/master/ssh2/sftp.pyx#L157) and the examples ([sftp_read.py](https://github.com/ParallelSSH/ssh2-python/blob/master/examples/sftp_read.py#L40), for example). This may be tested using ``libssh2`` directly by changing line 251 of the [``sftp.c``](https://github.com/libssh2/libssh2/blob/master/example/sftp.c) example from:\r\n```c\r\nlibssh2_sftp_open(sftp_session, sftppath, LIBSSH2_FXF_READ, 0);\r\n```\r\nto\r\n```c\r\nlibssh2_sftp_open(sftp_session, sftppath, 0, 0);\r\n```\r\nThis will make ``libssh2_sftp_read()`` fail in in the same way described in the actual behaviour.\r\n\r\nI should be able to send a pull request to fix the documentation and examples if needed (and my understanding of the issue is correct).","author":{"url":"https://github.com/gvialetto","@type":"Person","name":"gvialetto"},"datePublished":"2017-11-16T13:35:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/13/ssh2-python/issues/13"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:305ab1a1-1c95-c487-37f7-d15787263bdc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EA86:3037EB:7F38BB:B137DF:696A5A75 |
| html-safe-nonce | 2784da8b1b37d65293c707f3094cec611ede0989d9d4fc9ea502f2aa7b8fdc35 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQTg2OjMwMzdFQjo3RjM4QkI6QjEzN0RGOjY5NkE1QTc1IiwidmlzaXRvcl9pZCI6IjUxMDY2ODE0MzkxNDY2Mjk3NDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2955366bc63df44dce2e78989672b7698f74ac63974a3df53d775c2f63432644 |
| hovercard-subject-tag | issue:274517597 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/ParallelSSH/ssh2-python/13/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2a127b7d6339724fd9ea9d8bceed212ce20beb0ddcb7050b2efc684816aa2276/ParallelSSH/ssh2-python/issues/13 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2a127b7d6339724fd9ea9d8bceed212ce20beb0ddcb7050b2efc684816aa2276/ParallelSSH/ssh2-python/issues/13 |
| og:image:alt | Steps to reproduce: Simply use the code in the README file to read a file from SFTP: sftp = session.sftp_init() with sftp.open( |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gvialetto |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3f871c8e07f0ae1886fa8dac284166d28b09ad5bada6476fc10b674e489788ef |
| turbo-cache-control | no-preview |
| go-import | github.com/ParallelSSH/ssh2-python git https://github.com/ParallelSSH/ssh2-python.git |
| octolytics-dimension-user_id | 22918200 |
| octolytics-dimension-user_login | ParallelSSH |
| octolytics-dimension-repository_id | 98586974 |
| octolytics-dimension-repository_nwo | ParallelSSH/ssh2-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 98586974 |
| octolytics-dimension-repository_network_root_nwo | ParallelSSH/ssh2-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 63c426b30d262aba269ef14c40e3c817b384cd61 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width