From: <cg...@us...> - 2008-12-31 21:56:51
|
Revision: 5822 http://jython.svn.sourceforge.net/jython/?rev=5822&view=rev Author: cgroves Date: 2008-12-31 21:56:48 +0000 (Wed, 31 Dec 2008) Log Message: ----------- Patch from David Morley to rename set in PySequence to pyset such that PySequence can be subclassed by List without requiring a type on List. See http://www.nabble.com/PySequence-set-method-incompatible-with-List%3CPyObject%3E--to14964846.html Modified Paths: -------------- trunk/jython/src/org/python/core/AstList.java trunk/jython/src/org/python/core/PyArray.java trunk/jython/src/org/python/core/PyList.java trunk/jython/src/org/python/core/PySequence.java trunk/jython/src/org/python/core/PySequenceList.java Modified: trunk/jython/src/org/python/core/AstList.java =================================================================== --- trunk/jython/src/org/python/core/AstList.java 2008-12-31 21:38:23 UTC (rev 5821) +++ trunk/jython/src/org/python/core/AstList.java 2008-12-31 21:56:48 UTC (rev 5822) @@ -454,10 +454,6 @@ return new AstList(newList); } - protected void set(int i, PyObject value) { - data.set(i, value); - } - protected void setslice(int start, int stop, int step, PyObject value) { if(stop < start) { stop = start; @@ -587,13 +583,12 @@ return adapter.ast2py(data.get(index)); } - public PyObject pyset(int index, PyObject element) { + public void pyset(int index, PyObject element) { if (adapter == null) { - return (PyObject)data.set(index, element); + data.set(index, element); } Object o = adapter.py2ast(element); data.set(index, o); - return element; } public Object remove(int index) { Modified: trunk/jython/src/org/python/core/PyArray.java =================================================================== --- trunk/jython/src/org/python/core/PyArray.java 2008-12-31 21:38:23 UTC (rev 5821) +++ trunk/jython/src/org/python/core/PyArray.java 2008-12-31 21:56:48 UTC (rev 5822) @@ -1312,6 +1312,10 @@ * value to set the element to */ public void set(int i, PyObject value) { + pyset(i, value); + } + + protected void pyset(int i, PyObject value) { if ("u".equals(typecode)) { Array.setInt(data, i, getCodePoint(value)); return; Modified: trunk/jython/src/org/python/core/PyList.java =================================================================== --- trunk/jython/src/org/python/core/PyList.java 2008-12-31 21:38:23 UTC (rev 5821) +++ trunk/jython/src/org/python/core/PyList.java 2008-12-31 21:56:48 UTC (rev 5822) @@ -116,10 +116,6 @@ remove(start, stop); } - protected void set(int i, PyObject value) { - list.pyset(i, value); - } - protected void setslice(int start, int stop, int step, PyObject value) { if(stop < start) { stop = start; Modified: trunk/jython/src/org/python/core/PySequence.java =================================================================== --- trunk/jython/src/org/python/core/PySequence.java 2008-12-31 21:38:23 UTC (rev 5821) +++ trunk/jython/src/org/python/core/PySequence.java 2008-12-31 21:56:48 UTC (rev 5822) @@ -63,7 +63,7 @@ * @param value * the value to set this element to. */ - protected void set(int index, PyObject value) { + protected void pyset(int index, PyObject value) { throw Py.TypeError("can't assign to immutable object"); } @@ -399,7 +399,7 @@ @Override public void setItem(int idx, PyObject value) { - set(idx, value); + pyset(idx, value); } @Override Modified: trunk/jython/src/org/python/core/PySequenceList.java =================================================================== --- trunk/jython/src/org/python/core/PySequenceList.java 2008-12-31 21:38:23 UTC (rev 5821) +++ trunk/jython/src/org/python/core/PySequenceList.java 2008-12-31 21:56:48 UTC (rev 5822) @@ -99,8 +99,8 @@ return list.pyget(index); } - public PyObject pyset(int index, PyObject element) { - return list.pyset(index, element); + public void pyset(int index, PyObject element) { + list.pyset(index, element); } public Object remove(int index) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |