# 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


369  369  ... 
370  370  TypeError: Unable to convert x (='1.00...00*I') to real number. 
371  371  
 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  
372  380  """ 
373  381  C = self._polynomial_class 
374  382  if isinstance(x, list): 
… 
… 

391  399  elif P == self.base_ring(): 
392  400  return C(self, [x], check=True, is_gen=False, 
393  401  construct=construct) 
394   
395  402  elif self.base_ring().has_coerce_map_from(P): 
396  403  return C(self, [x], check=True, is_gen=False, 
397  404  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) 
402  408  if isinstance(x, SingularElement) and self._has_singular: 
403  409  self._singular_().set_ring() 
404  410  try: 