From: <cg...@us...> - 2007-04-18 04:57:20
|
Revision: 3166 http://svn.sourceforge.net/jython/?rev=3166&view=rev Author: cgroves Date: 2007-04-17 21:57:10 -0700 (Tue, 17 Apr 2007) Log Message: ----------- apply patch #1636030 from LeoUser for bug #1603686. The comparison and shift operators in int now handle longs as arguments Modified Paths: -------------- trunk/jython/NEWS trunk/jython/src/org/python/core/PyInteger.java Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-04-18 04:33:00 UTC (rev 3165) +++ trunk/jython/NEWS 2007-04-18 04:57:10 UTC (rev 3166) @@ -24,6 +24,7 @@ - [ 1619040 ] dict.fromkeys() should take iterable - [ 1658647 ] type(x) calls x.__class__.__init__ - [ 1699556 ] SAXException descends from Java's Exception instead of Python's + - [ 1603686 ] Unmarshaling long-error Patches applied - [ 1681774 ] str.decode, unicode.encode and str(u'') fixes - [ 1682423 ] Convert PyModule to a new-style class Modified: trunk/jython/src/org/python/core/PyInteger.java =================================================================== --- trunk/jython/src/org/python/core/PyInteger.java 2007-04-18 04:33:00 UTC (rev 3165) +++ trunk/jython/src/org/python/core/PyInteger.java 2007-04-18 04:57:10 UTC (rev 3166) @@ -1124,7 +1124,10 @@ final PyObject int___truediv__(PyObject right) { if (right instanceof PyInteger) return __float__().__truediv__(right); - return null; + else if(right instanceof PyLong) + return int___long__().__truediv__(right); + else + return null; } public PyObject __rtruediv__(PyObject left) { @@ -1134,7 +1137,10 @@ final PyObject int___rtruediv__(PyObject left) { if (left instanceof PyInteger) return left.__float__().__truediv__(this); - return null; + else if(left instanceof PyLong) + return left.__truediv__(int___long__()); + else + return null; } private static int modulo(int x, int y, int xdivy) { @@ -1293,11 +1299,13 @@ } final PyObject int___lshift__(PyObject right) { - int rightv; - if (right instanceof PyInteger) - rightv = ((PyInteger)right).getValue(); - else - return null; + int rightv; + if (right instanceof PyInteger) + rightv = ((PyInteger) right).getValue(); + else if (right instanceof PyLong) + return int___long__().__lshift__(right); + else + return null; if (rightv > 31) return Py.newInteger(0); @@ -1306,12 +1314,14 @@ return Py.newInteger(getValue() << rightv); } - final PyObject int___rlshift__(PyObject left){ - int leftv; - if (left instanceof PyInteger) - leftv = ((PyInteger)left).getValue(); - else - return null; + final PyObject int___rlshift__(PyObject left) { + int leftv; + if (left instanceof PyInteger) + leftv = ((PyInteger) left).getValue(); + else if (left instanceof PyLong) + return left.__rlshift__(int___long__()); + else + return null; if (getValue() > 31) return Py.newInteger(0); @@ -1324,23 +1334,27 @@ return int___rshift__(right); } - final PyObject int___rshift__(PyObject right) { - int rightv; - if (right instanceof PyInteger) - rightv = ((PyInteger)right).getValue(); - else - return null; + final PyObject int___rshift__(PyObject right) { + int rightv; + if (right instanceof PyInteger) + rightv = ((PyInteger) right).getValue(); + else if (right instanceof PyLong) + return int___long__().__rshift__(right); + else + return null; - if(rightv < 0) - throw Py.ValueError("negative shift count"); + if (rightv < 0) + throw Py.ValueError("negative shift count"); - return Py.newInteger(getValue() >> rightv); - } + return Py.newInteger(getValue() >> rightv); + } final PyObject int___rrshift__(PyObject left) { int leftv; if (left instanceof PyInteger) leftv = ((PyInteger)left).getValue(); + else if(left instanceof PyLong) + return left.__rshift__(int___long__()); else return null; @@ -1357,7 +1371,9 @@ final PyObject int___and__(PyObject right) { int rightv; if (right instanceof PyInteger) - rightv = ((PyInteger)right).getValue(); + rightv = ((PyInteger) right).getValue(); + else if (right instanceof PyLong) + return int___long__().__and__(right); else return null; @@ -1372,20 +1388,24 @@ return int___xor__(right); } - final PyObject int___xor__(PyObject right) { - int rightv; - if (right instanceof PyInteger) - rightv = ((PyInteger)right).getValue(); - else - return null; + final PyObject int___xor__(PyObject right) { + int rightv; + if (right instanceof PyInteger) + rightv = ((PyInteger) right).getValue(); + else if (right instanceof PyLong) + return int___long__().__xor__(right); + else + return null; - return Py.newInteger(getValue() ^ rightv); + return Py.newInteger(getValue() ^ rightv); } final PyObject int___rxor__(PyObject left){ int leftv; if (left instanceof PyInteger) leftv = ((PyInteger)left).getValue(); + else if(left instanceof PyLong) + return left.__rxor__(int___long__()); else return null; @@ -1396,14 +1416,16 @@ return int___or__(right); } - final PyObject int___or__(PyObject right) { - int rightv; - if (right instanceof PyInteger) - rightv = ((PyInteger)right).getValue(); - else - return null; + final PyObject int___or__(PyObject right) { + int rightv; + if (right instanceof PyInteger) + rightv = ((PyInteger) right).getValue(); + else if (right instanceof PyLong) + return int___long__().__or__(right); + else + return null; - return Py.newInteger(getValue() | rightv); + return Py.newInteger(getValue() | rightv); } final PyObject int___ror__(PyObject left){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-04-20 04:19:32
|
Revision: 3173 http://svn.sourceforge.net/jython/?rev=3173&view=rev Author: cgroves Date: 2007-04-19 21:19:30 -0700 (Thu, 19 Apr 2007) Log Message: ----------- Fix for bug #1691096 and #1230674. Pass in the containing frame's compiler flag when importing or evalling, and use the CodeCompilers flags in created PyCode. Modified Paths: -------------- trunk/jython/NEWS trunk/jython/src/org/python/compiler/CodeCompiler.java trunk/jython/src/org/python/core/CompilerFlags.java trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-04-19 05:37:48 UTC (rev 3172) +++ trunk/jython/NEWS 2007-04-20 04:19:30 UTC (rev 3173) @@ -25,10 +25,14 @@ - [ 1658647 ] type(x) calls x.__class__.__init__ - [ 1699556 ] SAXException descends from Java's Exception instead of Python's - [ 1603686 ] Unmarshaling long-error + - [ 1230674 ] eval with from future does not work through import + - [ 663592 ] Problems calling an overriden class in the constructor Patches applied - [ 1681774 ] str.decode, unicode.encode and str(u'') fixes - [ 1682423 ] Convert PyModule to a new-style class - [ 1682498 ] Fix int(None) raising an AttributeError + - [ 1684172 ] Changes to make compileall work + Jython 2.2 beta1 New features Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2007-04-19 05:37:48 UTC (rev 3172) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2007-04-20 04:19:30 UTC (rev 3173) @@ -6,6 +6,7 @@ import java.util.Hashtable; import java.util.Stack; import java.util.Vector; + import org.python.core.CompilerFlags; import org.python.core.PyComplex; import org.python.core.PyFloat; @@ -2102,7 +2103,7 @@ scope.setup_closure(); scope.dump(); module.PyCode(retSuite, name, true, className, - false, false, node.beginLine, scope).get(code); + false, false, node.beginLine, scope, cflags).get(code); if (!makeClosure(scope)) { if (mrefs.PyFunction_init1 == 0) { @@ -2168,7 +2169,7 @@ scope.dump(); //Make code object out of suite module.PyCode(new Suite(node.body, node), name, false, name, - true, false, node.beginLine, scope).get(code); + true, false, node.beginLine, scope, cflags).get(code); //Get doc string (if there) getDocString(node.body); Modified: trunk/jython/src/org/python/core/CompilerFlags.java =================================================================== --- trunk/jython/src/org/python/core/CompilerFlags.java 2007-04-19 05:37:48 UTC (rev 3172) +++ trunk/jython/src/org/python/core/CompilerFlags.java 2007-04-20 04:19:30 UTC (rev 3173) @@ -1,10 +1,10 @@ package org.python.core; -public class CompilerFlags extends Object { +public class CompilerFlags { + + public CompilerFlags(){} - public CompilerFlags() {} - public CompilerFlags(int co_flags) { if ((co_flags & org.python.core.PyTableCode.CO_NESTED) != 0) { this.nested_scopes = true; @@ -16,6 +16,13 @@ this.generator_allowed = true; } } + + public String toString() { + return "CompilerFlags[division=" + division + " nested_scopes=" + nested_scopes + " generators=" + + generator_allowed + "]"; + } + + public boolean nested_scopes = true; public boolean division; Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2007-04-19 05:37:48 UTC (rev 3172) +++ trunk/jython/src/org/python/core/imp.java 2007-04-20 04:19:30 UTC (rev 3173) @@ -176,7 +176,7 @@ } org.python.parser.ast.modType node; try { - node = parser.parse(fp, "exec", filename, null); + node = parser.parse(fp, "exec", filename, Py.getCompilerFlags()); } finally { fp.close(); } @@ -187,7 +187,7 @@ true, false, true, - null); + Py.getCompilerFlags()); return ofp.toByteArray(); } catch(Throwable t) { throw parser.fixParseError(null, t, filename); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-04-22 21:09:34
|
Revision: 3176 http://svn.sourceforge.net/jython/?rev=3176&view=rev Author: cgroves Date: 2007-04-22 14:09:32 -0700 (Sun, 22 Apr 2007) Log Message: ----------- Added JLineConsole to provide readline like functionality through JLine. Moved the raw_input replacement out of ReadlineConsole into InteractiveConsole so the JLine and Readline consoles could share it. Modified Paths: -------------- trunk/jython/NEWS trunk/jython/build.xml trunk/jython/src/org/python/util/InteractiveConsole.java trunk/jython/src/org/python/util/ReadlineConsole.java Added Paths: ----------- trunk/jython/src/org/python/util/JLineConsole.java Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-04-20 04:21:44 UTC (rev 3175) +++ trunk/jython/NEWS 2007-04-22 21:09:32 UTC (rev 3176) @@ -6,6 +6,8 @@ functions - Classmethods added to newstyle classes - array is a newstyle class + - org.python.util.JLineConsole provides readline-like functionality with + JLine without requiring native readline Bugs fixed - [ 1599012 ] current directory is prepended to entries in sys.path Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2007-04-20 04:21:44 UTC (rev 3175) +++ trunk/jython/build.xml 2007-04-22 21:09:32 UTC (rev 3176) @@ -91,7 +91,10 @@ # - org.gnu.readline readline.jar=${basedir}/../externals/external-jars/readline.jar +# - jline +jline.jar=${basedir}/../externals/external-jars/jline-0.9.91.jar + # - zxJDBC # (for mysql, see www.mysql.com/downloads/api-jdbc-stable.html) # (for postgres, see http://jdbc.postgresql.org/) @@ -172,6 +175,7 @@ <!-- classpaths --> <path id="main.classpath"> <pathelement path="${readline.jar}" /> + <pathelement path="${jline.jar}" /> <pathelement path="${servlet.jar}" /> <pathelement path="${informix.jar}" /> <pathelement path="${oracle.jar}" /> @@ -186,6 +190,7 @@ <available property="secureclassloader.present" classname="java.security.SecureClassLoader" /> <available property="servlet.present" classname="javax.servlet.Servlet" classpath="${servlet.jar}" /> <available property="readline.present" classname="org.gnu.readline.Readline" classpath="${readline.jar}" /> + <available property="jline.present" classname="jline.Terminal" classpath="${jline.jar}" /> <available property="informix.present" classname="com.informix.jdbc.IfxDriver" classpath="${informix.jar}" /> <available property="mysql.present" classname="org.gjt.mm.mysql.Driver" classpath="${mysql.jar}" /> <available property="postgresql.present" classname="org.postgresql.Driver" classpath="${postgresql.jar}" /> @@ -247,6 +252,7 @@ <taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" classpathref="svn.classpath" /> <!-- Require all of the optional jars for a full build --> <fail unless="readline.present" message="readline jar not present" /> + <fail unless="jline.present" message="jline jar not present" /> <fail unless="servlet.present" message="servlet jar not present" /> <fail unless="informix.present" message="informix jar not present" /> <fail unless="mysql.present" message="mysql jar not present" /> @@ -268,6 +274,7 @@ <echo>secureclassloader = '${secureclassloader.present}'</echo> <echo>servlet = '${servlet.present}'</echo> <echo>readline = '${readline.present}'</echo> + <echo>jline = '${jline.present}'</echo> <echo>oracle = '${oracle.present}'</echo> <echo>informix = '${informix.present}'</echo> <echo>mysql = '${mysql.present}'</echo> @@ -436,6 +443,7 @@ <exclude name="org/python/parser/python.java" /> <exclude name="**/PyServlet.java" unless="servlet.present" /> <exclude name="**/ReadlineConsole.java" unless="readline.present" /> + <exclude name="**/JLineConsole.java" unless="jline.present" /> <exclude name="**/handler/InformixDataHandler.java" unless="informix.present" /> <exclude name="**/handler/MySQLDataHandler.java" unless="mysql.present" /> <exclude name="**/handler/OracleDataHandler.java" unless="oracle.present" /> @@ -503,6 +511,7 @@ <attribute name="secureclassloader" value="${secureclassloader.present}" /> <attribute name="servlet" value="${servlet.present}" /> <attribute name="readline" value="${readline.present}" /> + <attribute name="jline" value="${jline.present}" /> <attribute name="oracle" value="${oracle.present}" /> <attribute name="informix" value="${informix.present}" /> <attribute name="mysql" value="${mysql.present}" /> @@ -674,6 +683,7 @@ <attribute name="secureclassloader" value="${secureclassloader.present}" /> <attribute name="servlet" value="${servlet.present}" /> <attribute name="readline" value="${readline.present}" /> + <attribute name="jline" value="${jline.present}" /> <attribute name="oracle" value="${oracle.present}" /> <attribute name="informix" value="${informix.present}" /> <attribute name="mysql" value="${mysql.present}" /> Modified: trunk/jython/src/org/python/util/InteractiveConsole.java =================================================================== --- trunk/jython/src/org/python/util/InteractiveConsole.java 2007-04-20 04:21:44 UTC (rev 3175) +++ trunk/jython/src/org/python/util/InteractiveConsole.java 2007-04-22 21:09:32 UTC (rev 3176) @@ -1,57 +1,85 @@ // Copyright (c) Corporation for National Research Initiatives package org.python.util; -import org.python.core.*; +import org.python.core.Py; +import org.python.core.PyBuiltinFunctionSet; +import org.python.core.PyException; +import org.python.core.PyObject; +import org.python.core.PySystemState; +import org.python.core.__builtin__; + // Based on CPython-1.5.2's code module +public class InteractiveConsole extends InteractiveInterpreter { -public class InteractiveConsole extends InteractiveInterpreter { + public static final String CONSOLE_FILENAME = "<console>"; + public String filename; public InteractiveConsole() { - this(null, "<console>"); + this(null, CONSOLE_FILENAME); } + public InteractiveConsole(PyObject locals) { - this(locals, "<console>"); + this(locals, CONSOLE_FILENAME); } + public InteractiveConsole(PyObject locals, String filename) { + this(locals, filename, false); + } + + /** + * @param replaceRawInput - + * if true, we hook this Class's raw_input into the builtins + * table so that clients like cmd.Cmd use it. + */ + public InteractiveConsole(PyObject locals, String filename, boolean replaceRawInput) { super(locals); this.filename = filename; + if(replaceRawInput) { + PyObject newRawInput = new PyBuiltinFunctionSet("raw_input", 0, 0, 1) { + + public PyObject __call__() { + return __call__(Py.EmptyString); + } + + public PyObject __call__(PyObject prompt) { + return Py.newString(raw_input(prompt)); + } + }; + Py.getSystemState().builtins.__setitem__("raw_input", newRawInput); + } } /** * Closely emulate the interactive Python console. - * - * The optional banner argument specifies the banner to print before - * the first interaction; by default it prints a banner similar to the - * one printed by the real Python interpreter, followed by the current - * class name in parentheses (so as not to confuse this with the real - * interpreter -- since it's so close!). - **/ + * + * The optional banner argument specifies the banner to print before the + * first interaction; by default it prints "Jython <version> on <platform>". + */ public void interact() { interact(getDefaultBanner()); } public static String getDefaultBanner() { - return "Jython " + PySystemState.version + " on " - + PySystemState.platform; + return "Jython " + PySystemState.version + " on " + PySystemState.platform; } public void interact(String banner) { - if (banner != null) { + if(banner != null) { write(banner); write("\n"); } // Dummy exec in order to speed up response on first command exec("2"); - //System.err.println("interp2"); + // System.err.println("interp2"); boolean more = false; - while (true) { + while(true) { PyObject prompt = more ? systemState.ps2 : systemState.ps1; String line; try { line = raw_input(prompt); - } catch (PyException exc) { - if (!Py.matchException(exc, Py.EOFError)) + } catch(PyException exc) { + if(!Py.matchException(exc, Py.EOFError)) throw exc; write("\n"); break; @@ -62,36 +90,35 @@ /** * Push a line to the interpreter. - * + * * The line should not have a trailing newline; it may have internal - * newlines. The line is appended to a buffer and the interpreter's - * runsource() method is called with the concatenated contents of the - * buffer as source. If this indicates that the command was executed - * or invalid, the buffer is reset; otherwise, the command is - * incomplete, and the buffer is left as it was after the line was - * appended. The return value is 1 if more input is required, 0 if the - * line was dealt with in some way (this is the same as runsource()). - **/ - + * newlines. The line is appended to a buffer and the interpreter's + * runsource() method is called with the concatenated contents of the buffer + * as source. If this indicates that the command was executed or invalid, + * the buffer is reset; otherwise, the command is incomplete, and the buffer + * is left as it was after the line was appended. The return value is 1 if + * more input is required, 0 if the line was dealt with in some way (this is + * the same as runsource()). + */ public boolean push(String line) { - if (buffer.length() > 0) + if(buffer.length() > 0) buffer.append("\n"); buffer.append(line); boolean more = runsource(buffer.toString(), filename); - if (!more) + if(!more) resetbuffer(); return more; } /** * Write a prompt and read a line. - * - * The returned line does not include the trailing newline. When the - * user enters the EOF key sequence, EOFError is raised. - * + * + * The returned line does not include the trailing newline. When the user + * enters the EOF key sequence, EOFError is raised. + * * The base implementation uses the built-in function raw_input(); a * subclass may replace this with a different implementation. - **/ + */ public String raw_input(PyObject prompt) { return __builtin__.raw_input(prompt); } Added: trunk/jython/src/org/python/util/JLineConsole.java =================================================================== --- trunk/jython/src/org/python/util/JLineConsole.java (rev 0) +++ trunk/jython/src/org/python/util/JLineConsole.java 2007-04-22 21:09:32 UTC (rev 3176) @@ -0,0 +1,48 @@ +package org.python.util; + +import java.io.IOException; +import jline.ConsoleReader; +import jline.Terminal; +import org.python.core.Py; +import org.python.core.PyObject; + +/** + * This class uses <a href="http://jline.sourceforge.net/">JLine</a> to provide + * readline like functionality to its console without requiring native readline + * support. + */ +public class JLineConsole extends InteractiveConsole { + + public JLineConsole() { + this(null); + } + + public JLineConsole(PyObject locals) { + this(locals, CONSOLE_FILENAME); + } + + public JLineConsole(PyObject locals, String filename) { + super(locals, filename, true); + Terminal.setupTerminal(); + try { + reader = new ConsoleReader(); + } catch(IOException e) { + throw new RuntimeException(e); + } + } + + public String raw_input(PyObject prompt) { + String line = null; + try { + line = reader.readLine(prompt.toString()); + } catch(IOException io) { + throw Py.IOError(io); + } + if(line == null) { + throw Py.EOFError("Ctrl-D exit"); + } + return line.endsWith("\n") ? line.substring(0, line.length() - 1) : line; + } + + private ConsoleReader reader; +} Modified: trunk/jython/src/org/python/util/ReadlineConsole.java =================================================================== --- trunk/jython/src/org/python/util/ReadlineConsole.java 2007-04-20 04:21:44 UTC (rev 3175) +++ trunk/jython/src/org/python/util/ReadlineConsole.java 2007-04-22 21:09:32 UTC (rev 3176) @@ -3,81 +3,57 @@ import org.gnu.readline.Readline; import org.gnu.readline.ReadlineLibrary; -import org.python.core.ArgParser; import org.python.core.Py; import org.python.core.PyException; import org.python.core.PyObject; -import org.python.core.PyString; import org.python.core.PySystemState; /** - * Uses: - * <a href="http://java-readline.sourceforge.net/">Java Readline</a> - * <p/> - * + * Uses: <a href="http://java-readline.sourceforge.net/">Java Readline</a> <p/> + * * Based on CPython-1.5.2's code module - * + * */ public class ReadlineConsole extends InteractiveConsole { + public String filename; public ReadlineConsole() { - this(null, "<console>"); + this(null, CONSOLE_FILENAME); } + public ReadlineConsole(PyObject locals) { - this(locals, "<console>"); + this(locals, CONSOLE_FILENAME); } + public ReadlineConsole(PyObject locals, String filename) { - super(locals,filename); - String backingLib = PySystemState.registry.getProperty( - "python.console.readlinelib", "Editline"); + super(locals, filename, true); + String backingLib = PySystemState.registry.getProperty("python.console.readlinelib", + "Editline"); try { Readline.load(ReadlineLibrary.byName(backingLib)); - } catch (RuntimeException e) { + } catch(RuntimeException e) { // Silently ignore errors during load of the native library. // Will use a pure java fallback. } - - // hook into the builtins table so that clients like cmd.Cmd can - // also use readline. - Py.getSystemState().builtins.__setitem__("raw_input", - Py.newJavaFunc(this.getClass(), "_raw_input")); - Readline.initReadline("jython"); } - /** * Write a prompt and read a line. - * - * The returned line does not include the trailing newline. When the - * user enters the EOF key sequence, EOFError is raised. - * + * + * The returned line does not include the trailing newline. When the user + * enters the EOF key sequence, EOFError is raised. + * * This subclass implements the functionality using JavaReadline. - **/ + */ public String raw_input(PyObject prompt) { - return _raw_input(new PyObject[] { prompt }, new String[0]); - } - - /** - * Central point of dispatch to Readline library for all clients, - * whether the console itself or others like cmd.Cmd interpreters. - * Both of these uses come through here. - * - * @param args should contain a single prompt - * @param kws keywords - * @return the user input - **/ - public static String _raw_input(PyObject args[], String kws[]) { - ArgParser ap = new ArgParser("raw_input", args, kws, "prompt"); - PyObject prompt = ap.getPyObject(0, new PyString("")); try { - String line = Readline.readline( - prompt==null ? "" : prompt.toString()); + String line = Readline.readline(prompt == null ? "" : prompt.toString()); return (line == null ? "" : line); - } catch (java.io.EOFException eofe) { + } catch(java.io.EOFException eofe) { throw new PyException(Py.EOFError); - } catch (java.io.IOException e) { + } catch(java.io.IOException e) { throw new PyException(Py.IOError); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-04-23 03:45:35
|
Revision: 3178 http://svn.sourceforge.net/jython/?rev=3178&view=rev Author: cgroves Date: 2007-04-22 20:45:34 -0700 (Sun, 22 Apr 2007) Log Message: ----------- Apply LeoUser's patch #1637931 to fix bug #448398. We now close PyFile in finalize and in a shutdown hook. Modified Paths: -------------- trunk/jython/NEWS trunk/jython/src/org/python/core/PyFile.java Added Paths: ----------- trunk/jython/bugtests/test397.py trunk/jython/bugtests/test397m.py Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-04-22 22:13:34 UTC (rev 3177) +++ trunk/jython/NEWS 2007-04-23 03:45:34 UTC (rev 3178) @@ -29,6 +29,7 @@ - [ 1603686 ] Unmarshaling long-error - [ 1230674 ] eval with from future does not work through import - [ 663592 ] Problems calling an overriden class in the constructor + - [ 448398 ] open('test.txt', 'w').write('test') fails Patches applied - [ 1681774 ] str.decode, unicode.encode and str(u'') fixes - [ 1682423 ] Convert PyModule to a new-style class Added: trunk/jython/bugtests/test397.py =================================================================== --- trunk/jython/bugtests/test397.py (rev 0) +++ trunk/jython/bugtests/test397.py 2007-04-23 03:45:34 UTC (rev 3178) @@ -0,0 +1,41 @@ +''' +Checks that files are closed in three situations: +1. Garbage collection/finalization close +2. Regular close +3. Shutdown time, close out open PyFiles +''' + +import os +import support + +from java.io import File +from java.lang import System, Thread + +def check(fn='test.txt'): + f = File(fn) + if not f.exists(): + raise support.TestError('"%s" should exist' % fn) + if not f.length(): + raise support.TestError('"%s" should have contents' % fn) + os.remove(fn) + + +open("garbagecollected", "w").write("test") + +#Wait up to 2 seconds for garbage collected to disappear +System.gc() +for i in range(10): + if not os.path.exists('garbagecollected'): + break + Thread.sleep(200) + +check("garbagecollected") + +f = open("normalclose", "w") +f.write("test") +f.close() +check("normalclose") + +#test397m writes to "shutdown" and exits +support.runJython('test397m.py') +check('shutdown') Added: trunk/jython/bugtests/test397m.py =================================================================== --- trunk/jython/bugtests/test397m.py (rev 0) +++ trunk/jython/bugtests/test397m.py 2007-04-23 03:45:34 UTC (rev 3178) @@ -0,0 +1 @@ +open("shutdown", "w").write('exiting') Modified: trunk/jython/src/org/python/core/PyFile.java =================================================================== --- trunk/jython/src/org/python/core/PyFile.java 2007-04-22 22:13:34 UTC (rev 3177) +++ trunk/jython/src/org/python/core/PyFile.java 2007-04-23 03:45:34 UTC (rev 3178) @@ -1,7 +1,12 @@ // Copyright (c) Corporation for National Research Initiatives package org.python.core; -import java.io.*; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.LinkedList; // To do: // - readinto(array) @@ -13,7 +18,6 @@ /** * A python file wrapper around a java stream, reader/writer or file. */ - public class PyFile extends PyObject { @@ -1094,18 +1098,7 @@ String nameArg = ap.getString(0, null); String modeArg = ap.getString(1, "r"); int buffArg = ap.getInt(2, 0); - FileWrapper fw = _setup(nameArg, modeArg, buffArg); - - //xxx: c&p'ed from one of the constructors. - fw.setMode(modeArg); - this.name = nameArg; - this.mode = modeArg; - this.softspace = false; - this.closed = false; - if (modeArg.indexOf('b') < 0) - this.file = new TextWrapper(fw); - else - this.file = fw; + file_init(_setup(nameArg, modeArg, buffArg), nameArg, modeArg); } public PyFile() { @@ -1117,15 +1110,21 @@ } public PyFile(FileWrapper file, String name, String mode) { + file_init(file, name, mode); + } + + private void file_init(FileWrapper file, String name, String mode){ file.setMode(mode); this.name = name; this.mode = mode; this.softspace = false; this.closed = false; - if (mode.indexOf('b') < 0) + if (mode.indexOf('b') < 0){ this.file = new TextWrapper(file); - else + }else{ this.file = file; + } + closer = new Closer(this.file); } public PyFile(java.io.InputStream istream, java.io.OutputStream ostream, @@ -1483,10 +1482,9 @@ } final void file_close() { - try { - file.close(); - } catch (java.io.IOException e) { - throw Py.IOError(e); + if(closer != null){ + closer.close(); + closer = null; } closed = true; file = new FileWrapper(); @@ -1570,4 +1568,86 @@ public boolean getClosed() { return closed; } + + protected void finalize() throws Throwable { + super.finalize(); + if(closer != null) { + closer.close(); + } + } + + /** + * A mechanism to make sure PyFiles are closed on exit. On creation Closer + * adds itself to a list of Closers that will be run by PyFileCloser on JVM + * shutdown. When a PyFile's close or finalize methods are called, PyFile calls + * its Closer.close which clears Closer out of the shutdown queue. + * + * We use a regular object here rather than WeakReferences and their + * ilk as they may be collected before the shutdown hook runs. There's no + * guarantee that finalize will be called during shutdown, so we can't use + * it. It's vital that this Closer has no reference to the PyFile it's + * closing so the PyFile remains garbage collectable. + */ + private static class Closer { + + public Closer(FileWrapper fw){ + this.fw = fw; + //Add ourselves to the queue of Closers to be run on shutdown + synchronized(closers) { + closers.add(this); + } + } + + public void close() { + synchronized(closers) { + if(!closers.remove(this)){ + return; + } + } + _close(); + } + + public void _close(){ + try { + fw.close(); + } catch(java.io.IOException e) { + throw Py.IOError(e); + } finally { + fw = null; + } + } + + private FileWrapper fw; + } + + + private Closer closer; + + private static LinkedList closers = new LinkedList(); + static { + try { + Runtime.getRuntime().addShutdownHook(new PyFileCloser()); + } catch(SecurityException e) { + Py.writeDebug("PyFile", "Can't register file closer hook"); + } + } + + private static class PyFileCloser extends Thread { + + public PyFileCloser() { + super("Jython Shutdown File Closer"); + } + + public void run() { + synchronized(closers) { + while(closers.size() > 0) { + try { + ((Closer)closers.pop())._close(); + } catch(PyException e) {} + } + } + } + } + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-04-23 04:01:29
|
Revision: 3180 http://svn.sourceforge.net/jython/?rev=3180&view=rev Author: cgroves Date: 2007-04-22 21:01:28 -0700 (Sun, 22 Apr 2007) Log Message: ----------- patch #1657100 from mattshelton. include SimpleXMLRPCServer from CPython and add a testcase for it Modified Paths: -------------- trunk/jython/build.Lib.include.properties Added Paths: ----------- trunk/jython/Lib/test/test_SimpleXMLRPCServer.py Added: trunk/jython/Lib/test/test_SimpleXMLRPCServer.py =================================================================== --- trunk/jython/Lib/test/test_SimpleXMLRPCServer.py (rev 0) +++ trunk/jython/Lib/test/test_SimpleXMLRPCServer.py 2007-04-23 04:01:28 UTC (rev 3180) @@ -0,0 +1,88 @@ +# +# Matt Shelton <ma...@ma...> +# + +from SimpleXMLRPCServer import SimpleXMLRPCServer +import threading, xmlrpclib, unittest + +HOST = "127.0.0.1" +PORT = 7218 + +def multiply(x, y): + return x * y + +class MyService: + """This test class is going to be used to test an entire class being + exposed via XML-RPC.""" + + def _dispatch(self, method, params): + """This method is called whenever a call is made to the + service.""" + func = getattr(self, 'expose_' + method) + return func(*params) + + def expose_squared(self, x): + """Square""" + return x * x + +class ServerThread(threading.Thread): + """A test harness for launching a SimpleXMLRPCServer instance in the + background.""" + def __init__(self, server): + threading.Thread.__init__(self) + self.server = server + + def run(self): + self.server.socket.settimeout(5) + self.server.allow_reuse_address = 1 + self.server.handle_request() + self.server.server_close() + +class SimpleXMLRPCServerTestCase(unittest.TestCase): + """Test case for the Python SimpleXMLRPCServer module.""" + def test_exposeLambda(self): + """Expose a lambda function via XML-RPC.""" + # Create a server instance. + server = SimpleXMLRPCServer((HOST, PORT)) + server.register_function(lambda x,y: x+y, 'add') + ServerThread(server).start() + + # Access the exposed service. + client = xmlrpclib.ServerProxy("http://%s:%d" % (HOST, PORT)) + self.assertEqual(client.add(10, 20), 30) + + def test_exposeFunction1(self): + """Expose a function via XML-RPC.""" + server = SimpleXMLRPCServer((HOST, PORT + 1)) + server.register_function(multiply) + ServerThread(server).start() + + # Access the exposed service. + client = xmlrpclib.ServerProxy("http://%s:%d" % (HOST, PORT + 1)) + self.assertEqual(client.multiply(5, 10), 50) + + def test_exposeFunction2(self): + """Expose a function using a different name via XML-RPC.""" + server = SimpleXMLRPCServer((HOST, PORT + 2)) + server.register_function(multiply, "mult") + ServerThread(server).start() + + # Access the exposed service. + client = xmlrpclib.ServerProxy("http://%s:%d" % (HOST, PORT + 2)) + self.assertEqual(client.mult(7, 11), 77) + + def test_exposeClass(self): + """Expose an entire class and test the _dispatch method.""" + server = SimpleXMLRPCServer((HOST, PORT + 3)) + server.register_instance(MyService()) + ServerThread(server).start() + + # Access the exposed service. + client = xmlrpclib.ServerProxy("http://%s:%d" % (HOST, PORT + 3)) + self.assertEqual(client.squared(10), 100) + + +if __name__ == "__main__": + unittest.main() + +# vim:et:ts=4:sw=4: Modified: trunk/jython/build.Lib.include.properties =================================================================== --- trunk/jython/build.Lib.include.properties 2007-04-23 03:52:01 UTC (rev 3179) +++ trunk/jython/build.Lib.include.properties 2007-04-23 04:01:28 UTC (rev 3180) @@ -97,6 +97,7 @@ shlex.py shutil.py SimpleHTTPServer.py +SimpleXMLRPCServer.py site.py smtplib.py sndhdr.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-04-23 04:15:36
|
Revision: 3181 http://svn.sourceforge.net/jython/?rev=3181&view=rev Author: cgroves Date: 2007-04-22 21:15:35 -0700 (Sun, 22 Apr 2007) Log Message: ----------- fix bug #1671373. Include jythonc generated modules in determining if a directory is a python package Modified Paths: -------------- trunk/jython/NEWS trunk/jython/src/org/python/core/PathPackageManager.java Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-04-23 04:01:28 UTC (rev 3180) +++ trunk/jython/NEWS 2007-04-23 04:15:35 UTC (rev 3181) @@ -30,6 +30,7 @@ - [ 1230674 ] eval with from future does not work through import - [ 663592 ] Problems calling an overriden class in the constructor - [ 448398 ] open('test.txt', 'w').write('test') fails + - [ 1671373 ] A "$_PyInner.class" file in a package causes import to fail Patches applied - [ 1681774 ] str.decode, unicode.encode and str(u'') fixes - [ 1682423 ] Convert PyModule to a new-style class Modified: trunk/jython/src/org/python/core/PathPackageManager.java =================================================================== --- trunk/jython/src/org/python/core/PathPackageManager.java 2007-04-23 04:01:28 UTC (rev 3180) +++ trunk/jython/src/org/python/core/PathPackageManager.java 2007-04-23 04:15:35 UTC (rev 3181) @@ -59,10 +59,10 @@ private boolean python; public boolean accept(File dir, String name) { - if (name.endsWith(".py") || name.endsWith("$py.class")) { - this.python = true; - } else if (name.endsWith(".class")) { - this.java = true; + if(name.endsWith(".py") || name.endsWith("$py.class") || name.endsWith("$_PyInner.class")) { + python = true; + }else if (name.endsWith(".class")) { + java = true; } return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-04-24 20:38:20
|
Revision: 3187 http://svn.sourceforge.net/jython/?rev=3187&view=rev Author: fwierzbicki Date: 2007-04-24 13:38:18 -0700 (Tue, 24 Apr 2007) Log Message: ----------- Fix for #1642285. Empty class files in jar files are treated as if they cannot be accessed. Empty class files in jars have been seen in the wild (for example, in jars distributed by bea for weblogic). test398 creates such a jar file generates a fake cache creation. Modified Paths: -------------- trunk/jython/src/org/python/core/PackageManager.java Added Paths: ----------- trunk/jython/bugtests/test398.py Added: trunk/jython/bugtests/test398.py =================================================================== --- trunk/jython/bugtests/test398.py (rev 0) +++ trunk/jython/bugtests/test398.py 2007-04-24 20:38:18 UTC (rev 3187) @@ -0,0 +1,71 @@ +""" +test fix for bug #1642285 + +Try importing from a jar which contains a .class file which is completely empty (0bytes). +Make sure that the bad class file is skipped while good class file is processed. + +Although this is an aberrant .class file, it has been seen in the wild (see bug report, found in a weblogic +jar). + +""" + +import support +import sys +import os + +from java.io import File +from java.lang import String +from java.util import Properties +from org.python.core import SysPackageManager + +PACKAGE = "test398javapackage" +CACHEDIR = "test398cache" +BAD_CLAZZ = "test398j1" +GOOD_CLAZZ = "test398j2" +JARDIR = "test398jar" +JARFILE = "test398.jar" +GOOD_CLAZZ_FILE = File(PACKAGE, "%s.class" % GOOD_CLAZZ) # java.io.File +BAD_CLAZZ_FILE = File(PACKAGE, "%s.class" % BAD_CLAZZ) # java.io.File + +def mkdir(dir): + if not os.path.exists(dir): + os.mkdir(dir) + +def mkjavaclass(): + mkdir(PACKAGE) + f = open("%s/%s.java" % (PACKAGE, GOOD_CLAZZ), "w") + f.write(""" +package %s; +public class %s { +} +""" % (PACKAGE, GOOD_CLAZZ)) + f.close() + support.compileJava("%s/%s.java" % (PACKAGE, GOOD_CLAZZ)) + +def mkbadclass(): + mkdir(PACKAGE) + f = open("%s/%s.class" % (PACKAGE, BAD_CLAZZ), "w") + f.close() + +def mkjar(): + mkdir(JARDIR) + jarFile = File(JARDIR, JARFILE) + jarPacker = support.JarPacker(jarFile, bufsize=128) + jarPacker.addFile(GOOD_CLAZZ_FILE, parentDirName=PACKAGE) + jarPacker.addFile(BAD_CLAZZ_FILE, parentDirName=PACKAGE) + jarPacker.close() + return jarFile + +def mkprops(): + props = Properties() + props.setProperty("java.ext.dirs", String(JARDIR)); + props.setProperty("python.security.respectJavaAccessibility", String("true")); + return props + +# create a .jar file containing a .class file +mkjavaclass() +mkbadclass() +jarFile = mkjar() +props = mkprops() +man = SysPackageManager(File(CACHEDIR, "packages"), props) +assert os.path.exists(os.path.join(CACHEDIR, "packages", "test398.pkc")) Modified: trunk/jython/src/org/python/core/PackageManager.java =================================================================== --- trunk/jython/src/org/python/core/PackageManager.java 2007-04-24 05:42:42 UTC (rev 3186) +++ trunk/jython/src/org/python/core/PackageManager.java 2007-04-24 20:38:18 UTC (rev 3187) @@ -3,6 +3,8 @@ package org.python.core; +import java.io.EOFException; + /** * Abstract package manager. */ @@ -168,15 +170,20 @@ throws java.io.IOException { java.io.DataInputStream istream = new java.io.DataInputStream(cstream); - int magic = istream.readInt(); - + try { + int magic = istream.readInt(); + if (magic != 0xcafebabe) { + return -1; + } + } catch (EOFException eof) { + //Empty or 1 byte file. + return -1; + } //int minor = istream.readShort(); //int major = istream.readShort(); - if (magic != 0xcafebabe) - return -1; // Check versions??? // System.out.println("magic: "+magic+", "+major+", "+minor); int nconstants = istream.readShort(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-04-25 06:02:40
|
Revision: 3189 http://svn.sourceforge.net/jython/?rev=3189&view=rev Author: cgroves Date: 2007-04-24 23:02:10 -0700 (Tue, 24 Apr 2007) Log Message: ----------- Don't call dict.update(obj) when we've determined obj is a list. Fixes bug #1671431, dir not working on database connection objects Modified Paths: -------------- trunk/jython/NEWS trunk/jython/src/org/python/core/PyObject.java Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-04-25 05:30:10 UTC (rev 3188) +++ trunk/jython/NEWS 2007-04-25 06:02:10 UTC (rev 3189) @@ -31,6 +31,7 @@ - [ 663592 ] Problems calling an overriden class in the constructor - [ 448398 ] open('test.txt', 'w').write('test') fails - [ 1671373 ] A "$_PyInner.class" file in a package causes import to fail + - [ 1671431 ] dir function does not work with database connection object Patches applied - [ 1681774 ] str.decode, unicode.encode and str(u'') fixes - [ 1682423 ] Convert PyModule to a new-style class Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2007-04-25 05:30:10 UTC (rev 3188) +++ trunk/jython/src/org/python/core/PyObject.java 2007-04-25 06:02:10 UTC (rev 3189) @@ -1086,8 +1086,9 @@ for (; (name = lst_iter.__iternext__())!= null; ) { accum.__setitem__(name, Py.None); } + } else { + accum.update(obj); } - accum.update(obj); } protected void __rawdir__(PyDictionary accum) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-04-30 07:08:59
|
Revision: 3202 http://svn.sourceforge.net/jython/?rev=3202&view=rev Author: cgroves Date: 2007-04-30 00:08:57 -0700 (Mon, 30 Apr 2007) Log Message: ----------- test_zlib is from CPython's trunk and had no output, but we were pulling over the output from the CPython 2.2 test_zlib which was calling regrtest to mark it as a failure Modified Paths: -------------- trunk/jython/Lib/test/regrtest.py trunk/jython/build.xml Modified: trunk/jython/Lib/test/regrtest.py =================================================================== --- trunk/jython/Lib/test/regrtest.py 2007-04-30 06:57:46 UTC (rev 3201) +++ trunk/jython/Lib/test/regrtest.py 2007-04-30 07:08:57 UTC (rev 3202) @@ -1065,7 +1065,6 @@ test_threaded_import test_trace test_weakref - test_zlib ''', } Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2007-04-30 06:57:46 UTC (rev 3201) +++ trunk/jython/build.xml 2007-04-30 07:08:57 UTC (rev 3202) @@ -626,6 +626,7 @@ <patternset> <includesfile name="${jython.base.dir}/build.Lib.include.properties" /> <exclude name="test/output/test_sax"/> + <exclude name="test/output/test_zlib"/> </patternset> </fileset> </copy> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-05-05 18:42:25
|
Revision: 3207 http://svn.sourceforge.net/jython/?rev=3207&view=rev Author: cgroves Date: 2007-05-05 11:42:22 -0700 (Sat, 05 May 2007) Log Message: ----------- add Vista to known operating systems to fix bug #1713513 Modified Paths: -------------- trunk/jython/Lib/javashell.py trunk/jython/NEWS Modified: trunk/jython/Lib/javashell.py =================================================================== --- trunk/jython/Lib/javashell.py 2007-05-05 16:05:06 UTC (rev 3206) +++ trunk/jython/Lib/javashell.py 2007-05-05 18:42:22 UTC (rev 3207) @@ -138,7 +138,8 @@ _osTypeMap = ( ( "nt", ( 'nt', 'Windows NT', 'Windows NT 4.0', 'WindowsNT', - 'Windows 2000', 'Windows 2003', 'Windows XP', 'Windows CE' )), + 'Windows 2000', 'Windows 2003', 'Windows XP', 'Windows CE', + 'Windows Vista' )), ( "dos", ( 'dos', 'Windows 95', 'Windows 98', 'Windows ME' )), ( "mac", ( 'mac', 'MacOS', 'Darwin' )), ( "None", ( 'None', )), Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-05-05 16:05:06 UTC (rev 3206) +++ trunk/jython/NEWS 2007-05-05 18:42:22 UTC (rev 3207) @@ -32,6 +32,7 @@ - [ 448398 ] open('test.txt', 'w').write('test') fails - [ 1671373 ] A "$_PyInner.class" file in a package causes import to fail - [ 1671431 ] dir function does not work with database connection object + - [ 1713513 ] os.environ fails in Windows Vista JDK 1.6_01 Patches applied - [ 1681774 ] str.decode, unicode.encode and str(u'') fixes - [ 1682423 ] Convert PyModule to a new-style class This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kz...@us...> - 2007-05-06 20:55:48
|
Revision: 3213 http://svn.sourceforge.net/jython/?rev=3213&view=rev Author: kzuberi Date: 2007-05-06 13:55:46 -0700 (Sun, 06 May 2007) Log Message: ----------- revert binascii changes from r3205, caused regressions in test_quopri Modified Paths: -------------- trunk/jython/NEWS trunk/jython/src/org/python/modules/binascii.java Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-05-06 06:44:44 UTC (rev 3212) +++ trunk/jython/NEWS 2007-05-06 20:55:46 UTC (rev 3213) @@ -38,7 +38,6 @@ - [ 1682423 ] Convert PyModule to a new-style class - [ 1682498 ] Fix int(None) raising an AttributeError - [ 1684172 ] Changes to make compileall work - - [ 1626844 ] fixes for failing binascii unit tests - [ 1628469 ] fixes for failing builtin tests Modified: trunk/jython/src/org/python/modules/binascii.java =================================================================== --- trunk/jython/src/org/python/modules/binascii.java 2007-05-06 06:44:44 UTC (rev 3212) +++ trunk/jython/src/org/python/modules/binascii.java 2007-05-06 20:55:46 UTC (rev 3213) @@ -9,14 +9,10 @@ package org.python.modules; -import java.util.regex.Pattern; - -import org.python.core.ArgParser; import org.python.core.Py; import org.python.core.PyException; import org.python.core.PyObject; import org.python.core.PyString; -import org.python.core.PyStringMap; import org.python.core.PyTuple; /** @@ -128,21 +124,11 @@ public static String __doc__ = "Conversion between binary data and ASCII"; - public static final PyObject Error = Py.makeClass("Error", - new PyObject[] { Py.Exception }, - Py.newJavaCode(binascii.class, "empty__init__"), - Py.None); + public static final PyString Error = new PyString("binascii.Error"); - public static PyObject empty__init__(PyObject[] arg, String[] kws) { - PyObject dict = new PyStringMap(); - dict.__setitem__("__module__", new PyString("binascii")); - return dict; - } + public static final PyString Incomplete = + new PyString("binascii.Incomplete"); - public static final PyObject Incomplete = Py.makeClass("Incomplete", - new PyObject[] { Py.Exception }, - Py.newJavaCode(binascii.class, "empty__init__"), - Py.None); // hqx lookup table, ascii->binary. private static char RUNCHAR = 0x90; @@ -291,7 +277,7 @@ int bin_len = (ascii_data.charAt(0) - ' ') & 077; - for (i = 0; bin_len > 0 && ascii_len > 0; i++, ascii_len--) { + for (i = 0; bin_len > 0; i++, ascii_len--) { this_ch = ascii_data.charAt(i+1); if (this_ch == '\n' || this_ch == '\r' || ascii_len <= 0) { // Whitespace. Assume some spaces got eaten at @@ -318,7 +304,6 @@ bin_len--; } } - // Finally, check that if there's anything left on the line // that it's whitespace only. while (ascii_len-- > 0) { @@ -329,11 +314,6 @@ throw new PyException(Error, "Trailing garbage"); } } - - // finally, if we haven't decoded enough stuff, fill it up with zeros - for (; i<bin_len; i++) - bin_data.append((char)0); - return bin_data.toString(); } @@ -835,6 +815,7 @@ private static char[] hexdigit = "0123456789abcdef".toCharArray(); + public static PyString __doc__b2a_hex = new PyString( "b2a_hex(data) -> s; Hexadecimal representation of binary data.\n" + "\n" + @@ -898,140 +879,8 @@ return a2b_hex(argbuf); } - final private static char[] upper_hexdigit = "0123456789ABCDEF".toCharArray(); - - private static StringBuffer qpEscape(StringBuffer sb, char c) - { - sb.append('='); - sb.append(upper_hexdigit[(c >>> 4) & 0xF]); - sb.append(upper_hexdigit[c & 0xF]); - return sb; - } - final private static Pattern WS = Pattern.compile("=\r?\n|[\t ]+$"); - final private static Pattern UNDERSCORE = Pattern.compile("_"); - final public static PyString __doc__a2b_qp = new PyString("Decode a string of qp-encoded data"); - - public static boolean getIntFlagAsBool(ArgParser ap, int index, int dflt, String errMsg) { - boolean val; - try { - val = ap.getInt(index, dflt) != 0; - } catch (PyException e) { - if (Py.matchException(e, Py.AttributeError) || Py.matchException(e, Py.ValueError)) - throw Py.TypeError(errMsg); - throw e; - } - return val; - } - - public static String a2b_qp(PyObject[] arg, String[] kws) - { - ArgParser ap = new ArgParser("a2b_qp", arg, kws, new String[] {"s", "header"}); - String s = ap.getString(0); - StringBuffer sb = new StringBuffer(); - boolean header = getIntFlagAsBool(ap, 1, 0, "an integer is required"); - - if (header) - s = UNDERSCORE.matcher(s).replaceAll(" "); - - s = WS.matcher(s).replaceAll(""); - - for (int i=0, m=s.length(); i<m;) { - char c = s.charAt(i++); - if (c == '=') { - if (i < m) { - c = s.charAt(i++); - if (c == '=') { - sb.append(c); - } else if ((c >= '0' && c <= '9' || c >= 'A' && c <= 'F') && i < m) { - char nc = s.charAt(i++); - if ((nc >= '0' && nc <= '9' || nc >= 'A' && nc <= 'F')) { - sb.append((char)(Character.digit(c, 16) << 4 | Character.digit(nc, 16))); - } else { - sb.append('=').append(c).append(nc); - } - } else if (c != '\n') { - sb.append('=').append(c); - } - } - } else { - sb.append(c); - } - } - - return sb.toString(); - } - - final private static Pattern RN_TO_N = Pattern.compile("\r\n"); - final private static Pattern N_TO_RN = Pattern.compile("(?<!\r)\n"); - - final public static PyString __doc__b2a_qp = new PyString("b2a_qp(data, quotetabs=0, istext=1, header=0) -> s;\n" - + "Encode a string using quoted-printable encoding.\n\n" - + "On encoding, when istext is set, newlines are not encoded, and white\n" - + "space at end of lines is. When istext is not set, \r and \n (CR/LF) are\n" - + "both encoded. When quotetabs is set, space and tabs are encoded."); - - public static String b2a_qp(PyObject[] arg, String[] kws) { - ArgParser ap = new ArgParser("b2a_qp", arg, kws, new String[] {"s", "quotetabs", "istext", "header"}); - String s = ap.getString(0); - boolean quotetabs = getIntFlagAsBool(ap, 1, 0, "an integer is required"); - boolean istext = getIntFlagAsBool(ap, 2, 1, "an integer is required"); - boolean header = getIntFlagAsBool(ap, 3, 0, "an integer is required"); - - String lineEnd; - int pos = s.indexOf('\n'); - if (pos > 0 && s.charAt(pos-1) == '\r') { - lineEnd = "\r\n"; - s = N_TO_RN.matcher(s).replaceAll("\r\n"); - } else { - lineEnd = "\n"; - s = RN_TO_N.matcher(s).replaceAll("\n"); - } - StringBuffer sb = new StringBuffer(); - int count = 0; - for (int i=0, m=s.length(); i<m; i++) { - char c = s.charAt(i); - if (('!' <= c && c <= '<') - || ('>' <= c && c <= '^') - || ('`' <= c && c <= '~') - || (c == '_' && !header) - || (c == '\n' || c == '\r' && istext)) { - if (count == 75) { - sb.append("=").append(lineEnd); - count = 0; - } - sb.append(c); - count++; - } - else if (!quotetabs && (c == '\t' || c == ' ')) { - if (count >= 72) { - sb.append("=").append(lineEnd); - count = 0; - } - - if (count >= 71) { - count += 3; - qpEscape(sb, c); - } else { - if (c == ' ' && header) - sb.append('_'); - else - sb.append(c); - count += 1; - } - } else { - if (count >= 72) { - sb.append("=").append(lineEnd); - count = 0; - } - count += 3; - qpEscape(sb, c); - } - } - return sb.toString(); - } - /* public static void main(String[] args) { String l = b2a_uu("Hello"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-05-08 07:51:12
|
Revision: 3217 http://svn.sourceforge.net/jython/?rev=3217&view=rev Author: cgroves Date: 2007-05-08 00:51:10 -0700 (Tue, 08 May 2007) Log Message: ----------- moved to 2.2b2 Modified Paths: -------------- trunk/jython/README.txt trunk/jython/build.xml trunk/jython/src/org/python/core/PySystemState.java Modified: trunk/jython/README.txt =================================================================== --- trunk/jython/README.txt 2007-05-07 09:40:57 UTC (rev 3216) +++ trunk/jython/README.txt 2007-05-08 07:51:10 UTC (rev 3217) @@ -1,7 +1,7 @@ -Welcome to Jython 2.2b1 +Welcome to Jython 2.2b2 ======================= -This is the first beta release towards the 2.2 version of Jython. It +This is the second beta release towards the 2.2 version of Jython. It contains all of the new features for the 2.2 release: - new-style classes - Java List integration @@ -12,10 +12,10 @@ - support for running on modern JVMs - a new installer -In addition to these major features, scads of bugs have been fixed -since 2.2a1. See the NEWS file for a more complete list of changes. +In addition to these major features, many bugs have been fixed from 2.2b1. See +the NEWS file for a more complete list of changes. -The release was compiled on OS X with a 1.5 JDK but it should run on +The release was compiled on Windows XP with JDK 6 but it should run on 1.4.2+. This release exists to solicit feedback about any bugs or missing @@ -24,8 +24,5 @@ questions can be sent to the Jython-dev mailing list, jyt...@li.... -The current plan calls for a second beta release with several known -CPython compatibility issues and bugs fixed, and then a progression of -as few release candidates as possible to create a stable Jython 2.2. -Once the second beta is created, the bar will be set even higher for -changes, so now is the best time to send in bugs and patches. +The current plan calls for a release candiate in a few weeks, and if it proves +stable, the final release of 2.2 a few weeks after that. Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2007-05-07 09:40:57 UTC (rev 3216) +++ trunk/jython/build.xml 2007-05-08 07:51:10 UTC (rev 3217) @@ -111,7 +111,7 @@ #deprecation=off # - the svn tag to build from; only needed for full-build -#svn.tag=Release_2_2beta1 +#svn.tag=Release_2_2beta2 #svn.tag=HEAD # - the revision; defaults to svn.tag; only needed for full-build @@ -220,7 +220,7 @@ <property name="do.templates" value="true" /> <!-- predefined tags for jython and cpython --> - <property name="svn.tag" value="Release_2_2beta1" /> + <property name="svn.tag" value="Release_2_2beta2" /> <property name="work.dir" value="${basedir}/../full_build_${svn.tag}" /> <property name="svn.checkout.dir" value="${work.dir}/checkout" /> @@ -238,7 +238,7 @@ <condition property="jython.version" value="${svn.revision}"> <isset property="svn.revision" /> </condition> - <property name="jython.version" value="2.2b1" /> + <property name="jython.version" value="2.2b2" /> <property name="svn.revision" value="HEAD"/> <!-- classpath for svn ant task --> @@ -389,10 +389,10 @@ <!-- the following replacements have to be updated if the version strings in PySystemState.java change --> <target name="version" depends="checkout" if="do.snapshot.build" > <property name="replace.value.version" value='version = "2.2b${svn.revision}"' /> - <replace file="${source.dir}/org/python/core/PySystemState.java" token='version = "2.2b1"' value="${replace.value.version}" /> + <replace file="${source.dir}/org/python/core/PySystemState.java" token='version = "2.2b2"' value="${replace.value.version}" /> <replace file="${source.dir}/org/python/core/PySystemState.java" token="PY_RELEASE_LEVEL = 0x0B" value="PY_RELEASE_LEVEL = 0xAA" /> <property name="replace.value.serial" value="PY_RELEASE_SERIAL = ${svn.revision}" /> - <replace file="${source.dir}/org/python/core/PySystemState.java" token="PY_RELEASE_SERIAL = 1" value="${replace.value.serial}" /> + <replace file="${source.dir}/org/python/core/PySystemState.java" token="PY_RELEASE_SERIAL = 2" value="${replace.value.serial}" /> </target> <!-- separate build.xml for parser grammar --> Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2007-05-07 09:40:57 UTC (rev 3216) +++ trunk/jython/src/org/python/core/PySystemState.java 2007-05-08 07:51:10 UTC (rev 3217) @@ -47,13 +47,13 @@ * <p> * This also applies for the <code>PY_*</code> integer values below */ - public static String version = "2.2b1"; + public static String version = "2.2b2"; private static int PY_MAJOR_VERSION = 2; private static int PY_MINOR_VERSION = 2; private static int PY_MICRO_VERSION = 0; private static int PY_RELEASE_LEVEL = 0x0B; - private static int PY_RELEASE_SERIAL = 1; + private static int PY_RELEASE_SERIAL = 2; public static int hexversion = ((PY_MAJOR_VERSION << 24) | (PY_MINOR_VERSION << 16) | This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-05-14 05:49:34
|
Revision: 3225 http://svn.sourceforge.net/jython/?rev=3225&view=rev Author: cgroves Date: 2007-05-13 22:49:31 -0700 (Sun, 13 May 2007) Log Message: ----------- applied patch #1716709 from laukpe to fix bug #1662689 and bug #1661700. os.path.abspath no longer eliminates symlinks or raises an IOException if a drive isn't available Modified Paths: -------------- trunk/jython/Lib/javapath.py trunk/jython/NEWS Modified: trunk/jython/Lib/javapath.py =================================================================== --- trunk/jython/Lib/javapath.py 2007-05-14 05:06:57 UTC (rev 3224) +++ trunk/jython/Lib/javapath.py 2007-05-14 05:49:31 UTC (rev 3225) @@ -150,9 +150,7 @@ """Test whether two pathnames reference the same actual file""" path = _tostr(path, "samefile") path2 = _tostr(path2, "samefile") - f = File(path) - f2 = File(path2) - return f.getCanonicalPath() == f2.getCanonicalPath() + return _realpath(path) == _realpath(path2) def ismount(path): """Test whether a path is a mount point. @@ -162,7 +160,6 @@ """ return 0 - def walk(top, func, arg): """Walk a directory tree. @@ -234,14 +231,26 @@ comps.append(curdir) return slashes + string.joinfields(comps, sep) -# Return an absolute path. def abspath(path): + """Return an absolute path normalized but symbolic links not eliminated""" path = _tostr(path, "abspath") - return File(path).getCanonicalPath() + return _abspath(path) +def _abspath(path): + # Must use normpath separately because getAbsolutePath doesn't normalize + # and getCanonicalPath would eliminate symlinks. + return normpath(File(path).getAbsolutePath()) + def realpath(path): + """Return an absolute path normalized and symbolic links eliminated""" path = _tostr(path, "realpath") - return File(path).getCanonicalPath() + return _realpath(path) + +def _realpath(path): + try: + return File(path).getCanonicalPath() + except java.io.IOException: + return _abspath(path) def getsize(path): path = _tostr(path, "getsize") Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-05-14 05:06:57 UTC (rev 3224) +++ trunk/jython/NEWS 2007-05-14 05:49:31 UTC (rev 3225) @@ -1,5 +1,11 @@ Jython NEWS +Jython 2.2 rc1 + Bugs fixed + - [ 1708080 ] float("1d") -> 1.0 (not ValueError as expected) + - [ 1661700 ] os.path.abspath raises IOException if drive not accessible + - [ 1662689 ] os.path.abspath eliminates symlinks + Jython 2.2 beta2 New features - All functions in __builtin__ are new style functions instead of reflected This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-05-14 06:11:51
|
Revision: 3226 http://svn.sourceforge.net/jython/?rev=3226&view=rev Author: cgroves Date: 2007-05-13 23:11:50 -0700 (Sun, 13 May 2007) Log Message: ----------- applied patch #1717499 from laukpe to fix bug #1717498. os.path.splitdrive will actually split windows drives now Modified Paths: -------------- trunk/jython/Lib/javapath.py trunk/jython/NEWS Modified: trunk/jython/Lib/javapath.py =================================================================== --- trunk/jython/Lib/javapath.py 2007-05-14 05:49:31 UTC (rev 3225) +++ trunk/jython/Lib/javapath.py 2007-05-14 06:11:50 UTC (rev 3226) @@ -8,7 +8,6 @@ # Incompletely implemented: # islink -- How? # ismount -- How? -# splitdrive -- How? # normcase -- How? # Missing: @@ -72,13 +71,15 @@ return (path[:n], path[n:]) def splitdrive(path): - """Split a pathname into drive and path. + """Split a pathname into drive and path specifiers. - On JDK, drive is always empty. - XXX This isn't correct for JDK on DOS/Windows! - + Returns a 2-tuple "(drive,path)"; either part may be empty. """ - return ("", path) + # Algorithm based on CPython's ntpath.splitdrive and ntpath.isabs. + if path[1:2] == ':' and path[0].lower() in 'abcdefghijklmnopqrstuvwxyz' \ + and (path[2:] == '' or path[2] in '/\\'): + return path[:2], path[2:] + return '', path def exists(path): """Test whether a path exists. Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-05-14 05:49:31 UTC (rev 3225) +++ trunk/jython/NEWS 2007-05-14 06:11:50 UTC (rev 3226) @@ -5,6 +5,7 @@ - [ 1708080 ] float("1d") -> 1.0 (not ValueError as expected) - [ 1661700 ] os.path.abspath raises IOException if drive not accessible - [ 1662689 ] os.path.abspath eliminates symlinks + - [ 1717498 ] os.path.splitdrive does nothing for Windows drives Jython 2.2 beta2 New features This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2007-05-24 06:06:27
|
Revision: 3240 http://svn.sourceforge.net/jython/?rev=3240&view=rev Author: otmarhumbel Date: 2007-05-23 23:06:25 -0700 (Wed, 23 May 2007) Log Message: ----------- enable explicit imports of the form 'import java.net.URL' in standalone mode Modified Paths: -------------- trunk/jython/bugtests/test386jar/test386called.py trunk/jython/src/org/python/core/JavaImportHelper.java Modified: trunk/jython/bugtests/test386jar/test386called.py =================================================================== --- trunk/jython/bugtests/test386jar/test386called.py 2007-05-24 06:01:03 UTC (rev 3239) +++ trunk/jython/bugtests/test386jar/test386called.py 2007-05-24 06:06:25 UTC (rev 3240) @@ -37,4 +37,7 @@ from javax.imageio.event import IIOReadProgressListener # importing this twice was a problem from org.python.core import PySystemState -from org.python.core import PySystemState \ No newline at end of file +from org.python.core import PySystemState +# verify explicit imports of the form 'import java.net.URL' +import javax.security.auth.Policy +assert javax.security.auth.Policy \ No newline at end of file Modified: trunk/jython/src/org/python/core/JavaImportHelper.java =================================================================== --- trunk/jython/src/org/python/core/JavaImportHelper.java 2007-05-24 06:01:03 UTC (rev 3239) +++ trunk/jython/src/org/python/core/JavaImportHelper.java 2007-05-24 06:06:25 UTC (rev 3240) @@ -34,18 +34,23 @@ // handle package name if (isLoadedPackage(packageName, packages)) { - packageAdded = addPackage(packageName); + packageAdded = addPackage(packageName, packageAdded); } String parentPackageName = packageName; int dotPos = 0; + String lastDottedName = null; do { dotPos = parentPackageName.lastIndexOf("."); if (dotPos > 0) { parentPackageName = parentPackageName.substring(0, dotPos); if (isLoadedPackage(parentPackageName, packages)) { - boolean parentAdded = addPackage(parentPackageName); - if (parentAdded) { - packageAdded = true; + packageAdded = addPackage(parentPackageName, packageAdded); + } + // handle 'import java.net.URL' style explicit imports + if (lastDottedName == null) { + lastDottedName = packageName.substring(dotPos + 1); + if (isJavaClass(parentPackageName, lastDottedName)) { + packageAdded = addPackage(parentPackageName, packageAdded); } } } @@ -59,20 +64,13 @@ if (obj instanceof String) { String fromName = (String) obj; if (!"*".equals(fromName)) { - boolean fromAdded = false; if (isJavaClass(packageName, fromName)) { - fromAdded = addPackage(packageName); - if (fromAdded) { - packageAdded = true; - } + packageAdded = addPackage(packageName, packageAdded); } else { // handle cases like: from java import math String fromPackageName = packageName + "." + fromName; if (isLoadedPackage(fromPackageName, packages)) { - fromAdded = addPackage(fromPackageName); - if (fromAdded) { - packageAdded = true; - } + packageAdded = addPackage(fromPackageName, packageAdded); } } } @@ -163,7 +161,7 @@ * * @return <code>true</code> if something was really added, <code>false</code> otherwise */ - private static boolean addPackage(String packageName) { + private static boolean addPackage(String packageName, boolean packageAdded) { boolean added = false; PyObject module = Py.getSystemState().modules.__finditem__(packageName.intern()); if (module == null || module == Py.None) { @@ -184,7 +182,11 @@ } } while (dotPos > 0); } - return added; + // make sure not to turn off the packageAdded flag + if (added && !packageAdded) { + packageAdded = true; + } + return packageAdded; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-06-22 08:50:40
|
Revision: 3264 http://svn.sourceforge.net/jython/?rev=3264&view=rev Author: cgroves Date: 2007-06-22 01:50:35 -0700 (Fri, 22 Jun 2007) Log Message: ----------- prepare for 2.2rc1 Modified Paths: -------------- trunk/jython/NEWS trunk/jython/README.txt trunk/jython/src/org/python/core/PySystemState.java Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-06-22 04:23:57 UTC (rev 3263) +++ trunk/jython/NEWS 2007-06-22 08:50:35 UTC (rev 3264) @@ -1,11 +1,22 @@ Jython NEWS Jython 2.2 rc1 + New features + - Completely rewritten socket module and new select module using java.nio + which allows the use of SSL and non-blocking sockets. + - Explicit imports of Java classes like 'from java.net import URL' or + 'import java.net.URL' work with package scanning disabled. Bugs fixed - [ 1708080 ] float("1d") -> 1.0 (not ValueError as expected) - [ 1661700 ] os.path.abspath raises IOException if drive not accessible - [ 1662689 ] os.path.abspath eliminates symlinks - [ 1717498 ] os.path.splitdrive does nothing for Windows drives + - [ 1622207 ] _weakref.ref(o) only works if the argument is hasheable + - [ 1735864 ] Parser not threadsafe + - [ 1722306 ] OverflowError in UDP Socket Implementation + - [ 1348645 ] socket.py send() requires too many arguments + - [ 998602 ] urllib : https request does not work + - [ 621180 ] module socket _udpsocket close bug Jython 2.2 beta2 New features Modified: trunk/jython/README.txt =================================================================== --- trunk/jython/README.txt 2007-06-22 04:23:57 UTC (rev 3263) +++ trunk/jython/README.txt 2007-06-22 08:50:35 UTC (rev 3264) @@ -1,7 +1,7 @@ -Welcome to Jython 2.2b2 +Welcome to Jython 2.2rc1 ======================= -This is the second beta release towards the 2.2 version of Jython. It +This is the first release candidate of the 2.2 version of Jython. It contains all of the new features for the 2.2 release: - new-style classes - Java List integration @@ -11,18 +11,20 @@ - __future__ division - support for running on modern JVMs - a new installer + - ssl and non-blocking support for socket -In addition to these major features, many bugs have been fixed from 2.2b1. See +In addition to these major features, many bugs have been fixed from 2.2b2. See the NEWS file for a more complete list of changes. -The release was compiled on Windows XP with JDK 6 but it should run on +The release was compiled on Mac OS X with JDK 5 but it should run on 1.4.2+. -This release exists to solicit feedback about any bugs or missing -features; if you can provide it, it is greatly appreciated. Bug -reports can be created at http://jython.org/bugs whereas more general -questions can be sent to the Jython-dev mailing list, -jy...@li.... +This release is intended to find any major bugs before releasing 2.2. If none +are found, this will become the 2.2 release. If you can run this and check for +bugs, it will be greatly appreciated. Bug reports can be created at +http://jython.org/bugs whereas more general questions can be sent to the +Jython-users mailing list, jyt...@li.... -The current plan calls for a release candiate in a few weeks, and if it proves -stable, the final release of 2.2 a few weeks after that. +If this release proves stable, the final release of 2.2 will be in a couple +weeks. If not, successive release candidates will be made until all the major +bugs are ironed out. Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2007-06-22 04:23:57 UTC (rev 3263) +++ trunk/jython/src/org/python/core/PySystemState.java 2007-06-22 08:50:35 UTC (rev 3264) @@ -47,13 +47,13 @@ * <p> * This also applies for the <code>PY_*</code> integer values below */ - public static String version = "2.2b2"; + public static String version = "2.2rc1"; private static int PY_MAJOR_VERSION = 2; private static int PY_MINOR_VERSION = 2; private static int PY_MICRO_VERSION = 0; - private static int PY_RELEASE_LEVEL = 0x0B; - private static int PY_RELEASE_SERIAL = 2; + private static int PY_RELEASE_LEVEL = 0x0C; + private static int PY_RELEASE_SERIAL = 1; public static int hexversion = ((PY_MAJOR_VERSION << 24) | (PY_MINOR_VERSION << 16) | This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <am...@us...> - 2007-07-01 18:06:54
|
Revision: 3279 http://svn.sourceforge.net/jython/?rev=3279&view=rev Author: amak Date: 2007-07-01 11:06:51 -0700 (Sun, 01 Jul 2007) Log Message: ----------- Tidied exception handling to present a more pythonic interface. 1. Introduced a pythonic select.error exception for when a blocking socket is registered for multiplexing, with a corresponding new errno code. 2. Changed the socket module to raise a pythonic exception when a host is not found. Modified Paths: -------------- trunk/jython/Lib/select.py trunk/jython/Lib/socket.py trunk/jython/Lib/test/test_select.py trunk/jython/Lib/test/test_socket.py trunk/jython/src/org/python/modules/errno.java Modified: trunk/jython/Lib/select.py =================================================================== --- trunk/jython/Lib/select.py 2007-06-30 08:57:09 UTC (rev 3278) +++ trunk/jython/Lib/select.py 2007-07-01 18:06:51 UTC (rev 3279) @@ -11,14 +11,31 @@ try: import errno - ERRNO_EINVAL = errno.EINVAL - ERRNO_ENOTSOCK = errno.ENOTSOCK + ERRNO_EINVAL = errno.EINVAL + ERRNO_ENOTSOCK = errno.ENOTSOCK + ERRNO_ESOCKISBLOCKING = errno.ESOCKISBLOCKING except ImportError: - ERRNO_EINVAL = 22 - ERRNO_ENOTSOCK = 88 + ERRNO_EINVAL = 22 + ERRNO_ENOTSOCK = 88 + ERRNO_ESOCKISBLOCKING = 20000 class error(Exception): pass +ALL = None + +_exception_map = { + +# (<javaexception>, <circumstance>) : lambda: <code that raises the python equivalent> + +(java.nio.channels.IllegalBlockingModeException, ALL) : lambda exc: error(ERRNO_ESOCKISBLOCKING, 'socket must be in non-blocking mode'), +} + +def _map_exception(exc, circumstance=ALL): + try: + return _exception_map[(exc.__class__, circumstance)](exc) + except KeyError: + return error('Unmapped java exception: %s' % exc.toString()) + POLLIN = 1 POLLOUT = 2 @@ -73,18 +90,24 @@ self.unconnected_sockets = temp_list def register(self, socket_object, mask = POLLIN|POLLOUT|POLLPRI): - channel = self._getselectable(socket_object) - if channel is None: - # The socket is not yet connected, and thus has no channel - # Add it to a pending list, and return - self.unconnected_sockets.append( (socket_object, mask) ) - return - self._register_channel(socket_object, channel, mask) + try: + channel = self._getselectable(socket_object) + if channel is None: + # The socket is not yet connected, and thus has no channel + # Add it to a pending list, and return + self.unconnected_sockets.append( (socket_object, mask) ) + return + self._register_channel(socket_object, channel, mask) + except java.lang.Exception, jlx: + raise _map_exception(jlx) def unregister(self, socket_object): - channel = self._getselectable(socket_object) - self.chanmap[channel][1].cancel() - del self.chanmap[channel] + try: + channel = self._getselectable(socket_object) + self.chanmap[channel][1].cancel() + del self.chanmap[channel] + except java.lang.Exception, jlx: + raise _map_exception(jlx) def _dopoll(self, timeout): if timeout is None or timeout < 0: @@ -103,24 +126,30 @@ return self.selector.selectedKeys() def poll(self, timeout=None): - self._check_unconnected_sockets() - selectedkeys = self._dopoll(timeout) - results = [] - for k in selectedkeys.iterator(): - jmask = k.readyOps() - pymask = 0 - if jmask & OP_READ: pymask |= POLLIN - if jmask & OP_WRITE: pymask |= POLLOUT - if jmask & OP_ACCEPT: pymask |= POLLIN - if jmask & OP_CONNECT: pymask |= POLLOUT - # Now return the original userobject, and the return event mask - results.append( (self.chanmap[k.channel()][0], pymask) ) - return results + try: + self._check_unconnected_sockets() + selectedkeys = self._dopoll(timeout) + results = [] + for k in selectedkeys.iterator(): + jmask = k.readyOps() + pymask = 0 + if jmask & OP_READ: pymask |= POLLIN + if jmask & OP_WRITE: pymask |= POLLOUT + if jmask & OP_ACCEPT: pymask |= POLLIN + if jmask & OP_CONNECT: pymask |= POLLOUT + # Now return the original userobject, and the return event mask + results.append( (self.chanmap[k.channel()][0], pymask) ) + return results + except java.lang.Exception, jlx: + raise _map_exception(jlx) def close(self): - for k in self.selector.keys(): - k.cancel() - self.selector.close() + try: + for k in self.selector.keys(): + k.cancel() + self.selector.close() + except java.lang.Exception, jlx: + raise _map_exception(jlx) def _calcselecttimeoutvalue(value): if value is None: Modified: trunk/jython/Lib/socket.py =================================================================== --- trunk/jython/Lib/socket.py 2007-06-30 08:57:09 UTC (rev 3278) +++ trunk/jython/Lib/socket.py 2007-07-01 18:06:51 UTC (rev 3279) @@ -35,6 +35,7 @@ import java.net.InetSocketAddress import java.net.Socket import java.net.SocketTimeoutException +import java.net.UnknownHostException import java.nio.ByteBuffer import java.nio.channels.DatagramChannel import java.nio.channels.IllegalBlockingModeException @@ -45,16 +46,18 @@ try: import errno - ERRNO_EWOULDBLOCK = errno.EWOULDBLOCK - ERRNO_EACCES = errno.EACCES - ERRNO_ECONNREFUSED = errno.ECONNREFUSED - ERRNO_EINPROGRESS = errno.EINPROGRESS + ERRNO_EWOULDBLOCK = errno.EWOULDBLOCK + ERRNO_EACCES = errno.EACCES + ERRNO_ECONNREFUSED = errno.ECONNREFUSED + ERRNO_EINPROGRESS = errno.EINPROGRESS + ERRNO_EGETADDRINFOFAILED = errno.EGETADDRINFOFAILED except ImportError: # Support jython 2.1 - ERRNO_EWOULDBLOCK = 11 - ERRNO_EACCES = 13 - ERRNO_ECONNREFUSED = 111 - ERRNO_EINPROGRESS = 115 + ERRNO_EWOULDBLOCK = 11 + ERRNO_EACCES = 13 + ERRNO_ECONNREFUSED = 111 + ERRNO_EINPROGRESS = 115 + ERRNO_EGETADDRINFOFAILED = 20001 class error(Exception): pass class herror(error): pass @@ -63,7 +66,7 @@ ALL = None -exception_map = { +_exception_map = { # (<javaexception>, <circumstance>) : lambda: <code that raises the python equivalent> @@ -71,23 +74,18 @@ (java.net.BindException, ALL) : lambda exc: error(ERRNO_EACCES, 'Permission denied'), (java.net.ConnectException, ALL) : lambda exc: error( (ERRNO_ECONNREFUSED, 'Connection refused') ), (java.net.SocketTimeoutException, ALL) : lambda exc: timeout('timed out'), - +(java.net.UnknownHostException, ALL) : lambda exc: gaierror(ERRNO_EGETADDRINFOFAILED, 'getaddrinfo failed'), } def would_block_error(exc=None): return error( (ERRNO_EWOULDBLOCK, 'The socket operation could not complete without blocking') ) -def map_exception(exc, circumstance=ALL): +def _map_exception(exc, circumstance=ALL): try: -# print "Mapping exception: %s" % str(exc) - return exception_map[(exc.__class__, circumstance)](exc) + return _exception_map[(exc.__class__, circumstance)](exc) except KeyError: return error('Unmapped java exception: %s' % exc.toString()) -exception_map.update({ - (java.nio.channels.IllegalBlockingModeException, ALL) : would_block_error, - }) - MODE_BLOCKING = 'block' MODE_NONBLOCKING = 'nonblock' MODE_TIMEOUT = 'timeout' @@ -208,7 +206,7 @@ new_cli_sock = self.jsocket.accept() return _client_socket_impl(new_cli_sock) except java.lang.Exception, jlx: - raise map_exception(jlx) + raise _map_exception(jlx) def close(self): _nio_impl.close(self) @@ -284,10 +282,16 @@ return name def gethostname(): - return java.net.InetAddress.getLocalHost().getHostName() + try: + return java.net.InetAddress.getLocalHost().getHostName() + except java.lang.Exception, jlx: + raise _map_exception(jlx) def gethostbyname(name): - return java.net.InetAddress.getByName(name).getHostAddress() + try: + return java.net.InetAddress.getByName(name).getHostAddress() + except java.lang.Exception, jlx: + raise _map_exception(jlx) def gethostbyaddr(name): names, addrs = _gethostbyaddr(name) @@ -433,7 +437,7 @@ self.sock_impl = _server_socket_impl(host, port, backlog, self.reuse_addr) self._config() except java.lang.Exception, jlx: - raise map_exception(jlx) + raise _map_exception(jlx) # # The following has information on a java.lang.NullPointerException problem I'm having @@ -453,7 +457,7 @@ cliconn._setup(new_sock) return cliconn, new_sock.getpeername() except java.lang.Exception, jlx: - raise map_exception(jlx) + raise _map_exception(jlx) def _get_host_port(self, addr): host, port = _unpack_address_tuple(addr) @@ -471,9 +475,8 @@ self.sock_impl.bind(bind_host, bind_port) self._config() # Configure timeouts, etc, now that the socket exists self.sock_impl.connect(host, port) - self._setup(self.sock_impl) except java.lang.Exception, jlx: - raise map_exception(jlx) + raise _map_exception(jlx) def connect(self, addr): "This signifies a client socket" @@ -510,7 +513,7 @@ data = data[:m] return data.tostring() except java.lang.Exception, jlx: - raise map_exception(jlx) + raise _map_exception(jlx) def recvfrom(self, n): return self.recv(n), None @@ -702,7 +705,7 @@ bytes = bytes[:m] return bytes.tostring(), (host, port) except java.lang.Exception, jlx: - raise map_exception(jlx) + raise _map_exception(jlx) def recv(self, n): try: @@ -715,7 +718,7 @@ bytes = bytes[:m] return bytes.tostring() except java.lang.Exception, jlx: - raise map_exception(jlx) + raise _map_exception(jlx) def getsockname(self): assert self.sock_impl Modified: trunk/jython/Lib/test/test_select.py =================================================================== --- trunk/jython/Lib/test/test_select.py 2007-06-30 08:57:09 UTC (rev 3278) +++ trunk/jython/Lib/test/test_select.py 2007-07-01 18:06:51 UTC (rev 3279) @@ -7,7 +7,9 @@ except NameError: class object: pass -import socket, select +import errno +import select +import socket import os import sys @@ -159,6 +161,23 @@ result_sockets = [r[0] for r in result_list] self.failUnless(self.cli in result_sockets, "Connected client socket should have been selectable") + def testSocketMustBeNonBlocking(self): + self.cli_conn = self.serv.accept() + + def _testSocketMustBeNonBlocking(self): + self.cli.setblocking(1) + self.cli.connect( (test_socket.HOST, test_socket.PORT) ) + timeout = 1000 # milliseconds + poll_object = select.poll() + try: + poll_object.register(self.cli) + except select.error, se: + self.failUnlessEqual(se[0], errno.ESOCKISBLOCKING) + except Exception, x: + self.fail("Registering blocking socket should have raised select.error, not %s" % str(x)) + else: + self.fail("Registering blocking socket should have raised select.error") + class TestPipes(unittest.TestCase): verbose = 1 Modified: trunk/jython/Lib/test/test_socket.py =================================================================== --- trunk/jython/Lib/test/test_socket.py 2007-06-30 08:57:09 UTC (rev 3278) +++ trunk/jython/Lib/test/test_socket.py 2007-07-01 18:06:51 UTC (rev 3279) @@ -7,6 +7,7 @@ import unittest #from test import test_support +import errno import socket import select import time @@ -921,6 +922,14 @@ self.assert_(issubclass(socket.gaierror, socket.error)) self.assert_(issubclass(socket.timeout, socket.error)) + def testHostNotFound(self): + try: + socket.gethostbyname("doesnotexist") + except socket.gaierror, gaix: + self.failUnlessEqual(gaix[0], errno.EGETADDRINFOFAILED) + except Exception, x: + self.fail("Get host name for non-existent host raised wrong exception: %s" % x) + class TestAddressParameters: def testBindNonTupleEndpointRaisesTypeError(self): Modified: trunk/jython/src/org/python/modules/errno.java =================================================================== --- trunk/jython/src/org/python/modules/errno.java 2007-06-30 08:57:09 UTC (rev 3278) +++ trunk/jython/src/org/python/modules/errno.java 2007-07-01 18:06:51 UTC (rev 3279) @@ -137,6 +137,10 @@ public static final int EREMOTEIO = 121; public static final int EDQUOT = 122; + // AMAK: Starting a new series of jython specific error numbers + public static final int ESOCKISBLOCKING = 20000; + public static final int EGETADDRINFOFAILED = 20001; + public static final PyObject errorcode = new PyDictionary(); private static final PyObject strerror = new PyDictionary(); @@ -264,6 +268,9 @@ addcode(dict, EREMOTEIO, "EREMOTEIO", "Remote I/O error"); addcode(dict, EDQUOT, "EDQUOT", "Disk quota exceeded"); + // AMAK: starting a new series of jython specific errors + addcode(dict, ESOCKISBLOCKING, "ESOCKISBLOCKING", "Socket is in blocking mode"); + addcode(dict, EGETADDRINFOFAILED, "EGETADDRINFOFAILED", "getaddrinfo failed"); } public static PyObject strerror(PyObject error) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-07-07 23:05:46
|
Revision: 3283 http://svn.sourceforge.net/jython/?rev=3283&view=rev Author: cgroves Date: 2007-07-07 16:05:44 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Patch #1746339 from mehendran to fix bug #931129 where a jython jar using __run__.py couldn't have certain directory structures in its path Modified Paths: -------------- trunk/jython/NEWS trunk/jython/src/org/python/util/jython.java Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-07-06 23:19:57 UTC (rev 3282) +++ trunk/jython/NEWS 2007-07-07 23:05:44 UTC (rev 3283) @@ -1,5 +1,9 @@ Jython NEWS +Jython 2.2 rc2 + Bugs fixed + - [ 931129 ] jython -jar some-path/test.jar fails + Jython 2.2 rc1 New features - Completely rewritten socket module and new select module using java.nio Modified: trunk/jython/src/org/python/util/jython.java =================================================================== --- trunk/jython/src/org/python/util/jython.java 2007-07-06 23:19:57 UTC (rev 3282) +++ trunk/jython/src/org/python/util/jython.java 2007-07-07 23:05:44 UTC (rev 3283) @@ -47,6 +47,15 @@ throw Py.ValueError("jar file missing '__run__.py'"); PyStringMap locals = new PyStringMap(); + + // Stripping the stuff before the last File.separator fixes Bug + // #931129 by keeping illegal characters out of the generated + // proxy class name + int beginIndex; + if ((beginIndex = filename.lastIndexOf(File.separator)) != -1) { + filename = filename.substring(beginIndex + 1); + } + locals.__setitem__("__name__", new PyString(filename)); locals.__setitem__("zipfile", Py.java2py(zip)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-07-07 23:36:36
|
Revision: 3284 http://svn.sourceforge.net/jython/?rev=3284&view=rev Author: cgroves Date: 2007-07-07 16:36:35 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Fix for bug #1719528 where -c didn't add the empty string to sys.path Modified Paths: -------------- trunk/jython/NEWS trunk/jython/src/org/python/util/jython.java Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-07-07 23:05:44 UTC (rev 3283) +++ trunk/jython/NEWS 2007-07-07 23:36:35 UTC (rev 3284) @@ -3,6 +3,7 @@ Jython 2.2 rc2 Bugs fixed - [ 931129 ] jython -jar some-path/test.jar fails + - [ 1719528 ] -c doesn't put the empty string in sys.path Jython 2.2 rc1 New features Modified: trunk/jython/src/org/python/util/jython.java =================================================================== --- trunk/jython/src/org/python/util/jython.java 2007-07-07 23:05:44 UTC (rev 3283) +++ trunk/jython/src/org/python/util/jython.java 2007-07-07 23:36:35 UTC (rev 3284) @@ -168,14 +168,6 @@ } } - if (opts.command != null) { - try { - interp.exec(opts.command); - } catch (Throwable t) { - Py.printException(t); - } - } - // was there a filename on the command line? if (opts.filename != null) { String path = new java.io.File(opts.filename).getParent(); @@ -213,6 +205,14 @@ // was given, sys.path[0] will have gotten filled in with the // dir of the argument filename. Py.getSystemState().path.insert(0, new PyString("")); + + if (opts.command != null) { + try { + interp.exec(opts.command); + } catch (Throwable t) { + Py.printException(t); + } + } } if (opts.interactive) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-07-08 00:08:17
|
Revision: 3285 http://svn.sourceforge.net/jython/?rev=3285&view=rev Author: cgroves Date: 2007-07-07 17:08:16 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Don't add a u prefix while unicode escaping a value > 255 if working on a unicode object since it always has the u. Fixes bug #1746957 Modified Paths: -------------- trunk/jython/NEWS trunk/jython/src/org/python/core/PyString.java trunk/jython/src/org/python/core/PyUnicode.java Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-07-07 23:36:35 UTC (rev 3284) +++ trunk/jython/NEWS 2007-07-08 00:08:16 UTC (rev 3285) @@ -4,6 +4,7 @@ Bugs fixed - [ 931129 ] jython -jar some-path/test.jar fails - [ 1719528 ] -c doesn't put the empty string in sys.path + - [ 1746957 ] Weird 'uu' prefix for unicode Jython 2.2 rc1 New features Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2007-07-07 23:36:35 UTC (rev 3284) +++ trunk/jython/src/org/python/core/PyString.java 2007-07-08 00:08:16 UTC (rev 3285) @@ -1666,11 +1666,17 @@ public static String encode_UnicodeEscape(String str, boolean use_quotes) { + return encode_UnicodeEscape(str, use_quotes, false); + } + + public static String encode_UnicodeEscape(String str, + boolean use_quotes, + boolean unicodeDesignatorPresent) + { int size = str.length(); StringBuffer v = new StringBuffer(str.length()); char quote = 0; - boolean unicode = false; if (use_quotes) { quote = str.indexOf('\'') >= 0 && @@ -1687,9 +1693,9 @@ } /* Map 16-bit characters to '\\uxxxx' */ else if (ch >= 256) { - if (use_quotes && !unicode) { + if (use_quotes && !unicodeDesignatorPresent) { v.insert(0, 'u'); - unicode = true; + unicodeDesignatorPresent = true; } v.append('\\'); v.append('u'); Modified: trunk/jython/src/org/python/core/PyUnicode.java =================================================================== --- trunk/jython/src/org/python/core/PyUnicode.java 2007-07-07 23:36:35 UTC (rev 3284) +++ trunk/jython/src/org/python/core/PyUnicode.java 2007-07-08 00:08:16 UTC (rev 3285) @@ -1520,11 +1520,11 @@ } public PyString __repr__() { - return new PyUnicode("u" + encode_UnicodeEscape(string, true)); + return new PyString('u' + encode_UnicodeEscape(string, true, true)); } public String unicode_toString() { - return "u" + str_toString(); + return str_toString(); } final int unicode___cmp__(PyObject other) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-07-08 00:30:36
|
Revision: 3286 http://svn.sourceforge.net/jython/?rev=3286&view=rev Author: cgroves Date: 2007-07-07 17:30:34 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Remove a module from sys.modules if it blows up while being imported. Fixes bug #1747092 Modified Paths: -------------- trunk/jython/NEWS trunk/jython/bugtests/test258.py trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-07-08 00:08:16 UTC (rev 3285) +++ trunk/jython/NEWS 2007-07-08 00:30:34 UTC (rev 3286) @@ -5,6 +5,7 @@ - [ 931129 ] jython -jar some-path/test.jar fails - [ 1719528 ] -c doesn't put the empty string in sys.path - [ 1746957 ] Weird 'uu' prefix for unicode + - [ 1747092 ] Failed imports should not be "cached" Jython 2.2 rc1 New features Modified: trunk/jython/bugtests/test258.py =================================================================== --- trunk/jython/bugtests/test258.py 2007-07-08 00:08:16 UTC (rev 3285) +++ trunk/jython/bugtests/test258.py 2007-07-08 00:30:34 UTC (rev 3286) @@ -8,7 +8,7 @@ import sys -if not sys.modules.has_key('test258m1'): - raise support.TestError, "Module should exists in sys.modules" +if sys.modules.has_key('test258m1'): + raise support.TestError, "Module should not exist in sys.modules" Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2007-07-08 00:08:16 UTC (rev 3285) +++ trunk/jython/src/org/python/core/imp.java 2007-07-08 00:30:34 UTC (rev 3286) @@ -233,8 +233,13 @@ if (c instanceof PyTableCode) { code = (PyTableCode) c; } - PyFrame f = new PyFrame(code, module.__dict__, module.__dict__, null); - code.call(f); + try { + PyFrame f = new PyFrame(code, module.__dict__, module.__dict__, null); + code.call(f); + } catch (RuntimeException t) { + Py.getSystemState().modules.__delitem__(name.intern()); + throw t; + } if(moduleLocation != null) { module.__setattr__("__file__", new PyString(moduleLocation)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-07-08 06:21:43
|
Revision: 3287 http://svn.sourceforge.net/jython/?rev=3287&view=rev Author: cgroves Date: 2007-07-07 23:21:39 -0700 (Sat, 07 Jul 2007) Log Message: ----------- The last commit didn't actually fix bug #1747092. It got a somewhat similar but different bug where importing a module that throws an exception on import added it to sys.modules. That caused it to be silently imported as an empty module without an exception if tried again. This commit keeps top-level imports from being added to sys.modules if they're not found, so if sys.path is corrected and the import is tried again it'll actually work. It still adds None for subpackage and submodule imports so they're not tried again after they fail. Modified Paths: -------------- trunk/jython/bugtests/test001.py trunk/jython/src/org/python/core/imp.java Added Paths: ----------- trunk/jython/bugtests/test400/ trunk/jython/bugtests/test400/x/ trunk/jython/bugtests/test400/x/__init__.py trunk/jython/bugtests/test400.py Modified: trunk/jython/bugtests/test001.py =================================================================== --- trunk/jython/bugtests/test001.py 2007-07-08 00:30:34 UTC (rev 3286) +++ trunk/jython/bugtests/test001.py 2007-07-08 06:21:39 UTC (rev 3287) @@ -11,5 +11,5 @@ support.compare(str(v.size), "<java function size") -if type(v.size) != BuiltinFunctionType: - raise support.TestError('Wrong type for v.size' + `type(v.size)`) +if not callable(v.size): + raise support.TestError('v.size should be callable') Added: trunk/jython/bugtests/test400/x/__init__.py =================================================================== Added: trunk/jython/bugtests/test400.py =================================================================== --- trunk/jython/bugtests/test400.py (rev 0) +++ trunk/jython/bugtests/test400.py 2007-07-08 06:21:39 UTC (rev 3287) @@ -0,0 +1,10 @@ +import support + +try: + import x + raise support.TestError, "x shouldn't be on sys.path until after this" +except: + pass +import sys +sys.path.append('test400') +import x Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2007-07-08 00:30:34 UTC (rev 3286) +++ trunk/jython/src/org/python/core/imp.java 2007-07-08 06:21:39 UTC (rev 3287) @@ -656,13 +656,14 @@ } else { firstName = name.substring(0, dot); } - StringBuffer parentNameBuffer = new StringBuffer( - pkgMod != null ? pkgName : ""); + StringBuffer parentNameBuffer = new StringBuffer(pkgMod != null ? pkgName : ""); PyObject topMod = import_next(pkgMod, parentNameBuffer, firstName, name, fromlist); if (topMod == Py.None || topMod == null) { - if (topMod == null) { - modules.__setitem__(parentNameBuffer.toString().intern(), - Py.None); + // Add None to sys.modules for submodule or subpackage names that aren't found, but + // leave top-level entries out. This allows them to be tried again if another + // import attempt is made after they've been added to sys.path. + if (topMod == null && pkgMod != null) { + modules.__setitem__(parentNameBuffer.toString().intern(), Py.None); } parentNameBuffer = new StringBuffer(""); // could throw ImportError This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-07-10 06:40:23
|
Revision: 3289 http://svn.sourceforge.net/jython/?rev=3289&view=rev Author: cgroves Date: 2007-07-09 23:40:19 -0700 (Mon, 09 Jul 2007) Log Message: ----------- Version bump for 2.2rc2 Modified Paths: -------------- trunk/jython/README.txt trunk/jython/build.xml trunk/jython/src/org/python/core/PySystemState.java Modified: trunk/jython/README.txt =================================================================== --- trunk/jython/README.txt 2007-07-09 11:10:56 UTC (rev 3288) +++ trunk/jython/README.txt 2007-07-10 06:40:19 UTC (rev 3289) @@ -1,7 +1,7 @@ -Welcome to Jython 2.2rc1 +Welcome to Jython 2.2rc2 ======================= -This is the first release candidate of the 2.2 version of Jython. It +This is the second release candidate of the 2.2 version of Jython. It contains all of the new features for the 2.2 release: - new-style classes - Java List integration @@ -13,8 +13,8 @@ - a new installer - ssl and non-blocking support for socket -In addition to these major features, many bugs have been fixed from 2.2b2. See -the NEWS file for a more complete list of changes. +In addition to these major features, several bugs have been fixed from 2.2rc1. +See the NEWS file for a more complete list of changes. The release was compiled on Mac OS X with JDK 5 but it should run on 1.4.2+. Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2007-07-09 11:10:56 UTC (rev 3288) +++ trunk/jython/build.xml 2007-07-10 06:40:19 UTC (rev 3289) @@ -220,7 +220,7 @@ <property name="do.templates" value="true" /> <!-- predefined tags for jython and cpython --> - <property name="svn.tag" value="Release_2_2rc1" /> + <property name="svn.tag" value="Release_2_2rc2" /> <property name="work.dir" value="${basedir}/../full_build_${svn.tag}" /> <property name="svn.checkout.dir" value="${work.dir}/checkout" /> @@ -238,7 +238,7 @@ <condition property="jython.version" value="${svn.revision}"> <isset property="svn.revision" /> </condition> - <property name="jython.version" value="2.2rc1" /> + <property name="jython.version" value="2.2rc2" /> <property name="svn.revision" value="HEAD"/> <!-- classpath for svn ant task --> @@ -390,13 +390,13 @@ in PySystemState.java and README.txt change --> <target name="version" depends="checkout" if="do.snapshot.build" > <property name="replace.value.version" value='version = "2.2rc${svn.revision}"' /> - <replace file="${source.dir}/org/python/core/PySystemState.java" token='version = "2.2rc1"' value="${replace.value.version}" /> - <replace file="${source.dir}/org/python/core/PySystemState.java" token="PY_RELEASE_LEVEL = 0x0B" value="PY_RELEASE_LEVEL = 0xAA" /> + <replace file="${source.dir}/org/python/core/PySystemState.java" token='version = "2.2rc2"' value="${replace.value.version}" /> + <replace file="${source.dir}/org/python/core/PySystemState.java" token="PY_RELEASE_LEVEL = 0x0C" value="PY_RELEASE_LEVEL = 0xAA" /> <property name="replace.value.serial" value="PY_RELEASE_SERIAL = ${svn.revision}" /> <replace file="${source.dir}/org/python/core/PySystemState.java" token="PY_RELEASE_SERIAL = 2" value="${replace.value.serial}" /> <!-- change README.txt --> - <replace file="${jython.base.dir}/README.txt" token='2.2rc1' value='2.2rc${svn.revision}' /> + <replace file="${jython.base.dir}/README.txt" token='2.2rc2' value='2.2rc${svn.revision}' /> <replace file="${jython.base.dir}/README.txt"> <replacetoken>=======================</replacetoken> <replacevalue>-------------------------- Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2007-07-09 11:10:56 UTC (rev 3288) +++ trunk/jython/src/org/python/core/PySystemState.java 2007-07-10 06:40:19 UTC (rev 3289) @@ -47,13 +47,13 @@ * <p> * This also applies for the <code>PY_*</code> integer values below */ - public static String version = "2.2rc1"; + public static String version = "2.2rc2"; private static int PY_MAJOR_VERSION = 2; private static int PY_MINOR_VERSION = 2; private static int PY_MICRO_VERSION = 0; private static int PY_RELEASE_LEVEL = 0x0C; - private static int PY_RELEASE_SERIAL = 1; + private static int PY_RELEASE_SERIAL = 2; public static int hexversion = ((PY_MAJOR_VERSION << 24) | (PY_MINOR_VERSION << 16) | This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-07-23 05:35:44
|
Revision: 3350 http://svn.sourceforge.net/jython/?rev=3350&view=rev Author: cgroves Date: 2007-07-22 22:35:41 -0700 (Sun, 22 Jul 2007) Log Message: ----------- Version bumpage for 2.2rc3 Modified Paths: -------------- trunk/jython/NEWS trunk/jython/README.txt trunk/jython/build.xml trunk/jython/src/org/python/core/PySystemState.java Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2007-07-23 05:30:37 UTC (rev 3349) +++ trunk/jython/NEWS 2007-07-23 05:35:41 UTC (rev 3350) @@ -1,5 +1,22 @@ Jython NEWS +Jython 2.2 rc3 + New Features + - Added telnetlib from CPython + - Added cpython_compatible_select to select. See + http://wiki.python.org/jython/SelectModule for information on when + to use it. + - Several more java.nio exceptions are mapped to their corresponding + Python error codes when thrown. + Bugs fixed + - recv on closed sockets threw an exception instead returning the + empty string + - A PySystemState being garbage collected caused System.out and + System.in to be closed. This would cause 'print' to stop working. + - Closing a FileWrapper on a socket closes its underlying socket + - Sockets just have their [In|Out]putStreams closed instead of being + properly shutdown by shutdown() + Jython 2.2 rc2 Bugs fixed - [ 931129 ] jython -jar some-path/test.jar fails Modified: trunk/jython/README.txt =================================================================== --- trunk/jython/README.txt 2007-07-23 05:30:37 UTC (rev 3349) +++ trunk/jython/README.txt 2007-07-23 05:35:41 UTC (rev 3350) @@ -1,7 +1,7 @@ -Welcome to Jython 2.2rc2 +Welcome to Jython 2.2rc3 ======================= -This is the second release candidate of the 2.2 version of Jython. It +This is the third release candidate of the 2.2 version of Jython. It contains all of the new features for the 2.2 release: - new-style classes - Java List integration @@ -13,7 +13,7 @@ - a new installer - ssl and non-blocking support for socket -In addition to these major features, several bugs have been fixed from 2.2rc1. +In addition to these major features, several bugs have been fixed from 2.2rc2. See the NEWS file for a more complete list of changes. The release was compiled on Mac OS X with JDK 5 but it should run on Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2007-07-23 05:30:37 UTC (rev 3349) +++ trunk/jython/build.xml 2007-07-23 05:35:41 UTC (rev 3350) @@ -220,7 +220,7 @@ <property name="do.templates" value="true" /> <!-- predefined tags for jython and cpython --> - <property name="svn.tag" value="Release_2_2rc2" /> + <property name="svn.tag" value="Release_2_2rc3" /> <property name="work.dir" value="${basedir}/../full_build_${svn.tag}" /> <property name="svn.checkout.dir" value="${work.dir}/checkout" /> @@ -238,7 +238,7 @@ <condition property="jython.version" value="${svn.revision}"> <isset property="svn.revision" /> </condition> - <property name="jython.version" value="2.2rc2" /> + <property name="jython.version" value="2.2rc3" /> <property name="svn.revision" value="HEAD"/> <!-- classpath for svn ant task --> @@ -390,13 +390,13 @@ in PySystemState.java and README.txt change --> <target name="version" depends="checkout" if="do.snapshot.build" > <property name="replace.value.version" value='version = "2.2rc${svn.revision}"' /> - <replace file="${source.dir}/org/python/core/PySystemState.java" token='version = "2.2rc2"' value="${replace.value.version}" /> + <replace file="${source.dir}/org/python/core/PySystemState.java" token='version = "2.2rc3"' value="${replace.value.version}" /> <replace file="${source.dir}/org/python/core/PySystemState.java" token="PY_RELEASE_LEVEL = 0x0C" value="PY_RELEASE_LEVEL = 0xAA" /> <property name="replace.value.serial" value="PY_RELEASE_SERIAL = ${svn.revision}" /> - <replace file="${source.dir}/org/python/core/PySystemState.java" token="PY_RELEASE_SERIAL = 2" value="${replace.value.serial}" /> + <replace file="${source.dir}/org/python/core/PySystemState.java" token="PY_RELEASE_SERIAL = 3" value="${replace.value.serial}" /> <!-- change README.txt --> - <replace file="${jython.base.dir}/README.txt" token='2.2rc2' value='2.2rc${svn.revision}' /> + <replace file="${jython.base.dir}/README.txt" token='2.2rc3' value='2.2rc${svn.revision}' /> <replace file="${jython.base.dir}/README.txt"> <replacetoken>=======================</replacetoken> <replacevalue>-------------------------- Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2007-07-23 05:30:37 UTC (rev 3349) +++ trunk/jython/src/org/python/core/PySystemState.java 2007-07-23 05:35:41 UTC (rev 3350) @@ -47,13 +47,13 @@ * <p> * This also applies for the <code>PY_*</code> integer values below */ - public static String version = "2.2rc2"; + public static String version = "2.2rc3"; private static int PY_MAJOR_VERSION = 2; private static int PY_MINOR_VERSION = 2; private static int PY_MICRO_VERSION = 0; private static int PY_RELEASE_LEVEL = 0x0C; - private static int PY_RELEASE_SERIAL = 2; + private static int PY_RELEASE_SERIAL = 3; public static int hexversion = ((PY_MAJOR_VERSION << 24) | (PY_MINOR_VERSION << 16) | This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2007-07-23 06:32:39
|
Revision: 3352 http://svn.sourceforge.net/jython/?rev=3352&view=rev Author: cgroves Date: 2007-07-22 23:32:32 -0700 (Sun, 22 Jul 2007) Log Message: ----------- test_socket uses unittest for its testing, so don't include any output for comparison Modified Paths: -------------- trunk/jython/build.xml Removed Paths: ------------- trunk/jython/Lib/test/output/test_socket Deleted: trunk/jython/Lib/test/output/test_socket =================================================================== --- trunk/jython/Lib/test/output/test_socket 2007-07-23 06:20:50 UTC (rev 3351) +++ trunk/jython/Lib/test/output/test_socket 2007-07-23 06:32:32 UTC (rev 3352) @@ -1 +0,0 @@ -test_socket Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2007-07-23 06:20:50 UTC (rev 3351) +++ trunk/jython/build.xml 2007-07-23 06:32:32 UTC (rev 3352) @@ -641,6 +641,7 @@ <patternset> <includesfile name="${jython.base.dir}/build.Lib.include.properties" /> <exclude name="test/output/test_sax"/> + <exclude name="test/output/test_socket"/> <exclude name="test/output/test_zlib"/> </patternset> </fileset> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |