Mathics3 / mathics-core

An open-source Mathematica. This repository contains the Python modules for WL Built-in functions, variables, core primitives, e.g. Symbol, a parser to create Expressions, and an evaluator to execute them.

Home Page:https://mathics.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Max Recursion in Flat attribute testing using CPython

rocky opened this issue · comments

Description

On CPython 3.8.16 , 3.10.9 (and probably others) we are getting an Exception maximum recursion depth exceeded in running a doctest for the Flat attribute.

How to Reproduce

Set to C python 3.8 and run

MATHICS_CHARACTER_ENCODING="ASCII" SANDBOX= python mathics/docpipeline.py -xs 'Flat'

Output Given

Testing section: Attributes of Definitions / Flat
b'   1 ( 0): TEST SetAttributes[f, Flat]'
b'   2 ( 0): TEST f[a, f[b, c]]'
b'   3 ( 0): TEST f[a, b, c] /. f[a, b] -> d'
b'   4 ( 0): TEST SetAttributes[{u, v}, Flat]'
b'   5 ( 0): TEST u[x_] := {x}'
b'   6 ( 0): TEST u[]'
b'   7 ( 0): TEST u[a]'
b'   8 ( 0): TEST u[a, b]'
----------------------------------------------------------------------
Test failed: Flat in Reference of Built-in Symbols / Attributes of Definitions
Reference of Built-in Symbols
Exception maximum recursion depth exceeded while calling a Python object

Traceback (most recent call last):
  File "/src/external-vcs/github/Mathics3/mathics-core/mathics/core/expression.py", line 1332, in sameQ
    return all(
  File "/src/external-vcs/github/Mathics3/mathics-core/mathics/core/expression.py", line 1333, in <genexpr>
    (id(element) == id(oelement) or element.sameQ(oelement))
  File "/src/external-vcs/github/Mathics3/mathics-core/mathics/core/expression.py", line 1332, in sameQ
    return all(
  File "/src/external-vcs/github/Mathics3/mathics-core/mathics/core/expression.py", line 1333, in <genexpr>
...
  File "/src/external-vcs/github/Mathics3/mathics-core/mathics/core/expression.py", line 1332, in sameQ
    return all(
  File "/src/external-vcs/github/Mathics3/mathics-core/mathics/core/expression.py", line 1333, in <genexpr>
    (id(element) == id(oelement) or element.sameQ(oelement))
  File "/src/external-vcs/github/Mathics3/mathics-core/mathics/core/expression.py", line 1332, in sameQ
    return all(
  File "/src/external-vcs/github/Mathics3/mathics-core/mathics/core/expression.py", line 1333, in <genexpr>
    (id(element) == id(oelement) or element.sameQ(oelement))
RecursionError: maximum recursion depth exceeded while calling a Python object

Expected behavior

Test should pass

Workarounds

Use Pyston or PyPy interpreters.

Priority

Should be fixed before the next general Mathics3 release

Additional context

@rocky, this seems to have already been addressed. Shall we close this?

Yes - thanks for the reminder. I will be looking at the other PRs soon. Sorry for the delay.