Python3.4 pickle dump function fails with TypeError
<p>I have a simple script that is suppose to import a module that initializes a db dictionary. The script then should open a file and use pickle.dump to write the db dictionary to the file. However it fails with the following TypeError:</p>

<pre><code>Traceback (most recent call last):
  File "make_db_pickle.py", line 6, in &lt;module&gt;
    pickle.dump(db, dbfile)
TypeError: must be str, not bytes

from initdata import db
import pickle
dbfile = open('people_pickle', 'w')
pickle.dump(db, dbfile)
dbfile.close()
</code></pre>

<p>The type function show my variables dbfile and db as:</p>

<pre><code>&lt;class '_io.TextIOWrapper'&gt;
&lt;class 'dict'&gt;
</code></pre>