Commits

Anonymous committed ef68c09

[1.2.X] Ensure stdin is a tty before handing it to termios, so as to prevent prolems when running under IDEs.

r15911 from trunk.

Comments (0)

Files changed (1)

django/utils/autoreload.py

 
 def ensure_echo_on():
     if termios:
-        fd = sys.stdin.fileno()
-        attr_list = termios.tcgetattr(fd)
-        if not attr_list[3] & termios.ECHO:
-            attr_list[3] |= termios.ECHO
-            termios.tcsetattr(fd, termios.TCSANOW, attr_list)
+        fd = sys.stdin
+        if fd.isatty():
+            attr_list = termios.tcgetattr(fd)
+            if not attr_list[3] & termios.ECHO:
+                attr_list[3] |= termios.ECHO
+                termios.tcsetattr(fd, termios.TCSANOW, attr_list)
 
 def reloader_thread():
     ensure_echo_on()