diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-01-20 17:59:32 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-01-20 17:59:32 -0800 |
commit | fc9fdba08b5ac46ffb8cdf34753624d6050d8052 (patch) | |
tree | bfb679ecdc8ac2d7dd5f12fa4b036208137959fc /pym/portage/util/_pty.py | |
parent | ecbdd241f7e8e28f1057781c4ac2013e8d476288 (diff) | |
download | portage-fc9fdba08b5ac46ffb8cdf34753624d6050d8052.tar.gz portage-fc9fdba08b5ac46ffb8cdf34753624d6050d8052.tar.bz2 portage-fc9fdba08b5ac46ffb8cdf34753624d6050d8052.zip |
PtyEofTestCase: test unbuffered fdopen
New development: It appears that array.fromfile() is usable
with python3 as long as fdopen is called with a bufsize
argument of 0.
Diffstat (limited to 'pym/portage/util/_pty.py')
-rw-r--r-- | pym/portage/util/_pty.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/pym/portage/util/_pty.py b/pym/portage/util/_pty.py index 877430e96..7e769d204 100644 --- a/pym/portage/util/_pty.py +++ b/pym/portage/util/_pty.py @@ -28,11 +28,19 @@ def _can_test_pty_eof(): """ return platform.system() in ("Linux",) -def _test_pty_eof(): +def _test_pty_eof(fdopen_buffered=True): """ Returns True if this issues is fixed for the currently running version of python: http://bugs.python.org/issue5380 Raises an EnvironmentError from openpty() if it fails. + + NOTE: This issue is only problematic when array.fromfile() + is used, rather than os.read(). However, array.fromfile() + is preferred since it is approximatly 10% faster. + + New development: It appears that array.fromfile() is usable + with python3 as long as fdopen is called with a bufsize + argument of 0. """ use_fork = False @@ -78,7 +86,10 @@ def _test_pty_eof(): if pid is not None: os.waitpid(pid, 0) - master_file = os.fdopen(master_fd, 'rb') + if fdopen_buffered: + master_file = os.fdopen(master_fd, 'rb') + else: + master_file = os.fdopen(master_fd, 'rb', 0) eof = False data = [] iwtd = [master_file] |