Message352813
pickle.load() and pickle.dump() take a file object as an argument. That file object must be opened in binary mode ("rb" or "wb"). If it's not, pickle raises a confusing error message.
When pickle.dump()'ing to a file opened in "w" mode instead of "wb" mode it'll raise a TypeError:
TypeError: write() argument must be str, not bytes
I thought it might be getting this because I was pickling bytes objects.
For pickle.load()'ing from a file opened in "r" mode instead of "rb" mode, it'll raise a UnicodeDecodeError
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
There are a couple pages on the internet (just search "pickle" followed by either error message) with people being confused about this.
pickle should catch these errors and report something more useful. |
|
Date |
User |
Action |
Args |
2019-09-19 20:31:01 | boris | set | recipients:
+ boris |
2019-09-19 20:31:01 | boris | set | messageid: <1568925061.22.0.28448935108.issue38226@roundup.psfhosted.org> |
2019-09-19 20:31:01 | boris | link | issue38226 messages |
2019-09-19 20:31:00 | boris | create | |
|