From: <cg...@us...> - 2008-12-06 03:01:21
|
Revision: 5707 http://jython.svn.sourceforge.net/jython/?rev=5707&view=rev Author: cgroves Date: 2008-12-06 03:01:16 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Tidying Modified Paths: -------------- branches/newstyle-java-types/Lib/test/jser2_classes.py branches/newstyle-java-types/Lib/test/test_jser2.py branches/newstyle-java-types/src/org/python/util/PythonObjectInputStream.java branches/newstyle-java-types/tests/java/org/python/util/InterpreterTest.java Property Changed: ---------------- branches/newstyle-java-types/Lib/test/jser2_classes.py branches/newstyle-java-types/Lib/test/test_jser2.py Modified: branches/newstyle-java-types/Lib/test/jser2_classes.py =================================================================== (Binary files differ) Property changes on: branches/newstyle-java-types/Lib/test/jser2_classes.py ___________________________________________________________________ Deleted: svn:mime-type - application/octet-stream Modified: branches/newstyle-java-types/Lib/test/test_jser2.py =================================================================== (Binary files differ) Property changes on: branches/newstyle-java-types/Lib/test/test_jser2.py ___________________________________________________________________ Deleted: svn:mime-type - application/octet-stream Modified: branches/newstyle-java-types/src/org/python/util/PythonObjectInputStream.java =================================================================== --- branches/newstyle-java-types/src/org/python/util/PythonObjectInputStream.java 2008-12-06 02:49:45 UTC (rev 5706) +++ branches/newstyle-java-types/src/org/python/util/PythonObjectInputStream.java 2008-12-06 03:01:16 UTC (rev 5707) @@ -1,52 +1,53 @@ // Copyright 2000 Finn Bock - package org.python.util; -import java.io.*; -import org.python.core.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectStreamClass; +import org.python.core.Py; +import org.python.core.PyObject; +import org.python.core.PyTuple; +import org.python.core.__builtin__; + public class PythonObjectInputStream extends ObjectInputStream { + public PythonObjectInputStream(InputStream istr) throws IOException { super(istr); } - protected Class resolveClass(ObjectStreamClass v) - throws IOException, ClassNotFoundException { + protected Class<?> resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { String clsName = v.getName(); - //System.out.println(clsName); if (clsName.startsWith("org.python.proxies")) { int idx = clsName.lastIndexOf('$'); - if (idx > 19) - clsName = clsName.substring(19, idx); - //System.out.println("new:" + clsName); - + if (idx > 19) { + clsName = clsName.substring(19, idx); + } idx = clsName.indexOf('$'); if (idx >= 0) { String mod = clsName.substring(0, idx); - clsName = clsName.substring(idx+1); - + clsName = clsName.substring(idx + 1); PyObject module = importModule(mod); PyObject pycls = module.__getattr__(clsName.intern()); Object cls = pycls.__tojava__(Class.class); - - if (cls != null && cls != Py.NoConversion) - return (Class) cls; + if (cls != null && cls != Py.NoConversion) { + return (Class<?>)cls; + } } } try { return super.resolveClass(v); } catch (ClassNotFoundException exc) { PyObject m = importModule(clsName); - //System.out.println("m:" + m); Object cls = m.__tojava__(Class.class); - //System.out.println("cls:" + cls); - if (cls != null && cls != Py.NoConversion) - return (Class) cls; + if (cls != null && cls != Py.NoConversion) { + return (Class<?>)cls; + } throw exc; } } - private static PyObject importModule(String name) { PyObject fromlist = new PyTuple(Py.newString("__doc__")); return __builtin__.__import__(name, null, null, fromlist); Modified: branches/newstyle-java-types/tests/java/org/python/util/InterpreterTest.java =================================================================== --- branches/newstyle-java-types/tests/java/org/python/util/InterpreterTest.java 2008-12-06 02:49:45 UTC (rev 5706) +++ branches/newstyle-java-types/tests/java/org/python/util/InterpreterTest.java 2008-12-06 03:01:16 UTC (rev 5707) @@ -2,8 +2,9 @@ import junit.framework.TestCase; -import org.python.core.*; -import org.python.util.*; +import org.python.core.PyDictionary; +import org.python.core.PyObject; +import org.python.core.PyUnicode; public class InterpreterTest extends TestCase { @@ -13,8 +14,7 @@ public void testBasicEval() throws Exception { PyDictionary test = new PyDictionary(); test.__setitem__(new PyUnicode("one"), new PyUnicode("two")); - PythonInterpreter.initialize(System.getProperties(), null, new -String[] {}); + PythonInterpreter.initialize(System.getProperties(), null, new String[] {}); PythonInterpreter interp = new PythonInterpreter(); PyObject pyo = interp.eval("{u'one': u'two'}"); assertEquals(test, pyo); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |