From jython-checkins at python.org Sun Jun 17 07:48:06 2018 From: jython-checkins at python.org (stefan.richthofer) Date: Sun, 17 Jun 2018 11:48:06 +0000 Subject: [Jython-checkins] =?utf-8?q?jython=3A_Fixed_=232688=2E?= Message-ID: <20180617114806.1.5C588D156B0B66F0@mg.python.org> https://hg.python.org/jython/rev/4b156d3d0d8b changeset: 8167:4b156d3d0d8b user: Stefan Richthofer 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) 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 otherList = (List) oList; + List otherList = (List) 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