gh-145492: fix regression test for defaultdict factory repr by KowalskiThomas · Pull Request #145788 · python/cpython · GitHub
Skip to content

gh-145492: fix regression test for defaultdict factory repr - #145788

Merged
encukou merged 1 commit into
python:mainfrom
KowalskiThomas:kowalski/test-fix-regression-test-for-defaultdict-factory-repr
Mar 11, 2026
Merged

encukou merged 1 commit into
python:mainfrom
KowalskiThomas:kowalski/test-fix-regression-test-for-defaultdict-factory-repr

Conversation

@KowalskiThomas

@KowalskiThomas KowalskiThomas commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

What is this PR?

This PR fixes the regression test introduced in #145761 and that did not properly reproduce the issue.

Running the test without the repr changes now properly crashes.

% ./python.exe -m unittest test.test_defaultdict
..........E..
======================================================================
ERROR: test_repr_recursive_factory (test.test_defaultdict.TestDefaultDict.test_repr_recursive_factory)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/thomas.kowalski/Documents/cpython/Lib/test/test_defaultdict.py", line 219, in test_repr_recursive_factory
    r = repr(dd)
  File "/Users/thomas.kowalski/Documents/cpython/Lib/test/test_defaultdict.py", line 215, in __repr__
    return f"ProblematicFactory for {dd}"
                                    ^^^^
  File "/Users/thomas.kowalski/Documents/cpython/Lib/test/test_defaultdict.py", line 215, in __repr__
    return f"ProblematicFactory for {dd}"
                                    ^^^^
  File "/Users/thomas.kowalski/Documents/cpython/Lib/test/test_defaultdict.py", line 215, in __repr__
    return f"ProblematicFactory for {dd}"
                                    ^^^^
  [Previous line repeated 981 more times]
RecursionError: maximum recursion depth exceeded

----------------------------------------------------------------------
Ran 13 tests in 1.742s

gh-145492

@YvesDup

YvesDup commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

@encukou
encukou merged commit aa4240e into python:main Mar 11, 2026
51 checks passed
@encukou

encukou commented Mar 11, 2026

Copy link
Copy Markdown
Member

Thank you!

encukou pushed a commit to miss-islington/cpython that referenced this pull request Mar 11, 2026
encukou pushed a commit to miss-islington/cpython that referenced this pull request Mar 11, 2026
@KowalskiThomas

Copy link
Copy Markdown
Contributor Author

I guess we should backport the non-regression test as well?

encukou pushed a commit that referenced this pull request Mar 12, 2026
) (GH-145747)

(cherry picked from commit 2d35f9b)

Includes test fix-up from GH-145788
(cherry picked from commit aa4240e)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
Co-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>
encukou pushed a commit that referenced this pull request Mar 12, 2026
) (GH-145746)

(cherry picked from commit 2d35f9b)

Includes test fix-up from GH-145788
(cherry picked from commit aa4240e)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
Co-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>
@encukou

encukou commented Mar 12, 2026

Copy link
Copy Markdown
Member

Yes, I included it in the backports :)

@KowalskiThomas

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants