Message5890

Author zyasoft
Recipients somejan, zyasoft
Date 2010-07-13.03:40:56
SpamBayes Score 6.7675987e-06
Marked as misclassified No
Message-id <1278992458.03.0.528031599368.issue1633@psf.upfronthosting.co.za>
In-reply-to
Content
This is what I would expect, from

Jython 2.5.2b1 (trunk:7076M, Jul 12 2010, 17:46:19) 
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_20

>>> from java.util import HashSet
>>> s = HashSet()    
>>> s.add(s)
True
>>> s.add(s)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: maximum recursion depth exceeded

Python's sets work better here, simply refusing to do this (even for reasons not related to building inadvertent self recursive structures):

>>> s = set()
>>> s.add(s)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: set objects are unhashable

Note that our sets are backed by a ConcurrentHashMap, but it works out the same:

>>> from java.util.concurrent import ConcurrentHashMap as CHM
>>> s = CHM()
>>> s[s] = True
>>> s[s] = True
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: maximum recursion depth exceeded

I don't believe there's really anything to do here except report this to the OpenJDK team. Seg faults in cases like this are really a fault of the JVM. Jython simply catches the StackOverflowError and converts it to the equivalent Python exception (RuntimeError: maximum recursion depth exceeded).
History
Date User Action Args
2010-07-13 03:40:58zyasoftsetmessageid: <1278992458.03.0.528031599368.issue1633@psf.upfronthosting.co.za>
2010-07-13 03:40:58zyasoftsetrecipients: + zyasoft, somejan
2010-07-13 03:40:57zyasoftlinkissue1633 messages
2010-07-13 03:40:56zyasoftcreate