Skip to content

Commit a0656ce

Browse files
gpsheadclaude
andcommitted
πŸ“ Address PR code review comments for documentation and formatting
- Add cross-references between command line flags and environment variables - Clarify default behavior when PYTHON_TRACEBACK_TIMESTAMPS is unset - Simplify traceback.rst wording to use "canonical output" - Fix alphabetical ordering in test_config.py - Improve comment formatting in test_sys.py for better readability πŸ€– Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 77ffb5a commit a0656ce

File tree

6 files changed

+15
-11
lines changed

6 files changed

+15
-11
lines changed

β€ŽDoc/library/exceptions.rstβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ The following exceptions are used mostly as base classes for other exceptions.
165165
(usually: when it was raised); the same accuracy as :func:`time.time_ns`.
166166
Display of these timestamps after the exception message in tracebacks is
167167
off by default but can be configured using the
168-
:envvar:`PYTHON_TRACEBACK_TIMESTAMPS` environment variable. In
168+
:envvar:`PYTHON_TRACEBACK_TIMESTAMPS` environment variable or the
169+
:option:`-X traceback_timestamps <-X>` command line option. In
169170
applications with complicated exception chains and exception groups it
170171
may be useful to help understand what happened when. The value will be
171172
``0`` if a timestamp was not recorded. :exc:`StopIteration` and

β€ŽDoc/library/sys.rstβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,8 @@ always available. Unless explicitly noted otherwise, all variables are read-only
607607
:envvar:`PYTHON_CONTEXT_AWARE_WARNINGS`
608608

609609
* - .. attribute:: flags.traceback_timestamps
610-
- :option:`-X traceback_timestamps <-X>`. This is a string containing
610+
- :option:`-X traceback_timestamps <-X>` and
611+
:envvar:`PYTHON_TRACEBACK_TIMESTAMPS`. This is a string containing
611612
the selected format (``us``, ``ns``, ``iso``), or an empty string
612613
when disabled.
613614

β€ŽDoc/library/traceback.rstβ€Ž

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ Module-Level Functions
213213
via the :envvar:`PYTHON_TRACEBACK_TIMESTAMPS` environment variable or the
214214
:option:`-X traceback_timestamps <-X>` command line option, any timestamp
215215
after the exception message will be omitted. This is useful for tests or
216-
other situations where you need consistent output regardless of when
217-
exceptions occur.
216+
other situations where you need canonical output.
218217

219218
.. versionchanged:: 3.10
220219
The *etype* parameter has been renamed to *exc* and is now

β€ŽDoc/using/cmdline.rstβ€Ž

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,10 +1322,10 @@ conflict.
13221322
* ``iso``: Prints the timestamp formatted by :meth:`~datetime.datetime.isoformat` (also microsecond precision).
13231323
* ``0``: Explicitly disables timestamps.
13241324

1325-
The time is not recorded on the :exc:`StopIteration` family of exceptions
1326-
for performance reasons as those are used for control flow rather than
1327-
errors. If unset, empty, or set to invalid values, this feature remains disabled
1328-
when using the environment variable.
1325+
When unset, timestamps are disabled by default. The time is not recorded on
1326+
the :exc:`StopIteration` family of exceptions for performance reasons as those
1327+
are used for control flow rather than errors. If set to empty or invalid values,
1328+
this feature remains disabled when using the environment variable.
13291329

13301330
Note that the command line option :option:`-X` ``traceback_timestamps`` takes
13311331
precedence over this environment variable when both are specified.

β€ŽLib/test/test_capi/test_config.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def test_config_get(self):
8686
("stdio_encoding", str, None),
8787
("stdio_errors", str, None),
8888
("stdlib_dir", str | None, "_stdlib_dir"),
89-
("tracemalloc", int, None),
9089
("traceback_timestamps", str, None),
90+
("tracemalloc", int, None),
9191
("use_environment", bool, None),
9292
("use_frozen_modules", bool, None),
9393
("use_hash_seed", bool, None),

β€ŽLib/test/test_sys.pyβ€Ž

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,8 +1890,11 @@ def test_pythontypes(self):
18901890
# symtable entry
18911891
# XXX
18921892
# sys.flags
1893-
# FIXME: The +3 is for the 'gil', 'thread_inherit_context',
1894-
# 'context_aware_warnings', and 'traceback_timestamps' flags.
1893+
# FIXME: The non_sequence_fields adjustment is for these flags:
1894+
# - 'gil'
1895+
# - 'thread_inherit_context'
1896+
# - 'context_aware_warnings'
1897+
# - 'traceback_timestamps'
18951898
# It will not be necessary once GH-122575 is fixed.
18961899
non_sequence_fields = 4
18971900
check(sys.flags, vsize('') + self.P + self.P * (non_sequence_fields + len(sys.flags)))

0 commit comments

Comments
Β (0)