diff --git a/django/core/management/color.py b/django/core/management/color.py
index 8c7a87f..ec63b11 100644
a
|
b
|
import sys
|
7 | 7 | |
8 | 8 | from django.utils import termcolors |
9 | 9 | |
| 10 | console_handle = sys.stdout |
| 11 | |
| 12 | def patch_console(): |
| 13 | try: |
| 14 | global console_handle |
| 15 | from pyreadline import console as _console |
| 16 | console_handle = _console.Console() |
| 17 | console_handle.closed = False |
| 18 | sys.stdout = console_handle |
| 19 | sys.stderr = console_handle |
| 20 | return True |
| 21 | except ImportError: |
| 22 | return False |
| 23 | |
10 | 24 | def supports_color(): |
11 | 25 | """ |
12 | 26 | Returns True if the running system's terminal supports color, and False |
13 | 27 | otherwise. |
14 | 28 | """ |
15 | 29 | unsupported_platform = (sys.platform in ('win32', 'Pocket PC')) |
| 30 | if type(sys.stdout) is file: |
| 31 | if patch_console(): |
| 32 | unsupported_platform = False |
| 33 | else: |
| 34 | unsupported_platform = False |
16 | 35 | # isatty is not always implemented, #6223. |
17 | 36 | is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() |
18 | 37 | if unsupported_platform or not is_a_tty: |