Loading an object containing a matrix that was saved in Python 2 sage

26 views
Skip to first unread message

Paul Leopardi

unread,
Aug 19, 2020, 8:17:40 AM8/19/20
to sage-support
Hello,
I am currently trying to convert my Boolean-Cayley-graphs project from Python 2 to Python 3 Sage. https://github.com/penguian/Boolean-Cayley-graphs/tree/23-port-to-python-3

I have succeeded in converting the code, but am having a tough time trying to load objects that were saved by my previous Python 2-based code. These objects contain matrices as members.What do I need to do to be able to load these objects?

As far as I can tell, load(...,encoding='latin-1') doesn't work with a dict containing a matrix but load(...,encoding='bytes') does. See the attachment.
Thanks!
matrix-load-save-example.txt

Paul Leopardi

unread,
Aug 19, 2020, 8:24:48 AM8/19/20
to sage-support

Nils Bruin

unread,
Aug 19, 2020, 12:35:15 PM8/19/20
to sage-support
Yes, we know how to fix it and it's not complicated: if "bytes" is expected in a pickle and a "str" is found, we should assume it represents the bytes-object via latin-1. It's come up in matrices elsewhere and we should just make this change. We've already determined that "encoding='bytes'" is a lot harder to get to work.

Please open a ticket. Fixing this should save a LOT of pickles.

Paul Leopardi

unread,
Aug 20, 2020, 12:10:34 AM8/20/20
to sage-support

Paul Leopardi

unread,
Aug 20, 2020, 12:12:14 AM8/20/20
to sage-support
I have about 6 TB of saved Sage objects that I would like to recover, so am interested in testing the fix.
Reply all
Reply to author
Forward
0 new messages