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] |