Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit 342030c

Browse files
committed
fix (un)pickle
1 parent f6250c2 commit 342030c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/sage/matrix/matrix_integer_dense.pyx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,23 @@ cdef class Matrix_integer_dense(Matrix_dense):
550550
return data
551551

552552
def _unpickle(self, data, int version):
553+
"""
554+
TESTS::
555+
556+
sage: b = matrix(ZZ,2,3, [0,0,0, 0, 0, 0])
557+
sage: s = b'1 61 f -2 3 0'
558+
sage: t = s.decode()
559+
sage: b._unpickle(s, 0) == b._unpickle(t, 0)
560+
True
561+
sage: b
562+
[ 1 193 15]
563+
[ -2 3 0]
564+
"""
553565
if version == 0:
566+
if isinstance(data, str):
567+
# old Py2 pickle: old "bytes" object reaches us as a
568+
# latin1-encoded string.
569+
data = data.encode('latin1')
554570
if isinstance(data, bytes):
555571
self._unpickle_version0(data)
556572
elif isinstance(data, list):

0 commit comments

Comments
 (0)