Skip to content

Commit

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

@pytest.mark.skipif(
platform.python_implementation() != "CPython" or
(sys.version_info >= (3, 8, 0) and sys.version_info < (3, 8, 2)),
reason="Underlying bug fixed upstream starting Python 3.8.2")
def test_reducer_override_reference_cycle(self):
# Early versions of Python 3.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 Python 3.8.2, but is still present using
# cloudpickle and Python 3.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 f4ce61f

Please sign in to comment.