python2/3, convert problem pickle.loads()
by kaz2100 from LinuxQuestions.org on (#5JV4F)
Hya
Can any experts direct me to next step?
While converting python2 script to python3, I ran intoCode: rd = pickle.loads(rag.GetDataHere(BB.DD_FORMAT))
TypeError: GetDataHere(self, buf: sip.voidptr): argument 1 has unexpected type 'DataFormat'Code: kp = pickle.loads(str(link.GetHref()))
TypeError: a bytes-like object is required, not 'str'Documentation of python2 is only one line! -- Code:Help on function loads in module pickle:
loads(str) while python3 document looks good. As I cannot figure out what python2 does, I got stuck.
With the second case above, I played around .encode('utf-8') and bytes(##, 'utf-8), which resulted inCode:pickle.UnpicklingError: unpickling stack underflow(FYI: link.GetHref() is a string, "\\x80\\x04\\x95...". as pycharm said.)
Web search only gives me pickle.load() problem, which is 'r','w' vs. 'rb','wb' issue opening a file.
Can any experts please direct me to next step or solution?
Any clue will be appreciated.
cheers
Can any experts direct me to next step?
While converting python2 script to python3, I ran intoCode: rd = pickle.loads(rag.GetDataHere(BB.DD_FORMAT))
TypeError: GetDataHere(self, buf: sip.voidptr): argument 1 has unexpected type 'DataFormat'Code: kp = pickle.loads(str(link.GetHref()))
TypeError: a bytes-like object is required, not 'str'Documentation of python2 is only one line! -- Code:Help on function loads in module pickle:
loads(str) while python3 document looks good. As I cannot figure out what python2 does, I got stuck.
With the second case above, I played around .encode('utf-8') and bytes(##, 'utf-8), which resulted inCode:pickle.UnpicklingError: unpickling stack underflow(FYI: link.GetHref() is a string, "\\x80\\x04\\x95...". as pycharm said.)
Web search only gives me pickle.load() problem, which is 'r','w' vs. 'rb','wb' issue opening a file.
Can any experts please direct me to next step or solution?
Any clue will be appreciated.
cheers