Index: C:/eclipse3.2/eclipse/workspace/jython23/src/org/python/modules/_weakref.java =================================================================== --- C:/eclipse3.2/eclipse/workspace/jython23/src/org/python/modules/_weakref.java (revision 3008) +++ C:/eclipse3.2/eclipse/workspace/jython23/src/org/python/modules/_weakref.java (working copy) @@ -121,16 +121,26 @@ public static class GlobalRef extends WeakReference { private Vector references = new Vector(); private int hash; + private boolean hasheable = false; public GlobalRef(PyObject object) { super(object); - hash = object.hashCode(); + saveHash(object); } + public GlobalRef(PyObject object, ReferenceQueue queue) { super(object, queue); - hash = object.hashCode(); + saveHash(object); } + private void saveHash(PyObject object) { + try { + hash = object.hashCode(); + hasheable = true; + } catch (Exception e) { + hasheable = false; + } + } public synchronized void add(AbstractReference ref) { Reference r = new WeakReference(ref); @@ -210,7 +220,13 @@ * Allow GlobalRef's to be used as hashtable keys. */ public int hashCode() { - return hash; + if (hasheable) { + return hash; + } else { + return 0; //XXX: What else can we do? + //GlobalRef objects are stored on hashtable so we + //can't raise an exception here. + } } }