[New-bugs-announce] [issue43907] pickle.py bytearray memoization bug with protocol 5
Carl Friedrich Bolz-Tereick
report at bugs.python.org
Wed Apr 21 14:08:15 EDT 2021
New submission from Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>:
The new codepath for the BYTEARRAY8 bytecode is missing memoization:
>>> import pickletools, pickle
>>> b = (bytearray(b"abc"), ) * 2
>>> b1, b2 = pickle.loads(pickle.dumps(b, 5)) # C version
>>> b1 is b2
True
(bytearray(b'abc'), bytearray(b'abc'))
>>> b1, b2 = pickle.loads(pickle._dumps(b, 5)) # python version
>>> b1 is b2 # :-(
False
Found it because PyPy is using pickle.py with no C implementation. I'm preparing a patch.
----------
messages: 391537
nosy: Carl.Friedrich.Bolz
priority: normal
severity: normal
status: open
title: pickle.py bytearray memoization bug with protocol 5
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43907>
_______________________________________
More information about the New-bugs-announce
mailing list