On Saturday, January 31, 2015 at 9:15:33 AM UTC-8, vdelecroix wrote: > > I found out where it is. The Interface objects inherits from > ParentWithBasis and the base is itself... > > sage: p = Gp() > sage: p._base is p > True > Hm, that's a problem. Parent objects are virtually always involved in cyclic references (e.g., rings will hold references to "zero" and "one" objects which, being elements, refer back to the ring). So trying to eliminate circular references will be hard/futile. Does Gp need to inherit from parent? almost certainly, I guess ...
So we need to make our expect interface wrappers deletable in the presence of circular references. One solution is to upgrade to Python 3. Another is to put all the "__del__" code into a separate object that the "parent" object holds a reference to, but that itself does not refer to the parent. Then the __del__-equipped object is not involved in a cycle. Since the standard del tries to call self.quit(), it would require a significant bit of refactoring. Plus, ParentWithBase is deprecated. So perhaps we should go for a quick fix anyway: self._base seems to be the only self-reference, so: --- a/src/sage/interfaces/interface.py +++ b/src/sage/interfaces/interface.py @@ -59,7 +59,7 @@ class Interface(ParentWithBase): self.__coerce_name = '_' + name.lower() + '_' self.__seq = -1 self._available_vars = [] - ParentWithBase.__init__(self, self) + ParentWithBase.__init__(self, None) might be an acceptable solution for now. Having "__del__" methods in sage is always risky, because many structures end up having cycles. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.