[Jython-checkins] jython: Fixed #2688.
stefan.richthofer
jython-checkins at python.org
Sun Jun 17 07:48:06 EDT 2018
https://hg.python.org/jython/rev/4b156d3d0d8b
changeset: 8167:4b156d3d0d8b
user: Stefan Richthofer <stefan.richthofer at gmx.de>
date: Sun Jun 17 13:47:32 2018 +0200
summary:
Fixed #2688.
files:
Lib/test/test_list_jy.py | 7 +++++++
NEWS | 1 +
src/org/python/core/PyList.java | 10 +++++-----
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/Lib/test/test_list_jy.py b/Lib/test/test_list_jy.py
--- a/Lib/test/test_list_jy.py
+++ b/Lib/test/test_list_jy.py
@@ -256,6 +256,13 @@
jl.remove(i)
self.assertEqual(jl, b_to_z_by_2)
+ def test_concat(self):
+ # See http://bugs.jython.org/issue2688
+ lst = ArrayList([1, 2, 3])
+ lst2 = [4, 5, 6]
+ self.assertEquals(lst+lst2, [1, 2, 3, 4, 5, 6])
+ self.assertEquals(lst2+lst, [4, 5, 6, 1, 2, 3])
+
class ListSubclassTestCase(unittest.TestCase):
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@
Developement tip
Bugs fixed
+ - [ 2688 ] ClassCastException when adding list of non-PyObjects
- [ 2659 ] Determine console encoding without access violation (Java 9)
- [ 2662 ] IllegalAccessException accessing public abstract method via PyReflectedFunction
- [ 2501 ] JAVA_STACK doesn't work (fixed for Windows launcher only)
diff --git a/src/org/python/core/PyList.java b/src/org/python/core/PyList.java
--- a/src/org/python/core/PyList.java
+++ b/src/org/python/core/PyList.java
@@ -43,10 +43,10 @@
list = Generic.list();
}
- private PyList(List list, boolean convert) {
+ private PyList(List<?> list, boolean convert) {
super(TYPE);
if (!convert) {
- this.list = list;
+ this.list = (List<PyObject>) list;
} else {
this.list = Generic.list();
for (Object o : list) {
@@ -72,7 +72,7 @@
this(TYPE, elements);
}
- public PyList(Collection c) {
+ public PyList(Collection<?> c) {
this(TYPE, c);
}
@@ -392,10 +392,10 @@
Object oList = o.__tojava__(List.class);
if (oList != Py.NoConversion && oList != null) {
@SuppressWarnings("unchecked")
- List<PyObject> otherList = (List<PyObject>) oList;
+ List<Object> otherList = (List<Object>) oList;
sum = new PyList();
sum.list_extend(this);
- for (PyObject ob: otherList) {
+ for (Object ob: otherList) {
sum.add(ob);
}
}
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list