Ticket #13374: trac_13374-test-before-checking-coercion.patch

File trac_13374-test-before-checking-coercion.patch, 799 bytes (added by nbruin, 9 years ago)

First try

  • sage/rings/ring.pyx

    # HG changeset patch
    # User Nils Bruin <nbruin@sfu.ca>
    # Date 1345153735 25200
    # Node ID af89f20808055c9ad6e8f1b84627423a1d7c5ea5
    # Parent  cf77426ac0a141b53e83d83f49870fee4ac63668
    #13374: test appropriateness of argument before calling has_coerce_map_from on it.
    That routine caches, so it's better to e careful with what you feed it.
    
    diff --git a/sage/rings/ring.pyx b/sage/rings/ring.pyx
    a b  
    492492                break
    493493            elif isinstance(first, (list, tuple)):
    494494                gens = first
    495             elif self.has_coerce_map_from(first):
     495            elif first in _Rings and self.has_coerce_map_from(first):
    496496                gens = first.gens() # we have a ring as argument
    497497            else:
    498498                break