# Bug report

### Bug description:

```python
./python.exe -m test -R 3:3 test_pydoc                                   
Using random seed: 928599674
0:00:00 load avg: 6.51 Run 1 test sequentially
0:00:00 load avg: 6.51 [1/1] test_pydoc.test_pydoc
beginning 6 repetitions. Showing number of leaks (. for 0 or less, X for 10 or more)
123:456
XXX XXX
test_pydoc.test_pydoc leaked [609, 609, 609] references, sum=1827
test_pydoc.test_pydoc leaked [607, 607, 607] memory blocks, sum=1821
test_pydoc.test_pydoc failed (reference leak)

== Tests result: FAILURE ==

1 test failed:
    test_pydoc.test_pydoc

Total duration: 15.7 sec
Total tests: run=108 skipped=3
Total test files: run=1/1 failed=1
Result: FAILURE
```

### CPython versions tested on:

CPython main branch

### Operating systems tested on:

macOS

<!-- gh-linked-prs -->
### Linked PRs
* gh-119705
* gh-119707
* gh-119708
<!-- /gh-linked-prs -->

``test_pydoc`` leaks references
This is a GitHub Issue
repo:cpython
owner:python
Title : ``test_pydoc`` leaks references
Issue date:

--- start body ---
# Bug report

### Bug description:

```python
./python.exe -m test -R 3:3 test_pydoc                                   
Using random seed: 928599674
0:00:00 load avg: 6.51 Run 1 test sequentially
0:00:00 load avg: 6.51 [1/1] test_pydoc.test_pydoc
beginning 6 repetitions. Showing number of leaks (. for 0 or less, X for 10 or more)
123:456
XXX XXX
test_pydoc.test_pydoc leaked [609, 609, 609] references, sum=1827
test_pydoc.test_pydoc leaked [607, 607, 607] memory blocks, sum=1821
test_pydoc.test_pydoc failed (reference leak)

== Tests result: FAILURE ==

1 test failed:
    test_pydoc.test_pydoc

Total duration: 15.7 sec
Total tests: run=108 skipped=3
Total test files: run=1/1 failed=1
Result: FAILURE
```

### CPython versions tested on:

CPython main branch

### Operating systems tested on:

macOS

<!-- gh-linked-prs -->
### Linked PRs
* gh-119705
* gh-119707
* gh-119708
<!-- /gh-linked-prs -->

--- end body ---
