summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Quast <contact@jeffquast.com>2016-07-02 08:59:27 -0700
committerGitHub <noreply@github.com>2016-07-02 08:59:27 -0700
commitba20384b6168d3a99a66719894cf04306ac01302 (patch)
tree12e6334865054f6ffbb787f39f69de6fe3eb2451
parent248cb49a55b4e01560ad1149ec0cec61daf80c82 (diff)
parentdc07ae89c386980eadf1b4fc58978f4385d2a4af (diff)
downloadpexpect-ba20384b6168d3a99a66719894cf04306ac01302.tar.gz
Merge pull request #361 from pexpect/restore-posix4.2
Prepare 4.2 release
-rw-r--r--doc/history.rst5
-rw-r--r--pexpect/fdpexpect.py21
2 files changed, 16 insertions, 10 deletions
diff --git a/doc/history.rst b/doc/history.rst
index 1b3b4ab..f90d515 100644
--- a/doc/history.rst
+++ b/doc/history.rst
@@ -11,7 +11,10 @@ Version 4.2
:class:`~.run` family of calls containing a value for ``PATH``, its value is
used to discover the target executable from a relative path, rather than the
current process's environment ``PATH``. This mirrors the behavior of
- :func:`subprocess.Popen` in the standard library.
+ :func:`subprocess.Popen` in the standard library (:ghissue:`348`).
+
+* Regression: Re-introduce capability for :meth:`read_nonblocking` in class
+ :class:`fdspawn` as previously supported in version 3.3 (:ghissue:`359`).
Version 4.0
```````````
diff --git a/pexpect/fdpexpect.py b/pexpect/fdpexpect.py
index 40817b9..ac7443e 100644
--- a/pexpect/fdpexpect.py
+++ b/pexpect/fdpexpect.py
@@ -115,17 +115,20 @@ class fdspawn(SpawnBase):
self.write(s)
def read_nonblocking(self, size=1, timeout=-1):
- """ Read from the file descriptor and return the result as a string.
+ """
+ Read from the file descriptor and return the result as a string.
+
+ The read_nonblocking method of :class:`SpawnBase` assumes that a call
+ to os.read will not block (timeout parameter is ignored). This is not
+ the case for POSIX file-like objects such as sockets and serial ports.
- The read_nonblocking method of SpawnBase assumes that a call to
- os.read will not block. This is not the case for POSIX file like
- objects like sockets and serial ports. So we use select to implement
- the timeout on POSIX.
+ Use :func:`select.select`, timeout is implemented conditionally for
+ POSIX systems.
- :param size: Read at most size bytes
- :param timeout: Wait timeout seconds for file descriptor to be ready
- to read. If -1, use self.timeout. If 0, poll.
- :return: String containing the bytes read
+ :param int size: Read at most *size* bytes.
+ :param int timeout: Wait timeout seconds for file descriptor to be
+ ready to read. When -1 (default), use self.timeout. When 0, poll.
+ :return: String containing the bytes read
"""
if os.name == 'posix':
if timeout == -1: