Message9952

Author jmadden
Recipients jmadden, stefan.richthofer, zyasoft
Date 2015-04-24.13:24:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1429881883.78.0.621277580217.issue2336@psf.upfronthosting.co.za>
In-reply-to
Content
This patch should be null-safe; it makes the example work at least:

diff -r 95d09ba14aa7 src/org/python/modules/gc.java
--- a/src/org/python/modules/gc.java	Wed Apr 15 18:34:17 2015 -0400
+++ b/src/org/python/modules/gc.java	Fri Apr 24 08:22:23 2015 -0500
@@ -706,8 +706,12 @@

         public boolean equals(Object ob) {
             if (ob instanceof WeakReferenceGC) {
-                return ((WeakReferenceGC) ob).get().equals(get())
-                    && ((WeakReferenceGC) ob).hashCode() == hashCode();
+                WeakReferenceGC otherRef = (WeakReferenceGC)ob;
+                Object mine = get();
+                Object theirs = otherRef.get();
+                return (mine == theirs //same object, or both null
+                        || (mine != null && mine.equals(theirs))) //at least one is not null
+                    && hashCode() == otherRef.hashCode();
             } else if (ob instanceof WeakrefGCCompareDummy) {
                 return ((WeakrefGCCompareDummy) ob).compare != null
                         && ((WeakrefGCCompareDummy) ob).compare.equals(get());
History
Date User Action Args
2015-04-24 13:24:43jmaddensetmessageid: <1429881883.78.0.621277580217.issue2336@psf.upfronthosting.co.za>
2015-04-24 13:24:43jmaddensetrecipients: + jmadden, zyasoft, stefan.richthofer
2015-04-24 13:24:43jmaddenlinkissue2336 messages
2015-04-24 13:24:43jmaddencreate