﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34768	Calling `colorama.init()` on module load can have unwanted side effects	Charlie DeTar	Sulabh Katila	"`django.core.management.color` calls [https://github.com/django/django/blob/aa3cb3f37265be37d892e2b391ff023e9caee2a4/django/core/management/color.py#L12-L14 `colorama.init()`] on module load if the module is present in the system.  This causes `sys.stdout` to be replaced by an instance of `colorama.ansitowin32.StreamWrapper`.

This, in turn, can cause problems in other contexts that do not expect `sys.stdout` to be a colorama wrapper.  For example, using `pytest` with `pytest-xdist` in `--looponfail` mode (which uses [https://pypi.org/project/execnet/ execnet] to further wrap its output) results in ansi color escapes getting dropped from the output.

In discussion of #32740, a maintainer commented ""There's no reason to have colorama installed at all if you're not on windows"".  However, colorama now [https://github.com/tartley/colorama describes itself] as providing a ""simple cross-platform API for printing colored terminal text from Python""; and indeed, [https://github.com/Riverside-Healthcare/djlint djlint] installs colorama as a dependency for all platforms, using other color utilities within the project rather than the stream wrapper.  In short: it is probably not right to assume that `colorama` will only be present on win32, and thus Django probably shouldn't be replacing `sys.stdout` with it on module import without at a platform check.

To summarize: a linux environment which installs:
- Django v3.2 -> dev
- djlint v1.32.x
- pytest-xdist v3.3.x
will lose colorized output while running `pytest` with `--looponfail` due to Django's call to `colorama.init()`, which is an unnecessary call on that platform."	Cleanup/optimization	closed	Core (Management commands)	4.2	Normal	fixed			Ready for checkin	1	0	0	0	0	0
