Skip to content

[FEAT] - Implement io.IOBase protocol for opened SFTP file objects #2452

Open

Description

@mxmlnkn

Is this feature for paramiko acting as a client or a server?

Client

What functionality does this feature request relate to?

SFTP

For client-side features, does this relate to a specific type of SSH server?

No response

If you're using paramiko as part of another tool, which tool/version?

No response

Desired behavior

I am opening a file object via SFTPClient.open. The returned file object looks very much like a typical Python file object, but differs in two ways noticable for my use case:

  • It inherits from paramiko.sftp_file.SFTPFile and does not have io.IOBase in its inheritance hierarchy, i.e., isinstance(fileobj, io.IOBase) does not work.
  • paramiko.sftp_file.SFTPFile.seek does not return the new file position. This is in stark contrast to io.IOBase.seek, which "return[s] the new absolute position".
  • paramiko.sftp_file.SFTPFile.write does not return the number of bytes that have been written, which is also in conflict with IOBase.

I guess, I will need to either inject-replace a new seek method or more cleaner, but maybe worse for performance and code conciseness, wrap paramiko.sftp_file.SFTPFile in a new class that correctly implements the io.IOBase protocol.

Anything else?

No response

Activity

  1. added a commit that references this issue on Sep 22, 2024
    469d58b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions