gh-112730: Use color to highlight error locations (gh-112732)

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
Pablo Galindo Salgado 2023-12-06 22:29:54 +00:00 committed by GitHub
parent 3870d19d15
commit 16448cab44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 369 additions and 40 deletions

View file

@ -612,6 +612,27 @@ Miscellaneous options
.. versionadded:: 3.13
The ``-X presite`` option.
Controlling Color
~~~~~~~~~~~~~~~~~
The Python interpreter is configured by default to use colors to highlight
output in certain situations such as when displaying tracebacks. This
behavior can be controlled by setting different environment variables.
Setting the environment variable ``TERM`` to ``dumb`` will disable color.
If the environment variable ``FORCE_COLOR`` is set, then color will be
enabled regardless of the value of TERM. This is useful on CI systems which
arent terminals but can none-the-less display ANSI escape sequences.
If the environment variable ``NO_COLOR`` is set, Python will disable all color
in the output. This takes precedence over ``FORCE_COLOR``.
All these environment variables are used also by other tools to control color
output. To control the color output only in the Python interpreter, the
:envvar:`PYTHON_COLORS` environment variable can be used. This variable takes
precedence over ``NO_COLOR``, which in turn takes precedence over
``FORCE_COLOR``.
Options you shouldn't use
~~~~~~~~~~~~~~~~~~~~~~~~~
@ -1110,6 +1131,12 @@ conflict.
.. versionadded:: 3.13
.. envvar:: PYTHON_COLORS
If this variable is set to ``1``, the interpreter will colorize various kinds
of output. Setting it to ``0`` deactivates this behavior.
.. versionadded:: 3.13
Debug-mode variables
~~~~~~~~~~~~~~~~~~~~