diff --git a/src/sage/interfaces/expect.py b/src/sage/interfaces/expect.py index 789da270163..67f267f9154 100644 --- a/src/sage/interfaces/expect.py +++ b/src/sage/interfaces/expect.py @@ -67,6 +67,8 @@ from sage.env import SAGE_EXTCODE, LOCAL_IDENTIFIER from sage.misc.object_multiplexer import Multiplex +from six import reraise as raise_ + BAD_SESSION = -2 # The subprocess is a shared resource. In a multi-threaded @@ -883,7 +885,7 @@ def _eval_line(self, line, allow_use_file=True, wait_for_prompt=True, restart_if except (TypeError, RuntimeError): pass return self._eval_line(line,allow_use_file=allow_use_file, wait_for_prompt=wait_for_prompt, restart_if_needed=False) - raise RuntimeError, "%s\nError evaluating %s in %s"%(msg, line, self), sys.exc_info()[2] + raise_(RuntimeError, "%s\nError evaluating %s in %s"%(msg, line, self), sys.exc_info()[2]) if len(line)>0: try: @@ -1329,7 +1331,7 @@ def __init__(self, parent, value, is_name=False, name=None): # coercion to work properly. except (RuntimeError, ValueError) as x: self._session_number = -1 - raise TypeError, x, sys.exc_info()[2] + raise_(TypeError, x, sys.exc_info()[2]) except BaseException: self._session_number = -1 raise diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py index 2e2190809f5..c9743de9501 100644 --- a/src/sage/interfaces/singular.py +++ b/src/sage/interfaces/singular.py @@ -334,6 +334,8 @@ from sage.misc.misc import get_verbose from sage.misc.superseded import deprecation +from six import reraise as raise_ + class SingularError(RuntimeError): """ Raised if Singular printed an error message @@ -1261,7 +1263,7 @@ def __init__(self, parent, type, value, is_name=False): # coercion to work properly. except SingularError as x: self._session_number = -1 - raise TypeError, x, sys.exc_info()[2] + raise_(TypeError, x, sys.exc_info()[2]) except BaseException: self._session_number = -1 raise diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py index f4577fa0007..9867d3e3144 100644 --- a/src/sage/schemes/elliptic_curves/ell_number_field.py +++ b/src/sage/schemes/elliptic_curves/ell_number_field.py @@ -109,6 +109,8 @@ import gal_reps_number_field +from six import reraise as raise_ + class EllipticCurve_number_field(EllipticCurve_field): r""" Elliptic curve over a number field. @@ -893,7 +895,7 @@ def _reduce_model(self): (a1, a2, a3, a4, a6) = [ZK(a) for a in self.a_invariants()] except TypeError: import sys - raise TypeError, "_reduce_model() requires an integral model.", sys.exc_info()[2] + raise_(TypeError, "_reduce_model() requires an integral model.", sys.exc_info()[2]) # N.B. Must define s, r, t in the right order. if ZK.absolute_degree() == 1: