Skip to content

AST Recursion failure from hypothesis in SymPy CI #4364

Closed
@oscarbenjamin

Description

@oscarbenjamin

This is coming from sympy/sympy#27967

The hypothesis tests in SymPy CI are failing because of what looks like a bug in hypothesis:
https://github.com/sympy/sympy/actions/runs/14534219412/job/40779555253?pr=27821

The failure is a RecursionError:

=================================== FAILURES ===================================
_____________________________ test_gcd_hypothesis ______________________________
[gw3] linux -- Python 3.13.3 /opt/hostedtoolcache/Python/3.13.3/x64/bin/python

    @given(f=polys(), g=polys(), r=polys())
>   def test_gcd_hypothesis(f, g, r):

sympy/polys/tests/test_hypothesis.py:17: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.13.3/x64/lib/python3.13/ast.py:428: in visit
    return visitor(node)
...
/opt/hostedtoolcache/Python/3.13.3/x64/lib/python3.13/ast.py:438: in generic_visit
    self.visit(value)
/opt/hostedtoolcache/Python/3.13.3/x64/lib/python3.13/ast.py:428: in visit
    return visitor(node)
/opt/hostedtoolcache/Python/3.13.3/x64/lib/python3.13/ast.py:438: in generic_visit
    self.visit(value)
/opt/hostedtoolcache/Python/3.13.3/x64/lib/python3.13/ast.py:428: in visit
    return visitor(node)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <hypothesis.internal.constants_ast.ConstantVisitor object at 0x7fe7fc6e0870>
node = <ast.BinOp object at 0x7fe7fcb4fc50>

    def generic_visit(self, node):
        """Called if no explicit visitor function exists for a node."""
>       for field, value in iter_fields(node):
E       RecursionError: maximum recursion depth exceeded

I don't understand enough about hypothesis to know why it is using the ast module here or what ast it is trying to analyse. The code in the test functions is not complicated so there is no reason why it would have a large ast.

I don't know how to reproduce the failure outside of CI but it happens reliably there on all PRs now.

Metadata

Metadata

Assignees

Labels

bugsomething is clearly wrong here

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions