Skip to content

Commit

Permalink
Add a test for cloudpipe#327
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreglaser committed Feb 4, 2020
1 parent 7ef2657 commit a8ac785
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/cloudpickle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,27 @@ def setUp(self):
def tearDown(self):
shutil.rmtree(self.tmpdir)

@pytest.mark.skipif(
sys.version_info >= (3, 8, 0) and sys.version_info < (3, 8, 2),
reason="Underlying bug fixed upstream starting Python3.8.2")
def test_reducer_override_reference_cycle(self):
# Early versions of Python3.8 introduced a reference cycle between a
# Pickler and it's reducer_override method. Because a Pickler
# object references every object it has pickled through its memo, this
# cycle prevented the garbage-collection of those external pickled
# objects. See #327 as well as https://bugs.python.org/issue39492
# This bug was fixed in Python3.8.2, but is still present using
# cloudpickle and Python3.8.0/1, hence the skipif directive.
class MyClass:
pass

my_object = MyClass()
wr = weakref.ref(my_object)

cloudpickle.dumps(my_object)
del my_object
assert wr() is None, "'del'-ed my_object has not been collected"

def test_itemgetter(self):
d = range(10)
getter = itemgetter(1)
Expand Down

0 comments on commit a8ac785

Please sign in to comment.