[Python-checkins] r53606 - in python/branches/release25-maint: Lib/pty.py Lib/test/test_pty.py Misc/NEWS
georg.brandl
python-checkins at python.org
Wed Jan 31 08:48:50 CET 2007
Author: georg.brandl
Date: Wed Jan 31 08:48:49 2007
New Revision: 53606
Modified:
python/branches/release25-maint/Lib/pty.py
python/branches/release25-maint/Lib/test/test_pty.py
python/branches/release25-maint/Misc/NEWS
Log:
[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>)
Backport from trunk rev. 53146.
Modified: python/branches/release25-maint/Lib/pty.py
==============================================================================
--- python/branches/release25-maint/Lib/pty.py (original)
+++ python/branches/release25-maint/Lib/pty.py Wed Jan 31 08:48:49 2007
@@ -121,6 +121,8 @@
# 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
Modified: python/branches/release25-maint/Lib/test/test_pty.py
==============================================================================
--- python/branches/release25-maint/Lib/test/test_pty.py (original)
+++ python/branches/release25-maint/Lib/test/test_pty.py Wed Jan 31 08:48:49 2007
@@ -115,6 +115,12 @@
os._exit(4)
else:
debug("Waiting for child (%d) to finish."%pid)
+ ##line = os.read(master_fd, 80)
+ ##lines = line.replace('\r\n', '\n').split('\n')
+ ##if False and lines != ['In child, calling os.setsid()',
+ ## 'Good: OSError was raised.', '']:
+ ## raise TestFailed("Unexpected output from child: %r" % line)
+
(pid, status) = os.waitpid(pid, 0)
res = status >> 8
debug("Child (%d) exited with status %d (%d)."%(pid, res, status))
@@ -127,6 +133,15 @@
elif res != 4:
raise TestFailed, "pty.fork() failed for unknown reasons."
+ ##debug("Reading from master_fd now that the child has exited")
+ ##try:
+ ## s1 = os.read(master_fd, 1024)
+ ##except os.error:
+ ## pass
+ ##else:
+ ## raise TestFailed("Read from master_fd did not raise exception")
+
+
os.close(master_fd)
# pty.fork() passed.
Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS (original)
+++ python/branches/release25-maint/Misc/NEWS Wed Jan 31 08:48:49 2007
@@ -154,6 +154,9 @@
Library
-------
+- Patch #783050: the pty.fork() function now closes the slave fd
+ correctly.
+
- Patch #1638243: the compiler package is now able to correctly compile
a with statement; previously, executing code containing a with statement
compiled by the compiler package crashed the interpreter.
More information about the Python-checkins
mailing list