From c053dc993744b0062be2c82ec3efd3aa932ddeff Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Thu, 27 Feb 2020 10:02:52 +0000 Subject: [PATCH 1/4] Regression test for #906 --- traits/tests/test_callable.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/traits/tests/test_callable.py b/traits/tests/test_callable.py index a33309c66..098f31813 100644 --- a/traits/tests/test_callable.py +++ b/traits/tests/test_callable.py @@ -91,6 +91,21 @@ def test_callable_in_complex_trait(self): a.callable_or_str = value self.assertEqual(a.callable_or_str, old_value) + def test_compound_callable_refcount(self): + # Regression test for enthought/traits#906. + + def my_function(): + pass + + a = MyCallable() + + string_value = "some string" + callable_value = my_function + + for _ in range(10): + a.callable_or_str = string_value + a.callable_or_str = callable_value + def test_disallow_none(self): class MyNewCallable(HasTraits): From 5ef4f393485c98968656c0e76d57ea9230bdd29d Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Fri, 28 Feb 2020 08:25:07 +0000 Subject: [PATCH 2/4] See if a single iteration is enough to cause a segfault --- traits/tests/test_callable.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/traits/tests/test_callable.py b/traits/tests/test_callable.py index 098f31813..50478fbc7 100644 --- a/traits/tests/test_callable.py +++ b/traits/tests/test_callable.py @@ -102,9 +102,8 @@ def my_function(): string_value = "some string" callable_value = my_function - for _ in range(10): - a.callable_or_str = string_value - a.callable_or_str = callable_value + a.callable_or_str = string_value + a.callable_or_str = callable_value def test_disallow_none(self): From 4548a242878da04e01ce6e3bd6a5400e219052f2 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Fri, 28 Feb 2020 08:41:43 +0000 Subject: [PATCH 3/4] Try two iterations --- traits/tests/test_callable.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/traits/tests/test_callable.py b/traits/tests/test_callable.py index 50478fbc7..56f1298e5 100644 --- a/traits/tests/test_callable.py +++ b/traits/tests/test_callable.py @@ -102,8 +102,9 @@ def my_function(): string_value = "some string" callable_value = my_function - a.callable_or_str = string_value - a.callable_or_str = callable_value + for _ in range(2): + a.callable_or_str = string_value + a.callable_or_str = callable_value def test_disallow_none(self): From 9725f683bd52139476f60103538f78dd71b29c71 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Fri, 28 Feb 2020 08:46:18 +0000 Subject: [PATCH 4/4] Now try 3 iterations --- traits/tests/test_callable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/traits/tests/test_callable.py b/traits/tests/test_callable.py index 56f1298e5..7677634e0 100644 --- a/traits/tests/test_callable.py +++ b/traits/tests/test_callable.py @@ -102,7 +102,7 @@ def my_function(): string_value = "some string" callable_value = my_function - for _ in range(2): + for _ in range(3): a.callable_or_str = string_value a.callable_or_str = callable_value