Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Include/internal/pycore_traceback.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif

/* Maximum number of error tracebacks to print */
#define PyTraceBack_LIMIT 1000

// Export for '_ctypes' shared extension
PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int, int *, PyObject **);

Expand Down
3 changes: 3 additions & 0 deletions Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,9 @@ def check(tracebacklimit, expected):
b' ~~^~~',
b'ZeroDivisionError: division by zero'
]
self.assertTrue(hasattr(sys, "tracebacklimit"),
'tracebacklimit attribute does not exist')
self.assertEqual(sys.tracebacklimit, 1_000)
check(10, traceback)
check(3, traceback)
check(2, traceback[:1] + traceback[4:])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix missing :attr:`sys.tracebacklimit` in :mod:`sys`. Patch by RUANG.
3 changes: 3 additions & 0 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Data members:
#include "pycore_structseq.h" // _PyStructSequence_InitBuiltinWithFlags()
#include "pycore_sysmodule.h" // export _PySys_GetSizeOf()
#include "pycore_tuple.h" // _PyTuple_FromArray()
#include "pycore_traceback.h" // PyTraceBack_LIMIT

#include "pydtrace.h" // PyDTrace_AUDIT()
#include "osdefs.h" // DELIM
Expand Down Expand Up @@ -3666,6 +3667,8 @@ _PySys_UpdateConfig(PyThreadState *tstate)
COPY_LIST("path", config->module_search_paths);
}

SET_SYS("tracebacklimit", PyLong_FromLong(PyTraceBack_LIMIT));

COPY_WSTR("executable", config->executable);
COPY_WSTR("_base_executable", config->base_executable);
COPY_WSTR("prefix", config->prefix);
Expand Down
2 changes: 0 additions & 2 deletions Python/traceback.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,6 @@ tb_printinternal(PyTracebackObject *tb, PyObject *f, long limit)
return -1;
}

#define PyTraceBack_LIMIT 1000

int
_PyTraceBack_Print(PyObject *v, const char *header, PyObject *f)
{
Expand Down
Loading