]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] GH-139946: Document argparse includes color codes when redirecting to stderr...
authorSavannah Ostrowski <savannah@python.org>
Tue, 9 Dec 2025 17:22:26 +0000 (09:22 -0800)
committerGitHub <noreply@github.com>
Tue, 9 Dec 2025 17:22:26 +0000 (17:22 +0000)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Doc/library/argparse.rst

index b8ecbf3e5846306dcc8dbb50cb5ba24bd9291cf5..f64ace037f69753ace5236ee5a4122fd6933d175 100644 (file)
@@ -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