Ticket #9880: trac_9880-fix_comparison-p1.rebased-5.5.rc0.patch

File trac_9880-fix_comparison-p1.rebased-5.5.rc0.patch, 4.0 KB (added by burcin, 9 years ago)
  • sage/libs/ginac.pxd

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1308337530 25200
    # Node ID 64c7960d7ab80fa5bc77a00d00f8dc51c7aaeb77
    # Parent  654539ac75fb05f46dcf318d2887c4faba46542a
    Trac #9880: Fix for the x._cmp_add(1) crash.
    
    diff --git a/sage/libs/ginac.pxd b/sage/libs/ginac.pxd
    a b  
    535535cdef extern from "pynac/order.h":
    536536    bint print_order_compare "GiNaC::print_order().compare" \
    537537            (GEx left, GEx right) except +
     538    bint print_order_compare_mul "GiNaC::print_order_mul().compare" \
     539            (GEx left, GEx right) except +
    538540    bint print_order "GiNaC::print_order()" \
    539541            (GEx left, GEx right) except +
    540542    bint print_order_mul "GiNaC::print_order_mul()" \
  • sage/symbolic/expression.pxd

    diff --git a/sage/symbolic/expression.pxd b/sage/symbolic/expression.pxd
    a b  
    1212    cpdef bint is_infinity(self)
    1313    cpdef object pyobject(self)
    1414    cpdef Expression _subs_expr(self, expr)
    15     cpdef int _cmp_add(left, CommutativeRingElement right) except -2
    16     cpdef int _cmp_mul(left, CommutativeRingElement right) except -2
     15    cpdef int _cmp_add(Expression left, Expression right) except -2
     16    cpdef int _cmp_mul(Expression left, Expression right) except -2
    1717   
    1818cpdef bint is_Expression(x)
    1919cdef Expression new_Expression_from_GEx(parent, GEx juice)
  • sage/symbolic/expression.pyx

    diff --git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
    a b  
    28622862        return (<Element>left)._cmp(right)
    28632863
    28642864    cdef int _cmp_c_impl(left, Element right) except -2:
    2865         return -print_order_compare((<Expression>right)._gobj,left._gobj)
    2866 
    2867     cpdef int _cmp_add(left, CommutativeRingElement right) except -2:
    2868         return print_order(left._gobj,(<Expression>right)._gobj)
    2869 
    2870     cpdef int _cmp_mul(left, CommutativeRingElement right) except -2:
    2871         return print_order_mul(left._gobj,(<Expression>right)._gobj)
     2865        """
     2866        Compare ``left`` and ``right``.
     2867
     2868        INPUT:
     2869
     2870        - ``right`` -- A :class:`Expression` instance.
     2871
     2872        OUTPUT:
     2873
     2874        Boolean.
     2875
     2876        EXAMPLES::
     2877
     2878            sage: a = sqrt(3)
     2879            sage: b = x^2+1
     2880            sage: a.__cmp__(b)   # indirect doctest
     2881            -1
     2882        """
     2883        return print_order_compare(left._gobj, (<Expression>right)._gobj)
     2884
     2885    cpdef int _cmp_add(Expression left, Expression right) except -2:
     2886        """
     2887        Compare ``left`` and ``right`` in the print order.
     2888
     2889        INPUT:
     2890
     2891        - ``right`` -- A :class:`Expression` instance.
     2892
     2893        OUTPUT:
     2894
     2895        Boolean.
     2896
     2897        EXAMPLES::
     2898
     2899            sage: a = sqrt(3)
     2900            sage: b = x^2+1
     2901            sage: a._cmp_add(b)
     2902            -1
     2903            sage: b._cmp_add(a)
     2904            1
     2905            sage: b._cmp_add(1)
     2906            Traceback (most recent call last):
     2907            ...
     2908            TypeError: Argument 'right' has incorrect type (expected
     2909            sage.symbolic.expression.Expression, got sage.rings.integer.Integer)
     2910        """
     2911        return print_order_compare(left._gobj, right._gobj)
     2912
     2913    cpdef int _cmp_mul(Expression left, Expression right) except -2:
     2914        """
     2915        Compare ``left`` and ``right`` in the print order for products.
     2916
     2917        INPUT:
     2918
     2919        - ``right`` -- A :class:`Expression` instance.
     2920
     2921        OUTPUT:
     2922
     2923        Boolean.
     2924
     2925        EXAMPLES::
     2926
     2927            sage: a = sqrt(3)
     2928            sage: b = x^2+1
     2929            sage: a._cmp_mul(b)
     2930            -1
     2931            sage: b._cmp_mul(a)
     2932            1
     2933            sage: b._cmp_mul(1)
     2934            Traceback (most recent call last):
     2935            ...
     2936            TypeError: Argument 'right' has incorrect type (expected
     2937            sage.symbolic.expression.Expression, got sage.rings.integer.Integer)
     2938        """
     2939        return print_order_compare_mul(left._gobj, right._gobj)
    28722940
    28732941    def __pow__(self, exp, ignored):
    28742942        """