Ticket #7535: trac_7535-errors-raise.patch

File trac_7535-errors-raise.patch, 6.1 KB (added by timdumol, 3 years ago)

Makes all remaining returns of exceptions into raising.

  • sage/geometry/polyhedra.py

    #7535 Errors should be raised, not returned.
    
    diff -r 7ad9673fabcf sage/geometry/polyhedra.py
    a b  
    10651065        """ 
    10661066        if self.dim() > 4: 
    10671067            print "Dimension is too large for wireframe" 
    1068             return NotImplementedError 
     1068            raise NotImplementedError 
    10691069        if self.dim() < 4: 
    10701070            if self.ieqs() == self.vertices() == []:  
    10711071                return Graphics() 
  • sage/groups/perm_gps/permgroup_named.py

    diff -r 7ad9673fabcf sage/groups/perm_gps/permgroup_named.py
    a b  
    964964        not a (smallish) "Hurwitz prime", an error message will be printed.  
    965965        """ 
    966966        if self.matrix_degree()!=2: 
    967             return ValueError, "Degree must be 2." 
     967            raise ValueError("Degree must be 2.") 
    968968        F = self.base_ring() 
    969969        q = F.order()            
    970970        from sage.misc.misc import SAGE_EXTCODE 
     
    10071007        randomness to the ordering of the characters. 
    10081008        """ 
    10091009        if self.matrix_degree()!=2: 
    1010             return ValueError, "Degree must be 2." 
     1010            raise ValueError("Degree must be 2.") 
    10111011        F = self.base_ring() 
    10121012        q = F.order()            
    10131013        from sage.misc.misc import SAGE_EXTCODE 
  • sage/interfaces/gap.py

    diff -r 7ad9673fabcf sage/interfaces/gap.py
    a b  
    574574        E = self._expect 
    575575        try: 
    576576            if len(line) > 4095: 
    577                 raise RuntimeError,"Passing commands this long to gap would hang" 
     577                raise RuntimeError("Passing commands this long to gap would hang") 
    578578            E.sendline(line) 
    579579        except OSError: 
    580             return RuntimeError, "Error evaluating %s in %s"%(line, self) 
     580            raise RuntimeError("Error evaluating %s in %s"%(line, self)) 
    581581        if wait_for_prompt == False: 
    582582            return ('','') 
    583583        if len(line)==0: 
     
    629629                    pass  # there is no need to do anything 
    630630        except pexpect.EOF: 
    631631            if not expect_eof: 
    632                 raise RuntimeError, "Unexpected EOF from %s executing %s"%(self,line) 
     632                raise RuntimeError("Unexpected EOF from %s executing %s"%(self,line)) 
    633633        except IOError: 
    634             raise RuntimeError, "IO Error from %s executing %s"%(self,line) 
     634            raise RuntimeError("IO Error from %s executing %s"%(self,line)) 
    635635        return ("".join(normal_outputs),"".join(error_outputs))         
    636636 
    637637    def _keyboard_interrupt(self): 
  • sage/modular/abvar/finite_subgroup.py

    diff -r 7ad9673fabcf sage/modular/abvar/finite_subgroup.py
    a b  
    277277        A = self.abelian_variety() 
    278278        B = other.abelian_variety() 
    279279        if not A.in_same_ambient_variety(B): 
    280             return ValueError, "self and other must be in the same ambient Jacobian" 
     280            raise ValueError("self and other must be in the same ambient Jacobian") 
    281281        K = composite_field(self.field_of_definition(), other.field_of_definition()) 
    282282        lattice = self.lattice() + other.lattice() 
    283283        if A != B: 
  • sage/modular/arithgroup/congroup_gammaH.py

    diff -r 7ad9673fabcf sage/modular/arithgroup/congroup_gammaH.py
    a b  
    937937 
    938938        from all import is_Gamma0, is_Gamma1 
    939939        if not isinstance(other, GammaH_class): 
    940             return NotImplementedError 
     940            raise NotImplementedError 
    941941 
    942942        # level of self should divide level of other 
    943943        if self.level() % other.level(): 
  • sage/rings/finite_field_element.py

    diff -r 7ad9673fabcf sage/rings/finite_field_element.py
    a b  
    381381            return self.__multiplicative_order 
    382382        except AttributeError: 
    383383            if self.is_zero(): 
    384                 return ArithmeticError, "Multiplicative order of 0 not defined." 
     384                raise ArithmeticError("Multiplicative order of 0 not defined.") 
    385385            n = self.parent().order() - 1 
    386386            order = 1 
    387387            for p, e in arith.factor(n): 
  • sage/rings/finite_field_givaro.pyx

    diff -r 7ad9673fabcf sage/rings/finite_field_givaro.pyx
    a b  
    19531953            return self.__multiplicative_order 
    19541954        else: 
    19551955            if self.is_zero(): 
    1956                 return ArithmeticError, "Multiplicative order of 0 not defined." 
     1956                raise ArithmeticError("Multiplicative order of 0 not defined.") 
    19571957            n = (parent_object(self)).order_c() - 1 
    19581958            order = 1 
    19591959            for p, e in sage.rings.arith.factor(n): 
  • sage/schemes/elliptic_curves/ell_curve_isogeny.py

    diff -r 7ad9673fabcf sage/schemes/elliptic_curves/ell_curve_isogeny.py
    a b  
    39903990    j = QQ(j) 
    39913991    if l != None: 
    39923992        if not l.is_prime(): 
    3993             return ValueError, "%s is not prime."%l 
     3993            raise ValueError("%s is not prime."%l) 
    39943994        if not isog_table.has_key((l,j)): 
    39953995            return [] 
    39963996        Ew = E.short_weierstrass_model() 
  • sage/symbolic/expression_conversions.py

    diff -r 7ad9673fabcf sage/symbolic/expression_conversions.py
    a b  
    638638        if f_sympy: 
    639639            return f_sympy(*sympy.sympify(g)) 
    640640        else: 
    641             return NotImplementedError("SymPy function '%s' doesn't exist" % f) 
     641            raise NotImplementedError("SymPy function '%s' doesn't exist" % f) 
    642642         
    643643sympy = SympyConverter() 
    644644