(self)
| 310 | self.assertFalse(stderr) |
| 311 | |
| 312 | def test_datetime_weakref_cycle(self): |
| 313 | # https://github.com/python/cpython/issues/132413 |
| 314 | # If the weakref used by the datetime extension gets cleared by the GC (due to being |
| 315 | # in an unreachable cycle) then datetime functions would crash (get_module_state() |
| 316 | # was returning a NULL pointer). This bug is fixed by clearing weakrefs without |
| 317 | # callbacks *after* running finalizers. |
| 318 | code = """if 1: |
| 319 | import _datetime |
| 320 | class C: |
| 321 | def __del__(self): |
| 322 | print('__del__ called') |
| 323 | _datetime.timedelta(days=1) # crash? |
| 324 | |
| 325 | l = [C()] |
| 326 | l.append(l) |
| 327 | """ |
| 328 | rc, stdout, stderr = assert_python_ok("-c", code) |
| 329 | self.assertEqual(rc, 0) |
| 330 | self.assertEqual(stdout.strip(), b'__del__ called') |
| 331 | |
| 332 | @refcount_test |
| 333 | def test_frame(self): |
nothing calls this directly
no test coverage detected