From: Finn B. <bc...@us...> - 2002-11-05 17:05:57
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv22185 Modified Files: PyXRange.java Log Message: - Added deprication warnings. - Justify the stop value. Index: PyXRange.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyXRange.java,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -d -r2.4 -r2.5 *** PyXRange.java 28 Oct 2001 17:13:43 -0000 2.4 --- PyXRange.java 5 Nov 2002 17:05:54 -0000 2.5 *************** *** 28,31 **** --- 28,32 ---- cycleLength = 0; } + this.stop = start + cycleLength*step; copies = 1; } *************** *** 48,51 **** --- 49,54 ---- protected PyObject getslice(int start, int stop, int step) { + Py.DeprecationWarning("xrange object slicing is deprecated; " + + "convert to list instead"); if (copies != 1) { throw Py.TypeError("cannot slice a replicated range"); *************** *** 60,63 **** --- 63,68 ---- protected PyObject repeat(int howmany) { + Py.DeprecationWarning("xrange object multiplication is deprecated; " + + "convert to list instead"); PyXRange x = new PyXRange(start, stop, step); x.copies = copies*howmany; *************** *** 69,72 **** --- 74,94 ---- } + public PyObject __findattr__(String name) { + String msg = "xrange object's 'start', 'stop' and 'step' " + + "attributes are deprecated"; + if (name == "start") { + Py.DeprecationWarning(msg); + return Py.newInteger(start); + } else if (name == "stop") { + Py.DeprecationWarning(msg); + return Py.newInteger(stop); + } else if (name == "step") { + Py.DeprecationWarning(msg); + return Py.newInteger(step); + } else { + return super.__findattr__(name); + } + } + public int hashCode() { // Not the greatest hash function *************** *** 92,95 **** --- 114,119 ---- public PyList tolist() { + Py.DeprecationWarning("xrange.tolist() is deprecated; " + + "use list(xrange) instead"); PyList list = new PyList(); int count = __len__(); |