Compiler RecursionError more likely to occur in 3.13
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug report
Bug description:
Reference: https://github.com/sympy/sympy/issues/26692
There's a long expression in sympy that's causing a RecursionError in ast.c. The source of the RecursionError is https://github.com/python/cpython/blob/ffc8e21c80627c46be7a7467ee5427924fdeb885/Python/ast.c#L217.
This seems to happen with a 3.13 debug build due to a lower recursion limit. The error doesn't happen in 3.13 release.
Interestingly, the error doesn't happen in the 3.12 debug build, even though the recursion limit appears to be the same. This leads me to believe that 3.13 is causing more recursive calls than expected. I think we should investigate why 3.13 is making additional calls and/or raise the recursion limit.
Simple repro:
import ast
contents = "x = " + " * ".join(["1"] * 2000)
result = ast.parse(contents)
On 3.12 debug, this code runs fine. On 3.13 debug, this code causes a RecursionError even when we change 2000 to 500 (leading me to believe that it is not the case that 3.13 is just adding a constant number of additional calls).
CPython versions tested on:
3.12, 3.13
Operating systems tested on:
Linux
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, den Ausdruck mit ast.parse in 3.12- und 3.13-Debug-Builds zu reproduzieren, und untersuche dann Python/ast.c bei der gemeldeten Rekursionsprüfung um Zeile 217. Ermittle, warum 3.13 zusätzliche rekursive Aufrufe ausführt oder ob das Rekursionslimit ungeeignet ist; erledigt ist die Aufgabe, wenn die Regression behoben und verifiziert wurde, dass die bereitgestellte Reproduktion nicht mehr fehlschlägt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 32/100