Ticket #7718: 7718.patch

File 7718.patch, 1.3 KB (added by roed, 11 years ago)
  • sage/structure/coerce_actions.pyx

    # HG changeset patch
    # User David Roe <roed@math.harvard.edu>
    # Date 1261035305 18000
    # Node ID e498852f3b83caa1671c8a873ba84d867ea49358
    # Parent  964c2f4ce74db0417a771de0b0cfc951b1fab73c
    Fixes a segfault caused by a failure to check whether certain variables are None.
    
    diff -r 964c2f4ce74d -r e498852f3b83 sage/structure/coerce_actions.pyx
    a b  
    159159        (None,)
    160160        sage: detect_element_action(ZZ, QQ, True),
    161161        (None,)
     162
     163    TESTS:
     164
     165    This test checks that the issue in Trac #7718 has been fixed::
     166
     167        sage: class MyParent(Parent):
     168        ...    def an_element(self):
     169        ...        pass
     170        ...
     171        sage: A = MyParent()
     172        sage: detect_element_action(A, ZZ, True)
     173        Traceback (most recent call last):
     174        ...
     175        RuntimeError: an_element() returned None
    162176    """
    163177    cdef Element x = X.an_element()
    164178    cdef Element y = Y.an_element()
     179    if x is None or y is None:
     180        raise RuntimeError, "an_element() returned None"
    165181    if isinstance(x, ModuleElement) and isinstance(y, RingElement):
    166182        # Elements defining _lmul_ and _rmul_
    167183        try: