From: Savannah Ostrowski Date: Tue, 9 Dec 2025 17:22:26 +0000 (-0800) Subject: [3.14] GH-139946: Document argparse includes color codes when redirecting to stderr... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69ecb4c234b6aa6f2863e8282526264a1f7942ba;p=thirdparty%2FPython%2Fcpython.git [3.14] GH-139946: Document argparse includes color codes when redirecting to stderr to file (#142398) Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index b8ecbf3e5846..f64ace037f69 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -644,6 +644,13 @@ variables and terminal capabilities. However, if ``color=False``, colored output is always disabled, even if environment variables like ``FORCE_COLOR`` are set. +.. note:: + + Error messages will include color codes when redirecting stderr to a + file. To avoid this, set the |NO_COLOR|_ or :envvar:`PYTHON_COLORS` + environment variable (for example, + ``NO_COLOR=1 python script.py 2> errors.txt``). + .. versionadded:: 3.14