When trying to save my list of reactionrole objects with pickle it gives me the error Command raised an exception: TypeError: cannot pickle 'TaskStepMethWrapper' object
.
I have not tried anything because I'm not sure what TaskStepMethWrapper is. Here's my code:
@client.command()
async def reactionadd(ctx):
# await ctx.send('Please give me the ID of the message you want to have a reactionrole on.')
# msgid_var = await client.wait_for('message')
await ctx.send('Please react with the emoji you want the reactionrole to use.')
emoji_var = await client.wait_for('reaction_add')
# await ctx.send('Please give me the ID of the role you want the reactionrole to give.')
# roleid_var = await client.wait_for('message')
if not os.path.isfile('reactionrole.obj'):
rrf = open('reactionrole.obj', 'xb')
rrf.close()
rrf = open('reactionrole.obj', 'rb+')
if os.stat('reactionrole.obj').st_size == 0:
rrobj = []
else:
rrobj = pickle.load(rrf)
emoji_var = emoji_var[0]
rrobj.append(reactionrole(749316751212150965, emoji_var, 749317419255857232))
pickle.dump(rrobj, rrf)
rrf.close()
class reactionrole:
def __init__(self, msgid, emoji, roleid):
self.msgid = msgid
self.emoji = emoji
self.roleid = roleid
SO, how to fix this error? should I go on with pickle or use another serialization technique? I could write to and parse a text file myself if needed.
Google
to check what isTaskStepMethWrapper
? It shows that it part ofasyncio
and it unpickable. Probably it is inemoji_var
. You should check what you have inemoji_var
-print(emoji_var)
,print( type(emoji_var) )
. And see if you need it or if you can get values fromemoji_var
asstrings
,list
,dict
,int
which are pickleabel – furasGoogle
I found similar problem Why is python pickle failing to dump dictionaries in 3.7 but also without solution. – furasawait
andasync
so you may get someasyncio
object instead of expectedstring
– furas