-
# 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
|
|
5 | 5 | #so that we import sage from the proper spot |
6 | 6 | try: |
7 | 7 | sys.path.remove(os.path.realpath(os.getcwd())) |
8 | | except: |
| 8 | except ValueError: |
9 | 9 | pass |
10 | 10 | |
11 | 11 | from sage.misc.cachefunc import cached_method |
-
diff --git a/sage/coding/linear_code.py b/sage/coding/linear_code.py
a
|
b
|
|
1220 | 1220 | r = C.CoveringRadius() |
1221 | 1221 | try: |
1222 | 1222 | 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") |
1225 | 1225 | |
1226 | 1226 | @rename_keyword(deprecation=11033, method="algorithm") |
1227 | 1227 | def decode(self, right, algorithm="syndrome"): |
-
diff --git a/sage/combinat/free_module.py b/sage/combinat/free_module.py
a
|
b
|
|
1261 | 1261 | g = iter(self.basis().keys()) |
1262 | 1262 | for c in range(1,4): |
1263 | 1263 | x = x + self.term(g.next(), R(c)) |
1264 | | except: |
| 1264 | except (StandardError, StopIteration): |
1265 | 1265 | pass |
1266 | 1266 | return x |
1267 | 1267 | |
-
diff --git a/sage/combinat/posets/poset_examples.py b/sage/combinat/posets/poset_examples.py
a
|
b
|
|
351 | 351 | """ |
352 | 352 | try: |
353 | 353 | n = Integer(n) |
354 | | except: |
| 354 | except TypeError: |
355 | 355 | raise TypeError("number of elements must be an integer, not {0}".format(n)) |
356 | 356 | if n < 0: |
357 | 357 | raise ValueError("number of elements must be non-negative, not {0}".format(n)) |
-
diff --git a/sage/combinat/root_system/ambient_space.py b/sage/combinat/root_system/ambient_space.py
a
|
b
|
|
170 | 170 | sage: e[0] |
171 | 171 | Traceback (most recent call last): |
172 | 172 | ... |
173 | | AssertionError: Value out of range |
| 173 | IndexError: value out of range |
174 | 174 | """ |
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") |
176 | 177 | return self.monomial(i-1) |
177 | 178 | |
178 | 179 | def coroot_lattice(self): |
-
diff --git a/sage/combinat/skew_partition.py b/sage/combinat/skew_partition.py
a
|
b
|
|
820 | 820 | try: |
821 | 821 | if len(x) != 2: |
822 | 822 | return False |
823 | | except: |
| 823 | except TypeError: |
824 | 824 | return False |
825 | 825 | |
826 | 826 | p = sage.combinat.partition.Partitions() |
-
diff --git a/sage/geometry/polyhedron/base.py b/sage/geometry/polyhedron/base.py
a
|
b
|
|
1147 | 1147 | """ |
1148 | 1148 | try: |
1149 | 1149 | return self._equations |
1150 | | except: |
| 1150 | except AttributeError: |
1151 | 1151 | self._equations = [list(eq) for eq in self.equation_generator()] |
1152 | 1152 | return self._equations |
1153 | 1153 | |
… |
… |
|
1195 | 1195 | """ |
1196 | 1196 | try: |
1197 | 1197 | return self._vertices |
1198 | | except: |
| 1198 | except AttributeError: |
1199 | 1199 | self._vertices = [list(x) for x in self.vertex_generator()] |
1200 | 1200 | return self._vertices |
1201 | 1201 | |
… |
… |
|
1270 | 1270 | """ |
1271 | 1271 | try: |
1272 | 1272 | return self._rays |
1273 | | except: |
| 1273 | except AttributeError: |
1274 | 1274 | self._rays = [list(x) for x in self.ray_generator()] |
1275 | 1275 | return self._rays |
1276 | 1276 | |
… |
… |
|
1310 | 1310 | """ |
1311 | 1311 | try: |
1312 | 1312 | return self._lines |
1313 | | except: |
| 1313 | except AttributeError: |
1314 | 1314 | self._lines = [list(x) for x in self.line_generator()] |
1315 | 1315 | return self._lines |
1316 | 1316 | |
-
diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
a
|
b
|
|
431 | 431 | """ |
432 | 432 | # inputs must be (di)graphs: |
433 | 433 | 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)) |
435 | 435 | from sage.graphs.all import Graph |
436 | 436 | g1_is_graph = isinstance(self, Graph) # otherwise, DiGraph |
437 | 437 | g2_is_graph = isinstance(other, Graph) # otherwise, DiGraph |
… |
… |
|
505 | 505 | """ |
506 | 506 | if isinstance(n, (int, long, Integer)): |
507 | 507 | 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') |
509 | 509 | if n == 1: |
510 | 510 | from copy import copy |
511 | 511 | return copy(self) |
512 | 512 | return sum([self]*(n-1), self) |
513 | 513 | 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') |
515 | 515 | |
516 | 516 | def __ne__(self, other): |
517 | 517 | """ |
… |
… |
|
1059 | 1059 | |
1060 | 1060 | """ |
1061 | 1061 | 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") |
1063 | 1063 | |
1064 | 1064 | verts = self.vertices(boundary_first=boundary_first) |
1065 | 1065 | new_indices = dict((v,i) for i,v in enumerate(verts)) |
… |
… |
|
1293 | 1293 | 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]}) |
1294 | 1294 | Traceback (most recent call last): |
1295 | 1295 | ... |
1296 | | Exception: embedding is not valid for Petersen graph |
| 1296 | ValueError: embedding is not valid for Petersen graph |
1297 | 1297 | """ |
1298 | 1298 | if self.check_embedding_validity(embedding): |
1299 | 1299 | self._embedding = embedding |
1300 | 1300 | else: |
1301 | | raise Exception('embedding is not valid for %s'%self) |
| 1301 | raise ValueError('embedding is not valid for %s'%self) |
1302 | 1302 | |
1303 | 1303 | def get_embedding(self): |
1304 | 1304 | """ |
… |
… |
|
1320 | 1320 | if self.check_embedding_validity(): |
1321 | 1321 | return self._embedding |
1322 | 1322 | 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) |
1324 | 1324 | |
1325 | 1325 | def check_embedding_validity(self, embedding=None): |
1326 | 1326 | """ |
… |
… |
|
3091 | 3091 | if self.check_embedding_validity(on_embedding): |
3092 | 3092 | return (0 == self.genus(minimal=False,set_embedding=False,on_embedding=on_embedding)) |
3093 | 3093 | 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) |
3095 | 3095 | else: |
3096 | 3096 | from sage.graphs.planarity import is_planar |
3097 | 3097 | G = self.to_undirected() |
… |
… |
|
3324 | 3324 | sage: g.set_planar_positions(test=True,set_embedding=True) |
3325 | 3325 | Traceback (most recent call last): |
3326 | 3326 | ... |
3327 | | Exception: Complete graph is not a planar graph. |
| 3327 | ValueError: Complete graph is not a planar graph |
3328 | 3328 | """ |
3329 | 3329 | from sage.graphs.schnyder import _triangulate, _normal_label, _realizer, _compute_coordinates |
3330 | 3330 | |
… |
… |
|
3336 | 3336 | embedding_copy = None |
3337 | 3337 | if set_embedding: |
3338 | 3338 | 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) |
3340 | 3340 | embedding_copy = G._embedding |
3341 | 3341 | else: |
3342 | 3342 | if on_embedding is not None: |
3343 | 3343 | if G.check_embedding_validity(on_embedding): |
3344 | 3344 | 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 ) |
3346 | 3346 | 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) |
3348 | 3348 | else: |
3349 | 3349 | if hasattr(G,'_embedding'): |
3350 | 3350 | if G.check_embedding_validity(): |
3351 | 3351 | 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) |
3353 | 3353 | embedding_copy = G._embedding |
3354 | 3354 | 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) |
3356 | 3356 | else: |
3357 | 3357 | G.is_planar(set_embedding=True) |
3358 | 3358 | |
… |
… |
|
3379 | 3379 | # self.add_edge( (v3, v1) ) |
3380 | 3380 | # other_added_edges.append( (v3, v1) ) |
3381 | 3381 | # 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) |
3383 | 3383 | |
3384 | 3384 | # Triangulate the graph |
3385 | 3385 | extra_edges = _triangulate( G, G._embedding) |
… |
… |
|
3390 | 3390 | test_faces = G.trace_faces(G._embedding) |
3391 | 3391 | for face in test_faces: |
3392 | 3392 | if len(face) != 3: |
3393 | | raise Exception('BUG: Triangulation returned face: %s'%face) |
| 3393 | raise RuntimeError('BUG: Triangulation returned face: %s'%face) |
3394 | 3394 | |
3395 | 3395 | G.is_planar(set_embedding=True) |
3396 | 3396 | faces = G.trace_faces(G._embedding) |
… |
… |
|
3636 | 3636 | if self.has_loops() or self.is_directed() or self.has_multiple_edges(): |
3637 | 3637 | raise NotImplementedError, "Can't work with embeddings of non-simple graphs" |
3638 | 3638 | 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') |
3642 | 3643 | return (2-verts+edges-faces)/2 |
3643 | 3644 | else: # compute genus on the provided dict |
3644 | 3645 | faces = len(self.trace_faces(on_embedding)) |
… |
… |
|
6772 | 6773 | sage: g.matching(algorithm="somethingdifferent") |
6773 | 6774 | Traceback (most recent call last): |
6774 | 6775 | ... |
6775 | | ValueError: Algorithm must be set to either "Edmonds" or "LP". |
| 6776 | ValueError: algorithm must be set to either "Edmonds" or "LP" |
6776 | 6777 | """ |
6777 | 6778 | from sage.rings.real_mpfr import RR |
6778 | 6779 | weight = lambda x: x if x in RR else 1 |
… |
… |
|
6825 | 6826 | if b[min(u, v)][max(u, v)] == 1] |
6826 | 6827 | |
6827 | 6828 | 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"') |
6830 | 6830 | |
6831 | 6831 | def dominating_set(self, independent=False, value_only=False, solver=None, verbose=0): |
6832 | 6832 | r""" |
… |
… |
|
10448 | 10448 | # answer is valid, especally when it is so cheap ;-) |
10449 | 10449 | |
10450 | 10450 | 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!") |
10452 | 10452 | |
10453 | 10453 | return (False, hole) |
10454 | 10454 | |
… |
… |
|
12884 | 12884 | sage: G.complement() |
12885 | 12885 | Traceback (most recent call last): |
12886 | 12886 | ... |
12887 | | TypeError: Complement not well defined for (di)graphs with multiple edges. |
| 12887 | TypeError: complement not well defined for (di)graphs with multiple edges |
12888 | 12888 | """ |
12889 | 12889 | 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') |
12891 | 12891 | from copy import copy |
12892 | 12892 | G = copy(self) |
12893 | 12893 | G.delete_edges(G.edges()) |
… |
… |
|
13055 | 13055 | [0, 1, 2, 'a', 'b'] |
13056 | 13056 | """ |
13057 | 13057 | 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') |
13059 | 13059 | |
13060 | 13060 | if not verbose_relabel: |
13061 | 13061 | r_self = {}; r_other = {}; i = 0 |
… |
… |
|
13093 | 13093 | [(0, 1), (0, 2), (0, 3), (1, 2), (2, 3)] |
13094 | 13094 | """ |
13095 | 13095 | 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') |
13097 | 13097 | if self._directed: |
13098 | 13098 | from sage.graphs.all import DiGraph |
13099 | 13099 | G = DiGraph() |
… |
… |
|
13156 | 13156 | from sage.graphs.all import Graph |
13157 | 13157 | G = Graph() |
13158 | 13158 | 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') |
13160 | 13160 | |
13161 | 13161 | G.add_vertices( [(u,v) for u in self for v in other] ) |
13162 | 13162 | for u,w in self.edge_iterator(labels=None): |
… |
… |
|
13237 | 13237 | from sage.graphs.all import Graph |
13238 | 13238 | G = Graph() |
13239 | 13239 | 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') |
13241 | 13241 | G.add_vertices( [(u,v) for u in self for v in other] ) |
13242 | 13242 | for u,w in self.edges(labels=None): |
13243 | 13243 | for v,x in other.edges(labels=None): |
… |
… |
|
13303 | 13303 | from sage.graphs.all import Graph |
13304 | 13304 | G = Graph() |
13305 | 13305 | 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') |
13307 | 13307 | G.add_vertices( [(u,v) for u in self for v in other] ) |
13308 | 13308 | for u,w in self.edges(labels=None): |
13309 | 13309 | for v in other: |
… |
… |
|
13371 | 13371 | from sage.graphs.all import Graph |
13372 | 13372 | G = Graph() |
13373 | 13373 | 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') |
13375 | 13375 | |
13376 | 13376 | G.add_vertices( [(u,v) for u in self for v in other] ) |
13377 | 13377 | for u,w in self.edges(labels=None): |
… |
… |
|
13436 | 13436 | from sage.graphs.all import Graph |
13437 | 13437 | G = Graph() |
13438 | 13438 | 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') |
13440 | 13440 | |
13441 | 13441 | G.add_vertices( [(u,v) for u in self for v in other] ) |
13442 | 13442 | for u,w in self.edges(labels=None): |
-
diff --git a/sage/graphs/graph_decompositions/fast_digraph.pyx b/sage/graphs/graph_decompositions/fast_digraph.pyx
a
|
b
|
|
28 | 28 | Constructor for ``FastDigraph``. |
29 | 29 | """ |
30 | 30 | 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))) |
32 | 32 | |
33 | 33 | self.n = D.order() |
34 | 34 | self.graph = NULL |
-
diff --git a/sage/graphs/graph_decompositions/rankwidth.pyx b/sage/graphs/graph_decompositions/rankwidth.pyx
a
|
b
|
|
162 | 162 | sage: rank_decomposition(g) |
163 | 163 | Traceback (most recent call last): |
164 | 164 | ... |
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 |
166 | 166 | |
167 | 167 | The empty graph:: |
168 | 168 | |
… |
… |
|
173 | 173 | cdef int n = G.order() |
174 | 174 | |
175 | 175 | 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") |
178 | 178 | |
179 | 179 | elif n == 0: |
180 | 180 | from sage.graphs.graph import Graph |
-
diff --git a/sage/graphs/graph_generators.py b/sage/graphs/graph_generators.py
a
|
b
|
|
6909 | 6909 | import networkx |
6910 | 6910 | try: |
6911 | 6911 | return graph.Graph(networkx.random_powerlaw_tree(n, gamma, seed=seed, tries=tries)) |
6912 | | except: |
| 6912 | except networkx.NetworkXError: |
6913 | 6913 | return False |
6914 | 6914 | |
6915 | 6915 | def RandomRegular(self, d, n, seed=None): |
-
diff --git a/sage/graphs/isgci.py b/sage/graphs/isgci.py
a
|
b
|
|
444 | 444 | sage: graph_classes.Chordal > graph_classes.Tree |
445 | 445 | Traceback (most recent call last): |
446 | 446 | ... |
447 | | Exception: Not Implemented |
| 447 | NotImplementedError |
448 | 448 | sage: graph_classes.Chordal < graph_classes.Tree |
449 | 449 | Traceback (most recent call last): |
450 | 450 | ... |
451 | | Exception: Not Implemented |
| 451 | NotImplementedError |
452 | 452 | sage: graph_classes.Chordal != graph_classes.Tree |
453 | 453 | Traceback (most recent call last): |
454 | 454 | ... |
455 | | Exception: Not Implemented |
| 455 | NotImplementedError |
456 | 456 | """ |
457 | | raise Exception("Not Implemented") |
| 457 | raise NotImplementedError |
458 | 458 | |
459 | 459 | __gt__ = __ne__ = __lt__ |
460 | 460 | |
-
diff --git a/sage/gsl/ode.pyx b/sage/gsl/ode.pyx
a
|
b
|
|
512 | 512 | sig_on() |
513 | 513 | status = gsl_odeiv_evolve_apply (e, c, s, &sys, &t, t_end, &h, y) |
514 | 514 | sig_off() |
515 | | except: |
| 515 | if (status != GSL_SUCCESS): |
| 516 | raise RuntimeError |
| 517 | except RuntimeError: |
516 | 518 | gsl_odeiv_evolve_free (e) |
517 | 519 | gsl_odeiv_control_free (c) |
518 | 520 | gsl_odeiv_step_free (s) |
519 | 521 | sage_free(y) |
520 | 522 | 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") |
531 | 524 | |
532 | 525 | for j from 0<=j<dim: |
533 | 526 | v[j]=<double> y[j] |
… |
… |
|
546 | 539 | sig_on() |
547 | 540 | status = gsl_odeiv_evolve_apply (e, c, s, &sys, &t, t_end, &h, y) |
548 | 541 | sig_off() |
549 | | except: |
| 542 | if (status != GSL_SUCCESS): |
| 543 | raise RuntimeError |
| 544 | except RuntimeError: |
550 | 545 | gsl_odeiv_evolve_free (e) |
551 | 546 | gsl_odeiv_control_free (c) |
552 | 547 | gsl_odeiv_step_free (s) |
553 | 548 | sage_free(y) |
554 | 549 | 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") |
567 | 551 | |
568 | 552 | for j from 0<=j<dim: |
569 | 553 | v[j]=<double> y[j] |
-
diff --git a/sage/homology/cubical_complex.py b/sage/homology/cubical_complex.py
a
|
b
|
|
1628 | 1628 | sage: cubical_complexes.SurfaceOfGenus(1, orientable=False) |
1629 | 1629 | Cubical complex with 21 vertices and 81 cubes |
1630 | 1630 | """ |
| 1631 | try: |
| 1632 | g = Integer(g) |
| 1633 | except TypeError: |
| 1634 | raise ValueError("genus must be a non-negative integer") |
1631 | 1635 | 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") |
1637 | 1637 | if g == 0: |
1638 | 1638 | if not orientable: |
1639 | | raise ValueError, "No non-orientable surface of genus zero." |
| 1639 | raise ValueError("no non-orientable surface of genus zero") |
1640 | 1640 | else: |
1641 | 1641 | return cubical_complexes.Sphere(2) |
1642 | 1642 | if orientable: |
-
diff --git a/sage/homology/delta_complex.py b/sage/homology/delta_complex.py
a
|
b
|
|
1578 | 1578 | sage: delta_g4.homology() == simpl_g4.homology() |
1579 | 1579 | True |
1580 | 1580 | """ |
| 1581 | try: |
| 1582 | g = Integer(g) |
| 1583 | except TypeError: |
| 1584 | raise ValueError("genus must be a non-negative integer") |
1581 | 1585 | 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") |
1587 | 1587 | if g == 0: |
1588 | 1588 | if not orientable: |
1589 | | raise ValueError, "No non-orientable surface of genus zero." |
| 1589 | raise ValueError("no non-orientable surface of genus zero") |
1590 | 1590 | else: |
1591 | 1591 | return delta_complexes.Sphere(2) |
1592 | 1592 | if orientable: |
-
diff --git a/sage/homology/simplicial_complex.py b/sage/homology/simplicial_complex.py
a
|
b
|
|
251 | 251 | lookup = dict(zip(keep, range(len(keep)))) |
252 | 252 | try: |
253 | 253 | return lookup[n] |
254 | | except: |
| 254 | except KeyError: |
255 | 255 | if left: |
256 | 256 | return "L" + str(n) |
257 | 257 | else: |
-
diff --git a/sage/interacts/library.py b/sage/interacts/library.py
a
|
b
|
|
1435 | 1435 | """ |
1436 | 1436 | from sage.all import Integer |
1437 | 1437 | if not 0 <= rule_number <= 255: |
1438 | | raise Exception('Invalid rule number') |
| 1438 | raise ValueError('Invalid rule number') |
1439 | 1439 | binary_digits = Integer(rule_number).digits(base=2) |
1440 | 1440 | rule = binary_digits + [0]*(8-len(binary_digits)) |
1441 | 1441 | |
-
diff --git a/sage/interfaces/ecm.py b/sage/interfaces/ecm.py
a
|
b
|
|
448 | 448 | child.sendline(str(n)) |
449 | 449 | try: |
450 | 450 | child.sendeof() |
451 | | except: |
| 451 | except Exception: |
452 | 452 | pass |
453 | 453 | child.expect('20\s+25\s+30\s+35\s+40\s+45\s+50\s+55\s+60\s+65') |
454 | 454 | if verbose: |
-
diff --git a/sage/interfaces/expect.py b/sage/interfaces/expect.py
a
|
b
|
|
1012 | 1012 | :: |
1013 | 1013 | |
1014 | 1014 | 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' |
1017 | 1019 | Did not get expression |
1018 | 1020 | |
1019 | 1021 | A quick consistency check on the time that the above took:: |
-
diff --git a/sage/interfaces/gap3.py b/sage/interfaces/gap3.py
a
|
b
|
|
263 | 263 | 2 |
264 | 264 | sage: try: |
265 | 265 | ... gap3._keyboard_interrupt() |
266 | | ... except: |
| 266 | ... except KeyboardInterrupt: |
267 | 267 | ... pass #optional - gap3 |
268 | 268 | Interrupting Gap3... |
269 | 269 | sage: gap3(2) #optional - gap3 |
-
diff --git a/sage/interfaces/giac.py b/sage/interfaces/giac.py
a
|
b
|
|
310 | 310 | 2 |
311 | 311 | sage: try: # optional - giac |
312 | 312 | ... giac._keyboard_interrupt() |
313 | | ... except: |
| 313 | ... except KeyboardInterrupt: |
314 | 314 | ... pass |
315 | 315 | ... |
316 | 316 | Interrupting Giac... |
-
diff --git a/sage/interfaces/interface.py b/sage/interfaces/interface.py
a
|
b
|
|
49 | 49 | def __repr__(self): |
50 | 50 | return str(self) |
51 | 51 | |
52 | | class PropTypeError(Exception): |
53 | | pass |
54 | | |
55 | 52 | |
56 | 53 | class Interface(ParentWithBase): |
57 | 54 | """ |
-
diff --git a/sage/interfaces/mwrank.py b/sage/interfaces/mwrank.py
a
|
b
|
|
209 | 209 | if self._expect is None: return |
210 | 210 | try: |
211 | 211 | os.kill(self._expect.pid, 9) |
212 | | except: pass |
| 212 | except OSError: |
| 213 | pass |
213 | 214 | self._expect = None |
214 | 215 | |
215 | 216 | |
-
diff --git a/sage/interfaces/povray.py b/sage/interfaces/povray.py
a
|
b
|
|
36 | 36 | try: |
37 | 37 | width = kwargs['W'] |
38 | 38 | height = kwargs['H'] |
39 | | except: |
| 39 | except KeyError: |
40 | 40 | return "You must specify a width and height." |
41 | 41 | |
42 | 42 | cmd = "povray -D +FP +I%s +O%s " % (pov_file, outfile) |
-
diff --git a/sage/interfaces/psage.py b/sage/interfaces/psage.py
a
|
b
|
|
43 | 43 | import os, time |
44 | 44 | |
45 | 45 | from sage0 import Sage, SageElement |
46 | | |
| 46 | from pexpect import ExceptionPexpect |
47 | 47 | |
48 | 48 | number = 0 |
49 | 49 | |
… |
… |
|
85 | 85 | try: |
86 | 86 | self.expect().expect(self._prompt) |
87 | 87 | self.expect().expect(self._prompt) |
88 | | except: |
| 88 | except ExceptionPexpect: |
89 | 89 | pass |
90 | 90 | return open(self.__tmp).read() == '__locked__' |
91 | 91 | |
… |
… |
|
149 | 149 | E.write(self.preparse(x) + '\n') |
150 | 150 | try: |
151 | 151 | E.expect(self._prompt) |
152 | | except: |
| 152 | except ExceptionPexpect: |
153 | 153 | pass |
154 | 154 | E.write(self._unlock_code + '\n\n') |
155 | 155 | |
-
diff --git a/sage/interfaces/quit.py b/sage/interfaces/quit.py
a
|
b
|
|
75 | 75 | if verbose: |
76 | 76 | print "Killing spawned job %s"%pid |
77 | 77 | os.killpg(int(pid), 9) |
78 | | except: |
| 78 | except OSError: |
79 | 79 | pass |
80 | 80 | |
81 | 81 | def is_running(pid): |
-
diff --git a/sage/libs/pari/gen.pyx b/sage/libs/pari/gen.pyx
a
|
b
|
|
10411 | 10411 | P.allocatemem(silent=True) |
10412 | 10412 | elif errno == user: |
10413 | 10413 | sig_off() |
10414 | | raise Exception, "PARI user exception" |
| 10414 | raise RuntimeError("PARI user exception") |
10415 | 10415 | else: |
10416 | 10416 | sig_off() |
10417 | 10417 | raise PariError, errno |
-
diff --git a/sage/matrix/constructor.py b/sage/matrix/constructor.py
a
|
b
|
|
1967 | 1967 | raise ValueError('size of elementary matrix must be given') |
1968 | 1968 | try: |
1969 | 1969 | n = rings.Integer(arg0) |
1970 | | except: |
| 1970 | except TypeError: |
1971 | 1971 | raise TypeError('size of elementary matrix must be an integer, not {0}'.format(arg0)) |
1972 | 1972 | if n <= 0: |
1973 | 1973 | raise ValueError('size of elementary matrix must be 1 or greater, not {0}'.format(n)) |
… |
… |
|
1995 | 1995 | # analyze parameters to determine matrix type |
1996 | 1996 | try: |
1997 | 1997 | row1 = rings.Integer(row1) |
1998 | | except: |
| 1998 | except TypeError: |
1999 | 1999 | raise TypeError('{0} of elementary matrix must be an integer, not {1}'.format(opstring, row1)) |
2000 | 2000 | if row1 < 0 or row1 >= n : |
2001 | 2001 | raise ValueError('{0} of elementary matrix must be positive and smaller than {1}, not {2}'.format(opstring, n, row1)) |
2002 | 2002 | if not row2 is None: |
2003 | 2003 | try: |
2004 | 2004 | row2 = rings.Integer(row2) |
2005 | | except: |
| 2005 | except TypeError: |
2006 | 2006 | raise TypeError('{0} of elementary matrix must be an integer, not {1}'.format(opstring, row2)) |
2007 | 2007 | if row2 < 0 or row2 >= n : |
2008 | 2008 | raise ValueError('{0} of elementary matrix must be positive and smaller than {1}, not {2}'.format(opstring, n, row2)) |
-
diff --git a/sage/matrix/matrix_double_dense.pyx b/sage/matrix/matrix_double_dense.pyx
a
|
b
|
|
745 | 745 | else: |
746 | 746 | try: |
747 | 747 | p = sage.rings.integer.Integer(p) |
748 | | except: |
| 748 | except TypeError: |
749 | 749 | raise ValueError("condition number 'p' must be +/- infinity, 'frob', 'sv' or an integer, not %s" % p) |
750 | 750 | if p not in [-2,-1,1,2]: |
751 | 751 | raise ValueError("condition number integer values of 'p' must be -2, -1, 1 or 2, not %s" % p) |
… |
… |
|
885 | 885 | else: |
886 | 886 | try: |
887 | 887 | p = sage.rings.integer.Integer(p) |
888 | | except: |
| 888 | except TypeError: |
889 | 889 | raise ValueError("matrix norm 'p' must be +/- infinity, 'frob' or an integer, not %s" % p) |
890 | 890 | if not p in [-2,-1,1,2]: |
891 | 891 | raise ValueError("matrix norm integer values of 'p' must be -2, -1, 1 or 2, not %s" % p) |
-
diff --git a/sage/modular/local_comp/type_space.py b/sage/modular/local_comp/type_space.py
a
|
b
|
|
667 | 667 | if d % p != 0: |
668 | 668 | try: |
669 | 669 | a = self._a |
670 | | except: |
| 670 | except AttributeError: |
671 | 671 | self._discover_torus_action() |
672 | 672 | a = self._a |
673 | 673 | i = 0 |
-
diff --git a/sage/modular/modsym/space.py b/sage/modular/modsym/space.py
a
|
b
|
|
1713 | 1713 | # For Gamma_0(N), n = \frac{k}{12}[\SL_2(\Z):\Gamma_0(N)] |
1714 | 1714 | try: |
1715 | 1715 | return self.__sturm_bound |
1716 | | except: |
| 1716 | except AttributeError: |
1717 | 1717 | if self.character() is not None: |
1718 | 1718 | self.__sturm_bound = Gamma0(self.level()).sturm_bound(self.weight()) |
1719 | 1719 | else: |
-
diff --git a/sage/modular/overconvergent/weightspace.py b/sage/modular/overconvergent/weightspace.py
a
|
b
|
|
68 | 68 | from sage.rings.padics.padic_generic_element import pAdicGenericElement |
69 | 69 | from sage.misc.misc import verbose |
70 | 70 | from sage.misc.cachefunc import cached_method |
| 71 | from sage.rings.padics.precision_error import PrecisionError |
71 | 72 | import weakref |
72 | 73 | |
73 | 74 | _wscache = {} |
… |
… |
|
529 | 530 | if x.parent().prime() != self._p: |
530 | 531 | raise TypeError, "x must be an integer or a %s-adic integer" % self._p |
531 | 532 | if self._p**(x.precision_absolute()) < self._chi.conductor(): |
532 | | raise Exception, "Precision too low" |
| 533 | raise PrecisionError("Precision too low") |
533 | 534 | xint = x.lift() |
534 | 535 | else: |
535 | 536 | xint = x |
-
diff --git a/sage/modular/ssmod/ssmod.py b/sage/modular/ssmod/ssmod.py
a
|
b
|
|
733 | 733 | """ |
734 | 734 | try: |
735 | 735 | return self.__dimension |
736 | | except: |
| 736 | except AttributeError: |
737 | 737 | pass |
738 | 738 | if self.__level == 1: |
739 | 739 | G = Gamma0(self.__prime) |
… |
… |
|
861 | 861 | """ |
862 | 862 | try: |
863 | 863 | return (self._ss_points_dic, self._ss_points) |
864 | | except: |
| 864 | except AttributeError: |
865 | 865 | pass |
866 | 866 | Fp2 = self.__finite_field |
867 | 867 | level = self.__level |
-
diff --git a/sage/numerical/mip.pyx b/sage/numerical/mip.pyx
a
|
b
|
|
1640 | 1640 | else: |
1641 | 1641 | self._backend.solver_parameter(name, value) |
1642 | 1642 | |
1643 | | class MIPSolverException(Exception): |
| 1643 | class MIPSolverException(RuntimeError): |
1644 | 1644 | r""" |
1645 | 1645 | Exception raised when the solver fails. |
1646 | 1646 | """ |
… |
… |
|
1659 | 1659 | |
1660 | 1660 | TESTS: |
1661 | 1661 | |
1662 | | No continuous solution:: |
| 1662 | No continuous solution:: |
1663 | 1663 | |
1664 | 1664 | sage: p=MixedIntegerLinearProgram(solver="GLPK") |
1665 | 1665 | sage: v=p.new_variable() |
… |
… |
|
1667 | 1667 | sage: p.add_constraint(v[0],min=7.6) |
1668 | 1668 | sage: p.set_objective(v[0]) |
1669 | 1669 | |
1670 | | Tests of GLPK's Exceptions:: |
| 1670 | Tests of GLPK's Exceptions:: |
1671 | 1671 | |
1672 | 1672 | sage: p.solve() |
1673 | 1673 | Traceback (most recent call last): |
1674 | 1674 | ... |
1675 | 1675 | MIPSolverException: 'GLPK : Solution is undefined' |
1676 | 1676 | |
1677 | | No integer solution:: |
| 1677 | No integer solution:: |
1678 | 1678 | |
1679 | 1679 | sage: p=MixedIntegerLinearProgram(solver="GLPK") |
1680 | 1680 | sage: v=p.new_variable() |
… |
… |
|
1683 | 1683 | sage: p.set_objective(v[0]) |
1684 | 1684 | sage: p.set_integer(v) |
1685 | 1685 | |
1686 | | Tests of GLPK's Exceptions:: |
| 1686 | Tests of GLPK's Exceptions:: |
1687 | 1687 | |
1688 | 1688 | sage: p.solve() |
1689 | 1689 | Traceback (most recent call last): |
-
diff --git a/sage/plot/plot3d/parametric_surface.pyx b/sage/plot/plot3d/parametric_surface.pyx
a
|
b
|
|
359 | 359 | try: |
360 | 360 | self.realloc((m+1)*(n+1), m*n, 4*m*n) |
361 | 361 | self.eval_grid(urange, vrange) |
362 | | except: # TODO -- this would catch control-C,etc. -- FIX THIS TO CATCH WHAT IS RAISED!!!! |
| 362 | except StandardError: |
363 | 363 | sig_off() |
364 | 364 | self.fcount = self.vcount = 0 |
365 | 365 | self.render_grid = None |
-
diff --git a/sage/quadratic_forms/quadratic_form.py b/sage/quadratic_forms/quadratic_form.py
a
|
b
|
|
1290 | 1290 | """ |
1291 | 1291 | try: |
1292 | 1292 | return self.__det |
1293 | | except: |
| 1293 | except AttributeError: |
1294 | 1294 | ## Compute the determinant |
1295 | 1295 | if self.dim() == 0: |
1296 | 1296 | new_det = self.base_ring()(1) |
… |
… |
|
1395 | 1395 | ## Try to return the cached level |
1396 | 1396 | try: |
1397 | 1397 | return self.__level |
1398 | | except: |
| 1398 | except AttributeError: |
1399 | 1399 | |
1400 | 1400 | ## Check that the base ring is a PID |
1401 | 1401 | if not is_PrincipalIdealDomain(self.base_ring()): |
… |
… |
|
1411 | 1411 | ## Check invertibility and find the inverse |
1412 | 1412 | try: |
1413 | 1413 | mat_inv = self.matrix()**(-1) |
1414 | | except: |
| 1414 | except ZeroDivisionError: |
1415 | 1415 | raise TypeError, "Oops! The quadratic form is degenerate (i.e. det = 0). =(" |
1416 | 1416 | |
1417 | 1417 | ## Compute the level |
-
diff --git a/sage/quadratic_forms/quadratic_form__automorphisms.py b/sage/quadratic_forms/quadratic_form__automorphisms.py
a
|
b
|
|
302 | 302 | ## Check for a cached value |
303 | 303 | try: |
304 | 304 | return self.__automorphisms |
305 | | except: |
| 305 | except AttributeError: |
306 | 306 | pass |
307 | 307 | |
308 | 308 | |
… |
… |
|
404 | 404 | #print "Using the cached number of automorphisms." |
405 | 405 | #print "We stored", self.__number_of_automorphisms |
406 | 406 | return self.__number_of_automorphisms |
407 | | except: |
| 407 | except AttributeError: |
408 | 408 | pass |
409 | 409 | |
410 | 410 | ## Otherwise cache and return the result |
-
diff --git a/sage/quadratic_forms/quadratic_form__genus.py b/sage/quadratic_forms/quadratic_form__genus.py
a
|
b
|
|
151 | 151 | if force_recomputation == False: |
152 | 152 | try: |
153 | 153 | return self.__CS_genus_symbol_list |
154 | | except: |
| 154 | except AttributeError: |
155 | 155 | pass |
156 | 156 | |
157 | 157 | ## Otherwise recompute and cache the list |
-
diff --git a/sage/quadratic_forms/quadratic_form__local_field_invariants.py b/sage/quadratic_forms/quadratic_form__local_field_invariants.py
a
|
b
|
|
822 | 822 | ## Try to use the cached value |
823 | 823 | try: |
824 | 824 | def_str = self.__definiteness_string |
825 | | except: |
| 825 | except AttributeError: |
826 | 826 | self.compute_definiteness() |
827 | 827 | def_str = self.__definiteness_string |
828 | 828 | |
… |
… |
|
861 | 861 | ## Try to use the cached value |
862 | 862 | try: |
863 | 863 | def_str = self.__definiteness_string |
864 | | except: |
| 864 | except AttributeError: |
865 | 865 | self.compute_definiteness() |
866 | 866 | def_str = self.__definiteness_string |
867 | 867 | |
… |
… |
|
899 | 899 | ## Try to use the cached value |
900 | 900 | try: |
901 | 901 | def_str = self.__definiteness_string |
902 | | except: |
| 902 | except AttributeError: |
903 | 903 | self.compute_definiteness() |
904 | 904 | def_str = self.__definiteness_string |
905 | 905 | |
… |
… |
|
936 | 936 | ## Try to use the cached value |
937 | 937 | try: |
938 | 938 | def_str = self.__definiteness_string |
939 | | except: |
| 939 | except AttributeError: |
940 | 940 | self.compute_definiteness() |
941 | 941 | def_str = self.__definiteness_string |
942 | 942 | |
-
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
|
|
647 | 647 | ## Try to use the cached result |
648 | 648 | try: |
649 | 649 | return self.__conway_mass |
650 | | except: |
| 650 | except AttributeError: |
651 | 651 | ## Double the form so it's integer-matrix |
652 | 652 | Q = self.scale_by_factor(2) |
653 | 653 | |
-
diff --git a/sage/quadratic_forms/quadratic_form__theta.py b/sage/quadratic_forms/quadratic_form__theta.py
a
|
b
|
|
59 | 59 | ## Sanity Check: Max is an integer or an allowed string: |
60 | 60 | try: |
61 | 61 | M = ZZ(Max) |
62 | | except: |
| 62 | except TypeError: |
63 | 63 | M = -1 |
64 | 64 | |
65 | 65 | if (Max not in ['mod_form']) and (not M >= 0): |
… |
… |
|
369 | 369 | raise ValueError, "The quadratic form must be positive definite" |
370 | 370 | try: |
371 | 371 | X = ZZ(prec-1) # maximum discriminant |
372 | | except: |
| 372 | except TypeError: |
373 | 373 | raise TypeError, "prec is not an integer" |
374 | 374 | |
375 | 375 | if X < -1: |
-
diff --git a/sage/rings/complex_double.pyx b/sage/rings/complex_double.pyx
a
|
b
|
|
579 | 579 | from integer import Integer |
580 | 580 | try: |
581 | 581 | n = Integer(n) |
582 | | except: |
| 582 | except TypeError: |
583 | 583 | raise ValueError, "n must be a positive integer" |
584 | 584 | |
585 | 585 | if n<1: |
-
diff --git a/sage/rings/complex_field.py b/sage/rings/complex_field.py
a
|
b
|
|
299 | 299 | |
300 | 300 | try: |
301 | 301 | return self(x.sage()) |
302 | | except: |
| 302 | except (AttributeError, TypeError): |
303 | 303 | pass |
304 | 304 | try: |
305 | 305 | return x._complex_mpfr_field_( self ) |
-
diff --git a/sage/rings/infinity.py b/sage/rings/infinity.py
a
|
b
|
|
778 | 778 | """ |
779 | 779 | return isinstance(x, InfinityElement) |
780 | 780 | |
781 | | class SignError(Exception): |
| 781 | class SignError(ArithmeticError): |
782 | 782 | pass |
783 | 783 | |
784 | 784 | class InfinityRing_class(_uniq, Ring): |
-
diff --git a/sage/rings/number_field/totallyreal.pyx b/sage/rings/number_field/totallyreal.pyx
a
|
b
|
|
263 | 263 | if not isinstance(n, Integer): |
264 | 264 | try: |
265 | 265 | n = Integer(n) |
266 | | except: |
| 266 | except TypeError: |
267 | 267 | raise TypeError, "cannot coerce n (= %s) to an integer"%n |
268 | 268 | if (n < 1): |
269 | 269 | raise ValueError, "n must be at least 1." |
-
diff --git a/sage/rings/number_field/totallyreal_rel.py b/sage/rings/number_field/totallyreal_rel.py
a
|
b
|
|
692 | 692 | if not isinstance(m, Integer): |
693 | 693 | try: |
694 | 694 | m = Integer(m) |
695 | | except: |
| 695 | except TypeError: |
696 | 696 | raise TypeError, "cannot coerce m (= %s) to an integer" % m |
697 | 697 | if (m < 1): |
698 | 698 | raise ValueError, "m must be at least 1." |
-
diff --git a/sage/rings/padics/precision_error.py b/sage/rings/padics/precision_error.py
a
|
b
|
|
11 | 11 | |
12 | 12 | #***************************************************************************** |
13 | 13 | # Copyright (C) 2008 David Roe <roed@math.harvard.edu> |
14 | | # William Stein <wstein@gmail.com> |
15 | 14 | # |
16 | 15 | # 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. |
18 | 18 | # http://www.gnu.org/licenses/ |
19 | 19 | #***************************************************************************** |
20 | 20 | |
21 | | class PrecisionError(Exception): |
| 21 | class PrecisionError(ArithmeticError): |
22 | 22 | pass |
23 | | |
24 | | class HaltingError(PrecisionError): |
25 | | pass |
26 | | |
27 | | class PrecisionLimitError(PrecisionError): |
28 | | pass |
-
diff --git a/sage/rings/polynomial/multi_polynomial_element.py b/sage/rings/polynomial/multi_polynomial_element.py
a
|
b
|
|
1069 | 1069 | True |
1070 | 1070 | """ |
1071 | 1071 | mons = self.element().dict().keys() |
1072 | | try: |
1073 | | len(mons[0]) # number of generators |
1074 | | except: |
1075 | | return True # zero |
1076 | 1072 | |
1077 | 1073 | found = -1 |
1078 | 1074 | for mon in mons: |
-
diff --git a/sage/rings/polynomial/pbori.pyx b/sage/rings/polynomial/pbori.pyx
a
|
b
|
|
879 | 879 | |
880 | 880 | try: |
881 | 881 | return self._coerce_c_impl(other) |
882 | | except NameError, msg: |
883 | | raise NameError, msg |
884 | 882 | except TypeError: |
885 | 883 | pass |
886 | 884 | |
… |
… |
|
4018 | 4016 | M = self.set() |
4019 | 4017 | try: # 0 |
4020 | 4018 | d = iter(M).next().degree() |
4021 | | except: |
| 4019 | except StopIteration: |
4022 | 4020 | return True |
4023 | 4021 | for m in M: |
4024 | 4022 | if m.degree() != d: |
-
diff --git a/sage/rings/qqbar.py b/sage/rings/qqbar.py
a
|
b
|
|
1865 | 1865 | single_number = False |
1866 | 1866 | try: |
1867 | 1867 | len(numbers) |
1868 | | except: |
| 1868 | except TypeError: |
1869 | 1869 | numbers = [numbers] |
1870 | 1870 | single_number = True |
1871 | 1871 | |
-
diff --git a/sage/schemes/elliptic_curves/ell_point.py b/sage/schemes/elliptic_curves/ell_point.py
a
|
b
|
|
3281 | 3281 | M = E._order |
3282 | 3282 | try: |
3283 | 3283 | plist = E._prime_factors_of_order |
3284 | | except: |
| 3284 | except AttributeError: |
3285 | 3285 | plist = M.prime_divisors() |
3286 | 3286 | E._prime_factors_of_order = plist |
3287 | 3287 | N = generic.order_from_multiple(self,M,plist,operation='+') |
… |
… |
|
3297 | 3297 | if 2*N>bounds[1]: # then we have a generator, so cache this |
3298 | 3298 | try: |
3299 | 3299 | dummy = E._order |
3300 | | except: |
| 3300 | except AttributeError: |
3301 | 3301 | E._order = N |
3302 | 3302 | try: |
3303 | 3303 | dummy = E.__abelian_group |
3304 | | except: |
| 3304 | except AttributeError: |
3305 | 3305 | E.__abelian_group = AbelianGroup([N]), (self,) |
3306 | 3306 | |
3307 | 3307 | self._order = N |
-
diff --git a/sage/schemes/elliptic_curves/monsky_washnitzer.py b/sage/schemes/elliptic_curves/monsky_washnitzer.py
a
|
b
|
|
2564 | 2564 | """ |
2565 | 2565 | try: |
2566 | 2566 | return self._helper_matrix |
2567 | | except: |
2568 | | AttributeError |
| 2567 | except AttributeError: |
| 2568 | pass |
| 2569 | |
2569 | 2570 | # The smallest y term of (1/j) d(x^i y^j) is constant for all j. |
2570 | 2571 | L = [] |
2571 | 2572 | x, y = self.base_ring().gens() |
-
diff --git a/sage/structure/category_object.pyx b/sage/structure/category_object.pyx
a
|
b
|
|
58 | 58 | if obj.is_field(): |
59 | 59 | from sage.categories.all import Fields |
60 | 60 | return Fields() |
61 | | except: |
| 61 | except (AttributeError, NotImplementedError): |
62 | 62 | pass |
63 | 63 | try: |
64 | 64 | if obj.is_ring(): |
-
diff --git a/sage/structure/coerce.pyx b/sage/structure/coerce.pyx
a
|
b
|
|
326 | 326 | |
327 | 327 | try: |
328 | 328 | raise TypeError, "just a test" |
329 | | except: |
| 329 | except TypeError: |
330 | 330 | cm._record_exception() |
331 | 331 | """ |
332 | 332 | if not self._record_exceptions: |
… |
… |
|
354 | 354 | """ |
355 | 355 | try: |
356 | 356 | raise TypeError, "just a test" |
357 | | except: |
| 357 | except TypeError: |
358 | 358 | self._record_exception() |
359 | 359 | |
360 | 360 | def exception_stack(self): |
-
diff --git a/sage/structure/factorization.py b/sage/structure/factorization.py
a
|
b
|
|
1078 | 1078 | if not isinstance(n, Integer): |
1079 | 1079 | try: |
1080 | 1080 | n = Integer(n) |
1081 | | except: |
| 1081 | except TypeError: |
1082 | 1082 | raise TypeError, "Exponent n (= %s) must be an integer." % n |
1083 | 1083 | if n == 1: |
1084 | 1084 | return self |
-
diff --git a/sage/structure/sage_object.pyx b/sage/structure/sage_object.pyx
a
|
b
|
|
144 | 144 | name = self.__custom_name |
145 | 145 | if name is not None: |
146 | 146 | return name |
147 | | except: |
| 147 | except AttributeError: |
148 | 148 | pass |
149 | 149 | try: |
150 | 150 | repr_func = self._repr_ |
-
diff --git a/sage/symbolic/assumptions.py b/sage/symbolic/assumptions.py
a
|
b
|
|
205 | 205 | return False |
206 | 206 | try: |
207 | 207 | CC(value) |
208 | | except: |
| 208 | except TypeError: |
209 | 209 | return False |
210 | 210 | if self._assumption == 'integer': |
211 | 211 | return value not in ZZ |
-
diff --git a/sage/tests/benchmark.py b/sage/tests/benchmark.py
a
|
b
|
|
136 | 136 | """ |
137 | 137 | try: |
138 | 138 | return self.repr_str |
139 | | except: |
| 139 | except AttributeError: |
140 | 140 | return 'sage.tests.benchmark.Benchmark instance' |
141 | 141 | |
142 | 142 | class Divpoly(Benchmark): |