Ticket #11239: trac_11239-polynomial_coercion_preliminary.patch

File trac_11239-polynomial_coercion_preliminary.patch, 1.7 KB (added by pbruin, 6 years ago)

update (old version had bogus doctest fix)

  • sage/rings/polynomial/polynomial_ring.py

    # HG changeset patch
    # User Peter Bruin <peter.bruin@math.uzh.ch>
    # Date 1375728721 -7200
    # Node ID c207130fe25465501d8bcb45b7751a346751c0a1
    # Parent  bd180d3628471439bec614b2c38e7f3997c1263e
    Trac 11239: fix coercion of polynomials over finite fields, first step 
    
    diff --git a/sage/rings/polynomial/polynomial_ring.py b/sage/rings/polynomial/polynomial_ring.py
    a b  
    369369            ...
    370370            TypeError: Unable to convert x (='1.00...00*I') to real number.
    371371
     372        Check that the bug in :trac:`11239` is fixed::
     373
     374            sage: K.<a> = GF(5^2, conway=True, prefix='z')
     375            sage: L.<b> = GF(5^4, conway=True, prefix='z')
     376            sage: f = K['x'].gen() + a
     377            sage: L['x'](f)
     378            x + b^3 + b^2 + b + 3
     379
    372380        """
    373381        C = self._polynomial_class
    374382        if isinstance(x, list):
     
    391399            elif P == self.base_ring():
    392400                return C(self, [x], check=True, is_gen=False,
    393401                         construct=construct)
    394                
    395402            elif self.base_ring().has_coerce_map_from(P):
    396403                return C(self, [x], check=True, is_gen=False,
    397404                        construct=construct)
    398         try: #if hasattr(x, '_polynomial_'):
    399             return x._polynomial_(self)
    400         except AttributeError:
    401             pass
     405            elif self.has_coerce_map_from(P):
     406                return C(self, x, check=True, is_gen=False,
     407                         construct=construct)
    402408        if isinstance(x, SingularElement) and self._has_singular:
    403409            self._singular_().set_ring()
    404410            try: