chiark / gitweb /
tiocnotty: use with statement
authorColin Watson <cjwatson@chiark.greenend.org.uk>
Thu, 14 Jun 2012 02:00:33 +0000 (03:00 +0100)
committerColin Watson <cjwatson@chiark.greenend.org.uk>
Thu, 14 Jun 2012 02:00:33 +0000 (03:00 +0100)
tiocnotty

index 694c62ddfe45ef79993a305610021e9dbc3484d1..1324d3a90bb479fc6c417832cd5e91eee710f454 100755 (executable)
--- a/tiocnotty
+++ b/tiocnotty
@@ -6,9 +6,8 @@ import sys
 import termios
 
 try:
 import termios
 
 try:
-    tty = open('/dev/tty')
-    fcntl.ioctl(tty, termios.TIOCNOTTY)
-    tty.close()
+    with open('/dev/tty') as tty:
+        fcntl.ioctl(tty, termios.TIOCNOTTY)
 except IOError:
     pass
 
 except IOError:
     pass