Python implementation of traceback limit does not default to 1000 as documented 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:
According to the documentation of sys.tracebacklimit, it should default to 1000 if not set, so the following snippet:
import sys
def f():
f()
sys.setrecursionlimit(2000)
f()
produces a traceback of 1000 frames as expected in 3.12:
Traceback (most recent call last):
File "t.py", line 4, in f
f()
~^^
File "t.py", line 4, in f
f()
~^^
File "t.py", line 4, in f
f()
~^^
[Previous line repeated 997 more times]
RecursionError: maximum recursion depth exceeded
But in 3.13 and the current master, it produces a traceback of all 2000 frames:
Traceback (most recent call last):
File "t.py", line 4, in f
f()
~^^
File "t.py", line 4, in f
f()
~^^
File "t.py", line 4, in f
f()
~^^
File "t.py", line 4, in f
f()
~^^
[Previous line repeated 1996 more times]
RecursionError: maximum recursion depth exceeded
This is because with issue #110721, traceback is now printed with the traceback module by default, and the traceback module defaults sys.tracebacklimit to None when not set:
https://github.com/python/cpython/blob/c3ed775899eedd47d37f8f1840345b108920e400/Lib/traceback.py#L458
whereas the C implementation of the traceback printer has a proper default of 1000 for sys.tracebacklimit as documented:
https://github.com/python/cpython/blob/c3ed775899eedd47d37f8f1840345b108920e400/Python/traceback.c#L707
I will submit a PR to make 1000 the default value for sys.tracebacklimit in the Python implementation of the traceback module.
CPython versions tested on:
3.13, CPython main branch
Operating systems tested on:
Linux, Windows
Linked PRs
- gh-125719
- gh-125777
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 in Lib/traceback.py bei der Standardbehandlung für sys.tracebacklimit und vergleiche sie mit der C-Implementierung in Python/traceback.c. Überprüfe den dokumentierten Standardwert von 1000 anhand des rekursiven Beispiels aus dem Issue und stelle sicher, dass Pythons Traceback-Ausgabe die Ausgabe konsistent mit der C-Implementierung begrenzt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 20/100