Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #6223 -- When determining if terminal supports color, don't cal…

…l `isatty` if it doesn't exist, thanks mamadou.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7202 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 7fbebae8c8797fa7452466055b53c42d6b123811 1 parent a75e58b
@gdub gdub authored
Showing with 14 additions and 2 deletions.
  1. +14 −2 django/core/management/color.py
View
16 django/core/management/color.py
@@ -6,10 +6,22 @@
from django.utils import termcolors
+def supports_color():
+ """
+ Returns True if the running system's terminal supports color, and False
+ otherwise.
+ """
+ unsupported_platform = (sys.platform in ('win32', 'Pocket PC')
+ or sys.platform.startswith('java'))
+ # isatty is not always implemented, #6223.
+ is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
+ if unsupported_platform or not is_a_tty:
+ return False
+ return True
+
def color_style():
"""Returns a Style object with the Django color scheme."""
- if (sys.platform == 'win32' or sys.platform == 'Pocket PC'
- or sys.platform.startswith('java') or not sys.stdout.isatty()):
+ if not supports_color():
return no_style()
class dummy: pass
style = dummy()
Please sign in to comment.
Something went wrong with that request. Please try again.