Question

I'm getting the following error via cgitb:

TypeError: must be str, not bytes 
      args = ('must be str, not bytes',) 
      with_traceback = <built-in method with_traceback of TypeError object>

The line of code that is singled out is:

pickle.dump(state, output_file)

The output file is opened to a particular path for writing.

I don't think I've seen "hello pickle" for Py3k's creating, marshalling, and unmarshalling a "hello world" string the new way. Anyone be willing to explain what I need to be doing differently with the file (specify UTF-8 encoding or something), and post "Hello world" that marshals and unmarshals from Py3k's basic string?

Was it helpful?

Solution

If you are opening the file in w or r mode, change it to wb, It should work. Basically, open it in binary mode.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top