summaryrefslogtreecommitdiff
path: root/pexpect
diff options
context:
space:
mode:
authorMartin Di Paola <martinp.dipaola@gmail.com>2019-12-09 00:07:55 +0000
committerMartin Di Paola <martinp.dipaola@gmail.com>2019-12-09 00:07:55 +0000
commitf98485ae7ddd2786f2d0fc6234d15f9f1e55caea (patch)
treef9360a2ea1ab34038a2073a673e1750e3e0cf97c /pexpect
parent7b073bfa10209d6b3836d7b3e2429df89e7bf305 (diff)
downloadpexpect-f98485ae7ddd2786f2d0fc6234d15f9f1e55caea.tar.gz
Disable chaining Timeout and EOF exceptions
The code works in Python 2.x and 3.x but it should be replaced by "raise exception from other-exception" when the support for Python 2.x gets dropped.
Diffstat (limited to 'pexpect')
-rw-r--r--pexpect/expect.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/pexpect/expect.py b/pexpect/expect.py
index db376d5..34a2c93 100644
--- a/pexpect/expect.py
+++ b/pexpect/expect.py
@@ -60,7 +60,10 @@ class Expecter(object):
msg += '\nsearcher: %s' % self.searcher
if err is not None:
msg = str(err) + '\n' + msg
- raise EOF(msg)
+
+ exc = EOF(msg)
+ exc.__cause__ = None # in Python 3.x we can use "raise exc from None"
+ raise exc
def timeout(self, err=None):
spawn = self.spawn
@@ -79,7 +82,10 @@ class Expecter(object):
msg += '\nsearcher: %s' % self.searcher
if err is not None:
msg = str(err) + '\n' + msg
- raise TIMEOUT(msg)
+
+ exc = TIMEOUT(msg)
+ exc.__cause__ = None # in Python 3.x we can use "raise exc from None"
+ raise exc
def errored(self):
spawn = self.spawn