##// END OF EJS Templates
safer check for isatty...
Min RK -
Show More
@@ -74,11 +74,17 b' def get_default_editor():'
74 else:
74 else:
75 return 'notepad' # same in Windows!
75 return 'notepad' # same in Windows!
76
76
77
77 # conservatively check for tty
78 if sys.stdin and sys.stdout and sys.stderr:
78 # overridden streams can result in things like:
79 _is_tty = (sys.stdin.isatty()) and (sys.stdout.isatty()) and (sys.stderr.isatty())
79 # - sys.stdin = None
80 # - no isatty method
81 for _name in ('stdin', 'stdout', 'stderr'):
82 _stream = getattr(sys, _name)
83 if not _stream or not hasattr(_stream, 'isatty') or not _stream.isatty():
84 _is_tty = False
85 break
80 else:
86 else:
81 _is_tty = False
87 _is_tty = True
82
88
83
89
84 _use_simple_prompt = ('IPY_TEST_SIMPLE_PROMPT' in os.environ) or (not _is_tty)
90 _use_simple_prompt = ('IPY_TEST_SIMPLE_PROMPT' in os.environ) or (not _is_tty)
General Comments 0
You need to be logged in to leave comments. Login now