From: <pj...@us...> - 2009-10-27 22:16:29
|
Revision: 6917 http://jython.svn.sourceforge.net/jython/?rev=6917&view=rev Author: pjenvey Date: 2009-10-27 22:16:17 +0000 (Tue, 27 Oct 2009) Log Message: ----------- is{Number,Mapping,Sequence}Type are unnecessary for PyNone now Modified Paths: -------------- trunk/jython/Lib/test/test_operator_jy.py trunk/jython/src/org/python/core/PyNone.java Modified: trunk/jython/Lib/test/test_operator_jy.py =================================================================== --- trunk/jython/Lib/test/test_operator_jy.py 2009-10-27 22:09:16 UTC (rev 6916) +++ trunk/jython/Lib/test/test_operator_jy.py 2009-10-27 22:16:17 UTC (rev 6917) @@ -44,6 +44,8 @@ (2L, True, False, False), (3.0, True, False, False), (4j, True, False, False), + (None, False, False, False), + (Ellipsis, False, False, False), (Exception(), False, False, True), (collections.deque(), False, False, True), (collections.defaultdict(), False, True, False), Modified: trunk/jython/src/org/python/core/PyNone.java =================================================================== --- trunk/jython/src/org/python/core/PyNone.java 2009-10-27 22:09:16 UTC (rev 6916) +++ trunk/jython/src/org/python/core/PyNone.java 2009-10-27 22:16:17 UTC (rev 6917) @@ -1,4 +1,7 @@ -// Copyright (c) Corporation for National Research Initiatives +/* + * Copyright (c) Corporation for National Research Initiatives + * Copyright (c) Jython Developers + */ package org.python.core; import java.io.Serializable; @@ -7,11 +10,10 @@ import org.python.expose.ExposedType; /** - * A class representing the singleton None object, + * The singleton None object. */ @ExposedType(name = "NoneType", isBaseType = false) -public class PyNone extends PyObject implements Serializable -{ +public class PyNone extends PyObject implements Serializable { public static final PyType TYPE = PyType.fromClass(PyNone.class); @@ -19,24 +21,25 @@ super(TYPE); } - private Object writeReplace() { - return new Py.SingletonResolver("None"); - } - + @Override public boolean __nonzero__() { return false; } - public Object __tojava__(Class c) { - //Danger here. java.lang.Object gets null not None - if (c == PyObject.class) + @Override + public Object __tojava__(Class<?> c) { + if (c == PyObject.class) { return this; - if (c.isPrimitive()) + } + if (c.isPrimitive()) { return Py.NoConversion; + } + // Java gets null return null; } - public String toString() throws PyIgnoreMethodTag { + @Override + public String toString() { return NoneType_toString(); } @@ -45,23 +48,17 @@ return "None"; } - public boolean isMappingType() { - return false; - } - - public boolean isSequenceType() { - return false; - } - - public boolean isNumberType() { - return false; - } - + @Override public String asStringOrNull(int index) { return null; } + @Override public String asStringOrNull() { return null; } + + private Object writeReplace() { + return new Py.SingletonResolver("None"); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |