Article 5JV4F python2/3, convert problem pickle.loads()

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.

cheerslatest?d=yIl2AUoC8zA latest?i=E7ueVM3MR8U:OWxC2ix6l-s:F7zBnMy latest?i=E7ueVM3MR8U:OWxC2ix6l-s:V_sGLiP latest?d=qj6IDK7rITs latest?i=E7ueVM3MR8U:OWxC2ix6l-s:gIN9vFwE7ueVM3MR8U
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments