coleifer / micawber

a small library for extracting rich content from urls
http://micawber.readthedocs.org/
MIT License
632 stars 91 forks source link

Fix PicleCache error on Python3 #92

Closed tptlab closed 4 years ago

tptlab commented 4 years ago

On Python3, pickle.dump and load require byte stream. For the example, run the following code

import micawber

cache = micawber.PickleCache()
providers = micawber.bootstrap_basic(cache)
providers.request('https://www.youtube.com/watch?v=e7zzdl8OXCU')
cache.save()

then the last line raises an exception:

Traceback (most recent call last): File "/home/mictest.py", line 6, in cache.save() File "/usr/local/lib/python3.8/site-packages/micawber/cache.py", line 36, in save fh.write(pickle.dumps(self._cache)) TypeError: write() argument must be str, not bytes