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: <pj...@us...> - 2009-07-30 03:11:42
|
Revision: 6599 http://jython.svn.sourceforge.net/jython/?rev=6599&view=rev Author: pjenvey Date: 2009-07-30 03:11:24 +0000 (Thu, 30 Jul 2009) Log Message: ----------- handle null array results fixes #1413 Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/JDBC20DataHandler.java Modified: trunk/jython/src/com/ziclix/python/sql/JDBC20DataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/JDBC20DataHandler.java 2009-07-30 03:10:33 UTC (rev 6598) +++ trunk/jython/src/com/ziclix/python/sql/JDBC20DataHandler.java 2009-07-30 03:11:24 UTC (rev 6599) @@ -15,6 +15,7 @@ import java.io.InputStreamReader; import java.io.Reader; import java.math.BigDecimal; +import java.sql.Array; import java.sql.Blob; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -52,8 +53,9 @@ * @throws SQLException */ @SuppressWarnings("fallthrough") - 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; } @@ -97,7 +99,6 @@ if (lob != null) { stmt.setBytes(index, lob); - break; } default : @@ -115,8 +116,8 @@ * @return a Python object * @throws SQLException */ + @Override public PyObject getPyObject(ResultSet set, int col, int type) throws SQLException { - PyObject obj = Py.None; switch (type) { @@ -127,7 +128,6 @@ // in JDBC 2.0, use of a scale is deprecated try { BigDecimal bd = set.getBigDecimal(col); - obj = (bd == null) ? Py.None : Py.newFloat(bd.doubleValue()); } catch (SQLException e) { obj = super.getPyObject(set, col, type); @@ -192,7 +192,8 @@ break; case Types.ARRAY: - obj = Py.java2py(set.getArray(col).getArray()); + Array array = set.getArray(col); + obj = array == null ? Py.None : Py.java2py(array.getArray()); break; default : 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:10:51
|
Revision: 6598 http://jython.svn.sourceforge.net/jython/?rev=6598&view=rev Author: fwierzbicki Date: 2009-07-30 03:10:33 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Remove compiler warning. Modified Paths: -------------- trunk/jython/src/org/python/compiler/Code.java Modified: trunk/jython/src/org/python/compiler/Code.java =================================================================== --- trunk/jython/src/org/python/compiler/Code.java 2009-07-28 13:58:03 UTC (rev 6597) +++ trunk/jython/src/org/python/compiler/Code.java 2009-07-30 03:10:33 UTC (rev 6598) @@ -72,8 +72,8 @@ return returnLocal; } - public Vector getActiveLocals() { - Vector ret = new Vector(); + public Vector<String> getActiveLocals() { + Vector<String> ret = new Vector<String>(); ret.setSize(nlocals); for (int l = argcount; l<nlocals; l++) { if (l == returnLocal || finallyLocals.get(l)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-28 13:58:10
|
Revision: 6597 http://jython.svn.sourceforge.net/jython/?rev=6597&view=rev Author: fwierzbicki Date: 2009-07-28 13:58:03 +0000 (Tue, 28 Jul 2009) Log Message: ----------- Remove tests made redundant by test_codeop.py. Modified Paths: -------------- trunk/jython/Lib/test/test_codeop_jy.py Modified: trunk/jython/Lib/test/test_codeop_jy.py =================================================================== --- trunk/jython/Lib/test/test_codeop_jy.py 2009-07-28 13:57:07 UTC (rev 6596) +++ trunk/jython/Lib/test/test_codeop_jy.py 2009-07-28 13:58:03 UTC (rev 6597) @@ -24,7 +24,6 @@ else: self.assert_(code) - def assertInvalid(self, str, symbol='single', is_syntax=1): '''succeed iff str is the start of an invalid piece of code''' try: @@ -35,26 +34,14 @@ except OverflowError: self.assert_(not is_syntax) - assertIncomplete = assertInvalid - def test_valid(self): av = self.assertValid - av("") - av("\n") av("\n\n") av("# a\n") - av("a = 1") - av("\na = 1") - av("a = 1\n") - av("a = 1\n\n") av("\n\na = 1\n\n",values={'a':1}) - av("def x():\n pass\n") - av("if 1:\n pass\n") - - av("\n\nif 1: pass\n") av("\n\nif 1: a=1\n\n",values={'a':1}) av("def x():\n pass") @@ -62,35 +49,15 @@ av("def x():\n pass\n ") av("\n\ndef x():\n pass") - av("def x():\n\n pass\n") # failed under 2.1 - av("def x():\n pass\n \n") - av("def x():\n pass\n \n") - # 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\n") - av("if 1:\n pass\n if 1:\n pass\n else:\n pass\n") - - av("pass\n") - av("3**3\n") - av("if 9==3:\n pass\nelse:\n pass") - av("if 9==3:\n pass\nelse:\n pass\n") av("if 1:\n pass\n if 1:\n pass\n else:\n pass") - av("if 1:\n pass\n if 1:\n pass\n else:\n pass\n") - av("#a\n#b\na = 3\n") av("#a\n\n \na=3\n",values={'a':3}) - av("a=3\n\n") - av("a = 9+ \\\n3") - av("3**3","eval") - av("(lambda z: \n z**3)","eval") - av("9+ \\\n3","eval") - av("9+ \\\n3\n","eval") - # these failed under 2.1 self.eval_d = {'a': 2} av("\n\na**3","eval",value=8) @@ -105,69 +72,9 @@ av("def f():\n pass\n#foo") - def test_incomplete(self): - ai = self.assertIncomplete - - ai("(a **") - ai("(a,b,") - ai("(a,b,(") - ai("(a,b,(") - ai("a = (") - ai("a = {") - ai("b + {") - - ai("if 9==3:\n pass\nelse:") - ai("if 9==3:\n pass\nelse:\n") - - ai("if 1:") - ai("if 1:\n") - ai("if 1:\n pass\n if 1:\n pass\n else:") - ai("if 1:\n pass\n if 1:\n pass\n else:\n") - - ai("def x():") - ai("def x():\n") - ai("def x():\n\n") - - ai("a = 9+ \\") - ai("a = 'a\\") - ai("a = '''xy") - - ai("","eval") - ai("\n","eval") - ai("(","eval") - ai("(\n\n\n","eval") - ai("(9+","eval") - ai("9+ \\","eval") - ai("lambda z: \\","eval") - def test_invalid(self): ai = self.assertInvalid - ai("a b") - - ai("a @") - ai("a b @") - ai("a ** @") - - ai("a = ") - ai("a = 9 +") - - ai("def x():\n\npass\n") - - ai("\n\n if 1: pass\n\npass") # valid for 2.1 ?! - - ai("a = 9+ \\\n") - ai("a = 'a\\ ") - ai("a = 'a\\\n") - - ai("a = 1","eval") - ai("a = (","eval") - ai("]","eval") - ai("())","eval") - ai("[}","eval") - ai("9+","eval") - ai("lambda z:","eval") - ai("a b","eval") ai("return 2.3") ai("del 1") ai("del ()") @@ -177,13 +84,7 @@ ai("if (a == 1 and b = 2): pass") ai("[i for i in range(10)] = (1, 2, 3)") - def test_filename(self): - self.assertEquals(compile_("a = 1\n", "abc").co_filename, - compile("a = 1\n", "abc", 'single').co_filename) - self.assertNotEquals(compile_("a = 1\n", "abc").co_filename, - compile("a = 1\n", "def", 'single').co_filename) - class CodeopTests(unittest.TestCase): def test_no_universal_newlines(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-28 13:57:15
|
Revision: 6596 http://jython.svn.sourceforge.net/jython/?rev=6596&view=rev Author: fwierzbicki Date: 2009-07-28 13:57:07 +0000 (Tue, 28 Jul 2009) Log Message: ----------- Make diff w/Python.g smaller. Modified Paths: -------------- trunk/jython/grammar/Base.g Modified: trunk/jython/grammar/Base.g =================================================================== --- trunk/jython/grammar/Base.g 2009-07-28 13:29:09 UTC (rev 6595) +++ trunk/jython/grammar/Base.g 2009-07-28 13:57:07 UTC (rev 6596) @@ -1143,6 +1143,8 @@ $channel=HIDDEN; } } + } else if (this.single && newlines == 1) { + throw new ParseException("Trailing space in single mode."); } else { // make a string of n newlines char[] nls = new char[newlines]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-28 13:29:19
|
Revision: 6595 http://jython.svn.sourceforge.net/jython/?rev=6595&view=rev Author: fwierzbicki Date: 2009-07-28 13:29:09 +0000 (Tue, 28 Jul 2009) Log Message: ----------- Only one test still failing for us - will require a large change in PythonPartial.g to fix. 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-27 20:39:10 UTC (rev 6594) +++ trunk/jython/Lib/test/test_codeop.py 2009-07-28 13:29:09 UTC (rev 6595) @@ -173,7 +173,10 @@ ai("a = 'a\\\n") ai("a = 1","eval") - #ai("a = (","eval") + #XXX: Current limitation in PythonPartial.g prevents this from properly + # erroring on Jython. + if not is_jython: + ai("a = (","eval") ai("]","eval") ai("())","eval") ai("[}","eval") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-27 20:39:19
|
Revision: 6594 http://jython.svn.sourceforge.net/jython/?rev=6594&view=rev Author: fwierzbicki Date: 2009-07-27 20:39:10 +0000 (Mon, 27 Jul 2009) Log Message: ----------- Now handling trailing backslashes in single mode more like CPython. 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-27 19:30:01 UTC (rev 6593) +++ trunk/jython/Lib/test/test_codeop.py 2009-07-27 20:39:10 UTC (rev 6594) @@ -168,9 +168,9 @@ ai("\n\n if 1: pass\n\npass") - #ai("a = 9+ \\\n") + ai("a = 9+ \\\n") ai("a = 'a\\ ") - #ai("a = 'a\\\n") + ai("a = 'a\\\n") ai("a = 1","eval") #ai("a = (","eval") Modified: trunk/jython/grammar/PythonPartial.g =================================================================== --- trunk/jython/grammar/PythonPartial.g 2009-07-27 19:30:01 UTC (rev 6593) +++ trunk/jython/grammar/PythonPartial.g 2009-07-27 20:39:10 UTC (rev 6594) @@ -1085,12 +1085,21 @@ * emit a newline. */ CONTINUED_LINE +@init { + boolean extraNewlines = false; +} : '\\' ('\r')? '\n' (' '|'\t')* { $channel=HIDDEN; } ( COMMENT | nl=NEWLINE + { + extraNewlines = true; + } | ) { if (input.LA(1) == -1) { + if (extraNewlines) { + throw new ParseException("invalid syntax"); + } emit(new CommonToken(TRAILBACKSLASH,"\\")); } } @@ -1103,10 +1112,7 @@ * Frank Wierzbicki added: Also ignore FORMFEEDS (\u000C). */ NEWLINE -@init { - int newlines = 0; -} - : (('\u000C')?('\r')? '\n' {newlines++; } )+ { + : (('\u000C')?('\r')? '\n' )+ { if ( startPos==0 || implicitLineJoiningLevel>0 ) $channel=HIDDEN; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-27 19:30:14
|
Revision: 6593 http://jython.svn.sourceforge.net/jython/?rev=6593&view=rev Author: fwierzbicki Date: 2009-07-27 19:30:01 +0000 (Mon, 27 Jul 2009) Log Message: ----------- Get our Lexer to properly fail for trailing whitespace in single mode. Modified Paths: -------------- trunk/jython/Lib/test/test_codeop.py trunk/jython/grammar/Python.g trunk/jython/src/org/python/antlr/BaseParser.java Modified: trunk/jython/Lib/test/test_codeop.py =================================================================== --- trunk/jython/Lib/test/test_codeop.py 2009-07-27 17:22:32 UTC (rev 6592) +++ trunk/jython/Lib/test/test_codeop.py 2009-07-27 19:30:01 UTC (rev 6593) @@ -133,8 +133,8 @@ ai("def x():\n\n") ai("def x():\n pass") - #ai("def x():\n pass\n ") - #ai("def x():\n pass\n ") + ai("def x():\n pass\n ") + ai("def x():\n pass\n ") ai("\n\ndef x():\n pass") ai("a = 9+ \\") Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2009-07-27 17:22:32 UTC (rev 6592) +++ trunk/jython/grammar/Python.g 2009-07-27 19:30:01 UTC (rev 6593) @@ -209,6 +209,7 @@ //For use in partial parsing. public boolean eofWhileNested = false; public boolean partial = false; +public boolean single = false; int implicitLineJoiningLevel = 0; int startPos=-1; @@ -1967,6 +1968,8 @@ $channel=HIDDEN; } } + } else if (this.single && newlines == 1) { + throw new ParseException("Trailing space in single mode."); } else { // make a string of n newlines char[] nls = new char[newlines]; Modified: trunk/jython/src/org/python/antlr/BaseParser.java =================================================================== --- trunk/jython/src/org/python/antlr/BaseParser.java 2009-07-27 17:22:32 UTC (rev 6592) +++ trunk/jython/src/org/python/antlr/BaseParser.java 2009-07-27 19:30:01 UTC (rev 6593) @@ -32,10 +32,16 @@ } public static class PyLexer extends PythonLexer { - public PyLexer(CharStream lexer) { + public PyLexer(CharStream lexer, boolean single) { super(lexer); + this.single = single; } + public PyLexer(CharStream lexer) { + this(lexer, false); + } + + public Token nextToken() { startPos = getCharPositionInLine(); return super.nextToken(); @@ -53,12 +59,8 @@ } } - private CharStream charStream(boolean single) { - return charStream; - } - private PythonParser setupParser(boolean single) { - PythonLexer lexer = new PyLexer(this.charStream(single)); + PythonLexer lexer = new PyLexer(charStream, single); lexer.setErrorHandler(errorHandler); CommonTokenStream tokens = new CommonTokenStream(lexer); PythonTokenSource indentedSource = new PythonTokenSource(tokens, filename, single); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-27 17:22:41
|
Revision: 6592 http://jython.svn.sourceforge.net/jython/?rev=6592&view=rev Author: fwierzbicki Date: 2009-07-27 17:22:32 +0000 (Mon, 27 Jul 2009) Log Message: ----------- Clean up indent. Modified Paths: -------------- trunk/jython/grammar/PythonPartial.g Modified: trunk/jython/grammar/PythonPartial.g =================================================================== --- trunk/jython/grammar/PythonPartial.g 2009-07-26 16:34:54 UTC (rev 6591) +++ trunk/jython/grammar/PythonPartial.g 2009-07-27 17:22:32 UTC (rev 6592) @@ -545,9 +545,9 @@ : simple_stmt | NEWLINE (EOF | (DEDENT)+ EOF - |INDENT (stmt)+ (DEDENT - |EOF - ) + | INDENT (stmt)+ (DEDENT + |EOF + ) ) ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-07-26 16:35:01
|
Revision: 6591 http://jython.svn.sourceforge.net/jython/?rev=6591&view=rev Author: cgroves Date: 2009-07-26 16:34:54 +0000 (Sun, 26 Jul 2009) Log Message: ----------- Me wrap you long line. Modified Paths: -------------- trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java Modified: trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java =================================================================== --- trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java 2009-07-26 16:32:05 UTC (rev 6590) +++ trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java 2009-07-26 16:34:54 UTC (rev 6591) @@ -9,13 +9,14 @@ import org.python.core.Py; public class PyScriptEngineFactory implements ScriptEngineFactory { - + public String getEngineName() { return "jython"; } public String getEngineVersion() { - return String.format("%s.%s.%s", Version.PY_MAJOR_VERSION, Version.PY_MINOR_VERSION, Version.PY_MICRO_VERSION); + return String.format("%s.%s.%s", Version.PY_MAJOR_VERSION, Version.PY_MINOR_VERSION, + Version.PY_MICRO_VERSION); } public List<String> getExtensions() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-07-26 16:32:14
|
Revision: 6590 http://jython.svn.sourceforge.net/jython/?rev=6590&view=rev Author: cgroves Date: 2009-07-26 16:32:05 +0000 (Sun, 26 Jul 2009) Log Message: ----------- Add Py.javas2pys. It takes a varargs array of Object and returns a corresponding array of PyObject. Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/DataHandler.java trunk/jython/src/com/ziclix/python/sql/Jython22DataHandler.java trunk/jython/src/com/ziclix/python/sql/PyCursor.java trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/PyObject.java trunk/jython/src/org/python/jsr223/PyScriptEngine.java Modified: trunk/jython/src/com/ziclix/python/sql/DataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/DataHandler.java 2009-07-26 15:23:38 UTC (rev 6589) +++ trunk/jython/src/com/ziclix/python/sql/DataHandler.java 2009-07-26 16:32:05 UTC (rev 6590) @@ -507,9 +507,9 @@ public static final DataHandler getSystemDataHandler() { DataHandler dh = new DataHandler(); - for (int i = 0; i < SYSTEM_DATAHANDLERS.length; i++) { + for (String element : SYSTEM_DATAHANDLERS) { try { - Class c = Class.forName(SYSTEM_DATAHANDLERS[i]); + Class c = Class.forName(element); Constructor cons = c.getConstructor(new Class[]{DataHandler.class}); dh = (DataHandler) cons.newInstance(new Object[]{dh}); } catch (Throwable t) {} @@ -524,7 +524,7 @@ * @return a list of datahandlers */ public PyObject __chain__() { - return new PyList(new PyObject[] { Py.java2py(this) }); + return new PyList(Py.javas2pys(this)); } /** Modified: trunk/jython/src/com/ziclix/python/sql/Jython22DataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/Jython22DataHandler.java 2009-07-26 15:23:38 UTC (rev 6589) +++ trunk/jython/src/com/ziclix/python/sql/Jython22DataHandler.java 2009-07-26 16:32:05 UTC (rev 6590) @@ -446,7 +446,7 @@ * @return a list of datahandlers */ public PyObject __chain__() { - return new PyList(new PyObject[] { Py.java2py(this) }); + return new PyList(Py.javas2pys(this)); } } Modified: trunk/jython/src/com/ziclix/python/sql/PyCursor.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/PyCursor.java 2009-07-26 15:23:38 UTC (rev 6589) +++ trunk/jython/src/com/ziclix/python/sql/PyCursor.java 2009-07-26 16:32:05 UTC (rev 6590) @@ -750,13 +750,11 @@ SQLWarning warning = event.getWarning(); while (warning != null) { - PyObject[] warn = new PyObject[] { - // there are three parts: (reason, state, vendorCode) - Py.java2py(warning.getMessage()), - Py.java2py(warning.getSQLState()), - Py.newInteger(warning.getErrorCode()) - }; + // there are three parts: (reason, state, vendorCode) + PyObject[] warn = + Py.javas2pys(warning.getMessage(), warning.getSQLState(), warning.getErrorCode()); + // add the warning to the list ((PyList)this.warnings).append(new PyTuple(warn)); Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-07-26 15:23:38 UTC (rev 6589) +++ trunk/jython/src/org/python/core/Py.java 2009-07-26 16:32:05 UTC (rev 6590) @@ -853,9 +853,7 @@ if (args == null || args.length == 0) { pargs = Py.EmptyObjects; } else { - pargs = new PyObject[args.length]; - for(int i=0; i<args.length; i++) - pargs[i] = Py.java2py(args[i]); + pargs = Py.javas2pys(args); } instance = pyc.__call__(pargs); instance.javaProxy = proxy; @@ -1487,6 +1485,20 @@ } /** + * Uses the PyObjectAdapter passed to {@link PySystemState#initialize} to turn + * <code>objects</code> into an array of PyObjects. + * + * @see ClassicPyObjectAdapter - default PyObjectAdapter type + */ + public static PyObject[] javas2pys(Object... objects) { + PyObject[] objs = new PyObject[objects.length]; + for (int i = 0; i < objs.length; i++) { + objs[i] = java2py(objects[i]); + } + return objs; + } + + /** * @return the ExtensiblePyObjectAdapter used by java2py. */ public static ExtensiblePyObjectAdapter getAdapter() { Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2009-07-26 15:23:38 UTC (rev 6589) +++ trunk/jython/src/org/python/core/PyObject.java 2009-07-26 16:32:05 UTC (rev 6590) @@ -51,7 +51,7 @@ if (Py.BOOTSTRAP_TYPES.size() > 0) { Py.writeWarning("init", "Bootstrap types weren't encountered in bootstrapping: " + Py.BOOTSTRAP_TYPES); - + } } @@ -325,7 +325,7 @@ public PyObject __call__(PyObject args[], String keywords[]) { throw Py.TypeError(String.format("'%s' object is not callable", getType().fastGetName())); } - + public PyObject __call__(ThreadState state, PyObject args[], String keywords[]) { return __call__(args, keywords); } @@ -350,7 +350,7 @@ newArgs[0] = arg1; return __call__(newArgs, keywords); } - + public PyObject __call__(ThreadState state, PyObject arg1, PyObject args[], String keywords[]) { return __call__(arg1, args, keywords); } @@ -366,7 +366,7 @@ public PyObject __call__(PyObject args[]) { return __call__(args, Py.NoKeywords); } - + public PyObject __call__(ThreadState state, PyObject args[]) { return __call__(args); } @@ -380,7 +380,7 @@ public PyObject __call__() { return __call__(Py.EmptyObjects, Py.NoKeywords); } - + public PyObject __call__(ThreadState state) { return __call__(); } @@ -396,7 +396,7 @@ public PyObject __call__(PyObject arg0) { return __call__(new PyObject[] { arg0 }, Py.NoKeywords); } - + public PyObject __call__(ThreadState state, PyObject arg0) { return __call__(arg0); } @@ -431,7 +431,7 @@ public PyObject __call__(PyObject arg0, PyObject arg1, PyObject arg2) { return __call__(new PyObject[] { arg0, arg1, arg2 }, Py.NoKeywords); } - + public PyObject __call__(ThreadState state, PyObject arg0, PyObject arg1, PyObject arg2) { return __call__(arg0, arg1, arg2); } @@ -452,7 +452,7 @@ new PyObject[] { arg0, arg1, arg2, arg3 }, Py.NoKeywords); } - + public PyObject __call__(ThreadState state, PyObject arg0, PyObject arg1, PyObject arg2, PyObject arg3) { return __call__(arg0, arg1, arg2, arg3); } @@ -3496,12 +3496,8 @@ * A convenience function for PyProxys. */ public PyObject _jcallexc(Object[] args) throws Throwable { - PyObject[] pargs = new PyObject[args.length]; try { - for (int i = 0; i < args.length; i++) { - pargs[i] = Py.java2py(args[i]); - } - return __call__(pargs); + return __call__(Py.javas2pys(args)); } catch (PyException e) { if (e.value.getJavaProxy() != null) { Object t = e.value.__tojava__(Throwable.class); Modified: trunk/jython/src/org/python/jsr223/PyScriptEngine.java =================================================================== --- trunk/jython/src/org/python/jsr223/PyScriptEngine.java 2009-07-26 15:23:38 UTC (rev 6589) +++ trunk/jython/src/org/python/jsr223/PyScriptEngine.java 2009-07-26 16:32:05 UTC (rev 6590) @@ -66,43 +66,49 @@ private PyCode compileScript(String script, ScriptContext context) throws ScriptException { try { String filename = (String) context.getAttribute(ScriptEngine.FILENAME); - if (filename == null) + if (filename == null) { return interp.compile(script); - else + } else { return interp.compile(script, filename); + } } catch (PyException pye) { throw scriptException(pye); } } - + private PyCode compileScript(Reader reader, ScriptContext context) throws ScriptException { try { String filename = (String) context.getAttribute(ScriptEngine.FILENAME); - if (filename == null) + if (filename == null) { return interp.compile(reader); - else + } else { return interp.compile(reader, filename); + } } catch (PyException pye) { throw scriptException(pye); } } - public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException { + public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, + NoSuchMethodException { try { - if (!(thiz instanceof PyObject)) + if (!(thiz instanceof PyObject)) { thiz = Py.java2py(thiz); - return ((PyObject) thiz).invoke(name, java2py(args)).__tojava__(Object.class); + } + return ((PyObject) thiz).invoke(name, Py.javas2pys(args)).__tojava__(Object.class); } catch (PyException pye) { return throwInvokeException(pye, name); } } - public Object invokeFunction(String name, Object... args) throws ScriptException, NoSuchMethodException { + public Object invokeFunction(String name, Object... args) throws ScriptException, + NoSuchMethodException { try { PyObject function = interp.get(name); - if (function == null) + if (function == null) { throw new NoSuchMethodException(name); - return function.__call__(java2py(args)).__tojava__(Object.class); + } + return function.__call__(Py.javas2pys(args)).__tojava__(Object.class); } catch (PyException pye) { return throwInvokeException(pye, name); } @@ -113,23 +119,28 @@ } public <T> T getInterface(Object obj, Class<T> clazz) { - if (obj == null) + if (obj == null) { throw new IllegalArgumentException("object expected"); - if (clazz == null || !clazz.isInterface()) + } + if (clazz == null || !clazz.isInterface()) { throw new IllegalArgumentException("interface expected"); - final Object thiz = Py.java2py(obj); - return (T) Proxy.newProxyInstance( + } + final PyObject thiz = Py.java2py(obj); + @SuppressWarnings("unchecked") + T proxy = (T) Proxy.newProxyInstance( clazz.getClassLoader(), new Class[] { clazz }, new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { - return ((PyObject) thiz).invoke(method.getName(), java2py(args)).__tojava__(Object.class); + PyObject result = thiz.invoke(method.getName(), Py.javas2pys(args)); + return result.__tojava__(Object.class); } catch (PyException pye) { return throwInvokeException(pye, method.getName()); } } }); + return proxy; } private static Object throwInvokeException(PyException pye, String methodName) @@ -162,11 +173,11 @@ offset == null ? 0 : offset.asInt()); } else if (tb != null) { String filename; - if (tb.tb_frame == null || tb.tb_frame.f_code == null) + if (tb.tb_frame == null || tb.tb_frame.f_code == null) { filename = null; - else + } else { filename = tb.tb_frame.f_code.co_filename; - + } se = new ScriptException( Py.formatException(type, value), filename, @@ -182,14 +193,6 @@ return se; } - private static PyObject[] java2py(Object[] args) { - PyObject wrapped[] = new PyObject[args.length]; - for (int i = 0; i < args.length; i++) { - wrapped[i] = Py.java2py(args[i]); - } - return wrapped; - } - private class PyCompiledScript extends CompiledScript { private PyCode code; @@ -197,10 +200,12 @@ this.code = code; } + @Override public ScriptEngine getEngine() { return PyScriptEngine.this; } + @Override public Object eval(ScriptContext ctx) throws ScriptException { return PyScriptEngine.this.eval(code, ctx); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-07-26 15:23:45
|
Revision: 6589 http://jython.svn.sourceforge.net/jython/?rev=6589&view=rev Author: cgroves Date: 2009-07-26 15:23:38 +0000 (Sun, 26 Jul 2009) Log Message: ----------- Grooming Modified Paths: -------------- trunk/jython/src/org/python/compiler/AdapterMaker.java trunk/jython/src/org/python/compiler/ClassConstants.java trunk/jython/src/org/python/compiler/JavaMaker.java trunk/jython/src/org/python/compiler/ProxyMaker.java trunk/jython/src/org/python/core/MakeProxies.java trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/src/org/python/compiler/AdapterMaker.java =================================================================== --- trunk/jython/src/org/python/compiler/AdapterMaker.java 2009-07-26 08:16:28 UTC (rev 6588) +++ trunk/jython/src/org/python/compiler/AdapterMaker.java 2009-07-26 15:23:38 UTC (rev 6589) @@ -1,8 +1,6 @@ // Copyright (c) Corporation for National Research Initiatives - package org.python.compiler; -import java.io.OutputStream; import java.lang.reflect.Method; import java.util.HashSet; @@ -10,40 +8,27 @@ import org.objectweb.asm.Opcodes; import org.python.util.Generic; +public class AdapterMaker extends ProxyMaker { -public class AdapterMaker extends ProxyMaker -{ - public AdapterMaker(Class<?> interfac) { - super(interfac.getName()+"$Adapter", interfac); + public AdapterMaker(String adapterName, Class<?> interfac) { + super(adapterName, Object.class, new Class<?>[] {interfac}); } + @Override public void build() throws Exception { names = Generic.set(); - int access = Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNCHRONIZED; classfile = new ClassFile(myClass, "java/lang/Object", access); - classfile.addInterface(mapClass(interfaces[0])); - addMethods(interfaces[0], new HashSet<String>()); addConstructors(Object.class); doConstants(); } - - public static String makeAdapter(Class interfac, OutputStream ostream) - throws Exception - { - AdapterMaker pm = new AdapterMaker(interfac); - pm.build(); - pm.classfile.write(ostream); - return pm.myClass; - } - @Override public void doConstants() throws Exception { for (String name : names) { - classfile.addField(name, "Lorg/python/core/PyObject;", Opcodes.ACC_PUBLIC); + classfile.addField(name, $pyObj, Opcodes.ACC_PUBLIC); } } @@ -51,15 +36,11 @@ public void addMethod(Method method, int access) throws Exception { Class<?>[] parameters = method.getParameterTypes(); Class<?> ret = method.getReturnType(); - String sig = makeSignature(parameters, ret); - String name = method.getName(); names.add(name); - - Code code = classfile.addMethod(name, sig, Opcodes.ACC_PUBLIC); - + Code code = classfile.addMethod(name, makeSig(ret, parameters), Opcodes.ACC_PUBLIC); code.aload(0); - code.getfield(classfile.name, name, "Lorg/python/core/PyObject;"); + code.getfield(classfile.name, name, $pyObj); code.dup(); Label returnNull = new Label(); code.ifnull(returnNull); Modified: trunk/jython/src/org/python/compiler/ClassConstants.java =================================================================== --- trunk/jython/src/org/python/compiler/ClassConstants.java 2009-07-26 08:16:28 UTC (rev 6588) +++ trunk/jython/src/org/python/compiler/ClassConstants.java 2009-07-26 15:23:38 UTC (rev 6589) @@ -24,5 +24,4 @@ final static String $str = "Ljava/lang/String;"; final static String $strArr = "[Ljava/lang/String;"; final static String $throwable = "Ljava/lang/Throwable;"; - } Modified: trunk/jython/src/org/python/compiler/JavaMaker.java =================================================================== --- trunk/jython/src/org/python/compiler/JavaMaker.java 2009-07-26 08:16:28 UTC (rev 6588) +++ trunk/jython/src/org/python/compiler/JavaMaker.java 2009-07-26 15:23:38 UTC (rev 6589) @@ -6,7 +6,7 @@ import org.python.core.PyObject; -public class JavaMaker extends ProxyMaker implements ClassConstants { +public class JavaMaker extends ProxyMaker { public String pythonClass, pythonModule; @@ -35,8 +35,7 @@ callSuper(code, "<init>", name, parameters, null, sig); code.visitVarInsn(ALOAD, 0); getArgs(code, parameters); - - code.visitMethodInsn(INVOKEVIRTUAL, classfile.name, "__initProxy__", "([Ljava/lang/Object;)V"); + code.visitMethodInsn(INVOKEVIRTUAL, classfile.name, "__initProxy__", makeSig("V", $objArr)); code.visitInsn(RETURN); } @@ -46,14 +45,14 @@ super.addProxy(); // _initProxy method - Code code = classfile.addMethod("__initProxy__", "([Ljava/lang/Object;)V", Modifier.PUBLIC); + Code code = classfile.addMethod("__initProxy__", makeSig("V", $objArr), Modifier.PUBLIC); code.visitVarInsn(ALOAD, 0); code.visitLdcInsn(pythonModule); code.visitLdcInsn(pythonClass); - code.visitVarInsn(ALOAD, 1); - code.visitMethodInsn(INVOKESTATIC, "org/python/core/Py", "initProxy", "(" + $pyProxy + $str + $str + $objArr + ")V"); + code.visitMethodInsn(INVOKESTATIC, "org/python/core/Py", "initProxy", + makeSig("V", $pyProxy, $str, $str, $objArr)); code.visitInsn(RETURN); } Modified: trunk/jython/src/org/python/compiler/ProxyMaker.java =================================================================== --- trunk/jython/src/org/python/compiler/ProxyMaker.java 2009-07-26 08:16:28 UTC (rev 6588) +++ trunk/jython/src/org/python/compiler/ProxyMaker.java 2009-07-26 15:23:38 UTC (rev 6589) @@ -1,9 +1,6 @@ // Copyright (c) Corporation for National Research Initiatives package org.python.compiler; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; import java.io.OutputStream; import java.lang.reflect.Constructor; import java.lang.reflect.Method; @@ -11,13 +8,13 @@ import java.util.Map; import java.util.Set; +import org.objectweb.asm.Label; +import org.objectweb.asm.Opcodes; import org.python.core.Py; import org.python.core.PyMethod; import org.python.core.PyObject; import org.python.core.PyProxy; import org.python.core.PyReflectedFunction; -import org.objectweb.asm.Label; -import org.objectweb.asm.Opcodes; import org.python.util.Generic; public class ProxyMaker implements ClassConstants, Opcodes @@ -34,7 +31,7 @@ public static final int tOther=9; public static final int tNone=10; - public static Map<Class<?>, Integer> types=fillTypes(); + public static Map<Class<?>, Integer> types = fillTypes(); public static Map<Class<?>, Integer> fillTypes() { Map<Class<?>, Integer> typeMap = Generic.map(); @@ -51,10 +48,15 @@ } public static int getType(Class<?> c) { - if (c == null) return tNone; + if (c == null) { + return tNone; + } Object i = types.get(c); - if (i == null) return tOther; - else return ((Integer)i).intValue(); + if (i == null) { + return tOther; + } else { + return ((Integer)i); + } } /** @@ -89,35 +91,58 @@ Set<String> names; Set<String> supernames = Generic.set(); public ClassFile classfile; + /** The name of the class to build. */ public String myClass; - public ProxyMaker(String classname, Class<?> superclass) { - this.myClass = "org.python.proxies."+classname; - if (superclass.isInterface()) { - this.superclass = Object.class; - this.interfaces = new Class[] {superclass}; - } else { - this.superclass = superclass; - this.interfaces = new Class[0]; - } + /** + * Creates a proxy class maker that produces classes named + * <code>org.python.proxies.(superclassName)</code> with <code>superclass</code> as an + * implemented interface or extended class, depending on the its type. + * + * @deprecated - Use {@link ProxyMaker#ProxyMaker(String, Class, Class[]) + + */ + @Deprecated + public ProxyMaker(String superclassName, Class<?> superclass) { + this("org.python.proxies." + superclassName, + superclass.isInterface() ? Object.class : superclass, + superclass.isInterface() ? new Class<?>[] { superclass} : new Class<?>[0]); + } - public ProxyMaker(String myClass, Class<?> superclass, Class<?>[] interfaces) { - this.myClass = myClass; - if (superclass == null) + /** + * Creates a proxy class maker that produces classes named <code>proxyClassName</code> that + * extends <code>superclass</code> and implements the interfaces in <code>interfaces</code>. + */ + public ProxyMaker(String proxyClassName, Class<?> superclass, Class<?>... interfaces) { + this.myClass = proxyClassName; + if (superclass == null) { superclass = Object.class; + } + if (superclass.isInterface()) { + throw new IllegalArgumentException("Given an interface, " + superclass.getName() + + ", for a proxy superclass"); + } this.superclass = superclass; - if (interfaces == null) + if (interfaces == null) { interfaces = new Class[0]; + } + for (Class<?> interfac : interfaces) { + if (!interfac.isInterface()) { + throw new IllegalArgumentException( + "All classes in the interfaces array must be interfaces, unlike " + + interfac.getName()); + } + } this.interfaces = interfaces; } public static String mapClass(Class<?> c) { String name = c.getName(); int index = name.indexOf("."); - if (index == -1) + if (index == -1) { return name; - + } StringBuffer buf = new StringBuffer(name.length()); int last_index = 0; while (index != -1) { @@ -149,20 +174,25 @@ } } - public static String makeSignature(Class<?>[] sig, Class<?> ret) { - StringBuffer buf=new StringBuffer(); - buf.append("("); - for (Class<?> element : sig) { - buf.append(mapType(element)); + public static String makeSig(Class<?> ret, Class<?>... sig) { + String[] mapped = new String[sig.length]; + for (int i = 0; i < mapped.length; i++) { + mapped[i] = mapType(sig[i]); } - buf.append(")"); - buf.append(mapType(ret)); - return buf.toString(); + return makeSig(mapType(ret), mapped); } + public static String makeSig(String returnType, String... parameterTypes) { + StringBuilder buf = new StringBuilder("("); + for (String param : parameterTypes) { + buf.append(param); + } + return buf.append(')').append(returnType).toString(); + } + public void doConstants() throws Exception { - Code code = classfile.addMethod("<clinit>", "()V", Modifier.STATIC); + Code code = classfile.addMethod("<clinit>", makeSig("V"), Modifier.STATIC); code.return_(); } @@ -276,8 +306,8 @@ String jcallName) throws Exception { - code.invokevirtual("org/python/core/PyObject", jcallName, "(" + $objArr + ")" + $pyObj); - code.invokestatic("org/python/core/Py", "py2"+name, "(" + $pyObj + ")"+type); + code.invokevirtual("org/python/core/PyObject", jcallName, makeSig($pyObj, $objArr)); + code.invokestatic("org/python/core/Py", "py2"+name, makeSig(type, $pyObj)); } @@ -385,10 +415,10 @@ doJavaCall(code, "void", "V", jcallName); break; default: - code.invokevirtual("org/python/core/PyObject", jcallName, "(" + $objArr + ")" + $pyObj); + code.invokevirtual("org/python/core/PyObject", jcallName, makeSig($pyObj, $objArr)); code.ldc(ret.getName()); - code.invokestatic("java/lang/Class","forName", "(" + $str + ")" + $clss); - code.invokestatic("org/python/core/Py", "tojava", "(" + $pyObj + $clss + ")" + $obj); + code.invokestatic("java/lang/Class","forName", makeSig($clss, $str)); + code.invokestatic("org/python/core/Py", "tojava", makeSig($obj, $pyObj, $clss)); // I guess I need this checkcast to keep the verifier happy code.checkcast(mapClass(ret)); break; @@ -429,7 +459,7 @@ code.aload(instLocal); code.aload(excLocal); - code.invokevirtual("org/python/core/PyObject", "_jthrow", "(" + $throwable + ")V"); + code.invokevirtual("org/python/core/PyObject", "_jthrow", makeSig("V", $throwable)); code.visitTryCatchBlock(start, end, handlerStart, "java/lang/Throwable"); code.freeLocal(excLocal); @@ -450,7 +480,7 @@ Class<?>[] parameters = method.getParameterTypes(); Class<?> ret = method.getReturnType(); - String sig = makeSignature(parameters, ret); + String sig = makeSig(ret, parameters); String name = method.getName(); names.add(name); @@ -462,8 +492,8 @@ if (!isAbstract) { int tmp = code.getLocal("org/python/core/PyObject"); - code.invokestatic("org/python/compiler/ProxyMaker", "findPython", "(" + $pyProxy + $str - + ")" + $pyObj); + code.invokestatic("org/python/compiler/ProxyMaker", "findPython", + makeSig($pyObj, $pyProxy, $str)); code.astore(tmp); code.aload(tmp); @@ -480,8 +510,8 @@ addSuperMethod("super__"+name, name, superClass, parameters, ret, sig, access); } else { - code.invokestatic("org/python/compiler/ProxyMaker", "findPython", "(" + $pyProxy + $str - + ")" + $pyObj); + code.invokestatic("org/python/compiler/ProxyMaker", "findPython", + makeSig($pyObj, $pyProxy, $str)); code.dup(); Label returnNull = new Label(); code.ifnull(returnNull); @@ -506,10 +536,9 @@ protected void addMethods(Class<?> c, Set<String> t) throws Exception { Method[] methods = c.getDeclaredMethods(); for (Method method : methods) { - String s = methodString(method); - if (t.contains(s)) + if (!t.add(methodString(method))) { continue; - t.add(s); + } int access = method.getModifiers(); if (Modifier.isStatic(access) || Modifier.isPrivate(access)) { @@ -528,16 +557,18 @@ } } else if (Modifier.isFinal(access)) { continue; + } else if (!Modifier.isPublic(access)) { + continue; // package protected by process of elimination; we can't override } addMethod(method, access); } Class<?> sc = c.getSuperclass(); - if (sc != null) + if (sc != null) { addMethods(sc, t); + } - Class<?>[] ifaces = c.getInterfaces(); - for (Class<?> iface : ifaces) { + for (Class<?> iface : c.getInterfaces()) { addMethods(iface, t); } } @@ -556,15 +587,17 @@ String name = mapClass(c); for (Constructor<?> constructor : constructors) { int access = constructor.getModifiers(); - if (Modifier.isPrivate(access)) + if (Modifier.isPrivate(access)) { continue; - if (Modifier.isNative(access)) + } + if (Modifier.isNative(access)) { access = access & ~Modifier.NATIVE; - if (Modifier.isProtected(access)) + } + if (Modifier.isProtected(access)) { access = access & ~Modifier.PROTECTED | Modifier.PUBLIC; + } Class<?>[] parameters = constructor.getParameterTypes(); - String sig = makeSignature(parameters, Void.TYPE); - addConstructor(name, parameters, Void.TYPE, sig, access); + addConstructor(name, parameters, Void.TYPE, makeSig(Void.TYPE, parameters), access); } } @@ -585,7 +618,6 @@ public void addSuperMethod(Method method, int access) throws Exception { Class<?>[] parameters = method.getParameterTypes(); Class<?> ret = method.getReturnType(); - String sig = makeSignature(parameters, ret); String superClass = mapClass(method.getDeclaringClass()); String superName = method.getName(); String methodName = superName; @@ -594,7 +626,7 @@ access &= ~Modifier.FINAL; } addSuperMethod(methodName, superName, superClass, parameters, - ret, sig, access); + ret, makeSig(ret, parameters), access); } public void addSuperMethod(String methodName, @@ -612,10 +644,11 @@ first that redefines the JC method foo. */ try { - superclass.getMethod(methodName,parameters); + superclass.getMethod(methodName, parameters); return; - } catch(NoSuchMethodException e) { - } catch(SecurityException e) { + } catch (NoSuchMethodException e) { + // OK, no one else defines it, so we need to + } catch (SecurityException e) { return; } } @@ -626,66 +659,65 @@ public void addProxy() throws Exception { // implement PyProxy interface - classfile.addField("__proxy", "Lorg/python/core/PyObject;", - Modifier.PROTECTED); + classfile.addField("__proxy", $pyObj, Modifier.PROTECTED); // setProxy methods - Code code = classfile.addMethod("_setPyInstance", - "(Lorg/python/core/PyObject;)V", - Modifier.PUBLIC); + Code code = classfile.addMethod("_setPyInstance", makeSig("V", $pyObj), Modifier.PUBLIC); code.aload(0); code.aload(1); - code.putfield(classfile.name, "__proxy", "Lorg/python/core/PyObject;"); + code.putfield(classfile.name, "__proxy", $pyObj); code.return_(); // getProxy method - code = classfile.addMethod("_getPyInstance", - "()Lorg/python/core/PyObject;", - Modifier.PUBLIC); + code = classfile.addMethod("_getPyInstance", makeSig($pyObj), Modifier.PUBLIC); code.aload(0); - code.getfield(classfile.name, "__proxy", "Lorg/python/core/PyObject;"); + code.getfield(classfile.name, "__proxy", $pyObj); code.areturn(); + String pySys = "Lorg/python/core/PySystemState;"; // implement PyProxy interface - classfile.addField("__systemState", - "Lorg/python/core/PySystemState;", - Modifier.PROTECTED | Modifier.TRANSIENT); + classfile.addField("__systemState", pySys, Modifier.PROTECTED | Modifier.TRANSIENT); // setProxy method code = classfile.addMethod("_setPySystemState", - "(Lorg/python/core/PySystemState;)V", + makeSig("V", pySys), Modifier.PUBLIC); code.aload(0); code.aload(1); - code.putfield(classfile.name, "__systemState", "Lorg/python/core/PySystemState;"); + code.putfield(classfile.name, "__systemState", pySys); code.return_(); // getProxy method - code = classfile.addMethod("_getPySystemState", - "()Lorg/python/core/PySystemState;", - Modifier.PUBLIC); + code = classfile.addMethod("_getPySystemState", makeSig(pySys), Modifier.PUBLIC); code.aload(0); - code.getfield(classfile.name, "__systemState", "Lorg/python/core/PySystemState;"); + code.getfield(classfile.name, "__systemState", pySys); code.areturn(); } public void addClassDictInit() throws Exception { // classDictInit method classfile.addInterface(mapClass(org.python.core.ClassDictInit.class)); - Code code = classfile.addMethod("classDictInit", - "(" + $pyObj + ")V", - Modifier.PUBLIC | Modifier.STATIC); + Code code = classfile.addMethod("classDictInit", makeSig("V", $pyObj), + Modifier.PUBLIC | Modifier.STATIC); code.aload(0); code.ldc("__supernames__"); int strArray = CodeCompiler.makeStrings(code, supernames); code.aload(strArray); code.freeLocal(strArray); - code.invokestatic("org/python/core/Py", "java2py", "(" + $obj + ")" + $pyObj); - code.invokevirtual("org/python/core/PyObject", "__setitem__", "(" + $str + $pyObj + ")V"); + code.invokestatic("org/python/core/Py", "java2py", makeSig($pyObj, $obj)); + code.invokevirtual("org/python/core/PyObject", "__setitem__", makeSig("V", $str, $pyObj)); code.return_(); } + /** + * Builds this proxy and writes its bytecode to <code>out</code>. + */ + public void build(OutputStream out) throws Exception { + build(); + classfile.write(out); + } + public void build() throws Exception { names = Generic.set(); int access = superclass.getModifiers(); @@ -712,23 +744,4 @@ doConstants(); addClassDictInit(); } - - public static File makeFilename(String name, File dir) { - int index = name.indexOf("."); - if (index == -1) - return new File(dir, name+".class"); - - return makeFilename(name.substring(index+1, name.length()), - new File(dir, name.substring(0, index))); - } - - // This is not general enough - public static OutputStream getFile(String d, String name) - throws IOException - { - File dir = new File(d); - File file = makeFilename(name, dir); - file.getParentFile().mkdirs(); - return new FileOutputStream(file); - } } Modified: trunk/jython/src/org/python/core/MakeProxies.java =================================================================== --- trunk/jython/src/org/python/core/MakeProxies.java 2009-07-26 08:16:28 UTC (rev 6588) +++ trunk/jython/src/org/python/core/MakeProxies.java 2009-07-26 15:23:38 UTC (rev 6589) @@ -32,16 +32,16 @@ public static Class<?> makeAdapter(Class<?> c) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - String name; + AdapterMaker maker = new AdapterMaker(proxyPrefix + c.getName(), c); try { - name = AdapterMaker.makeAdapter(c, bytes); + maker.build(bytes); } catch (Exception exc) { throw Py.JavaError(exc); } - Py.saveClassFile(name, bytes); + Py.saveClassFile(maker.myClass, bytes); - return makeClass(c, null, name, bytes); + return makeClass(c, null, maker.myClass, bytes); } private static final String proxyPrefix = "org.python.proxies."; @@ -82,9 +82,8 @@ fullProxyName, dict); try { - jm.build(); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - jm.classfile.write(bytes); + jm.build(bytes); if (customProxyName != null) { Py.saveClassFile(fullProxyName, bytes, Py.getSystemState().javaproxy_dir); } else { Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-07-26 08:16:28 UTC (rev 6588) +++ trunk/jython/src/org/python/core/Py.java 2009-07-26 15:23:38 UTC (rev 6589) @@ -1143,7 +1143,7 @@ return pye; } - + /** * @deprecated As of Jython 2.5, use {@link PyException#match} instead. */ @@ -1448,7 +1448,7 @@ throw Py.TypeError("None required for void return"); } } - + private final static PyString[] letters = new PyString[256]; static { @@ -1767,10 +1767,12 @@ if (dirname == null) { return; } - byte[] bytes = baos.toByteArray(); + saveClassFile(name, baos.toByteArray(), dirname); + } + + public static void saveClassFile(String name, byte[] bytes, String dirname) { File dir = new File(dirname); File file = makeFilename(name, dir); - new File(file.getParent()).mkdirs(); try { FileOutputStream o = new FileOutputStream(file); @@ -1991,7 +1993,7 @@ PyObject closure) { return func.__call__(arg1, arg2, arg3); } - + @Override public PyObject call(ThreadState state, PyObject arg1, PyObject arg2, PyObject arg3, PyObject arg4, PyObject globals, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2009-07-26 08:16:35
|
Revision: 6588 http://jython.svn.sourceforge.net/jython/?rev=6588&view=rev Author: nriley Date: 2009-07-26 08:16:28 +0000 (Sun, 26 Jul 2009) Log Message: ----------- Remove some unused imports. 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-26 08:16:22 UTC (rev 6587) +++ trunk/jython/src/org/python/util/PythonInterpreter.java 2009-07-26 08:16:28 UTC (rev 6588) @@ -1,7 +1,5 @@ package org.python.util; -import java.io.FilterReader; -import java.io.IOException; import java.io.Reader; import java.io.StringReader; import java.util.Properties; @@ -19,7 +17,6 @@ import org.python.core.PyObject; import org.python.core.PyString; import org.python.core.PyStringMap; -import org.python.core.PySyntaxError; import org.python.core.PySystemState; import org.python.core.__builtin__; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2009-07-26 08:16:30
|
Revision: 6587 http://jython.svn.sourceforge.net/jython/?rev=6587&view=rev Author: nriley Date: 2009-07-26 08:16:22 +0000 (Sun, 26 Jul 2009) Log Message: ----------- JSR 223: Use PY_MAJOR_VERSION.PY_MINOR_VERSION for language version. Modified Paths: -------------- trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java Modified: trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java =================================================================== --- trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java 2009-07-26 07:45:38 UTC (rev 6586) +++ trunk/jython/src/org/python/jsr223/PyScriptEngineFactory.java 2009-07-26 08:16:22 UTC (rev 6587) @@ -27,7 +27,7 @@ } public String getLanguageVersion() { - return "2.5.0"; + return String.format("%s.%s", Version.PY_MAJOR_VERSION, Version.PY_MINOR_VERSION); } public Object getParameter(String key) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2009-07-26 07:45:54
|
Revision: 6586 http://jython.svn.sourceforge.net/jython/?rev=6586&view=rev Author: nriley Date: 2009-07-26 07:45:38 +0000 (Sun, 26 Jul 2009) Log Message: ----------- JSR 223: use Writer and ErrorWriter from ScriptContext; remove unnecessary PySystemState setting. 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-07-25 22:34:45 UTC (rev 6585) +++ trunk/jython/src/org/python/jsr223/PyScriptEngine.java 2009-07-26 07:45:38 UTC (rev 6586) @@ -30,11 +30,13 @@ } public Object eval(String script, ScriptContext context) throws ScriptException { - return eval(compileScript(script, context)); + return eval(compileScript(script, context), context); } - private Object eval(PyCode code) throws ScriptException { + private Object eval(PyCode code, ScriptContext context) throws ScriptException { try { + interp.setOut(context.getWriter()); + interp.setErr(context.getErrorWriter()); return interp.eval(code).__tojava__(Object.class); } catch (PyException pye) { throw scriptException(pye); @@ -42,7 +44,7 @@ } public Object eval(Reader reader, ScriptContext context) throws ScriptException { - return eval(compileScript(reader, context)); + return eval(compileScript(reader, context), context); } public Bindings createBindings() { @@ -190,11 +192,9 @@ private class PyCompiledScript extends CompiledScript { private PyCode code; - private PySystemState systemState; PyCompiledScript(PyCode code) { this.code = code; - this.systemState = Py.getSystemState(); } public ScriptEngine getEngine() { @@ -202,9 +202,7 @@ } public Object eval(ScriptContext ctx) throws ScriptException { - // can't read filename from context at this point - Py.setSystemState(systemState); - return PyScriptEngine.this.eval(code); + return PyScriptEngine.this.eval(code, ctx); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-07-25 22:34:57
|
Revision: 6585 http://jython.svn.sourceforge.net/jython/?rev=6585&view=rev Author: pjenvey Date: 2009-07-25 22:34:45 +0000 (Sat, 25 Jul 2009) Log Message: ----------- quiet KeyErrors triggered during weakref callbacks. these don't seem to happen on the ref counting GC because the ref is always collected before the callback can be triggered Modified Paths: -------------- trunk/jython/Lib/weakref.py Modified: trunk/jython/Lib/weakref.py =================================================================== --- trunk/jython/Lib/weakref.py 2009-07-25 22:16:39 UTC (rev 6584) +++ trunk/jython/Lib/weakref.py 2009-07-25 22:34:45 UTC (rev 6585) @@ -46,7 +46,10 @@ def remove(wr, selfref=ref(self)): self = selfref() if self is not None: - del self.data[wr.key] + try: + del self.data[wr.key] + except KeyError: + pass self._remove = remove UserDict.UserDict.__init__(self, *args, **kw) @@ -232,7 +235,10 @@ def remove(k, selfref=ref(self)): self = selfref() if self is not None: - del self.data[k] + try: + del self.data[k] + except KeyError: + pass self._remove = remove if dict is not None: self.update(dict) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-07-25 22:16:46
|
Revision: 6584 http://jython.svn.sourceforge.net/jython/?rev=6584&view=rev Author: pjenvey Date: 2009-07-25 22:16:39 +0000 (Sat, 25 Jul 2009) Log Message: ----------- from: http://svn.python.org/projects/python/branches/release25-maint/Lib/weakref.py@45853 Added Paths: ----------- trunk/jython/Lib/weakref.py Added: trunk/jython/Lib/weakref.py =================================================================== --- trunk/jython/Lib/weakref.py (rev 0) +++ trunk/jython/Lib/weakref.py 2009-07-25 22:16:39 UTC (rev 6584) @@ -0,0 +1,355 @@ +"""Weak reference support for Python. + +This module is an implementation of PEP 205: + +http://python.sourceforge.net/peps/pep-0205.html +""" + +# Naming convention: Variables named "wr" are weak reference objects; +# they are called this instead of "ref" to avoid name collisions with +# the module-global ref() function imported from _weakref. + +import UserDict + +from _weakref import ( + getweakrefcount, + getweakrefs, + ref, + proxy, + CallableProxyType, + ProxyType, + ReferenceType) + +from exceptions import ReferenceError + + +ProxyTypes = (ProxyType, CallableProxyType) + +__all__ = ["ref", "proxy", "getweakrefcount", "getweakrefs", + "WeakKeyDictionary", "ReferenceType", "ProxyType", + "CallableProxyType", "ProxyTypes", "WeakValueDictionary"] + + +class WeakValueDictionary(UserDict.UserDict): + """Mapping class that references values weakly. + + Entries in the dictionary will be discarded when no strong + reference to the value exists anymore + """ + # We inherit the constructor without worrying about the input + # dictionary; since it uses our .update() method, we get the right + # checks (if the other dictionary is a WeakValueDictionary, + # objects are unwrapped on the way out, and we always wrap on the + # way in). + + def __init__(self, *args, **kw): + def remove(wr, selfref=ref(self)): + self = selfref() + if self is not None: + del self.data[wr.key] + self._remove = remove + UserDict.UserDict.__init__(self, *args, **kw) + + def __getitem__(self, key): + o = self.data[key]() + if o is None: + raise KeyError, key + else: + return o + + def __contains__(self, key): + try: + o = self.data[key]() + except KeyError: + return False + return o is not None + + def has_key(self, key): + try: + o = self.data[key]() + except KeyError: + return False + return o is not None + + def __repr__(self): + return "<WeakValueDictionary at %s>" % id(self) + + def __setitem__(self, key, value): + self.data[key] = KeyedRef(value, self._remove, key) + + def copy(self): + new = WeakValueDictionary() + for key, wr in self.data.items(): + o = wr() + if o is not None: + new[key] = o + return new + + def get(self, key, default=None): + try: + wr = self.data[key] + except KeyError: + return default + else: + o = wr() + if o is None: + # This should only happen + return default + else: + return o + + def items(self): + L = [] + for key, wr in self.data.items(): + o = wr() + if o is not None: + L.append((key, o)) + return L + + def iteritems(self): + for wr in self.data.itervalues(): + value = wr() + if value is not None: + yield wr.key, value + + def iterkeys(self): + return self.data.iterkeys() + + def __iter__(self): + return self.data.iterkeys() + + def itervaluerefs(self): + """Return an iterator that yields the weak references to the values. + + The references are not guaranteed to be 'live' at the time + they are used, so the result of calling the references needs + to be checked before being used. This can be used to avoid + creating references that will cause the garbage collector to + keep the values around longer than needed. + + """ + return self.data.itervalues() + + def itervalues(self): + for wr in self.data.itervalues(): + obj = wr() + if obj is not None: + yield obj + + def popitem(self): + while 1: + key, wr = self.data.popitem() + o = wr() + if o is not None: + return key, o + + def pop(self, key, *args): + try: + o = self.data.pop(key)() + except KeyError: + if args: + return args[0] + raise + if o is None: + raise KeyError, key + else: + return o + + def setdefault(self, key, default=None): + try: + wr = self.data[key] + except KeyError: + self.data[key] = KeyedRef(default, self._remove, key) + return default + else: + return wr() + + def update(self, dict=None, **kwargs): + d = self.data + if dict is not None: + if not hasattr(dict, "items"): + dict = type({})(dict) + for key, o in dict.items(): + d[key] = KeyedRef(o, self._remove, key) + if len(kwargs): + self.update(kwargs) + + def valuerefs(self): + """Return a list of weak references to the values. + + The references are not guaranteed to be 'live' at the time + they are used, so the result of calling the references needs + to be checked before being used. This can be used to avoid + creating references that will cause the garbage collector to + keep the values around longer than needed. + + """ + return self.data.values() + + def values(self): + L = [] + for wr in self.data.values(): + o = wr() + if o is not None: + L.append(o) + return L + + +class KeyedRef(ref): + """Specialized reference that includes a key corresponding to the value. + + This is used in the WeakValueDictionary to avoid having to create + a function object for each key stored in the mapping. A shared + callback object can use the 'key' attribute of a KeyedRef instead + of getting a reference to the key from an enclosing scope. + + """ + + __slots__ = "key", + + def __new__(type, ob, callback, key): + self = ref.__new__(type, ob, callback) + self.key = key + return self + + def __init__(self, ob, callback, key): + super(KeyedRef, self).__init__(ob, callback) + + +class WeakKeyDictionary(UserDict.UserDict): + """ Mapping class that references keys weakly. + + Entries in the dictionary will be discarded when there is no + longer a strong reference to the key. This can be used to + associate additional data with an object owned by other parts of + an application without adding attributes to those objects. This + can be especially useful with objects that override attribute + accesses. + """ + + def __init__(self, dict=None): + self.data = {} + def remove(k, selfref=ref(self)): + self = selfref() + if self is not None: + del self.data[k] + self._remove = remove + if dict is not None: self.update(dict) + + def __delitem__(self, key): + del self.data[ref(key)] + + def __getitem__(self, key): + return self.data[ref(key)] + + def __repr__(self): + return "<WeakKeyDictionary at %s>" % id(self) + + def __setitem__(self, key, value): + self.data[ref(key, self._remove)] = value + + def copy(self): + new = WeakKeyDictionary() + for key, value in self.data.items(): + o = key() + if o is not None: + new[o] = value + return new + + def get(self, key, default=None): + return self.data.get(ref(key),default) + + def has_key(self, key): + try: + wr = ref(key) + except TypeError: + return 0 + return wr in self.data + + def __contains__(self, key): + try: + wr = ref(key) + except TypeError: + return 0 + return wr in self.data + + def items(self): + L = [] + for key, value in self.data.items(): + o = key() + if o is not None: + L.append((o, value)) + return L + + def iteritems(self): + for wr, value in self.data.iteritems(): + key = wr() + if key is not None: + yield key, value + + def iterkeyrefs(self): + """Return an iterator that yields the weak references to the keys. + + The references are not guaranteed to be 'live' at the time + they are used, so the result of calling the references needs + to be checked before being used. This can be used to avoid + creating references that will cause the garbage collector to + keep the keys around longer than needed. + + """ + return self.data.iterkeys() + + def iterkeys(self): + for wr in self.data.iterkeys(): + obj = wr() + if obj is not None: + yield obj + + def __iter__(self): + return self.iterkeys() + + def itervalues(self): + return self.data.itervalues() + + def keyrefs(self): + """Return a list of weak references to the keys. + + The references are not guaranteed to be 'live' at the time + they are used, so the result of calling the references needs + to be checked before being used. This can be used to avoid + creating references that will cause the garbage collector to + keep the keys around longer than needed. + + """ + return self.data.keys() + + def keys(self): + L = [] + for wr in self.data.keys(): + o = wr() + if o is not None: + L.append(o) + return L + + def popitem(self): + while 1: + key, value = self.data.popitem() + o = key() + if o is not None: + return o, value + + def pop(self, key, *args): + return self.data.pop(ref(key), *args) + + def setdefault(self, key, default=None): + return self.data.setdefault(ref(key, self._remove),default) + + def update(self, dict=None, **kwargs): + d = self.data + if dict is not None: + if not hasattr(dict, "items"): + dict = type({})(dict) + for key, value in dict.items(): + d[ref(key, self._remove)] = value + if len(kwargs): + self.update(kwargs) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-07-25 21:39:35
|
Revision: 6583 http://jython.svn.sourceforge.net/jython/?rev=6583&view=rev Author: pjenvey Date: 2009-07-25 21:39:13 +0000 (Sat, 25 Jul 2009) Log Message: ----------- read LONGVARCHAR from a character stream Reader since it's destined for unicode. for better TEXT handling on mysql Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/DataHandler.java Modified: trunk/jython/src/com/ziclix/python/sql/DataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/DataHandler.java 2009-07-25 14:38:23 UTC (rev 6582) +++ trunk/jython/src/com/ziclix/python/sql/DataHandler.java 2009-07-25 21:39:13 UTC (rev 6583) @@ -12,9 +12,7 @@ import org.python.core.PyFile; import org.python.core.PyObject; import org.python.core.PyList; -import org.python.core.util.StringUtil; -import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -239,30 +237,12 @@ case Types.CHAR: case Types.VARCHAR: String string = set.getString(col); - - obj = (string == null) ? Py.None : Py.newUnicode(string); + obj = string == null ? Py.None : Py.newUnicode(string); break; case Types.LONGVARCHAR: - InputStream longvarchar = set.getAsciiStream(col); - - if (longvarchar == null) { - obj = Py.None; - } else { - try { - longvarchar = new BufferedInputStream(longvarchar); - - byte[] bytes = DataHandler.read(longvarchar); - - if (bytes != null) { - obj = Py.newUnicode(StringUtil.fromBytes(bytes)); - } - } finally { - try { - longvarchar.close(); - } catch (Throwable t) {} - } - } + Reader reader = set.getCharacterStream(col); + obj = reader == null ? Py.None : Py.newUnicode(read(reader)); break; case Types.NUMERIC: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-25 14:38:30
|
Revision: 6582 http://jython.svn.sourceforge.net/jython/?rev=6582&view=rev Author: fwierzbicki Date: 2009-07-25 14:38:23 +0000 (Sat, 25 Jul 2009) Log Message: ----------- Oops, left test code in. Modified Paths: -------------- trunk/jython/Lib/pawt/swing.py Modified: trunk/jython/Lib/pawt/swing.py =================================================================== --- trunk/jython/Lib/pawt/swing.py 2009-07-25 14:37:44 UTC (rev 6581) +++ trunk/jython/Lib/pawt/swing.py 2009-07-25 14:38:23 UTC (rev 6582) @@ -4,8 +4,6 @@ from javax import swing import sys -print "testing" - def test(panel, size=None, name='Swing Tester'): f = swing.JFrame(name, windowClosing=lambda event: sys.exit(0)) if hasattr(panel, 'init'): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-07-25 14:37:51
|
Revision: 6581 http://jython.svn.sourceforge.net/jython/?rev=6581&view=rev Author: fwierzbicki Date: 2009-07-25 14:37:44 +0000 (Sat, 25 Jul 2009) Log Message: ----------- Remove the goofy imports since we no longer support JDK 1.1, but keep the API around for backwards compatibility. Modified Paths: -------------- trunk/jython/Lib/pawt/swing.py Modified: trunk/jython/Lib/pawt/swing.py =================================================================== --- trunk/jython/Lib/pawt/swing.py 2009-07-25 02:34:28 UTC (rev 6580) +++ trunk/jython/Lib/pawt/swing.py 2009-07-25 14:37:44 UTC (rev 6581) @@ -1,23 +1,11 @@ """ -A hack to make pawt.swing point to the java swing library. -This allows code which imports pawt.swing to work on both JDK1.1 and 1.2 +No longer needed, but keeping for backwards compatibility. """ -swing = None - -try: - import javax.swing.Icon - from javax import swing -except (ImportError, AttributeError): - try: - import java.awt.swing.Icon - from java.awt import swing - except (ImportError, AttributeError): - try: - import com.sun.java.swing.Icon - from com.sun.java import swing - except (ImportError, AttributeError): - raise ImportError, 'swing not defined in javax.swing or java.awt.swing or com.sun.java.swing' +from javax import swing import sys + +print "testing" + def test(panel, size=None, name='Swing Tester'): f = swing.JFrame(name, windowClosing=lambda event: sys.exit(0)) if hasattr(panel, 'init'): @@ -36,7 +24,3 @@ pawt.swing = swing sys.modules['pawt.swing'] = swing swing.__dict__['test'] = test - - #These two lines help out jythonc to figure out this very strange module - swing.__dict__['__file__'] = __file__ - swing.__dict__['__jpythonc_name__'] = 'pawt.swing' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-07-25 02:34:47
|
Revision: 6580 http://jython.svn.sourceforge.net/jython/?rev=6580&view=rev Author: pjenvey Date: 2009-07-25 02:34:28 +0000 (Sat, 25 Jul 2009) Log Message: ----------- don't convert mysql YEAR columns to datetime.dates Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/DataHandler.java Modified: trunk/jython/src/com/ziclix/python/sql/DataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/DataHandler.java 2009-07-24 05:34:08 UTC (rev 6579) +++ trunk/jython/src/com/ziclix/python/sql/DataHandler.java 2009-07-25 02:34:28 UTC (rev 6580) @@ -303,7 +303,9 @@ break; case Types.DATE: - obj = Py.newDate(set.getDate(col)); + Object date = set.getObject(col); + // don't newDate mysql YEAR columns + obj = date instanceof Date ? Py.newDate((Date)date) : Py.java2py(date); break; case Types.NULL: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-07-24 04:59:07
|
Revision: 6575 http://jython.svn.sourceforge.net/jython/?rev=6575&view=rev Author: pjenvey Date: 2009-07-24 04:58:46 +0000 (Fri, 24 Jul 2009) Log Message: ----------- coding standards/whitespace Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/handler/MySQLDataHandler.java Modified: trunk/jython/src/com/ziclix/python/sql/handler/MySQLDataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/handler/MySQLDataHandler.java 2009-07-24 04:58:25 UTC (rev 6574) +++ trunk/jython/src/com/ziclix/python/sql/handler/MySQLDataHandler.java 2009-07-24 04:58:46 UTC (rev 6575) @@ -30,49 +30,49 @@ */ public class MySQLDataHandler extends RowIdHandler { - /** - * Decorator for handling MySql specific issues. - * - * @param datahandler the delegate DataHandler - */ - public MySQLDataHandler(DataHandler datahandler) { - super(datahandler); - } + /** + * Decorator for handling MySql specific issues. + * + * @param datahandler the delegate DataHandler + */ + public MySQLDataHandler(DataHandler datahandler) { + super(datahandler); + } - protected String getRowIdMethodName() { - return "getLastInsertID"; - } - - /** - * Handle LONGVARCHAR. - */ - public void setJDBCObject(PreparedStatement stmt, int index, PyObject object, int type) throws SQLException { - - if (DataHandler.checkNull(stmt, index, object, type)) { - return; + @Override + protected String getRowIdMethodName() { + return "getLastInsertID"; } - switch (type) { - - case Types.LONGVARCHAR: - // XXX: Only works with ASCII data! - byte[] bytes; - if (object instanceof PyFile) { - bytes = ((PyFile) object).read().toBytes(); - } else { - String varchar = (String) object.__tojava__(String.class); - bytes = StringUtil.toBytes(varchar); + /** + * Handle LONGVARCHAR. + */ + @Override + public void setJDBCObject(PreparedStatement stmt, int index, PyObject object, int type) + throws SQLException { + if (DataHandler.checkNull(stmt, index, object, type)) { + return; } - InputStream stream = new ByteArrayInputStream(bytes); - stream = new BufferedInputStream(stream); + switch (type) { + case Types.LONGVARCHAR: + // XXX: Only works with ASCII data! + byte[] bytes; + if (object instanceof PyFile) { + bytes = ((PyFile) object).read().toBytes(); + } else { + String varchar = (String) object.__tojava__(String.class); + bytes = StringUtil.toBytes(varchar); + } + InputStream stream = new ByteArrayInputStream(bytes); + stream = new BufferedInputStream(stream); - stmt.setAsciiStream(index, stream, bytes.length); - break; + stmt.setAsciiStream(index, stream, bytes.length); + break; - default : - super.setJDBCObject(stmt, index, object, type); - break; + default : + super.setJDBCObject(stmt, index, object, type); + break; + } } - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2009-07-23 07:38:03
|
Revision: 6571 http://jython.svn.sourceforge.net/jython/?rev=6571&view=rev Author: nriley Date: 2009-07-23 07:37:58 +0000 (Thu, 23 Jul 2009) Log Message: ----------- Support JSR 223 on JDK 5 with LiveTribe implementation; update NEWS. Modified Paths: -------------- trunk/jython/NEWS trunk/jython/build.xml Added Paths: ----------- trunk/jython/extlibs/livetribe-jsr223-2.0.5.jar Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-07-23 06:31:56 UTC (rev 6570) +++ trunk/jython/NEWS 2009-07-23 07:37:58 UTC (rev 6571) @@ -6,6 +6,7 @@ - [ 1859477 ] Dynamically loaded ServletFilters like PyServlet - Setting __javaname__ in classes subclassing Java classes or implementing Java interfaces sets the name of the produced proxy class. + - Built in JSR 223 scripting engine, with LiveTribe JSR 223 implementation for JDK 5 Bugs Fixed - [ 645615 ] cannot import through symbolic links - [ 1366 ] parsing of lamda expression fails @@ -14,6 +15,8 @@ - [ 1381 ] Redundant declarations of interface implementation hides overriden methods - [ 1189 ] MD5 hash is incorrectly calculated when string contains non-latin chars and using python md5 lib - [ 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 Jython 2.5.0 The same as rc4. Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2009-07-23 06:31:56 UTC (rev 6570) +++ trunk/jython/build.xml 2009-07-23 07:37:58 UTC (rev 6571) @@ -185,6 +185,7 @@ <pathelement path="${extlibs.dir}/antlr-2.7.7.jar" /> <pathelement path="${extlibs.dir}/antlr-3.1.3.jar" /> <pathelement path="${extlibs.dir}/stringtemplate-3.2.jar" /> + <pathelement path="${extlibs.dir}/livetribe-jsr223-2.0.5.jar" /> <pathelement path="${extlibs.dir}/asm-3.1.jar" /> <pathelement path="${extlibs.dir}/asm-commons-3.1.jar" /> Added: trunk/jython/extlibs/livetribe-jsr223-2.0.5.jar =================================================================== (Binary files differ) Property changes on: trunk/jython/extlibs/livetribe-jsr223-2.0.5.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2009-07-23 06:31:58
|
Revision: 6570 http://jython.svn.sourceforge.net/jython/?rev=6570&view=rev Author: nriley Date: 2009-07-23 06:31:56 +0000 (Thu, 23 Jul 2009) Log Message: ----------- Restore some accidentally-reverted changes from the JSR 223 merge. Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/PyFinalizableInstance.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-07-23 05:16:14 UTC (rev 6569) +++ trunk/jython/src/org/python/core/Py.java 2009-07-23 06:31:56 UTC (rev 6570) @@ -1027,7 +1027,7 @@ stderr.println(getStackTrace((Throwable) javaError)); } } - stderr.println(formatException(type, value, tb)); + stderr.println(formatException(type, value)); } /** @@ -1080,7 +1080,7 @@ out.print("^\n"); } - static String formatException(PyObject type, PyObject value, PyObject tb) { + public static String formatException(PyObject type, PyObject value) { StringBuilder buf = new StringBuilder(); if (PyException.isExceptionClass(type)) { @@ -1106,7 +1106,7 @@ } else { buf.append(type.__str__()); } - if (value != Py.None) { + if (value != null && value != Py.None) { // only print colon if the str() of the object is not the empty string PyObject s = value.__str__(); if (!(s instanceof PyString) || s.__len__() != 0) { Modified: trunk/jython/src/org/python/core/PyFinalizableInstance.java =================================================================== --- trunk/jython/src/org/python/core/PyFinalizableInstance.java 2009-07-23 05:16:14 UTC (rev 6569) +++ trunk/jython/src/org/python/core/PyFinalizableInstance.java 2009-07-23 06:31:56 UTC (rev 6570) @@ -31,7 +31,7 @@ } catch (PyException e) { ; } Py.stderr.println("Exception " + - Py.formatException(exc.type, exc.value, exc.traceback) + + Py.formatException(exc.type, exc.value) + " in " + method + " ignored"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2009-07-23 05:16:19
|
Revision: 6569 http://jython.svn.sourceforge.net/jython/?rev=6569&view=rev Author: nriley Date: 2009-07-23 05:16:14 +0000 (Thu, 23 Jul 2009) Log Message: ----------- JSR 223 branch has been merged into trunk. Removed Paths: ------------- branches/jsr223/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2009-07-23 05:15:51
|
Revision: 6568 http://jython.svn.sourceforge.net/jython/?rev=6568&view=rev Author: nriley Date: 2009-07-23 05:15:49 +0000 (Thu, 23 Jul 2009) Log Message: ----------- Removed merge tracking for "svnmerge" for https://jython.svn.sourceforge.net/svnroot/jython/branches/jsr223 Property Changed: ---------------- trunk/jython/ Property changes on: trunk/jython ___________________________________________________________________ Modified: svnmerge-integrated - /branches/jsr223:1-6566 /branches/pbcvm:1-6045 + /branches/pbcvm:1-6045 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |