You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(107) |
Dec
(67) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(76) |
Feb
(125) |
Mar
(72) |
Apr
(13) |
May
(18) |
Jun
(12) |
Jul
(129) |
Aug
(47) |
Sep
(1) |
Oct
(36) |
Nov
(128) |
Dec
(124) |
2002 |
Jan
(59) |
Feb
|
Mar
(14) |
Apr
(14) |
May
(72) |
Jun
(9) |
Jul
(3) |
Aug
(5) |
Sep
(18) |
Oct
(65) |
Nov
(28) |
Dec
(12) |
2003 |
Jan
(10) |
Feb
(2) |
Mar
(4) |
Apr
(33) |
May
(21) |
Jun
(9) |
Jul
(29) |
Aug
(34) |
Sep
(4) |
Oct
(8) |
Nov
(15) |
Dec
(4) |
2004 |
Jan
(26) |
Feb
(12) |
Mar
(11) |
Apr
(9) |
May
(7) |
Jun
|
Jul
(5) |
Aug
|
Sep
(3) |
Oct
(7) |
Nov
(1) |
Dec
(10) |
2005 |
Jan
(2) |
Feb
(72) |
Mar
(16) |
Apr
(39) |
May
(48) |
Jun
(97) |
Jul
(57) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(100) |
Dec
(24) |
2006 |
Jan
(15) |
Feb
(34) |
Mar
(33) |
Apr
(31) |
May
(79) |
Jun
(64) |
Jul
(41) |
Aug
(64) |
Sep
(31) |
Oct
(46) |
Nov
(55) |
Dec
(37) |
2007 |
Jan
(32) |
Feb
(61) |
Mar
(11) |
Apr
(58) |
May
(46) |
Jun
(30) |
Jul
(94) |
Aug
(93) |
Sep
(86) |
Oct
(69) |
Nov
(125) |
Dec
(177) |
2008 |
Jan
(169) |
Feb
(97) |
Mar
(74) |
Apr
(113) |
May
(120) |
Jun
(334) |
Jul
(215) |
Aug
(237) |
Sep
(72) |
Oct
(189) |
Nov
(126) |
Dec
(160) |
2009 |
Jan
(180) |
Feb
(45) |
Mar
(98) |
Apr
(140) |
May
(151) |
Jun
(71) |
Jul
(107) |
Aug
(119) |
Sep
(73) |
Oct
(121) |
Nov
(14) |
Dec
(6) |
2010 |
Jan
(13) |
Feb
(9) |
Mar
(10) |
Apr
(64) |
May
(3) |
Jun
(16) |
Jul
(7) |
Aug
(23) |
Sep
(17) |
Oct
(37) |
Nov
(5) |
Dec
(8) |
2011 |
Jan
(10) |
Feb
(11) |
Mar
(77) |
Apr
(11) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fwi...@us...> - 2009-08-02 19:56:45
|
Revision: 6624 http://jython.svn.sourceforge.net/jython/?rev=6624&view=rev Author: fwierzbicki Date: 2009-08-02 19:56:36 +0000 (Sun, 02 Aug 2009) Log Message: ----------- More redirects. Added Paths: ----------- trunk/website/redirects/docs/ trunk/website/redirects/docs/compile.txt trunk/website/redirects/docs/differences.txt trunk/website/redirects/docs/embedding.txt trunk/website/redirects/docs/index.txt trunk/website/redirects/docs/interpreter.txt trunk/website/redirects/docs/jarray.txt trunk/website/redirects/docs/jreload.txt trunk/website/redirects/docs/jythonc.txt trunk/website/redirects/docs/properties.txt trunk/website/redirects/docs/registry.txt trunk/website/redirects/docs/subclassing.txt trunk/website/redirects/docs/usejava.txt trunk/website/redirects/docs/whatis.txt trunk/website/redirects/docs/zxjdbc.txt Added: trunk/website/redirects/docs/compile.txt =================================================================== --- trunk/website/redirects/docs/compile.txt (rev 0) +++ trunk/website/redirects/docs/compile.txt 2009-08-02 19:56:36 UTC (rev 6624) @@ -0,0 +1,7 @@ +This page has been retired for versions of Jython older than 2.1. + +If you want the archived web page: + +`2.1 docs/compile`_ + +.. _2.1 docs/compile: ../archive/21/docs/compile.html Property changes on: trunk/website/redirects/docs/compile.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/website/redirects/docs/differences.txt =================================================================== --- trunk/website/redirects/docs/differences.txt (rev 0) +++ trunk/website/redirects/docs/differences.txt 2009-08-02 19:56:36 UTC (rev 6624) @@ -0,0 +1,7 @@ +This page has been retired for versions of Jython older than 2.1. + +If you want the archived web page: + +`2.1 docs/differences`_ + +.. _2.1 docs/differences: ../archive/21/docs/differences.html Property changes on: trunk/website/redirects/docs/differences.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/website/redirects/docs/embedding.txt =================================================================== --- trunk/website/redirects/docs/embedding.txt (rev 0) +++ trunk/website/redirects/docs/embedding.txt 2009-08-02 19:56:36 UTC (rev 6624) @@ -0,0 +1,7 @@ +This page has been retired for versions of Jython older than 2.1. + +If you want the archived web page: + +`2.1 docs/embedding`_ + +.. _2.1 docs/embedding: ../archive/21/docs/embedding.html Property changes on: trunk/website/redirects/docs/embedding.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/website/redirects/docs/index.txt =================================================================== --- trunk/website/redirects/docs/index.txt (rev 0) +++ trunk/website/redirects/docs/index.txt 2009-08-02 19:56:36 UTC (rev 6624) @@ -0,0 +1,7 @@ +This page has been retired for versions of Jython older than 2.1. + +If you want the archived web page: + +`2.1 docs/index`_ + +.. _2.1 docs/index: ../archive/21/docs/index.html Property changes on: trunk/website/redirects/docs/index.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/website/redirects/docs/interpreter.txt =================================================================== --- trunk/website/redirects/docs/interpreter.txt (rev 0) +++ trunk/website/redirects/docs/interpreter.txt 2009-08-02 19:56:36 UTC (rev 6624) @@ -0,0 +1,7 @@ +This page has been retired for versions of Jython older than 2.1. + +If you want the archived web page: + +`2.1 docs/interpreter`_ + +.. _2.1 docs/interpreter: ../archive/21/docs/interpreter.html Property changes on: trunk/website/redirects/docs/interpreter.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/website/redirects/docs/jarray.txt =================================================================== --- trunk/website/redirects/docs/jarray.txt (rev 0) +++ trunk/website/redirects/docs/jarray.txt 2009-08-02 19:56:36 UTC (rev 6624) @@ -0,0 +1,7 @@ +This page has been retired for versions of Jython older than 2.1. + +If you want the archived web page: + +`2.1 docs/jarray`_ + +.. _2.1 docs/jarray: ../archive/21/docs/jarray.html Property changes on: trunk/website/redirects/docs/jarray.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/website/redirects/docs/jreload.txt =================================================================== --- trunk/website/redirects/docs/jreload.txt (rev 0) +++ trunk/website/redirects/docs/jreload.txt 2009-08-02 19:56:36 UTC (rev 6624) @@ -0,0 +1,7 @@ +This page has been retired for versions of Jython older than 2.1. + +If you want the archived web page: + +`2.1 docs/jreload`_ + +.. _2.1 docs/jreload: ../archive/21/docs/jreload.html Property changes on: trunk/website/redirects/docs/jreload.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/website/redirects/docs/jythonc.txt =================================================================== --- trunk/website/redirects/docs/jythonc.txt (rev 0) +++ trunk/website/redirects/docs/jythonc.txt 2009-08-02 19:56:36 UTC (rev 6624) @@ -0,0 +1,7 @@ +This page has been retired for versions of Jython older than 2.1. + +If you want the archived web page: + +`2.1 docs/jythonc`_ + +.. _2.1 docs/jythonc: ../archive/21/docs/jythonc.html Property changes on: trunk/website/redirects/docs/jythonc.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/website/redirects/docs/properties.txt =================================================================== --- trunk/website/redirects/docs/properties.txt (rev 0) +++ trunk/website/redirects/docs/properties.txt 2009-08-02 19:56:36 UTC (rev 6624) @@ -0,0 +1,7 @@ +This page has been retired for versions of Jython older than 2.1. + +If you want the archived web page: + +`2.1 docs/properties`_ + +.. _2.1 docs/properties: ../archive/21/docs/properties.html Property changes on: trunk/website/redirects/docs/properties.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/website/redirects/docs/registry.txt =================================================================== --- trunk/website/redirects/docs/registry.txt (rev 0) +++ trunk/website/redirects/docs/registry.txt 2009-08-02 19:56:36 UTC (rev 6624) @@ -0,0 +1,7 @@ +This page has been retired for versions of Jython older than 2.1. + +If you want the archived web page: + +`2.1 docs/registry`_ + +.. _2.1 docs/registry: ../archive/21/docs/registry.html Property changes on: trunk/website/redirects/docs/registry.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/website/redirects/docs/subclassing.txt =================================================================== --- trunk/website/redirects/docs/subclassing.txt (rev 0) +++ trunk/website/redirects/docs/subclassing.txt 2009-08-02 19:56:36 UTC (rev 6624) @@ -0,0 +1,7 @@ +This page has been retired for versions of Jython older than 2.1. + +If you want the archived web page: + +`2.1 docs/subclassing`_ + +.. _2.1 docs/subclassing: ../archive/21/docs/subclassing.html Property changes on: trunk/website/redirects/docs/subclassing.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/website/redirects/docs/usejava.txt =================================================================== --- trunk/website/redirects/docs/usejava.txt (rev 0) +++ trunk/website/redirects/docs/usejava.txt 2009-08-02 19:56:36 UTC (rev 6624) @@ -0,0 +1,7 @@ +This page has been retired for versions of Jython older than 2.1. + +If you want the archived web page: + +`2.1 docs/usejava`_ + +.. _2.1 docs/usejava: ../archive/21/docs/usejava.html Property changes on: trunk/website/redirects/docs/usejava.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/website/redirects/docs/whatis.txt =================================================================== --- trunk/website/redirects/docs/whatis.txt (rev 0) +++ trunk/website/redirects/docs/whatis.txt 2009-08-02 19:56:36 UTC (rev 6624) @@ -0,0 +1,7 @@ +This page has been retired for versions of Jython older than 2.1. + +If you want the archived web page: + +`2.1 docs/whatis`_ + +.. _2.1 docs/whatis: ../archive/21/docs/whatis.html Property changes on: trunk/website/redirects/docs/whatis.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/website/redirects/docs/zxjdbc.txt =================================================================== --- trunk/website/redirects/docs/zxjdbc.txt (rev 0) +++ trunk/website/redirects/docs/zxjdbc.txt 2009-08-02 19:56:36 UTC (rev 6624) @@ -0,0 +1,7 @@ +This page has been retired for versions of Jython older than 2.1. + +If you want the archived web page: + +`2.1 docs/zxjdbc`_ + +.. _2.1 docs/zxjdbc: ../archive/21/docs/zxjdbc.html Property changes on: trunk/website/redirects/docs/zxjdbc.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision 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-08-02 17:13:24
|
Revision: 6623 http://jython.svn.sourceforge.net/jython/?rev=6623&view=rev Author: fwierzbicki Date: 2009-08-02 17:13:16 +0000 (Sun, 02 Aug 2009) Log Message: ----------- Moved the rest of the tests that could be moved from test_codeop_jy to test_codeop.py. Modified Paths: -------------- trunk/jython/Lib/test/test_codeop.py trunk/jython/Lib/test/test_codeop_jy.py Modified: trunk/jython/Lib/test/test_codeop.py =================================================================== --- trunk/jython/Lib/test/test_codeop.py 2009-08-02 00:09:03 UTC (rev 6622) +++ trunk/jython/Lib/test/test_codeop.py 2009-08-02 17:13:16 UTC (rev 6623) @@ -108,12 +108,26 @@ av("\n \na**3","eval") av("#a\n#b\na**3","eval") - # From Jython project, not Jython specific + av("\n\na = 1\n\n") + av("\n\nif 1: a=1\n\n") + + av("if 1:\n pass\n if 1:\n pass\n else:\n pass\n") + av("#a\n\n \na=3\n\n") + + av("\n\na**3","eval") + av("\n \na**3","eval") + av("#a\n#b\na**3","eval") + # this failed under Jython 2.2.1 - av("def x():\n try: pass\n finally: [a for a in (1,2)]\n") + av("def f():\n try: pass\n finally: [x for x in (1,2)]\n") + av("def f():\n pass\n#foo\n") + #XXX: works in CPython + if not is_jython: + av("@a.b.c\ndef f():\n pass\n") + def test_incomplete(self): ai = self.assertIncomplete @@ -155,8 +169,6 @@ ai("9+ \\","eval") ai("lambda z: \\","eval") - # From Jython project, not Jython specific - #Did not work in Jython 2.5rc2 see first issue in # http://bugs.jython.org/issue1354 ai("if True:\n if True:\n if True: \n") @@ -266,10 +278,11 @@ ai("a = 'a\\\n") ai("a = 1","eval") - #XXX: Current limitation in PythonPartial.g prevents this from properly - # erroring on Jython. + + # XXX: PythonPartial.g needs to reject this. if not is_jython: ai("a = (","eval") + ai("]","eval") ai("())","eval") ai("[}","eval") @@ -277,17 +290,30 @@ ai("lambda z:","eval") ai("a b","eval") - # From Jython project, not Jython specific ai("return 2.3") ai("if (a == 1 and b = 2): pass") + # XXX: PythonPartial.g needs to reject these. + if not is_jython: + ai("del 1") + ai("del ()") + ai("del (1,)") + ai("del [1]") + ai("del '1'") + ai("[i for i in range(10)] = (1, 2, 3)") + def test_filename(self): self.assertEquals(compile_command("a = 1\n", "abc").co_filename, compile("a = 1\n", "abc", 'single').co_filename) self.assertNotEquals(compile_command("a = 1\n", "abc").co_filename, compile("a = 1\n", "def", 'single').co_filename) + def test_no_universal_newlines(self): + # previously \r was translated due to universal newlines + code = compile_command("'\rfoo\r'", symbol='eval') + self.assertEqual(eval(code), '\rfoo\r') + def test_main(): run_unittest(CodeopTests) Modified: trunk/jython/Lib/test/test_codeop_jy.py =================================================================== --- trunk/jython/Lib/test/test_codeop_jy.py 2009-08-02 00:09:03 UTC (rev 6622) +++ trunk/jython/Lib/test/test_codeop_jy.py 2009-08-02 17:13:16 UTC (rev 6623) @@ -37,38 +37,25 @@ def test_valid(self): av = self.assertValid + # Failed for Jython 2.5a2. See http://bugs.jython.org/issue1116. + # For some reason this tests fails when run from test_codeops#test_valid + # when run from Jython (works in CPython). + av("@a.b.c\ndef f():\n pass") + + # These tests pass on Jython, but fail on CPython. Will need to investigate + # to decide if we need to match CPython. av("\n\n") av("# a\n") - av("\n\na = 1\n\n",values={'a':1}) - av("\n\nif 1: a=1\n\n",values={'a':1}) - - av("def x():\n pass") av("def x():\n pass\n ") av("def x():\n pass\n ") - av("\n\ndef x():\n pass") - - av("if 9==3:\n pass\nelse:\n pass") - av("if 1:\n pass\n if 1:\n pass\n else:\n pass") - av("#a\n\n \na=3\n",values={'a':3}) - - - # these failed under 2.1 - self.eval_d = {'a': 2} - av("\n\na**3","eval",value=8) - av("\n \na**3","eval",value=8) - av("#a\n#b\na**3","eval",value=8) - - # this failed under 2.2.1 - av("def f():\n try: pass\n finally: [x for x in (1,2)]") - - # Failed for Jython 2.5a2. See http://bugs.jython.org/issue1116. - av("@a.b.c\ndef f():\n pass") - av("def f():\n pass\n#foo") + # these tests fail in Jython in test_codeop.py because PythonPartial.g + # erroneously allows them through. Once that is fixed, these tests + # can be deleted. def test_invalid(self): ai = self.assertInvalid @@ -80,17 +67,8 @@ ai("[i for i in range(10)] = (1, 2, 3)") -class CodeopTests(unittest.TestCase): - - def test_no_universal_newlines(self): - # previously \r was translated due to universal newlines - code = codeop.compile_command("'\rfoo\r'", symbol='eval') - self.assertEqual(eval(code), '\rfoo\r') - - def test_main(): - run_unittest(CompileTests, - CodeopTests) + run_unittest(CompileTests) if __name__ == "__main__": This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2009-08-02 00:09:18
|
Revision: 6622 http://jython.svn.sourceforge.net/jython/?rev=6622&view=rev Author: nriley Date: 2009-08-02 00:09:03 +0000 (Sun, 02 Aug 2009) Log Message: ----------- Set python.home for javatest as well, so ScriptEngineIOTest works. Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2009-08-01 21:19:21 UTC (rev 6621) +++ trunk/jython/build.xml 2009-08-02 00:09:03 UTC (rev 6622) @@ -837,6 +837,7 @@ <mkdir dir="${junit.reports}"/> <junit fork="true" printsummary="true"> <formatter type="xml"/> + <sysproperty key="python.home" value="${dist.dir}"/> <classpath refid="test.classpath"/> <batchtest todir="${junit.reports}"> <fileset dir="${test.source.dir}" includes="**/*Test*.java"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-08-01 21:19:46
|
Revision: 6621 http://jython.svn.sourceforge.net/jython/?rev=6621&view=rev Author: pjenvey Date: 2009-08-01 21:19:21 +0000 (Sat, 01 Aug 2009) Log Message: ----------- no longer needed Modified Paths: -------------- trunk/jython/src/org/python/jsr223/PyScriptEngine.java Modified: trunk/jython/src/org/python/jsr223/PyScriptEngine.java =================================================================== --- trunk/jython/src/org/python/jsr223/PyScriptEngine.java 2009-08-01 21:15:59 UTC (rev 6620) +++ trunk/jython/src/org/python/jsr223/PyScriptEngine.java 2009-08-01 21:19:21 UTC (rev 6621) @@ -33,7 +33,6 @@ return eval(compileScript(script, context), context); } - @SuppressWarnings("deprecation") private Object eval(PyCode code, ScriptContext context) throws ScriptException { try { interp.setIn(context.getReader()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-08-01 21:16:08
|
Revision: 6620 http://jython.svn.sourceforge.net/jython/?rev=6620&view=rev Author: pjenvey Date: 2009-08-01 21:15:59 +0000 (Sat, 01 Aug 2009) Log Message: ----------- fix arg parsing I broke in r6611 Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/util/PyArgParser.java Modified: trunk/jython/src/com/ziclix/python/sql/util/PyArgParser.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/util/PyArgParser.java 2009-08-01 19:36:10 UTC (rev 6619) +++ trunk/jython/src/com/ziclix/python/sql/util/PyArgParser.java 2009-08-01 21:15:59 UTC (rev 6620) @@ -48,8 +48,8 @@ int largs = args.length; if (kws != null) { - for (String kw: kws) { - keywords.put(kw, args[--largs]); + for (int i = kws.length - 1; i >= 0; i--) { + keywords.put(kws[i], args[--largs]); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-08-01 19:36:30
|
Revision: 6619 http://jython.svn.sourceforge.net/jython/?rev=6619&view=rev Author: pjenvey Date: 2009-08-01 19:36:10 +0000 (Sat, 01 Aug 2009) Log Message: ----------- carry over nanoseconds in datetime to Timestamp conversions Modified Paths: -------------- trunk/jython/Lib/datetime.py Modified: trunk/jython/Lib/datetime.py =================================================================== --- trunk/jython/Lib/datetime.py 2009-07-31 19:20:24 UTC (rev 6618) +++ trunk/jython/Lib/datetime.py 2009-08-01 19:36:10 UTC (rev 6619) @@ -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) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2009-07-31 19:20:35
|
Revision: 6618 http://jython.svn.sourceforge.net/jython/?rev=6618&view=rev Author: nriley Date: 2009-07-31 19:20:24 +0000 (Fri, 31 Jul 2009) Log Message: ----------- stdin redirection for JSR 223 and PythonInterpreter, contributed by Jim White. Fixes #1408. Modified Paths: -------------- trunk/jython/src/org/python/core/PyFileWriter.java trunk/jython/src/org/python/jsr223/PyScriptEngine.java trunk/jython/src/org/python/util/PythonInterpreter.java Added Paths: ----------- trunk/jython/src/org/python/core/PyFileReader.java trunk/jython/tests/java/org/python/jsr223/ScriptEngineIOTest.java Added: trunk/jython/src/org/python/core/PyFileReader.java =================================================================== --- trunk/jython/src/org/python/core/PyFileReader.java (rev 0) +++ trunk/jython/src/org/python/core/PyFileReader.java 2009-07-31 19:20:24 UTC (rev 6618) @@ -0,0 +1,176 @@ +// A file-like object for reading from java.io.Reader objects; +// only to be used for stdin in PythonInterpreter#setIn(Reader) +// (for JSR 223 support) + +package org.python.core; + +import java.io.Reader; +import java.io.IOException; +import java.io.BufferedReader; + + +public class PyFileReader extends PyObject +{ + static final int DEFAULT_BUF_SIZE = 1024; + + private final BufferedReader reader; + private boolean closed; + + private char[] reuseableBuffer = null; + + public PyFileReader(Reader reader) + { + this.reader = (reader instanceof BufferedReader) ? (BufferedReader) reader : new BufferedReader(reader); + closed = false; + } + + public boolean closed() + { + return closed; + } + + public void checkClosed() + { + if (closed()) { + throw Py.ValueError("I/O operation on closed file"); + } + } + + public synchronized void flush() + { + checkClosed(); + } + + public void close() + { + try { + if (!closed()) { + reader.close(); + closed = true; + } + } catch (IOException e) { + throw Py.IOError(e); + } + } + + protected char[] needBuffer(int size) + { + if (reuseableBuffer == null) { + if (size > DEFAULT_BUF_SIZE) + return new char[size]; + + reuseableBuffer = new char[DEFAULT_BUF_SIZE]; + } + + if (size <= reuseableBuffer.length) + return reuseableBuffer; + + return new char[size]; + } + + public PyString read(int n) + { + if (n < 0) { + synchronized(reader) { + checkClosed(); + + final StringBuilder sb = new StringBuilder(); + + final char[] cbuf = needBuffer(DEFAULT_BUF_SIZE); + final int buflen = cbuf.length; + + while (true) { + try { + final int x = reader.read(cbuf, 0, buflen); + + if (x < 0) + break; + + sb.append(cbuf, 0, x); + + if (x < buflen) + break; + } catch (IOException e) { + throw Py.IOError(e); + } + } + + return new PyString(sb.toString()); + } + } + + synchronized(reader) { + checkClosed(); + + final char[] cbuf = needBuffer(n); + final int buflen = cbuf.length; + + try { + final int x = reader.read(cbuf, 0, n); + + if (x < 1) + return new PyString(""); + + return new PyString(new String(cbuf, 0, x)); + } catch (IOException e) { + throw Py.IOError(e); + } + } + } + + public PyString read() + { + return read(-1); + } + + public PyString readline(int max) + { + if (!(max < 0)) + throw Py.NotImplementedError("size argument to readline not implemented for PyFileReader"); + + synchronized (reader) { + try { + final String line = reader.readLine(); + + if (line == null) { + return new PyString(""); + } else { + return new PyString(line + "\n"); + } + } catch (IOException e) { + throw Py.IOError(e); + } + } + } + + public PyString readline() + { + return readline(-1); + } + + public PyObject readlines(final int sizehint) { + synchronized (reader) { + checkClosed(); + final PyList list = new PyList(); + int size = 0; + do { + final PyString line = readline(-1); + int len = line.string.length(); + if (len == 0) { + // EOF + break; + } + size += len; + list.append(line); + } while (sizehint <= 0 || size < sizehint); + + return list; + } + } + + public PyObject readlines() { + return readlines(0); + } + + +} Modified: trunk/jython/src/org/python/core/PyFileWriter.java =================================================================== --- trunk/jython/src/org/python/core/PyFileWriter.java 2009-07-31 19:20:05 UTC (rev 6617) +++ trunk/jython/src/org/python/core/PyFileWriter.java 2009-07-31 19:20:24 UTC (rev 6618) @@ -1,6 +1,6 @@ // A file-like object for writing to java.io.Writer objects; // only to be used for stdout, stderr in PythonInterpreter#setOut(Writer), #setErr(Writer) -// (for backwards compatibility) +// (for backwards compatibility and JSR 223 support) // // no attempts to close etc at shutdown are done for this object (unlike PyFile), // since again just for PythonInterpreter Modified: trunk/jython/src/org/python/jsr223/PyScriptEngine.java =================================================================== --- trunk/jython/src/org/python/jsr223/PyScriptEngine.java 2009-07-31 19:20:05 UTC (rev 6617) +++ trunk/jython/src/org/python/jsr223/PyScriptEngine.java 2009-07-31 19:20:24 UTC (rev 6618) @@ -36,6 +36,7 @@ @SuppressWarnings("deprecation") private Object eval(PyCode code, ScriptContext context) throws ScriptException { try { + interp.setIn(context.getReader()); interp.setOut(context.getWriter()); interp.setErr(context.getErrorWriter()); return interp.eval(code).__tojava__(Object.class); Modified: trunk/jython/src/org/python/util/PythonInterpreter.java =================================================================== --- trunk/jython/src/org/python/util/PythonInterpreter.java 2009-07-31 19:20:05 UTC (rev 6617) +++ trunk/jython/src/org/python/util/PythonInterpreter.java 2009-07-31 19:20:24 UTC (rev 6618) @@ -19,6 +19,7 @@ import org.python.core.PyStringMap; import org.python.core.PySystemState; import org.python.core.__builtin__; +import org.python.core.PyFileReader; /** * The PythonInterpreter class is a standard wrapper for a Jython interpreter for use embedding in a @@ -88,6 +89,30 @@ } /** + * Set the Python object to use for the standard input stream + * + * @param inStream + * Python file-like object to use as input stream + */ + public void setIn(PyObject inStream) { + systemState.stdin = inStream; + } + + public void setIn(java.io.Reader inStream) { + setIn(new PyFileReader(inStream)); + } + + /** + * Set a java.io.InputStream to use for the standard input stream + * + * @param inStream + * InputStream to use as input stream + */ + public void setIn(java.io.InputStream inStream) { + setIn(new PyFile(inStream)); + } + + /** * Set the Python object to use for the standard output stream * * @param outStream Added: trunk/jython/tests/java/org/python/jsr223/ScriptEngineIOTest.java =================================================================== --- trunk/jython/tests/java/org/python/jsr223/ScriptEngineIOTest.java (rev 0) +++ trunk/jython/tests/java/org/python/jsr223/ScriptEngineIOTest.java 2009-07-31 19:20:24 UTC (rev 6618) @@ -0,0 +1,81 @@ +package org.python.jsr223; + +import javax.script.ScriptEngine; +import javax.script.ScriptException; +import javax.script.ScriptEngineFactory; + +import junit.framework.TestCase; + +import java.io.StringReader; +import java.io.StringWriter; + +public class ScriptEngineIOTest extends TestCase +{ + ScriptEngineFactory pythonEngineFactory; + ScriptEngine pythonEngine; + + public void setUp() throws ScriptException + { + pythonEngineFactory = new PyScriptEngineFactory(); + pythonEngine = new PyScriptEngine(pythonEngineFactory); + } + + public void testEvalString() throws ScriptException + { + assertNull(pythonEngine.eval("x = 5")); + assertEquals(Integer.valueOf(5), pythonEngine.eval("x")); + } + + public void testReadline() throws ScriptException + { + final String testString = "Shazaam Batman!\n"; + + pythonEngine.getContext().setReader(new StringReader(testString)); + + assertNull(pythonEngine.eval("import sys")); + assertEquals(testString, pythonEngine.eval("sys.stdin.readline()")); + } + + public void testReadlines() throws ScriptException + { + final String testString = "Holy Smokes Batman!\nBIF!\r\n\nKAPOW!!!\rTHE END."; + + pythonEngine.getContext().setReader(new StringReader(testString)); + + assertNull(pythonEngine.eval("import sys")); + final Object o = pythonEngine.eval("''.join(sys.stdin.readlines())"); + + assertEquals("Holy Smokes Batman!\nBIF!\n\nKAPOW!!!\nTHE END.\n", o); + } + + public void testWriter() throws ScriptException + { + final StringWriter sw = new StringWriter(); + + pythonEngine.getContext().setWriter(sw); + + final String testString = "It is a wonderful world."; + + assertNull(pythonEngine.eval("print '" + testString + "',")); + assertEquals(testString, sw.toString()); + } + + public void testErrorWriter() throws ScriptException + { + final StringWriter stdout = new StringWriter(); + final StringWriter stderr = new StringWriter(); + + pythonEngine.getContext().setWriter(stdout); + pythonEngine.getContext().setErrorWriter(stderr); + + final String testString1 = "It is a wonderful world."; + final String testString2 = "Stuff happens!"; + + assertNull(pythonEngine.eval("import sys")); + assertNull(pythonEngine.eval("sys.stdout.write('" + testString1 + "')")); + assertNull(pythonEngine.eval("sys.stderr.write('" + testString2 + "')")); + + assertEquals(testString1, stdout.toString()); + assertEquals(testString2, stderr.toString()); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2009-07-31 19:20:11
|
Revision: 6617 http://jython.svn.sourceforge.net/jython/?rev=6617&view=rev Author: nriley Date: 2009-07-31 19:20:05 +0000 (Fri, 31 Jul 2009) Log Message: ----------- Set python.home for singlejavatest so ScriptEngineIOTest works. Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2009-07-31 19:19:56 UTC (rev 6616) +++ trunk/jython/build.xml 2009-07-31 19:20:05 UTC (rev 6617) @@ -822,6 +822,7 @@ <junit haltonfailure="true" fork="true"> <formatter type="brief" usefile="false"/> <sysproperty key="python.cachedir.skip" value="true"/> + <sysproperty key="python.home" value="${dist.dir}"/> <classpath refid="test.classpath"/> <batchtest> <fileset dir="${test.source.dir}" includes="**/${test}.java"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2009-07-31 19:20:03
|
Revision: 6616 http://jython.svn.sourceforge.net/jython/?rev=6616&view=rev Author: nriley Date: 2009-07-31 19:19:56 +0000 (Fri, 31 Jul 2009) Log Message: ----------- Make clear which encoding can't be found. Modified Paths: -------------- trunk/jython/src/org/python/core/codecs.java Modified: trunk/jython/src/org/python/core/codecs.java =================================================================== --- trunk/jython/src/org/python/core/codecs.java 2009-07-31 19:19:46 UTC (rev 6615) +++ trunk/jython/src/org/python/core/codecs.java 2009-07-31 19:19:56 UTC (rev 6616) @@ -79,7 +79,7 @@ if (searchPath.__len__() == 0) { throw new PyException(Py.LookupError, "no codec search functions registered: " + - "can't find encoding"); + "can't find encoding '" + encoding + "'"); } PyObject iter = searchPath.__iter__(); @@ -96,8 +96,8 @@ break; } if (func == null) { - throw new PyException(Py.LookupError, "unknown encoding " + - encoding); + throw new PyException(Py.LookupError, "unknown encoding '" + + encoding + "'"); } searchCache.__setitem__(v, result); return (PyTuple) result; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2009-07-31 19:19:55
|
Revision: 6615 http://jython.svn.sourceforge.net/jython/?rev=6615&view=rev Author: nriley Date: 2009-07-31 19:19:46 +0000 (Fri, 31 Jul 2009) Log Message: ----------- Undeprecate PythonInterpreter.set{Out,Err} since JSR 223 needs them. Modified Paths: -------------- trunk/jython/src/org/python/util/PythonInterpreter.java Modified: trunk/jython/src/org/python/util/PythonInterpreter.java =================================================================== --- trunk/jython/src/org/python/util/PythonInterpreter.java 2009-07-31 15:33:23 UTC (rev 6614) +++ trunk/jython/src/org/python/util/PythonInterpreter.java 2009-07-31 19:19:46 UTC (rev 6615) @@ -97,8 +97,6 @@ systemState.stdout = outStream; } - /** @deprecated */ - @Deprecated public void setOut(java.io.Writer outStream) { setOut(new PyFileWriter(outStream)); } @@ -117,8 +115,6 @@ systemState.stderr = outStream; } - /** @deprecated */ - @Deprecated public void setErr(java.io.Writer outStream) { setErr(new PyFileWriter(outStream)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-31 15:33:32
|
Revision: 6614 http://jython.svn.sourceforge.net/jython/?rev=6614&view=rev Author: fwierzbicki Date: 2009-07-31 15:33:23 +0000 (Fri, 31 Jul 2009) Log Message: ----------- Add @Overides, remove unused import, fix a shadowed variable. Modified Paths: -------------- trunk/jython/src/org/python/compiler/ClassFile.java trunk/jython/src/org/python/compiler/CodeCompiler.java trunk/jython/src/org/python/compiler/LineNumberTable.java trunk/jython/src/org/python/compiler/Module.java trunk/jython/src/org/python/compiler/SymInfo.java Modified: trunk/jython/src/org/python/compiler/ClassFile.java =================================================================== --- trunk/jython/src/org/python/compiler/ClassFile.java 2009-07-31 14:41:13 UTC (rev 6613) +++ trunk/jython/src/org/python/compiler/ClassFile.java 2009-07-31 15:33:23 UTC (rev 6614) @@ -2,7 +2,6 @@ package org.python.compiler; import java.io.ByteArrayOutputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-07-31 14:41:13 UTC (rev 6613) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-07-31 15:33:23 UTC (rev 6614) @@ -841,10 +841,10 @@ Future.checkFromFuture(node); // future stmt support setline(node); code.ldc(node.getInternalModule()); - java.util.List<alias> names = node.getInternalNames(); - if (names == null || names.size() == 0) { + java.util.List<alias> aliases = node.getInternalNames(); + if (aliases == null || aliases.size() == 0) { throw new ParseException("Internel parser error", node); - } else if (names.size() == 1 && names.get(0).getInternalName().equals("*")) { + } else if (aliases.size() == 1 && aliases.get(0).getInternalName().equals("*")) { if (node.getInternalLevel() > 0) { throw new ParseException("'import *' not allowed with 'from .'", node); } @@ -870,9 +870,9 @@ } else { java.util.List<String> fromNames = new ArrayList<String>();//[names.size()]; java.util.List<String> asnames = new ArrayList<String>();//[names.size()]; - for (int i = 0; i < names.size(); i++) { - fromNames.add(names.get(i).getInternalName()); - asnames.add(names.get(i).getInternalAsname()); + for (int i = 0; i < aliases.size(); i++) { + fromNames.add(aliases.get(i).getInternalName()); + asnames.add(aliases.get(i).getInternalAsname()); if (asnames.get(i) == null) asnames.set(i, fromNames.get(i)); } @@ -893,11 +893,11 @@ } code.invokestatic("org/python/core/imp", "importFrom", "(" + $str + $strArr + $pyFrame + "I" + ")" + $pyObjArr); int tmp = storeTop(); - for (int i = 0; i < names.size(); i++) { + for (int i = 0; i < aliases.size(); i++) { code.aload(tmp); code.iconst(i); code.aaload(); - set(new Name(names.get(i), asnames.get(i), expr_contextType.Store)); + set(new Name(aliases.get(i), asnames.get(i), expr_contextType.Store)); } code.freeLocal(tmp); } Modified: trunk/jython/src/org/python/compiler/LineNumberTable.java =================================================================== --- trunk/jython/src/org/python/compiler/LineNumberTable.java 2009-07-31 14:41:13 UTC (rev 6613) +++ trunk/jython/src/org/python/compiler/LineNumberTable.java 2009-07-31 15:33:23 UTC (rev 6614) @@ -7,7 +7,7 @@ import java.io.IOException; /** - * @Deprecated Not used. + * @Deprecated Not used. Delete in 2.6. */ public class LineNumberTable { int attName; Modified: trunk/jython/src/org/python/compiler/Module.java =================================================================== --- trunk/jython/src/org/python/compiler/Module.java 2009-07-31 14:41:13 UTC (rev 6613) +++ trunk/jython/src/org/python/compiler/Module.java 2009-07-31 15:33:23 UTC (rev 6614) @@ -451,7 +451,7 @@ int nparamcell = scope.jy_paramcells.size(); if(nparamcell > 0) { Map<String, SymInfo> tbl = scope.tbl; - List paramcells = scope.jy_paramcells; + List<String> paramcells = scope.jy_paramcells; for(int i = 0; i < nparamcell; i++) { c.aload(1); SymInfo syminf = tbl.get(paramcells.get(i)); Modified: trunk/jython/src/org/python/compiler/SymInfo.java =================================================================== --- trunk/jython/src/org/python/compiler/SymInfo.java 2009-07-31 14:41:13 UTC (rev 6613) +++ trunk/jython/src/org/python/compiler/SymInfo.java 2009-07-31 15:33:23 UTC (rev 6614) @@ -17,6 +17,7 @@ public int env_index; + @Override public String toString() { return "SymInfo[" + flags + " " + locals_index + " " + env_index + "]"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-31 14:41:29
|
Revision: 6613 http://jython.svn.sourceforge.net/jython/?rev=6613&view=rev Author: fwierzbicki Date: 2009-07-31 14:41:13 +0000 (Fri, 31 Jul 2009) Log Message: ----------- Added Override annotations. Modified Paths: -------------- trunk/jython/src/org/python/antlr/BaseParser.java trunk/jython/src/org/python/antlr/ParseException.java trunk/jython/src/org/python/antlr/PythonErrorNode.java trunk/jython/src/org/python/antlr/PythonTreeAdaptor.java trunk/jython/src/org/python/compiler/CodeCompiler.java Modified: trunk/jython/src/org/python/antlr/BaseParser.java =================================================================== --- trunk/jython/src/org/python/antlr/BaseParser.java 2009-07-31 05:02:10 UTC (rev 6612) +++ trunk/jython/src/org/python/antlr/BaseParser.java 2009-07-31 14:41:13 UTC (rev 6613) @@ -42,6 +42,7 @@ } + @Override public Token nextToken() { startPos = getCharPositionInLine(); return super.nextToken(); @@ -53,6 +54,7 @@ super(lexer); } + @Override public Token nextToken() { startPos = getCharPositionInLine(); return super.nextToken(); Modified: trunk/jython/src/org/python/antlr/ParseException.java =================================================================== --- trunk/jython/src/org/python/antlr/ParseException.java 2009-07-31 05:02:10 UTC (rev 6612) +++ trunk/jython/src/org/python/antlr/ParseException.java 2009-07-31 14:41:13 UTC (rev 6613) @@ -1,6 +1,5 @@ package org.python.antlr; -import org.python.antlr.PythonTree; import org.python.core.Py; import org.python.core.PyObject; Modified: trunk/jython/src/org/python/antlr/PythonErrorNode.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonErrorNode.java 2009-07-31 05:02:10 UTC (rev 6612) +++ trunk/jython/src/org/python/antlr/PythonErrorNode.java 2009-07-31 14:41:13 UTC (rev 6613) @@ -20,18 +20,22 @@ this.errorNode = errorNode; } + @Override public boolean isNil() { return errorNode.isNil(); } + @Override public int getAntlrType() { return errorNode.getType(); } + @Override public String getText() { return errorNode.getText(); } + @Override public String toString() { return errorNode.toString(); } Modified: trunk/jython/src/org/python/antlr/PythonTreeAdaptor.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTreeAdaptor.java 2009-07-31 05:02:10 UTC (rev 6612) +++ trunk/jython/src/org/python/antlr/PythonTreeAdaptor.java 2009-07-31 14:41:13 UTC (rev 6613) @@ -8,6 +8,7 @@ public class PythonTreeAdaptor extends CommonTreeAdaptor { + @Override public void setTokenBoundaries(Object t, Token startToken, Token stopToken) { if (t==null) { return; @@ -33,10 +34,12 @@ pt.setCharStopIndex(stopChar); } + @Override public Object create(Token token) { return new PythonTree(token); } + @Override public Object errorNode(TokenStream input, Token start, Token stop, RecognitionException e) { @@ -45,6 +48,7 @@ return t; } + @Override public Object dupNode(Object t) { if (t == null) { return null; @@ -52,16 +56,19 @@ return create(((PythonTree) t).getToken()); } + @Override public boolean isNil(Object tree) { return ((PythonTree)tree).isNil(); } + @Override public void addChild(Object t, Object child) { if ( t!=null && child!=null ) { ((PythonTree)t).addChild((PythonTree)child); } } + @Override public Object becomeRoot(Object newRoot, Object oldRoot) { //System.out.println("becomeroot new "+newRoot.toString()+" old "+oldRoot); PythonTree newRootTree = (PythonTree)newRoot; @@ -85,6 +92,7 @@ return newRootTree; } + @Override public Object rulePostProcessing(Object root) { //System.out.println("rulePostProcessing: "+((PythonTree)root).toStringTree()); PythonTree r = (PythonTree)root; @@ -102,6 +110,7 @@ return r; } + @Override public Object create(int tokenType, Token fromToken) { fromToken = createToken(fromToken); //((ClassicToken)fromToken).setType(tokenType); @@ -110,6 +119,7 @@ return t; } + @Override public Object create(int tokenType, Token fromToken, String text) { fromToken = createToken(fromToken); fromToken.setType(tokenType); @@ -118,33 +128,40 @@ return t; } + @Override public Object create(int tokenType, String text) { Token fromToken = createToken(tokenType, text); PythonTree t = (PythonTree)create(fromToken); return t; } + @Override public int getType(Object t) { ((PythonTree)t).getType(); return 0; } + @Override public String getText(Object t) { return ((PythonTree)t).getText(); } + @Override public Object getChild(Object t, int i) { return ((PythonTree)t).getChild(i); } + @Override public void setChild(Object t, int i, Object child) { ((PythonTree)t).setChild(i, (PythonTree)child); } + @Override public Object deleteChild(Object t, int i) { return ((PythonTree)t).deleteChild(i); } + @Override public int getChildCount(Object t) { return ((PythonTree)t).getChildCount(); } Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-07-31 05:02:10 UTC (rev 6612) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-07-31 14:41:13 UTC (rev 6613) @@ -89,8 +89,7 @@ import org.objectweb.asm.commons.Method; -public class CodeCompiler extends Visitor implements Opcodes, ClassConstants //, PythonGrammarTreeConstants -{ +public class CodeCompiler extends Visitor implements Opcodes, ClassConstants { public static final Object Exit=new Integer(1); public static final Object NoExit=null; @@ -127,13 +126,13 @@ public Stack<ExceptionHandler> exceptionHandlers; public Vector<Label> yields = new Vector<Label>(); - /* break/continue finally's level. - * This is the lowest level in the exceptionHandlers which should - * be executed at break or continue. - * It is saved/updated/restored when compiling loops. - * A similar level for returns is not needed because a new CodeCompiler - * is used for each PyCode, ie. each 'function'. - * When returning through finally's all the exceptionHandlers are executed. + /* + * break/continue finally's level. This is the lowest level in the + * exceptionHandlers which should be executed at break or continue. It is + * saved/updated/restored when compiling loops. A similar level for + * returns is not needed because a new CodeCompiler is used for each + * PyCode, in other words: each 'function'. When returning through + * finally's all the exceptionHandlers are executed. */ public int bcfLevel = 0; @@ -202,13 +201,11 @@ code.freeLocal(tmp); } - public void set(PythonTree node, int tmp) throws Exception { temporary = tmp; visit(node); } - private void saveAugTmps(PythonTree node, int count) throws Exception { if (count >= 4) { augtmp4 = code.getLocal("Lorg/python/core/PyObject;"); @@ -234,7 +231,6 @@ code.aload(augtmp4); } - private void restoreAugTmps(PythonTree node, int count) throws Exception { code.aload(augtmp1); code.freeLocal(augtmp1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-07-31 05:02:22
|
Revision: 6612 http://jython.svn.sourceforge.net/jython/?rev=6612&view=rev Author: pjenvey Date: 2009-07-31 05:02:10 +0000 (Fri, 31 Jul 2009) Log Message: ----------- quiet warnings Modified Paths: -------------- trunk/jython/src/org/python/jsr223/PyScriptEngine.java trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java Modified: trunk/jython/src/org/python/jsr223/PyScriptEngine.java =================================================================== --- trunk/jython/src/org/python/jsr223/PyScriptEngine.java 2009-07-31 05:01:54 UTC (rev 6611) +++ trunk/jython/src/org/python/jsr223/PyScriptEngine.java 2009-07-31 05:02:10 UTC (rev 6612) @@ -33,6 +33,7 @@ return eval(compileScript(script, context), context); } + @SuppressWarnings("deprecation") private Object eval(PyCode code, ScriptContext context) throws ScriptException { try { interp.setOut(context.getWriter()); Modified: trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java =================================================================== --- trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java 2009-07-31 05:01:54 UTC (rev 6611) +++ trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java 2009-07-31 05:02:10 UTC (rev 6612) @@ -85,6 +85,7 @@ return new PyScriptEngine(this); } + @SuppressWarnings("unchecked") public List<String> getMimeTypes() { return Collections.EMPTY_LIST; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-07-31 05:02:13
|
Revision: 6611 http://jython.svn.sourceforge.net/jython/?rev=6611&view=rev Author: pjenvey Date: 2009-07-31 05:01:54 +0000 (Fri, 31 Jul 2009) Log Message: ----------- quiet warnings, some coding standards Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/Fetch.java trunk/jython/src/com/ziclix/python/sql/PyExtendedCursor.java trunk/jython/src/com/ziclix/python/sql/util/PyArgParser.java trunk/jython/src/com/ziclix/python/sql/util/Queue.java Modified: trunk/jython/src/com/ziclix/python/sql/Fetch.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/Fetch.java 2009-07-31 04:52:17 UTC (rev 6610) +++ trunk/jython/src/com/ziclix/python/sql/Fetch.java 2009-07-31 05:01:54 UTC (rev 6611) @@ -79,7 +79,7 @@ /** * A list of warning listeners. */ - private List listeners; + private List<WarningListener> listeners; /** * Constructor Fetch @@ -92,7 +92,7 @@ this.rownumber = -1; this.description = Py.None; this.datahandler = datahandler; - this.listeners = new ArrayList(3); + this.listeners = new ArrayList<WarningListener>(3); } /** @@ -142,7 +142,7 @@ * @param resultSet * @param skipCols JDBC-indexed set of columns to be skipped */ - abstract public void add(ResultSet resultSet, Set skipCols); + abstract public void add(ResultSet resultSet, Set<Integer> skipCols); /** * Method add @@ -151,7 +151,8 @@ * @param procedure * @param params */ - abstract public void add(CallableStatement callableStatement, Procedure procedure, PyObject params); + abstract public void add(CallableStatement callableStatement, Procedure procedure, + PyObject params); /** * Fetch the next row of a query result set, returning a single sequence, @@ -253,7 +254,6 @@ * precision and scale are only available for numeric types */ protected PyObject createDescription(ResultSetMetaData meta) throws SQLException { - PyObject metadata = new PyList(); for (int i = 1; i <= meta.getColumnCount(); i++) { @@ -265,7 +265,6 @@ a[3] = Py.None; switch (meta.getColumnType(i)) { - case Types.BIGINT: case Types.BIT: case Types.DECIMAL: @@ -284,7 +283,6 @@ } a[6] = Py.newInteger(meta.isNullable(i)); - ((PyList) metadata).append(new PyTuple(a)); } @@ -299,7 +297,6 @@ * precision and scale are only available for numeric types */ protected PyObject createDescription(Procedure procedure) throws SQLException { - PyObject metadata = new PyList(); for (int i = 0, len = procedure.columns.__len__(); i < len; i++) { @@ -307,7 +304,6 @@ int colType = column.__getitem__(Procedure.COLUMN_TYPE).asInt(); switch (colType) { - case DatabaseMetaData.procedureColumnReturn: PyObject[] a = new PyObject[7]; @@ -317,7 +313,6 @@ a[3] = column.__getitem__(Procedure.LENGTH); switch (a[1].asInt()) { - case Types.BIGINT: case Types.BIT: case Types.DECIMAL: @@ -336,9 +331,7 @@ } int nullable = column.__getitem__(Procedure.NULLABLE).asInt(); - a[6] = (nullable == DatabaseMetaData.procedureNullable) ? Py.One : Py.Zero; - ((PyList) metadata).append(new PyTuple(a)); break; } @@ -356,8 +349,8 @@ * @return PyObject * @throws SQLException */ - protected PyObject createResults(CallableStatement callableStatement, Procedure procedure, PyObject params) throws SQLException { - + protected PyObject createResults(CallableStatement callableStatement, Procedure procedure, + PyObject params) throws SQLException { PyList results = new PyList(); for (int i = 0, j = 0, len = procedure.columns.__len__(); i < len; i++) { @@ -367,7 +360,6 @@ int dataType = column.__getitem__(Procedure.DATA_TYPE).asInt(); switch (colType) { - case DatabaseMetaData.procedureColumnIn: j++; break; @@ -399,9 +391,7 @@ } PyList ret = new PyList(); - ret.append(PyTuple.fromIterable(results)); - return ret; } @@ -413,13 +403,12 @@ * @return a list of tuples of the results * @throws SQLException */ - protected PyList createResults(ResultSet set, Set skipCols, PyObject metaData) throws SQLException { - + protected PyList createResults(ResultSet set, Set<Integer> skipCols, PyObject metaData) + throws SQLException { PyList res = new PyList(); while (set.next()) { PyObject tuple = createResult(set, skipCols, metaData); - res.append(tuple); } @@ -434,40 +423,36 @@ * @return a tuple of the results * @throws SQLException */ - protected PyTuple createResult(ResultSet set, Set skipCols, PyObject metaData) throws SQLException { - + protected PyTuple createResult(ResultSet set, Set<Integer> skipCols, PyObject metaData) + throws SQLException { int descriptionLength = metaData.__len__(); PyObject[] row = new PyObject[descriptionLength]; for (int i = 0; i < descriptionLength; i++) { - if ((skipCols != null) && skipCols.contains(new Integer(i + 1))) { + if (skipCols != null && skipCols.contains(i + 1)) { row[i] = Py.None; } else { int type = ((PyInteger) metaData.__getitem__(i).__getitem__(1)).getValue(); - row[i] = datahandler.getPyObject(set, i + 1, type); } } SQLWarning warning = set.getWarnings(); - if (warning != null) { fireWarning(warning); } - PyTuple tuple = new PyTuple(row); - - return tuple; + return new PyTuple(row); } protected void fireWarning(SQLWarning warning) { - WarningEvent event = new WarningEvent(this, warning); - for (int i = listeners.size() - 1; i >= 0; i--) { + for (WarningListener listener : listeners) { try { - ((WarningListener) listeners.get(i)).warning(event); + listener.warning(event); } catch (Throwable t) { + // ok } } } @@ -493,23 +478,21 @@ /** * Field results */ - protected List results; + protected List<PyObject> results; /** * Field descriptions */ - protected List descriptions; + protected List<PyObject> descriptions; /** * Construct a static fetch. The entire result set is iterated as it * is added and the result set is immediately closed. */ public StaticFetch(DataHandler datahandler) { - super(datahandler); - - this.results = new LinkedList(); - this.descriptions = new LinkedList(); + this.results = new LinkedList<PyObject>(); + this.descriptions = new LinkedList<PyObject>(); } /** @@ -517,6 +500,7 @@ * * @param resultSet */ + @Override public void add(ResultSet resultSet) { this.add(resultSet, null); } @@ -527,10 +511,10 @@ * @param resultSet * @param skipCols */ - public void add(ResultSet resultSet, Set skipCols) { - + @Override + public void add(ResultSet resultSet, Set<Integer> skipCols) { try { - if ((resultSet != null) && (resultSet.getMetaData() != null)) { + if (resultSet != null && resultSet.getMetaData() != null) { PyObject metadata = this.createDescription(resultSet.getMetaData()); PyObject result = this.createResults(resultSet, skipCols, metadata); @@ -538,10 +522,10 @@ this.descriptions.add(metadata); // we want the rowcount of the first result set - this.rowcount = ((PyObject) this.results.get(0)).__len__(); + this.rowcount = this.results.get(0).__len__(); // we want the description of the first result set - this.description = ((PyObject) this.descriptions.get(0)); + this.description = this.descriptions.get(0); // set the current rownumber this.rownumber = 0; @@ -565,8 +549,8 @@ * @param procedure * @param params */ + @Override public void add(CallableStatement callableStatement, Procedure procedure, PyObject params) { - try { PyObject result = this.createResults(callableStatement, procedure, params); @@ -575,10 +559,10 @@ this.descriptions.add(this.createDescription(procedure)); // we want the rowcount of the first result set - this.rowcount = ((PyObject) this.results.get(0)).__len__(); + this.rowcount = this.results.get(0).__len__(); // we want the description of the first result set - this.description = ((PyObject) this.descriptions.get(0)); + this.description = this.descriptions.get(0); // set the current rownumber this.rownumber = 0; @@ -601,6 +585,7 @@ * @return a sequence of sequences from the result set, or an empty sequence when * no more data is available */ + @Override public PyObject fetchall() { return fetchmany(this.rowcount); } @@ -627,21 +612,22 @@ * @return a sequence of sequences from the result set, or an empty sequence when * no more data is available */ + @Override public PyObject fetchmany(int size) { - - if ((results == null) || (results.size() == 0)) { + if (results == null || results.size() == 0) { throw zxJDBC.makeException(zxJDBC.DatabaseError, "no results"); } PyObject res = new PyList(); - PyObject current = (PyObject) results.get(0); + PyObject current = results.get(0); if (size <= 0) { size = this.rowcount; } if (this.rownumber < this.rowcount) { - res = current.__getslice__(Py.newInteger(this.rownumber), Py.newInteger(this.rownumber + size), Py.One); + res = current.__getslice__(Py.newInteger(this.rownumber), + Py.newInteger(this.rownumber + size), Py.One); this.rownumber += size; } @@ -654,8 +640,8 @@ * @param value * @param mode 'relative' or 'absolute' */ + @Override public void scroll(int value, String mode) { - int pos; if ("relative".equals(mode)) { @@ -663,10 +649,11 @@ } else if ("absolute".equals(mode)) { pos = value; } else { - throw zxJDBC.makeException(zxJDBC.ProgrammingError, "invalid cursor scroll mode [" + mode + "]"); + throw zxJDBC.makeException(zxJDBC.ProgrammingError, "invalid cursor scroll mode [" + + mode + "]"); } - if ((pos >= 0) && (pos < this.rowcount)) { + if (pos >= 0 && pos < this.rowcount) { this.rownumber = pos; } else { throw zxJDBC.makeException(Py.IndexError, "cursor index [" + pos + "] out of range"); @@ -678,32 +665,30 @@ * * @return true if more sets exist, else None */ + @Override public PyObject nextset() { - PyObject next = Py.None; - if ((results != null) && (results.size() > 1)) { + if (results != null && results.size() > 1) { this.results.remove(0); this.descriptions.remove(0); - next = (PyObject) this.results.get(0); - this.description = (PyObject) this.descriptions.get(0); + next = this.results.get(0); + this.description = this.descriptions.get(0); this.rowcount = next.__len__(); this.rownumber = 0; } - return (next == Py.None) ? Py.None : Py.One; + return next == Py.None ? Py.None : Py.One; } /** * Remove the results. */ + @Override public void close() throws SQLException { - super.close(); - this.rownumber = -1; - this.results.clear(); } } @@ -720,7 +705,7 @@ /** * Field skipCols */ - protected Set skipCols; + protected Set<Integer> skipCols; /** * Field resultSet @@ -741,6 +726,7 @@ * at any one time. Since this is a dynamic iteration, it precludes * the addition of more than one result set. */ + @Override public void add(ResultSet resultSet) { add(resultSet, null); } @@ -752,14 +738,14 @@ * at any one time. Since this is a dynamic iteration, it precludes * the addition of more than one result set. */ - public void add(ResultSet resultSet, Set skipCols) { - + @Override + public void add(ResultSet resultSet, Set<Integer> skipCols) { if (this.resultSet != null) { throw zxJDBC.makeException(zxJDBC.getString("onlyOneResultSet")); } try { - if ((resultSet != null) && (resultSet.getMetaData() != null)) { + if (resultSet != null && resultSet.getMetaData() != null) { if (this.description == Py.None) { this.description = this.createDescription(resultSet.getMetaData()); } @@ -787,13 +773,16 @@ * @param procedure * @param params */ + @Override public void add(CallableStatement callableStatement, Procedure procedure, PyObject params) { - throw zxJDBC.makeException(zxJDBC.NotSupportedError, zxJDBC.getString("nocallprocsupport")); + throw zxJDBC.makeException(zxJDBC.NotSupportedError, + zxJDBC.getString("nocallprocsupport")); } /** * Iterate the remaining contents of the ResultSet and return. */ + @Override public PyObject fetchall() { return fetch(0, true); } @@ -801,6 +790,7 @@ /** * Iterate up to size rows remaining in the ResultSet and return. */ + @Override public PyObject fetchmany(int size) { return fetch(size, false); } @@ -812,7 +802,6 @@ * the set. */ private PyObject fetch(int size, boolean all) { - PyList res = new PyList(); if (this.resultSet == null) { @@ -822,14 +811,15 @@ try { all = (size < 0) ? true : all; - while (((size-- > 0) || all) && this.resultSet.next()) { + while ((size-- > 0 || all) && this.resultSet.next()) { PyTuple tuple = createResult(this.resultSet, this.skipCols, this.description); res.append(tuple); this.rowcount++; this.rownumber = this.resultSet.getRow(); } } catch (AbstractMethodError e) { - throw zxJDBC.makeException(zxJDBC.NotSupportedError, zxJDBC.getString("nodynamiccursors")); + throw zxJDBC.makeException(zxJDBC.NotSupportedError, + zxJDBC.getString("nodynamiccursors")); } catch (PyException e) { throw e; } catch (Throwable e) { @@ -842,6 +832,7 @@ /** * Always returns None. */ + @Override public PyObject nextset() { return Py.None; } @@ -852,12 +843,12 @@ * @param value * @param mode */ + @Override public void scroll(int value, String mode) { - try { int type = this.resultSet.getType(); - if ((type != ResultSet.TYPE_FORWARD_ONLY) || (value > 0)) { + if (type != ResultSet.TYPE_FORWARD_ONLY || value > 0) { if ("relative".equals(mode)) { if (value < 0) { value = Math.abs(this.rownumber + value); @@ -866,29 +857,33 @@ } } else if ("absolute".equals(mode)) { if (value < 0) { - throw zxJDBC.makeException(Py.IndexError, "cursor index [" + value + "] out of range"); + throw zxJDBC.makeException(Py.IndexError, "cursor index [" + value + + "] out of range"); } } else { - throw zxJDBC.makeException(zxJDBC.ProgrammingError, "invalid cursor scroll mode [" + mode + "]"); + throw zxJDBC.makeException(zxJDBC.ProgrammingError, + "invalid cursor scroll mode [" + mode + "]"); } if (value == 0) { this.resultSet.beforeFirst(); } else { if (!this.resultSet.absolute(value)) { - throw zxJDBC.makeException(Py.IndexError, "cursor index [" + value + "] out of range"); + throw zxJDBC.makeException(Py.IndexError, "cursor index [" + value + + "] out of range"); } } // since .rownumber is the *next* row, then the JDBC value suits us fine this.rownumber = this.resultSet.getRow(); } else { - String msg = "dynamic result set of type [" + type + "] does not support scrolling"; - + String msg = "dynamic result set of type [" + type + + "] does not support scrolling"; throw zxJDBC.makeException(zxJDBC.NotSupportedError, msg); } } catch (AbstractMethodError e) { - throw zxJDBC.makeException(zxJDBC.NotSupportedError, zxJDBC.getString("nodynamiccursors")); + throw zxJDBC.makeException(zxJDBC.NotSupportedError, + zxJDBC.getString("nodynamiccursors")); } catch (SQLException e) { throw zxJDBC.makeException(e); } catch (Throwable t) { @@ -899,8 +894,8 @@ /** * Close the underlying ResultSet. */ + @Override public void close() throws SQLException { - super.close(); if (this.resultSet == null) { Modified: trunk/jython/src/com/ziclix/python/sql/PyExtendedCursor.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/PyExtendedCursor.java 2009-07-31 04:52:17 UTC (rev 6610) +++ trunk/jython/src/com/ziclix/python/sql/PyExtendedCursor.java 2009-07-31 05:01:54 UTC (rev 6611) @@ -14,7 +14,6 @@ import java.util.Set; import org.python.core.Py; import org.python.core.PyBuiltinMethodSet; -import org.python.core.PyClass; import org.python.core.PyList; import org.python.core.PyObject; import org.python.core.PyString; @@ -86,7 +85,8 @@ * @param rsType * @param rsConcur */ - PyExtendedCursor(PyConnection connection, boolean dynamicFetch, PyObject rsType, PyObject rsConcur) { + PyExtendedCursor(PyConnection connection, boolean dynamicFetch, PyObject rsType, + PyObject rsConcur) { super(connection, dynamicFetch, rsType, rsConcur); } @@ -95,6 +95,7 @@ * * @return a string representation of the object. */ + @Override public String toString() { return "<PyExtendedCursor object instance at " + Py.id(this) + ">"; } @@ -105,7 +106,6 @@ * @param dict */ static public void classDictInit(PyObject dict) { - PyCursor.classDictInit(dict); dict.__setitem__("__version__", Py.newString("$Revision$").__getslice__(Py.newInteger(11), Py.newInteger(-2), null)); dict.__setitem__("tables", new ExtendedCursorFunc("tables", 100, 4, 4, "query for table information")); @@ -131,8 +131,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 ("__methods__".equals(name)) { return __methods__; } else if ("__members__".equals(name)) { @@ -153,7 +153,6 @@ * @param type */ protected void tables(PyObject qualifier, PyObject owner, PyObject table, PyObject type) { - clear(); String q = getMetaDataName(qualifier); @@ -197,7 +196,6 @@ * @param column */ protected void columns(PyObject qualifier, PyObject owner, PyObject table, PyObject column) { - clear(); String q = getMetaDataName(qualifier); @@ -220,7 +218,6 @@ * @param procedure */ protected void procedures(PyObject qualifier, PyObject owner, PyObject procedure) { - clear(); String q = getMetaDataName(qualifier); @@ -242,8 +239,8 @@ * @param procedure * @param column */ - protected void procedurecolumns(PyObject qualifier, PyObject owner, PyObject procedure, PyObject column) { - + protected void procedurecolumns(PyObject qualifier, PyObject owner, PyObject procedure, + PyObject column) { clear(); String q = getMetaDataName(qualifier); @@ -296,8 +293,9 @@ * @param foreignOwner * @param foreignTable */ - protected void foreignkeys(PyObject primaryQualifier, PyObject primaryOwner, PyObject primaryTable, PyObject foreignQualifier, PyObject foreignOwner, PyObject foreignTable) { - + protected void foreignkeys(PyObject primaryQualifier, PyObject primaryOwner, + PyObject primaryTable, PyObject foreignQualifier, + PyObject foreignOwner, PyObject foreignTable) { clear(); String pq = getMetaDataName(primaryQualifier); @@ -324,14 +322,13 @@ * @param unique * @param accuracy */ - protected void statistics(PyObject qualifier, PyObject owner, PyObject table, PyObject unique, PyObject accuracy) { - + protected void statistics(PyObject qualifier, PyObject owner, PyObject table, PyObject unique, + PyObject accuracy) { clear(); - Set skipCols = new HashSet(); + Set<Integer> skipCols = new HashSet<Integer>(); + skipCols.add(12); - skipCols.add(new Integer(12)); - String q = getMetaDataName(qualifier); String o = getMetaDataName(owner); String t = getMetaDataName(table); @@ -351,14 +348,12 @@ * @param type data type for which to provide information */ protected void typeinfo(PyObject type) { - clear(); - Set skipCols = new HashSet(); + Set<Integer> skipCols = new HashSet<Integer>(); + skipCols.add(16); + skipCols.add(17); - skipCols.add(new Integer(16)); - skipCols.add(new Integer(17)); - try { this.fetch.add(getMetaData().getTypeInfo(), skipCols); } catch (SQLException e) { @@ -384,7 +379,6 @@ * Gets a description of possible table types. */ protected void tabletypeinfo() { - clear(); try { @@ -403,7 +397,6 @@ * @param table */ protected void bestrow(PyObject qualifier, PyObject owner, PyObject table) { - clear(); String c = getMetaDataName(qualifier); @@ -428,7 +421,6 @@ * @param table a table name */ protected void versioncolumns(PyObject qualifier, PyObject owner, PyObject table) { - clear(); String q = getMetaDataName(qualifier); @@ -449,7 +441,6 @@ * @return String */ protected String getMetaDataName(PyObject name) { - if (name == Py.None) { return null; } @@ -481,20 +472,17 @@ super(name, index, minargs, maxargs, doc, PyExtendedCursor.class); } + @Override public PyObject __call__() { - PyExtendedCursor cursor = (PyExtendedCursor) __self__; switch (index) { - case 107: cursor.typeinfo(Py.None); - return Py.None; case 108: cursor.tabletypeinfo(); - return Py.None; default : @@ -502,15 +490,13 @@ } } + @Override public PyObject __call__(PyObject arga) { - PyExtendedCursor cursor = (PyExtendedCursor) __self__; switch (index) { - case 107: cursor.typeinfo(arga); - return Py.None; default : @@ -518,80 +504,68 @@ } } + @Override public PyObject __call__(PyObject arga, PyObject argb, PyObject argc) { - PyExtendedCursor cursor = (PyExtendedCursor) __self__; switch (index) { - case 102: cursor.primarykeys(arga, argb, argc); - return Py.None; case 104: cursor.procedures(arga, argb, argc); - return Py.None; case 109: cursor.bestrow(arga, argb, argc); - return Py.None; case 110: cursor.versioncolumns(arga, argb, argc); - return Py.None; - default : + default: throw info.unexpectedCall(3, false); } } + @Override public PyObject fancyCall(PyObject[] args) { - PyExtendedCursor cursor = (PyExtendedCursor) __self__; switch (index) { - case 103: cursor.foreignkeys(args[0], args[1], args[2], args[3], args[4], args[5]); - return Py.None; case 106: cursor.statistics(args[0], args[1], args[2], args[3], args[4]); - return Py.None; - default : + default: throw info.unexpectedCall(args.length, true); } } + @Override public PyObject __call__(PyObject arg1, PyObject arg2, PyObject arg3, PyObject arg4) { - PyExtendedCursor cursor = (PyExtendedCursor) __self__; switch (index) { - case 100: cursor.tables(arg1, arg2, arg3, arg4); - return Py.None; case 101: cursor.columns(arg1, arg2, arg3, arg4); - return Py.None; case 105: cursor.procedurecolumns(arg1, arg2, arg3, arg4); - return Py.None; - default : + default: throw info.unexpectedCall(4, false); } } Modified: trunk/jython/src/com/ziclix/python/sql/util/PyArgParser.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/util/PyArgParser.java 2009-07-31 04:52:17 UTC (rev 6610) +++ trunk/jython/src/com/ziclix/python/sql/util/PyArgParser.java 2009-07-31 05:01:54 UTC (rev 6611) @@ -22,24 +22,18 @@ */ public class PyArgParser extends Object { - /** - * Field keywords - */ - protected Map keywords; + /** Field keywords. */ + protected Map<String, PyObject> keywords; - /** - * Field arguments - */ + /** Field arguments. */ protected PyObject[] arguments; /** * Construct a parser with the arguments and keywords. */ public PyArgParser(PyObject[] args, String[] kws) { - - this.keywords = new HashMap(); - this.arguments = null; - + keywords = new HashMap<String, PyObject>(); + arguments = null; parse(args, kws); } @@ -50,33 +44,31 @@ * @param kws */ protected void parse(PyObject[] args, String[] kws) { - // walk backwards through the kws and build the map int largs = args.length; if (kws != null) { - for (int i = kws.length - 1; i >= 0; i--) { - keywords.put(kws[i], args[--largs]); + for (String kw: kws) { + keywords.put(kw, args[--largs]); } } - this.arguments = new PyObject[largs]; - - System.arraycopy(args, 0, this.arguments, 0, largs); + arguments = new PyObject[largs]; + System.arraycopy(args, 0, arguments, 0, largs); } /** * How many keywords? */ public int numKw() { - return this.keywords.keySet().size(); + return keywords.keySet().size(); } /** * Does the keyword exist? */ public boolean hasKw(String kw) { - return this.keywords.containsKey(kw); + return keywords.containsKey(kw); } /** @@ -84,12 +76,11 @@ * not exist. */ public PyObject kw(String kw) { - if (!hasKw(kw)) { throw Py.KeyError(kw); } - return (PyObject) this.keywords.get(kw); + return keywords.get(kw); } /** @@ -97,35 +88,33 @@ * not exist. */ public PyObject kw(String kw, PyObject def) { - if (!hasKw(kw)) { return def; } - return (PyObject) this.keywords.get(kw); + return keywords.get(kw); } /** * Get the array of keywords. */ public String[] kws() { - return (String[]) this.keywords.keySet().toArray(new String[0]); + return keywords.keySet().toArray(new String[0]); } /** * Get the number of arguments. */ public int numArg() { - return this.arguments.length; + return arguments.length; } /** * Return the argument at the given index, raise an IndexError if out of range. */ public PyObject arg(int index) { - - if ((index >= 0) && (index <= this.arguments.length - 1)) { - return this.arguments[index]; + if (index >= 0 && index <= arguments.length - 1) { + return arguments[index]; } throw Py.IndexError("index out of range"); @@ -135,9 +124,8 @@ * Return the argument at the given index, or the default if the index is out of range. */ public PyObject arg(int index, PyObject def) { - - if ((index >= 0) && (index <= this.arguments.length - 1)) { - return this.arguments[index]; + if (index >= 0 && index <= arguments.length - 1) { + return arguments[index]; } return def; Modified: trunk/jython/src/com/ziclix/python/sql/util/Queue.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/util/Queue.java 2009-07-31 04:52:17 UTC (rev 6610) +++ trunk/jython/src/com/ziclix/python/sql/util/Queue.java 2009-07-31 05:01:54 UTC (rev 6611) @@ -28,7 +28,7 @@ /** * Field queue */ - protected LinkedList queue; + protected LinkedList<Object> queue; /** * Field capacity, threshold @@ -49,7 +49,7 @@ this.closed = false; this.capacity = capacity; - this.queue = new LinkedList(); + this.queue = new LinkedList<Object>(); this.threshold = (int) (this.capacity * 0.75f); } @@ -57,7 +57,6 @@ * Enqueue an object and notify all waiting Threads. */ public synchronized void enqueue(Object element) throws InterruptedException { - if (closed) { throw new QueueClosedException(); } @@ -81,7 +80,6 @@ * Blocks until an object is dequeued or the queue is closed. */ public synchronized Object dequeue() throws InterruptedException { - while (this.queue.size() <= 0) { this.wait(); @@ -104,9 +102,7 @@ * Close the queue and notify all waiting Threads. */ public synchronized void close() { - this.closed = true; - this.notifyAll(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-07-31 04:52:42
|
Revision: 6610 http://jython.svn.sourceforge.net/jython/?rev=6610&view=rev Author: pjenvey Date: 2009-07-31 04:52:17 +0000 (Fri, 31 Jul 2009) Log Message: ----------- o read CLOBs into unicode instead of str o cleanup the DataHandler.read and have them close their input Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/DataHandler.java trunk/jython/src/com/ziclix/python/sql/JDBC20DataHandler.java trunk/jython/src/com/ziclix/python/sql/handler/InformixDataHandler.java trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java Modified: trunk/jython/src/com/ziclix/python/sql/DataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/DataHandler.java 2009-07-30 15:11:03 UTC (rev 6609) +++ trunk/jython/src/com/ziclix/python/sql/DataHandler.java 2009-07-31 04:52:17 UTC (rev 6610) @@ -14,6 +14,7 @@ import org.python.core.PyList; import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.Reader; @@ -48,7 +49,7 @@ */ public class DataHandler { - // default size for buffers + /** Default size for buffers. */ private static final int INITIAL_SIZE = 1024 * 4; private static final String[] SYSTEM_DATAHANDLERS = { @@ -153,7 +154,8 @@ * @param type the <i>java.sql.Types</i> for which this PyObject should be bound * @throws SQLException */ - public void setJDBCObject(PreparedStatement stmt, int index, PyObject object, int type) throws SQLException { + public void setJDBCObject(PreparedStatement stmt, int index, PyObject object, int type) + throws SQLException { try { if (checkNull(stmt, index, object, type)) { return; @@ -163,19 +165,16 @@ case Types.DATE: Date date = (Date) object.__tojava__(Date.class); - stmt.setDate(index, date); break; case Types.TIME: Time time = (Time) object.__tojava__(Time.class); - stmt.setTime(index, time); break; case Types.TIMESTAMP: Timestamp timestamp = (Timestamp) object.__tojava__(Timestamp.class); - stmt.setTimestamp(index, timestamp); break; @@ -203,7 +202,8 @@ break; } } catch (Exception e) { - SQLException cause = null, ex = new SQLException("error setting index [" + index + "], type [" + type + "]"); + SQLException cause = null, ex = new SQLException("error setting index [" + index + + "], type [" + type + "]"); if (e instanceof SQLException) { cause = (SQLException) e; @@ -212,7 +212,6 @@ } ex.setNextException(cause); - throw ex; } } @@ -229,7 +228,6 @@ * @throws SQLException if the type is unmappable */ public PyObject getPyObject(ResultSet set, int col, int type) throws SQLException { - PyObject obj = Py.None; switch (type) { @@ -309,7 +307,7 @@ throw new SQLException(msg); } - return (set.wasNull() || (obj == null)) ? Py.None : obj; + return set.wasNull() || obj == null ? Py.None : obj; } /** @@ -322,7 +320,6 @@ * @throws SQLException if the type is unmappable */ public PyObject getPyObject(CallableStatement stmt, int col, int type) throws SQLException { - PyObject obj = Py.None; switch (type) { @@ -331,14 +328,12 @@ case Types.VARCHAR: case Types.LONGVARCHAR: String string = stmt.getString(col); - obj = (string == null) ? Py.None : Py.newUnicode(string); break; case Types.NUMERIC: case Types.DECIMAL: BigDecimal bd = stmt.getBigDecimal(col); - obj = (bd == null) ? Py.None : Py.newFloat(bd.doubleValue()); break; @@ -398,7 +393,7 @@ throw new SQLException(msg); } - return (stmt.wasNull() || (obj == null)) ? Py.None : obj; + return stmt.wasNull() || obj == null ? Py.None : obj; } /** @@ -414,7 +409,8 @@ * @throws SQLException * */ - public void registerOut(CallableStatement statement, int index, int colType, int dataType, String dataTypeName) throws SQLException { + public void registerOut(CallableStatement statement, int index, int colType, int dataType, + String dataTypeName) throws SQLException { try { statement.registerOutParameter(index, dataType); @@ -439,7 +435,8 @@ * * @return true if the object is null and was set on the statement, false otherwise */ - public static final boolean checkNull(PreparedStatement stmt, int index, PyObject object, int type) throws SQLException { + public static final boolean checkNull(PreparedStatement stmt, int index, PyObject object, + int type) throws SQLException { if ((object == null) || (Py.None == object)) { stmt.setNull(index, type); @@ -449,54 +446,57 @@ } /** - * Since the driver needs to the know the length of all streams, - * read it into a byte[] array. + * Consume the InputStream into an byte array and close the InputStream. * - * @return the stream as a byte[] + * @return the contents of the InputStream a byte[] */ public static final byte[] read(InputStream stream) { + int size = 0; + byte[] buffer = new byte[INITIAL_SIZE]; + ByteArrayOutputStream baos = new ByteArrayOutputStream(INITIAL_SIZE); - int b = -1, read = 0; - byte[] results = new byte[INITIAL_SIZE]; - try { - while ((b = stream.read()) != -1) { - if (results.length < (read + 1)) { - byte[] tmp = results; - results = new byte[results.length * 2]; - System.arraycopy(tmp, 0, results, 0, tmp.length); - } - results[read++] = (byte) b; + while ((size = stream.read(buffer)) != -1) { + baos.write(buffer, 0, size); } - } catch (IOException e) { - throw zxJDBC.makeException(e); + } catch (IOException ioe) { + throw zxJDBC.makeException(ioe); + } finally { + try { + stream.close(); + } catch (IOException ioe) { + throw zxJDBC.makeException(ioe); + } } - byte[] tmp = results; - results = new byte[read]; - System.arraycopy(tmp, 0, results, 0, read); - return results; + return baos.toByteArray(); } /** - * Read all the chars from the Reader into the String. + * Consume the Reader into a String and close the Reader. * - * @return the contents of the Reader in a String + * @return the contents of the Reader as a String */ - public static final String read(Reader reader) { + public static String read(Reader reader) { + int size = 0; + char[] buffer = new char[INITIAL_SIZE]; + StringBuilder builder = new StringBuilder(INITIAL_SIZE); - int c = 0; - StringBuffer buffer = new StringBuffer(INITIAL_SIZE); - try { - while ((c = reader.read()) != -1) { - buffer.append((char) c); + while ((size = reader.read(buffer)) != -1) { + builder.append(buffer, 0, size); } - } catch (IOException e) { - throw zxJDBC.makeException(e); + } catch (IOException ioe) { + throw zxJDBC.makeException(ioe); + } finally { + try { + reader.close(); + } catch (IOException ioe) { + throw zxJDBC.makeException(ioe); + } } - return buffer.toString(); + return builder.toString(); } /** @@ -509,8 +509,8 @@ for (String element : SYSTEM_DATAHANDLERS) { try { - Class c = Class.forName(element); - Constructor cons = c.getConstructor(new Class[]{DataHandler.class}); + Class<?> c = Class.forName(element); + Constructor<?> cons = c.getConstructor(new Class<?>[]{DataHandler.class}); dh = (DataHandler) cons.newInstance(new Object[]{dh}); } catch (Throwable t) {} } @@ -530,6 +530,7 @@ /** * Returns the classname of this datahandler. */ + @Override public String toString() { return getClass().getName(); } Modified: trunk/jython/src/com/ziclix/python/sql/JDBC20DataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/JDBC20DataHandler.java 2009-07-30 15:11:03 UTC (rev 6609) +++ trunk/jython/src/com/ziclix/python/sql/JDBC20DataHandler.java 2009-07-31 04:52:17 UTC (rev 6610) @@ -9,10 +9,8 @@ package com.ziclix.python.sql; import java.io.BufferedInputStream; -import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.io.InputStreamReader; import java.io.Reader; import java.math.BigDecimal; import java.sql.Array; @@ -92,7 +90,7 @@ // it really is unfortunate that I need to send the length of the stream if (jobject instanceof InputStream) { - lob = DataHandler.read(new BufferedInputStream((InputStream) jobject)); + lob = read((InputStream) jobject); } else if (jobject instanceof byte[]) { lob = (byte[]) jobject; } @@ -135,60 +133,13 @@ break; case Types.CLOB: - - /* - * It seems some drivers (well at least Informix) don't clean up after themselves - * if the Clob is requested. The engine keeps a handle to an open table for each - * row requested and cleans up fully only when the ResultSet or Connection is closed. - * While this generally will never be noticed because the number of CLOBs or BLOBs - * queried will likely be small in the event a large number are queried, it is a huge - * problem. So, handle it as low as possible by managing the stream directly. I've - * decided to leave this in the generic JDBC20 handler because it works for all engines - * I've tested and seems to perform quite well to boot. - */ - Reader reader = null; - - try { - InputStream stream = set.getBinaryStream(col); - - if (stream == null) { - obj = Py.None; - } else { - reader = new InputStreamReader(stream); - reader = new BufferedReader(reader); - obj = Py.newString(DataHandler.read(reader)); - } - } finally { - if (reader != null) { - try { - reader.close(); - } catch (Exception e) { - } - } - } + Reader reader = set.getCharacterStream(col); + obj = reader == null ? Py.None : Py.newUnicode(read(reader)); break; case Types.BLOB: Blob blob = set.getBlob(col); - - if (blob == null) { - obj = Py.None; - } else { - InputStream stream = null; - - try { - stream = blob.getBinaryStream(); - stream = new BufferedInputStream(stream); - obj = Py.java2py(DataHandler.read(stream)); - } finally { - if (stream != null) { - try { - stream.close(); - } catch (Exception e) { - } - } - } - } + obj = blob == null ? Py.None : Py.java2py(read(blob.getBinaryStream())); break; case Types.ARRAY: Modified: trunk/jython/src/com/ziclix/python/sql/handler/InformixDataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/handler/InformixDataHandler.java 2009-07-30 15:11:03 UTC (rev 6609) +++ trunk/jython/src/com/ziclix/python/sql/handler/InformixDataHandler.java 2009-07-31 04:52:17 UTC (rev 6610) @@ -8,12 +8,10 @@ */ package com.ziclix.python.sql.handler; +import com.informix.jdbc.IfmxStatement; + import com.ziclix.python.sql.DataHandler; import com.ziclix.python.sql.FilterDataHandler; -import org.python.core.Py; -import org.python.core.PyFile; -import org.python.core.PyObject; -import org.python.core.PyString; import java.io.InputStream; import java.sql.Blob; @@ -23,6 +21,11 @@ import java.sql.Statement; import java.sql.Types; +import org.python.core.Py; +import org.python.core.PyFile; +import org.python.core.PyObject; +import org.python.core.PyString; + /** * Informix specific data handling. * @@ -48,12 +51,11 @@ * @return PyObject * @throws SQLException */ + @Override public PyObject getRowId(Statement stmt) throws SQLException { - - if (stmt instanceof com.informix.jdbc.IfmxStatement) { - return Py.newInteger(((com.informix.jdbc.IfmxStatement) stmt).getSerial()); + if (stmt instanceof IfmxStatement) { + return Py.newInteger(((IfmxStatement) stmt).getSerial()); } - return super.getRowId(stmt); } @@ -66,8 +68,9 @@ * @param type * @throws SQLException */ - public void setJDBCObject(PreparedStatement stmt, int index, PyObject object, int type) throws SQLException { - + @Override + public void setJDBCObject(PreparedStatement stmt, int index, PyObject object, int type) + throws SQLException { if (DataHandler.checkNull(stmt, index, object, type)) { return; } @@ -105,9 +108,11 @@ * @param object * @throws SQLException */ - public void setJDBCObject(PreparedStatement stmt, int index, PyObject object) throws SQLException { - - // there is a bug in the Ifx driver when using setObject() with a String for a prepared statement + @Override + public void setJDBCObject(PreparedStatement stmt, int index, PyObject object) + throws SQLException { + // there is a bug in the Ifx driver when using setObject() with a String for a + // prepared statement if (object instanceof PyString) { super.setJDBCObject(stmt, index, object, Types.VARCHAR); } else { @@ -125,6 +130,7 @@ * @throws SQLException thrown for a sql exception */ @SuppressWarnings("fallthrough") + @Override public PyObject getPyObject(ResultSet set, int col, int type) throws SQLException { PyObject obj = Py.None; @@ -133,7 +139,6 @@ case Types.OTHER: try { - // informix returns boolean as OTHERs, so let's give that a try obj = set.getBoolean(col) ? Py.One : Py.Zero; } catch (SQLException e) { @@ -145,33 +150,15 @@ int major = set.getStatement().getConnection().getMetaData().getDriverMajorVersion(); int minor = set.getStatement().getConnection().getMetaData().getDriverMinorVersion(); - if ((major <= 2) && (minor <= 11)) { + if (major <= 2 && minor <= 11) { Blob blob = set.getBlob(col); - - if (blob == null) { - obj = Py.None; - } else { - InputStream is = null; - - try { - - // the available() bug means we CANNOT buffer this stream - is = blob.getBinaryStream(); - obj = Py.java2py(DataHandler.read(is)); - } finally { - try { - is.close(); - } catch (Exception e) { - } - } - } - + obj = blob == null ? Py.None : Py.java2py(read(blob.getBinaryStream())); break; } default : obj = super.getPyObject(set, col, type); } - return (set.wasNull() || (obj == null)) ? Py.None : obj; + return set.wasNull() || obj == null ? Py.None : obj; } } Modified: trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java 2009-07-30 15:11:03 UTC (rev 6609) +++ trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java 2009-07-31 04:52:17 UTC (rev 6610) @@ -48,18 +48,18 @@ * @param name * @return String */ + @Override public String getMetaDataName(PyObject name) { - String metaName = super.getMetaDataName(name); - return (metaName == null) ? null : metaName.toUpperCase(); } /** * Provide functionality for Oracle specific types, such as ROWID. */ - public void setJDBCObject(PreparedStatement stmt, int index, PyObject object, int type) throws SQLException { - + @Override + public void setJDBCObject(PreparedStatement stmt, int index, PyObject object, int type) + throws SQLException { if (DataHandler.checkNull(stmt, index, object, type)) { return; } @@ -102,22 +102,15 @@ /** * Provide functionality for Oracle specific types, such as ROWID. */ + @Override public PyObject getPyObject(ResultSet set, int col, int type) throws SQLException { - PyObject obj = Py.None; switch (type) { case Types.BLOB: BLOB blob = ((OracleResultSet) set).getBLOB(col); - - if (blob == null) { - return Py.None; - } - - InputStream stream = new BufferedInputStream(blob.getBinaryStream()); - - obj = Py.java2py(DataHandler.read(stream)); + obj = blob == null ? Py.None : Py.java2py(read(blob.getBinaryStream())); break; case OracleTypes.ROWID: @@ -132,7 +125,7 @@ obj = super.getPyObject(set, col, type); } - return (set.wasNull() ? Py.None : obj); + return set.wasNull() ? Py.None : obj; } /** @@ -146,7 +139,9 @@ * @param dataTypeName the JDBC datatype name * @throws SQLException */ - public void registerOut(CallableStatement statement, int index, int colType, int dataType, String dataTypeName) throws SQLException { + @Override + public void registerOut(CallableStatement statement, int index, int colType, int dataType, + String dataTypeName) throws SQLException { if (dataType == Types.OTHER) { if ("REF CURSOR".equals(dataTypeName)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-30 15:11:10
|
Revision: 6609 http://jython.svn.sourceforge.net/jython/?rev=6609&view=rev Author: fwierzbicki Date: 2009-07-30 15:11:03 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Excercise all of the partial valid sentences that I can think of to avoid screwing up things like "try:" in the future. Modified Paths: -------------- trunk/jython/Lib/test/test_codeop.py Modified: trunk/jython/Lib/test/test_codeop.py =================================================================== --- trunk/jython/Lib/test/test_codeop.py 2009-07-30 14:46:38 UTC (rev 6608) +++ trunk/jython/Lib/test/test_codeop.py 2009-07-30 15:11:03 UTC (rev 6609) @@ -161,6 +161,18 @@ # http://bugs.jython.org/issue1354 ai("if True:\n if True:\n if True: \n") + ai("@a(") + ai("@a(b") + ai("@a(b,") + ai("@a(b,c") + ai("@a(b,c,") + + ai("from a import (") + ai("from a import (b") + ai("from a import (b,") + ai("from a import (b,c") + ai("from a import (b,c,") + ai("["); ai("[a"); ai("[a,"); @@ -183,6 +195,14 @@ ai("a(b,c") ai("a(b,c,") + ai("a[") + ai("a[b") + ai("a[b,") + ai("a[b:") + ai("a[b:c") + ai("a[b:c:") + ai("a[b:c:d") + ai("def a(") ai("def a(b") ai("def a(b,") @@ -195,11 +215,37 @@ ai("(a,b") ai("(a,b,") + ai("if a:\n pass\nelif b:") + ai("if a:\n pass\nelif b:\n pass\nelse:") + + ai("while a:") + ai("while a:\n pass\nelse:") + + ai("for a in b:") + ai("for a in b:\n pass\nelse:") + ai("try:") ai("try:\n pass\nexcept:") ai("try:\n pass\nfinally:") ai("try:\n pass\nexcept:\n pass\nfinally:") + ai("with a:") + ai("with a as b:") + + ai("class a:") + ai("class a(") + ai("class a(b") + ai("class a(b,") + ai("class a():") + + ai("[x for") + ai("[x for x in") + ai("[x for x in (") + + ai("(x for") + ai("(x for x in") + ai("(x for x in (") + def test_invalid(self): ai = self.assertInvalid ai("a b") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-30 14:46:49
|
Revision: 6608 http://jython.svn.sourceforge.net/jython/?rev=6608&view=rev Author: fwierzbicki Date: 2009-07-30 14:46:38 +0000 (Thu, 30 Jul 2009) Log Message: ----------- As CPython trunk: assert_ -> assertTrue Modified Paths: -------------- trunk/jython/Lib/test/test_codeop.py Modified: trunk/jython/Lib/test/test_codeop.py =================================================================== --- trunk/jython/Lib/test/test_codeop.py 2009-07-30 14:42:55 UTC (rev 6607) +++ trunk/jython/Lib/test/test_codeop.py 2009-07-30 14:46:38 UTC (rev 6608) @@ -23,7 +23,7 @@ '''succeed iff str is a valid piece of code''' if is_jython: code = compile_command(str, "<input>", symbol) - self.assert_(code) + self.assertTrue(code) if symbol == "single": d,r = {},{} saved_stdout = sys.stdout @@ -52,9 +52,9 @@ compile_command(str,symbol=symbol) self.fail("No exception thrown for invalid code") except SyntaxError: - self.assert_(is_syntax) + self.assertTrue(is_syntax) except OverflowError: - self.assert_(not is_syntax) + self.assertTrue(not is_syntax) def test_valid(self): av = self.assertValid This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-30 14:43:05
|
Revision: 6607 http://jython.svn.sourceforge.net/jython/?rev=6607&view=rev Author: fwierzbicki Date: 2009-07-30 14:42:55 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Statement "try:" was not working in interactive mode. Added tests for the basic try: partial sentences. Modified Paths: -------------- trunk/jython/Lib/test/test_codeop.py trunk/jython/grammar/PythonPartial.g Modified: trunk/jython/Lib/test/test_codeop.py =================================================================== --- trunk/jython/Lib/test/test_codeop.py 2009-07-30 14:36:21 UTC (rev 6606) +++ trunk/jython/Lib/test/test_codeop.py 2009-07-30 14:42:55 UTC (rev 6607) @@ -195,6 +195,11 @@ ai("(a,b") ai("(a,b,") + ai("try:") + ai("try:\n pass\nexcept:") + ai("try:\n pass\nfinally:") + ai("try:\n pass\nexcept:\n pass\nfinally:") + def test_invalid(self): ai = self.assertInvalid ai("a b") Modified: trunk/jython/grammar/PythonPartial.g =================================================================== --- trunk/jython/grammar/PythonPartial.g 2009-07-30 14:36:21 UTC (rev 6606) +++ trunk/jython/grammar/PythonPartial.g 2009-07-30 14:42:55 UTC (rev 6607) @@ -522,7 +522,7 @@ : TRY COLON suite ( except_clause+ (ORELSE COLON suite)? (FINALLY COLON suite)? | FINALLY COLON suite - ) + )? ; //with_stmt: 'with' test [ with_var ] ':' suite This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-30 14:36:26
|
Revision: 6606 http://jython.svn.sourceforge.net/jython/?rev=6606&view=rev Author: fwierzbicki Date: 2009-07-30 14:36:21 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Beefing up tests for partial sentences in interactive mode. Modified Paths: -------------- trunk/jython/Lib/test/test_codeop.py Modified: trunk/jython/Lib/test/test_codeop.py =================================================================== --- trunk/jython/Lib/test/test_codeop.py 2009-07-30 14:31:06 UTC (rev 6605) +++ trunk/jython/Lib/test/test_codeop.py 2009-07-30 14:36:21 UTC (rev 6606) @@ -161,6 +161,40 @@ # http://bugs.jython.org/issue1354 ai("if True:\n if True:\n if True: \n") + ai("["); + ai("[a"); + ai("[a,"); + ai("[a,b"); + ai("[a,b,"); + + ai("{"); + ai("{a"); + ai("{a:"); + ai("{a:b"); + ai("{a:b,"); + ai("{a:b,c"); + ai("{a:b,c:"); + ai("{a:b,c:d"); + ai("{a:b,c:d,"); + + ai("a(") + ai("a(b") + ai("a(b,") + ai("a(b,c") + ai("a(b,c,") + + ai("def a(") + ai("def a(b") + ai("def a(b,") + ai("def a(b,c") + ai("def a(b,c,") + + ai("(") + ai("(a") + ai("(a,") + ai("(a,b") + ai("(a,b,") + def test_invalid(self): ai = self.assertInvalid ai("a b") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-30 14:31:18
|
Revision: 6605 http://jython.svn.sourceforge.net/jython/?rev=6605&view=rev Author: fwierzbicki Date: 2009-07-30 14:31:06 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Moved a few tests from test_codeop_jy to test_codeop as they are valid for both CPython and Jython. Prepping to push these and a few more upstream to CPython. Modified Paths: -------------- trunk/jython/Lib/test/test_codeop.py trunk/jython/Lib/test/test_codeop_jy.py Modified: trunk/jython/Lib/test/test_codeop.py =================================================================== --- trunk/jython/Lib/test/test_codeop.py 2009-07-30 12:09:14 UTC (rev 6604) +++ trunk/jython/Lib/test/test_codeop.py 2009-07-30 14:31:06 UTC (rev 6605) @@ -108,6 +108,12 @@ av("\n \na**3","eval") av("#a\n#b\na**3","eval") + # From Jython project, not Jython specific + + # this failed under Jython 2.2.1 + av("def x():\n try: pass\n finally: [a for a in (1,2)]\n") + + def test_incomplete(self): ai = self.assertIncomplete @@ -149,6 +155,8 @@ ai("9+ \\","eval") ai("lambda z: \\","eval") + # From Jython project, not Jython specific + #Did not work in Jython 2.5rc2 see first issue in # http://bugs.jython.org/issue1354 ai("if True:\n if True:\n if True: \n") @@ -184,6 +192,10 @@ ai("lambda z:","eval") ai("a b","eval") + # From Jython project, not Jython specific + ai("return 2.3") + ai("if (a == 1 and b = 2): pass") + def test_filename(self): self.assertEquals(compile_command("a = 1\n", "abc").co_filename, compile("a = 1\n", "abc", 'single').co_filename) Modified: trunk/jython/Lib/test/test_codeop_jy.py =================================================================== --- trunk/jython/Lib/test/test_codeop_jy.py 2009-07-30 12:09:14 UTC (rev 6604) +++ trunk/jython/Lib/test/test_codeop_jy.py 2009-07-30 14:31:06 UTC (rev 6605) @@ -49,9 +49,6 @@ av("def x():\n pass\n ") av("\n\ndef x():\n pass") - # this failed under 2.2.1 - av("def x():\n try: pass\n finally: [a for a in (1,2)]\n") - av("if 9==3:\n pass\nelse:\n pass") av("if 1:\n pass\n if 1:\n pass\n else:\n pass") @@ -75,13 +72,11 @@ def test_invalid(self): ai = self.assertInvalid - ai("return 2.3") ai("del 1") ai("del ()") ai("del (1,)") ai("del [1]") ai("del '1'") - ai("if (a == 1 and b = 2): pass") ai("[i for i in range(10)] = (1, 2, 3)") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-30 12:09:22
|
Revision: 6604 http://jython.svn.sourceforge.net/jython/?rev=6604&view=rev Author: fwierzbicki Date: 2009-07-30 12:09:14 +0000 (Thu, 30 Jul 2009) Log Message: ----------- More compiler warning fixes. Modified Paths: -------------- trunk/jython/src/org/python/antlr/PythonTree.java trunk/jython/src/org/python/compiler/Module.java trunk/jython/src/org/python/compiler/ScopesCompiler.java trunk/jython/src/org/python/core/PyList.java Modified: trunk/jython/src/org/python/antlr/PythonTree.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTree.java 2009-07-30 04:40:15 UTC (rev 6603) +++ trunk/jython/src/org/python/antlr/PythonTree.java 2009-07-30 12:09:14 UTC (rev 6604) @@ -202,7 +202,7 @@ buf.append(' '); } for (int i = 0; children != null && i < children.size(); i++) { - PythonTree t = (PythonTree)children.get(i); + PythonTree t = children.get(i); if (i > 0) { buf.append(' '); } @@ -269,7 +269,7 @@ public PythonTree getFirstChildWithType(int type) { for (int i = 0; children!=null && i < children.size(); i++) { - PythonTree t = (PythonTree) children.get(i); + PythonTree t = children.get(i); if ( t.getAntlrType()==type ) { return t; } @@ -306,7 +306,7 @@ if ( this.children!=null ) { // must copy, this has children already int n = childTree.children.size(); for (int i = 0; i < n; i++) { - PythonTree c = (PythonTree)childTree.children.get(i); + PythonTree c = childTree.children.get(i); this.children.add(c); // handle double-link stuff for each child of nil root c.setParent(this); @@ -335,7 +335,7 @@ /** 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 = (PythonTree) kids.get(i); + PythonTree t = kids.get(i); addChild(t); } } @@ -359,7 +359,7 @@ if ( children==null ) { return null; } - PythonTree killed = (PythonTree)children.remove(i); + PythonTree killed = children.remove(i); // walk rest and decrement their child indexes this.freshenParentAndChildIndexes(i); return killed; @@ -398,7 +398,7 @@ if ( delta == 0 ) { int j = 0; // index into new children for (int i=startChildIndex; i<=stopChildIndex; i++) { - PythonTree child = (PythonTree)newChildren.get(j); + PythonTree child = newChildren.get(j); children.set(i, child); child.setParent(this); child.setChildIndex(i); @@ -413,7 +413,7 @@ int indexToDelete = startChildIndex+numNewChildren; for (int c=indexToDelete; c<=stopChildIndex; c++) { // delete same index, shifting everybody down each time - PythonTree killed = (PythonTree)children.remove(indexToDelete); + PythonTree killed = children.remove(indexToDelete); } freshenParentAndChildIndexes(startChildIndex); } Modified: trunk/jython/src/org/python/compiler/Module.java =================================================================== --- trunk/jython/src/org/python/compiler/Module.java 2009-07-30 04:40:15 UTC (rev 6603) +++ trunk/jython/src/org/python/compiler/Module.java 2009-07-30 12:09:14 UTC (rev 6604) @@ -332,7 +332,7 @@ Hashtable<Constant,Constant> constants; private Constant findConstant(Constant c) { - Constant ret = (Constant)constants.get(c); + Constant ret = constants.get(c); if (ret != null) return ret; ret = c; @@ -620,7 +620,7 @@ public String getFilename() { return sfilename; } public ScopeInfo getScopeInfo(PythonTree node) { - return (ScopeInfo) scopes.get(node); + return scopes.get(node); } public void error(String msg,boolean err,PythonTree node) Modified: trunk/jython/src/org/python/compiler/ScopesCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/ScopesCompiler.java 2009-07-30 04:40:15 UTC (rev 6603) +++ trunk/jython/src/org/python/compiler/ScopesCompiler.java 2009-07-30 12:09:14 UTC (rev 6604) @@ -66,7 +66,7 @@ level--; ScopeInfo up = null; if (!scopes.empty()) { - up = (ScopeInfo) scopes.pop(); + up = scopes.pop(); } //Go into the stack to find a non class containing scope to use making the closure //See PEP 227 @@ -74,7 +74,7 @@ ScopeInfo referenceable = up; for (int i = scopes.size() - 1; i >= 0 && referenceable.kind == CLASSSCOPE; i--, dist++) { - referenceable = ((ScopeInfo) scopes.get(i)); + referenceable = (scopes.get(i)); } cur.cook(referenceable, dist, code_compiler); cur.dump(); // debug Modified: trunk/jython/src/org/python/core/PyList.java =================================================================== --- trunk/jython/src/org/python/core/PyList.java 2009-07-30 04:40:15 UTC (rev 6603) +++ trunk/jython/src/org/python/core/PyList.java 2009-07-30 12:09:14 UTC (rev 6604) @@ -287,7 +287,7 @@ if (list instanceof ArrayList) { ((ArrayList) list).ensureCapacity(newSize); } - List oldList = new ArrayList<PyObject>(list); + List<PyObject> oldList = new ArrayList<PyObject>(list); for (int i = 1; i < count; i++) { list.addAll(oldList); } @@ -1152,7 +1152,7 @@ stop = start; } int n = sliceLength(start, stop, step); - List newList; + List<PyObject> newList; if (step == 1) { newList = new ArrayList<PyObject>(list.subList(start, stop)); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-30 04:40:23
|
Revision: 6603 http://jython.svn.sourceforge.net/jython/?rev=6603&view=rev Author: fwierzbicki Date: 2009-07-30 04:40:15 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Oops, created new cast warnings in compiler package, fixed. Also fixed some of the warnings in the antlr package, but things are a little tricky there. Modified Paths: -------------- trunk/jython/src/org/python/antlr/GrammarActions.java trunk/jython/src/org/python/antlr/PythonTokenSource.java trunk/jython/src/org/python/antlr/PythonTree.java trunk/jython/src/org/python/compiler/CodeCompiler.java trunk/jython/src/org/python/compiler/Module.java Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2009-07-30 04:11:55 UTC (rev 6602) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2009-07-30 04:40:15 UTC (rev 6603) @@ -217,7 +217,7 @@ return new For(t, target, iter, b, o); } - stmt makeTryExcept(Token t, List body, List handlers, List orelse, List finBody) { + stmt makeTryExcept(Token t, List body, List<excepthandler> handlers, List orelse, List finBody) { List<stmt> b = castStmts(body); List<excepthandler> e = handlers; List<stmt> o = castStmts(orelse); @@ -695,7 +695,7 @@ if (isTuple) { List<slice> st; - List etypes = new ArrayList(); + List<expr> etypes = new ArrayList<expr>(); for (Object o : sltypes) { if (o instanceof Index) { Index i = (Index)o; @@ -706,8 +706,7 @@ } } if (!extslice) { - List<expr> es = etypes; - expr t = new Tuple(begin, es, expr_contextType.Load); + expr t = new Tuple(begin, etypes, expr_contextType.Load); s = new Index(begin, t); } } else if (sltypes.size() == 1) { Modified: trunk/jython/src/org/python/antlr/PythonTokenSource.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTokenSource.java 2009-07-30 04:11:55 UTC (rev 6602) +++ trunk/jython/src/org/python/antlr/PythonTokenSource.java 2009-07-30 04:40:15 UTC (rev 6603) @@ -83,7 +83,7 @@ int sp=-1; // grow upwards /** The queue of tokens */ - Vector tokens = new Vector(); + Vector<Token> tokens = new Vector<Token>(); /** We pull real tokens from this lexer */ CommonTokenStream stream; @@ -134,7 +134,7 @@ public Token nextToken() { // if something in queue, just remove and return it if (tokens.size() > 0) { - Token t = (Token)tokens.firstElement(); + Token t = tokens.firstElement(); tokens.removeElementAt(0); //System.out.println(filename + t); return t; @@ -264,7 +264,7 @@ } } } - List hiddenTokens = stream.getTokens(lastTokenAddedIndex + 1,t.getTokenIndex() - 1); + List<Token> hiddenTokens = stream.getTokens(lastTokenAddedIndex + 1,t.getTokenIndex() - 1); if (hiddenTokens != null) { tokens.addAll(hiddenTokens); } Modified: trunk/jython/src/org/python/antlr/PythonTree.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTree.java 2009-07-30 04:11:55 UTC (rev 6602) +++ trunk/jython/src/org/python/antlr/PythonTree.java 2009-07-30 04:40:15 UTC (rev 6603) @@ -251,19 +251,19 @@ } //XXX: From here down copied from org.antlr.runtime.tree.BaseTree - protected List children; + protected List<PythonTree> children; public PythonTree getChild(int i) { if ( children==null || i>=children.size() ) { return null; } - return (PythonTree)children.get(i); + 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 getChildren() { + public List<PythonTree> getChildren() { return children; } @@ -333,7 +333,7 @@ } /** Add all elements of kids list as children of this node */ - public void addChildren(List kids) { + public void addChildren(List<PythonTree> kids) { for (int i = 0; i < kids.size(); i++) { PythonTree t = (PythonTree) kids.get(i); addChild(t); @@ -382,13 +382,13 @@ int replacingHowMany = stopChildIndex - startChildIndex + 1; int replacingWithHowMany; PythonTree newTree = (PythonTree)t; - List newChildren = null; + List<PythonTree> newChildren = null; // normalize to a list of children to add: newChildren if ( newTree.isNil() ) { newChildren = newTree.children; } else { - newChildren = new ArrayList(1); + newChildren = new ArrayList<PythonTree>(1); newChildren.add(newTree); } replacingWithHowMany = newChildren.size(); @@ -432,8 +432,8 @@ } /** Override in a subclass to change the impl of children list */ - protected List createChildrenList() { - return new ArrayList(); + protected List<PythonTree> createChildrenList() { + return new ArrayList<PythonTree>(); } /** Set the parent and child index values for all child of t */ Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-07-30 04:11:55 UTC (rev 6602) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-07-30 04:40:15 UTC (rev 6603) @@ -555,7 +555,7 @@ doFinallysDownTo(bcfLevel); - code.goto_((Label)breakLabels.peek()); + code.goto_(breakLabels.peek()); return null; } @@ -568,7 +568,7 @@ doFinallysDownTo(bcfLevel); - code.goto_((Label)continueLabels.peek()); + code.goto_(continueLabels.peek()); return Exit; } @@ -691,7 +691,7 @@ code.astore(locals); for (int i = 0; i < v.size(); i++) { - String type = (String) v.elementAt(i); + String type = v.elementAt(i); if (type == null) continue; code.aload(locals); @@ -717,8 +717,7 @@ Label end = new Label(); code.label(end); for (int i = 0; i < exceptionHandlers.size(); ++i) { - ExceptionHandler handler = - (ExceptionHandler)exceptionHandlers.elementAt(i); + ExceptionHandler handler = exceptionHandlers.elementAt(i); handler.exceptionEnds.addElement(end); } } @@ -728,8 +727,7 @@ Label start = new Label(); code.label(start); for (int i = 0; i < exceptionHandlers.size(); ++i) { - ExceptionHandler handler = - (ExceptionHandler)exceptionHandlers.elementAt(i); + ExceptionHandler handler = exceptionHandlers.elementAt(i); handler.exceptionStarts.addElement(start); } } @@ -742,7 +740,7 @@ code.astore(locals); for (int i = 0; i < v.size(); i++) { - String type = (String) v.elementAt(i); + String type = v.elementAt(i); if (type == null) continue; code.aload(locals); @@ -1063,8 +1061,8 @@ @Override public Object visitWhile(While node) throws Exception { int savebcf = beginLoop(); - Label continue_loop = (Label)continueLabels.peek(); - Label break_loop = (Label)breakLabels.peek(); + Label continue_loop = continueLabels.peek(); + Label break_loop = breakLabels.peek(); Label start_loop = new Label(); @@ -1097,8 +1095,8 @@ @Override public Object visitFor(For node) throws Exception { int savebcf = beginLoop(); - Label continue_loop = (Label)continueLabels.peek(); - Label break_loop = (Label)breakLabels.peek(); + Label continue_loop = continueLabels.peek(); + Label break_loop = breakLabels.peek(); Label start_loop = new Label(); Label next_loop = new Label(); @@ -1280,14 +1278,12 @@ private void doFinallysDownTo(int level) throws Exception { Stack<ExceptionHandler> poppedHandlers = new Stack<ExceptionHandler>(); while (exceptionHandlers.size() > level) { - ExceptionHandler handler = - (ExceptionHandler)exceptionHandlers.pop(); + ExceptionHandler handler = exceptionHandlers.pop(); inlineFinally(handler); poppedHandlers.push(handler); } while (poppedHandlers.size() > 0) { - ExceptionHandler handler = - (ExceptionHandler)poppedHandlers.pop(); + ExceptionHandler handler = poppedHandlers.pop(); reenterProtectedBody(handler); exceptionHandlers.push(handler); } Modified: trunk/jython/src/org/python/compiler/Module.java =================================================================== --- trunk/jython/src/org/python/compiler/Module.java 2009-07-30 04:11:55 UTC (rev 6602) +++ trunk/jython/src/org/python/compiler/Module.java 2009-07-30 04:40:15 UTC (rev 6603) @@ -475,7 +475,7 @@ yields[0] = start; for (int i = 1; i < yields.length; i++) { - yields[i] = (Label) compiler.yields.get(i-1); + yields[i] = compiler.yields.get(i-1); } c.tableswitch(0, yields.length - 1, start, yields); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-30 04:12:01
|
Revision: 6602 http://jython.svn.sourceforge.net/jython/?rev=6602&view=rev Author: fwierzbicki Date: 2009-07-30 04:11:55 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Finished warnings in compiler package. Again, being extra careful to avoid messing with public interfaces. Deprecated LineNumberTable instead of deleting, even though I'm sure it isn't used. Modified Paths: -------------- trunk/jython/src/org/python/compiler/LineNumberTable.java trunk/jython/src/org/python/compiler/Module.java trunk/jython/src/org/python/compiler/ScopesCompiler.java Modified: trunk/jython/src/org/python/compiler/LineNumberTable.java =================================================================== --- trunk/jython/src/org/python/compiler/LineNumberTable.java 2009-07-30 03:38:40 UTC (rev 6601) +++ trunk/jython/src/org/python/compiler/LineNumberTable.java 2009-07-30 04:11:55 UTC (rev 6602) @@ -2,18 +2,19 @@ package org.python.compiler; -import java.io.*; -import java.util.*; +import java.util.Vector; +import java.io.DataOutputStream; +import java.io.IOException; +/** + * @Deprecated Not used. + */ public class LineNumberTable { int attName; - //ConstantPool pool; - Vector lines; + Vector<Short> lines; public LineNumberTable() throws IOException { - //this.pool = pool; - //attName = pool.UTF8("LineNumberTable"); - lines = new Vector(); + lines = new Vector<Short>(); } public void write(DataOutputStream stream) throws IOException { @@ -22,8 +23,8 @@ stream.writeInt(n * 2 + 2); stream.writeShort(n / 2); for (int i = 0; i < n; i += 2) { - Short startpc = (Short) lines.elementAt(i); - Short lineno = (Short) lines.elementAt(i+1); + Short startpc = lines.elementAt(i); + Short lineno = lines.elementAt(i+1); stream.writeShort(startpc.shortValue()); stream.writeShort(lineno.shortValue()); } Modified: trunk/jython/src/org/python/compiler/Module.java =================================================================== --- trunk/jython/src/org/python/compiler/Module.java 2009-07-30 03:38:40 UTC (rev 6601) +++ trunk/jython/src/org/python/compiler/Module.java 2009-07-30 04:11:55 UTC (rev 6602) @@ -301,7 +301,7 @@ public Constant mainCode; public boolean linenumbers; Future futures; - Hashtable scopes; + Hashtable<PythonTree,ScopeInfo> scopes; long mtime; public Module(String name, String filename, boolean linenumbers) { @@ -313,15 +313,15 @@ this.mtime = mtime; classfile = new ClassFile(name, "org/python/core/PyFunctionTable", ACC_SYNCHRONIZED | ACC_PUBLIC, mtime); - constants = new Hashtable(); + constants = new Hashtable<Constant,Constant>(); sfilename = filename; if (filename != null) this.filename = PyString(filename); else this.filename = null; - codes = new ArrayList(); + codes = new ArrayList<PyCodeConstant>(); futures = new Future(); - scopes = new Hashtable(); + scopes = new Hashtable<PythonTree,ScopeInfo>(); } public Module(String name) { @@ -329,7 +329,7 @@ } // This block of code handles the pool of Python Constants - Hashtable constants; + Hashtable<Constant,Constant> constants; private Constant findConstant(Constant c) { Constant ret = (Constant)constants.get(c); @@ -365,10 +365,10 @@ return findConstant(new PyLongConstant(value)); } - List codes; + List<PyCodeConstant> codes; //XXX: this can probably go away now that we can probably just copy the list. - private List<String> toNameAr(List names,boolean nullok) { + private List<String> toNameAr(List<String> names,boolean nullok) { int sz = names.size(); if (sz == 0 && nullok) return null; List<String> nameArray = new ArrayList<String>(); @@ -562,7 +562,7 @@ } for(int i=0; i<codes.size(); i++) { - PyCodeConstant pyc = (PyCodeConstant)codes.get(i); + PyCodeConstant pyc = codes.get(i); pyc.put(c); } @@ -589,7 +589,7 @@ code.tableswitch(0, labels.length - 1, def, labels); for(i=0; i<labels.length; i++) { code.label(labels[i]); - code.invokevirtual(classfile.name, ((PyCodeConstant)codes.get(i)).fname, "(" + $pyFrame + $threadState + ")" + $pyObj); + code.invokevirtual(classfile.name, (codes.get(i)).fname, "(" + $pyFrame + $threadState + ")" + $pyObj); code.areturn(); } code.label(def); Modified: trunk/jython/src/org/python/compiler/ScopesCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/ScopesCompiler.java 2009-07-30 03:38:40 UTC (rev 6601) +++ trunk/jython/src/org/python/compiler/ScopesCompiler.java 2009-07-30 04:11:55 UTC (rev 6602) @@ -34,17 +34,17 @@ private CompilationContext code_compiler; - private Stack scopes; + private Stack<ScopeInfo> scopes; private ScopeInfo cur = null; - private Hashtable nodeScopes; + private Hashtable<PythonTree,ScopeInfo> nodeScopes; private int level = 0; private int func_level = 0; - public ScopesCompiler(CompilationContext code_compiler, Hashtable nodeScopes) { + public ScopesCompiler(CompilationContext code_compiler, Hashtable<PythonTree,ScopeInfo> nodeScopes) { this.code_compiler = code_compiler; this.nodeScopes = nodeScopes; - scopes = new Stack(); + scopes = new Stack<ScopeInfo>(); } public void beginScope(String name, int kind, PythonTree node, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-30 03:38:50
|
Revision: 6601 http://jython.svn.sourceforge.net/jython/?rev=6601&view=rev Author: fwierzbicki Date: 2009-07-30 03:38:40 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Fix compiler warnings. Note that I am not replacing Vectors with Lists, etc (as much as I'd like to) since this is a minor release and most of these are public fields (yuck). Modified Paths: -------------- trunk/jython/src/org/python/compiler/CodeCompiler.java trunk/jython/src/org/python/compiler/ScopeInfo.java Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-07-30 03:12:37 UTC (rev 6600) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-07-30 03:38:40 UTC (rev 6601) @@ -120,12 +120,12 @@ public ScopeInfo my_scope; boolean optimizeGlobals = true; - public Vector names; + public Vector<String> names; public String className; - public Stack continueLabels, breakLabels; - public Stack exceptionHandlers; - public Vector yields = new Vector(); + public Stack<Label> continueLabels, breakLabels; + public Stack<ExceptionHandler> exceptionHandlers; + public Vector<Label> yields = new Vector<Label>(); /* break/continue finally's level. * This is the lowest level in the exceptionHandlers which should @@ -148,9 +148,9 @@ mrefs = this; cw = module.classfile.cw; - continueLabels = new Stack(); - breakLabels = new Stack(); - exceptionHandlers = new Stack(); + continueLabels = new Stack<Label>(); + breakLabels = new Stack<Label>(); + exceptionHandlers = new Stack<ExceptionHandler>(); } public void getNone() throws IOException { @@ -682,7 +682,7 @@ private void restoreLocals() throws Exception { endExceptionHandlers(); - Vector v = code.getActiveLocals(); + Vector<String> v = code.getActiveLocals(); loadFrame(); code.getfield("org/python/core/PyFrame", "f_savedlocals", "[Ljava/lang/Object;"); @@ -735,7 +735,7 @@ } private void saveLocals() throws Exception { - Vector v = code.getActiveLocals(); + Vector<String> v = code.getActiveLocals(); code.iconst(v.size()); code.anewarray("java/lang/Object"); int locals = code.getLocal("[Ljava/lang/Object;"); @@ -1278,7 +1278,7 @@ * all the handlers above level temporarily. */ private void doFinallysDownTo(int level) throws Exception { - Stack poppedHandlers = new Stack(); + Stack<ExceptionHandler> poppedHandlers = new Stack<ExceptionHandler>(); while (exceptionHandlers.size() > level) { ExceptionHandler handler = (ExceptionHandler)exceptionHandlers.pop(); @@ -2414,8 +2414,8 @@ * We also need to stop coverage for the recovery of the locals after * a yield. */ - public Vector exceptionStarts = new Vector(); - public Vector exceptionEnds = new Vector(); + public Vector<Label> exceptionStarts = new Vector<Label>(); + public Vector<Label> exceptionEnds = new Vector<Label>(); public boolean bodyDone = false; @@ -2434,13 +2434,13 @@ public void addExceptionHandlers(Label handlerStart) throws Exception { for (int i = 0; i < exceptionStarts.size(); ++i) { - Label start = (Label)exceptionStarts.elementAt(i); - Label end = (Label)exceptionEnds.elementAt(i); + Label start = exceptionStarts.elementAt(i); + Label end = exceptionEnds.elementAt(i); //FIXME: not at all sure that getOffset() test is correct or necessary. if (start.getOffset() != end.getOffset()) { code.trycatch( - (Label)exceptionStarts.elementAt(i), - (Label)exceptionEnds.elementAt(i), + exceptionStarts.elementAt(i), + exceptionEnds.elementAt(i), handlerStart, "java/lang/Throwable"); } Modified: trunk/jython/src/org/python/compiler/ScopeInfo.java =================================================================== --- trunk/jython/src/org/python/compiler/ScopeInfo.java 2009-07-30 03:12:37 UTC (rev 6600) +++ trunk/jython/src/org/python/compiler/ScopeInfo.java 2009-07-30 03:38:40 UTC (rev 6601) @@ -69,7 +69,7 @@ public ArgListCompiler ac; public Map<String, SymInfo> tbl = new LinkedHashMap<String, SymInfo>(); - public Vector names = new Vector(); + public Vector<String> names = new Vector<String>(); public int addGlobal(String name) { // global kind = func vs. class @@ -116,11 +116,11 @@ private final static Object PRESENT = new Object(); - public Hashtable inner_free = new Hashtable(); + public Hashtable<String,Object> inner_free = new Hashtable<String,Object>(); - public Vector cellvars = new Vector(); + public Vector<String> cellvars = new Vector<String>(); - public Vector jy_paramcells = new Vector(); + public Vector<String> jy_paramcells = new Vector<String>(); public int jy_npurecell; @@ -135,7 +135,7 @@ this.up = up; this.distance = distance; boolean func = kind == FUNCSCOPE; - Vector purecells = new Vector(); + Vector<String> purecells = new Vector<String>(); cell = 0; boolean some_inner_free = inner_free.size() > 0; @@ -223,7 +223,7 @@ ctxt.error(illegal.toString(), true, scope_node); } - public Vector freevars = new Vector(); + public Vector<String> freevars = new Vector<String>(); /** * setup the closure on this scope using the scope passed into cook as up as This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-07-30 03:12:43
|
Revision: 6600 http://jython.svn.sourceforge.net/jython/?rev=6600&view=rev Author: pjenvey Date: 2009-07-30 03:12:37 +0000 (Thu, 30 Jul 2009) Log Message: ----------- changelog r6599 Modified Paths: -------------- trunk/jython/NEWS Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-07-30 03:11:24 UTC (rev 6599) +++ trunk/jython/NEWS 2009-07-30 03:12:37 UTC (rev 6600) @@ -17,6 +17,7 @@ - [ 1802339 ] Problem printing unicode when stdout intercepted - [ 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) Jython 2.5.0 The same as rc4. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |