summaryrefslogtreecommitdiff
path: root/pexpect/spawnbase.py
diff options
context:
space:
mode:
authorJeff Quast <contact@jeffquast.com>2015-09-20 14:30:04 -0700
committerJeff Quast <contact@jeffquast.com>2015-09-20 14:46:01 -0700
commit8e5163c597348465cd0892639250656ddfe814bd (patch)
tree51d1648763d2e04fab571ed7eee0c806c5a2bb3a /pexpect/spawnbase.py
parentfaff3e605b2e1d6d30d3f9ded95473ccfbb8daf0 (diff)
downloadpexpect-git-8e5163c597348465cd0892639250656ddfe814bd.tar.gz
Clarify ducked-typed return value of expect() call
This directly addresses issue #77. Rephrase first three sentences about the meaning of after and before. Instead, immediately address the availability of the match attribute and its possible value types. Instead of 'If an error occured' phrase, use 'On general exception' to better clarify the onerror() method behavior described here before re-raising in general 'except:' clause.
Diffstat (limited to 'pexpect/spawnbase.py')
-rw-r--r--pexpect/spawnbase.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/pexpect/spawnbase.py b/pexpect/spawnbase.py
index 9fd2e18..8a6975a 100644
--- a/pexpect/spawnbase.py
+++ b/pexpect/spawnbase.py
@@ -242,12 +242,14 @@ class SpawnBase(object):
# returns 0('foobar') if all input is available at once,
# but returs 1('foo') if parts of the final 'bar' arrive late
- After a match is found the instance attributes 'before', 'after' and
- 'match' will be set. You can see all the data read before the match in
- 'before'. You can see the data that was matched in 'after'. The
- re.MatchObject used in the re match will be in 'match'. If an error
- occurred then 'before' will be set to all the data read so far and
- 'after' and 'match' will be None.
+ When a match is found for the given pattern, the class instance
+ attribute *match* becomes an re.MatchObject result. Should an EOF
+ or TIMEOUT pattern match, then the match attribute will be an instance
+ of that exception class. The pairing before and after class
+ instance attributes are views of the data preceding and following
+ the matching pattern. On general exception, class attribute
+ *before* is all data received up to the exception, while *match* and
+ *after* attributes are value None.
If timeout is -1 then timeout will be set to the self.timeout value.