Georg Brandl | 7e8bfa4 | 2006-01-10 19:29:24 +0000 | [diff] [blame^] | 1 | # |
| 2 | # This file is for everybody to add tests for crashes that aren't |
| 3 | # fixed yet. Please add a test case and appropriate description. |
| 4 | # |
| 5 | # When you fix one of the crashes, please move the test to the correct |
| 6 | # test_ module. |
| 7 | # |
| 8 | |
| 9 | import unittest |
| 10 | from test import test_support |
| 11 | |
| 12 | |
| 13 | # Bug 1377858 |
| 14 | # |
| 15 | # mwh's description: |
| 16 | # The problem is obvious if you read typeobject.c around line 660: the weakref |
| 17 | # list is cleared before __del__ is called, so any weakrefs added during the |
| 18 | # execution of __del__ are never informed of the object's death. |
| 19 | |
| 20 | import weakref |
| 21 | ref = None |
| 22 | |
| 23 | class TestBug1377858(unittest.TestCase): |
| 24 | class Target(object): |
| 25 | def __del__(self): |
| 26 | global ref |
| 27 | ref = weakref.ref(self) |
| 28 | |
| 29 | def testBug1377858(self): |
| 30 | w = self.__class__.Target() |
| 31 | w = None |
| 32 | print ref() |
| 33 | |
| 34 | def test_main(): |
| 35 | test_support.run_unittest(TestBug1377858) |
| 36 | |
| 37 | if __name__ == "__main__": |
| 38 | test_main() |