Skip to content

Commit 69ecb4c

Browse files
[3.14] GH-139946: Document argparse includes color codes when redirecting to stderr to file (#142398)
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 04ecff5 commit 69ecb4c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Doc/library/argparse.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,13 @@ variables and terminal capabilities. However, if ``color=False``, colored
644644
output is always disabled, even if environment variables like ``FORCE_COLOR``
645645
are set.
646646

647+
.. note::
648+
649+
Error messages will include color codes when redirecting stderr to a
650+
file. To avoid this, set the |NO_COLOR|_ or :envvar:`PYTHON_COLORS`
651+
environment variable (for example,
652+
``NO_COLOR=1 python script.py 2> errors.txt``).
653+
647654
.. versionadded:: 3.14
648655

649656

0 commit comments

Comments
 (0)