From f98485ae7ddd2786f2d0fc6234d15f9f1e55caea Mon Sep 17 00:00:00 2001 From: Martin Di Paola Date: Mon, 9 Dec 2019 00:07:55 +0000 Subject: 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. --- pexpect/expect.py | 10 ++++++++-- 1 file 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 -- cgit v1.2.1