Ticket #9054: trac_9054_polynomial_base_field.patch

File trac_9054_polynomial_base_field.patch, 1.7 KB (added by saraedum, 6 years ago)

polynomial used for a field extension must be defined over the base field

  • sage/rings/function_field/function_field.py

    exporting patch:
    # HG changeset patch
    # User Julian Rüth <julian.rueth@gmail.com>
    # Date 1307562725 -7200
    # Node ID e515debf2b340e3d58cb352452503702b39e4385
    # Parent  3ff1fea4eb0e943ae478fcf59a159d34b059d8d3
    Trac 9054: polynomial must be defined over the base field
    
    diff -r 3ff1fea4eb0e -r e515debf2b34 sage/rings/function_field/function_field.py
    a b  
    125125            sage: K.extension(y^5 - x^3 - 3*x + x*y)
    126126            Function field in y defined by y^5 + x*y - x^3 - 3*x
    127127
    128 
    129128        A nonintegral defining polynomial::
    130129
    131130            sage: K.<t> = FunctionField(QQ); R.<y> = K[]
     
    137136            sage: K.extension(t*y^3 + (1/t)*y + t^3/(t+1))
    138137            Function field in y defined by t*y^3 + 1/t*y + t^3/(t + 1)
    139138        """
     139        from sage.rings.polynomial.all import is_Polynomial
    140140        if names is None:
    141141            names = f.variable_name()
     142        if not is_Polynomial(f):
     143            raise TypeError, "polynomial must be a polynomial"
     144        if f.parent().base_ring() is not self:
     145            raise ValueError, "The polynomial must be defined over the base field"
    142146        return FunctionField_polymod(f, names)
    143147
    144148    def order_with_basis(self, basis, check=True):
     
    288292        We make another extension of a rational function field::
    289293       
    290294            sage: R2.<t> = FunctionField(QQ); S2.<w> = R2[]
    291             sage: L2.<w> = R.extension((4*w)^2 - (t+1)^3 - 1)
     295            sage: L2.<w> = R2.extension((4*w)^2 - (t+1)^3 - 1)
    292296
    293297        We define a morphism, by givin the images of generators::
    294298