[Jython-checkins] jython: Use ArrayList in gc.get_objects() and test if the object is null before adding
darjus.loktevic
jython-checkins at python.org
Mon Jan 4 17:06:50 EST 2016
https://hg.python.org/jython/rev/c085ec851271
changeset: 7848:c085ec851271
user: Darjus Loktevic <darjus at gmail.com>
date: Tue Jan 05 09:06:44 2016 +1100
summary:
Use ArrayList in gc.get_objects() and test if the object is null before adding it to the results
files:
src/org/python/modules/gc.java | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/org/python/modules/gc.java b/src/org/python/modules/gc.java
--- a/src/org/python/modules/gc.java
+++ b/src/org/python/modules/gc.java
@@ -2,7 +2,6 @@
import java.util.Set;
import java.util.List;
-import java.util.LinkedList;
import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.HashSet;
@@ -2572,10 +2571,13 @@
throw Py.NotImplementedError(
"not applicable in Jython if gc module is not monitoring PyObjects");
}
- LinkedList<PyObject> resultList = new LinkedList<>();
+ ArrayList<PyObject> resultList = new ArrayList<>();
synchronized (monitoredObjects) {
for (WeakReferenceGC src: monitoredObjects) {
- resultList.add((PyObject) src.get());
+ PyObject obj = src.get();
+ if (obj != null) {
+ resultList.add(obj);
+ }
}
}
return new PyList(resultList);
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list