docs: def open(self, filename, mode='r', bufsize=-1):
          """
          Open a file on the remote server.  The arguments are the same as for
          Python's built-in `python:file` (aka `python:open`).  A file-like
          object is returned, which closely mimics the behavior of a normal
          Python file object, including the ability to be used as a context
          manager.
  
          The mode indicates how the file is to be opened: ``'r'`` for reading,
          ``'w'`` for writing (truncating an existing file), ``'a'`` for
          appending, ``'r+'`` for reading/writing, ``'w+'`` for reading/writing
          (truncating an existing file), ``'a+'`` for reading/appending.  The
          Python ``'b'`` flag is ignored, since SSH treats all files as binary.
          The ``'U'`` flag is supported in a compatible way.
  
          Since 1.5.2, an ``'x'`` flag indicates that the operation should only
          succeed if the file was created and did not previously exist.  This has
          no direct mapping to Python's file flags, but is commonly known as the
          ``O_EXCL`` flag in posix.
  
          The file will be buffered in standard Python style by default, but
          can be altered with the ``bufsize`` parameter.  ``0`` turns off
          buffering, ``1`` uses line buffering, and any number greater than 1
          (``>1``) uses that specific buffer size.
  
          :param str filename: name of the file to open
          :param str mode: mode (Python-style) to open in
          :param int bufsize: desired buffering (-1 = default buffer size)
          :return: an `.SFTPFile` object representing the open file
  
          :raises IOError: if the file could not be opened.
          """
          filename = self._adjust_cwd(filename)
          self._log(DEBUG, 'open(%r, %r)' % (filename, mode))
          imode = 0
          if ('r' in mode) or ('+' in mode):
              imode |= SFTP_FLAG_READ
          if ('w' in mode) or ('+' in mode) or ('a' in mode):
              imode |= SFTP_FLAG_WRITE
          if 'w' in mode:
              imode |= SFTP_FLAG_CREATE | SFTP_FLAG_TRUNC
          if 'a' in mode:
              imode |= SFTP_FLAG_CREATE | SFTP_FLAG_APPEND
          if 'x' in mode:
              imode |= SFTP_FLAG_CREATE | SFTP_FLAG_EXCL
          attrblock = SFTPAttributes()
          t, msg = self._request(CMD_OPEN, filename, imode, attrblock)
          if t != CMD_HANDLE:
              raise SFTPError('Expected handle')
          handle = msg.get_binary()
          self._log(DEBUG, 'open(%r, %r) -> %s' % (filename, mode, hexlify(handle)))
          return SFTPFile(self, handle, mode, bufsize)