Ticket #11310: trac_11310.patch

File trac_11310.patch, 47.7 KB (added by vbraun, 11 years ago)

Rediffed patch

  • doc/common/builder.py

    # HG changeset patch
    # User Jeroen Demeyer <jdemeyer@cage.ugent.be>
    # Date 1304787750 -7200
    # Node ID 24015425fc5a436bf802a6dce8d46c79f4a92fd5
    # Parent  ba36aabaed96c8bdeac1a3cf553403f5e8f008b9
    Make some bare "except:" statements catch specific exceptions instead
    
    diff --git a/doc/common/builder.py b/doc/common/builder.py
    a b  
    55#so that we import sage from the proper spot
    66try:
    77    sys.path.remove(os.path.realpath(os.getcwd()))
    8 except:
     8except ValueError:
    99    pass
    1010
    1111from sage.misc.cachefunc import cached_method
  • sage/coding/linear_code.py

    diff --git a/sage/coding/linear_code.py b/sage/coding/linear_code.py
    a b  
    12201220        r = C.CoveringRadius()
    12211221        try:
    12221222            return ZZ(r)
    1223         except:
    1224             raise ValueError("Sorry, the covering radius of this code cannot be computed by Guava.")
     1223        except TypeError:
     1224            raise RuntimeError("the covering radius of this code cannot be computed by Guava")
    12251225
    12261226    @rename_keyword(deprecation=11033, method="algorithm")
    12271227    def decode(self, right, algorithm="syndrome"):
  • sage/combinat/free_module.py

    diff --git a/sage/combinat/free_module.py b/sage/combinat/free_module.py
    a b  
    12611261            g = iter(self.basis().keys())
    12621262            for c in range(1,4):
    12631263                x = x + self.term(g.next(), R(c))
    1264         except:
     1264        except (StandardError, StopIteration):
    12651265            pass
    12661266        return x
    12671267
  • sage/combinat/posets/poset_examples.py

    diff --git a/sage/combinat/posets/poset_examples.py b/sage/combinat/posets/poset_examples.py
    a b  
    351351        """
    352352        try:
    353353            n = Integer(n)
    354         except:
     354        except TypeError:
    355355            raise TypeError("number of elements must be an integer, not {0}".format(n))
    356356        if n < 0:
    357357            raise ValueError("number of elements must be non-negative, not {0}".format(n))
  • sage/combinat/root_system/ambient_space.py

    diff --git a/sage/combinat/root_system/ambient_space.py b/sage/combinat/root_system/ambient_space.py
    a b  
    170170            sage: e[0]
    171171            Traceback (most recent call last):
    172172            ...
    173             AssertionError: Value out of range
     173            IndexError: value out of range
    174174        """
    175         assert (i > 0 and i <= self.dimension()), "Value out of range"
     175        if not (i > 0 and i <= self.dimension()):
     176            raise IndexError("value out of range")
    176177        return self.monomial(i-1)
    177178
    178179    def coroot_lattice(self):
  • sage/combinat/skew_partition.py

    diff --git a/sage/combinat/skew_partition.py b/sage/combinat/skew_partition.py
    a b  
    820820        try:
    821821            if len(x) != 2:
    822822                return False
    823         except:
     823        except TypeError:
    824824            return False
    825825
    826826        p = sage.combinat.partition.Partitions()
  • sage/geometry/polyhedron/base.py

    diff --git a/sage/geometry/polyhedron/base.py b/sage/geometry/polyhedron/base.py
    a b  
    11471147        """
    11481148        try:
    11491149            return self._equations
    1150         except:
     1150        except AttributeError:
    11511151            self._equations = [list(eq) for eq in self.equation_generator()]
    11521152            return self._equations
    11531153
     
    11951195        """
    11961196        try:
    11971197            return self._vertices
    1198         except:
     1198        except AttributeError:
    11991199            self._vertices = [list(x) for x in self.vertex_generator()]
    12001200            return self._vertices
    12011201
     
    12701270        """
    12711271        try:
    12721272            return self._rays
    1273         except:
     1273        except AttributeError:
    12741274            self._rays = [list(x) for x in self.ray_generator()]
    12751275            return self._rays
    12761276
     
    13101310        """
    13111311        try:
    13121312            return self._lines
    1313         except:
     1313        except AttributeError:
    13141314            self._lines = [list(x) for x in self.line_generator()]
    13151315            return self._lines
    13161316
  • sage/graphs/generic_graph.py

    diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
    a b  
    431431        """
    432432        # inputs must be (di)graphs:
    433433        if not isinstance(other, GenericGraph):
    434             raise TypeError("Cannot compare graph to non-graph (%s)."%str(other))
     434            raise TypeError("cannot compare graph to non-graph (%s)"%str(other))
    435435        from sage.graphs.all import Graph
    436436        g1_is_graph = isinstance(self, Graph) # otherwise, DiGraph
    437437        g2_is_graph = isinstance(other, Graph) # otherwise, DiGraph
     
    505505        """
    506506        if isinstance(n, (int, long, Integer)):
    507507            if n < 1:
    508                 raise TypeError('Multiplication of a graph and a nonpositive integer is not defined.')
     508                raise TypeError('multiplication of a graph and a nonpositive integer is not defined')
    509509            if n == 1:
    510510                from copy import copy
    511511                return copy(self)
    512512            return sum([self]*(n-1), self)
    513513        else:
    514             raise TypeError('Multiplication of a graph and something other than an integer is not defined.')
     514            raise TypeError('multiplication of a graph and something other than an integer is not defined')
    515515
    516516    def __ne__(self, other):
    517517        """
     
    10591059
    10601060        """
    10611061        if self.has_multiple_edges():
    1062             raise NotImplementedError, "Don't know how to represent weights for a multigraph."
     1062            raise NotImplementedError("don't know how to represent weights for a multigraph")
    10631063
    10641064        verts = self.vertices(boundary_first=boundary_first)
    10651065        new_indices = dict((v,i) for i,v in enumerate(verts))
     
    12931293            sage: G.set_embedding({'s': [1, 5, 4], 1: [0, 2, 6], 2: [1, 3, 7], 3: [8, 2, 4], 4: [0, 9, 3], 5: [0, 8, 7], 6: [8, 1, 9], 7: [9, 2, 5], 8: [3, 5, 6], 9: [4, 6, 7]})
    12941294            Traceback (most recent call last):
    12951295            ...
    1296             Exception: embedding is not valid for Petersen graph
     1296            ValueError: embedding is not valid for Petersen graph
    12971297        """
    12981298        if self.check_embedding_validity(embedding):
    12991299            self._embedding = embedding
    13001300        else:
    1301             raise Exception('embedding is not valid for %s'%self)
     1301            raise ValueError('embedding is not valid for %s'%self)
    13021302
    13031303    def get_embedding(self):
    13041304        """
     
    13201320        if self.check_embedding_validity():
    13211321            return self._embedding
    13221322        else:
    1323             raise Exception('%s has been modified and the embedding is no longer valid.'%self)
     1323            raise ValueError('%s has been modified and the embedding is no longer valid'%self)
    13241324
    13251325    def check_embedding_validity(self, embedding=None):
    13261326        """
     
    30913091            if self.check_embedding_validity(on_embedding):
    30923092                return (0 == self.genus(minimal=False,set_embedding=False,on_embedding=on_embedding))
    30933093            else:
    3094                 raise Exception('on_embedding is not a valid embedding for %s.'%self)
     3094                raise ValueError('on_embedding is not a valid embedding for %s'%self)
    30953095        else:
    30963096            from sage.graphs.planarity import is_planar
    30973097            G = self.to_undirected()
     
    33243324            sage: g.set_planar_positions(test=True,set_embedding=True)
    33253325            Traceback (most recent call last):
    33263326            ...
    3327             Exception: Complete graph is not a planar graph.
     3327            ValueError: Complete graph is not a planar graph
    33283328        """
    33293329        from sage.graphs.schnyder import _triangulate, _normal_label, _realizer, _compute_coordinates
    33303330       
     
    33363336        embedding_copy = None
    33373337        if set_embedding:
    33383338            if not (G.is_planar(set_embedding=True)):
    3339                 raise Exception('%s is not a planar graph.'%self)
     3339                raise ValueError('%s is not a planar graph'%self)
    33403340            embedding_copy = G._embedding
    33413341        else:
    33423342            if on_embedding is not None:
    33433343                if G.check_embedding_validity(on_embedding):
    33443344                    if not (G.is_planar(on_embedding=on_embedding)):
    3345                         raise Exception( 'Provided embedding is not a planar embedding for %s.'%self )
     3345                        raise ValueError('provided embedding is not a planar embedding for %s'%self )
    33463346                else:
    3347                     raise Exception('Provided embedding is not a valid embedding for %s. Try putting set_embedding=True.'%self)
     3347                    raise ValueError('provided embedding is not a valid embedding for %s. Try putting set_embedding=True'%self)
    33483348            else:
    33493349                if hasattr(G,'_embedding'):
    33503350                    if G.check_embedding_validity():
    33513351                        if not (G.is_planar(on_embedding=G._embedding)):
    3352                             raise Exception('%s has nonplanar _embedding attribute.  Try putting set_embedding=True.'%self)
     3352                            raise ValueError('%s has nonplanar _embedding attribute.  Try putting set_embedding=True'%self)
    33533353                        embedding_copy = G._embedding
    33543354                    else:
    3355                         raise Exception('Provided embedding is not a valid embedding for %s. Try putting set_embedding=True.'%self)
     3355                        raise ValueError('provided embedding is not a valid embedding for %s. Try putting set_embedding=True'%self)
    33563356                else:
    33573357                    G.is_planar(set_embedding=True)
    33583358       
     
    33793379        #        self.add_edge( (v3, v1) )
    33803380        #        other_added_edges.append( (v3, v1) )
    33813381        #    if not self.is_planar(set_embedding=True): # get new combinatorial embedding (with added edges)
    3382         #        raise Exception('Modified graph %s is not planar.  Try specifying an external face.'%self)
     3382        #        raise ValueError('modified graph %s is not planar.  Try specifying an external face'%self)
    33833383       
    33843384        # Triangulate the graph
    33853385        extra_edges = _triangulate( G, G._embedding)
     
    33903390            test_faces = G.trace_faces(G._embedding)
    33913391            for face in test_faces:
    33923392                if len(face) != 3:
    3393                     raise Exception('BUG: Triangulation returned face: %s'%face)
     3393                    raise RuntimeError('BUG: Triangulation returned face: %s'%face)
    33943394       
    33953395        G.is_planar(set_embedding=True)
    33963396        faces = G.trace_faces(G._embedding)
     
    36363636            if self.has_loops() or self.is_directed() or self.has_multiple_edges():
    36373637                raise NotImplementedError, "Can't work with embeddings of non-simple graphs"
    36383638            if on_embedding: #i.e., if on_embedding True (returns False if on_embedding is of type dict)
    3639                 if not hasattr(self,'_embedding'):
    3640                     raise Exception("Graph must have attribute _embedding set to compute current (embedded) genus.")
    3641                 faces = len(self.trace_faces(self._embedding))
     3639                try:
     3640                    faces = len(self.trace_faces(self._embedding))
     3641                except AttributeError:
     3642                    raise AttributeError('graph must have attribute _embedding set to compute current (embedded) genus')
    36423643                return (2-verts+edges-faces)/2
    36433644            else: # compute genus on the provided dict
    36443645                faces = len(self.trace_faces(on_embedding))
     
    67726773           sage: g.matching(algorithm="somethingdifferent")
    67736774           Traceback (most recent call last):
    67746775           ...
    6775            ValueError: Algorithm must be set to either "Edmonds" or "LP".
     6776           ValueError: algorithm must be set to either "Edmonds" or "LP"
    67766777        """
    67776778        from sage.rings.real_mpfr import RR
    67786779        weight = lambda x: x if x in RR else 1
     
    68256826                        if b[min(u, v)][max(u, v)] == 1]
    68266827
    68276828        else:
    6828             raise ValueError(
    6829                 'Algorithm must be set to either "Edmonds" or "LP".')
     6829            raise ValueError('algorithm must be set to either "Edmonds" or "LP"')
    68306830
    68316831    def dominating_set(self, independent=False, value_only=False, solver=None, verbose=0):
    68326832        r"""
     
    1044810448            # answer is valid, especally when it is so cheap ;-)
    1044910449   
    1045010450            if hole.order() <= 3 or not hole.is_regular(k=2):
    10451                 raise Exception("The graph is not chordal, and something went wrong in the computation of the certificate. Please report this bug, providing the graph if possible !")
     10451                raise RuntimeError("the graph is not chordal, and something went wrong in the computation of the certificate. Please report this bug, providing the graph if possible!")
    1045210452   
    1045310453            return (False, hole)
    1045410454
     
    1288412884            sage: G.complement()
    1288512885            Traceback (most recent call last):
    1288612886            ...
    12887             TypeError: Complement not well defined for (di)graphs with multiple edges.
     12887            TypeError: complement not well defined for (di)graphs with multiple edges
    1288812888        """
    1288912889        if self.has_multiple_edges():
    12890             raise TypeError('Complement not well defined for (di)graphs with multiple edges.')
     12890            raise TypeError('complement not well defined for (di)graphs with multiple edges')
    1289112891        from copy import copy
    1289212892        G = copy(self)
    1289312893        G.delete_edges(G.edges())
     
    1305513055            [0, 1, 2, 'a', 'b']
    1305613056        """
    1305713057        if (self._directed and not other._directed) or (not self._directed and other._directed):
    13058             raise TypeError('Both arguments must be of the same class.')
     13058            raise TypeError('both arguments must be of the same class')
    1305913059
    1306013060        if not verbose_relabel:
    1306113061            r_self = {}; r_other = {}; i = 0
     
    1309313093            [(0, 1), (0, 2), (0, 3), (1, 2), (2, 3)]
    1309413094        """
    1309513095        if (self._directed and not other._directed) or (not self._directed and other._directed):
    13096             raise TypeError('Both arguments must be of the same class.')
     13096            raise TypeError('both arguments must be of the same class')
    1309713097        if self._directed:
    1309813098            from sage.graphs.all import DiGraph
    1309913099            G = DiGraph()
     
    1315613156            from sage.graphs.all import Graph
    1315713157            G = Graph()
    1315813158        else:
    13159             raise TypeError('The graphs should be both directed or both undirected.')
     13159            raise TypeError('the graphs should be both directed or both undirected')
    1316013160
    1316113161        G.add_vertices( [(u,v) for u in self for v in other] )
    1316213162        for u,w in self.edge_iterator(labels=None):
     
    1323713237            from sage.graphs.all import Graph
    1323813238            G = Graph()
    1323913239        else:
    13240             raise TypeError('The graphs should be both directed or both undirected.')
     13240            raise TypeError('the graphs should be both directed or both undirected')
    1324113241        G.add_vertices( [(u,v) for u in self for v in other] )
    1324213242        for u,w in self.edges(labels=None):
    1324313243            for v,x in other.edges(labels=None):
     
    1330313303            from sage.graphs.all import Graph
    1330413304            G = Graph()
    1330513305        else:
    13306             raise TypeError('The graphs should be both directed or both undirected.')
     13306            raise TypeError('the graphs should be both directed or both undirected')
    1330713307        G.add_vertices( [(u,v) for u in self for v in other] )
    1330813308        for u,w in self.edges(labels=None):
    1330913309            for v in other:
     
    1337113371            from sage.graphs.all import Graph
    1337213372            G = Graph()
    1337313373        else:
    13374             raise TypeError('The graphs should be both directed or both undirected.')
     13374            raise TypeError('the graphs should be both directed or both undirected')
    1337513375
    1337613376        G.add_vertices( [(u,v) for u in self for v in other] )
    1337713377        for u,w in self.edges(labels=None):
     
    1343613436            from sage.graphs.all import Graph
    1343713437            G = Graph()
    1343813438        else:
    13439             raise TypeError('The graphs should be both directed or both undirected.')
     13439            raise TypeError('the graphs should be both directed or both undirected')
    1344013440
    1344113441        G.add_vertices( [(u,v) for u in self for v in other] )
    1344213442        for u,w in self.edges(labels=None):
  • sage/graphs/graph_decompositions/fast_digraph.pyx

    diff --git a/sage/graphs/graph_decompositions/fast_digraph.pyx b/sage/graphs/graph_decompositions/fast_digraph.pyx
    a b  
    2828        Constructor for ``FastDigraph``.
    2929        """
    3030        if D.order() > 8*sizeof(int):
    31             raise Exception("Too many vertices. This structure can only encode digraphs on at most sizeof(int) vertices.")
     31            raise OverflowError("Too many vertices. This structure can only encode digraphs on at most %i vertices"%(8*sizeof(int)))
    3232
    3333        self.n = D.order()
    3434        self.graph = NULL
  • sage/graphs/graph_decompositions/rankwidth.pyx

    diff --git a/sage/graphs/graph_decompositions/rankwidth.pyx b/sage/graphs/graph_decompositions/rankwidth.pyx
    a b  
    162162        sage: rank_decomposition(g)
    163163        Traceback (most recent call last):
    164164        ...
    165         Exception: The rank decomposition cannot be computed on graphs of >= 32 vertices.
     165        RuntimeError: the rank decomposition cannot be computed on graphs of >= 32 vertices
    166166
    167167    The empty graph::
    168168
     
    173173    cdef int n = G.order()
    174174
    175175    if n >= 32:
    176         raise Exception("The rank decomposition cannot be computed "+
    177                         "on graphs of >= 32 vertices.")
     176        raise RuntimeError("the rank decomposition cannot be computed "+
     177                        "on graphs of >= 32 vertices")
    178178
    179179    elif n == 0:
    180180        from sage.graphs.graph import Graph
  • sage/graphs/graph_generators.py

    diff --git a/sage/graphs/graph_generators.py b/sage/graphs/graph_generators.py
    a b  
    69096909        import networkx
    69106910        try:
    69116911            return graph.Graph(networkx.random_powerlaw_tree(n, gamma, seed=seed, tries=tries))
    6912         except:
     6912        except networkx.NetworkXError:
    69136913            return False
    69146914
    69156915    def RandomRegular(self, d, n, seed=None):
  • sage/graphs/isgci.py

    diff --git a/sage/graphs/isgci.py b/sage/graphs/isgci.py
    a b  
    444444            sage: graph_classes.Chordal > graph_classes.Tree
    445445            Traceback (most recent call last):
    446446            ...
    447             Exception: Not Implemented
     447            NotImplementedError
    448448            sage: graph_classes.Chordal < graph_classes.Tree
    449449            Traceback (most recent call last):
    450450            ...
    451             Exception: Not Implemented
     451            NotImplementedError
    452452            sage: graph_classes.Chordal != graph_classes.Tree
    453453            Traceback (most recent call last):
    454454            ...
    455             Exception: Not Implemented
     455            NotImplementedError
    456456        """
    457         raise Exception("Not Implemented")
     457        raise NotImplementedError
    458458
    459459    __gt__ = __ne__ = __lt__
    460460
  • sage/gsl/ode.pyx

    diff --git a/sage/gsl/ode.pyx b/sage/gsl/ode.pyx
    a b  
    512512                        sig_on()
    513513                        status = gsl_odeiv_evolve_apply (e, c, s, &sys, &t, t_end, &h, y)
    514514                        sig_off()
    515                     except:
     515                        if (status != GSL_SUCCESS):
     516                            raise RuntimeError
     517                    except RuntimeError:
    516518                        gsl_odeiv_evolve_free (e)
    517519                        gsl_odeiv_control_free (c)
    518520                        gsl_odeiv_step_free (s)
    519521                        sage_free(y)
    520522                        sage_free(scale_abs_array)
    521                         raise ValueError,"error solving"
    522 
    523 
    524                     if (status != GSL_SUCCESS):
    525                         gsl_odeiv_evolve_free (e)
    526                         gsl_odeiv_control_free (c)
    527                         gsl_odeiv_step_free (s)
    528                         sage_free(y)
    529                         sage_free(scale_abs_array)
    530                         raise ValueError,"error solving"
     523                        raise ValueError("error solving")
    531524
    532525                for j  from 0<=j<dim:
    533526                    v[j]=<double> y[j]
     
    546539                        sig_on()
    547540                        status = gsl_odeiv_evolve_apply (e, c, s, &sys, &t, t_end, &h, y)
    548541                        sig_off()
    549                     except:
     542                        if (status != GSL_SUCCESS):
     543                            raise RuntimeError
     544                    except RuntimeError:
    550545                        gsl_odeiv_evolve_free (e)
    551546                        gsl_odeiv_control_free (c)
    552547                        gsl_odeiv_step_free (s)
    553548                        sage_free(y)
    554549                        sage_free(scale_abs_array)
    555                         raise ValueError,"error solving"
    556 
    557 
    558                     if (status != GSL_SUCCESS):
    559                         gsl_odeiv_evolve_free (e)
    560                         gsl_odeiv_control_free (c)
    561                         gsl_odeiv_step_free (s)
    562                         sage_free(y)
    563                         sage_free(scale_abs_array)
    564                         raise ValueError,"error solving"
    565 
    566 
     550                        raise ValueError("error solving")
    567551
    568552                for j from 0<=j<dim:
    569553                    v[j]=<double> y[j]
  • sage/homology/cubical_complex.py

    diff --git a/sage/homology/cubical_complex.py b/sage/homology/cubical_complex.py
    a b  
    16281628            sage: cubical_complexes.SurfaceOfGenus(1, orientable=False)
    16291629            Cubical complex with 21 vertices and 81 cubes
    16301630        """
     1631        try:
     1632            g = Integer(g)
     1633        except TypeError:
     1634            raise ValueError("genus must be a non-negative integer")
    16311635        if g < 0:
    1632             raise ValueError, "Genus must be a non-negative integer."
    1633         try:
    1634             Integer(g)
    1635         except:
    1636             raise ValueError, "Genus must be a non-negative integer."
     1636            raise ValueError("genus must be a non-negative integer")
    16371637        if g == 0:
    16381638            if not orientable:
    1639                 raise ValueError, "No non-orientable surface of genus zero."
     1639                raise ValueError("no non-orientable surface of genus zero")
    16401640            else:
    16411641                return cubical_complexes.Sphere(2)
    16421642        if orientable:
  • sage/homology/delta_complex.py

    diff --git a/sage/homology/delta_complex.py b/sage/homology/delta_complex.py
    a b  
    15781578            sage: delta_g4.homology() == simpl_g4.homology()
    15791579            True           
    15801580        """
     1581        try:
     1582            g = Integer(g)
     1583        except TypeError:
     1584            raise ValueError("genus must be a non-negative integer")
    15811585        if g < 0:
    1582             raise ValueError, "Genus must be a non-negative integer."
    1583         try:
    1584             Integer(g)
    1585         except:
    1586             raise ValueError, "Genus must be a non-negative integer."
     1586            raise ValueError("genus must be a non-negative integer")
    15871587        if g == 0:
    15881588            if not orientable:
    1589                 raise ValueError, "No non-orientable surface of genus zero."
     1589                raise ValueError("no non-orientable surface of genus zero")
    15901590            else:
    15911591                return delta_complexes.Sphere(2)
    15921592        if orientable:
  • sage/homology/simplicial_complex.py

    diff --git a/sage/homology/simplicial_complex.py b/sage/homology/simplicial_complex.py
    a b  
    251251    lookup = dict(zip(keep, range(len(keep))))
    252252    try:
    253253        return lookup[n]
    254     except:
     254    except KeyError:
    255255        if left:
    256256            return "L" + str(n)
    257257        else:
  • sage/interacts/library.py

    diff --git a/sage/interacts/library.py b/sage/interacts/library.py
    a b  
    14351435    """
    14361436    from sage.all import Integer
    14371437    if not 0 <= rule_number <= 255:
    1438         raise Exception('Invalid rule number')
     1438        raise ValueError('Invalid rule number')
    14391439    binary_digits = Integer(rule_number).digits(base=2)
    14401440    rule = binary_digits + [0]*(8-len(binary_digits))
    14411441
  • sage/interfaces/ecm.py

    diff --git a/sage/interfaces/ecm.py b/sage/interfaces/ecm.py
    a b  
    448448        child.sendline(str(n))
    449449        try:
    450450            child.sendeof()
    451         except:
     451        except Exception:
    452452            pass
    453453        child.expect('20\s+25\s+30\s+35\s+40\s+45\s+50\s+55\s+60\s+65')
    454454        if verbose:
  • sage/interfaces/expect.py

    diff --git a/sage/interfaces/expect.py b/sage/interfaces/expect.py
    a b  
    10121012        ::
    10131013       
    10141014            sage: t = walltime()
    1015             sage: try: r._expect_expr('25', timeout=0.5)
    1016             ... except: print 'Did not get expression'
     1015            sage: try:
     1016            ...    r._expect_expr('25', timeout=0.5)
     1017            ... except Exception:
     1018            ...    print 'Did not get expression'
    10171019            Did not get expression
    10181020       
    10191021        A quick consistency check on the time that the above took::
  • sage/interfaces/gap3.py

    diff --git a/sage/interfaces/gap3.py b/sage/interfaces/gap3.py
    a b  
    263263        2
    264264        sage: try:
    265265        ...     gap3._keyboard_interrupt()
    266         ... except:
     266        ... except KeyboardInterrupt:
    267267        ...     pass                                       #optional - gap3
    268268        Interrupting Gap3...
    269269        sage: gap3(2)                                      #optional - gap3
  • sage/interfaces/giac.py

    diff --git a/sage/interfaces/giac.py b/sage/interfaces/giac.py
    a b  
    310310            2
    311311            sage: try:                                   # optional - giac
    312312            ...     giac._keyboard_interrupt()
    313             ... except:
     313            ... except KeyboardInterrupt:
    314314            ...     pass
    315315            ...
    316316            Interrupting Giac...
  • sage/interfaces/interface.py

    diff --git a/sage/interfaces/interface.py b/sage/interfaces/interface.py
    a b  
    4949    def __repr__(self):
    5050        return str(self)
    5151
    52 class PropTypeError(Exception):
    53     pass
    54    
    5552
    5653class Interface(ParentWithBase):
    5754    """
  • sage/interfaces/mwrank.py

    diff --git a/sage/interfaces/mwrank.py b/sage/interfaces/mwrank.py
    a b  
    209209        if self._expect is None: return
    210210        try:
    211211            os.kill(self._expect.pid, 9)
    212         except: pass
     212        except OSError:
     213            pass
    213214        self._expect = None
    214215
    215216
  • sage/interfaces/povray.py

    diff --git a/sage/interfaces/povray.py b/sage/interfaces/povray.py
    a b  
    3636        try:
    3737            width = kwargs['W']
    3838            height = kwargs['H']
    39         except:
     39        except KeyError:
    4040            return "You must specify a width and height."
    4141
    4242        cmd = "povray -D +FP +I%s +O%s " % (pov_file, outfile)
  • sage/interfaces/psage.py

    diff --git a/sage/interfaces/psage.py b/sage/interfaces/psage.py
    a b  
    4343import os, time
    4444
    4545from sage0 import Sage, SageElement
    46 
     46from pexpect import ExceptionPexpect
    4747
    4848number = 0
    4949
     
    8585            try:
    8686                self.expect().expect(self._prompt)
    8787                self.expect().expect(self._prompt)
    88             except:
     88            except ExceptionPexpect:
    8989                pass
    9090        return open(self.__tmp).read() == '__locked__'
    9191
     
    149149        E.write(self.preparse(x) + '\n')
    150150        try:
    151151            E.expect(self._prompt)
    152         except:
     152        except ExceptionPexpect:
    153153            pass
    154154        E.write(self._unlock_code + '\n\n')
    155155
  • sage/interfaces/quit.py

    diff --git a/sage/interfaces/quit.py b/sage/interfaces/quit.py
    a b  
    7575            if verbose:
    7676                print "Killing spawned job %s"%pid
    7777            os.killpg(int(pid), 9)
    78         except:
     78        except OSError:
    7979            pass
    8080           
    8181def is_running(pid):
  • sage/libs/pari/gen.pyx

    diff --git a/sage/libs/pari/gen.pyx b/sage/libs/pari/gen.pyx
    a b  
    1041110411        P.allocatemem(silent=True)
    1041210412    elif errno == user:
    1041310413        sig_off()
    10414         raise Exception, "PARI user exception"
     10414        raise RuntimeError("PARI user exception")
    1041510415    else:
    1041610416        sig_off()
    1041710417        raise PariError, errno
  • sage/matrix/constructor.py

    diff --git a/sage/matrix/constructor.py b/sage/matrix/constructor.py
    a b  
    19671967        raise ValueError('size of elementary matrix must be given')
    19681968    try:
    19691969        n = rings.Integer(arg0)
    1970     except:
     1970    except TypeError:
    19711971        raise TypeError('size of elementary matrix must be an integer, not {0}'.format(arg0))
    19721972    if n <= 0:
    19731973        raise ValueError('size of elementary matrix must be 1 or greater, not {0}'.format(n))
     
    19951995    # analyze parameters to determine matrix type
    19961996    try:
    19971997        row1 = rings.Integer(row1)
    1998     except:
     1998    except TypeError:
    19991999        raise TypeError('{0} of elementary matrix must be an integer, not {1}'.format(opstring, row1))
    20002000    if row1 < 0 or row1 >= n :
    20012001        raise ValueError('{0} of elementary matrix must be positive and smaller than {1}, not {2}'.format(opstring, n, row1))
    20022002    if not row2 is None:
    20032003        try:
    20042004            row2 = rings.Integer(row2)
    2005         except:
     2005        except TypeError:
    20062006            raise TypeError('{0} of elementary matrix must be an integer, not {1}'.format(opstring, row2))
    20072007        if row2 < 0 or row2 >= n :
    20082008            raise ValueError('{0} of elementary matrix must be positive and smaller than {1}, not {2}'.format(opstring, n, row2))
  • sage/matrix/matrix_double_dense.pyx

    diff --git a/sage/matrix/matrix_double_dense.pyx b/sage/matrix/matrix_double_dense.pyx
    a b  
    745745        else:
    746746            try:
    747747                p = sage.rings.integer.Integer(p)
    748             except:
     748            except TypeError:
    749749                raise ValueError("condition number 'p' must be +/- infinity, 'frob', 'sv' or an integer, not %s" % p)
    750750            if p not in [-2,-1,1,2]:
    751751                raise ValueError("condition number integer values of 'p' must be -2, -1, 1 or 2, not %s" % p)
     
    885885        else:
    886886            try:
    887887                p = sage.rings.integer.Integer(p)
    888             except:
     888            except TypeError:
    889889                raise ValueError("matrix norm 'p' must be +/- infinity, 'frob' or an integer, not %s" % p)
    890890            if not p in [-2,-1,1,2]:
    891891                raise ValueError("matrix norm integer values of 'p' must be -2, -1, 1 or 2, not %s" % p)
  • sage/modular/local_comp/type_space.py

    diff --git a/sage/modular/local_comp/type_space.py b/sage/modular/local_comp/type_space.py
    a b  
    667667        if d % p != 0:
    668668            try:
    669669                a = self._a
    670             except:
     670            except AttributeError:
    671671                self._discover_torus_action()
    672672                a = self._a
    673673            i = 0
  • sage/modular/modsym/space.py

    diff --git a/sage/modular/modsym/space.py b/sage/modular/modsym/space.py
    a b  
    17131713        # For Gamma_0(N), n = \frac{k}{12}[\SL_2(\Z):\Gamma_0(N)]
    17141714        try:
    17151715            return self.__sturm_bound
    1716         except:
     1716        except AttributeError:
    17171717            if self.character() is not None:
    17181718                self.__sturm_bound = Gamma0(self.level()).sturm_bound(self.weight())
    17191719            else:
  • sage/modular/overconvergent/weightspace.py

    diff --git a/sage/modular/overconvergent/weightspace.py b/sage/modular/overconvergent/weightspace.py
    a b  
    6868from sage.rings.padics.padic_generic_element import pAdicGenericElement
    6969from sage.misc.misc import verbose
    7070from sage.misc.cachefunc import cached_method
     71from sage.rings.padics.precision_error import PrecisionError
    7172import weakref
    7273
    7374_wscache = {}
     
    529530            if x.parent().prime() != self._p:
    530531                raise TypeError, "x must be an integer or a %s-adic integer" % self._p
    531532            if self._p**(x.precision_absolute()) < self._chi.conductor():
    532                 raise Exception, "Precision too low"
     533                raise PrecisionError("Precision too low")
    533534            xint = x.lift()
    534535        else:
    535536            xint = x
  • sage/modular/ssmod/ssmod.py

    diff --git a/sage/modular/ssmod/ssmod.py b/sage/modular/ssmod/ssmod.py
    a b  
    733733        """
    734734        try:
    735735            return self.__dimension
    736         except:
     736        except AttributeError:
    737737            pass
    738738        if self.__level == 1:
    739739            G = Gamma0(self.__prime)
     
    861861        """
    862862        try:
    863863            return (self._ss_points_dic, self._ss_points)
    864         except:
     864        except AttributeError:
    865865            pass
    866866        Fp2 = self.__finite_field
    867867        level = self.__level
  • sage/numerical/mip.pyx

    diff --git a/sage/numerical/mip.pyx b/sage/numerical/mip.pyx
    a b  
    16401640        else:
    16411641            self._backend.solver_parameter(name, value)
    16421642
    1643 class MIPSolverException(Exception):
     1643class MIPSolverException(RuntimeError):
    16441644    r"""
    16451645    Exception raised when the solver fails.
    16461646    """
     
    16591659
    16601660        TESTS:
    16611661
    1662          No continuous solution::
     1662        No continuous solution::
    16631663
    16641664            sage: p=MixedIntegerLinearProgram(solver="GLPK")
    16651665            sage: v=p.new_variable()
     
    16671667            sage: p.add_constraint(v[0],min=7.6)
    16681668            sage: p.set_objective(v[0])
    16691669
    1670          Tests of GLPK's Exceptions::
     1670        Tests of GLPK's Exceptions::
    16711671
    16721672            sage: p.solve()
    16731673            Traceback (most recent call last):
    16741674            ...
    16751675            MIPSolverException: 'GLPK : Solution is undefined'
    16761676
    1677          No integer solution::
     1677        No integer solution::
    16781678
    16791679            sage: p=MixedIntegerLinearProgram(solver="GLPK")
    16801680            sage: v=p.new_variable()
     
    16831683            sage: p.set_objective(v[0])
    16841684            sage: p.set_integer(v)
    16851685
    1686          Tests of GLPK's Exceptions::
     1686        Tests of GLPK's Exceptions::
    16871687
    16881688            sage: p.solve()
    16891689            Traceback (most recent call last):
  • sage/plot/plot3d/parametric_surface.pyx

    diff --git a/sage/plot/plot3d/parametric_surface.pyx b/sage/plot/plot3d/parametric_surface.pyx
    a b  
    359359        try:
    360360            self.realloc((m+1)*(n+1), m*n, 4*m*n)
    361361            self.eval_grid(urange, vrange)
    362         except:       # TODO -- this would catch control-C,etc. -- FIX THIS TO CATCH WHAT IS RAISED!!!!
     362        except StandardError:
    363363            sig_off()
    364364            self.fcount = self.vcount = 0
    365365            self.render_grid = None
  • sage/quadratic_forms/quadratic_form.py

    diff --git a/sage/quadratic_forms/quadratic_form.py b/sage/quadratic_forms/quadratic_form.py
    a b  
    12901290        """
    12911291        try:
    12921292            return self.__det
    1293         except:
     1293        except AttributeError:
    12941294            ## Compute the determinant
    12951295            if self.dim() == 0:
    12961296                new_det = self.base_ring()(1)
     
    13951395        ## Try to return the cached level
    13961396        try:
    13971397            return self.__level
    1398         except:
     1398        except AttributeError:
    13991399       
    14001400            ## Check that the base ring is a PID
    14011401            if not is_PrincipalIdealDomain(self.base_ring()):
     
    14111411            ## Check invertibility and find the inverse
    14121412            try:
    14131413                mat_inv = self.matrix()**(-1)
    1414             except:
     1414            except ZeroDivisionError:
    14151415                raise TypeError, "Oops!  The quadratic form is degenerate (i.e. det = 0). =("
    14161416   
    14171417            ## Compute the level       
  • sage/quadratic_forms/quadratic_form__automorphisms.py

    diff --git a/sage/quadratic_forms/quadratic_form__automorphisms.py b/sage/quadratic_forms/quadratic_form__automorphisms.py
    a b  
    302302    ## Check for a cached value
    303303    try:
    304304        return self.__automorphisms
    305     except:
     305    except AttributeError:
    306306        pass
    307307
    308308
     
    404404            #print "Using the cached number of automorphisms."
    405405            #print "We stored", self.__number_of_automorphisms
    406406            return self.__number_of_automorphisms
    407         except:
     407        except AttributeError:
    408408            pass
    409409       
    410410    ## Otherwise cache and return the result
  • sage/quadratic_forms/quadratic_form__genus.py

    diff --git a/sage/quadratic_forms/quadratic_form__genus.py b/sage/quadratic_forms/quadratic_form__genus.py
    a b  
    151151    if force_recomputation == False:
    152152        try:
    153153            return self.__CS_genus_symbol_list
    154         except:
     154        except AttributeError:
    155155            pass
    156156
    157157    ## Otherwise recompute and cache the list
  • sage/quadratic_forms/quadratic_form__local_field_invariants.py

    diff --git a/sage/quadratic_forms/quadratic_form__local_field_invariants.py b/sage/quadratic_forms/quadratic_form__local_field_invariants.py
    a b  
    822822    ## Try to use the cached value
    823823    try:
    824824        def_str = self.__definiteness_string
    825     except:
     825    except AttributeError:
    826826        self.compute_definiteness()
    827827        def_str = self.__definiteness_string
    828828
     
    861861    ## Try to use the cached value
    862862    try:
    863863        def_str = self.__definiteness_string
    864     except:
     864    except AttributeError:
    865865        self.compute_definiteness()
    866866        def_str = self.__definiteness_string
    867867
     
    899899    ## Try to use the cached value
    900900    try:
    901901        def_str = self.__definiteness_string
    902     except:
     902    except AttributeError:
    903903        self.compute_definiteness()
    904904        def_str = self.__definiteness_string
    905905
     
    936936    ## Try to use the cached value
    937937    try:
    938938        def_str = self.__definiteness_string
    939     except:
     939    except AttributeError:
    940940        self.compute_definiteness()
    941941        def_str = self.__definiteness_string
    942942
  • sage/quadratic_forms/quadratic_form__mass__Conway_Sloane_masses.py

    diff --git a/sage/quadratic_forms/quadratic_form__mass__Conway_Sloane_masses.py b/sage/quadratic_forms/quadratic_form__mass__Conway_Sloane_masses.py
    a b  
    647647    ## Try to use the cached result
    648648    try:
    649649        return self.__conway_mass
    650     except:
     650    except AttributeError:
    651651        ## Double the form so it's integer-matrix
    652652        Q = self.scale_by_factor(2)
    653653
  • sage/quadratic_forms/quadratic_form__theta.py

    diff --git a/sage/quadratic_forms/quadratic_form__theta.py b/sage/quadratic_forms/quadratic_form__theta.py
    a b  
    5959    ## Sanity Check: Max is an integer or an allowed string:
    6060    try:
    6161        M = ZZ(Max)
    62     except:
     62    except TypeError:
    6363        M = -1
    6464
    6565    if (Max not in ['mod_form']) and (not M >= 0):
     
    369369        raise ValueError, "The quadratic form must be positive definite"
    370370    try:
    371371        X = ZZ(prec-1)    # maximum discriminant
    372     except:
     372    except TypeError:
    373373        raise TypeError, "prec is not an integer"
    374374
    375375    if X < -1:
  • sage/rings/complex_double.pyx

    diff --git a/sage/rings/complex_double.pyx b/sage/rings/complex_double.pyx
    a b  
    579579        from integer import Integer
    580580        try:
    581581           n = Integer(n)
    582         except:
     582        except TypeError:
    583583           raise ValueError, "n must be a positive integer"
    584584               
    585585        if n<1:
  • sage/rings/complex_field.py

    diff --git a/sage/rings/complex_field.py b/sage/rings/complex_field.py
    a b  
    299299
    300300            try:
    301301                return self(x.sage())
    302             except:
     302            except (AttributeError, TypeError):
    303303                pass
    304304            try:
    305305                return x._complex_mpfr_field_( self )
  • sage/rings/infinity.py

    diff --git a/sage/rings/infinity.py b/sage/rings/infinity.py
    a b  
    778778    """
    779779    return isinstance(x, InfinityElement)
    780780
    781 class SignError(Exception):
     781class SignError(ArithmeticError):
    782782    pass
    783783
    784784class InfinityRing_class(_uniq, Ring):
  • sage/rings/number_field/totallyreal.pyx

    diff --git a/sage/rings/number_field/totallyreal.pyx b/sage/rings/number_field/totallyreal.pyx
    a b  
    263263    if not isinstance(n, Integer):
    264264        try:
    265265            n = Integer(n)
    266         except:
     266        except TypeError:
    267267            raise TypeError, "cannot coerce n (= %s) to an integer"%n
    268268    if (n < 1):
    269269        raise ValueError, "n must be at least 1."
  • sage/rings/number_field/totallyreal_rel.py

    diff --git a/sage/rings/number_field/totallyreal_rel.py b/sage/rings/number_field/totallyreal_rel.py
    a b  
    692692    if not isinstance(m, Integer):
    693693        try:
    694694            m = Integer(m)
    695         except:
     695        except TypeError:
    696696            raise TypeError, "cannot coerce m (= %s) to an integer" % m
    697697    if (m < 1):
    698698        raise ValueError, "m must be at least 1."
  • sage/rings/padics/precision_error.py

    diff --git a/sage/rings/padics/precision_error.py b/sage/rings/padics/precision_error.py
    a b  
    1111
    1212#*****************************************************************************
    1313#       Copyright (C) 2008 David Roe <roed@math.harvard.edu>
    14 #                          William Stein <wstein@gmail.com>
    1514#
    1615#  Distributed under the terms of the GNU General Public License (GPL)
    17 #
     16#  as published by the Free Software Foundation; either version 2 of
     17#  the License, or (at your option) any later version.
    1818#                  http://www.gnu.org/licenses/
    1919#*****************************************************************************
    2020
    21 class PrecisionError(Exception):
     21class PrecisionError(ArithmeticError):
    2222    pass
    23 
    24 class HaltingError(PrecisionError):
    25     pass
    26 
    27 class PrecisionLimitError(PrecisionError):
    28     pass
  • sage/rings/polynomial/multi_polynomial_element.py

    diff --git a/sage/rings/polynomial/multi_polynomial_element.py b/sage/rings/polynomial/multi_polynomial_element.py
    a b  
    10691069            True
    10701070        """
    10711071        mons = self.element().dict().keys()
    1072         try:
    1073             len(mons[0]) # number of generators
    1074         except:
    1075             return True # zero
    10761072
    10771073        found = -1
    10781074        for mon in mons:
  • sage/rings/polynomial/pbori.pyx

    diff --git a/sage/rings/polynomial/pbori.pyx b/sage/rings/polynomial/pbori.pyx
    a b  
    879879
    880880        try:
    881881            return self._coerce_c_impl(other)
    882         except NameError, msg:
    883             raise NameError, msg
    884882        except TypeError:
    885883            pass
    886884
     
    40184016        M = self.set()
    40194017        try: # 0
    40204018            d = iter(M).next().degree()
    4021         except:
     4019        except StopIteration:
    40224020            return True
    40234021        for m in M:
    40244022            if m.degree() != d:
  • sage/rings/qqbar.py

    diff --git a/sage/rings/qqbar.py b/sage/rings/qqbar.py
    a b  
    18651865    single_number = False
    18661866    try:
    18671867        len(numbers)
    1868     except:
     1868    except TypeError:
    18691869        numbers = [numbers]
    18701870        single_number = True
    18711871
  • sage/schemes/elliptic_curves/ell_point.py

    diff --git a/sage/schemes/elliptic_curves/ell_point.py b/sage/schemes/elliptic_curves/ell_point.py
    a b  
    32813281            M = E._order
    32823282            try:
    32833283                plist = E._prime_factors_of_order
    3284             except:
     3284            except AttributeError:
    32853285                plist = M.prime_divisors()
    32863286                E._prime_factors_of_order = plist
    32873287            N = generic.order_from_multiple(self,M,plist,operation='+')
     
    32973297        if 2*N>bounds[1]: # then we have a generator, so cache this
    32983298            try:
    32993299                dummy = E._order
    3300             except:
     3300            except AttributeError:
    33013301                E._order = N
    33023302            try:
    33033303                dummy = E.__abelian_group
    3304             except:
     3304            except AttributeError:
    33053305                E.__abelian_group = AbelianGroup([N]), (self,)
    33063306               
    33073307        self._order = N
  • sage/schemes/elliptic_curves/monsky_washnitzer.py

    diff --git a/sage/schemes/elliptic_curves/monsky_washnitzer.py b/sage/schemes/elliptic_curves/monsky_washnitzer.py
    a b  
    25642564        """
    25652565        try:
    25662566            return self._helper_matrix
    2567         except:
    2568             AttributeError
     2567        except AttributeError:
     2568            pass
     2569
    25692570        # The smallest y term of (1/j) d(x^i y^j) is constant for all j.
    25702571        L = []
    25712572        x, y = self.base_ring().gens()
  • sage/structure/category_object.pyx

    diff --git a/sage/structure/category_object.pyx b/sage/structure/category_object.pyx
    a b  
    5858        if obj.is_field():
    5959            from sage.categories.all import Fields
    6060            return Fields()
    61     except:
     61    except (AttributeError, NotImplementedError):
    6262        pass
    6363    try:
    6464        if obj.is_ring():
  • sage/structure/coerce.pyx

    diff --git a/sage/structure/coerce.pyx b/sage/structure/coerce.pyx
    a b  
    326326           
    327327            try:
    328328                raise TypeError, "just a test"
    329             except:
     329            except TypeError:
    330330                cm._record_exception()
    331331        """
    332332        if not self._record_exceptions:
     
    354354        """
    355355        try:
    356356            raise TypeError, "just a test"
    357         except:
     357        except TypeError:
    358358            self._record_exception()
    359359       
    360360    def exception_stack(self):
  • sage/structure/factorization.py

    diff --git a/sage/structure/factorization.py b/sage/structure/factorization.py
    a b  
    10781078        if not isinstance(n, Integer):
    10791079            try:
    10801080                n = Integer(n)
    1081             except:
     1081            except TypeError:
    10821082                raise TypeError, "Exponent n (= %s) must be an integer." % n
    10831083        if n == 1:
    10841084            return self
  • sage/structure/sage_object.pyx

    diff --git a/sage/structure/sage_object.pyx b/sage/structure/sage_object.pyx
    a b  
    144144            name = self.__custom_name
    145145            if name is not None:
    146146                return name
    147         except:
     147        except AttributeError:
    148148            pass
    149149        try:
    150150            repr_func = self._repr_
  • sage/symbolic/assumptions.py

    diff --git a/sage/symbolic/assumptions.py b/sage/symbolic/assumptions.py
    a b  
    205205            return False
    206206        try:
    207207            CC(value)
    208         except:
     208        except TypeError:
    209209            return False
    210210        if self._assumption == 'integer':
    211211            return value not in ZZ
  • sage/tests/benchmark.py

    diff --git a/sage/tests/benchmark.py b/sage/tests/benchmark.py
    a b  
    136136        """
    137137        try:
    138138            return self.repr_str
    139         except:
     139        except AttributeError:
    140140            return 'sage.tests.benchmark.Benchmark instance'
    141141
    142142class Divpoly(Benchmark):