1
0
mirror of https://github.com/django/django.git synced 2025-01-03 15:06:09 +00:00

Fixed #34768 -- Avoided initializing colorama on non-Windows platforms.

This commit is contained in:
Sulabh Katila 2023-08-30 23:03:30 -04:00 committed by Mariusz Felisiak
parent 9cc0d7f7f8
commit 9a9620dda6
6 changed files with 10 additions and 7 deletions

View File

@ -11,7 +11,8 @@ from django.utils import termcolors
try: try:
import colorama import colorama
colorama.init() # Avoid initializing colorama in non-Windows platforms.
colorama.just_fix_windows_console()
except (ImportError, OSError): except (ImportError, OSError):
HAS_COLORAMA = False HAS_COLORAMA = False
else: else:
@ -48,7 +49,7 @@ def supports_color():
return is_a_tty and ( return is_a_tty and (
sys.platform != "win32" sys.platform != "win32"
or HAS_COLORAMA or (HAS_COLORAMA and getattr(colorama, "fixed_windows_console", False))
or "ANSICON" in os.environ or "ANSICON" in os.environ
or or
# Windows Terminal supports VT codes. # Windows Terminal supports VT codes.

View File

@ -103,12 +103,12 @@ terminal. In modern terminals this should work for both CMD and PowerShell. If
for some reason this needs to be disabled, set the environmental variable for some reason this needs to be disabled, set the environmental variable
:envvar:`DJANGO_COLORS` to ``nocolor``. :envvar:`DJANGO_COLORS` to ``nocolor``.
On older Windows versions, or legacy terminals, :pypi:`colorama` must be On older Windows versions, or legacy terminals, :pypi:`colorama` 0.4.6+ must be
installed to enable syntax coloring: installed to enable syntax coloring:
.. code-block:: doscon .. code-block:: doscon
...\> py -m pip install colorama ...\> py -m pip install "colorama >= 0.4.6"
See :ref:`syntax-coloring` for more information on color settings. See :ref:`syntax-coloring` for more information on color settings.

View File

@ -281,7 +281,7 @@ dependencies:
* :pypi:`argon2-cffi` 19.2.0+ * :pypi:`argon2-cffi` 19.2.0+
* :pypi:`asgiref` 3.7.0+ (required) * :pypi:`asgiref` 3.7.0+ (required)
* :pypi:`bcrypt` * :pypi:`bcrypt`
* :pypi:`colorama` * :pypi:`colorama` 0.4.6+
* :pypi:`docutils` * :pypi:`docutils`
* :pypi:`geoip2` * :pypi:`geoip2`
* :pypi:`Jinja2` 2.11+ * :pypi:`Jinja2` 2.11+

View File

@ -1931,7 +1931,7 @@ two third-party libraries are needed:
.. code-block:: doscon .. code-block:: doscon
...\> py -m pip install colorama ...\> py -m pip install "colorama >= 0.4.6"
* Install `ANSICON`_, a third-party tool that allows ``cmd.exe`` to process * Install `ANSICON`_, a third-party tool that allows ``cmd.exe`` to process
ANSI color codes. Django commands will detect its presence and will make use ANSI color codes. Django commands will detect its presence and will make use

View File

@ -630,6 +630,8 @@ Miscellaneous
requests with the :mimetype:`application/x-www-form-urlencoded` content type. requests with the :mimetype:`application/x-www-form-urlencoded` content type.
See :rfc:`1866` for more details. See :rfc:`1866` for more details.
* The minimum supported version of ``colorama`` is increased to 0.4.6.
.. _deprecated-features-5.0: .. _deprecated-features-5.0:
Features deprecated in 5.0 Features deprecated in 5.0

View File

@ -18,4 +18,4 @@ selenium >= 4.8.0
sqlparse >= 0.3.1 sqlparse >= 0.3.1
tblib >= 1.5.0 tblib >= 1.5.0
tzdata tzdata
colorama; sys.platform == 'win32' colorama >= 0.4.6; sys.platform == 'win32'