docs: def membuf_tempfile(memfile):
      """Write in-memory file object to real file."""
      memfile.seek(0, 0)
  
      tmpfd, tmpname = mkstemp(suffix='.rar')
      tmpf = os.fdopen(tmpfd, "wb")
  
      try:
          while True:
              buf = memfile.read(BSIZE)
              if not buf:
                  break
              tmpf.write(buf)
          tmpf.close()
      except:
          tmpf.close()
          os.unlink(tmpname)
          raise
      return tmpname