Test that chmod() actually exists before calling it (it doesn't on MacOS9).
diff --git a/Lib/fileinput.py b/Lib/fileinput.py
index f6b1329..27ccc3b 100644
--- a/Lib/fileinput.py
+++ b/Lib/fileinput.py
@@ -309,7 +309,8 @@
                                      perm)
                         self._output = os.fdopen(fd, "w")
                         try:
-                            os.chmod(self._filename, perm)
+                            if hasattr(os, 'chmod'):
+                                os.chmod(self._filename, perm)
                         except OSError:
                             pass
                     self._savestdout = sys.stdout