From: <fwi...@us...> - 2008-12-03 18:28:58
|
Revision: 5684 http://jython.svn.sourceforge.net/jython/?rev=5684&view=rev Author: fwierzbicki Date: 2008-12-03 18:28:54 +0000 (Wed, 03 Dec 2008) Log Message: ----------- Merged revisions 5639-5640,5644-5648,5655,5661,5670,5680-5682 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython Modified Paths: -------------- branches/astwrite/Lib/test/test_genexps.py branches/astwrite/Lib/test/test_stringmap.py branches/astwrite/Lib/test/test_subprocess_jy.py branches/astwrite/build.xml branches/astwrite/src/org/python/antlr/GrammarActions.java branches/astwrite/src/org/python/antlr/PythonTree.java branches/astwrite/src/org/python/compiler/CodeCompiler.java branches/astwrite/src/org/python/core/PyDataDescr.java branches/astwrite/src/org/python/core/PyStringMap.java branches/astwrite/src/org/python/core/PySystemState.java branches/astwrite/src/org/python/expose/generate/DescriptorExposer.java branches/astwrite/src/org/python/expose/generate/Exposer.java branches/astwrite/src/org/python/modules/zipimport/zipimporter.java branches/astwrite/src/shell/jython branches/astwrite/src/shell/jython.bat branches/astwrite/tests/java/org/python/expose/generate/DescriptorExposerTest.java branches/astwrite/tests/java/org/python/expose/generate/ExposedTypeProcessorTest.java branches/astwrite/tests/java/org/python/expose/generate/MethodExposerTest.java branches/astwrite/tests/java/org/python/expose/generate/SimpleExposed.java Added Paths: ----------- branches/astwrite/Lib/test/test_genexps_jy.py branches/astwrite/extlibs/constantine-0.4.jar Removed Paths: ------------- branches/astwrite/extlibs/constantine.jar Property Changed: ---------------- branches/astwrite/ Property changes on: branches/astwrite ___________________________________________________________________ Modified: svnmerge-integrated - /trunk/jython:1-5634 + /trunk/jython:1-5683 Modified: branches/astwrite/Lib/test/test_genexps.py =================================================================== --- branches/astwrite/Lib/test/test_genexps.py 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/Lib/test/test_genexps.py 2008-12-03 18:28:54 UTC (rev 5684) @@ -1,9 +1,8 @@ -#From http://svn.python.org/projects/python/branches/release25-maint/Lib/test_genexps.py@51333 +# From http://svn.python.org/projects/python/branches/release25-maint/Lib/test_genexps.py@51333 -#Ignoring details of SyntaxError for now -- justified I think for "invalid +# Ignoring details of SyntaxError for now -- justified I think for "invalid # syntax" since that #message has very little info, where Antlr provides more -# detail. The others really are #differences that should be addressed, but I -# want to concentrate on the other errors for now. +# detail. doctests = """ Copied: branches/astwrite/Lib/test/test_genexps_jy.py (from rev 5682, trunk/jython/Lib/test/test_genexps_jy.py) =================================================================== --- branches/astwrite/Lib/test/test_genexps_jy.py (rev 0) +++ branches/astwrite/Lib/test/test_genexps_jy.py 2008-12-03 18:28:54 UTC (rev 5684) @@ -0,0 +1,23 @@ +"""Misc generator expression tests + +Made for Jython. +""" +import unittest +from test import test_support + +locals_test = list(local for local in locals() if not local.startswith('_')) + +class GeneratorExpressionsTestCase(unittest.TestCase): + + def test_module_level_locals(self): + # NOTE: The locals_test genexp used to cause a 'dictionary + # changed size during iteration' RuntimeError. If we've gotten + # this far we've already passed + self.assert_(sorted(locals_test) == ['test_support', 'unittest']) + + +def test_main(): + test_support.run_unittest(GeneratorExpressionsTestCase) + +if __name__ == '__main__': + test_main() Modified: branches/astwrite/Lib/test/test_stringmap.py =================================================================== --- branches/astwrite/Lib/test/test_stringmap.py 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/Lib/test/test_stringmap.py 2008-12-03 18:28:54 UTC (rev 5684) @@ -62,7 +62,10 @@ for i in r.keys(): self.assert_(d.has_key(i)) self.assert_(i in d) - + + # Test unhashability + self.assertRaises(TypeError, hash, d) + def test_stringmap_in_mapping(self): class A: def __init__(self): Modified: branches/astwrite/Lib/test/test_subprocess_jy.py =================================================================== --- branches/astwrite/Lib/test/test_subprocess_jy.py 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/Lib/test/test_subprocess_jy.py 2008-12-03 18:28:54 UTC (rev 5684) @@ -14,10 +14,30 @@ stdout=PIPE) self.assertEquals('something', p1.stdout.read()) + +# tests for (some parts of) issue #1187: JYTHON_OPTS should not be enriched by arguments +class JythonOptsTest(unittest.TestCase): + def testNoJythonOpts(self): + os.environ['JYTHON_OPTS'] = '' + p1 = Popen([sys.executable, "-c", + 'import os, sys; sys.stdout.write(os.environ["JYTHON_OPTS"])'], + stdout=PIPE) + self.assertEquals('', p1.stdout.read()) + + def testExistingJythonOpts(self): + options = '-Qold -Qwarn' + os.environ['JYTHON_OPTS'] = options + p1 = Popen([sys.executable, "-c", + 'import os, sys; sys.stdout.write(os.environ["JYTHON_OPTS"])'], + stdout=PIPE) + self.assertEquals(options, p1.stdout.read()) + def test_main(): - test_support.run_unittest(EnvironmentInheritanceTest) + test_classes = ( + EnvironmentInheritanceTest, + JythonOptsTest, + ) + test_support.run_unittest(*test_classes) if __name__ == '__main__': test_main() - - Modified: branches/astwrite/build.xml =================================================================== --- branches/astwrite/build.xml 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/build.xml 2008-12-03 18:28:54 UTC (rev 5684) @@ -526,7 +526,7 @@ <zipfileset src="extlibs/jna-posix.jar"/> <!-- <rule pattern="com.sun.jna.**" result="org.python.jna.@1"/> --> <rule pattern="org.jruby.ext.posix.**" result="org.python.posix.@1"/> - <zipfileset src="extlibs/constantine.jar"/> + <zipfileset src="extlibs/constantine-0.4.jar"/> <rule pattern="com.kenai.constantine.**" result="org.python.constantine.@1"/> </jarjar> <unjar src="${output.dir}/jarjar.jar" dest="${jarjar.dir}"> Copied: branches/astwrite/extlibs/constantine-0.4.jar (from rev 5682, trunk/jython/extlibs/constantine-0.4.jar) =================================================================== (Binary files differ) Deleted: branches/astwrite/extlibs/constantine.jar =================================================================== (Binary files differ) Modified: branches/astwrite/src/org/python/antlr/GrammarActions.java =================================================================== --- branches/astwrite/src/org/python/antlr/GrammarActions.java 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/src/org/python/antlr/GrammarActions.java 2008-12-03 18:28:54 UTC (rev 5684) @@ -2,7 +2,6 @@ import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; -import org.antlr.runtime.tree.Tree; import org.python.core.Py; import org.python.core.PyComplex; Modified: branches/astwrite/src/org/python/antlr/PythonTree.java =================================================================== --- branches/astwrite/src/org/python/antlr/PythonTree.java 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/src/org/python/antlr/PythonTree.java 2008-12-03 18:28:54 UTC (rev 5684) @@ -12,7 +12,6 @@ import java.util.List; public class PythonTree extends AST { - public boolean from_future_checked = false; private int charStartIndex = -1; private int charStopIndex = -1; @@ -449,5 +448,4 @@ child.setParent(this); } } - } Modified: branches/astwrite/src/org/python/compiler/CodeCompiler.java =================================================================== --- branches/astwrite/src/org/python/compiler/CodeCompiler.java 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/src/org/python/compiler/CodeCompiler.java 2008-12-03 18:28:54 UTC (rev 5684) @@ -2180,7 +2180,6 @@ @Override public Object visitGeneratorExp(GeneratorExp node) throws Exception { String bound_exp = "_(x)"; - String tmp_append ="_(" + node.getLine() + "_" + node.getCharPositionInLine() + ")"; setline(node); @@ -2220,7 +2219,7 @@ java.util.List<stmtType> bod = new ArrayList<stmtType>(); bod.add(n); - module.PyCode(new Suite(node, bod), tmp_append, true, + module.PyCode(new Suite(node, bod), "<genexpr>", true, className, false, false, node.getLine(), scope, cflags).get(code); @@ -2230,19 +2229,15 @@ } else { code.invokespecial( "org/python/core/PyFunction", "<init>", "(" + $pyObj + $pyObjArr + $pyCode + $pyObj + $pyObjArr + ")V"); } + int genExp = storeTop(); - set(new Name(node, tmp_append, expr_contextType.Store)); - visit(iter); - visit(new Name(node, tmp_append, expr_contextType.Load)); + code.aload(genExp); + code.freeLocal(genExp); code.swap(); code.invokevirtual("org/python/core/PyObject", "__iter__", "()Lorg/python/core/PyObject;"); code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $pyObj + ")" + $pyObj); - java.util.List<exprType> targets = new ArrayList<exprType>(); - targets.add(new Name(n, tmp_append, expr_contextType.Del)); - visit(new Delete(n, targets)); - return null; } Modified: branches/astwrite/src/org/python/core/PyDataDescr.java =================================================================== --- branches/astwrite/src/org/python/core/PyDataDescr.java 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/src/org/python/core/PyDataDescr.java 2008-12-03 18:28:54 UTC (rev 5684) @@ -75,9 +75,12 @@ @ExposedMethod public void getset_descriptor___set__(PyObject obj, PyObject value) { checkGetterType(obj.getType()); + // XXX: We may want to special case value being PyUnicode and ofType being String + // (then explicitly value.encode() first) Object converted = value.__tojava__(ofType); if(converted == Py.NoConversion) { - throw Py.TypeError(""); // xxx + throw Py.TypeError(String.format("unsupported type for assignment to %s: '%.200s'", + name, value.getType().fastGetName())); } invokeSet(obj, converted); } Modified: branches/astwrite/src/org/python/core/PyStringMap.java =================================================================== --- branches/astwrite/src/org/python/core/PyStringMap.java 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/src/org/python/core/PyStringMap.java 2008-12-03 18:28:54 UTC (rev 5684) @@ -500,4 +500,8 @@ return pyKey; } } + + public int hashCode() { + throw Py.TypeError(String.format("unhashable type: '%.200s'", getType().fastGetName())); + } } Modified: branches/astwrite/src/org/python/core/PySystemState.java =================================================================== --- branches/astwrite/src/org/python/core/PySystemState.java 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/src/org/python/core/PySystemState.java 2008-12-03 18:28:54 UTC (rev 5684) @@ -34,6 +34,7 @@ protected static final String CACHEDIR_DEFAULT_NAME = "cachedir"; public static final String JYTHON_JAR = "jython.jar"; + public static final String JYTHON_COMPLETE_JAR = "jython-complete.jar"; private static final String JAR_URL_PREFIX = "jar:file:"; private static final String JAR_SEPARATOR = "!"; @@ -392,10 +393,14 @@ if (root == null) { String classpath = preProperties.getProperty("java.class.path"); if (classpath != null) { - int jpy = classpath.toLowerCase().indexOf(JYTHON_JAR); - if (jpy >= 0) { - int start = classpath.lastIndexOf(java.io.File.pathSeparator, jpy) + 1; - root = classpath.substring(start, jpy); + String lowerCaseClasspath = classpath.toLowerCase(); + int jarIndex = lowerCaseClasspath.indexOf(JYTHON_COMPLETE_JAR); + if (jarIndex < 0) { + jarIndex = lowerCaseClasspath.indexOf(JYTHON_JAR); + } + if (jarIndex >= 0) { + int start = classpath.lastIndexOf(java.io.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 root = jarFileName; Modified: branches/astwrite/src/org/python/expose/generate/DescriptorExposer.java =================================================================== --- branches/astwrite/src/org/python/expose/generate/DescriptorExposer.java 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/src/org/python/expose/generate/DescriptorExposer.java 2008-12-03 18:28:54 UTC (rev 5684) @@ -139,7 +139,7 @@ mv.visitVarInsn(ALOAD, 1); mv.visitTypeInsn(CHECKCAST, onType.getInternalName()); call(onType, getterMethodName, ofType); - if(PRIMITIVES.containsKey(ofType)) { + if(PRIMITIVES.containsKey(ofType) || ofType.equals(STRING)) { toPy(ofType); } endMethod(ARETURN); @@ -153,7 +153,7 @@ onType.getInternalName(), getterFieldName, ofType.getDescriptor()); - if(PRIMITIVES.containsKey(ofType)) { + if(PRIMITIVES.containsKey(ofType) || ofType.equals(STRING)) { toPy(ofType); } endMethod(ARETURN); Modified: branches/astwrite/src/org/python/expose/generate/Exposer.java =================================================================== --- branches/astwrite/src/org/python/expose/generate/Exposer.java 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/src/org/python/expose/generate/Exposer.java 2008-12-03 18:28:54 UTC (rev 5684) @@ -5,6 +5,7 @@ import org.python.objectweb.asm.ClassVisitor; import org.python.objectweb.asm.ClassWriter; +import org.python.objectweb.asm.Label; import org.python.objectweb.asm.MethodVisitor; import org.python.objectweb.asm.Opcodes; import org.python.objectweb.asm.Type; @@ -228,7 +229,16 @@ if(inputType.equals(VOID)) { getStatic(PY, "None", PYOBJ); } else if(inputType.equals(STRING)) { + Label newString = new Label(); + Label end = new Label(); + mv.visitInsn(DUP); + mv.visitJumpInsn(IFNONNULL, newString); + mv.visitInsn(POP); + getStatic(PY, "None", PYOBJ); + mv.visitJumpInsn(GOTO, end); + mv.visitLabel(newString); callStatic(PY, "newString", PYSTR, STRING); + mv.visitLabel(end); } else if(inputType.equals(BOOLEAN)) { callStatic(PY, "newBoolean", PYBOOLEAN, BOOLEAN); } else if(inputType.equals(INT) || inputType.equals(BYTE) || inputType.equals(SHORT)) { Modified: branches/astwrite/src/org/python/modules/zipimport/zipimporter.java =================================================================== --- branches/astwrite/src/org/python/modules/zipimport/zipimporter.java 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/src/org/python/modules/zipimport/zipimporter.java 2008-12-03 18:28:54 UTC (rev 5684) @@ -50,12 +50,12 @@ "a zipfile. ZipImportError is raised if 'archivepath' doesn't point to\n" + "a valid Zip archive."); - /** zip_searchorder defines how we search for a module in the Zip + /** zipSearchOrder defines how we search for a module in the Zip * archive */ static enum EntryType { IS_SOURCE, IS_BYTECODE, IS_PACKAGE }; - static final SearchOrderEntry[] zip_searchorder = new SearchOrderEntry[] { + static final SearchOrderEntry[] zipSearchOrder = new SearchOrderEntry[] { new SearchOrderEntry(File.separator + "__init__$py.class", EnumSet.of(EntryType.IS_PACKAGE, EntryType.IS_BYTECODE)), new SearchOrderEntry(File.separator + "__init__.py", @@ -126,9 +126,7 @@ break; } - String childFile = pathFile.getPath(); - prefix = childFile.substring(childFile.lastIndexOf(File.separator) + 1) - + File.separator + prefix; + prefix = pathFile.getName() + File.separator + prefix; pathFile = parentFile; } @@ -364,8 +362,7 @@ private ModuleInfo getModuleInfo(String fullname) { String path = makeFilename(prefix, getSubname(fullname)); - for (int i = 0; i < zip_searchorder.length; i++) { - SearchOrderEntry entry = zip_searchorder[i]; + for (SearchOrderEntry entry : zipSearchOrder) { PyObject tocEntry = files.__finditem__(path + entry.suffix); if (tocEntry == null) continue; @@ -392,8 +389,7 @@ return null; } - for (int i = 0; i < zip_searchorder.length; i++) { - SearchOrderEntry entry = zip_searchorder[i]; + for (SearchOrderEntry entry : zipSearchOrder) { String suffix = entry.suffix; String searchPath = path + suffix; @@ -606,7 +602,12 @@ @ExposedMethod(names = "__repr__") final String zipimporter_toString() { - return "<zipimporter object \"" + archive + "\">"; + String displayArchive = archive != null ? archive : "???"; + if (prefix != null && !"".equals(prefix)) { + return String.format("<zipimporter object \"%.300s%c%.150s\">", + displayArchive, File.separatorChar, prefix); + } + return String.format("<zipimporter object \"%.300s\">", displayArchive); } /** Modified: branches/astwrite/src/shell/jython =================================================================== --- branches/astwrite/src/shell/jython 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/src/shell/jython 2008-12-03 18:28:54 UTC (rev 5684) @@ -43,16 +43,24 @@ JAVA_CMD=("$JAVA_HOME/bin/java") fi +# try to dynamically determine jython home +# (this script typically resides in jython home, or in the /bin subdirectory) if [ -z "$JYTHON_HOME" ] ; then if [ "$PRG" = "./jython" ] ; then - # current dir is /bin dir - JYTHON_HOME_1=`pwd` # the ./bin dir - JYTHON_HOME=`dirname "$JYTHON_HOME_1"` # the . dir + # current dir is the script dir + JYTHON_HOME_1=`pwd` else - # current dir is not /bin dir - JYTHON_HOME_1=`dirname "$PRG"` # the ./bin dir - JYTHON_HOME=`dirname "$JYTHON_HOME_1"` # the . dir + # current dir is not the script dir + JYTHON_HOME_1=`dirname "$PRG"` fi + if [ -f "$JYTHON_HOME_1"/jython-complete.jar -o -f "$JYTHON_HOME_1"/jython.jar ] ; then + JYTHON_HOME="$JYTHON_HOME_1" + else + JYTHON_HOME=`dirname "$JYTHON_HOME_1"` + fi + if [ ! -f "$JYTHON_HOME"/jython-complete.jar -a ! -f "$JYTHON_HOME"/jython.jar ] ; then + JYTHON_HOME="$JYTHON_HOME_FALLBACK" + fi fi if [ -z "$JYTHON_OPTS" ] ; then @@ -117,6 +125,10 @@ -D*) python_args=("${python_args[@]}" "$1") ;; + # Print the command, don't execute it + --print) + print_requested=true + ;; # Run with the instrumented profiler: http://jiprof.sourceforge.net/ --profile) rm -f profile.txt # XXX do this? @@ -189,12 +201,17 @@ [ -n "$profile_requested" ] && echo "Running with instrumented profiler" java_args=("${java_args[@]}" -classpath "$CP$CP_DELIMITER$CLASSPATH") else - if [ -z $help_requested ] ; then + if [ -z "$help_requested" -a -z "$print_requested" ] ; then JAVA_CMD=(exec "${JAVA_CMD[@]}") fi - java_args=("${java_args[@]}" -Xbootclasspath/a:"$CP" -classpath "$CLASSPATH") + java_args=("${java_args[@]}" -Xbootclasspath/a:"$CP") + [ -n "$CLASSPATH" ] && java_args=("${java_args[@]}" -classpath "$CLASSPATH") fi +if [ -n "$print_requested" ] ; then + JAVA_CMD=(echo $JAVA_CMD) +fi + "${JAVA_CMD[@]}" $JAVA_OPTS "${java_args[@]}" -Dpython.home="$JYTHON_HOME" \ -Dpython.executable="$PRG" org.python.util.jython $JYTHON_OPTS "$@" @@ -205,6 +222,7 @@ echo "Jython launcher options:" >&2 echo "-Jarg : pass argument through to Java VM (e.g. -J-Xmx512m)" >&2 echo "--jdb : run under JDB" >&2 + echo "--print : print the Java command instead of executing it" >&2 echo "--profile: run with the Java Interactive Profiler (http://jiprof.sf.net)" >&2 echo "--verify : enable bytecode verifier for Jython classes (for development)" >&2 echo "-- : pass remaining arguments through to Jython" >&2 Modified: branches/astwrite/src/shell/jython.bat =================================================================== --- branches/astwrite/src/shell/jython.bat 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/src/shell/jython.bat 2008-12-03 18:28:54 UTC (rev 5684) @@ -24,6 +24,13 @@ set _JAVA_CMD="%JAVA_HOME:"=%\bin\java" ) +rem remove surrounding quotes from jython opts, to be able to safely empty-test it +set _TRIMMED_JYTHON_OPTS=%JYTHON_OPTS% +for /f "useback tokens=*" %%a in ('%_TRIMMED_JYTHON_OPTS%') do set _TRIMMED_JYTHON_OPTS=%%~a +if not "%_TRIMMED_JYTHON_OPTS%"=="" ( + set _JYTHON_OPTS="%_TRIMMED_JYTHON_OPTS%" +) + rem remove surrounding quotes from jython home, to be able to safely empty-test it set _TRIMMED_JYTHON_HOME=%JYTHON_HOME% for /f "useback tokens=*" %%a in ('%_TRIMMED_JYTHON_HOME%') do set _TRIMMED_JYTHON_HOME=%%~a @@ -31,9 +38,22 @@ set _JYTHON_HOME="%_TRIMMED_JYTHON_HOME%" goto gotHome ) + +rem try to dynamically determine jython home +rem (this script typically resides in jython home, or in the /bin subdirectory) +pushd "%~dp0%" +set _JYTHON_HOME="%CD%" +popd +if exist %_JYTHON_HOME%\jython.jar goto gotHome +if exist %_JYTHON_HOME%\jython-complete.jar goto gotHome pushd "%~dp0%\.." set _JYTHON_HOME="%CD%" popd +if exist %_JYTHON_HOME%\jython.jar goto gotHome +if exist %_JYTHON_HOME%\jython-complete.jar goto gotHome +rem jython home fallback (if all else fails) +rem if present, %JYTHON_HOME_FALLBACK% is already quoted +set _JYTHON_HOME=%JYTHON_HOME_FALLBACK% :gotHome if not exist %_JYTHON_HOME%\jython.jar goto tryComplete @@ -49,7 +69,7 @@ if exist %_JYTHON_HOME%/jython-complete.jar goto run echo Cannot find jython.jar or jython-complete.jar in %_JYTHON_HOME% -echo Try running this batch file from the 'bin' directory of an installed Jython +echo Try running this batch file from the 'bin' directory of an installed Jython, echo or setting JYTHON_HOME. goto cleanup @@ -68,6 +88,7 @@ set _ARGS=%_ARGS:"=_D% set _ARGS="%_ARGS%" +set _JYTHON_ARGS= :scanArgs rem split args by spaces into first and rest @@ -121,7 +142,7 @@ if "%_CMP2:"=\\%" == "-J" goto jvmArg :jythonArg -set JYTHON_OPTS=%JYTHON_OPTS% %_CMP% +set _JYTHON_ARGS=%_JYTHON_ARGS% %_CMP% goto nextArg :jvmArg @@ -140,7 +161,7 @@ goto scanArgs :argsDone -%_JAVA_CMD% %_JAVA_OPTS% %_JAVA_STACK% -Xbootclasspath/a:%_CP% -Dpython.home=%_JYTHON_HOME% -Dpython.executable="%~f0" -classpath "%CLASSPATH%" org.python.util.jython %JYTHON_OPTS% %_ARGS% +%_JAVA_CMD% %_JAVA_OPTS% %_JAVA_STACK% -Xbootclasspath/a:%_CP% -Dpython.home=%_JYTHON_HOME% -Dpython.executable="%~f0" -classpath "%CLASSPATH%" org.python.util.jython %_JYTHON_OPTS% %_JYTHON_ARGS% %_ARGS% set E=%ERRORLEVEL% :cleanup @@ -153,8 +174,11 @@ set _JAVA_OPTS= set _JAVA_STACK= set _JYTHON_HOME= +set _JYTHON_OPTS= +set _JYTHON_ARGS= set _TRIMMED_JAVA_HOME= set _TRIMMED_JYTHON_HOME= +set _TRIMMED_JYTHON_OPTS= :finish exit /b %E% Modified: branches/astwrite/tests/java/org/python/expose/generate/DescriptorExposerTest.java =================================================================== --- branches/astwrite/tests/java/org/python/expose/generate/DescriptorExposerTest.java 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/tests/java/org/python/expose/generate/DescriptorExposerTest.java 2008-12-03 18:28:54 UTC (rev 5684) @@ -76,7 +76,17 @@ assertFalse(instance.implementsDescrSet()); assertFalse(instance.implementsDescrDelete()); } + + public void testNullReturns() throws Exception { + PyDataDescr instance = makeDescriptor(new DescSetup() { + public void setup(DescriptorExposer de) { + de.addFieldGetter("nullString", STRING); + } + }); + assertEquals(Py.None, instance.__get__(se, PY_TYPE)); + } + public void testMethodSetter() throws Exception { PyDataDescr instance = makeDescriptor(new DescSetup() { @@ -224,5 +234,7 @@ public boolean bool; public String toStringVal = SimpleExposed.TO_STRING_RETURN; + + public String nullString = null; } } Modified: branches/astwrite/tests/java/org/python/expose/generate/ExposedTypeProcessorTest.java =================================================================== --- branches/astwrite/tests/java/org/python/expose/generate/ExposedTypeProcessorTest.java 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/tests/java/org/python/expose/generate/ExposedTypeProcessorTest.java 2008-12-03 18:28:54 UTC (rev 5684) @@ -18,7 +18,7 @@ .getResourceAsStream("org/python/expose/generate/SimpleExposed.class"); ExposedTypeProcessor ice = new ExposedTypeProcessor(in); assertEquals("simpleexposed", ice.getName()); - assertEquals(18, ice.getMethodExposers().size()); + assertEquals(19, ice.getMethodExposers().size()); assertNotNull(ice.getNewExposer()); assertEquals(1, ice.getDescriptorExposers().size()); assertEquals("simpleexposed", ice.getTypeExposer().getName()); Modified: branches/astwrite/tests/java/org/python/expose/generate/MethodExposerTest.java =================================================================== --- branches/astwrite/tests/java/org/python/expose/generate/MethodExposerTest.java 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/tests/java/org/python/expose/generate/MethodExposerTest.java 2008-12-03 18:28:54 UTC (rev 5684) @@ -189,6 +189,10 @@ assertEquals("a", createBound("charReturn", CHAR).__call__().toString()); } + public void testNullReturns() throws Exception { + assertEquals(Py.None, createBound("stringReturnNull", STRING).__call__()); + } + public void testClassMethod() throws Exception { ClassMethodExposer exp = new ClassMethodExposer(Type.getType(SimpleExposed.class), Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, Modified: branches/astwrite/tests/java/org/python/expose/generate/SimpleExposed.java =================================================================== --- branches/astwrite/tests/java/org/python/expose/generate/SimpleExposed.java 2008-12-03 17:59:13 UTC (rev 5683) +++ branches/astwrite/tests/java/org/python/expose/generate/SimpleExposed.java 2008-12-03 18:28:54 UTC (rev 5684) @@ -123,6 +123,11 @@ return 'a'; } + @ExposedMethod + public String stringReturnNull() { + return null; + } + @ExposedClassMethod public static char classmethod(PyType onType) { return 'a'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |