(self)
| 441 | @support.skip_if_unlimited_stack_size |
| 442 | @support.skip_emscripten_stack_overflow() |
| 443 | def test_recursive_pickle(self): |
| 444 | with replaced_module('functools', self.module): |
| 445 | f = self.partial(capture) |
| 446 | f.__setstate__((f, (), {}, {})) |
| 447 | try: |
| 448 | for proto in range(pickle.HIGHEST_PROTOCOL + 1): |
| 449 | # gh-117008: Small limit since pickle uses C stack memory |
| 450 | with support.infinite_recursion(100): |
| 451 | with self.assertRaises(RecursionError): |
| 452 | pickle.dumps(f, proto) |
| 453 | finally: |
| 454 | f.__setstate__((capture, (), {}, {})) |
| 455 | |
| 456 | f = self.partial(capture) |
| 457 | f.__setstate__((capture, (f,), {}, {})) |
| 458 | try: |
| 459 | for proto in range(pickle.HIGHEST_PROTOCOL + 1): |
| 460 | f_copy = pickle.loads(pickle.dumps(f, proto)) |
| 461 | try: |
| 462 | self.assertIs(f_copy.args[0], f_copy) |
| 463 | finally: |
| 464 | f_copy.__setstate__((capture, (), {}, {})) |
| 465 | finally: |
| 466 | f.__setstate__((capture, (), {}, {})) |
| 467 | |
| 468 | f = self.partial(capture) |
| 469 | f.__setstate__((capture, (), {'a': f}, {})) |
| 470 | try: |
| 471 | for proto in range(pickle.HIGHEST_PROTOCOL + 1): |
| 472 | f_copy = pickle.loads(pickle.dumps(f, proto)) |
| 473 | try: |
| 474 | self.assertIs(f_copy.keywords['a'], f_copy) |
| 475 | finally: |
| 476 | f_copy.__setstate__((capture, (), {}, {})) |
| 477 | finally: |
| 478 | f.__setstate__((capture, (), {}, {})) |
| 479 | |
| 480 | # Issue 6083: Reference counting bug |
| 481 | def test_setstate_refcount(self): |
nothing calls this directly
no test coverage detected