Skip to content

MAINT: don't assert RecursionError in monster dtype test - #30375

Merged
charris merged 2 commits into
numpy:mainfrom
ngoldbaum:fix-tuple-recursion-test
Dec 4, 2025
Merged

charris merged 2 commits into
numpy:mainfrom
ngoldbaum:fix-tuple-recursion-test

Conversation

@ngoldbaum

Copy link
Copy Markdown
Member

Fixes #30370.

Newer CPython versions can recurse more deeply without raising a RecursionError and blowing out the stack. It happens that on x86_64 MacOS the np.dtype call succeeds and no error is raised. IMO it's fine if there's no error, the test was simply checking for the observed behavior of CPython and verifying that the case doesn't lead to a seg fault. See bb76bff for context.

Comment thread numpy/_core/tests/test_dtype.py Resolved
@colesbury

Copy link
Copy Markdown

This makes sense to me. For what it's worth, I was able to repro this with setup/python on GHA but not uv's version of Python. I think it's just that we don't hit the recursion limit at 100,000 iterations. Increasing the iterations to 1,000,000 seemed to trigger the RecursionError on macOS x86-64:

Here are runs from a test repo:

https://github.com/colesbury/issue142253/actions/runs/19940622355 (100,000)
https://github.com/colesbury/issue142253/actions/runs/19940738167 (1,000,000)

@ngoldbaum ngoldbaum added the 09 - Backport-Candidate PRs tagged should be backported label Dec 4, 2025
@charris
charris merged commit eeaf046 into numpy:main Dec 4, 2025
67 checks passed
@charris

charris commented Dec 4, 2025

Copy link
Copy Markdown
Member

Thanks Nathan. Should we do the same for the list recursion test?

@ngoldbaum

Copy link
Copy Markdown
Member Author

Nope, that one is self-referential so it has to error eventually.

charris pushed a commit to charris/numpy that referenced this pull request Dec 4, 2025
* MAINT: don't assert RecursionError in monster dtype test

* MAINT: use contextlib
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Dec 4, 2025
charris added a commit that referenced this pull request Dec 4, 2025
MAINT: don't assert RecursionError in monster dtype test (#30375)
cakedev0 pushed a commit to cakedev0/numpy that referenced this pull request Dec 5, 2025
* MAINT: don't assert RecursionError in monster dtype test

* MAINT: use contextlib
IndifferentArea pushed a commit to IndifferentArea/numpy that referenced this pull request Dec 7, 2025
* MAINT: don't assert RecursionError in monster dtype test

* MAINT: use contextlib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python 3.14.1t seems to be failing test_tuple_recursion on macos x86_64

4 participants