Skip to content

pickle.load and pickle.loads fail #443

@peterhinch

Description

@peterhinch

Using code loaded with upip on the Unix build, I get

MicroPython v1.16-243-gd608d0ed7 on 2021-08-29; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import pickle
>>> with open('20210831', 'r') as f:
...     a = pickle.load(f)

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/home/adminpete/.micropython/lib/pickle.py", line 11, in load
  File "/home/adminpete/.micropython/lib/pickle.py", line 15, in loads
AttributeError: 'str' object has no attribute 'decode'
>>> 

Commenting out line 15 fixes the problem with my data.

There is another issue in that the code downloaded does not match that in micropython-lib. Both have the error, but in the micropython-lib version it is on a different line. While the hack has fixed my immediate problem it would be interesting to know why these versions differ and which is correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions