exporting patch:
# HG changeset patch
# User Julian Rüth <julian.rueth@gmail.com>
# Date 1309281507 7200
# Node ID 58c4d3f474221e7cdd8c5eab1d2fda05febcbdcf
# Parent e515debf2b340e3d58cb352452503702b39e4385
Trac 9054: treat zero correctly
diff r e515debf2b34 r 58c4d3f47422 sage/rings/function_field/function_field_element.pyx
a

b


215  215  <type 'sage.rings.function_field.function_field_element.FunctionFieldElement_polymod'> 
216  216  """ 
217  217  FieldElement.__init__(self, parent) 
218   self._x = x 
 218  self._x = x % self._parent.polynomial() 
219  219  
220  220  def element(self): 
221  221  """ 
… 
… 

251  251  True 
252  252  sage: bool(L(0)) 
253  253  False 
 254  sage: bool(L.coerce(L.polynomial())) 
 255  False 
254  256  """ 
255  257  return not not self._x 
256  258  
… 
… 

275  277  sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2  x*y + 4*x^3) 
276  278  sage: (2*Y + x/(1+x^3)) + (3*Y + 5*x*Y) # indirect doctest 
277  279  (5*x + 5)*Y + x/(x^3 + 1) 
 280  sage: (Y^2  x*Y + 4*x^3)==0 # indirect doctest 
 281  True 
278  282  """ 
279  283  cdef FunctionFieldElement res = self._new_c() 
280  284  res._x = self._x + (<FunctionFieldElement>right)._x 
… 
… 

311  315  sage: K.<x> = FunctionField(QQ); R.<y> = K[]; L.<Y> = K.extension(y^2  x*y + 4*x^3) 
312  316  sage: (2*Y + x/(1+x^3)) / (2*Y + x/(1+x^3)) # indirect doctest 
313  317  1 
 318  sage: 1 / (Y^2  x*Y + 4*x^3) # indirect doctest 
 319  Traceback (most recent call last): 
 320  ... 
 321  ZeroDivisionError: Cannot invert 0 
314  322  """ 
315  323  return self * ~right 
316  324  
… 
… 

324  332  sage: a*(2*Y + 1/x) 
325  333  1 
326  334  """ 
 335  if self.is_zero(): 
 336  raise ZeroDivisionError, "Cannot invert 0" 
327  337  P = self._parent 
328  338  return P(self._x.xgcd(P._polynomial)[1]) 
329  339  