From: <fwi...@us...> - 2009-07-17 04:28:58
|
Revision: 6540 http://jython.svn.sourceforge.net/jython/?rev=6540&view=rev Author: fwierzbicki Date: 2009-07-17 04:28:55 +0000 (Fri, 17 Jul 2009) Log Message: ----------- Simplest possible test of InvokeDynamic embedded in Jython. Used R?\195?\169mi Forax's 292 backport, just because I got it working before I got an MLVM patched JDK 7 working. Modified Paths: -------------- branches/indy/build.xml Added Paths: ----------- branches/indy/extlibs/asm-all-3.2.jar branches/indy/extlibs/jsr292-backport.jar branches/indy/extlibs/jsr292-mock.jar branches/indy/src/org/python/compiler/IndyTest.java Modified: branches/indy/build.xml =================================================================== --- branches/indy/build.xml 2009-07-15 20:05:51 UTC (rev 6539) +++ branches/indy/build.xml 2009-07-17 04:28:55 UTC (rev 6540) @@ -115,12 +115,11 @@ <target name="init" depends="version-init"> <property name="build.compiler" value="modern" /> - <property name="jdk.target.version" value="1.5" /> - <property name="jdk.source.version" value="1.5" /> + <property name="jdk.target.version" value="1.7" /> + <property name="jdk.source.version" value="1.7" /> <property name="deprecation" value="true" /> <property name="debug" value="true" /> <property name="nowarn" value="false" /> - <property name="javac.Xlint" value="-Xlint -Xlint:-serial -Xlint:-unchecked -Xlint:-cast"/> <!-- properties work.dir and jython.base.dir are also defined in full-preinit --> <property name="work.dir" value="${basedir}" /> @@ -141,7 +140,11 @@ <property name="dist.dir" value="${work.dir}/dist" /> <property name="apidoc.dir" value="${dist.dir}/Doc/javadoc" /> <property name="junit.reports" value="${dist.dir}/testreports" /> + <property name="javac.Xlint" value="-Xlint -Xlint:-serial -Xlint:-unchecked -Xlint:-cast -Xbootclasspath/p:${extlibs.dir}/jsr292-mock.jar"/> + <!-- + <property name="javac.Xlint" value="-Xlint -Xlint:-serial -XDinvokedynamic -Xlint:-unchecked -Xlint:-cast"/> + --> <!-- classpaths --> <path id="main.classpath"> <pathelement path="${extlibs.dir}/libreadline-java-0.8.jar" /> @@ -155,10 +158,10 @@ <pathelement path="${extlibs.dir}/antlr-3.1.3.jar" /> <pathelement path="${extlibs.dir}/stringtemplate-3.2.jar" /> - <pathelement path="${extlibs.dir}/asm-3.1.jar" /> - <pathelement path="${extlibs.dir}/asm-commons-3.1.jar" /> + <pathelement path="${extlibs.dir}/asm-all-3.2.jar" /> <pathelement path="${extlibs.dir}/constantine-0.4.jar" /> <pathelement path="${extlibs.dir}/jna-posix.jar"/> + <pathelement path="${extlibs.dir}/jsr292-mock.jar"/> </path> <available property="informix.present" classname="com.informix.jdbc.IfxDriver" classpath="${informix.jar}" /> @@ -166,7 +169,7 @@ <path id="test.classpath"> <path refid="main.classpath"/> - <pathelement path="${extlibs.dir}/asm-commons-3.1.jar" /> + <pathelement path="${extlibs.dir}/asm-all-3.2.jar" /> <pathelement path="${extlibs.dir}/junit-3.8.2.jar" /> <pathelement path="${exposed.dir}" /> <pathelement path="${compile.dir}" /> @@ -548,9 +551,7 @@ <zipfileset src="${dist.dir}/${jython.dev.jar}"/> <zipfileset src="extlibs/antlr-runtime-3.1.3.jar"/> <rule pattern="org.antlr.runtime.**" result="org.python.antlr.runtime.@1"/> - <zipfileset src="extlibs/asm-3.1.jar"/> - <zipfileset src="extlibs/asm-commons-3.1.jar"/> - <zipfileset src="extlibs/asm-util-3.1.jar"/> + <zipfileset src="extlibs/asm-all-3.2.jar"/> <rule pattern="org.objectweb.asm.**" result="org.python.objectweb.asm.@1"/> <zipfileset src="extlibs/jna.jar"/> <zipfileset src="extlibs/jna-posix.jar"/> Added: branches/indy/extlibs/asm-all-3.2.jar =================================================================== (Binary files differ) Property changes on: branches/indy/extlibs/asm-all-3.2.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: branches/indy/extlibs/jsr292-backport.jar =================================================================== (Binary files differ) Property changes on: branches/indy/extlibs/jsr292-backport.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: branches/indy/extlibs/jsr292-mock.jar =================================================================== (Binary files differ) Property changes on: branches/indy/extlibs/jsr292-mock.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: branches/indy/src/org/python/compiler/IndyTest.java =================================================================== --- branches/indy/src/org/python/compiler/IndyTest.java (rev 0) +++ branches/indy/src/org/python/compiler/IndyTest.java 2009-07-17 04:28:55 UTC (rev 6540) @@ -0,0 +1,27 @@ +package org.python.compiler; + +import java.dyn.CallSite; +import java.dyn.InvokeDynamic; +import java.dyn.Linkage; +import java.dyn.MethodType; +import java.dyn.MethodHandles; +import java.dyn.MethodType; + +import org.python.core.Py; +import org.python.core.PyString; + +public class IndyTest { + + public static void run() { + PyString result = InvokeDynamic.<PyString>sayHello("Hello Indy!"); + System.out.println(result); + } + + static { Linkage.registerBootstrapMethod("linkDynamic"); } + private static CallSite linkDynamic(Class<?> caller, String name, MethodType type) { + CallSite c = new CallSite(caller, name, type); + c.setTarget(MethodHandles.lookup().findStatic(Py.class, "newString", + MethodType.make(PyString.class, String.class))); + return c; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-11 05:00:19
|
Revision: 6661 http://jython.svn.sourceforge.net/jython/?rev=6661&view=rev Author: fwierzbicki Date: 2009-08-11 05:00:06 +0000 (Tue, 11 Aug 2009) Log Message: ----------- Merged revisions 6525-6539,6543-6550,6552-6558,6566-6568,6570-6571,6575,6580-6623,6626-6659 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython Modified Paths: -------------- branches/indy/.classpath branches/indy/CoreExposed.includes branches/indy/Lib/_rawffi.py branches/indy/Lib/codeop.py branches/indy/Lib/datetime.py branches/indy/Lib/dbexts.py branches/indy/Lib/fileinput.py branches/indy/Lib/isql.py branches/indy/Lib/javapath.py branches/indy/Lib/javashell.py branches/indy/Lib/os.py branches/indy/Lib/pawt/__init__.py branches/indy/Lib/pawt/colors.py branches/indy/Lib/pawt/swing.py branches/indy/Lib/pkgutil.py branches/indy/Lib/posixpath.py branches/indy/Lib/readline.py branches/indy/Lib/signal.py branches/indy/Lib/socket.py branches/indy/Lib/subprocess.py branches/indy/Lib/telnetlib.py branches/indy/Lib/test/Graph.py branches/indy/Lib/test/anygui.py branches/indy/Lib/test/jser2_classes.py branches/indy/Lib/test/regrtest.py branches/indy/Lib/test/test_SimpleXMLRPCServer.py branches/indy/Lib/test/test__rawffi.py branches/indy/Lib/test/test_array_jy.py branches/indy/Lib/test/test_ast_jy.py branches/indy/Lib/test/test_bigmem.py branches/indy/Lib/test/test_builtin.py branches/indy/Lib/test/test_builtin_jy.py branches/indy/Lib/test/test_cmath_jy.py branches/indy/Lib/test/test_codeop.py branches/indy/Lib/test/test_codeop_jy.py branches/indy/Lib/test/test_coerce_jy.py branches/indy/Lib/test/test_compile_jy.py branches/indy/Lib/test/test_concat_jy.py branches/indy/Lib/test/test_descr_jy.py branches/indy/Lib/test/test_dict2java.py branches/indy/Lib/test/test_exceptions_jy.py branches/indy/Lib/test/test_float_jy.py branches/indy/Lib/test/test_func_syntax_jy.py branches/indy/Lib/test/test_grammar_jy.py branches/indy/Lib/test/test_import_jy.py branches/indy/Lib/test/test_importhooks.py branches/indy/Lib/test/test_java_integration.py branches/indy/Lib/test/test_java_list_delegate.py branches/indy/Lib/test/test_java_subclasses.py branches/indy/Lib/test/test_java_visibility.py branches/indy/Lib/test/test_javalist.py branches/indy/Lib/test/test_javashell.py branches/indy/Lib/test/test_jbasic.py branches/indy/Lib/test/test_joverload.py branches/indy/Lib/test/test_jser.py branches/indy/Lib/test/test_jy_generators.py branches/indy/Lib/test/test_jy_internals.py branches/indy/Lib/test/test_list_jy.py branches/indy/Lib/test/test_marshal.py branches/indy/Lib/test/test_metaclass_support/simpleclass.py branches/indy/Lib/test/test_module.py branches/indy/Lib/test/test_pbcvm.py branches/indy/Lib/test/test_pythoninterpreter_jy.py branches/indy/Lib/test/test_random.py branches/indy/Lib/test/test_re.py branches/indy/Lib/test/test_re_jy.py branches/indy/Lib/test/test_sax.py branches/indy/Lib/test/test_sax_jy.py branches/indy/Lib/test/test_set_jy.py branches/indy/Lib/test/test_socket.py branches/indy/Lib/test/test_sort.py branches/indy/Lib/test/test_sort_jy.py branches/indy/Lib/test/test_str2unicode.py branches/indy/Lib/test/test_stringmap.py branches/indy/Lib/test/test_subclasses.py branches/indy/Lib/test/test_subclasses_jy.py branches/indy/Lib/test/test_sys_jy.py branches/indy/Lib/test/test_thread_jy.py branches/indy/Lib/test/test_thread_local.py branches/indy/Lib/test/test_threading.py branches/indy/Lib/test/test_threading_jy.py branches/indy/Lib/test/test_timeit.py branches/indy/Lib/test/test_trace.py branches/indy/Lib/test/test_trace_threaded.py branches/indy/Lib/test/test_tuple.py branches/indy/Lib/test/test_unicode_jy.py branches/indy/Lib/test/test_userdict.py branches/indy/Lib/test/test_weakref.py branches/indy/Lib/test/test_with.py branches/indy/Lib/test/test_xml_etree_jy.py branches/indy/Lib/test/test_zipimport_jy.py branches/indy/Lib/test/whrandom.py branches/indy/Lib/test/zxjdbc/dbextstest.py branches/indy/Lib/test/zxjdbc/jndi.py branches/indy/Lib/test/zxjdbc/runner.py branches/indy/Lib/test/zxjdbc/sptest.py branches/indy/Lib/test/zxjdbc/test_zxjdbc_dbapi20.py branches/indy/Lib/test/zxjdbc/zxtest.py branches/indy/Lib/threading.py branches/indy/Lib/unicodedata.py branches/indy/Lib/xml/Uri.py branches/indy/Lib/xml/dom/minidom.py branches/indy/Lib/xml/dom/pulldom.py branches/indy/Lib/xml/parsers/expat.py branches/indy/Lib/xml/sax/_exceptions.py branches/indy/Lib/xml/sax/drivers2/drv_javasax.py branches/indy/Lib/xml/sax/handler.py branches/indy/Lib/xml/sax/saxutils.py branches/indy/Lib/zlib.py branches/indy/NEWS branches/indy/ast/asdl_antlr.py branches/indy/grammar/Base.g branches/indy/grammar/Python.g branches/indy/grammar/PythonPartial.g branches/indy/src/com/xhaus/modjy/ModjyJServlet.java branches/indy/src/com/ziclix/python/sql/DataHandler.java branches/indy/src/com/ziclix/python/sql/Fetch.java branches/indy/src/com/ziclix/python/sql/JDBC20DataHandler.java branches/indy/src/com/ziclix/python/sql/Jython22DataHandler.java branches/indy/src/com/ziclix/python/sql/PyConnection.java branches/indy/src/com/ziclix/python/sql/PyCursor.java branches/indy/src/com/ziclix/python/sql/PyExtendedCursor.java branches/indy/src/com/ziclix/python/sql/PyStatement.java branches/indy/src/com/ziclix/python/sql/handler/InformixDataHandler.java branches/indy/src/com/ziclix/python/sql/handler/MySQLDataHandler.java branches/indy/src/com/ziclix/python/sql/handler/OracleDataHandler.java branches/indy/src/com/ziclix/python/sql/util/PyArgParser.java branches/indy/src/com/ziclix/python/sql/util/Queue.java branches/indy/src/com/ziclix/python/sql/zxJDBC.java branches/indy/src/org/python/antlr/AST.java branches/indy/src/org/python/antlr/BaseParser.java branches/indy/src/org/python/antlr/GrammarActions.java branches/indy/src/org/python/antlr/ParseException.java branches/indy/src/org/python/antlr/PythonErrorNode.java branches/indy/src/org/python/antlr/PythonTokenSource.java branches/indy/src/org/python/antlr/PythonTree.java branches/indy/src/org/python/antlr/PythonTreeAdaptor.java branches/indy/src/org/python/antlr/adapter/AliasAdapter.java branches/indy/src/org/python/antlr/adapter/AstAdapters.java branches/indy/src/org/python/antlr/adapter/CmpopAdapter.java branches/indy/src/org/python/antlr/adapter/ComprehensionAdapter.java branches/indy/src/org/python/antlr/adapter/ExcepthandlerAdapter.java branches/indy/src/org/python/antlr/adapter/ExprAdapter.java branches/indy/src/org/python/antlr/adapter/IdentifierAdapter.java branches/indy/src/org/python/antlr/adapter/KeywordAdapter.java branches/indy/src/org/python/antlr/adapter/SliceAdapter.java branches/indy/src/org/python/antlr/adapter/StmtAdapter.java branches/indy/src/org/python/antlr/ast/Assert.java branches/indy/src/org/python/antlr/ast/Assign.java branches/indy/src/org/python/antlr/ast/Attribute.java branches/indy/src/org/python/antlr/ast/AugAssign.java branches/indy/src/org/python/antlr/ast/BinOp.java branches/indy/src/org/python/antlr/ast/BoolOp.java branches/indy/src/org/python/antlr/ast/Break.java branches/indy/src/org/python/antlr/ast/Call.java branches/indy/src/org/python/antlr/ast/ClassDef.java branches/indy/src/org/python/antlr/ast/Compare.java branches/indy/src/org/python/antlr/ast/Continue.java branches/indy/src/org/python/antlr/ast/Delete.java branches/indy/src/org/python/antlr/ast/Dict.java branches/indy/src/org/python/antlr/ast/Ellipsis.java branches/indy/src/org/python/antlr/ast/ExceptHandler.java branches/indy/src/org/python/antlr/ast/Exec.java branches/indy/src/org/python/antlr/ast/Expr.java branches/indy/src/org/python/antlr/ast/Expression.java branches/indy/src/org/python/antlr/ast/ExtSlice.java branches/indy/src/org/python/antlr/ast/For.java branches/indy/src/org/python/antlr/ast/FunctionDef.java branches/indy/src/org/python/antlr/ast/GeneratorExp.java branches/indy/src/org/python/antlr/ast/Global.java branches/indy/src/org/python/antlr/ast/If.java branches/indy/src/org/python/antlr/ast/IfExp.java branches/indy/src/org/python/antlr/ast/Import.java branches/indy/src/org/python/antlr/ast/ImportFrom.java branches/indy/src/org/python/antlr/ast/Index.java branches/indy/src/org/python/antlr/ast/Interactive.java branches/indy/src/org/python/antlr/ast/Lambda.java branches/indy/src/org/python/antlr/ast/List.java branches/indy/src/org/python/antlr/ast/ListComp.java branches/indy/src/org/python/antlr/ast/Module.java branches/indy/src/org/python/antlr/ast/Name.java branches/indy/src/org/python/antlr/ast/Num.java branches/indy/src/org/python/antlr/ast/Pass.java branches/indy/src/org/python/antlr/ast/Print.java branches/indy/src/org/python/antlr/ast/Raise.java branches/indy/src/org/python/antlr/ast/Repr.java branches/indy/src/org/python/antlr/ast/Return.java branches/indy/src/org/python/antlr/ast/Slice.java branches/indy/src/org/python/antlr/ast/Str.java branches/indy/src/org/python/antlr/ast/Subscript.java branches/indy/src/org/python/antlr/ast/Suite.java branches/indy/src/org/python/antlr/ast/TryExcept.java branches/indy/src/org/python/antlr/ast/TryFinally.java branches/indy/src/org/python/antlr/ast/Tuple.java branches/indy/src/org/python/antlr/ast/UnaryOp.java branches/indy/src/org/python/antlr/ast/While.java branches/indy/src/org/python/antlr/ast/With.java branches/indy/src/org/python/antlr/ast/Yield.java branches/indy/src/org/python/antlr/ast/alias.java branches/indy/src/org/python/antlr/ast/arguments.java branches/indy/src/org/python/antlr/ast/comprehension.java branches/indy/src/org/python/antlr/ast/keyword.java branches/indy/src/org/python/compiler/AdapterMaker.java branches/indy/src/org/python/compiler/ClassConstants.java branches/indy/src/org/python/compiler/ClassFile.java branches/indy/src/org/python/compiler/Code.java branches/indy/src/org/python/compiler/CodeCompiler.java branches/indy/src/org/python/compiler/IndyTest.java branches/indy/src/org/python/compiler/JavaMaker.java branches/indy/src/org/python/compiler/LineNumberTable.java branches/indy/src/org/python/compiler/Module.java branches/indy/src/org/python/compiler/ProxyMaker.java branches/indy/src/org/python/compiler/ScopeInfo.java branches/indy/src/org/python/compiler/ScopesCompiler.java branches/indy/src/org/python/compiler/SymInfo.java branches/indy/src/org/python/core/ArgParser.java branches/indy/src/org/python/core/MakeProxies.java branches/indy/src/org/python/core/ParserFacade.java branches/indy/src/org/python/core/Py.java branches/indy/src/org/python/core/PyFileWriter.java branches/indy/src/org/python/core/PyFinalizableInstance.java branches/indy/src/org/python/core/PyJavaType.java branches/indy/src/org/python/core/PyList.java branches/indy/src/org/python/core/PyObject.java branches/indy/src/org/python/core/PySystemState.java branches/indy/src/org/python/core/PyTuple.java branches/indy/src/org/python/core/PyType.java branches/indy/src/org/python/core/PythonTraceFunction.java branches/indy/src/org/python/core/StdoutWrapper.java branches/indy/src/org/python/core/__builtin__.java branches/indy/src/org/python/core/codecs.java branches/indy/src/org/python/core/imp.java branches/indy/src/org/python/core/util/StringUtil.java branches/indy/src/org/python/expose/generate/ExposeTask.java branches/indy/src/org/python/modules/Setup.java branches/indy/src/org/python/modules/_collections/Collections.java branches/indy/src/org/python/modules/_collections/PyDeque.java branches/indy/src/org/python/util/GlobMatchingTask.java branches/indy/src/org/python/util/JycompileAntTask.java branches/indy/src/org/python/util/PythonInterpreter.java branches/indy/src/org/python/util/jython.java Added Paths: ----------- branches/indy/Lib/test/import_as_java_class.py branches/indy/Lib/test/static_proxy.py branches/indy/Lib/weakref.py branches/indy/extlibs/livetribe-jsr223-2.0.5.jar branches/indy/src/META-INF/ branches/indy/src/META-INF/services/ branches/indy/src/META-INF/services/javax.script.ScriptEngineFactory branches/indy/src/org/python/core/ContextGuard.java branches/indy/src/org/python/core/ContextManager.java branches/indy/src/org/python/core/PyFileReader.java branches/indy/src/org/python/core/util/PlatformUtil.java branches/indy/src/org/python/jsr223/ branches/indy/src/org/python/jsr223/PyScriptEngine.java branches/indy/src/org/python/jsr223/PyScriptEngineFactory.java branches/indy/src/org/python/jsr223/PyScriptEngineScope.java branches/indy/src/org/python/modules/_threading/ branches/indy/src/org/python/modules/_threading/Condition.java branches/indy/src/org/python/modules/_threading/Lock.java branches/indy/src/org/python/modules/_threading/_threading.java branches/indy/src/org/python/util/CompileProxiesTask.java branches/indy/src/org/python/util/FileNameMatchingTask.java branches/indy/tests/java/org/python/jsr223/ branches/indy/tests/java/org/python/jsr223/ScriptEngineIOTest.java branches/indy/tests/java/org/python/jsr223/ScriptEngineTest.java Removed Paths: ------------- branches/indy/Lib/test/test_bugfixes.py branches/indy/src/META-INF/services/ branches/indy/src/META-INF/services/javax.script.ScriptEngineFactory branches/indy/src/org/python/jsr223/PyScriptEngine.java branches/indy/src/org/python/jsr223/PyScriptEngineFactory.java branches/indy/src/org/python/jsr223/PyScriptEngineScope.java branches/indy/src/org/python/modules/_threading/Condition.java branches/indy/src/org/python/modules/_threading/Lock.java branches/indy/src/org/python/modules/_threading/_threading.java branches/indy/tests/java/org/python/jsr223/ScriptEngineIOTest.java branches/indy/tests/java/org/python/jsr223/ScriptEngineTest.java Property Changed: ---------------- branches/indy/ branches/indy/tests/java/org/python/tests/RedundantInterfaceDeclarations.java Property changes on: branches/indy ___________________________________________________________________ Modified: svnmerge-integrated - /branches/pbcvm:1-6045 /trunk/jython:1-6522 + /branches/pbcvm:1-6045 /trunk/jython:1-6660 Modified: svn:mergeinfo - /branches/newstyle-java-types:5564-5663,5666-5729 + /branches/jsr223:6285-6565 /branches/newstyle-java-types:5564-5663,5666-5729 Modified: branches/indy/.classpath =================================================================== --- branches/indy/.classpath 2009-08-11 03:00:08 UTC (rev 6660) +++ branches/indy/.classpath 2009-08-11 05:00:06 UTC (rev 6661) @@ -20,6 +20,7 @@ <classpathentry kind="lib" path="extlibs/constantine-0.4.jar"/> <classpathentry kind="lib" path="extlibs/jna-posix.jar"/> <classpathentry kind="lib" path="extlibs/mockrunner-0.4.1/jar/jdom.jar"/> - <classpathentry kind="lib" path="extlibs/mockrunner-0.4.1/lib/jdk1.5/j2ee1.3/mockrunner-servlet.jar"/> + <classpathentry kind="lib" path="extlibs/mockrunner-0.4.1/lib/jdk1.5/j2ee1.3/mockrunner-servlet.jar"/> + <classpathentry kind="lib" path="extlibs/jna.jar"/> <classpathentry kind="output" path="bugtests/classes"/> </classpath> Modified: branches/indy/CoreExposed.includes =================================================================== --- branches/indy/CoreExposed.includes 2009-08-11 03:00:08 UTC (rev 6660) +++ branches/indy/CoreExposed.includes 2009-08-11 05:00:06 UTC (rev 6661) @@ -41,25 +41,28 @@ org/python/core/PyType.class org/python/core/PyUnicode.class org/python/core/PyXRange.class +org/python/modules/PyStruct.class +org/python/modules/PyTeeIterator.class +org/python/jsr223/PyScriptEngineScope.class org/python/modules/_codecs$EncodingMap.class +org/python/modules/_collections/PyDefaultDict.class +org/python/modules/_collections/PyDeque.class org/python/modules/_csv/PyDialect.class org/python/modules/_csv/PyReader.class org/python/modules/_csv/PyWriter.class org/python/modules/_functools/PyPartial.class +org/python/modules/_hashlib$Hash.class +org/python/modules/_threading/Condition.class +org/python/modules/_threading/Lock.class org/python/modules/_weakref/CallableProxyType.class +org/python/modules/_weakref/ProxyType.class org/python/modules/_weakref/ReferenceType.class -org/python/modules/_weakref/ProxyType.class -org/python/modules/_hashlib$Hash.class -org/python/modules/_collections/PyDefaultDict.class -org/python/modules/_collections/PyDeque.class org/python/modules/operator$PyAttrGetter.class org/python/modules/operator$PyItemGetter.class org/python/modules/random/PyRandom.class org/python/modules/thread/PyLocal.class org/python/modules/time/PyTimeTuple.class org/python/modules/zipimport/zipimporter.class -org/python/modules/PyStruct.class -org/python/modules/PyTeeIterator.class org/python/antlr/AST.class org/python/antlr/ast/alias.class org/python/antlr/ast/arguments.class Modified: branches/indy/Lib/_rawffi.py =================================================================== --- branches/indy/Lib/_rawffi.py 2009-08-11 03:00:08 UTC (rev 6660) +++ branches/indy/Lib/_rawffi.py 2009-08-11 05:00:06 UTC (rev 6661) @@ -52,6 +52,3 @@ fnp = FuncPtr(fn, name, argtypes, restype) self.cache[key] = fnp return fnp - - - Modified: branches/indy/Lib/codeop.py =================================================================== --- branches/indy/Lib/codeop.py 2009-08-11 03:00:08 UTC (rev 6660) +++ branches/indy/Lib/codeop.py 2009-08-11 05:00:06 UTC (rev 6661) @@ -132,4 +132,3 @@ raise ValueError,"symbol arg must be either single or eval" symbol = CompileMode.getMode(symbol) return Py.compile_command_flags(source,filename,symbol,self._cflags,0) - Modified: branches/indy/Lib/datetime.py =================================================================== --- branches/indy/Lib/datetime.py 2009-08-11 03:00:08 UTC (rev 6660) +++ branches/indy/Lib/datetime.py 2009-08-11 05:00:06 UTC (rev 6661) @@ -13,7 +13,7 @@ Sources for time zone and DST data: http://www.twinsun.com/tz/tz-link.htm This was originally copied from the sandbox of the CPython CVS repository. -Thanks to Tim Peters for suggesting using it. +Thanks to Tim Peters for suggesting using it. """ import time as _time @@ -599,9 +599,9 @@ def __neg__(self): # for CPython compatibility, we cannot use # our __class__ here, but need a real timedelta - return timedelta(-self.__days, - -self.__seconds, - -self.__microseconds) + return timedelta(-self.__days, + -self.__seconds, + -self.__microseconds) def __pos__(self): return self @@ -1622,7 +1622,7 @@ if L[-1] == 0: del L[-1] if L[-1] == 0: - del L[-1] + del L[-1] s = ", ".join(map(str, L)) s = "%s(%s)" % ('datetime.' + self.__class__.__name__, s) if self._tzinfo is not None: @@ -1853,12 +1853,14 @@ calendar.clear() calendar.set(self.year, self.month - 1, self.day, self.hour, self.minute, self.second) - calendar.set(Calendar.MILLISECOND, self.microsecond // 1000) if java_class == Calendar: + calendar.set(Calendar.MILLISECOND, self.microsecond // 1000) return calendar else: - return Timestamp(calendar.getTimeInMillis()) + timestamp = Timestamp(calendar.getTimeInMillis()) + timestamp.setNanos(self.microsecond * 1000) + return timestamp datetime.min = datetime(1, 1, 1) @@ -2074,4 +2076,3 @@ perverse time zone returns a negative dst()). So a breaking case must be pretty bizarre, and a tzinfo subclass can override fromutc() if it is. """ - Modified: branches/indy/Lib/dbexts.py =================================================================== --- branches/indy/Lib/dbexts.py 2009-08-11 03:00:08 UTC (rev 6660) +++ branches/indy/Lib/dbexts.py 2009-08-11 05:00:06 UTC (rev 6661) @@ -56,671 +56,671 @@ choose = lambda bool, a, b: (bool and [a] or [b])[0] def console(rows, headers=()): - """Format the results into a list of strings (one for each row): + """Format the results into a list of strings (one for each row): - <header> - <headersep> - <row1> - <row2> - ... + <header> + <headersep> + <row1> + <row2> + ... - headers may be given as list of strings. + headers may be given as list of strings. - Columns are separated by colsep; the header is separated from - the result set by a line of headersep characters. + Columns are separated by colsep; the header is separated from + the result set by a line of headersep characters. - The function calls stringify to format the value data into a string. - It defaults to calling str() and striping leading and trailing whitespace. + The function calls stringify to format the value data into a string. + It defaults to calling str() and striping leading and trailing whitespace. - - copied and modified from mxODBC - """ + - copied and modified from mxODBC + """ - # Check row entry lengths - output = [] - headers = map(lambda header: header.upper(), list(map(lambda x: x or "", headers))) - collen = map(len,headers) - output.append(headers) - if rows and len(rows) > 0: - for row in rows: - row = map(lambda x: str(x), row) - for i in range(len(row)): - entry = row[i] - if collen[i] < len(entry): - collen[i] = len(entry) - output.append(row) - if len(output) == 1: - affected = "0 rows affected" - elif len(output) == 2: - affected = "1 row affected" - else: - affected = "%d rows affected" % (len(output) - 1) + # Check row entry lengths + output = [] + headers = map(lambda header: header.upper(), list(map(lambda x: x or "", headers))) + collen = map(len,headers) + output.append(headers) + if rows and len(rows) > 0: + for row in rows: + row = map(lambda x: str(x), row) + for i in range(len(row)): + entry = row[i] + if collen[i] < len(entry): + collen[i] = len(entry) + output.append(row) + if len(output) == 1: + affected = "0 rows affected" + elif len(output) == 2: + affected = "1 row affected" + else: + affected = "%d rows affected" % (len(output) - 1) - # Format output - for i in range(len(output)): - row = output[i] - l = [] - for j in range(len(row)): - l.append('%-*s' % (collen[j],row[j])) - output[i] = " | ".join(l) + # Format output + for i in range(len(output)): + row = output[i] + l = [] + for j in range(len(row)): + l.append('%-*s' % (collen[j],row[j])) + output[i] = " | ".join(l) - # Insert header separator - totallen = len(output[0]) - output[1:1] = ["-"*(totallen/len("-"))] - output.append("\n" + affected) - return output + # Insert header separator + totallen = len(output[0]) + output[1:1] = ["-"*(totallen/len("-"))] + output.append("\n" + affected) + return output def html(rows, headers=()): - output = [] - output.append('<table class="results">') - output.append('<tr class="headers">') - headers = map(lambda x: '<td class="header">%s</td>' % (x.upper()), list(headers)) - map(output.append, headers) - output.append('</tr>') - if rows and len(rows) > 0: - for row in rows: - output.append('<tr class="row">') - row = map(lambda x: '<td class="value">%s</td>' % (x), row) - map(output.append, row) - output.append('</tr>') - output.append('</table>') - return output + output = [] + output.append('<table class="results">') + output.append('<tr class="headers">') + headers = map(lambda x: '<td class="header">%s</td>' % (x.upper()), list(headers)) + map(output.append, headers) + output.append('</tr>') + if rows and len(rows) > 0: + for row in rows: + output.append('<tr class="row">') + row = map(lambda x: '<td class="value">%s</td>' % (x), row) + map(output.append, row) + output.append('</tr>') + output.append('</table>') + return output comments = lambda x: re.compile("{.*?}", re.S).sub("", x, 0) class mxODBCProxy: - """Wraps mxODBC to provide proxy support for zxJDBC's additional parameters.""" - def __init__(self, c): - self.c = c - def __getattr__(self, name): - if name == "execute": - return self.execute - elif name == "gettypeinfo": - return self.gettypeinfo - else: - return getattr(self.c, name) - def execute(self, sql, params=None, bindings=None, maxrows=None): - if params: - self.c.execute(sql, params) - else: - self.c.execute(sql) - def gettypeinfo(self, typeid=None): - if typeid: - self.c.gettypeinfo(typeid) + """Wraps mxODBC to provide proxy support for zxJDBC's additional parameters.""" + def __init__(self, c): + self.c = c + def __getattr__(self, name): + if name == "execute": + return self.execute + elif name == "gettypeinfo": + return self.gettypeinfo + else: + return getattr(self.c, name) + def execute(self, sql, params=None, bindings=None, maxrows=None): + if params: + self.c.execute(sql, params) + else: + self.c.execute(sql) + def gettypeinfo(self, typeid=None): + if typeid: + self.c.gettypeinfo(typeid) class executor: - """Handles the insertion of values given dynamic data.""" - def __init__(self, table, cols): - self.cols = cols - self.table = table - if self.cols: - self.sql = "insert into %s (%s) values (%s)" % (table, ",".join(self.cols), ",".join(("?",) * len(self.cols))) - else: - self.sql = "insert into %s values (%%s)" % (table) - def execute(self, db, rows, bindings): - assert rows and len(rows) > 0, "must have at least one row" - if self.cols: - sql = self.sql - else: - sql = self.sql % (",".join(("?",) * len(rows[0]))) - db.raw(sql, rows, bindings) + """Handles the insertion of values given dynamic data.""" + def __init__(self, table, cols): + self.cols = cols + self.table = table + if self.cols: + self.sql = "insert into %s (%s) values (%s)" % (table, ",".join(self.cols), ",".join(("?",) * len(self.cols))) + else: + self.sql = "insert into %s values (%%s)" % (table) + def execute(self, db, rows, bindings): + assert rows and len(rows) > 0, "must have at least one row" + if self.cols: + sql = self.sql + else: + sql = self.sql % (",".join(("?",) * len(rows[0]))) + db.raw(sql, rows, bindings) def connect(dbname): - return dbexts(dbname) + return dbexts(dbname) def lookup(dbname): - return dbexts(jndiname=dbname) + return dbexts(jndiname=dbname) class dbexts: - def __init__(self, dbname=None, cfg=None, formatter=console, autocommit=0, jndiname=None, out=None): - self.verbose = 1 - self.results = [] - self.headers = [] - self.autocommit = autocommit - self.formatter = formatter - self.out = out - self.lastrowid = None - self.updatecount = None + def __init__(self, dbname=None, cfg=None, formatter=console, autocommit=0, jndiname=None, out=None): + self.verbose = 1 + self.results = [] + self.headers = [] + self.autocommit = autocommit + self.formatter = formatter + self.out = out + self.lastrowid = None + self.updatecount = None - if not jndiname: - if cfg == None: - fn = os.path.join(os.path.split(__file__)[0], "dbexts.ini") - if not os.path.exists(fn): - fn = os.path.join(os.environ['HOME'], ".dbexts") - self.dbs = IniParser(fn) - elif isinstance(cfg, IniParser): - self.dbs = cfg - else: - self.dbs = IniParser(cfg) - if dbname == None: dbname = self.dbs[("default", "name")] + if not jndiname: + if cfg == None: + fn = os.path.join(os.path.split(__file__)[0], "dbexts.ini") + if not os.path.exists(fn): + fn = os.path.join(os.environ['HOME'], ".dbexts") + self.dbs = IniParser(fn) + elif isinstance(cfg, IniParser): + self.dbs = cfg + else: + self.dbs = IniParser(cfg) + if dbname == None: dbname = self.dbs[("default", "name")] - if __OS__ == 'java': + if __OS__ == 'java': - from com.ziclix.python.sql import zxJDBC - database = zxJDBC - if not jndiname: - t = self.dbs[("jdbc", dbname)] - self.dburl, dbuser, dbpwd, jdbcdriver = t['url'], t['user'], t['pwd'], t['driver'] - if t.has_key('datahandler'): - self.datahandler = [] - for dh in t['datahandler'].split(','): - classname = dh.split(".")[-1] - datahandlerclass = __import__(dh, globals(), locals(), classname) - self.datahandler.append(datahandlerclass) - keys = [x for x in t.keys() if x not in ['url', 'user', 'pwd', 'driver', 'datahandler', 'name']] - props = {} - for a in keys: - props[a] = t[a] - self.db = apply(database.connect, (self.dburl, dbuser, dbpwd, jdbcdriver), props) - else: - self.db = database.lookup(jndiname) - self.db.autocommit = self.autocommit + from com.ziclix.python.sql import zxJDBC + database = zxJDBC + if not jndiname: + t = self.dbs[("jdbc", dbname)] + self.dburl, dbuser, dbpwd, jdbcdriver = t['url'], t['user'], t['pwd'], t['driver'] + if t.has_key('datahandler'): + self.datahandler = [] + for dh in t['datahandler'].split(','): + classname = dh.split(".")[-1] + datahandlerclass = __import__(dh, globals(), locals(), classname) + self.datahandler.append(datahandlerclass) + keys = [x for x in t.keys() if x not in ['url', 'user', 'pwd', 'driver', 'datahandler', 'name']] + props = {} + for a in keys: + props[a] = t[a] + self.db = apply(database.connect, (self.dburl, dbuser, dbpwd, jdbcdriver), props) + else: + self.db = database.lookup(jndiname) + self.db.autocommit = self.autocommit - elif __OS__ == 'nt': + elif __OS__ == 'nt': - for modname in ["mx.ODBC.Windows", "ODBC.Windows"]: - try: - database = __import__(modname, globals(), locals(), "Windows") - break - except: - continue - else: - raise ImportError("unable to find appropriate mxODBC module") + for modname in ["mx.ODBC.Windows", "ODBC.Windows"]: + try: + database = __import__(modname, globals(), locals(), "Windows") + break + except: + continue + else: + raise ImportError("unable to find appropriate mxODBC module") - t = self.dbs[("odbc", dbname)] - self.dburl, dbuser, dbpwd = t['url'], t['user'], t['pwd'] - self.db = database.Connect(self.dburl, dbuser, dbpwd, clear_auto_commit=1) + t = self.dbs[("odbc", dbname)] + self.dburl, dbuser, dbpwd = t['url'], t['user'], t['pwd'] + self.db = database.Connect(self.dburl, dbuser, dbpwd, clear_auto_commit=1) - self.dbname = dbname - for a in database.sqltype.keys(): - setattr(self, database.sqltype[a], a) - for a in dir(database): - try: - p = getattr(database, a) - if issubclass(p, Exception): - setattr(self, a, p) - except: - continue - del database + self.dbname = dbname + for a in database.sqltype.keys(): + setattr(self, database.sqltype[a], a) + for a in dir(database): + try: + p = getattr(database, a) + if issubclass(p, Exception): + setattr(self, a, p) + except: + continue + del database - def __str__(self): - return self.dburl + def __str__(self): + return self.dburl - def __repr__(self): - return self.dburl + def __repr__(self): + return self.dburl - def __getattr__(self, name): - if "cfg" == name: - return self.dbs.cfg - raise AttributeError("'dbexts' object has no attribute '%s'" % (name)) + def __getattr__(self, name): + if "cfg" == name: + return self.dbs.cfg + raise AttributeError("'dbexts' object has no attribute '%s'" % (name)) - def close(self): - """ close the connection to the database """ - self.db.close() + def close(self): + """ close the connection to the database """ + self.db.close() - def begin(self, style=None): - """ reset ivars and return a new cursor, possibly binding an auxiliary datahandler """ - self.headers, self.results = [], [] - if style: - c = self.db.cursor(style) - else: - c = self.db.cursor() - if __OS__ == 'java': - if hasattr(self, 'datahandler'): - for dh in self.datahandler: - c.datahandler = dh(c.datahandler) - else: - c = mxODBCProxy(c) - return c + def begin(self, style=None): + """ reset ivars and return a new cursor, possibly binding an auxiliary datahandler """ + self.headers, self.results = [], [] + if style: + c = self.db.cursor(style) + else: + c = self.db.cursor() + if __OS__ == 'java': + if hasattr(self, 'datahandler'): + for dh in self.datahandler: + c.datahandler = dh(c.datahandler) + else: + c = mxODBCProxy(c) + return c - def commit(self, cursor=None, close=1): - """ commit the cursor and create the result set """ - if cursor and cursor.description: - self.headers = cursor.description - self.results = cursor.fetchall() - if hasattr(cursor, "nextset"): - s = cursor.nextset() - while s: - self.results += cursor.fetchall() - s = cursor.nextset() - if hasattr(cursor, "lastrowid"): - self.lastrowid = cursor.lastrowid - if hasattr(cursor, "updatecount"): - self.updatecount = cursor.updatecount - if not self.autocommit or cursor is None: - if not self.db.autocommit: - self.db.commit() - if cursor and close: cursor.close() + def commit(self, cursor=None, close=1): + """ commit the cursor and create the result set """ + if cursor and cursor.description: + self.headers = cursor.description + self.results = cursor.fetchall() + if hasattr(cursor, "nextset"): + s = cursor.nextset() + while s: + self.results += cursor.fetchall() + s = cursor.nextset() + if hasattr(cursor, "lastrowid"): + self.lastrowid = cursor.lastrowid + if hasattr(cursor, "updatecount"): + self.updatecount = cursor.updatecount + if not self.autocommit or cursor is None: + if not self.db.autocommit: + self.db.commit() + if cursor and close: cursor.close() - def rollback(self): - """ rollback the cursor """ - self.db.rollback() + def rollback(self): + """ rollback the cursor """ + self.db.rollback() - def prepare(self, sql): - """ prepare the sql statement """ - cur = self.begin() - try: - return cur.prepare(sql) - finally: - self.commit(cur) + def prepare(self, sql): + """ prepare the sql statement """ + cur = self.begin() + try: + return cur.prepare(sql) + finally: + self.commit(cur) - def display(self): - """ using the formatter, display the results """ - if self.formatter and self.verbose > 0: - res = self.results - if res: - print >> self.out, "" - for a in self.formatter(res, map(lambda x: x[0], self.headers)): - print >> self.out, a - print >> self.out, "" + def display(self): + """ using the formatter, display the results """ + if self.formatter and self.verbose > 0: + res = self.results + if res: + print >> self.out, "" + for a in self.formatter(res, map(lambda x: x[0], self.headers)): + print >> self.out, a + print >> self.out, "" - def __execute__(self, sql, params=None, bindings=None, maxrows=None): - """ the primary execution method """ - cur = self.begin() - try: - if bindings: - cur.execute(sql, params, bindings, maxrows=maxrows) - elif params: - cur.execute(sql, params, maxrows=maxrows) - else: - cur.execute(sql, maxrows=maxrows) - finally: - self.commit(cur, close=isinstance(sql, StringType)) + def __execute__(self, sql, params=None, bindings=None, maxrows=None): + """ the primary execution method """ + cur = self.begin() + try: + if bindings: + cur.execute(sql, params, bindings, maxrows=maxrows) + elif params: + cur.execute(sql, params, maxrows=maxrows) + else: + cur.execute(sql, maxrows=maxrows) + finally: + self.commit(cur, close=isinstance(sql, StringType)) - def isql(self, sql, params=None, bindings=None, maxrows=None): - """ execute and display the sql """ - self.raw(sql, params, bindings, maxrows=maxrows) - self.display() + def isql(self, sql, params=None, bindings=None, maxrows=None): + """ execute and display the sql """ + self.raw(sql, params, bindings, maxrows=maxrows) + self.display() - def raw(self, sql, params=None, bindings=None, delim=None, comments=comments, maxrows=None): - """ execute the sql and return a tuple of (headers, results) """ - if delim: - headers = [] - results = [] - if type(sql) == type(StringType): - if comments: sql = comments(sql) - statements = filter(lambda x: len(x) > 0, - map(lambda statement: statement.strip(), sql.split(delim))) - else: - statements = [sql] - for a in statements: - self.__execute__(a, params, bindings, maxrows=maxrows) - headers.append(self.headers) - results.append(self.results) - self.headers = headers - self.results = results - else: - self.__execute__(sql, params, bindings, maxrows=maxrows) - return (self.headers, self.results) + def raw(self, sql, params=None, bindings=None, delim=None, comments=comments, maxrows=None): + """ execute the sql and return a tuple of (headers, results) """ + if delim: + headers = [] + results = [] + if type(sql) == type(StringType): + if comments: sql = comments(sql) + statements = filter(lambda x: len(x) > 0, + map(lambda statement: statement.strip(), sql.split(delim))) + else: + statements = [sql] + for a in statements: + self.__execute__(a, params, bindings, maxrows=maxrows) + headers.append(self.headers) + results.append(self.results) + self.headers = headers + self.results = results + else: + self.__execute__(sql, params, bindings, maxrows=maxrows) + return (self.headers, self.results) - def callproc(self, procname, params=None, bindings=None, maxrows=None): - """ execute a stored procedure """ - cur = self.begin() - try: - cur.callproc(procname, params=params, bindings=bindings, maxrows=maxrows) - finally: - self.commit(cur) - self.display() + def callproc(self, procname, params=None, bindings=None, maxrows=None): + """ execute a stored procedure """ + cur = self.begin() + try: + cur.callproc(procname, params=params, bindings=bindings, maxrows=maxrows) + finally: + self.commit(cur) + self.display() - def pk(self, table, owner=None, schema=None): - """ display the table's primary keys """ - cur = self.begin() - cur.primarykeys(schema, owner, table) - self.commit(cur) - self.display() + def pk(self, table, owner=None, schema=None): + """ display the table's primary keys """ + cur = self.begin() + cur.primarykeys(schema, owner, table) + self.commit(cur) + self.display() - def fk(self, primary_table=None, foreign_table=None, owner=None, schema=None): - """ display the table's foreign keys """ - cur = self.begin() - if primary_table and foreign_table: - cur.foreignkeys(schema, owner, primary_table, schema, owner, foreign_table) - elif primary_table: - cur.foreignkeys(schema, owner, primary_table, schema, owner, None) - elif foreign_table: - cur.foreignkeys(schema, owner, None, schema, owner, foreign_table) - self.commit(cur) - self.display() + def fk(self, primary_table=None, foreign_table=None, owner=None, schema=None): + """ display the table's foreign keys """ + cur = self.begin() + if primary_table and foreign_table: + cur.foreignkeys(schema, owner, primary_table, schema, owner, foreign_table) + elif primary_table: + cur.foreignkeys(schema, owner, primary_table, schema, owner, None) + elif foreign_table: + cur.foreignkeys(schema, owner, None, schema, owner, foreign_table) + self.commit(cur) + self.display() - def table(self, table=None, types=("TABLE",), owner=None, schema=None): - """If no table argument, displays a list of all tables. If a table argument, - displays the columns of the given table.""" - cur = self.begin() - if table: - cur.columns(schema, owner, table, None) - else: - cur.tables(schema, owner, None, types) - self.commit(cur) - self.display() + def table(self, table=None, types=("TABLE",), owner=None, schema=None): + """If no table argument, displays a list of all tables. If a table argument, + displays the columns of the given table.""" + cur = self.begin() + if table: + cur.columns(schema, owner, table, None) + else: + cur.tables(schema, owner, None, types) + self.commit(cur) + self.display() - def proc(self, proc=None, owner=None, schema=None): - """If no proc argument, displays a list of all procedures. If a proc argument, - displays the parameters of the given procedure.""" - cur = self.begin() - if proc: - cur.procedurecolumns(schema, owner, proc, None) - else: - cur.procedures(schema, owner, None) - self.commit(cur) - self.display() + def proc(self, proc=None, owner=None, schema=None): + """If no proc argument, displays a list of all procedures. If a proc argument, + displays the parameters of the given procedure.""" + cur = self.begin() + if proc: + cur.procedurecolumns(schema, owner, proc, None) + else: + cur.procedures(schema, owner, None) + self.commit(cur) + self.display() - def stat(self, table, qualifier=None, owner=None, unique=0, accuracy=0): - """ display the table's indicies """ - cur = self.begin() - cur.statistics(qualifier, owner, table, unique, accuracy) - self.commit(cur) - self.display() + def stat(self, table, qualifier=None, owner=None, unique=0, accuracy=0): + """ display the table's indicies """ + cur = self.begin() + cur.statistics(qualifier, owner, table, unique, accuracy) + self.commit(cur) + self.display() - def typeinfo(self, sqltype=None): - """ display the types available for the database """ - cur = self.begin() - cur.gettypeinfo(sqltype) - self.commit(cur) - self.display() + def typeinfo(self, sqltype=None): + """ display the types available for the database """ + cur = self.begin() + cur.gettypeinfo(sqltype) + self.commit(cur) + self.display() - def tabletypeinfo(self): - """ display the table types available for the database """ - cur = self.begin() - cur.gettabletypeinfo() - self.commit(cur) - self.display() + def tabletypeinfo(self): + """ display the table types available for the database """ + cur = self.begin() + cur.gettabletypeinfo() + self.commit(cur) + self.display() - def schema(self, table, full=0, sort=1, owner=None): - """Displays a Schema object for the table. If full is true, then generates - references to the table in addition to the standard fields. If sort is true, - sort all the items in the schema, else leave them in db dependent order.""" - print >> self.out, str(Schema(self, table, owner, full, sort)) + def schema(self, table, full=0, sort=1, owner=None): + """Displays a Schema object for the table. If full is true, then generates + references to the table in addition to the standard fields. If sort is true, + sort all the items in the schema, else leave them in db dependent order.""" + print >> self.out, str(Schema(self, table, owner, full, sort)) - def bulkcopy(self, dst, table, include=[], exclude=[], autobatch=0, executor=executor): - """Returns a Bulkcopy object using the given table.""" - if type(dst) == type(""): - dst = dbexts(dst, cfg=self.dbs) - bcp = Bulkcopy(dst, table, include=include, exclude=exclude, autobatch=autobatch, executor=executor) - return bcp + def bulkcopy(self, dst, table, include=[], exclude=[], autobatch=0, executor=executor): + """Returns a Bulkcopy object using the given table.""" + if type(dst) == type(""): + dst = dbexts(dst, cfg=self.dbs) + bcp = Bulkcopy(dst, table, include=include, exclude=exclude, autobatch=autobatch, executor=executor) + return bcp - def bcp(self, src, table, where='(1=1)', params=[], include=[], exclude=[], autobatch=0, executor=executor): - """Bulkcopy of rows from a src database to the current database for a given table and where clause.""" - if type(src) == type(""): - src = dbexts(src, cfg=self.dbs) - bcp = self.bulkcopy(self, table, include, exclude, autobatch, executor) - num = bcp.transfer(src, where, params) - return num + def bcp(self, src, table, where='(1=1)', params=[], include=[], exclude=[], autobatch=0, executor=executor): + """Bulkcopy of rows from a src database to the current database for a given table and where clause.""" + if type(src) == type(""): + src = dbexts(src, cfg=self.dbs) + bcp = self.bulkcopy(self, table, include, exclude, autobatch, executor) + num = bcp.transfer(src, where, params) + return num - def unload(self, filename, sql, delimiter=",", includeheaders=1): - """ Unloads the delimited results of the query to the file specified, optionally including headers. """ - u = Unload(self, filename, delimiter, includeheaders) - u.unload(sql) + def unload(self, filename, sql, delimiter=",", includeheaders=1): + """ Unloads the delimited results of the query to the file specified, optionally including headers. """ + u = Unload(self, filename, delimiter, includeheaders) + u.unload(sql) class Bulkcopy: - """The idea for a bcp class came from http://object-craft.com.au/projects/sybase""" - def __init__(self, dst, table, include=[], exclude=[], autobatch=0, executor=executor): - self.dst = dst - self.table = table - self.total = 0 - self.rows = [] - self.autobatch = autobatch - self.bindings = {} + """The idea for a bcp class came from http://object-craft.com.au/projects/sybase""" + def __init__(self, dst, table, include=[], exclude=[], autobatch=0, executor=executor): + self.dst = dst + self.table = table + self.total = 0 + self.rows = [] + self.autobatch = autobatch + self.bindings = {} - include = map(lambda x: x.lower(), include) - exclude = map(lambda x: x.lower(), exclude) + include = map(lambda x: x.lower(), include) + exclude = map(lambda x: x.lower(), exclude) - _verbose = self.dst.verbose - self.dst.verbose = 0 - try: - self.dst.table(self.table) - if self.dst.results: - colmap = {} - for a in self.dst.results: - colmap[a[3].lower()] = a[4] - cols = self.__filter__(colmap.keys(), include, exclude) - for a in zip(range(len(cols)), cols): - self.bindings[a[0]] = colmap[a[1]] - colmap = None - else: - cols = self.__filter__(include, include, exclude) - finally: - self.dst.verbose = _verbose + _verbose = self.dst.verbose + self.dst.verbose = 0 + try: + self.dst.table(self.table) + if self.dst.results: + colmap = {} + for a in self.dst.results: + colmap[a[3].lower()] = a[4] + cols = self.__filter__(colmap.keys(), include, exclude) + for a in zip(range(len(cols)), cols): + self.bindings[a[0]] = colmap[a[1]] + colmap = None + else: + cols = self.__filter__(include, include, exclude) + finally: + self.dst.verbose = _verbose - self.executor = executor(table, cols) + self.executor = executor(table, cols) - def __str__(self): - return "[%s].[%s]" % (self.dst, self.table) + def __str__(self): + return "[%s].[%s]" % (self.dst, self.table) - def __repr__(self): - return "[%s].[%s]" % (self.dst, self.table) + def __repr__(self): + return "[%s].[%s]" % (self.dst, self.table) - def __getattr__(self, name): - if name == 'columns': - return self.executor.cols + def __getattr__(self, name): + if name == 'columns': + return self.executor.cols - def __filter__(self, values, include, exclude): - cols = map(lambda col: col.lower(), values) - if exclude: - cols = filter(lambda x, ex=exclude: x not in ex, cols) - if include: - cols = filter(lambda x, inc=include: x in inc, cols) - return cols + def __filter__(self, values, include, exclude): + cols = map(lambda col: col.lower(), values) + if exclude: + cols = filter(lambda x, ex=exclude: x not in ex, cols) + if include: + cols = filter(lambda x, inc=include: x in inc, cols) + return cols - def format(self, column, type): - self.bindings[column] = type + def format(self, column, type): + self.bindings[column] = type - def done(self): - if len(self.rows) > 0: - return self.batch() - return 0 + def done(self): + if len(self.rows) > 0: + return self.batch() + return 0 - def batch(self): - self.executor.execute(self.dst, self.rows, self.bindings) - cnt = len(self.rows) - self.total += cnt - self.rows = [] - return cnt + def batch(self): + self.executor.execute(self.dst, self.rows, self.bindings) + cnt = len(self.rows) + self.total += cnt + self.rows = [] + return cnt - def rowxfer(self, line): - self.rows.append(line) - if self.autobatch: self.batch() + def rowxfer(self, line): + self.rows.append(line) + if self.autobatch: self.batch() - def transfer(self, src, where="(1=1)", params=[]): - sql = "select %s from %s where %s" % (", ".join(self.columns), self.table, where) - h, d = src.raw(sql, params) - if d: - map(self.rowxfer, d) - return self.done() - return 0 + def transfer(self, src, where="(1=1)", params=[]): + sql = "select %s from %s where %s" % (", ".join(self.columns), self.table, where) + h, d = src.raw(sql, params) + if d: + map(self.rowxfer, d) + return self.done() + return 0 class Unload: - """Unloads a sql statement to a file with optional formatting of each value.""" - def __init__(self, db, filename, delimiter=",", includeheaders=1): - self.db = db - self.filename = filename - self.delimiter = delimiter - self.includeheaders = includeheaders - self.formatters = {} + """Unloads a sql statement to a file with optional formatting of each value.""" + def __init__(self, db, filename, delimiter=",", includeheaders=1): + self.db = db + self.filename = filename + self.delimiter = delimiter + self.includeheaders = includeheaders + self.formatters = {} - def format(self, o): - if not o: - return "" - o = str(o) - if o.find(",") != -1: - o = "\"\"%s\"\"" % (o) - return o + def format(self, o): + if not o: + return "" + o = str(o) + if o.find(",") != -1: + o = "\"\"%s\"\"" % (o) + return o - def unload(self, sql, mode="w"): - headers, results = self.db.raw(sql) - w = open(self.filename, mode) - if self.includeheaders: - w.write("%s\n" % (self.delimiter.join(map(lambda x: x[0], headers)))) - if results: - for a in results: - w.write("%s\n" % (self.delimiter.join(map(self.format, a)))) - w.flush() - ... [truncated message content] |
From: <fwi...@us...> - 2009-09-08 18:21:55
|
Revision: 6764 http://jython.svn.sourceforge.net/jython/?rev=6764&view=rev Author: fwierzbicki Date: 2009-09-08 18:21:38 +0000 (Tue, 08 Sep 2009) Log Message: ----------- Merged revisions 6662-6665,6667-6698,6710,6713,6717-6719,6724-6725,6735-6741 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython ........ r6662 | cgroves | 2009-08-11 02:45:00 -0400 (Tue, 11 Aug 2009) | 1 line Documentation and formatting cleanup ........ r6663 | pjenvey | 2009-08-11 23:12:07 -0400 (Tue, 11 Aug 2009) | 2 lines cleanup/quiet warnings ........ r6664 | fwierzbicki | 2009-08-12 21:54:15 -0400 (Wed, 12 Aug 2009) | 2 lines Better lineno col_offset match with CPython on elif. ........ r6665 | fwierzbicki | 2009-08-12 22:49:57 -0400 (Wed, 12 Aug 2009) | 2 lines Adjusted BinOp lineno and col_offset to align better with CPython. ........ r6667 | pjenvey | 2009-08-15 21:11:01 -0400 (Sat, 15 Aug 2009) | 2 lines allow Oracle's touchy DML returning ResultSet to be used here ........ r6668 | pjenvey | 2009-08-15 21:30:38 -0400 (Sat, 15 Aug 2009) | 3 lines steal Python3's _wrap_close to fix popen files' close to return the exit status when its non-zero ........ r6669 | pjenvey | 2009-08-15 21:32:41 -0400 (Sat, 15 Aug 2009) | 1 line changelog r6668, fixes #1434 ........ r6670 | pjenvey | 2009-08-15 22:36:35 -0400 (Sat, 15 Aug 2009) | 1 line preserve our old exit code behavior ........ r6671 | fwierzbicki | 2009-08-15 22:49:27 -0400 (Sat, 15 Aug 2009) | 2 lines Better match with CPython for col_offset on BoolOp with left arg in parens. ........ r6672 | fwierzbicki | 2009-08-15 22:51:07 -0400 (Sat, 15 Aug 2009) | 2 lines Bugfix for test ast generation code. ........ r6673 | fwierzbicki | 2009-08-15 22:55:25 -0400 (Sat, 15 Aug 2009) | 2 lines Added tests for BoolOp and parens. ........ r6674 | fwierzbicki | 2009-08-15 23:04:08 -0400 (Sat, 15 Aug 2009) | 2 lines Fix col_offset for some NOT expressions. ........ r6675 | cgroves | 2009-08-16 04:11:44 -0400 (Sun, 16 Aug 2009) | 1 line Have lookup call through to lookup_where rather than duplicating the lookup functionality ........ r6676 | cgroves | 2009-08-16 06:28:49 -0400 (Sun, 16 Aug 2009) | 1 line Continue looking for methods to merge up the inheritance chain if the non-public class being merged has a parent that's non-public as well. Fixes issue 1430. ........ r6677 | fwierzbicki | 2009-08-16 10:26:06 -0400 (Sun, 16 Aug 2009) | 2 lines Fix for http://bugs.jython.org/issue1439: Can't write() array.array ........ r6678 | fwierzbicki | 2009-08-16 10:32:28 -0400 (Sun, 16 Aug 2009) | 2 lines Update NEWS. ........ r6679 | fwierzbicki | 2009-08-16 11:32:04 -0400 (Sun, 16 Aug 2009) | 2 lines Test file.write(array) ........ r6680 | fwierzbicki | 2009-08-16 13:46:24 -0400 (Sun, 16 Aug 2009) | 3 lines Added some bug fixes to NEWS that didn't make it in before. Also re-ordered my most recent additions since most people grow the fix list downwards :) ........ r6681 | fwierzbicki | 2009-08-16 14:21:50 -0400 (Sun, 16 Aug 2009) | 2 lines Found a couple more closed bugs that didn't make it into NEWS. ........ r6682 | cgroves | 2009-08-16 18:25:58 -0400 (Sun, 16 Aug 2009) | 3 lines Remove the ant exposer from Eclipse as it never seemed to work. ........ r6683 | pjenvey | 2009-08-16 18:40:47 -0400 (Sun, 16 Aug 2009) | 2 lines restrict array writes to binary mode ........ r6684 | pjenvey | 2009-08-16 19:39:05 -0400 (Sun, 16 Aug 2009) | 1 line fix javadoc, small cleanup ........ r6685 | cgroves | 2009-08-16 20:17:36 -0400 (Sun, 16 Aug 2009) | 5 lines WHERE_PLACEHOLDER could hold on to a reference to a type for a while, and it's causing static initialization problems. Screw using a static array and just pass in null if we don't want to know where the item was found. ........ r6686 | pjenvey | 2009-08-16 21:43:09 -0400 (Sun, 16 Aug 2009) | 2 lines fix writelines' handling of non-strs and not resetting softspace ........ r6687 | pjenvey | 2009-08-16 21:47:30 -0400 (Sun, 16 Aug 2009) | 1 line quiet warnings ........ r6688 | fwierzbicki | 2009-08-16 22:29:34 -0400 (Sun, 16 Aug 2009) | 5 lines Added ast tests for "naked tuples" in for statements like: for a,b in c: pass ........ r6689 | fwierzbicki | 2009-08-16 22:30:53 -0400 (Sun, 16 Aug 2009) | 3 lines Removed dynamic scope on expr::lparen. Need to pass the lparen info up to each rule anyway. ........ r6690 | fwierzbicki | 2009-08-16 23:15:31 -0400 (Sun, 16 Aug 2009) | 4 lines Better match of CPython col_offset for factors with parens like: (a - b) * c ........ r6691 | fwierzbicki | 2009-08-17 09:25:59 -0400 (Mon, 17 Aug 2009) | 2 lines Better BinOp col_offsets. ........ r6692 | fwierzbicki | 2009-08-17 14:41:12 -0400 (Mon, 17 Aug 2009) | 3 lines Added "devclean": deletes everything but the generated antlr files, cachedir, and Lib. ........ r6693 | pjenvey | 2009-08-17 22:19:12 -0400 (Mon, 17 Aug 2009) | 1 line small cleanup ........ r6694 | pjenvey | 2009-08-17 22:44:03 -0400 (Mon, 17 Aug 2009) | 2 lines add __unicode__ ........ r6695 | fwierzbicki | 2009-08-19 09:23:14 -0400 (Wed, 19 Aug 2009) | 6 lines A simple class that allows a jarred up Jython app with a __run__.py to run with java -jar myapp.jar as long as it is specified as the main class in the manifest. ........ r6696 | fwierzbicki | 2009-08-19 10:30:14 -0400 (Wed, 19 Aug 2009) | 2 lines Added support for "jython -J-classpath cp_arg_goes_here" in jython unix shell. ........ r6697 | fwierzbicki | 2009-08-19 10:31:17 -0400 (Wed, 19 Aug 2009) | 2 lines Need to add the shell support for -J-classpath to NEWS ........ r6698 | otmarhumbel | 2009-08-19 12:15:00 -0400 (Wed, 19 Aug 2009) | 1 line add livetribe-jsr223-2.0.5.jar to the eclipse .classpath to enable compilation of the jsr223 packages ........ r6710 | fwierzbicki | 2009-08-23 13:35:06 -0400 (Sun, 23 Aug 2009) | 3 lines From CPython http://svn.python.org/python/trunk/Parser/asdl.py@74541 ........ r6713 | cgroves | 2009-08-23 15:47:55 -0400 (Sun, 23 Aug 2009) | 1 line Roll back 6532-6534 and 6548 to keep __javaname__ and sys.javaproxy_dir from going out with 2.5.1. __javaname__ just went away in favor of a naming proxymaker on the customizable-proxymaker branch, and sys.javaproxy_dir doesn't make sense without named proxies. I'll need to re-commit 6533, 6534 and 6548 when I merge customizable-proxymaker to trunk. ........ r6717 | leosoto | 2009-08-23 23:30:29 -0400 (Sun, 23 Aug 2009) | 1 line Fixing typo in org.pyton.modules.thread.thread docs ........ r6718 | cgroves | 2009-08-25 03:59:28 -0400 (Tue, 25 Aug 2009) | 1 line Need to flush the underlying io object after writing our buffer to it to get things really flushed. Fixes issue #1433. ........ r6719 | pjenvey | 2009-08-26 00:19:39 -0400 (Wed, 26 Aug 2009) | 2 lines always flush the raw io, even when nothing is buffered ........ r6724 | pjenvey | 2009-08-29 13:54:06 -0400 (Sat, 29 Aug 2009) | 1 line use @Override ........ r6725 | pjenvey | 2009-08-29 14:30:16 -0400 (Sat, 29 Aug 2009) | 4 lines treat line buffered read streams as the default buffered mode. CPython 2 line buffered read uses a different bufsize than the default depending on the platform (sometimes smaller, sometimes bigger) ........ r6735 | fwierzbicki | 2009-08-31 14:46:06 -0400 (Mon, 31 Aug 2009) | 3 lines Fix for http://bugs.jython.org/issue1424 "Relative imports do not work in some cases". ........ r6736 | fwierzbicki | 2009-08-31 14:47:55 -0400 (Mon, 31 Aug 2009) | 2 lines Update NEWS ........ r6737 | fwierzbicki | 2009-09-01 09:57:52 -0400 (Tue, 01 Sep 2009) | 2 lines Increment APIVersion for coroutine bugfixes in compiler. ........ r6738 | fwierzbicki | 2009-09-01 09:59:14 -0400 (Tue, 01 Sep 2009) | 2 lines Update version numbers. ........ r6739 | fwierzbicki | 2009-09-01 10:02:31 -0400 (Tue, 01 Sep 2009) | 2 lines Update README ........ r6740 | fwierzbicki | 2009-09-01 10:24:42 -0400 (Tue, 01 Sep 2009) | 2 lines Mark release as Gamma level (release candidate) and serial of 1. ........ r6741 | fwierzbicki | 2009-09-01 10:25:55 -0400 (Tue, 01 Sep 2009) | 2 lines Crud, also update the version text strings. ........ Modified Paths: -------------- branches/indy/.classpath branches/indy/.project branches/indy/Lib/os.py branches/indy/Lib/test/test_array.py branches/indy/Lib/test/test_ast.py branches/indy/Lib/test/test_java_subclasses.py branches/indy/Lib/test/test_java_visibility.py branches/indy/NEWS branches/indy/README.txt branches/indy/ast/asdl.py branches/indy/build.xml branches/indy/grammar/Python.g branches/indy/src/com/ziclix/python/sql/PyConnection.java branches/indy/src/com/ziclix/python/sql/PyStatement.java branches/indy/src/com/ziclix/python/sql/connect/Connectx.java branches/indy/src/com/ziclix/python/sql/connect/Lookup.java branches/indy/src/com/ziclix/python/sql/handler/OracleDataHandler.java branches/indy/src/org/python/antlr/GrammarActions.java branches/indy/src/org/python/compiler/Module.java branches/indy/src/org/python/core/MakeProxies.java branches/indy/src/org/python/core/Py.java branches/indy/src/org/python/core/PyFile.java branches/indy/src/org/python/core/PyJavaType.java branches/indy/src/org/python/core/PyOverridableNew.java branches/indy/src/org/python/core/PySystemState.java branches/indy/src/org/python/core/PyType.java branches/indy/src/org/python/core/imp.java branches/indy/src/org/python/core/io/BinaryIOWrapper.java branches/indy/src/org/python/core/io/BufferedIOMixin.java branches/indy/src/org/python/core/io/BufferedRandom.java branches/indy/src/org/python/core/io/BufferedReader.java branches/indy/src/org/python/core/io/BufferedWriter.java branches/indy/src/org/python/core/io/DatagramSocketIO.java branches/indy/src/org/python/core/io/FileIO.java branches/indy/src/org/python/core/io/LineBufferedRandom.java branches/indy/src/org/python/core/io/LineBufferedWriter.java branches/indy/src/org/python/core/io/RawIOBase.java branches/indy/src/org/python/core/io/ServerSocketIO.java branches/indy/src/org/python/core/io/SocketIO.java branches/indy/src/org/python/core/io/SocketIOBase.java branches/indy/src/org/python/core/io/StreamIO.java branches/indy/src/org/python/core/io/TextIOBase.java branches/indy/src/org/python/core/io/TextIOWrapper.java branches/indy/src/org/python/core/io/UniversalIOWrapper.java branches/indy/src/org/python/core/util/ByteSwapper.java branches/indy/src/org/python/core/util/ConcurrentHashSet.java branches/indy/src/org/python/core/util/StringUtil.java branches/indy/src/org/python/expose/ExposedNew.java branches/indy/src/org/python/expose/generate/ExposeTask.java branches/indy/src/org/python/expose/generate/ExposedTypeProcessor.java branches/indy/src/org/python/expose/generate/NewExposer.java branches/indy/src/org/python/modules/thread/thread.java branches/indy/src/org/python/util/GlobMatchingTask.java branches/indy/src/org/python/util/JycompileAntTask.java branches/indy/src/shell/jython Added Paths: ----------- branches/indy/src/org/python/util/JarRunner.java branches/indy/tests/java/org/python/tests/multihidden/ branches/indy/tests/java/org/python/tests/multihidden/BaseConnection.java branches/indy/tests/java/org/python/tests/multihidden/SpecialConnection.java Removed Paths: ------------- branches/indy/.externalToolBuilders/ branches/indy/Lib/test/import_as_java_class.py branches/indy/Lib/test/static_proxy.py branches/indy/src/org/python/util/CompileProxiesTask.java branches/indy/src/org/python/util/FileNameMatchingTask.java branches/indy/tests/java/org/python/tests/multihidden/BaseConnection.java branches/indy/tests/java/org/python/tests/multihidden/SpecialConnection.java Property Changed: ---------------- branches/indy/ branches/indy/extlibs/xercesImpl-2.9.1.jar branches/indy/tests/java/org/python/tests/RedundantInterfaceDeclarations.java Property changes on: branches/indy ___________________________________________________________________ Modified: svnmerge-integrated - /trunk/jython:1-6660 + /trunk/jython:1-6751 Modified: svn:mergeinfo - /branches/jsr223:6285-6565 /branches/newstyle-java-types:5564-5663,5666-5729 + /branches/jsr223:6285-6565 /branches/newstyle-java-types:5564-5663,5666-5729 /trunk/jython:6662-6741 Modified: branches/indy/.classpath =================================================================== --- branches/indy/.classpath 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/.classpath 2009-09-08 18:21:38 UTC (rev 6764) @@ -1,10 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry excluding="com/ziclix/python/sql/handler/InformixDataHandler.java|com/ziclix/python/sql/handler/OracleDataHandler.java" kind="src" output="build/classes" path="src"/> + <classpathentry excluding="com/ziclix/python/sql/handler/InformixDataHandler.java|com/ziclix/python/sql/handler/OracleDataHandler.java" kind="src" path="src"/> <classpathentry kind="src" path="tests/modjy/java"/> - <classpathentry kind="src" output="build/classes" path="build/gensrc"/> - <classpathentry kind="src" output="build/classes" path="tests/java"/> - <classpathentry kind="src" path="bugtests/classes"/> + <classpathentry kind="src" path="build/gensrc"/> + <classpathentry kind="src" path="tests/java"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/> <classpathentry kind="lib" path="extlibs/jline-0.9.95-SNAPSHOT.jar"/> @@ -20,7 +19,8 @@ <classpathentry kind="lib" path="extlibs/constantine-0.4.jar"/> <classpathentry kind="lib" path="extlibs/jna-posix.jar"/> <classpathentry kind="lib" path="extlibs/mockrunner-0.4.1/jar/jdom.jar"/> - <classpathentry kind="lib" path="extlibs/mockrunner-0.4.1/lib/jdk1.5/j2ee1.3/mockrunner-servlet.jar"/> - <classpathentry kind="lib" path="extlibs/jna.jar"/> - <classpathentry kind="output" path="bugtests/classes"/> + <classpathentry kind="lib" path="extlibs/mockrunner-0.4.1/lib/jdk1.5/j2ee1.3/mockrunner-servlet.jar"/> + <classpathentry kind="lib" path="extlibs/jna.jar"/> + <classpathentry kind="lib" path="extlibs/livetribe-jsr223-2.0.5.jar"/> + <classpathentry kind="output" path="build/classes"/> </classpath> Modified: branches/indy/.project =================================================================== --- branches/indy/.project 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/.project 2009-09-08 18:21:38 UTC (rev 6764) @@ -10,16 +10,6 @@ <arguments> </arguments> </buildCommand> - <buildCommand> - <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> - <triggers>auto,</triggers> - <arguments> - <dictionary> - <key>LaunchConfigHandle</key> - <value><project>/.externalToolBuilders/Expose and jar.launch</value> - </dictionary> - </arguments> - </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> Modified: branches/indy/Lib/os.py =================================================================== --- branches/indy/Lib/os.py 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/Lib/os.py 2009-09-08 18:21:38 UTC (rev 6764) @@ -732,14 +732,35 @@ """ import subprocess if mode == 'r': - return subprocess.Popen(command, bufsize=bufsize, shell=True, - stdout=subprocess.PIPE).stdout + proc = subprocess.Popen(command, bufsize=bufsize, shell=True, + stdout=subprocess.PIPE) + return _wrap_close(proc.stdout, proc) elif mode == 'w': - return subprocess.Popen(command, bufsize=bufsize, shell=True, - stdin=subprocess.PIPE).stdin + proc = subprocess.Popen(command, bufsize=bufsize, shell=True, + stdin=subprocess.PIPE) + return _wrap_close(proc.stdin, proc) else: raise OSError(errno.EINVAL, strerror(errno.EINVAL)) +# Helper for popen() -- a proxy for a file whose close waits for the process +class _wrap_close(object): + def __init__(self, stream, proc): + self._stream = stream + self._proc = proc + def close(self): + self._stream.close() + returncode = self._proc.wait() + if returncode == 0: + return None + if _name == 'nt': + return returncode + else: + return returncode + def __getattr__(self, name): + return getattr(self._stream, name) + def __iter__(self): + return iter(self._stream) + # os module versions of the popen# methods have different return value # order than popen2 functions Deleted: branches/indy/Lib/test/import_as_java_class.py =================================================================== --- branches/indy/Lib/test/import_as_java_class.py 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/Lib/test/import_as_java_class.py 2009-09-08 18:21:38 UTC (rev 6764) @@ -1,7 +0,0 @@ -# Part of test_java_subclasses.StaticProxyCompilationTest -from java.lang import Class - -# Grab the proxy class statically compiled by the containing test -cls = Class.forName("test.static_proxy.RunnableImpl") -# Instantiating the proxy class should import the module containing it and create the Python side -assert cls.newInstance().meth() == 78 Deleted: branches/indy/Lib/test/static_proxy.py =================================================================== --- branches/indy/Lib/test/static_proxy.py 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/Lib/test/static_proxy.py 2009-09-08 18:21:38 UTC (rev 6764) @@ -1,11 +0,0 @@ -# Part of test_java_subclasses.StaticProxyCompilationTest. This needs to be its own module -# so the statically compiled proxy can import it. -from java.lang import Runnable - -class RunnableImpl(Runnable): - __javaname__ = "test.static_proxy.RunnableImpl" - def run(self): - pass - - def meth(self): - return 78 Modified: branches/indy/Lib/test/test_array.py =================================================================== --- branches/indy/Lib/test/test_array.py 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/Lib/test/test_array.py 2009-09-08 18:21:38 UTC (rev 6764) @@ -216,6 +216,25 @@ if a.itemsize>1 and self.typecode not in ('b', 'B'): self.assertRaises(ValueError, b.fromstring, "x") + def test_filewrite(self): + a = array.array(self.typecode, 2*self.example) + f = open(test_support.TESTFN, 'wb') + try: + f.write(a) + f.close() + b = array.array(self.typecode) + f = open(test_support.TESTFN, 'rb') + b.fromfile(f, len(self.example)) + self.assertEqual(b, array.array(self.typecode, self.example)) + self.assertNotEqual(a, b) + b.fromfile(f, len(self.example)) + self.assertEqual(a, b) + f.close() + finally: + if not f.closed: + f.close() + test_support.unlink(test_support.TESTFN) + def test_repr(self): a = array.array(self.typecode, 2*self.example) self.assertEqual(a, eval(repr(a), {"array": array.array})) Modified: branches/indy/Lib/test/test_ast.py =================================================================== --- branches/indy/Lib/test/test_ast.py 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/Lib/test/test_ast.py 2009-09-08 18:21:38 UTC (rev 6764) @@ -64,6 +64,15 @@ "break", # Continue "continue", + # Parens and BoolOp + "(a == '') and b", + "not (a == '') or b", + # Parens and BinOp + "(a - b) * c", + # for statements with naked tuples + "for a,b in c: pass", + "[(a,b) for a,b in c]", + "((a,b) for a,b in c)", ] # These are compiled through "single" @@ -297,7 +306,7 @@ print kind+"_results = [" for s in statements: print repr(to_tuple(compile(s, "?", kind, 0x400)))+"," - print "]" + print "]" print "main()" raise SystemExit test_main() @@ -326,6 +335,12 @@ ('Module', [('Pass', (1, 0))]), ('Module', [('Break', (1, 0))]), ('Module', [('Continue', (1, 0))]), +('Module', [('Expr', (1, 0), ('BoolOp', (1, 0), ('And',), [('Compare', (1, 1), ('Name', (1, 1), 'a', ('Load',)), [('Eq',)], [('Str', (1, 6), '')]), ('Name', (1, 14), 'b', ('Load',))]))]), +('Module', [('Expr', (1, 0), ('BoolOp', (1, 0), ('Or',), [('UnaryOp', (1, 0), ('Not',), ('Compare', (1, 5), ('Name', (1, 5), 'a', ('Load',)), [('Eq',)], [('Str', (1, 10), '')])), ('Name', (1, 17), 'b', ('Load',))]))]), +('Module', [('Expr', (1, 0), ('BinOp', (1, 0), ('BinOp', (1, 1), ('Name', (1, 1), 'a', ('Load',)), ('Sub',), ('Name', (1, 5), 'b', ('Load',))), ('Mult',), ('Name', (1, 10), 'c', ('Load',))))]), +('Module', [('For', (1, 0), ('Tuple', (1, 4), [('Name', (1, 4), 'a', ('Store',)), ('Name', (1, 6), 'b', ('Store',))], ('Store',)), ('Name', (1, 11), 'c', ('Load',)), [('Pass', (1, 14))], [])]), +('Module', [('Expr', (1, 0), ('ListComp', (1, 1), ('Tuple', (1, 2), [('Name', (1, 2), 'a', ('Load',)), ('Name', (1, 4), 'b', ('Load',))], ('Load',)), [('comprehension', ('Tuple', (1, 11), [('Name', (1, 11), 'a', ('Store',)), ('Name', (1, 13), 'b', ('Store',))], ('Store',)), ('Name', (1, 18), 'c', ('Load',)), [])]))]), +('Module', [('Expr', (1, 0), ('GeneratorExp', (1, 1), ('Tuple', (1, 2), [('Name', (1, 2), 'a', ('Load',)), ('Name', (1, 4), 'b', ('Load',))], ('Load',)), [('comprehension', ('Tuple', (1, 11), [('Name', (1, 11), 'a', ('Store',)), ('Name', (1, 13), 'b', ('Store',))], ('Store',)), ('Name', (1, 18), 'c', ('Load',)), [])]))]), ] single_results = [ ('Interactive', [('Expr', (1, 0), ('BinOp', (1, 0), ('Num', (1, 0), 1), ('Add',), ('Num', (1, 2), 2)))]), Modified: branches/indy/Lib/test/test_java_subclasses.py =================================================================== --- branches/indy/Lib/test/test_java_subclasses.py 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/Lib/test/test_java_subclasses.py 2009-09-08 18:21:38 UTC (rev 6764) @@ -1,8 +1,6 @@ '''Tests subclassing Java classes in Python''' import os import sys -import tempfile -import subprocess import unittest from test import test_support @@ -323,56 +321,10 @@ self.assertEquals(len(called), 1) -class SettingJavaClassNameTest(unittest.TestCase): - def test_setting_name(self): - class Fixedname(Runnable): - __javaname__ = 'name.set.in.Python' - def run(self): - pass - self.assertEquals('name.set.in.Python', Fixedname().getClass().name) - try: - class NumberPackageName(Runnable): - __javaname__ = 'ok.7.ok' - def run(self): - pass - self.fail("Shouldn't be able to set a package name that starts with a digit") - except TypeError: - pass - try: - class LiteralPackageName(Runnable): - __javaname__ = 'ok.true.ok' - def run(self): - pass - self.fail("Shouldn't be able to use a Java literal as a package name") - except TypeError: - pass - -class StaticProxyCompilationTest(unittest.TestCase): - def setUp(self): - self.orig_proxy_dir = sys.javaproxy_dir - sys.javaproxy_dir = tempfile.mkdtemp() - - def tearDown(self): - sys.javaproxy_dir = self.orig_proxy_dir - - def test_proxies_without_classloader(self): - # importing with proxy_dir set compiles RunnableImpl there - import static_proxy - - # Use the existing environment with the proxy dir added on the classpath - env = dict(os.environ) - env["CLASSPATH"] = sys.javaproxy_dir - script = test_support.findfile("import_as_java_class.py") - self.assertEquals(subprocess.call([sys.executable, "-J-Dpython.cachedir.skip=true", - script], env=env), - 0) - def test_main(): test_support.run_unittest(InterfaceTest, TableModelTest, AutoSuperTest, PythonSubclassesTest, AbstractOnSyspathTest, - ContextClassloaderTest, - SettingJavaClassNameTest, - StaticProxyCompilationTest) + ContextClassloaderTest) Modified: branches/indy/Lib/test/test_java_visibility.py =================================================================== --- branches/indy/Lib/test/test_java_visibility.py 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/Lib/test/test_java_visibility.py 2009-09-08 18:21:38 UTC (rev 6764) @@ -10,6 +10,7 @@ from org.python.tests import VisibilityResults as Results from org.python.tests.RedundantInterfaceDeclarations import (Implementation, ExtraClass, ExtraString, ExtraStringAndClass, ExtraClassAndString) +from org.python.tests.multihidden import BaseConnection class VisibilityTest(unittest.TestCase): def test_invisible(self): @@ -167,6 +168,15 @@ self.assertEquals("int", instance.call(7)) self.assertEquals("Class", instance.call(LinkedList)) + def test_extending_multiple_hidden_classes(self): + '''Tests multiple levels of non-public classes overriding public methods from superclasses + + Bug #1430''' + conn = BaseConnection.newConnection() + self.assertEquals("wrapper close", conn.close()) + self.assertEquals("special close", conn.close(7)) + + class JavaClassTest(unittest.TestCase): def test_class_methods_visible(self): self.assertFalse(HashMap.isInterface(), Modified: branches/indy/NEWS =================================================================== --- branches/indy/NEWS 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/NEWS 2009-09-08 18:21:38 UTC (rev 6764) @@ -1,14 +1,12 @@ Jython NEWS -Jython 2.5.1 +Jython 2.5.1rc1 New Features - Upgraded to ANTLR 3.1.3 - [ 1859477 ] Dynamically loaded ServletFilters like PyServlet - - Setting __javaname__ in classes subclassing Java classes or implementing Java interfaces sets - the name of the produced proxy class. - Built in JSR 223 scripting engine, with LiveTribe JSR 223 implementation for JDK 5 + - Jython "-J-classpath cp_args_here" now works as expected for unix shell. Bugs Fixed - - [ 1415 ] ast Node creation fails with no arg constructors - [ 645615 ] cannot import through symbolic links - [ 1366 ] parsing of lamda expression fails - [ 1365 ] continuation lines fail in interactive interpreter @@ -19,6 +17,19 @@ - [ 1145 ] Jython 2.5 compatibility problem with JSR 223 - [ 1400 ] Evaluating expression via JSR 223 ScriptEngine returns null instead of True/False - [ 1413 ] Array data type (PostgreSQL) is not supported (NPE) + - [ 1434 ] Cannot get return code from a process started with os.popen with Jython 2.5 (worked in 2.2) + - [ 1391 ] socket.getaddrinfo() breaks ftplib FTP client + - [ 1409 ] JSR-233 engine version numbers backwards + - [ 1408 ] JSR-223 engine doesn't implement I/O redirection + - [ 1393 ] TypeError: _new_impl(): expected 1 args; got 0 + - [ 1415 ] ast Node creation fails with no arg constructors + - [ 1405 ] Executing __run__.py from .jar throws exception(SystemExit: 0) in main when sys.exit(0) is called + - [ 1439 ] Can't write() array.array + - [ 1139 ] crashes on isinstance + - [ 1430 ] Oracle JDBC Connection close + - [ 1406 ] Parsing a simple PEP 342 coroutine crashes Jython 2.5 + - [ 1407 ] ClassCastException in plain Python coroutine + - [ 1424 ] Relative imports do not work in some cases Jython 2.5.0 The same as rc4. Modified: branches/indy/README.txt =================================================================== --- branches/indy/README.txt 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/README.txt 2009-09-08 18:21:38 UTC (rev 6764) @@ -1,11 +1,10 @@ -Welcome to Jython 2.5.0 -======================= +Welcome to Jython 2.5.1rc1 +========================== -This is the final release of the 2.5.0 version of Jython and brings us up to -language level compatibility with the 2.5 version of CPython. This release has -had a strong focus on CPython compatibility, and so this release of Jython can -run more pure Python apps then any previous release. Please see the NEWS file -for detailed release notes. +This is the first release candidate of the 2.5.1 version of Jython. This +release fixes a number of bugs, including some major errors when using +coroutines and when using relative imports. Please see the NEWS file for +detailed release notes. The release was compiled on Mac OS X with JDK 5 and requires JDK 5 to run. Modified: branches/indy/ast/asdl.py =================================================================== --- branches/indy/ast/asdl.py 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/ast/asdl.py 2009-09-08 18:21:38 UTC (rev 6764) @@ -10,14 +10,12 @@ Changes for Python: Add support for module versions """ -#__metaclass__ = type - import os import traceback import spark -class Token: +class Token(object): # spark seems to dispatch in the parser based on a token's # type attribute def __init__(self, type, lineno): @@ -45,7 +43,7 @@ self.value = value self.lineno = lineno -class ASDLSyntaxError: +class ASDLSyntaxError(Exception): def __init__(self, lineno, token=None, msg=None): self.lineno = lineno @@ -167,7 +165,7 @@ return Product(fields) def p_sum_0(self, (constructor,)): - " sum ::= constructor """ + " sum ::= constructor " return [constructor] def p_sum_1(self, (constructor, _, sum)): @@ -206,19 +204,19 @@ def p_field_2(self, (type, _, name)): " field ::= Id * Id " - return Field(type, name, seq=1) + return Field(type, name, seq=True) def p_field_3(self, (type, _, name)): " field ::= Id ? Id " - return Field(type, name, opt=1) + return Field(type, name, opt=True) def p_field_4(self, (type, _)): " field ::= Id * " - return Field(type, seq=1) + return Field(type, seq=True) def p_field_5(self, (type, _)): " field ::= Id ? " - return Field(type, opt=1) + return Field(type, opt=True) builtin_types = ("identifier", "string", "int", "bool", "object") @@ -226,7 +224,7 @@ # not sure if any of the methods are useful yet, but I'm adding them # piecemeal as they seem helpful -class AST: +class AST(object): pass # a marker class class Module(AST): @@ -258,7 +256,7 @@ return "Constructor(%s, %s)" % (self.name, self.fields) class Field(AST): - def __init__(self, type, name=None, seq=0, opt=0): + def __init__(self, type, name=None, seq=False, opt=False): self.type = type self.name = name self.seq = seq @@ -266,9 +264,9 @@ def __repr__(self): if self.seq: - extra = ", seq=1" + extra = ", seq=True" elif self.opt: - extra = ", opt=1" + extra = ", opt=True" else: extra = "" if self.name is None: @@ -296,7 +294,7 @@ class VisitorBase(object): - def __init__(self, skip=0): + def __init__(self, skip=False): self.cache = {} self.skip = skip @@ -331,7 +329,7 @@ class Check(VisitorBase): def __init__(self): - super(Check, self).__init__(skip=1) + super(Check, self).__init__(skip=True) self.cons = {} self.errors = 0 self.types = {} @@ -373,7 +371,7 @@ v.visit(mod) for t in v.types: - if not mod.types.has_key(t) and not t in builtin_types: + if t not in mod.types and not t in builtin_types: v.errors += 1 uses = ", ".join(v.types[t]) print "Undefined type %s, used in %s" % (t, uses) Modified: branches/indy/build.xml =================================================================== --- branches/indy/build.xml 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/build.xml 2009-09-08 18:21:38 UTC (rev 6764) @@ -108,12 +108,43 @@ <target name="full-build" depends="full-check, install" description="a full build with svn checkout" /> <target name="needed-check" unless="full-build"> - <uptodate property="antlr.notneeded" targetfile="${dist.dir}/${jython.dev.jar}"> + <uptodate property="antlr.notneeded" targetfile="${gensrc.dir}/org/python/antlr/PythonParser.java"> <srcfiles dir="grammar" includes="*.g" /> </uptodate> </target> - <target name="init" depends="version-init"> + <target name="init"> + <property file="${user.home}/ant.properties" /> + <property file="${basedir}/ant.properties" /> + + <property name="PY_RELEASE_LEVEL_ALPHA" value="10"/> <!-- 0xA --> + <property name="PY_RELEASE_LEVEL_BETA" value="11"/> <!-- 0xB --> + <property name="PY_RELEASE_LEVEL_GAMMA" value="12"/> <!-- 0xC --> + <property name="PY_RELEASE_LEVEL_FINAL" value="15"/> <!-- 0xF --> + <property name="PY_RELEASE_LEVEL_SNAPSHOT" value="170"/> <!-- 0xAA --> + + <!-- The current version info --> + <property name="jython.version" value="2.5.1+"/> + <property name="jython.version.noplus" value="2.5.1"/> + <property name="jython.major_version" value="2"/> + <property name="jython.minor_version" value="5"/> + <property name="jython.micro_version" value="1"/> + <property name="jython.release_level" value="${PY_RELEASE_LEVEL_GAMMA}"/> + <property name="jython.release_serial" value="1"/> + + <condition property="do.snapshot.build"> + <isset property="snapshot.revision" /> + </condition> + <!-- Switch to a snapshot release_level when appropriate --> + <condition property="jython.real_release_level" value="${PY_RELEASE_LEVEL_SNAPSHOT}" else="${jython.release_level}"> + <isset property="do.snapshot.build" /> + </condition> + <condition property="os.family.unix"> + <os family="unix"/> + </condition> + <condition property="os.family.windows"> + <os family="windows"/> + </condition> <property name="build.compiler" value="modern" /> <property name="jdk.target.version" value="1.7" /> <property name="jdk.source.version" value="1.7" /> @@ -158,10 +189,14 @@ <pathelement path="${extlibs.dir}/antlr-3.1.3.jar" /> <pathelement path="${extlibs.dir}/stringtemplate-3.2.jar" /> + <pathelement path="${extlibs.dir}/livetribe-jsr223-2.0.5.jar" /> <pathelement path="${extlibs.dir}/asm-all-3.2.jar" /> + <pathelement path="${extlibs.dir}/jna.jar"/> <pathelement path="${extlibs.dir}/constantine-0.4.jar" /> <pathelement path="${extlibs.dir}/jna-posix.jar"/> + <!-- <pathelement path="${extlibs.dir}/jsr292-mock.jar"/> + --> </path> <available property="informix.present" classname="com.informix.jdbc.IfxDriver" classpath="${informix.jar}" /> @@ -311,6 +346,23 @@ </delete> </target> + <target name="devclean" depends="init" + description="clean up build working directories, without deleting antlr files, cachedir, or Lib."> + + <delete includeemptydirs="true" failonerror="false"> + <fileset dir="${output.dir}" includes="**/*" excludes="gensrc/**"/> + </delete> + <!-- deletes all files and subdirectories of ${dist.dir}, without ${dist.dir} itself. --> + <delete includeemptydirs="true" failonerror="false"> + <fileset dir="${dist.dir}" includes="**/*" excludes="cachedir/**,Lib/**"/> + </delete> + <!-- delete the installation .jar file from ${work.dir}, but no other files --> + <delete failonerror="false"> + <fileset dir="${work.dir}" includes="jython*.jar" /> + </delete> + </target> + + <!-- clean svn.checkout.dir if we really checkout --> <target name="clean-checkout-dir" if="do.checkout"> <delete includeemptydirs="true" failonerror="false"> Property changes on: branches/indy/extlibs/xercesImpl-2.9.1.jar ___________________________________________________________________ Modified: svn:mergeinfo - /branches/newstyle-java-types/extlibs/xercesImpl.jar:5564-5663,5666-5729 + /branches/newstyle-java-types/extlibs/xercesImpl.jar:5564-5663,5666-5729 /trunk/jython/extlibs/xercesImpl-2.9.1.jar:6662-6741 Modified: branches/indy/grammar/Python.g =================================================================== --- branches/indy/grammar/Python.g 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/grammar/Python.g 2009-09-08 18:21:38 UTC (rev 6764) @@ -885,23 +885,23 @@ //if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] if_stmt - : IF test[expr_contextType.Load] COLON ifsuite=suite[false] elif_clause[$test.start]? + : IF test[expr_contextType.Load] COLON ifsuite=suite[false] elif_clause? -> ^(IF<If>[$IF, actions.castExpr($test.tree), actions.castStmts($ifsuite.stypes), actions.makeElse($elif_clause.stypes, $elif_clause.tree)]) ; //not in CPython's Grammar file elif_clause - [Token iftest] returns [List stypes] + returns [List stypes] : else_clause { $stypes = $else_clause.stypes; } | ELIF test[expr_contextType.Load] COLON suite[false] - (e2=elif_clause[$iftest] - -> ^(ELIF<If>[$iftest, actions.castExpr($test.tree), actions.castStmts($suite.stypes), actions.makeElse($e2.stypes, $e2.tree)]) + (e2=elif_clause + -> ^(ELIF<If>[$test.start, actions.castExpr($test.tree), actions.castStmts($suite.stypes), actions.makeElse($e2.stypes, $e2.tree)]) | - -> ^(ELIF<If>[$iftest, actions.castExpr($test.tree), actions.castStmts($suite.stypes), new ArrayList<stmt>()]) + -> ^(ELIF<If>[$test.start, actions.castExpr($test.tree), actions.castStmts($suite.stypes), new ArrayList<stmt>()]) ) ; @@ -1038,10 +1038,15 @@ ; //or_test: and_test ('or' and_test)* -or_test[expr_contextType ctype] +or_test + [expr_contextType ctype] returns [Token leftTok] @after { if ($or != null) { - $or_test.tree = actions.makeBoolOp($left.tree, boolopType.Or, $right); + Token tok = $left.start; + if ($left.leftTok != null) { + tok = $left.leftTok; + } + $or_test.tree = actions.makeBoolOp(tok, $left.tree, boolopType.Or, $right); } } : left=and_test[ctype] @@ -1053,10 +1058,15 @@ ; //and_test: not_test ('and' not_test)* -and_test[expr_contextType ctype] +and_test + [expr_contextType ctype] returns [Token leftTok] @after { if ($and != null) { - $and_test.tree = actions.makeBoolOp($left.tree, boolopType.And, $right); + Token tok = $left.start; + if ($left.leftTok != null) { + tok = $left.leftTok; + } + $and_test.tree = actions.makeBoolOp(tok, $left.tree, boolopType.And, $right); } } : left=not_test[ctype] @@ -1068,18 +1078,21 @@ ; //not_test: 'not' not_test | comparison -not_test[expr_contextType ctype] +not_test + [expr_contextType ctype] returns [Token leftTok] : NOT nt=not_test[ctype] -> ^(NOT<UnaryOp>[$NOT, unaryopType.Not, actions.castExpr($nt.tree)]) - | comparison[ctype] + | comparison[ctype] {$leftTok = $comparison.leftTok;} ; //comparison: expr (comp_op expr)* -comparison[expr_contextType ctype] +comparison + [expr_contextType ctype] returns [Token leftTok] @init { List cmps = new ArrayList(); } @after { + $leftTok = $left.leftTok; if (!cmps.isEmpty()) { $comparison.tree = new Compare($left.start, actions.castExpr($left.tree), actions.makeCmpOps(cmps), actions.castExprs($right)); @@ -1125,7 +1138,8 @@ //expr: xor_expr ('|' xor_expr)* -expr[expr_contextType ect] +expr + [expr_contextType ect] returns [Token leftTok] scope { expr_contextType ctype; } @@ -1133,8 +1147,13 @@ $expr::ctype = ect; } @after { + $leftTok = $left.lparen; if ($op != null) { - $expr.tree = actions.makeBinOp($left.tree, operatorType.BitOr, $right); + Token tok = $left.start; + if ($left.lparen != null) { + tok = $left.lparen; + } + $expr.tree = actions.makeBinOp(tok, $left.tree, operatorType.BitOr, $right); } } : left=xor_expr @@ -1148,10 +1167,16 @@ //xor_expr: and_expr ('^' and_expr)* xor_expr + returns [Token lparen = null] @after { if ($op != null) { - $xor_expr.tree = actions.makeBinOp($left.tree, operatorType.BitXor, $right); + Token tok = $left.start; + if ($left.lparen != null) { + tok = $left.lparen; + } + $xor_expr.tree = actions.makeBinOp(tok, $left.tree, operatorType.BitXor, $right); } + $lparen = $left.lparen; } : left=and_expr ( (op=CIRCUMFLEX right+=and_expr @@ -1163,10 +1188,16 @@ //and_expr: shift_expr ('&' shift_expr)* and_expr + returns [Token lparen = null] @after { if ($op != null) { - $and_expr.tree = actions.makeBinOp($left.tree, operatorType.BitAnd, $right); + Token tok = $left.start; + if ($left.lparen != null) { + tok = $left.lparen; + } + $and_expr.tree = actions.makeBinOp(tok, $left.tree, operatorType.BitAnd, $right); } + $lparen = $left.lparen; } : left=shift_expr ( (op=AMPER right+=shift_expr @@ -1178,18 +1209,26 @@ //shift_expr: arith_expr (('<<'|'>>') arith_expr)* shift_expr + returns [Token lparen = null] @init { List ops = new ArrayList(); + List toks = new ArrayList(); } @after { if (!ops.isEmpty()) { - $shift_expr.tree = actions.makeBinOp($left.tree, ops, $right); + Token tok = $left.start; + if ($left.lparen != null) { + tok = $left.lparen; + } + $shift_expr.tree = actions.makeBinOp(tok, $left.tree, ops, $right, toks); } + $lparen = $left.lparen; } : left=arith_expr ( ( shift_op right+=arith_expr { ops.add($shift_op.op); + toks.add($shift_op.start); } )+ | @@ -1207,18 +1246,26 @@ //arith_expr: term (('+'|'-') term)* arith_expr + returns [Token lparen = null] @init { List ops = new ArrayList(); + List toks = new ArrayList(); } @after { if (!ops.isEmpty()) { - $arith_expr.tree = actions.makeBinOp($left.tree, ops, $right); + Token tok = $left.start; + if ($left.lparen != null) { + tok = $left.lparen; + } + $arith_expr.tree = actions.makeBinOp(tok, $left.tree, ops, $right, toks); } + $lparen = $left.lparen; } : left=term ( (arith_op right+=term { ops.add($arith_op.op); + toks.add($arith_op.start); } )+ | @@ -1244,18 +1291,26 @@ //term: factor (('*'|'/'|'%'|'//') factor)* term + returns [Token lparen = null] @init { List ops = new ArrayList(); + List toks = new ArrayList(); } @after { + $lparen = $left.lparen; if (!ops.isEmpty()) { - $term.tree = actions.makeBinOp($left.tree, ops, $right); + Token tok = $left.start; + if ($left.lparen != null) { + tok = $left.lparen; + } + $term.tree = actions.makeBinOp(tok, $left.tree, ops, $right, toks); } } : left=factor ( (term_op right+=factor { ops.add($term_op.op); + toks.add($term_op.start); } )+ | @@ -1277,7 +1332,7 @@ //factor: ('+'|'-'|'~') factor | power factor - returns [expr etype] + returns [expr etype, Token lparen = null] @after { $factor.tree = $etype; } @@ -1288,17 +1343,21 @@ | TILDE t=factor {$etype = new UnaryOp($TILDE, unaryopType.Invert, $t.etype);} | power - {$etype = actions.castExpr($power.tree);} + { + $etype = actions.castExpr($power.tree); + $lparen = $power.lparen; + } ; //power: atom trailer* ['**' factor] power - returns [expr etype] + returns [expr etype, Token lparen = null] @after { $power.tree = $etype; } : atom (t+=trailer[$atom.start, $atom.tree])* (options {greedy=true;}:d=DOUBLESTAR factor)? { + $lparen = $atom.lparen; //XXX: This could be better. $etype = actions.castExpr($atom.tree); if ($t != null) { @@ -1325,7 +1384,7 @@ if ($d != null) { List right = new ArrayList(); right.add($factor.tree); - $etype = actions.makeBinOp($etype, operatorType.Pow, right); + $etype = actions.makeBinOp($atom.start, $etype, operatorType.Pow, right); } } ; @@ -1336,7 +1395,8 @@ // '`' testlist1 '`' | // NAME | NUMBER | STRING+) atom - : LPAREN + returns [Token lparen = null] + : LPAREN {$lparen = $LPAREN;} ( yield_expr -> yield_expr | testlist_gexp Modified: branches/indy/src/com/ziclix/python/sql/PyConnection.java =================================================================== --- branches/indy/src/com/ziclix/python/sql/PyConnection.java 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/src/com/ziclix/python/sql/PyConnection.java 2009-09-08 18:21:38 UTC (rev 6764) @@ -12,13 +12,11 @@ import java.sql.SQLException; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import org.python.core.ClassDictInit; import org.python.core.Py; import org.python.core.PyBuiltinMethodSet; -import org.python.core.PyClass; import org.python.core.PyInteger; import org.python.core.PyList; import org.python.core.PyObject; @@ -36,39 +34,25 @@ */ public class PyConnection extends PyObject implements ClassDictInit { - /** - * Field closed - */ + /** True if closed. */ protected boolean closed; - /** - * Field connection - */ - protected Connection connection; - - /** - * Field supportsTransactions - */ + /** Whether transactions are supported. */ protected boolean supportsTransactions; - /** - * Field cursors - */ - private Set cursors; + /** The underlying java.sql.Connection. */ + protected Connection connection; - /** - * Field statements - */ - private Set statements; + /** Underlying cursors. */ + private Set<PyCursor> cursors; - /** - * Field __members__ - */ + /** Underlying statements. */ + private Set<PyStatement> statements; + + /** Field __members__ */ protected static PyList __members__; - /** - * Field __methods__ - */ + /** Field __methods__ */ protected static PyList __methods__; static { @@ -101,11 +85,10 @@ * @throws SQLException */ public PyConnection(Connection connection) throws SQLException { - this.closed = false; - this.cursors = new HashSet(); + this.cursors = new HashSet<PyCursor>(); this.connection = connection; - this.statements = new HashSet(); + this.statements = new HashSet<PyStatement>(); this.supportsTransactions = this.connection.getMetaData().supportsTransactions(); if (this.supportsTransactions) { @@ -120,7 +103,6 @@ */ @Override public String toString() { - try { return String.format("<PyConnection object at %s user='%s', url='%s'>", Py.idstr(this), connection.getMetaData().getUserName(), @@ -136,14 +118,20 @@ * @param dict */ static public void classDictInit(PyObject dict) { - + PyObject version = + Py.newString("$Revision$").__getslice__(Py.newInteger(11), + Py.newInteger(-2)); + dict.__setitem__("__version__", version); dict.__setitem__("autocommit", new PyInteger(0)); - dict.__setitem__("__version__", Py.newString("$Revision$").__getslice__(Py.newInteger(11), Py.newInteger(-2), null)); dict.__setitem__("close", new ConnectionFunc("close", 0, 0, 0, zxJDBC.getString("close"))); - dict.__setitem__("commit", new ConnectionFunc("commit", 1, 0, 0, zxJDBC.getString("commit"))); - dict.__setitem__("cursor", new ConnectionFunc("cursor", 2, 0, 4, zxJDBC.getString("cursor"))); - dict.__setitem__("rollback", new ConnectionFunc("rollback", 3, 0, 0, zxJDBC.getString("rollback"))); - dict.__setitem__("nativesql", new ConnectionFunc("nativesql", 4, 1, 1, zxJDBC.getString("nativesql"))); + dict.__setitem__("commit", new ConnectionFunc("commit", 1, 0, 0, + zxJDBC.getString("commit"))); + dict.__setitem__("cursor", new ConnectionFunc("cursor", 2, 0, 4, + zxJDBC.getString("cursor"))); + dict.__setitem__("rollback", new ConnectionFunc("rollback", 3, 0, 0, + zxJDBC.getString("rollback"))); + dict.__setitem__("nativesql", new ConnectionFunc("nativesql", 4, 1, 1, + zxJDBC.getString("nativesql"))); // hide from python dict.__setitem__("initModule", null); @@ -161,8 +149,8 @@ * @param name * @param value */ + @Override public void __setattr__(String name, PyObject value) { - if ("autocommit".equals(name)) { try { if (this.supportsTransactions) { @@ -171,7 +159,6 @@ } catch (SQLException e) { throw zxJDBC.makeException(zxJDBC.DatabaseError, e); } - return; } @@ -184,8 +171,8 @@ * @param name the name of the attribute of interest * @return the value for the attribute of the specified name */ + @Override public PyObject __findattr_ex__(String name) { - if ("autocommit".equals(name)) { try { return connection.getAutoCommit() ? Py.One : Py.Zero; @@ -240,40 +227,31 @@ } /** - * Close the connection now (rather than whenever __del__ is called). - * The connection will be unusable from this point forward; an Error - * (or subclass) exception will be raised if any operation is attempted - * with the connection. The same applies to all cursor objects trying - * to use the connection. + * Close the connection now (rather than whenever __del__ is called). The connection + * will be unusable from this point forward; an Error (or subclass) exception will be + * raised if any operation is attempted with the connection. The same applies to all + * cursor objects trying to use the connection. */ public void close() { - if (closed) { throw zxJDBC.makeException(zxJDBC.ProgrammingError, "connection is closed"); } - // mark ourselves closed now so that any callbacks we - // get from closing down cursors and statements to not - // try and modify our internal sets + // mark ourselves closed now so that any callbacks we get from closing down + // cursors and statements to not try and modify our internal sets this.closed = true; synchronized (this.cursors) { - - // close the cursors - for (Iterator i = this.cursors.iterator(); i.hasNext();) { - ((PyCursor) i.next()).close(); + for (PyCursor cursor: cursors) { + cursor.close(); } - this.cursors.clear(); } synchronized (this.statements) { - - // close the cursors - for (Iterator i = this.statements.iterator(); i.hasNext();) { - ((PyStatement) i.next()).close(); + for (PyStatement statement : statements) { + statement.close(); } - this.statements.clear(); } @@ -285,15 +263,14 @@ } /** - * Commit any pending transaction to the database. Note that if the - * database supports an auto-commit feature, this must be initially - * off. An interface method may be provided to turn it back on. + * Commit any pending transaction to the database. Note that if the database supports + * an auto-commit feature, this must be initially off. An interface method may be + * provided to turn it back on. * <p/> - * Database modules that do not support transactions should implement - * this method with void functionality. + * Database modules that do not support transactions should implement this method with + * void functionality. */ public void commit() { - if (closed) { throw zxJDBC.makeException(zxJDBC.ProgrammingError, "connection is closed"); } @@ -310,16 +287,13 @@ } /** - * <i>This method is optional since not all databases provide transaction - * support.</i> + * <i>This method is optional since not all databases provide transaction support.</i> * <p/> - * In case a database does provide transactions this method causes the database - * to roll back to the start of any pending transaction. Closing a connection - * without committing the changes first will cause an implicit rollback to be - * performed. + * In case a database does provide transactions this method causes the database to + * roll back to the start of any pending transaction. Closing a connection without + * committing the changes first will cause an implicit rollback to be performed. */ public void rollback() { - if (closed) { throw zxJDBC.makeException(zxJDBC.ProgrammingError, "connection is closed"); } @@ -336,10 +310,10 @@ } /** - * Converts the given SQL statement into the system's native SQL grammar. A - * driver may convert the JDBC sql grammar into its system's native SQL grammar - * prior to sending it; this method returns the native form of the statement - * that the driver would have sent. + * Converts the given SQL statement into the system's native SQL grammar. A driver may + * convert the JDBC sql grammar into its system's native SQL grammar prior to sending + * it; this method returns the native form of the statement that the driver would have + * sent. * * @param nativeSQL * @return the native form of this statement @@ -364,9 +338,9 @@ } /** - * Return a new Cursor Object using the connection. If the database does not - * provide a direct cursor concept, the module will have to emulate cursors - * using other means to the extent needed by this specification. + * Return a new Cursor Object using the connection. If the database does not provide a + * direct cursor concept, the module will have to emulate cursors using other means to + * the extent needed by this specification. * * @return a new cursor using this connection */ @@ -375,9 +349,9 @@ } /** - * Return a new Cursor Object using the connection. If the database does not - * provide a direct cursor concept, the module will have to emulate cursors - * using other means to the extent needed by this specification. + * Return a new Cursor Object using the connection. If the database does not provide a + * direct cursor concept, the module will have to emulate cursors using other means to + * the extent needed by this specification. * * @param dynamicFetch if true, dynamically iterate the result * @return a new cursor using this connection @@ -387,9 +361,9 @@ } /** - * Return a new Cursor Object using the connection. If the database does not - * provide a direct cursor concept, the module will have to emulate cursors - * using other means to the extent needed by this specification. + * Return a new Cursor Object using the connection. If the database does not provide a + * direct cursor concept, the module will have to emulate cursors using other means to + * the extent needed by this specification. * * @param dynamicFetch if true, dynamically iterate the result * @param rsType the type of the underlying ResultSet @@ -397,15 +371,12 @@ * @return a new cursor using this connection */ public PyCursor cursor(boolean dynamicFetch, PyObject rsType, PyObject rsConcur) { - if (closed) { throw zxJDBC.makeException(zxJDBC.ProgrammingError, "connection is closed"); } PyCursor cursor = new PyExtendedCursor(this, dynamicFetch, rsType, rsConcur); - this.cursors.add(cursor); - return cursor; } @@ -415,11 +386,9 @@ * @param cursor */ void remove(PyCursor cursor) { - if (closed) { return; } - this.cursors.remove(cursor); } @@ -429,11 +398,9 @@ * @param statement statement */ void add(PyStatement statement) { - if (closed) { return; } - this.statements.add(statement); } @@ -444,20 +411,20 @@ * @return boolean */ boolean contains(PyStatement statement) { - if (closed) { return false; } - return this.statements.contains(statement); } } class ConnectionFunc extends PyBuiltinMethodSet { + ConnectionFunc(String name, int index, int minargs, int maxargs, String doc) { super(name, index, minargs, maxargs, doc, PyConnection.class); } + @Override public PyObject __call__() { PyConnection c = (PyConnection) __self__; switch (index) { @@ -472,11 +439,12 @@ case 3: c.rollback(); return Py.None; - default : + default: throw info.unexpectedCall(0, false); } } + @Override public PyObject __call__(PyObject arg) { PyConnection c = (PyConnection) __self__; switch (index) { @@ -484,21 +452,23 @@ return c.cursor(arg.__nonzero__()); case 4: return c.nativesql(arg); - default : + default: throw info.unexpectedCall(1, false); } } + @Override public PyObject __call__(PyObject arg1, PyObject arg2, PyObject arg3) { PyConnection c = (PyConnection) __self__; switch (index) { case 2: return c.cursor(arg1.__nonzero__(), arg2, arg3); - default : + default: throw info.unexpectedCall(3, false); } } + @Override public PyObject __call__(PyObject[] args, String[] keywords) { PyConnection c = (PyConnection) __self__; PyArgParser parser = new PyArgParser(args, keywords); @@ -514,7 +484,7 @@ return c.cursor(dynamic.__nonzero__(), rstype, rsconcur); - default : + default: throw info.unexpectedCall(args.length, true); } } Modified: branches/indy/src/com/ziclix/python/sql/PyStatement.java =================================================================== --- branches/indy/src/com/ziclix/python/sql/PyStatement.java 2009-09-07 21:48:20 UTC (rev 6763) +++ branches/indy/src/com/ziclix/python/sql/PyStatement.java 2009-09-08 18:21:38 UTC (rev 6764) @@ -8,12 +8,13 @@ */ package com.ziclix.python.sql; +import org.python.core.codecs; impor... [truncated message content] |
From: <fwi...@us...> - 2009-09-25 03:08:57
|
Revision: 6810 http://jython.svn.sourceforge.net/jython/?rev=6810&view=rev Author: fwierzbicki Date: 2009-09-25 03:08:49 +0000 (Fri, 25 Sep 2009) Log Message: ----------- Replace tableswitch in modules with MethodHandles. Modified Paths: -------------- branches/indy/build.xml branches/indy/src/org/python/compiler/ClassConstants.java branches/indy/src/org/python/compiler/Code.java branches/indy/src/org/python/compiler/Module.java branches/indy/src/org/python/core/Py.java branches/indy/src/org/python/core/imp.java Added Paths: ----------- branches/indy/src/org/python/core/IndyCode.java branches/indy/src/org/python/core/IndyFunctionTable.java branches/indy/src/org/python/util/CodegenUtils.java Modified: branches/indy/build.xml =================================================================== --- branches/indy/build.xml 2009-09-24 01:34:49 UTC (rev 6809) +++ branches/indy/build.xml 2009-09-25 03:08:49 UTC (rev 6810) @@ -171,11 +171,11 @@ <property name="dist.dir" value="${work.dir}/dist" /> <property name="apidoc.dir" value="${dist.dir}/Doc/javadoc" /> <property name="junit.reports" value="${dist.dir}/testreports" /> + <!-- <property name="javac.Xlint" value="-Xlint -Xlint:-serial -Xlint:-unchecked -Xlint:-cast -Xbootclasspath/p:${extlibs.dir}/jsr292-mock.jar"/> - <!-- + --> <property name="javac.Xlint" value="-Xlint -Xlint:-serial -XDinvokedynamic -Xlint:-unchecked -Xlint:-cast"/> - --> <!-- classpaths --> <path id="main.classpath"> <pathelement path="${extlibs.dir}/libreadline-java-0.8.jar" /> Modified: branches/indy/src/org/python/compiler/ClassConstants.java =================================================================== --- branches/indy/src/org/python/compiler/ClassConstants.java 2009-09-24 01:34:49 UTC (rev 6809) +++ branches/indy/src/org/python/compiler/ClassConstants.java 2009-09-25 03:08:49 UTC (rev 6810) @@ -15,7 +15,7 @@ final static String $pyFloat = "Lorg/python/core/PyFloat;"; final static String $pyComplex = "Lorg/python/core/PyComplex;"; final static String $pyRunnable = "Lorg/python/core/PyRunnable;"; - final static String $pyFuncTbl = "Lorg/python/core/PyFunctionTable;"; + final static String $pyFuncTbl = "Lorg/python/core/IndyFunctionTable;"; final static String $pyProxy = "Lorg/python/core/PyProxy;"; final static String $obj = "Ljava/lang/Object;"; Modified: branches/indy/src/org/python/compiler/Code.java =================================================================== --- branches/indy/src/org/python/compiler/Code.java 2009-09-24 01:34:49 UTC (rev 6809) +++ branches/indy/src/org/python/compiler/Code.java 2009-09-25 03:08:49 UTC (rev 6810) @@ -480,7 +480,11 @@ public void invokevirtual(String owner, String name, String type) { mv.visitMethodInsn(INVOKEVIRTUAL, owner, name, type); } - + + public void invokedynamic(String owner, String name, String type) { + mv.visitMethodInsn(INVOKEDYNAMIC, owner, name, type); + } + public void ireturn() { mv.visitInsn(IRETURN); } Modified: branches/indy/src/org/python/compiler/Module.java =================================================================== --- branches/indy/src/org/python/compiler/Module.java 2009-09-24 01:34:49 UTC (rev 6809) +++ branches/indy/src/org/python/compiler/Module.java 2009-09-25 03:08:49 UTC (rev 6810) @@ -16,6 +16,7 @@ import org.python.core.CodeFlag; import org.python.core.CodeLoader; import org.python.core.CompilerFlags; +import org.python.core.invokedynamic.InvokeDynamicSupport; import org.python.core.Py; import org.python.core.PyException; import org.python.core.PyRunnableBootstrap; @@ -24,6 +25,7 @@ import org.python.antlr.PythonTree; import org.python.antlr.ast.Suite; import org.python.antlr.base.mod; +import static org.python.util.CodegenUtils.*; class PyIntegerConstant extends Constant implements ClassConstants, Opcodes { @@ -268,8 +270,23 @@ c.getstatic(module.classfile.name, "self", "L"+module.classfile.name+";"); - c.iconst(id); + //REPLACING WITH METH HANDLE + //c.iconst(id); +c.visitMethodInsn(INVOKESTATIC, "java/dyn/MethodHandles", "lookup", "()Ljava/dyn/MethodHandles$Lookup;"); +c.visitLdcInsn(Type.getType("L"+module.classfile.name+";")); +c.visitLdcInsn(fname); +c.visitLdcInsn(Type.getType("Lorg/python/core/PyObject;")); +c.visitLdcInsn(Type.getType("Lorg/python/core/PyFrame;")); +c.visitInsn(ICONST_1); +c.visitTypeInsn(ANEWARRAY, "java/lang/Class"); +c.visitInsn(DUP); +c.visitInsn(ICONST_0); +c.visitLdcInsn(Type.getType("Lorg/python/core/ThreadState;")); +c.visitInsn(AASTORE); +c.visitMethodInsn(INVOKESTATIC, "java/dyn/MethodType", "make", "(Ljava/lang/Class;Ljava/lang/Class;[Ljava/lang/Class;)Ljava/dyn/MethodType;"); +c.visitMethodInsn(INVOKEVIRTUAL, "java/dyn/MethodHandles$Lookup", "findVirtual", "(Ljava/lang/Class;Ljava/lang/String;Ljava/dyn/MethodType;)Ljava/dyn/MethodHandle;"); + if (cellvars != null) { int strArray = CodeCompiler.makeStrings(c, cellvars); c.aload(strArray); @@ -287,7 +304,7 @@ c.iconst(moreflags); - c.invokestatic("org/python/core/Py", "newCode", "(I" + $strArr + $str + $str + "IZZ" + $pyFuncTbl + "I" + $strArr + $strArr + "II)" + $pyCode); + c.invokestatic("org/python/core/Py", "newCode", "(I" + $strArr + $str + $str + "IZZ" + $pyFuncTbl + "Ljava/dyn/MethodHandle;" + $strArr + $strArr + "II)" + $pyCode); c.putstatic(module.classfile.name, name, $pyCode); } } @@ -310,7 +327,7 @@ public Module(String name, String filename, boolean linenumbers, long mtime) { this.linenumbers = linenumbers; this.mtime = mtime; - classfile = new ClassFile(name, "org/python/core/PyFunctionTable", + classfile = new ClassFile(name, "org/python/core/IndyFunctionTable", ACC_SYNCHRONIZED | ACC_PUBLIC, mtime); constants = new Hashtable<Constant,Constant>(); sfilename = filename; @@ -523,7 +540,11 @@ public void addInit() throws IOException { Code c = classfile.addMethod("<init>", "(Ljava/lang/String;)V", ACC_PUBLIC); c.aload(0); - c.invokespecial("org/python/core/PyFunctionTable", "<init>", "()V"); + c.invokespecial("org/python/core/IndyFunctionTable", "<init>", "()V"); + + //HERE + //c.invokestatic(p(InvokeDynamicSupport.class), "registerBootstrap", sig(void.class, Class.class)); + addConstants(c); } @@ -584,30 +605,22 @@ public void addFunctions() throws IOException { Code code = classfile.addMethod( "call_function", - "(I" + $pyFrame + $threadState + ")" + $pyObj, + "(Ljava/dyn/MethodHandle;" + $pyFrame + $threadState + ")" + $pyObj, ACC_PUBLIC); + code.aload(1); // handle code.aload(0); // this code.aload(2); // frame code.aload(3); // thread state + /* Label def = new Label(); Label[] labels = new Label[codes.size()]; int i; for(i=0; i<labels.length; i++) labels[i] = new Label(); - //Get index for function to call - code.iload(1); - code.tableswitch(0, labels.length - 1, def, labels); - for(i=0; i<labels.length; i++) { - code.label(labels[i]); - code.invokevirtual(classfile.name, (codes.get(i)).fname, "(" + $pyFrame + $threadState + ")" + $pyObj); - code.areturn(); - } - code.label(def); - - //Should probably throw internal exception here - code.aconst_null(); + */ + code.invokevirtual("java/dyn/MethodHandle", "invoke", "(Ljava/lang/Object;" + $pyFrame + $threadState + ")" + $pyObj); code.areturn(); } Added: branches/indy/src/org/python/core/IndyCode.java =================================================================== --- branches/indy/src/org/python/core/IndyCode.java (rev 0) +++ branches/indy/src/org/python/core/IndyCode.java 2009-09-25 03:08:49 UTC (rev 6810) @@ -0,0 +1,212 @@ +// Copyright (c) Corporation for National Research Initiatives +package org.python.core; + +/** + * An implementation of PyCode where the actual executable content + * is stored as a PyFunctionTable instance and an integer index. + */ + +import org.python.modules._systemrestart; +import java.dyn.MethodHandle; + +public class IndyCode extends PyBaseCode +{ + + IndyFunctionTable funcs; + MethodHandle func_id; + public String co_code = ""; // only used by inspect + + public IndyCode(int argcount, String varnames[], + String filename, String name, + int firstlineno, + boolean varargs, boolean varkwargs, + IndyFunctionTable funcs, MethodHandle func_id) + { + this(argcount, varnames, filename, name, firstlineno, varargs, + varkwargs, funcs, func_id, null, null, 0, 0); + } + + public IndyCode(int argcount, String varnames[], + String filename, String name, + int firstlineno, + boolean varargs, boolean varkwargs, + IndyFunctionTable funcs, MethodHandle func_id, + String[] cellvars, String[] freevars, int npurecell, + int moreflags) // may change + { + co_argcount = nargs = argcount; + co_varnames = varnames; + co_nlocals = varnames.length; + co_filename = filename; + co_firstlineno = firstlineno; + co_cellvars = cellvars; + co_freevars = freevars; + this.jy_npurecell = npurecell; + this.varargs = varargs; + co_name = name; + if (varargs) { + co_argcount -= 1; + co_flags.setFlag(CodeFlag.CO_VARARGS); + } + this.varkwargs = varkwargs; + if (varkwargs) { + co_argcount -= 1; + co_flags.setFlag(CodeFlag.CO_VARKEYWORDS); + } + co_flags = new CompilerFlags(co_flags.toBits() | moreflags); + this.funcs = funcs; + this.func_id = func_id; + } + + private static final String[] __members__ = { + "co_name", "co_argcount", + "co_varnames", "co_filename", "co_firstlineno", + "co_flags","co_cellvars","co_freevars","co_nlocals" + // not supported: co_code, co_consts, co_names, + // co_lnotab, co_stacksize + }; + + public PyObject __dir__() { + PyString members[] = new PyString[__members__.length]; + for (int i = 0; i < __members__.length; i++) + members[i] = new PyString(__members__[i]); + return new PyList(members); + } + + private void throwReadonly(String name) { + for (int i = 0; i < __members__.length; i++) + if (__members__[i] == name) + throw Py.TypeError("readonly attribute"); + throw Py.AttributeError(name); + } + + public void __setattr__(String name, PyObject value) { + // no writable attributes + throwReadonly(name); + } + + public void __delattr__(String name) { + throwReadonly(name); + } + + private static PyTuple toPyStringTuple(String[] ar) { + if (ar == null) return Py.EmptyTuple; + int sz = ar.length; + PyString[] pystr = new PyString[sz]; + for (int i = 0; i < sz; i++) { + pystr[i] = new PyString(ar[i]); + } + return new PyTuple(pystr); + } + + public PyObject __findattr_ex__(String name) { + // have to craft co_varnames specially + if (name == "co_varnames") { + return toPyStringTuple(co_varnames); + } + if (name == "co_cellvars") { + return toPyStringTuple(co_cellvars); + } + if (name == "co_freevars") { + return toPyStringTuple(co_freevars); + } + if (name == "co_filename") { + return new PyString(co_filename); + } + if (name == "co_name") { + return new PyString(co_name); + } + if (name == "co_flags") { + return Py.newInteger(co_flags.toBits()); + } + return super.__findattr_ex__(name); + } + + @Override + public PyObject call(ThreadState ts, PyFrame frame, PyObject closure) { +// System.err.println("tablecode call: "+co_name); + if (ts.systemState == null) { + ts.systemState = Py.defaultSystemState; + } + //System.err.println("got ts: "+ts+", "+ts.systemState); + + // Cache previously defined exception + PyException previous_exception = ts.exception; + + // Push frame + frame.f_back = ts.frame; + if (frame.f_builtins == null) { + if (frame.f_back != null) { + frame.f_builtins = frame.f_back.f_builtins; + } else { + //System.err.println("ts: "+ts); + //System.err.println("ss: "+ts.systemState); + frame.f_builtins = PySystemState.builtins; + } + } + // nested scopes: setup env with closure + // this should only be done once, so let the frame take care of it + frame.setupEnv((PyTuple)closure); + + ts.frame = frame; + + // Handle trace function for debugging + if (ts.tracefunc != null) { + frame.f_lineno = co_firstlineno; + frame.tracefunc = ts.tracefunc.traceCall(frame); + } + + // Handle trace function for profiling + if (ts.profilefunc != null) { + ts.profilefunc.traceCall(frame); + } + + PyObject ret; + try { + ret = funcs.call_function(func_id, frame, ts); + } catch (Throwable t) { + // Convert exceptions that occured in Java code to PyExceptions + PyException pye = Py.JavaError(t); + pye.tracebackHere(frame); + + frame.f_lasti = -1; + + if (frame.tracefunc != null) { + frame.tracefunc.traceException(frame, pye); + } + if (ts.profilefunc != null) { + ts.profilefunc.traceException(frame, pye); + } + + // Rethrow the exception to the next stack frame + ts.exception = previous_exception; + ts.frame = ts.frame.f_back; + throw pye; + } + + if (frame.tracefunc != null) { + frame.tracefunc.traceReturn(frame, ret); + } + // Handle trace function for profiling + if (ts.profilefunc != null) { + ts.profilefunc.traceReturn(frame, ret); + } + + // Restore previously defined exception + ts.exception = previous_exception; + + ts.frame = ts.frame.f_back; + + // Check for interruption, which is used for restarting the interpreter + // on Jython + if (Thread.currentThread().isInterrupted()) { + throw new PyException(_systemrestart.SystemRestart); + } + return ret; + } + + @Override + protected PyObject interpret(PyFrame f, ThreadState ts) { + throw new UnsupportedOperationException("Inlined interpret to improve call performance (may want to reconsider in the future)."); + } +} Property changes on: branches/indy/src/org/python/core/IndyCode.java ___________________________________________________________________ Added: svn:eol-style + native Added: branches/indy/src/org/python/core/IndyFunctionTable.java =================================================================== --- branches/indy/src/org/python/core/IndyFunctionTable.java (rev 0) +++ branches/indy/src/org/python/core/IndyFunctionTable.java 2009-09-25 03:08:49 UTC (rev 6810) @@ -0,0 +1,15 @@ +// Copyright (c) Corporation for National Research Initiatives +package org.python.core; + +import java.dyn.MethodHandle; +/** + * An entry point for class that implements several function calls. + * <P> + * Used together with the PyTableCode class. + * + * @see PyTableCode + */ + +public abstract class IndyFunctionTable { + abstract public PyObject call_function(MethodHandle mh, PyFrame frame, ThreadState ts); +} Property changes on: branches/indy/src/org/python/core/IndyFunctionTable.java ___________________________________________________________________ Added: svn:eol-style + native Modified: branches/indy/src/org/python/core/Py.java =================================================================== --- branches/indy/src/org/python/core/Py.java 2009-09-24 01:34:49 UTC (rev 6809) +++ branches/indy/src/org/python/core/Py.java 2009-09-25 03:08:49 UTC (rev 6810) @@ -1,6 +1,7 @@ // Copyright (c) Corporation for National Research Initiatives package org.python.core; +import java.dyn.MethodHandle; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; @@ -630,10 +631,10 @@ public static PyCode newCode(int argcount, String varnames[], String filename, String name, boolean args, boolean keywords, - PyFunctionTable funcs, int func_id, + IndyFunctionTable funcs, MethodHandle func_id, String[] cellvars, String[] freevars, int npurecell, int moreflags) { - return new PyTableCode(argcount, varnames, + return new IndyCode(argcount, varnames, filename, name, 0, args, keywords, funcs, func_id, cellvars, freevars, npurecell, moreflags); @@ -643,10 +644,10 @@ String filename, String name, int firstlineno, boolean args, boolean keywords, - PyFunctionTable funcs, int func_id, + IndyFunctionTable funcs, MethodHandle func_id, String[] cellvars, String[] freevars, int npurecell, int moreflags) { - return new PyTableCode(argcount, varnames, + return new IndyCode(argcount, varnames, filename, name, firstlineno, args, keywords, funcs, func_id, cellvars, freevars, npurecell, moreflags); @@ -656,8 +657,8 @@ public static PyCode newCode(int argcount, String varnames[], String filename, String name, boolean args, boolean keywords, - PyFunctionTable funcs, int func_id) { - return new PyTableCode(argcount, varnames, + IndyFunctionTable funcs, MethodHandle func_id) { + return new IndyCode(argcount, varnames, filename, name, 0, args, keywords, funcs, func_id); } @@ -666,8 +667,8 @@ String filename, String name, int firstlineno, boolean args, boolean keywords, - PyFunctionTable funcs, int func_id) { - return new PyTableCode(argcount, varnames, + IndyFunctionTable funcs, MethodHandle func_id) { + return new IndyCode(argcount, varnames, filename, name, firstlineno, args, keywords, funcs, func_id); } @@ -1194,9 +1195,9 @@ globals = ts.frame.f_globals; } - PyTableCode tc = null; - if (code instanceof PyTableCode) { - tc = (PyTableCode) code; + IndyCode tc = null; + if (code instanceof IndyCode) { + tc = (IndyCode) code; } f = new PyFrame(tc, locals, globals, Modified: branches/indy/src/org/python/core/imp.java =================================================================== --- branches/indy/src/org/python/core/imp.java 2009-09-24 01:34:49 UTC (rev 6809) +++ branches/indy/src/org/python/core/imp.java 2009-09-25 03:08:49 UTC (rev 6810) @@ -308,9 +308,9 @@ public static PyObject createFromCode(String name, PyCode c, String moduleLocation) { PyModule module = addModule(name); - PyTableCode code = null; - if (c instanceof PyTableCode) { - code = (PyTableCode) c; + IndyCode code = null; + if (c instanceof IndyCode) { + code = (IndyCode) c; } if (moduleLocation != null) { Added: branches/indy/src/org/python/util/CodegenUtils.java =================================================================== --- branches/indy/src/org/python/util/CodegenUtils.java (rev 0) +++ branches/indy/src/org/python/util/CodegenUtils.java 2009-09-25 03:08:49 UTC (rev 6810) @@ -0,0 +1,137 @@ +/* + * Initial code taken from Charlie Nutter's org.jruby.util.CodegenUtils. + */ + +package org.python.util; + +import java.util.Arrays; + +public class CodegenUtils { + + /** + * Creates a dotted class name from a path/package name + */ + public static String c(String p) { + return p.replace('/', '.'); + } + + /** + * Creates a class path name, from a Class. + */ + public static String p(Class n) { + return n.getName().replace('.','/'); + } + + /** + * Creates a class identifier of form Labc/abc;, from a Class. + */ + public static String ci(Class n) { + if (n.isArray()) { + n = n.getComponentType(); + if (n.isPrimitive()) { + if (n == Byte.TYPE) { + return "[B"; + } else if (n == Boolean.TYPE) { + return "[Z"; + } else if (n == Short.TYPE) { + return "[S"; + } else if (n == Character.TYPE) { + return "[C"; + } else if (n == Integer.TYPE) { + return "[I"; + } else if (n == Float.TYPE) { + return "[F"; + } else if (n == Double.TYPE) { + return "[D"; + } else if (n == Long.TYPE) { + return "[J"; + } else { + throw new RuntimeException("Unrecognized type in compiler: " + n.getName()); + } + } else { + return "[" + ci(n); + } + } else { + if (n.isPrimitive()) { + if (n == Byte.TYPE) { + return "B"; + } else if (n == Boolean.TYPE) { + return "Z"; + } else if (n == Short.TYPE) { + return "S"; + } else if (n == Character.TYPE) { + return "C"; + } else if (n == Integer.TYPE) { + return "I"; + } else if (n == Float.TYPE) { + return "F"; + } else if (n == Double.TYPE) { + return "D"; + } else if (n == Long.TYPE) { + return "J"; + } else if (n == Void.TYPE) { + return "V"; + } else { + throw new RuntimeException("Unrecognized type in compiler: " + n.getName()); + } + } else { + return "L" + p(n) + ";"; + } + } + } + + /** + * Create a method signature from the given param types and return values + */ + public static String sig(Class retval, Class... params) { + return sigParams(params) + ci(retval); + } + + public static String sig(Class retval, String descriptor, Class... params) { + return sigParams(descriptor, params) + ci(retval); + } + + public static String sigParams(Class... params) { + StringBuilder signature = new StringBuilder("("); + + for (int i = 0; i < params.length; i++) { + signature.append(ci(params[i])); + } + + signature.append(")"); + + return signature.toString(); + } + + public static String sigParams(String descriptor, Class... params) { + StringBuilder signature = new StringBuilder("("); + + signature.append(descriptor); + + for (int i = 0; i < params.length; i++) { + signature.append(ci(params[i])); + } + + signature.append(")"); + + return signature.toString(); + } + + public static Class[] params(Class... classes) { + return classes; + } + + public static Class[] params(Class cls, int times) { + Class[] classes = new Class[times]; + Arrays.fill(classes, cls); + return classes; + } + + public static Class[] params(Class cls1, Class clsFill, int times) { + Class[] classes = new Class[times + 1]; + Arrays.fill(classes, clsFill); + classes[0] = cls1; + return classes; + } + +} Property changes on: branches/indy/src/org/python/util/CodegenUtils.java ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-10-01 01:16:50
|
Revision: 6817 http://jython.svn.sourceforge.net/jython/?rev=6817&view=rev Author: fwierzbicki Date: 2009-10-01 01:16:13 +0000 (Thu, 01 Oct 2009) Log Message: ----------- Merged revisions 6762-6763,6766-6785,6788-6789,6795-6797,6800,6807-6808,6812,6814 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython ........ r6762 | zyasoft | 2009-09-07 16:41:45 -0400 (Mon, 07 Sep 2009) | 4 lines Fixed regression where threading._Lock, _RLock were no longer available as synonyms to Lock and RLock respectively, which Twisted needs. Added a test case to prevent recurrence. This resolves #1079. ........ r6763 | zyasoft | 2009-09-07 17:48:20 -0400 (Mon, 07 Sep 2009) | 5 lines CodeCompiler#visitAssert now looks up the AssertionError by using PyFrame#getglobal, so user code can redefine the behavior of assert. Fixes #1461 Bumped bytecode magic. ........ r6766 | pjenvey | 2009-09-08 22:58:36 -0400 (Tue, 08 Sep 2009) | 4 lines don't assume posix fixes #1425 thanks Matthew L Daniel ........ r6767 | pjenvey | 2009-09-08 23:06:20 -0400 (Tue, 08 Sep 2009) | 3 lines fix os.popen*/popen2 to only invoke a shell if cmd is a string refs http://bugs.python.org/issue5329 ........ r6768 | pjenvey | 2009-09-08 23:24:04 -0400 (Tue, 08 Sep 2009) | 3 lines fix array.to/fromfile on files in + mode fixes #1457 ........ r6769 | pjenvey | 2009-09-08 23:45:43 -0400 (Tue, 08 Sep 2009) | 4 lines fix __cmp__ specifying the wrong array type to lookup_where triggering an ArrayStoreException in some cases fixes #1382 ........ r6770 | pjenvey | 2009-09-08 23:47:22 -0400 (Tue, 08 Sep 2009) | 2 lines regen per r6769 ........ r6771 | pjenvey | 2009-09-09 00:16:49 -0400 (Wed, 09 Sep 2009) | 3 lines allow hashlib updating from arrays fixes #1443 ........ r6772 | pjenvey | 2009-09-09 00:59:15 -0400 (Wed, 09 Sep 2009) | 3 lines allow zlib input from arrays fixes #1444 ........ r6773 | pjenvey | 2009-09-09 01:47:17 -0400 (Wed, 09 Sep 2009) | 1 line whitespace ........ r6774 | fwierzbicki | 2009-09-09 08:11:47 -0400 (Wed, 09 Sep 2009) | 2 lines tab -> spaces. ........ r6775 | fwierzbicki | 2009-09-09 12:59:20 -0400 (Wed, 09 Sep 2009) | 2 lines Cleanup. ........ r6776 | fwierzbicki | 2009-09-09 13:28:32 -0400 (Wed, 09 Sep 2009) | 3 lines Add PyList testing for http://bugs.jython.org/issue1419, but it will also be a good place for testing the Java List interface of PyList in the future. ........ r6777 | fwierzbicki | 2009-09-09 13:35:38 -0400 (Wed, 09 Sep 2009) | 3 lines Test PyTuple for http://bugs.jython.org/issue1419 "Bug in PyTuple.indexOf and PyList.indexOf". ........ r6778 | fwierzbicki | 2009-09-09 13:47:39 -0400 (Wed, 09 Sep 2009) | 2 lines Give tests non-stupid names. ........ r6779 | fwierzbicki | 2009-09-09 13:59:05 -0400 (Wed, 09 Sep 2009) | 2 lines Also test the toArray() bugs fixed by Andrea's patch applied by Tobias. ........ r6780 | pjenvey | 2009-09-10 23:35:35 -0400 (Thu, 10 Sep 2009) | 4 lines support multiple ResultSets via cursor.nextset. to accommodate this staticFetch Statements are no longer immediately closed after execute (unless an exception was thrown), like dynamicFetch ........ r6781 | cgroves | 2009-09-11 01:22:00 -0400 (Fri, 11 Sep 2009) | 1 line Widening, standards ........ r6782 | pjenvey | 2009-09-11 01:34:56 -0400 (Fri, 11 Sep 2009) | 4 lines o fix PyTuple/List.equals not trying rich comparison (_eq) to all other PyObjects like PyObject.equals does o no need to synchronize all of PyList.equals ........ r6783 | pjenvey | 2009-09-11 01:52:44 -0400 (Fri, 11 Sep 2009) | 1 line cleanup ........ r6784 | zyasoft | 2009-09-11 02:44:19 -0400 (Fri, 11 Sep 2009) | 4 lines Added with-statement support to zxJDBC: * PyConnection - commit if no exception, otherwise rollback * PyCursor - always close this resource ........ r6785 | cgroves | 2009-09-11 02:55:34 -0400 (Fri, 11 Sep 2009) | 3 lines Use the builtin codecs when nothing is found in the registry. Fixes issue 1458. ........ r6788 | zyasoft | 2009-09-11 22:24:31 -0400 (Fri, 11 Sep 2009) | 1 line Updated NEWS re zxJDBC support of with-statement ........ r6789 | fwierzbicki | 2009-09-12 14:14:14 -0400 (Sat, 12 Sep 2009) | 2 lines Update versions. ........ r6795 | pjenvey | 2009-09-13 19:30:43 -0400 (Sun, 13 Sep 2009) | 1 line add @Overrides ........ r6796 | pjenvey | 2009-09-13 21:05:23 -0400 (Sun, 13 Sep 2009) | 4 lines force real O_APPEND for files' 'a' mode by going through FileOutputStream, otherwise emulate it with a performance hit for 'a+' mode fixes #1466 ........ r6797 | pjenvey | 2009-09-13 21:49:05 -0400 (Sun, 13 Sep 2009) | 1 line actually test 'a+' ........ r6800 | fwierzbicki | 2009-09-17 00:14:04 -0400 (Thu, 17 Sep 2009) | 2 lines Remove modules that now have modified versions living in our Lib/ ........ r6807 | fwierzbicki | 2009-09-23 20:16:35 -0400 (Wed, 23 Sep 2009) | 2 lines Update README for rc3. ........ r6808 | fwierzbicki | 2009-09-23 20:17:16 -0400 (Wed, 23 Sep 2009) | 2 lines Finish updating README for rc3. ........ r6812 | fwierzbicki | 2009-09-26 12:14:48 -0400 (Sat, 26 Sep 2009) | 2 lines Update README and version numbering. ........ r6814 | fwierzbicki | 2009-09-26 21:34:11 -0400 (Sat, 26 Sep 2009) | 2 lines Removed unused import from thread.java, expanded javadoc package scan. ........ Modified Paths: -------------- branches/indy/CPythonLib.includes branches/indy/Lib/distutils/util.py branches/indy/Lib/popen2.py branches/indy/Lib/test/test_array_jy.py branches/indy/Lib/test/test_cmp_jy.py branches/indy/Lib/test/test_hashlib_jy.py branches/indy/Lib/test/test_seq_jy.py branches/indy/Lib/test/test_threading_jy.py branches/indy/Lib/threading.py branches/indy/Lib/zlib.py branches/indy/NEWS branches/indy/README.txt branches/indy/build.xml branches/indy/src/com/ziclix/python/sql/PyConnection.java branches/indy/src/com/ziclix/python/sql/PyCursor.java branches/indy/src/org/python/antlr/PythonTree.java branches/indy/src/org/python/antlr/ast/AssertDerived.java branches/indy/src/org/python/antlr/ast/AssignDerived.java branches/indy/src/org/python/antlr/ast/AttributeDerived.java branches/indy/src/org/python/antlr/ast/AugAssignDerived.java branches/indy/src/org/python/antlr/ast/BinOpDerived.java branches/indy/src/org/python/antlr/ast/BoolOpDerived.java branches/indy/src/org/python/antlr/ast/BreakDerived.java branches/indy/src/org/python/antlr/ast/CallDerived.java branches/indy/src/org/python/antlr/ast/ClassDefDerived.java branches/indy/src/org/python/antlr/ast/CompareDerived.java branches/indy/src/org/python/antlr/ast/ContinueDerived.java branches/indy/src/org/python/antlr/ast/DeleteDerived.java branches/indy/src/org/python/antlr/ast/DictDerived.java branches/indy/src/org/python/antlr/ast/EllipsisDerived.java branches/indy/src/org/python/antlr/ast/ExceptHandlerDerived.java branches/indy/src/org/python/antlr/ast/ExecDerived.java branches/indy/src/org/python/antlr/ast/ExprDerived.java branches/indy/src/org/python/antlr/ast/ExpressionDerived.java branches/indy/src/org/python/antlr/ast/ExtSliceDerived.java branches/indy/src/org/python/antlr/ast/ForDerived.java branches/indy/src/org/python/antlr/ast/FunctionDefDerived.java branches/indy/src/org/python/antlr/ast/GeneratorExpDerived.java branches/indy/src/org/python/antlr/ast/GlobalDerived.java branches/indy/src/org/python/antlr/ast/IfDerived.java branches/indy/src/org/python/antlr/ast/IfExpDerived.java branches/indy/src/org/python/antlr/ast/ImportDerived.java branches/indy/src/org/python/antlr/ast/ImportFromDerived.java branches/indy/src/org/python/antlr/ast/IndexDerived.java branches/indy/src/org/python/antlr/ast/InteractiveDerived.java branches/indy/src/org/python/antlr/ast/LambdaDerived.java branches/indy/src/org/python/antlr/ast/ListCompDerived.java branches/indy/src/org/python/antlr/ast/ListDerived.java branches/indy/src/org/python/antlr/ast/ModuleDerived.java branches/indy/src/org/python/antlr/ast/NameDerived.java branches/indy/src/org/python/antlr/ast/NumDerived.java branches/indy/src/org/python/antlr/ast/PassDerived.java branches/indy/src/org/python/antlr/ast/PrintDerived.java branches/indy/src/org/python/antlr/ast/RaiseDerived.java branches/indy/src/org/python/antlr/ast/ReprDerived.java branches/indy/src/org/python/antlr/ast/ReturnDerived.java branches/indy/src/org/python/antlr/ast/SliceDerived.java branches/indy/src/org/python/antlr/ast/StrDerived.java branches/indy/src/org/python/antlr/ast/SubscriptDerived.java branches/indy/src/org/python/antlr/ast/SuiteDerived.java branches/indy/src/org/python/antlr/ast/TryExceptDerived.java branches/indy/src/org/python/antlr/ast/TryFinallyDerived.java branches/indy/src/org/python/antlr/ast/TupleDerived.java branches/indy/src/org/python/antlr/ast/UnaryOpDerived.java branches/indy/src/org/python/antlr/ast/WhileDerived.java branches/indy/src/org/python/antlr/ast/WithDerived.java branches/indy/src/org/python/antlr/ast/YieldDerived.java branches/indy/src/org/python/antlr/ast/aliasDerived.java branches/indy/src/org/python/antlr/ast/argumentsDerived.java branches/indy/src/org/python/antlr/ast/comprehensionDerived.java branches/indy/src/org/python/antlr/ast/keywordDerived.java branches/indy/src/org/python/antlr/op/AddDerived.java branches/indy/src/org/python/antlr/op/AndDerived.java branches/indy/src/org/python/antlr/op/AugLoadDerived.java branches/indy/src/org/python/antlr/op/AugStoreDerived.java branches/indy/src/org/python/antlr/op/BitAndDerived.java branches/indy/src/org/python/antlr/op/BitOrDerived.java branches/indy/src/org/python/antlr/op/BitXorDerived.java branches/indy/src/org/python/antlr/op/DelDerived.java branches/indy/src/org/python/antlr/op/DivDerived.java branches/indy/src/org/python/antlr/op/EqDerived.java branches/indy/src/org/python/antlr/op/FloorDivDerived.java branches/indy/src/org/python/antlr/op/GtDerived.java branches/indy/src/org/python/antlr/op/GtEDerived.java branches/indy/src/org/python/antlr/op/InDerived.java branches/indy/src/org/python/antlr/op/InvertDerived.java branches/indy/src/org/python/antlr/op/IsDerived.java branches/indy/src/org/python/antlr/op/IsNotDerived.java branches/indy/src/org/python/antlr/op/LShiftDerived.java branches/indy/src/org/python/antlr/op/LoadDerived.java branches/indy/src/org/python/antlr/op/LtDerived.java branches/indy/src/org/python/antlr/op/LtEDerived.java branches/indy/src/org/python/antlr/op/ModDerived.java branches/indy/src/org/python/antlr/op/MultDerived.java branches/indy/src/org/python/antlr/op/NotDerived.java branches/indy/src/org/python/antlr/op/NotEqDerived.java branches/indy/src/org/python/antlr/op/NotInDerived.java branches/indy/src/org/python/antlr/op/OrDerived.java branches/indy/src/org/python/antlr/op/ParamDerived.java branches/indy/src/org/python/antlr/op/PowDerived.java branches/indy/src/org/python/antlr/op/RShiftDerived.java branches/indy/src/org/python/antlr/op/StoreDerived.java branches/indy/src/org/python/antlr/op/SubDerived.java branches/indy/src/org/python/antlr/op/UAddDerived.java branches/indy/src/org/python/antlr/op/USubDerived.java branches/indy/src/org/python/compiler/CodeCompiler.java branches/indy/src/org/python/core/ClasspathPyImporterDerived.java branches/indy/src/org/python/core/PyArray.java branches/indy/src/org/python/core/PyArrayDerived.java branches/indy/src/org/python/core/PyBaseExceptionDerived.java branches/indy/src/org/python/core/PyBooleanDerived.java branches/indy/src/org/python/core/PyClassMethodDerived.java branches/indy/src/org/python/core/PyComplexDerived.java branches/indy/src/org/python/core/PyDictionaryDerived.java branches/indy/src/org/python/core/PyEnumerateDerived.java branches/indy/src/org/python/core/PyFileDerived.java branches/indy/src/org/python/core/PyFloatDerived.java branches/indy/src/org/python/core/PyFrozenSetDerived.java branches/indy/src/org/python/core/PyIntegerDerived.java branches/indy/src/org/python/core/PyList.java branches/indy/src/org/python/core/PyListDerived.java branches/indy/src/org/python/core/PyLongDerived.java branches/indy/src/org/python/core/PyModuleDerived.java branches/indy/src/org/python/core/PyObjectDerived.java branches/indy/src/org/python/core/PyPropertyDerived.java branches/indy/src/org/python/core/PySetDerived.java branches/indy/src/org/python/core/PySliceDerived.java branches/indy/src/org/python/core/PyStringDerived.java branches/indy/src/org/python/core/PySuperDerived.java branches/indy/src/org/python/core/PyTuple.java branches/indy/src/org/python/core/PyTupleDerived.java branches/indy/src/org/python/core/PyTypeDerived.java branches/indy/src/org/python/core/PyUnicodeDerived.java branches/indy/src/org/python/core/codecs.java branches/indy/src/org/python/core/imp.java branches/indy/src/org/python/core/io/FileIO.java branches/indy/src/org/python/modules/_collections/PyDefaultDictDerived.java branches/indy/src/org/python/modules/_collections/PyDequeDerived.java branches/indy/src/org/python/modules/_csv/PyDialectDerived.java branches/indy/src/org/python/modules/_functools/PyPartialDerived.java branches/indy/src/org/python/modules/_hashlib.java branches/indy/src/org/python/modules/_threading/_threading.java branches/indy/src/org/python/modules/_weakref/ReferenceTypeDerived.java branches/indy/src/org/python/modules/random/PyRandomDerived.java branches/indy/src/org/python/modules/thread/PyLocalDerived.java branches/indy/src/org/python/modules/thread/thread.java branches/indy/src/org/python/modules/zipimport/zipimporterDerived.java branches/indy/src/templates/object.derived Added Paths: ----------- branches/indy/Lib/test/print_sans_lib.py branches/indy/Lib/test/test_codecs_jy.py branches/indy/Lib/test/test_file_jy.py branches/indy/Lib/test/test_zlib_jy.py branches/indy/tests/java/org/python/core/PyListTest.java branches/indy/tests/java/org/python/core/PyTupleTest.java Property Changed: ---------------- branches/indy/ branches/indy/extlibs/xercesImpl-2.9.1.jar branches/indy/tests/java/org/python/tests/RedundantInterfaceDeclarations.java Property changes on: branches/indy ___________________________________________________________________ Modified: svnmerge-integrated - /trunk/jython:1-6751 + /trunk/jython:1-6814 Modified: svn:mergeinfo - /branches/jsr223:6285-6565 /branches/newstyle-java-types:5564-5663,5666-5729 /trunk/jython:6662-6741 + /branches/jsr223:6285-6565 /branches/newstyle-java-types:5564-5663,5666-5729 /trunk/jython:6662-6741,6762-6814 Modified: branches/indy/CPythonLib.includes =================================================================== --- branches/indy/CPythonLib.includes 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/CPythonLib.includes 2009-10-01 01:16:13 UTC (rev 6817) @@ -55,17 +55,14 @@ dummy_thread.py dummy_threading.py exceptions.py -fileinput.py fnmatch.py formatter.py fpformat.py ftplib.py functools.py getopt.py -gettext.py glob.py gopherlib.py -gzip.py hashlib.py heapq.py hmac.py @@ -76,13 +73,11 @@ ihooks.py imaplib.py imghdr.py -inspect.py keyword.py linecache.py locale.py macpath.py macurl2path.py -mailbox.py mailcap.py markupbase.py md5.py @@ -94,9 +89,7 @@ modulefinder.py multifile.py mutex.py -netrc.py nntplib.py -ntpath.py nturl2path.py opcode.py optparse.py @@ -104,15 +97,12 @@ pickle.py pickletools.py pipes.py -pkgutil.py -platform.py poplib.py posixfile.py pprint.py profile.py pstats.py pyclbr.py -pydoc.py Queue.py quopri.py random.py @@ -130,9 +120,7 @@ shelve.py shlex.py shutil.py -SimpleHTTPServer.py SimpleXMLRPCServer.py -site.py site-packages/README smtpd.py smtplib.py @@ -145,26 +133,20 @@ symbol.py tabnanny.py this.py -threading.py textwrap.py -timeit.py token.py tokenize.py trace.py traceback.py tzparse.py unittest.py -urllib.py urllib2.py urlparse.py user.py UserDict.py UserList.py UserString.py -uu.py uuid.py -warnings.py -weakref.py whichdb.py whrandom.py wsgiref.egg-info @@ -172,4 +154,3 @@ xdrlib.py xmllib.py xmlrpclib.py -zipfile.py Modified: branches/indy/Lib/distutils/util.py =================================================================== --- branches/indy/Lib/distutils/util.py 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/Lib/distutils/util.py 2009-10-01 01:16:13 UTC (rev 6817) @@ -155,25 +155,26 @@ Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS. """ - if os.name == 'posix' or os.name == 'java': + os_name = os._name if sys.platform.startswith('java') else os.name + if os_name == 'posix': if not os.path.isabs(pathname): return os.path.join(new_root, pathname) else: return os.path.join(new_root, pathname[1:]) - elif os.name == 'nt': + elif os_name == 'nt': (drive, path) = os.path.splitdrive(pathname) if path[0] == '\\': path = path[1:] return os.path.join(new_root, path) - elif os.name == 'os2': + elif os_name == 'os2': (drive, path) = os.path.splitdrive(pathname) if path[0] == os.sep: path = path[1:] return os.path.join(new_root, path) - elif os.name == 'mac': + elif os_name == 'mac': if not os.path.isabs(pathname): return os.path.join(new_root, pathname) else: @@ -184,7 +185,7 @@ else: raise DistutilsPlatformError, \ - "nothing known about platform '%s'" % os.name + "nothing known about platform '%s'" % os_name _environ_checked = 0 Modified: branches/indy/Lib/popen2.py =================================================================== --- branches/indy/Lib/popen2.py 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/Lib/popen2.py 2009-10-01 01:16:13 UTC (rev 6817) @@ -34,7 +34,8 @@ process.""" stderr = subprocess.PIPE if capturestderr else None PIPE = subprocess.PIPE - self._popen = subprocess.Popen(cmd, bufsize=bufsize, shell=True, + self._popen = subprocess.Popen(cmd, bufsize=bufsize, + shell=isinstance(cmd, basestring), stdin=PIPE, stdout=PIPE, stderr=stderr) self._setup(cmd) @@ -73,7 +74,8 @@ def __init__(self, cmd, bufsize=-1): PIPE = subprocess.PIPE - self._popen = subprocess.Popen(cmd, bufsize=bufsize, shell=True, + self._popen = subprocess.Popen(cmd, bufsize=bufsize, + shell=isinstance(cmd, basestring), stdin=PIPE, stdout=PIPE, stderr=subprocess.STDOUT) self._setup(cmd) Copied: branches/indy/Lib/test/print_sans_lib.py (from rev 6814, trunk/jython/Lib/test/print_sans_lib.py) =================================================================== --- branches/indy/Lib/test/print_sans_lib.py (rev 0) +++ branches/indy/Lib/test/print_sans_lib.py 2009-10-01 01:16:13 UTC (rev 6817) @@ -0,0 +1,4 @@ +import sys +sys.path = [path for path in sys.path if not path.startswith('/')] +encoded = u'hi'.encode("utf-8") +encoded.decode('utf-8') Modified: branches/indy/Lib/test/test_array_jy.py =================================================================== --- branches/indy/Lib/test/test_array_jy.py 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/Lib/test/test_array_jy.py 2009-10-01 01:16:13 UTC (rev 6817) @@ -1,6 +1,7 @@ # The jarray module is being phased out, with all functionality # now available in the array module. - +from __future__ import with_statement +import os import unittest from test import test_support from array import array, zeros @@ -11,7 +12,6 @@ class ArrayJyTestCase(unittest.TestCase): def test_jarray(self): # until it is fully formally removed - # While jarray is still being phased out, just flex the initializers. # The rest of the test for array will catch all the big problems. import jarray @@ -44,8 +44,34 @@ Color.RGBtoHSB(0, 255, 255, hsb1) self.assertEqual(hsb, hsb1, "hsb float arrays were not equal") + +class ToFromfileTestCase(unittest.TestCase): + + def tearDown(self): + if os.path.exists(test_support.TESTFN): + os.remove(test_support.TESTFN) + + def test_tofromfile(self): + # http://bugs.jython.org/issue1457 + x = array('i', range(5)) + with open(test_support.TESTFN, 'wb') as f: + x.tofile(f) + + x = array('i', []) + with open(test_support.TESTFN, 'r+b') as f: + x.fromfile(f, 5) + x *= 2 + x.tofile(f) + + with open(test_support.TESTFN, 'rb') as f: + x.fromfile(f, 10) + self.assertEqual(x, array('i', range(5) * 4)) + + def test_main(): - test_support.run_unittest(ArrayJyTestCase) + test_support.run_unittest(ArrayJyTestCase, + ToFromfileTestCase) + if __name__ == "__main__": test_main() Modified: branches/indy/Lib/test/test_cmp_jy.py =================================================================== --- branches/indy/Lib/test/test_cmp_jy.py 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/Lib/test/test_cmp_jy.py 2009-10-01 01:16:13 UTC (rev 6817) @@ -1,7 +1,18 @@ "Tests for cmp() compatibility with CPython" +import UserDict import unittest from test import test_support +class CmpGeneralTestCase(unittest.TestCase): + + def test_type_crash(self): + # Used to throw ArrayStoreException: + # http://bugs.jython.org/issue1382 + class Configuration(object, UserDict.DictMixin): + pass + self.assertNotEqual(Configuration(), None) + + class UnicodeDerivedCmp(unittest.TestCase): "Test for http://bugs.jython.org/issue1889394" def testCompareWithString(self): @@ -14,6 +25,7 @@ class B(unicode): pass self.assertEqual(A(), B()) + class LongDerivedCmp(unittest.TestCase): def testCompareWithString(self): class Test(long): @@ -21,6 +33,7 @@ self.assertNotEqual(Test(0), 'foo') self.assertTrue('foo' in [Test(12), 'foo']) + class IntStrCmp(unittest.TestCase): def testIntStrCompares(self): assert not (-1 > 'a') @@ -31,6 +44,7 @@ assert (-2 < 'a') assert not (-1 == 'a') + class CustomCmp(unittest.TestCase): def test___cmp___returns(self): class Foo(object): @@ -63,13 +77,16 @@ __eq__ = lambda self, other: True self.assertEqual(cmp(Foo(), Bar()), 1) + def test_main(): test_support.run_unittest( + CmpGeneralTestCase, UnicodeDerivedCmp, LongDerivedCmp, IntStrCmp, CustomCmp ) + if __name__ == '__main__': test_main() Copied: branches/indy/Lib/test/test_codecs_jy.py (from rev 6814, trunk/jython/Lib/test/test_codecs_jy.py) =================================================================== --- branches/indy/Lib/test/test_codecs_jy.py (rev 0) +++ branches/indy/Lib/test/test_codecs_jy.py 2009-10-01 01:16:13 UTC (rev 6817) @@ -0,0 +1,19 @@ +import subprocess +import sys +import test_support +import unittest + +class AccessBuiltinCodecs(unittest.TestCase): + def test_print_sans_lib(self): + '''Encodes and decodes using utf-8 after in an environment without the standard library + + Checks that the builtin utf-8 codec is always available: http://bugs.jython.org/issue1458''' + subprocess.call([sys.executable, "-J-Dpython.cachedir.skip=true", + "-J-Dpython.security.respectJavaAccessibility=false", + test_support.findfile('print_sans_lib.py')]) + +def test_main(): + test_support.run_unittest(AccessBuiltinCodecs) + +if __name__ == "__main__": + test_main() Copied: branches/indy/Lib/test/test_file_jy.py (from rev 6814, trunk/jython/Lib/test/test_file_jy.py) =================================================================== --- branches/indy/Lib/test/test_file_jy.py (rev 0) +++ branches/indy/Lib/test/test_file_jy.py 2009-10-01 01:16:13 UTC (rev 6817) @@ -0,0 +1,39 @@ +"""Misc file tests. + +Made for Jython. +""" +from __future__ import with_statement +import os +import unittest +from test import test_support + +class FileTestCase(unittest.TestCase): + + def tearDown(self): + if os.path.exists(test_support.TESTFN): + os.remove(test_support.TESTFN) + + def test_append(self): + self._test_append('ab') + + def test_appendplus(self): + self._test_append('a+') + + def _test_append(self, mode): + # http://bugs.jython.org/issue1466 + fp1 = open(test_support.TESTFN, mode) + fp1.write('test1\n') + fp2 = open(test_support.TESTFN, mode) + fp2.write('test2\n') + fp1.close() + fp2.close() + with open(test_support.TESTFN) as fp: + self.assertEqual('test1\ntest2\n', fp.read()) + + +def test_main(): + test_support.run_unittest(FileTestCase) + + +if __name__ == '__main__': + test_main() Modified: branches/indy/Lib/test/test_hashlib_jy.py =================================================================== --- branches/indy/Lib/test/test_hashlib_jy.py 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/Lib/test/test_hashlib_jy.py 2009-10-01 01:16:13 UTC (rev 6817) @@ -5,6 +5,7 @@ """ import hashlib import unittest +from array import array from test import test_support class HashlibTestCase(unittest.TestCase): @@ -14,7 +15,14 @@ 'acbd18db4cc2f85cedef654fccc4a4d8') self.assertRaises(UnicodeEncodeError, hashlib.md5, u'Gráin amháiñ') + def test_array(self): + self.assertEqual(hashlib.sha1(array('c', 'hovercraft')).hexdigest(), + '496df4d8de2c71973d7e917c4fbe57e6ad46d738') + intarray = array('i', range(5)) + self.assertEqual(hashlib.sha1(intarray).hexdigest(), + hashlib.sha1(intarray.tostring()).hexdigest()) + def test_main(): test_support.run_unittest(HashlibTestCase) Modified: branches/indy/Lib/test/test_seq_jy.py =================================================================== --- branches/indy/Lib/test/test_seq_jy.py 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/Lib/test/test_seq_jy.py 2009-10-01 01:16:13 UTC (rev 6817) @@ -27,6 +27,14 @@ self.assertTrue(foo in seq1) self.assertFalse(eq_called) + def test_seq_equality(self): + class Foo(object): + def __eq__(self, other): + return True + foo = [Foo()] + for type2test in self.types2test: + self.assertTrue(type2test() in foo) + def test_seq_subclass_equality(self): # Various combinations of PyObject._eq, overriden Object.equals, # and cmp implementations Modified: branches/indy/Lib/test/test_threading_jy.py =================================================================== --- branches/indy/Lib/test/test_threading_jy.py 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/Lib/test/test_threading_jy.py 2009-10-01 01:16:13 UTC (rev 6817) @@ -36,8 +36,14 @@ time.sleep(random.random()) +class TwistedTestCase(unittest.TestCase): + + def test_needs_underscored_versions(self): + self.assertEqual(threading.Lock, threading._Lock) + self.assertEqual(threading.RLock, threading._RLock) + def test_main(): - test_support.run_unittest(ThreadingTestCase) + test_support.run_unittest(ThreadingTestCase, TwistedTestCase) if __name__ == "__main__": Copied: branches/indy/Lib/test/test_zlib_jy.py (from rev 6814, trunk/jython/Lib/test/test_zlib_jy.py) =================================================================== --- branches/indy/Lib/test/test_zlib_jy.py (rev 0) +++ branches/indy/Lib/test/test_zlib_jy.py 2009-10-01 01:16:13 UTC (rev 6817) @@ -0,0 +1,37 @@ +"""Misc zlib tests + +Made for Jython. +""" +import unittest +import zlib +from array import array +from test import test_support + +class ArrayTestCase(unittest.TestCase): + + def test_array(self): + self._test_array(zlib.compress, zlib.decompress) + + def test_array_compressobj(self): + def compress(value): + co = zlib.compressobj() + return co.compress(value) + co.flush() + def decompress(value): + dco = zlib.decompressobj() + return dco.decompress(value) + dco.flush() + self._test_array(compress, decompress) + + def _test_array(self, compress, decompress): + self.assertEqual(compress(array('c', 'jython')), compress('jython')) + intarray = array('i', range(5)) + self.assertEqual(compress(intarray), compress(intarray.tostring())) + compressed = array('c', compress('jython')) + self.assertEqual('jython', decompress(compressed)) + + +def test_main(): + test_support.run_unittest(ArrayTestCase) + + +if __name__ == '__main__': + test_main() Modified: branches/indy/Lib/threading.py =================================================================== --- branches/indy/Lib/threading.py 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/Lib/threading.py 2009-10-01 01:16:13 UTC (rev 6817) @@ -5,7 +5,7 @@ from org.python.util import jython from thread import _newFunctionThread from thread import _local as local -from _threading import Lock, RLock, Condition +from _threading import Lock, RLock, Condition, _Lock, _RLock import java.lang.Thread import weakref Modified: branches/indy/Lib/zlib.py =================================================================== --- branches/indy/Lib/zlib.py 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/Lib/zlib.py 2009-10-01 01:16:13 UTC (rev 6817) @@ -13,7 +13,9 @@ Compressor objects support compress() and flush() methods; decompressor objects support decompress() and flush(). """ -import jarray, binascii +import array +import binascii +import jarray from java.util.zip import Adler32, Deflater, Inflater, DataFormatException from java.lang import Long, String @@ -59,13 +61,14 @@ if level < Z_BEST_SPEED or level > Z_BEST_COMPRESSION: raise error, "Bad compression level" deflater = Deflater(level, 0) + string = _to_input(string) deflater.setInput(string, 0, len(string)) deflater.finish() return _get_deflate_data(deflater) def decompress(string, wbits=0, bufsize=16384): inflater = Inflater(wbits < 0) - inflater.setInput(string) + inflater.setInput(_to_input(string)) return _get_inflate_data(inflater) @@ -84,6 +87,7 @@ def compress(self, string): if self._ended: raise error("compressobj may not be used after flush(Z_FINISH)") + string = _to_input(string) self.deflater.setInput(string, 0, len(string)) return _get_deflate_data(self.deflater) @@ -123,6 +127,7 @@ if max_length < 0: raise ValueError("max_length must be a positive integer") + string = _to_input(string) self.inflater.setInput(string) inflated = _get_inflate_data(self.inflater, max_length) @@ -146,6 +151,8 @@ self.inflater.end() return last +def _to_input(string): + return string.tostring() if isinstance(string, array.array) else string def _get_deflate_data(deflater): buf = jarray.zeros(1024, 'b') Modified: branches/indy/NEWS =================================================================== --- branches/indy/NEWS 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/NEWS 2009-10-01 01:16:13 UTC (rev 6817) @@ -1,5 +1,22 @@ Jython NEWS +Jython 2.5.1rc3 + Bugs Fixed + - [ 1466 ] wrong handling of append only files + +Jython 2.5.1rc2 + New Features + - zxJDBC supports the with-statement: connections are committed or rollbacked; cursors are closed + Bugs Fixed + - [ 1079 ] fixed regression on issue: twisted.python.threadable module: missing attribute '_RLock' + - [ 1461 ] assert statement should lookup AssertionError using getglobal + - [ 1425 ] distutils/util.py assumes too much posix + - [ 1457 ] Cannot write an array in a file opened in r+b mode. + - [ 1382 ] __cmp__ on certain types raises ArrayStoreException + - [ 1443 ] Can't update() hashlib.sha1() with array.array('c') + - [ 1444 ] Can't zlib.compress() with array.array('c') + - [ 1458 ] Builtin codecs aren't available without standard lib + Jython 2.5.1rc1 New Features - Upgraded to ANTLR 3.1.3 Modified: branches/indy/README.txt =================================================================== --- branches/indy/README.txt 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/README.txt 2009-10-01 01:16:13 UTC (rev 6817) @@ -1,10 +1,10 @@ -Welcome to Jython 2.5.1rc1 -========================== +Welcome to Jython 2.5.1 Final +============================= -This is the first release candidate of the 2.5.1 version of Jython. This -release fixes a number of bugs, including some major errors when using -coroutines and when using relative imports. Please see the NEWS file for -detailed release notes. +This is the final release of the 2.5.1 version of Jython. This release fixes a +number of bugs, including some major errors when using coroutines and when +using relative imports, as well as a potential data loss bug when writing to +files in append mode. Please see the NEWS file for detailed release notes. The release was compiled on Mac OS X with JDK 5 and requires JDK 5 to run. Modified: branches/indy/build.xml =================================================================== --- branches/indy/build.xml 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/build.xml 2009-10-01 01:16:13 UTC (rev 6817) @@ -129,8 +129,8 @@ <property name="jython.major_version" value="2"/> <property name="jython.minor_version" value="5"/> <property name="jython.micro_version" value="1"/> - <property name="jython.release_level" value="${PY_RELEASE_LEVEL_GAMMA}"/> - <property name="jython.release_serial" value="1"/> + <property name="jython.release_level" value="${PY_RELEASE_LEVEL_FINAL}"/> + <property name="jython.release_serial" value="0"/> <condition property="do.snapshot.build"> <isset property="snapshot.revision" /> @@ -679,7 +679,7 @@ source="${jdk.source.version}" public="true" breakiterator="yes" - packagenames="org.python.core, org.python.util, com.ziclix.python.sql" + packagenames="org.python.core.*, org.python.util.*, org.python.modules.*, com.ziclix.python.sql, com.xhaus.modjy" windowtitle="Jython API documentation" bottom="<a href='http://www.jython.org' target='_top'>Jython homepage</a>" > Property changes on: branches/indy/extlibs/xercesImpl-2.9.1.jar ___________________________________________________________________ Modified: svn:mergeinfo - /branches/newstyle-java-types/extlibs/xercesImpl.jar:5564-5663,5666-5729 /trunk/jython/extlibs/xercesImpl-2.9.1.jar:6662-6741 + /branches/newstyle-java-types/extlibs/xercesImpl.jar:5564-5663,5666-5729 /trunk/jython/extlibs/xercesImpl-2.9.1.jar:6662-6741,6762-6814 Modified: branches/indy/src/com/ziclix/python/sql/PyConnection.java =================================================================== --- branches/indy/src/com/ziclix/python/sql/PyConnection.java 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/src/com/ziclix/python/sql/PyConnection.java 2009-10-01 01:16:13 UTC (rev 6817) @@ -17,6 +17,7 @@ import org.python.core.ClassDictInit; import org.python.core.Py; import org.python.core.PyBuiltinMethodSet; +import org.python.core.PyException; import org.python.core.PyInteger; import org.python.core.PyList; import org.python.core.PyObject; @@ -24,7 +25,10 @@ import org.python.core.PyUnicode; import com.ziclix.python.sql.util.PyArgParser; +import org.python.core.ContextManager; +import org.python.core.ThreadState; + /** * A connection to the database. * @@ -32,7 +36,7 @@ * @author last revised by $Author$ * @version $Revision$ */ -public class PyConnection extends PyObject implements ClassDictInit { +public class PyConnection extends PyObject implements ClassDictInit, ContextManager { /** True if closed. */ protected boolean closed; @@ -40,6 +44,9 @@ /** Whether transactions are supported. */ protected boolean supportsTransactions; + /** Whether multiple ResultSets are supported. */ + protected boolean supportsMultipleResultSets; + /** The underlying java.sql.Connection. */ protected Connection connection; @@ -90,6 +97,8 @@ this.connection = connection; this.statements = new HashSet<PyStatement>(); this.supportsTransactions = this.connection.getMetaData().supportsTransactions(); + this.supportsMultipleResultSets = + this.connection.getMetaData().supportsMultipleResultSets(); if (this.supportsTransactions) { this.connection.setAutoCommit(false); @@ -132,6 +141,8 @@ zxJDBC.getString("rollback"))); dict.__setitem__("nativesql", new ConnectionFunc("nativesql", 4, 1, 1, zxJDBC.getString("nativesql"))); + dict.__setitem__("__enter__", new ConnectionFunc("__enter__", 5, 0, 0, "__enter__")); + dict.__setitem__("__exit__", new ConnectionFunc("__exit__", 6, 3, 3, "__exit__")); // hide from python dict.__setitem__("initModule", null); @@ -416,6 +427,33 @@ } return this.statements.contains(statement); } + + public PyObject __enter__(ThreadState ts) { + return this; + } + + public PyObject __enter__() { + return this; + } + + public boolean __exit__(ThreadState ts, PyException exception) { + if (exception == null) { + commit(); + } else { + rollback(); + } + return false; + } + + public boolean __exit__(PyObject type, PyObject value, PyObject traceback) { + if (type == null || type == Py.None) { + commit(); + } else { + rollback(); + } + return false; + } + } class ConnectionFunc extends PyBuiltinMethodSet { @@ -439,6 +477,8 @@ case 3: c.rollback(); return Py.None; + case 5: + return c.__enter__(); default: throw info.unexpectedCall(0, false); } @@ -463,6 +503,8 @@ switch (index) { case 2: return c.cursor(arg1.__nonzero__(), arg2, arg3); + case 6: + return Py.newBoolean(c.__exit__(arg1, arg2, arg3)); default: throw info.unexpectedCall(3, false); } Modified: branches/indy/src/com/ziclix/python/sql/PyCursor.java =================================================================== --- branches/indy/src/com/ziclix/python/sql/PyCursor.java 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/src/com/ziclix/python/sql/PyCursor.java 2009-10-01 01:16:13 UTC (rev 6817) @@ -26,7 +26,10 @@ import org.python.core.PyUnicode; import com.ziclix.python.sql.util.PyArgParser; +import org.python.core.ContextManager; +import org.python.core.ThreadState; + /** * These objects represent a database cursor, which is used to manage the * context of a fetch operation. @@ -35,7 +38,7 @@ * @author last revised by $Author$ * @version $Revision$ */ -public class PyCursor extends PyObject implements ClassDictInit, WarningListener { +public class PyCursor extends PyObject implements ClassDictInit, WarningListener, ContextManager { /** Field fetch */ protected Fetch fetch; @@ -260,6 +263,8 @@ dict.__setitem__("scroll", new CursorFunc("scroll", 10, 1, 2, "scroll the cursor in the result set to a new position according to mode")); dict.__setitem__("write", new CursorFunc("write", 11, 1, "execute the sql written to this file-like object")); dict.__setitem__("prepare", new CursorFunc("prepare", 12, 1, "prepare the sql statement for later execution")); + dict.__setitem__("__enter__", new CursorFunc("__enter__", 13, 0, 0, "__enter__")); + dict.__setitem__("__exit__", new CursorFunc("__exit__", 14, 3, 3, "__exit__")); // hide from python dict.__setitem__("classDictInit", null); @@ -482,15 +487,11 @@ throw zxJDBC.makeException(zxJDBC.NotSupportedError, zxJDBC.getString("noStoredProc")); } - } catch (PyException e) { - throw e; - } catch (Throwable e) { - throw zxJDBC.makeException(e); - } finally { - if (this.statement != null) { - // close what we opened - this.statement.close(); + } catch (Throwable t) { + if (statement != null) { + statement.close(); } + throw zxJDBC.makeException(t); } } @@ -584,17 +585,12 @@ this.execute(Py.None, Py.None); } } - } catch (PyException e) { - throw e; - } catch (Throwable e) { - throw zxJDBC.makeException(zxJDBC.Error, e, rowIndex); - } finally { - if (this.statement != null) { + } catch (Throwable t) { + if (statement != null && !(sql instanceof PyStatement)) { // only close static, single-use statements - if (!(sql instanceof PyStatement) && !this.dynamicFetch) { - this.statement.close(); - } + statement.close(); } + throw zxJDBC.makeException(zxJDBC.Error, t, rowIndex); } } @@ -605,18 +601,12 @@ protected void execute(PyObject params, PyObject bindings) { try { Statement stmt = this.statement.statement; - this.datahandler.preExecute(stmt); // this performs the SQL execution and fetch per the Statement type this.statement.execute(this, params, bindings); - this.lastrowid = this.datahandler.getRowId(stmt); - - int uc = stmt.getUpdateCount(); - - this.updatecount = uc < 0 ? Py.None : Py.newInteger(uc); - + this.updateAttributes(stmt.getUpdateCount()); warning(new WarningEvent(this, stmt.getWarnings())); this.datahandler.postExecute(stmt); } catch (PyException e) { @@ -627,6 +617,17 @@ } /** + * Update the cursor's lastrowid and updatecount. + * + * @param updateCount The int value of updatecount + * @throws SQLException + */ + private void updateAttributes(int updateCount) throws SQLException { + lastrowid = datahandler.getRowId(statement.statement); + updatecount = updateCount < 0 ? Py.None : Py.newInteger(updateCount); + } + + /** * Fetch the next row of a query result set, returning a single sequence, * or None when no more data is available. * @@ -691,7 +692,28 @@ */ public PyObject nextset() { ensureOpen(); - return this.fetch.nextset(); + PyObject nextset = fetch.nextset(); + + // If the fetch is exhausted and multiple ResultSets are supported, try addding a + // next ResultSet. XXX: DynamicFetch currently isn't so tailored for this + if (!nextset.__nonzero__() && connection.supportsMultipleResultSets && !dynamicFetch) { + Statement stmt = statement.statement; + try { + boolean hasMoreResults; + int updateCount = -1; + if ((hasMoreResults = stmt.getMoreResults()) + || (updateCount = stmt.getUpdateCount()) != -1) { + // Only call getUpdateCount once, per its docs + updateAttributes(!hasMoreResults ? updateCount : stmt.getUpdateCount()); + fetch.add(stmt.getResultSet()); + nextset = Py.One; + } + } catch (SQLException sqle) { + throw zxJDBC.makeException(sqle); + } + } + + return nextset; } /** @@ -784,12 +806,9 @@ } if (this.statement != null) { - // we can't close a dynamic fetch statement until everything has been - // consumed so the only time we can clean up is now - // but if this is a previously prepared statement we don't want to close - // it underneath someone; we can check this by looking in the set + // Finally done with the Statement: only close it if we created it try { - if (this.dynamicFetch && !this.connection.contains(this.statement)) { + if (!this.connection.contains(this.statement)) { this.statement.close(); } } finally { @@ -870,6 +889,24 @@ throw zxJDBC.makeException(zxJDBC.ProgrammingError, "cursor is closed"); } } + + public PyObject __enter__(ThreadState ts) { + return this; + } + + public PyObject __enter__() { + return this; + } + + public boolean __exit__(ThreadState ts, PyException exception) { + close(); + return false; + } + + public boolean __exit__(PyObject type, PyObject value, PyObject traceback) { + close(); + return false; + } } class CursorFunc extends PyBuiltinMethodSet { @@ -897,6 +934,8 @@ return cursor.fetchone(); case 4 : return cursor.nextset(); + case 13 : + return cursor.__enter__(); default : throw info.unexpectedCall(0, false); } @@ -969,6 +1008,8 @@ case 9 : cursor.executemany(arga, argb, argc, Py.None); return Py.None; + case 14 : + return Py.newBoolean(cursor.__exit__(arga, argc, argc)); default : throw info.unexpectedCall(3, false); } Modified: branches/indy/src/org/python/antlr/PythonTree.java =================================================================== --- branches/indy/src/org/python/antlr/PythonTree.java 2009-10-01 01:13:04 UTC (rev 6816) +++ branches/indy/src/org/python/antlr/PythonTree.java 2009-10-01 01:16:13 UTC (rev 6817) @@ -16,22 +16,10 @@ private int charStartIndex = -1; private int charStopIndex = -1; private CommonTree node; + + /** Who is the parent node of this node; if null, implies node is root */ private PythonTree parent; - /** A single token is the payload */ - //private Token token; - - /** What token indexes bracket all tokens associated with this node - * and below? - */ - //protected int startIndex=-1, stopIndex=-1; - - /** Who is the parent node of this node; if null, implies node is root */ - //private PythonTree parent; - - /** What index is this node in the child list? Range: 0..n-1 */ - //private int childIndex = -1; - public PythonTree() { node = new CommonTree(); } @@ -60,73 +48,73 @@ charStartIndex = tree.getCharStartIndex(); charStopIndex = tree.getCharStopIndex(); } - + public CommonTree getNode() { return node; } - public Token getToken() { - return node.getToken(); - } + public Token getToken() { + return node.getToken(); + } - public PythonTree dupNode() { - return new PythonTree(this); - } + public PythonTree dupNode() { + return new PythonTree(this); + } - public boolean isNil() { - return node.isNil(); - } + public boolean isNil() { + return node.isNil(); + } - public int getAntlrType() { - return node.getType(); - } + public int getAntlrType() { + return node.getType(); + } - public String getText() { - return node.getText(); - } + public String getText() { + return node.getText(); + } - public int getLine() { - if (node.getToken()==null || node.getToken().getLine()==0) { - if ( getChildCount()>0 ) { - return getChild(0).getLine(); - } - return 1; - } - return node.getToken().getLine(); - } + public int getLine() { + if (node.getToken()==null || node.getToken().getLine()==0) { + if ( getChildCount()>0 ) { + return getChild(0).getLine(); + } + return 1; + } + return node.getToken().getLine(); + } - public int getCharPositionInLine() { + public int getCharPositionInLine() { Token token = node.getToken(); - if (token==null || token.getCharPositionInLine()==-1) { - if (getChildCount()>0) { - return getChild(0).getCharPositionInLine(); - } - return 0; - } else if (token != null && token.getCharPositionInLine() == -2) { + if (token==null || token.getCharPositionInLine()==-1) { + if (getChildCount()>0) { + return getChild(0).getCharPositionInLine(); + } + return 0; + } else if (token != null && token.getCharPositionInLine() == -2) { //XXX: yucky fix because CPython's ast uses -1 as a real value // for char pos in certain circumstances (for example, the // char pos of multi-line strings. I would just use -1, // but ANTLR is using -1 in special ways also. return -1; } - return token.getCharPositionInLine(); - } + return token.getCharPositionInLine(); + } - public int getTokenStartIndex() { + public int getTokenStartIndex() { return node.getTokenStartIndex(); - } + } - public void setTokenStartIndex(int index) { - node.setTokenStartIndex(index); - } + public void setTokenStartIndex(int index) { + node.setTokenStartIndex(index); + } - public int getTokenStopIndex() { + public int getTokenStopIndex() { return node.getTokenStopIndex(); - } + } - public void setTokenStopIndex(int index) { - node.setTokenStopIndex(index); - } + public void setTokenStopIndex(int index) { + node.setTokenStopIndex(index); + } public int getCharStartIndex() { if (charStartIndex == -1 && node.getToken() != null) { @@ -160,33 +148,33 @@ charStopIndex = index; } - public int getChildIndex() { - return node.getChildIndex(); - } + public int getChildIndex() { + return node.getChildIndex(); + } - public PythonTree getParent() { - return parent; - } + public PythonTree getParent() { + return parent; + } - public void setParent(PythonTree t) { - this.parent = t; - } + public void setParent(PythonTree t) { + this.parent = t; + } - public void setChildIndex(int index) { - node.setChildIndex(index); - } + public void setChildIndex(int index) { + node.setChildIndex(index); + } @Override public String toString() { if (isNil()) { return "None"; } - if ( getAntlrType()==Token.INVALID_TOKEN_TYPE ) { - return "<errornode>"; - } - if ( node.getToken()==null ) { - return null; - } + if ( getAntlrType()==Token.INVALID_TOKEN_TYPE ) { + return "<errornode>"; + } + if ( node.getToken()==null ) { + return null; + } return node.getToken().getText() + "(" + this.getLine() + "," + this.getCharPositionInLine() + ")"; } @@ -251,203 +239,194 @@ } //XXX: From here down copied from org.antlr.runtime.tree.BaseTree - protected List<PythonTree> children; + protected List<PythonTree> children; - public PythonTree getChild(int i) { - if ( children==null || i>=children.size() ) { - return null; - } - return children.get(i); - } + public PythonTree getChild(int i) { + if ( children==null || i>=children.size() ) { + return null; + } + return children.get(i); + } - /** Get the children internal List; note that if you directly mess with - * the list, do so at your own risk. - */ - public List<PythonTree> getChildren() { - return children; - } + /** Get the children internal List; note that if you directly mess with + * the list, do so at your own risk. + */ + public List<PythonTree> getChildren() { + return children; + } - public PythonTree getFirstChildWithType(int type) { - for (int i = 0; children!=null && i < children.size(); i++) { - PythonTree t = children.get(i); - if ( t.getAntlrType()==type ) { - return t; - } - } - return null; - } + public PythonTree getFirstChildWithType(int type) { + for (int i = 0; children!=null && i < children.size(); i++) { + PythonTree t = children.get(i); + if ( t.getAntlrType()==type ) { + return t; + } + } + return null; + } - public int getChildCount() { - if ( children==null ) { - return 0; - } - return children.size(); - } + public int getChildCount() { + if ( children==null ) { + return 0; + } + return children.size(); + } - /** Add t as child of this node. - * - * Warning: if t has no children, but child does - * and child isNil then this routine moves children to t via - * t.children = child.children; i.e., without copying the array. - */ - public void addChild(PythonTree t) { - //System.out.println("add child "+t.toStringTree()+" "+this.toStringTree()); - //System.out.println("existing children: "+children); - if ( t==null ) { - return; // do nothing upon addChild(null) - } - PythonTree childTree = t; - if ( childTree.isNil() ) { // t is an empty node possibly with children - if ( this.children!=null && this.children == childTree.children ) { - throw new RuntimeException("attempt to add child list to itself"); - } - // just add all of childTree's children to this - if ( childTree.children!=null ) { - if ( this.children!=null ) { // must copy, this has children already - int n = childTree.children.size(); - for (int i = 0; i < n; i++) { - PythonTree c = childTree.children.get(i); - this.children.add(c); - // handle double-link stuff for each child of nil root - c.setParent(this); - c.setChildIndex(children.size()-1); - } - } - else { - // no children for this but t has children; just set pointer - // call general freshener routine - this.children = childTree.children; - this.freshenParentAndChildIndexes(); - } - } - } - else { // child is not nil (don't care about children) - if ( children==null ) { - children = createChildrenList(); // create children list on demand - } - children.add(t); - childTree.setParent(this); - childTree.setChildIndex(children.size()-1); - } - // System.out.println("now children are: "+children); - } + /** Add t as child of this node. + * + * Warning: if t has no children, but child does + * and child isNil then this routine moves children to t via + * t.children = child.children; i.e., without copying the array. + */ + public void addChild(PythonTree t) { + if ( t==null ) { + return; // do nothing upon addChild(null) + } + PythonTree childTree = t; + if ( childTree.isNil() ) { // t is an empty node possibly with children + if ( this.children!=null && this.children == childTree.children ) { + throw new RuntimeException("attempt to add child list to itself"); + } + // just add all of childTree's children to this + if ( childTree.children!=null ) { + if ( this.children!=null ) { // must copy, this has children already + int n = childTree.children.size(); + for (int i = 0; i < n; i++) { + PythonTree c = childTree.children.get(i); + this.children.add(c); + // handle double-link stuff for each child of nil root + c.setParent(this); + c.setChildIndex(children.size()-1); + } + } + else { + // no children for this but t has children; just set pointer + // call general freshener routine + this.children = childTree.children; + this.freshenParentAndChildIndexes(); + } + } + } + else { // child is not nil (don't care about children) + if ( children==null ) { + children = createChildrenList(); // create children list on demand + } + children.add(t); + childTree.setParent(this); + childTree.setChildIndex(children.size()-1); + } + } - /** Add all elements of kids list as children of this node */ - public void addChildren(List<PythonTree> kids) { - for (int i = 0; i < kids.size(); i++) { - PythonTree t = kids.get(i); - addChild(t); - } - } + /** Add all elements of kids list as children of this node */ + public void addChildren(List<PythonTree> kids) { + for (int i = 0; i < kids.size(); i++) { + PythonTree t = kids.get(i); + addChild(t); + } + } - public void setChild(int i, PythonTree t) { - if ( t==null ) { - return; - } - if ( t.isNil() ) { - throw new IllegalArgumentException("Can't set single child to a list"); - } - if ( children==null ) { - children = createChildrenList(); - } - children.set(i, t); - t.setParent(this); - t.setChildIndex(i); - } - - public Object deleteChild(int i) { - if ( children==null ) { - return null; - } - PythonTree killed = children.remove(i); - // walk rest and decrement their child indexes - this.freshenParentAndChildIndexes(i); - return killed; - } + public void setChild(int i, PythonTree t) { + if ( t==null ) { + return; + } + if ( t.isNil() ) { + throw new IllegalArgumentException("Can't set single child to a list"); + } + if ( children==null ) { + children = createChildrenList(); + } + children.set(i, t); + t.setParent(this); + t.setChildIndex(i); + } + + public Object deleteChild(int i) { + if ( children==null ) { + return null; + } + PythonTree killed = children.remove(i); + // walk rest and decrement their child indexes + this.freshenParentAndChildIndexes(i); + return killed; + } - /** Delete children from start to stop and replace with t even if t is - * a list (nil-root tree). num of children can increase or decrease. - * For huge child lists, inserting children can force walking rest of - * children to set their childindex; could be slow. - */ - public void replaceChildren(int startChildIndex, int stopChildIndex, Object t) { - /* - System.out.println("replaceChildren "+startChildIndex+", "+stopChildIndex+ - " with "+((PythonTree)t).toStringTree()); - System.out.println("in="+toStringTree()); - */ - if ( children==null ) { - throw new IllegalArgumentException("indexes invalid; no children in list"); - } - int replacingHowMany = stopChildIndex - startChildIndex + 1; - int replacingWithHowMany; - PythonTree newTree = (PythonTree)t; - List<PythonTree> newChildren = null; - // normalize to a list of c... [truncated message content] |
From: <fwi...@us...> - 2009-10-21 01:58:16
|
Revision: 6887 http://jython.svn.sourceforge.net/jython/?rev=6887&view=rev Author: fwierzbicki Date: 2009-10-21 01:58:03 +0000 (Wed, 21 Oct 2009) Log Message: ----------- Merged revisions 6815-6816,6818-6824,6826-6886 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython ........ r6815 | pjenvey | 2009-09-30 21:06:20 -0400 (Wed, 30 Sep 2009) | 2 lines allow del of default_factory, small cleanup ........ r6816 | pjenvey | 2009-09-30 21:13:04 -0400 (Wed, 30 Sep 2009) | 3 lines correct the callable check fixes #1478 ........ r6818 | fwierzbicki | 2009-09-30 21:25:40 -0400 (Wed, 30 Sep 2009) | 2 lines svn:ignore *$py.class in these. ........ r6819 | fwierzbicki | 2009-10-01 16:11:08 -0400 (Thu, 01 Oct 2009) | 4 lines Remove useless little inner subclasses, which where there just to add a behavior to nextToken() in Python.g -- since we override nextToken() in Python.g anyway, I relocated the functionality there. ........ r6820 | fwierzbicki | 2009-10-01 16:48:58 -0400 (Thu, 01 Oct 2009) | 3 lines Added a comment for trailing whitespace handling in single mode. Tobias asked me what it did and it took way too long to answer :) ........ r6821 | pjenvey | 2009-10-01 20:59:40 -0400 (Thu, 01 Oct 2009) | 2 lines small cleanup ........ r6822 | pjenvey | 2009-10-01 21:46:27 -0400 (Thu, 01 Oct 2009) | 3 lines allow exec of PyByteCode objects and simplify pycimport so it's not creating frames directly ........ r6823 | pjenvey | 2009-10-01 23:45:27 -0400 (Thu, 01 Oct 2009) | 2 lines pass the cached type through constructors ........ r6824 | pjenvey | 2009-10-02 00:05:54 -0400 (Fri, 02 Oct 2009) | 5 lines o convert PyFrame to exposed annotations o specify its cached type during construction to avoid repeated PyType.fromClass calls o fix the f_lineno value while tracing PyByteCode ........ r6826 | fwierzbicki | 2009-10-02 16:29:01 -0400 (Fri, 02 Oct 2009) | 2 lines Initial import of the part of JRuby's CodegenUtils that we can use. ........ r6827 | fwierzbicki | 2009-10-02 20:09:30 -0400 (Fri, 02 Oct 2009) | 2 lines First nibble at using CodegenUtils. ........ r6828 | fwierzbicki | 2009-10-02 20:48:54 -0400 (Fri, 02 Oct 2009) | 4 lines Converted almost all "org/python/Foo" to p(Foo.class). There is one I'm not sure about as it looks like "[org/python/core/PyObject" which doesn't make sense to me -- I'd expect "[Lorg/python/core/PyObject;". ........ r6829 | pjenvey | 2009-10-03 16:34:59 -0400 (Sat, 03 Oct 2009) | 3 lines add the ability for the method exposer to optionally pass in the current ThreadState when a method signature requests it @ arg 0 ........ r6830 | fwierzbicki | 2009-10-03 21:16:45 -0400 (Sat, 03 Oct 2009) | 2 lines Converted invokespecial and getfield to CodegenUtils. ........ r6831 | fwierzbicki | 2009-10-03 22:42:47 -0400 (Sat, 03 Oct 2009) | 3 lines Fix all invokevirtual to use sig() -- fix some invokespecial lines that went over 100 chars as per coding conventions. ........ r6832 | fwierzbicki | 2009-10-04 10:10:58 -0400 (Sun, 04 Oct 2009) | 2 lines Use sig() for invokestatic calls. ........ r6833 | fwierzbicki | 2009-10-04 10:39:40 -0400 (Sun, 04 Oct 2009) | 2 lines Finish up CodeCompiler conversion to CodegenUtils. ........ r6834 | fwierzbicki | 2009-10-04 11:10:21 -0400 (Sun, 04 Oct 2009) | 2 lines Use sig for invokevirtual. ........ r6835 | fwierzbicki | 2009-10-04 13:03:17 -0400 (Sun, 04 Oct 2009) | 2 lines use sig for invokestatic. ........ r6836 | fwierzbicki | 2009-10-04 16:16:12 -0400 (Sun, 04 Oct 2009) | 2 lines Use sig for invokespecial and addMethod. ........ r6837 | pjenvey | 2009-10-04 17:25:41 -0400 (Sun, 04 Oct 2009) | 3 lines hack around PyReflectedFunction's assumption of how instancemethod calls into it so instancemethod's ThreadState pass through optimization can be enabled ........ r6838 | fwierzbicki | 2009-10-04 18:31:22 -0400 (Sun, 04 Oct 2009) | 2 lines switch to p() from raw path strings where possible, also some cleanup. ........ r6839 | pjenvey | 2009-10-04 19:25:51 -0400 (Sun, 04 Oct 2009) | 4 lines only abspath module __file__s. the only other type having __file__ here is javapackage and their jar paths are already canonicalized by packagecache. saves maybe 150ms off startup ........ r6840 | amak | 2009-10-06 08:27:51 -0400 (Tue, 06 Oct 2009) | 3 lines Adding proper interpreter shutdown on servlet.destroy() for modjy. Fixes: http://bugs.jython.org/issue1474 Thanks to Colin Evans for reporting the issue. ........ r6841 | amak | 2009-10-06 08:38:52 -0400 (Tue, 06 Oct 2009) | 1 line Tabs to spaces. ........ r6842 | amak | 2009-10-06 09:11:06 -0400 (Tue, 06 Oct 2009) | 1 line Tabs to spaces, DOS line-endings to unix. ........ r6843 | fwierzbicki | 2009-10-06 16:32:55 -0400 (Tue, 06 Oct 2009) | 8 lines Make constants more.... constant in the compiler package. Changed confusing method names of the form Py*() that return constants to *constant. For example PyInteger() -> integerConstant(). Also reduced public interface of compiler package, especially around compiler constants. ........ r6844 | pjenvey | 2009-10-06 22:48:36 -0400 (Tue, 06 Oct 2009) | 6 lines optimize attr lookup on Deriveds inheriting object.__getattribute__: don't bother going through the descriptor. Derived's __findattr_ex__ now lives in a Deriveds util class (like java.util.Arrays/Collections but trickier to pronounce) so it can toggle the package private fast path flag on PyType fixes #1102 ........ r6845 | pjenvey | 2009-10-06 22:50:46 -0400 (Tue, 06 Oct 2009) | 1 line regen per r6844 ........ r6846 | fwierzbicki | 2009-10-07 15:16:54 -0400 (Wed, 07 Oct 2009) | 5 lines Make PyCodeConstant an actual constant. Move construction details into PyCodeConstant constructor. Hide more implementation details by making public fields package private. ........ r6847 | fwierzbicki | 2009-10-07 22:33:20 -0400 (Wed, 07 Oct 2009) | 2 lines Coding standards / Cleanup. ........ r6848 | fwierzbicki | 2009-10-07 23:30:17 -0400 (Wed, 07 Oct 2009) | 2 lines Coding standards / Cleanup. ........ r6849 | pjenvey | 2009-10-08 23:17:04 -0400 (Thu, 08 Oct 2009) | 1 line rearrange/cleanup by exposing __call__ with ThreadState ........ r6850 | fwierzbicki | 2009-10-09 14:32:33 -0400 (Fri, 09 Oct 2009) | 3 lines Make all of the fields in CodeCompiler private except "yields". I plan to make "yields" private as well, but that's going to take some surgery on Module. ........ r6851 | pjenvey | 2009-10-10 01:44:16 -0400 (Sat, 10 Oct 2009) | 3 lines after a SystemRestart don't reset PySystemState until after the exitfuncs are called, otherwise some strange problems can occur ........ r6852 | pjenvey | 2009-10-10 02:05:26 -0400 (Sat, 10 Oct 2009) | 3 lines add a flag to sys as a faster SystemRestart check for the code objects. otherwise currentThread().isInterrupted() is now a noticable performance hit ........ r6853 | pjenvey | 2009-10-12 01:04:37 -0400 (Mon, 12 Oct 2009) | 10 lines port Armin Rigo's global mro cache optimization from PyPy/CPython 2.6. unlike their's this version is thread safe (non-blocking). being global, it may become less optimal when shared by many PythonInterpreters/PySystemStates this provides a nice attribute lookup speedup but it can slow down silly things like class attribute counters (maybe due to our extra allocation around the cache invalidation) refs http://bugs.python.org/issue1700288 ........ r6854 | pjenvey | 2009-10-12 22:31:45 -0400 (Mon, 12 Oct 2009) | 2 lines move the cached objectGetattribute out of PyObject to ease bootstrapping ........ r6855 | pjenvey | 2009-10-13 23:19:24 -0400 (Tue, 13 Oct 2009) | 4 lines add support for specifying docstrings in ExposedType/ExposedGet annotations. exposed type.__doc__, which for the most part removes the need for PyObject.getDoc ........ r6856 | pjenvey | 2009-10-14 02:02:01 -0400 (Wed, 14 Oct 2009) | 2 lines docs galore, enable test_descr.descrdoc ........ r6857 | pjenvey | 2009-10-14 02:37:50 -0400 (Wed, 14 Oct 2009) | 2 lines add classmethod docs ........ r6858 | pjenvey | 2009-10-14 02:54:56 -0400 (Wed, 14 Oct 2009) | 1 line fix the docstring test ........ r6859 | amak | 2009-10-15 13:40:22 -0400 (Thu, 15 Oct 2009) | 1 line Checking in support for loading site-packages, through the use of imp.load("site"). Controlled with a "load_site_packages" option, which defaults to true. ........ r6860 | otmarhumbel | 2009-10-15 15:34:31 -0400 (Thu, 15 Oct 2009) | 1 line fixed javadoc warnings ........ r6861 | pjenvey | 2009-10-15 22:39:10 -0400 (Thu, 15 Oct 2009) | 1 line doc sets and BaseException ........ r6862 | pjenvey | 2009-10-15 22:41:41 -0400 (Thu, 15 Oct 2009) | 1 line toArray arg can't be null ........ r6863 | pjenvey | 2009-10-15 23:34:01 -0400 (Thu, 15 Oct 2009) | 1 line make the exposed methods final, cleanup ........ r6864 | pjenvey | 2009-10-16 01:51:46 -0400 (Fri, 16 Oct 2009) | 4 lines The GC thread should be able to safely create GeneratorExits now that PyExceptions no longer create tracebacks when constructed (and so don't immediately need a frame on hand). this speeds up generator construction ........ r6865 | pjenvey | 2009-10-16 22:11:46 -0400 (Fri, 16 Oct 2009) | 3 lines fast path lists along with tuples and avoid the overhead of __len__'ing generators which can be a somewhat common make_array argument ........ r6866 | amak | 2009-10-17 12:03:45 -0400 (Sat, 17 Oct 2009) | 1 line Fixing a previously unnoticed bug where a relative value for "python.home" was not being treated relative to the context root and should have been. ........ r6867 | amak | 2009-10-17 12:10:18 -0400 (Sat, 17 Oct 2009) | 1 line Adding a sample config value for load_site_packages. ........ r6868 | pjenvey | 2009-10-17 12:57:13 -0400 (Sat, 17 Oct 2009) | 2 lines hardcode the __new__ descriptors' __doc__ ........ r6869 | pjenvey | 2009-10-17 13:07:38 -0400 (Sat, 17 Oct 2009) | 2 lines expose PyFastSequenceIter and avoid PyType.fromClass during its construction ........ r6870 | pjenvey | 2009-10-18 14:59:19 -0400 (Sun, 18 Oct 2009) | 1 line cache TYPE ........ r6871 | pjenvey | 2009-10-19 00:56:15 -0400 (Mon, 19 Oct 2009) | 2 lines two exceptions walk into a bar. ouch! ........ r6872 | pjenvey | 2009-10-19 17:26:09 -0400 (Mon, 19 Oct 2009) | 2 lines bring in constantine 0.6 release, for OpenFlags ........ r6873 | pjenvey | 2009-10-19 17:56:07 -0400 (Mon, 19 Oct 2009) | 4 lines move os.py -> posix.py, in prep. for separating the posix bits from it os.py from: http://svn.python.org/projects/python/branches/release26-maint/Lib/os.py@75144 ........ r6874 | pjenvey | 2009-10-19 18:02:41 -0400 (Mon, 19 Oct 2009) | 10 lines o pull posix bits out of os into their own module o further pull some of the slower to initialize bits out of posix into a Java _posix (_nt on Windows) module. this speeds up startup. eventually we should move more if not everything there o adapt 2.6's os.py: - hide exec* - we don't need to use set/get/putenv for the environ dict wrapper - our stat_result can be pickled, remove the copy_reg workaround - re-add some 2.5isms ........ r6875 | pjenvey | 2009-10-19 18:04:02 -0400 (Mon, 19 Oct 2009) | 2 lines remove the platform hiding functionality, until we actually need it ........ r6876 | pjenvey | 2009-10-19 18:08:32 -0400 (Mon, 19 Oct 2009) | 1 line unused imports ........ r6877 | pjenvey | 2009-10-19 20:06:05 -0400 (Mon, 19 Oct 2009) | 1 line don't hardcode the platform module name ........ r6878 | pjenvey | 2009-10-19 20:20:58 -0400 (Mon, 19 Oct 2009) | 5 lines o jna-posix does the pure java stat for us, simplify it + move it to PosixModule o move strerror to PosixModule because it does the work of falling back to Linux errno descriptions on Windows, and we need that from some Java calls ........ r6879 | pjenvey | 2009-10-19 20:54:00 -0400 (Mon, 19 Oct 2009) | 3 lines o constantine lacks sensible Windows OpenFlags constants, roll our own o fix put/unset/getenv on Windows ........ r6880 | pjenvey | 2009-10-19 21:15:51 -0400 (Mon, 19 Oct 2009) | 2 lines move the environ dict into the more appropriate PosixModule ........ r6881 | pjenvey | 2009-10-19 21:20:43 -0400 (Mon, 19 Oct 2009) | 1 line avoid the types import ........ r6882 | pjenvey | 2009-10-19 23:28:30 -0400 (Mon, 19 Oct 2009) | 1 line only import these when necessary ........ r6883 | pjenvey | 2009-10-19 23:43:46 -0400 (Mon, 19 Oct 2009) | 1 line identify reflected funcs as routines so they can show up in help() ........ r6884 | pjenvey | 2009-10-20 00:04:53 -0400 (Tue, 20 Oct 2009) | 2 lines move _exit/listdir to PosixModule, get rid of a duplicate getlogin impl ........ r6885 | pjenvey | 2009-10-20 00:24:54 -0400 (Tue, 20 Oct 2009) | 2 lines fix missing imports and reference to now fixed os.__name__ ........ r6886 | pjenvey | 2009-10-20 00:25:15 -0400 (Tue, 20 Oct 2009) | 4 lines don't decode bytes when searching for an encoding defined in an InputStream thanks artichoke fixes #1487 ........ Modified Paths: -------------- branches/indy/CoreExposed.includes branches/indy/Demo/modjy_webapp/WEB-INF/web.xml branches/indy/Lib/grp.py branches/indy/Lib/inspect.py branches/indy/Lib/modjy/__init__.py branches/indy/Lib/modjy/modjy.py branches/indy/Lib/modjy/modjy_exceptions.py branches/indy/Lib/modjy/modjy_impl.py branches/indy/Lib/modjy/modjy_log.py branches/indy/Lib/modjy/modjy_params.py branches/indy/Lib/modjy/modjy_publish.py branches/indy/Lib/modjy/modjy_response.py branches/indy/Lib/modjy/modjy_write.py branches/indy/Lib/modjy/modjy_wsgi.py branches/indy/Lib/ntpath.py branches/indy/Lib/posixpath.py branches/indy/Lib/pwd.py branches/indy/Lib/pycimport.py branches/indy/Lib/select.py branches/indy/Lib/site.py branches/indy/Lib/subprocess.py branches/indy/Lib/test/test_descr.py branches/indy/Lib/test/test_fileno.py branches/indy/Lib/test/test_import_jy.py branches/indy/Misc/make_pydocs.py branches/indy/NEWS branches/indy/build.xml branches/indy/grammar/Python.g branches/indy/grammar/PythonPartial.g branches/indy/src/com/xhaus/modjy/ModjyJServlet.java branches/indy/src/org/python/antlr/BaseParser.java branches/indy/src/org/python/antlr/PythonTree.java branches/indy/src/org/python/antlr/ast/AssertDerived.java branches/indy/src/org/python/antlr/ast/AssignDerived.java branches/indy/src/org/python/antlr/ast/AttributeDerived.java branches/indy/src/org/python/antlr/ast/AugAssignDerived.java branches/indy/src/org/python/antlr/ast/BinOpDerived.java branches/indy/src/org/python/antlr/ast/BoolOpDerived.java branches/indy/src/org/python/antlr/ast/BreakDerived.java branches/indy/src/org/python/antlr/ast/CallDerived.java branches/indy/src/org/python/antlr/ast/ClassDefDerived.java branches/indy/src/org/python/antlr/ast/CompareDerived.java branches/indy/src/org/python/antlr/ast/ContinueDerived.java branches/indy/src/org/python/antlr/ast/DeleteDerived.java branches/indy/src/org/python/antlr/ast/DictDerived.java branches/indy/src/org/python/antlr/ast/EllipsisDerived.java branches/indy/src/org/python/antlr/ast/ExceptHandlerDerived.java branches/indy/src/org/python/antlr/ast/ExecDerived.java branches/indy/src/org/python/antlr/ast/ExprDerived.java branches/indy/src/org/python/antlr/ast/ExpressionDerived.java branches/indy/src/org/python/antlr/ast/ExtSliceDerived.java branches/indy/src/org/python/antlr/ast/ForDerived.java branches/indy/src/org/python/antlr/ast/FunctionDefDerived.java branches/indy/src/org/python/antlr/ast/GeneratorExpDerived.java branches/indy/src/org/python/antlr/ast/GlobalDerived.java branches/indy/src/org/python/antlr/ast/IfDerived.java branches/indy/src/org/python/antlr/ast/IfExpDerived.java branches/indy/src/org/python/antlr/ast/ImportDerived.java branches/indy/src/org/python/antlr/ast/ImportFromDerived.java branches/indy/src/org/python/antlr/ast/IndexDerived.java branches/indy/src/org/python/antlr/ast/InteractiveDerived.java branches/indy/src/org/python/antlr/ast/LambdaDerived.java branches/indy/src/org/python/antlr/ast/ListCompDerived.java branches/indy/src/org/python/antlr/ast/ListDerived.java branches/indy/src/org/python/antlr/ast/ModuleDerived.java branches/indy/src/org/python/antlr/ast/NameDerived.java branches/indy/src/org/python/antlr/ast/NumDerived.java branches/indy/src/org/python/antlr/ast/PassDerived.java branches/indy/src/org/python/antlr/ast/PrintDerived.java branches/indy/src/org/python/antlr/ast/RaiseDerived.java branches/indy/src/org/python/antlr/ast/ReprDerived.java branches/indy/src/org/python/antlr/ast/ReturnDerived.java branches/indy/src/org/python/antlr/ast/SliceDerived.java branches/indy/src/org/python/antlr/ast/StrDerived.java branches/indy/src/org/python/antlr/ast/SubscriptDerived.java branches/indy/src/org/python/antlr/ast/SuiteDerived.java branches/indy/src/org/python/antlr/ast/TryExceptDerived.java branches/indy/src/org/python/antlr/ast/TryFinallyDerived.java branches/indy/src/org/python/antlr/ast/TupleDerived.java branches/indy/src/org/python/antlr/ast/UnaryOpDerived.java branches/indy/src/org/python/antlr/ast/WhileDerived.java branches/indy/src/org/python/antlr/ast/WithDerived.java branches/indy/src/org/python/antlr/ast/YieldDerived.java branches/indy/src/org/python/antlr/ast/aliasDerived.java branches/indy/src/org/python/antlr/ast/argumentsDerived.java branches/indy/src/org/python/antlr/ast/comprehensionDerived.java branches/indy/src/org/python/antlr/ast/keywordDerived.java branches/indy/src/org/python/antlr/op/AddDerived.java branches/indy/src/org/python/antlr/op/AndDerived.java branches/indy/src/org/python/antlr/op/AugLoadDerived.java branches/indy/src/org/python/antlr/op/AugStoreDerived.java branches/indy/src/org/python/antlr/op/BitAndDerived.java branches/indy/src/org/python/antlr/op/BitOrDerived.java branches/indy/src/org/python/antlr/op/BitXorDerived.java branches/indy/src/org/python/antlr/op/DelDerived.java branches/indy/src/org/python/antlr/op/DivDerived.java branches/indy/src/org/python/antlr/op/EqDerived.java branches/indy/src/org/python/antlr/op/FloorDivDerived.java branches/indy/src/org/python/antlr/op/GtDerived.java branches/indy/src/org/python/antlr/op/GtEDerived.java branches/indy/src/org/python/antlr/op/InDerived.java branches/indy/src/org/python/antlr/op/InvertDerived.java branches/indy/src/org/python/antlr/op/IsDerived.java branches/indy/src/org/python/antlr/op/IsNotDerived.java branches/indy/src/org/python/antlr/op/LShiftDerived.java branches/indy/src/org/python/antlr/op/LoadDerived.java branches/indy/src/org/python/antlr/op/LtDerived.java branches/indy/src/org/python/antlr/op/LtEDerived.java branches/indy/src/org/python/antlr/op/ModDerived.java branches/indy/src/org/python/antlr/op/MultDerived.java branches/indy/src/org/python/antlr/op/NotDerived.java branches/indy/src/org/python/antlr/op/NotEqDerived.java branches/indy/src/org/python/antlr/op/NotInDerived.java branches/indy/src/org/python/antlr/op/OrDerived.java branches/indy/src/org/python/antlr/op/ParamDerived.java branches/indy/src/org/python/antlr/op/PowDerived.java branches/indy/src/org/python/antlr/op/RShiftDerived.java branches/indy/src/org/python/antlr/op/StoreDerived.java branches/indy/src/org/python/antlr/op/SubDerived.java branches/indy/src/org/python/antlr/op/UAddDerived.java branches/indy/src/org/python/antlr/op/USubDerived.java branches/indy/src/org/python/compiler/CodeCompiler.java branches/indy/src/org/python/compiler/Constant.java branches/indy/src/org/python/compiler/Module.java branches/indy/src/org/python/core/BuiltinDocs.java branches/indy/src/org/python/core/ClasspathPyImporterDerived.java branches/indy/src/org/python/core/ParserFacade.java branches/indy/src/org/python/core/Py.java branches/indy/src/org/python/core/PyArrayDerived.java branches/indy/src/org/python/core/PyBaseCode.java branches/indy/src/org/python/core/PyBaseException.java branches/indy/src/org/python/core/PyBaseExceptionDerived.java branches/indy/src/org/python/core/PyBaseString.java branches/indy/src/org/python/core/PyBoolean.java branches/indy/src/org/python/core/PyBooleanDerived.java branches/indy/src/org/python/core/PyBuiltinCallable.java branches/indy/src/org/python/core/PyCell.java branches/indy/src/org/python/core/PyClassMethod.java branches/indy/src/org/python/core/PyClassMethodDerived.java branches/indy/src/org/python/core/PyClassMethodDescr.java branches/indy/src/org/python/core/PyComplex.java branches/indy/src/org/python/core/PyComplexDerived.java branches/indy/src/org/python/core/PyDataDescr.java branches/indy/src/org/python/core/PyDictionary.java branches/indy/src/org/python/core/PyDictionaryDerived.java branches/indy/src/org/python/core/PyEnumerate.java branches/indy/src/org/python/core/PyEnumerateDerived.java branches/indy/src/org/python/core/PyFastSequenceIter.java branches/indy/src/org/python/core/PyFile.java branches/indy/src/org/python/core/PyFileDerived.java branches/indy/src/org/python/core/PyFloat.java branches/indy/src/org/python/core/PyFloatDerived.java branches/indy/src/org/python/core/PyFrame.java branches/indy/src/org/python/core/PyFrozenSet.java branches/indy/src/org/python/core/PyFrozenSetDerived.java branches/indy/src/org/python/core/PyFunction.java branches/indy/src/org/python/core/PyGenerator.java branches/indy/src/org/python/core/PyInteger.java branches/indy/src/org/python/core/PyIntegerDerived.java branches/indy/src/org/python/core/PyJavaType.java branches/indy/src/org/python/core/PyList.java branches/indy/src/org/python/core/PyListDerived.java branches/indy/src/org/python/core/PyLong.java branches/indy/src/org/python/core/PyLongDerived.java branches/indy/src/org/python/core/PyMethod.java branches/indy/src/org/python/core/PyMethodDescr.java branches/indy/src/org/python/core/PyModule.java branches/indy/src/org/python/core/PyModuleDerived.java branches/indy/src/org/python/core/PyNewWrapper.java branches/indy/src/org/python/core/PyObject.java branches/indy/src/org/python/core/PyObjectDerived.java branches/indy/src/org/python/core/PyProperty.java branches/indy/src/org/python/core/PyPropertyDerived.java branches/indy/src/org/python/core/PyReflectedConstructor.java branches/indy/src/org/python/core/PyReflectedFunction.java branches/indy/src/org/python/core/PySet.java branches/indy/src/org/python/core/PySetDerived.java branches/indy/src/org/python/core/PySlice.java branches/indy/src/org/python/core/PySliceDerived.java branches/indy/src/org/python/core/PyStaticMethod.java branches/indy/src/org/python/core/PyString.java branches/indy/src/org/python/core/PyStringDerived.java branches/indy/src/org/python/core/PySuper.java branches/indy/src/org/python/core/PySuperDerived.java branches/indy/src/org/python/core/PySystemState.java branches/indy/src/org/python/core/PyTableCode.java branches/indy/src/org/python/core/PyTraceback.java branches/indy/src/org/python/core/PyTuple.java branches/indy/src/org/python/core/PyTupleDerived.java branches/indy/src/org/python/core/PyType.java branches/indy/src/org/python/core/PyTypeDerived.java branches/indy/src/org/python/core/PyUnicode.java branches/indy/src/org/python/core/PyUnicodeDerived.java branches/indy/src/org/python/core/PyXRange.java branches/indy/src/org/python/core/ReflectedArgs.java branches/indy/src/org/python/core/exceptions.java branches/indy/src/org/python/core/io/FileIO.java branches/indy/src/org/python/core/io/StreamIO.java branches/indy/src/org/python/core/util/FileUtil.java branches/indy/src/org/python/expose/BaseTypeBuilder.java branches/indy/src/org/python/expose/ExposedClassMethod.java branches/indy/src/org/python/expose/ExposedGet.java branches/indy/src/org/python/expose/ExposedType.java branches/indy/src/org/python/expose/TypeBuilder.java branches/indy/src/org/python/expose/generate/ClassMethodExposer.java branches/indy/src/org/python/expose/generate/DescriptorExposer.java branches/indy/src/org/python/expose/generate/DescriptorVisitor.java branches/indy/src/org/python/expose/generate/ExposedFieldFinder.java branches/indy/src/org/python/expose/generate/ExposedMethodFinder.java branches/indy/src/org/python/expose/generate/ExposedTypeProcessor.java branches/indy/src/org/python/expose/generate/ExposedTypeVisitor.java branches/indy/src/org/python/expose/generate/InstanceMethodExposer.java branches/indy/src/org/python/expose/generate/MethodExposer.java branches/indy/src/org/python/expose/generate/PyTypes.java branches/indy/src/org/python/expose/generate/TypeExposer.java branches/indy/src/org/python/modules/Setup.java branches/indy/src/org/python/modules/_collections/PyDefaultDict.java branches/indy/src/org/python/modules/_collections/PyDefaultDictDerived.java branches/indy/src/org/python/modules/_collections/PyDequeDerived.java branches/indy/src/org/python/modules/_csv/PyDialectDerived.java branches/indy/src/org/python/modules/_functools/PyPartialDerived.java branches/indy/src/org/python/modules/_weakref/ReferenceTypeDerived.java branches/indy/src/org/python/modules/cPickle.java branches/indy/src/org/python/modules/cStringIO.java branches/indy/src/org/python/modules/itertools.java branches/indy/src/org/python/modules/random/PyRandomDerived.java branches/indy/src/org/python/modules/thread/PyLocalDerived.java branches/indy/src/org/python/modules/zipimport/zipimporterDerived.java branches/indy/src/org/python/util/jython.java branches/indy/src/templates/object.derived branches/indy/tests/java/org/python/antlr/PythonPartialTester.java branches/indy/tests/java/org/python/antlr/PythonTreeTester.java branches/indy/tests/java/org/python/expose/generate/ExposeMethodFinderTest.java branches/indy/tests/java/org/python/expose/generate/ExposedTypeProcessorTest.java branches/indy/tests/java/org/python/expose/generate/ExposedTypeVisitorTest.java branches/indy/tests/java/org/python/expose/generate/MethodExposerTest.java branches/indy/tests/java/org/python/expose/generate/SimpleExposed.java branches/indy/tests/java/org/python/expose/generate/TypeExposerTest.java branches/indy/tests/modjy/java/com/xhaus/modjy/ModjyTestBase.java branches/indy/tests/modjy/java/com/xhaus/modjy/ModjyTestContentHeaders.java branches/indy/tests/modjy/test_apps_dir/content_header_tests.py branches/indy/tests/modjy/test_apps_dir/environ_tests.py branches/indy/tests/modjy/test_apps_dir/header_tests.py branches/indy/tests/modjy/test_apps_dir/return_tests.py branches/indy/tests/modjy/test_apps_dir/simple_app.py branches/indy/tests/modjy/test_apps_dir/stream_tests.py branches/indy/tests/modjy/test_apps_dir/web_inf_tests.py Added Paths: ----------- branches/indy/Lib/nt.py branches/indy/Lib/os.py branches/indy/Lib/posix.py branches/indy/Lib/test/test_inspect_jy.py branches/indy/extlibs/constantine.jar branches/indy/src/org/python/core/Deriveds.java branches/indy/src/org/python/modules/posix/ branches/indy/src/org/python/modules/posix/OS.java branches/indy/src/org/python/modules/posix/PosixModule.java branches/indy/src/org/python/modules/posix/PyStatResult.java branches/indy/src/org/python/modules/posix/PythonPOSIXHandler.java branches/indy/tests/modjy/java/com/xhaus/modjy/ModjyTestInterpreterLifecycle.java branches/indy/tests/modjy/test_apps_dir/lifecycle_tests.py Removed Paths: ------------- branches/indy/Lib/os.py branches/indy/Lib/posix.py branches/indy/extlibs/constantine-0.4.jar branches/indy/src/org/python/modules/posix/OS.java branches/indy/src/org/python/modules/posix/PosixModule.java branches/indy/src/org/python/modules/posix/PyStatResult.java branches/indy/src/org/python/modules/posix/PythonPOSIXHandler.java Property Changed: ---------------- branches/indy/ branches/indy/Lib/collections/ branches/indy/Lib/compiler/ branches/indy/Lib/distutils/ branches/indy/Lib/distutils/command/ branches/indy/Lib/distutils/tests/ branches/indy/Lib/modjy/ branches/indy/Lib/test/bugs/ branches/indy/Lib/test/bugs/pr133/ branches/indy/Lib/test/pbcvm/test/ branches/indy/Lib/test/pyservlet/ branches/indy/Lib/test/test_metaclass_support/ branches/indy/Lib/test/zxjdbc/ branches/indy/Lib/xml/etree/ branches/indy/Lib/xml/parsers/ branches/indy/extlibs/xercesImpl-2.9.1.jar branches/indy/tests/java/org/python/tests/RedundantInterfaceDeclarations.java Property changes on: branches/indy ___________________________________________________________________ Modified: svnmerge-integrated - /trunk/jython:1-6814 + /trunk/jython:1-6886 Modified: svn:mergeinfo - /branches/jsr223:6285-6565 /branches/newstyle-java-types:5564-5663,5666-5729 /trunk/jython:6662-6741,6762-6814 + /branches/jsr223:6285-6565 /branches/newstyle-java-types:5564-5663,5666-5729 /trunk/jython:6662-6741,6762-6886 Modified: branches/indy/CoreExposed.includes =================================================================== --- branches/indy/CoreExposed.includes 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/CoreExposed.includes 2009-10-21 01:58:03 UTC (rev 6887) @@ -15,8 +15,10 @@ org/python/core/PyDictProxy.class org/python/core/PyEnumerate.class org/python/core/PyEllipsis.class +org/python/core/PyFastSequenceIter.class org/python/core/PyFile.class org/python/core/PyFloat.class +org/python/core/PyFrame.class org/python/core/PyFrozenSet.class org/python/core/PyFunction.class org/python/core/PyGenerator.class @@ -59,6 +61,7 @@ org/python/modules/_weakref/ReferenceType.class org/python/modules/operator$PyAttrGetter.class org/python/modules/operator$PyItemGetter.class +org/python/modules/posix/PyStatResult.class org/python/modules/random/PyRandom.class org/python/modules/thread/PyLocal.class org/python/modules/time/PyTimeTuple.class Modified: branches/indy/Demo/modjy_webapp/WEB-INF/web.xml =================================================================== --- branches/indy/Demo/modjy_webapp/WEB-INF/web.xml 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/Demo/modjy_webapp/WEB-INF/web.xml 2009-10-21 01:58:03 UTC (rev 6887) @@ -6,7 +6,7 @@ <display-name>modjy demo application</display-name> <description> - modjy WSGI demo application + modjy WSGI demo application </description> <servlet> @@ -15,58 +15,67 @@ <init-param> <param-name>python.home</param-name> <param-value>C:/jython2.5</param-value> - </init-param> -<!-- - There are two different ways you can specify an application to modjy - 1. Using the app_import_name mechanism - 2. Using a combination of app_directory/app_filename/app_callable_name - Examples of both are given below - See the documenation for more details. + </init-param> +<!-- + There are two different ways you can specify an application to modjy + 1. Using the app_import_name mechanism + 2. Using a combination of app_directory/app_filename/app_callable_name + Examples of both are given below + See the documenation for more details. http://modjy.xhaus.com/locating.html#locating_callables ---> -<!-- - This is the app_import_name mechanism. If you specify a value - for this variable, then it will take precedence over the other mechanism +--> +<!-- + This is the app_import_name mechanism. If you specify a value + for this variable, then it will take precedence over the other mechanism <init-param> <param-name>app_import_name</param-name> <param-value>my_wsgi_module.my_handler_class().handler_method</param-value> - </init-param> + </init-param> --> -<!-- - And this is the app_directory/app_filename/app_callable_name combo - The defaults for these three variables are ""/application.py/handler - So if you specify no values at all for any of app_* variables, then modjy - will by default look for "handler" in "application.py" in the servlet - context root. +<!-- + And this is the app_directory/app_filename/app_callable_name combo + The defaults for these three variables are ""/application.py/handler + So if you specify no values at all for any of app_* variables, then modjy + will by default look for "handler" in "application.py" in the servlet + context root. <init-param> <param-name>app_directory</param-name> <param-value>some_sub_directory</param-value> - </init-param> + </init-param> --> <init-param> <param-name>app_filename</param-name> <param-value>demo_app.py</param-value> </init-param> -<!-- - Supply a value for this parameter if you want your application - callable to have a different name than the default. +<!-- + Supply a value for this parameter if you want your application + callable to have a different name than the default. <init-param> <param-name>app_callable_name</param-name> <param-value>my_handler_func</param-value> </init-param> ---> - <!-- Do you want application callables to be cached? --> +--> + <!-- Do you want application callables to be cached? --> <init-param> <param-name>cache_callables</param-name> <param-value>1</param-value> - </init-param> - <!-- Should the application be reloaded if it's .py file changes? --> + </init-param> + <!-- Should the application be reloaded if it's .py file changes? --> <!-- Does not work with the app_import_name mechanism --> <init-param> <param-name>reload_on_mod</param-name> <param-value>1</param-value> </init-param> + <!-- + Is site-packages to be loaded through imp.load("site")? + Same as -S option to command line interpreter + --> <init-param> + <param-name>load_site_packages</param-name> + <param-value>1</param-value> +<!-- <param-value>0</param-value> --> + </init-param> + <init-param> <param-name>log_level</param-name> <param-value>debug</param-value> <!-- <param-value>info</param-value> --> Property changes on: branches/indy/Lib/collections ___________________________________________________________________ Added: svn:ignore + *$py.class Property changes on: branches/indy/Lib/compiler ___________________________________________________________________ Added: svn:ignore + *$py.class Property changes on: branches/indy/Lib/distutils ___________________________________________________________________ Added: svn:ignore + *$py.class Property changes on: branches/indy/Lib/distutils/command ___________________________________________________________________ Added: svn:ignore + *$py.class Property changes on: branches/indy/Lib/distutils/tests ___________________________________________________________________ Added: svn:ignore + *$py.class Modified: branches/indy/Lib/grp.py =================================================================== --- branches/indy/Lib/grp.py 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/Lib/grp.py 2009-10-21 01:58:03 UTC (rev 6887) @@ -17,7 +17,7 @@ __all__ = ['getgrgid', 'getgrnam', 'getgrall'] -from os import _name, _posix +from os import _name, _posix_impl if _name == 'nt': raise ImportError, 'grp module not supported on Windows' @@ -50,7 +50,7 @@ Return the group database entry for the given numeric group ID. If id is not valid, raise KeyError. """ - entry = _posix.getgrgid(uid) + entry = _posix_impl.getgrgid(uid) if not entry: raise KeyError(uid) return struct_group(entry) @@ -62,7 +62,7 @@ Return the group database entry for the given group name. If name is not valid, raise KeyError. """ - entry = _posix.getgrnam(name) + entry = _posix_impl.getgrnam(name) if not entry: raise KeyError(name) return struct_group(entry) @@ -76,7 +76,7 @@ """ groups = [] while True: - group = _posix.getgrent() + group = _posix_impl.getgrent() if not group: break groups.append(struct_group(group)) Modified: branches/indy/Lib/inspect.py =================================================================== --- branches/indy/Lib/inspect.py 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/Lib/inspect.py 2009-10-21 01:58:03 UTC (rev 6887) @@ -30,6 +30,7 @@ import sys, os, types, string, re, dis, imp, tokenize, linecache from operator import attrgetter +ReflectedFunctionType = type(os.listdir) # ----------------------------------------------------------- type-checking def ismodule(object): @@ -196,7 +197,8 @@ return (isbuiltin(object) or isfunction(object) or ismethod(object) - or ismethoddescriptor(object)) + or ismethoddescriptor(object) + or isinstance(object, ReflectedFunctionType)) def getmembers(object, predicate=None): """Return all members of an object as (name, value) pairs sorted by name. Property changes on: branches/indy/Lib/modjy ___________________________________________________________________ Added: svn:ignore + *$py.class Modified: branches/indy/Lib/modjy/__init__.py =================================================================== --- branches/indy/Lib/modjy/__init__.py 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/Lib/modjy/__init__.py 2009-10-21 01:58:03 UTC (rev 6887) @@ -1,22 +1,22 @@ -### -# -# Copyright Alan Kennedy. -# -# You may contact the copyright holder at this uri: -# -# http://www.xhaus.com/contact/modjy -# -# The licence under which this code is released is the Apache License v2.0. -# -# The terms and conditions of this license are listed in a file contained -# in the distribution that also contained this file, under the name -# LICENSE.txt. -# -# You may also read a copy of the license at the following web address. -# -# http://modjy.xhaus.com/LICENSE.txt -# -### - -__all__ = ['modjy', 'modjy_exceptions', 'modjy_impl', 'modjy_log', 'modjy_params', 'modjy_publish', 'modjy_response', 'modjy_write', 'modjy_wsgi',] - +### +# +# Copyright Alan Kennedy. +# +# You may contact the copyright holder at this uri: +# +# http://www.xhaus.com/contact/modjy +# +# The licence under which this code is released is the Apache License v2.0. +# +# The terms and conditions of this license are listed in a file contained +# in the distribution that also contained this file, under the name +# LICENSE.txt. +# +# You may also read a copy of the license at the following web address. +# +# http://modjy.xhaus.com/LICENSE.txt +# +### + +__all__ = ['modjy', 'modjy_exceptions', 'modjy_impl', 'modjy_log', 'modjy_params', 'modjy_publish', 'modjy_response', 'modjy_write', 'modjy_wsgi',] + Modified: branches/indy/Lib/modjy/modjy.py =================================================================== --- branches/indy/Lib/modjy/modjy.py 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/Lib/modjy/modjy.py 2009-10-21 01:58:03 UTC (rev 6887) @@ -1,121 +1,121 @@ -### -# -# Copyright Alan Kennedy. -# -# You may contact the copyright holder at this uri: -# -# http://www.xhaus.com/contact/modjy -# -# The licence under which this code is released is the Apache License v2.0. -# -# The terms and conditions of this license are listed in a file contained -# in the distribution that also contained this file, under the name -# LICENSE.txt. -# -# You may also read a copy of the license at the following web address. -# -# http://modjy.xhaus.com/LICENSE.txt -# -### - -import jarray -import synchronize -import sys -import types - -sys.add_package("javax.servlet") -sys.add_package("javax.servlet.http") -sys.add_package("org.python.core") - -from modjy_exceptions import * -from modjy_log import * -from modjy_params import modjy_param_mgr, modjy_servlet_params -from modjy_wsgi import modjy_wsgi -from modjy_response import start_response_object -from modjy_impl import modjy_impl -from modjy_publish import modjy_publisher - -from javax.servlet.http import HttpServlet - -class modjy_servlet(HttpServlet, modjy_publisher, modjy_wsgi, modjy_impl): - - def __init__(self): - HttpServlet.__init__(self) - - def do_param(self, name, value): - if name[:3] == 'log': - getattr(self.log, "set_%s" % name)(value) - else: - self.params[name] = value - - def process_param_container(self, param_container): - param_enum = param_container.getInitParameterNames() - while param_enum.hasMoreElements(): - param_name = param_enum.nextElement() - self.do_param(param_name, param_container.getInitParameter(param_name)) - - def get_params(self): - self.process_param_container(self.servlet_context) - self.process_param_container(self.servlet) - - def init(self, delegator): - self.servlet = delegator - self.servlet_context = self.servlet.getServletContext() - self.servlet_config = self.servlet.getServletConfig() - self.log = modjy_logger(self.servlet_context) - self.params = modjy_param_mgr(modjy_servlet_params) - self.get_params() - self.init_impl() - self.init_publisher() - import modjy_exceptions - self.exc_handler = getattr(modjy_exceptions, '%s_handler' % self.params['exc_handler'])() - - def service (self, req, resp): - wsgi_environ = {} - try: - self.dispatch_to_application(req, resp, wsgi_environ) - except ModjyException, mx: - self.log.error("Exception servicing request: %s" % str(mx)) - typ, value, tb = sys.exc_info()[:] - self.exc_handler.handle(req, resp, wsgi_environ, mx, (typ, value, tb) ) - - def get_j2ee_ns(self, req, resp): - return { - 'servlet': self.servlet, - 'servlet_context': self.servlet_context, - 'servlet_config': self.servlet_config, - 'request': req, - 'response': resp, - } - - def dispatch_to_application(self, req, resp, environ): - app_callable = self.get_app_object(req, environ) - self.set_wsgi_environment(req, resp, environ, self.params, self.get_j2ee_ns(req, resp)) - response_callable = start_response_object(req, resp) - try: - app_return = self.call_application(app_callable, environ, response_callable) - if app_return is None: - raise ReturnNotIterable("Application returned None: must return an iterable") - self.deal_with_app_return(environ, response_callable, app_return) - except ModjyException, mx: - self.raise_exc(mx.__class__, str(mx)) - except Exception, x: - self.raise_exc(ApplicationException, str(x)) - - def call_application(self, app_callable, environ, response_callable): - if self.params['multithread']: - return app_callable.__call__(environ, response_callable) - else: - return synchronize.apply_synchronized( \ - app_callable, \ - app_callable, \ - (environ, response_callable)) - - def expand_relative_path(self, path): - if path.startswith("$"): - return self.servlet.getServletContext().getRealPath(path[1:]) - return path - - def raise_exc(self, exc_class, message): - self.log.error(message) - raise exc_class(message) +### +# +# Copyright Alan Kennedy. +# +# You may contact the copyright holder at this uri: +# +# http://www.xhaus.com/contact/modjy +# +# The licence under which this code is released is the Apache License v2.0. +# +# The terms and conditions of this license are listed in a file contained +# in the distribution that also contained this file, under the name +# LICENSE.txt. +# +# You may also read a copy of the license at the following web address. +# +# http://modjy.xhaus.com/LICENSE.txt +# +### + +import jarray +import synchronize +import sys +import types + +sys.add_package("javax.servlet") +sys.add_package("javax.servlet.http") +sys.add_package("org.python.core") + +from modjy_exceptions import * +from modjy_log import * +from modjy_params import modjy_param_mgr, modjy_servlet_params +from modjy_wsgi import modjy_wsgi +from modjy_response import start_response_object +from modjy_impl import modjy_impl +from modjy_publish import modjy_publisher + +from javax.servlet.http import HttpServlet + +class modjy_servlet(HttpServlet, modjy_publisher, modjy_wsgi, modjy_impl): + + def __init__(self): + HttpServlet.__init__(self) + + def do_param(self, name, value): + if name[:3] == 'log': + getattr(self.log, "set_%s" % name)(value) + else: + self.params[name] = value + + def process_param_container(self, param_container): + param_enum = param_container.getInitParameterNames() + while param_enum.hasMoreElements(): + param_name = param_enum.nextElement() + self.do_param(param_name, param_container.getInitParameter(param_name)) + + def get_params(self): + self.process_param_container(self.servlet_context) + self.process_param_container(self.servlet) + + def init(self, delegator): + self.servlet = delegator + self.servlet_context = self.servlet.getServletContext() + self.servlet_config = self.servlet.getServletConfig() + self.log = modjy_logger(self.servlet_context) + self.params = modjy_param_mgr(modjy_servlet_params) + self.get_params() + self.init_impl() + self.init_publisher() + import modjy_exceptions + self.exc_handler = getattr(modjy_exceptions, '%s_handler' % self.params['exc_handler'])() + + def service (self, req, resp): + wsgi_environ = {} + try: + self.dispatch_to_application(req, resp, wsgi_environ) + except ModjyException, mx: + self.log.error("Exception servicing request: %s" % str(mx)) + typ, value, tb = sys.exc_info()[:] + self.exc_handler.handle(req, resp, wsgi_environ, mx, (typ, value, tb) ) + + def get_j2ee_ns(self, req, resp): + return { + 'servlet': self.servlet, + 'servlet_context': self.servlet_context, + 'servlet_config': self.servlet_config, + 'request': req, + 'response': resp, + } + + def dispatch_to_application(self, req, resp, environ): + app_callable = self.get_app_object(req, environ) + self.set_wsgi_environment(req, resp, environ, self.params, self.get_j2ee_ns(req, resp)) + response_callable = start_response_object(req, resp) + try: + app_return = self.call_application(app_callable, environ, response_callable) + if app_return is None: + raise ReturnNotIterable("Application returned None: must return an iterable") + self.deal_with_app_return(environ, response_callable, app_return) + except ModjyException, mx: + self.raise_exc(mx.__class__, str(mx)) + except Exception, x: + self.raise_exc(ApplicationException, str(x)) + + def call_application(self, app_callable, environ, response_callable): + if self.params['multithread']: + return app_callable.__call__(environ, response_callable) + else: + return synchronize.apply_synchronized( \ + app_callable, \ + app_callable, \ + (environ, response_callable)) + + def expand_relative_path(self, path): + if path.startswith("$"): + return self.servlet.getServletContext().getRealPath(path[1:]) + return path + + def raise_exc(self, exc_class, message): + self.log.error(message) + raise exc_class(message) Modified: branches/indy/Lib/modjy/modjy_exceptions.py =================================================================== --- branches/indy/Lib/modjy/modjy_exceptions.py 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/Lib/modjy/modjy_exceptions.py 2009-10-21 01:58:03 UTC (rev 6887) @@ -1,91 +1,91 @@ -### -# -# Copyright Alan Kennedy. -# -# You may contact the copyright holder at this uri: -# -# http://www.xhaus.com/contact/modjy -# -# The licence under which this code is released is the Apache License v2.0. -# -# The terms and conditions of this license are listed in a file contained -# in the distribution that also contained this file, under the name -# LICENSE.txt. -# -# You may also read a copy of the license at the following web address. -# -# http://modjy.xhaus.com/LICENSE.txt -# -### - -import sys -import StringIO -import traceback - -from java.lang import IllegalStateException -from java.io import IOException -from javax.servlet import ServletException - -class ModjyException(Exception): pass - -class ModjyIOException(ModjyException): pass - -class ConfigException(ModjyException): pass -class BadParameter(ConfigException): pass -class ApplicationNotFound(ConfigException): pass -class NoCallable(ConfigException): pass - -class RequestException(ModjyException): pass - -class ApplicationException(ModjyException): pass -class StartResponseNotCalled(ApplicationException): pass -class StartResponseCalledTwice(ApplicationException): pass -class ResponseCommitted(ApplicationException): pass -class HopByHopHeaderSet(ApplicationException): pass -class WrongLength(ApplicationException): pass -class BadArgument(ApplicationException): pass -class ReturnNotIterable(ApplicationException): pass -class NonStringOutput(ApplicationException): pass - -class exception_handler: - - def handle(self, req, resp, environ, exc, exc_info): - pass - - def get_status_and_message(self, req, resp, exc): - return resp.SC_INTERNAL_SERVER_ERROR, "Server configuration error" - -# -# Special exception handler for testing -# - -class testing_handler(exception_handler): - - def handle(self, req, resp, environ, exc, exc_info): - typ, value, tb = exc_info - err_msg = StringIO.StringIO() - err_msg.write("%s: %s\n" % (typ, value,) ) - err_msg.write(">Environment\n") - for k in environ.keys(): - err_msg.write("%s=%s\n" % (k, repr(environ[k])) ) - err_msg.write("<Environment\n") - err_msg.write(">TraceBack\n") - for line in traceback.format_exception(typ, value, tb): - err_msg.write(line) - err_msg.write("<TraceBack\n") - try: - status, message = self.get_status_and_message(req, resp, exc) - resp.setStatus(status) - resp.setContentLength(len(err_msg.getvalue())) - resp.getOutputStream().write(err_msg.getvalue()) - except IllegalStateException, ise: - raise exc # Let the container deal with it - -# -# Standard exception handler -# - -class standard_handler(exception_handler): - - def handle(self, req, resp, environ, exc, exc_info): - raise exc_info[0], exc_info[1], exc_info[2] +### +# +# Copyright Alan Kennedy. +# +# You may contact the copyright holder at this uri: +# +# http://www.xhaus.com/contact/modjy +# +# The licence under which this code is released is the Apache License v2.0. +# +# The terms and conditions of this license are listed in a file contained +# in the distribution that also contained this file, under the name +# LICENSE.txt. +# +# You may also read a copy of the license at the following web address. +# +# http://modjy.xhaus.com/LICENSE.txt +# +### + +import sys +import StringIO +import traceback + +from java.lang import IllegalStateException +from java.io import IOException +from javax.servlet import ServletException + +class ModjyException(Exception): pass + +class ModjyIOException(ModjyException): pass + +class ConfigException(ModjyException): pass +class BadParameter(ConfigException): pass +class ApplicationNotFound(ConfigException): pass +class NoCallable(ConfigException): pass + +class RequestException(ModjyException): pass + +class ApplicationException(ModjyException): pass +class StartResponseNotCalled(ApplicationException): pass +class StartResponseCalledTwice(ApplicationException): pass +class ResponseCommitted(ApplicationException): pass +class HopByHopHeaderSet(ApplicationException): pass +class WrongLength(ApplicationException): pass +class BadArgument(ApplicationException): pass +class ReturnNotIterable(ApplicationException): pass +class NonStringOutput(ApplicationException): pass + +class exception_handler: + + def handle(self, req, resp, environ, exc, exc_info): + pass + + def get_status_and_message(self, req, resp, exc): + return resp.SC_INTERNAL_SERVER_ERROR, "Server configuration error" + +# +# Special exception handler for testing +# + +class testing_handler(exception_handler): + + def handle(self, req, resp, environ, exc, exc_info): + typ, value, tb = exc_info + err_msg = StringIO.StringIO() + err_msg.write("%s: %s\n" % (typ, value,) ) + err_msg.write(">Environment\n") + for k in environ.keys(): + err_msg.write("%s=%s\n" % (k, repr(environ[k])) ) + err_msg.write("<Environment\n") + err_msg.write(">TraceBack\n") + for line in traceback.format_exception(typ, value, tb): + err_msg.write(line) + err_msg.write("<TraceBack\n") + try: + status, message = self.get_status_and_message(req, resp, exc) + resp.setStatus(status) + resp.setContentLength(len(err_msg.getvalue())) + resp.getOutputStream().write(err_msg.getvalue()) + except IllegalStateException, ise: + raise exc # Let the container deal with it + +# +# Standard exception handler +# + +class standard_handler(exception_handler): + + def handle(self, req, resp, environ, exc, exc_info): + raise exc_info[0], exc_info[1], exc_info[2] Modified: branches/indy/Lib/modjy/modjy_impl.py =================================================================== --- branches/indy/Lib/modjy/modjy_impl.py 2009-10-20 04:25:15 UTC (rev 6886) +++ branches/indy/Lib/modjy/modjy_impl.py 2009-10-21 01:58:03 UTC (rev 6887) @@ -1,101 +1,101 @@ -### -# -# Copyright Alan Kennedy. -# -# You may contact the copyright holder at this uri: -# -# http://www.xhaus.com/contact/modjy -# -# The licence under which this code is released is the Apache License v2.0. -# -# The terms and conditions of this license are listed in a file contained -# in the distribution that also contained this file, under the name -# LICENSE.txt. -# -# You may also read a copy of the license at the following web address. -# -# http://modjy.xhaus.com/LICENSE.txt -# -### - -import types -import sys - -from modjy_exceptions import * - -class modjy_impl: - - def deal_with_app_return(self, environ, start_response_callable, app_return): - self.log.debug("Processing app return type: %s" % str(type(app_return))) - if isinstance(app_return, types.StringTypes): - raise ReturnNotIterable("Application returned object that was not an iterable: %s" % str(type(app_return))) - if type(app_return) is types.FileType: - pass # TBD: What to do here? can't call fileno() - if hasattr(app_return, '__len__') and callable(app_return.__len__): - expected_pieces = app_return.__len__() - else: - expected_pieces = -1 - try: - try: - ix = 0 - for next_piece in app_return: - if not isinstance(next_piece, types.StringTypes): - raise NonStringOutput("Application returned iterable containing non-strings: %s" % str(type(next_piece))) - if ix == 0: - # The application may have called start_response in the first iteration - if not start_response_callable.called: - raise StartResponseNotCalled("Start_response callable was never called.") - if not start_response_callable.content_length \ - and expected_pieces == 1 \ - and start_response_callable.write_callable.num_writes == 0: - # Take the length of the first piece - start_response_callable.set_content_length(len(next_piece)) - start_response_callable.write_callable(next_piece) - ix += 1 - if ix == expected_pieces: - break - if expected_pieces != -1 and ix != expected_pieces: - raise WrongLength("Iterator len() was wrong. Expected %d pieces: got %d" % (expected_pieces, ix) ) - except AttributeError, ax: - if str(ax) == "__getitem__": - raise ReturnNotIterable("Application returned object that was not an iterable: %s" % str(type(app_return))) - else: - raise ax - except TypeError, tx: - raise ReturnNotIterable("Application returned object that was not an iterable: %s" % str(type(app_return))) - except ModjyException, mx: - raise mx - except Exception, x: - raise ApplicationException(x) - finally: - if hasattr(app_return, 'close') and callable(app_return.close): - app_return.close() - - def init_impl(self): - self.do_j_env_params() - - def add_packages(self, package_list): - packages = [p.strip() for p in package_list.split(';')] - for p in packages: - self.log.info("Adding java package %s to jython" % p) - sys.add_package(p) - - def add_classdirs(self, classdir_list): - classdirs = [cd.strip() for cd in classdir_list.split(';')] - for cd in classdirs: - self.log.info("Adding directory %s to jython class file search path" % cd) - sys.add_classdir(cd) - - def add_extdirs(self, extdir_list): - extdirs = [ed.strip() for ed in extdir_list.split(';')] - for ed in extdirs: - self.log.info("Adding directory %s for .jars and .zips search path" % ed) - sys.add_extdir(self.expand_relative_path(ed)) - - def do_j_env_params(self): - if self.params['packages']: - self.add_packages(self.params['packages']) - if self.params['classdirs']: - self.add_classdirs(self.params['classdirs']) - if self.params['extdirs']: - self.add_extdirs(self.params['extdirs']) +### +# +# Copyright Alan Kennedy. +# +# You may contact the copyright holder at this uri: +# +# http://www.xhaus.com/contact/modjy +# +# The licence under which this code is released is the Apache License v2.0. +# +# The terms and conditions of this license are listed in a file contained +# in the distribution that also contained this file, under the name +# LICENSE.txt. +# +# You may also read a copy of the license at the following web address. +# +# http://modjy.xhaus.com/LICENSE.txt +# +### + +import types +import sys + +from modjy_exceptions import * + +class modjy_impl: + + def deal_with_app_return(self, environ, start_response_callable, app_return): + self.log.debug("Processing app return type: %s" % str(type(app_return))) + if isinstance(app_return, types.StringTypes): + raise ReturnNotIterable("Application returned object that was not an iterable: %s" % str(type(app_return))) + if type(app_return) is types.FileType: + pass # TBD: What to do here? can't call fileno() + if hasattr(app_return, '__len__') and callable(app_return.__len__): + expected_pieces = app_return.__len__() + else: + expected_pieces = -1 + try: + try: + ix = 0 + for next_piece in app_return: + if not isinstance(next_piece, types.StringTypes): + raise NonStringOutput("Application returned iterable containing non-strings: %s" % str(type(next_piece))) + if ix == 0: + # The application may have called start_response in the first iteration + if not start_response_callable.called: + raise StartResponseNotCalled("Start_response callable was never called.") + if not start_response_callable.content_length \ + and expected_pieces == 1 \ + and start_response_callable.write_callable.num_writes == 0: + # Take the length of the first piece + start_response_callable.set_content_length(len(next_piece)) + start_response_callable.write_callable(next_piece) + ix += 1 ... [truncated message content] |
From: <fwi...@us...> - 2009-10-23 19:10:31
|
Revision: 6890 http://jython.svn.sourceforge.net/jython/?rev=6890&view=rev Author: fwierzbicki Date: 2009-10-23 19:10:19 +0000 (Fri, 23 Oct 2009) Log Message: ----------- Need to up permgen for regrtest and hardcode indy options in jython shell to get regrtest to run well. Modified Paths: -------------- branches/indy/build.xml branches/indy/src/shell/jython Modified: branches/indy/build.xml =================================================================== --- branches/indy/build.xml 2009-10-23 06:01:53 UTC (rev 6889) +++ branches/indy/build.xml 2009-10-23 19:10:19 UTC (rev 6890) @@ -910,6 +910,9 @@ <target name="regrtest" depends="developer-build,regrtest-unix,regrtest-windows"/> <target name="regrtest-unix" if="os.family.unix"> <exec executable="${dist.dir}/bin/jython"> + <!-- XXX hopefully maxperm won't be necessary once indy matures --> + <arg value="-J-XX:MaxPermSize=128M"/> + <arg value="${dist.dir}/Lib/test/regrtest.py"/> <!-- Only run the tests that are expected to work on Jython --> <arg value="--expected"/> Modified: branches/indy/src/shell/jython =================================================================== --- branches/indy/src/shell/jython 2009-10-23 06:01:53 UTC (rev 6889) +++ branches/indy/src/shell/jython 2009-10-23 19:10:19 UTC (rev 6890) @@ -244,6 +244,9 @@ fi fi +#XXX Hard code --boot for indy for now. +boot_requested=true + if [ -n "$profile_requested" -o -z "$boot_requested" ] ; then [ -n "$profile_requested" ] && echo "Running with instrumented profiler" java_args=("${java_args[@]}" -classpath "$CP$CP_DELIMITER$CLASSPATH") @@ -259,7 +262,9 @@ JAVA_CMD=(echo $JAVA_CMD) fi -"${JAVA_CMD[@]}" $JAVA_OPTS "${java_args[@]}" -Dpython.home="$JYTHON_HOME" \ +#XXX Hard code indy options for now +_INDY_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+EnableInvokeDynamic" +"${JAVA_CMD[@]}" $JAVA_OPTS $_INDY_OPTS "${java_args[@]}" -Dpython.home="$JYTHON_HOME" \ -Dpython.executable="$PRG" org.python.util.jython $JYTHON_OPTS "$@" JYTHON_STATUS=$? This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |