# HG changeset patch
# User Simon King <simon.king@uni-jena.de>
# Date 1369144471 -7200
# Node ID 12b2b39a39cdc741520e270f7546815db71684ba
# Parent d972add21785a473d6144c850fafff39caf69fe9
#14249: Fix some doc formatting, and use Python 3 style errors
diff --git a/sage/structure/coerce_actions.pyx b/sage/structure/coerce_actions.pyx
a
|
b
|
|
174 | 174 | This test checks that the issue in :trac:`7718` has been fixed:: |
175 | 175 | |
176 | 176 | sage: class MyParent(Parent): |
177 | | ... def an_element(self): |
178 | | ... pass |
179 | | ... |
| 177 | ....: def an_element(self): |
| 178 | ....: pass |
| 179 | ....: |
180 | 180 | sage: A = MyParent() |
181 | 181 | sage: detect_element_action(A, ZZ, True) |
182 | 182 | Traceback (most recent call last): |
… |
… |
|
189 | 189 | else: |
190 | 190 | x = X_el |
191 | 191 | if x is None: |
192 | | raise RuntimeError, "an_element() for %s returned None" % X |
| 192 | raise RuntimeError("an_element() for %s returned None" % X) |
193 | 193 | if Y_el is None or (parent_c(Y_el) is not Y): |
194 | 194 | y = an_element(Y) |
195 | 195 | else: |
196 | 196 | y = Y_el |
197 | 197 | if y is None: |
198 | 198 | if isinstance(Y, Parent): |
199 | | raise RuntimeError, "an_element() for %s returned None" % Y |
| 199 | raise RuntimeError("an_element() for %s returned None" % Y) |
200 | 200 | else: |
201 | 201 | return # don't know how to make elements of this type... |
202 | 202 | if isinstance(x, ModuleElement) and isinstance(y, RingElement): |
… |
… |
|
329 | 329 | if g is None: |
330 | 330 | g = G.an_element() |
331 | 331 | if parent_c(g) is not G: |
332 | | raise CoercionException,"The parent of %s is not %s but %s"%(g,G,parent_c(g)) |
| 332 | raise CoercionException("The parent of %s is not %s but %s"%(g,G,parent_c(g))) |
333 | 333 | if a is None: |
334 | 334 | a = S.an_element() |
335 | 335 | if parent_c(a) is not S: |
336 | | raise CoercionException,"The parent of %s is not %s but %s"%(a,S,parent_c(a)) |
| 336 | raise CoercionException("The parent of %s is not %s but %s"%(a,S,parent_c(a))) |
337 | 337 | if not isinstance(g, RingElement) or not isinstance(a, ModuleElement): |
338 | | raise CoercionException, "Not a ring element acting on a module element." |
| 338 | raise CoercionException("Not a ring element acting on a module element.") |
339 | 339 | res = self.act(g, a) |
340 | 340 | if parent_c(res) is not the_set: |
341 | 341 | # In particular we will raise an error if res is None |
342 | | raise CoercionException, "Result is None or has wrong parent." |
| 342 | raise CoercionException("Result is None or has wrong parent.") |
343 | 343 | |
344 | 344 | |
345 | 345 | def _repr_name_(self): |
diff --git a/sage/structure/parent.pyx b/sage/structure/parent.pyx
a
|
b
|
|
64 | 64 | |
65 | 65 | sage: from sage.structure.element import RingElement |
66 | 66 | sage: class MyElement(RingElement): |
67 | | ... def __init__(self, x,y, parent = None): |
68 | | ... RingElement.__init__(self, parent) |
69 | | ... def _mul_(self, other): |
70 | | ... return self |
71 | | ... def _rmul_(self, other): |
72 | | ... return self |
73 | | ... def _lmul_(self, other): |
74 | | ... return self |
| 67 | ....: def __init__(self, x,y, parent = None): |
| 68 | ....: RingElement.__init__(self, parent) |
| 69 | ....: def _mul_(self, other): |
| 70 | ....: return self |
| 71 | ....: def _rmul_(self, other): |
| 72 | ....: return self |
| 73 | ....: def _lmul_(self, other): |
| 74 | ....: return self |
75 | 75 | sage: class MyParent(Parent): |
76 | | ... Element = MyElement |
77 | | |
78 | | Now, we define |
| 76 | ....: Element = MyElement |
| 77 | |
| 78 | Now, we define :: |
79 | 79 | |
80 | 80 | sage: P = MyParent(base=ZZ, category=Rings()) |
81 | 81 | sage: a = P(1,2) |