[Patch #783050 from Patrick Lynch] The emulation of forkpty() is incorrect;
the master should close the slave fd.

Added a test to test_pty.py that reads from the master_fd after doing
a pty.fork(); without the fix it hangs forever instead of raising an
exception.  (<crossing fingers for the buildbots>)

2.5 backport candidate.
diff --git a/Lib/pty.py b/Lib/pty.py
index 889113c..d3eb64f 100644
--- a/Lib/pty.py
+++ b/Lib/pty.py
@@ -121,7 +121,9 @@
         # Explicitly open the tty to make it become a controlling tty.
         tmp_fd = os.open(os.ttyname(STDOUT_FILENO), os.O_RDWR)
         os.close(tmp_fd)
-
+    else:
+        os.close(slave_fd)
+        
     # Parent and child process.
     return pid, master_fd