From: <pj...@us...> - 2008-11-24 02:48:39
|
Revision: 5627 http://jython.svn.sourceforge.net/jython/?rev=5627&view=rev Author: pjenvey Date: 2008-11-24 02:48:33 +0000 (Mon, 24 Nov 2008) Log Message: ----------- disallow sublcassing a number of types fixes #1758319 Modified Paths: -------------- trunk/jython/Lib/test/test_bool.py trunk/jython/src/org/python/core/PyBoolean.java trunk/jython/src/org/python/core/PyCell.java trunk/jython/src/org/python/core/PyClassMethodDescr.java trunk/jython/src/org/python/core/PyDataDescr.java trunk/jython/src/org/python/core/PyDictProxy.java trunk/jython/src/org/python/core/PyEllipsis.java trunk/jython/src/org/python/core/PyFunction.java trunk/jython/src/org/python/core/PyGenerator.java trunk/jython/src/org/python/core/PyMethod.java trunk/jython/src/org/python/core/PyMethodDescr.java trunk/jython/src/org/python/core/PyNone.java trunk/jython/src/org/python/core/PyNotImplemented.java trunk/jython/src/org/python/core/PySlice.java trunk/jython/src/org/python/core/PySlot.java trunk/jython/src/org/python/core/PyTraceback.java trunk/jython/src/org/python/core/PyXRange.java trunk/jython/src/org/python/modules/PyTeeIterator.java trunk/jython/src/org/python/modules/_codecs.java trunk/jython/src/org/python/modules/_weakref/CallableProxyType.java trunk/jython/src/org/python/modules/_weakref/ProxyType.java trunk/jython/src/org/python/modules/operator.java trunk/jython/src/org/python/modules/time/PyTimeTuple.java Modified: trunk/jython/Lib/test/test_bool.py =================================================================== --- trunk/jython/Lib/test/test_bool.py 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/Lib/test/test_bool.py 2008-11-24 02:48:33 UTC (rev 5627) @@ -343,9 +343,6 @@ # StackOverflow if __nonzero__ returns self # http://jython.org/bugs/1758318 del BoolTest.test_convert_to_bool -# bool should not be subclassable -# http://jython.org/bugs/1758319 -del BoolTest.test_subclass def test_main(): test_support.run_unittest(BoolTest) Modified: trunk/jython/src/org/python/core/PyBoolean.java =================================================================== --- trunk/jython/src/org/python/core/PyBoolean.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PyBoolean.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -1,7 +1,5 @@ package org.python.core; -import java.io.Serializable; - import org.python.expose.ExposedMethod; import org.python.expose.ExposedNew; import org.python.expose.ExposedType; @@ -10,7 +8,7 @@ /** * A builtin python bool. */ -@ExposedType(name = "bool") +@ExposedType(name = "bool", isBaseType = false) public class PyBoolean extends PyInteger { public static final PyType TYPE = PyType.fromClass(PyBoolean.class); Modified: trunk/jython/src/org/python/core/PyCell.java =================================================================== --- trunk/jython/src/org/python/core/PyCell.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PyCell.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -10,7 +10,7 @@ * Cells are used to implement variables referenced by multiple * scopes. */ -@ExposedType(name = "cell") +@ExposedType(name = "cell", isBaseType = false) public class PyCell extends PyObject { /** The underlying content of the cell, or null. */ Modified: trunk/jython/src/org/python/core/PyClassMethodDescr.java =================================================================== --- trunk/jython/src/org/python/core/PyClassMethodDescr.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PyClassMethodDescr.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -3,7 +3,7 @@ import org.python.expose.ExposedMethod; import org.python.expose.ExposedType; -@ExposedType(name = "classmethod_descriptor") +@ExposedType(name = "classmethod_descriptor", isBaseType = false) public class PyClassMethodDescr extends PyMethodDescr { public static final PyType TYPE = PyType.fromClass(PyClassMethodDescr.class); Modified: trunk/jython/src/org/python/core/PyDataDescr.java =================================================================== --- trunk/jython/src/org/python/core/PyDataDescr.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PyDataDescr.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -12,7 +12,7 @@ * those methods, their respective implementsDescr* methods should be overriden * as well. */ -@ExposedType(name = "getset_descriptor", base = PyObject.class) +@ExposedType(name = "getset_descriptor", base = PyObject.class, isBaseType = false) public abstract class PyDataDescr extends PyDescriptor { protected Class ofType; Modified: trunk/jython/src/org/python/core/PyDictProxy.java =================================================================== --- trunk/jython/src/org/python/core/PyDictProxy.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PyDictProxy.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -9,7 +9,7 @@ * Readonly proxy for dictionaries (actually any mapping). * */ -@ExposedType(name = "dictproxy") +@ExposedType(name = "dictproxy", isBaseType = false) public class PyDictProxy extends PyObject { /** The dict proxied to. */ Modified: trunk/jython/src/org/python/core/PyEllipsis.java =================================================================== --- trunk/jython/src/org/python/core/PyEllipsis.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PyEllipsis.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -8,8 +8,7 @@ /** * A class representing the singleton Ellipsis <code>...</code> object. */ -// XXX: not subclassable -@ExposedType(name = "ellipsis", base = PyObject.class) +@ExposedType(name = "ellipsis", base = PyObject.class, isBaseType = false) public class PyEllipsis extends PySingleton implements Serializable { public static final PyType TYPE = PyType.fromClass(PyEllipsis.class); Modified: trunk/jython/src/org/python/core/PyFunction.java =================================================================== --- trunk/jython/src/org/python/core/PyFunction.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PyFunction.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -11,7 +11,7 @@ /** * A Python function. */ -@ExposedType(name = "function") +@ExposedType(name = "function", isBaseType = false) public class PyFunction extends PyObject { public static final PyType TYPE = PyType.fromClass(PyFunction.class); Modified: trunk/jython/src/org/python/core/PyGenerator.java =================================================================== --- trunk/jython/src/org/python/core/PyGenerator.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PyGenerator.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -4,7 +4,7 @@ import org.python.expose.ExposedMethod; import org.python.expose.ExposedType; -@ExposedType(name="generator", base=PyObject.class) +@ExposedType(name = "generator", base = PyObject.class, isBaseType = false) public class PyGenerator extends PyIterator { @ExposedGet Modified: trunk/jython/src/org/python/core/PyMethod.java =================================================================== --- trunk/jython/src/org/python/core/PyMethod.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PyMethod.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -10,7 +10,7 @@ /** * A Python method. */ -@ExposedType(name = "instancemethod") +@ExposedType(name = "instancemethod", isBaseType = false) public class PyMethod extends PyObject { public static final PyType TYPE = PyType.fromClass(PyMethod.class); Modified: trunk/jython/src/org/python/core/PyMethodDescr.java =================================================================== --- trunk/jython/src/org/python/core/PyMethodDescr.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PyMethodDescr.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -4,7 +4,7 @@ import org.python.expose.ExposedMethod; import org.python.expose.ExposedType; -@ExposedType(name = "method_descriptor", base = PyObject.class) +@ExposedType(name = "method_descriptor", base = PyObject.class, isBaseType = false) public class PyMethodDescr extends PyDescriptor implements PyBuiltinCallable.Info { protected int minargs, maxargs; Modified: trunk/jython/src/org/python/core/PyNone.java =================================================================== --- trunk/jython/src/org/python/core/PyNone.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PyNone.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -9,8 +9,7 @@ /** * A class representing the singleton None object, */ -// XXX: not subclassable -@ExposedType(name = "NoneType") +@ExposedType(name = "NoneType", isBaseType = false) public class PyNone extends PyObject implements Serializable { Modified: trunk/jython/src/org/python/core/PyNotImplemented.java =================================================================== --- trunk/jython/src/org/python/core/PyNotImplemented.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PyNotImplemented.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -2,6 +2,7 @@ import java.io.Serializable; +// XXX: isBaseType = false public class PyNotImplemented extends PySingleton implements Serializable { PyNotImplemented() { Modified: trunk/jython/src/org/python/core/PySlice.java =================================================================== --- trunk/jython/src/org/python/core/PySlice.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PySlice.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -9,7 +9,7 @@ /** * The Python slice object. */ -@ExposedType(name = "slice") +@ExposedType(name = "slice", isBaseType = false) public class PySlice extends PyObject { public static final PyType TYPE = PyType.fromClass(PySlice.class); Modified: trunk/jython/src/org/python/core/PySlot.java =================================================================== --- trunk/jython/src/org/python/core/PySlot.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PySlot.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -4,7 +4,7 @@ import org.python.expose.ExposedMethod; import org.python.expose.ExposedType; -@ExposedType(name = "member_descriptor", base = PyObject.class) +@ExposedType(name = "member_descriptor", base = PyObject.class, isBaseType = false) public class PySlot extends PyDescriptor { private int index; Modified: trunk/jython/src/org/python/core/PyTraceback.java =================================================================== --- trunk/jython/src/org/python/core/PyTraceback.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PyTraceback.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -6,6 +6,7 @@ /** * A python traceback object. */ +// XXX: isBaseType = false public class PyTraceback extends PyObject { public PyObject tb_next; Modified: trunk/jython/src/org/python/core/PyXRange.java =================================================================== --- trunk/jython/src/org/python/core/PyXRange.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/core/PyXRange.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -8,8 +8,7 @@ /** * The builtin xrange type. */ -// XXX: Not subclassable -@ExposedType(name = "xrange", base = PyObject.class) +@ExposedType(name = "xrange", base = PyObject.class, isBaseType = false) public class PyXRange extends PySequence { public static final PyType TYPE = PyType.fromClass(PyXRange.class); Modified: trunk/jython/src/org/python/modules/PyTeeIterator.java =================================================================== --- trunk/jython/src/org/python/modules/PyTeeIterator.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/modules/PyTeeIterator.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -13,7 +13,7 @@ import org.python.expose.ExposedNew; import org.python.expose.ExposedType; -@ExposedType(name = "itertools.tee", base = PyObject.class) +@ExposedType(name = "itertools.tee", base = PyObject.class, isBaseType = false) public class PyTeeIterator extends PyIterator { private final int position; Modified: trunk/jython/src/org/python/modules/_codecs.java =================================================================== --- trunk/jython/src/org/python/modules/_codecs.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/modules/_codecs.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -650,7 +650,7 @@ * creating integer objects in the process. The trie is created by inverting the * encoding map. */ - @ExposedType(name = "EncodingMap") + @ExposedType(name = "EncodingMap", isBaseType = false) public static class EncodingMap extends PyObject { char[] level1; Modified: trunk/jython/src/org/python/modules/_weakref/CallableProxyType.java =================================================================== --- trunk/jython/src/org/python/modules/_weakref/CallableProxyType.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/modules/_weakref/CallableProxyType.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -9,8 +9,7 @@ /** * ProxyType with __call__. */ -// XXX: not subclassable -@ExposedType(name = "weakcallableproxy") +@ExposedType(name = "weakcallableproxy", isBaseType = false) public class CallableProxyType extends ProxyType { public static final PyType TYPE = PyType.fromClass(CallableProxyType.class); Modified: trunk/jython/src/org/python/modules/_weakref/ProxyType.java =================================================================== --- trunk/jython/src/org/python/modules/_weakref/ProxyType.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/modules/_weakref/ProxyType.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -1,10 +1,8 @@ /* Copyright (c) Jython Developers */ package org.python.modules._weakref; -import org.python.core.Py; import org.python.core.PyComplex; import org.python.core.PyFloat; -import org.python.core.PyLong; import org.python.core.PyObject; import org.python.core.PyString; import org.python.core.PyType; @@ -13,8 +11,7 @@ /** * A weak reference proxy object. */ -// XXX: not subclassable -@ExposedType(name = "weakproxy") +@ExposedType(name = "weakproxy", isBaseType = false) public class ProxyType extends AbstractReference { public static final PyType TYPE = PyType.fromClass(ProxyType.class); Modified: trunk/jython/src/org/python/modules/operator.java =================================================================== --- trunk/jython/src/org/python/modules/operator.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/modules/operator.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -286,8 +286,7 @@ /** * The attrgetter type. */ - // XXX: not subclassable - @ExposedType(name = "operator.attrgetter") + @ExposedType(name = "operator.attrgetter", isBaseType = false) static class PyAttrGetter extends PyObject { public static final PyType TYPE = PyType.fromClass(PyAttrGetter.class); @@ -350,8 +349,7 @@ /** * The itemgetter type. */ - // XXX: not subclassable - @ExposedType(name = "operator.itemgetter") + @ExposedType(name = "operator.itemgetter", isBaseType = false) static class PyItemGetter extends PyObject { public static final PyType TYPE = PyType.fromClass(PyItemGetter.class); Modified: trunk/jython/src/org/python/modules/time/PyTimeTuple.java =================================================================== --- trunk/jython/src/org/python/modules/time/PyTimeTuple.java 2008-11-24 02:02:47 UTC (rev 5626) +++ trunk/jython/src/org/python/modules/time/PyTimeTuple.java 2008-11-24 02:48:33 UTC (rev 5627) @@ -3,11 +3,9 @@ import org.python.core.ArgParser; import org.python.core.Py; -import org.python.core.PyInteger; import org.python.core.PyList; import org.python.core.PyNewWrapper; import org.python.core.PyObject; -import org.python.core.PySequence; import org.python.core.PyTuple; import org.python.core.PyType; import org.python.expose.ExposedGet; @@ -20,7 +18,7 @@ * struct_time of the time module. * */ -@ExposedType(name = "time.struct_time") +@ExposedType(name = "time.struct_time", isBaseType = false) public class PyTimeTuple extends PyTuple { @ExposedGet This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |