@@ -79,7 +79,7 @@ Module-Level Functions
7979
8080
8181.. function :: print_exception(exc, /[, value, tb], limit=None, \
82- file=None, chain=True, \* , no_timestamp=False )
82+ file=None, chain=True, \* , timestamps=None )
8383
8484 Print exception information and stack trace entries from
8585 :ref: `traceback object <traceback-objects >`
@@ -108,11 +108,14 @@ Module-Level Functions
108108 printed as well, like the interpreter itself does when printing an unhandled
109109 exception.
110110
111- If *no_timestamp * is ``True `` and a traceback timestamp format is enabled via the
112- :envvar: `PYTHON_TRACEBACK_TIMESTAMPS ` environment variable or the
113- :option: `-X traceback_timestamps <-X> ` option, any timestamp after the exception
114- message will be omitted. This is useful for tests or other situations where
115- you need consistent output regardless of when exceptions occur.
111+ The *timestamps * argument controls whether the
112+ :attr: `~BaseException.__timestamp_ns__ ` of each exception is appended after
113+ its message. When ``None `` (the default), the global configuration set by
114+ :envvar: `PYTHON_TRACEBACK_TIMESTAMPS ` or
115+ :option: `-X traceback_timestamps <-X> ` is followed. When ``False ``,
116+ timestamps are never shown. When ``True ``, any non-zero
117+ ``__timestamp_ns__ `` is shown regardless of the global configuration, using
118+ the configured format if one is set and the ``ns `` format otherwise.
116119
117120 .. versionchanged :: 3.5
118121 The *etype * argument is ignored and inferred from the type of *value *.
@@ -122,7 +125,7 @@ Module-Level Functions
122125 positional-only.
123126
124127 .. versionchanged :: next
125- The *no_timestamp * keyword only argument was added.
128+ The *timestamps * keyword- only argument was added.
126129
127130
128131.. function :: print_exc(limit=None, file=None, chain=True)
@@ -191,7 +194,7 @@ Module-Level Functions
191194
192195
193196.. function :: format_exception_only(exc, /[, value], \*, show_group=False, \
194- no_timestamp=False )
197+ timestamps=None )
195198
196199 Format the exception part of a traceback using an exception value such as
197200 given by :data: `sys.last_value `. The return value is a list of strings, each
@@ -209,11 +212,8 @@ Module-Level Functions
209212 :exc: `BaseExceptionGroup `, the nested exceptions are included as
210213 well, recursively, with indentation relative to their nesting depth.
211214
212- If *no_timestamp * is ``True `` and a traceback timestamp formatting is enabled
213- via the :envvar: `PYTHON_TRACEBACK_TIMESTAMPS ` environment variable or the
214- :option: `-X traceback_timestamps <-X> ` command line option, any timestamp
215- after the exception message will be omitted. This is useful for tests or
216- other situations where you need canonical output.
215+ The *timestamps * argument has the same meaning as for
216+ :func: `print_exception `.
217217
218218 .. versionchanged :: 3.10
219219 The *etype * parameter has been renamed to *exc * and is now
@@ -227,24 +227,20 @@ Module-Level Functions
227227 *show_group * parameter was added.
228228
229229 .. versionchanged :: next
230- The *no_timestamp * keyword only argument was added.
230+ The *timestamps * keyword- only argument was added.
231231
232232
233233.. function :: format_exception(exc, /[, value, tb], limit=None, chain=True, \
234- \* , no_timestamp=False )
234+ \* , timestamps=None )
235235
236236 Format a stack trace and the exception information. The arguments have the
237237 same meaning as the corresponding arguments to :func: `print_exception `. The
238238 return value is a list of strings, each ending in a newline and some
239239 containing internal newlines. When these lines are concatenated and printed,
240240 exactly the same text is printed as does :func: `print_exception `.
241241
242- If *no_timestamp * is ``True `` and a traceback timestamp formatting is enabled
243- via the :envvar: `PYTHON_TRACEBACK_TIMESTAMPS ` environment variable or the
244- :option: `-X traceback_timestamps <-X> ` command line option, any timestamp
245- after the exception message will be omitted. This is useful for tests or
246- other situations where you need consistent output regardless of when
247- exceptions occur.
242+ The *timestamps * argument has the same meaning as for
243+ :func: `print_exception `.
248244
249245 .. versionchanged :: 3.5
250246 The *etype * argument is ignored and inferred from the type of *value *.
@@ -254,7 +250,7 @@ Module-Level Functions
254250 :func: `print_exception `.
255251
256252 .. versionchanged :: next
257- The *no_timestamp * keyword only argument was added.
253+ The *timestamps * keyword- only argument was added.
258254
259255
260256.. function :: format_exc(limit=None, chain=True)
@@ -329,7 +325,7 @@ storing this information by avoiding holding references to
329325In addition, they expose more options to configure the output compared to
330326the module-level functions described above.
331327
332- .. class :: TracebackException(exc_type, exc_value, exc_traceback, \*, limit=None, lookup_lines=True, capture_locals=False, compact=False, max_group_width=15, max_group_depth=10, no_timestamp=False )
328+ .. class :: TracebackException(exc_type, exc_value, exc_traceback, \*, limit=None, lookup_lines=True, capture_locals=False, compact=False, max_group_width=15, max_group_depth=10, timestamps=None )
333329
334330 Capture an exception for later rendering. The meaning of *limit *,
335331 *lookup_lines * and *capture_locals * are as for the :class: `StackSummary `
@@ -349,9 +345,13 @@ the module-level functions described above.
349345 group's exceptions array. The formatted output is truncated when either
350346 limit is exceeded.
351347
352- If *no_timestamp * is ``True `` the ``__timestamp_ns__ `` attribute from the
353- exception will not be rendered when formatting this
354- :class: `!TracebackException `.
348+ The *timestamps * argument controls whether each exception's
349+ :attr: `~BaseException.__timestamp_ns__ ` is captured for later rendering.
350+ When ``None `` (the default), the global configuration set by
351+ :envvar: `PYTHON_TRACEBACK_TIMESTAMPS ` or
352+ :option: `-X traceback_timestamps <-X> ` is followed. When ``False ``,
353+ timestamps are never shown. When ``True ``, any non-zero
354+ ``__timestamp_ns__ `` is shown regardless of the global configuration.
355355
356356 .. versionchanged :: 3.10
357357 Added the *compact * parameter.
@@ -360,7 +360,7 @@ the module-level functions described above.
360360 Added the *max_group_width * and *max_group_depth * parameters.
361361
362362 .. versionchanged :: next
363- Added the *no_timestamp * parameter.
363+ Added the *timestamps * parameter.
364364
365365 .. attribute :: __cause__
366366
0 commit comments