Ticket #14497: 14497-universal_cyclotomic_field_rational_zero.patch

File 14497-universal_cyclotomic_field_rational_zero.patch, 901 bytes (added by mraum, 7 years ago)
  • sage/rings/universal_cyclotomic_field/universal_cyclotomic_field.py

    # HG changeset patch
    # Parent b698ff17f144aef9b51ce6b04337eed6367bdbda
    
    diff --git a/sage/rings/universal_cyclotomic_field/universal_cyclotomic_field.py b/sage/rings/universal_cyclotomic_field/universal_cyclotomic_field.py
    a b  
    12441244                sage: x.parent()
    12451245                Rational Field
    12461246            """
    1247             if self.is_rational():
    1248                 return self.value._monomial_coefficients[(1,0)]
     1247            if self.is_rational() :
     1248                try :
     1249                    return self.value._monomial_coefficients[(1,0)]
     1250                except :
     1251                    return QQ.zero_element()
     1252
    12491253            raise TypeError("No conversion of %s to the rational field QQ."%str(self))
    12501254
    12511255        def _integer_(self):