Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proof of concept: Add timestamps to tracebacks. #129337

Draft
wants to merge 30 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c5a9ccd
Proof of concept: Add timestamps to tracebacks.
gpshead Jan 27, 2025
3dc00c2
`PYTHON_TRACEBACK_TIMESTAMPS=1` required to enable their display.
gpshead Jan 27, 2025
a05766f
skip timestamp on StopIteration - not an error
gpshead Jan 28, 2025
cdb67f0
include the timestamp in exception pickles.
gpshead Jan 28, 2025
99ffc8a
os.environ not os.environb
gpshead Jan 30, 2025
c119a02
Cleaner struct layout.
gpshead Feb 2, 2025
bcc720b
Timestamp format configurability.
gpshead Feb 2, 2025
b065394
Plumb into exception subtypes; including pickling.
gpshead Feb 2, 2025
09a547a
minor cleanups
gpshead Feb 2, 2025
daa752d
initial pass at documentation.
gpshead Feb 2, 2025
e7fab86
Fix doc references?
gpshead Feb 2, 2025
e8a6297
proper refcount cleanup in error cases.
gpshead Feb 2, 2025
6809426
Merge branch 'main' into traceback-timestamps
gpshead Feb 9, 2025
0d83447
Allow `PyErr_Display*` to emit timestamps as well.
gpshead Feb 10, 2025
7c83ebf
Make the testsuite pass with timestamps turned on.
gpshead Feb 10, 2025
beadfb8
Docs docs docs docs docs
gpshead Feb 10, 2025
354c5f0
docs make check
gpshead Feb 10, 2025
33d20dd
docs typo
gpshead Feb 10, 2025
2f72323
GIT
gpshead Feb 10, 2025
7f7357d
docs: reword exceptions
gpshead Feb 10, 2025
d9d2b1f
vi PEBKAC reformatted traceback.rst? undo
gpshead Feb 10, 2025
98b4593
more formatting messup undo
gpshead Feb 10, 2025
c9ad56d
more undo
gpshead Feb 10, 2025
53b5500
reword some docs, add examples
gpshead Feb 10, 2025
8043b80
REDO BEFORE MERGE: enable on some CI builds
gpshead Feb 10, 2025
75072cb
Go full on -X traceback_timestamps command line flag.
gpshead Feb 26, 2025
eebec1d
Disable time collection when display is disabled.
gpshead Mar 2, 2025
9ff3234
remove errant Doc temp db file
gpshead Mar 2, 2025
f30c74d
WIP: optional config string
gpshead Mar 7, 2025
85496cf
WIP: no dict key for reduce when 0
gpshead Mar 7, 2025
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
Prev Previous commit
Next Next commit
minor cleanups
gpshead committed Feb 2, 2025
commit 09a547a7cadaae411a60388341967090fffca1f4
7 changes: 1 addition & 6 deletions Lib/traceback.py
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@
'FrameSummary', 'StackSummary', 'TracebackException',
'walk_stack', 'walk_tb', 'print_list']


#
# Formatting and printing lists of traceback lines.
#
@@ -1083,11 +1082,7 @@ def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
self.__notes__ = [
f'Ignored error getting __notes__: {_safe_string(e, '__notes__', repr)}']

if _TIMESTAMP_FORMAT:
self._timestamp_ns = exc_value.__timestamp_ns__
else:
self._timestamp_ns = 0

self._timestamp_ns = exc_value.__timestamp_ns__ if _TIMESTAMP_FORMAT else 0
self._is_syntax_error = False
self._have_exc_type = exc_type is not None
if exc_type is not None:
6 changes: 1 addition & 5 deletions Objects/exceptions.c
Original file line number Diff line number Diff line change
@@ -244,11 +244,7 @@ BaseException___reduce___impl(PyBaseExceptionObject *self)
if (!BaseException_add_timestamp_to_dict(self, self->dict)) {
return NULL;
}
if (self->args && self->dict) {
return PyTuple_Pack(3, Py_TYPE(self), self->args, self->dict);
} else {
return PyTuple_Pack(2, Py_TYPE(self), self->args);
}
return PyTuple_Pack(3, Py_TYPE(self), self->args, self->dict);
}

/*