From: <cg...@us...> - 2009-01-26 03:36:33
|
Revision: 5983 http://jython.svn.sourceforge.net/jython/?rev=5983&view=rev Author: cgroves Date: 2009-01-26 03:36:25 +0000 (Mon, 26 Jan 2009) Log Message: ----------- Fix javatests Modified Paths: -------------- trunk/jython/src/org/python/core/PyNewWrapper.java trunk/jython/src/org/python/core/PySystemState.java trunk/jython/tests/java/org/python/expose/generate/TypeExposerTest.java Modified: trunk/jython/src/org/python/core/PyNewWrapper.java =================================================================== --- trunk/jython/src/org/python/core/PyNewWrapper.java 2009-01-26 03:10:36 UTC (rev 5982) +++ trunk/jython/src/org/python/core/PyNewWrapper.java 2009-01-26 03:36:25 UTC (rev 5983) @@ -28,15 +28,15 @@ PyType subtype, PyObject[] args, String[] keywords); - + public PyBuiltinCallable bind(PyObject self) { throw Py.SystemError("__new__ wrappers are already bound"); } - + public PyType getWrappedType() { return for_type; } - + public void setWrappedType(PyType type) { self = type; for_type = type; @@ -48,26 +48,22 @@ public PyObject __call__(PyObject[] args, String[] keywords) { int nargs = args.length; - if(nargs < 1 || nargs == keywords.length) { - throw Py.TypeError(for_type.fastGetName() - + ".__new__(): not enough arguments"); + if (nargs < 1 || nargs == keywords.length) { + throw Py.TypeError(for_type.fastGetName() + ".__new__(): not enough arguments"); } PyObject arg0 = args[0]; - if(!(arg0 instanceof PyType)) { - throw Py.TypeError(for_type.fastGetName() - + ".__new__(X): X is not a type object (" + if (!(arg0 instanceof PyType)) { + throw Py.TypeError(for_type.fastGetName() + ".__new__(X): X is not a type object (" + arg0.getType().fastGetName() + ")"); } PyType subtype = (PyType)arg0; - if(!subtype.isSubType(for_type)) { - throw Py.TypeError(for_type.fastGetName() + ".__new__(" - + subtype.fastGetName() + "): " + subtype.fastGetName() - + " is not a subtype of " + for_type.fastGetName()); + if (!subtype.isSubType(for_type)) { + throw Py.TypeError(for_type.fastGetName() + ".__new__(" + subtype.fastGetName() + "): " + + subtype.fastGetName() + " is not a subtype of " + for_type.fastGetName()); } - if(subtype.getStatic() != for_type) { - throw Py.TypeError(for_type.fastGetName() + ".__new__(" - + subtype.fastGetName() + ") is not safe, use " - + subtype.fastGetName() + ".__new__()"); + if (subtype.getStatic() != for_type) { + throw Py.TypeError(for_type.fastGetName() + ".__new__(" + subtype.fastGetName() + + ") is not safe, use " + subtype.fastGetName() + ".__new__()"); } PyObject[] rest = new PyObject[nargs - 1]; System.arraycopy(args, 1, rest, 0, nargs - 1); Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2009-01-26 03:10:36 UTC (rev 5982) +++ trunk/jython/src/org/python/core/PySystemState.java 2009-01-26 03:36:25 UTC (rev 5983) @@ -502,8 +502,9 @@ if (jarIndex >= 0) { int start = classpath.lastIndexOf(File.pathSeparator, jarIndex) + 1; root = classpath.substring(start, jarIndex); - } else { - // in case JYTHON_JAR is referenced from a MANIFEST inside another jar on the classpath + } else if (jarFileName != null) { + // in case JYTHON_JAR is referenced from a MANIFEST inside another jar on the + // classpath root = new File(jarFileName).getParent(); } } Modified: trunk/jython/tests/java/org/python/expose/generate/TypeExposerTest.java =================================================================== --- trunk/jython/tests/java/org/python/expose/generate/TypeExposerTest.java 2009-01-26 03:10:36 UTC (rev 5982) +++ trunk/jython/tests/java/org/python/expose/generate/TypeExposerTest.java 2009-01-26 03:36:25 UTC (rev 5983) @@ -2,9 +2,6 @@ import java.io.IOException; -import junit.framework.TestCase; - -import org.objectweb.asm.Type; import org.python.core.Py; import org.python.core.PyNewWrapper; import org.python.core.PyObject; @@ -38,8 +35,9 @@ .getResourceAsStream("org/python/expose/generate/TypeExposerTest$SimplestNew.class")); TypeBuilder te = etp.getTypeExposer().makeBuilder(); assertEquals(true, te.getIsBaseType()); - PyObject new_ = te.getDict(PyType.fromClass(SimplestNew.class)).__finditem__("__new__"); - assertEquals(Py.One, new_.__call__(PyType.fromClass(SimplestNew.class))); + PyType simplestType = PyType.fromClass(SimplestNew.class); + PyNewWrapper new_ = (PyNewWrapper)te.getDict(simplestType).__finditem__("__new__"); + assertEquals(Py.One, new_.new_impl(false, null, null, null)); } public void testCatchingDupes() throws IOException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |