Opened 17 years ago
Closed 17 years ago
#6223 closed (fixed)
Do not call isatty if it doesn't exist
Reported by: | Owned by: | Gary Wilson | |
---|---|---|---|
Component: | Uncategorized | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In source:django/trunk/django/core/management/color.py
if (sys.platform == 'win32' or sys.platform == 'Pocket PC' or sys.platform.startswith('java') or not sys.stdout.isatty()):
Should be replaced by:
if not (hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()):
Because according to the python docs, isatty isn't mandatory to implement.
In practice, isatty isn't implemented when importing django classes from a twistd daemon, hence a crash.
Attachments (3)
Change History (7)
comment:1 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
by , 17 years ago
comment:2 by , 17 years ago
Has patch: | set |
---|
comment:3 by , 17 years ago
Owner: | changed from | to
---|
Patch is good, I'm using it on django trunk, don't let it bitrot.
by , 17 years ago
Attachment: | 6223.2.diff added |
---|
by , 17 years ago
Attachment: | 6223.3.diff added |
---|
comment:4 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
It seems the java check can be removed because it was added due to Jython not having the
isatty
method (#5319). It appears that the Windows check was added for the same reason (#1762), but I've got a Windows XP machine here with Python 2.4 that does have anisatty
method which returnsTrue
. Does Windows support terminal colors? If not, then the win32 check needs to stay.