Ticket #12969: trac_12969-avoid_coercion_from_none.patch

File trac_12969-avoid_coercion_from_none.patch, 823 bytes (added by SimonKing, 8 years ago)

Shortcut when searching for a coercion from a type that is no parent (e.g., <str>)

  • sage/structure/parent_old.pyx

    # HG changeset patch
    # User Simon King <simon.king@uni-jena.de>
    # Date 1343120815 -7200
    # Node ID afb456b2a09c07ca5caff5bbe6a1064b9d76fe7b
    # Parent  d6e26a552700b911920c6329546817dd64e601f2
    imported patch trac_12969-avoid_coercion_from_none.patch
    
    diff --git a/sage/structure/parent_old.pyx b/sage/structure/parent_old.pyx
    a b  
    150150        if mor is None and isinstance(S, type):
    151151            #Convert Python types to native Sage types
    152152            sage_type = py_scalar_parent(S)
     153            if sage_type is None:
     154                self._coerce_from_hash[S] = None
     155                return None
    153156            mor = self.coerce_map_from_c(sage_type)
    154157            if mor is not None:
    155158                mor = mor * sage_type.coerce_map_from(S)