-
# HG changeset patch
# User Jeroen Demeyer <jdemeyer@cage.ugent.be>
# Date 1340296066 -7200
# Node ID 70fbebedf416c0d2831f2a5eee555a939054892c
# Parent 343ee9f47e426764c063f5ec27c4e3764e95c457
Replace "raise Exception" by "raise RuntimeError", replace "except:" by "except StandardError:"
diff --git a/doc/common/builder.py b/doc/common/builder.py
a
|
b
|
|
391 | 391 | file = open(self.cache_filename(), 'rb') |
392 | 392 | try: |
393 | 393 | cache = cPickle.load(file) |
394 | | except: |
| 394 | except StandardError: |
395 | 395 | logger.debug("Cache file '%s' is corrupted; ignoring it..."% filename) |
396 | 396 | cache = {} |
397 | 397 | else: |
-
diff --git a/sage/algebras/group_algebra.py b/sage/algebras/group_algebra.py
a
|
b
|
|
222 | 222 | (self.base_ring().random_element(), self.group().random_element()), |
223 | 223 | (self.base_ring().random_element(), self.group().random_element()), |
224 | 224 | ])) |
225 | | except: # base ring or group might not implement .random_element() |
| 225 | except StandardError: # base ring or group might not implement .random_element() |
226 | 226 | return self(self._formal_sum_module([ (self.base_ring().an_element(), self.group().an_element()) ])) |
227 | 227 | |
228 | 228 | def __call__(self, x, check=True): |
-
diff --git a/sage/algebras/iwahori_hecke_algebra.py b/sage/algebras/iwahori_hecke_algebra.py
a
|
b
|
|
354 | 354 | # avoids accidental coercion into a field of fractions. |
355 | 355 | i1 = self._q1.__pow__(-1) |
356 | 356 | i2 = self._q2.__pow__(-1) |
357 | | except: |
| 357 | except StandardError: |
358 | 358 | raise ValueError("%s and %s must be invertible."%(self._q1, self._q2)) |
359 | 359 | return (-i1*i2)*self.algebra_generator(i)+(i1+i2) |
360 | 360 | |
-
diff --git a/sage/all.py b/sage/all.py
a
|
b
|
|
176 | 176 | #try: |
177 | 177 | # import resource # unix only... |
178 | 178 | # resource.setrlimit(resource.RLIMIT_AS, (-1,-1)) |
179 | | #except: |
| 179 | #except StandardError: |
180 | 180 | # pass |
181 | 181 | |
182 | 182 | # very useful 2-letter shortcuts |
-
diff --git a/sage/categories/examples/finite_enumerated_sets.py b/sage/categories/examples/finite_enumerated_sets.py
a
|
b
|
|
191 | 191 | """ |
192 | 192 | try: |
193 | 193 | return self.lift(x) in self.ambient() |
194 | | except: |
| 194 | except StandardError: |
195 | 195 | return False |
-
diff --git a/sage/categories/facade_sets.py b/sage/categories/facade_sets.py
a
|
b
|
|
197 | 197 | for parent in self.facade_for(): |
198 | 198 | try: |
199 | 199 | return parent(element) |
200 | | except: |
| 200 | except StandardError: |
201 | 201 | pass |
202 | 202 | raise ValueError, "Can't coerce `%s` in any parent `%s` is a facade for"%(element, self) |
203 | 203 | |
-
diff --git a/sage/categories/fields.py b/sage/categories/fields.py
a
|
b
|
|
91 | 91 | """ |
92 | 92 | try: |
93 | 93 | return self._contains_helper(x) or is_Field(x) |
94 | | except: |
| 94 | except StandardError: |
95 | 95 | return False |
96 | 96 | |
97 | 97 | @lazy_class_attribute |
-
diff --git a/sage/categories/functor.pyx b/sage/categories/functor.pyx
a
|
b
|
|
253 | 253 | """ |
254 | 254 | try: |
255 | 255 | return self(f.domain()).hom(f, self(f.codomain())) |
256 | | except: |
| 256 | except StandardError: |
257 | 257 | raise TypeError, 'unable to transform %s into a morphism in %s'%(f,self.codomain()) |
258 | 258 | |
259 | 259 | def _coerce_into_domain(self, x): |
-
diff --git a/sage/categories/morphism.pyx b/sage/categories/morphism.pyx
a
|
b
|
|
261 | 261 | """ |
262 | 262 | try: |
263 | 263 | return self._function(x, *args, **kwds) |
264 | | except: |
| 264 | except StandardError: |
265 | 265 | raise TypeError, "Underlying map %s does not accept additional arguments"%type(self._function) |
266 | 266 | |
267 | 267 | cdef _extra_slots(self, _slots): |
-
diff --git a/sage/coding/binary_code.pyx b/sage/coding/binary_code.pyx
a
|
b
|
|
1527 | 1527 | self.nrows = <int> arg1 |
1528 | 1528 | self.nwords = 1 << self.nrows |
1529 | 1529 | self.ncols = <int> arg2 |
1530 | | except: |
| 1530 | except StandardError: |
1531 | 1531 | other = arg1 |
1532 | 1532 | self.nrows = other.nrows |
1533 | 1533 | self.nwords = other.nwords |
-
diff --git a/sage/combinat/crystals/tensor_product.py b/sage/combinat/crystals/tensor_product.py
a
|
b
|
|
967 | 967 | spin_shapes = tuple( tuple(shape) for shape in shapes ) |
968 | 968 | try: |
969 | 969 | shapes = tuple( tuple(trunc(i) for i in shape) for shape in spin_shapes ) |
970 | | except: |
| 970 | except StandardError: |
971 | 971 | raise ValueError("shapes should all be partitions or half-integer partitions") |
972 | 972 | if spin_shapes == shapes: |
973 | 973 | return super(CrystalOfTableaux, cls).__classcall__(cls, cartan_type, shapes) |
-
diff --git a/sage/combinat/designs/incidence_structures.py b/sage/combinat/designs/incidence_structures.py
a
|
b
|
|
134 | 134 | y = block[:] |
135 | 135 | y.sort() |
136 | 136 | bs.append(y) |
137 | | except: |
| 137 | except StandardError: |
138 | 138 | bs.append(block) |
139 | 139 | bs.sort(cmp) |
140 | 140 | self.v = v |
-
diff --git a/sage/combinat/integer_vectors_mod_permgroup.py b/sage/combinat/integer_vectors_mod_permgroup.py
a
|
b
|
|
455 | 455 | """ |
456 | 456 | try: |
457 | 457 | return self.is_canonical(self.element_class(self, list(v), check=False), check=False) |
458 | | except: |
| 458 | except StandardError: |
459 | 459 | return False |
460 | 460 | |
461 | 461 | def __call__(self, v, check=True): |
… |
… |
|
474 | 474 | return v |
475 | 475 | else: |
476 | 476 | raise ValueError, '%s shoud be a Python list of integer'%(v) |
477 | | except: |
| 477 | except StandardError: |
478 | 478 | return self.element_class(self, list(v), check=check) |
479 | 479 | |
480 | 480 | def orbit(self, v): |
… |
… |
|
505 | 505 | if v.parent() is self: |
506 | 506 | return orbit(self._sgs, v) |
507 | 507 | raise TypeError |
508 | | except: |
| 508 | except StandardError: |
509 | 509 | return orbit(self._sgs, self.element_class(self, v, check=False)) |
510 | 510 | |
511 | 511 | def subset(self, sum=None, max_part=None): |
… |
… |
|
698 | 698 | """ |
699 | 699 | try: |
700 | 700 | return (self(v)).parent() is self |
701 | | except: |
| 701 | except StandardError: |
702 | 702 | return False |
703 | 703 | |
704 | 704 | def __call__(self, v, check=True): |
… |
… |
|
720 | 720 | return v |
721 | 721 | else: |
722 | 722 | raise ValueError, '%s shoud be a Python list of integer'%(v) |
723 | | except: |
| 723 | except StandardError: |
724 | 724 | return self.element_class(self, list(v), check=check) |
725 | 725 | |
726 | 726 | def __iter__(self): |
… |
… |
|
936 | 936 | try: |
937 | 937 | if v.parent() is self: |
938 | 938 | return orbit(self._sgs, v) |
939 | | except: |
| 939 | except StandardError: |
940 | 940 | return orbit(self._sgs, self.element_class(self, v, check=False)) |
941 | 941 | |
942 | 942 | class Element(ClonableIntArray): |
-
diff --git a/sage/combinat/kazhdan_lusztig.py b/sage/combinat/kazhdan_lusztig.py
a
|
b
|
|
129 | 129 | tr = floor((y.length()-x.length()+1)/2) |
130 | 130 | try: |
131 | 131 | ret = p.truncate(tr) |
132 | | except: |
| 132 | except StandardError: |
133 | 133 | ret = laurent_polynomial_truncate(p, tr) |
134 | 134 | if self._trace: |
135 | 135 | print " P(%s,%s)=%s"%(x, y, ret) |
-
diff --git a/sage/combinat/permutation_cython.pyx b/sage/combinat/permutation_cython.pyx
a
|
b
|
|
161 | 161 | |
162 | 162 | try: |
163 | 163 | T = PyList_New(N-1) |
164 | | except: |
| 164 | except StandardError: |
165 | 165 | sage_free(c) |
166 | 166 | raise MemoryError, "Failed to allocate memory in permutation_iterator_transposition_list" |
167 | 167 | |
-
diff --git a/sage/combinat/posets/poset_examples.py b/sage/combinat/posets/poset_examples.py
a
|
b
|
|
357 | 357 | raise ValueError("number of elements must be non-negative, not {0}".format(n)) |
358 | 358 | try: |
359 | 359 | p = float(p) |
360 | | except: |
| 360 | except StandardError: |
361 | 361 | raise TypeError("probability must be a real number, not {0}".format(p)) |
362 | 362 | if p < 0 or p> 1: |
363 | 363 | raise ValueError("probability must be between 0 and 1, not {0}".format(p)) |
-
diff --git a/sage/combinat/posets/posets.py b/sage/combinat/posets/posets.py
a
|
b
|
|
428 | 428 | # Compute a linear extension of the poset (a topological sort). |
429 | 429 | try: |
430 | 430 | lin_ext = D.topological_sort() |
431 | | except: |
| 431 | except StandardError: |
432 | 432 | raise ValueError, "Hasse diagram contains cycles." |
433 | 433 | |
434 | 434 | # Relabel using the linear_extension. |
-
diff --git a/sage/combinat/root_system/root_system.py b/sage/combinat/root_system/root_system.py
a
|
b
|
|
263 | 263 | # still fails for CartanType G2xA1 |
264 | 264 | try: |
265 | 265 | self.dual = RootSystem(self._cartan_type.dual(), as_dual_of=self); |
266 | | except: |
| 266 | except StandardError: |
267 | 267 | pass |
268 | 268 | else: |
269 | 269 | self.dual_side = True |
-
diff --git a/sage/combinat/root_system/weyl_group.py b/sage/combinat/root_system/weyl_group.py
a
|
b
|
|
286 | 286 | r = self.__call__(Matrix([self.domain().reflection(alp)(x).to_vector() for x in self.domain().basis()])) |
287 | 287 | ret[r] = alp |
288 | 288 | return Family(ret) |
289 | | except: |
| 289 | except StandardError: |
290 | 290 | raise NotImplementedError, "reflections are only implemented for finite Weyl groups" |
291 | 291 | |
292 | 292 | def gens(self): |
-
diff --git a/sage/combinat/sf/classical.py b/sage/combinat/sf/classical.py
a
|
b
|
|
304 | 304 | else: |
305 | 305 | try: |
306 | 306 | return eclass(self, {sage.combinat.partition.Partition_class([]):R(x)}) |
307 | | except: |
| 307 | except StandardError: |
308 | 308 | raise TypeError, "do not know how to make x (= %s) an element of self"%(x) |
309 | 309 | |
310 | 310 | |
-
diff --git a/sage/combinat/sf/sfa.py b/sage/combinat/sf/sfa.py
a
|
b
|
|
381 | 381 | raise TypeError, "Argument R must be a commutative ring." |
382 | 382 | try: |
383 | 383 | z = R(Integer(1)) |
384 | | except: |
| 384 | except StandardError: |
385 | 385 | raise ValueError, "R must have a unit element" |
386 | 386 | |
387 | 387 | if basis_name is not None: |
-
diff --git a/sage/combinat/sloane_functions.py b/sage/combinat/sloane_functions.py
a
|
b
|
|
366 | 366 | return self._small[n-1] |
367 | 367 | try: |
368 | 368 | return Integer(gap.gap.eval('NumberSmallGroups(%s)'%n)) |
369 | | except: # help, don't know what to do here? Jaap |
| 369 | except StandardError: # help, don't know what to do here? Jaap |
370 | 370 | print "Install database_gap first. See optional packages" |
371 | 371 | |
372 | 372 | |
-
diff --git a/sage/combinat/species/series.py b/sage/combinat/species/series.py
a
|
b
|
|
54 | 54 | raise TypeError, "Argument R must be a ring." |
55 | 55 | try: |
56 | 56 | z = R(Integer(1)) |
57 | | except: |
| 57 | except StandardError: |
58 | 58 | raise ValueError, "R must have a unit element" |
59 | 59 | |
60 | 60 | #Take care of the names |
-
diff --git a/sage/combinat/species/stream.py b/sage/combinat/species/stream.py
a
|
b
|
|
44 | 44 | while True: |
45 | 45 | try: |
46 | 46 | yield func(list) |
47 | | except: |
| 47 | except StandardError: |
48 | 48 | break |
49 | 49 | |
50 | 50 | def Stream(x=None, const=None): |
-
diff --git a/sage/combinat/tableau.py b/sage/combinat/tableau.py
a
|
b
|
|
1262 | 1262 | if not isinstance(tab2, Tableau_class): |
1263 | 1263 | try: |
1264 | 1264 | tab2 = Tableau_class(tab2) |
1265 | | except: |
| 1265 | except StandardError: |
1266 | 1266 | raise TypeError, "tab2 must be a standard tableau" |
1267 | 1267 | |
1268 | 1268 | if tab2.size() != n: |
-
diff --git a/sage/combinat/words/alphabet.py b/sage/combinat/words/alphabet.py
a
|
b
|
|
65 | 65 | else: |
66 | 66 | try: |
67 | 67 | return OrderedAlphabet_Finite(data) |
68 | | except: |
| 68 | except StandardError: |
69 | 69 | raise TypeError, "cannot construct an alphabet from given data" |
70 | 70 | |
71 | 71 | OrderedAlphabet = Alphabet |
… |
… |
|
191 | 191 | """ |
192 | 192 | try: |
193 | 193 | return a in self._alphabet |
194 | | except: |
| 194 | except StandardError: |
195 | 195 | return False |
196 | 196 | |
197 | 197 | def __le__(self, other): |
-
diff --git a/sage/combinat/words/finite_word.py b/sage/combinat/words/finite_word.py
a
|
b
|
|
249 | 249 | try: |
250 | 250 | other = self.parent()(other) |
251 | 251 | other.parent()._check(other, length=None) |
252 | | except: |
| 252 | except StandardError: |
253 | 253 | try: |
254 | 254 | self = other.parent()(self) |
255 | 255 | self.parent()._check(self, length=None) |
256 | | except: |
| 256 | except StandardError: |
257 | 257 | raise TypeError, "no coercion rule between %r and %r" % (self.parent(), other.parent()) |
258 | 258 | return self, other |
259 | 259 | |
-
diff --git a/sage/combinat/words/morphism.py b/sage/combinat/words/morphism.py
a
|
b
|
|
398 | 398 | for key,val in data.iteritems(): |
399 | 399 | try: |
400 | 400 | it = iter(val) |
401 | | except: |
| 401 | except StandardError: |
402 | 402 | it = [val] |
403 | 403 | codom_alphabet.update(it) |
404 | 404 | return Words(sorted(codom_alphabet)) |
-
diff --git a/sage/crypto/classical.py b/sage/crypto/classical.py
a
|
b
|
|
346 | 346 | return AffineCipher(self, key=(a,b)) |
347 | 347 | else: |
348 | 348 | raise ValueError |
349 | | except: |
| 349 | except StandardError: |
350 | 350 | raise ValueError("(a, b) = (%s, %s) is outside the range of acceptable values for a key of this affine cryptosystem." % (a, b)) |
351 | 351 | |
352 | 352 | def _repr_(self): |
… |
… |
|
1150 | 1150 | return D(strip_encoding(S)) |
1151 | 1151 | try: |
1152 | 1152 | return D.encoding(S) |
1153 | | except: |
| 1153 | except StandardError: |
1154 | 1154 | raise TypeError("Argument S = %s does not encode in the cipher domain" % S) |
1155 | 1155 | |
1156 | 1156 | def inverse_key(self, a, b): |
… |
… |
|
1242 | 1242 | aInv = inverse_mod(a, n) |
1243 | 1243 | bInv = Mod(-b * aInv, n).lift() |
1244 | 1244 | return (aInv, bInv) |
1245 | | except: |
| 1245 | except StandardError: |
1246 | 1246 | raise ValueError("(a, b) = (%s, %s) is outside the range of acceptable values for a key of this affine cipher." % (a, b)) |
1247 | 1247 | |
1248 | 1248 | def random_key(self): |
… |
… |
|
1393 | 1393 | if isinstance(A, list): |
1394 | 1394 | try: |
1395 | 1395 | A = M(A) |
1396 | | except: |
| 1396 | except StandardError: |
1397 | 1397 | raise TypeError("A (= %s) must specify a square matrix of degree %s." % (A, m)) |
1398 | 1398 | return HillCipher(self, A) |
1399 | 1399 | |
… |
… |
|
1538 | 1538 | return S(strip_encoding(M)) |
1539 | 1539 | try: |
1540 | 1540 | return S.encoding(M) |
1541 | | except: |
| 1541 | except StandardError: |
1542 | 1542 | raise TypeError("Argument M = %s does not encode in the cipher domain" % M) |
1543 | 1543 | |
1544 | 1544 | def deciphering(self, A, C): |
… |
… |
|
2846 | 2846 | return D(strip_encoding(S)) |
2847 | 2847 | try: |
2848 | 2848 | return D.encoding(S) |
2849 | | except: |
| 2849 | except StandardError: |
2850 | 2850 | raise TypeError("Argument S = %s does not encode in the cipher domain" % S) |
2851 | 2851 | |
2852 | 2852 | def inverse_key(self, K): |
… |
… |
|
3203 | 3203 | return S(strip_encoding(M)) |
3204 | 3204 | try: |
3205 | 3205 | return S.encoding(M) |
3206 | | except: |
| 3206 | except StandardError: |
3207 | 3207 | raise TypeError("Argument M = %s does not encode in the cipher domain" % M) |
3208 | 3208 | |
3209 | 3209 | def deciphering(self, K, C): |
… |
… |
|
3336 | 3336 | if isinstance(K, list): |
3337 | 3337 | try: |
3338 | 3338 | K = G(K) |
3339 | | except: |
| 3339 | except StandardError: |
3340 | 3340 | raise TypeError("K (= %s) must specify a permutation." % K) |
3341 | 3341 | if not isinstance(K, PermutationGroupElement) and K.parent() == G: |
3342 | 3342 | raise TypeError("K (= %s) must be a permutation or list specifying a permutation." % K) |
… |
… |
|
3447 | 3447 | return S(strip_encoding(M)) |
3448 | 3448 | try: |
3449 | 3449 | return S.encoding(M) |
3450 | | except: |
| 3450 | except StandardError: |
3451 | 3451 | raise TypeError("Argument M = %s does not encode in the cipher domain" % M) |
3452 | 3452 | |
3453 | 3453 | def deciphering(self, K, C): |
… |
… |
|
3583 | 3583 | if isinstance(K, list): |
3584 | 3584 | try: |
3585 | 3585 | K = S(K) |
3586 | | except: |
| 3586 | except StandardError: |
3587 | 3587 | raise TypeError("K (= %s) must specify a string of length %s." % (K, m)) |
3588 | 3588 | if not len(K) == m: |
3589 | 3589 | raise TypeError("K (= %s) must specify a string of length %s." % (K, m)) |
… |
… |
|
3690 | 3690 | return S(strip_encoding(M)) |
3691 | 3691 | try: |
3692 | 3692 | return S.encoding(M) |
3693 | | except: |
| 3693 | except StandardError: |
3694 | 3694 | raise TypeError("Argument M = %s does not encode in the cipher domain" % M) |
3695 | 3695 | |
3696 | 3696 | def deciphering(self, K, C): |
-
diff --git a/sage/crypto/classical_cipher.py b/sage/crypto/classical_cipher.py
a
|
b
|
|
230 | 230 | E = self.parent() |
231 | 231 | try: |
232 | 232 | B = E.inverse_key(self.key()) |
233 | | except: |
| 233 | except StandardError: |
234 | 234 | raise ValueError, "Argument\n\n%s\n\nmust be an invertible cipher." % self |
235 | 235 | return E(B) |
236 | 236 | |
-
diff --git a/sage/crypto/stream.py b/sage/crypto/stream.py
a
|
b
|
|
97 | 97 | S = self.cipher_domain() |
98 | 98 | try: |
99 | 99 | return S.encoding(M) |
100 | | except: |
| 100 | except StandardError: |
101 | 101 | raise TypeError, "Argument M = %s does not encode in the cipher domain" % M |
102 | 102 | |
103 | 103 | class ShrinkingGeneratorCryptosystem(SymmetricKeyCryptosystem): |
… |
… |
|
159 | 159 | S = self.cipher_domain() |
160 | 160 | try: |
161 | 161 | return S.encoding(M) |
162 | | except: |
| 162 | except StandardError: |
163 | 163 | raise TypeError, "Argument M = %s does not encode in the cipher domain" % M |
164 | 164 | |
165 | 165 | def blum_blum_shub(length, seed=None, p=None, q=None, |
-
diff --git a/sage/databases/conv.py b/sage/databases/conv.py
a
|
b
|
|
130 | 130 | print N |
131 | 131 | try: |
132 | 132 | newforms(N, recompute=recompute) |
133 | | except: |
| 133 | except StandardError: |
134 | 134 | print "Error for N=",N |
135 | 135 | |
-
diff --git a/sage/databases/sql_db.py b/sage/databases/sql_db.py
a
|
b
|
|
662 | 662 | try: |
663 | 663 | cur = self.__database__.__connection__.cursor() |
664 | 664 | cur.execute(self.__query_string__, self.__param_tuple__) |
665 | | except: |
| 665 | except StandardError: |
666 | 666 | raise RuntimeError('Failure to fetch query.') |
667 | 667 | |
668 | 668 | print _create_print_table(cur, [des[0] for des in cur.description], \ |
… |
… |
|
1280 | 1280 | try: |
1281 | 1281 | cur = self.__connection__.cursor() |
1282 | 1282 | cur.execute('SELECT * FROM ' + table_name) |
1283 | | except: |
| 1283 | except StandardError: |
1284 | 1284 | raise RuntimeError('Failure to fetch data.') |
1285 | 1285 | print _create_print_table(cur, [des[0] for des in cur.description], \ |
1286 | 1286 | **kwds) |
… |
… |
|
2068 | 2068 | try: |
2069 | 2069 | cur = self.get_cursor() |
2070 | 2070 | cur.execute(delete_statement, query.__param_tuple__) |
2071 | | except: |
| 2071 | except StandardError: |
2072 | 2072 | raise RuntimeError('Failure to complete delete. Check your data.') |
2073 | 2073 | |
2074 | 2074 | def add_rows(self, table_name, rows, entry_order=None): |
-
diff --git a/sage/ext/gen_interpreters.py b/sage/ext/gen_interpreters.py
a
|
b
|
|
3100 | 3100 | {% if do_cleanup %} |
3101 | 3101 | try: |
3102 | 3102 | {% print indent_lines(4, the_call) %} |
3103 | | except: |
| 3103 | except StandardError: |
3104 | 3104 | {% for ch in s.chunks %} |
3105 | 3105 | {% if ch.needs_cleanup_on_error() %} |
3106 | 3106 | {% print indent_lines(12, ch.handle_cleanup()) %} |
… |
… |
|
3121 | 3121 | {% if do_cleanup %} |
3122 | 3122 | try: |
3123 | 3123 | {% print indent_lines(4, the_call_c) %} |
3124 | | except: |
| 3124 | except StandardError: |
3125 | 3125 | {% for ch in s.chunks %} |
3126 | 3126 | {% if ch.needs_cleanup_on_error() %} |
3127 | 3127 | {% print indent_lines(12, ch.handle_cleanup()) %} |
… |
… |
|
3532 | 3532 | , <PyObject*>self._domain |
3533 | 3533 | , self._code |
3534 | 3534 | ) |
3535 | | except: |
| 3535 | except StandardError: |
3536 | 3536 | for i in range(self._n_stack): |
3537 | 3537 | Py_CLEAR(self._stack[i]) |
3538 | 3538 | raise |
-
diff --git a/sage/functions/generalized.py b/sage/functions/generalized.py
a
|
b
|
|
143 | 143 | return None |
144 | 144 | else: |
145 | 145 | return 0 |
146 | | except: # x is symbolic |
147 | | pass |
| 146 | except StandardError: # x is symbolic |
| 147 | pass |
148 | 148 | return None |
149 | 149 | |
150 | 150 | dirac_delta = FunctionDiracDelta() |
… |
… |
|
249 | 249 | return 1 |
250 | 250 | else: |
251 | 251 | return 0 |
252 | | except: # x is symbolic |
253 | | pass |
| 252 | except StandardError: # x is symbolic |
| 253 | pass |
254 | 254 | return None |
255 | 255 | |
256 | 256 | def _derivative_(self, x, diff_param=None): |
… |
… |
|
358 | 358 | return 1 |
359 | 359 | else: |
360 | 360 | return 0 |
361 | | except: # x is symbolic |
362 | | pass |
| 361 | except StandardError: # x is symbolic |
| 362 | pass |
363 | 363 | return None |
364 | 364 | |
365 | 365 | def _derivative_(self, x, diff_param=None): |
… |
… |
|
493 | 493 | return ZZ(1) |
494 | 494 | else: |
495 | 495 | return ZZ(-1) |
496 | | except: # x is symbolic |
497 | | pass |
| 496 | except StandardError: # x is symbolic |
| 497 | pass |
498 | 498 | return None |
499 | 499 | |
500 | 500 | def _derivative_(self, x, diff_param=None): |
… |
… |
|
598 | 598 | return 0 |
599 | 599 | else: |
600 | 600 | return 0 # x is complex |
601 | | except: # x is symbolic |
602 | | pass |
| 601 | except StandardError: # x is symbolic |
| 602 | pass |
603 | 603 | return None |
604 | 604 | |
605 | 605 | def _derivative_(self, *args, **kwds): |
-
diff --git a/sage/functions/special.py b/sage/functions/special.py
a
|
b
|
|
1738 | 1738 | from sage.rings.real_mpfr import RR |
1739 | 1739 | try: |
1740 | 1740 | return RR(t).erfc() |
1741 | | except: |
| 1741 | except StandardError: |
1742 | 1742 | raise NotImplementedError |
1743 | 1743 | |
1744 | 1744 | |
-
diff --git a/sage/graphs/base/c_graph.pyx b/sage/graphs/base/c_graph.pyx
a
|
b
|
|
1168 | 1168 | return vertex_ints[u] |
1169 | 1169 | try: |
1170 | 1170 | u_int = u |
1171 | | except: |
| 1171 | except StandardError: |
1172 | 1172 | return -1 |
1173 | 1173 | if u_int < 0 or u_int >= G.active_vertices.size or u_int in vertex_labels: |
1174 | 1174 | return -1 |
… |
… |
|
1825 | 1825 | try: |
1826 | 1826 | v = hash(verts) |
1827 | 1827 | is_hashable = True |
1828 | | except: |
| 1828 | except StandardError: |
1829 | 1829 | pass |
1830 | 1830 | if is_hashable and self.has_vertex(verts): |
1831 | 1831 | return iter([verts]) |
-
diff --git a/sage/graphs/base/sparse_graph.pyx b/sage/graphs/base/sparse_graph.pyx
a
|
b
|
|
1656 | 1656 | for e in edges: |
1657 | 1657 | try: |
1658 | 1658 | u,v,l = e |
1659 | | except: |
| 1659 | except StandardError: |
1660 | 1660 | u,v = e |
1661 | 1661 | l = None |
1662 | 1662 | self.add_edge(u,v,l,directed) |
-
diff --git a/sage/graphs/bipartite_graph.py b/sage/graphs/bipartite_graph.py
a
|
b
|
|
361 | 361 | Graph.__init__(self, data, *args, **kwds) |
362 | 362 | try: |
363 | 363 | self.left, self.right = self.bipartite_sets() |
364 | | except: |
| 364 | except StandardError: |
365 | 365 | raise TypeError("Input graph is not bipartite!") |
366 | 366 | else: |
367 | 367 | import networkx |
… |
… |
|
384 | 384 | if not (hasattr(self, "left") and hasattr(self, "right")): |
385 | 385 | try: |
386 | 386 | self.left, self.right = self.bipartite_sets() |
387 | | except: |
| 387 | except StandardError: |
388 | 388 | raise TypeError("Input graph is not bipartite!") |
389 | 389 | |
390 | 390 | # restore vertex partition checking |
… |
… |
|
670 | 670 | # vertex) |
671 | 671 | try: |
672 | 672 | self.left.remove(vertex) |
673 | | except: |
| 673 | except StandardError: |
674 | 674 | try: |
675 | 675 | self.right.remove(vertex) |
676 | | except: |
| 676 | except StandardError: |
677 | 677 | raise RuntimeError( |
678 | 678 | "Vertex (%s) not found in partitions" % vertex) |
679 | 679 | |
… |
… |
|
714 | 714 | for vertex in vertices: |
715 | 715 | try: |
716 | 716 | self.left.remove(vertex) |
717 | | except: |
| 717 | except StandardError: |
718 | 718 | try: |
719 | 719 | self.right.remove(vertex) |
720 | | except: |
| 720 | except StandardError: |
721 | 721 | raise RuntimeError( |
722 | 722 | "Vertex (%s) not found in partitions" % vertex) |
723 | 723 | |
… |
… |
|
771 | 771 | if v is None: |
772 | 772 | try: |
773 | 773 | u, v, label = u |
774 | | except: |
| 774 | except StandardError: |
775 | 775 | u, v = u |
776 | 776 | label = None |
777 | 777 | else: |
… |
… |
|
1022 | 1022 | ... print "Load/save failed for code with edges:" |
1023 | 1023 | ... print b.edges() |
1024 | 1024 | ... break |
1025 | | ... except: |
| 1025 | ... except StandardError: |
1026 | 1026 | ... print "Exception encountered for graph of order "+ str(order) |
1027 | 1027 | ... print "with edges: " |
1028 | 1028 | ... g.edges() |
-
diff --git a/sage/graphs/digraph.py b/sage/graphs/digraph.py
a
|
b
|
|
622 | 622 | try: |
623 | 623 | e = int(e) |
624 | 624 | assert e >= 0 |
625 | | except: |
| 625 | except StandardError: |
626 | 626 | if weighted is False: |
627 | 627 | raise ValueError("Non-weighted digraph's"+ |
628 | 628 | " adjacency matrix must have only nonnegative"+ |
-
diff --git a/sage/graphs/dot2tex_utils.py b/sage/graphs/dot2tex_utils.py
a
|
b
|
|
27 | 27 | import dot2tex |
28 | 28 | # Test for this required feature from dot2tex 2.8.7 |
29 | 29 | return dot2tex.dot2tex("graph {}", format = "positions") == {} |
30 | | except: |
| 30 | except StandardError: |
31 | 31 | return False |
32 | 32 | return True |
33 | 33 | |
-
diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
a
|
b
|
|
838 | 838 | return self._backend._nxg.copy() |
839 | 839 | else: |
840 | 840 | return self._backend._nxg |
841 | | except: |
| 841 | except StandardError: |
842 | 842 | import networkx |
843 | 843 | if self._directed and self.allows_multiple_edges(): |
844 | 844 | class_type = networkx.MultiDiGraph |
… |
… |
|
7535 | 7535 | """ |
7536 | 7536 | try: |
7537 | 7537 | hash(vertex) |
7538 | | except: |
| 7538 | except StandardError: |
7539 | 7539 | return False |
7540 | 7540 | return self._backend.has_vertex(vertex) |
7541 | 7541 | |
… |
… |
|
8097 | 8097 | if v is None: |
8098 | 8098 | try: |
8099 | 8099 | u, v, label = u |
8100 | | except: |
| 8100 | except StandardError: |
8101 | 8101 | try: |
8102 | 8102 | u, v = u |
8103 | | except: |
| 8103 | except StandardError: |
8104 | 8104 | pass |
8105 | 8105 | else: |
8106 | 8106 | if v is None: |
8107 | 8107 | try: |
8108 | 8108 | u, v = u |
8109 | | except: |
| 8109 | except StandardError: |
8110 | 8110 | pass |
8111 | 8111 | if not self.allows_loops() and u==v: |
8112 | 8112 | return |
… |
… |
|
8382 | 8382 | if v is None: |
8383 | 8383 | try: |
8384 | 8384 | u, v, label = u |
8385 | | except: |
| 8385 | except StandardError: |
8386 | 8386 | u, v = u |
8387 | 8387 | label = None |
8388 | 8388 | self._backend.del_edge(u, v, label, self._directed) |
… |
… |
|
8560 | 8560 | if v is None: |
8561 | 8561 | try: |
8562 | 8562 | u, v, label = u |
8563 | | except: |
| 8563 | except StandardError: |
8564 | 8564 | u, v = u |
8565 | 8565 | label = None |
8566 | 8566 | return self._backend.has_edge(u, v, label) |
… |
… |
|
10288 | 10288 | sage: for g in graphs(5): |
10289 | 10289 | ... try: |
10290 | 10290 | ... forget = g.is_chordal() |
10291 | | ... except: |
| 10291 | ... except StandardError: |
10292 | 10292 | ... print("Oh no.") |
10293 | 10293 | |
10294 | 10294 | REFERENCES: |
… |
… |
|
11362 | 11362 | e = self.eccentricity(with_labels=True) |
11363 | 11363 | try: |
11364 | 11364 | r = min(e.values()) |
11365 | | except: |
| 11365 | except StandardError: |
11366 | 11366 | return [] |
11367 | 11367 | return [v for v in e if e[v]==r] |
11368 | 11368 | |
… |
… |
|
11697 | 11697 | e = self.eccentricity(with_labels=True) |
11698 | 11698 | try: |
11699 | 11699 | r = max(e.values()) |
11700 | | except: |
| 11700 | except StandardError: |
11701 | 11701 | return [] |
11702 | 11702 | return [v for v in e if e[v]==r] |
11703 | 11703 | |
… |
… |
|
11920 | 11920 | except AttributeError: |
11921 | 11921 | try: |
11922 | 11922 | L = networkx.bidirectional_dijkstra(self.networkx_graph(copy=False), u, v)[1] |
11923 | | except: |
| 11923 | except StandardError: |
11924 | 11924 | L = False |
11925 | 11925 | else: |
11926 | 11926 | L = networkx.dijkstra_path(self.networkx_graph(copy=False), u, v) |
… |
… |
|
11934 | 11934 | else: |
11935 | 11935 | try: |
11936 | 11936 | L = networkx.single_source_shortest_path(self.networkx_graph(copy=False), u)[v] |
11937 | | except: |
| 11937 | except StandardError: |
11938 | 11938 | L = False |
11939 | 11939 | if L: |
11940 | 11940 | return L |
-
diff --git a/sage/graphs/graph.py b/sage/graphs/graph.py
a
|
b
|
|
1204 | 1204 | try: |
1205 | 1205 | e = int(e) |
1206 | 1206 | assert e >= 0 |
1207 | | except: |
| 1207 | except StandardError: |
1208 | 1208 | if weighted is False: |
1209 | 1209 | raise ValueError("Non-weighted graph's"+ |
1210 | 1210 | " adjacency matrix must have only nonnegative"+ |
… |
… |
|
2956 | 2956 | |
2957 | 2957 | try: |
2958 | 2958 | p.solve(log=verbose) |
2959 | | except: |
| 2959 | except StandardError: |
2960 | 2960 | return None |
2961 | 2961 | |
2962 | 2962 | classss=p.get_values(classss) |
-
diff --git a/sage/graphs/graph_coloring.py b/sage/graphs/graph_coloring.py
a
|
b
|
|
1251 | 1251 | |
1252 | 1252 | except MIPSolverException: |
1253 | 1253 | if k == (Integer(max(g.degree()))/2).ceil(): |
1254 | | raise Exception("It looks like you have found a counterexample to a very old conjecture. Please do not loose it ! Please publish it, and send a post to sage-devel to warn us. I implore you ! Nathann Cohen ") |
| 1254 | raise RuntimeError("It looks like you have found a counterexample to a very old conjecture. Please do not loose it ! Please publish it, and send a post to sage-devel to warn us. I implore you ! Nathann Cohen ") |
1255 | 1255 | else: |
1256 | 1256 | raise ValueError("This graph can not be colored with the given number of colors.") |
1257 | 1257 | |
… |
… |
|
1405 | 1405 | except ValueError: |
1406 | 1406 | k = k+1 |
1407 | 1407 | |
1408 | | raise Exception("This should not happen. Please report a bug !") |
| 1408 | raise RuntimeError("This should not happen. Please report a bug !") |
1409 | 1409 | |
1410 | 1410 | elif k==0: |
1411 | 1411 | k = max(g.degree())+2 |
… |
… |
|
1456 | 1456 | |
1457 | 1457 | except MIPSolverException: |
1458 | 1458 | if k == max(g.degree()) + 2: |
1459 | | raise Exception("It looks like you have found a counterexample to a very old conjecture. Please do not loose it ! Please publish it, and send a post to sage-devel to warn us. I implore you ! Nathann Cohen ") |
| 1459 | raise RuntimeError("It looks like you have found a counterexample to a very old conjecture. Please do not loose it ! Please publish it, and send a post to sage-devel to warn us. I implore you ! Nathann Cohen ") |
1460 | 1460 | else: |
1461 | 1461 | raise ValueError("This graph can not be colored with the given number of colors.") |
1462 | 1462 | |
-
diff --git a/sage/graphs/graph_decompositions/rankwidth.pyx b/sage/graphs/graph_decompositions/rankwidth.pyx
a
|
b
|
|
185 | 185 | cdef int i |
186 | 186 | |
187 | 187 | if sage_graph_to_matrix(G): |
188 | | raise Exception("There has been a mistake while converting the Sage "+ |
| 188 | raise RuntimeError("There has been a mistake while converting the Sage "+ |
189 | 189 | "graph to a C structure. The memory is probably "+ |
190 | 190 | "insufficient (2^(n+1) is a *LOT*).") |
191 | 191 | |
-
diff --git a/sage/graphs/graph_generators.py b/sage/graphs/graph_generators.py
a
|
b
|
|
6960 | 6960 | N = networkx.random_regular_graph(d, n, seed=seed) |
6961 | 6961 | if N is False: return False |
6962 | 6962 | return graph.Graph(N, sparse=True) |
6963 | | except: |
| 6963 | except StandardError: |
6964 | 6964 | return False |
6965 | 6965 | |
6966 | 6966 | def RandomShell(self, constructor, seed=None): |
-
diff --git a/sage/graphs/graph_latex.py b/sage/graphs/graph_latex.py
a
|
b
|
|
1122 | 1122 | elif name in color_options: |
1123 | 1123 | try: |
1124 | 1124 | cc.to_rgb(value) |
1125 | | except: |
| 1125 | except StandardError: |
1126 | 1126 | raise ValueError('%s option needs to be a matplotlib color (always as a string), not %s' % (name, value)) |
1127 | 1127 | elif name in boolean_options and not type(value) == bool: |
1128 | 1128 | raise ValueError('%s option must be True or False, not %s' % (name, value)) |
… |
… |
|
1146 | 1146 | for key, c in value.items(): |
1147 | 1147 | try: |
1148 | 1148 | cc.to_rgb(c) |
1149 | | except: |
| 1149 | except StandardError: |
1150 | 1150 | raise ValueError('%s option for %s needs to be a matplotlib color (always as a string), not %s' % (name, key, c)) |
1151 | 1151 | elif name in positive_scalar_dicts: |
1152 | 1152 | if not type(value) == dict: |
-
diff --git a/sage/graphs/planarity.pyx b/sage/graphs/planarity.pyx
a
|
b
|
|
70 | 70 | ... continue # long time |
71 | 71 | ... try: # long time |
72 | 72 | ... _ = g.is_planar(set_embedding=True, set_pos=True) # long time |
73 | | ... except: # long time |
| 73 | ... except StandardError: # long time |
74 | 74 | ... print "There is something wrong here !" # long time |
75 | 75 | ... break # long time |
76 | 76 | """ |
-
diff --git a/sage/graphs/schnyder.py b/sage/graphs/schnyder.py
a
|
b
|
|
93 | 93 | for face in faces: |
94 | 94 | new_face = [] |
95 | 95 | if len(face) < 3: |
96 | | raise Exception('Triangulate method created face %s with < 3 edges.'%face) |
| 96 | raise RuntimeError('Triangulate method created face %s with < 3 edges.'%face) |
97 | 97 | if len(face) == 3: |
98 | 98 | continue # This face is already triangulated |
99 | 99 | elif len(face) == 4: # In this special case just add diagonal edge to square |
… |
… |
|
190 | 190 | while g.order() > 3: |
191 | 191 | try: |
192 | 192 | v = contractible.pop() |
193 | | except: |
194 | | raise Exception('Contractible list is empty but graph still has %d vertices. (Expected 3.)'%g.order()) |
| 193 | except StandardError: |
| 194 | raise RuntimeError('Contractible list is empty but graph still has %d vertices. (Expected 3.)'%g.order()) |
195 | 195 | |
196 | 196 | break |
197 | 197 | # going to contract v |
… |
… |
|
498 | 498 | r[i] -= q |
499 | 499 | |
500 | 500 | if sum(r) != g.order() - 1: |
501 | | raise Exception("Computing coordinates failed: vertex %s's coordinates sum to %s. Expected %s"%(v,sum(r),g.order()-1)) |
| 501 | raise RuntimeError("Computing coordinates failed: vertex %s's coordinates sum to %s. Expected %s"%(v,sum(r),g.order()-1)) |
502 | 502 | |
503 | 503 | coordinates[v] = r[:-1] |
504 | 504 | |
-
diff --git a/sage/groups/generic.py b/sage/groups/generic.py
a
|
b
|
|
553 | 553 | sage: def test(): |
554 | 554 | ... try: |
555 | 555 | ... discrete_log_rho(I(123456),I(1),operation='+') |
556 | | ... except: |
| 556 | ... except StandardError: |
557 | 557 | ... print "FAILURE" |
558 | 558 | sage: test() # random failure |
559 | 559 | FAILURE |
… |
… |
|
782 | 782 | if operation in multiplication_names: |
783 | 783 | try: |
784 | 784 | ord = base.multiplicative_order() |
785 | | except: |
| 785 | except StandardError: |
786 | 786 | ord = base.order() |
787 | 787 | elif operation in addition_names: |
788 | 788 | try: |
789 | 789 | ord = base.additive_order() |
790 | | except: |
| 790 | except StandardError: |
791 | 791 | ord = base.order() |
792 | 792 | else: |
793 | 793 | try: |
794 | 794 | ord = base.order() |
795 | | except: |
| 795 | except StandardError: |
796 | 796 | raise ValueError, "ord must be specified" |
797 | 797 | try: |
798 | 798 | from sage.rings.infinity import Infinity |
… |
… |
|
1146 | 1146 | try: |
1147 | 1147 | n = P.multiplicative_order() |
1148 | 1148 | m = Q.multiplicative_order() |
1149 | | except: |
| 1149 | except StandardError: |
1150 | 1150 | n = P.order() |
1151 | 1151 | m = Q.order() |
1152 | 1152 | elif operation in addition_names: |
… |
… |
|
1154 | 1154 | try: |
1155 | 1155 | n = P.additive_order() |
1156 | 1156 | m = Q.additive_order() |
1157 | | except: |
| 1157 | except StandardError: |
1158 | 1158 | n = P.order() |
1159 | 1159 | m = Q.order() |
1160 | 1160 | else: |
-
diff --git a/sage/groups/perm_gps/permgroup.py b/sage/groups/perm_gps/permgroup.py
a
|
b
|
|
148 | 148 | """ |
149 | 149 | try: |
150 | 150 | gap.eval('LoadPackage("hap")') |
151 | | except: |
| 151 | except StandardError: |
152 | 152 | gap.eval('LoadPackage("hap")') |
153 | 153 | |
154 | 154 | def hap_decorator(f): |
… |
… |
|
722 | 722 | """ |
723 | 723 | try: |
724 | 724 | item = self(item, check=True) |
725 | | except: |
| 725 | except StandardError: |
726 | 726 | return False |
727 | 727 | return True |
728 | 728 | |
… |
… |
|
1660 | 1660 | """ |
1661 | 1661 | try: |
1662 | 1662 | g = PermutationGroupElement(g) |
1663 | | except: |
| 1663 | except StandardError: |
1664 | 1664 | raise TypeError("{0} does not convert to a permutation group element".format(g)) |
1665 | 1665 | return PermutationGroup(gap_group=gap.ConjugateGroup(self, g)) |
1666 | 1666 | |
-
diff --git a/sage/gsl/ode.pyx b/sage/gsl/ode.pyx
a
|
b
|
|
84 | 84 | dfdt[i]=jac_list[y_n][i] |
85 | 85 | |
86 | 86 | return GSL_SUCCESS |
87 | | except: |
| 87 | except StandardError: |
88 | 88 | return -1 |
89 | 89 | |
90 | 90 | cdef int c_f(double t,double* y, double* dydt,void *params): |
… |
… |
|
106 | 106 | for i from 0<=i<y_n: |
107 | 107 | dydt[i]=dydt_list[i] |
108 | 108 | return GSL_SUCCESS |
109 | | except: |
| 109 | except StandardError: |
110 | 110 | return -1 |
111 | 111 | |
112 | 112 | |
-
diff --git a/sage/gsl/probability_distribution.pyx b/sage/gsl/probability_distribution.pyx
a
|
b
|
|
627 | 627 | for x in parameters: |
628 | 628 | try: |
629 | 629 | float(x) |
630 | | except: |
| 630 | except StandardError: |
631 | 631 | raise TypeError, "Uniform distribution requires parameters coercible to float" |
632 | 632 | self.parameters = <double*>sage_malloc(sizeof(double)*2) |
633 | 633 | self.parameters[0] = parameters[0] |
… |
… |
|
635 | 635 | elif name == 'gaussian': |
636 | 636 | try: |
637 | 637 | float(parameters) |
638 | | except: |
| 638 | except StandardError: |
639 | 639 | raise TypeError, "gaussian distribution requires parameter sigma coercible to float" |
640 | 640 | self.parameters = <double*>sage_malloc(sizeof(double)) |
641 | 641 | self.parameters[0] = float(parameters) |
… |
… |
|
645 | 645 | raise TypeError, "pareto distribution has two parameters" |
646 | 646 | try: |
647 | 647 | map(float, parameters) |
648 | | except: |
| 648 | except StandardError: |
649 | 649 | raise TypeError, "parameters must be coercible to float" |
650 | 650 | self.parameters = <double*>sage_malloc(sizeof(double)*2) |
651 | 651 | self.parameters[0] = float(parameters[0]) |
… |
… |
|
655 | 655 | self.distribution_type = rayleigh |
656 | 656 | try: |
657 | 657 | float(parameters) |
658 | | except: |
| 658 | except StandardError: |
659 | 659 | raise TypeError, "rayleigh distribution requires parameter sigma coercible to float" |
660 | 660 | self.parameters = <double*>sage_malloc(sizeof(double)) |
661 | 661 | self.parameters[0] = float(parameters) |
… |
… |
|
666 | 666 | for x in parameters: |
667 | 667 | try: |
668 | 668 | float(x) |
669 | | except: |
| 669 | except StandardError: |
670 | 670 | raise TypeError, "Lognormal distribution requires real parameters" |
671 | 671 | self.parameters = <double*>sage_malloc(sizeof(double)*2) |
672 | 672 | self.parameters[0] = float(parameters[0]) |
… |
… |
|
675 | 675 | elif name == 't': |
676 | 676 | try: |
677 | 677 | float(parameters) |
678 | | except: |
| 678 | except StandardError: |
679 | 679 | raise TypeError, "parameter to t distribution must be coercible to float" |
680 | 680 | self.parameters = <double*>sage_malloc(sizeof(double)) |
681 | 681 | self.parameters[0] = float(parameters) |
… |
… |
|
685 | 685 | raise TypeError, "F-distribution requires two real parameters" |
686 | 686 | try: |
687 | 687 | map(float, parameters) |
688 | | except: |
| 688 | except StandardError: |
689 | 689 | raise TypeError, "F-distribution requires real parameters" |
690 | 690 | self.parameters = <double *>malloc(sizeof(double)*2) |
691 | 691 | self.parameters[0] = float(parameters[0]) |
… |
… |
|
694 | 694 | elif name == 'chisquared': |
695 | 695 | try: |
696 | 696 | float(parameters) |
697 | | except: |
| 697 | except StandardError: |
698 | 698 | raise TypeError, "parameters to t distribution must be coercible to float" |
699 | 699 | self.parameters = <double *>sage_malloc(sizeof(double)) |
700 | 700 | self.parameters[0] = float(parameters) |
… |
… |
|
705 | 705 | for x in parameters: |
706 | 706 | try: |
707 | 707 | float(x) |
708 | | except: |
| 708 | except StandardError: |
709 | 709 | raise TypeError, "exponential power distribution requires real parameters" |
710 | 710 | self.parameters = <double*>sage_malloc(sizeof(double)*2) |
711 | 711 | self.parameters[0] = float(parameters[0]) |
… |
… |
|
716 | 716 | raise TypeError, "weibull distribution requires two real parameters" |
717 | 717 | try: |
718 | 718 | map(float, parameters) |
719 | | except: |
| 719 | except StandardError: |
720 | 720 | raise TypeError, "weibull distribution requires real parameters" |
721 | 721 | self.parameters = <double *>sage_malloc(sizeof(double)*2) |
722 | 722 | self.parameters[0] = float(parameters[0]) |
… |
… |
|
727 | 727 | raise TypeError, "beta distribution requires two real parameters" |
728 | 728 | try: |
729 | 729 | map(float, parameters) |
730 | | except: |
| 730 | except StandardError: |
731 | 731 | raise TypeError, "beta distribution requires real parameters" |
732 | 732 | self.parameters = <double *>sage_malloc(sizeof(double)*2) |
733 | 733 | self.parameters[0] = float(parameters[0]) |
-
diff --git a/sage/homology/chain_complex.py b/sage/homology/chain_complex.py
a
|
b
|
|
403 | 403 | |
404 | 404 | try: |
405 | 405 | deg = grading_group(degree) |
406 | | except: |
| 406 | except StandardError: |
407 | 407 | raise ValueError, "The 'degree' does not appear to be an element of the grading group." |
408 | 408 | # check form of data |
409 | 409 | new_data = {} |
-
diff --git a/sage/homology/simplicial_complex.py b/sage/homology/simplicial_complex.py
a
|
b
|
|
806 | 806 | # build dictionary of generator names |
807 | 807 | try: |
808 | 808 | gen_dict[v] = 'x%s'%int(v) |
809 | | except: |
| 809 | except StandardError: |
810 | 810 | gen_dict[v] = v |
811 | 811 | # build set of facets |
812 | 812 | good_faces = [] |
-
diff --git a/sage/interacts/debugger.py b/sage/interacts/debugger.py
a
|
b
|
|
116 | 116 | try: |
117 | 117 | code = compile(line + '\n', '<stdin>', 'single') |
118 | 118 | exec code in globals, locals |
119 | | except: |
| 119 | except StandardError: |
120 | 120 | import sys |
121 | 121 | t, v = sys.exc_info()[:2] |
122 | 122 | if type(t) == type(''): |
-
diff --git a/sage/interfaces/axiom.py b/sage/interfaces/axiom.py
a
|
b
|
|
886 | 886 | try: |
887 | 887 | import sage.misc.sage_eval |
888 | 888 | return sage.misc.sage_eval.sage_eval(self.unparsed_input_form()) |
889 | | except: |
| 889 | except StandardError: |
890 | 890 | raise NotImplementedError |
891 | 891 | |
892 | 892 | |
-
diff --git a/sage/interfaces/giac.py b/sage/interfaces/giac.py
a
|
b
|
|
1047 | 1047 | try: |
1048 | 1048 | from sage.symbolic.all import SR |
1049 | 1049 | return SR(result) |
1050 | | except: |
| 1050 | except StandardError: |
1051 | 1051 | raise NotImplementedError, "Unable to parse Giac output: %s" % result |
1052 | 1052 | else: |
1053 | 1053 | return [entry.sage() for entry in self] |
-
diff --git a/sage/interfaces/interface.py b/sage/interfaces/interface.py
a
|
b
|
|
734 | 734 | try: |
735 | 735 | if P.eval("%s %s %s"%(self.name(), P._greaterthan_symbol(), other.name())) == P._true_symbol(): |
736 | 736 | return 1 |
737 | | except: |
| 737 | except StandardError: |
738 | 738 | pass |
739 | 739 | |
740 | 740 | # everything is supposed to be comparable in Python, so we define |
… |
… |
|
847 | 847 | string = self._sage_repr() |
848 | 848 | try: |
849 | 849 | return sage.misc.sage_eval.sage_eval(string) |
850 | | except: |
| 850 | except StandardError: |
851 | 851 | raise NotImplementedError, "Unable to parse output: %s" % string |
852 | 852 | |
853 | 853 | |
-
diff --git a/sage/interfaces/macaulay2.py b/sage/interfaces/macaulay2.py
a
|
b
|
|
1097 | 1097 | from sage.misc.sage_eval import sage_eval |
1098 | 1098 | try: |
1099 | 1099 | return sage_eval(repr_str) |
1100 | | except: |
| 1100 | except StandardError: |
1101 | 1101 | raise NotImplementedError, "cannot convert %s to a Sage object"%repr_str |
1102 | 1102 | |
1103 | 1103 | |
-
diff --git a/sage/interfaces/magma.py b/sage/interfaces/magma.py
a
|
b
|
|
1034 | 1034 | else: |
1035 | 1035 | try: |
1036 | 1036 | self.eval('Append(~_sage_, 0);') |
1037 | | except: |
| 1037 | except StandardError: |
1038 | 1038 | # this exception could happen if the Magma process |
1039 | 1039 | # was interrupted during startup / initialization. |
1040 | 1040 | self.eval('_sage_ := [* 0 : i in [1..%s] *];'%self.__seq) |
-
diff --git a/sage/interfaces/maple.py b/sage/interfaces/maple.py
a
|
b
|
|
703 | 703 | cmd = 'echo "interface(verboseproc=2): print(%s);" | maple -q'%s |
704 | 704 | src = os.popen(cmd).read() |
705 | 705 | if src.strip() == s: |
706 | | raise Exception, "no source code could be found" |
| 706 | raise RuntimeError, "no source code could be found" |
707 | 707 | else: |
708 | 708 | return src |
709 | 709 | |
… |
… |
|
1102 | 1102 | try: |
1103 | 1103 | from sage.symbolic.all import SR |
1104 | 1104 | return SR(result) |
1105 | | except: |
| 1105 | except StandardError: |
1106 | 1106 | raise NotImplementedError, "Unable to parse Maple output: %s" % result |
1107 | 1107 | |
1108 | 1108 | # An instance |
-
diff --git a/sage/interfaces/mathematica.py b/sage/interfaces/mathematica.py
a
|
b
|
|
799 | 799 | try: |
800 | 800 | return symbolic_expression_from_string(res, lsymbols, |
801 | 801 | accept_sequence=True) |
802 | | except: |
| 802 | except StandardError: |
803 | 803 | raise NotImplementedError, "Unable to parse Mathematica \ |
804 | 804 | output: %s" % res |
805 | 805 | |
-
diff --git a/sage/interfaces/phc.py b/sage/interfaces/phc.py
a
|
b
|
|
220 | 220 | start_data += output_list[found_solutions] + '\n\n' |
221 | 221 | try: |
222 | 222 | var_number = int(output_list[found_solutions+1].split(' ')[1]) |
223 | | except: |
| 223 | except StandardError: |
224 | 224 | # bad error handling |
225 | 225 | var_number = int(output_list[found_solutions+2].split(' ')[1]) |
226 | 226 | sol_count = 0 |
-
diff --git a/sage/interfaces/psage.py b/sage/interfaces/psage.py
a
|
b
|
|
115 | 115 | self.expect().expect(self._prompt) |
116 | 116 | try: |
117 | 117 | return Sage.eval(self, x, **kwds) |
118 | | except: |
| 118 | except StandardError: |
119 | 119 | return "<<currently executing code>>" |
120 | 120 | |
121 | 121 | |
… |
… |
|
125 | 125 | """ |
126 | 126 | try: |
127 | 127 | return self.eval('print %s'%var) |
128 | | except: |
| 128 | except StandardError: |
129 | 129 | return "<<currently executing code>>" |
130 | 130 | |
131 | 131 | def set(self, var, value): |
-
diff --git a/sage/interfaces/tests.py b/sage/interfaces/tests.py
a
|
b
|
|
49 | 49 | sys.stdout.flush() |
50 | 50 | v.append(s(t)) |
51 | 51 | print '\nsuccess -- time = cpu: %s, wall: %s'%(cputime(t), walltime(w)) |
52 | | except: |
| 52 | except StandardError: |
53 | 53 | print "%s -- failed!"%s |
54 | 54 | |
55 | 55 | def manyvars_all(num=70000): |
-
diff --git a/sage/libs/ntl/ntl_lzz_p.pyx b/sage/libs/ntl/ntl_lzz_p.pyx
a
|
b
|
|
144 | 144 | else: |
145 | 145 | try: |
146 | 146 | modulus = int(modulus) |
147 | | except: |
| 147 | except StandardError: |
148 | 148 | raise ValueError, "%s is not a valid modulus."%modulus |
149 | 149 | self.c = <ntl_zz_pContext_class>ntl_zz_pContext(modulus) |
150 | 150 | |
-
diff --git a/sage/libs/ntl/ntl_lzz_pX.pyx b/sage/libs/ntl/ntl_lzz_pX.pyx
a
|
b
|
|
160 | 160 | else: |
161 | 161 | try: |
162 | 162 | modulus = int(modulus) |
163 | | except: |
| 163 | except StandardError: |
164 | 164 | raise ValueError, "%s is not a valid modulus."%modulus |
165 | 165 | self.c = <ntl_zz_pContext_class>ntl_zz_pContext(modulus) |
166 | 166 | |
-
diff --git a/sage/matrix/matrix2.pyx b/sage/matrix/matrix2.pyx
a
|
b
|
|
7895 | 7895 | raise NotImplementedError('QR decomposition is implemented over exact rings, try CDF for numerical results, not %s' % R) |
7896 | 7896 | try: |
7897 | 7897 | F = R.fraction_field() |
7898 | | except: |
| 7898 | except StandardError: |
7899 | 7899 | raise ValueError("QR decomposition needs a fraction field of %s" % R) |
7900 | 7900 | m = self.nrows() |
7901 | 7901 | n = self.ncols() |
… |
… |
|
9261 | 9261 | JA, SA = A.jordan_form(transformation=True) |
9262 | 9262 | else: |
9263 | 9263 | JA = A.jordan_form(transformation=False) |
9264 | | except: |
| 9264 | except StandardError: |
9265 | 9265 | raise ValueError('unable to compute Jordan canonical form for a matrix') |
9266 | 9266 | try: |
9267 | 9267 | if transformation: |
9268 | 9268 | JB, SB = B.jordan_form(transformation=True) |
9269 | 9269 | else: |
9270 | 9270 | JB = B.jordan_form(transformation=False) |
9271 | | except: |
| 9271 | except StandardError: |
9272 | 9272 | raise ValueError('unable to compute Jordan canonical form for a matrix') |
9273 | 9273 | similar = (JA == JB) |
9274 | 9274 | transform = None |
… |
… |
|
10281 | 10281 | if not R.is_field(): |
10282 | 10282 | try: |
10283 | 10283 | F = R.fraction_field() |
10284 | | except: |
| 10284 | except StandardError: |
10285 | 10285 | msg = 'base ring of the matrix needs a field of fractions, not {0}' |
10286 | 10286 | raise TypeError(msg.format(R)) |
10287 | 10287 | else: |
… |
… |
|
10294 | 10294 | try: |
10295 | 10295 | abs(F.an_element()) |
10296 | 10296 | pivot = 'partial' |
10297 | | except: |
| 10297 | except StandardError: |
10298 | 10298 | if pivot == 'partial': |
10299 | 10299 | msg = "cannot take absolute value of matrix entries, try 'pivot=nonzero'" |
10300 | 10300 | raise TypeError(msg) |
-
diff --git a/sage/matrix/matrix_double_dense.pyx b/sage/matrix/matrix_double_dense.pyx
a
|
b
|
|
2674 | 2674 | global numpy |
2675 | 2675 | try: |
2676 | 2676 | tol = float(tol) |
2677 | | except: |
| 2677 | except StandardError: |
2678 | 2678 | raise TypeError('tolerance must be a real number, not {0}'.format(tol)) |
2679 | 2679 | if tol <= 0: |
2680 | 2680 | raise ValueError('tolerance must be positive, not {0}'.format(tol)) |
-
diff --git a/sage/matrix/operation_table.py b/sage/matrix/operation_table.py
a
|
b
|
|
360 | 360 | raise ValueError('%s is infinite' % S) |
361 | 361 | try: |
362 | 362 | elems = tuple(S) |
363 | | except: |
| 363 | except StandardError: |
364 | 364 | raise ValueError('unable to determine elements of %s' % S) |
365 | 365 | else: |
366 | 366 | elems = [] |
… |
… |
|
369 | 369 | coerced = S(e) |
370 | 370 | if not(coerced in elems): |
371 | 371 | elems.append(coerced) |
372 | | except: |
| 372 | except StandardError: |
373 | 373 | raise TypeError('unable to coerce %s into %s' % (e, S)) |
374 | 374 | self._elts = elems |
375 | 375 | self._n = len(self._elts) |
… |
… |
|
411 | 411 | row.append(self._elts.index(result)) |
412 | 412 | except ValueError: # list/index condition |
413 | 413 | raise ValueError('%s%s%s=%s, and so the set is not closed' % (g, self._ascii_symbol, h, result)) |
414 | | except: |
| 414 | except StandardError: |
415 | 415 | raise TypeError('elements %s and %s of %s are incompatible with operation: %s' % (g,h,S,self._operation)) |
416 | 416 | self._table.append(row) |
417 | 417 | |
-
diff --git a/sage/misc/explain_pickle.py b/sage/misc/explain_pickle.py
a
|
b
|
|
2704 | 2704 | try: |
2705 | 2705 | cpickle_res = unp.load() |
2706 | 2706 | cpickle_ok = True |
2707 | | except: |
| 2707 | except StandardError: |
2708 | 2708 | cpickle_ok = False |
2709 | 2709 | |
2710 | 2710 | current_repr = repr(current_res) |
-
diff --git a/sage/misc/functional.py b/sage/misc/functional.py
a
|
b
|
|
106 | 106 | return y |
107 | 107 | else: |
108 | 108 | raise AttributeError, "The base ring of %s is not a field"%x |
109 | | except: |
| 109 | except StandardError: |
110 | 110 | raise |
111 | 111 | |
112 | 112 | def basis(x): |
-
diff --git a/sage/misc/getusage.py b/sage/misc/getusage.py
a
|
b
|
|
157 | 157 | t = open(_proc_status) |
158 | 158 | v = t.read() |
159 | 159 | t.close() |
160 | | except: |
| 160 | except StandardError: |
161 | 161 | return 0.0 # non-Linux? |
162 | 162 | # get VmKey line e.g. 'VmRSS: 9999 kB\n ...' |
163 | 163 | i = v.index(VmKey) |
-
diff --git a/sage/misc/hg.py b/sage/misc/hg.py
a
|
b
|
|
264 | 264 | """ |
265 | 265 | try: |
266 | 266 | tmp_branch_list = [s[5:] for s in os.listdir(SAGE_ROOT + "/devel") if s.startswith("sage-")] |
267 | | except: |
| 267 | except StandardError: |
268 | 268 | raise RuntimeError, "Oops! We had trouble... Check that SAGE_ROOT gives the correct directory." |
269 | 269 | |
270 | 270 | if print_flag: |
-
diff --git a/sage/misc/interpreter.py b/sage/misc/interpreter.py
a
|
b
|
|
193 | 193 | if line[:6] == 'iload ': |
194 | 194 | try: |
195 | 195 | name = str(eval(line[6:])) |
196 | | except: |
| 196 | except StandardError: |
197 | 197 | name = str(line[6:].strip()) |
198 | 198 | try: |
199 | 199 | F = open(name) |
-
diff --git a/sage/misc/latex.py b/sage/misc/latex.py
a
|
b
|
|
2255 | 2255 | try: |
2256 | 2256 | if bv in CC: |
2257 | 2257 | s += "%s\cdot %s"%(coeff, b) |
2258 | | except: |
| 2258 | except StandardError: |
2259 | 2259 | s += "%s%s"%(coeff, b) |
2260 | 2260 | first = False |
2261 | 2261 | i += 1 |
-
diff --git a/sage/misc/log.py b/sage/misc/log.py
a
|
b
|
|
254 | 254 | x = self._output[n] |
255 | 255 | try: |
256 | 256 | L = latex.latex(x) |
257 | | except: |
| 257 | except StandardError: |
258 | 258 | L = "\\mbox{error TeXing object}" |
259 | 259 | single_png = os.path.join(self._images, '%s.png' % n) |
260 | 260 | try: |
-
diff --git a/sage/misc/misc.py b/sage/misc/misc.py
a
|
b
|
|
1627 | 1627 | # see trac #7398 for a discussion |
1628 | 1628 | try: |
1629 | 1629 | return it is iter(it) |
1630 | | except: |
| 1630 | except StandardError: |
1631 | 1631 | return False |
1632 | 1632 | |
1633 | 1633 | |
-
diff --git a/sage/modular/arithgroup/congroup_pyx.pyx b/sage/modular/arithgroup/congroup_pyx.pyx
a
|
b
|
|
302 | 302 | # print [type(lift_to_sl2z(c, d, level)) for c,d in crs] |
303 | 303 | try: |
304 | 304 | reps = [Matrix_integer_2x2(Mat2Z,lift_to_sl2z(c, d, level),False,True) for c,d in crs] |
305 | | except: |
| 305 | except StandardError: |
306 | 306 | raise ArithmeticError, "Error lifting to SL2Z: level=%s crs=%s" % (level, crs) |
307 | 307 | ans = [] |
308 | 308 | for i from 0 <= i < len(crs): |
-
diff --git a/sage/modular/modform/element.py b/sage/modular/modform/element.py
a
|
b
|
|
248 | 248 | """ |
249 | 249 | try: |
250 | 250 | self._ensure_is_compatible(other) |
251 | | except: |
| 251 | except StandardError: |
252 | 252 | return self.parent().__cmp__(other.parent()) |
253 | 253 | if self.element() == other.element(): |
254 | 254 | return 0 |
… |
… |
|
685 | 685 | """ |
686 | 686 | try: |
687 | 687 | self._ensure_is_compatible(other) |
688 | | except: |
| 688 | except StandardError: |
689 | 689 | return False |
690 | 690 | if isinstance(other, Newform): |
691 | 691 | if self.q_expansion(self.parent().sturm_bound()) == other.q_expansion(other.parent().sturm_bound()): |
… |
… |
|
714 | 714 | """ |
715 | 715 | try: |
716 | 716 | self._ensure_is_compatible(other) |
717 | | except: |
| 717 | except StandardError: |
718 | 718 | return self.parent().__cmp__(other.parent()) |
719 | 719 | if isinstance(other, Newform): |
720 | 720 | if self.q_expansion(self.parent().sturm_bound()) == other.q_expansion(other.parent().sturm_bound()): |
-
diff --git a/sage/modular/overconvergent/genus0.py b/sage/modular/overconvergent/genus0.py
a
|
b
|
|
1589 | 1589 | for i in xrange(self.gexp().prec()): |
1590 | 1590 | if 12/ZZ(p - 1)*i*(r - s) - F(self.gexp()[i]).normalized_valuation() == self.r_ord(r): |
1591 | 1591 | return i |
1592 | | raise Exception, "Can't get here" |
| 1592 | raise RuntimeError, "Can't get here" |
1593 | 1593 | |
1594 | 1594 | def valuation_plot(self, rmax = None): |
1595 | 1595 | r""" |
-
diff --git a/sage/modules/vector_double_dense.pyx b/sage/modules/vector_double_dense.pyx
a
|
b
|
|
740 | 740 | else: |
741 | 741 | try: |
742 | 742 | p = RDF(p) |
743 | | except: |
| 743 | except StandardError: |
744 | 744 | raise ValueError("vector norm 'p' must be +/- infinity or a real number, not %s" % p) |
745 | 745 | n = numpy.linalg.norm(self._vector_numpy, ord=p) |
746 | 746 | # p = 0 returns integer *count* of non-zero entries |
-
diff --git a/sage/monoids/string_monoid_element.py b/sage/monoids/string_monoid_element.py
a
|
b
|
|
248 | 248 | """ |
249 | 249 | try: |
250 | 250 | c = self._element_list[n] |
251 | | except: |
| 251 | except StandardError: |
252 | 252 | raise IndexError("Argument n (= %s) is not a valid index." % n) |
253 | 253 | if not isinstance(c, list): |
254 | 254 | c = [c] |
-
diff --git a/sage/numerical/backends/gurobi_backend.pyx b/sage/numerical/backends/gurobi_backend.pyx
a
|
b
|
|
47 | 47 | check(self.env, error) |
48 | 48 | |
49 | 49 | if env[0] == NULL: |
50 | | raise Exception("Could not initialize Gurobi environment") |
| 50 | raise RuntimeError("Could not initialize Gurobi environment") |
51 | 51 | |
52 | 52 | self.model = <GRBmodel **> sage_malloc(sizeof(GRBmodel *)) |
53 | 53 | |
… |
… |
|
56 | 56 | self.env = GRBgetenv (self.model[0]) |
57 | 57 | |
58 | 58 | if error: |
59 | | raise Exception("Could not initialize Gurobi model") |
| 59 | raise RuntimeError("Could not initialize Gurobi model") |
60 | 60 | |
61 | 61 | if maximization: |
62 | 62 | error = GRBsetintattr(self.model[0], "ModelSense", -1) |
-
diff --git a/sage/plot/matrix_plot.py b/sage/plot/matrix_plot.py
a
|
b
|
|
456 | 456 | entries = list(mat._dict().items()) |
457 | 457 | try: |
458 | 458 | data = np.asarray([d for _,d in entries], dtype=float) |
459 | | except: |
| 459 | except StandardError: |
460 | 460 | raise ValueError, "can not convert entries to floating point numbers" |
461 | 461 | positions = np.asarray([[row for (row,col),_ in entries], |
462 | 462 | [col for (row,col),_ in entries]], dtype=int) |
-
diff --git a/sage/plot/plot3d/implicit_surface.pyx b/sage/plot/plot3d/implicit_surface.pyx
a
|
b
|
|
965 | 965 | gradient = (orig_f.diff(self.vars[0]), |
966 | 966 | orig_f.diff(self.vars[1]), |
967 | 967 | orig_f.diff(self.vars[2])) |
968 | | except: |
| 968 | except StandardError: |
969 | 969 | # Would be nice to have more nuanced error handling here. |
970 | 970 | |
971 | 971 | # If anything goes wrong, we'll just use central differencing. |
-
diff --git a/sage/quadratic_forms/extras.py b/sage/quadratic_forms/extras.py
a
|
b
|
|
63 | 63 | disc_sqrt = ZZ(sqrt(1+8*n)) |
64 | 64 | a = ZZ( (ZZ(-1) + disc_sqrt) / ZZ(2) ) |
65 | 65 | return a |
66 | | except: |
| 66 | except StandardError: |
67 | 67 | return False |
68 | 68 | |
69 | 69 | |
-
diff --git a/sage/quadratic_forms/quadratic_form.py b/sage/quadratic_forms/quadratic_form.py
a
|
b
|
|
424 | 424 | ## Verify the size of the matrix is an integer >= 0 |
425 | 425 | try: |
426 | 426 | n = int(n) |
427 | | except: |
| 427 | except StandardError: |
428 | 428 | raise TypeError, "Oops! The size " + str(n) + " must be an integer." |
429 | 429 | if (n < 0): |
430 | 430 | raise TypeError, "Oops! The size " + str(n) + " must be a non-negative integer." |
… |
… |
|
624 | 624 | ## Set the entry |
625 | 625 | try: |
626 | 626 | self.__coeffs[i*self.__n - i*(i-1)/2 + j -i] = self.__base_ring(coeff) |
627 | | except: |
| 627 | except StandardError: |
628 | 628 | raise RuntimeError, "Oops! This coefficient can't be coerced to an element of the base ring for the quadratic form." |
629 | 629 | |
630 | 630 | |
… |
… |
|
752 | 752 | # """ |
753 | 753 | # try: |
754 | 754 | # c = self.base_ring()(right) |
755 | | # except: |
| 755 | # except StandardError: |
756 | 756 | # raise TypeError, "Oh no! The multiplier cannot be coerced into the base ring of the quadratic form. =(" |
757 | 757 | # |
758 | 758 | # return QuadraticForm(self.base_ring(), self.dim(), [c * self.__coeffs[i] for i in range(len(self.__coeffs))]) |
… |
… |
|
868 | 868 | if len(v) > 0: |
869 | 869 | try: |
870 | 870 | x = self.base_ring()(v[0]) |
871 | | except: |
| 871 | except StandardError: |
872 | 872 | raise TypeError, "Oops! Your vector is not coercible to the base ring of the quadratic form... =(" |
873 | 873 | |
874 | 874 | ## Attempt to evaluate Q[v] |
… |
… |
|
932 | 932 | for i in range(n): |
933 | 933 | for j in range(i, n): |
934 | 934 | x = R(A[i,j]) |
935 | | except: |
| 935 | except StandardError: |
936 | 936 | return False |
937 | 937 | |
938 | 938 | ## Test that the diagonal is even (if 1/2 isn't in R) |
… |
… |
|
1084 | 1084 | flag = True |
1085 | 1085 | try: |
1086 | 1086 | self.Gram_matrix() |
1087 | | except: |
| 1087 | except StandardError: |
1088 | 1088 | flag = False |
1089 | 1089 | |
1090 | 1090 | return flag |
… |
… |
|
1156 | 1156 | B = self.base_ring() |
1157 | 1157 | try: |
1158 | 1158 | R = PolynomialRing(self.base_ring(),names,n) |
1159 | | except: |
| 1159 | except StandardError: |
1160 | 1160 | raise ValueError, 'Can only create polynomial rings over commutative rings.' |
1161 | 1161 | V = vector(R.gens()) |
1162 | 1162 | P = (V*M).dot_product(V) |
-
diff --git a/sage/quadratic_forms/quadratic_form__automorphisms.py b/sage/quadratic_forms/quadratic_form__automorphisms.py
a
|
b
|
|
50 | 50 | return deepcopy(self.__basis_of_short_vectors) |
51 | 51 | else: |
52 | 52 | return deepcopy(self.__basis_of_short_vectors) |
53 | | except: |
| 53 | except StandardError: |
54 | 54 | pass |
55 | 55 | |
56 | 56 | |
… |
… |
|
413 | 413 | self.__number_of_automorphisms = self.number_of_automorphisms__souvigner() |
414 | 414 | try: |
415 | 415 | self._external_initialization_list.remove('number_of_automorphisms') |
416 | | except: |
| 416 | except StandardError: |
417 | 417 | pass ## Do nothing if the removal fails, since it might not be in the list (causing an error)! |
418 | 418 | return self.__number_of_automorphisms |
419 | 419 | |
-
diff --git a/sage/quadratic_forms/quadratic_form__genus.py b/sage/quadratic_forms/quadratic_form__genus.py
a
|
b
|
|
60 | 60 | ## Return the result |
61 | 61 | try: |
62 | 62 | return Genus(self.Hessian_matrix()) |
63 | | except: |
| 63 | except StandardError: |
64 | 64 | raise TypeError, "Oops! There is a problem computing the genus symbols for this form." |
65 | 65 | |
66 | 66 | |
… |
… |
|
127 | 127 | try: |
128 | 128 | M = self.Hessian_matrix() |
129 | 129 | return LocalGenusSymbol(M, p) |
130 | | except: |
| 130 | except StandardError: |
131 | 131 | raise TypeError, "Oops! There is a problem computing the local genus symbol at the prime " + str(p) + " for this form." |
132 | 132 | |
133 | 133 | |
-
diff --git a/sage/quadratic_forms/quadratic_form__local_normal_form.py b/sage/quadratic_forms/quadratic_form__local_normal_form.py
a
|
b
|
|
354 | 354 | return copy.deepcopy(self.__jordan_blocks_by_scale_and_unimodular_dict[p]) |
355 | 355 | else: |
356 | 356 | return self.__jordan_blocks_by_scale_and_unimodular_dict[p] |
357 | | except: |
| 357 | except StandardError: |
358 | 358 | ## Initialize the global dictionary if it doesn't exist |
359 | 359 | if not hasattr(self, '__jordan_blocks_by_scale_and_unimodular_dict'): |
360 | 360 | self.__jordan_blocks_by_scale_and_unimodular_dict = {} |
-
diff --git a/sage/quadratic_forms/quadratic_form__variable_substitutions.py b/sage/quadratic_forms/quadratic_form__variable_substitutions.py
a
|
b
|
|
212 | 212 | # it doesn't work by scoping reasons. |
213 | 213 | Q = self.__class__(R, self.dim(), list2) |
214 | 214 | return Q |
215 | | except: |
| 215 | except StandardError: |
216 | 216 | if (change_value_ring_flag == False): |
217 | 217 | raise TypeError, "Oops! We could not rescale the lattice in this way and preserve its defining ring." |
218 | 218 | else: |
-
diff --git a/sage/quadratic_forms/random_quadraticform.py b/sage/quadratic_forms/random_quadraticform.py
a
|
b
|
|
107 | 107 | ## Check if condition c is satisfied |
108 | 108 | try: |
109 | 109 | bool_ans = Q.c() |
110 | | except: |
| 110 | except StandardError: |
111 | 111 | bool_ans = c(Q) |
112 | 112 | |
113 | 113 | ## Create a new quadratic form if a condition fails |
-
diff --git a/sage/rings/complex_mpc.pyx b/sage/rings/complex_mpc.pyx
a
|
b
|
|
1580 | 1580 | else: |
1581 | 1581 | try: |
1582 | 1582 | p = (<MPComplexField_class>x._parent)(right) |
1583 | | except: |
| 1583 | except StandardError: |
1584 | 1584 | raise ValueError |
1585 | 1585 | mpc_pow(z.value, x.value, p.value, (<MPComplexField_class>x._parent).__rnd) |
1586 | 1586 | |
-
diff --git a/sage/rings/finite_rings/integer_mod.pyx b/sage/rings/finite_rings/integer_mod.pyx
a
|
b
|
|
1226 | 1226 | ... L = b.nth_root(e, all=True) |
1227 | 1227 | ... if len(L) > 0: |
1228 | 1228 | ... c = b.nth_root(e) |
1229 | | ... except: |
| 1229 | ... except StandardError: |
1230 | 1230 | ... L = [-1] |
1231 | 1231 | ... M = b._nth_root_naive(e) |
1232 | 1232 | ... if sorted(L) != M: |
-
diff --git a/sage/rings/fraction_field_element.pyx b/sage/rings/fraction_field_element.pyx
a
|
b
|
|
202 | 202 | try: |
203 | 203 | num *= den.inverse_of_unit() |
204 | 204 | den = den.parent().one_element() |
205 | | except: |
| 205 | except StandardError: |
206 | 206 | pass |
207 | 207 | self.__numerator = num |
208 | 208 | self.__denominator = den |
-
diff --git a/sage/rings/homset.py b/sage/rings/homset.py
a
|
b
|
|
59 | 59 | try: |
60 | 60 | if isinstance(x, morphism.RingHomomorphism_im_gens) and x.domain().fraction_field().has_coerce_map_from(self.domain()): |
61 | 61 | return morphism.RingHomomorphism_im_gens(self, x.im_gens()) |
62 | | except: |
| 62 | except StandardError: |
63 | 63 | pass |
64 | 64 | # Case 3: the homomorphism can be extended by coercion |
65 | 65 | try: |
66 | 66 | return x.extend_codomain(self.codomain()).extend_domain(self.domain()) |
67 | | except: |
| 67 | except StandardError: |
68 | 68 | pass |
69 | 69 | # Last resort, case 4: the homomorphism is induced from the base ring |
70 | 70 | if self.domain()==self.domain().base() or self.codomain()==self.codomain().base(): |
… |
… |
|
72 | 72 | try: |
73 | 73 | x = self.domain().base().Hom(self.codomain().base())(x) |
74 | 74 | return morphism.RingHomomorphism_from_base(self, x) |
75 | | except: |
| 75 | except StandardError: |
76 | 76 | raise TypeError |
77 | 77 | |
78 | 78 | def __call__(self, im_gens, check=True): |
-
diff --git a/sage/rings/integer.pyx b/sage/rings/integer.pyx
a
|
b
|
|
2214 | 2214 | # upper is *greater* than the answer |
2215 | 2215 | try: |
2216 | 2216 | upper = rif_log.upper().ceiling() |
2217 | | except: |
| 2217 | except StandardError: |
2218 | 2218 | # ceiling is probably Infinity |
2219 | 2219 | # I'm not sure what to do now |
2220 | 2220 | upper = 0 |
-
diff --git a/sage/rings/morphism.pyx b/sage/rings/morphism.pyx
a
|
b
|
|
1381 | 1381 | P = self.codomain() |
1382 | 1382 | try: |
1383 | 1383 | return P(dict([(a, self.__underlying(b)) for a,b in x.dict().items()])) |
1384 | | except: |
| 1384 | except StandardError: |
1385 | 1385 | pass |
1386 | 1386 | try: |
1387 | 1387 | return P([self.__underlying(b) for b in x]) |
1388 | | except: |
| 1388 | except StandardError: |
1389 | 1389 | pass |
1390 | 1390 | try: |
1391 | 1391 | return P(self.__underlying(x.numerator()))/P(self.__underlying(x.denominator())) |
1392 | | except: |
| 1392 | except StandardError: |
1393 | 1393 | raise TypeError, "invalid argument %s"%repr(x) |
1394 | 1394 | |
1395 | 1395 | cdef class RingHomomorphism_cover(RingHomomorphism): |
-
diff --git a/sage/rings/number_field/morphism.py b/sage/rings/number_field/morphism.py
a
|
b
|
|
300 | 300 | # try to get the cached transformation matrix and vector space isomorphisms if they exist |
301 | 301 | try: |
302 | 302 | M,LtoV,VtoK = self._transformation_data |
303 | | except: |
| 303 | except StandardError: |
304 | 304 | # get the identifications of K and L with vector spaces over Q |
305 | 305 | V,VtoL,LtoV = self.codomain().absolute_vector_space() |
306 | 306 | V,VtoK,KtoV = self.domain().absolute_vector_space() |
-
diff --git a/sage/rings/number_field/totallyreal_rel.py b/sage/rings/number_field/totallyreal_rel.py
a
|
b
|
|
602 | 602 | for a0 in a0s: |
603 | 603 | try: |
604 | 604 | ind = self.amaxvals[0].remove(a0) |
605 | | except: |
| 605 | except StandardError: |
606 | 606 | True |
607 | 607 | |
608 | 608 | if verbose: |
-
diff --git a/sage/rings/polynomial/groebner_fan.py b/sage/rings/polynomial/groebner_fan.py
a
|
b
|
|
1056 | 1056 | if vert > adj[0]: |
1057 | 1057 | try: |
1058 | 1058 | edges.append([tpoints[adj[0]],tpoints[vert]]) |
1059 | | except: |
| 1059 | except StandardError: |
1060 | 1060 | print adj |
1061 | 1061 | print 'tpoints: ' + str(tpoints) |
1062 | 1062 | print 'fpoints: ' + str(fpoints) |
… |
… |
|
1112 | 1112 | for cone_data in cone_info: |
1113 | 1113 | try: |
1114 | 1114 | cone_lines = self._4d_to_3d(cone_data) |
1115 | | except: |
| 1115 | except StandardError: |
1116 | 1116 | print cone_data._rays |
1117 | 1117 | raise RuntimeError |
1118 | 1118 | for a_line in cone_lines: |
-
diff --git a/sage/rings/polynomial/infinite_polynomial_element.py b/sage/rings/polynomial/infinite_polynomial_element.py
a
|
b
|
|
335 | 335 | try: |
336 | 336 | from sage.misc.sage_eval import sage_eval |
337 | 337 | return sage_eval(repr(res), self.parent()._gens_dict) |
338 | | except: |
| 338 | except StandardError: |
339 | 339 | return res |
340 | 340 | |
341 | 341 | def _getAttributeNames(self): |
… |
… |
|
502 | 502 | # One may need a new parent for self._p and x._p |
503 | 503 | try: |
504 | 504 | return InfinitePolynomial_sparse(self.parent(),self._p+x._p) |
505 | | except: |
| 505 | except StandardError: |
506 | 506 | pass |
507 | 507 | ## We can now assume that self._p and x._p actually are polynomials, |
508 | 508 | ## hence, their parent is not simply the underlying ring. |
… |
… |
|
526 | 526 | """ |
527 | 527 | try: |
528 | 528 | return InfinitePolynomial_sparse(self.parent(),self._p*x._p) |
529 | | except: |
| 529 | except StandardError: |
530 | 530 | pass |
531 | 531 | ## We can now assume that self._p and x._p actually are polynomials, |
532 | 532 | ## hence, their parent is not just the underlying ring. |
… |
… |
|
604 | 604 | """ |
605 | 605 | try: |
606 | 606 | return InfinitePolynomial_sparse(self.parent(),self._p-x._p) |
607 | | except: |
| 607 | except StandardError: |
608 | 608 | pass |
609 | 609 | ## We can now assume that self._p and x._p actually are polynomials, |
610 | 610 | ## hence, their parent is not just the underlying ring. |
… |
… |
|
1318 | 1318 | # But, to be on the safe side... |
1319 | 1319 | try: |
1320 | 1320 | self._p = self.parent()._P(self._p) |
1321 | | except: |
| 1321 | except StandardError: |
1322 | 1322 | pass |
1323 | 1323 | try: |
1324 | 1324 | x._p = x.parent()._P(x._p) |
1325 | | except: |
| 1325 | except StandardError: |
1326 | 1326 | pass |
1327 | 1327 | return cmp(self._p,x._p) |
1328 | 1328 | |
-
diff --git a/sage/rings/polynomial/infinite_polynomial_ring.py b/sage/rings/polynomial/infinite_polynomial_ring.py
a
|
b
|
|
449 | 449 | try: |
450 | 450 | if len(L)==2: |
451 | 451 | return self._D[L[0]][int(L[1])] |
452 | | except: |
| 452 | except StandardError: |
453 | 453 | pass |
454 | 454 | raise KeyError, "%s is not a variable name"%k |
455 | 455 | |
… |
… |
|
673 | 673 | try: |
674 | 674 | if not (hasattr(R,'is_ring') and R.is_ring() and hasattr(R,'is_commutative') and R.is_commutative()): |
675 | 675 | raise TypeError |
676 | | except: |
| 676 | except StandardError: |
677 | 677 | raise TypeError, "The given 'base ring' (= %s) must be a commutative ring"%(R) |
678 | 678 | |
679 | 679 | # now, the input is accepted |
… |
… |
|
866 | 866 | # We don't care about the orders. But base ring and generators |
867 | 867 | # of the pushout should remain the same as in self. |
868 | 868 | v = (P._names == self._names and P._base == self._base) |
869 | | except: |
| 869 | except StandardError: |
870 | 870 | v = False |
871 | 871 | try: |
872 | 872 | self._coerce_cache[S] = v |
873 | | except: |
| 873 | except StandardError: |
874 | 874 | pass |
875 | 875 | return v |
876 | 876 | |
… |
… |
|
906 | 906 | # the string representation. |
907 | 907 | from sage.misc.sage_eval import sage_eval |
908 | 908 | if isinstance(x, basestring): |
909 | | try: |
| 909 | try: |
910 | 910 | return sage_eval(x, self.gens_dict()) |
911 | | except: |
| 911 | except StandardError: |
912 | 912 | raise ValueError, "Can't convert %s into an element of %s" % (x, self) |
913 | 913 | |
914 | 914 | if hasattr(x, 'parent') and isinstance(x.parent(), InfinitePolynomialRing_sparse): |
… |
… |
|
931 | 931 | # remark: Conversion to self._P (if applicable) |
932 | 932 | # is done in InfinitePolynomial() |
933 | 933 | return InfinitePolynomial(self, x) |
934 | | except: |
| 934 | except StandardError: |
935 | 935 | pass |
936 | 936 | |
937 | 937 | # By now, we can assume that x has a parent, because |
… |
… |
|
940 | 940 | # If it isn't a polynomial (duck typing: we need |
941 | 941 | # the variables attribute), we fall back to using strings |
942 | 942 | if not hasattr(x,'variables'): |
943 | | try: |
| 943 | try: |
944 | 944 | return sage_eval(repr(x), self.gens_dict()) |
945 | | except: |
| 945 | except StandardError: |
946 | 946 | raise ValueError, "Can't convert %s into an element of %s" % (x, self) |
947 | 947 | |
948 | 948 | # direct conversion will only be used if the underlying polynomials are libsingular. |
… |
… |
|
1032 | 1032 | # Hence, for being on the safe side, we coerce into a pushout ring: |
1033 | 1033 | x = R(1)*x |
1034 | 1034 | return InfinitePolynomial(self,x) |
1035 | | except: |
| 1035 | except StandardError: |
1036 | 1036 | # OK, last resort, to be on the safe side |
1037 | 1037 | try: |
1038 | 1038 | return sage_eval(repr(x), self._gens_dict) |
… |
… |
|
1087 | 1087 | # try to find the correct base ring in other ways: |
1088 | 1088 | try: |
1089 | 1089 | o = B.one_element()*R.one_element() |
1090 | | except: |
| 1090 | except StandardError: |
1091 | 1091 | raise TypeError, "We can't tensor with "+repr(R) |
1092 | 1092 | return InfinitePolynomialRing(o.parent(), self._names, self._order, implementation='sparse') |
1093 | 1093 | |
… |
… |
|
1587 | 1587 | # try to find the correct base ring in other ways: |
1588 | 1588 | try: |
1589 | 1589 | o = B.one_element()*R.one_element() |
1590 | | except: |
| 1590 | except StandardError: |
1591 | 1591 | raise TypeError, "We can't tensor with "+repr(R) |
1592 | 1592 | return InfinitePolynomialRing(o.parent(), self._names, self._order, implementation='dense') |
1593 | 1593 | |
-
diff --git a/sage/rings/polynomial/pbori.pyx b/sage/rings/polynomial/pbori.pyx
a
|
b
|
|
944 | 944 | |
945 | 945 | try: |
946 | 946 | i = int(other) |
947 | | except: |
| 947 | except StandardError: |
948 | 948 | raise TypeError, "cannot convert %s to BooleanPolynomial"%(type(other)) |
949 | 949 | |
950 | 950 | i = i % 2 |
… |
… |
|
4662 | 4662 | if PY_TYPE_CHECK(x, BooleanPolynomial): |
4663 | 4663 | return result.lm() |
4664 | 4664 | return result |
4665 | | except: |
| 4665 | except StandardError: |
4666 | 4666 | raise TypeError, "Cannot convert to Boolean Monomial %s"%(str(type(x))) |
4667 | 4667 | |
4668 | 4668 | cdef class VariableConstruct: |
… |
… |
|
7774 | 7774 | if PY_TYPE_CHECK(arg, BooleanPolynomial): |
7775 | 7775 | return result.lm() |
7776 | 7776 | return result |
7777 | | except: |
| 7777 | except StandardError: |
7778 | 7778 | raise TypeError, \ |
7779 | 7779 | "Cannot %s convert to Boolean Monomial"%(str(type(arg))) |
7780 | 7780 | |
-
diff --git a/sage/rings/polynomial/polynomial_ring.py b/sage/rings/polynomial/polynomial_ring.py
a
|
b
|
|
394 | 394 | self._singular_().set_ring() |
395 | 395 | try: |
396 | 396 | return x.sage_poly(self) |
397 | | except: |
| 397 | except StandardError: |
398 | 398 | raise TypeError, "Unable to coerce singular object" |
399 | 399 | elif isinstance(x , str): |
400 | 400 | try: |
-
diff --git a/sage/rings/polynomial/symmetric_ideal.py b/sage/rings/polynomial/symmetric_ideal.py
a
|
b
|
|
247 | 247 | """ |
248 | 248 | try: |
249 | 249 | return self.reduce(p) == 0 |
250 | | except: |
| 250 | except StandardError: |
251 | 251 | return False |
252 | 252 | |
253 | 253 | def __mul__ (self, other): |
… |
… |
|
953 | 953 | |
954 | 954 | try: # working around one libsingular bug and one libsingular oddity |
955 | 955 | DenseIdeal = [CommonR(P._p) if ((CommonR is P._p.parent()) or CommonR.ngens()!=P._p.parent().ngens()) else CommonR(repr(P._p)) for P in OUT.gens()]*CommonR |
956 | | except: |
| 956 | except StandardError: |
957 | 957 | if report != None: |
958 | 958 | print "working around a libsingular bug" |
959 | 959 | DenseIdeal = [repr(P._p) for P in OUT.gens()]*CommonR |
-
diff --git a/sage/rings/polynomial/term_order.py b/sage/rings/polynomial/term_order.py
a
|
b
|
|
622 | 622 | if not isinstance(name, (tuple,list)): |
623 | 623 | name = name.list() # name may be a matrix |
624 | 624 | name = tuple(name) |
625 | | except: |
| 625 | except StandardError: |
626 | 626 | raise TypeError, "%s is not a valid term order"%(name,) |
627 | 627 | |
628 | 628 | self._blocks = tuple() |
… |
… |
|
640 | 640 | if not isinstance(t, TermOrder): |
641 | 641 | try: |
642 | 642 | t = TermOrder(t,force=True) |
643 | | except: |
| 643 | except StandardError: |
644 | 644 | raise TypeError |
645 | 645 | if t.name() == 'block': |
646 | 646 | blocks = blocks + list(t.blocks()) |
… |
… |
|
1684 | 1684 | if not isinstance(other, TermOrder): |
1685 | 1685 | try: |
1686 | 1686 | other = TermOrder(other, force=True) |
1687 | | except: |
| 1687 | except StandardError: |
1688 | 1688 | return False |
1689 | 1689 | |
1690 | 1690 | return (self._name == other._name # note that length is not considered. |
-
diff --git a/sage/rings/polynomial/toy_variety.py b/sage/rings/polynomial/toy_variety.py
a
|
b
|
|
71 | 71 | else: |
72 | 72 | try: |
73 | 73 | G = B.gens() |
74 | | except: |
| 74 | except StandardError: |
75 | 75 | raise TypeError, "is_triangular wants as input an ideal, or a list of polynomials\n" |
76 | 76 | vars = G[0].parent().gens() |
77 | 77 | n = len(G) |
… |
… |
|
262 | 262 | else: |
263 | 263 | try: |
264 | 264 | G = B.gens() |
265 | | except: |
| 265 | except StandardError: |
266 | 266 | raise TypeError, "triangular_factorization wants as input an ideal, or a list of polynomials\n" |
267 | 267 | # easy cases |
268 | 268 | if len(G)==0: |
… |
… |
|
331 | 331 | else: |
332 | 332 | try: |
333 | 333 | G = B.gens() |
334 | | except: |
| 334 | except StandardError: |
335 | 335 | raise TypeError, "elim_pol wants as input an ideal or a list of polynomials" |
336 | 336 | |
337 | 337 | # setup -- main algorithm |
-
diff --git a/sage/rings/rational.pyx b/sage/rings/rational.pyx
a
|
b
|
|
2287 | 2287 | except AttributeError: |
2288 | 2288 | try: |
2289 | 2289 | return type(n)(self)**n |
2290 | | except: |
| 2290 | except StandardError: |
2291 | 2291 | raise TypeError, "exponent (=%s) must be an integer.\nCoerce your numbers to real or complex numbers first."%n |
2292 | 2292 | |
2293 | 2293 | except OverflowError: |
-
diff --git a/sage/rings/real_lazy.pyx b/sage/rings/real_lazy.pyx
a
|
b
|
|
718 | 718 | """ |
719 | 719 | try: |
720 | 720 | return self.eval(complex) |
721 | | except: |
| 721 | except StandardError: |
722 | 722 | from complex_field import ComplexField |
723 | 723 | return complex(self.eval(ComplexField(53))) |
724 | 724 | |
-
diff --git a/sage/rings/residue_field.pyx b/sage/rings/residue_field.pyx
a
|
b
|
|
855 | 855 | |
856 | 856 | try: |
857 | 857 | return self._F(self._to_vs(x) * self._PBinv) |
858 | | except: pass |
| 858 | except StandardError: pass |
859 | 859 | |
860 | 860 | # Now we do have to work harder...below this point we handle |
861 | 861 | # cases which failed before trac 1951 was fixed. |
-
diff --git a/sage/schemes/elliptic_curves/ell_field.py b/sage/schemes/elliptic_curves/ell_field.py
a
|
b
|
|
657 | 657 | jbase = g.preimage(j) |
658 | 658 | f = g |
659 | 659 | break |
660 | | except: |
| 660 | except StandardError: |
661 | 661 | pass |
662 | 662 | if f == None: |
663 | 663 | return None |
664 | 664 | else: |
665 | 665 | try: |
666 | 666 | jbase = f.preimage(j) |
667 | | except: |
| 667 | except StandardError: |
668 | 668 | return None |
669 | 669 | E = EllipticCurve(j=jbase) |
670 | 670 | E2 = EllipticCurve(self.base_field(), [f(a) for a in E.a_invariants()]) |
… |
… |
|
692 | 692 | if Etwist.is_isomorphic(self): |
693 | 693 | try: |
694 | 694 | Eout = EllipticCurve(K, [f.preimage(a) for a in Etwist.a_invariants()]) |
695 | | except: |
| 695 | except StandardError: |
696 | 696 | return None |
697 | 697 | else: |
698 | 698 | return Eout |
-
diff --git a/sage/schemes/elliptic_curves/ell_finite_field.py b/sage/schemes/elliptic_curves/ell_finite_field.py
a
|
b
|
|
1417 | 1417 | N=self._order |
1418 | 1418 | if debug: |
1419 | 1419 | print "Group order already known to be ",N |
1420 | | except: |
| 1420 | except StandardError: |
1421 | 1421 | if (q<50): |
1422 | 1422 | if debug: |
1423 | 1423 | print "Computing group order naively" |
-
diff --git a/sage/schemes/elliptic_curves/ell_point.py b/sage/schemes/elliptic_curves/ell_point.py
a
|
b
|
|
3211 | 3211 | if ord==None: ord=self.order() |
3212 | 3212 | try: |
3213 | 3213 | return generic.discrete_log(Q,self,ord,operation='+') |
3214 | | except: |
| 3214 | except StandardError: |
3215 | 3215 | raise ValueError, "ECDLog problem has no solution" |
3216 | 3216 | |
3217 | 3217 | |
… |
… |
|
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='+') |
3288 | | except: |
| 3288 | except StandardError: |
3289 | 3289 | if K.is_prime_field(): |
3290 | 3290 | M = E.cardinality() # computed and cached |
3291 | 3291 | plist = M.prime_divisors() |
-
diff --git a/sage/schemes/elliptic_curves/ell_tate_curve.py b/sage/schemes/elliptic_curves/ell_tate_curve.py
a
|
b
|
|
498 | 498 | yy = t + s * C**2 * P[0] + C**3 * P[1] |
499 | 499 | try: |
500 | 500 | Pq = Eq([xx,yy]) |
501 | | except: |
| 501 | except StandardError: |
502 | 502 | raise RuntimeError, "Bug : Point %s does not lie on the curve "%[xx,yy] |
503 | 503 | |
504 | 504 | tt = -xx/yy |
-
diff --git a/sage/schemes/elliptic_curves/gal_reps.py b/sage/schemes/elliptic_curves/gal_reps.py
a
|
b
|
|
1150 | 1150 | misc.verbose("field of degree %s. try to compute galois group"%(d),2) |
1151 | 1151 | try: |
1152 | 1152 | G = K.galois_group() |
1153 | | except: |
| 1153 | except StandardError: |
1154 | 1154 | self.__image_type[p] = "The image is a group of order %s."%d |
1155 | 1155 | return self.__image_type[p] |
1156 | 1156 | |
-
diff --git a/sage/schemes/generic/rational_point.py b/sage/schemes/generic/rational_point.py
a
|
b
|
|
368 | 368 | for c in cartesian_product_iterator([F]*n): |
369 | 369 | try: |
370 | 370 | pts.append(X(c)) |
371 | | except: |
| 371 | except StandardError: |
372 | 372 | pass |
373 | 373 | pts.sort() |
374 | 374 | return pts |
-
diff --git a/sage/server/notebook/cell.py b/sage/server/notebook/cell.py
a
|
b
|
|
1919 | 1919 | except OSError: |
1920 | 1920 | try: |
1921 | 1921 | shutil.rmtree(F) |
1922 | | except: |
| 1922 | except StandardError: |
1923 | 1923 | pass |
1924 | 1924 | |
1925 | 1925 | def version(self): |
-
diff --git a/sage/server/notebook/compress/JavaScriptCompressor.py b/sage/server/notebook/compress/JavaScriptCompressor.py
a
|
b
|
|
212 | 212 | key = 0 |
213 | 213 | try: |
214 | 214 | key = self.__container.index(str) |
215 | | except: |
| 215 | except StandardError: |
216 | 216 | key = len(self.__container) |
217 | 217 | self.__container.append(str) |
218 | 218 | return key |
-
diff --git a/sage/server/notebook/interact.py b/sage/server/notebook/interact.py
a
|
b
|
|
2269 | 2269 | ... try: |
2270 | 2270 | ... x = A\v |
2271 | 2271 | ... html('$$%s %s = %s$$'%(latex(A), latex(x), latex(v))) |
2272 | | ... except: |
| 2272 | ... except StandardError: |
2273 | 2273 | ... html('There is no solution to $$%s x=%s$$'%(latex(A), latex(v))) |
2274 | 2274 | <html>... |
2275 | 2275 | |
… |
… |
|
2521 | 2521 | try: |
2522 | 2522 | x = m\v |
2523 | 2523 | html('$$%s %s = %s$$'%(latex(m), latex(x), latex(v))) |
2524 | | except: |
| 2524 | except StandardError: |
2525 | 2525 | html('There is no solution to $$%s x=%s$$'%(latex(m), latex(v))) |
2526 | 2526 | |
2527 | 2527 | EXAMPLES:: |
-
diff --git a/sage/server/notebook/notebook.py b/sage/server/notebook/notebook.py
a
|
b
|
|
2071 | 2071 | if os.path.exists(dir): |
2072 | 2072 | try: |
2073 | 2073 | nb = load(sobj, compress=False) |
2074 | | except: |
| 2074 | except StandardError: |
2075 | 2075 | backup = '%s/backups/'%dir |
2076 | 2076 | if os.path.exists(backup): |
2077 | 2077 | print "****************************************************************" |
-
diff --git a/sage/server/notebook/sage_email.py b/sage/server/notebook/sage_email.py
a
|
b
|
|
103 | 103 | |
104 | 104 | try: |
105 | 105 | pid = os.fork() |
106 | | except: |
| 106 | except StandardError: |
107 | 107 | print "Fork not possible -- the email command is not supported on this platform." |
108 | 108 | return |
109 | 109 | |
-
diff --git a/sage/server/notebook/twist.py b/sage/server/notebook/twist.py
a
|
b
|
|
2462 | 2462 | |
2463 | 2463 | #child_login = RedirectLogin() |
2464 | 2464 | |
2465 | | # userchild_* is like Twisted's child_, etc. except: |
| 2465 | # userchild_* is like Twisted's child_, etc. except StandardError: |
2466 | 2466 | # (1) it also sets the username in the __init__ method, and |
2467 | 2467 | # (2) it calls the constructor for the object, i.e., it is |
2468 | 2468 | # a class rather than an object. |
-
diff --git a/sage/server/notebook/user.py b/sage/server/notebook/user.py
a
|
b
|
|
57 | 57 | if os.path.exists(history_file): |
58 | 58 | try: |
59 | 59 | self.history = cPickle.load(open(history_file)) |
60 | | except: |
| 60 | except StandardError: |
61 | 61 | print "Error loading history for user %s"%self.__username |
62 | 62 | self.history = [] |
63 | 63 | else: |
-
diff --git a/sage/server/notebook/worksheet.py b/sage/server/notebook/worksheet.py
a
|
b
|
|
1995 | 1995 | #print "Saving ", self.directory() |
1996 | 1996 | self.save() # make sure the worksheet.txt file is up to date. |
1997 | 1997 | del d['_Worksheet__cells'] |
1998 | | except: |
| 1998 | except StandardError: |
1999 | 1999 | # It is important to catch all exceptions. If |
2000 | 2000 | # *anything* goes wrong here we must catch it or the |
2001 | 2001 | # whole notebook sobj could get messed up, |
… |
… |
|
2719 | 2719 | |
2720 | 2720 | try: |
2721 | 2721 | os.kill(pid, 9) |
2722 | | except: |
| 2722 | except StandardError: |
2723 | 2723 | pass |
2724 | 2724 | |
2725 | 2725 | del self.__sage |
… |
… |
|
3352 | 3352 | try: |
3353 | 3353 | cell = completions[r + l*c] |
3354 | 3354 | row.append(cell) |
3355 | | except: |
| 3355 | except StandardError: |
3356 | 3356 | pass |
3357 | 3357 | rows.append(row) |
3358 | 3358 | return format_completions_as_html(id, rows) |
… |
… |
|
4115 | 4115 | a, b = v.strip().split('=') |
4116 | 4116 | try: |
4117 | 4117 | b = eval(b) |
4118 | | except: |
| 4118 | except StandardError: |
4119 | 4119 | pass |
4120 | 4120 | w.append([a, b]) |
4121 | 4121 | except ValueError: |
-
diff --git a/sage/server/support.py b/sage/server/support.py
a
|
b
|
|
274 | 274 | try: |
275 | 275 | try: |
276 | 276 | return obj._sage_src_() |
277 | | except: |
| 277 | except StandardError: |
278 | 278 | pass |
279 | 279 | newline = "\n\n" # blank line to start new paragraph |
280 | 280 | indent = " " # indent source code to mark it as a code block |
-
diff --git a/sage/structure/category_object.pyx b/sage/structure/category_object.pyx
a
|
b
|
|
73 | 73 | return Algebras(obj._base) |
74 | 74 | else: |
75 | 75 | return Rings() |
76 | | except: |
| 76 | except StandardError: |
77 | 77 | pass |
78 | 78 | from sage.structure.parent import Parent |
79 | 79 | #if isinstance(obj, Parent): |
-
diff --git a/sage/structure/coerce.pyx b/sage/structure/coerce.pyx
a
|
b
|
|
641 | 641 | pass |
642 | 642 | try: |
643 | 643 | ret = parent_c(~parent.one_element()) |
644 | | except: |
| 644 | except StandardError: |
645 | 645 | self._record_exception() |
646 | 646 | ret = parent_c(~parent.an_element()) |
647 | 647 | self._division_parents.set(parent, None, None, ret) |
… |
… |
|
927 | 927 | if is_Integer(x) and not x and not PY_TYPE_CHECK_EXACT(yp, type): |
928 | 928 | try: |
929 | 929 | return yp(0), y |
930 | | except: |
| 930 | except StandardError: |
931 | 931 | self._record_exception() |
932 | 932 | |
933 | 933 | if is_Integer(y) and not y and not PY_TYPE_CHECK_EXACT(xp, type): |
934 | 934 | try: |
935 | 935 | return x, xp(0) |
936 | | except: |
| 936 | except StandardError: |
937 | 937 | self._record_exception() |
938 | 938 | |
939 | 939 | raise TypeError, "no common canonical parent for objects with parents: '%s' and '%s'"%(xp, yp) |
… |
… |
|
1169 | 1169 | if coerce_S is None: |
1170 | 1170 | raise TypeError, "No coercion from %s to pushout %s" % (S, Z) |
1171 | 1171 | return coerce_R, coerce_S |
1172 | | except: |
| 1172 | except StandardError: |
1173 | 1173 | self._record_exception() |
1174 | 1174 | |
1175 | 1175 | return None |
-
diff --git a/sage/structure/coerce_maps.pyx b/sage/structure/coerce_maps.pyx
a
|
b
|
|
34 | 34 | cpdef Element _call_(self, x): |
35 | 35 | try: |
36 | 36 | return self._codomain._element_constructor(self._codomain, x) |
37 | | except: |
| 37 | except StandardError: |
38 | 38 | if print_warnings: |
39 | 39 | print type(self._codomain), self._codomain |
40 | 40 | print type(self._codomain._element_constructor), self._codomain._element_constructor |
… |
… |
|
53 | 53 | return self._codomain._element_constructor(self._codomain, x, *args) |
54 | 54 | else: |
55 | 55 | return self._codomain._element_constructor(self._codomain, x, *args, **kwds) |
56 | | except: |
| 56 | except StandardError: |
57 | 57 | if print_warnings: |
58 | 58 | print type(self._codomain), self._codomain |
59 | 59 | print type(self._codomain._element_constructor), self._codomain._element_constructor |
… |
… |
|
75 | 75 | cpdef Element _call_(self, x): |
76 | 76 | try: |
77 | 77 | return self._codomain._element_constructor(x) |
78 | | except: |
| 78 | except StandardError: |
79 | 79 | if print_warnings: |
80 | 80 | print type(self._codomain), self._codomain |
81 | 81 | print type(self._codomain._element_constructor), self._codomain._element_constructor |
… |
… |
|
93 | 93 | return self._codomain._element_constructor(x, *args) |
94 | 94 | else: |
95 | 95 | return self._codomain._element_constructor(x, *args, **kwds) |
96 | | except: |
| 96 | except StandardError: |
97 | 97 | if print_warnings: |
98 | 98 | print type(self._codomain), self._codomain |
99 | 99 | print type(self._codomain._element_constructor), self._codomain._element_constructor |
… |
… |
|
261 | 261 | y = self._func(self._codomain, x) |
262 | 262 | else: |
263 | 263 | y = self._func(x) |
264 | | except: |
| 264 | except StandardError: |
265 | 265 | if print_warnings: |
266 | 266 | print self._func |
267 | 267 | print self._codomain |
… |
… |
|
297 | 297 | y = self._func(self._codomain, x, *args, **kwds) |
298 | 298 | else: |
299 | 299 | y = self._func(x, *args, **kwds) |
300 | | except: |
| 300 | except StandardError: |
301 | 301 | if print_warnings: |
302 | 302 | print self._func |
303 | 303 | print self._codomain |
-
diff --git a/sage/structure/element.pyx b/sage/structure/element.pyx
a
|
b
|
|
3356 | 3356 | return a.parent().one() |
3357 | 3357 | except AttributeError: |
3358 | 3358 | return type(a)(1) |
3359 | | except: |
| 3359 | except StandardError: |
3360 | 3360 | return 1 #oops, the one sucks |
3361 | 3361 | else: |
3362 | 3362 | return one |
-
diff --git a/sage/structure/factorization.py b/sage/structure/factorization.py
a
|
b
|
|
420 | 420 | return cmp(type(self), type(other)) |
421 | 421 | try: |
422 | 422 | return cmp(self.value(), other.value()) |
423 | | except: |
| 423 | except StandardError: |
424 | 424 | c = cmp(self.__unit, other.__unit) |
425 | 425 | if c: return c |
426 | 426 | return list.__cmp__(self, other) |
… |
… |
|
583 | 583 | """ |
584 | 584 | try: |
585 | 585 | return self.universe().is_commutative() |
586 | | except: |
| 586 | except StandardError: |
587 | 587 | # This is not the mathematically correct default, but agrees with |
588 | 588 | # history -- we've always assumed factored things commute |
589 | 589 | return True |
-
diff --git a/sage/structure/parent.pyx b/sage/structure/parent.pyx
a
|
b
|
|
1258 | 1258 | if is_Integer(x) and not x: |
1259 | 1259 | try: |
1260 | 1260 | return self(0) |
1261 | | except: |
| 1261 | except StandardError: |
1262 | 1262 | _record_exception() |
1263 | 1263 | raise TypeError("no canonical coercion from %s to %s" % (parent_c(x), self)) |
1264 | 1264 | else: |
… |
… |
|
2643 | 2643 | return super(Parent, self)._an_element_() |
2644 | 2644 | except EmptySetError: |
2645 | 2645 | raise |
2646 | | except: |
| 2646 | except StandardError: |
2647 | 2647 | _record_exception() |
2648 | 2648 | pass |
2649 | 2649 | |
2650 | 2650 | try: |
2651 | 2651 | return self.gen(0) |
2652 | | except: |
| 2652 | except StandardError: |
2653 | 2653 | _record_exception() |
2654 | 2654 | pass |
2655 | 2655 | |
2656 | 2656 | try: |
2657 | 2657 | return self.gen() |
2658 | | except: |
| 2658 | except StandardError: |
2659 | 2659 | _record_exception() |
2660 | 2660 | pass |
2661 | 2661 | |
-
diff --git a/sage/structure/parent_old.pyx b/sage/structure/parent_old.pyx
a
|
b
|
|
362 | 362 | check_old_coerce(self) |
363 | 363 | try: |
364 | 364 | return self.gen(0) |
365 | | except: |
| 365 | except StandardError: |
366 | 366 | pass |
367 | 367 | |
368 | 368 | try: |
369 | 369 | return self.gen() |
370 | | except: |
| 370 | except StandardError: |
371 | 371 | pass |
372 | 372 | |
373 | 373 | from sage.rings.infinity import infinity |
-
diff --git a/sage/structure/sage_object.pyx b/sage/structure/sage_object.pyx
a
|
b
|
|
367 | 367 | except NotImplementedError: |
368 | 368 | # It would be best to make sure that this NotImplementedError was triggered by AbstractMethod |
369 | 369 | tester.fail("Not implemented method: %s"%name) |
370 | | except: |
| 370 | except StandardError: |
371 | 371 | pass |
372 | 372 | |
373 | 373 | def _test_pickling(self, **options): |
… |
… |
|
433 | 433 | else: |
434 | 434 | try: |
435 | 435 | s = self._interface_init_(I) |
436 | | except: |
| 436 | except StandardError: |
437 | 437 | raise NotImplementedError, "coercion of object %s to %s not implemented:\n%s\n%s"%\ |
438 | 438 | (repr(self), I) |
439 | 439 | X = I(s) |
-
diff --git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
a
|
b
|
|
3229 | 3229 | else: |
3230 | 3230 | B=[A[0],SR(A[1])] |
3231 | 3231 | B.append(Integer(A[len(A)-1])) |
3232 | | except: |
| 3232 | except StandardError: |
3233 | 3233 | raise NotImplementedError, "Wrong arguments passed to taylor. See taylor? for more details." |
3234 | 3234 | l = self._maxima_().taylor(B) |
3235 | 3235 | return self.parent()(l) |
… |
… |
|
8282 | 8282 | from sage.symbolic.relation import solve_ineq |
8283 | 8283 | try: |
8284 | 8284 | return(solve_ineq(self)) # trying solve_ineq_univar |
8285 | | except: |
| 8285 | except StandardError: |
8286 | 8286 | pass |
8287 | 8287 | try: |
8288 | 8288 | return(solve_ineq([self])) # trying solve_ineq_fourier |
8289 | | except: |
| 8289 | except StandardError: |
8290 | 8290 | raise NotImplementedError, "solving only implemented for equalities and few special inequalities, see solve_ineq" |
8291 | 8291 | ex = self |
8292 | 8292 | else: |
… |
… |
|
8358 | 8358 | s = m.to_poly_solve(x) |
8359 | 8359 | T = string_to_list_of_solutions(repr(s)) |
8360 | 8360 | X = [t[0] for t in T] |
8361 | | except: # if that gives an error, stick with no solutions |
| 8361 | except StandardError: # if that gives an error, stick with no solutions |
8362 | 8362 | X = [] |
8363 | 8363 | |
8364 | 8364 | for eq in X: |
-
diff --git a/sage/symbolic/function.pyx b/sage/symbolic/function.pyx
a
|
b
|
|
416 | 416 | else: |
417 | 417 | try: |
418 | 418 | nargs[i] = SR.coerce(carg) |
419 | | except: |
| 419 | except StandardError: |
420 | 420 | raise TypeError, "cannot coerce arguments: %s"%(err) |
421 | 421 | args = nargs |
422 | 422 | else: # coerce == False |
-
diff --git a/sage/symbolic/pynac.pyx b/sage/symbolic/pynac.pyx
a
|
b
|
|
922 | 922 | cdef public bint py_is_even(object x) except +: |
923 | 923 | try: |
924 | 924 | return not(x%2) |
925 | | except: |
| 925 | except StandardError: |
926 | 926 | try: |
927 | 927 | return not(ZZ(x)%2) |
928 | | except: |
| 928 | except StandardError: |
929 | 929 | pass |
930 | 930 | return 0 |
931 | 931 | |
… |
… |
|
968 | 968 | cdef public bint py_is_prime(object n) except +: |
969 | 969 | try: |
970 | 970 | return n.is_prime() |
971 | | except: # yes, I'm doing this on purpose. |
| 971 | except StandardError: # yes, I'm doing this on purpose. |
972 | 972 | pass |
973 | 973 | try: |
974 | 974 | return sage.rings.arith.is_prime(n) |
975 | | except: |
| 975 | except StandardError: |
976 | 976 | pass |
977 | 977 | return False |
978 | 978 | |
-
diff --git a/sage/symbolic/relation.py b/sage/symbolic/relation.py
a
|
b
|
|
423 | 423 | if repr( f() ).strip() == "0": |
424 | 424 | return True |
425 | 425 | break |
426 | | except: |
| 426 | except StandardError: |
427 | 427 | pass |
428 | 428 | return False |
429 | 429 | |
… |
… |
|
690 | 690 | |
691 | 691 | try: |
692 | 692 | s = m.solve(variables) |
693 | | except: # if Maxima gave an error, try its to_poly_solve |
| 693 | except StandardError: # if Maxima gave an error, try its to_poly_solve |
694 | 694 | try: |
695 | 695 | s = m.to_poly_solve(variables) |
696 | 696 | except TypeError, mess: # if that gives an error, raise an error. |
… |
… |
|
702 | 702 | if len(s)==0: # if Maxima's solve gave no solutions, try its to_poly_solve |
703 | 703 | try: |
704 | 704 | s = m.to_poly_solve(variables) |
705 | | except: # if that gives an error, stick with no solutions |
| 705 | except StandardError: # if that gives an error, stick with no solutions |
706 | 706 | s = [] |
707 | 707 | |
708 | 708 | if len(s)==0: # if to_poly_solve gave no solutions, try use_grobner |
709 | 709 | try: |
710 | 710 | s = m.to_poly_solve(variables,'use_grobner=true') |
711 | | except: # if that gives an error, stick with no solutions |
| 711 | except StandardError: # if that gives an error, stick with no solutions |
712 | 712 | s = [] |
713 | 713 | |
714 | 714 | sol_list = string_to_list_of_solutions(repr(s)) |
-
diff --git a/setup.py b/setup.py
a
|
b
|
|
823 | 823 | ## f = open(CYTHON_DEPS_FILE) |
824 | 824 | ## deps = pickle.load(open(CYTHON_DEPS_FILE)) |
825 | 825 | ## f.close() |
826 | | ## except: |
| 826 | ## except StandardError: |
827 | 827 | ## deps = DependencyTree() |
828 | 828 | deps = DependencyTree() |
829 | 829 | queue = compile_command_list(ext_modules, deps) |