Ticket #9054: trac_9054_maximal_order_member_check.patch

File trac_9054_maximal_order_member_check.patch, 1.3 KB (added by saraedum, 6 years ago)

_element_constructor_ checks that element is in maximal order

  • sage/rings/function_field/function_field_order.py

    exporting patch:
    # HG changeset patch
    # User Julian Rueth <julian.rueth@gmail.com>
    Trac 9054: check that elements are in maximal order
    
    diff --git a/sage/rings/function_field/function_field_order.py b/sage/rings/function_field/function_field_order.py
    index 1616485..d88af0a 100644
    a b class FunctionFieldOrder_rational(PrincipalIdealDomain, FunctionFieldOrder): 
    403403            sage: R.maximal_order()._element_constructor_(y)
    404404            y
    405405        """
    406         # HUGE TODO: have to check that f is really in self!!
    407        
    408406        if f.parent() is self.fraction_field():
     407            if not f.denominator() in self.fraction_field().constant_base_field():
     408                raise ValueError("`%s` is not a member of `%s`"%(f,self))
    409409            f = f.element()
    410         if f.parent() is self._ring:
    411             return function_field_element.FunctionFieldElement_rational(self, f)
    412         return function_field_element.FunctionFieldElement_rational(self, self._ring(f))
     410        from function_field_element import FunctionFieldElement_rational
     411        return FunctionFieldElement_rational(self, self._ring(f))
    413412
    414413##     def polynomial_quotient_ring(self):
    415414##         """