#1286: allow using fileinput.FileInput as context manager.
diff --git a/Lib/fileinput.py b/Lib/fileinput.py
index 90a600b..a25a021 100644
--- a/Lib/fileinput.py
+++ b/Lib/fileinput.py
@@ -238,6 +238,12 @@
         self.nextfile()
         self._files = ()
 
+    def __enter__(self):
+        return self
+
+    def __exit__(self, type, value, traceback):
+        self.close()
+
     def __iter__(self):
         return self