Issue2357

classification
Title: Infinite recursion with set subclass
Type: crash Severity: normal
Components: Library Versions: Jython 2.7
Milestone: Jython 2.7.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: jdemoor, zyasoft
Priority: Keywords:

Created on 2015-05-21.05:48:51 by jdemoor, last changed 2015-11-10.16:29:15 by zyasoft.

Messages
msg10071 (view) Author: Julien Demoor (jdemoor) Date: 2015-05-21.05:48:50
The following code fails with an infinite recursion in Jython 2.7. It works well on CPython. The problem is apparent in SQLAlchemy's SortedSet implementation.


class TestSet(set):

    def difference_update(self, other):
        set.difference_update(self, other)
        return self

    __isub__ = difference_update

a = TestSet('a')
print a.difference_update(a) # inifinite recursion
msg10072 (view) Author: Julien Demoor (jdemoor) Date: 2015-05-21.05:55:16
The error occurs in a more general case than above (`other` doesn't need to be `self` or to contain the same members).

class TestSet(set):

    def difference_update(self, other):
        set.difference_update(self, other)
        return self

    __isub__ = difference_update

a = TestSet('a')
print a.difference_update(TestSet('b')) # inifinite recursion
msg10424 (view) Author: Jim Baker (zyasoft) Date: 2015-10-31.16:48:18
Fixed as of https://hg.python.org/jython/rev/a7d1380c4594 - as is often the case, comprehensive testing all possible ways this problem could manifest was more work than actually fixing __isub__/difference_update along with the other failing case of __iand__/intersection_update
History
Date User Action Args
2015-11-10 16:29:15zyasoftsetstatus: pending -> closed
2015-10-31 16:48:18zyasoftsetstatus: open -> pending
nosy: + zyasoft
messages: + msg10424
assignee: zyasoft
milestone: Jython 2.7.2 -> Jython 2.7.1
resolution: accepted -> fixed
2015-10-29 22:40:27zyasoftsetmilestone: Jython 2.7.2
2015-05-21 06:49:37zyasoftsetresolution: accepted
2015-05-21 05:55:16jdemoorsetmessages: + msg10072
2015-05-21 05:48:51jdemoorcreate