Ticket #11339: trac_11339_illegal_use_of__deallocate__in_libsingular.patch

File trac_11339_illegal_use_of__deallocate__in_libsingular.patch, 2.4 KB (added by vbraun, 10 years ago)

Initial patch

  • sage/libs/singular/groebner_strategy.pxd

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1308382532 25200
    # Node ID 98384e23365ea358ca371706cafe542f4a60d084
    # Parent  f625708936ab3db040ebe54bad2faf5c441c38b7
    Trac #11339: Illegal use of __deallocate__ in cython (pyx) code
    
    The __deallocate__() method must not reference any class attributes
    that are Python objects, only C/C++ attributes are allowed. This patch
    adds a pointer to the GroebnerStrategy._parent._ring C data structure
    which will be legal to access in GroebnerStrategy.__deallocate__()
    even when GroebnerStrategy._parent has been cleared by the garbage
    collector.
    
    diff --git a/sage/libs/singular/groebner_strategy.pxd b/sage/libs/singular/groebner_strategy.pxd
    a b  
    1 from sage.libs.singular.decl cimport skStrategy
     1from sage.libs.singular.decl cimport skStrategy, ring
    22
    33from sage.rings.polynomial.multi_polynomial_libsingular cimport MPolynomialRing_libsingular, MPolynomial_libsingular
    44from sage.structure.sage_object cimport SageObject
     
    66
    77cdef class GroebnerStrategy(SageObject):
    88    cdef skStrategy *_strat
     9    cdef ring *_parent_ring
    910    cdef MPolynomialRing_libsingular _parent
    1011    cdef object _ideal
    1112
  • sage/libs/singular/groebner_strategy.pyx

    diff --git a/sage/libs/singular/groebner_strategy.pyx b/sage/libs/singular/groebner_strategy.pyx
    a b  
    4242
    4343    Uses Singular via libSINGULAR
    4444    """
     45   
    4546    def __init__(self, L):
    4647        """
    4748        Create a new :class:`GroebnerStrategy` object for the
     
    100101
    101102        cdef MPolynomialRing_libsingular R = <MPolynomialRing_libsingular>L.ring()
    102103        self._parent = R
     104        self._parent_ring = R._ring
    103105
    104106        if not R.term_order().is_global():
    105107            raise NotImplementedError("The local case is not implemented yet.")
     
    154156            omfree(self._strat.fromQ)
    155157            id_Delete(&self._strat.Shdl, self._parent._ring)
    156158
    157             if self._parent._ring != currRing:
     159            if self._parent_ring != currRing:
    158160                oldRing = currRing
    159                 rChangeCurrRing(self._parent._ring)
     161                rChangeCurrRing(self._parent_ring)
    160162                delete_skStrategy(self._strat)
    161163                rChangeCurrRing(oldRing)
    162164            else: