]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Add __reduce_ex__ to MutableList; add compat for older pickles
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 9 Apr 2019 21:38:53 +0000 (17:38 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 10 Apr 2019 01:13:56 +0000 (21:13 -0400)
commit21099479daf98dca84cb97e928951ea0c486b479
tree67e6fcd1da61577cc339eab8d0bb1133483b07cf
parent1ec2f7cfd6c1fa8acf9a41330df597af99dcadc7
Add __reduce_ex__ to MutableList; add compat for older pickles

Fixed bug where using ``copy.copy()`` or ``copy.deepcopy()`` on
:class:`.MutableList` would cause the items within the list to be
duplicated, due to an inconsistency in how Python pickle and copy both make
use of ``__getstate__()`` and ``__setstate__()`` regarding lists.  In order
to resolve, a ``__reduce_ex__`` method had to be added to
:class:`.MutableList`.  In order to maintain backwards compatibility with
existing pickles based on ``__getstate__()``, the ``__setstate__()`` method
remains as well; the test suite asserts that pickles made against the old
version of the class can still be deserialized by the pickle module.

Also modified sqlalchemy.testing.util.picklers to return picklers all the way through
pickle.HIGHEST_PROTOCOL.

Fixes: #4603
Change-Id: I7f78b9cfb89d59a706248536c553dc5e1d987b88
doc/build/changelog/unreleased_13/4603.rst [new file with mode: 0644]
lib/sqlalchemy/ext/mutable.py
lib/sqlalchemy/testing/util.py
test/ext/test_mutable.py